Beispiel #1
0
function friend_check($touids)
{
    global $_G;
    if (empty($_G['uid'])) {
        return false;
    }
    if (is_array($touids)) {
        $query = DB::query("SELECT fuid FROM " . DB::table('home_friend') . " WHERE uid='{$_G['uid']}' AND fuid IN (" . dimplode($touids) . ")");
        while ($value = DB::fetch($query)) {
            $touid = $value['fuid'];
            $var = "home_friend_{$_G['uid']}_{$touid}";
            $fvar = "home_friend_{$touid}_{$_G['uid']}";
            $_G[$var] = $_G[$fvar] = true;
        }
    } else {
        $touid = $touids;
        $var = "home_friend_{$_G['uid']}_{$touid}";
        $fvar = "home_friend_{$touid}_{$_G['uid']}";
        if (!isset($_G[$var])) {
            $friend = DB::fetch_first("SELECT fuid FROM " . DB::table('home_friend') . " WHERE uid='{$_G['uid']}' AND fuid='{$touid}'");
            $_G[$var] = $_G[$fvar] = $friend ? true : false;
        }
        return $_G[$var];
    }
}
function build_cache_fields_connect_register()
{
    global $_G;
    $data = array();
    $fields = array();
    if ($_G['setting']['connect']['register_gender']) {
        $fields[] = 'gender';
    }
    if ($_G['setting']['connect']['register_birthday']) {
        $fields[] = 'birthyear';
        $fields[] = 'birthmonth';
        $fields[] = 'birthday';
    }
    if ($fields) {
        $query = DB::query("SELECT * FROM " . DB::table('common_member_profile_setting') . " WHERE fieldid IN (" . dimplode($fields) . ")");
        while ($field = DB::fetch($query)) {
            $choices = array();
            if ($field['selective']) {
                foreach (explode("\n", $field['choices']) as $item) {
                    list($index, $choice) = explode('=', $item);
                    $choices[trim($index)] = trim($choice);
                }
                $field['choices'] = $choices;
            } else {
                unset($field['choices']);
            }
            $field['showinregister'] = 1;
            $field['available'] = 1;
            $data['field_' . $field['fieldid']] = $field;
        }
    }
    save_syscache('fields_connect_register', $data);
}
function build_cache_globalstick()
{
    $data = array();
    $query = C::t('forum_forum')->fetch_all_valid_forum();
    $fuparray = $threadarray = array();
    foreach ($query as $forum) {
        switch ($forum['type']) {
            case 'forum':
                $fuparray[$forum['fid']] = $forum['fup'];
                break;
            case 'sub':
                $fuparray[$forum['fid']] = $fuparray[$forum['fup']];
                break;
        }
    }
    foreach (C::t('forum_thread')->fetch_all_by_displayorder(array(2, 3)) as $thread) {
        switch ($thread['displayorder']) {
            case 2:
                $threadarray[$fuparray[$thread['fid']]][] = $thread['tid'];
                break;
            case 3:
                $threadarray['global'][] = $thread['tid'];
                break;
        }
    }
    foreach (array_unique($fuparray) as $gid) {
        if (!empty($threadarray[$gid])) {
            $data['categories'][$gid] = array('tids' => dimplode($threadarray[$gid]), 'count' => intval(@count($threadarray[$gid])));
        }
    }
    $data['global'] = array('tids' => empty($threadarray['global']) ? '' : dimplode($threadarray['global']), 'count' => intval(@count($threadarray['global'])));
    savecache('globalstick', $data);
}
function build_cache_globalstick()
{
    $data = array();
    $query = DB::query("SELECT fid, type, fup FROM " . DB::table('forum_forum') . " WHERE status='1' AND type IN ('forum', 'sub') ORDER BY type");
    $fuparray = $threadarray = array();
    while ($forum = DB::fetch($query)) {
        switch ($forum['type']) {
            case 'forum':
                $fuparray[$forum['fid']] = $forum['fup'];
                break;
            case 'sub':
                $fuparray[$forum['fid']] = $fuparray[$forum['fup']];
                break;
        }
    }
    $query = DB::query("SELECT tid, fid, displayorder FROM " . DB::table('forum_thread') . " WHERE fid>'0' AND displayorder IN (2, 3)");
    while ($thread = DB::fetch($query)) {
        switch ($thread['displayorder']) {
            case 2:
                $threadarray[$fuparray[$thread['fid']]][] = $thread['tid'];
                break;
            case 3:
                $threadarray['global'][] = $thread['tid'];
                break;
        }
    }
    foreach (array_unique($fuparray) as $gid) {
        if (!empty($threadarray[$gid])) {
            $data['categories'][$gid] = array('tids' => dimplode($threadarray[$gid]), 'count' => intval(@count($threadarray[$gid])));
        }
    }
    $data['global'] = array('tids' => empty($threadarray['global']) ? '' : dimplode($threadarray['global']), 'count' => intval(@count($threadarray['global'])));
    save_syscache('globalstick', $data);
}
 public function fetch_all_will_birthday_by_uid($uids)
 {
     $birthlist = array();
     if (!empty($uids)) {
         $uids = explode(',', (string) $uids);
         $uids = dimplode(dintval($uids, true));
         list($s_month, $s_day) = explode('-', dgmdate(TIMESTAMP - 3600 * 24 * 3, 'n-j'));
         list($n_month, $n_day) = explode('-', dgmdate(TIMESTAMP, 'n-j'));
         list($e_month, $e_day) = explode('-', dgmdate(TIMESTAMP + 3600 * 24 * 7, 'n-j'));
         if ($e_month == $s_month) {
             $wheresql = "sf.birthmonth='{$s_month}' AND sf.birthday>='{$s_day}' AND sf.birthday<='{$e_day}'";
         } else {
             $wheresql = "(sf.birthmonth='{$s_month}' AND sf.birthday>='{$s_day}') OR (sf.birthmonth='{$e_month}' AND sf.birthday<='{$e_day}' AND sf.birthday>'0')";
         }
         $query = DB::query("SELECT sf.uid,sf.birthyear,sf.birthmonth,sf.birthday,s.username\n\t\t\t\tFROM " . DB::table('common_member_profile') . " sf\n\t\t\t\tLEFT JOIN " . DB::table('common_member') . " s USING(uid)\n\t\t\t\tWHERE (sf.uid IN ({$uids})) AND ({$wheresql})");
         while ($value = DB::fetch($query)) {
             $value['istoday'] = 0;
             if ($value['birthmonth'] == $n_month && $value['birthday'] == $n_day) {
                 $value['istoday'] = 1;
             }
             $key = sprintf("%02d", $value['birthmonth']) . sprintf("%02d", $value['birthday']);
             $birthlist[$key][] = $value;
             ksort($birthlist);
         }
     }
     return $birthlist;
 }
