public static function getmyappiconpath($appid, $iconstatus = 0) { if ($iconstatus > 0) { return getglobal('setting/attachurl') . './' . 'myapp/icon/' . $appid . '.jpg'; } return 'http://appicon.manyou.com/icons/' . $appid; }
public function wx_sendMsg($data) { if (!getglobal('setting/CorpID') || !getglobal('setting/CorpSecret')) { return false; } $user = C::t('user')->fetch($data['uid']); if (!$user['wechat_userid'] || $user['wechat_status'] != 1) { C::t('notification')->update($data['id'], array('wx_new' => $data['wx_new'] + 1)); return false; } $agentid = 0; if ($data['from_idtype'] == 'app' && $data['from_id'] && ($wxapp = C::t('wx_app')->fetch($data['from_id']))) { if ($wxapp['agentid'] && $wxapp['status'] < 1) { $agentid = $wxapp['agentid']; } } $wx = new qyWechat(array('appid' => getglobal('setting/CorpID'), 'appsecret' => getglobal('setting/CorpSecret'))); $msg = array("touser" => "dzz-" . $data['uid'], "safe" => 0, "agentid" => $agentid, "msgtype" => "news", "news" => array("articles" => array(array("title" => $data['title'], "description" => getstr($data['wx_note'], 0, 0, 0, 0, -1), "url" => $wx->getOauthRedirect(getglobal('siteurl') . 'index.php?mod=system&op=wxredirect&url=' . dzzencode($data['redirecturl'])))))); if ($ret = $wx->sendMessage($msg)) { C::t('notification')->update($data['id'], array('wx_new' => 0)); return true; } else { C::t('notification')->update($data['id'], array('wx_new' => $data['wx_new'] + 1)); $message = 'wx_notification:errCode:' . $wx->errCode . ';errMsg:' . $wx->errMsg; runlog('wxlog', $message); return false; } }
function outputvariables() { global $_G; $variables = array(); foreach ($this->params as $param) { if (substr($param, 0, 1) == '$') { if ($param == '$_G') { continue; } $var = substr($param, 1); if (preg_match("/^[a-zA-Z_][a-zA-Z0-9_]*\$/", $var)) { $variables[$param] = $GLOBALS[$var]; } } else { if (preg_replace($this->safevariables, '', $param) !== $param) { continue; } $variables[$param] = getglobal($param); } } $xml = array('Version' => $this->version, 'Charset' => strtoupper($_G['charset']), 'Variables' => $variables); if (!empty($_G['messageparam'])) { $xml['Message'] = $_G['messageparam']; } require_once libfile('class/xml'); echo array2xml($xml); exit; }
function getdata($style, $parameter) { $advid = 0; if (!empty($parameter['title'])) { $parameter['title'] = addslashes($parameter['title']); $adv = DB::fetch_first('SELECT * FROM ' . DB::table('common_advertisement_custom') . " WHERE name='{$parameter['title']}'"); if (empty($adv)) { $advid = DB::insert('common_advertisement_custom', array('name' => $parameter['title']), 1); } else { $advid = $adv['id']; } } elseif (!empty($parameter['adv'])) { $parameter['adv'] = addslashes($parameter['adv']); $adv = DB::fetch_first('SELECT * FROM ' . DB::table('common_advertisement_custom') . " WHERE 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); }
public function setUnrun_by_aid($aid, $r) { //设置允许运行,如果文件在本地同时修改实际文件名,增加无法运行的后缀; $data = parent::fetch($aid); if ($data['remote'] == 0 || $data['remote'] == 1) { //文件在本地,修改文件名 if ($r > 0) { $earr = explode('.', $data['attachment']); foreach ($earr as $key => $ext) { if (in_array(strtolower($ext), array($data['filetype'], 'dzz'))) { unset($earr[$key]); } } $tattachment = implode('.', $earr) . '.dzz'; if ($is_file(getglobal('setting/attachdir') . './' . $data['attachment']) && @rename(getglobal('setting/attachdir') . './' . $data['attachment'], getglobal('setting/attachdir') . './' . $tattachment)) { return parent::update($aid, array('unrun' => $r, 'attachment' => $tattachment)); } } else { $earr = explode('.', $data['attachment']); foreach ($earr as $key => $ext) { if (in_array(strtolower($ext), array($data['filetype'], 'dzz'))) { unset($earr[$key]); } } $tattachment = implode('.', $earr) . '.' . $data['filetype']; if ($is_file(getglobal('setting/attachdir') . './' . $data['attachment']) && @rename(getglobal('setting/attachdir') . './' . $data['attachment'], getglobal('setting/attachdir') . './' . $tattachment)) { return parent::update($aid, array('unrun' => $r, 'attachment' => $tattachment)); } } } return false; }
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; }
public function update_by_cid($cid, $message, $rcid, $attach) { $ret = 0; $ret += parent::update($cid, array('message' => $message, 'rcid' => $rcid, 'edituid' => getglobal('uid'), 'edittime' => TIMESTAMP)); $ret += C::t('comment_attach')->update_by_cid($cid, $attach); return $ret; }
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); }
function upload($source, $target) { if ($this->error()) { return 0; } $old_dir = $this->ftp_pwd(); $dirname = dirname($target); $filename = basename($target); if (!$this->ftp_chdir($dirname)) { if ($this->ftp_mkdir($dirname)) { $this->ftp_chmod($dirname); if (!$this->ftp_chdir($dirname)) { $this->set_error(FTP_ERR_CHDIR); } $this->ftp_put('index.htm', getglobal('setting/attachdir') . '/index.htm', FTP_BINARY); } else { $this->set_error(FTP_ERR_MKDIR); } } $res = 0; if (!$this->error()) { if ($fp = @fopen($source, 'rb')) { $res = $this->ftp_fput($filename, $fp, FTP_BINARY); @fclose($fp); !$res && $this->set_error(FTP_ERR_TARGET_WRITE); } else { $this->set_error(FTP_ERR_SOURCE_READ); } } $this->ftp_chdir($old_dir); return $res ? 1 : 0; }
public function insert_by_uid($uid, $jobid) { if (!$jobid) { return self::delete_by_uid($uid); } $setarr = array('uid' => $uid, 'jobid' => $jobid, 'dateline' => TIMESTAMP, 'opuid' => getglobal('uid')); return parent::insert($setarr, 1, 1); }
function updatestat($type, $primary = 0, $num = 1) { $uid = getglobal('uid'); $updatestat = getglobal('setting/updatestat'); if (empty($uid) || empty($updatestat)) { return false; } C::t('common_stat')->updatestat($uid, $type, $primary, $num); }
public static function dbsize() { $dbsize = 0; $query = DB::query("SHOW TABLE STATUS LIKE '" . getglobal('config/db/1/tablepre') . "%'", 'SILENT'); while ($table = DB::fetch($query)) { $dbsize += $table['Data_length'] + $table['Index_length']; } return $dbsize; }
public function __construct() { $this->_table = 'common_block'; $this->_pk = 'bid'; parent::__construct(); $this->_allowmem = null; $this->cache_ttl = $this->_cache_ttl = getglobal('setting/memory/diyblock'); $this->allowmem = $this->_cache_ttl !== null && memory('check'); }
function &instance() { static $object; if (empty($object)) { $object = new memory_driver_redis(); $object->init(getglobal('config/memory/redis')); } return $object; }
public function insert($uid, $orgid) { if (!$uid || !$orgid) { return 0; } $id = parent::insert(array("orgid" => $orgid, 'uid' => $uid, 'opuid' => getglobal('uid'), 'dateline' => TIMESTAMP), 1, 1); self::update_groupid_by_uid($uid); return DB::result_first('select id from %t where uid=%d and orgid=%d', array($this->_table, $uid, $orgid)); }
public function add($siteUid, $pkId, $type, $authorId, $author, $fromId, $fromIdType, $note, $fromNum, $dateline, $extra = array()) { $_params = array('openid' => $this->getUserOpenId($siteUid), 'sSiteUid' => $siteUid, 'pkId' => $pkId, 'type' => $type, 'authorId' => $authorId, 'author' => $author, 'fromId' => $fromId, 'fromIdType' => $fromIdType, 'fromNum' => $fromNum, 'content' => $note, 'dateline' => $dateline, 'deviceToken' => $this->getUserDeviceToken($siteUid), 'extra' => array('isAdminGroup' => getglobal('adminid'), 'groupId' => getglobal('groupid'), 'groupName' => getglobal('group/grouptitle'))); if ($extra) { foreach ($extra as $key => $value) { $_params['extra'][$key] = $value; } } return $this->_callMethod('connect.discuz.notification.add', $_params); }
function geturl() { $url = getglobal('basefilename') . '?'; if (!empty($_GET)) { foreach ($_GET as $key => $value) { $url .= urlencode($key) . '=' . urlencode(stripslashes($value)) . '&'; } } return $url; }
public static function check_module($module) { $status = 0; $allowfuntype = array('portal', 'group', 'follow', 'collection', 'guide', 'feed', 'blog', 'doing', 'album', 'share', 'wall', 'homepage', 'ranklist'); $module = in_array($module, $allowfuntype) ? trim($module) : ''; if (!empty($module)) { $status = getglobal('setting/' . $module . 'status'); } return $status; }
public function delete($val, $unbuffered = false) { if ($val = dintval($val, true)) { $this->_pre_cache_key = 'blockstylecache_'; $this->_cache_ttl = getglobal('setting/memory/diyblock/ttl'); $this->_allowmem = getglobal('setting/memory/diyblock/enable') && memory('check'); return parent::delete($val, $unbuffered); } return false; }
public function cache($name) { if (!isset($this->app->var['cache'][$name])) { loadcache($name); } if ($this->app->var['cache'][$name] === null) { return null; } else { return getglobal('cache/' . $name); } }
public function trans($var) { $vars = explode(':', $var); $isplugin = count($vars) == 2; if (!$isplugin) { if (!isset($this->language['inner'])) { $this->language['inner'] = array(); } $langvar =& $this->language['inner']; } else { if (!isset($this->language['plugin'][$vars[0]])) { $this->language['plugin'][$vars[0]] = array(); } $langvar =& $this->language['plugin'][$vars[0]]; $var =& $vars[1]; } if (!isset($langvar[$var])) { $this->language['inner'] = lang('template'); if (!$isplugin) { if (defined('IN_MOBILE')) { $mobiletpl = getglobal('mobiletpl'); list($path) = explode('/', str_replace($mobiletpl[IN_MOBILE] . '/', '', $this->root)); } else { list($path) = explode('/', $this->root); } foreach (lang($path . '/template') as $k => $v) { $this->language['inner'][$k] = $v; } if (defined('IN_MOBILE')) { foreach (lang('mobile/template') as $k => $v) { $this->language['inner'][$k] = $v; } } } else { global $_G; if (empty($_G['config']['plugindeveloper'])) { loadcache('pluginlanguage_template'); } elseif (!isset($_G['cache']['pluginlanguage_template'][$vars[0]]) && preg_match("/^[a-z]+[a-z0-9_]*\$/i", $vars[0])) { if (@(include DISCUZ_ROOT . './data/plugindata/' . $vars[0] . '.lang.php')) { $_G['cache']['pluginlanguage_template'][$vars[0]] = $templatelang[$vars[0]]; } else { loadcache('pluginlanguage_template'); } } $this->language['plugin'][$vars[0]] = $_G['cache']['pluginlanguage_template'][$vars[0]]; } } if (isset($langvar[$var])) { return $langvar[$var]; } else { return '!' . $var . '!'; } }
public function getShortUrl($url) { $sid = self::getSid($url); if (DB::result_first("select COUNT(*) from %t where sid=%s", array($this->_table, $sid))) { return getglobal('siteurl') . 'short.php?sid=' . $sid; } $setarr = array('sid' => $sid, 'url' => $url); if (parent::insert($setarr)) { return getglobal('siteurl') . 'short.php?sid=' . $sid; } return ''; }
public function __construct($para = array()) { if (!empty($para)) { $this->_table = $para['table']; $this->_pk = $para['pk']; } if (isset($this->_pre_cache_key) && (($ttl = getglobal('setting/memory/' . $this->_table)) !== null || ($ttl = $this->_cache_ttl) !== null) && memory('check')) { $this->_cache_ttl = $ttl; $this->_allowmem = true; } parent::__construct(); }
function userlogin($username, $password, $questionid, $answer, $loginfield = 'username', $ip = '') { $return = array(); if($loginfield == 'uid' && getglobal('setting/uidlogin')) { $isuid = 1; } elseif($loginfield == 'email') { $isuid = 2; } elseif($loginfield == 'auto') { $isuid = 3; } else { $isuid = 0; } if(!function_exists('uc_user_login')) { loaducenter(); } if($isuid == 3) { if(!strcmp(dintval($username), $username) && getglobal('setting/uidlogin')) { $return['ucresult'] = uc_user_login($username, $password, 1, 1, $questionid, $answer, $ip); } elseif(isemail($username)) { $return['ucresult'] = uc_user_login($username, $password, 2, 1, $questionid, $answer, $ip); } if($return['ucresult'][0] <= 0 && $return['ucresult'][0] != -3) { $return['ucresult'] = uc_user_login(addslashes($username), $password, 0, 1, $questionid, $answer, $ip); } } else { $return['ucresult'] = uc_user_login(addslashes($username), $password, $isuid, 1, $questionid, $answer, $ip); } $tmp = array(); $duplicate = ''; list($tmp['uid'], $tmp['username'], $tmp['password'], $tmp['email'], $duplicate) = $return['ucresult']; $return['ucresult'] = $tmp; if($duplicate && $return['ucresult']['uid'] > 0 || $return['ucresult']['uid'] <= 0) { $return['status'] = 0; return $return; } $member = getuserbyuid($return['ucresult']['uid'], 1); if(!$member || empty($member['uid'])) { $return['status'] = -1; return $return; } $return['member'] = $member; $return['status'] = 1; if($member['_inarchive']) { C::t('common_member_archive')->move_to_master($member['uid']); } if($member['email'] != $return['ucresult']['email']) { C::t('common_member')->update($return['ucresult']['uid'], array('email' => $return['ucresult']['email'])); } return $return; }
public function getQRcodeBySid($sid) { $target = './qrcode/' . $sid[0] . '/' . $sid . '.png'; $targetpath = dirname(getglobal('setting/attachdir') . $target); dmkdir($targetpath); if (@getimagesize(getglobal('setting/attachdir') . $target)) { return getglobal('setting/attachurl') . $target; } else { //生成二维码 QRcode::png(getglobal('siteurl') . 's.php?sid=' . $sid, getglobal('setting/attachdir') . $target, 'M', 4, 2); return getglobal('setting/attachurl') . $target; } }
function getportalcategoryurl($catid) { if (empty($catid)) { return ''; } loadcache('portalcategory'); $portalcategory = getglobal('cache/portalcategory'); if ($portalcategory[$catid]) { return $portalcategory[$catid]['caturl']; } else { return ''; } }
function downloadmyappicon($appid) { $iconpath = getglobal('setting/attachdir') . './' . 'myapp/icon/' . $appid . '.jpg'; if (!is_dir(dirname($iconpath))) { dmkdir(dirname($iconpath)); } DB::update('common_myapp', array('iconstatus' => '-1'), array('appid' => $appid)); $icondata = file_get_contents(getmyappiconpath($appid, 0)); if ($icondata) { file_put_contents($iconpath, $icondata); DB::update('common_myapp', array('iconstatus' => '1', 'icondowntime' => TIMESTAMP), array('appid' => $appid)); } }
public function after_newreply() { global $firststand, $stand; if ($this->param['special'] == 5) { if (!$firststand) { C::t('forum_debate')->update_debaters($this->thread['tid'], $stand); } else { $stand = $firststand; } C::t('forum_debate')->update_replies($this->thread['tid'], $stand); C::t('forum_debatepost')->insert(array('tid' => $this->thread['tid'], 'pid' => $this->pid, 'uid' => $this->member['uid'], 'dateline' => getglobal('timestamp'), 'stand' => $stand, 'voters' => 0, 'voterids' => '')); } }
function downloadmyappicon($appid) { $iconpath = getglobal('setting/attachdir') . './' . 'myapp/icon/' . $appid . '.jpg'; if (!is_dir(dirname($iconpath))) { dmkdir(dirname($iconpath)); } C::t('common_myapp')->update($appid, array('iconstatus' => '-1')); $ctx = stream_context_create(array('http' => array('timeout' => 10))); $icondata = file_get_contents(getmyappiconpath($appid, 0), false, $ctx); if ($icondata) { file_put_contents($iconpath, $icondata); C::t('common_myapp')->update($appid, array('iconstatus' => '1', 'icondowntime' => TIMESTAMP)); } }
function block_member() { $this->setting = array('uids' => array('title' => 'memberlist_uids', 'type' => 'text'), 'groupid' => array('title' => 'memberlist_groupid', 'type' => 'mselect', 'value' => array()), 'special' => array('title' => 'memberlist_special', 'type' => 'mradio', 'value' => array(array('', 'memberlist_special_nolimit'), array('0', 'memberlist_special_hot'), array('1', 'memberlist_special_default')), 'default' => ''), 'gender' => array('title' => 'memberlist_gender', 'type' => 'mradio', 'value' => array(array('1', 'memberlist_gender_male'), array('2', 'memberlist_gender_female'), array('', 'memberlist_gender_nolimit')), 'default' => ''), 'birthcity' => array('title' => 'memberlist_birthcity', 'type' => 'district', 'value' => array('xbirthprovince', 'xbirthcity', 'xbirthdist', 'xbirthcommunity')), 'residecity' => array('title' => 'memberlist_residecity', 'type' => 'district', 'value' => array('xresideprovince', 'xresidecity', 'xresidedist', 'xresidecommunity')), 'avatarstatus' => array('title' => 'memberlist_avatarstatus', 'type' => 'radio', 'default' => ''), 'emailstatus' => array('title' => 'memberlist_emailstatus', 'type' => 'mcheckbox', 'value' => array(array(1, 'memberlist_yes')), 'default' => ''), 'verifystatus' => array('title' => 'memberlist_verifystatus', 'type' => 'mcheckbox', 'value' => array(), 'default' => ''), 'orderby' => array('title' => 'memberlist_orderby', 'type' => 'mradio', 'value' => array(array('credits', 'memberlist_orderby_credits'), array('extcredits', 'memberlist_orderby_extcredits'), array('threads', 'memberlist_orderby_threads'), array('posts', 'memberlist_orderby_posts'), array('blogs', 'memberlist_orderby_blogs'), array('doings', 'memberlist_orderby_doings'), array('albums', 'memberlist_orderby_albums'), array('sharings', 'memberlist_orderby_sharings'), array('digestposts', 'memberlist_orderby_digestposts'), array('regdate', 'memberlist_orderby_regdate'), array('show', 'memberlist_orderby_show'), array('special', 'memberlist_orderby_special'), array('todayposts', 'memberlist_orderby_todayposts')), 'default' => 'credits'), 'extcredit' => array('title' => 'memberlist_orderby_extcreditselect', 'type' => 'select', 'value' => array()), 'lastpost' => array('title' => 'memberlist_lastpost', 'type' => 'mradio', 'value' => array(array('', 'memberlist_lastpost_nolimit'), array('3600', 'memberlist_lastpost_hour'), array('86400', 'memberlist_lastpost_day'), array('604800', 'memberlist_lastpost_week'), array('2592000', 'memberlist_lastpost_month')), 'default' => ''), 'startrow' => array('title' => 'memberlist_startrow', 'type' => 'text', 'default' => 0)); $verifys = getglobal('setting/verify'); if (!empty($verifys)) { foreach ($verifys as $key => $value) { if ($value['title']) { $this->setting['verifystatus']['value'][] = array($key, $value['title']); } } } if (empty($this->setting['verifystatus']['value'])) { unset($this->setting['verifystatus']); } }