Esempio n. 1
0
/** Displays the results of a query for objects returning the 'id' and 'name' fields.
 *  The query must have been done with at least a limit of '$MaxRowsReturned + 1'.
 *  '$MaxObjectsReturned' can be '0', which means the query had no limits (ex: $MaxNpcsReturned).
 *  '$OpenObjectById' must contain the name of the page used to open one of the object (ex: npc.php) by passing it
 *    the ID by GET method.
 *  'IdAttribute' and 'NameAttribute' are the name of the columns retrieved used for ID and Name (ex: 'id' and 'name').
 *  '$ObjectDescription' is the text describing the kind of objects to display (ex: 'NPC'). '$ObjectsDescription' is the plural.
 */
function PrintQueryResults($FoundObjects, $MaxObjectsReturned, $OpenObjectByIdPage, $ObjectDescription, $ObjectsDescription, $IdAttribute, $NameAttribute, $ExtraField, $ExtraFieldDescription, $ExtraSkill)
{
    global $dbskills;
    $ObjectsToShow = mysql_num_rows($FoundObjects);
    if ($ObjectsToShow > LimitToUse($MaxObjectsReturned)) {
        $ObjectsToShow = LimitToUse($MaxObjectsReturned);
        $MoreObjectsExist = True;
    } else {
        $MoreObjectsExist = False;
    }
    if ($ObjectsToShow == 0) {
        echo "<ul><li><b>No " . $ObjectDescription . " found.</b></li></ul>\n";
    } else {
        echo "<ul><li><b>" . $ObjectsToShow . " " . ($ObjectsToShow == 1 ? $ObjectDescription : $ObjectsDescription) . " displayed.";
        if ($MoreObjectsExist) {
            echo " More " . $ObjectsDescription . " exist but you have reached the search limit.";
        }
        echo "</b></li>\n";
        echo "<ul>\n";
        for ($j = 1; $j <= $ObjectsToShow; $j++) {
            $row = mysql_fetch_array($FoundObjects);
            $PrintString = " <li><a href='" . $OpenObjectByIdPage . "?id=" . $row[$IdAttribute] . "'>";
            if ($ObjectDescription == "npc") {
                // Clean up the name for NPCs
                $PrintString .= ReadableNpcName($row[$NameAttribute]);
            } else {
                $PrintString .= $row[$NameAttribute];
            }
            $PrintString .= " (" . $row[$IdAttribute] . ")</a>";
            if ($ExtraField && $ExtraFieldDescription && $ExtraSkill) {
                $PrintString .= " - " . ucfirstwords(str_replace("_", " ", $dbskills[$row[$ExtraSkill]])) . ", {$ExtraFieldDescription} " . $row[$ExtraField];
            }
            echo $PrintString;
            echo "</li>\n";
        }
        echo "</ul>\n</ul>\n";
    }
}
Esempio n. 2
0
$iname = isset($_GET['iname']) ? $_GET['iname'] : '';
if ($isearch != "") {
    if ($iname == "") {
        $name = "";
    } else {
        $name = addslashes($iname);
    }
    $Query = "SELECT {$tbnpctypes}.id,{$tbnpctypes}.name\n\t\tFROM {$tbnpctypes}\n\t\tWHERE 1=1";
    if ($name != "") {
        $name = str_replace('`', '-', str_replace('_', '%', str_replace(' ', '%', $name)));
        $Query .= " AND {$tbnpctypes}.Name like '%{$name}%'";
    }
    if ($HideInvisibleMen) {
        $Query .= " AND {$tbnpctypes}.race != 127 AND {$tbnpctypes}.race != 240";
    }
    $Query .= " ORDER BY {$tbnpctypes}.Name, {$tbnpctypes}.id LIMIT " . (LimitToUse($MaxNpcsReturned) + 1);
    $QueryResult = mysql_query($Query) or message_die('npcs.php', 'MYSQL_QUERY', $Query, mysql_error());
    if (mysql_num_rows($QueryResult) == 1) {
        $row = mysql_fetch_array($QueryResult);
        header("Location: npc.php?id=" . $row["id"]);
        exit;
    }
}
/** Here the following holds :
 *    $QueryResult : NPCs queried for if any query was issued, otherwise it is not defined
 *    $iname : previously-typed query, or empty by default
 *    $isearch is set if a query was issued
 */