Beispiel #6
0
 function usesubmit()
 {
     global $_G;
     $id = intval($_GET['id']);
     $idtype = $_GET['idtype'];
     $blog = magic_check_idtype($id, $idtype);
     $num = 10;
     $list = $ids = $note_inserts = array();
     $fusername = dimplode($_POST['fusername']);
     if ($fusername) {
         $query = C::t('home_friend')->fetch_all_by_uid_username($_G['uid'], $_POST['fusername'], 0, $num);
         $note = lang('spacecp', 'magic_call', array('url' => "home.php?mod=space&uid={$_G['uid']}&do=blog&id={$id}"));
         foreach ($query as $value) {
             $ids[] = $value['fuid'];
             $value['avatar'] = str_replace("'", "\\'", avatar($value[fuid], 'small'));
             $list[] = $value;
             $note_inserts[] = array('uid' => $value['fuid'], 'type' => $name, 'new' => 1, 'authorid' => $_G['uid'], 'author' => $_G['username'], 'note' => $note, 'dateline' => $_G['timestamp']);
         }
     }
     if (empty($ids)) {
         showmessage('magicuse_has_no_valid_friend');
     }
     foreach ($note_inserts as $note_insert) {
         C::t('home_notification')->insert($note_insert);
     }
     C::t('common_member')->increase($ids, array('newprompt' => 1));
     usemagic($this->magic['magicid'], $this->magic['num']);
     updatemagiclog($this->magic['magicid'], '2', '1', '0', '0', $idtype, $id);
     $op = 'show';
     include template('home/magic_call');
 }
 public function increase($tids, $fieldarr)
 {
     $tids = dintval((array) $tids, true);
     $sql = array();
     $num = 0;
     $allowkey = array('replies', 'lastposter', 'lastpost');
     foreach ($fieldarr as $key => $value) {
         if (in_array($key, $allowkey)) {
             if (is_array($value)) {
                 $sql[] = DB::field($key, $value[0]);
             } else {
                 $value = dintval($value);
                 $sql[] = "`{$key}`=`{$key}`+'{$value}'";
             }
         } else {
             unset($fieldarr[$key]);
         }
     }
     if ($getsetarr) {
         return $sql;
     }
     if (!empty($sql)) {
         $cmd = "UPDATE ";
         $num = DB::query($cmd . DB::table($this->_table) . " SET " . implode(',', $sql) . " WHERE tid IN (" . dimplode($tids) . ")", 'UNBUFFERED');
         $this->increase_cache($tids, $fieldarr);
     }
     return $num;
 }
 function usesubmit()
 {
     global $_G;
     $list = $uids = array();
     $num = !empty($this->parameters['num']) ? intval($this->parameters['num']) : 10;
     $limit = $num + 20;
     loadcache('magics');
     $mid = !empty($_G['magics']['gift']) ? intval($_G['magics']['gift']['magicid']) : 0;
     if ($mid) {
         $query = DB::query('SELECT * FROM ' . DB::table('common_magiclog') . " WHERE magicid = '{$mid}' AND action='2' AND uid != '{$_G['uid']}' ORDER BY dateline DESC LIMIT 0,{$limit}");
         while ($value = DB::fetch($query)) {
             $uids[] = intval($value['uid']);
         }
     }
     if ($uids) {
         $counter = 0;
         $query = DB::query('SELECT m.username, mfh.uid, mfh.magicgift FROM ' . DB::table('common_member') . " m LEFT JOIN " . DB::table('common_member_field_home') . " mfh USING(uid) WHERE m.uid IN (" . dimplode($uids) . ")");
         while ($value = DB::fetch($query)) {
             $info = !empty($value['magicgift']) ? unserialize($value['magicgift']) : array();
             if (!empty($info['left']) && (empty($info['receiver']) || !in_array($_G['uid'], $info['receiver']))) {
                 $value['avatar'] = addcslashes(avatar($value['uid'], 'small'), "'");
                 $list[$value['uid']] = $value;
                 $counter++;
                 if ($counter >= $num) {
                     break;
                 }
             }
         }
     }
     usemagic($this->magic['magicid'], $this->magic['num']);
     updatemagiclog($this->magic['magicid'], '2', '1', '0', '0', 'uid', $_G['uid']);
     $op = 'show';
     include template('home/magic_detector');
 }
