"; } //gathers performance data on a query - added 9/28/2014 function dbp_query_stat($index, $query) { global $game_db; //start the timer dbp_mark_time($index); //execute the query $game_db->query($query); //stop the timer $time = dbp_check_time($index); //get an explanation of the query //$result = $game_db->query("EXPLAIN ".$query); $result = $game_db->query($query); $explain_rows = ''; foreach($result AS $row) { $explain_rows .= " \n". " ".$row['select_type']."\n". " ".$row['table']."\n". " ".$row['type']."\n". " ".$row['possible_keys']."\n". " ".$row['key']."\n". " ".$row['key_len']."\n". " ".$row['ref']."\n". " ".$row['rows']."\n". " ".$row['Extra']."\n". " \n"; } $explain_head = "\n". " \n". " \n". " \n". " \n". " \n". " \n". " \n". " \n". " \n". " \n". " \n". " \n". " \n". " \n". " \n". " \n"; $explain_tail = " \n". "
Explanation:
select_typetabletypepossible_keyskeykey_lenrefrowsExtra
\n"; dbp_append_buffer($index, "
\n"); dbp_append_buffer($index, "
\n

Query:

\n

" . $query . "

\n
\n"); dbp_append_buffer($index, "
\n

Time:

\n

" . $time . "

\n

\n"); dbp_append_buffer($index, $explain_head . $explain_rows . $explain_tail); dbp_append_buffer($index, "
\n"); } //appends text onto the log that gets output later - added 9/28/2014 function dbp_append_buffer($index,$text) { global $dbp_output_buffer; $dbp_output_buffer[$index] .= $text; } //clears the output buffer - added 9/28/2014 function dbp_clear_buffer($index) { global $dbp_output_buffer; $dbp_output_buffer[$index] = ""; } //returns the output buffer - added 9/28/2014 function dbp_dump_buffer($index) { global $dbp_output_buffer; return "
\n".$dbp_output_buffer[$index]."
\n"; } function GetPermissions($gm, $anonlevel, $char_id) { global $permissions, $game_db; $query = "SELECT value FROM quest_globals WHERE charid = $char_id and name = 'charbrowser_profile';"; if (defined('DB_PERFORMANCE')) dbp_query_stat('query', $query); //added 9/28/2014 $results = $game_db->query($query); if (numRows($results)) { $row = fetchRows($results); if ($row[0]['value'] == 1) return $permissions['PUBLIC']; if ($row[0]['value'] == 2) return $permissions['PRIVATE']; } if ($gm) return $permissions['GM']; if ($anonlevel == 2) return $permissions['ROLEPLAY']; if ($anonlevel == 1) return $permissions['ANON']; return $permissions['ALL']; } function message_die($dietitle, $text) { global $language, $template; //drop page $d_title = " - ".$dietitle; include("include/header.php"); $template->set_filenames(array( 'message' => 'message_body.tpl') ); $template->assign_vars(array( 'DIETITLE' => $dietitle, 'TEXT' => $text, 'L_BACK' => $language['BUTTON_BACK']) ); $template->pparse('message'); //dump footer include("include/footer.php"); exit(); } function message($title, $text) { global $language; global $template; $template->set_filenames(array( 'message' => 'message_body.tpl') ); $template->assign_vars(array( 'TITLE' => $title, 'TEXT' => $text, 'L_BACK' => $language['BUTTON_BACK']) ); $template->pparse('message'); } function generate_pagination($base_url, $num_items, $per_page, $start_item, $add_prevnext_text = TRUE) { global $language, $tlp; $total_pages = ceil($num_items/$per_page); if ($total_pages == 1) { return ''; } $on_page = floor($start_item / $per_page) + 1; $page_string = ''; $tlp_string = $tlp ? "&tlp=1" : ""; if ($total_pages > 10) { $init_page_max = ( $total_pages > 3 ) ? 3 : $total_pages; for($i=1;$i<$init_page_max+1;$i++) { $page_string .= ( $i == $on_page ) ? '' . $i . '' : '' . $i . ''; if ($i < $init_page_max) { $page_string .= ", "; } } if ($total_pages > 3) { if ($on_page > 1 && $on_page < $total_pages) { $page_string .= ($on_page > 5) ? ' ... ' : ', '; $init_page_min = ($on_page > 4) ? $on_page : 5; $init_page_max = ($on_page < $total_pages - 4) ? $on_page : $total_pages - 4; for($i=$init_page_min-1;$i<$init_page_max+2;$i++) { $page_string .= ($i == $on_page) ? '' . $i . '' : '' . $i . ''; if ($i < $init_page_max + 1) { $page_string .= ', '; } } $page_string .= ( $on_page < $total_pages - 4 ) ? ' ... ' : ', '; } else { $page_string .= ' ... '; } for($i=$total_pages-2;$i<$total_pages+1;$i++) { $page_string .= ( $i == $on_page ) ? '' . $i . '' : '' . $i . ''; if($i < $total_pages) { $page_string .= ", "; } } } } else { for($i=1;$i<$total_pages+1;$i++) { $page_string .= ( $i == $on_page ) ? '' . $i . '' : '' . $i . ''; if ($i < $total_pages) { $page_string .= ', '; } } } if ($add_prevnext_text) { if ($on_page > 1) { $page_string = ' ' . $language['SEARCH_PREVIOUS'] . '  ' . $page_string; } if ($on_page < $total_pages) { $page_string .= '  ' . $language['SEARCH_NEXT'] . ''; } } $page_string = $lang['Goto_page'] . ' ' . $page_string; return $page_string; } function IsAlphaSpace($str) { $old = Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", " "); $new = Array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""); if (str_replace($old, $new, $str) == "") { return (true); } else { return (false); } } function IsAlphaNumericSpace($str) { $old = Array(" ", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"); $new = Array("", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ""); if (str_replace($old, $new, $str) == "") { return (true); } else { return (false); } } ?>