Ejemplo n.º 1
0
 public static function query($sql, $is_master = false)
 {
     $sql = trim($sql);
     if (!mod_sqlsafecheck::checkquery($sql)) {
         throw new Exception('Sorry,Your SQL is bad', 444);
     }
     self::$current_link = self::init_mysql(true, $is_master);
     try {
         self::$sql = $sql;
         self::$query = @mysql_query($sql, self::$current_link);
         if (self::$query === false) {
             throw new Exception(mysql_error());
         } else {
             self::$query_count++;
             return self::$query;
         }
     } catch (Exception $e) {
         if (!TRUE) {
         } else {
             echo $e->getMessage(), '<br/>';
             echo '<pre>', $e->getTraceAsString(), '</pre>';
             echo '<strong>Query: </strong> ' . $sql;
         }
         self::log($e->getMessage());
         exit;
     }
 }
Ejemplo n.º 2
0
 /**
  * 写配置
  *
  * @param  array
  * @return none
  * @throws none
  */
 public static function set_configs($configs = array())
 {
     foreach ($configs as $current_key => $current_value) {
         if (false === strpos($current_key, 'fl_')) {
             $current_key = 'fl_' . $current_key;
         }
         pm_db::query("replace `pm_config` set `fl_value` = '" . $current_value . "', `fl_name` = '" . $current_key . "'");
     }
 }
Ejemplo n.º 3
0
 public static function get_user_msg($username, $start, $perpage = 20)
 {
     $condition = '';
     if ($start > -1 && $perpage > 0) {
         $condition = "ORDER BY id DESC LIMIT {$start}, {$perpage}";
     }
     $query = pm_db::query("SELECT SQL_CALC_FOUND_ROWS * FROM gamebi_usermsg WHERE touser='******' {$condition}");
     $ndata = array();
     while ($row = pm_db::fetch_one($query)) {
         pm_db::query("UPDATE gamebi_usermsg SET is_read=1 WHERE id='{$row['id']}'");
         $ndata[] = $row;
     }
     $data = array();
     if ($ndata) {
         $data['data'] = $ndata;
         $data['total'] = pm_db::result_first("SELECT FOUND_ROWS() AS rows");
         return $data;
     } else {
         return null;
     }
 }
Ejemplo n.º 4
0
 public static function get_menu_list()
 {
     $data = array();
     $query = pm_db::query("SELECT * FROM pm_menu WHERE parent_id=0 AND level=1 AND status=1 ORDER BY sort ASC");
     while ($row = pm_db::fetch_one($query)) {
         $data[] = $row;
         $secondquery = pm_db::query("SELECT * FROM pm_menu WHERE parent_id='{$row['menu_id']}' AND level=2 ORDER BY sort ASC");
         while ($second = pm_db::fetch_one($secondquery)) {
             if (!$second) {
                 continue;
             } else {
                 $data[] = $second;
                 $query1 = pm_db::query("SELECT * FROM pm_menu WHERE parent_id='{$second['menu_id']}' AND level=3 AND status=1 ORDER BY sort ASC");
                 while ($row1 = pm_db::fetch_one($query1)) {
                     $data[] = $row1;
                 }
             }
         }
     }
     return $data;
 }