Beispiel #9
0
 function usesubmit()
 {
     global $_G;
     $id = intval($_G['gp_id']);
     $idtype = $_G['gp_idtype'];
     $blog = magic_check_idtype($id, $idtype);
     $num = 10;
     $list = $ids = $note_inserts = array();
     $fusername = dimplode($_POST['fusername']);
     if ($fusername) {
         $query = DB::query('SELECT * FROM ' . DB::table('home_friend') . " WHERE uid='{$_G['uid']}' AND fusername IN (" . $fusername . ") LIMIT {$num}");
         $note = lang('spacecp', 'magic_call', array('url' => "home.php?mod=space&uid={$_G['uid']}&do=blog&id={$id}"));
         while ($value = DB::fetch($query)) {
             $ids[] = $value['fuid'];
             $value['avatar'] = str_replace("'", "\\'", avatar($value[fuid], 'small'));
             $list[] = $value;
             $note_inserts[] = "('{$value['fuid']}', '{$name}', '1', '{$_G['uid']}', '{$_G['username']}', '{$note}', '{$_G['timestamp']}')";
         }
     }
     if (empty($ids)) {
         showmessage('magicuse_has_no_valid_friend');
     }
     DB::query('INSERT INTO ' . DB::table('home_notification') . '(uid, type, new, authorid, author, note, dateline) VALUES ' . implode(',', $note_inserts));
     DB::query('UPDATE ' . DB::table('common_member') . ' SET newprompt = newprompt + 1 WHERE uid IN (' . dimplode($ids) . ')');
     usemagic($this->magic['magicid'], $this->magic['num']);
     updatemagiclog($this->magic['magicid'], '2', '1', '0', '0', $idtype, $id);
     $op = 'show';
     include template('home/magic_call');
 }
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     loadcache('portalcategory');
     $thecatid = !empty($parameter['thecatid']) ? explode(',', $parameter['thecatid']) : array();
     if (!empty($parameter['catid'])) {
         $catid = $parameter['catid'];
     } else {
         $catid = array_keys($_G['cache']['portalcategory']);
         $catid[] = '0';
     }
     $orderby = $parameter['orderby'] == 'articles' ? ' ORDER BY articles DESC' : ' ORDER BY displayorder';
     $wheres = array();
     if ($thecatid) {
         $wheres[] = "catid IN (" . dimplode($thecatid) . ")";
     }
     if ($catid) {
         $wheres[] = "upid IN (" . dimplode($catid) . ")";
     }
     $wheresql = $wheres ? implode(' AND ', $wheres) : '1';
     $list = array();
     $query = DB::query('SELECT * FROM ' . DB::table('portal_category') . " WHERE {$wheresql} {$orderby}");
     while ($data = DB::fetch($query)) {
         $list[] = array('id' => $data['catid'], 'idtype' => 'catid', 'title' => htmlspecialchars($data['catname']), 'url' => $_G['cache']['portalcategory'][$data['catid']]['caturl'], 'pic' => '', 'picflag' => '0', 'summary' => '', 'fields' => array('dateline' => $data['dateline'], 'articles' => $data['articles']));
     }
     return array('html' => '', 'data' => $list);
 }
Beispiel #11
0
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     $fups = isset($parameter['fups']) && !in_array(0, (array) $parameter['fups']) ? $parameter['fups'] : '';
     $orderby = isset($parameter['orderby']) ? in_array($parameter['orderby'], array('displayorder', 'threads', 'posts', 'todayposts')) ? $parameter['orderby'] : 'displayorder' : 'displayorder';
     $titlelength = isset($parameter['titlelength']) ? intval($parameter['titlelength']) : 40;
     $summarylength = isset($parameter['summarylength']) ? intval($parameter['summarylength']) : 80;
     $startrow = isset($parameter['startrow']) ? intval($parameter['startrow']) : 0;
     $items = !empty($parameter['items']) ? intval($parameter['items']) : 10;
     $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
     $sqlban = !empty($bannedids) ? ' AND f.fid NOT IN (' . dimplode($bannedids) . ')' : '';
     if (empty($fups)) {
         loadcache('forums');
         if (empty($_G['cache']['forums'])) {
             $fups = array('0');
         } else {
             $fups = array_keys($_G['cache']['forums']);
         }
     }
     $ffadd1 = ", ff.icon, ff.description";
     $ffadd2 = "LEFT JOIN `" . DB::table('forum_forumfield') . "` ff ON f.`fid`=ff.`fid`";
     $query = DB::query("SELECT f.* {$ffadd1}\r\n\t\t\tFROM `" . DB::table('forum_forum') . "` f {$ffadd2}\r\n\t\t\tWHERE\r\n\t\t\t" . ($fups ? "f.`fup` IN (" . dimplode($fups) . ") " : "1 ") . "\r\n\t\t\tAND f.`status`='1' AND f.`type`!='group'\r\n\t\t\t{$sqlban}\r\n\t\t\tORDER BY " . ($orderby == 'displayorder' ? "f.fup, f.`displayorder` ASC " : "f.`{$orderby}` DESC") . " LIMIT {$startrow}, {$items}");
     $datalist = $list = array();
     $attachurl = preg_match('/^(http|ftp|ftps|https):\\/\\//', $_G['setting']['attachurl']) ? $_G['setting']['attachurl'] : $_G['siteurl'] . $_G['setting']['attachurl'];
     while ($data = DB::fetch($query)) {
         if (!empty($data['icon'])) {
             $data['icon'] = preg_match('/^(http|ftp|ftps|https):\\/\\//', $data['icon']) ? $data['icon'] : $attachurl . 'common/' . $data['icon'];
         } else {
             $data['icon'] = 'static/image/common/forum_new.gif';
         }
         $list[] = array('id' => $data['fid'], 'idtype' => 'fid', 'title' => cutstr($data['name'], $titlelength, ''), 'url' => 'forum.php?mod=forumdisplay&fid=' . $data['fid'], 'pic' => '', 'summary' => cutstr($data['description'], $summarylength, ''), 'fields' => array('fulltitle' => $data['name'], 'icon' => $data['icon'], 'threads' => intval($data['threads']), 'posts' => intval($data['posts']), 'todayposts' => intval($data['todayposts'])));
     }
     return array('html' => '', 'data' => $list);
 }
