Example #1
0
function foo()
{
    $x = new C();
    $y = $x->simpleRet($x);
    var_dump($x);
    var_dump($y);
}
Example #2
0
function main()
{
    print "Test begin\n";
    foo();
    // Tricky case: $this is the last reference
    $x = new C();
    $x->bluh();
    print "Test end\n";
}
Example #3
0
function main()
{
    $c = new C();
    for ($i = 0; $i < 3; $i++) {
        test();
        foo();
        $c->snoot();
        if ($i == 1) {
            fb_intercept('foo', 'bar', false);
            fb_intercept('C::__call', 'swizzle');
        }
    }
}
Example #4
0
 public function testSiblings()
 {
     $node = new Node();
     $node->appendChild($a = new A());
     $b = new B($node);
     $node->prependChild($c = new C());
     $node->appendChild($d = new D());
     $a->remove();
     $this->assertSame(null, $c->getPreviousSibling());
     $this->assertSame($b, $c->getNextSibling());
     $this->assertSame(null, $d->getNextSibling());
     $this->assertSame($b, $d->getPreviousSibling());
     $this->assertSame($c, $b->getPreviousSibling());
     $this->assertSame($d, $b->getNextSibling());
 }
Example #5
0
 private static function _loadConfig($confFile)
 {
     $confFile = C::filterChars($confFile);
     $file = CONF_PATH . DS . $confFile . '.php';
     $res = C::loadFile($file);
     return $res;
 }
Example #6
0
 public function setType($data)
 {
     if (!is_string($data) || !array_key_exists($data, C::g('MENUITEM_TYPE'))) {
         throw new Exception('INVALID MENUITEM TYPE PARAMETER', 500);
     }
     $this->type = $data;
 }
Example #7
0
 public function yar()
 {
     var_dump(isset($this));
     $obj = new static();
     var_dump($obj->cls);
     C::yar();
 }
Example #8
0
 function usesubmit()
 {
     global $_G;
     $id = intval($_GET['id']);
     if (empty($id)) {
         showmessage(lang('magic/namepost', 'namepost_info_nonexistence'));
     }
     $idtype = !empty($_GET['idtype']) ? dhtmlspecialchars($_GET['idtype']) : '';
     if (!in_array($idtype, array('pid', 'cid'))) {
         showmessage(lang('magic/namepost', 'namepost_use_error'));
     }
     if ($idtype == 'pid') {
         $_G['tid'] = intval($_GET['ptid']);
         $post = getpostinfo($id, 'pid', array('p.first', 'p.tid', 'p.fid', 'p.authorid', 'p.dateline', 'p.anonymous'));
         $this->_check($post);
         $authorid = $post['authorid'];
         $author = $post['anonymous'] ? '' : 1;
     } elseif ($idtype == 'cid') {
         $comment = C::t('home_comment')->fetch($id);
         $authorid = $comment['authorid'];
         $author = $comment['author'];
     }
     if ($author) {
         showmessage('magicuse_bad_object');
     }
     $member = getuserbyuid($authorid);
     if (!checkmagicperm($this->parameters['targetgroups'], $member['groupid'])) {
         showmessage(lang('magic/namepost', 'namepost_info_user_noperm'));
     }
     $author = daddslashes($member['username']);
     usemagic($this->magic['magicid'], $this->magic['num']);
     updatemagiclog($this->magic['magicid'], '2', '1', '0', 0, $idtype, $id);
     showmessage(lang('magic/namepost', 'magic_namepost_succeed'), 'javascript:;', array('uid' => $authorid, 'username' => $author, 'avatar' => 1), array('alert' => 'right'));
 }
Example #9
0
 public function onConnectSetConfig($data)
 {
     global $_G;
     $settingFields = array('connectappid', 'connectappkey');
     if (!$data) {
         return false;
     }
     $setting = C::t('common_setting')->fetch_all(array('connect'));
     $connectData = (array) dunserialize($setting['connect']);
     if (!is_array($connectData)) {
         $connectData = array();
     }
     $settings = array();
     foreach ($data as $k => $v) {
         if (in_array($k, $settingFields)) {
             $settings[$k] = $v;
         } else {
             $connectData[$k] = $v;
         }
     }
     if ($connectData) {
         $settings['connect'] = $connectData;
     }
     if ($settings) {
         C::t('common_setting')->update_batch($settings);
         return true;
     }
     return false;
 }