Ejemplo n.º 5
0
 /**
  *  系统信息
  *
  */
 public static function system_info()
 {
     define("YES", "<span class='resYes'>YES</span>");
     define("NO", "<span class='resNo'>NO</span>");
     // 系统基本信息
     $serverapi = strtoupper(php_sapi_name());
     $phpversion = PHP_VERSION;
     $systemversion = explode(" ", php_uname());
     $sysReShow = 'none';
     switch (PHP_OS) {
         case "Linux":
             $sysReShow = false !== ($sysInfo = self::sys_linux()) ? "show" : "none";
             $sysinfo = $systemversion[0] . '   ' . $systemversion[2];
             break;
         case "FreeBSD":
             $sysReShow = false !== ($sysInfo = self::sys_freebsd()) ? "show" : "none";
             $sysinfo = $systemversion[0] . '   ' . $systemversion[2];
             break;
         default:
             $sysinfo = $systemversion[0] . '  ' . $systemversion[1] . ' ' . $systemversion[3] . $systemversion[4] . $systemversion[5];
             break;
     }
     if ($sysReShow == 'show') {
         $pmemory = '共' . $sysInfo['memTotal'] . 'M, 已使用' . $sysInfo['memUsed'] . 'M, 空闲' . $sysInfo['memFree'] . 'M, 使用率' . $sysInfo['memPercent'] . '%';
         $pmemorybar = $sysInfo['memPercent'];
         $swapmomory = '共' . $sysInfo['swapTotal'] . 'M, 已使用' . $sysInfo['swapUsed'] . 'M, 空闲' . $sysInfo['swapFree'] . 'M, 使用率' . $sysInfo['swapPercent'] . '%';
         $swapmemorybar = $sysInfo['swapPercent'];
         $syslaodavg = $sysInfo['loadAvg'];
     }
     pm_db::query("SELECT VERSION() AS dbversion");
     $mysql = pm_db::fetch_one();
     $mysql = $mysql['dbversion'];
     $phpsafe = self::getcon("safe_mode");
     $dispalyerror = self::getcon("display_errors");
     $allowurlopen = self::getcon("allow_url_fopen");
     $registerglobal = self::getcon("register_globals");
     $maxpostsize = self::getcon("post_max_size");
     $maxupsize = self::getcon("upload_max_filesize");
     $maxexectime = self::getcon("max_execution_time") . 's';
     $mqqsp = get_magic_quotes_gpc() === 1 ? YES : NO;
     $mprsp = get_magic_quotes_runtime() === 1 ? YES : NO;
     $zendoptsp = get_cfg_var("zend_optimizer.optimization_level") || get_cfg_var("zend_extension_manager.optimizer_ts") || get_cfg_var("zend_extension_ts") ? YES : NO;
     $iconvsp = self::isfun('iconv');
     $curlsp = self::isfun('curl_init');
     $gdsp = self::isfun('gd_info');
     $zlibsp = self::isfun('gzclose');
     $eaccsp = self::isfun('eaccelerator_info');
     $xcachesp = extension_loaded('XCache') ? YES : NO;
     $sessionsp = self::isfun("session_start");
     $cookiesp = isset($_COOKIE) ? YES : NO;
     $serverip = @gethostbyname($_SERVER['SERVER_NAME']);
     $serverip = $serverip == '' ? '' : "  ({$serverip})";
     $systime = gmdate("Y年n月j日 H:i:s", time() + 8 * 3600);
     $phpversionsp = $phpversion > '5.0' ? YES : NO;
     $mysqlversionsp = $mysql['dbversion'] > '4.1' ? YES : NO;
     $dbasp = extension_loaded('dba') ? YES : NO;
     // 数据库大小
     $databasesize = 0;
     pm_db::query("SHOW TABLE STATUS");
     while ($rs = pm_db::fetch_one()) {
         $databasesize += $rs['Data_length'] + $rs['Index_length'];
     }
     $databasesize = bytes_to_string($databasesize);
     //站点统计
     pm_db::query("SELECT count(*) as sum FROM gh_ghinfo");
     $rt = pm_db::fetch_one();
     $ghsum = $rt['sum'];
     //系统日志大小超过限制提示
     $noticemsg = '';
     if (@filesize(PATH_DATA . '/log/admin_log.php') > 409600) {
         $noticemsg = '后台记录日志';
     }
     if (@filesize(PATH_DATA . '/log/php_error.log') > 409600) {
         $data['noticemsg'] = 'PHP错误日志';
     }
     if (@filesize(PATH_DATA . '/log/mysql_error.php') > 409600) {
         $data['noticemsg'] = 'mysql日志';
     }
     $data['serverip'] = $serverip;
     $data['systime'] = $systime;
     $data['sysinfo'] = $sysinfo;
     $data['phpversion'] = $phpversion;
     $data['dbversion'] = $mysql;
     $data['dispalyerror'] = $dispalyerror;
     $data['serverapi'] = $serverapi;
     $data['phpsafe'] = $phpsafe;
     $data['sessionsp'] = $sessionsp;
     $data['cookiesp'] = $cookiesp;
     $data['phpsafe'] = $phpsafe;
     $data['zendoptsp'] = $zendoptsp;
     $data['eaccsp'] = $eaccsp;
     $data['xcachesp'] = $xcachesp;
     $data['registerglobal'] = $registerglobal;
     $data['mqqsp'] = $mqqsp;
     $data['mprsp'] = $mprsp;
     $data['maxupsize'] = $maxupsize;
     $data['maxpostsize'] = $maxpostsize;
     $data['maxexectime'] = $maxexectime;
     $data['allowurlopen'] = $allowurlopen;
     $data['curlsp'] = $curlsp;
     $data['iconvsp'] = $iconvsp;
     $data['zlibsp'] = $zlibsp;
     $data['gdsp'] = $gdsp;
     $data['dbasp'] = $dbasp;
     $data['datasize'] = $databasesize;
     $data['ghsum'] = $ghsum;
     return $data;
 }