Beispiel #12
0
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     $uids = isset($parameter['uids']) && !in_array(0, (array) $parameter['uids']) ? $parameter['uids'] : '';
     $startrow = isset($parameter['startrow']) ? intval($parameter['startrow']) : 0;
     $items = isset($parameter['items']) ? intval($parameter['items']) : 10;
     $titlelength = intval($parameter['titlelength']);
     $orderby = isset($parameter['orderby']) && in_array($parameter['orderby'], array('dateline', 'replynum')) ? $parameter['orderby'] : 'dateline';
     $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
     $datalist = $list = array();
     $wheres = array();
     if ($uids) {
         $wheres[] = 'uid IN (' . dimplode($uids) . ')';
     }
     if ($bannedids) {
         $wheres[] = 'doid NOT IN (' . dimplode($bannedids) . ')';
     }
     $wheres[] = " status = '0'";
     $wheresql = $wheres ? implode(' AND ', $wheres) : '1';
     $query = DB::query("SELECT * FROM " . DB::table('home_doing') . " WHERE {$wheresql} ORDER BY {$orderby} DESC LIMIT {$startrow},{$items}");
     while ($data = DB::fetch($query)) {
         $datalist = array('id' => $data['doid'], 'idtype' => 'doid', 'title' => cutstr(strip_tags($data['message']), $titlelength, ''), 'url' => 'home.php?mod=space&uid=' . $data['uid'] . '&do=doing&doid=' . $data['doid'], 'pic' => '', 'summary' => '', 'fields' => array('fulltitle' => strip_tags($data['message']), 'uid' => $data['uid'], 'username' => $data['username'], 'avatar' => avatar($data['uid'], 'small', true, false, false, $_G['setting']['ucenterurl']), 'avatar_middle' => avatar($data['uid'], 'middle', true, false, false, $_G['setting']['ucenterurl']), 'avatar_big' => avatar($data['uid'], 'big', true, false, false, $_G['setting']['ucenterurl']), 'dateline' => $data['dateline'], 'replynum' => $data['replynum']));
         if ($titlelength) {
             $datalist['title'] = cutstr(strip_tags($data['message']), $titlelength);
         } else {
             $datalist['title'] = strip_tags($data['message'], '<img>');
         }
         $list[] = $datalist;
     }
     return array('html' => '', 'data' => $list);
 }
 public function fetch_all_by_bid($bid, $isverified = 1, $start = 0, $limit = 0, $bannedids = array(), $format = true)
 {
     $data = array();
     if ($bid = dintval($bid, true)) {
         $addsql = $bannedids = dintval($bannedids, true) ? ' AND id NOT IN (' . dimplode($bannedids) . ')' : '';
         $query = DB::query('SELECT * FROM %t WHERE ' . DB::field('bid', $bid) . ' AND isverified=%d' . $addsql . ' ORDER BY stickgrade DESC, displayorder DESC, verifiedtime DESC, dataid DESC ' . DB::limit($start, $limit), array($this->_table, $isverified));
         while ($value = DB::fetch($query)) {
             if ($format) {
                 $value['fields'] = unserialize($value['fields']);
                 $value['fields']['timestamp'] = $value['fields']['dateline'];
                 $value['fields']['dateline'] = dgmdate($value['fields']['dateline']);
                 $value['pic'] = $value['pic'] !== STATICURL . 'image/common/nophoto.gif' ? $value['pic'] : '';
                 if ($value['pic'] && $value['picflag'] == '1') {
                     $value['pic'] = getglobal('setting/attachurl') . $value['pic'];
                 } elseif ($value['picflag'] == '2') {
                     $value['pic'] = getglobal('setting/ftp/attachurl') . $value['pic'];
                 }
                 $value['dateline'] = dgmdate($value['dateline'], 'u');
                 $value['verifiedtime'] = dgmdate($value['verifiedtime'], 'u');
             }
             $data[$value['id']] = $value;
         }
     }
     return $data;
 }
