function yg_shutdown() { DB::close(); fire_hook('shutdown'); }
/** * Close the DB connection. */ protected function disconnectDB() { if (isset($this->db)) { $this->db->close(); $this->db = null; } }
/** * Feng Office shutdown function * * @param void * @return null */ function __shutdown() { DB::close(); $logger_session = Logger::getSession(); if(($logger_session instanceof Logger_Session) && !$logger_session->isEmpty()) { Logger::saveSession(); } // if } // __shutdown
/** * Make a sql query to the database. * * @param string $sql * @return integer */ public static function query($sql) { DB::connect(); $res = mysqli_query(DB::$connection, $sql); DB::close(); return $res; }
/** * Close the session * @return bool */ function close() { $this->gc(); DB::close(); //close database-connection return true; }
/** * 销毁 */ public function __destruct() { global $_M; DB::close(); //关闭数据库连接 exit; }
function run() { DB::connect(); //determin controller switch ($_GET['ctrl']) { case 'page': $ctrl = new PageController(); break; case 'wine': $ctrl = new WineController(); break; case 'response': $ctrl = new ResponseController(); break; case 'report': $ctrl = new ReportController(); break; case 'dp': $ctrl = new DianPingController(); break; default: $ctrl = new PageController(); } return $ctrl->dispatch($_GET['action'] . "Action"); DB::close(); }
public static function sendError($error = 1) { header('HTTP/1.1 500 Internal Server Error'); //header('Content-Type: application/json; charset=UTF-8'); DB::close(); User::destroySession(); exit(self::encodeError($error)); }
public function end() { if ($this->isAlreadyOpened === TRUE) { $this->endTransaction(); $this->DB->close(); } unset($this->DB); $this->isAlreadyOpened = FALSE; }
private function newUser() { $db = new DB(); $query = 'INSERT INTO mototimes_users (id_vk, name, role) VALUES(?,"new user","standart")'; $stmt = $db->prepare($query); $stmt->bind_param('i', $this->get('userid')); $stmt->execute(); $db->close(); }
public static function drawTemplate() { DB::close(); self::saveContentCurrentBox(); ob_get_flush(); if (function_exists('gz_handler')) { ob_start("gz_handler"); } include_once './template/' . self::$template . '/template.php'; }
public function execute() { $db = new DB(); if ($db->connect_errno) { $this->result = ErrorBuilder::dbError($db->connect_error); return; } $query = ' SELECT id, UNIX_TIMESTAMP(created) AS created, lat, lng AS lon, karma, alignment, CASE transport WHEN 1 THEN "GS" WHEN 2 THEN "RT" WHEN 3 THEN "CAR" ELSE "GS" END AS type, `text` FROM mototimes_events WHERE UNIX_TIMESTAMP() - UNIX_TIMESTAMP(created) < 14400 + karma*60 AND transport IN (1,2,3) UNION ALL SELECT id, 0 AS created, lat, lon, 0 AS karma, 0 AS alignment, type, `text` FROM objects WHERE `stop` IS NULL OR `stop`>CURRENT_TIMESTAMP() '; $result = $db->query($query); if ($db->errno !== 0) { $this->result = ErrorBuilder::dbError($db->error); return; } $list = array(); while ($row = $result->fetch_assoc()) { $list[] = array('id' => (int) $row['id'], 'created' => (int) $row['created'], 'lat' => (double) $row['lat'], 'lon' => (double) $row['lon'], 'karma' => (int) $row['karma'], 'alignment' => (int) $row['alignment'], 'type' => $row['type'], 'text' => $row['text']); } $db->close(); $this->result = array("error" => "OK", "data" => $list); }
static function getFromEnglish($english) { $mysqli = DB::getConn(); $sql = "select * from english where english='{$english}'"; $result = DB::getResult($sql, $mysqli); $arr = array(); while ($array = $result->fetch_assoc()) { $arr[] = $array; } DB::close($mysqli, null, $result); return $arr; }
function vote() { if (isset($_GET['dir']) && isset($_GET['did'])) { $d = new Diff(); if ($d->populateDiff($_GET['did'])) { if ($_GET['dir'] == 1 || $_GET['dir'] == -1) { $db = new DB(); $db->query("SELECT * FROM `rating` WHERE `did` = '{$_GET['did']}' AND `uid` = '{$_SESSION['uid']}';"); if ($db->numRows() == 0) { $db->query("INSERT INTO `rating` (`did`, `uid`, `rating`) VALUES ('{$_GET['did']}', '{$_SESSION['uid']}', '{$_GET['dir']}');"); } else { $db->query("UPDATE `rating` SET `rating` = '{$_GET['dir']}' WHERE `did` = '{$_GET['did']}' AND `uid` = '{$_SESSION['uid']}';"); } $db->close(); } } } }
function Document($row) { Module::Module($row); $cmd = Url::get('cmd'); require_once "forms/DocumentList.php"; switch ($cmd) { case 'delete': $this->add_form(new Deletedocument()); break; case 'change': $this->add_form(new PublicdocumentForm()); break; default: $id = (int) Url::get('id'); $azname = trim(URL::get("azname", '')); if ($id || $azname != '') { if ($id && $azname != '') { $document = DB::select("document", "id={$id}"); if ($document && $azname == AZLib::safe_title($document['title']) && $document['file_path']) { $file_src = DATA_PATH . "document/{$document['file_path']}"; if (file_exists(ROOT_PATH . $file_src)) { $ext = AZLib::getExtension($file_src); if ($ext && strlen($ext) <= 5) { $ext_app = substr($ext, 1); if ($document['status'] == 1 || User::haveAnyPermission(ADMIN_DOCUMENT)) { DB::query("UPDATE document SET down_num=down_num+1, time_last=" . TIME_NOW . " WHERE id={$id}"); DB::close(); header("Content-type: application/{$ext_app}"); header("Content-Disposition: attachment; filename=" . date("Y.m.d-H\\hi", $document['time_m']) . "-{$id}-{$azname}{$ext}"); readfile(ROOT_PATH . $file_src); exit; } } } } } header("HTTP/1.0 404 Not Found"); echo "<h1>404 - Not Found!<br />Return to <a href='" . WEB_ROOT . "'>" . WEB_NAME . "</a></h1>"; exit; } $this->add_form(new ListdocumentForm()); break; } }
private function readPoint() { $db = new DB(); $query = 'SELECT userid, created, lat, lng, karma, alignment, transport FROM mototimes_events WHERE id=?'; $stmt = $db->prepare($query); $stmt->bind_param('i', $this->id); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows == 0) { $this->setUpError("NO POINT", $this->id); } else { $data = $result->fetch_assoc(); $this->alignment = $data['alignment']; $this->transport = $data['transport']; $this->lat = $data['lat']; $this->lng = $data['lng']; $this->karma = $data['karma']; $this->owner = $data['userid']; $this->created = $data['created']; } $db->close(); }
static function Send($title, $message_text, $reciver, $is_system = 2) { if (!is_numeric($reciver)) { return; } $title = TextSave($title); $message_text = TextSave($message_text, 2); $db = new DB(); $db->connect("PM"); $Row = $db->fetch_assoc($db->execute("SELECT `login` FROM `users` WHERE `id` = '{$reciver}'")); if (empty($Row['login'])) { return; } if ($is_system == 2) { global $player; //AuthReset(); $sender = $player['id']; } else { $sender = 0; } $db->execute("INSERT INTO `pm` (`title`,`message`,`reciver`,`sender`,`time`) VALUES ('{$title}','{$message_text}','{$reciver}'," . $sender . "," . time() . ")"); $db->close(); }
function populateDiff($did) { $db = new DB(); $db->query("SELECT * FROM diff WHERE did = {$did};"); if ($db->numRows() > 0) { $diffinfo = $db->fetchRow(); $this->did = $did; $this->sid = $diffinfo[1]; $this->uid = $diffinfo[2]; $this->toreplace = $diffinfo[3]; $this->replacewith = $diffinfo[4]; $this->time = $diffinfo[5]; $this->ip = long2ip($diffinfo[7]); $this->comment = $diffinfo[6]; $db->query("SELECT SUM(rating) FROM rating WHERE did = {$this->did};"); $row = $db->fetchRow(); $this->rating = $row[0]; $db->close(); return true; } else { $db->close(); return false; } }
$action = Utilities::postOrNull('action'); $token = Utilities::postOrNull('token'); $rid = Utilities::postOrNull('rid'); $page = Utilities::postOrNull('page'); User::construct($rid, $token); if ($action == null) { Utilities::log("handler: Action is null " . User::toString(), Utilities::LOG_E); Ajax::sendError(); } switch ($action) { case Config::AJAX_ACTION_GENERATE_RID: $data = Ajax::generateRid(); break; case Config::AJAX_ACTION_GENERATE_NUMBER: $data = Ajax::generateNumber(); break; case Config::AJAX_ACTION_CHECK_RID: $data = Ajax::checkRid(); break; case Config::AJAX_ACTION_CHECK_USER: $data = Ajax::checkUser(); break; case Config::AJAX_ACTION_GET_PAGE: $data = Ajax::getPage($page); break; default: Utilities::log("Incorrect action {$action} " . User::toString(), Utilities::LOG_E); Ajax::sendError(); } DB::close(); exit($data);
/** * Créer les tables de la base d'une structure et les remplir * * @param void * @return void */ public static function DB_creer_remplir_tables_structure() { $tab_files = FileSystem::lister_contenu_dossier(CHEMIN_DOSSIER_SQL_STRUCTURE); foreach($tab_files as $file) { $extension = pathinfo($file,PATHINFO_EXTENSION); if($extension=='sql') { $requetes = file_get_contents(CHEMIN_DOSSIER_SQL_STRUCTURE.$file); DB::query(SACOCHE_STRUCTURE_BD_NAME , $requetes ); // Attention, sur certains LCS ça bloque au dela de 40 instructions MySQL (mais un INSERT multiple avec des milliers de lignes ne pose pas de pb). /* La classe PDO a un bug. Si on envoie plusieurs requêtes d'un coup ça passe, mais si on recommence juste après alors on récolte : "Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute." La seule issue est de fermer la connexion après chaque requête multiple en utilisant exceptionnellement la méthode ajouté par SebR suite à mon signalement : DB::close(nom_de_la_connexion); */ DB::close(SACOCHE_STRUCTURE_BD_NAME); } } }
$tab_eval[$DB_ROW['eleve_id']][$DB_ROW['item_id']][] = array('note' => $DB_ROW['note'], 'date' => $DB_ROW['date'], 'info' => $DB_ROW['info']); } } } } if (!count($tab_eval) && !$make_officiel) { exit('Aucune évaluation trouvée sur la période ' . $date_debut . ' ~ ' . $date_fin . ' selon les paramètres choisis !'); } // //////////////////////////////////////////////////////////////////////////////////////////////////// /* * Libérer de la place mémoire car les scripts de bilans sont assez gourmands. * Supprimer $DB_TAB ne fonctionne pas si on ne force pas auparavant la fermeture de la connexion. * SebR devrait peut-être envisager d'ajouter une méthode qui libère cette mémoire, si c'est possible... */ // //////////////////////////////////////////////////////////////////////////////////////////////////// DB::close(SACOCHE_STRUCTURE_BD_NAME); unset($DB_TAB); // //////////////////////////////////////////////////////////////////////////////////////////////////// // Tableaux et variables pour mémoriser les infos ; dans cette partie on ne fait que les calculs (aucun affichage) // //////////////////////////////////////////////////////////////////////////////////////////////////// $tab_etat = array('A' => 'v', 'VA' => 'o', 'NA' => 'r'); $tab_score_eleve_item = array(); // Retenir les scores / élève / matière / synthese / item $tab_infos_acquis_eleve = array(); // Retenir les infos (nb A - VA - NA) / élève / matière / synthèse + total $tab_infos_detail_synthese = array(); // Retenir le détail du contenu d'une synthèse / élève / synthèse $nb_syntheses_total = 0; /* On renseigne : $tab_score_eleve_item[$eleve_id][$matiere_id][$synthese_ref][$item_id]
$fd = fopen($toppath, "rb"); $UR = fread($fd, filesize($toppath)); fclose($fd); } elseif (file_exists($topgpath)) { $fd = fopen($topgpath, "rb"); $UR = fread($fd, filesize($topgpath)); fclose($fd); } $DbLink = new DB(); $Room = stripslashes($R); if ($UR == "") { $UR = L_DEFAULT_TOPIC_1; } $DbLink->query("SELECT room FROM " . C_USR_TBL . " WHERE username='******'"); list($BR) = $DbLink->next_record(); $DbLink->close(); $botcontrol = "botfb/" . $R . ".txt"; if ((file_exists($botcontrol) || $BR == $R) && C_BOT_PUBLIC) { $Expl .= BOT_TIPS; $Ex .= '<b>' . C_BOT_NAME . '</b> - ' . $Expl . ''; } elseif ($BR != "" && C_BOT_PUBLIC) { $Expl .= sprintf(BOT_PRIV_TIPS, $BR); $Ex .= '<b>' . C_BOT_NAME . '</b> - ' . $Expl . ''; } elseif (file_exists($botcontrol) && !C_BOT_PUBLIC) { $Expl .= BOT_PRIVONLY_TIPS; $Ex .= '<b>' . C_BOT_NAME . '</b> - ' . $Expl . ''; } else { $Ex .= ''; } $UR = stripslashes($UR); # if (C_POPUP_LINKS || eregi('target="_blank"></a>',$UR))
function UserStatus($id, $boolean) { $Online_Block = '<span class="label label-success">Онлайн</span>'; $Offiline_Block = '<span class="label label-danger">Оффлайн</span>'; if ($boolean == false) { $db = new DB(); $db->connect("UserStatus1"); $Row = $db->fetch_assoc($db->execute("SELECT `last_online` FROM `users` WHERE `id` = '{$id}'")); if (empty($Row['last_online'])) { $db->close(); return $Offiline_Block; } else { $db->close(); $time = time() - (int) $Row['last_online']; if ($time <= 300) { return $Online_Block; } else { return $Offiline_Block; } } } else { $db = new DB(); $db->connect("UserStatus2"); $Row = $db->fetch_assoc($db->execute("SELECT `last_online` FROM `users` WHERE `id` = '{$id}'")); if (empty($Row['last_online'])) { $db->close(); return false; } else { $db->close(); return true; } } }
/** * Extract all variables necessary for processing the request. */ function updateRecord($in) { $precondition = array("url", "cap", "cat", "xid"); $required_vars_are_present = checkVarsPresent($in, $precondition); if ($required_vars_are_present) { // open the DB $DB = new DB(); $binds = null; $meta["action"] = "update"; $parent = isset($in["parent"]) ? $in["parent"] : null; $binds = array($in["url"], $in["cap"], $in["cat"], $parent, $in["xid"]); $query = "UPDATE entries SET url=?, cap=?, cat=?, parent=? WHERE id=?"; // update the record in the database $rows = $DB->query($query, $binds); // check if the update really worked and feedback to $meta properly $meta["ok"] = count($rows) > 0; $id = trim($in["xid"]); $query = "SELECT * FROM entries WHERE id={$id};"; $rows = $DB->query($query); $DB->close(); return array("rows" => $rows, "meta" => $meta); } else { $results = []; $results["meta"]["ok"] = false; $results["meta"]["status"] = 400; $results["meta"]["msg"] = "Bad Request"; $results["meta"]["feedback"] = "That request doesn't appear to have all the necessary fields for it to work."; $results["meta"]["developer"] = "See the required and received fields in json metadata to evaluate what was omitted."; $results["meta"]["received"] = $in; $results["meta"]["required"] = $precondition; } }
/** * 更新表中的属性值 */ public function updateParamById($tableName, $atrName, $atrValue, $key, $value) { $sql = "UPDATE " . $tableName . " set "; for ($i = 0; $i < sizeof($atrName); $i++) { $sql .= $atrName[$i] . "='" . $atrValue[$i] . "'"; if ($i < sizeof($atrName) - 1) { $sql .= ','; } } $sql .= ' where ' . $key . "=" . $value; $db = new DB(); $db->open(); if (mysql_query($sql)) { //$key不要单引号 $db->close(); return true; } else { $db->close(); return false; } }
if ($sghosts != "" && ghosts_in($userclosed, $sghosts, $Charset) || C_HIDE_ADMINS && ($statusclosed == "a" || $statusclosed == "t") || C_HIDE_MODERS && $statusclosed == "m") { } else { $ChatM->query("INSERT INTO " . C_MSG_TBL . " VALUES ('" . $usertype . "', '" . $userroom . "', 'SYS exit', '', '" . time() . "', '', 'sprintf(L_CLOSED_ROM, \"(" . $when . ") " . $userclosed . "\")', '', '')"); } if (C_EN_STATS) { $ChatM->query("UPDATE " . C_STS_TBL . " SET seconds_away=seconds_away+({$usertime}-last_away), longest_away=IF({$usertime}-last_away < longest_away, longest_away, {$usertime}-last_away), last_away='' WHERE (stat_date=FROM_UNIXTIME(last_away,'%Y-%m-%d') OR stat_date=FROM_UNIXTIME(last_in,'%Y-%m-%d')) AND room='{$userroom}' AND username='******' AND last_away!='0'"); $ChatM->query("UPDATE " . C_STS_TBL . " SET seconds_in=seconds_in+({$usertime}-last_in), longest_in=IF({$usertime}-last_in < longest_in, longest_in, {$usertime}-last_in), last_in='' WHERE stat_date=FROM_UNIXTIME(last_in,'%Y-%m-%d') AND room='{$userroom}' AND username='******' AND last_in!='0'"); } $ChatM->query("DELETE FROM " . C_USR_TBL . " WHERE username='******'"); $CleanUsrTbl = $ChatM->affected_rows() > 0; $highpath = "botfb/" . $userclosed; // file is in DIR "botfb" and called "username" if (file_exists($highpath)) { unlink($highpath); } // checks to see if user file exists. // if it does delete it. $botpath = "botfb/" . $userclosed . ".txt"; // file is in DIR "botfb" and called "username.txt" if (file_exists($botpath)) { unlink($botpath); } // checks to see if user file exists. } $ChatM->close(); // Clean users table of disconnected users if booting is disabled if (!C_CHAT_BOOT && !$CleanUsrTbl) { $Chat->query("DELETE FROM " . C_USR_TBL . " WHERE username != '" . C_BOT_NAME . "' AND (u_time<'" . (time() - C_USR_DEL * 60) . "' OR (status='k' AND u_time<'" . (time() - 20) . "'))"); $CleanUsrTbl = $Chat->affected_rows() > 0; $Chat->close(); }
if ($PWD_Hash == md5(stripslashes($pmc_password)) || $PWD_Hash == $pmc_password) { // Ensure the one who lauch the admin.php script is really admin if (isset($MUST_BE_ADMIN) && $perms != "admin") { $Error = L_ERR_USR_11; } else { $do_not_login = true; $_SESSION["adminlogged"] = true; } } } else { if (isset($perms)) { unset($perms); } } $DbLink4Login->clean_results(); $DbLink4Login->close(); } // If no login yet entered if (!isset($do_not_login) || !$do_not_login) { // Special cache instructions for IE5+ $CachePlus = ""; #if (ereg("MSIE [56789]", (isset($HTTP_USER_AGENT)) ? $HTTP_USER_AGENT : getenv("HTTP_USER_AGENT"))) $CachePlus = ", pre-check=0, post-check=0, max-age=0"; if (stripos(isset($HTTP_USER_AGENT) ? $HTTP_USER_AGENT : getenv("HTTP_USER_AGENT"), "MSIE") !== false) { $CachePlus = ", pre-check=0, post-check=0, max-age=0"; } $now = gmdate('D, d M Y H:i:s') . ' GMT'; header("Expires: {$now}"); header("Last-Modified: {$now}"); header("Cache-Control: no-cache, must-revalidate" . $CachePlus); header("Pragma: no-cache"); header("Content-Type: text/html; charset={$Charset}");
<?php require $_SERVER['DOCUMENT_ROOT'] . '/system.php'; $db = new DB(); $db->connect("NEWS_Launcher"); $query = $db->execute("SELECT * FROM `news` ORDER BY `id` DESC LIMIT 10"); $db->close(); $html = ''; while ($data = $db->fetch_assoc($query)) { $html .= '<div class="news-block"><div class="news-title"><a target="_blank" href="/news/id/' . $data['id'] . '/">' . $data['title'] . '</a><p class="date">' . ToNTime($data['date']) . '</p></div> <div class="news-text">' . $data['text'] . '</div><div class="news-bottom"><p class="left">Автор: <a target="_blank" href="/profile/' . $data['author_id'] . '/">' . IDToLogin($data['author_id']) . '</a></p> <p class="right"><a target="_blank" href="/news/id/' . $data['id'] . '/">Подробнее...</a></p></div></div>'; } if (empty($html)) { $html = "<center style='color:#FFF'>Новостей нет :c</center>"; } ?> <!DOCTYPE html> <html> <head> <title>DarkMine Новости</title> <meta charset="utf-8"> <style type="text/css"> *{ margin: 0px; } a:visited { color: #2980b9; } a { color: #2980b9;
/** * DB_STRUCTURE_creer_remplir_tables_structure * * @param string $dossier_requetes './_sql/structure/' ou './_sql/webmestre/' * @return void */ function DB_STRUCTURE_creer_remplir_tables_structure($dossier_requetes) { $tab_files = Lister_Contenu_Dossier($dossier_requetes); foreach($tab_files as $file) { $extension = pathinfo($file,PATHINFO_EXTENSION); if($extension=='sql') { $requetes = file_get_contents($dossier_requetes.$file); DB::query(SACOCHE_STRUCTURE_BD_NAME , $requetes ); /* La classe PDO a un bug. Si on envoie plusieurs requêtes d'un coup ça passe, mais si on recommence juste après alors on récolte : "Cannot execute queries while other unbuffered queries are active. Consider using PDOStatement::fetchAll(). Alternatively, if your code is only ever going to run against mysql, you may enable query buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute." La seule issue est de fermer la connexion après chaque requête multiple en utilisant exceptionnellement la méthode ajouté par SebR suite à mon signalement : DB::close(nom_de_la_connexion); */ DB::close(SACOCHE_STRUCTURE_BD_NAME); } } }
$colornamedest_tag = "<FONT color=" . $colornamedest . ">"; unset($colornamedest); } elseif (C_ITALICIZE_POWERS) { if ($perms_dest == "admin" && $Dest != C_BOT_NAME || $perms_dest == "topmod") { $colornamedest_tag = "<FONT color=" . COLOR_CA . ">"; } elseif ($perms_dest == "moderator") { $colornamedest_tag = "<FONT color=" . COLOR_CM . ">"; } else { $colornamedest_tag = "<FONT color=" . COLOR_CD . ">"; } } else { $colornamedest_tag = "<FONT color=" . COLOR_CD . ">"; } $colorname_endtag = "</FONT>"; $colornamedest_endtag = "</FONT>"; $DbColor->close(); } else { $colorname_tag = ""; $colornamedest_tag = ""; $colorname_endtag = ""; $colornamedest_endtag = ""; } $NewMsg = "<tr align=texttop valign=top>"; $Time = strftime(L_SHORT_DATETIME, $Time + C_TMZ_OFFSET * 60 * 60); if (stristr(PHP_OS, 'win') && (strstr($L, "chinese") || strstr($L, "korean") || strstr($L, "japanese"))) { $Time = str_replace(" ", "", $Time); } $NewMsg .= "<td width=\"1%\" nowrap=\"nowrap\">" . $Time . "</td><td width=\"1%\" nowrap=\"nowrap\">" . $Room . "</td>"; if ($Dest != " *" && $User != "SYS room" && $User != "SYS image" && $User != "SYS video" && $User != "SYS utube" && $User != "SYS math" && $User != "SYS topic" && $User != "SYS topic reset" && substr($User, 0, 8) != "SYS dice") { $User = $colorname_tag . "[" . special_char($User, $Latin1) . "]" . $colorname_endtag; if ($Dest != "") {