function get_user_info_by_id($uid) { $sql_pre = "SELECT `username` ,`password` FROM `user` WHERE `id` = ?i AND username = ?s LIMIT 1 "; $array = array('1', "haixiao"); $sql = prepare($sql_pre, $array); return get_line($sql); }
function get_law_by_id($caseid) { $sql_pre = "SELECT `id` , `title` , `lawcat` , `time` , `content` FROM `yxy_laws` WHERE `id` = ?i "; $array = array($caseid); $sql = prepare($sql_pre, $array); return get_line($sql); }
function get_master_info($username) { $sql_pre = "SELECT `username` , `password` FROM `yxy_master` WHERE `username` = ?s"; $array = array($username); $sql = prepare($sql_pre, $array); return get_line($sql); }
function get_admin_info_by_id($id) { $sql = "SELECT * FROM `admin` WHERE `admin_id` = '" . intval($id) . "' LIMIT 1"; if ($line = get_line($sql)) { return $line; } return false; }
function modif_field() { echo "What do you want to update?\n> "; $arr = array("age", "name", "email", "phone"); $field = get_line(); while (!in_array($field, $arr)) { echo "Erreur: age/name/email/phone.\n"; echo "What do you want to update?\n> "; $field = get_line(); } return $field; }
function confirm() { echo "Are you sure ?\n> "; $conf = get_line(); while (preg_match_all("/^oui|yes|no|non\$/i", $conf) != 1) { echo "Erreur: Oui / Yes / Non / No.\n"; echo "Are you sure ?\n> "; $conf = get_line(); } if (preg_match_all("/^oui|yes\$/i", $conf) == 1) { return TRUE; } else { return FALSE; } }
function get_number($new = 0) { if ($new == 1) { $phrase = "New phone number ?\n> "; } else { $phrase = "Phone number ?\n> "; } echo $phrase; $number = get_line(); while (preg_match("/^[0-9]{10}\$/i", $number) !== 1) { echo "Erreur: Numéro invalide.\n"; echo $phrase; $number = get_line(); } return $number; }
function plugin_simple_token() { $do = z(t(v('do'))); switch ($do) { case 'create': case 'refresh': $new_token = substr(md5(uid() . time("Y h j G") . rand(1, 9999)), 0, rand(9, 20)); $new_token = uid() . substr(md5($new_token), 0, 10); $sql = "REPLACE INTO `stoken` ( `uid` , `token` , `on` ) VALUES ( '" . intval(uid()) . "' , '" . s($new_token) . "' , '1' )"; run_sql($sql); if (db_errno() == 0) { return ajax_echo('done'); } else { return ajax_echo('error'); } break; case 'close': $sql = "UPDATE `stoken` SET `on` = '0' WHERE `uid` = '" . intval(uid()) . "' LIMIT 1"; run_sql($sql); if (db_errno() == 0) { return ajax_echo('done'); } else { return ajax_echo('error'); } break; case 'reopen': $sql = "UPDATE `stoken` SET `on` = '1' WHERE `uid` = '" . intval(uid()) . "' LIMIT 1"; run_sql($sql); if (db_errno() == 0) { return ajax_echo('done'); } else { return ajax_echo('error'); } break; default: $data['tinfo'] = get_line("SELECT * FROM `stoken` WHERE `uid` = '" . intval(uid()) . "' LIMIT 1"); render($data, 'ajax', 'plugin', 'simple_token'); } }
function get_line($date, $epg_lines, $line_num) { $epg_line = @trim($epg_lines[$line_num]); preg_match("/(\\d+):(\\d+)[\\s\t]*([\\S\\s]+)/", $epg_line, $tmp_line); if (@$tmp_line[1] && $tmp_line[2] && $tmp_line[3]) { $result = array(); $time = $date . ' ' . $tmp_line[1] . ':' . $tmp_line[2] . ':00'; $result['time'] = $time; //$result['name'] = addslashes($tmp_line[3]); $result['name'] = $tmp_line[3]; $next_line = get_line($date, $epg_lines, $line_num + 1); if (!empty($next_line)) { $time_to = $next_line['time']; $result['time_to'] = $time_to; $result['duration'] = strtotime($time_to) - strtotime($time); } else { $result['time_to'] = 0; $result['duration'] = 0; } return $result; } return false; }
public function login() { $u = t(v('uname')); $p = t(v('psw')); if (true !== $this->loginCheck($u, $p)) { return ajax_json(array('title' => '登录失败:', 'status' => 1, 'msg' => '用户名或者密码错误!')); } // $p=md5(v('psw')); $sql = "select name from admin_user as u where u.name=" . s($u); $result = get_line($sql); //var_dump($result); if (!$result) { return ajax_json(array('title' => '登录失败:', 'status' => 1, 'msg' => '用户名或者密码错误1!')); } elseif ($result['status'] == 'delete') { return ajax_json(array('title' => '登录失败:', 'status' => 1, 'msg' => '用户已经被封禁!')); } elseif ($result['status'] == 'active') { ss_set('uid', $result['id']); ss_set('email', $result['email']); ss_set('nickname', $result['nickname']); ss_set('uname', $u); admin_log($result['id'], "登录后台管理系统."); return ajax_json(array('title' => '登录成功:', 'status' => 0, 'msg' => '您已成功登录!')); } }
} else { trigger_error("You can only run this script from the command line\n", E_USER_ERROR); } if (empty($SYSTEM_ROOT)) { echo $err_msg; exit; } if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT . '/core/include/init.inc')) { echo "ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n"; exit; } require_once $SYSTEM_ROOT . '/core/include/init.inc'; echo "Note: data/public/test_message.php has been moved to core/lib/web/test_message.php as a result of RM #5722\n"; $confirm = null; while ($confirm != 'y' && $confirm != 'n') { $confirm = strtolower(get_line('Delete data/public/test_message.php? (y/n)? : ')); if ($confirm != 'y' && $confirm != 'n') { echo 'Please answer y or n' . "\n"; } } if ($confirm == 'y') { echo "Removing.."; $file_path = $SYSTEM_ROOT . '/data/public/test_message.php'; if (is_file($file_path)) { unlink($file_path); } echo "done.\n"; } /** * Prints the specified prompt message and returns the line from stdin *
public function login_check() { $email = z(t(v('email'))); $password = z(t(v('password'))); if (strlen($email) < 1 || strlen($password) < 1) { return ajax_echo("电子邮件和密码不能为空"); } $sql = "SELECT `id` , `email` FROM `__meta_user` WHERE `email` = '" . s($email) . "' AND `password` = '" . md5($password) . "'"; if (!($user = get_line($sql))) { return ajax_echo("电子邮件和密码不匹配,请重试"); } $_SESSION['uid'] = $user['id']; $_SESSION['email'] = $user['email']; $_SESSION['ulevel'] = 9; // do login return ajax_echo("成功登录,转向中…<script>location = '?a=index';</script>"); }
echo "ERROR: You need to supply the path to the System Root as the first argument\n"; exit; } if (!is_dir($SYSTEM_ROOT) || !is_readable($SYSTEM_ROOT . '/core/include/init.inc')) { echo "ERROR: Path provided doesn't point to a Matrix installation's System Root. Please provide correct path and try again.\n"; exit; } require_once $SYSTEM_ROOT . '/core/include/init.inc'; $root_user = $GLOBALS['SQ_SYSTEM']->am->getSystemAsset('root_user'); $GLOBALS['SQ_SYSTEM']->setCurrentUser($root_user); echo "\n"; $GLOBALS['SQ_SYSTEM']->changeDatabaseConnection('db2'); $db =& $GLOBALS['SQ_SYSTEM']->db; $action = NULL; while ($action != 'add' && $action != 'remove') { $action = get_line('Please specify whether you want to \'add\' or \'remove\' a URL: '); } require_once $SYSTEM_ROOT . '/scripts/url_manager.inc'; if ($action == 'add') { $inputs = URL_Manager::cliInterfaceAddUrl(); $queries = URL_Manager::addUrl($inputs['http'], $inputs['https'], $inputs['new_url'], $inputs['existing_url'], $inputs['siteid'], $inputs['update_file_public_live_assets'], $inputs['existing_urlid'], $SYSTEM_ROOT); } else { if ($action == 'remove') { $remove_url_info = URL_Manager::cliInterfaceRemoveUrl(); $queries = URL_Manager::removeUrl($remove_url_info['remove_urlid'], $remove_url_info['remove_assetid'], $remove_url_info['remove_url'], FALSE, $SYSTEM_ROOT); } } //end else if $GLOBALS['SQ_SYSTEM']->restoreDatabaseConnection(); $GLOBALS['SQ_SYSTEM']->restoreCurrentUser(); exit(0);
function plugin_check_mail() { if (intval(kget('mqueue_on')) != 1) { return false; } $sql = "SELECT * FROM `mail_queue` WHERE `timeline` > '" . date("Y-m-d H:i:s", strtotime("-1 hour")) . "' LIMIT 1"; if ($line = get_line($sql)) { session_write_close(); $info = unserialize($line['data']); if (phpmailer_send_mail($info['to'], $info['subject'], $info['body'], kget('mqueue_username'), kget('mqueue_server'), kget('mqueue_port'), kget('mqueue_username'), kget('mqueue_password'))) { $sql = "DELETE FROM `mail_queue` WHERE `id` = '" . intval($line['id']) . "' LIMIT 1"; } else { $sql = "UPDATE `mail_queue` SET `timeline` = '" . date("Y-m-d H:i:s", strtotime("-2 hours")) . "' LIMIT 1 "; } run_sql($sql); } include_once AROOT . 'controller' . DS . 'api.class.php'; if (db_errno() != 0) { apiController::send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . db_error()); } return apiController::send_result(array('to_send' => get_var("SELECT COUNT(*) FROM `mail_queue` WHERE `timeline` > '" . date("Y-m-d H:i:s", strtotime("-1 hour")) . "' "))); }
function get_var($sql, $db = NULL) { $data = get_line($sql, $db); return $data[@reset(@array_keys($data))]; }
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <h1>categories</h1> <?php require 'bdd.php'; $champ1 = 1; $champ2 = 2; $rep_id_categorie_nom = '../' . $id_categorie_nom; $last_line_categories = get_nb_last_line($rep_id_categorie_nom); $tab_categories[$last_line_categories][2] = 0; for ($i = 1; $i <= $last_line_categories; $i++) { $categorie_line = get_line($rep_id_categorie_nom, $i); $tab_categories[$i][$champ1] = get_champ_line($categorie_line, $champ1); $tab_categories[$i][$champ2] = get_champ_line($categorie_line, $champ2); } $j = 1; for ($i = 1; $i <= $last_line_categories; $i++) { if ($j == 1) { echo '<div style="color:green;background-color:D8D8D8;float:left;width:72%;height:45px;">'; $j++; } else { echo '<div style="color:green;float:left;width:72%;height:45px;">'; $j = 1; } echo '<strong>' . $tab_categories[$i][$champ2] . '</strong><br />'; echo '</div>'; echo '<div style="float:left;width:28%;height:45px;">'; echo '<img onclick="edit_categorie();" width="45px" height="45px" src="../bdd/images/icones/edit.png">'; echo '<img onclick="delete_categorie();" width="45px" height="45px" src="../bdd/images/icones/delete.png">'; echo '</div>'; }
$champ3 = 3; // numero dernieres lignes fini $last_line_categories = get_nb_last_line($id_categorie_nom); $last_line_relations = get_nb_last_line($id_page_id_categorie_nom_page); // tableaux fini $tab_categories[$last_line_categories][2] = 0; $tab_relations[$last_line_relations][3] = 0; // tab categories fini for ($i = 1; $i <= $last_line_categories; $i++) { $categorie_line = get_line($id_categorie_nom, $i); $tab_categories[$i][$champ1] = get_champ_line($categorie_line, $champ1); $tab_categories[$i][$champ2] = get_champ_line($categorie_line, $champ2); } // tab avec lignes relations fini for ($j = 1; $j <= $last_line_relations; $j++) { $relation = get_line($id_page_id_categorie_nom_page, $j); $tab_relations[$j][$champ1] = get_champ_line($relation, $champ1); $tab_relations[$j][$champ2] = get_champ_line($relation, $champ2); $tab_relations[$j][$champ3] = get_champ_line($relation, $champ3); } // affichage des categories et ses pages for ($i = 1; $i <= $last_line_categories; $i++) { echo '<div style="margin-bottom:4px;margin-top:4px;font-size:150%;background-color:grey;color:white;"><strong>' . $tab_categories[$i][$champ2] . '</strong></div>'; //echo '<h2>'.$tab_categories[$i][$champ2].'</h2>'; for ($j = 1; $j <= $last_line_relations; $j++) { if ($tab_categories[$i][$champ1] == $tab_relations[$j][$champ2]) { echo '<div style="background-color:D8D8D8;font-size:120%;margin-top:4px;"><a href="core/print_page.php?id_page=' . $tab_relations[$j][$champ1] . '">' . $tab_relations[$j][$champ3] . '</a></div>'; } } } //echo '<ul>';
} if (substr($from_url . '/', 0, strlen($root_url) + 1) == $root_url . '/') { $matching_from_roots[] = $root_url; } } if (empty($matching_roots)) { echo 'The new URL entered, "' . $to_url . '", is not based upon an existing System Root URL.' . "\n"; $to_url = get_line('Please re-enter the new URL: '); } else { $root_ok = TRUE; } } //end while root not OK $confirm = null; while ($confirm != 'y' && $confirm != 'n') { $confirm = strtolower(get_line('Change ' . $from_url . ' to ' . $to_url . ' (y/n)? : ')); if ($confirm != 'y' && $confirm != 'n') { echo 'Please answer y or n' . "\n"; } else { if ($confirm == 'n') { exit; } } } // update any urls that use this url in the lookup and lookup value tables foreach (array('sq_ast_lookup_value', 'sq_ast_lookup') as $tablename) { $sql = 'UPDATE ' . $tablename . ' SET url = :to_url || SUBSTR(url, :from_url_length + 1) WHERE
/** * 以变量方式获取记录 * @param $sql * @return mixed */ function get_var($sql, $db = NULL) { $data = get_line($sql, $db); return !is_array($data) ? NULL : @array_shift($data); }
function get_user_info_by_id($username) { $sql = prepare("SELECT * FROM `login` WHERE `UserName` = ?s", array($username)); return get_line($sql); }
public function get_token() { $token_account_field = c('token_account_field'); $token_password_field = c('token_password_field'); $token_table_name = c('token_table_name'); $account = z(t(v($token_account_field))); $password = z(t(v($token_password_field))); $token_table_name = z(t($token_table_name)); $sql = "SELECT * FROM `" . s($token_table_name) . "` WHERE `" . s($token_account_field) . "` = '" . s($account) . "' AND `" . s($token_password_field) . "` = '" . md5($password) . "' LIMIT 1"; if ($user = get_line($sql)) { session_start(); $token = session_id(); $_SESSION['token'] = $token; $_SESSION['uid'] = $user['id']; $_SESSION['account'] = $user[c('token_account_field')]; return $this->send_result(array('token' => $token, 'uid' => $user['id'])); } else { return $this->send_error(LR_API_TOKEN_ERROR, 'BAD ACCOUNT OR PASSWORD'); } }
// 载入框架引导文件 require APP . 'system/_shell.php'; require APP . 'funcs/spider.fn.php'; require APP . 'models/ContentModel.php'; system('echo -e "\\033[32m开始获取队列... \\033[0m"'); $contentModel = new ContentModel(); $configs = array('need_push' => 'yes'); $url_list = $contentModel->getUrlList($configs, 'LIMIT 50 '); $url_count = count($url_list); system('echo -e "\\033[32m 获取到' . $url_count . '条要采集的内容... \\033[0m"'); if (!empty($url_list)) { foreach ($url_list as $v) { $tmp_url_data[$v['task_list_id']][] = $v; } foreach ($tmp_url_data as $ko => $vo) { $url_info = get_line(prepare('select * from task_list where id=?i limit 1', array($ko))); $content_rules = $url_info['content_rules']; $content_rules = json_decode($content_rules, true); $chatset = $content_rules['charset']; if (!empty($content_rules['type'])) { foreach ($vo as $va) { system("echo -e '获取内容链接: \\033[32m" . $va['url'] . "\\033[0m'"); $html = ''; $html = http_client_request($va['url']); if ($chatset != 'utf-8') { iconv($chatset, "UTF-8", $html); } if (empty($html)) { if ($va['error_time'] >= 3) { update('task_url', array('need_push' => 'no'), array('hash' => $va['hash'])); } else {
function echo_line($line) { echo get_line($line); }
function get_var($sql, $conn = null) { $data = get_line($sql, $conn); return $data[@reset(@array_keys($data))]; }
function api_checklist_add() { $content = z(t(v('text'))); if (!not_empty($content)) { return apiController::send_error(LR_API_ARGS_ERROR, 'TEXT CAN\'T EMPTY'); } $tid = intval(v('tid')); if (intval($tid) < 1) { return apiController::send_error(LR_API_ARGS_ERROR, 'TID NOT EXISTS'); } // check user $tinfo = get_todo_info_by_id($tid); if (intval($tinfo['details']['is_public']) == 0 && uid() != $tinfo['owner_uid']) { return apiController::send_error(LR_API_FORBIDDEN, 'ONLY PUBLIC TODO CAN ADD CHECKLIST BY OTHERS'); } $sql = "INSERT INTO `checklist` ( `tid` , `title` , `content` , `timeline` , `uid` ) VALUES ( '" . intval($tid) . "' , '" . s($content) . "' , '" . s($content) . "' , NOW() , '" . intval(uid()) . "' ) "; run_sql($sql); if (db_errno() != 0) { return apiController::send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . mysql_error()); } else { return apiController::send_result(get_line("SELECT * FROM `checklist` WHERE `id` = '" . intval(last_id()) . "' LIMIT 1", db())); } }
function html_compress($data, $options = null) { if (!isset($options)) { $options = array(); } $data .= "\n"; $out = ''; $inside_pre = false; $bytecount = 0; while ($line = get_line($data)) { $bytecount += strlen($line); if (!$inside_pre) { if (strpos($line, '<pre') === false) { // Since we're not inside a <pre> block, we can trim both ends of the line $line = trim($line); // And condense multiple spaces down to one $line = preg_replace('/\\s\\s+/', ' ', $line); } else { // Only trim the beginning since we just entered a <pre> block... $line = ltrim($line); $inside_pre = true; // If the <pre> ends on the same line, don't turn on $inside_pre... if (strpos($line, '</pre') !== false && strripos($line, '</pre') >= strripos($line, '<pre')) { $line = rtrim($line); $inside_pre = false; } } } else { if (strpos($line, '</pre') !== false && strripos($line, '</pre') >= strripos($line, '<pre')) { // Trim the end of the line now that we found the end of the <pre> block... $line = rtrim($line); $inside_pre = false; } } // Filter out any blank lines that aren't inside a <pre> block... if ($inside_pre || $line != '') { $out .= $line . "\n"; } } // Remove HTML comments... if (array_key_exists('c', $options) || array_key_exists('no-comments', $options)) { $out = preg_replace('/(<!--.*?-->)/ms', '', $out); $out = str_replace('<!>', '', $out); } // Perform any extra (unsafe) compression techniques... if (array_key_exists('x', $options) || array_key_exists('extra', $options)) { // Can break layouts that are dependent on whitespace between tags $out = str_replace(">\n<", '><', $out); } // Remove the trailing \n $out = trim($out); // Output either our stats or the compressed data... if (array_key_exists('s', $options) || array_key_exists('stats', $options)) { $echo = ''; $echo .= "Original Size: {$bytecount}\n"; $echo .= "Compressed Size: " . strlen($out) . "\n"; $echo .= "Savings: " . round((1 - strlen($out) / $bytecount) * 100, 2) . "%\n"; echo $echo; } else { if (array_key_exists('o', $options) || array_key_exists('overwrite', $options)) { if ($GLOBALS['argc'] > 1 && is_writable($GLOBALS['argv'][$GLOBALS['argc'] - 1])) { file_put_contents($GLOBALS['argv'][$GLOBALS['argc'] - 1], $out); return true; } else { return "Error: could not write to " . $GLOBALS['argv'][$GLOBALS['argc'] - 1] . "\n"; } } else { return $out; } } }
/** * 取得用户未读信息 * * * @param string token , 必填 * @return array ('notice'=>'未读计数' , 'nid' => '最后一条Notice ID' , 'text' => '最后一条未读Notice内容') * @author EasyChen */ public function user_unread() { // 处理掉全部的未读计数 // 私信和系统通知 $sql = "SELECT COUNT(*) FROM `notice` WHERE `to_uid` = '" . intval(uid()) . "' AND `is_read` = 0 "; $notice_count = intval(get_var($sql)); $sql = "SELECT COUNT(*) FROM `message` WHERE `to_uid` = '" . intval(uid()) . "' AND `is_read` = 0 "; $message_count = intval(get_var($sql)); $sql = "SELECT COUNT( * ) AS `from_cnt` , `from_uid` FROM `message` WHERE `to_uid` = '" . intval(uid()) . "' AND `is_read` = 0 GROUP BY `from_uid` "; $muids = array(); $muidstring = ''; if ($mdata = get_data($sql)) { foreach ($mdata as $mitem) { $muids[] = $mitem['from_uid']; } $muidstring = join('|', $muids); } $last_notice = get_line("SELECT * FROM `notice` WHERE `to_uid` = '" . intval(uid()) . "' AND `is_read` = 0 ORDER BY `id` DESC LIMIT 1"); $last_message = get_line("SELECT * FROM `message` WHERE `to_uid` = '" . intval(uid()) . "' AND `is_read` = 0 ORDER BY `id` DESC LIMIT 1"); // update user online $sql = "REPLACE `online` ( `uid` , `session` , `last_active` , `device` ) VALUES ( '" . intval(uid()) . "' , '" . s(session_id()) . "' , NOW() , '" . get_device() . "' ) "; run_sql($sql); return self::send_result(array('all' => $message_count + $notice_count, 'message' => $message_count, 'uids' => $muidstring, 'notice' => $notice_count, 'nid' => $last_notice['id'], 'mid' => $last_message['id'], 'text' => $last_notice['content'])); }
function get_user_info_by_id($username, $password) { $sql = prepare("SELECT * FROM `login` WHERE `UserName` = ?s AND `Password` = ?s AND `actNum` = ?i", array($username, $password, 0)); return get_line($sql); }
function get_feed_by_id($fid) { if ($feed = get_line("SELECT * FROM `feed` WHERE `id` = '" . intval($fid) . "' LIMIT 1")) { $feed['user'] = get_line("SELECT " . USER_INFO . " FROM `user` WHERE `id` = '" . intval($feed['uid']) . "'"); return $feed; } return false; }
function is_online($uid) { $sql = "SELECT * FROM `online` WHERE `uid` = '" . intval($uid) . "' AND `last_active` > '" . date("Y-m-d H:i:s", strtotime("-5 minutes")) . "' LIMIT 1"; return get_line($sql); }