function get_list($start = 0, $limit = 20) { $bannedlist = array(); $this->refresh(); $query = $this->db->query("SELECT * FROM `" . DB_TABLEPRE . "banned` ORDER BY id DESC LIMIT {$start},{$limit}"); while ($banned = $this->db->fetch_array($query)) { $banned['endtime'] = tdate($banned['time'] + $banned['expiration']); $banned['starttime'] = tdate($banned['time']); if ($banned['ip1'] < 0) { $banned['ip1'] = '*'; } if ($banned['ip2'] < 0) { $banned['ip2'] = '*'; } if ($banned['ip3'] < 0) { $banned['ip3'] = '*'; } if ($banned['ip4'] < 0) { $banned['ip4'] = '*'; } $banned['ip'] = $banned['ip1'] . '.' . $banned['ip2'] . '.' . $banned['ip3'] . '.' . $banned['ip4']; $bannedlist[] = $banned; } return $bannedlist; }
function get_list($limit = 100) { $datacalllist = array(); $query = $this->db->query("select * from " . DB_TABLEPRE . "datacall order by id desc limit {$limit}"); while ($datacall = $this->db->fetch_array($query)) { $datacall['time_format'] = tdate($datacall['time']); $datacalllist[] = $datacall; } return $datacalllist; }
function convert($line) { $params = explode('|', $line); $base = $this->base; $item['user'] = $base('user')->findById($params[0]); $item['format_dateline'] = tdate($params[1]); $item['content'] = implode('|', array_slice($params, 2)); //万一内容里面有这个符号,不能去掉了。 return $item; }
function get_list($start = 0, $limit = 10) { $notelist = array(); $query = $this->db->query("select * from " . DB_TABLEPRE . "note order by id desc limit {$start},{$limit}"); while ($note = $this->db->fetch_array($query)) { $note['format_time'] = tdate($note['time'], 3, 0); $notelist[] = $note; } return $notelist; }
function get_by_aid($aid, $start = 0, $limit = 10) { $commentlist = array(); $query = $this->db->query("SELECT * FROM `" . DB_TABLEPRE . "answer_comment` WHERE aid={$aid} ORDER BY `time` DESC limit {$start},{$limit}"); while ($comment = $this->db->fetch_array($query)) { $comment['avatar'] = get_avatar_dir($comment['authorid']); $comment['format_time'] = tdate($comment['time']); $commentlist[] = $comment; } return $commentlist; }
function get_by_noteid($noteid, $start = 0, $limit = 10) { $commentlist = array(); $query = $this->db->query("SELECT * FROM " . DB_TABLEPRE . "note_comment WHERE noteid='{$noteid}' ORDER BY `time` DESC LIMIT {$start},{$limit}"); while ($comment = $this->db->fetch_array($query)) { $comment['avatar'] = get_avatar_dir($comment['authorid']); $comment['format_time'] = tdate($comment['time']); $commentlist[] = $comment; } return $commentlist; }
function get_list($start = 0, $limit = 10) { $uid = $this->base->user['uid']; $questionlist = array(); $query = $this->db->query("SELECT q.title,f.qid,f.id,f.time,f.uid FROM `" . DB_TABLEPRE . "question` as q ,`" . DB_TABLEPRE . "favorite` as f WHERE q.id=f.qid AND f.uid={$uid} LIMIT {$start},{$limit}"); while ($question = $this->db->fetch_array($query)) { $question['format_time'] = tdate($question['time']); $questionlist[] = $question; } return $questionlist; }
function get_list($start = 0, $limit = 10) { $informlist = array(); $query = $this->db->query("SELECT * FROM " . DB_TABLEPRE . "inform ORDER BY time DESC LIMIT {$start},{$limit}"); while ($inform = $this->db->fetch_array($query)) { $inform['time'] = tdate($inform['time'], 3, 0); $inform['content'] = implode(';', unserialize($inform['content'])); $inform['reasons'] = $this->get_reasons(unserialize($inform['keywords'])); $informlist[] = $inform; } return $informlist; }
function get_list($answersize = 3, $start = 0, $limit = 3) { $famouslist = array(); $query = $this->db->query("SELECT u.uid,u.username,u.questions,u.answers,u.signature,u.credit1,u.credit2,u.credit3,f.id,f.reason,f.time FROM " . DB_TABLEPRE . "famous as f," . DB_TABLEPRE . "user as u WHERE f.uid=u.uid ORDER BY f.id DESC LIMIT {$start} ,{$limit}"); while ($famous = $this->db->fetch_array($query)) { $famous['avatar'] = get_avatar_dir($famous['uid']); $famous['time'] = tdate($famous['time']); $famous['bestanswer'] = $this->get_solve_answer($famous['uid'], 0, $answersize); $famouslist[] = $famous; } return $famouslist; }
function get_list($showquestion = 0, $start = 0, $limit = 3) { $expertlist = array(); $query = $this->db->query("SELECT * FROM " . DB_TABLEPRE . "user WHERE expert=1 ORDER BY credit1 DESC,answers DESC LIMIT {$start} ,{$limit}"); while ($expert = $this->db->fetch_array($query)) { $expert['avatar'] = get_avatar_dir($expert['uid']); $expert['lastlogin'] = tdate($expert['lastlogin']); $expert['category'] = $this->get_category($expert['uid']); $showquestion && ($expert['bestanswer'] = $this->get_solve_answer($expert['uid'], 0, 6)); $expertlist[] = $expert; } return $expertlist; }
function get_list($start = 0, $limit = 10) { $recommendlist = array(); $query = $this->db->query("SELECT * FROM " . DB_TABLEPRE . "recommend ORDER BY TIME DESC LIMIT {$start},{$limit}"); while ($recommend = $this->db->fetch_array($query)) { $recommend['category_name'] = $this->base->category[$recommend['cid']]['name']; $recommend['format_time'] = tdate($recommend['time']); $recommend['category_name'] = $this->base->category[$recommend['cid']]['name']; $recommend['url'] = url('question/view/' . $recommend['qid'], $recommend['url']); $recommend['image'] = $recommend['image'] ? $recommend['image'] : 'css/default/recomend.jpg'; $recommendlist[] = $recommend; } return $recommendlist; }
function get_sqlfile_list($filedir) { $filelist = array(); $handle = opendir($filedir); while ($filename = readdir($handle)) { if (!is_dir($filedir . $filename) && '.' != $filename && '..' != $filename && ('.zip' == substr($filename, -4) || '.sql' == substr($filename, -4))) { $file['filename'] = $filename; $file['filepath'] = "/data/db_backup/" . $file['filename']; $filesize = filesize($filedir . $filename) / 1024; $size = explode(".", $filesize); $file['filesize'] = $size[0] . " KB"; $file['filectime'] = tdate(filectime($filedir . $filename)); $filelist[] = $file; } } closedir($handle); return $filelist; }
function list_by_type($searchtype = 'all', $uid = 0, $start = 0, $limit = 20) { $doinglist = array(); $sql = "SELECT q.title,q.attentions,q.answers,q.views,q.time,q.hidden,d.* FROM " . DB_TABLEPRE . "doing AS d," . DB_TABLEPRE . "question AS q WHERE q.id=d.questionid"; $searchtype == 'my' && ($sql .= " AND d.authorid={$uid}"); $searchtype == 'atentto' && ($sql .= " AND q.id IN (SELECT qid FROM " . DB_TABLEPRE . "question_attention WHERE followerid={$uid})"); $sql .= " ORDER BY d.createtime DESC LIMIT {$start},{$limit}"; $query = $this->db->query($sql); while ($doing = $this->db->fetch_array($query)) { $doing['question_time'] = tdate($doing['time']); $doing['doing_time'] = tdate($doing['createtime']); $doing['avatar'] = get_avatar_dir($doing['authorid']); $doing['actiondesc'] = $this->actiontable[$doing['action']]; if ($doing['refer_authorid']) { $doing['refer_avatar'] = get_avatar_dir($doing['refer_authorid']); } $doinglist[] = $doing; } return $doinglist; }
function onview() { $id = intval($this->get[2]); $datacall = $_ENV['datacall']->get($id); !$datacall && exit(" document.write('·Ç·¨µ÷ÓÃ!') "); $expressionarr = unserialize($datacall['expression']); $jscache = $this->cache->read('js_' . $id, $expressionarr['cachelife']); if (!$jscache) { $tpl = stripslashes(base64_decode($expressionarr['tpl'])); $cid = 0; $cfield = ''; if ($expressionarr['category']) { $cids = explode(":", substr($expressionarr['category'], 0, -1)); foreach ($cids as $c) { $c && ($cid = $c); } } $cid && ($cfield = 'cid' . $this->category[$cid]['grade']); $questionlist = $_ENV['question']->list_by_cfield_cvalue_status($cfield, $cid, $expressionarr['status'], $expressionarr['start'], $expressionarr['limit']); $jscache = ''; foreach ($questionlist as $question) { $replaces = array(); foreach ($question as $qkey => $qval) { $replaces["[{$qkey}]"] = $qval; } $replaces['[title]'] = cutstr(strip_tags($question['title']), $expressionarr['maxbyte']); $replaces['[qid]'] = $question['id']; $replaces['[time]'] = tdate($question['time']); $replaces['[category_name]'] = $this->category[$cid]['name']; $replaces['[cid]'] = $cid; $replaces['[author]'] = $question['author']; $replaces['[authorid]'] = $question['authorid']; $replaces['[answers]'] = $question['answers']; $replaces['[views]'] = $question['views']; $jscache .= $this->replacesitevar($tpl, $replaces); } $this->cache->write('js_' . $id, $jscache); } echo "document.write('{$jscache}')"; }
function onview() { $this->setting['stopcopy_on'] && $_ENV['question']->stopcopy(); //是否开启了防采集功能 $qid = intval($this->get[2]); //接收qid参数 $_ENV['question']->add_views($qid); //更新问题浏览次数 $question = $_ENV['question']->get($qid); empty($question) && $this->message('问题已经被删除!'); 0 == $question['status'] && $this->message('问题正在审核中,请耐心等待!'); /* 问题过期处理 */ if ($question['endtime'] < $this->time && ($question['status'] == 1 || $question['status'] == 4)) { $question['status'] = 9; $_ENV['question']->update_status($qid, 9); $this->send($question['authorid'], $question['id'], 2); } $asktime = tdate($question['time']); $endtime = timeLength($question['endtime'] - $this->time); $solvetime = tdate($question['endtime']); $supplylist = $_ENV['question']->get_supply($question['id']); if (isset($this->get[3]) && $this->get[3] == 1) { $ordertype = 2; $ordertitle = '倒序查看回答'; } else { $ordertype = 1; $ordertitle = '正序查看回答'; } //回答分页 @($page = max(1, intval($this->get[4]))); $pagesize = $this->setting['list_default']; $startindex = ($page - 1) * $pagesize; $rownum = $this->db->fetch_total("answer", " qid={$qid} AND status>0 AND adopttime =0"); $answerlistarray = $_ENV['answer']->list_by_qid($qid, $this->get[3], $rownum, $startindex, $pagesize); $departstr = page($rownum, $pagesize, $page, "question/view/{$qid}/" . $this->get[3]); $answerlist = $answerlistarray[0]; $already = $answerlistarray[1]; $solvelist = $_ENV['question']->list_by_cfield_cvalue_status('cid', $question['cid'], 2); $nosolvelist = $_ENV['question']->list_by_cfield_cvalue_status('cid', $question['cid'], 1); $navlist = $_ENV['category']->get_navigation($question['cid'], true); $expertlist = $_ENV['expert']->get_by_cid($question['cid']); $typearray = array('1' => 'nosolve', '2' => 'solve', '4' => 'nosolve', '6' => 'solve', '9' => 'close'); $typedescarray = array('1' => '待解决', '2' => '已解决', '4' => '高悬赏', '6' => '已推荐', '9' => '已关闭'); $navtitle = $question['title']; $dirction = $typearray[$question['status']]; 'solve' == $dirction && ($bestanswer = $_ENV['answer']->get_best($qid)); $categoryjs = $_ENV['category']->get_js(); $taglist = $_ENV['tag']->get_by_qid($qid); $expertlist = $_ENV['expert']->get_by_cid($question['cid']); $is_followed = $_ENV['question']->is_followed($qid, $this->user['uid']); $followerlist = $_ENV['question']->get_follower($qid); /* SEO */ $curnavname = $navlist[count($navlist) - 1]['name']; if (!$bestanswer) { $bestanswer = array(); $bestanswer['content'] = ''; } if ($this->setting['seo_question_title']) { $seo_title = str_replace("{wzmc}", $this->setting['site_name'], $this->setting['seo_question_title']); $seo_title = str_replace("{wtbt}", $question['title'], $seo_title); $seo_title = str_replace("{wtzt}", $typedescarray[$question['status']], $seo_title); $seo_title = str_replace("{flmc}", $curnavname, $seo_title); } if ($this->setting['seo_question_description']) { $seo_description = str_replace("{wzmc}", $this->setting['site_name'], $this->setting['seo_question_description']); $seo_description = str_replace("{wtbt}", $question['title'], $seo_description); $seo_description = str_replace("{wtzt}", $typedescarray[$question['status']], $seo_description); $seo_description = str_replace("{flmc}", $curnavname, $seo_description); $seo_description = str_replace("{wtms}", strip_tags($question['description']), $seo_description); $seo_description = str_replace("{zjda}", strip_tags($bestanswer['content']), $seo_description); } if ($this->setting['seo_question_keywords']) { $seo_keywords = str_replace("{wzmc}", $this->setting['site_name'], $this->setting['seo_question_keywords']); $seo_keywords = str_replace("{wtbt}", $question['title'], $seo_keywords); $seo_keywords = str_replace("{wtzt}", $typedescarray[$question['status']], $seo_keywords); $seo_keywords = str_replace("{flmc}", $curnavname, $seo_keywords); $seo_keywords = str_replace("{wtbq}", implode(",", $taglist), $seo_keywords); $seo_keywords = str_replace("{description}", strip_tags($question['description']), $seo_keywords); $seo_keywords = str_replace("{zjda}", strip_tags($bestanswer['content']), $seo_keywords); } include template($dirction); }
function list_by_condition($condition, $start = 0, $limit = 10) { $answerlist = array(); $query = $this->db->query("SELECT * FROM `" . DB_TABLEPRE . "answer` WHERE {$condition} ORDER BY `time` DESC limit {$start},{$limit}"); while ($answer = $this->db->fetch_array($query)) { $answer['time'] = tdate($answer['time']); $answerlist[] = $answer; } return $answerlist; }
function get_attention_question($followerid, $start = 0, $limit = 20) { $questionlist = array(); $query = $this->db->query("SELECT q.cid,q.title,q.id,qa.time FROM " . DB_TABLEPRE . "question AS q," . DB_TABLEPRE . "question_attention as qa WHERE q.id=qa.qid AND qa.followerid={$followerid} ORDER BY qa.time DESC LIMIT {$start},{$limit}"); while ($question = $this->db->fetch_array($query)) { $question['attention_time'] = tdate($question['time']); $question['category_name'] = $this->base->category[$question['cid']]['name']; $questionlist[] = $question; } return $questionlist; }
echo $perfila; ?> </center></a></td><td class="caixatitpesq" width="10%"> <a href="detalhes_usuario.php?idusu=<?php echo $idusuario; ?> "> <center> <?php if ($dias > 45) { ?> <font color="#FF0000"><?php } ?> <?php echo SomarData(tdate($data, 1), 45, 0, 0); ?> </font> </center> </a> </td> </tr> <?php } ?> </table> <BR><BR> <table align="center" border="1" width="70%" cellpadding="0" cellspacing="0"> <tr>
function list_user_recommend($uid, $user_categorys, $start = 0, $limit = 20) { $questionlist = array(); if (!$user_categorys) { return $questionlist; } $cids = implode(",", $user_categorys); $query = $this->db->query("SELECT * FROM " . DB_TABLEPRE . "question WHERE cid IN ({$cids}) AND authorid<>{$uid} ORDER BY time DESC LIMIT {$start},{$limit}"); while ($question = $this->db->fetch_array($query)) { $question['format_time'] = tdate($question['time']); $question['category_name'] = $this->base->category[$question['cid']]['name']; $questionlist[] = $question; } return $questionlist; }
function list_by_searchlog($pricerange, $giftname, $username, $datestart, $dateend, $start = 0, $limit = 10) { $sql = "SELECT * FROM `" . DB_TABLEPRE . "giftlog` WHERE 1=1 "; $giftname && ($sql .= " AND `giftname` LIKE '{$giftname}%' "); $username && ($sql .= "AND `username` LIKE '{$username}%' "); $datestart && ($sql .= " AND `time` >= " . strtotime($datestart)); $dateend && ($sql .= " AND `time` <= " . strtotime($dateend)); if ($pricerange && $pricerange != 'all') { $ranges = explode("-", $pricerange); print_r($ranges); $sql .= " AND `credit`>" . intval($ranges[0]) . " AND `credit`<= " . intval($ranges[1]); } $sql .= " ORDER BY `time` DESC LIMIT {$start},{$limit}"; $giftloglist = array(); $query = $this->db->query($sql); while ($log = $this->db->fetch_array($query)) { $log['time'] = tdate($log['time'], 3, 0); $giftloglist[] = $log; } return $giftloglist; }
function search_title($title, $status = '1,2,6', $addbestanswer = 0, $start = 0, $limit = 20) { $questionlist = array(); if ($this->base->setting['xunsearch_open']) { $statusarr = explode(",", $status); $size = count($statusarr); $to = $statusarr[$size - 1]; $from = $statusarr[0]; $result = $this->search->setQuery($title)->addRange('status', $from, $to)->setLimit($limit, $start)->search(); foreach ($result as $doc) { $question = array(); $question['id'] = $doc->id; $question['cid'] = $doc->cid; $question['category_name'] = $this->base->category[$question['cid']]['name']; $question['cid1'] = $doc->cid1; $question['cid2'] = $doc->cid2; $question['cid3'] = $doc->cid3; $question['author'] = $doc->author; $question['authorid'] = $doc->authorid; $question['answers'] = $doc->answers; $question['status'] = $doc->status; $question['format_time'] = tdate($doc->time); $question['title'] = $this->search->highlight($doc->title); $question['description'] = $this->search->highlight(strip_tags($doc->description)); $questionlist[] = $question; } } else { $sql = "SELECT * FROM " . DB_TABLEPRE . "question WHERE STATUS IN ({$status}) AND title LIKE '%{$title}%' "; $sql .= " LIMIT {$start},{$limit}"; $query = $this->db->query($sql); while ($question = $this->db->fetch_array($query)) { $question['category_name'] = $this->base->category[$question['cid']]['name']; $question['format_time'] = tdate($question['time']); $addbestanswer && ($question['bestanswer'] = $this->db->result_first("SELECT content FROM `" . DB_TABLEPRE . "answer` WHERE qid=" . $question['id'] . " AND adopttime>0 ")); $question['description'] = strip_tags($question['description']); $questionlist[] = $question; } } return $questionlist; }
function runlog($file, $message, $halt = 0) { $nowurl = $_SERVER['REQUEST_URI'] ? $_SERVER['REQUEST_URI'] : ($_SERVER['PHP_SELF'] ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']); $log = tdate($_SERVER['REQUEST_TIME'], 'Y-m-d H:i:s') . "\t" . $_SERVER['REMOTE_ADDR'] . "\t{$nowurl}\t" . str_replace(array("\r", "\n"), array(' ', ' '), trim($message)) . "\n"; $yearmonth = gmdate('Ym', $_SERVER['REQUEST_TIME']); $logdir = TIPASK_ROOT . '/data/logs/'; if (!is_dir($logdir)) { mkdir($logdir, 0777); } $logfile = $logdir . $yearmonth . '_' . $file . '.php'; if (@filesize($logfile) > 2048000) { $dir = opendir($logdir); $length = strlen($file); $maxid = $id = 0; while ($entry = readdir($dir)) { if (strpos($entry, $yearmonth . '_' . $file) !== false) { $id = intval(substr($entry, $length + 8, -4)); var_dump($id); $id > $maxid && ($maxid = $id); } } closedir($dir); $logfilebak = $logdir . $yearmonth . '_' . $file . '_' . ($maxid + 1) . '.php'; @rename($logfile, $logfilebak); @unlink($logfilebak); } if ($fp = @fopen($logfile, 'a')) { @flock($fp, 2); fwrite($fp, "<?PHP exit;?>\t" . str_replace(array('<?', '?>', "\r", "\n"), '', $log) . "\n"); fclose($fp); } if ($halt) { exit; } }