Beispiel #14
0
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     $uids = !empty($parameter['uids']) ? explode(',', $parameter['uids']) : array();
     $aids = !empty($parameter['aids']) ? explode(',', $parameter['aids']) : array();
     $catid = !empty($parameter['catid']) ? $parameter['catid'] : array();
     $startrow = isset($parameter['startrow']) ? intval($parameter['startrow']) : 0;
     $items = isset($parameter['items']) ? intval($parameter['items']) : 10;
     $titlelength = isset($parameter['titlelength']) ? intval($parameter['titlelength']) : 40;
     $orderby = isset($parameter['orderby']) && in_array($parameter['orderby'], array('dateline', 'picnum', 'updatetime')) ? $parameter['orderby'] : 'dateline';
     $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
     $list = array();
     $wheres = array();
     if ($aids) {
         $wheres[] = 'albumid IN (' . dimplode($aids) . ')';
     }
     if ($bannedids) {
         $wheres[] = 'albumid NOT IN (' . dimplode($bannedids) . ')';
     }
     if ($uids) {
         $wheres[] = 'uid IN (' . dimplode($uids) . ')';
     }
     if ($catid && !in_array('0', $catid)) {
         $wheres[] = 'catid IN (' . dimplode($catid) . ')';
     }
     $wheres[] = "friend = '0'";
     $wheresql = $wheres ? implode(' AND ', $wheres) : '1';
     $sql = "SELECT * FROM " . DB::table('home_album') . " WHERE {$wheresql} ORDER BY {$orderby} DESC";
     $query = DB::query($sql . " LIMIT {$startrow},{$items};");
     while ($data = DB::fetch($query)) {
         $list[] = array('id' => $data['albumid'], 'idtype' => 'albumid', 'title' => cutstr($data['albumname'], $titlelength, ''), 'url' => "home.php?mod=space&uid={$data['uid']}&do=album&id={$data['albumid']}", 'pic' => 'album/' . $data['pic'], 'picflag' => $data['picflag'], 'summary' => '', 'fields' => array('fulltitle' => $data['albumname'], 'uid' => $data['uid'], 'username' => $data['username'], 'dateline' => $data['dateline'], 'updatetime' => $data['updatetime'], 'picnum' => $data['picnum']));
     }
     return array('html' => '', 'data' => $list);
 }
 public function delete_by_did($dids)
 {
     if (!is_array($dids)) {
         $dids = array($dids);
     }
     return DB::delete($this->_table, "did IN (" . dimplode($dids) . ")");
 }
 public function update_by_type($types, $data)
 {
     if (!empty($types) && !empty($data) && is_array($data)) {
         $types = array_map('intval', (array) $types);
         return DB::update($this->_table, $data, "type IN (" . dimplode($types) . ")");
     }
     return 0;
 }
Beispiel #17
0
 function viewthread_posttop_output()
 {
     global $_G, $postlist;
     if (empty($postlist) || !is_array($postlist)) {
         return;
     }
     foreach ($postlist as $posts) {
         $pids[] = $posts['pid'];
         $return[$posts['pid']] = '';
     }
     $query = DB::query("SELECT * FROM " . DB::table('forum_post') . " WHERE pid in(" . dimplode($pids) . ") AND first=1");
     while ($table = DB::fetch($query)) {
         $tiddb = DB::fetch_first("SELECT * FROM " . DB::table('dsu_marcopostview') . " WHERE tid='{$_G['tid']}'");
         $thread_view = '<font color=' . $this->view_color . '>' . $_G['forum_thread']['views'] . '</font>';
         if ($tiddb['last_view'] == '&#65288;' . lang('plugin/dsu_marcopostview', 'class_php_6') . '&#65289;') {
             $view = "'" . lang('plugin/dsu_marcopostview', 'class_php_1') . "{$tiddb[guest]}" . lang('plugin/dsu_marcopostview', 'class_php_2') . "<br/>" . lang('plugin/dsu_marcopostview', 'class_php_3') . "{$tiddb[member]}" . lang('plugin/dsu_marcopostview', 'class_php_2') . "<br/>" . lang('plugin/dsu_marcopostview', 'class_php_4') . "{$tiddb[last_view]}'";
         } else {
             $view = "'" . lang('plugin/dsu_marcopostview', 'class_php_1') . "{$tiddb[guest]}" . lang('plugin/dsu_marcopostview', 'class_php_2') . "<br/>" . lang('plugin/dsu_marcopostview', 'class_php_3') . "{$tiddb[member]}" . lang('plugin/dsu_marcopostview', 'class_php_2') . "<br/>" . lang('plugin/dsu_marcopostview', 'class_php_4') . "<a href=\\'{$_G['siteurl']}home.php?mod=space&username="******"\\' target=\\'_blank\\'>{$tiddb[last_view]}</a>'";
         }
         if ($tiddb['guest'] + $tiddb['member'] <= 0) {
             $view_info = $thread_view;
         } else {
             $view_info = '<a href="javascript:;" onclick="showDialog(' . $view . ', \'notice\', \'' . lang('plugin/dsu_marcopostview', 'class_php_5') . '\', null, 0)">' . $thread_view . '</a>';
         }
         $_G['forum_thread']['dateline'] = dgmdate($_G['forum_thread']['dateline'], 'dt', $_G['setting']['timeoffset']);
         $find = array("{bbname}", "{author}", "{dateline}", "{view_info}");
         $replace = array($_G['setting']['bbname'], $_G['forum_thread']['author'], $_G['forum_thread']['dateline'], $view_info);
         $view_info = str_replace($find, $replace, $this->your_template);
         if ($this->open == 1) {
             if (!in_array($_G['fid'], $this->forums)) {
                 if (!$tiddb) {
                     DB::query("INSERT INTO " . DB::table('dsu_marcopostview') . " (tid,guest,member,last_view) VALUES ('{$_G['tid']}','0','0','{$_G['username']}')");
                 } else {
                     if ($_G['uid'] && $_G['session']['invisible'] == 0) {
                         DB::query("UPDATE " . DB::table('dsu_marcopostview') . " SET member=member+1,last_view='{$_G['username']}' WHERE tid='{$_G['tid']}'");
                     } elseif ($_G['uid'] && $_G['session']['invisible'] == 1) {
                         DB::query("UPDATE " . DB::table('dsu_marcopostview') . " SET member=member+1,last_view='&#65288;" . lang('plugin/dsu_marcopostview', 'class_php_6') . "&#65289;' WHERE tid='{$_G['tid']}'");
                     } elseif (!$_G['uid']) {
                         DB::query("UPDATE " . DB::table('dsu_marcopostview') . " SET guest=guest+1 WHERE tid='{$_G['tid']}'");
                     }
                 }
             }
         }
         if ($this->open == 1) {
             if ($this->forums == '') {
                 $return[$table['pid']] = "";
             } elseif (in_array($_G['fid'], $this->forums)) {
                 $return[$table['pid']] = "";
             } else {
                 $return[$table['pid']] = "{$view_info}<br />";
             }
         } else {
             $return[$table['pid']] = "";
         }
         return array_values($return);
     }
 }