$Title = "NPCs search";
$XhtmlCompliant = TRUE;
include $includes_dir . 'headers.php';
Esempio n. 3
0
echo "</td></tr>\n";
echo "<tr><td nowrap='1'><b>Deity : </b></td><td>";
SelectDeity("ideity", $ideity);
echo "</td></tr>\n";
echo "</td></tr></table>";
echo "<tr align='center'><td nowrap='1' colspan='2'><input type='submit' value='Search' name='isearch'/>&nbsp;<input type='reset' value='Reset'/></td></tr>\n";
echo "</form>\n";
echo "</tbody>";
echo "</table>\n";
// Print the query results if any
if (isset($QueryResult)) {
    $Tableborder = 0;
    $num_rows = mysql_num_rows($QueryResult);
    $total_row_count = $num_rows;
    if ($num_rows > LimitToUse($MaxItemsReturned)) {
        $num_rows = LimitToUse($MaxItemsReturned);
    }
    echo "<center>";
    if ($num_rows == 0) {
        echo "<b>No items found...</b><br>";
    } else {
        $OutOf = "";
        if ($total_row_count > $num_rows) {
            $OutOf = " (Searches are limited to 100 Max Results)";
        }
        echo "<b>" . $num_rows . " " . ($num_rows == 1 ? "item" : "items") . " displayed</b>" . $OutOf . "<br>";
        echo "</center>";
        echo "<center><table border='{$Tableborder}' cellpadding='5' width='0%'>";
        echo "<tr>\n\t\t\t\t\t<th class='menuh'>Icon</th>\n\t\t\t\t\t<th class='menuh'>Item Name</th>\n\t\t\t\t\t<th class='menuh'>Item Type</th>\n\t\t\t\t\t<th class='menuh'>AC</th>\n\t\t\t\t\t<th class='menuh'>HPs</th>\n\t\t\t\t\t<th class='menuh'>Mana</th>\n\t\t\t\t\t<th class='menuh'>Damage</th>\n\t\t\t\t\t<th class='menuh'>Delay</th>\n\t\t\t\t\t<th class='menuh'>Item ID</th>\n\t\t\t\t\t</tr>";
        $RowClass = "lr";
        for ($count = 1; $count <= $num_rows; $count++) {
Esempio n. 4
0
 *  If 'iname' is not set then it is equivalent to searching for all factions.
 *  For compatbility with Wikis and multi-word searches, underscores are treated as jokers in 'iname'.
 */
include './includes/constantes.php';
include './includes/config.php';
include $includes_dir . 'mysql.php';
include $includes_dir . 'functions.php';
$isearch = isset($_GET['isearch']) ? $_GET['isearch'] : '';
$iname = isset($_GET['iname']) ? $_GET['iname'] : '';
if ($isearch != "") {
    if ($iname == "") {
        $name = "";
    } else {
        $name = str_replace('_', '%', addslashes($iname));
    }
    $Query = "SELECT {$tbfactionlist}.id,{$tbfactionlist}.name\n\t\t\t\tFROM {$tbfactionlist}\n\t\t\t\tWHERE {$tbfactionlist}.name like '%" . $name . "%'\n\t\t\t\tORDER BY {$tbfactionlist}.name\n\t\t\t\tLIMIT " . (LimitToUse($MaxFactionsReturned) + 1);
    $QueryResult = mysql_query($Query) or message_die('factions.php', 'MYSQL_QUERY', $Query, mysql_error());
    if (mysql_num_rows($QueryResult) == 1) {
        $row = mysql_fetch_array($QueryResult);
        header("Location: faction.php?id=" . $row["id"]);
        exit;
    }
}
/** Here the following holds :
 *    $QueryResult : factions queried for if any query was issued, otherwise it is not defined
 *    $iname : previously-typed query, or empty by default
 *    $isearch is set if a query was issued
 */
$Title = "Faction Search";
$XhtmlCompliant = TRUE;
include $includes_dir . 'headers.php';
Esempio n. 5
0
    header("Location: items.php");
    exit;
}
// Query for factions
$Query = "SELECT {$tbfactionlist}.id,{$tbfactionlist}.name\n        FROM {$tbfactionlist}\n        WHERE {$Where}\n        ORDER BY {$tbfactionlist}.name,{$tbfactionlist}.id\n        LIMIT " . (LimitToUse($MaxFactionsReturned) + 1);
$FoundFactions = mysql_query($Query) or message_die('fullsearch.php', 'MYSQL_QUERY', $Query, mysql_error());
// Query for Items
if ($DiscoveredItemsOnly == TRUE) {
    $Query = "SELECT * FROM {$tbitems}, discovered_items WHERE {$tbitems}.id='" . $id . "' AND discovered_items.item_id={$tbitems}.id";
    $Query = "SELECT {$tbitems}.id,{$tbitems}.name\n\t\tFROM {$tbitems}, discovered_items\n\t\tWHERE {$Where}\n\t\tAND discovered_items.item_id={$tbitems}.id \n\t\tORDER BY {$tbitems}.name,{$tbitems}.id\n\t\tLIMIT " . (LimitToUse($MaxItemsReturned) + 1);
} else {
    $Query = "SELECT {$tbitems}.id,{$tbitems}.name\n\t\tFROM {$tbitems}\n\t\tWHERE {$Where}\n\t\tORDER BY {$tbitems}.name,{$tbitems}.id\n\t\tLIMIT " . (LimitToUse($MaxItemsReturned) + 1);
}
$FoundItems = mysql_query($Query) or message_die('fullsearch.php', 'MYSQL_QUERY', $Query, mysql_error());
// Query for NPCs
$Query = "SELECT {$tbnpctypes}.id,{$tbnpctypes}.name\n        FROM {$tbnpctypes}\n        WHERE {$Where}\n        ORDER BY {$tbnpctypes}.name,{$tbnpctypes}.id\n        LIMIT " . (LimitToUse($MaxNpcsReturned) + 1);
$FoundNpcs = mysql_query($Query) or message_die('fullsearch.php', 'MYSQL_QUERY', $Query, mysql_error());
// In case only one object is found, redirect to its page
if (mysql_num_rows($FoundFactions) == 1 and mysql_num_rows($FoundItems) == 0 and mysql_num_rows($FoundNpcs) == 0) {
    $FactionRow = mysql_fetch_array($FoundFactions);
    header("Location: faction.php?id=" . $FactionRow["id"]);
    exit;
}
if (mysql_num_rows($FoundFactions) == 0 and mysql_num_rows($FoundItems) == 1 and mysql_num_rows($FoundNpcs) == 0) {
    $ItemRow = mysql_fetch_array($FoundItems);
    header("Location: item.php?id=" . $ItemRow["id"]);
    exit;
}
if (mysql_num_rows($FoundFactions) == 0 and mysql_num_rows($FoundItems) == 0 and mysql_num_rows($FoundNpcs) == 1) {
    $NpcRow = mysql_fetch_array($FoundNpcs);
    header("Location: npc.php?id=" . $NpcRow["id"]);