"; } return; } function wrap_content_box($content) { $return_buffer = '
' . $content . '
'; return $return_buffer; } function display_header($header) { return ' ' . $header . ' '; } function display_table($content, $width = 500) { $return_buffer = ' ' . $content . '
'; return $return_buffer; } function display_row($left, $right = "") { return ' ' . $left . ' ' . $right . ' '; } function search_box($name = "", $value = "", $placeholder = "") { return ' '; } function strip_underscores($string) { $string = str_replace("_", " ", $string); return $string; } function print_query_results( $mysql_reference_data, $rows_to_return, $anchor_link_callout, $query_description, /* Example: NPCs */ $object_description, $href_id_name, $href_name_attribute, $extra_field = "", $extra_field_description = "", $extra_skill = "" ) { global $dbskills; $mysql_rows_returned = mysqli_num_rows($mysql_reference_data); if ($mysql_rows_returned > get_max_query_results_count($rows_to_return)) { $mysql_rows_returned = get_max_query_results_count($rows_to_return); $more_objects_exist = true; } else { $more_objects_exist = false; } if ($mysql_rows_returned == 0) { $return_buffer .= ""; } else { $return_buffer .= "

" . $mysql_rows_returned . " " . ($mysql_rows_returned == 1 ? $query_description : $object_description) . " displayed"; if ($more_objects_exist) { $return_buffer .= " More " . $object_description . " exist but you reached the query limit."; } $return_buffer .= "

"; $return_buffer .= ""; } return wrap_content_box($return_buffer); } function get_max_query_results_count($MaxObjects) { if ($MaxObjects == 0) { $Result = 2147483647; } else { $Result = $MaxObjects; } return $Result; } function get_npc_name_human_readable($DbName) { $Result = str_replace( '-', '`', str_replace( '_', ' ', str_replace('#', '', str_replace('!', '', str_replace('~', '', $DbName))) ) ); for ($i = 0; $i < 10; $i++) { $Result = str_replace($i, '', $Result); } return $Result; } /** Returns the type of NPC based on the name of an NPC from its database-encoded '$DbName'. */ function NpcTypeFromName($DbName) { global $NPCTypeArray; foreach ($NPCTypeArray as $key => $type) { $KeyCount = substr_count($DbName, $key); $StringLength = strlen($DbName); $KeyLength = strlen($key); if ($KeyCount > 0 && substr($DbName, 0, $KeyLength) == $key) { return $type; } } return "Normal"; } // Converts the first letter of each word in $str to upper case and the rest to lower case. function ucfirstwords($str) { return ucwords(strtolower($str)); } /** Returns the URL in the Wiki to the image illustrating the NPC with ID '$NpcId' * Returns an empty string if the image does not exist in the Wiki */ function NpcImage($WikiServerUrl, $WikiRootName, $NpcId) { $SystemCall = "wget -q \"" . $WikiServerUrl . $WikiRootName . "/index.php/Image:Npc-" . $NpcId . ".jpg\" -O -| grep \"/" . $WikiRootName . "/images\" | head -1 | sed 's;.*\\(/" . $WikiRootName . "/images/[^\"]*\\).*;\\1;'"; $Result = `$SystemCall`; if ($Result != "") { $Result = $WikiServerUrl . $Result; } return $Result; } /** Returns a human-readable translation of '$sec' seconds (for respawn times) * If '$sec' is '0', returns 'time' (prints 'Spawns all the time' as a result) */ function translate_time($sec) { if ($sec == 0) { $Result = "time"; } else { $h = floor($sec / 3600); $m = floor(($sec - $h * 3600) / 60); $s = $sec - $h * 3600 - $m * 60; $Result = ($h > 1 ? "$h hours " : "") . ($h == 1 ? "1 hour " : "") . ($m > 0 ? "$m min " : "") . ($s > 0 ? "$s sec" : ""); } return $Result; } /** Returns the rest of the euclidian division of '$d' by '$v' * Returns '0' if '$v' equals '0' * Supposes '$d' and '$v' are positive */ function modulo($d, $v) { if ($v == 0) { $Result = 0; } else { $s = floor($d / $v); $Result = $d - $v * $s; } } /** Returns the list of slot names '$val' corresponds to (as a bit field) */ function get_slots_string($val) { global $dbslots; reset($dbslots); do { $key = key($dbslots); if ($key <= $val) { $val -= $key; $Result .= $v . current($dbslots); $v = ", "; } } while (next($dbslots)); return $Result; } function get_class_usable_string($val) { global $db_classes_short; reset($db_classes_short); do { $key = key($db_classes_short); if ($key <= $val) { $val -= $key; $res .= $v . current($db_classes_short); $v = " "; } } while (next($db_classes_short)); return $res; } function get_race_usable_string($val) { global $db_races_short; reset($db_races_short); do { $key = key($db_races_short); if ($key <= $val) { $val -= $key; $res .= $v . current($db_races_short); $v = " "; } } while (next($db_races_short)); return $res; } function get_size_string($val) { switch ($val) { case 0: return "Tiny"; break; case 1: return "Small"; break; case 2: return "Medium"; break; case 3: return "Large"; break; case 4: return "Giant"; break; default: return "$val?"; break; } } function getspell($id) { global $spells_table, $spell_globals_table, $use_spell_globals; if ($use_spell_globals == true) { $query = "SELECT " . $spells_table . ".* FROM " . $spells_table . " WHERE " . $spells_table . ".id=" . $id . " AND ISNULL((SELECT " . $spell_globals_table . ".spellid FROM " . $spell_globals_table . " WHERE " . $spell_globals_table . ".spellid = " . $spells_table . ".id))"; } else { $query = "SELECT * FROM $spells_table WHERE id=$id"; } $result = db_mysql_query($query) or message_die('functions.php', 'getspell', $query, mysqli_error()); $s = mysqli_fetch_array($result); return $s; } function get_deity_usable_string($val) { global $dbideities; reset($dbideities); do { $key = key($dbideities); if ($key <= $val) { $val -= $key; $res .= $v . current($dbideities); $v = ", "; } } while (next($dbideities)); return $res; } function SelectMobRace($name, $selected) { global $dbiracenames; $return_buffer = ""; return $return_buffer; } function SelectLevel($name, $maxlevel, $selevel) { $return_buffer = ""; return $return_buffer; } function WriteIt($value, $name, $sel) { $return_buffer = "