Example #10
0
 function usesubmit()
 {
     global $_G;
     $idtype = !empty($_GET['idtype']) ? $_GET['idtype'] : '';
     if (!in_array($idtype, $this->idtypearray)) {
         showmessage(lang('magic/highlight', 'highlight_info_notype'), dreferer(), array(), array('showdialog' => 1, 'locationtime' => true));
     }
     if (empty($_GET['id'])) {
         showmessage(lang('magic/highlight', 'highlight_info_nonexistence_' . $idtype));
     }
     if ($idtype == 'tid') {
         $info = getpostinfo($_GET['id'], $idtype, array('fid', 'authorid', 'subject'));
         $this->_check($info['fid']);
         magicthreadmod($_GET['id']);
         C::t('forum_thread')->update($_GET['id'], array('highlight' => $_GET['highlight_color'], 'moderated' => 1));
         $this->parameters['expiration'] = $this->parameters['expiration'] ? intval($this->parameters['expiration']) : 24;
         $expiration = TIMESTAMP + $this->parameters['expiration'] * 3600;
         updatemagicthreadlog($_GET['id'], $this->magic['magicid'], $expiration > 0 ? 'EHL' : 'HLT', $expiration);
         if ($info['authorid'] != $_G['uid']) {
             notification_add($info['authorid'], 'magic', lang('magic/highlight', 'highlight_notification'), array('tid' => $_GET['id'], 'subject' => $info['subject'], 'magicname' => $this->magic['name']));
         }
     } elseif ($idtype == 'blogid') {
         $info = getpostinfo($_GET['id'], $idtype, array('uid', 'subject'));
         C::t('home_blogfield')->update($_GET['id'], array('magiccolor' => $_GET['highlight_color']));
         if ($info['uid'] != $_G['uid']) {
             notification_add($info['uid'], 'magic', lang('magic/highlight', 'highlight_notification_blogid'), array('blogid' => $_GET['id'], 'subject' => $info['subject'], 'magicname' => $this->magic['name']));
         }
     }
     usemagic($this->magic['magicid'], $this->magic['num']);
     updatemagiclog($this->magic['magicid'], '2', '1', '0', 0, $idtype, $_GET['id']);
     showmessage(lang('magic/highlight', 'highlight_succeed_' . $idtype), dreferer(), array(), array('alert' => 'right', 'showdialog' => 1, 'locationtime' => true));
 }
 function common()
 {
     global $_G;
     if ($_GET['do'] == 'recommend') {
         if (!$_GET['hash'] || FORMHASH != $_GET['hash'] || !$_GET['pid'] || !$_GET['tid'] || !$_G['uid']) {
             mobile_core::result(mobile_core::variable(array('result' => -1)));
         }
         $_G['wechat']['setting'] = unserialize($_G['setting']['mobilewechat']);
         if (!$_G['wechat']['setting']['wsq_allow'] || !in_array($_GET['tid'], (array) $_G['wechat']['setting']['showactivity']['tids'])) {
             mobile_core::result(mobile_core::variable(array('result' => -2)));
         }
         $postinfo = C::t('forum_post')->fetch('tid:' . $_GET['tid'], $_GET['pid']);
         if (!$postinfo) {
             mobile_core::result(mobile_core::variable(array('result' => -3)));
         }
         $post = C::t('forum_debatepost')->fetch($_GET['pid']);
         if (!$post) {
             C::t('forum_debatepost')->insert(array('pid' => $_GET['pid'], 'tid' => $_GET['tid'], 'dateline' => TIMESTAMP, 'stand' => 0, 'voters' => 1, 'voterids' => "{$_G['uid']}\t"));
             mobile_core::result(mobile_core::variable(array('result' => 1)));
         } elseif (strpos("\t" . $post['voterids'], "\t{$_G['uid']}\t") === FALSE) {
             C::t('forum_debatepost')->update_voters($_GET['pid'], $_G['uid']);
             mobile_core::result(mobile_core::variable(array('result' => 1)));
         } else {
             mobile_core::result(mobile_core::variable(array('result' => 0)));
         }
     }
 }