Beispiel #18
0
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     $blogids = !empty($parameter['blogids']) ? explode(',', $parameter['blogids']) : array();
     $uids = !empty($parameter['uids']) ? explode(',', $parameter['uids']) : array();
     $catid = !empty($parameter['catid']) ? $parameter['catid'] : array();
     $startrow = isset($parameter['startrow']) ? intval($parameter['startrow']) : 0;
     $items = isset($parameter['items']) ? intval($parameter['items']) : 10;
     $hours = isset($parameter['hours']) ? intval($parameter['hours']) : '';
     $titlelength = $parameter['titlelength'] ? intval($parameter['titlelength']) : 40;
     $summarylength = $parameter['summarylength'] ? intval($parameter['summarylength']) : 80;
     $orderby = isset($parameter['orderby']) && in_array($parameter['orderby'], array('dateline', 'viewnum', 'replynum', 'hot')) ? $parameter['orderby'] : 'dateline';
     $picrequired = !empty($parameter['picrequired']) ? 1 : 0;
     $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
     $datalist = $list = array();
     $wheres = array();
     if ($blogids) {
         $wheres[] = 'b.blogid IN (' . dimplode($blogids) . ')';
     }
     if ($bannedids) {
         $wheres[] = 'b.blogid NOT IN (' . dimplode($bannedids) . ')';
     }
     if ($uids) {
         $wheres[] = 'b.uid IN (' . dimplode($uids) . ')';
     }
     if ($catid) {
         $wheres[] = 'b.catid IN (' . dimplode($catid) . ')';
     }
     if ($hours) {
         $timestamp = TIMESTAMP - 3600 * $hours;
         $wheres[] = "b.dateline >= '{$timestamp}'";
     }
     $tablesql = $fieldsql = '';
     if ($style['getpic'] || $style['getsummary'] || $picrequired) {
         if ($picrequired) {
             $wheres[] = "bf.pic != ''";
         }
         $tablesql = ' LEFT JOIN ' . DB::table('home_blogfield') . " bf ON b.blogid = bf.blogid";
         $fieldsql = ', bf.pic, b.picflag, bf.message';
     }
     $wheresql = $wheres ? implode(' AND ', $wheres) : '1';
     $sql = "SELECT b.* {$fieldsql} FROM " . DB::table('home_blog') . " b {$tablesql} WHERE {$wheresql} ORDER BY b.{$orderby} DESC";
     $query = DB::query($sql . " LIMIT {$startrow},{$items};");
     while ($data = DB::fetch($query)) {
         if (empty($data['pic'])) {
             $data['pic'] = STATICURL . 'image/common/nophoto.gif';
             $data['picflag'] = '0';
         } else {
             $data['pic'] = preg_replace('/\\.thumb\\.jpg$/', '', $data['pic']);
             $data['pic'] = 'album/' . $data['pic'];
             $data['picflag'] = $data['remote'] == '1' ? '2' : '1';
         }
         $list[] = array('id' => $data['blogid'], 'idtype' => 'blogid', 'title' => cutstr($data['subject'], $titlelength), 'url' => 'home.php?mod=space&uid=' . $data[uid] . '&do=blog&id=' . $data['blogid'], 'pic' => $data['pic'], 'picflag' => $data['picflag'], 'summary' => $data['message'] ? preg_replace("/&amp;[a-z]+\\;/i", '', cutstr(strip_tags($data['message']), $summarylength)) : '', 'fields' => array('dateline' => $data['dateline'], 'uid' => $data['uid'], 'username' => $data['username'], 'replynum' => $data['replynum'], 'viewnum' => $data['viewnum'], 'click1' => $data['click1'], 'click2' => $data['click2'], 'click3' => $data['click3'], 'click4' => $data['click4'], 'click5' => $data['click5'], 'click6' => $data['click6'], 'click7' => $data['click7'], 'click8' => $data['click8']));
     }
     return array('html' => '', 'data' => $list);
 }
