本文整理汇总了PHP中SQL::close方法的典型用法代码示例。如果您正苦于以下问题:PHP SQL::close方法的具体用法?PHP SQL::close怎么用?PHP SQL::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SQL
的用法示例。
在下文中一共展示了SQL::close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _leiphp_request_method_router
function _leiphp_request_method_router()
{
// 如果已调用APP::end(),则不再执行此函数,因为在die后仍然会执行register_shutdown_function注册的函数
if (APP::$is_exit) {
return;
}
// 执行相应的请求方法
$method = strtolower($_SERVER['REQUEST_METHOD']);
$funcname = "method_{$method}";
define('APP_TIMESTAMP_ROUTE', microtime(true));
if (function_exists($funcname)) {
$funcname();
} elseif (function_exists('method_all')) {
$funcname = 'method_all';
method_all();
} else {
$funcname = 'method_undefine';
}
// 关闭数据库连接
@SQL::close();
// 显示调试信息
$accept_type = strtolower(trim($_SERVER['HTTP_ACCEPT']));
if (APP::$is_debug && substr($accept_type, 0, 9) == 'text/html') {
$spent2 = round((microtime(true) - APP_TIMESTAMP_ROUTE) * 1000, 3);
$spent = round((microtime(true) - APP_TIMESTAMP_START) * 1000, 3);
$debug = DEBUG::clear();
echo "<div style='\n font-size: 14px;\n line-height: 1.6em;\n text-align: left;\n color: #000;\n padding: 12px 8px;\n border: 1px solid #DDD;\n font-family: \"Microsoft yahei\", \"Helvetica Neue\", \"Lucida Grande\", \"Lucida Sans Unicode\", Helvetica, Arial, sans-serif !important;\n background-color: #EEE;\n margin-top: 50px;\n'>Debug<br>Function {$funcname} spent: {$spent2}ms<br>Total spent: {$spent}ms<br>\n<hr><pre style='\n font-family: \"Microsoft yahei\", \"Helvetica Neue\", \"Lucida Grande\", \"Lucida Sans Unicode\", Helvetica, Arial, sans-serif !important;\n'>{$debug}</pre>\n</div>";
}
}
示例2: get_additional_data
/**
* calculate creature health, mana and armor
*
* kinda crappy way, but works
*
* if $type is used:
* 1 -> returns health
* 2 -> returns mana
* 3 -> returns armor
* 0 -> returns array(health,mana,armor)
*/
function get_additional_data($entryid, $type = 0)
{
global $world_db, $realm_id;
if (!is_numeric($entryid)) {
return array(0, 0, 0);
}
$sqlw = new SQL();
$sqlw->connect($world_db[$realm_id]['addr'], $world_db[$realm_id]['user'], $world_db[$realm_id]['pass'], $world_db[$realm_id]['name']);
$q = $sqlw->query("\n\t\tSELECT \n\t\t\t(SELECT unit_class \n\t\t\tFROM creature_template \n\t\t\tWHERE entry = " . $entryid . ") AS class, \n\t\t\t\t(SELECT FLOOR(minlevel + (RAND() * (maxlevel - minlevel + 1))) \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ") AS level, \n\t\t\t\t(SELECT exp \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ") AS exp;");
$data = $sqlw->fetch_assoc($q);
if ($sqlw->num_rows($q) == 0) {
return array(0, 0, 0);
}
$q = "\n\t\t\tSELECT \n\t\t\t\t((SELECT Health_Mod \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ")\n\t\t\t\t\t*(SELECT basehp" . $data['exp'] . " \n\t\t\t\t\tFROM creature_classlevelstats \n\t\t\t\t\tWHERE level = " . $data['level'] . " AND class = " . $data['class'] . ")+0.5), \n\t\t\t\t((SELECT Mana_Mod \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ")\n\t\t\t\t\t*(SELECT basemana \n\t\t\t\t\tFROM creature_classlevelstats \n\t\t\t\t\tWHERE level = " . $data['level'] . " AND class = " . $data['class'] . ")+0.5),\n\t\t\t\t((SELECT Armor_Mod \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ")\n\t\t\t\t*(SELECT basearmor \n\t\t\t\tFROM creature_classlevelstats \n\t\t\t\tWHERE level = " . $data['level'] . " AND class = " . $data['class'] . ")+0.5);";
if ($type == 1) {
$q = "\n\t\t\tSELECT \n\t\t\t\t((SELECT Health_Mod \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ")\n\t\t\t\t\t*(SELECT basehp" . $data['exp'] . " \n\t\t\t\t\tFROM creature_classlevelstats \n\t\t\t\t\tWHERE level = " . $data['level'] . " AND class = " . $data['class'] . ")+0.5);";
}
if ($type == 2) {
$q = "\n\t\t\tSELECT \n\t\t\t\t((SELECT Mana_Mod \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ")\n\t\t\t\t\t*(SELECT basemana \n\t\t\t\t\tFROM creature_classlevelstats \n\t\t\t\t\tWHERE level = " . $data['level'] . " AND class = " . $data['class'] . ")+0.5);";
}
if ($type == 3) {
$q = "\n\t\t\tSELECT \n\t\t\t\t((SELECT Armor_Mod \n\t\t\t\tFROM creature_template \n\t\t\t\tWHERE entry = " . $entryid . ")\n\t\t\t\t\t*(SELECT basearmor \n\t\t\t\t\tFROM creature_classlevelstats \n\t\t\t\t\tWHERE level = " . $data['level'] . " AND class = " . $data['class'] . ")+0.5);";
}
$query = $sqlw->query($q);
$result = $sqlw->fetch_row($query);
$sqlw->close();
unset($sql);
if ($type == 2 && $result[0] == 0.5) {
return 0;
}
if ($type == 0 && $result[1] == 0.5) {
return array($result[0], 0, $result[2]);
}
return $type > 0 ? $result[0] : $result;
}
示例3: html_header
function html_header()
{
if (!defined('SITE_ROOT')) {
define('SITE_ROOT', './');
}
require SITE_ROOT . 'portal_config.php';
require_once SITE_ROOT . 'include/database.class.php';
$currentUserID = $_SESSION['current_userID'];
$db = new SQL(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME, false);
$db->query("SELECT * FROM forum_users WHERE id='{$currentUserID}'");
if ($row = $db->fetch_array()) {
$username = $row['username'];
$realname = $row['realname'];
}
$db->close();
if ($realname !== null) {
$displayname = $realname;
} else {
$displayname = $username;
}
echo '
<div id="wrap">
<div class="navbar navbar-top"><div class="navbar-inner"><div class="container">
<a class="brand" href="#index.php"><div class="logo-ip"></div></a>
<div class="btn-group pull-left">
<a href="../forum" class="btn btn-inverse"><i class="icon-rss"></i> Forum Ishare</a>
</div>
<div class="btn-group">
<button class="btn dropdown-toggle" data-toggle="dropdown"><i class="icon-list muted"></i> KampusLinks <span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="http://mpp.eng.usm.my/">MPPUSMKKj Official Blog</a></li>
<li><a href="http://hepp.eng.usm.my/">BHEPP USMKKj</a></li>
<li><a href="http://infodesk.eng.usm.my/">Infodesk PPKT USMKKj</a></li>
<li><a href="http://www.eng.usm.my/php/blockedIP/">Blocked Port List</a></li>
<li><a href="http://elearning.usm.my/">e-Learning Portal</a></li>
<li><a href="http://campusonline.usm.my/">CampusOnline Portal</a></li>
<li><a href="http://www.tcom.usm.my/">Sistem Direktori Telefon USM</a></li>
<li><a href="http://www.facebook.com/ppkt.eng.usm">Facebook PPKT USMKKj</a></li>
<li class="divider"></li>
<li><a href="http://hik3.net/refcode"><i class="icon-bookmark"></i> RefCode (Snippets)</a></li>
</ul>
</div>
<div class="btn-group pull-right">
<a href="index.php" class="btn btn-primary"><i class="icon-home icon-white"></i> Home</a>
<a href="profile.php?id=' . $currentUserID . '" class="btn btn-inverse"><i class="icon-user"></i> ' . $displayname . '</a>
<button class="btn btn-danger dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="edit_profile.php"><i class="icon-edit muted"></i> Edit Profile</a></li>
<li><a href="edit_sharerlink.php"><i class="icon-hdd muted"></i> Edit Sharerlink</a></li>
<li class="divider"></li>
<li><a href="../forum/login.php?action=out&id=' . $currentUserID . '"><i class="icon-off muted"></i> Logout</a></li>
</ul>
</div>
</div></div></div>
';
}
示例4: _slimphp_request_method_router
function _slimphp_request_method_router()
{
// 如果已调用APP::end(),则不再执行此函数,因为在die后仍然会执行register_shutdown_function注册的函数
if (APP::$is_exit) {
return;
}
// 执行相应的请求方法
// strtolower(string)
// 参数 描述
// string 必需。规定要转换的字符串。
// 技术细节
// 返回值: 返回转换为小写的字符串。
// $_SERVER['REQUEST_METHOD'] #访问页面时的请求方法。例如:“GET”、“HEAD”,“POST”,“PUT”。
$method = strtolower($_SERVER['REQUEST_METHOD']);
//得到是get或者post然后下面拼接method_get或者method_post
$funcname = "method_{$method}";
//microtime() 函数返回当前 Unix 时间戳和微秒数。
define('APP_TIMESTAMP_ROUTE', microtime(true));
if (function_exists($funcname)) {
$funcname();
} elseif (function_exists('method_all')) {
$funcname = 'method_all';
method_all();
} else {
$funcname = 'method_undefine';
}
// 关闭数据库连接
@SQL::close();
// 显示调试信息
// $_SERVER['HTTP_ACCEPT'] #当前请求的 Accept: 头部的内容。
$accept_type = strtolower(trim($_SERVER['HTTP_ACCEPT']));
//substr(string,start,length)
//参数 描述
//string 必需。规定要返回其中一部分的字符串。
//start
//必需。规定在字符串的何处开始。
//正数 - 在字符串的指定位置开始
//负数 - 在从字符串结尾开始的指定位置开始
//0 - 在字符串中的第一个字符处开始
//length
//可选。规定被返回字符串的长度。默认是直到字符串的结尾。
//正数 - 从 start 参数所在的位置返回的长度
//负数 - 从字符串末端返回的长度
if (APP::$is_debug && substr($accept_type, 0, 9) == 'text/html') {
//APP_TIMESTAMP_ROUTE 25行
$spent2 = round((microtime(true) - APP_TIMESTAMP_ROUTE) * 1000, 3);
$spent = round((microtime(true) - APP_TIMESTAMP_START) * 1000, 3);
$debug = DEBUG::clear();
echo "<div style='\n font-size: 14px;\n line-height: 1.6em;\n text-align: left;\n color: #000;\n padding: 12px 8px;\n border: 1px solid #DDD;\n font-family: \"Microsoft yahei\", \"Helvetica Neue\", \"Lucida Grande\", \"Lucida Sans Unicode\", Helvetica, Arial, sans-serif !important;\n background-color: #EEE;\n margin-top: 50px;\n'>Debug<br>Function {$funcname} spent: {$spent2}ms<br>Total spent: {$spent}ms<br>\n<hr><pre style='\n font-family: \"Microsoft yahei\", \"Helvetica Neue\", \"Lucida Grande\", \"Lucida Sans Unicode\", Helvetica, Arial, sans-serif !important;\n'>{$debug}</pre>\n</div>";
}
}
示例5: populate_requestbox
function populate_requestbox()
{
$db = new SQL(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME, false);
$db->query("SELECT COUNT(id) FROM ip_requests");
$total_request = implode($db->fetch_assoc());
$db->query("SELECT COUNT(id) FROM ip_reply");
$total_reply = implode($db->fetch_assoc());
$db->close();
echo '<div class="alert alert-info">This is <strong>User\'s Request</strong> section (currently contained <strong>' . $total_request . '</strong> request shouts and <strong>' . $total_reply . '</strong> replies). Just use <code>!request</code> code in your shout to make them appear here. Please note that not all your requests will be replied. Lucky if you have!</div>';
echo '<div id="containerx">';
echo '<div class="data"></div>';
echo '<div class="pagination"></div>';
echo '</div>';
echo '
<script>
var replyID;
$(document).ready(function () { // START DOCUMENT.READY
$(".tip-top").tooltip();
function loadData(page){
$("#containerx").html("<div class=\\"loader\\" style=\\"margin-top:10px\\"></div>").fadeIn("fast");
$.ajax({
type: "GET",
url: "subfiles/requestbox_more.php?page="+page,
success: function(msg){
$("#containerx").html(msg);
}
});
}
loadData(1); // For first time page load default results
$("#containerx .pagination li.enx").live("click",function(e){
e.preventDefault();
var page = $(this).attr("p");
loadData(page);
});
}); // END DCOUMENT.READY
</script>
';
}
示例6: execute_reader
/**
* execute query and return all data in a reader
*
* @return SQLDataReader
*/
public function execute_reader()
{
$this->parse_query();
if (empty($this->queryParsed)) {
return new SQLDataReader();
}
$close = $this->conn->status() == 'closed';
$this->conn->open();
$res = $this->conn->query($this->queryParsed);
$data = array();
while ($row = $this->conn->fetch_array($res)) {
$data[] = $row;
}
// SQLite causes 'unknown error' after successful fetch of all data.
// Don't have a clue why...
$ret = empty($this->conn->error()) || $this->conn->error() == 'unknown error';
if ($close) {
$this->conn->close();
}
return $ret ? new SQLDataReader($data) : new SQLDataReader();
}
示例7: forum_view_topic
function forum_view_topic(&$sqlr, &$sqlc, &$sqlm)
{
global $enablesidecheck, $forum_skeleton, $maxqueries, $forum_lang, $user_lvl, $user_id, $output, $realm_db, $characters_db, $mmfpm_db, $realm_id;
if ($enablesidecheck) {
$side = get_side();
}
// Better to use it here instead of call it many time in the loop :)
$sqlm = new SQL();
$sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
//==========================$_GET and SECURE=================================
if (isset($_GET['id'])) {
$id = $sqlm->quote_smart($_GET['id']);
$post = false;
} else {
if (isset($_GET['postid'])) {
$id = $sqlm->quote_smart($_GET['postid']);
$post = true;
} else {
error($forum_lang['no_such_topic']);
}
}
if (!isset($_GET['page'])) {
$page = 0;
} else {
$page = $sqlm->quote_smart($_GET['page']);
}
// Fok you mathafoker haxorz
//==========================$_GET and SECURE end=============================
$start = $maxqueries * $page;
if (!$post) {
$posts = $sqlm->query('
SELECT id, authorid, authorname, forum, name, text, time, annouced, sticked, closed
FROM mm_forum_posts
WHERE topic = ' . $id . '
ORDER BY id ASC
LIMIT ' . $start . ', ' . $maxqueries . '');
$sqlr = new SQL();
$sqlr->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
// need to update this query to use ' instead of "
$query = "\r\n\t\t\tSELECT account, name, gender, race, class, level,\r\n\t\t\t\t(SELECT gmlevel\r\n\t\t\t\tFROM `{$realm_db['name']}`.account\r\n\t\t\t\tWHERE `{$realm_db['name']}`.account.id = `{$characters_db[$realm_id]['name']}`.characters.account) as gmlevel\r\n\t\t\tFROM `{$characters_db[$realm_id]['name']}`.characters\r\n\t\t\tWHERE totaltime IN \r\n\t\t\t\t(SELECT MAX(totaltime)\r\n\t\t\t\tFROM `{$characters_db[$realm_id]['name']}`.characters\r\n\t\t\t\tWHERE account IN (";
while ($post = $sqlm->fetch_row($posts)) {
$query .= "{$post['1']},";
}
mysql_data_seek($posts, 0);
$query .= "\r\n\t\t\t\t\t0)\r\n\t\t\t\tGROUP BY account);";
$sqlc = new SQL();
$sqlc->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']);
$results = $sqlc->query($query);
while ($avatar = $sqlc->fetch_assoc($results)) {
$char_gender = str_pad(dechex($avatar['gender']), 8, 0, STR_PAD_LEFT);
$avatars[$avatar['account']]['name'] = $avatar['name'];
$avatars[$avatar['account']]['sex'] = $char_gender['race'];
$avatars[$avatar['account']]['race'] = $avatar['race'];
$avatars[$avatar['account']]['class'] = $avatar['class'];
$avatars[$avatar['account']]['level'] = $avatar['level'];
$avatars[$avatar['account']]['gm'] = $avatar['gmlevel'];
}
$replies = $sqlm->num_rows($posts);
if ($replies == 0) {
error($forum_lang['no_such_topic']);
}
$post = $sqlm->fetch_assoc($posts);
$fid = $post['forum'];
$cat = 0;
$cid = $sqlm->query('
SELECT category, name, description, side_access, level_post_topic, level_read, level_post
FROM mm_forum_categories');
while ($category = $sqlm->fetch_assoc($cid)) {
$fid_ = $sqlm->query('
SELECT forum, category, name, description, side_access, level_post_topic, level_read, level_post
FROM mm_forum_forums
WHERE category = ' . $category['category'] . '');
while ($forum = $sqlm->fetch_assoc($fid_)) {
if ($forum['forum'] == $fid) {
$cat = $forum['category'];
}
if (empty($forum['forum'])) {
error($forum_lang['no_such_forum']);
}
if ($category['level_read'] > $user_lvl || $forum['level_read'] > $user_lvl) {
error($forum_lang['no_access']);
}
if ($user_lvl == 0 && $enablesidecheck) {
if ($category['side_access'] != 'ALL') {
// Not an all side forum
if ($side == 'NO') {
// No char
continue;
} else {
if ($category['side_access'] != $side) {
// Forumside different of the user side
continue;
}
}
}
if ($forum['side_access'] != 'ALL') {
// Not an all side forum
if ($side == 'NO') {
// No char
continue;
//.........这里部分代码省略.........
示例8: doregister
function doregister()
{
global $lang_global, $characters_db, $realm_db, $mmfpm_db, $realm_id, $disable_acc_creation, $limit_acc_per_ip, $valid_ip_mask, $send_mail_on_creation, $create_acc_locked, $from_mail, $defaultoption, $require_account_verify, $mailer_type, $smtp_cfg, $title;
if ($_POST['security_code'] != $_SESSION['security_code']) {
redirect("register.php?err=13");
}
if (empty($_POST['pass']) || empty($_POST['email']) || empty($_POST['username'])) {
redirect("register.php?err=1");
}
if ($disable_acc_creation) {
redirect("register.php?err=4");
}
$last_ip = getenv('HTTP_X_FORWARDED_FOR') ? getenv('HTTP_X_FORWARDED_FOR') : getenv('REMOTE_ADDR');
if (sizeof($valid_ip_mask)) {
$qFlag = 0;
$user_ip_mask = explode('.', $last_ip);
foreach ($valid_ip_mask as $mask) {
$vmask = explode('.', $mask);
$v_count = 4;
$i = 0;
foreach ($vmask as $range) {
$vmask_h = explode('-', $range);
if (isset($vmask_h[1])) {
if ($vmask_h[0] >= $user_ip_mask[$i] && $vmask_h[1] <= $user_ip_mask[$i]) {
$v_count--;
}
} else {
if ($vmask_h[0] == $user_ip_mask[$i]) {
$v_count--;
}
}
$i++;
}
if (!$v_count) {
$qFlag++;
break;
}
}
if (!$qFlag) {
redirect("register.php?err=9&usr={$last_ip}");
}
}
$sql = new SQL();
$sql->connect($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name']);
$user_name = $sql->quote_smart(trim($_POST['username']));
$pass = $sql->quote_smart($_POST['pass']);
$pass1 = $sql->quote_smart($_POST['pass1']);
//make sure username/pass at least 4 chars long and less than max
if (strlen($user_name) < 4 || strlen($user_name) > 15) {
$sql->close();
redirect("register.php?err=5");
}
require_once "libs/valid_lib.php";
//make sure it doesnt contain non english chars.
if (!valid_alphabetic($user_name)) {
$sql->close();
redirect("register.php?err=6");
}
//make sure the mail is valid mail format
$mail = $sql->quote_smart(trim($_POST['email']));
if (!valid_email($mail) || strlen($mail) > 224) {
$sql->close();
redirect("register.php?err=7");
}
$per_ip = $limit_acc_per_ip ? "OR last_ip='{$last_ip}'" : "";
$result = $sql->query("SELECT ip FROM ip_banned WHERE ip = '{$last_ip}'");
//IP is in ban list
if ($sql->num_rows($result)) {
$sql->close();
redirect("register.php?err=8&usr={$last_ip}");
}
//Email check
$result = $sql->query("SELECT email FROM account WHERE email='{$mail}' {$per_ip}");
if ($sql->num_rows($result)) {
$sql->close();
redirect("register.php?err=14");
}
//Username check
$result = $sql->query("SELECT username FROM account WHERE username='{$user_name}' {$per_ip}");
if ($sql->num_rows($result)) {
$sql->close();
redirect("register.php?err=3");
}
//there is already someone with same account name
if ($sql->num_rows($result)) {
$sql->close();
redirect("register.php?err=3&usr={$user_name}");
} else {
if ($expansion_select) {
$expansion = isset($_POST['expansion']) ? $sql->quote_smart($_POST['expansion']) : 0;
} else {
$expansion = $defaultoption;
}
if ($require_account_verify) {
$sqlm = new SQL();
$sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
$result2 = $sqlm->query("SELECT * FROM mm_account_verification WHERE username = '{$user_name}' OR email = '{$mail}'");
if ($sqlm->num_rows($result2) > 0) {
redirect("register.php?err=15");
} else {
//.........这里部分代码省略.........
示例9: dobackup
function dobackup()
{
global $lang_backup, $backup_dir, $tables_backup_realmd, $tables_backup_characters, $output, $realm_db, $characters_db, $realm_id, $tab_backup_user_realmd, $tab_backup_user_characters;
if (empty($_GET['backup_action']) || empty($_GET['backup_from_to'])) {
redirect("backup.php?error=1");
} else {
$backup_action = addslashes($_GET['backup_action']);
$backup_from_to = addslashes($_GET['backup_from_to']);
}
if ("load" == $backup_action && "file" == $backup_from_to) {
if (!eregi("(\\.(sql|qbquery))\$", $_FILES["uploaded_file"]["name"])) {
error($lang_backup['upload_sql_file_only']);
}
$uploaded_filename = str_replace(" ", "_", $_FILES["uploaded_file"]["name"]);
$uploaded_filename = preg_replace("/[^_A-Za-z0-9-\\.]/i", '', $uploaded_filename);
$file_name_new = $uploaded_filename . "_" . date("m.d.y_H.i.s") . ".sql";
move_uploaded_file($_FILES["uploaded_file"]["tmp_name"], "{$backup_dir}/{$file_name_new}") or die(error("{$lang_backup['upload_err_write_permission']} {$backup_dir}"));
if (file_exists("{$backup_dir}/{$file_name_new}")) {
require_once "libs/db_lib/sql_lib.php";
$use_db = addslashes($_POST['use_db']);
if ($use_db == $realm_db['name']) {
$queries = run_sql_script($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name'], "{$backup_dir}/{$file_name_new}", true);
} else {
foreach ($characters_db as $db) {
if ($use_db == $db['name']) {
$queries = run_sql_script($db['addr'], $db['user'], $db['pass'], $db['name'], "{$backup_dir}/{$file_name_new}", true);
}
}
}
redirect("backup.php?error=4&tot={$queries}");
} else {
error($lang_backup['file_not_found']);
}
} elseif ("load" == $backup_action && "web" == $backup_from_to) {
if (empty($_POST['selected_file_name'])) {
redirect("backup.php?error=1");
} else {
$file_name = addslashes($_POST['selected_file_name']);
}
if (file_exists("{$backup_dir}/{$file_name}")) {
require_once "libs/db_lib/sql_lib.php";
$use_db = addslashes($_POST['use_db']);
if ($use_db == $realm_db['name']) {
$queries = run_sql_script($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name'], "{$backup_dir}/{$file_name}", false);
} else {
foreach ($characters_db as $db) {
if ($use_db == $db['name']) {
$queries = run_sql_script($db['addr'], $db['user'], $db['pass'], $db['name'], "{$backup_dir}/{$file_name}", false);
}
}
}
redirect("backup.php?error=4&tot={$queries}");
} else {
error($lang_backup['file_not_found']);
}
} elseif ("save" == $backup_action && "file" == $backup_from_to) {
//save and send to user
$struc_backup = addslashes($_GET['struc_backup']);
$save_all_realms = addslashes($_GET['save_all_realms']);
if ($save_all_realms) {
$temp_id = "all_realms";
} else {
$temp_id = "realmid_" . $realm_id;
}
$file_name_new = $temp_id . "_backup_" . date("m.d.y_H.i.s") . ".sql";
$fp = fopen("{$backup_dir}/{$file_name_new}", 'w') or die(error($lang_backup['file_write_err']));
fwrite($fp, "CREATE DATABASE /*!32312 IF NOT EXISTS*/ {$realm_db['name']};\n") or die(error($lang_backup['file_write_err']));
fwrite($fp, "USE {$realm_db['name']};\n\n") or die(error($lang_backup['file_write_err']));
fclose($fp);
require_once "libs/db_lib/sql_lib.php";
foreach ($tables_backup_realmd as $value) {
sql_table_dump($realm_db['addr'], $realm_db['user'], $realm_db['pass'], $realm_db['name'], $value, $struc_backup, "{$backup_dir}/{$file_name_new}");
}
if ($save_all_realms) {
foreach ($characters_db as $db) {
$fp = fopen("{$backup_dir}/{$file_name_new}", 'r+') or die(error($lang_backup['file_write_err']));
fseek($fp, 0, SEEK_END);
fwrite($fp, "CREATE DATABASE /*!32312 IF NOT EXISTS*/ {$db['name']};\n") or die(error($lang_backup['file_write_err']));
fwrite($fp, "USE {$db['name']};\n\n") or die(error($lang_backup['file_write_err']));
fclose($fp);
foreach ($tables_backup_characters as $value) {
sql_table_dump($db['addr'], $db['user'], $db['pass'], $db['name'], $value, $struc_backup, "{$backup_dir}/{$file_name_new}");
}
}
} else {
$fp = fopen("{$backup_dir}/{$file_name_new}", 'r+') or die(error($lang_backup['file_write_err']));
fseek($fp, 0, SEEK_END);
fwrite($fp, "CREATE DATABASE /*!32312 IF NOT EXISTS*/ {$characters_db[$realm_id]['name']};\n") or die(error($lang_backup['file_write_err']));
fwrite($fp, "USE {$characters_db[$realm_id]['name']};\n\n") or die(error($lang_backup['file_write_err']));
fclose($fp);
foreach ($tables_backup_characters as $value) {
sql_table_dump($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name'], $value, $struc_backup, "{$backup_dir}/{$file_name_new}");
}
}
Header("Content-type: application/octet-stream");
Header("Content-Disposition: attachment; filename={$file_name_new}");
$fp = fopen("{$backup_dir}/{$file_name_new}", 'r') or die(error($lang_backup['file_write_err']));
while (!feof($fp)) {
$output_file = fread($fp, 1024);
echo $output_file;
//.........这里部分代码省略.........
示例10: SQL
require_once 'libs/db_lib.php';
// Try to globally fix security vulnerabilities (very dirty way..)
require_once 'libs/valid_lib.php';
$sqlm = new SQL();
//mysql_real_escape_string needs a sql connection
$sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
foreach ($_POST as $key => $value) {
$_POST[$key] = cleanSQL($value);
}
foreach ($_GET as $key => $value) {
$_GET[$key] = cleanSQL($value);
}
foreach ($_COOKIE as $key => $value) {
$_COOKIE[$key] = cleanSQL($value);
}
$sqlm->close();
unset($sqlm);
// End
//---------------------Loading User Theme and Language Settings----------------
if (isset($_COOKIE['theme'])) {
if (is_dir('themes/' . $_COOKIE['theme'])) {
if (is_file('themes/' . $_COOKIE['theme'] . '/' . $_COOKIE['theme'] . '_1024.css')) {
$theme = $_COOKIE['theme'];
}
}
}
if (isset($_COOKIE['lang'])) {
$lang = $_COOKIE['lang'];
if (file_exists('lang/' . $lang . '.php')) {
} else {
$lang = $language;
示例11: do_edit_char
//.........这里部分代码省略.........
}
if ($user_lvl > $owner_gmlvl) {
if (isset($_GET['check'])) {
$check = $sql->quote_smart($_GET['check']);
} else {
$check = NULL;
}
$new_name = $sql->quote_smart($_GET['name']);
if (isset($_GET['tot_time'])) {
$new_tot_time = $sql->quote_smart($_GET['tot_time']);
} else {
$new_tot_time = 0;
}
if (isset($_GET['money'])) {
$new_money = $sql->quote_smart($_GET['money']);
} else {
$new_money = 0;
}
if (isset($_GET['arena_points'])) {
$new_arena_points = $sql->quote_smart($_GET['arena_points']);
} else {
$new_arena_points = 0;
}
if (isset($_GET['honor_points'])) {
$new_honor_points = $sql->quote_smart($_GET['honor_points']);
} else {
$new_honor_points = 0;
}
if (isset($_GET['total_kills'])) {
$new_total_kills = $sql->quote_smart($_GET['total_kills']);
} else {
$new_total_kills = 0;
}
if (!is_numeric($new_tot_time) || !is_numeric($new_money) || !is_numeric($new_arena_points) || !is_numeric($new_honor_points)) {
error($lang_char['use_numeric']);
}
$x = isset($_GET['x']) ? $sql->quote_smart($_GET['x']) : 0;
$y = isset($_GET['y']) ? $sql->quote_smart($_GET['y']) : 0;
$z = isset($_GET['z']) ? $sql->quote_smart($_GET['z']) : 0;
$map = isset($_GET['map']) ? $sql->quote_smart($_GET['map']) : 0;
$tp_to = isset($_GET['tp_to']) ? $sql->quote_smart($_GET['tp_to']) : 0;
$sql->connect($characters_db[$realm_id]['addr'], $characters_db[$realm_id]['user'], $characters_db[$realm_id]['pass'], $characters_db[$realm_id]['name']);
$result = $sql->query("SELECT equipmentCache FROM characters WHERE guid = '{$id}'");
$char = $sql->fetch_row($result);
$eq_data = explode(' ', $char[0]);
//some items need to be deleted
if ($check) {
$item_offset = array("a0" => EQ_DATA_OFFSET_EQU_HEAD, "a1" => EQ_DATA_OFFSET_EQU_NECK, "a2" => EQ_DATA_OFFSET_EQU_SHOULDER, "a3" => EQ_DATA_OFFSET_EQU_SHIRT, "a4" => EQ_DATA_OFFSET_EQU_CHEST, "a5" => EQ_DATA_OFFSET_EQU_BELT, "a6" => EQ_DATA_OFFSET_EQU_LEGS, "a7" => EQ_DATA_OFFSET_EQU_FEET, "a8" => EQ_DATA_OFFSET_EQU_WRIST, "a9" => EQ_DATA_OFFSET_EQU_GLOVES, "a10" => EQ_DATA_OFFSET_EQU_FINGER1, "a11" => EQ_DATA_OFFSET_EQU_FINGER2, "a12" => EQ_DATA_OFFSET_EQU_TRINKET1, "a13" => EQ_DATA_OFFSET_EQU_TRINKET2, "a14" => EQ_DATA_OFFSET_EQU_BACK, "a15" => EQ_DATA_OFFSET_EQU_MAIN_HAND, "a16" => EQ_DATA_OFFSET_EQU_OFF_HAND, "a17" => EQ_DATA_OFFSET_EQU_RANGED, "a18" => EQ_DATA_OFFSET_EQU_TABARD);
foreach ($check as $item_num) {
//deleting equiped items
if ($item_num[0] == "a") {
$eq_data[$item_offset[$item_num]] = 0;
sscanf($item_num, "a%d", $item_num);
$result = $sql->query("SELECT item FROM character_inventory WHERE guid = '{$id}' AND slot = {$item_num} AND bag = 0");
$item_inst_id = $sql->result($result, 0, 'item');
$sql->query("DELETE FROM character_inventory WHERE guid = '{$id}' AND slot = {$item_num} AND bag = 0");
$sql->query("DELETE FROM item_instance WHERE guid = '{$item_inst_id}' AND owner_guid = '{$id}'");
} else {
//deleting inv/bank items
$sql->query("DELETE FROM character_inventory WHERE guid = '{$id}' AND item = '{$item_num}'");
$sql->query("DELETE FROM item_instance WHERE guid = '{$item_num}' AND owner_guid = '{$id}'");
}
}
}
$data = implode(' ', $eq_data);
if ($tp_to) {
$query = $sql->query("SELECT map, position_x, position_y, position_z, orientation FROM `" . $world_db[$realm_id]['name'] . "`.`game_tele` WHERE LOWER(name) = '" . strtolower($tp_to) . "'");
$tele = $sql->fetch_row($query);
if ($tele) {
$teleport = "map='{$tele['0']}', position_x='{$tele['1']}', position_y='{$tele['2']}', position_z='{$tele['3']}', orientation='{$tele['4']}',";
} else {
error($lang_char['no_tp_location']);
}
} else {
$teleport = "map='{$map}', position_x='{$x}', position_y='{$y}', position_z='{$z}',";
}
$result = $sql->query("UPDATE characters SET equipmentCache = '{$data}', name = '{$new_name}', {$teleport} totaltime = '{$new_tot_time}', money = '{$new_money}', arenaPoints = '{$new_arena_points}', totalHonorPoints = '{$new_honor_points}', totalKills = '{$new_total_kills}' WHERE guid = {$id}");
$sql->close();
unset($sql);
if ($result) {
redirect("char_edit.php?action=edit_char&id={$id}&error=3");
} else {
redirect("char_edit.php?action=edit_char&id={$id}&error=4");
}
} else {
$sql->close();
unset($sql);
error($lang_char['no_permission']);
}
} else {
$sql->close();
unset($sql);
redirect("char_edit.php?action=edit_char&id={$id}&error=2");
}
} else {
error($lang_char['no_char_found']);
}
$sql->close();
unset($sql);
}
示例12: do_update
//.........这里部分代码省略.........
$sql_query .= "BagFamily='{$BagFamily}',";
}
if ($item_templ['Map'] != $Map) {
$sql_query .= "Map='{$Map}',";
}
if ($item_templ['ScriptName'] != $ScriptName) {
$sql_query .= "ScriptName='{$ScriptName}',";
}
if ($item_templ['DisenchantID'] != $DisenchantID) {
$sql_query .= "DisenchantID='{$DisenchantID}',";
}
if ($item_templ['RequiredDisenchantSkill'] != $RequiredDisenchantSkill) {
$sql_query .= "RequiredDisenchantSkill='{$RequiredDisenchantSkill}',";
}
if ($item_templ['ArmorDamageModifier'] != $ArmorDamageModifier) {
$sql_query .= "ArmorDamageModifier='{$ArmorDamageModifier}',";
}
if ($item_templ['unk0'] != $unk0) {
$sql_query .= "unk0='{$unk0}',";
}
if ($item_templ['RandomSuffix'] != $RandomSuffix) {
$sql_query .= "RandomSuffix='{$RandomSuffix}',";
}
if ($item_templ['TotemCategory'] != $TotemCategory) {
$sql_query .= "TotemCategory='{$TotemCategory}',";
}
if ($item_templ['socketColor_1'] != $socketColor_1) {
$sql_query .= "socketColor_1='{$socketColor_1}',";
}
if ($item_templ['socketContent_1'] != $socketContent_1) {
$sql_query .= "socketContent_1='{$socketContent_1}',";
}
if ($item_templ['socketColor_2'] != $socketColor_2) {
$sql_query .= "socketColor_2='{$socketColor_2}',";
}
if ($item_templ['socketContent_2'] != $socketContent_2) {
$sql_query .= "socketContent_2='{$socketContent_2}',";
}
if ($item_templ['socketColor_3'] != $socketColor_3) {
$sql_query .= "socketColor_3='{$socketColor_3}',";
}
if ($item_templ['socketContent_3'] != $socketContent_3) {
$sql_query .= "socketContent_3='{$socketContent_3}',";
}
if ($item_templ['socketBonus'] != $socketBonus) {
$sql_query .= "socketBonus='{$socketBonus}',";
}
if ($item_templ['GemProperties'] != $GemProperties) {
$sql_query .= "GemProperties='{$GemProperties}',";
}
$sql->free_result($result);
unset($item_templ);
if ($sql_query == "UPDATE item_template SET " && !$de_item && !$del_de_items) {
$sql->close();
redirect("item.php?action=edit&entry={$entry}&error=6");
} else {
if ($sql_query != "UPDATE item_template SET ") {
$sql_query[strlen($sql_query) - 1] = " ";
$sql_query .= " WHERE entry = '{$entry}';\n";
} else {
$sql_query = "";
}
}
if ($de_item) {
$sql_query .= "INSERT INTO disenchant_loot_template (entry, item, ChanceOrQuestChance, `groupid`, mincountOrRef, maxcount, lootcondition, condition_value1, condition_value2)\n VALUES ({$DisenchantID},{$de_item},'{$de_ChanceOrQuestChance}', '{$de_groupid}' ,{$de_mincountOrRef} ,{$de_maxcount} ,{$de_lootcondition} ,{$de_condition_value1} ,{$de_condition_value2});\n";
}
if ($del_de_items) {
foreach ($del_de_items as $item_id) {
$sql_query .= "DELETE FROM disenchant_loot_template WHERE entry = {$DisenchantID} AND item = {$item_id};\n";
}
}
} else {
$sql->close();
redirect("item.php?error=5");
}
} else {
$sql->close();
redirect("item.php?error=5");
}
if (isset($_POST['backup_op']) && $_POST['backup_op'] == 1) {
$sql->close();
Header("Content-type: application/octet-stream");
Header("Content-Disposition: attachment; filename=itemid_{$entry}.sql");
echo $sql_query;
exit;
} else {
$sql_query = explode(';', $sql_query);
foreach ($sql_query as $tmp_query) {
if ($tmp_query && $tmp_query != "\n") {
$result = $sql->query($tmp_query);
}
}
$sql->close();
}
if ($result) {
redirect("item.php?action=edit&entry={$entry}&error=4");
} else {
redirect("item.php");
}
}
示例13: run_sql_script
function run_sql_script($dbhost, $dbuser, $dbpass, $dbname, $path, $unlink)
{
global $lang_global;
$fp = fopen($path, 'r') or die(error("Couldn't Open File!"));
$sql_1 = new SQL();
$sql_1->connect($dbhost, $dbuser, $dbpass, $dbname);
$query = "";
$queries = 0;
$linenumber = 0;
$inparents = false;
while (!feof($fp)) {
$dumpline = "";
while (!feof($fp) && substr($dumpline, -1) != "\n") {
$dumpline .= fgets($fp, 16384);
}
$dumpline = ereg_replace("\r\n\$", "\n", $dumpline);
$dumpline = ereg_replace("\r\$", "\n", $dumpline);
if (!$inparents) {
$skipline = false;
if (!$inparents && (trim($dumpline) == "" || strpos($dumpline, '#') === 0 || strpos($dumpline, '-- ') === 0)) {
$skipline = true;
}
if ($skipline) {
$linenumber++;
continue;
}
}
$dumpline_deslashed = str_replace("\\\\", "", $dumpline);
$parents = substr_count($dumpline_deslashed, "'") - substr_count($dumpline_deslashed, "\\'");
if ($parents % 2 != 0) {
$inparents = !$inparents;
}
$query .= $dumpline;
if (ereg(";\$", trim($dumpline)) && !$inparents) {
if (!$sql_1->query(trim($query))) {
fclose($fp);
if ($unlink) {
unlink($path);
}
$err = ereg_replace("\n", "", $sql_1->error());
$err = ereg_replace("\r\n\$", "", $err);
$err = ereg_replace("\r\$", "", $err);
error("SQL Error at the line: {$linenumber} in {$path} <br /> {$err}");
break;
}
$queries++;
$query = "";
}
$linenumber++;
}
$sql_1->close();
fclose($fp);
return $queries;
}
示例14: forum_move_topic
function forum_move_topic(&$sqlm)
{
global $forum_skeleton, $forum_lang, $maxqueries, $user_lvl, $user_id, $output, $mmfpm_db;
$sqlm = new SQL();
$sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
if (!isset($_GET['id'])) {
error($forum_lang['no_such_topic']);
} else {
$id = $sqlm->quote_smart($_GET['id']);
}
$topic = $sqlm->query('
SELECT id, topic, authorid, forum, name
FROM mm_forum_posts
WHERE id = ' . $id . '');
if ($sqlm->num_rows($topic) == 0) {
error($forum_lang['no_such_topic']);
}
$topic = $sqlm->fetch_assoc($topic);
if ($user_lvl == 0) {
error($forum_lang['no_access']);
}
$fid = $topic['forum'];
$cat = 0;
foreach ($forum_skeleton as $cid => $category) {
foreach ($category['forums'] as $fid_ => $forum) {
if ($fid_ == $fid) {
$cat = $cid;
}
}
}
if (empty($forum_skeleton[$cat]['forums'][$fid])) {
// No such forum..
error($forum_lang['no_such_forum']);
}
$forum = $forum_skeleton[$cat]["forums"][$fid];
$output .= '
<div class="top">
<h1>' . $forum_lang['forums'] . '</h1>
</div>
<center>
<table class="flat">
<tr>
<td align="left">
<a href="forum.php">' . $forum_lang['forum_index'] . '</a> ->
<a href="forum.php?action=view_forum&id=' . $fid . '">' . $forum['name'] . '</a> ->
<a href="forum.php?action=view_topic&id=' . $topic['topic'] . '">' . $topic['name'] . '</a> ->
' . $forum_lang["move"] . '!
</td>
</tr>
</table>
<table class="lined">
<tr>
<td>' . $forum_lang['where'] . ' :
<form action="forum.php?action=do_move_topic" method="POST" name="form">
<select name="forum">';
foreach ($forum_skeleton as $category) {
foreach ($category['forums'] as $fid_ => $forum) {
if ($fid_ != $fid) {
$output .= '
<option value=' . $fid_ . '>' . $forum['name'] . '</option>';
} else {
$output .= '
<option value=' . $fid_ . ' selected>' . $forum['name'] . '</option>';
}
}
}
$output .= '
</select>
<input type="hidden" name="id" value="' . $id . '">
</form>
</td>
</tr>
</table>
<table class="hidden">
<tr>
<td>';
makebutton($forum_lang['back'], "javascript:window.history.back()", 120);
makebutton($forum_lang['confirm'], "javascript:do_submit()", 120);
$output .= '
</td>
</tr>
</table>
</center>';
$sqlm->close();
// Queries : 1
}
示例15: forum_index
//.........这里部分代码省略.........
$output .= '
<div class="top">
<h1>' . $forum_lang['forums'] . '</h1>
</div>
<center>
<fieldset>
<legend><a href="forum.php">' . $forum_lang['forum_index'] . '</a></legend>
<table class="lined">';
$cid = $sqlm->query('
SELECT category, name, description, side_access, level_post_topic, level_read, level_post
FROM mm_forum_categories');
while ($category = $sqlm->fetch_assoc($cid)) {
if ($category['level_read'] > $user_lvl) {
continue;
}
if ($user_lvl == 0 && $enablesidecheck) {
if ($category['side_access'] != 'ALL') {
// Not an all side forum
if ($side == 'NO') {
// No char
continue;
} else {
if ($category['side_access'] != $side) {
// Forumside different of the user side
continue;
}
}
}
}
$output .= '
<tr>
<th class="head" align="left">' . $category['name'] . '<br />' . $category['description'] . '</th>
<th class="head">' . $forum_lang['topics'] . '</th>
<th class="head">' . $forum_lang['replies'] . '</th>
<th class="head" align="right">' . $forum_lang['last_post'] . '</th>
</tr>';
$fid = $sqlm->query('
SELECT forum, category, name, description, side_access, level_post_topic, level_read, level_post
FROM mm_forum_forums
WHERE category = ' . $category['category'] . '');
while ($forum = $sqlm->fetch_assoc($fid)) {
if ($forum['level_read'] > $user_lvl) {
continue;
}
if ($user_lvl == 0 && $enablesidecheck) {
if ($forum['side_access'] != 'ALL') {
// Not an all side forum
if ($side == 'NO') {
// No char
continue;
} else {
if ($forum['side_access'] != $side) {
// Forumside different of the user side
continue;
}
}
}
}
$totaltopics = $sqlm->query('
SELECT id
FROM mm_forum_posts
WHERE forum = ' . $forum['forum'] . ' AND id = topic');
$numtopics = $sqlm->num_rows($totaltopics);
$totalreplies = $sqlm->query('
SELECT id
FROM mm_forum_posts
WHERE forum = ' . $forum['forum'] . '');
$numreplies = $sqlm->num_rows($totalreplies);
$output .= '
<tr>
<td align="left"><a href="forum.php?action=view_forum&id=' . $forum['forum'] . '">' . $forum['name'] . '</a><br />' . $forum['description'] . '</td>
<td>' . $numtopics . '</td>
<td>' . $numreplies . '</td>';
if (isset($lasts[$forum['forum']])) {
$lasts[$forum['forum']]['name'] = htmlspecialchars($lasts[$forum['forum']]['name']);
$output .= '
<td align="right">
<a href="forum.php?action=view_topic&postid=' . $lasts[$forum['forum']]['id'] . '">' . $lasts[$forum['forum']]['name'] . '</a>
<br />by ' . $lasts[$forum['forum']]['authorname'] . '
<br /> ' . $lasts[$forum['forum']]['time'] . '
</td>
</tr>';
} else {
$output .= '
<td align="right">' . $forum_lang['no_topics'] . '</td>
</tr>';
}
}
}
$output .= '
<tr>
<td align="right" class="hidden"></td>
</tr>
</table>
</fieldset>
</center>
<br/>';
$sqlm->close();
// Queries : 1
}