Example #12
0
 public static function update($data)
 {
     //CHECK
     $checks = array('defaultLanguage' => 'is_string-!is_empty', 'availableLanguages' => 'is_array-!is_empty', 'defaultBaseUrl' => 'is_string-!is_empty', 'availableBaseUrl' => 'is_array-!is_empty');
     if (!KLib\Validator::arrayCheck($data, $checks)) {
         throw new Exception('INVALID CONFIG DATA', 500);
     }
     if (!array_key_exists($data['defaultLanguage'], C::g('LIST_LANGUAGE'))) {
         throw new Exception('INVALID CONFIG DATA', 500);
     }
     foreach ($data['availableLanguages'] as $id) {
         if (!array_key_exists(strtoupper($id), C::g('LIST_LANGUAGE'))) {
             throw new Exception('INVALID CONFIG DATA', 500);
         }
         $availableLanguages[] = "'" . strtoupper($id) . "'";
     }
     if (!filter_var('http://' . $data['defaultBaseUrl'], FILTER_VALIDATE_URL)) {
         throw new Exception('INVALID CONFIG DATA', 500);
     }
     foreach ($data['availableBaseUrl'] as $id) {
         if (!filter_var('http://' . $id, FILTER_VALIDATE_URL)) {
             throw new Exception('INVALID CONFIG DATA', 500);
         }
         $availableBaseUrls[] = "'" . $id . "'";
     }
     $raw = "<?php\n### Default language\n### Index of LIST_LANGUAGE\nC::s('DEFAULT_LANG', '" . $data['defaultLanguage'] . "');\n### Language available\n### List of index of LIST_LANGUAGE\nC::s('DEFAULT_AVAILABLE_LANG', array(" . implode(', ', $availableLanguages) . "));\n###  Default baseUrl\n### eg. 'www.korona.io'\nC::s('DEFAULT_BASEURL', '" . $data['defaultBaseUrl'] . "');\n###  List of available baseUrl\n### eg. 'www.korona.io'\nC::s('DEFAULT_AVAILABLE_BASEURL', array(" . implode(', ', $availableBaseUrls) . "));";
     return file_put_contents(self::$configPath, $raw);
 }
