📄 ask.class.php
字号:
<?php
class ask
{
var $db;
var $pages;
var $number;
var $table;
var $table_posts;
function __construct()
{
global $db;
$this->db = &$db;
$this->table = DB_PRE.'ask';
$this->table_posts = DB_PRE.'ask_posts';
$this->pay = load('pay_api.class.php', 'pay', 'api');
$this->credit = load('credit.class.php', 'ask', 'include');
}
function ask()
{
$this->__construct();
}
function detail($id = 0, $fields = '*', $ismore = 0)
{
$id = intval($id);
$sql = $ismore ? "SELECT $fields FROM $this->table a,$this->table_posts p WHERE a.askid=p.askid AND a.askid=$id" : "SELECT $fields FROM $this->table WHERE pid=$id";
return $this->db->get_one($sql);
}
function add($info,$posts)
{
global $_userid, $_username, $M, $LANG;
if(!is_array($info) || !is_array($posts)) return false;
$this->db->insert($this->table, $info);
$posts['askid'] = $this->db->insert_id();
$this->db->query("UPDATE ".DB_PRE."category SET items=items+1 WHERE catid='$info[catid]'");
if($info['reward'])
{
$this->credit->update($_userid, $_username, $info['reward'], 0);
$this->pay->update_exchange('ask', 'point', '-'.$info['reward'], $LANG['reword_diff']);
}
if($info['anonymity'])
{
$this->credit->update($_userid, $_username, $M['anybody_score'], 0);
$this->pay->update_exchange('ask', 'point', '-'.$M['anybody_score'], $LANG['anonymous_diff']);
}
$this->db->insert($this->table_posts, $posts);
$this->search_api($posts['askid']);
return $posts['askid'];
}
function edit($id, $info, $posts, $userid = 0)
{
$id = intval($id);
if(!$id || !is_array($info) || !is_array($posts)) return false;
$this->check_filed($info,array('catid','title','addtime','status','flag','answercount','anonymity','hits','ischeck'));
$this->check_filed($posts,array('message'));
if($userid) $sql = " AND userid=$userid AND status<4";
$this->db->update($this->table, $info, "askid=$id $sql");
$this->search_api($id);
return $this->db->update($this->table_posts, $posts, "askid=$id $sql");
}
function check_filed($data,$fields)
{
foreach($data AS $k=>$v)
{
if(!in_array($k,$fields)) showmessage('鏃犳潈淇
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -