function SetCache($prefix, $key, $value, $timeout = 3600, $is_memcache = TRUE) { global $cache_helper_config; $key = md5($key); /* Èç¹ûÆôÓÃMC»º´æ */ if (!empty($cache_helper_config['memcache']) && $cache_helper_config['memcache']['is_mc_enable'] === 'Y' && $is_memcache === TRUE) { $mc_path = empty($cache_helper_config['memcache']['mc'][substr($key, 0, 1)]) ? $cache_helper_config['memcache']['mc']['default'] : $cache_helper_config['memcache']['mc'][substr($key, 0, 1)]; $mc_path = parse_url($mc_path); $key = ltrim($mc_path['path'], '/') . '_' . $prefix . '_' . $key; if (empty($GLOBALS['mc_' . $mc_path['host']])) { $GLOBALS['mc_' . $mc_path['host']] = new Memcache(); $GLOBALS['mc_' . $mc_path['host']]->connect($mc_path['host'], $mc_path['port']); //ÉèÖÃÊý¾ÝѹËõÃż÷ //$GLOBALS ['mc_' . $mc_path ['host']]->setCompressThreshold(2048, 0.2); } $result = $GLOBALS['mc_' . $mc_path['host']]->set($key, $value, MEMCACHE_COMPRESSED, $timeout); return $result; } $key = substr($key, 0, 2) . '/' . substr($key, 2, 2) . '/' . substr($key, 4, 2) . '/' . $key; $tmp['data'] = $value; $tmp['timeout'] = $timeout != 0 ? time() + (int) $timeout : 0; $cache_data = "<?php exit('dedecms');?>\n\r" . @serialize($tmp); return @PutFile(DEDEDATA . "/cache/{$prefix}/{$key}.php", $cache_data); }
if ($cfg_notallowstr != '' && preg_match("#" . $cfg_notallowstr . "#i", $keyword)) { ShowMsg("你的搜索关键字中存在非法内容,被系统禁止!", "-1"); exit; } if (($keyword == '' || strlen($keyword) < 2) && empty($typeid)) { ShowMsg('关键字不能小于2个字节!', '-1'); exit; } //检查搜索间隔时间 $lockfile = DEDEDATA . '/time.lock.inc'; $lasttime = file_get_contents($lockfile); if (!empty($lasttime) && $lasttime + $cfg_search_time > time()) { ShowMsg('管理员设定搜索时间间隔为' . $cfg_search_time . '秒,请稍后再试!', '-1'); exit; } //开始时间 if (empty($starttime)) { $starttime = -1; } else { $starttime = is_numeric($starttime) ? $starttime : -1; if ($starttime > 0) { $dayst = GetMkTime("2008-1-2 0:0:0") - GetMkTime("2008-1-1 0:0:0"); $starttime = time() - $starttime * $dayst; } } $t1 = ExecTime(); $sp = new SearchView($typeid, $keyword, $orderby, $channeltype, $searchtype, $starttime, $pagesize, $kwtype, $mid); $keyword = $oldkeyword; $sp->Display(); PutFile($lockfile, time()); //echo ExecTime() - $t1;
/** * 从远程获取模块信息 * * @access public * @param string $moduletype 模块类型 * @return string */ function GetModuleUrlList($moduletype = '', $url = '') { $dh = dir($this->modulesPath) or die("没找到模块目录:({$this->modulesPath})!"); $fp = @fopen($this->modulesPath . '/modulescache.php', 'w') or die('读取文件权限出错,目录文件' . $this->modulesPath . '/modulescache.php不可写!'); $cachefile = DEDEDATA . '/module/moduleurllist.txt'; $remotelist = ''; if (file_exists($cachefile) && filemtime($cachefile) + 60 * 30 > time()) { // 30分钟本地缓存一次 $remotelist = file_get_contents($cachefile); } else { $del = new DedeHttpDown(); $del->OpenUrl($url); $remotelist = $del->GetHtml(); PutFile($cachefile, $remotelist); } if (empty($remotelist)) { return false; } $modules = unserialize($remotelist); if (empty($moduletype)) { return $modules; } $return = array(); foreach ($modules as $arrow => $data) { if ($data['moduletype'] == $moduletype) { $return[] = $data; } } return $return; }
function Save($id, $data, $ttl = 60) { $contents = array('time' => time(), 'ttl' => $ttl, 'data' => $data); if (PutFile($this->_cache_path . $id, serialize($contents))) { @chmod($this->_cache_path . $id, 0777); return TRUE; } return FALSE; }
<?php exit; } else { if ($dopost == 'showauth') { include 'templets/index_body_showauth.htm'; exit; } else { if ($dopost == 'showad') { include 'templets/index_body_showad.htm'; exit; } else { if ($dopost == 'setskin') { $cskin = empty($cskin) ? 1 : $cskin; $skin = !in_array($cskin, array(1, 2, 3, 4)) ? 1 : $cskin; $skinconfig = DEDEDATA . '/admin/skin.txt'; PutFile($skinconfig, $skin); } elseif ($dopost == 'get_seo') { if (!function_exists('fsocketopen') && !function_exists('curl_init')) { echo '没有支持的curl或fsocketopen组件'; exit; } function dedeseo_http_send($url, $limit = 0, $post = '', $cookie = '', $timeout = 5) { $return = ''; $matches = parse_url($url); $scheme = $matches['scheme']; $host = $matches['host']; $path = $matches['path'] ? $matches['path'] . (@$matches['query'] ? '?' . $matches['query'] : '') : '/'; $port = !empty($matches['port']) ? $matches['port'] : 80; if (function_exists('curl_init') && function_exists('curl_exec')) { $ch = curl_init();
if (!isset($uuid)) { ShowMsg('远程获取BShare的uuid错误,您需要重新尝试。', 'plus_bshare.php'); exit; } // 保存缓存文件 WriteBshareCache('TRUE', $email, $password, $uuid); // 写入默认代码 $codeOrder = 'qqmb%2csinaminiblog%2csohubai%2cbaiduhi%2crenren%2cbgoogle'; $remoteUrl = 'http://updatenew.dedecms.com/base-v57/dedecms/plus_bshare.txt'; $result = DownHost($remoteUrl); $codeOrder = isset($result['results']) ? $result['results'] : $codeOrder; $tplCode = <<<EOT <a class="bshareDiv" href="http://www.bshare.cn/share">分享按钮</a><script language="javascript" type="text/javascript" src="http://www.bshare.cn/button.js#uuid={$uuid}&style=2&textcolor=#000&bgcolor=none&bp={$codeOrder}&ssc=false&sn=true&text=分享到"></script> EOT; $putfileFunc = function_exists('PutFile') ? 'PutFile' : 'file_put_contents'; $putfileFunc($bscodeFile, $tplCode); ShowMsg('已经开通BShare服务,下面我们来进行体验吧。', 'plus_bshare.php'); exit; } else { ShowMsg('是否已经开启BShare服务,如果已经开启无需重复开启服务。', '-1'); exit; } } else { if ($do == 'setcode') { $bscode = isset($bscode) ? $bscode : ''; PutFile($bscodeFile, $bscode); ShowMsg('成功设定BShare代码', 'plus_bshare.php'); exit; } } }