Example #13
0
 function usesubmit()
 {
     global $_G;
     $list = $uids = array();
     $num = !empty($this->parameters['num']) ? intval($this->parameters['num']) : 10;
     $limit = $num + 20;
     $giftMagicID = C::t('common_magic')->fetch_by_identifier('gift');
     $mid = $giftMagicID['available'] ? intval($giftMagicID['magicid']) : 0;
     if ($mid) {
         foreach (C::t('common_magiclog')->fetch_all_by_magicid_action_uid($mid, 2, $_G['uid'], 0, $limit) as $value) {
             $uids[] = intval($value['uid']);
         }
     }
     if ($uids) {
         $counter = 0;
         $members = C::t('common_member')->fetch_all($uids);
         foreach (C::t('common_member_field_home')->fetch_all($uids) as $uid => $value) {
             $value = array_merge($members[$uid], $value);
             $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($uid, 'small'), "'");
                 $list[$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');
 }
 public function __construct($attributes = null)
 {
     if ($attributes !== null) {
         C::guardIsArray($attributes);
     }
     $this->_attributes = $attributes;
 }
Example #15
0
 function getdata($style, $parameter)
 {
     $advid = 0;
     if (!empty($parameter['title'])) {
         $adv = C::t('common_advertisement_custom')->fetch_by_name($parameter['title']);
         if (empty($adv)) {
             $advid = C::t('common_advertisement_custom')->insert(array('name' => $parameter['title']), true);
         } else {
             $advid = $adv['id'];
         }
     } elseif (!empty($parameter['adv'])) {
         $adv = C::t('common_advertisement_custom')->fetch_by_name($parameter['adv']);
         $advid = intval($adv['id']);
     } else {
         $return = 'Empty Ads';
     }
     if ($advid) {
         $flag = false;
         if (getglobal('inajax')) {
             $flag = true;
             setglobal('inajax', 0);
         }
         $return = adshow('custom_' . $advid);
         if ($flag) {
             setglobal('inajax', 1);
         }
     }
     return array('html' => $return, 'data' => null);
 }
Example #16
0
 function getsetting()
 {
     global $_G;
     $settings = array('fids' => array('title' => 'couplebanner_fids', 'type' => 'mselect', 'value' => array()), 'groups' => array('title' => 'couplebanner_groups', 'type' => 'mselect', 'value' => array()), 'category' => array('title' => 'couplebanner_category', 'type' => 'mselect', 'value' => array()), 'position' => array('title' => 'couplebanner_position', 'type' => 'mradio', 'value' => array(array(1, 'couplebanner_position_left'), array(2, 'couplebanner_position_right')), 'default' => 1), 'coupleadid' => array('title' => 'couplebanner_coupleadid', 'type' => 'select', 'value' => array()), 'disableclose' => array('title' => 'couplebanner_disableclose', 'type' => 'mradio', 'value' => array(array(0, 'couplebanner_show'), array(1, 'couplebanner_hidden')), 'default' => 0));
     loadcache(array('forums', 'grouptype'));
     $settings['fids']['value'][] = $settings['groups']['value'][] = array(0, '&nbsp;');
     $settings['fids']['value'][] = $settings['groups']['value'][] = array(-1, 'couplebanner_index');
     if (empty($_G['cache']['forums'])) {
         $_G['cache']['forums'] = array();
     }
     foreach ($_G['cache']['forums'] as $fid => $forum) {
         $settings['fids']['value'][] = array($fid, ($forum['type'] == 'forum' ? str_repeat('&nbsp;', 4) : ($forum['type'] == 'sub' ? str_repeat('&nbsp;', 8) : '')) . $forum['name']);
     }
     foreach ($_G['cache']['grouptype']['first'] as $gid => $group) {
         $settings['groups']['value'][] = array($gid, str_repeat('&nbsp;', 4) . $group['name']);
         if ($group['secondlist']) {
             foreach ($group['secondlist'] as $sgid) {
                 $settings['groups']['value'][] = array($sgid, str_repeat('&nbsp;', 8) . $_G['cache']['grouptype']['second'][$sgid]['name']);
             }
         }
     }
     foreach (C::t('common_advertisement')->fetch_all_by_type('couplebanner') as $couple) {
         $settings['coupleadid']['value'][] = array($couple['advid'], $couple['title']);
     }
     loadcache('portalcategory');
     $this->categoryvalue[] = array(-1, 'couplebanner_index');
     $this->getcategory(0);
     $settings['category']['value'] = $this->categoryvalue;
     return $settings;
 }
 public function fetch_all($uids, $force_from_db = false, $fetch_archive = 1)
 {
     $data = array();
     if (!empty($uids)) {
         if ($force_from_db || ($data = $this->fetch_cache($uids)) === false || count($uids) != count($data)) {
             if (is_array($data) && !empty($data)) {
                 $uids = array_diff($uids, array_keys($data));
             }
             if ($data === false) {
                 $data = array();
             }
             if (!empty($uids)) {
                 $query = DB::query('SELECT ' . implode(',', $this->_fields) . ' FROM ' . DB::table($this->_table) . ' WHERE ' . DB::field($this->_pk, $uids));
                 while ($value = DB::fetch($query)) {
                     $data[$value[$this->_pk]] = $value;
                     $this->store_cache($value[$this->_pk], $value);
                 }
             }
         }
         if (isset($this->membersplit) && $fetch_archive && count($data) != count($uids)) {
             $data = $data + C::t($this->_table . '_archive')->fetch_all(array_diff($uids, array_keys($data)), null, 0);
         }
     }
     return $data;
 }
Example #18
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');
 }
Example #19
0
 function csc($task = array())
 {
     global $_G;
     $taskvars = array('num' => 0);
     $num = 0;
     foreach (C::t('common_taskvar')->fetch_all_by_taskid($task['taskid']) as $taskvar) {
         if ($taskvar['value']) {
             $taskvars[$taskvar['variable']] = $taskvar['value'];
         }
     }
     $taskvars['time'] = floatval($taskvars['time']);
     if ($taskvars['act'] == 'favorite') {
         $favorite = C::t('forum_spacecache')->fetch($_G['uid'], 'favorite' . $task['taskid']);
         $favorite = $favorite['value'];
         $num = C::t('home_favorite')->count_by_uid_idtype($_G['uid'], 'tid') - $favorite;
     } elseif ($taskvars['act'] == 'magic') {
         $maxtime = $taskvars['time'] ? $task['applytime'] + 3600 * $taskvars['time'] : 0;
         $num = C::t('common_magiclog')->count_by_action_uid_dateline(2, $_G['uid'], $task['applytime'], $maxtime);
     } elseif ($taskvars['act'] == 'userapp') {
         $userapp = C::t('forum_spacecache')->fetch($_G['uid'], 'userapp' . $task['taskid']);
         $userapp = $userapp['value'];
         $num = C::t('home_userapp')->count_by_uid($_G['uid']) - $userapp;
     }
     if ($num && $num >= $taskvars['num']) {
         if ($taskvars['act'] == 'favorite' || $taskvars['act'] == 'userapp') {
             C::t('forum_spacecache')->delete($_G['uid'], $taskvars['act'] . $task['taskid']);
         }
         return TRUE;
     } elseif ($taskvars['time'] && TIMESTAMP >= $task['applytime'] + 3600 * $taskvars['time'] && (!$num || $num < $taskvars['num'])) {
         return FALSE;
     } else {
         return array('csc' => $num > 0 && $taskvars['num'] ? sprintf("%01.2f", $num / $taskvars['num'] * 100) : 0, 'remaintime' => $taskvars['time'] ? $task['applytime'] + $taskvars['time'] * 3600 - TIMESTAMP : 0);
     }
 }
Example #20
0
function build_cache_heats()
{
    global $_G;
    $addsql = '';
    $data = array();
    if (discuz_process::islocked('update_heats_list')) {
        return false;
    }
    if ($_G['setting']['indexhot']['status']) {
        require_once libfile('function/post');
        $_G['setting']['indexhot'] = array('status' => 1, 'limit' => intval($_G['setting']['indexhot']['limit'] ? $_G['setting']['indexhot']['limit'] : 10), 'days' => intval($_G['setting']['indexhot']['days'] ? $_G['setting']['indexhot']['days'] : 7), 'expiration' => intval($_G['setting']['indexhot']['expiration'] ? $_G['setting']['indexhot']['expiration'] : 900), 'messagecut' => intval($_G['setting']['indexhot']['messagecut'] ? $_G['setting']['indexhot']['messagecut'] : 200));
        $messageitems = 2;
        $limit = $_G['setting']['indexhot']['limit'];
        foreach (C::t('forum_thread')->fetch_all_heats() as $heat) {
            $post = C::t('forum_post')->fetch_threadpost_by_tid_invisible($heat['tid']);
            $heat = array_merge($heat, (array) $post);
            if ($limit == 0) {
                break;
            }
            if ($messageitems > 0) {
                $heat['message'] = !$heat['price'] ? messagecutstr($heat['message'], $_G['setting']['indexhot']['messagecut']) : '';
                $data['message'][$heat['tid']] = $heat;
            } else {
                unset($heat['message']);
                $data['subject'][$heat['tid']] = $heat;
            }
            $messageitems--;
            $limit--;
        }
        $data['expiration'] = TIMESTAMP + $_G['setting']['indexhot']['expiration'];
    }
    savecache('heats', $data);
    discuz_process::unlock('update_heats_list');
}
Example #21
0
function build_cache_usergroups_single()
{
    $pluginvalue = pluginsettingvalue('groups');
    $allowthreadplugin = C::t('common_setting')->fetch('allowthreadplugin', true);
    $data_uf = C::t('common_usergroup_field')->range();
    $data_ag = C::t('common_admingroup')->range();
    foreach (C::t('common_usergroup')->range() as $gid => $data) {
        $data = array_merge($data, (array) $data_uf[$gid], (array) $data_ag[$gid]);
        $ratearray = array();
        if ($data['raterange']) {
            foreach (explode("\n", $data['raterange']) as $rating) {
                $rating = explode("\t", $rating);
                $ratearray[$rating[0]] = array('isself' => $rating[1], 'min' => $rating[2], 'max' => $rating[3], 'mrpd' => $rating[4]);
            }
        }
        $data['raterange'] = $ratearray;
        $data['grouptitle'] = $data['color'] ? '<font color="' . $data['color'] . '">' . $data['grouptitle'] . '</font>' : $data['grouptitle'];
        $data['grouptype'] = $data['type'];
        $data['grouppublic'] = $data['system'] != 'private';
        $data['groupcreditshigher'] = $data['creditshigher'];
        $data['groupcreditslower'] = $data['creditslower'];
        $data['maxspacesize'] = intval($data['maxspacesize']) * 1024 * 1024;
        $data['allowthreadplugin'] = !empty($allowthreadplugin[$data['groupid']]) ? $allowthreadplugin[$data['groupid']] : array();
        $data['plugin'] = $pluginvalue[$data['groupid']];
        unset($data['type'], $data['system'], $data['creditshigher'], $data['creditslower'], $data['groupavatar'], $data['admingid']);
        savecache('usergroup_' . $data['groupid'], $data);
    }
}
function build_cache_styles()
{
    global $_G;
    $stylevars = $styledata = array();
    $defaultstyleid = $_G['setting']['styleid'];
    foreach (C::t('common_stylevar')->range() as $var) {
        $stylevars[$var['styleid']][$var['variable']] = $var['substitute'];
    }
    foreach (C::t('common_style')->fetch_all_data(true) as $data) {
        $data['tpldir'] = $data['directory'];
        $data = array_merge($data, (array) $stylevars[$data['styleid']]);
        $datanew = array();
        $data['imgdir'] = $data['imgdir'] ? $data['imgdir'] : STATICURL . 'image/common';
        $data['styleimgdir'] = $data['styleimgdir'] ? $data['styleimgdir'] : $data['imgdir'];
        foreach ($data as $k => $v) {
            if (substr($k, -7, 7) == 'bgcolor') {
                $newkey = substr($k, 0, -7) . 'bgcode';
                $datanew[$newkey] = setcssbackground($data, $k);
            }
        }
        $data = array_merge($data, $datanew);
        if (strstr($data['boardimg'], ',')) {
            $flash = explode(",", $data['boardimg']);
            $flash[0] = trim($flash[0]);
            $flash[0] = preg_match('/^http:\\/\\//i', $flash[0]) ? $flash[0] : $data['styleimgdir'] . '/' . $flash[0];
            $data['boardlogo'] = "<embed src=\"" . $flash[0] . "\" width=\"" . trim($flash[1]) . "\" height=\"" . trim($flash[2]) . "\" type=\"application/x-shockwave-flash\" wmode=\"transparent\"></embed>";
        } else {
            $data['boardimg'] = preg_match('/^http:\\/\\//i', $data['boardimg']) ? $data['boardimg'] : $data['styleimgdir'] . '/' . $data['boardimg'];
            $data['boardlogo'] = "<img src=\"{$data['boardimg']}\" alt=\"" . $_G['setting']['bbname'] . "\" border=\"0\" />";
        }
        $data['bold'] = $data['nobold'] ? 'normal' : 'bold';
        $contentwidthint = intval($data['contentwidth']);
        $contentwidthint = $contentwidthint ? $contentwidthint : 600;
        if ($data['extstyle']) {
            list($data['extstyle'], $data['defaultextstyle']) = explode('|', $data['extstyle']);
            $extstyle = explode("\t", $data['extstyle']);
            $data['extstyle'] = array();
            foreach ($extstyle as $dir) {
                if (file_exists($extstylefile = DISCUZ_ROOT . $data['tpldir'] . '/style/' . $dir . '/style.css')) {
                    if ($data['defaultextstyle'] == $dir) {
                        $data['defaultextstyle'] = $data['tpldir'] . '/style/' . $dir;
                    }
                    $content = file_get_contents($extstylefile);
                    if (preg_match('/\\[name\\](.+?)\\[\\/name\\]/i', $content, $r1) && preg_match('/\\[iconbgcolor](.+?)\\[\\/iconbgcolor]/i', $content, $r2)) {
                        $data['extstyle'][] = array($data['tpldir'] . '/style/' . $dir, $r1[1], $r2[1]);
                    }
                }
            }
        }
        $data['verhash'] = random(3);
        $styledata[] = $data;
    }
    foreach ($styledata as $data) {
        savecache('style_' . $data['styleid'], $data);
        if ($defaultstyleid == $data['styleid']) {
            savecache('style_default', $data);
        }
        writetocsscache($data);
    }
}
Example #23
0
function build_cache_stamps()
{
    $data = array();
    $fillarray = range(0, 99);
    $count = 0;
    $repeats = $stampicon = array();
    foreach (C::t('common_smiley')->fetch_all_by_type(array('stamp', 'stamplist')) as $stamp) {
        if (isset($fillarray[$stamp['displayorder']])) {
            unset($fillarray[$stamp['displayorder']]);
        } else {
            $repeats[] = $stamp['id'];
        }
        $count++;
    }
    foreach ($repeats as $id) {
        reset($fillarray);
        $displayorder = current($fillarray);
        unset($fillarray[$displayorder]);
        C::t('common_smiley')->update($id, array('displayorder' => $displayorder));
    }
    foreach (C::t('common_smiley')->fetch_all_by_type('stamplist') as $stamp) {
        if ($stamp['typeid'] < 1) {
            continue;
        }
        $row = C::t('common_smiley')->fetch_by_id_type($stamp['typeid'], 'stamp');
        $stampicon[$row['displayorder']] = $stamp['displayorder'];
    }
    foreach (C::t('common_smiley')->fetch_all_by_type(array('stamp', 'stamplist')) as $stamp) {
        $icon = $stamp['type'] == 'stamp' ? isset($stampicon[$stamp['displayorder']]) ? $stampicon[$stamp['displayorder']] : 0 : ($stamp['type'] == 'stamplist' && !in_array($stamp['displayorder'], $stampicon) ? 1 : 0);
        $data[$stamp['displayorder']] = array('url' => $stamp['url'], 'text' => $stamp['code'], 'type' => $stamp['type'], 'icon' => $icon);
    }
    savecache('stamps', $data);
}
Example #24
0
 public static function output()
 {
     global $_G;
     if (!empty($_G['uid'])) {
         if (self::$tmpavatarbig && self::$tmpavatarmiddle && self::$tmpavatarsmall) {
             $avatar1 = self::byte2hex(file_get_contents(self::$tmpavatarbig));
             $avatar2 = self::byte2hex(file_get_contents(self::$tmpavatarmiddle));
             $avatar3 = self::byte2hex(file_get_contents(self::$tmpavatarsmall));
             $extra = '&avatar1=' . $avatar1 . '&avatar2=' . $avatar2 . '&avatar3=' . $avatar3;
             $result = self::uc_api_post_ex('user', 'rectavatar', array('uid' => $_G['uid']), $extra);
             @unlink(self::$tmpavatar);
             @unlink(self::$tmpavatarbig);
             @unlink(self::$tmpavatarmiddle);
             @unlink(self::$tmpavatarsmall);
             if ($result == '<?xml version="1.0" ?><root><face success="1"/></root>') {
                 $variable = array('uploadavatar' => 'api_uploadavatar_success');
                 $tableext = '';
                 $member = C::t('common_member')->fetch($_G['uid'], false, 1);
                 if (!$member) {
                     self::error('api_uploadavatar_user_not_exists');
                 }
                 $tableext = isset($member['_inarchive']) ? '_archive' : '';
                 C::t('common_member' . $tableext)->update($_G['uid'], array('avatarstatus' => '1'));
                 bigapp_core::result(bigapp_core::variable($variable));
             } else {
                 self::error('api_uploadavatar_uc_error');
             }
         }
     } else {
         self::error('api_uploadavatar_unavailable_user');
     }
 }
Example #25
0
 function output()
 {
     global $_G;
     $forums = $GLOBALS['forums'] ? $GLOBALS['forums'] : C::t('forum_forum')->fetch_all_by_status(1);
     foreach ($forums as $forum) {
         if ($forum['fup'] && $GLOBALS['forumlist'][$forum['fup']]) {
             $GLOBALS['forumlist'][$forum['fup']]['sublist'][] = mobile_core::getvalues($forum, array('fid', 'name', 'threads', 'posts', 'redirect', 'todayposts', 'description'));
         }
         if ($GLOBALS['forumlist'][$forum['fid']]['icon']) {
             $icon = preg_match('/src="(.+?)"/', $GLOBALS['forumlist'][$forum['fid']]['icon'], $r) ? $r[1] : '';
             if (!preg_match('/^http:\\//', $icon)) {
                 $icon = $_G['siteurl'] . $icon;
             }
             $GLOBALS['forumlist'][$forum['fid']]['icon'] = $icon;
         }
         //TODO:现在是用发帖总量来展示"今日发布量",数据量大了改回来
         if ($GLOBALS['forumlist'][$forum['fid']]['posts']) {
             $GLOBALS['forumlist'][$forum['fid']]['posts'] = "今日 " . $GLOBALS['forumlist'][$forum['fid']]['posts'];
         }
     }
     if ($_GET['checknotice']) {
         $variable = array();
     } else {
         $variable = array('member_email' => $_G['member']['email'], 'member_credits' => $_G['member']['credits'], 'setting_bbclosed' => $_G['setting']['bbclosed'], 'group' => mobile_core::getvalues($_G['group'], array('groupid', 'grouptitle', '/^allow.+?$/')), 'catlist' => array_values(mobile_core::getvalues($GLOBALS['catlist'], array('/^\\d+$/'), array('fid', 'name', 'forums'))), 'forumlist' => array_values(mobile_core::getvalues($GLOBALS['forumlist'], array('/^\\d+$/'), array('fid', 'name', 'threads', 'posts', 'redirect', 'todayposts', 'description', 'sublist', 'icon'))));
     }
     mobile_core::result(mobile_core::variable($variable));
 }
Example #26
0
 public function addtags($tags, $appid)
 {
     if (!$tags) {
         C::t('app_relative')->delete_by_appid($appid);
         return;
     }
     if (!is_array($tags)) {
         if (strpos($tags, "','") !== false) {
             $tagnames = explode("','", trim($tags, "'"));
         } elseif (strpos($tags, ',') !== false) {
             $tagnames = explode(',', trim($tags));
         } else {
             $tagnames = array(trim($tags, "'"));
         }
     } else {
         $tagnames = $tags;
     }
     $tagarr = DB::fetch_all('SELECT tagid,tagname FROM ' . DB::table($this->_table) . "  WHERE  tagname IN( " . dimplode($tagnames) . ")");
     $have_tagnames = array();
     $have_tagids = array();
     foreach ($tagarr as $tagid => $value) {
         $have_tagnames[] = $value['tagname'];
         $have_tagids[] = $value['tagid'];
     }
     //已经存在的增加hot +1;
     DB::query("UPDATE " . DB::table($this->_table) . " SET hot=hot+1 WHERE tagid IN(%n)", array($have_tagids));
     $insert_names = array_diff($tagnames, $have_tagnames);
     foreach ($insert_names as $name) {
         $have_tagids[] = self::insert(array('tagname' => $name, 'dateline' => TIMESTAMP, 'hot' => 1), 1);
     }
     //插入关系表
     C::t('app_relative')->update_by_appid($appid, $have_tagids);
 }
Example #27
0
 public function fetch_by_picid($picid, $havecount = false)
 {
     //返回一条数据同时加载附件表数据
     global $_G;
     $picid = intval($picid);
     $image = $attachment = array();
     $image = self::fetch($picid);
     if ($image['aid']) {
         $attachment = C::t('attachment')->fetch($image['aid']);
     }
     $data = array_merge($attachment, $image);
     $data['title'] = $data['filename'];
     //$data['url']=getAttachUrl($data,true);
     //if($data['thumb']) $data['icon']=getimgthumbname($_G['setting']['attachurl'].$data['attachment']);
     //else $data['icon']=$data['url'];
     /*if($data['thumb']>1){
     			$data['url']=getimgthumbname($data['url'].'.1440x900');
     		}*/
     $data['ext'] = $data['filetype'];
     $data['size'] = $data['filesize'];
     if ($havecount) {
         $count = C::t('count')->fetch_by_type($picid, 'image');
         $data['viewnum'] = intval($count['viewnum']);
         $data['replynum'] = intval($count['replynum']);
         $data['downnum'] = intval($count['downnum']);
         $data['star'] = intval($count['star']);
         $data['starnum'] = intval($count['starnum']);
     }
     return $data;
 }
 public function check()
 {
     $forumlist = C::t('forum_forum')->fetch_all_by_recyclebin();
     if (empty($forumlist)) {
         $return = array('status' => 0, 'type' => 'none', 'lang' => lang('optimizer', 'optimizer_recyclebin_no_need'));
     } else {
         $forumdesc = '';
         $adminfile = defined(ADMINSCRIPT) ? ADMINSCRIPT : 'admin.php';
         $k = 1;
         foreach ($forumlist as $forum) {
             $forumdesc .= '<p class="recyclebinforumlist" ' . ($k > 2 ? 'style="display:none;"' : '') . '><a href="' . $adminfile . '"?action=forums&operation=edit&fid=' . $forum['fid'] . ' target="_blank">' . $forum['name'] . '</a></p>';
             if ($k == 3) {
                 $forumdesc .= '<p id="recyclebinmore"><a href="javascript:;" onclick="showlistmore(\\\'recyclebinmore\\\',\\\'recyclebinforumlist\\\');">' . lang('admincp', 'more') . '</a></p>';
             }
             $k++;
         }
         $extraurl = '';
         if (count($forumlist) == 1) {
             $extraurl = '&optimizefid=' . $forum['fid'];
             $forumdesc = '';
         }
         $return = array('status' => 1, 'type' => 'view', 'lang' => lang('optimizer', 'optimizer_recyclebin_need', array('forumdesc' => $forumdesc)), 'extraurl' => $extraurl);
     }
     return $return;
 }
Example #29
0
 public function viewthread_modoption()
 {
     global $_G;
     if (!$_G['adminid']) {
         return false;
     }
     $usergroupsfeedlist = unserialize($_G['setting']['qqgroup_usergroup_feed_list']);
     if (empty($usergroupsfeedlist) || !in_array($_G['groupid'], $usergroupsfeedlist)) {
         if (self::$util->isfounder($_G['member']) == false) {
             return false;
         }
     }
     $tid = $_G['tid'];
     $title = urlencode(trim($_G['forum_thread']['subject']));
     $post = C::t('forum_post')->fetch_all_by_tid_position($_G['fotum_thread']['posttableid'], $_G['tid'], 1);
     include_once libfile('function/discuzcode');
     $content = preg_replace("/\\[audio(=1)*\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/audio\\]/ies", '', trim($post[0]['message']));
     $content = preg_replace("/\\[flash(=(\\d+),(\\d+))?\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/flash\\]/ies", '', $content);
     $content = preg_replace("/\\[media=([\\w,]+)\\]\\s*([^\\[\\<\r\n]+?)\\s*\\[\\/media\\]/ies", '', $content);
     $content = preg_replace("/\\[hide[=]?(d\\d+)?[,]?(\\d+)?\\]\\s*(.*?)\\s*\\[\\/hide\\]/is", '', $content);
     $content = strip_tags(discuzcode($content, 0, 0, 0));
     $content = preg_replace('%\\[attach\\].*\\[/attach\\]%im', '', $content);
     $content = str_replace('&nbsp;', ' ', $content);
     $content = urlencode(cutstr($content, 50, ''));
     include template('qqgroup:push');
     return trim($return);
 }
Example #30
0
function main()
{
    $c = new C();
    B::test($c);
    C::test($c);
    D::test($c);
}