| admin_login.php | index.php | plugins_footer.php | plugins_header.php | qt_viewquests.php | qt_viewtimers.php | quest_timer.php | quest_timer/loadquests.php | quest_timer/newquests.php | quest_timer/savequests.php | quest_timer/submitquests.php | scroll_manager.php | show_create.php | sql_config_example.php | viewsource.php |

qt_viewquests.php

  [Go to page]


<?php
    
if (isset($_GET['viewsource']))
    {
        echo(
"<table><tr><td nowrap>");
        
show_source("qt_viewquests.php");
        die(
"</td></tr></table>");
    }

    require_once(
'admin_login.php'); // Sends cookies, must be before the header
    
require_once('plugins_header.php');
    
    if (
defined('MYSQL_CONNECTED'))
    {
        
//Note: $_REQUEST contains both $_POST and $_GET vars (as well as $_COOKIE)
        
$action = isset($_POST['action']) ? $_POST['action'] : $_GET['action'];
        
$orderby $_REQUEST['orderby'];
        if (
$orderby != "Days,Hours,Minutes" && $orderby != "Item,Text,Chest" && $orderby != "SubmittedBy" && $orderby != "DateAdded DESC" && $orderby != "ApprovedBy")
            
$orderby "QuestName";
        
        switch (
$action)
        {
            case 
'newquest':
                
$QuestName $_REQUEST['QuestName'];
                
$Days = (int) $_REQUEST['Days'];
                
$Hours = (int) $_REQUEST['Hours'];
                
$Minutes = (int) $_REQUEST['Minutes'];
                
$Text $_REQUEST['Text'];
                
$Item $_REQUEST['Item'];
                
$Chest $_REQUEST['Chest'];
                
$Droppable $_REQUEST['Droppable'] && $Item != '';
                
$SubmittedBy $_REQUEST['SubmittedBy'];
                
                
$redo true;
                
$insert false;
                
                
$response_text "";
                
                if (
$QuestName == '')
                    
$response_text "Please enter a Quest name";
                elseif (
$Days || $Hours || $Hours 23 || $Minutes || $Minutes 59 || ($Days $Hours $Minutes) <= 0)
                    
$response_text "The duration you entered is invalid";
                elseif (
$Text == '' &&  $Item == '' && $Chest == '')
                    
$response_text "Please enter a trigger method";
                else
                {
                    
$insert true;
                    
$updated false;
                    if (
$result mysql_query("SELECT * FROM QuestTimer_AvailableQuests WHERE QuestName = '$QuestName'"))
                    {
                        while (
$data mysql_fetch_array($result))
                        {
                            
$updated true;
                            if (
strtolower($data["Text"]) == stripslashes(strtolower($Text)) && 
                                    
strtolower($data["Item"]) == stripslashes(strtolower($Item)) && 
                                    
strtolower($data["Chest"]) == stripslashes(strtolower($Chest)) && 
                                    (
$data["Droppable"] && $data["Item"] != '') == ($Droppable && $Item != '') && 
                                    
$data["Days"] == $Days && 
                                    
$data["Hours"] == $Hours && 
                                    
$data["Minutes"] == $Minutes)
                            {
                                
$response_text "The Quest " htmlspecialchars(stripslashes($QuestName)) . " is already in the list!";
                                
$insert false;
                                break;
                            }
                        }
                    }
                    
                    if (
$insert && ($result mysql_query("SELECT * FROM QuestTimer_DeletedQuests WHERE QuestName = '$QuestName'")))
                    {
                        while (
$data mysql_fetch_array($result))
                        {
                            
$updated true;
                            if (
strtolower($data["Text"]) == stripslashes(strtolower($Text)) && 
                                    
strtolower($data["Item"]) == stripslashes(strtolower($Item)) && 
                                    
strtolower($data["Chest"]) == stripslashes(strtolower($Chest)) && 
                                    (
$data["Droppable"] && $data["Item"] != '') == ($Droppable && $Item != '') && 
                                    
$data["Days"] == $Days && 
                                    
$data["Hours"] == $Hours && 
                                    
$data["Minutes"] == $Minutes)
                            {
                                
$response_text "The Quest " htmlspecialchars(stripslashes($QuestName)) . " has previously been submitted and rejected. " .
                                    
"If you feel this is in error, please email me.";
                                
$insert false;
                                break;
                            }
                        }
                    }
                    
                    if (!
IS_ADMIN)
                    {
                        
$recaptcha recaptcha_check_answer($privatekey,  $_SERVER["REMOTE_ADDR"], 
                            
$_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
                        if (!
$recaptcha->is_valid)
                        {
                            if (
$response_text == "")
                                
$response_text "The text you entered for the CAPTCHA was incorrect.";
                            
$recaptcha_error $recaptcha->error;
                            
$insert false;
                        }
                    }
                    
                    if (
$insert)
                    {
                        if (
mysql_query("INSERT INTO QuestTimer_AvailableQuests (QuestName,Days,Hours,Minutes,Text,Item,Chest,Droppable,SubmittedBy,DateAdded,Approved) 
                                VALUES ('
$QuestName','$Days','$Hours','$Minutes','$Text','$Item','$Chest','$Droppable','$SubmittedBy','" gmdate('Y-m-d H:i:s') . "', '0')"))
                        {
                            if (
$updated)
                                
$response_text "A quest with the same name is already in the list, but has different trigger/timer info.<br>" .
                                                 
"Your quest has been submitted for an update and is pending review by Digero.  Thanks!";
                            else
                                
$response_text "Your quest has been submitted and is pending review by Digero.  Thanks!";
                            
$redo false;
                        }
                        else
                            
$response_text "Unable to submit quest -- SQL Query error: " mysql_error();
                    }
                }
                break;
                
            
/*
            case 'approve':
                if (!IS_ADMIN) break;
                
                $QuestID = $_REQUEST['QuestID'];
                switch ($_REQUEST['do'])
                {
                    case 'approve':
                        //Remove old quest if one exists
                        $data = mysql_fetch_array(mysql_query("SELECT QuestName FROM QuestTimer_AvailableQuests WHERE QuestID='$QuestID'"));
                        $sql = "SELECT QuestID FROM QuestTimer_AvailableQuests WHERE QuestName='" . addslashes($data['QuestName']) . "' AND Approved";
                        if ($result = mysql_query($sql))
                        {
                            while ($data = mysql_fetch_array($result))
                                if ($data['QuestID'] <> $QuestID)
                                    if (!mysql_query("DELETE FROM QuestTimer_AvailableQuests WHERE QuestID='$data[QuestID]'"))
                                        echo("SQL Query error: " . mysql_error());
                        }
                        else echo("SQL Query error: " . mysql_error() . "<br>Query: $sql");
                        
                        if (!mysql_query("UPDATE QuestTimer_AvailableQuests SET Approved = '1', DateAdded = '" . gmdate('Y-m-d H:i:s') . "' WHERE QuestID='$QuestID'"))
                            echo("SQL Query error: " . mysql_error());
                        break;
                    case 'disapprove':
                        if (!mysql_query("UPDATE QuestTimer_AvailableQuests SET Approved = '0' WHERE QuestID='$QuestID'"))
                            echo("SQL Query error: " . mysql_error());
                        break;
                    case 'delete':
                        if (!mysql_query("DELETE FROM QuestTimer_AvailableQuests WHERE QuestID='$QuestID'"))
                            echo("SQL Query error: " . mysql_error());
                        break;
                }
                break;
            */
                
            
case 'approve_multiple':
                if (!
IS_ADMIN) break;
                
                foreach(array(
'arr_approve''arr_disapprove''arr_delete') as $do)
                {
                    if (isset(
$_REQUEST[$do]) && $_REQUEST[$do] != '')
                        $
$do array_unique(explode(','$_REQUEST[$do]));
                    else
                        $
$do = array();
                }
                
                foreach (
$arr_approve as $QuestID)
                {
                    
//Remove old quest if one exists
                    
$data mysql_fetch_array(mysql_query("SELECT QuestName FROM QuestTimer_AvailableQuests WHERE QuestID='$QuestID'"));
                    
$sql "SELECT QuestID FROM QuestTimer_AvailableQuests WHERE QuestName='" addslashes($data['QuestName']) . "' AND Approved";
                    if (
$result mysql_query($sql))
                    {
                        while (
$data mysql_fetch_array($result))
                        {
                            if (
$data['QuestID'] != $QuestID && !in_array($data['QuestID'], $arr_delete))
                            {
                                
$arr_delete[] = $data['QuestID'];
                            }
                        }
                    }
                    else
                    {
                        echo(
"SQL Query error: " mysql_error() . "<br>Query: $sql");
                        break 
2// Breaks FOREACH and SWITCH (case 'approve_multiple')
                    
}
                    
                    
$sql "UPDATE QuestTimer_AvailableQuests SET Approved = '1', ApprovedBy = '$admin_username', 
                            DateAdded = '" 
gmdate('Y-m-d H:i:s') . "' WHERE QuestID='$QuestID'";
                    if (!
mysql_query($sql))
                    {
                        echo(
"SQL Query error: " mysql_error() . "<br>Query: $sql");
                        break 
2// Breaks FOREACH and SWITCH (case 'approve_multiple')
                    
}
                }
                
                foreach (
$arr_disapprove as $QuestID)
                {
                    
$sql "UPDATE QuestTimer_AvailableQuests SET Approved = '0' WHERE QuestID='$QuestID'";
                    if (!
mysql_query($sql))
                    {
                        echo(
"SQL Query error: " mysql_error() . "<br>Query: $sql");
                        break 
2// Breaks FOREACH and SWITCH (case 'approve_multiple')
                    
}
                }
                
                foreach (
$arr_delete as $QuestID)
                {
                    
$sql "REPLACE QuestTimer_DeletedQuests
                                SELECT * FROM QuestTimer_AvailableQuests 
                                    WHERE QuestID = '
$QuestID'";
                    if (!
mysql_query($sql))
                    {
                        echo(
"SQL Query error: " mysql_error() . "<br>Query: $sql");
                        break 
2// Breaks FOREACH and SWITCH (case 'approve_multiple')
                    
}
                    
$sql "UPDATE QuestTimer_DeletedQuests 
                                SET ApprovedBy = '
$admin_username', DateAdded = '" gmdate('Y-m-d H:i:s') . "', Approved='0'
                                WHERE QuestID = '
$QuestID'";
                    if (!
mysql_query($sql))
                    {
                        echo(
"SQL Query error: " mysql_error() . "<br>Query: $sql");
                        break 
2// Breaks FOREACH and SWITCH (case 'approve_multiple')
                    
}
                    
$sql "DELETE FROM QuestTimer_AvailableQuests 
                                WHERE QuestID = '
$QuestID'";
                    if (!
mysql_query($sql))
                    {
                        echo(
"SQL Query error: " mysql_error() . "<br>Query: $sql");
                        break 
2// Breaks FOREACH and SWITCH (case 'approve_multiple')
                    
}
                }
                break;
        } 
// switch ($action)
    
?>
<table width="100%" cellpadding="8" cellspacing="2">
    <tr>
        <td class="catHead">
            <table cellpadding="2" cellspacing="0">
                <tr>
                    <td><?=icon('quest_timer')?></td>
                    <td><span class="subtitle">Quest Timer - Available Quests</span></td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td class="row1"><a href="quest_timer.php">&laquo; Back to the main Quest Timer page</a><br>
            <span class="genmed">Note: If your browser tells you this page has expired, put a space at 
            the end of the URL and hit enter.</span></td>
    </tr>
<?php if ($action == 'newquest') { ?>
    <tr>
        <td height="5"></td>
    </tr>
    <tr>
        <td class="catHead"><b><?= $redo "Error Submitting Quest" "Quest Submitted" ?></b></td>
    </tr>
    <tr>
        <td class="row1"><?= $redo "<span class='emote'><b><i>$response_text</b></i></span>" $response_text ?></td>
    </tr>
<?php // if ($action == 'newquest') ?>
    <tr>
        <td height="5"></td>
    </tr>
    <tr>
        <td class="catHead"><?= make_show_hide('submit_quest'"<b>Submit New Quest</b>"?></td>
    </tr>
    <tr>
        <td class="row1" id="submit_quest">
            <span class="genmed">If there's a quest in the list with incorrect/outdated info, submit it with the <i>same 
                quest name</i> and the correct info, and I will review it for an update.</span>
            <form action="<?=$_SERVER['SCRIPT_NAME'] . '?' $_SERVER['QUERY_STRING']?>" method="post" name="addquest">
                <input type="hidden" name="action" value="newquest">
                <table cellpadding="2" cellspacing="2">
                    <?php
                        
function redoValue($value)
                        {
                            global 
$redo;
                            if (!
$redo)
                                return 
'';
                            
                            return 
'value="' htmlspecialchars(stripslashes($value)) . '"';
                        }
                    
?>
                    <tr><td><b>Quest Name</b></td><td><input type="text" name="QuestName" size="40" maxlength="60" <?= redoValue($QuestName?>></td></tr>
                    <tr><td><b>Duration</b></td><td>Days <input type="text" name="Days" size="3" maxlength="2" <?= redoValue($Days?>>&nbsp;&nbsp;
                                             Hours <input type="text" name="Hours" size="3" maxlength="2" <?= redoValue($Hours?>>&nbsp;&nbsp;
                                             Minutes <input type="text" name="Minutes" size="3" maxlength="2" <?= redoValue($Minutes?>></td></tr>
                    <tr><td><b>Text</b></td><td><input type="text" name="Text" size="60" maxlength="255" <?= redoValue($Text?>></td></tr>
                    <tr><td><b>Pickup</b></td><td><input type="text" name="Item" size="60" maxlength="100" <?= redoValue($Item?>> &nbsp;
                                           <input type="checkbox" name="Droppable" <?= ($redo && $Droppable) ? "checked" "" ?>><span style="cursor:default" onclick="tmp = document.forms['addquest'].elements['Droppable']; tmp.checked = !tmp.checked;"> Droppable</span></td></tr>
                    <tr><td><b>Chest/Corpse</b></td><td><input type="text" name="Chest" size="60" maxlength="100" <?= redoValue($Chest?>>&nbsp;
                                                        <span class="genmed"><em>Include 'Corpse of' for corpses</em></span></td></tr>
                    <tr><td><b>Submitted by</b></td><td><input type="text" name="SubmittedBy" size="25" maxlength="30" <?= redoValue($SubmittedBy?>> (optional)</td></tr>
                    <?php if (!IS_ADMIN): ?>
                    <tr><td valign="top"><b>CAPTCHA</b><br><i>(To prevent spam)</i></td><td><?= recaptcha_get_html($publickey$recaptcha_error?></td></tr>
                    <?php endif; ?>
                    <tr><td></td><td><input class="mainoption" type="submit" value="Submit New Quest"></td></tr>
                </table>
            </form>
        </td>
    </tr>
    <script language="javascript">
        function edtq (QuestName, Days, Hours, Minutes, Text, Item, Droppable, Chest)
        {
            show_ele('submit_quest');
            var frm = document.forms.addquest;
            frm.QuestName.value = QuestName;
            frm.Days.value = Days;
            frm.Hours.value = Hours;
            frm.Minutes.value = Minutes;
            frm.Text.value = Text;
            frm.Item.value = Item;
            frm.Droppable.checked = Droppable;
            frm.Chest.value = Chest;
        }
    </script>
<?php 
    
echo make_autohide('submit_quest');
    if (
IS_ADMIN): ?>
    <tr>
        <td height="5"></td>
    </tr>
    <tr>
        <td class="catHead"><?= make_show_hide('admin_panel'"<b>Admin Panel</b>"?></td>
    </tr>
    <tr>
        <td class="row1" id="admin_panel">
            Currently logged in as: <b><?= htmlspecialchars(stripslashes($admin_username)) ?></b> | 
                <a href="<?= $_SERVER['PHP_SELF'] . '?mode=' $_GET['mode'] . '&admin_logoff' ?>">Logout</a><br>
            <br>
            <table cellpadding="0" cellspacing="0" border="0" width="100%">
                <tr>
                    <td width="33%" align="center">
                        <b>Quests to Approve</b><br>
                        <textarea name="txt_approve" id="txt_approve" readonly="true" rows="6" style="width:98%;"></textarea><br>
                        <a class="gensmall" href="javascript:clear_list('approve')">Clear</a>
                    </td>
                    <td width="33%" align="center">
                        <b>Quests to Disapprove</b><br>
                        <textarea name="txt_disapprove" id="txt_disapprove" readonly="true" rows="6" style="width:98%;"></textarea><br>
                        <a class="gensmall" href="javascript:clear_list('disapprove')">Clear</a>
                    </td>
                    <td width="33%" align="center">
                        <b>Quests to Delete</b><br>
                        <textarea name="txt_delete" id="txt_delete" readonly="true" rows="6" style="width:98%;"></textarea><br>
                        <a class="gensmall" href="javascript:clear_list('delete')">Clear</a>
                    </td>
                </tr>
                <tr>
                    <td colspan="3" align="center">
                        &nbsp;<br>
                        <form action="<?= $_SERVER['PHP_SELF'?>?mode=<?= $_GET['mode'?>" method="post">
                            <input type="hidden" name="arr_approve" id="arr_approve" value="">
                            <input type="hidden" name="arr_disapprove" id="arr_disapprove" value="">
                            <input type="hidden" name="arr_delete" id="arr_delete" value="">
                            <input type="hidden" name="action" value="approve_multiple">
                            <input class="mainoption" type="submit" value="  Submit  "> &nbsp; 
                            <input class="mainoption" type="button" value="  Clear All  " onclick="clear_all();">
                        </form>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <script language="javascript">
        function add_to_list(QuestID, QuestName, action)
        {
            show_ele('admin_panel');
            remove_from_all(QuestID);
            document.getElementById('admin_panel').setAttribute('no_hiding', true);
            
            ele = document.getElementById('arr_' + action);
            ele_txt = document.getElementById('txt_' + action);
            
            namestr = QuestID + "|" + QuestName;
            if (ele.value == '')
            {
                ele.value = QuestID + "";
                ele_txt.value = namestr;
            }
            else
            {
                ele.value += "," + QuestID;
                ele_txt.value += "\n" + namestr;
            }
            document.getElementById(action + '_' + QuestID).style.fontWeight = 'bold';
        }
        
        function remove_from_all(QuestID, default_action)
        {
            remove_from(QuestID, 'approve');
            remove_from(QuestID, 'disapprove');
            remove_from(QuestID, 'delete');
            
            if (document.getElementById('arr_approve').value == '' &&
                document.getElementById('arr_disapprove').value == '' &&
                document.getElementById('arr_delete').value == '')
            {
                document.getElementById('admin_panel').removeAttribute('no_hiding');
            }
            if (default_action)
                document.getElementById(default_action + '_' + QuestID).style.fontWeight = 'bold';
        }
        
        function remove_from(QuestID, action, default_action)
        {
            show_ele('admin_panel');
            ele = document.getElementById('arr_' + action);
            ele_txt = document.getElementById('txt_' + action);
            document.getElementById(action + '_' + QuestID).style.fontWeight = 'normal';
            if (default_action)
                document.getElementById(default_action + '_' + QuestID).style.fontWeight = 'bold';
            
            if (ele.value != '')
            {
                arr = ele.value.split(",");
                arr_txt = ele_txt.value.split("\n");
                for (i = 0; i < arr.length; i++)
                {
                    if (arr[i] == QuestID)
                    {
                        arr = arr.slice(0, i).concat(arr.slice(i + 1, arr.length));
                        arr_txt = arr_txt.slice(0, i).concat(arr_txt.slice(i + 1, arr_txt.length));
                        break;
                    }
                }
                ele.value = arr.join(",");
                ele_txt.value = arr_txt.join("\n");
            }
        }
        
        function clear_all()
        {
            clear_list('approve');
            clear_list('disapprove');
            clear_list('delete');
            document.getElementById('admin_panel').removeAttribute('no_hiding');
        }
        
        function clear_list(action)
        {
            ele = document.getElementById('arr_' + action);
            ele_txt = document.getElementById('txt_' + action);
            if (ele.value != '')
            {
                arr = ele.value.split(",");
                for (i = 0; i < arr.length; i++)
                {
                    document.getElementById(action + '_' + arr[i]).style.fontWeight = 'normal';
                }
            }
            ele.value = '';
            ele_txt.value = '';
        }
    </script>
<?php 
        
elseif(isset($_GET['admin_logon'])):
?>
    <tr>
        <td height="5"></td>
    </tr>
    <tr>
        <td class="catHead"><?= make_show_hide('admin_panel'"<b>Admin Panel</b>"?></td>
    </tr>
    <tr>
        <td class="row1" id="admin_panel">
            <form action="<?= $_SERVER['PHP_SELF'] . '?mode=' $_GET['mode'?>" method="post">
            <table cellpadding="2" cellspacing="2" border="0">
                <tr>
                    <td>Username:</td><td><input type="text" name="qt_admin_username" value=""></td>
                </tr>
                <tr>
                    <td>Password:</td><td><input type="password" name="qt_admin_password" value=""></td>
                </tr>
                <tr>
                    <td></td><td><input type="submit" value="Submit" class="mainoption"></td>
                </tr>
            </table>
            </form>
        </td>
    </tr>
<?php
            
echo make_autohide('admin_panel');
        endif;
        
        
//Get List of Approved Quests
        
$approved_quests "";
        
$result mysql_query("SELECT QuestName FROM QuestTimer_AvailableQuests WHERE Approved");
        while (
$data mysql_fetch_array($result))
            
$approved_quests $approved_quests "'" addslashes($data['QuestName']) . "',";
        if (
strlen($approved_quests) > 0$approved_quests substr($approved_quests0, -1); //Remove trailing comma
        
        //Show New Quests Pending Approval
        
$result mysql_query("
                SELECT COUNT(QuestName) AS Num FROM QuestTimer_AvailableQuests 
                WHERE NOT Approved AND QuestName NOT IN (
$approved_quests)");
        
$data mysql_fetch_array($result);
        
//Only show if there's at least one
        
if ($data['Num'] > 0)
        {
            
show_quest_rows("New Quests Pending Approval ($data[Num])",
                
"SELECT * FROM QuestTimer_AvailableQuests 
                WHERE NOT Approved AND QuestName NOT IN (
$approved_quests
                ORDER BY 
$orderby, DateAdded DESC"'new_quests_list');
        }
        
        
//Show Quest Updates Pending Approval
        
$result mysql_query("
                SELECT COUNT(QuestName) AS Num FROM QuestTimer_AvailableQuests 
                WHERE NOT Approved AND QuestName IN (
$approved_quests)");
        
$data mysql_fetch_array($result);
        
//Only show if there's at least one
        
if ($data['Num'] > 0)
        {
            
show_quest_rows("Quest Updates Pending Approval ($data[Num])",
                
"SELECT * FROM QuestTimer_AvailableQuests 
                WHERE NOT Approved AND QuestName IN (
$approved_quests
                ORDER BY 
$orderby, DateAdded DESC"'updated_quests_list'true);
        } 
?>
    <tr>
        <td height="5"></td>
    </tr>
    <tr>
        <td class="catHead"><?= make_show_hide('avail_quests'"<b>Download all of the Available Quests</b>"?><a name="merge_quests"></a></td>
    </tr>
    <tr>
        <td class="row1" id="avail_quests">
            If you're having trouble getting these quests from in-game or just want them all in an 
            XML file, you can download this file.  After you download this file, all of the available 
            quests will appear on the Internet &gt; Available Quests tab.  This is the same as 
            clicking "Check Now" from ingame.<br>
            <br>
            Save the following link to the Quest Timer folder 
            (default <span class="cod" style="white-space:nowrap">C:\Program Files\Decal Plugins\Quest Timer</span>).
            Make sure to name the file <span class="cod">downloaded_quests.xml</span>.<br>
            <br>
            <a href="quest_timer/downloaded_quests.php">downloaded_quests.xml</a>
        </td>
    </tr>
<?php
        
echo make_autohide('avail_quests');
        
        
//Show Currently Available Quests
        
$result mysql_query("SELECT COUNT(QuestName) AS Num FROM QuestTimer_AvailableQuests WHERE Approved");
        
$data mysql_fetch_array($result);
        
show_quest_rows("Currently Available Quests ($data[Num])",
            
"SELECT * FROM QuestTimer_AvailableQuests 
            WHERE Approved 
            ORDER BY 
$orderby"'available_quests_list');
            
        
//Show Deleted Quests for Admins only
        
if (IS_ADMIN)
        {
            
$result mysql_query("SELECT COUNT(QuestName) AS Num FROM QuestTimer_DeletedQuests");
            
$data mysql_fetch_array($result);
            
$deleted_quests_id show_quest_rows("Deleted Quests ($data[Num])",
                
"SELECT * FROM QuestTimer_DeletedQuests 
                ORDER BY 
$orderby"'deleted_quests_list'falsefalsetrue);
        }
        else
        {
            
?>
            <tr>
                <td class="row1"><a class="genmed" href="<?= $_SERVER['PHP_SELF'?>?mode=viewquests&admin_logon">Admin Logon</a></td>
            </tr>
            <?php
        
}
?>
</table>
<?php
    
// if (mysql_connect(...))
    
else
        echo(
"Failed to connect to database");
        
    function 
show_orderby($text$order)
    {
        global 
$orderby;
        if (
$order == $orderby)
            return 
$text;
        else
        {
            
$query_string "mode=" $_REQUEST['mode'] . "&orderby=$order";
            return 
"<a class='th' href='$_SERVER[SCRIPT_NAME]?$query_string'><b>$text</b></a>";
        }
    }
    
    function 
frmt($key$data$upd)
    {
        if (
$upd[$key])
            return 
"<span class='emote'>" htmlspecialchars($data[$key]) . "</span>";
        else
            return 
htmlspecialchars($data[$key]);
    }
    
    function 
show_quest_rows($group_name$sql_query$ele_id$check_update false$show_admin IS_ADMIN$is_deleted_quests false)
    {
        
?>
        <tr>
            <td height="5"></td>
        </tr>
        <tr>
            <td class="catHead"><?= make_show_hide($ele_id"<b>$group_name</b>"?></td>
        </tr>
        <tr>
            <td class="row1" id="<?=$ele_id?>">
                <span class="genmed"><center><i>Click on a column header to sort</i></center></span><br>
                <table cellpadding="4" cellspacing="2" width="100%">
                    <tr>
                        <th align="left" width="220"><?=show_orderby('Quest Name','QuestName')?></th>
                        <th align="left" width="75" nowrap><?=show_orderby('Duration','Days,Hours,Minutes')?></th>
                        <th align="left"><?=show_orderby('Trigger','Item,Text,Chest')?></th>
                    <?php if($is_deleted_quests): ?>
                        <th align="center" width="100"><?=show_orderby('Deleted by','ApprovedBy')?></th>
                        <th align="center" width="90" nowrap><?=show_orderby('Deleted','DateAdded DESC')?></th>
                    <?php else: ?>
                        <th align="center" width="100"><?=show_orderby('Submitted by','SubmittedBy')?></th>
                        <th align="center" width="90" nowrap><?=show_orderby('Added','DateAdded DESC')?></th>
                    <?php endif; ?>
                        <?= $show_admin "<th align='center' width='90'><b>Admin</b></th>" "" ?>
                    </tr>
                    <?php
                        
if ($result mysql_query($sql_query))
                        {
                            
$i 1;
                            while(
$data mysql_fetch_array($result))
                            {
                                
$i++;
                                if (
$check_update)
                                {
                                    
$orig_quest_result mysql_query("SELECT * FROM QuestTimer_AvailableQuests WHERE QuestName = '" addslashes($data['QuestName']) . "' AND Approved");
                                    
$orig_quest_data mysql_fetch_array($orig_quest_result);
                                    foreach(
$orig_quest_data as $key => $value)
                                        
$upd[$key] = (strtolower($value) != strtolower($data[$key]));
                                }
                                
?>
                                <tr>
                                    <td class="row<?= ($i%2)*2 ?>" width="220">
                                        <?php 
                                            
if ($check_update) echo "<a href='#q$orig_quest_data[QuestID]' onClick='show_ele(\"available_quests_list\"); return true;'>";
                                            echo 
frmt('QuestName'$data$upd);
                                            if (
$check_update) echo "</a>";
                                        
?>
                                        <span class="gensmall">
                                            [<a class="gensmall" href="#top" onclick="edtq(<?= "'" 
                                            
addslashes(htmlspecialchars($data['QuestName'])) . 
                                            
"',$data[Days],$data[Hours],$data[Minutes],'" 
                                            
addslashes(htmlspecialchars($data['Text'])) . "','" 
                                            
addslashes(htmlspecialchars($data['Item'])) . "'," 
                                            
$data['Droppable'] . ",'" 
                                            
addslashes(htmlspecialchars($data['Chest'])) . "'" ?>)">Edit</a>]
                                            [<a class="gensmall" target="_blank" href="http://www.google.com/search?q=<?= urlencode($data['QuestName']) ?>+site%3Athejackcat.com+OR+site%3Aacvault.ign.com+OR+site%3Aac.warcry.com&btnG=Google+Search">Info</a>]
                                        </span>
                                    </td>
                                    <td class="row<?= ($i%2)*2 ?>" width="75" nowrap><?=frmt('Days',$data,$upd)?><?=frmt('Hours',$data,$upd)?><?=frmt('Minutes',$data,$upd)?>M</td>
                                    <td class="row<?= ($i%2)*2 ?>">
                                        <a name="q<?=$data['QuestID']?>"></a>
                                        <?php
                                            
if ($upd['Droppable'])
                                            {
                                                if (
$data['Droppable'])
                                                    
$Droppable "<span class='emote'> (droppable)</span>";
                                                else
                                                    
$Droppable "<span class='emote'> (not droppable)</span>";
                                            }
                                            elseif (
$data['Droppable'])
                                                
$Droppable " (droppable)";
                                            else
                                                
$Droppable "";
                                            
                                            if (
$data['Text']) echo("<b>[</b><i>Text</i><b>]</b> " frmt('Text',$data,$upd) . "<br>");
                                            if (
$data['Item']) echo("<b>[</b><i>Pickup" $Droppable "</i><b>]</b> " frmt('Item',$data,$upd) . "<br>");
                                            if (
$data['Chest']) echo("<b>[</b><i>Chest/Corpse</i><b>]</b> " frmt('Chest',$data,$upd));
                                        
?>
                                    </td>
                                    <?php if($is_deleted_quests): ?>
                                    <td class="row<?= ($i%2)*2 ?>" width="100" style="text-align:center"><?= $data['ApprovedBy'] == '' ?  "<i>Unknown</i>" htmlspecialchars($data['ApprovedBy']) ?></td>
                                    <?php else: ?>
                                    <td class="row<?= ($i%2)*2 ?>" width="100" style="text-align:center"><?= $data['SubmittedBy'] == '' ?  "<i>Anonymous</i>" htmlspecialchars($data['SubmittedBy']) ?></td>
                                    <?php endif; ?>
                                    <td class="row<?= ($i%2)*2 ?>" width="90" style="text-align:center" nowrap><?= date("M j, Y"strtotime($data['DateAdded']) + (int) date('Z')) ?></td>
                                    <?php 
                                        
if ($show_admin): 
                                            
$approve_template "<a href=\"javascript:add_to_list('" $data['QuestID'] . "','" 
                                                
addslashes(htmlspecialchars($data['QuestName'])) . "','%s')\">%s</a>";
                                    
?>
                                        <td class="row<?= ($i%2)*2 ?>" width="90" nowrap>
                                            <?php if ($data['Approved']): ?>
                                                <a id="approve_<?= $data['QuestID'?>" href="javascript:remove_from_all('<?= $data['QuestID'?>', 'approve')"><i>Yes</i></a> |
                                                <a id="disapprove_<?= $data['QuestID'?>" href="javascript:add_to_list(<?= "'" $data['QuestID'] . "','" addslashes(htmlspecialchars($data['QuestName'])) . "', 'disapprove', 'approve'" ?>)">No</a> |
                                            <?php else: ?>
                                                <a id="approve_<?= $data['QuestID'?>" href="javascript:add_to_list(<?= "'" $data['QuestID'] . "','" addslashes(htmlspecialchars($data['QuestName'])) . "', 'approve', 'disapprove'" ?>)">Yes</a> |
                                                <a id="disapprove_<?= $data['QuestID'?>" href="javascript:remove_from_all('<?= $data['QuestID'?>', 'disapprove')"><i>No</i></a> |
                                            <?php endif; ?>
                                            <a id="delete_<?= $data['QuestID'?>" href="javascript:add_to_list(<?= "'" $data['QuestID'] . "','" addslashes(htmlspecialchars($data['QuestName'])) . "', 'delete'" ?>)">Del</a>
                                        </td>
                                    <?php endif; ?>
                                </tr>
                                <?php
                                
}
                            }
                            else
                                echo(
"SQL Query error: " mysql_error());
                        
?>
                </table>
            </td>
        </tr>
    <?php
        
echo make_autohide($ele_id);
    } 
//function show_quest_rows
    
require_once('plugins_footer.php');
    
    
/*
        CREATE TABLE `QuestTimer_AvailableQuests` (
            `QuestID` int(11) NOT NULL auto_increment,
            `QuestName` varchar(75) NOT NULL default '',
            `Days` int(11) NOT NULL default '0',
            `Hours` int(11) NOT NULL default '0',
            `Minutes` int(11) NOT NULL default '0',
            `Text` varchar(255) default '',
            `Item` varchar(100) default '',
            `Chest` varchar(100) default '',
            `Droppable` tinyint(1) NOT NULL default '0',
            `SubmittedBy` varchar(50) default '',
            `DateAdded` datetime NOT NULL default '0000-00-00 00:00:00',
            `Approved` tinyint(1) NOT NULL default '0',
            `ApprovedBy` varchar(50) NOT NULL default '',
            PRIMARY KEY  (`QuestID`)
        ) TYPE=MyISAM;
        
        CREATE TABLE `QuestTimer_DeletedQuests` (
            `QuestID` int(11) NOT NULL default '0',
            `QuestName` varchar(75) NOT NULL default '',
            `Days` int(11) NOT NULL default '0',
            `Hours` int(11) NOT NULL default '0',
            `Minutes` int(11) NOT NULL default '0',
            `Text` varchar(255) default '',
            `Item` varchar(100) default '',
            `Chest` varchar(100) default '',
            `Droppable` tinyint(1) NOT NULL default '0',
            `SubmittedBy` varchar(50) default '',
            `DateAdded` datetime NOT NULL default '0000-00-00 00:00:00',
            `Approved` tinyint(1) NOT NULL default '0',
            `ApprovedBy` varchar(50) NOT NULL default '',
            PRIMARY KEY  (`QuestID`)
        ) TYPE=MyISAM;
    */
?>