Ejemplo n.º 6
0
 public function testaa()
 {
     $aa = pm_db::fetch_all(pm_db::query("select * from gamebi_giving_item"));
     echo "<pre>";
     print_r($aa);
     //echo pm_db::query("insert into gamebi_giving_item set itemid='14190001',name='炼武破片',type='2',gameid='100087'");
     //
     //
     //echo pm_db::query("insert into gamebi_giving_item set itemid='14190002',name='防具碎片',type='2',gameid='100087'");
     //echo pm_db::query("insert into gamebi_giving_item set itemid='14190003',name='饰品碎片',type='2',gameid='100087'");
     //echo pm_db::query("insert into gamebi_giving_item set itemid='14191001',name='上古残枪',type='2',gameid='100087'");
     //echo pm_db::query("insert into gamebi_giving_item set itemid='14191002',name='上古残扇',type='2',gameid='100087'");
     //echo pm_db::query("insert into gamebi_giving_item set itemid='14191003',name='上古残剑',type='2',gameid='100087'");
 }
Ejemplo n.º 7
0
 private function getparents($list)
 {
     foreach ($list as $val) {
         $p[] = $val['parent_id'];
     }
     $sql_2 = "SELECT * FROM iosadm_menu where menu_id in (" . implode(',', array_unique($p)) . ")";
     $parentlist = pm_db::fetch_all(pm_db::query($sql_2));
     foreach ($parentlist as $value) {
         $parent[$value['menu_id']] = $value['menu_name'];
     }
     foreach ($parent as $key => $value) {
         $menu[$key]['label'] = $value;
         foreach ($list as $val) {
             if ($val['parent_id'] == $key) {
                 $menu[$key]['children'][$val['menu_id']]['label'] = $val['menu_name'];
                 $menu[$key]['children'][$val['menu_id']]['action'] = $val['act_url'];
             }
         }
     }
     return $menu;
 }
Ejemplo n.º 8
0
 public static function get_ghzc_data_channel($channel, $starttime = '', $endtime = '')
 {
     $sql = "SELECT gz.thedate,SUM(gz.charge) AS c,SUM(gz.registernum) AS rn,SUM(gz.chargenum) AS cn FROM pm_ghzcdata AS gz WHERE 1=1";
     $sql .= " AND gz.channelid='{$channel}'";
     if ($starttime) {
         $sql .= " AND thedate>='{$starttime}'";
     }
     if ($endtime) {
         $sql .= " AND thedate<='{$endtime}'";
     }
     $sql .= "GROUP BY gz.thedate ORDER BY gz.thedate ASC";
     $query = pm_db::query($sql);
     $data = array();
     while ($row = pm_db::fetch_one($query)) {
         $row['thedate'] = date('Y-m-d', strtotime($row['thedate']));
         $data[] = $row;
     }
     return $data;
 }
Ejemplo n.º 9
0
 public static function get_soplog($start, $opuser = false, $ctrl = false, $act = false, $aday = false, $stime = false, $etime = false)
 {
     $data = array();
     $condition = '';
     if ($keyword && $cols) {
         $condition1 = " WHERE {$cols}='{$keyword}'";
     }
     if ($start > -1 && $page > 0) {
         $condition2 = "  ORDER BY timestamp DESC LIMIT {$start}, {$page}";
     }
     $condition = $condition1 . $condition2;
     $sql = "SELECT SQL_CALC_FOUND_ROWS * FROM pm_oplog {$condition}";
     //debug($sql);
     $query = pm_db::query($sql);
     while ($row = pm_db::fetch_one($query)) {
         $data[$row['oplid']] = $row;
     }
     if ($data) {
         $output = array();
         $total = pm_db::query('SELECT FOUND_ROWS() AS rows');
         $total = pm_db::fetch_one();
         $output['total'] = $total['rows'];
         $output['data'] = $data;
         return $output;
     } else {
         return false;
     }
 }
Ejemplo n.º 10
0
 public static function get_logslist($start, $username, $ctr_new, $act_new, $start_dategsh, $end_dategsh, $perpage = 20)
 {
     $where = '';
     if (!empty($username)) {
         $where .= " AND username = '******' ";
     }
     if (!empty($ctr_new)) {
         $where .= " AND ctrl = 'c={$ctr_new}' ";
     }
     if (!empty($act_new)) {
         $where .= " AND act = 'a={$act_new}' ";
     }
     if (!empty($start_dategsh)) {
         $where .= " AND aday >= {$start_dategsh} ";
     }
     if (!empty($end_dategsh)) {
         $where .= " AND aday <= {$end_dategsh} ";
     }
     if ($start > -1 && $perpage > 0) {
         $where .= " ORDER BY timestamp DESC LIMIT {$start}, {$perpage} ";
     }
     $sql = "SELECT SQL_CALC_FOUND_ROWS * FROM iosadm_oplog WHERE 1=1 {$where} ";
     $query = pm_db::query($sql);
     $data = pm_db::fetch_all($query);
     $total = pm_db::result_first(" SELECT FOUND_ROWS() AS rows ");
     if ($data) {
         $output = array();
         $output['data'] = $data;
         $output['total'] = $total;
         return $output;
     } else {
         return null;
     }
 }