function getdata($style, $parameter) { $array = array(); foreach ($parameter as $key => $value) { if (is_array($value)) { $parameter[$key] = implode(',', $value); } } $parameter['clientid'] = $this->blockdata['clientid']; $parameter['op'] = 'getdata'; $parameter['charset'] = CHARSET; $parameter['version'] = $this->blockdata['version']; $xmlurl = $this->blockdata['url']; $parse = parse_url($xmlurl); if (!empty($parse['host'])) { define('IN_ADMINCP', true); require_once libfile('function/importdata'); $importtxt = @dfsockopen($xmlurl, 0, create_sign_url($parameter, $this->blockdata['key'], $this->blockdata['signtype'])); } else { $importtxt = @file_get_contents($xmlurl); } if ($importtxt) { require libfile('class/xml'); $array = xml2array($importtxt); } $idtype = 'xml_' . $this->blockdata['id']; foreach ($array['data'] as $key => $value) { $value['idtype'] = $idtype; $array['data'][$key] = $value; } if (empty($array['data'])) { $array['data'] = null; } return $array; }
function connect_output_php($url, $postData = '') { global $_G; $response = dfsockopen($url, 0, $postData, '', false, $_G['setting']['cloud_api_ip']); $result = (array) unserialize($response); return $result; }
public function check_patch($ignore = 0) { global $_G; if (!$ignore && $_G['cookie']['checkpatch']) { return false; } require_once DISCUZ_ROOT . 'source/discuz_version.php'; require_once libfile('class/xml'); $versionpath = ''; foreach (explode(' ', substr(DISCUZ_VERSION, 1)) as $unit) { $versionpath = $unit; break; } $patchdir = 'http://upgrade.discuz.com/DiscuzX/' . $versionpath . '/'; $checkurl = $patchdir . 'md5sums'; $patchlist = dfsockopen($checkurl); if (defined('DISCUZ_FIXBUG')) { C::t('common_patch')->update_status_by_serial(1, DISCUZ_FIXBUG, '<='); } if ($patchlist) { $serial_md5s = explode("\r\n", $patchlist); $bound = intval(substr($serial_md5s[count($serial_md5s) - 2], 0, 8)); $maxpatch = intval(C::t('common_patch')->fetch_max_serial()); if (defined('DISCUZ_FIXBUG')) { $maxpatch = $maxpatch < DISCUZ_FIXBUG ? DISCUZ_FIXBUG : $maxpatch; } if ($bound > $maxpatch) { $insertarrlist = array(); foreach ($serial_md5s as $serial_md5) { $downloadpatch = $patch = ''; list($serial, $md5, $release) = explode(' ', $serial_md5); if ($serial > $maxpatch && (!$release || in_array(DISCUZ_RELEASE, explode(',', $release)))) { $downloadpatch = $patchdir . $serial . '.xml'; $patch = dfsockopen($downloadpatch); if (md5($patch) != $md5) { continue; } $patch = xml2array($patch); if (is_array($patch) && !empty($patch)) { $insertarr = array('serial' => intval($patch['serial']), 'rule' => serialize($patch['rule']), 'note' => $patch['note'], 'status' => 0, 'dateline' => $patch['dateline']); C::t('common_patch')->insert($insertarr); $insertarrlist[$insertarr['serial']] = $insertarr; } } } if ($insertarrlist && $_G['setting']['patch']['autoopened']) { foreach ($insertarrlist as $key => $patch) { $this->fix_patch($patch); } } if ($insertarrlist) { C::t('common_setting')->update('showpatchnotice', 1); include_once libfile('function/cache'); updatecache('setting'); } } } dsetcookie('checkpatch', 1, 60); return true; }
function getremotefile($file) { @set_time_limit(0); $file = $file.'?'.time().rand(1000, 9999); $str = @implode('', @file($file)); if(!$str) { $str = dfsockopen($file); } return $str; }
function down($file, $subfolder = '') { global $plugin_lang, $program_ver, $plugin_dir, $plugin_id; $temp = dfsockopen("http://dsu.googlecode.com/svn/trunk/PluginUpdater/{$plugin_id}/{$file}"); if (!$temp) { cpmsg("下载文件 {$file} 失败,请稍候再试", '', 'error'); } @unlink($plugin_dir . '/' . ($subfolder ? $subfolder . '/' : '') . $file); file_put_contents($plugin_dir . '/' . ($subfolder ? $subfolder . '/' : '') . $file, $temp); }
function uc_check_avatar($uid, $size = 'middle', $type = 'virtual') { global $_G; $url = $_G['siteurl'] . "avatar.php?uid={$uid}&size={$size}&type={$type}&check_file_exists=1"; $res = dfsockopen($url, 500000, '', '', TRUE, '', 20); if ($res == 1) { return 1; } else { return 0; } }
private function getResponse($action) { global $_G; $response = @dfsockopen($this->_myurl, 0, $this->getGlobalPostString($action), '', false, $_G['setting']['my_ip']); $result = unserialize($response); if (!$response) { throw new Cloud_Service_Client_RestfulException('Empty Response', 111); } elseif (!$result) { throw new Cloud_Service_Client_RestfulException('Error Response: ' . $response, 110); } if ($result['errCode']) { throw new Cloud_Service_Client_RestfulException($result['errMessage'], $result['errCode']); } return $result; }
function hux_get_data($url) { global $_G; if (function_exists('curl_init')) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_REFERER, $_G['siteurl']); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($curl); curl_close($curl); } else { $result = dfsockopen($url); } return $result; }
/** * 从第三方取快递信息 */ public function ajax_get_expressOp(){ $url = 'http://www.kuaidi100.com/query?type='.$_GET['e_code'].'&postid='.$_GET['shipping_code'].'&id=1&valicode=&temp='.random(4).'&sessionid=&tmp='.random(4); import('function.ftp'); $content = dfsockopen($url); $content = json_decode($content,true); if ($content['status'] != 200) exit(json_encode(false)); $content['data'] = array_reverse($content['data']); $output = array(); if (is_array($content['data'])){ foreach ($content['data'] as $k=>$v) { if ($v['time'] == '') continue; $output[]= $v['time'].' '.$v['context']; } } if (empty($output)) exit(json_encode(false)); echo json_encode($output); }
public function getRequest($requestURL, $extra = array(), $oauthMethod = 'GET', $multi = array()) { if ($multi) { $imageFile = $this->_getImageBinary($multi); $extra = array_merge($extra, $imageFile['binary']); } $params = $this->_getOAuthSignatureParams($extra); $params['oauth_signature'] = $this->_getOAuthSignature($requestURL, $params, $oauthMethod, $multi ? TRUE : FALSE); $queryString = $this->_httpBuildQuery($params, $imageFile['fileInfo']); if ($oauthMethod == 'GET') { $requestURL = $requestURL . '?' . $queryString; $queryString = ''; } else { $requestURL = $requestURL . '?'; } $response = dfsockopen($requestURL, 0, $queryString, '', false, $this->_apiIp, 15, TRUE, !$multi ? 'URLENCODE' : 'FORMDATA', false); return $response; }
function trade_notifycheck($type) { global $_G; if (!empty($_POST)) { $notify = $_POST; $location = FALSE; } elseif (!empty($_GET)) { $notify = $_GET; $location = TRUE; } else { exit('Access Denied'); } unset($notify['diy']); if (dfsockopen("http://notify.alipay.com/trade/notify_query.do?partner=" . DISCUZ_PARTNER . "¬ify_id=" . $notify['notify_id'], 60) !== 'true') { exit('Access Denied'); } if ($type == 'trade') { $urlstr = ''; foreach ($notify as $key => $val) { MAGIC_QUOTES_GPC && ($val = stripslashes($val)); $urlstr .= $key . '=' . rawurlencode(stripslashes($val)) . '&'; } } else { ksort($notify); $sign = ''; foreach ($notify as $key => $val) { if ($key != 'sign' and $key != 'sign_type') { $sign .= "&{$key}={$val}"; } } if ($notify['sign'] != md5(substr($sign, 1) . DISCUZ_SECURITYCODE)) { exit('Access Denied'); } } if ($type == 'credit' && (!DISCUZ_DIRECTPAY && $notify['notify_type'] == 'trade_status_sync' && ($notify['trade_status'] == 'WAIT_SELLER_SEND_GOODS' || $notify['trade_status'] == 'TRADE_FINISHED') || DISCUZ_DIRECTPAY && ($notify['trade_status'] == 'TRADE_FINISHED' || $notify['trade_status'] == 'TRADE_SUCCESS')) || $type == 'trade' && $notify['notify_type'] == 'trade_status_sync') { return array('validator' => TRUE, 'status' => trade_getstatus(!empty($notify['refund_status']) ? $notify['refund_status'] : $notify['trade_status'], 1), 'order_no' => $notify['out_trade_no'], 'price' => !DISCUZ_DIRECTPAY && $notify['price'] ? $notify['price'] : $notify['total_fee'], 'trade_no' => $notify['trade_no'], 'notify' => 'success', 'location' => $location); } else { return array('validator' => FALSE, 'notify' => 'fail', 'location' => $location); } }
public function sync() { global $_G; $setting = $_G['setting']; $my_url = 'http://api.manyou.com/uchome.php'; $mySiteId = empty($_G['setting']['my_siteid']) ? '' : $_G['setting']['my_siteid']; $siteName = $_G['setting']['bbname']; $siteUrl = $_G['siteurl']; $ucUrl = rtrim($_G['setting']['ucenterurl'], '/') . '/'; $siteCharset = $_G['charset']; $siteTimeZone = $_G['setting']['timeoffset']; $mySiteKey = empty($_G['setting']['my_sitekey']) ? '' : $_G['setting']['my_sitekey']; $siteKey = C::t('common_setting')->fetch('siteuniqueid'); $siteLanguage = $_G['config']['output']['language']; $siteVersion = $_G['setting']['version']; $utilService = Cloud::loadClass('Service_Util'); $myVersion = $utilService->getApiVersion(); $productType = 'DISCUZX'; $siteRealNameEnable = ''; $siteRealAvatarEnable = ''; $siteEnableApp = intval($setting['my_app_status']); $key = $mySiteId . $siteName . $siteUrl . $ucUrl . $siteCharset . $siteTimeZone . $siteRealNameEnable . $mySiteKey . $siteKey; $key = md5($key); $siteTimeZone = urlencode($siteTimeZone); $siteName = urlencode($siteName); $register = false; $postString = sprintf('action=%s&productType=%s&key=%s&mySiteId=%d&siteName=%s&siteUrl=%s&ucUrl=%s&siteCharset=%s&siteTimeZone=%s&siteEnableRealName=%s&siteEnableRealAvatar=%s&siteKey=%s&siteLanguage=%s&siteVersion=%s&myVersion=%s&siteEnableApp=%s&from=cloud', 'siteRefresh', $productType, $key, $mySiteId, $siteName, $siteUrl, $ucUrl, $siteCharset, $siteTimeZone, $siteRealNameEnable, $siteRealAvatarEnable, $siteKey, $siteLanguage, $siteVersion, $myVersion, $siteEnableApp); $response = @dfsockopen($my_url, 0, $postString, '', false, $setting['my_ip']); $res = unserialize($response); if (!$response) { throw new Cloud_Service_Client_RestfulException('Empty Response', 111); } elseif (!$res) { throw new Cloud_Service_Client_RestfulException('Error Response: ' . $response, 110); } if ($res['errCode']) { throw new Cloud_Service_Client_RestfulException($res['errMessage'], $res['errCode']); } return true; }
public function getRecWords($needNum = 14) { global $_G; $sId = $_G['setting']['my_siteid']; $data = array(); if ($sId) { $kname = 'search_recommend_words_' . $sId; loadcache($kname); if (isset($_G['cache'][$kname]['ts']) && TIMESTAMP - $_G['cache'][$kname]['ts'] <= 21600) { $data = $_G['cache'][$kname]['result']; } else { $apiUrl = 'http://api.discuz.qq.com/search/recwords/get'; $params = array('s_id' => $sId, 'need_random' => false, 'need_num' => $needNum, 'response_format' => 'php', 'version' => 1); $response = dfsockopen($apiUrl, 0, generateSiteSignUrl($params), '', false, $_G['setting']['cloud_api_ip']); $result = (array) unserialize($response); if (isset($result['status']) && $result['status'] === 0) { $data = $result['result']; save_syscache($kname, array('ts' => TIMESTAMP, 'result' => $data)); } } } return $data; }
public static function getVersion() { $version = array('user_version' => MOBCENT_VERSION, 'user_release' => MOBCENT_RELEASE, 'mobcent_version' => MOBCENT_VERSION, 'mobcent_release' => MOBCENT_RELEASE); $url = 'http://www.appbyme.com/mobcentACA/file/predefined.html'; $info = dfsockopen($url); if (!empty($info)) { $matches = array(); preg_match_all('/<mobcent_(version|release)>(.*?)<\\/mobcent_\\1>/s', $info, $matches, PREG_SET_ORDER); if (!empty($matches)) { foreach ($matches as $matches) { switch ($matches[1]) { case 'version': case 'release': $version['mobcent_' . $matches[1]] = $matches[2]; break; default: break; } } } } return $version; }
function zend_check() { if (!file_exists(PICK_PATH . '/zend/zendcheck')) { //应用中心不允许上传zend加密文件,故临时更换检测方法。 if (extension_loaded('Zend Optimizer') || extension_loaded('Zend Guard Loader') || get_cfg_var("zend_extension") || get_cfg_var("zend_optimizer.optimization_level") || get_cfg_var("zend_extension_manager.optimizer_ts") || get_cfg_var("zend_extension_ts")) { return 1; } else { return -2; } } else { $zend_check = dfsockopen(PICK_URL . '/zend/zendcheck.php'); if (!$zend_check) { return -1; } preg_match('/s=\'(.*?)\';v=\'(.*?)\';/is', $zend_check, $v_arr); $msg = $v_arr[1]; if ($msg == 'OK') { return 1; } return -2; } return 1; }
function import_block($xmlurl, $clientid, $xmlkey = '', $signtype = '', $ignoreversion = 1, $update = 0) { global $_G, $importtxt; $_G['gp_importtype'] = $_G['gp_importtxt'] = ''; $xmlurl = strip_tags($xmlurl); $clientid = strip_tags($clientid); $xmlkey = strip_tags($xmlkey); $parse = parse_url($xmlurl); if (!empty($parse['host'])) { $queryarr = explode('&', $parse['query']); $para = array(); foreach ($queryarr as $value) { $k = $v = ''; list($k, $v) = explode('=', $value); if (!empty($k) && !empty($v)) { $para[$k] = $v; } } $para['clientid'] = $clientid; $para['op'] = 'getconfig'; $para['charset'] = CHARSET; $signurl = create_sign_url($para, $xmlkey, $signtype); $pos = strpos($xmlurl, '?'); $pos = $pos === false ? strlen($xmlurl) : $pos; $signurl = substr($xmlurl, 0, $pos) . '?' . $signurl; $importtxt = @dfsockopen($signurl); } else { $importtxt = @implode('', file($xmlurl)); } $blockarrays = getimportdata('Discuz! Block', 0); if (empty($blockarrays['name']) || empty($blockarrays['fields']) || empty($blockarrays['getsetting'])) { cpmsg(cplang('import_data_typeinvalid') . cplang($importtxt), '', 'error'); } if (empty($ignoreversion) && strip_tags($blockarrays['version']) != strip_tags($_G['setting']['version'])) { cpmsg(cplang('blockxml_import_version_invalid'), '', 'error', array('cur_version' => $blockarrays['version'], 'set_version' => $_G['setting']['version'])); } $data = array('name' => htmlspecialchars($blockarrays['name']), 'version' => htmlspecialchars($blockarrays['version']), 'url' => $xmlurl, 'clientid' => $clientid, 'key' => $xmlkey, 'signtype' => !empty($signtype) ? 'MD5' : '', 'data' => serialize($blockarrays)); $data = daddslashes($data); if (!$update) { DB::insert('common_block_xml', $data); } else { DB::update('common_block_xml', $data, "`id`='{$update}'"); } }
public function download_file($upgradeinfo, $file, $folder = 'upload', $md5 = '', $position = 0, $offset = 0) { $dir = DISCUZ_ROOT . './data/update/Discuz! X' . $upgradeinfo['latestversion'] . ' Release[' . $upgradeinfo['latestrelease'] . ']/'; $this->mkdirs(dirname($dir . $file)); $downloadfileflag = true; if (!$position) { $mode = 'wb'; } else { $mode = 'ab'; } $fp = fopen($dir . $file, $mode); if (!$fp) { return 0; } $response = dfsockopen($this->upgradeurl . $upgradeinfo['latestversion'] . '/' . $upgradeinfo['latestrelease'] . '/' . $this->locale . '_' . $this->charset . '/' . $folder . '/' . $file . 'sc', $offset, '', '', FALSE, '', 120, TRUE, 'URLENCODE', FALSE, $position); if ($response) { if ($offset && strlen($response) == $offset) { $downloadfileflag = false; } fwrite($fp, $response); } fclose($fp); if ($downloadfileflag) { if (md5_file($dir . $file) == $md5) { return 2; } else { return 0; } } else { return 1; } }
} else { $focus['title'] = trim($_GET['focus_title']); $focus['title'] = empty($focus['title']) ? cplang('misc_focus') : $focus['title']; $focus['cookie'] = trim(intval($_GET['focus_cookie'])); $focus['cookie'] = empty($focus['cookie']) ? 0 : $focus['cookie']; C::t('common_setting')->update('focus', $focus); updatecache(array('setting', 'focus')); cpmsg('focus_conf_succeed', 'action=misc&operation=focus&do=config', 'succeed'); } } } elseif ($operation == 'checkstat') { if ($statid && $statkey) { $q = "statid={$statid}&statkey={$statkey}"; $q = rawurlencode(base64_encode($q)); $url = 'http://stat.discuz.com/stat_ins.php?action=checkstat&q=' . $q; $key = dfsockopen($url); $newstatdisable = $key == $statkey ? 0 : 1; if ($newstatdisable != $statdisable) { C::t('common_setting')->update('statdisable', $newstatdisable); require_once libfile('function/cache'); updatecache('setting'); } } } elseif ($operation == 'custommenu') { if (!$do) { if (!submitcheck('optionsubmit')) { $mpp = 10; $startlimit = ($page - 1) * $mpp; $num = C::t('common_admincp_cmenu')->count_by_uid($_G['uid']); $multipage = multi($num, $mpp, $page, ADMINSCRIPT . '?action=misc&operation=custommenu'); $optionlist = $ajaxoptionlist = '';
function cloudaddons_open($extra, $post = '', $timeout = 999) { return dfsockopen(cloudaddons_url('&from=s') . $extra, 0, $post, '', false, CLOUDADDONS_DOWNLOAD_IP, $timeout); }
/** * 同步微信头像处理 */ public static function syncAvatar($uid, $avatar) { if (!$uid || !$avatar) { return false; } if (!($content = dfsockopen($avatar))) { return false; } $tmpFile = DISCUZ_ROOT . './data/avatar/' . TIMESTAMP . random(6); file_put_contents($tmpFile, $content); if (!is_file($tmpFile)) { return false; } $result = uploadUcAvatar::upload($uid, $tmpFile); unlink($tmpFile); C::t('common_member')->update($uid, array('avatarstatus' => '1')); return $result; }
function get_img_content($img_url, $snoopy_obj = '', $ext = '') { $pick_config = get_pick_set(); if (!function_exists('fsockopen') && !function_exists('pfsockopen') || !$snoopy_obj) { $content = dfsockopen($img_url); } else { if ($pick_config['is_set_referer'] == 1) { $snoopy_obj->referer = $img_url; } //有些图片设置了这个反而采集不到比如:http://img1.gxcity.com/forum/201107/14/135857bbq214kkgbabz42m.jpg //有些必须设置这个 http://abbs.cn/pic/2012/03/08/1331168643.jpg //http://www.biketo.com/d/file/news/bikenews/2012-09-05/d8ca0bad794a799354fdad835742783f.jpg $snoopy_obj->fetch($img_url); $content = $snoopy_obj->results; $headers = $snoopy_obj->headers; if ($snoopy_obj->status == '403') { $snoopy_obj->referer = ''; $snoopy_obj->fetch($img_url); $content = $snoopy_obj->results; $headers = $snoopy_obj->headers; } if ($snoopy_obj->status == '404' || $snoopy_obj->status == '403') { return FALSE; } foreach ($headers as $v) { $v_arr = explode(':', $v); if ($v_arr[1]) { $header_arr[strtolower($v_arr[0])] = trim($v_arr[1]); } } pload('F:http'); $info['size'] = $header_arr['content-length']; $url_info = parse_url($img_url); $query_url = $url_info['query'] ? $url_info['query'] : $url_info['path']; $info['file_ext'] = addslashes(strtolower(substr(strrchr($query_url, '.'), 1, 10))); if ($header_arr['content-disposition']) { $c_d = $header_arr['content-disposition']; $info_arr = explode(';', $c_d); $file_arr = explode('=', $info_arr[1]); $arr[2] = preg_replace('(\'|\\")', '', $file_arr[1]); //去掉引号 $file_name = $info['file_name'] = str_iconv($arr[2]); $info['file_ext'] = $info['file_ext'] ? $info['file_ext'] : addslashes(strtolower(substr(strrchr($file_name, '.'), 1, 10))); $info['content'] = $content; return $info; } else { if (!$info['file_ext']) { $content_type = array_flip(GetContentType()); $header_arr['content-type'] = str_replace(';', '', $header_arr['content-type']); $info['file_ext'] = $content_type[$header_arr['content-type']]; } } if ($info['file_ext']) { $patharr = explode('/', $img_url); $info['file_name'] = trim($patharr[count($patharr) - 1]); if (strexists($info['file_name'], 'forum.php?mod=attachment')) { $info['file_name'] = $info['file_ext'] = ''; } } $info['content'] = $content; if ($ext == 'no_get') { return $info; } } return $content; }
function init($method, $source, $target, $nosuffix = 0) { global $_G; $this->errorcode = 0; if (empty($source)) { return -2; } $parse = parse_url($source); if (isset($parse['host'])) { if (empty($target)) { return -2; } $data = dfsockopen($source); $this->tmpfile = $source = tempnam($_G['setting']['attachdir'] . './temp/', 'tmpimg_'); file_put_contents($source, $data); if (!$data || $source === FALSE) { return -2; } } if ($method == 'thumb') { $target = empty($target) ? !$nosuffix ? getimgthumbname($source) : $source : $_G['setting']['attachdir'] . './' . $target; } elseif ($method == 'watermask') { $target = empty($target) ? $source : $_G['setting']['attachdir'] . './' . $target; } $targetpath = dirname($target); dmkdir($targetpath); clearstatcache(); if (!is_readable($source) || !is_writable($targetpath)) { return -2; } $imginfo = @getimagesize($source); if ($imginfo === FALSE) { return -1; } $this->source = $source; $this->target = $target; $this->imginfo['width'] = $imginfo[0]; $this->imginfo['height'] = $imginfo[1]; $this->imginfo['mime'] = $imginfo['mime']; $this->imginfo['size'] = @filesize($source); $this->libmethod = $this->param['imagelib'] && $this->param['imageimpath']; if (!$this->libmethod) { switch ($this->imginfo['mime']) { case 'image/jpeg': $this->imagecreatefromfunc = function_exists('imagecreatefromjpeg') ? 'imagecreatefromjpeg' : ''; $this->imagefunc = function_exists('imagejpeg') ? 'imagejpeg' : ''; break; case 'image/gif': $this->imagecreatefromfunc = function_exists('imagecreatefromgif') ? 'imagecreatefromgif' : ''; $this->imagefunc = function_exists('imagegif') ? 'imagegif' : ''; break; case 'image/png': $this->imagecreatefromfunc = function_exists('imagecreatefrompng') ? 'imagecreatefrompng' : ''; $this->imagefunc = function_exists('imagepng') ? 'imagepng' : ''; break; } } else { $this->imagecreatefromfunc = $this->imagefunc = TRUE; } if (!$this->libmethod && $this->imginfo['mime'] == 'image/gif') { if (!$this->imagecreatefromfunc) { return -4; } if (!($fp = @fopen($source, 'rb'))) { return -2; } $content = fread($fp, $this->imginfo['size']); fclose($fp); $this->imginfo['animated'] = strpos($content, 'NETSCAPE2.0') === FALSE ? 0 : 1; } return $this->imagecreatefromfunc ? 1 : -4; }
function _fsockopen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE) { return dfsockopen($url, $limit, $post, $cookie, $bysocket, $ip, $timeout, $block); }
public function getRecWords($needNum = 14, $format = 'num', $fid = 0) { global $_G; $sId = $_G['setting']['my_siteid']; $data = array(); if ($sId) { $fid = $fid ? $fid : 0; $kname = 'search_recommend_words_' . $fid; loadcache($kname); $cacheLife = isset($_G['setting']['my_search_data']['recwords_lifetime']) ? intval($_G['setting']['my_search_data']['recwords_lifetime']) : 21600; $cloudSettingTime = isset($_G['setting']['my_search_data']['set_forbidden_recwords_time']) ? intval($_G['setting']['my_search_data']['set_forbidden_recwords_time']) : 0; $cacheSettingTime = isset($_G['cache'][$kname]['setting_ts']) ? intval($_G['cache'][$kname]['setting_ts']) : 0; if ((!$cloudSettingTime || $cloudSettingTime == $cacheSettingTime) && isset($_G['cache'][$kname]['ts']) && TIMESTAMP - $_G['cache'][$kname]['ts'] <= $cacheLife) { $data = $_G['cache'][$kname]['result']; } else { $apiUrl = 'http://api.discuz.qq.com/search/recwords/get'; $params = array('s_id' => $sId, 'f_id' => $fid, 'need_random' => false, 'need_num' => $needNum, 'version' => $format == 'num' ? 1 : 2); $utilService = Cloud::loadClass('Service_Util'); $response = dfsockopen($apiUrl, 0, $utilService->generateSiteSignUrl($params), '', false, $_G['setting']['cloud_api_ip']); $result = (array) unserialize($response); if (isset($result['status']) && $result['status'] === 0) { $data = $result['result']; if ($cloudSettingTime) { save_syscache($kname, array('ts' => TIMESTAMP, 'setting_ts' => $cloudSettingTime, 'result' => $data)); } else { save_syscache($kname, array('ts' => TIMESTAMP, 'result' => $data)); } } } } return $data; }
$upload = new discuz_upload(); $attachaids = array(); foreach ($temp as $value) { $imageurl = $value[1]; $hash = md5($imageurl); if (strlen($imageurl)) { $imagereplace['oldimageurl'][] = $value[0]; if (!isset($existentimg[$hash])) { $existentimg[$hash] = $imageurl; $attach['ext'] = $upload->fileext($imageurl); if (!$upload->is_image_ext($attach['ext'])) { continue; } $content = ''; if (preg_match('/^(http:\\/\\/|\\.)/i', $imageurl)) { $content = dfsockopen($imageurl); } elseif (preg_match('/^(' . preg_quote(getglobal('setting/attachurl'), '/') . ')/i', $imageurl)) { $imagereplace['newimageurl'][] = $value[0]; } if (empty($content)) { continue; } $patharr = explode('/', $imageurl); $attach['name'] = trim($patharr[count($patharr) - 1]); $attach['thumb'] = ''; $attach['isimage'] = $upload->is_image_ext($attach['ext']); $attach['extension'] = $upload->get_target_extension($attach['ext']); $attach['attachdir'] = $upload->get_target_dir('forum'); $attach['attachment'] = $attach['attachdir'] . $upload->get_target_filename('forum') . '.' . $attach['extension']; $attach['target'] = getglobal('setting/attachdir') . './forum/' . $attach['attachment']; if (!@($fp = fopen($attach['target'], 'wb'))) {
/** * 从第三方取快递信息 * */ public function get_expressOp() { $url = 'http://www.kuaidi100.com/query?type=' . $_GET['e_code'] . '&postid=' . $_GET['shipping_code'] . '&id=1&valicode=&temp=' . random(4) . '&sessionid=&tmp=' . random(4); import('function.ftp'); $content = dfsockopen($url); $content = json_decode($content, true); if ($content['status'] != 200) { exit(json_encode(false)); } $content['data'] = array_reverse($content['data']); $output = ''; if (is_array($content['data'])) { foreach ($content['data'] as $k => $v) { if ($v['time'] == '') { continue; } $output .= '<li>' . $v['time'] . ' ' . $v['context'] . '</li>'; } } if ($output == '') { exit(json_encode(false)); } if (strtoupper(CHARSET) == 'GBK') { $output = Language::getUTF8($output); //网站GBK使用编码时,转换为UTF-8,防止json输出汉字问题 } echo json_encode($output); }
private static function _dfsockopen($get, $post = array()) { global $_G; $return = dfsockopen(self::$API_URL . http_build_query($get), 0, $post, '', false, $_G['config']['wsqapi_ip']); return json_decode($return); }
include DISCUZ_ROOT . 'source/language/lang_admincp_cloud.php'; $name = $extend_lang['connect_guest_group_name']; if ($needCreateGroup) { $userGroupData = array( 'type' => 'special', 'grouptitle' => $name, 'allowvisit' => 1, 'color' => '', 'stars' => '', ); $newGroupId = C::t('common_usergroup')->insert($userGroupData, true); $dataField = array( 'groupid' => $newGroupId, 'allowsearch' => 2, 'readaccess' => 1, 'allowgetattach' => 1, 'allowgetimage' => 1, ); C::t('common_usergroup_field')->insert($dataField); $newConnect['guest_groupid'] = $newGroupId; } $https = json_decode(dfsockopen('https://graph.qq.com/user/get_user_info')); $newConnect['oauth2'] = $https->ret == -1 ? 1 : 0; $updateData = array_merge($connect, $newConnect); C::t('common_setting')->update('connect', serialize($updateData)); updatecache('setting'); $finish = true;
function manyouSync() { global $_G; $setting = $_G['setting']; $my_url = 'http://api.manyou.com/uchome.php'; $mySiteId = empty($_G['setting']['my_siteid']) ? '' : $_G['setting']['my_siteid']; $siteName = $_G['setting']['bbname']; $siteUrl = $_G['siteurl']; $ucUrl = rtrim($_G['setting']['ucenterurl'], '/') . '/'; $siteCharset = $_G['charset']; $siteTimeZone = $_G['setting']['timeoffset']; $mySiteKey = empty($_G['setting']['my_sitekey']) ? '' : $_G['setting']['my_sitekey']; $siteKey = DB::result_first("SELECT svalue FROM " . DB::table('common_setting') . " WHERE skey='siteuniqueid'"); $siteLanguage = $_G['config']['output']['language']; $siteVersion = $_G['setting']['version']; $myVersion = cloud_get_api_version(); $productType = 'DISCUZX'; $siteRealNameEnable = ''; $siteRealAvatarEnable = ''; $siteEnableApp = intval($setting['my_app_status']); $key = $mySiteId . $siteName . $siteUrl . $ucUrl . $siteCharset . $siteTimeZone . $siteRealNameEnable . $mySiteKey . $siteKey; $key = md5($key); $siteTimeZone = urlencode($siteTimeZone); $siteName = urlencode($siteName); $register = false; $postString = sprintf('action=%s&productType=%s&key=%s&mySiteId=%d&siteName=%s&siteUrl=%s&ucUrl=%s&siteCharset=%s&siteTimeZone=%s&siteEnableRealName=%s&siteEnableRealAvatar=%s&siteKey=%s&siteLanguage=%s&siteVersion=%s&myVersion=%s&siteEnableApp=%s&from=cloud', 'siteRefresh', $productType, $key, $mySiteId, $siteName, $siteUrl, $ucUrl, $siteCharset, $siteTimeZone, $siteRealNameEnable, $siteRealAvatarEnable, $siteKey, $siteLanguage, $siteVersion, $myVersion, $siteEnableApp); $response = @dfsockopen($my_url, 0, $postString, '', false, $setting['my_ip']); $res = unserialize($response); if (!$response) { $res['errCode'] = 111; $res['errMessage'] = 'Empty Response'; $res['result'] = $response; } elseif (!$res) { $res['errCode'] = 110; $res['errMessage'] = 'Error Response'; $res['result'] = $response; } if ($res['errCode']) { cpmsg('cloud_sync_failure', '', 'error', array('errCode' => $res['errCode'], 'errMessage' => $res['errMessage'])); } }
public function save($file_path, $filename) { global $_G; $md5 = md5_file($file_path); $filesize = filesize($file_path); if ($md5 && ($attach = DB::fetch_first("select * from %t where md5=%s and filesize=%d", array('attachment', $md5, $filesize)))) { $attach['filename'] = $filename; $pathinfo = pathinfo($filename); $ext = $pathinfo['extension'] ? $pathinfo['extension'] : ''; $attach['filetype'] = $ext; if (in_array(strtolower($attach['filetype']), array('png', 'jpeg', 'jpg', 'gif', 'bmp'))) { $attach['img'] = C::t('attachment')->getThumbByAid($attach, $this->options['thumbnail']['max-width'], $this->options['thumbnail']['max-height']); $attach['isimage'] = 1; } else { $attach['img'] = geticonfromext($ext); $attach['isimage'] = 0; } @unlink($file_path); return $attach; } else { $target = self::getPath($filename); $pathinfo = pathinfo($filename); $ext = $pathinfo['extension'] ? $pathinfo['extension'] : ''; if ($ext && in_array(strtolower($ext), getglobal('setting/unRunExts'))) { $unrun = 1; } else { $unrun = 0; } $filepath = $_G['setting']['attachdir'] . $target; $handle = fopen($file_path, 'r'); $handle1 = fopen($filepath, 'w'); while (!feof($handle)) { fwrite($handle1, fread($handle, 8192)); } fclose($handle); fclose($handle1); @unlink($file_path); $filesize = filesize($filepath); $remote = 0; $attach = array('filesize' => $filesize, 'attachment' => $target, 'filetype' => strtolower($ext), 'filename' => $filename, 'remote' => $remote, 'copys' => 0, 'md5' => $md5, 'unrun' => $unrun, 'dateline' => $_G['timestamp']); if ($attach['aid'] = C::t('attachment')->insert($attach, 1)) { C::t('local_storage')->update_usesize_by_remoteid($attach['remote'], $attach['filesize']); dfsockopen($_G['siteurl'] . 'misc.php?mod=movetospace&aid=' . $attach['aid'] . '&remoteid=0', 0, '', '', FALSE, '', 1); if (in_array(strtolower($attach['filetype']), array('png', 'jpeg', 'jpg', 'gif', 'bmp'))) { $attach['img'] = C::t('attachment')->getThumbByAid($attach['aid'], $this->options['thumbnail']['max-width'], $this->options['thumbnail']['max-height']); $attach['isimage'] = 1; } else { $attach['img'] = geticonfromext($ext); $attach['isimage'] = 0; } return $attach; } else { return false; } } }