Ejemplo n.º 1
0
function msgboard_read_base($fields = "*", $condition = "", $get_type = "", $num = "", $by_col = "mess_id", $order = "desc", $cache = "", $cache_key = "")
{
    global $tablePreStr;
    global $page_num;
    global $page_total;
    global $cachePages;
    $t_msgboard = $tablePreStr . "msgboard";
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('r');
    $limit = $num ? " limit {$num} " : "";
    $by_col = $by_col ? " {$by_col} " : " mess_id ";
    $order = $order ? $order : "desc";
    $get_type = $get_type == 'getRow' ? "getRow" : "getRs";
    $sql = " select {$fields} from {$t_msgboard} where {$condition} order by {$by_col} {$order} {$limit} ";
    /*
    可以加入缓存机制
    */
    if (empty($result_rs)) {
        if ($limit == '') {
            $dbo->setPages(20, $page_num);
        }
        $result_rs = $dbo->{$get_type}($sql);
        $page_total = $dbo->totalPage;
    }
    return $result_rs;
}
Ejemplo n.º 2
0
function blog_read_base($fields = "*", $condition = "", $get_type = "", $num = "", $by_col = "log_id", $order = "desc", $cache = "", $cache_key = "")
{
    global $tablePreStr;
    global $page_num;
    global $page_total;
    global $is_self;
    $is_pass = '******';
    $is_admin = get_sess_admin();
    $t_blog = $tablePreStr . "blog";
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('r');
    $limit = $num ? " limit {$num} " : "";
    $by_col = $by_col ? " {$by_col} " : " log_id ";
    $order = $order ? $order : "desc";
    $get_type = $get_type == 'getRow' ? "getRow" : "getRs";
    $is_pass = $is_self == 'Y' || $is_admin ? '1' : $is_pass;
    $sql = " select {$fields} from {$t_blog} where {$is_pass} {$condition} order by {$by_col} {$order} {$limit} ";
    if (empty($result_rs)) {
        if ($limit == '') {
            $dbo->setPages(20, $page_num);
        }
        $result_rs = $dbo->{$get_type}($sql);
        $page_total = $dbo->totalPage;
    }
    return $result_rs;
}
Ejemplo n.º 3
0
function plugins_set_mine($id, $is_del = 0)
{
    $id = intval($id);
    $is_del = intval($is_del);
    $val = '';
    $uid = get_sess_userid();
    global $tablePreStr;
    $t_users = $tablePreStr . "users";
    $t_plugins = $tablePreStr . "plugins";
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('r');
    $u_apps = get_sess_apps();
    if ($is_del == 0) {
        if ($u_apps == '') {
            $val = $id;
        } else {
            $val = $u_apps . "," . $id;
        }
    } else {
        $val = str_replace(",{$id},", "", ",{$u_apps},");
    }
    $sql = " update {$t_users} set use_apps = '{$val}' where user_id = {$uid} ";
    if ($dbo->exeUpdate($sql)) {
        set_sess_apps($val);
        if ($is_del == 0) {
            $sql = " update {$t_plugins} set use_num=use_num+1 where id={$id} ";
        } else {
            $sql = " update {$t_plugins} set use_num=use_num-1 where id={$id} ";
        }
        return $dbo->exeUpdate($sql);
    } else {
        return 0;
    }
}
Ejemplo n.º 4
0
function inbox_read_base($fields = "*", $condition = "", $get_type = "", $num = "", $by_col = "mess_id", $order = "desc", $cache = "", $cache_key = "")
{
    global $tablePreStr;
    global $page_num;
    global $page_total;
    $uid = get_sess_userid();
    $t_scrip = $tablePreStr . "msg_inbox";
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('r');
    $by_col = $by_col ? " {$by_col} " : " mess_id ";
    $order = $order ? $order : "desc";
    $get_type = $get_type == 'getRow' ? "getRow" : "getRs";
    $sql = " select {$fields} from {$t_scrip} where user_id = {$uid} and mesinit_id!='' {$condition} order by {$by_col} {$order} ";
    if ($cache == 1 && $cache_key != '') {
        $key = 'inbox_' . $cache_key . $uid . '_' . $num;
        $key_mt = 'inbox_' . $cache_key . 'mt_' . $uid . '_' . $num;
        $result_rs = model_cache($key, $key_mt, $dbo, $sql, $get_type);
    }
    if (empty($result_rs)) {
        $dbo->setPages(20, $page_num);
        $result_rs = $dbo->{$get_type}($sql);
        $page_total = $dbo->totalPage;
    }
    return $result_rs;
}
Ejemplo n.º 5
0
function msgboard_set($to_user_id)
{
    global $tablePreStr;
    $dbo = new dbex();
    dbplugin('w');
    $t_message = $tablePreStr . "msgboard";
    $sql = "update {$t_message} set readed=1 where to_user_id='{$to_user_id}'";
    $dbo->exeUpdate($sql);
}
Ejemplo n.º 6
0
function user_get_user_point($user_id)
{
    global $tablePreStr;
    $t_users = $tablePreStr . "users";
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('r');
    $sql = "select user_point from {$t_users} where user_id={$user_id}";
    $result_rs = $dbo->getRow($sql);
    return $result_rs['user_point'];
}
Ejemplo n.º 7
0
function user_self_by_total()
{
    global $tablePreStr;
    $t_user = $tablePreStr . "users";
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('r');
    $sql = "select count(*) as total from {$t_user}";
    $result_rs = $dbo->getRow($sql);
    return $result_rs['total'];
}
Ejemplo n.º 8
0
function scrip_send($sender, $title, $content, $to_id, $scrip_id = '')
{
    global $tablePreStr;
    $uid = get_sess_userid();
    $uico = get_sess_userico();
    $t_scrip = $tablePreStr . "msg_inbox";
    $dbo = new dbex();
    dbplugin('w');
    $sql = "insert into {$t_scrip} (mess_title,mess_content,from_user,from_user_ico,user_id,add_time,from_user_id,mesinit_id)" . "value('{$title}','{$content}','{$sender}','{$uico}',{$to_id},NOW(),{$uid},'{$scrip_id}')";
    return $dbo->exeUpdate($sql);
}
Ejemplo n.º 9
0
function blog_sort_by_uid($id)
{
    global $tablePreStr;
    $t_blog = $tablePreStr . "blog_sort";
    $id = intval($id);
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('r');
    $sql = " select * from {$t_blog} where user_id = {$id} ";
    $result_rs = $dbo->getRs($sql);
    return $result_rs;
}
Ejemplo n.º 10
0
function user_set_update_user_point($user_id, $user_point)
{
    global $tablePreStr;
    $t_users = $tablePreStr . "users";
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('w');
    //update isns_users set user_point=2000 where user_id=1;
    $sql = "update {$t_users} set user_point={$user_point} where user_id={$user_id}";
    $result_rs = $dbo->exeUpdate($sql);
    return $result_rs;
}
Ejemplo n.º 11
0
function code_exists()
{
    $is_admin = '';
    $sendor_id = '';
    $admin_id = get_session('admin_id');
    if ($admin_id) {
        $is_admin = 1;
        $sendor_id = $admin_id;
    } else {
        $user_id = get_sess_userid();
        if (!$user_id) {
            return false;
            exit;
        }
        $is_admin = 0;
        $sendor_id = $user_id;
    }
    if ($sendor_id != '' && $is_admin !== '') {
        global $inviteCodeValue;
        global $tablePreStr;
        global $inviteCodeLength;
        $t_invite_code = $tablePreStr . "invite_code";
        $t_users = $tablePreStr . "users";
        if ($is_admin == 0) {
            $user_info = api_proxy('user_self_by_uid', 'integral', $sendor_id);
            $intg = $user_info['integral'];
            if ($inviteCodeValue > $intg) {
                return false;
            }
        }
        $dbo = new dbex();
        dbplugin('r');
        $invite_code = randkeys($inviteCodeLength);
        $sql = "select id from {$t_invite_code} where code_txt='{$invite_code}'";
        $is_exists = $dbo->getRow($sql);
        if ($is_exists['id']) {
            code_exists();
        } else {
            $time = time();
            $sql = "insert into {$t_invite_code} (sendor_id,code_txt,is_admin,add_time) values({$sendor_id},'{$invite_code}',0,{$time})";
            $success = $dbo->exeUpdate($sql);
            if ($success) {
                if ($is_admin == 0) {
                    $sql = "update {$t_users} set integral=integral-{$inviteCodeValue} where user_id={$sendor_id}";
                    $dbo->exeUpdate($sql);
                }
                return $invite_code;
            } else {
                return false;
            }
        }
    }
}
Ejemplo n.º 12
0
function money_set_add_user_money($user_id, $consume_point, $exchange_datetime, $exchange_money)
{
    global $tablePreStr;
    $t_money = $tablePreStr . "money";
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('w');
    //insert into isns_money (user_id, consume_point, exchange_datetime, exchange_money) value (1, 10, '2015-08-11 15:55:23', 33);
    $sql = "insert into {$t_money} (user_id, consume_point, exchange_datetime, exchange_money) \n\t\t\tvalue ({$user_id}, {$consume_point}, '{$exchange_datetime}', {$exchange_money})";
    $result_rs = $dbo->exeUpdate($sql);
    return $result_rs;
}
Ejemplo n.º 13
0
function pals_sort_def()
{
    global $tablePreStr;
    $t_pals_sort = $tablePreStr . "pals_def_sort";
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('r');
    $sql = " select * from {$t_pals_sort} ";
    $key = "pals_def_sort/list/order_num/0/all";
    $key_mt = "pals_def_sort/list/order_num/0/all_mt";
    $result_rs = model_cache($key, $key_mt, $dbo, $sql);
    if (empty($result_rs)) {
        $result_rs = $dbo->getALL($sql);
    }
    return $result_rs;
}
Ejemplo n.º 14
0
function group_sort_by_self()
{
    global $tablePreStr;
    $t_group_type = $tablePreStr . "group_type";
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('r');
    $sql = "select * from {$t_group_type} order by order_num desc";
    $key = "group_sort/list/order_num/0/all";
    $key_mt = 'group_sort/list/order_num/0/all_mt';
    $result_rs = model_cache($key, $key_mt, $dbo, $sql);
    if (empty($result_rs)) {
        $result_rs = $dbo->getRs($sql);
    }
    return $result_rs;
}
Ejemplo n.º 15
0
function plugins_get_pid($id, $get_type = '')
{
    global $tablePreStr;
    $t_plugins = $tablePreStr . "plugins";
    $t_plugin_url = $tablePreStr . "plugin_url";
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('r');
    $id_str = filt_num_array($id);
    $sql = "select a.*,b.url from {$t_plugins} as a join {$t_plugin_url} as b on (a.name=b.name) where a.id ={$id_str}";
    $get_type = $get_type ? $get_type : "getRow";
    if (strpos($id_str, ",")) {
        $sql = "select a.*,b.url from {$t_plugins} as a join {$t_plugin_url} as b on (a.name=b.name) where a.id in ({$id_str})";
        $get_type = "getRs";
    }
    return $dbo->{$get_type}($sql);
}
Ejemplo n.º 16
0
function scrip_notice_get($fields = "*", $num = "", $condition = "")
{
    global $tablePreStr;
    global $page_num;
    global $page_total;
    $fields = filt_fields($fields);
    $uid = get_sess_userid();
    $t_scrip = $tablePreStr . "msg_inbox";
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('r');
    $sql = " select {$fields} from {$t_scrip} where user_id = {$uid} and mesinit_id='' {$condition} order by mess_id desc ";
    $dbo->setPages(20, $page_num);
    $result_rs = $dbo->getRs($sql);
    $page_total = $dbo->totalPage;
    return $result_rs;
}
Ejemplo n.º 17
0
function check_pri($holder, $exp = '')
{
    $sess_uid = get_sess_userid();
    $is_admin = get_sess_admin();
    if ($sess_uid != $holder && !$is_admin) {
        if ($exp) {
            if (!$sess_uid) {
                return false;
            }
            if ($exp == '!all') {
                //全否定
                return false;
            }
            if (strpos(",{$exp}", "{")) {
                //限定人
                $per_str = preg_replace("/{([,\\d]+)}/", "\$1", $exp);
                if (strpos(",{$per_str}", ",{$sess_uid},")) {
                    return true;
                }
            }
            if (strpos(",{$exp}", "[")) {
                //限定组
                $sort_str = preg_replace("/\\[([,\\d]+)\\]/", "\$1", $exp);
                global $dbo;
                global $tablePreStr;
                global $dbServs;
                if (!$dbo) {
                    $dbo = new dbex();
                    dbplugin('r');
                }
                $table = $tablePreStr . "pals_mine";
                $sql = "select pals_sort_id from {$table} where pals_id={$sess_uid} and user_id={$holder}";
                $sort_id = $dbo->getRow($sql);
                $sess_sort_id = $sort_id['pals_sort_id'];
                if (strpos(",{$sort_str}", ",{$sess_sort_id},")) {
                    return true;
                }
            }
        } else {
            return true;
        }
    } else {
        return true;
    }
}
Ejemplo n.º 18
0
function group_self_by_pals($fields = "*")
{
    $fields = filt_fields($fields);
    $group_id_str = '';
    global $tablePreStr;
    $t_group_members = $tablePreStr . "group_members";
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('r');
    $pals_id = get_sess_mypals();
    $sql = " select group_id from {$t_group_members} where user_id in ({$pals_id}) ";
    $group_data = $dbo->getRs($sql);
    foreach ($group_data as $rs) {
        $group_id_str .= $rs['group_id'] . ",";
    }
    $group_id_str = preg_replace("/,\$/", "", $group_id_str);
    return group_self_by_gid($fields, $group_id_str);
}
Ejemplo n.º 19
0
function message_get_affair_uid($id, $type = '', $num = 20)
{
    $limit = intval($num) ? " limit {$num} " : "";
    $type_str = filt_num_array($type);
    $id_str = filt_num_array($id);
    $sql_type = "";
    if ($type_str != '') {
        $sql_type = " and mod_type in ({$type_str}) ";
    }
    global $tablePreStr;
    $t_recent_affair = $tablePreStr . "recent_affair";
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('r');
    $sql = "select * from {$t_recent_affair} where user_id in ({$id_str}) {$sql_type} order by id desc {$limit} ";
    $result_rs = $dbo->getALL($sql);
    return $result_rs;
}
Ejemplo n.º 20
0
function group_sub_read_base($fields = "*", $condition = "", $get_type = "", $num = "", $by_col = "subject_id", $order = "desc", $cache = "", $cache_key = "")
{
    global $tablePreStr;
    global $page_num;
    global $page_total;
    $t_group_subject = $tablePreStr . "group_subject";
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('r');
    $by_col = $by_col ? " {$by_col} " : " subject_id ";
    $order = $order ? $order : "desc";
    $get_type = $get_type ? "getRow" : "getRs";
    $sql = " select {$fields} from {$t_group_subject} where {$condition} order by {$by_col} {$order} ";
    if (empty($result_rs)) {
        $dbo->setPages(20, $page_num);
        $result_rs = $dbo->{$get_type}($sql);
        $page_total = $dbo->totalPage;
    }
    return $result_rs;
}
Ejemplo n.º 21
0
function user_recommend_base($fields = "*", $condition = "", $get_type = "", $num = "", $by_col = "rec_order", $order = "asc", $cache = "", $cache_key = "")
{
    global $tablePreStr;
    $t_recommend = $tablePreStr . "recommend";
    $fields_str = '';
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('r');
    $by_col = $by_col ? " {$by_col} " : " rec_order ";
    $order = $order ? $order : "asc";
    $get_type = $get_type == 'getRow' ? "getRow" : "getRs";
    $sql = " select {$fields} from {$t_recommend} where is_pass = 1 {$condition} order by {$by_col} {$order} ";
    //缓存机制
    $key = 'recommend/list/rec_order/all/0';
    $key_mt = 'recommend/list/rec_order/all/0_mt';
    $result_rs = model_cache($key, $key_mt, $dbo, $sql, $get_type);
    if (empty($result_rs)) {
        $result_rs = $dbo->{$get_type}($sql);
    }
    return $result_rs;
}
Ejemplo n.º 22
0
function tag_relation($mod_id, $tag_id, $content_id, $type = 'add')
{
    global $tablePreStr;
    global $dbo;
    $dbo = new dbex();
    dbplugin('w');
    $table = $tablePreStr . "tag_relation";
    $tag_id = explode(',', $tag_id);
    foreach ($tag_id as $rs) {
        if ($rs != '') {
            if ($type == 'add') {
                $sql = "insert into {$table} (`id`,`mod_id`,`content_id`) values ({$rs},{$mod_id},{$content_id})";
            } else {
                $sql = "delete from {$table} where content_id={$content_id} and id={$tag_id} and mod_id={$mod_id}";
            }
            if (!$dbo->exeUpdate($sql)) {
                return 'error';
                break;
            }
        }
    }
}
Ejemplo n.º 23
0
$comment_type = get_argp("comment_type");
//$user_id 	= get_session('user_id');
$commenter_id = get_sess_userid();
if (empty($commenter_id)) {
    header("location:error.php");
    exit;
}
$paper_id = get_argp("paper_id");
//数据表定义区
$t_comments = $tablePreStr . "comments";
$t_papers = $tablePreStr . "papers";
$current_time = date('y-m-d H:i:s', time());
$dbo = new dbex();
//增加评论数
//insert into isns_papers (user_id, content, picture, create_time) value (1, '纸条内容', '纸条路径', '2015-08-12 15:57:12');
dbplugin('r');
$get_comment_count_sql = "select {$t_papers}.comment_count,{$t_papers}.private_count from {$t_papers} where {$t_papers}.paper_id={$paper_id}";
$result_rs = $dbo->getRow($get_comment_count_sql);
$comment_count = $result_rs['comment_count'];
$private_count = $result_rs['private_count'];
if ($comment_type == 0) {
    $comment_count += 1;
} else {
    $private_count += 1;
}
//读写分离定义函数
dbtarget('w', $dbServs);
/* update isns_papers set isns_papers.comment_count = 3 where isns_papers.paper_id=111114; */
$update_comment_count_sql = "update {$t_papers} set {$t_papers}.comment_count={$comment_count},{$t_papers}.private_count={$private_count} where {$t_papers}.paper_id={$paper_id}";
if ($dbo->exeUpdate($update_comment_count_sql)) {
    //插入纸条评论
Ejemplo n.º 24
0
function paper_related_last_paper()
{
    global $tablePreStr;
    $t_papers = $tablePreStr . "papers";
    $result_rs = array();
    $dbo = new dbex();
    dbplugin('r');
    $sql = "select * from {$t_papers} where picture is not null and picture <> '' order by paper_id desc limit 5";
    $result_rs = $dbo->getALL($sql);
    return $result_rs;
}
Ejemplo n.º 25
0
function message_del_affair($rid)
{
    global $tablePreStr;
    $t_recent_affair = $tablePreStr . "recent_affair";
    $dbo = new dbex();
    dbplugin('w');
    $uid = get_sess_userid();
    $sql = "delete from {$t_recent_affair} where id={$rid} and user_id={$uid}";
    return $dbo->exeUpdate($sql);
}
Ejemplo n.º 26
0
function paper_get_pick_reasons($paper_id, $user_id)
{
    $paper_is_owned_user = paper_get_is_owned_user($user_id, $paper_id);
    global $tablePreStr;
    $t_users = $tablePreStr . "users";
    $t_comments = $tablePreStr . "comments";
    //评论类型
    $comment_type = 0;
    $paper_pick_reason_rs = array();
    $dbo = new dbex();
    dbplugin('r');
    $paper_comments_sql = "";
    if (1 == $paper_is_owned_user) {
        $paper_comments_sql = "select {$t_users}.*, {$t_comments}.* \n\tfrom {$t_comments}, {$t_users} where {$t_users}.user_id = {$t_comments}.commenter_id \n\tand {$t_comments}.paper_id = {$paper_id} and ({$t_comments}.comment_type=1 or {$t_comments}.comment_type=2) order by {$t_comments}.comment_time";
    } else {
        $paper_is_user_picked = paper_get_is_user_picked($paper_id, $user_id);
        if (1 == $paper_is_user_picked) {
            /*select isns_users.*, isns_comments.* 
            from isns_comments, isns_users where isns_users.user_id = isns_comments.commenter_id and isns_comments.commenter_id = 2
            and isns_comments.paper_id = 111113 and (isns_comments.comment_type=1 or isns_comments.comment_type=2) 
            order by isns_comments.comment_time*/
            $paper_comments_sql = "select {$t_users}.*, {$t_comments}.* \n\tfrom {$t_comments}, {$t_users} where {$t_users}.user_id = {$t_comments}.commenter_id and {$t_comments}.commenter_id = {$user_id}\n\tand {$t_comments}.paper_id = {$paper_id} and ({$t_comments}.comment_type=1 or {$t_comments}.comment_type=2) order by {$t_comments}.comment_time";
        } else {
            return null;
        }
    }
    $paper_pick_reason_rs = $dbo->getALL($paper_comments_sql);
    $re_pick_reasons = array();
    foreach ($paper_pick_reason_rs as $_ => $paper_reason) {
        $commenter_id = $paper_reason['commenter_id'];
        if (null == $re_pick_reasons[$commenter_id]) {
            $re_pick_reasons[$commenter_id] = array();
        }
        $re_pick_reasons[$commenter_id][] = $paper_reason;
    }
    return $re_pick_reasons;
}
Ejemplo n.º 27
0
function pals_self_isset($holder_id, $pals_id = '')
{
    global $tablePreStr;
    $t_pals = $tablePreStr . "pals_mine";
    $result_rs = array();
    $pals_id = $pals_id ? $pals_id : get_sess_userid();
    if ($pals_id) {
        $dbo = new dbex();
        dbplugin('r');
        $sql = "select id from {$t_pals} where user_id={$holder_id} and pals_id={$pals_id}";
        $result_rs = $dbo->getRow($sql);
    } else {
        $result_rs = 0;
    }
    return $result_rs;
}