Beispiel #19
0
 public function delete_by_pid($pids)
 {
     if (!$pids) {
         return false;
     }
     if (!is_array($pids)) {
         $pids = array($pids);
     }
     return DB::delete($this->_table, "pid IN (" . dimplode($pids) . ")");
 }
 public function delete_by_orgid($orgids)
 {
     if (!$orgids) {
         return;
     }
     if (!is_array($orgids)) {
         $orgids = array($orgids);
     }
     return DB::delete($this->_table, "orgid IN (" . dimplode($orgids) . ")");
 }
Beispiel #21
0
 public static function condSql($key, $value, $handle)
 {
     if (in_array($handle, array('>', '<', '>=', '<=', '!=', '<>'))) {
         $sql = "`{$key}` " . $handle . " '{$value}'";
     } elseif ($handle == 'IN') {
         $sql = "`{$key}` IN(" . dimplode($value) . ")";
     } elseif ($handle == 'LIKE') {
         $sql = "`{$key}` LIKE '%{$value}%'";
     } else {
         $sql = "`{$key}` = '{$value}'";
     }
     return $sql;
 }
 public function increase($catids, $data)
 {
     $catids = array_map('intval', (array) $catids);
     $sql = array();
     $allowkey = array('articles');
     foreach ($data as $key => $value) {
         if (($value = intval($value)) && in_array($key, $allowkey)) {
             $sql[] = "`{$key}`=`{$key}`+'{$value}'";
         }
     }
     if (!empty($sql)) {
         DB::query("UPDATE " . DB::table($this->_table) . " SET " . implode(',', $sql) . " WHERE catid IN (" . dimplode($catids) . ")", 'UNBUFFERED');
     }
 }
Beispiel #23
0
 public function increase($ids, $data)
 {
     $ids = array_map('intval', (array) $ids);
     $sql = array();
     $allowkey = array('commentnum', 'viewnum');
     foreach ($data as $key => $value) {
         if (($value = intval($value)) && in_array($key, $allowkey)) {
             $sql[] = "`{$key}`=`{$key}`+'{$value}'";
         }
     }
     if (!empty($sql)) {
         DB::query('UPDATE ' . DB::table($this->_table) . ' SET ' . implode(',', $sql) . ' WHERE topicid IN (' . dimplode($ids) . ')', 'UNBUFFERED');
     }
 }
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     loadcache('portalcategory');
     $catid = !empty($parameter['catid']) ? $parameter['catid'] : array_keys($_G['cache']['portalcategory']);
     $orderby = $parameter['orderby'] == 'articles' ? ' ORDER BY articles DESC' : ' ORDER BY displayorder';
     $list = array();
     $query = DB::query('SELECT * FROM ' . DB::table('portal_category') . " WHERE upid IN (" . dimplode($catid) . ") {$orderby}");
     while ($data = DB::fetch($query)) {
         $list[] = array('id' => $data['catid'], 'idtype' => 'catid', 'title' => $data['catname'], 'url' => 'portal.php?mod=list&catid=' . $data['catid'], 'pic' => '', 'picflag' => '0', 'summary' => '', 'fields' => array('dateline' => $data['dateline'], 'articles' => $data['articles']));
     }
     return array('html' => '', 'data' => $list);
 }
Beispiel #25
0
 public function delete_by_newid($newids)
 {
     $newids = (array) $newids;
     $ret = 0;
     $aids = array();
     $picids = array();
     foreach (DB::fetch_all("select picid,aid from %t where newid in (%n)", array($this->_table, $newids)) as $value) {
         $picids[] = $value['picid'];
         $aids[] = $value['aid'];
     }
     if ($aids) {
         C::t('attachment')->addcopy_by_aid($aids, -1);
     }
     return DB::delete($this->_table, "picid IN (" . dimplode($picids) . ")");
 }
 public function increase($uids, $setarr)
 {
     $uids = array_map('intval', (array) $uids);
     $sql = array();
     $allowkey = array('buyercredit', 'sellercredit', 'favtimes', 'sharetimes');
     foreach ($setarr as $key => $value) {
         if (($value = intval($value)) && in_array($key, $allowkey)) {
             $sql[] = "`{$key}`=`{$key}`+'{$value}'";
         }
     }
     if (!empty($sql)) {
         DB::query("UPDATE " . DB::table($this->_table) . " SET " . implode(',', $sql) . " WHERE uid IN (" . dimplode($uids) . ")", 'UNBUFFERED');
         $this->increase_cache($uids, $setarr);
     }
 }
Beispiel #27
0
 function _fetch_data($block_id)
 {
     global $_G, $postlist, $config, $authorid, $new_window, $tid, $hott;
     $db = DB::object();
     $tablepre = $db->tablepre;
     $limitforum = $config['disallow_fid'] ? ' AND fid NOT IN (' . dimplode(unserialize($config['disallow_fid'])) . ')' : '';
     $limit = $config['show_limit'] > 0 ? $config['show_limit'] : '6';
     $show_group = $config['show_group'] ? '' : ' AND isgroup=0';
     $date_limit = $config['date_limit'] == 0 ? '' : ' AND dateline>' . ($_G['timestamp'] - $config['date_limit'] * 86400);
     $query = DB::query("SELECT tid,highlight,subject FROM {$tablepre}forum_thread WHERE displayorder>-1 {$limitforum}{$date_limit}{$show_group} ORDER BY lastpost DESC LIMIT 0,{$limit}");
     while ($thread = DB::fetch($query)) {
         $hott_block[] = array('tid' => $thread['tid'], 'link' => "forum.php?mod=redirect&tid={$thread[tid]}&goto=lastpost#lastpost", 'link_info' => $new_window . $this->_sethighlight($thread['highlight']), 'subject' => cutstr($thread['subject'], $config['max_text']));
     }
     return (array) $hott_block;
 }
 public function clear_extcredits($uids, $extcredits)
 {
     $uids = dintval((array) $uids, true);
     $sql = $data = array();
     $allowkey = array('extcredits1', 'extcredits2', 'extcredits3', 'extcredits4', 'extcredits5', 'extcredits6', 'extcredits7', 'extcredits8');
     foreach ($extcredits as $value) {
         if (in_array($value, $allowkey, true)) {
             $sql[] = "`{$value}`='0'";
             $data[$value] = 0;
         }
     }
     if (!empty($sql)) {
         DB::query("UPDATE " . DB::table($this->_table) . " SET " . implode(',', $sql) . " WHERE uid IN (" . dimplode($uids) . ")", 'UNBUFFERED');
         $this->update_batch_cache($uids, $data);
     }
 }
