/** * 获取查询结果 * * @access protected * @param resource $query 数据库结果集资源符 * @param string|null 数据结果数组的索引key,为null则为自增key * @return array */ function _getAllResultFromQuery($query, $resultIndexKey = null) { $result = array(); if ($resultIndexKey) { while ($rt = $this->_db->fetch_array($query)) { $result[$rt[$resultIndexKey]] = $rt; } } else { while ($rt = $this->_db->fetch_array($query)) { $result[] = $rt; } } return $result; }
public function doindex() { global $_M; $jsrand = str_replace('.', '', $_M[config][metcms_v]) . $_M[config][met_patch]; if ($_M['config']['met_agents_type'] >= 2) { $met_admin_logo = "{$_M[url][site]}" . str_replace('../', '', $_M['config']['met_agents_logo_index']); $query = "SELECT * FROM {$_M['table']['config']} WHERE lang='{$_M['langset']}-metinfo'"; $result = DB::query($query); while ($list_config = DB::fetch_array($result)) { $lang_agents[$list_config['name']] = $list_config['value']; } $_M['word']['metinfo'] = $lang_agents['met_agents_name']; } // $toparr = get_adminnav(); if ($_M['config']['met_agents_type'] >= 2) { $met_admin_logo = "{$_M[url][site]}" . str_replace('../', '', $_M['config']['met_agents_logo_index']); $query = "SELECT * FROM {$_M['table']['config']} WHERE lang='{$_M['langset']}-metinfo'"; $result = DB::query($query); while ($list_config = DB::fetch_array($result)) { $lang_agents[$list_config['name']] = $list_config['value']; } $_M['word']['indexthanks'] = $lang_agents['met_agents_thanks']; $_M['word']['metinfo'] = $lang_agents['met_agents_name']; $_M['word']['copyright'] = $lang_agents['met_agents_copyright']; $_M['word']['oginmetinfo'] = $lang_agents['met_agents_depict_login']; $met_agents_display = "style=\"display:none\""; } else { $met_admin_logo = "{$_M[url][ui]}images/logo.png"; } // require $this->template('tem/index'); }
public function login($login, $pass) { //echo "construct " . $this->name[0]; if (!isset($_COOKIE['auth'])) { $db = new DB(); $sql = "SELECT *\n FROM users\n WHERE username = '******'"; $result = $db->query($sql); if ($row = $db->fetch_array($result)) { if ($row['password'] == md5($pass)) { $this->name = $login; $this->id = $row['id']; setcookie('user_id', $row['id']); setcookie('auth', md5(time())); setcookie('name', $this->name); } else { die('error login'); } } else { die('login error'); } } else { $this->name = $_COOKIE['name']; $this->id = $_COOKIE['user_id']; } return $this->name; }
function getAdverBenchs() { $benchs = array(); $query = $this->_db->query("SELECT * FROM pw_advert WHERE type=0"); while ($rs = $this->_db->fetch_array($query)) { list($title) = explode("~\t~", $rs['descrip']); $benchs[$rs['ckey']] = $title; } return $benchs; }
public static function allUsers() { $db = new DB(); $sql = "SELECT *\n FROM users"; $result = $db->query($sql); while ($row = $db->fetch_array($result)) { $users[] = ['id' => $row['id'], 'username' => $row['username']]; } return $users; }
function synlogin($user) { list($winduid, $windid, $windpwd) = explode("\t", $this->base->strcode($user, false)); header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"'); include ROOT_PATH . 'include/func/global.func.php'; DB::query("SELECT `uid`, `password` FROM `" . DB::table('members') . "` WHERE `ucuid`='{$winduid}'"); $UserFields = DB::fetch_array($query); if ($UserFields) { $auth = authcode("{$UserFields['password']}\t{$UserFields['uid']}", "ENCODE", '', 1209600); jsg_setcookie('sid', '', -311040000); jsg_setcookie('auth', $auth, 311040000); } }
public function testFetchArray() { $db = new DB(); $host = "localhost"; $user = "******"; $pass = ""; $db_name = "thankscard"; $db->db_connect($host, $user, $pass, $db_name); $sql = "SELECT * FROM user "; $rs = $db->db_query($sql); $user = $db->fetch_array($rs); print_r($user); echo 123; }
/** * 代理商配置语言修改 */ protected function load_agent_word($lang) { global $_M; if ($_M['config']['met_agents_type'] >= 2) { $query = "SELECT * FROM {$_M['table']['config']} WHERE lang='{$lang}-metinfo'"; $result = DB::query($query); while ($list_config = DB::fetch_array($result)) { $lang_agents[$list_config['name']] = $list_config['value']; } $_M['word']['indexthanks'] = $lang_agents['met_agents_thanks']; $_M['word']['metinfo'] = $lang_agents['met_agents_name']; $_M['word']['copyright'] = $lang_agents['met_agents_copyright']; $_M['word']['oginmetinfo'] = $lang_agents['met_agents_depict_login']; } }
public function get_group_list() { global $_M; if (!$this->grouplist[$this->lang]) { $this->grouplist[$this->lang] = cache::get("user/grouplist_{$this->lang}"); if (!$this->grouplist[$this->lang]) { $query = "SELECT * FROM {$_M['table']['user_group']} WHERE lang='{$this->lang}' order by access ASC"; $result = DB::query($query); while ($list = DB::fetch_array($result)) { $this->grouplist[$this->lang][$list['id']] = $list; } cache::put("user/grouplist_{$this->lang}", $this->grouplist[$this->lang]); } } return $this->grouplist[$this->lang]; }
public function get_outapp() { global $_M; $query = "SELECT * FROM {$_M['table']['app']} WHERE download=1 ORDER BY id DESC"; $result = DB::query($query); while ($list = DB::fetch_array($result)) { if (!$this->have_power($list['no'])) { continue; } $list = $this->standard($list); $app[$list[no]] = $list; } $query = "SELECT * FROM {$_M['table']['applist']} WHERE m_name != '' ORDER BY id DESC"; $result = DB::query($query); while ($list = DB::fetch_array($result)) { $list = $this->standard($list); $app[$list['no']] = $list; } return $app; }
<?php require_once dirname(__FILE__) . "/library/DB.php"; require_once dirname(__FILE__) . "/config/config.php"; session_start(); $db = new DB(); $db->db_connect(); if (isset($_SESSION["user"])) { header("Location: list.php"); } if (isset($_POST["eid"])) { $sql = "SELECT * FROM user WHERE (user_eid = '" . $db->db_escape_string($_POST["eid"]) . "' OR LOWER(user_nick_name) = LOWER('" . $db->db_escape_string($_POST["eid"]) . "')) AND active = 1"; $rs = $db->db_query($sql); $user = $db->fetch_array($rs); if (!$user) { $errors = "EID not exist"; } else { $_SESSION["user"] = $user; header("Location: list.php"); } } ?> <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/> <!-- Compiled and minified CSS --> <link rel="stylesheet" href="/bower_components/Materialize/dist/css/materialize.min.css"> <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <!--Let browser know website is optimized for mobile--> </head>
public function get_para_list($module, $class1, $class2, $class3) { global $_M; if (!$this->paralist[$module][$this->lang]) { $this->paralist[$module][$this->lang] = cache::get("para/paralist_{$module}_{$this->lang}"); if (!$this->paralist[$module][$this->lang]) { $query = "SELECT * FROM {$_M['table']['parameter']} WHERE module='{$module}' and lang='{$_M['lang']}' order by no_order ASC, id ASC"; $result = DB::query($query); while ($list = DB::fetch_array($result)) { if ($list['options']) { $lists = explode("\$|\$", $list['options']); $list['list'] = $lists; } $this->paralist[$module][$this->lang][$list['id']] = $list; } cache::put("para/paralist_{$module}_{$this->lang}", $this->paralist[$module][$this->lang]); } } $re = $this->paralist[$module][$this->lang]; $paralists = array(); foreach ($re as $val) { if ($val['class1']) { if ($val['class1'] == $class1) { if ($val['class2'] == 0 && $val['class3'] == 0) { $paralists[] = $val; } if ($val['class2'] && $val['class2'] == $class2 && $val['class3'] == 0) { $paralists[] = $val; } if ($val['class3'] && $val['class3'] == $class3) { $paralists[] = $val; } } } else { $paralists[] = $val; } } $re = $paralists; return $re; }
$result = $db->fetch_assoc($db->execute("SELECT * FROM `news` WHERE `id` = '{$id}'")); $db->close(); if (empty($result['id'])) { MessageSend(1, 'Новость не найдена!'); } $title = $result['title']; ob_start(); include SITE_ROOT . 'style/news/full.html'; $content_main = ob_get_clean(); } else { $title = 'Новости'; $menu_id = 'main'; $news_on_page = 6; $db = new DB(); $db->connect(); $news_count = $db->fetch_array($db->execute("SELECT COUNT(id) FROM `news`")); $total = ceil($news_count[0] / $news_on_page); if (empty($_GET['p'])) { $_GET['p'] = '1'; } $p = $_GET['p']; $p = TextSave($p); if (!ctype_digit($p) or $p > $total) { $p = "1"; } // формируем запрос $first = $p * $news_on_page - $news_on_page; $result = $db->execute("SELECT * FROM `news` ORDER BY `id` DESC LIMIT {$first}, {$news_on_page}"); ob_start(); include SITE_ROOT . 'style/news/news_list.html'; $content_main = ob_get_clean();
$db->connect(); $Row = $db->fetch_assoc($db->execute("SELECT * FROM `pm` WHERE `id` = {$id}")); if (empty($Row['id']) or $Row['reciver'] != $player['id']) { $db->close(); exit(header("Location: /pm/")); } $db->execute("UPDATE `pm` SET `readed` = '2' WHERE `id` = '{$id}'"); $db->close(); ob_start(); include SITE_ROOT . 'style/pm/see.html'; $content_main = ob_get_clean(); } else { $pm_on_page = 10; $db = new DB(); $db->connect(); $pm_count = $db->fetch_array($db->execute("SELECT COUNT(id) FROM `pm`")); $total = ceil($pm_count[0] / $pm_on_page); if (empty($_GET['p'])) { $_GET['p'] = '1'; } $p = $_GET['p']; $p = TextSave($p); if (!ctype_digit($p) or $p > $total) { $p = "1"; } // формируем запрос $first = $p * $pm_on_page - $pm_on_page; $result = $db->execute("SELECT * FROM `pm` WHERE `reciver` = '" . $player['id'] . "' ORDER BY `id` DESC LIMIT {$first}, {$pm_on_page}"); $db->close(); ob_start(); include SITE_ROOT . 'style/pm/list.html';
function glpiuImportPrinters($mode, $start = 0) { global $PRINTERSLIST, $UC_OCSIDS, $UC_NAMES, $CFG_GLPI, $LANG; $DBocs = new DBocs($_SESSION["ocsservers_id"]); $DB = new DB(); $noPort = 0; $numrows = 0; $UC_OCSIDS = array(); // Correspondance UC ocs/glpi // Recherche les ports $query_ports = "select distinct hardware.NAME as UC_Name, hardware.DEVICEID, printers.NAME, printers.PORT, printers.DRIVER from printers " . "inner join hardware on hardware.ID = printers.HARDWARE_ID where printers.DRIVER <> '' order by hardware.DEVICEID, printers.NAME, printers.PORT, printers.DRIVER"; $result_ports = $DBocs->query($query_ports) or die($DBocs->error()); if ($DBocs->numrows($result_ports) > 0) { // Récupère les UC dans GLPI $query_UC = "select distinct glpi_id, ocs_id from glpi_ocs_link order by glpi_id"; $result_UC = $DB->query($query_UC) or die($DB->error()); if ($DB->numrows($result_UC) > 0) { while ($data = $DB->fetch_array($result_UC)) { $UC_OCSIDS[$data["ocs_id"]] = array('glpi_id' => $data["glpi_id"], 'UC_Name' => '', 'driver' => ''); } } unset($result_UC); // Recherche les UC liés à une imprimante dans OCS $query_UC = "select distinct hardware.NAME as UC_Name, hardware.ID as ocs_id from hardware " . "inner join printers on printers.HARDWARE_ID = hardware.ID order by hardware.DEVICEID, hardware.NAME"; $result_UC = $DBocs->query($query_UC) or die($DBocs->error()); if ($DBocs->numrows($result_UC) > 0) { while ($data = $DBocs->fetch_array($result_UC)) { if (array_key_exists($data["ocs_id"], $UC_OCSIDS)) { $UC_OCSIDS[$data["ocs_id"]]['UC_Name'] = strtoupper($data["UC_Name"]); } } } unset($result_UC); // Suppression des UC sans imprimante // création d'une table des UC avec nom pour clé foreach ($UC_OCSIDS as $ocs_id => &$item) { if ($item['UC_Name'] === '') { unset($UC_OCSIDS[$ocs_id]); } else { $UC_NAMES[$item['UC_Name']] = array('glpi_id' => $item["glpi_id"], 'ocs_id' => $ocs_id); } } unset($UC_OCSIDS); // Création des imprimantes while ($data = $DBocs->fetch_array($result_ports)) { glpiuInsertPrinter($data["PORT"], $data["NAME"], $data["UC_Name"], $data["DRIVER"]); } unset($result_ports); unset($UC_NAMES); // Si en mode action, suppression des imprimantes /*if ($mode == 1 && count($PRINTERSLIST) > 0) { processObjects(PRINTER_TYPE, DELETE_ACTION); }*/ // Récupère les imprimantes dans GLPI $printer_names = array(); if (count($PRINTERSLIST) > 0) { $query_PRN = "select distinct ID, name from glpi_printers where deleted='0' "; $result_PRN = $DB->query($query_PRN) or die($DB->error()); if ($DB->numrows($result_PRN) > 0) { while ($data = $DB->fetch_array($result_PRN)) { $printer_names[$data["name"]] = $data["ID"]; } } } // Complétion des imprimantes et suppression de celles à ne pas importer $numrows = 0; foreach ($PRINTERSLIST as $prn_no => &$printer) { if ($printer->portType <= PORT_TYPE_USB) { $printer->getName(); if ($printer->server != '' && !isset($printer_names[$printer->name])) { $numrows++; } else { unset($PRINTERSLIST[$prn_no]); } } else { unset($PRINTERSLIST[$prn_no]); } } unset($printer_names); // Importation if ($mode == 1 && isset($_POST['toimport'])) { foreach ($_POST['toimport'] as $prn_no => $val) { if ($val == "on") { $PRINTERSLIST[$prn_no]->addToDB(); unset($PRINTERSLIST[$prn_no]); $numrows--; } } } unset($_POST['toimport']); // Affichage echo "<div align='center'>"; if ($numrows) { $readOnly = !haveRight("ocsng", "w"); $parameters = "objectType=" . PRINTER_TYPE . "&actionId=" . IMPORT_PRINTERS_ACTION; printPager($start, $numrows, $_SERVER["PHP_SELF"], $parameters); // delete end array_splice($PRINTERSLIST, $start + $_SESSION["glpilist_limit"]); // delete begin if ($start > 0) { array_splice($PRINTERSLIST, 0, $start); } echo "<form method='post' name='printer_form' id='printer_form' action='" . $_SERVER["PHP_SELF"] . "'>"; echo "<a href='" . $_SERVER["PHP_SELF"] . "' onclick= \"if ( markAllRows('printer_form') ) return false;\">" . $LANG["buttons"][18] . "</a> / <a href='" . $_SERVER["PHP_SELF"] . "' onclick= \"if ( unMarkAllRows('printer_form') ) return false;\">" . $LANG["buttons"][19] . "</a>"; echo "<input type='hidden' name='objectType' value='" . PRINTER_TYPE . "'>"; echo "<input type='hidden' name='actionId' value='" . IMPORT_PRINTERS_ACTION . "'>"; echo "<table class='tab_cadre'>"; if (!$readOnly) { echo "<tr class='tab_bg_1'><th colspan=8><input class='submit' type='submit' name='do_action' value='" . $LANG["buttons"][37] . "'></th></tr>" . chr(10); } echo '<tr><th></th><th>Type</th><th>IP</th><th>Nom</th><th width="150px">Port</th><th>Serveurs</th><th>Files d\'impression</th><th>Erreurs</th></tr>' . chr(10); foreach ($PRINTERSLIST as &$printer) { $printer->display(); } if (!$readOnly) { echo "<tr class='tab_bg_1'><th colspan=8><input class='submit' type='submit' name='do_action' value='" . $LANG["buttons"][37] . "'></th></tr>" . chr(10); } echo "</table>"; //echo '<br>'.$numrows.'<br>'; echo "</form>"; printPager($start, $numrows, $_SERVER["PHP_SELF"], $parameters); } else { echo "<strong>" . $LANG["ocsng"][9] . "<br>"; echo "<a href='../index.php'>" . $LANG["buttons"][13] . "</a></strong>"; } echo "</div>"; } return $numrows; }
/** * 获取应用列表 */ function get_applist() { global $_M; $query = "select * from {$_M['table']['applist']} order by no"; $result = DB::query($query); while ($list = DB::fetch_array($result)) { $list['url'] = "{$_M['url']['site_admin']}index.php?anyid={$_M['form']['anyid']}&lang={$_M['form']['lang']}&n={$list['m_name']}&c={$list['m_class']}&a={$list['m_action']}"; $applist[$list['id']] = $list; } return $applist; }
$db->db_connect(); if (isset($_SESSION["admin"])) { header("Location: user.php"); } if (isset($_POST["login_id"])) { $errors = array(); if ($_POST["login_id"] == "") { $errors[] = "please enter login id"; } if ($_POST["password"] == "") { $errors[] = "please enter password"; } $pw = md5($_POST["password"]); $sql = "SELECT * FROM admin WHERE admin_login = '******' AND admin_password = '******'"; $rs = $db->db_query($sql); $admin = $db->fetch_array($rs); print_r($admin); if (!$admin) { $errors[] = "login id or password is incorrect!"; } else { $_SESSION["admin"] = $admin; header("Location: user.php"); } } ?> <!DOCTYPE html> <html> <body> <h1>Thanks Card</h1>
$db = new DB(); $db->connect(); $Row = $db->fetch_assoc($db->execute("SELECT * FROM `shop` WHERE `id` = '{$ID}'")); $db->close(); if (empty($Row['id'])) { MessageSend(1, 'Товар не найден!'); } ob_start(); include SITE_ROOT . 'style/shop/buy.html'; $content_main = ob_get_clean(); } } else { $db = new DB(); $db->connect(); $items_on_page = 20; $items_count = $db->fetch_array($db->execute("SELECT COUNT(id) FROM `shop`")); $total = ceil($items_count[0] / $items_on_page); if (empty($_GET['p'])) { $_GET['p'] = '1'; } $p = $_GET['p']; $p = TextSave($p); if (!ctype_digit($p) or $p > $total) { $p = "1"; } // формируем запрос $first = $p * $items_on_page - $items_on_page; $result = $db->execute("SELECT * FROM `shop` ORDER BY `type` DESC, `name` ASC LIMIT {$first}, {$items_on_page}"); $db->close(); ob_start(); include SITE_ROOT . 'style/shop/index.html';
//设置默认首页导航 $targetDb->query(sprintf("REPLACE INTO `pw_common_config` (`name`, `namespace`, `value`, `vtype`, `description`) VALUES \n('homeUrl', 'site', 'index.php', 'string', ''), \n('homeRouter', 'site', '%s', 'array', '')", 'a:3:{s:1:"m";s:3:"bbs";s:1:"c";s:5:"index";s:1:"a";s:3:"run";}')); //添加临时表 createTmpTables($charset); refreshTo('credit', 'init'); } elseif ('init' == $step) { //初始化db配置数据、update操作 if ('credit' == $action) { //[init-credit] $creditMap = array('money' => 1, 'rvrc' => 2, 'credit' => 3, 'currency' => 4); $_commonConfig = array(); $creditConfig = array(1 => array('open' => 1, 'log' => 1), 2 => array('open' => 1, 'log' => 1), 3 => array('open' => 1, 'log' => 1), 4 => array('open' => 1, 'log' => 1)); //1、收集87中默认的4个积分配置 $sql = "SELECT * FROM pw_config WHERE db_name LIKE 'db_money%' OR db_name like 'db_rvrc%' OR db_name LIKE 'db_currency%' OR db_name LIKE 'db_credit%'"; $_tmp = $srcDb->query($sql); while ($row = $srcDb->fetch_array($_tmp)) { $name = substr($row['db_name'], -4); $r = preg_match('/^db_(.*)(name|unit)$/', $row['db_name'], $matches); if (!$r) { continue; } $creditConfig[$creditMap[$matches[1]]][$name] = $row['db_value']; } //2、收集87中扩展的积分设置 $sql = "SELECT * FROM pw_credits ORDER BY cid "; $_tmp = $srcDb->query($sql); $lastId = 4; while ($row = $srcDb->fetch_array($_tmp)) { $lastId++; $creditMap[$row['cid']] = $lastId; $creditConfig[$lastId] = array('open' => 1, 'log' => 0, 'name' => $row['name'], 'unit' => $row['unit'], 'desc' => $row['description']);
function cache_column() { global $_M; //mobile $query = "SELECT * FROM {$_M['table']['column']} WHERE lang='{$_M['lang']}' ORDER BY classtype desc,no_order"; $result = DB::query($query); while ($list = DB::fetch_array($result)) { $cache_column[$list['id']] = $list; } return cache_page("column_" . $lang . ".inc.php", $cache_column); }
/** * Get district name * */ private function getDistrictName($district_id) { $district = array(); $sql = "SELECT id, name FROM so_district WHERE id=" . $district_id; $district = DB::fetch_array($sql); return $district[0]['name']; }
if (Session::haveRight('plugin_relation', CREATE)) { if (PluginRelationRelation::isAncestor($_POST['items_id'], $_POST['id'], $_POST['type'])) { Session::addMessageAfterRedirect(__('Sorry. You cannot add an ancestor as a child!', 'Sorry. You cannot add an ancestor as a child!'), true); } else { PluginRelationRelation::addParent($_POST['id'], $_POST['items_id'], $_POST['itemtype'], $_POST['type'], $_POST['_nombresrelaciones']); // Logging here $child = PluginRelationRelation::getDeviceName($_POST['itemtype'], $_POST['items_id']); $parent = PluginRelationRelation::getDeviceName($_POST['type'], $_POST['id']); PluginRelationRelation::logChange($_POST['type'], $_POST['items_id'], $_POST['id'], $child, $parent, RELATIONS_LINK, $_POST['itemtype'], $_POST['_nombresrelaciones']); } } Html::redirect($_SERVER['HTTP_REFERER']); } else { if (isset($_GET['deleterelation'])) { //$PluginRelations->check($_GET['id'],'w'); $DB = new DB(); $query = "SELECT * FROM glpi_plugin_relation_relations WHERE id='" . $_GET['id'] . "'"; $result = $DB->query($query); if ($data = $DB->fetch_array($result)) { $PluginRelation->delete($_GET); // Logging $child = PluginRelationRelation::getDeviceName($data['itemtype'], $data['items_id']); $parent = PluginRelationRelation::getDeviceName($data['parent_type'], $data['parent_id']); PluginRelationRelation::logChange($data['parent_type'], $data['items_id'], $data['parent_id'], $child, $parent, RELATIONS_UNLINK, $data['itemtype'], $data['relation_type']); } Html::back(); } else { Html::back(); } } //Html::back();
public function get_user_para($id) { global $_M; $para = $this->get_user_para_info(); $query = "SELECT * FROM {$_M['table']['user_list']} WHERE userid='{$id}'"; $result = DB::query($query); while ($list = DB::fetch_array($result)) { $para_info[$list['paraid']] = $list; } foreach ($para as $key => $val) { $l['name'] = $val['name']; $l['info'] = $para_info[$val['id']]['info']; $paralist[] = $l; } return $paralist; }
$s_line = explode("`", $line); $s_type = explode("COMMENT", $s_line[2]); $s_type[0] = trim($s_type[0]); $s_type[0] = str_replace(" COLLATE utf8_unicode_ci", "", $s_type[0]); $s_type[0] = str_replace(" CHARACTER SET utf8", "", $s_type[0]); $a_tables_ref[$current_table][$s_line[1]] = str_replace(",", "", $s_type[0]); } } } // * Get tables from MySQL $a_tables_db = array(); $a_tables = array(); // SHOW TABLES; $query = "SHOW TABLES"; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { if (strstr($data[0], "monitoring")) { $data[0] = str_replace(" COLLATE utf8_unicode_ci", "", $data[0]); $data[0] = str_replace("( ", "(", $data[0]); $data[0] = str_replace(" )", ")", $data[0]); $a_tables[] = $data[0]; } } foreach ($a_tables as $table) { $query = "SHOW CREATE TABLE " . $table; $result = $DB->query($query); while ($data = $DB->fetch_array($result)) { $a_lines = explode("\n", $data['Create Table']); foreach ($a_lines as $line) { if (strstr($line, "CREATE TABLE ")) { $matches = array();
<div id="content-bottom"></div> </div> <?php break; case 3: // FOTOGALLERIJ ?> <div id="content"> <h1>Fotogallerij</h1> <?php if ($number_of_pages == 0) { print '<p>Momenteel zijn er nog geen foto’s beschikbaar.</p>'; } $db = new DB($DB_GEGEVENS); $query_return = $db->query("SELECT id, folder FROM folder ORDER BY id DESC LIMIT " . $start . "," . $albums_per_page); while ($row = $db->fetch_array($query_return)) { print "<h2>" . $row['folder'] . "</h2>"; $query_fotos = $db->query("SELECT id, photo, link FROM photo WHERE folderId = " . $row['id'] . " ORDER BY orderId ASC, id DESC"); while ($row2 = $db->fetch_array($query_fotos)) { print '<a href="' . $UPLOAD_FOLDER . '/' . $row2['link'] . '" rel="' . getCorrectRel($row['folder']) . '" title="' . $row['folder'] . '"><img src="' . $UPLOAD_FOLDER . '/th/' . $row2['link'] . '" /></a>'; } print '<p> </p>'; } unset($db); ?> <div class="page_numbering"> <?php if ($number_of_pages > 1) { print '<table border="0" style="width: 100%"><tr><td style="width: 100px">'; // previous page if ($_GET['n'] > 0) {
$Row = $db->fetch_assoc($db->execute("SELECT * FROM `streams` WHERE `id` = '{$stream_id}'")); $db->close(); if (empty($Row['id'])) { MessageSend(1, 'Стрим не найден!'); } ob_start(); include SITE_ROOT . 'style/admin/streams/edit.html'; $content_main = ob_get_clean(); } else { MessageSend(1, 'Стрим не найден!'); } } else { $streams_on_page = 22; $db = new DB(); $db->connect(); $streams_count = $db->fetch_array($db->execute("SELECT COUNT(creator) FROM `streams`")); $total = ceil($streams_count[0] / $streams_on_page); if (empty($_GET['p'])) { $_GET['p'] = '1'; } $p = $_GET['p']; $p = TextSave($p); if (!ctype_digit($p) or $p > $total) { $p = "1"; } // формируем запрос $first = $p * $streams_on_page - $streams_on_page; $result = $db->execute("SELECT * FROM `streams` ORDER BY `status` ASC LIMIT {$first}, {$streams_on_page}"); $db->close(); ob_start(); include SITE_ROOT . 'style/admin/streams/index.html';
require "DB_class.php"; $day = $_GET['day']; // connect database--MySQL //---> host, account, pw, dbname setting in the DB_config.php <---// // new a DB instance first $db = new DB(); // then connect to your DB through DB_class.php you may check how to use by openning the DB_class.php $db->connect_db($_DB['host'], $_DB['username'], $_DB['password'], $_DB['dbname']); // write you query here: $query = "SELECT epoch,value FROM sensor_data WHERE day='{$day}' AND entry='Pressure mbar'"; // execute query $db->query($query); // new an array for push your result into $resultArray = []; // fetch your result, result will be an Array return from MySQL while ($result = $db->fetch_array()) { $temArray = []; $temArray['epoch'] = $result['epoch']; $temArray['value'] = $result['value']; array_push($resultArray, $temArray); } // make to json format: $resultArray = json_encode($resultArray); header('Content-type: application/json'); echo $resultArray; //Write to file //$fp = fopen("C:\\Users\\Spartan-117\\Documents\\Visual Studio 2015\\WebSites\\WebSite1\\gps.json", 'w'); //fwrite($fp, $resultArray); //fclose($fp); // if you want to see whats the db return, you may print it: // $result = $db -> fetch_array();
} else { die('{"error": 1}'); } if (isset($_GET['guid']) && !empty($_GET['guid'])) { $guid = $_GET['guid']; } else { die('{"error": 1}'); } $TABLE_PAY = 'payment_orders'; // Имя таблицы в которой находятся совершенные оплаты if (isset($_GET['Load'])) { // Загружаем оплаты $sql = 'select ' . '`id`, ' . '`dor_id`, ' . '`contr_id`, ' . '`amount`, ' . '`datetime_load_server`, ' . '`datetime_load`, ' . '`datetime_unloading`, ' . '`token`, ' . '`card_last_four`, ' . '`card_type`, ' . '`user_name`, ' . '`ip_address`, ' . '`transaction_id`, ' . '`email`, ' . '`is_loaded`, ' . '`waiting` ' . 'from ' . $TABLE_PAY . ' ' . 'where `is_loaded` = 0 and `waiting` = 0'; $result = $DB->query($sql) or die('{"error": 1}'); $xml = new GenerateXML(); while ($product = $DB->fetch_array($result, MYSQL_BOTH)) { $a = $xml->addEl('Pay'); $xml->addEl('mysql_id', $product['id'], $a); $xml->addEl('dor_id', $product['dor_id'], $a); $xml->addEl('contr_id', $product['contr_id'], $a); $xml->addEl('amount', $product['amount'], $a); $xml->addEl('token', $product['token'], $a); $xml->addEl('card_last_four', $product['card_last_four'], $a); $xml->addEl('card_type', $product['card_type'], $a); $sql2 = "update " . $TABLE_PAY . " set guid='" . $DB->escape_string($guid) . "' where id = " . $product['id']; $result2 = $DB->query($sql2) or die('{"error": 1}'); } echo $xml->saveXML(); } else { if (isset($_GET['SavePay'])) { // сохранение оплаты
// echo "next =".$next; $count = $DBVAR->num_rows($result); if ($count != 0 || $count != '') { $next = $id; $explode = explode(',', $next); // pr($explode); // echo "explode =".$explode; $listExplode = array_unique($explode); if ($type == 'array') { //data baru berdasarkan pilihan $listImplode = implode(',', $listExplode); //data lama $query = "SELECT aset_list FROM apl_userasetlist WHERE aset_action = '{$mod}' AND UserSes = '{$SessionUser['ses_uid']}'"; // pr($query); $result = $DBVAR->query($query) or die($DBVAR->error()); $data = $DBVAR->fetch_array($result); if ($data[aset_list] == 0 || $data[aset_list] == '') { // echo "masuk sini ga ya?"; $oldData = ""; } else { $oldData = $data[aset_list]; } if ($oldData != "") { // echo "masuk old data"; $explode = explode(',', $oldData); $newCount = count($explode); if ($newCount != 0 || $count != '') { // echo "masuk combine"; $newData = $oldData . "," . $listImplode; $newDatacek = explode(',', $newData); // pr($newDatacek);
public function do_deduction_1($uid, $type, $typeinfo, $settle_no) { $db = new DB(); $db->Connect(DBHOST, DBUSER, DBPW, DBNAME); $bizset = new bizset(); $bizsetinfo = $bizset->get_bizset_bykey($type); //获取扣减项目对象 $percent = $bizsetinfo["bizvalue"]; //扣减比例 $manageprice = $percent; //扣除的费用 //检查奖金是否达到扣款数 $users = new users(); $usersinfo = $users->get_user_byid($uid); if ($usersinfo["amount"] < 100) { return; } //检查是否已经扣过 $sql = "select sum(amount) as sumamount from income where types='{$type}' and userid={$uid}"; $query_sumamount = $db->query($sql); $row = $db->fetch_array($query_sumamount); if (-$row["sumamount"] >= 100) { return; } if ($manageprice > 0) { //插入income $sql = "insert income(userid,types,amount,addtime,reason,states,settlementno) values(" . $uid . ",'" . $type . "','-" . $manageprice . "',now(),'" . $typeinfo . "',2,'{$settle_no}')"; $db->query($sql); //为用户扣减金额 $sql = "update users set amount = amount - " . $manageprice . " where id = " . $uid . ""; $db->query($sql); } }