function get_by_id($id, $conn) { $query = query("\n\t\tSELECT * FROM posts WHERE id = :id LIMIT 1", array("id" => $id), $conn); if ($query) { return $query->fetchAll(); } }
function get_products($page, $per_page, $short = false) { $start = abs($page * $per_page); $fields = $short ? 'product.id' : '*'; if (isset($_GET['sort'])) { $sort_query = $_GET['sort']; } elseif (!empty($_POST['sort'])) { $sort_query = $_POST['sort']; } else { $sort_query = 'id_asc'; } $cache_key = build_cache_key($page, $sort_query); $result = get_cache($cache_key); if (!$result) { $sort_data = get_sort($sort_query); $sort = $sort_data['sort']; $sort_field = $sort_data['sort_field']; if ($sort_field == 'id') { $q = 'select ' . $fields . ' from product JOIN (SELECT ' . $sort_field . ' FROM product ' . $sort . ' LIMIT ' . $start . ',' . $per_page . ') as b ON b.id = product.id'; } elseif ($sort_field == 'price') { $q = 'select ' . $fields . ' from product JOIN (SELECT id, price FROM product ' . $sort . ' LIMIT ' . $start . ',' . $per_page . ') as b ON b.id = product.id'; } $res = query($q); } else { $q = 'select ' . $fields . ' from product where id in(' . $result . ');'; $res = query($q); } return $res; }
function netbios_setup($name) { $infp = XNODE_getpathbytarget("", "inf", "uid", $name, 0); $stsp = XNODE_getpathbytarget("/runtime", "inf", "uid", $name, 0); if ($infp == "" || $stsp == "") { SHELL_info($_GLOBALS["START"], "infsvcs_setup: (" . $name . ") not exist."); SHELL_info($_GLOBALS["STOP"], "infsvcs_setup: (" . $name . ") not exist."); return; } $addrtype = query($stsp . "/inet/addrtype"); $ipaddr = query($stsp . "/inet/ipv4/ipaddr"); $devnam = query($stsp . "/devnam"); $hostname = query("device/hostname"); startcmd("hostname " . $hostname . "\n"); if ($ipaddr == "" || $devnam == "") { return; } if ($addrtype == "ipv4" || $addrtype == "ipv6") { //jef add + for support use shareport.local to access shareportmobile $web_file_access = query("/webaccess/enable"); if ($web_file_access == 1) { startcmd("netbios -i " . $devnam . " -r " . $hostname . " -r shareport.local -r shareport &\n"); startcmd("llmnresp -i " . $devnam . " -r " . $hostname . " -r shareport.local -r shareport &\n"); } else { //jef add - startcmd("netbios -i " . $devnam . " -r " . $hostname . " &\n"); startcmd("llmnresp -i " . $devnam . " -r " . $hostname . " &\n"); } stopcmd("killall netbios"); stopcmd("killall llmnresp"); } }
function GetId($username) { $query = "SELECT id FROM USERS WHERE username = '******'"; $result = query($query); $row = mysqli_fetch_array($result); return $row[0]; }
public function exclui($obj) { foreach ($this->get_related_objects() as $obj) { $obj->exclui(); } return query('DELETE FROM ' . $this->get_table_name() . ' WHERE id = ' . $this->id); }
function check_dmz_setting($path, $addrtype, $lan_ip, $mask) { if (query($path . "/enable") == "1") { anchor($path); $hostid = query("hostid"); if ($hostid == "") { set_result("FAILED", $path . "/hostid", i18n("DMZ IP Address cannot be empty.")); return "FAILED"; } if ($hostid <= 0) { set_result("FAILED", $path . "/hostid", i18n("DMZ IP Address is not a valid IP Address.")); return "FAILED"; } if ($addrtype == "ipv4") { $dmzip = ipv4ip($lan_ip, $mask, $hostid); if (INET_validv4host($dmzip, $mask) == 0) { set_result("FAILED", $path . "/hostid", i18n("DMZ IP Address is not a valid IP Address.")); return "FAILED"; } } } else { set($path . "/enable", "0"); } return "OK"; }
function dhcps_setcfg($prefix, $svc) { /* set dhcpX of inf */ $inf = cut($svc, 1, "."); $svc = tolower(cut($svc, 0, ".")); $base = XNODE_getpathbytarget("", "inf", "uid", $inf, 0); $dhcps_uid = query($prefix . "/inf/" . $svc); set($base . "/" . $svc, $dhcps_uid); /* copy the dhcp profile. */ $uid = INF_getinfinfo($inf, $svc); $spath = XNODE_getpathbytarget($prefix . "/" . $svc, "entry", "uid", $dhcps_uid, 0); $dhcps = XNODE_getpathbytarget("/" . $svc, "entry", "uid", $uid, 0); if ($dhcps != "") { if ($svc == "dhcps4") { copy_dhcps4($spath, $dhcps); } else { if ($svc == "dhcps6") { $_GLOBALS["SETCFG_DHCPS6_SRC_PATH"] = $spath; $_GLOBALS["SETCFG_DHCPS6_DST_PATH"] = $dhcps; $b = "/htdocs/phplib/setcfg/libs"; dophp("load", $b . "/dhcps6.php"); } } } else { TRACE_error("SETCFG/DHCPS: no dhcps entry for [" . $uid . "] found!"); } }
function ShowEquipTable($query) { $numRows = mysqli_num_rows(query($query)); echo "<br><p class='center-align'>" . ($numRows > 0 ? $numRows : "Nenhum") . " " . ($numRows > 1 ? "items." : "item.") . "</p>"; PrintEquipTable(query($query)); echo "<div class=\"divider\"></div>"; }
function check_qos_setting($path) { $enable = query($path . "/device/qos/enable"); $auto = query($path . "/device/qos/autobandwidth"); if ($enable == "1") { if ($auto == "0") { if (isdigit(query($path . "/inf/bandwidth/upstream")) == "0" || query($path . "/inf/bandwidth/upstream") > 102400 || query($path . "/inf/bandwidth/upstream") < 1) { set_result("FAILED", $path . "/inf/bandwidth/upstream", i18n("The input uplink speed is invalid.")); return "FAILED"; } else { // Remove the leading zeros. $upstream_dec = strtoul(query($path . "/inf/bandwidth/upstream"), 10); set($path . "/inf/bandwidth/upstream", $upstream_dec); } } else { set($path . "/device/qos/autobandwidth", "1"); } $type = query($path . "/inf/bandwidth/type"); if ($type == "AUTO" || $type == "ADSL" || $type == "CABLE") { } else { set_result("FAILED", $path . "/inf/bandwidth/type", i18n("Unsupported Connection type be assigned.")); return "FAILED"; } } else { set($path . "/device/qos/enable", "0"); } return "OK"; }
public function build($settings, $board_name) { global $config, $board; openBoard($board_name); $recent_images = array(); $recent_posts = array(); $stats = array(); $query = query(sprintf("SELECT *, `id` AS `thread_id`,\n\t\t\t\t(SELECT COUNT(`id`) FROM ``posts_%s`` WHERE `thread` = `thread_id`) AS `reply_count`,\n\t\t\t\t(SELECT SUM(`num_files`) FROM ``posts_%s`` WHERE `thread` = `thread_id` AND `num_files` IS NOT NULL) AS `image_count`,\n\t\t\t\t'%s' AS `board` FROM ``posts_%s`` WHERE `thread` IS NULL ORDER BY `bump` DESC", $board_name, $board_name, $board_name, $board_name, $board_name)) or error(db_error()); while ($post = $query->fetch(PDO::FETCH_ASSOC)) { $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], $post['thread'] ? $post['thread'] : $post['id']); $post['board_name'] = $board['name']; if ($post['embed'] && preg_match('/^https?:\\/\\/(\\w+\\.)?(?:youtube\\.com\\/watch\\?v=|youtu\\.be\\/)([a-zA-Z0-9\\-_]{10,11})(&.+)?$/i', $post['embed'], $matches)) { $post['youtube'] = $matches[2]; } if (isset($post['files'])) { $files = json_decode($post['files']); if ($files[0]->file == 'deleted') { continue; } $post['file'] = $config['uri_thumb'] . $files[0]->thumb; } $recent_posts[] = $post; } $required_scripts = array('js/jquery.min.js', 'js/jquery.mixitup.min.js', 'js/catalog.js'); foreach ($required_scripts as $i => $s) { if (!in_array($s, $config['additional_javascript'])) { $config['additional_javascript'][] = $s; } } file_write($config['dir']['home'] . $board_name . '/catalog.html', Element('themes/catalog/catalog.html', array('settings' => $settings, 'config' => $config, 'boardlist' => createBoardlist(), 'recent_images' => $recent_images, 'recent_posts' => $recent_posts, 'stats' => $stats, 'board' => $board_name, 'link' => $config['root'] . $board['dir']))); }
function vote($id) { $link = connect(); $query = "UPDATE quotes SET score = score +1 WHERE id={$id}"; query($query); close($link); }
function putMailSettings($data) { // кнопка «Сохранить» if ($data) { foreach ($data as $data_key => $data_value) { $sql = "UPDATE ntn_settings SET value = '{$data_value}' WHERE param = '{$data_key}'"; // file_put_contents('sql',$sql."\n",FILE_APPEND); query($sql); $sql = <<<EOD INSERT INTO ntn_settings (param, value) SELECT '{$data_key}', '{$data_value}' FROM DUAL WHERE NOT EXISTS ( SELECT 1 FROM ntn_settings WHERE param = '{$data_key}' AND value = '{$data_value}' ) EOD; // file_put_contents('sql',$sql."\n",FILE_APPEND); query($sql); } } return true; // почему-то эта функция всегда должна возвращать true, хотя ниже может быть и другой вариант развития событий }
function sConfig($key, $value) { $key = db_escape($key); $value = db_escape($value); $sql = "REPLACE INTO " . PREF . "config\n\t\tVALUE ('{$key}', '{$value}')"; query($sql); }
function getPersonalInfoById($id) { $sql = "SELECT * FROM personal WHERE id='{$id}'"; $res = query($sql); $result = mysql_fetch_object($res); return $result; }
/** * get a specific route informations (name, color and stations along the route) * from cache (MySQL database) based on route number. */ function query_route($route_number) { // get a specific route informations (name, color and stations along the route) // from cache (MySQL database) based on route number. Store in array $query $query = query("SELECT * FROM routes WHERE number = ?", $route_number); // iterate each row, there is actually only 1 row in $query. // 4 row in $query[0]: number, name, color and config foreach ($query[0] as $key => $value) { if ($key === 'config') { // return an array of strings, each of which is a substring of string $value // formed by splitting it by ',', each element in the array is a station along // the route $config = explode(',', $value); foreach ($config as $station_abbr) { // query current station $query = query("SELECT * FROM stations WHERE abbr = ?", $station_abbr); // build associative array $station = []; foreach ($query[0] as $key => $value) { $station[$key] = $value; } $route['config'][] = $station; } } else { // $route['numbr'] =.., $route['color'] =..,$route['name'] =.., $route[$key] = $value; } } // $route is an array with 3 basic elements and 1 element('config') that itself is a big array return $route; }
function login() { global $error; if (isset($_GET['error'])) { error_handler($_GET['error']); } if (!isset($_POST['username']) or !isset($_POST['password'])) { return false; } $username = $_POST['username']; $password = $_POST['password']; if (empty($username) and empty($password)) { $error = 'You did not fill out all forms. Do so please.'; return false; } if (!filter_var($username, FILTER_VALIDATE_EMAIL)) { $error = 'This is not an email, please fill in an email-address.'; return false; } $user = query('SELECT id FROM users WHERE email = "' . $username . '" AND password = "******" '); if ($_POST["vercode"] != $_SESSION["vercode"] or $_SESSION["vercode"] == '') { echo '<strong>Wrong verification code.</strong>'; } else { if (count($user) < 1) { $error = 'Wrong email, password or verification code.'; return false; } } $_SESSION['id'] = $user[0]['id']; header('Location: ../views/resultpage.php'); exit; }
public static function news($settings) { global $config; $query = query("SELECT * FROM `news` ORDER BY `time` DESC") or error(db_error()); $news = $query->fetchAll(PDO::FETCH_ASSOC); return Element('themes/categories/news.html', array('settings' => $settings, 'config' => $config, 'news' => $news)); }
static function new_image($image) { global $_zp_exifvars; $entry_locale = getUserLocale(); $languages = generateLanguageList(); $languageTags = $element = array(); $candidates = self::getTaggingItems(); foreach ($candidates as $key) { if ($meta = $image->get($key)) { setupCurrentLocale('en_US'); $en_us = $element[] = exifTranslate($meta); foreach ($languages as $language) { setupCurrentLocale($language); $xlated = exifTranslate($meta); if ($xlated != $en_us) { // the string has a translation in this language $element[] = $xlated; $languageTags[$language] = $xlated; } } } } setupCurrentLocale($entry_locale); $element = array_unique(array_merge($image->getTags(), $element)); $image->setTags($element); $image->save(); foreach ($languageTags as $language => $tag) { $sql = 'UPDATE ' . prefix('tags') . ' SET `language`=' . db_quote($language) . ' WHERE `name`=' . db_quote($tag) . ' AND `language`=NULL OR `language` LIKE ""'; query($sql, false); } return $image; }
function ShowManutTable($query) { $numRows = mysqli_num_rows(query($query)); echo "<div class=\"divider\"></div>"; echo "<br>" . ($numRows > 0 ? $numRows : "Nenhuma") . " " . ($numRows > 1 ? "manutenções." : "manutenção."); PrintTable(query($query)); }
function tearDown() { // Don't use naked queries outside of a model layer elsewhere. query("delete from password_reset_requests where nonce = '777777' or nonce = '77778877' or nonce = '7777777' or nonce = :nonce or _account_id = :id", [':nonce' => isset($this->nonce) ? $this->nonce : null, ':id' => $this->account_id]); TestAccountCreateAndDestroy::purge_test_accounts(); query("delete from password_reset_requests where nonce = '777777' or nonce = '77778877' or nonce = '7777777' or nonce = :nonce or _account_id = :id", [':nonce' => isset($this->nonce) ? $this->nonce : null, ':id' => $this->account_id]); }
function setup() { $sql = "CREATE TABLE IF NOT EXISTS mopclass (" . setupIddBase() . " name VARCHAR(64) NOT NULL DEFAULT ''," . " ord INT NOT NULL DEFAULT 0, INDEX(ord)" . ") ENGINE = MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci"; query($sql); $sql = "CREATE TABLE IF NOT EXISTS mopclasscontrol (" . " cid INT NOT NULL, id INT NOT NULL," . " leg TINYINT NOT NULL, ord TINYINT NOT NULL," . " PRIMARY KEY(cid, id, leg, ord), " . " ctrl INT NOT NULL DEFAULT 0" . ") ENGINE = MyISAM"; query($sql); $sql = "CREATE TABLE IF NOT EXISTS mopcompetition (" . setupIddBase() . " name VARCHAR(64) NOT NULL DEFAULT ''," . " date DATE NOT NULL DEFAULT '2013-11-04'," . " organizer VARCHAR(64) NOT NULL DEFAULT ''," . " homepage VARCHAR(128) NOT NULL DEFAULT ''" . ") ENGINE = MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci"; query($sql); $sql = "CREATE TABLE IF NOT EXISTS mopcompetitor (" . setupIddBase() . setupBaseCompetitor() . ", tstat TINYINT NOT NULL DEFAULT 0," . " it INT NOT NULL DEFAULT 0," . " timestamp INT NOT NULL DEFAULT 0" . ") ENGINE = MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci"; query($sql); $sql = "CREATE TABLE IF NOT EXISTS mopcontrol (" . setupIddBase() . " name VARCHAR(64) NOT NULL DEFAULT ''" . ") ENGINE = MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci"; query($sql); $sql = "CREATE TABLE IF NOT EXISTS moporganization (" . setupIddBase() . " name VARCHAR(64) NOT NULL DEFAULT ''" . ") ENGINE = MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci"; query($sql); $sql = "CREATE TABLE IF NOT EXISTS mopradio (" . " cid INT NOT NULL, id INT NOT NULL," . " ctrl INT NOT NULL," . " PRIMARY KEY(cid, id, ctrl), " . " rt INT NOT NULL DEFAULT 0," . " timestamp INT NOT NULL DEFAULT 0" . ") ENGINE = MyISAM"; query($sql); $sql = "CREATE TABLE IF NOT EXISTS mopteam (" . setupIddBase() . setupBaseCompetitor() . ") ENGINE = MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci"; query($sql); $sql = "CREATE TABLE IF NOT EXISTS mopteammember (" . " cid INT NOT NULL, id INT NOT NULL," . " leg TINYINT NOT NULL, ord TINYINT NOT NULL," . " PRIMARY KEY(cid, id, leg, ord), " . " rid INT NOT NULL DEFAULT 0" . ") ENGINE = MyISAM"; query($sql); $sql = "CREATE TABLE IF NOT EXISTS resultblog (" . " rcid int(11) NOT NULL," . " timestamp timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP," . " text varchar(256) CHARACTER SET utf8 NOT NULL" . ") ENGINE = MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci"; query($sql); $sql = "CREATE TABLE IF NOT EXISTS `resultclass` (\n `rcid` int(11) NOT NULL,\n `cid` int(11) NOT NULL default '0',\n `id` int(11) NOT NULL,\n `sid` int(11) NOT NULL,\n `panel` tinyint(2) NOT NULL default '1',\n KEY `rcid` (`rcid`),\n KEY `cid` (`cid`),\n KEY `id` (`id`),\n KEY `sid` (`sid`)\n ) ENGINE = MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci"; query($sql); $sql = "CREATE TABLE IF NOT EXISTS `resultconfig` (\n `rcid` int(11) NOT NULL,\n `name` varchar(64) character set utf8 NOT NULL,\n `active` tinyint(1) NOT NULL default '0' COMMENT '1=active',\n PRIMARY KEY (`rcid`)\n ) ENGINE = MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci"; query($sql); $sql = "CREATE TABLE IF NOT EXISTS `resultradio` (\n `idsender` tinyint(3) unsigned NOT NULL,\n `idreceiver` tinyint(3) unsigned NOT NULL,\n `senderbattery` smallint(6) unsigned NOT NULL,\n `rxlevel` int(10) NOT NULL,\n `timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP\n ) ENGINE = MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci"; query($sql); $sql = "CREATE TABLE IF NOT EXISTS `resultradioconfig` (\n `srcid` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'screen radio competition id',\n `srcname` varchar(30) NOT NULL,\n `srcmap` varchar(120) NOT NULL,\n `srcx0` double NOT NULL DEFAULT '0',\n `srcy0` double NOT NULL DEFAULT '0',\n `srcx1` double NOT NULL DEFAULT '100',\n `srcy1` double NOT NULL DEFAULT '100',\n PRIMARY KEY (`srcid`)\n ) ENGINE = MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci AUTO_INCREMENT=1 ;"; query($sql); $sql = "CREATE TABLE IF NOT EXISTS `resultradioposition` (\n `srcid` int(10) unsigned NOT NULL,\n `radioid` int(10) unsigned NOT NULL,\n `radiox` double NOT NULL,\n `radioy` double NOT NULL\n ) ENGINE = MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci"; query($sql); $sql = "CREATE TABLE IF NOT EXISTS `resultscreen` (\n `rcid` int(11) NOT NULL,\n `sid` int(11) NOT NULL,\n `cid` int(11) NOT NULL DEFAULT '0',\n `style` varchar(128) DEFAULT 'co2016-04-01s.css',\n `title` varchar(128) DEFAULT 'Title',\n `titlesize` tinyint(4) DEFAULT '24',\n `titlecolor` varchar(6) DEFAULT '000000',\n `subtitle` varchar(128) DEFAULT NULL,\n `subtitlesize` tinyint(4) DEFAULT '16',\n `subtitlecolor` varchar(6) DEFAULT '000000',\n `titleleftpict` varchar(128) DEFAULT NULL,\n `titlerightpict` varchar(128) DEFAULT NULL,\n `panelscount` tinyint(2) DEFAULT '2' COMMENT 'Number of panels (1 to 4)',\n `panel1content` tinyint(4) DEFAULT '2' COMMENT '1=picture, 2=text, 3=html, 4=start, 5=result, 6=summary, 7=blog, 8=slides',\n `panel1mode` tinyint(2) DEFAULT '1',\n `panel1tm_count` int(10) unsigned NOT NULL DEFAULT '2',\n `panel1alternate` tinyint(2) DEFAULT '0',\n `panel1pict` varchar(128) DEFAULT NULL,\n `panel1txt` varchar(512) DEFAULT NULL,\n `panel1txtsize` tinyint(4) DEFAULT '12',\n `panel1txtcolor` varchar(6) DEFAULT '000000',\n `panel1html` varchar(128) DEFAULT NULL,\n `panel1firstline` int(10) unsigned NOT NULL DEFAULT '1',\n `panel1fixedlines` tinyint(4) NOT NULL DEFAULT '3',\n `panel1scrolledlines` tinyint(4) NOT NULL DEFAULT '17',\n `panel1scrolltime` tinyint(4) NOT NULL DEFAULT '3',\n `panel1scrollbeforetime` tinyint(4) NOT NULL DEFAULT '50',\n `panel1scrollaftertime` tinyint(4) NOT NULL DEFAULT '50',\n `panel1updateduration` int(11) NOT NULL DEFAULT '10',\n `panel1lastrefresh` int(11) NOT NULL DEFAULT '0',\n `panel1lastredraw` int(11) NOT NULL DEFAULT '0',\n `panel2content` tinyint(2) DEFAULT '5' COMMENT '1=picture, 2=text, 3=html, 4=start, 5=result, 6=summary, 7=blog, 8=slides',\n `panel2mode` tinyint(2) DEFAULT '1',\n `panel2tm_count` int(10) unsigned NOT NULL DEFAULT '2',\n `panel2alternate` tinyint(2) DEFAULT '0',\n `panel2pict` varchar(128) DEFAULT NULL,\n `panel2txt` varchar(512) DEFAULT NULL,\n `panel2txtsize` tinyint(4) DEFAULT '12',\n `panel2txtcolor` varchar(6) DEFAULT '000000',\n `panel2html` varchar(128) DEFAULT NULL,\n `panel2firstline` int(10) unsigned NOT NULL DEFAULT '1',\n `panel2fixedlines` tinyint(4) NOT NULL DEFAULT '3',\n `panel2scrolledlines` tinyint(4) NOT NULL DEFAULT '17',\n `panel2scrolltime` tinyint(4) NOT NULL DEFAULT '3' COMMENT 'en 1/10s',\n `panel2scrollbeforetime` tinyint(4) NOT NULL DEFAULT '50' COMMENT 'en 0.1s',\n `panel2scrollaftertime` tinyint(4) NOT NULL DEFAULT '50' COMMENT 'en 0.1s',\n `panel2updateduration` int(11) NOT NULL DEFAULT '10',\n `panel2lastrefresh` int(11) NOT NULL DEFAULT '0',\n `panel2lastredraw` int(11) NOT NULL DEFAULT '0',\n `panel3content` tinyint(2) DEFAULT '5' COMMENT '1=picture, 2=text, 3=html, 4=start, 5=result, 6=summary, 7=blog, 8=slides',\n `panel3mode` tinyint(2) DEFAULT '1',\n `panel3tm_count` int(10) unsigned NOT NULL DEFAULT '2',\n `panel3alternate` tinyint(2) DEFAULT '0',\n `panel3pict` varchar(128) DEFAULT NULL,\n `panel3txt` varchar(512) DEFAULT NULL,\n `panel3txtsize` tinyint(4) DEFAULT '12',\n `panel3txtcolor` varchar(6) DEFAULT '000000',\n `panel3html` varchar(128) DEFAULT NULL,\n `panel3firstline` int(10) unsigned NOT NULL DEFAULT '1',\n `panel3fixedlines` tinyint(4) NOT NULL DEFAULT '3',\n `panel3scrolledlines` tinyint(4) NOT NULL DEFAULT '17',\n `panel3scrolltime` tinyint(4) NOT NULL DEFAULT '3' COMMENT 'en 1/10s',\n `panel3scrollbeforetime` tinyint(4) NOT NULL DEFAULT '50' COMMENT 'en 0.1s',\n `panel3scrollaftertime` tinyint(4) NOT NULL DEFAULT '50' COMMENT 'en 0.1s',\n `panel3updateduration` int(11) NOT NULL DEFAULT '10',\n `panel3lastrefresh` int(11) NOT NULL DEFAULT '0',\n `panel3lastredraw` int(11) NOT NULL DEFAULT '0',\n `panel4content` tinyint(4) DEFAULT '5' COMMENT '1=picture, 2=text, 3=html, 4=start, 5=result, 6=summary, 7=blog, 8=slides',\n `panel4mode` tinyint(2) DEFAULT '1',\n `panel4tm_count` int(10) unsigned NOT NULL DEFAULT '2',\n `panel4alternate` tinyint(2) DEFAULT '0',\n `panel4pict` varchar(128) DEFAULT NULL,\n `panel4txt` varchar(512) DEFAULT NULL,\n `panel4txtsize` tinyint(4) DEFAULT '12',\n `panel4txtcolor` varchar(6) DEFAULT '000000',\n `panel4html` varchar(128) DEFAULT NULL,\n `panel4firstline` int(10) unsigned NOT NULL DEFAULT '1',\n `panel4fixedlines` tinyint(4) NOT NULL DEFAULT '3',\n `panel4scrolledlines` tinyint(4) NOT NULL DEFAULT '17',\n `panel4scrolltime` tinyint(4) NOT NULL DEFAULT '10',\n `panel4scrollbeforetime` tinyint(4) NOT NULL DEFAULT '50',\n `panel4scrollaftertime` tinyint(4) NOT NULL DEFAULT '80',\n `panel4updateduration` int(11) NOT NULL DEFAULT '3',\n `panel4lastrefresh` int(11) NOT NULL DEFAULT '0',\n `panel4lastredraw` int(11) NOT NULL DEFAULT '0',\n `refresh` int(11) NOT NULL DEFAULT '0',\n PRIMARY KEY (`rcid`,`sid`),\n KEY `cid` (`cid`)\n ) ENGINE = MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci"; query($sql); }
function get_by_id($id, $conn) { $query = query('SELECT *FROM posts WHERE id= :id', array('id' => $id), $conn); if ($query) { return $query->fetchAll(); } }
/** * Função que valida um usuário e senha * * @param string $usuario - O usuário a ser validado * @param string $senha - A senha a ser validada * * @return bool - Se o usuário foi validado ou não (true/false) */ function validaUsuario($login, $senha) { global $_SG; $cS = $_SG['caseSensitive'] ? 'BINARY' : ''; // Usa a função addslashes para escapar as aspas $nlogin = addslashes($login); $nsenha = addslashes($senha); // Monta uma consulta SQL (query) para procurar um usuário $sql = "SELECT `user_id`, `username`, `root` FROM `" . $_SG['tabela'] . "` WHERE " . $cS . " `login` = '" . $nlogin . "' AND " . $cS . " `password` = '" . $nsenha . "' LIMIT 1"; $resultado = mysqli_fetch_assoc(query($sql)); // Verifica se encontrou algum registro if (empty($resultado)) { // Nenhum registro foi encontrado => o usuário é inválido return false; } else { // Definimos dois valores na sessão com os dados do usuário $_SESSION['usuarioID'] = $resultado['user_id']; // Pega o valor da coluna 'id do registro encontrado no MySQL $_SESSION['usuarioNome'] = $resultado['username']; // Pega o valor da coluna 'nome' do registro encontrado no MySQL $_SESSION['usuarioRoot'] = $resultado['root']; // Verifica a opção se sempre validar o login if ($_SG['validaSempre'] == true) { // Definimos dois valores na sessão com os dados do login $_SESSION['usuarioLogin'] = $login; $_SESSION['usuarioSenha'] = $senha; } return true; } }
/** * 调用厂家列表 */ function get_changjia(){ $sql = query("select * form v9_changjia wher catid=9"); var_dump($sql); return $result; }
function tearDown() { TestAccountCreateAndDestroy::destroy(); if ($this->message_id !== null) { query('delete from messages where message_id = :id', [':id' => $this->message_id]); } }
function showUsage() { $tracking = "INSERT INTO access_records (user_agent, user_ip, user_request) VALUES ('" . $_SERVER['HTTP_USER_AGENT'] . "', '" . $_SERVER['REMOTE_ADDR'] . "', 'show usage')"; query($tracking); header("Location: http://assignment.two.quite.cool/"); die; }
function caching($comics_id, $zip_path, $image_ext) { $comic = zip_open($zip_path); if (!is_resource($comic)) { die("[ERR]ZIP_OPEN : " . $zip_path); } $inzip_path = ""; $count = 0; $files = null; $db = new SQLite3(DB); $db->exec("BEGIN DEFERRED;"); while (($entry = zip_read($comic)) !== false) { $inzip_path = zip_entry_name($entry); $cache_name = md5($zip_path . "/" . $inzip_path) . '.' . get_ext($inzip_path); // 画像か否か if (!is_image($inzip_path, $image_ext)) { continue; } $data = zip_entry_read($entry, zip_entry_filesize($entry)); $filepath = CACHE . '/' . $cache_name; file_put_contents($filepath, $data); $count++; query("INSERT INTO images (comics_id, page, filepath) VALUES (" . $comics_id . ", " . $count . ", '" . $filepath . "')", $db); } zip_close($comic); query("UPDATE comics SET pages = " . $count . " WHERE id = " . $comics_id, $db); $db->exec("COMMIT;"); }
protected function tearDown() { TestAccountCreateAndDestroy::destroy(); if ($this->quest) { query('delete from quests where quest_id = :id and quest_id > 1', [':id' => $this->quest->id()]); } }
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 IP6TLAN_build_command($name) { fwrite("w", $_GLOBALS["START"], "#!/bin/sh\n"); fwrite("a", $_GLOBALS["START"], "ip6tables -t filter -F FWD." . $name . "\n"); fwrite("a", $_GLOBALS["START"], "ip6tables -t filter -F INP." . $name . "\n"); $iptcmdFWD = "ip6tables -t filter -A FWD." . $name; $iptcmdIN = "ip6tables -t filter -A INP." . $name; $path = XNODE_getpathbytarget("", "inf", "uid", $name, 0); if ($path != "") { $fw = XNODE_get_var("FIREWALL6.USED"); $security = query("/device/simple_security"); if ($fw > 0) { fwrite("a", $_GLOBALS["START"], $iptcmdFWD . " -j FIREWALL\n"); } if ($security > 0) { fwrite("a", $_GLOBALS["START"], $iptcmdFWD . " -j FWD.SMPSECURITY." . $name . "\n"); } if ($fw > 0) { fwrite("a", $_GLOBALS["START"], $iptcmdFWD . " -j FIREWALL_POLICY\n"); } /* Outbound filter will be run faster to drop some packets. */ fwrite("a", $_GLOBALS["START"], $iptcmdFWD . " -j FWD.OBFILTER\n"); fwrite("a", $_GLOBALS["START"], $iptcmdIN . " -j INP.OBFILTER\n"); } fwrite("a", $_GLOBALS["START"], "exit 0\n"); fwrite("w", $_GLOBALS["STOP"], "#!/bin/sh\n"); fwrite("a", $_GLOBALS["STOP"], "ip6tables -t filter -F FWD." . $name . "\n"); fwrite("a", $_GLOBALS["STOP"], "ip6tables -t filter -F INP." . $name . "\n"); fwrite("a", $_GLOBALS["STOP"], "exit 0\n"); }