Beispiel #29
0
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     $titlelength = !empty($parameter['titlelength']) ? intval($parameter['titlelength']) : 40;
     $startrow = !empty($parameter['startrow']) ? intval($parameter['startrow']) : '0';
     $items = !empty($parameter['items']) ? intval($parameter['items']) : 10;
     $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
     $bansql = $bannedids ? ' AND appid NOT IN (' . dimplode($bannedids) . ')' : '';
     $sql = 'SELECT * FROM ' . DB::table('common_myapp') . " WHERE flag>=0 {$bansql} ORDER BY flag DESC, displayorder LIMIT {$startrow}, {$items}";
     $query = DB::query($sql);
     while ($data = DB::fetch($query)) {
         $list[] = array('id' => $data['appid'], 'idtype' => 'appid', 'title' => cutstr(str_replace('\\\'', '&#39;', $data['appname']), $titlelength, ''), 'url' => 'userapp.php?id=' . $data['appid'], 'pic' => '', 'picflag' => '', 'summary' => '', 'fields' => array('icon' => 'http://appicon.manyou.com/logos/' . $data['appid'], 'icon_small' => 'http://appicon.manyou.com/icons/' . $data['appid'], 'icon_abouts' => 'http://appicon.manyou.com/abouts/' . $data['appid']));
     }
     return array('html' => '', 'data' => $list);
 }
Beispiel #30
0
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     $aids = !empty($parameter['aids']) ? explode(',', $parameter['aids']) : array();
     $uids = !empty($parameter['uids']) ? explode(',', $parameter['uids']) : array();
     $startrow = isset($parameter['startrow']) ? intval($parameter['startrow']) : 0;
     $items = isset($parameter['items']) ? intval($parameter['items']) : 10;
     $titlelength = isset($parameter['titlelength']) ? intval($parameter['titlelength']) : 40;
     $summarylength = isset($parameter['summarylength']) ? intval($parameter['summarylength']) : 80;
     $orderby = in_array($parameter['orderby'], array('dateline', 'viewnum', 'commentnum')) ? $parameter['orderby'] : 'dateline';
     $catid = !empty($parameter['catid']) && !in_array('0', $parameter['catid']) ? $parameter['catid'] : array();
     $picrequired = !empty($parameter['picrequired']) ? 1 : 0;
     $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
     loadcache('portalcategory');
     $list = array();
     $wheres = array();
     if ($aids) {
         $wheres[] = 'at.aid IN (' . dimplode($aids) . ')';
     }
     if ($uids) {
         $wheres[] = 'at.uid IN (' . dimplode($uids) . ')';
     }
     if ($catid) {
         $wheres[] = 'at.catid IN (' . dimplode($catid) . ')';
     }
     if ($style['getpic'] && $picrequired) {
         $wheres[] = "pic != ''";
     }
     if ($bannedids) {
         $wheres[] = 'at.aid NOT IN (' . dimplode($bannedids) . ')';
     }
     $wheresql = $wheres ? implode(' AND ', $wheres) : '1';
     $orderby = $orderby == 'dateline' ? 'at.dateline DESC ' : "ac.{$orderby} DESC";
     $query = DB::query("SELECT at.*, ac.viewnum, ac.commentnum FROM " . DB::table('portal_article_title') . " at LEFT JOIN " . DB::table('portal_article_count') . " ac ON at.aid=ac.aid WHERE {$wheresql} ORDER BY {$orderby} LIMIT {$startrow}, {$items}");
     while ($data = DB::fetch($query)) {
         if (empty($data['pic'])) {
             $data['pic'] = STATICURL . 'image/common/nophoto.gif';
             $data['picflag'] = '0';
         } else {
             $data['pic'] = 'portal/' . $data['pic'];
             $data['picflag'] = $data['remote'] == '1' ? '2' : '1';
         }
         $list[] = array('id' => $data['aid'], 'idtype' => 'aid', 'title' => cutstr($data['title'], $titlelength), 'url' => 'portal.php?mod=view&aid=' . $data['aid'], 'pic' => $data['pic'], 'picflag' => $data['picflag'], 'summary' => cutstr(strip_tags($data['summary']), $summarylength), 'fields' => array('dateline' => $data['dateline'], 'caturl' => 'portal.php?mod=list&catid=' . $data['catid'], 'catname' => $_G['cache']['portalcategory'][$data['catid']]['catname'], 'viewnum' => intval($data['viewnum']), 'commentnum' => intval($data['commentnum'])));
     }
     return array('html' => '', 'data' => $list);
 }