function _icl_ts_mysqldump($mysql_database) { global $wpdb; $upload_folder = wp_upload_dir(); $dump_tmp_file = $upload_folder['path'] . '/' . '__icl_mysqldump.sql'; $fp = @fopen($dump_tmp_file, 'w'); if (!$fp) { $fp = fopen('php://output', 'w'); ob_start(); } $sql = "SHOW TABLES LIKE '" . str_replace('_', '\\_', $wpdb->prefix) . "%';"; $result = mysql_query($sql); if ($result) { while ($row = mysql_fetch_row($result)) { //_icl_ts_mysqldump_table_structure($row[0]); //_icl_ts_mysqldump_table_data($row[0]); _icl_ts_backup_table($row[0], 0, $fp); } } else { echo "/* no tables in {$mysql_database} */\n"; } mysql_free_result($result); fclose($fp); if (file_exists($dump_tmp_file)) { $data = file_get_contents($dump_tmp_file); @unlink($dump_tmp_file); } else { $data = ob_get_contents(); ob_end_clean(); } return $data; }
function fetch_data() { global $include_path; global $PMBuserid; $this->info = array(); $this->users = array(); $requete_users = "SELECT userid, username FROM users order by username "; $res_users = mysql_query($requete_users); $this->all_users = array(); while (list($this->all_userid, $all_username) = mysql_fetch_row($res_users)) { $this->all_users[] = array($this->all_userid, $all_username); } if (!$this->id) { $this->users[] = $PMBuserid; return; } $req = "select * from mailtpl where id_mailtpl=" . $this->id; $resultat = mysql_query($req); if (mysql_num_rows($resultat)) { $r = mysql_fetch_object($resultat); $this->info['id'] = $r->id_mailtpl; $this->info['name'] = $r->mailtpl_name; $this->info['objet'] = $r->mailtpl_objet; $this->info['tpl'] = $r->mailtpl_tpl; $this->info['users'] = $r->mailtpl_users; } $this->users = explode(" ", $this->info['users']); // printr($this->info[28]); }
function changePassword($username, $currentpassword, $newpassword, $newpassword2) { global $seed; if (!valid_username($username) || !user_exists($username)) { return false; } if (!valid_password($newpassword) || $newpassword != $newpassword2) { return false; } // we get the current password from the database $query = sprintf("SELECT password FROM login WHERE username = '******' LIMIT 1", mysql_real_escape_string($username)); $result = mysql_query($query); $row = mysql_fetch_row($result); // compare it with the password the user entered, if they don't match, we return false, he needs to enter the correct password. if ($row[0] != sha1($currentpassword . $seed)) { return false; } // now we update the password in the database $query = sprintf("update login set password = '******' where username = '******'", mysql_real_escape_string(sha1($newpassword . $seed)), mysql_real_escape_string($username)); if (mysql_query($query)) { return true; } else { return false; } return false; }
public function getLoveHistory($page, $justUser = false) { $front = Frontend::getInstance(); $page--; $l = $this->getLimit() * $page; $where = ''; $sql = "SELECT count(*) " . "FROM " . LOVE_LOVE; $res = mysql_query($sql); $row = mysql_fetch_row($res); $loves = $row[0]; $sql = "SELECT count(*) " . "FROM " . LOVE_LOVE . " " . "WHERE " . LOVE_LOVE . ".receiver = '" . $front->getUser()->getUsername() . "' " . "OR " . LOVE_LOVE . ".giver = '" . $front->getUser()->getUsername() . "' " . ($sql .= $justUser ? '' : "OR " . LOVE_LOVE . ".company_id = '" . $front->getUser()->getCompany_id() . "' "); $sql .= $where . " " . "ORDER BY id DESC"; $res = mysql_query($sql); $row = mysql_fetch_row($res); $count = $row[0]; $cPages = ceil($count / $this->getLimit()); $sql = "SELECT id,giver,receiver,why,private,TIMESTAMPDIFF(SECOND,at,NOW()) as delta " . "FROM " . LOVE_LOVE . " " . "WHERE " . LOVE_LOVE . ".receiver = '" . $front->getUser()->getUsername() . "' " . "OR " . LOVE_LOVE . ".giver = '" . $front->getUser()->getUsername() . "' "; $sql .= $justUser ? '' : "OR " . LOVE_LOVE . ".company_id = '" . $front->getUser()->getCompany_id() . "' "; $sql .= $where . " " . "ORDER BY id DESC " . "LIMIT " . $l . "," . $this->getLimit(); $res = mysql_query($sql); // Construct json for history $this->pages = array(array($page, $cPages, number_format($loves))); for ($i = 1; $row = mysql_fetch_assoc($res); $i++) { $givernickname = getNickName($row['giver']); $givernickname = !empty($givernickname) ? $givernickname : $row['giver']; $receivernickname = getNickName($row['receiver']); $receivernickname = !empty($receivernickname) ? $receivernickname : $row['receiver']; $why = $row['why']; if ($row['private']) { $why .= " (love sent quietly)"; } $history[] = array("id" => $row['id'], "giver" => $row['giver'], "giverNickname" => $givernickname, "receiver" => $row['receiver'], "receiverNickname" => $receivernickname, "why" => $why, "delta" => Utils::relativeTime($row['delta'])); } return $history; }
function show_abts($dbh) { global $msg; global $charset; print "<table>\n\t\t<tr>\n\t\t<th>" . $msg[103] . "</th>\n\t\t<th style='display:none'>" . $msg["type_abts_prepay"] . "</th>\n\t\t<th style='display:none'>" . $msg["type_abts_prepay_dflt"] . "</th>\n\t\t<th>" . $msg["type_abts_tarif"] . "</th>\n\t\t<th>" . $msg["type_abts_caution"] . "</th>\n\t\t</tr>"; // affichage du tableau des utilisateurs $requete = "SELECT id_type_abt, type_abt_libelle, prepay, prepay_deflt_mnt,tarif,caution FROM type_abts ORDER BY type_abt_libelle,id_type_abt"; $res = mysql_query($requete, $dbh); $nbr = mysql_num_rows($res); $parity = 1; for ($i = 0; $i < $nbr; $i++) { $row = mysql_fetch_row($res); if ($row[2]) { $prepay = "x"; } if ($parity % 2) { $pair_impair = "even"; } else { $pair_impair = "odd"; } $parity += 1; $tr_javascript = " onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='{$pair_impair}'\" onmousedown=\"document.location='./admin.php?categ=finance&sub=abts&action=modif&id={$row['0']}';\" "; print pmb_bidi("<tr class='{$pair_impair}' {$tr_javascript} style='cursor: pointer'><td>" . htmlentities($row[1], ENT_QUOTES, $charset) . "</td>\n\t\t\t<td style='text-align:center;display:none'>{$prepay}</td><td style='display:none'>" . $row[3] . "</td><td>" . $row[4] . "</td><td>" . $row[5] . "</td>\n\t\t\t\t\t\t</tr>"); } print "</table>\n\t\t<input class='bouton' type='button' value=\" " . $msg["type_abts_add"] . " \" onClick=\"document.location='./admin.php?categ=finance&sub=abts&action=add'\" />"; }
protected function loadInfo($vf1965a857bc285d26fe22023aa5ab50d = false) { if ($vf1965a857bc285d26fe22023aa5ab50d === false) { $vac5c74b64b4b8352ef2f181affb5ac2a = "SELECT id, name, data_type, is_multiple, is_unsigned FROM cms3_object_field_types WHERE id = '{$this->id}'"; $result = l_mysql_query($vac5c74b64b4b8352ef2f181affb5ac2a); if ($v56bd7107802ebe56c6918992f0608ec6 = l_mysql_error()) { throw new coreException($v56bd7107802ebe56c6918992f0608ec6); return false; } $vf1965a857bc285d26fe22023aa5ab50d = mysql_fetch_row($result); } if (list($vb80bb7740288fda1f201890375a60c8f, $vb068931cc450442b63f5b3d276ea4297, $v17f71d965fe9589ddbd11caf7182243e, $v96a76ec43956dac431b643cbd544dd08, $vf089d93c2ef0d088edadddb0028d548d) = $vf1965a857bc285d26fe22023aa5ab50d) { if (!self::isValidDataType($v17f71d965fe9589ddbd11caf7182243e)) { throw new coreException("Wrong data type given for filed type #{$this->id}"); return false; } $this->name = $vb068931cc450442b63f5b3d276ea4297; $this->data_type = $v17f71d965fe9589ddbd11caf7182243e; $this->is_multiple = (bool) $v96a76ec43956dac431b643cbd544dd08; $this->is_unsigned = (bool) $vf089d93c2ef0d088edadddb0028d548d; return true; } else { return false; } }
function AddItem($bookId, $container) { //This create an error //function can not detect connection $dbUser = "******"; $dbPass = ""; $dbName = "libraryDB"; $dbServer = "127.0.0.1"; // Connect to the database and return // true/false depending on whether or // not a connection could be made. $s = mysql_connect($dbServer, $dbUser, $dbPass); $d = mysql_select_db($dbName, $s); $result = mysql_query("select count(*) from list where cookieId = '" . bookListId() . "' and bookId = {$bookId}"); $row = mysql_fetch_row($result); $numRows = $row[0]; if ($numRows == 0) { // This item doesn't exist in the users cart, // we will add it with an insert query //This also creates an error //Is the problem that it can't access to the database? mysql_query("insert into list(cookieId, bookId, container) values('" . bookListId() . "', {$bookId}, {$container})"); } else { // This item already exists in the users cart, // we will update it instead print "Book already exists! "; echo "<br>"; } }
function fetch_row() { if (!$this->result) { die("Query not executed<br>"); } return mysql_fetch_row($this->result); }
function update_gateway_fee2($vars) { $invoice = mysql_fetch_row(mysql_query("SELECT `userid` FROM `tblinvoices` WHERE `id`='" . $vars[invoiceid] . "'")); $user = mysql_fetch_row(mysql_query("SELECT `currency` FROM `tblclients` WHERE `id`='" . $invoice[0] . "'")); $currency = mysql_fetch_row(mysql_query("SELECT `code` FROM `tblcurrencies` WHERE `id`='" . $user[0] . "'")); $paymentmethod = $vars['paymentmethod']; delete_query("tblinvoiceitems", "invoiceid='" . $vars[invoiceid] . "' and notes='gateway_fees'"); $result = select_query("tbladdonmodules", "setting,value", "setting='fee_2_" . $vars['paymentmethod'] . '_' . $currency[0] . "' or setting='fee_1_" . $vars[paymentmethod] . '_' . $currency[0] . "'"); while ($data = mysql_fetch_array($result)) { $params[$data['setting']] = $data['value']; } $fee1 = $params['fee_1_' . $paymentmethod . '_' . $currency[0]]; $fee2 = $params['fee_2_' . $paymentmethod . '_' . $currency[0]]; $total = InvoiceTotal($vars['invoiceid']); if ($total > 0) { $amountdue = $fee1 + $total * $fee2 / 100; if ($fee1 > 0 & $fee2 > 0) { $d = $fee1 . '+' . $fee2 . "%"; } elseif ($fee2 > 0) { $d = $fee2 . "%"; } elseif ($fee1 > 0) { $d = $fee1; } } if ($d) { insert_query("tblinvoiceitems", array("userid" => $_SESSION['uid'], "invoiceid" => $vars[invoiceid], "type" => "Fee", "notes" => "gateway_fees", "description" => getGatewayName2($vars['paymentmethod']) . " комиссия ({$d}) в " . $currency[0], "amount" => $amountdue, "taxed" => "0", "duedate" => "now()", "paymentmethod" => $vars[paymentmethod])); } updateInvoiceTotal($vars[invoiceid]); }
function resul($s = false) { if ($s === false) { $s = $this->result; } return mysql_fetch_row($s); }
function exec_query($gl_type, $sku) { $query = "SELECT SUM(`qty`) FROM `journal_item` where `gl_type` = '" . $gl_type . "' and `sku` = '" . $sku . "'"; $resu = mysql_query($query); $cant = mysql_fetch_row($resu); return $cant[0]; }
function datadump($table) { // <--- thx to mrwebmaster for function # Creo la variabile $result $result .= "# Dump of {$table} \n"; $result .= "# Dump DATE : " . date("d-M-Y") . "\n\n"; # Conto i campi presenti nella tabella $query = mysql_query("select * from {$table}"); $num_fields = @mysql_num_fields($query); # Conto il numero di righe presenti nella tabella $numrow = mysql_num_rows($query); # Passo con un ciclo for tutte le righe della tabella for ($i = 0; $i < $numrow; $i++) { $row = mysql_fetch_row($query); # Ricreo la tipica sintassi di un comune Dump $result .= "INSERT INTO " . $table . " VALUES("; # Con un secondo ciclo for stampo i valori di tutti i campi # trovati in ogni riga for ($j = 0; $j < $num_fields; $j++) { $row[$j] = addslashes($row[$j]); $row[$j] = ereg_replace("\n", "\\n", $row[$j]); if (isset($row[$j])) { $result .= "\"{$row[$j]}\""; } else { $result .= "\"\""; } if ($j < $num_fields - 1) { $result .= ","; } } # Chiudo l'istruzione INSERT $result .= ");\n"; } return $result . "\n\n\n"; }
public function getCol($col = 0) { while ($row = mysql_fetch_row($this->queryResult)) { $result[] = $row[$col]; } return $result; }
function check_login($user_id, $password) { session_destroy(); session_start(); $moodle_host = "127.0.0.1"; $moodle_port = "3306"; $moodle_user = "******"; $moodle_db = "moodle"; $moodle_pass = ""; $moodle_conn = mysql_connect($moodle_host . ":" . $moodle_port, $moodle_user, $moodle_pass); $moodle_salt = '-Y9-h0;),c@<i)D~*i/j7.pD6lh/,B'; $password = md5($password . $moodle_salt); $ret = false; $moodle_pre = "mdl_"; $sql = "select password from " . $moodle_pre . "user where username='******'"; if ($moodle_conn) { mysql_select_db($moodle_db, $moodle_conn); $result = mysql_query($sql, $moodle_conn); $row = mysql_fetch_row($result); if ($row && $password == $row[0]) { $ret = $user_id; } } return $ret; }
public function count_active_games() { $sql = "\r\n\t\t\tSELECT COUNT(*)\r\n\t\t\tFROM `games`\r\n\t\t\tWHERE `games`.`status` = 'active'\r\n\t\t\t AND (`games`.`active_user_id` = {$this->id} OR `games`.`inactive_user_id` = {$this->id})\r\n\t\t"; $result = mysql_query($sql) or die('arjsdfjdj' . mysql_error()); $row = mysql_fetch_row($result); return $row[0]; }
function ViewLog() { global $db_host, $db_user, $db_pass, $db_name; global $total, $page, $size, $view_size; global $client_count_info, $client_from_info, $client_where_info, $client_select_info, $client_order_info; $page = intval($_GET["page"]); $role = $_GET["role"]; $Conn = mysql_connect($db_host, $db_user, $db_pass); mysql_query("SET NAMES 'GBK'"); mysql_select_db($db_name, $Conn); $role = mysql_escape_string($role); $qs = "{$client_count_info} {$client_from_info} {$client_where_info} and clc.role_name = '{$role}'"; $result = mysql_query($qs); $row = mysql_fetch_row($result); $total = intval($row[0]); $b = $page * $size - $size; $e = $size; printf("<p>查询条件是角色名: <b>{$role}</b><p>"); $qs = "{$client_select_info} {$client_from_info} {$client_where_info} and clc.role_name = '{$role}' {$client_order_info} limit {$b}, {$e}"; $result = mysql_query($qs); $content = array(); while ($row = mysql_fetch_row($result)) { $content[count($content)] = $row; } printf(GetClientLogHTML($content)); }
function show_empr_procs($idemprcaddie) { global $msg; global $PMBuserid; global $dbh; print "<hr />{$msg['caddie_select_proc']}<br /><table>"; // affichage du tableau des procédures if ($PMBuserid != 1) { $where = " and (autorisations='{$PMBuserid}' or autorisations like '{$PMBuserid} %' or autorisations like '% {$PMBuserid} %' or autorisations like '% {$PMBuserid}') "; } $requete = "SELECT idproc, type, name, requete, comment, autorisations, parameters FROM empr_caddie_procs WHERE type='SELECT' {$where} ORDER BY name "; $res = mysql_query($requete, $dbh); $nbr = mysql_num_rows($res); $parity = 1; for ($i = 0; $i < $nbr; $i++) { $row = mysql_fetch_row($res); $rqt_autorisation = explode(" ", $row[5]); if (array_search($PMBuserid, $rqt_autorisation) !== FALSE || $PMBuserid == 1) { if ($parity % 2) { $pair_impair = "even"; } else { $pair_impair = "odd"; } $parity += 1; if (preg_match_all("|!!(.*)!!|U", $row[3], $query_parameters)) { $action = "form_proc"; } else { $action = "add_item"; } $tr_javascript = " onmouseover=\"this.className='surbrillance'\" onmouseout=\"this.className='{$pair_impair}'\" onmousedown=\"document.location='./circ.php?categ=caddie&sub=gestion&quoi=selection&moyen=selection&action={$action}&id={$row['0']}&idemprcaddie={$idemprcaddie}';\" "; print pmb_bidi("<tr class='{$pair_impair}' {$tr_javascript} style='cursor: pointer'>\n\t\t\t\t\t<td>\n\t\t\t\t\t\t<strong>{$row['2']}</strong><br />\n\t\t\t\t\t\t<small>{$row['4']} </small>\n\t\t\t\t\t\t</td>\n\t\t\t\t</tr>"); } } print "</table>"; }
function doCheckUpdate($v, $d) { $db = openConnection(); $sql = ""; $user_id = ""; $str = "{\"result\":\"0\",\"version_code\":\"0\",\"version_name\":\"\",\"file\":\"\",\"size\":\"\",\"desc\":\"\"}"; if (!empty($d)) { $sql = "select id from root_tools_update_user where device='{$d}'"; $result = query($db, $sql); while (list($id) = mysql_fetch_row($result)) { $user_id = $id; break; } if ($user_id != "") { $sql = "select * from root_tools_update where ver_code > {$v} order by id desc limit 0,1"; $result = query($db, $sql); } } else { $sql = "select * from root_tools_update where tag=0 and ver_code > {$v} order by id desc limit 0,1"; $result = query($db, $sql); } closeConnection($db); while (list($id, $name, $ver_code, $size, $filename, $update_desc) = mysql_fetch_row($result)) { $str = "{\"result\":\"1\",\"version_code\":\"{$ver_code}\",\"version_name\":\"{$name}\",\"file\":\"{$filename}\",\"size\":\"{$size}\",\"desc\":" . json_encode($update_desc) . "}"; break; } return $str; }
function get_metar($station, $always_use_cache = 0) { /* * Looks in the database, and fetches a new metar is nesceary. If * $always_use_cache is true, then it ignores the timestamp of the * METAR and just returns it. * * You should pass a ICAO station identifier, eg. 'EKYT' for * Aalborg, Denmark. */ global $conn, $dbmMetar, $dbmTimestamp; $query = "SELECT metar, UNIX_TIMESTAMP(timestamp) FROM " . $db_prefix . "metars WHERE station = '{$station}'"; $result = mysql_query($query); @($metar_rows = mysql_num_rows($result)); /* this suppresses a php error message if the metars db has not yet been created. */ if (isset($metar_rows)) { /* found station */ list($metar, $timestamp) = mysql_fetch_row($result); } if (isset($metar)) { /* found station */ if ($always_use_cache || $timestamp > time() - 3600) { /* We have asked explicit for a cached metar, or the metar is * still fresh. */ return $metar; } else { /* We looked in the cache, but the metar was too old. */ return fetch_metar($station, 0); } } else { /* The station is new - we fetch a new METAR */ return fetch_metar($station, 1); } }
function check_db($dbhost, $dbuser, $dbpw, $dbname, $tablepre) { if (!function_exists('mysql_connect') && !function_exists('mysqli_connect')) { show_msg('undefine_func', 'mysql_connect', 0); } $mysqlmode = function_exists('mysql_connect') ? 'mysql' : 'mysqli'; $link = $mysqlmode == 'mysql' ? @mysql_connect($dbhost, $dbuser, $dbpw) : new mysqli($dbhost, $dbuser, $dbpw); if (!$link) { $errno = $mysqlmode == 'mysql' ? mysql_errno() : mysqli_errno(); $error = $mysqlmode == 'mysql' ? mysql_error() : mysqli_error(); if ($errno == 1045) { show_msg('database_errno_1045', $error, 0); } elseif ($errno == 2003) { show_msg('database_errno_2003', $error, 0); } else { show_msg('database_connect_error', $error, 0); } } else { if ($query = $mysqlmode == 'mysql' ? @mysql_query("SHOW TABLES FROM {$dbname}") : $link->query("SHOW TABLES FROM {$dbname}")) { if (!$query) { return false; } while ($row = $mysqlmode == 'mysql' ? mysql_fetch_row($query) : $query->fetch_row()) { if (preg_match("/^{$tablepre}/", $row[0])) { return false; } } } } return true; }
function check_db($dbhost, $dbuser, $dbpw, $dbname, $tablepre) { if (!function_exists('mysql_connect')) { show_msg('undefine_func', 'mysql_connect', 0); } if (!@mysql_connect($dbhost, $dbuser, $dbpw)) { $errno = mysql_errno(); $error = mysql_error(); if ($errno == 1045) { show_msg('database_errno_1045', $error, 0); } elseif ($errno == 2003) { show_msg('database_errno_2003', $error, 0); } else { show_msg('database_connect_error', $error, 0); } } else { if ($query = @mysql_query("SHOW TABLES FROM {$dbname}")) { while ($row = mysql_fetch_row($query)) { if (preg_match("/^{$tablepre}/", $row[0])) { return false; } } } } return true; }
/** * @param string $pid Process ID * @return array Process Data */ public function get($pid) { if (isset($this->_cached[$pid])) { return $this->_cached[$pid]; } if (preg_match('/[^a-zA-Z0-9_]/', $pid)) { throw new Oops_Process_Exception("Invalid pid", OOPS_PROCESS_EXCEPTION_INVALID_PID); } $r = Oops_Sql::Query("SELECT `class`, `currentState` FROM {$this->_tableProcesses} WHERE pid = '{$pid}'"); switch (mysql_num_rows($r)) { case 0: throw new Oops_Process_Exception("Process not found", OOPS_PROCESS_EXCEPTION_NOT_FOUND); case 1: $ret = mysql_fetch_assoc($r); $ret['variables'] = array(); $r = Oops_Sql::Query("SELECT name, class, id, serialized FROM {$this->_tableProcessData} WHERE pid = '{$pid}'"); while ((list($name, $class, $id, $serialized) = mysql_fetch_row($r)) !== false) { try { $ret['variables'][$name] = $this->_decomposeData($class, $id, $serialized); } catch (Exception $e) { /** * Something was wrong, throw exception? */ // @todo Make it clear with exceptions throw $e; } } $this->_cached[$pid] = $ret; return $ret; default: throw new Oops_Process_Exception("Process storage error", OOPS_PROCESS_EXCEPTION_NOT_FOUND); } }
/** * Find pixels coords and draw these on the current image * * @param integer $image Number of the image (to be used with $this->height) * @return boolean Success **/ function drawPixels($image) { $limit = 0; do { /** Select with limit */ $result = mysql_query(sprintf($this->query, $image * $this->height, ($image + 1) * $this->height - 1) . ' LIMIT ' . $limit . ',' . $this->limit); if ($result === false) { return $this->raiseError('Query failed: ' . mysql_error()); } $count = mysql_num_rows($result); while ($click = mysql_fetch_row($result)) { $x = (int) $click[0]; $y = (int) ($click[1] - $image * $this->height); if ($x < 0 || $x >= $this->width) { continue; } /** Apply a calculus for the step, with increases the speed of rendering : step = 3, then pixel is drawn at x = 2 (center of a 3x3 square) */ $x -= $x % $this->step - $this->startStep; $y -= $y % $this->step - $this->startStep; /** Add 1 to the current color of this pixel (color which represents the sum of clicks on this pixel) */ $color = imagecolorat($this->image, $x, $y) + 1; imagesetpixel($this->image, $x, $y, $color); $this->maxClicks = max($this->maxClicks, $color); if ($image === 0) { /** Looking for the maximum height of click */ $this->maxY = max($y, $this->maxY); } } /** Free resultset */ mysql_free_result($result); $limit += $this->limit; } while ($count === $this->limit); return true; }
function fetchRow($res) { if (!$res) { return false; } return mysql_fetch_row($res); }
function ModifyHolidays() { global $txt, $context, $db_prefix, $scripturl; loadTemplate('ManageCalendar'); $context['page_title'] = $txt['manage_holidays']; $context['sub_template'] = 'manage_holidays'; // Submitting something... if (isset($_REQUEST['delete']) && !empty($_REQUEST['holiday'])) { checkSession(); foreach ($_REQUEST['holiday'] as $id => $value) { $_REQUEST['holiday'][$id] = (int) $id; } // Now the IDs are "safe" do the delete... db_query("\n\t\t\tDELETE FROM {$db_prefix}calendar_holidays\n\t\t\tWHERE ID_HOLIDAY IN (" . implode(', ', $_REQUEST['holiday']) . ")\n\t\t\tLIMIT " . count($_REQUEST['holiday']), __FILE__, __LINE__); updateStats('calendar'); } // Total amount of holidays... for pagination. $request = db_query("\n\t\tSELECT COUNT(*)\n\t\tFROM {$db_prefix}calendar_holidays", __FILE__, __LINE__); list($context['holidayCount']) = mysql_fetch_row($request); mysql_free_result($request); $context['page_index'] = constructPageIndex($scripturl . '?action=managecalendar;sa=holidays', $_REQUEST['start'], $context['holidayCount'], 20); // Now load up all the holidays into a lovely large array. $request = db_query("\n\t\tSELECT ID_HOLIDAY, YEAR(eventDate) AS year, MONTH(eventDate) AS month, DAYOFMONTH(eventDate) AS day, title\n\t\tFROM {$db_prefix}calendar_holidays\n\t\tORDER BY title\n\t\tLIMIT {$_REQUEST['start']}, 20", __FILE__, __LINE__); $context['holidays'] = array(); while ($row = mysql_fetch_assoc($request)) { $context['holidays'][] = array('id' => $row['ID_HOLIDAY'], 'date' => $row['day'] . ' ' . $txt['months'][$row['month']] . ' ' . ($row['year'] == '0004' ? '(' . $txt['every_year'] . ')' : $row['year']), 'title' => $row['title']); } mysql_free_result($request); }
function query($query) { $kondisi = false; // only select if (!preg_match("/^[\\s]*select*/i", $query)) { $query = "select " . $query; } // filter count query if (preg_match("/^select[\\s]distinct/si", $query)) { //if distinct //if yes $query_temp = preg_replace("/select (.*) from (.*)/si", "select count(\\1) from \\2", $query); } else { //if no $query_temp = preg_replace("/select .* from (.*)/si", "select count(*) from \\1", $query); } $result_temp = mysql_query($query_temp) or die("Query Error"); list($this->p["count"]) = mysql_fetch_row($result_temp); // total page $this->p["total_page"] = ceil($this->p["count"] / $this->p["baris"]); // filter page if ($this->page <= 1) { $this->page = 1; } elseif ($this->page > $this->p["total_page"]) { $this->page = $this->p["total_page"]; } // awal data yang diambil $this->p["mulai"] = $this->page * $this->p["baris"] - $this->p["baris"]; $query = $query . " limit " . $this->p["mulai"] . "," . $this->p["baris"]; $query = mysql_query($query) or die("Query Error"); $this->query = $query; }
function get_table_rows($table) { $temp = mysql_query("SELECT SQL_CALC_FOUND_ROWS * FROM {$table} LIMIT 1"); $result = mysql_query("SELECT FOUND_ROWS()"); $total = mysql_fetch_row($result); return $total[0]; }
function evalLoggedUser($id, $u, $p) { $sql = "SELECT password FROM users WHERE id='{$id}' AND username='******' AND activated='1' LIMIT 1"; $query = mysql_query($sql); $row = mysql_fetch_row($query); $db_pass_pregd = preg_replace('#[^a-z0-9]#i', '', $row[0]); $sql = "SELECT ip FROM users WHERE id='{$id}' AND username='******' AND activated='1' LIMIT 1"; $query = mysql_query($sql) or die(mysql_error()); $numrows = mysql_num_rows($query); if ($numrows > 0 && $p == $db_pass_pregd) { //If wanted to log out because of a session left open without action, could destroy here. See older files for ie $_SESSION['LAST_ACT'] = time(); //Avoid attacks like Session Fixation if (!isset($_SESSION['CREATION'])) { $_SESSION['CREATION'] = time(); } else { if (time() - $_SESSION['CREATION'] > 1800) { // session started more than 30 minutes ago session_regenerate_id(true); // change session ID for the current session an invalidate old session ID $_SESSION['CREATION'] = time(); // update creation time } } //** Don't need to update last_act here anymore. See js/update-status.js **/ //$sql = "UPDATE users SET last_act=now() WHERE id='$id' LIMIT 1"; //$query = mysql_query($sql); return true; } }
private function loadTypes() { $vb99eb979e6f6efabc396f777b503f7e7 = cacheFrontend::getInstance(); $vda80b9ab86c2d00b85de0cf003cb3e6e = $vb99eb979e6f6efabc396f777b503f7e7->loadData('hierarchy_types'); if (!is_array($vda80b9ab86c2d00b85de0cf003cb3e6e)) { $vac5c74b64b4b8352ef2f181affb5ac2a = "SELECT `id`, `name`, `title`, `ext` FROM `cms3_hierarchy_types` ORDER BY `name`, `ext`"; $result = l_mysql_query($vac5c74b64b4b8352ef2f181affb5ac2a); $vda80b9ab86c2d00b85de0cf003cb3e6e = array(); while (list($vb80bb7740288fda1f201890375a60c8f) = $vf1965a857bc285d26fe22023aa5ab50d = mysql_fetch_row($result)) { $vda80b9ab86c2d00b85de0cf003cb3e6e[$vb80bb7740288fda1f201890375a60c8f] = $vf1965a857bc285d26fe22023aa5ab50d; } $vb99eb979e6f6efabc396f777b503f7e7->saveData('hierarchy_types', $vda80b9ab86c2d00b85de0cf003cb3e6e, 3600); } foreach ($vda80b9ab86c2d00b85de0cf003cb3e6e as $vb80bb7740288fda1f201890375a60c8f => $vf1965a857bc285d26fe22023aa5ab50d) { $v599dcce2998a6b40b1e38e8c6006cb0a = $vb99eb979e6f6efabc396f777b503f7e7->load($vb80bb7740288fda1f201890375a60c8f, 'element_type'); if ($v599dcce2998a6b40b1e38e8c6006cb0a instanceof iUmiHierarchyType == false) { try { $v599dcce2998a6b40b1e38e8c6006cb0a = new umiHierarchyType($vb80bb7740288fda1f201890375a60c8f, $vf1965a857bc285d26fe22023aa5ab50d); } catch (privateException $ve1671797c52e15f763380b45e841ec32) { continue; } $vb99eb979e6f6efabc396f777b503f7e7->save($v599dcce2998a6b40b1e38e8c6006cb0a, 'element_type'); } $this->types[$vb80bb7740288fda1f201890375a60c8f] = $v599dcce2998a6b40b1e38e8c6006cb0a; } return true; }
function show_alliance_rankings() { global $PHP_SELF; $counter = 1; table_text_open("text"); table_text_design("Alliance rankings by score", "", "", "5", "head"); table_text_close(); table_text_open("text"); table_text_design("<br>", "", "", "5", "text"); table_text_close(); table_text_open("head"); table_text_design("Place", "", "", "", "head"); table_text_design("Alliance", "", "", "", "head"); table_text_design("Empires", "", "", "", "head"); table_text_design("Average Score", "", "", "", "head"); table_text_design("Total Score", "", "", "", "head"); table_text_close(); $sth = mysql_query("select sum(u.score),sum(u.score)/count(u.id),a.name,a.color,count(u.id), a.id from users as u,alliance as a where u.alliance=a.id and u.alliance!=0 group by u.alliance order by 1 desc"); if (!$sth) { show_error("Database failure!"); return 0; } while ($score = mysql_fetch_row($sth)) { table_text(array($counter++, "<a href=\"database.php?act=info_alliance&aid=" . $score[5] . "\"><font color=\"" . $score[3] . "\">" . $score[2] . "</font></a>", $score[4], round($score[1]), $score[0]), "", "", "", "text"); } table_text(array("<a href=\"#top\">Top</a>"), "center", "", "5", "head"); }