function xml_doc() { if (!file_exists(DATA_CACHE_FILE) || filemtime(DATA_CACHE_FILE) + DATA_CACHE_TTL < time()) { cache_data(); } return simplexml_load_file(DATA_CACHE_FILE); }
function show_nav($elem = "li", $elem_class = "navbar_element", $a_class = "navbar_link") { $nav_bar_content = cache_retrieve('plugin_nav_bar'); if ($nav_bar_content == NULL) { if ($elem === 'li') { $nav_bar_content .= "<ul>"; } if (file_exists('./content/navigation.txt')) { $pages_list = fopen('./content/navigation.txt', "r"); if (!$pages_list) { $nav_bar_content .= '<' . $elem . ' class="' . $elem_class . '"><a href="' . sculpt_special_link("Home") . '" class="' . $a_class . '">Home</a></' . $elem . '>'; } else { //First item is index $nav_item = fgets($pages_list); $nav_bar_content .= '<' . $elem . ' class="' . $elem_class . '"><a href="' . sculpt_special_link("Home") . '" class="' . $a_class . '">' . $nav_item . '</a></' . $elem . '>'; //loop through rest while (!feof($pages_list)) { $nav_item = trim(fgets($pages_list)); if (page_is_registered($nav_item)) { $nav_bar_content .= '<' . $elem . ' class="' . $elem_class . '"><a href="' . sculpt_special_link($nav_item) . '" class="' . $a_class . '">' . $nav_item . '</a></' . $elem . '>'; } else { $nav_link = strtolower($nav_item); $nav_link = str_replace(" ", "_", $nav_link); $nav_bar_content .= '<' . $elem . ' class="' . $elem_class . '"><a href="' . sculpt_page_url($nav_link) . '" class="' . $a_class . '">' . $nav_item . '</a></' . $elem . '>'; } } fclose($pages_list); } } else { $nav_bar_content .= '<' . $elem . ' class="' . $elem_class . '"><a href="' . sculpt_special_link("Home") . '" class="' . $a_class . '">Home</a></</' . $elem . '>'; } if ($elem === 'li') { $nav_bar_content .= '</ul>'; } echo $nav_bar_content; cache_data($nav_bar_content, 'plugin_nav_bar'); } else { echo $nav_bar_content; } }
function member_public($run = 0) { if (intval($_GET['clear'])) { cache_del('member_public'); } $cache_data = load_cache('member_public'); $save_data = $cache_data ? $cache_data : ''; $temp_cache_data = ''; global $head_url, $header_config, $_G; if (!$_GET['submit'] || $run == 0) { $info['header'] = pick_header_output($header_config, $head_url); $info['save_data'] = $save_data; return $info; } else { if (intval($_GET['submit']) == 2) { unset($save_data); } if (!$save_data) { show_pick_info(milu_lang('start_config')); } $info = pick_common_get(); $info['reg_jump_num'] = $info['reg_jump_num'] ? $info['reg_jump_num'] : 100; $now_get = $save_data['now_get'] ? $save_data['now_get'] : 0; $start_dateline = $save_data['start_dateline'] ? $save_data['start_dateline'] : TIMESTAMP; $member_count = member_count('WHERE data_uid=0'); if (!$save_data && !$member_count) { show_pick_info(milu_lang('no_member_import_reg', array('url' => '?' . PICK_GO . 'member&myac=member_import_online&tpl=no')), 'finsh'); return FALSE; } $all_uid_count = $member_count; $get_count = $temp_cache_data['get_count'] = $save_data['get_count'] ? $save_data['get_count'] : ($info['reg_num'] && $info['reg_num'] < $all_uid_count ? $info['reg_num'] : $all_uid_count); $success_count = $save_data['success_count'] ? $save_data['success_count'] : 0; $limit_num = $info['reg_jump_num'] > $get_count ? $get_count : $info['reg_jump_num']; $query = DB::query("SELECT * FROM " . DB::table('strayer_member') . " WHERE data_uid=0 ORDER BY get_dateline DESC LIMIT 0,{$limit_num} "); while ($v = DB::fetch($query)) { show_pick_info(array(milu_lang('reg_member'), '<a>' . $v['username'] . '</a>'), 'left', array('li_no_end' => 1, 'no_border' => 1, 'now' => $now_get + 1)); $info['get_url'] = $v['url']; $v['password'] = $info['reg_pwd']; $v = get_member_setarr($v); $re = pick_reg($v); $now_get++; $pro = ceil(100 * ($success_count / $get_count)); $all_get_time = TIMESTAMP - $start_dateline; $avg_get_time = $all_get_time / $success_count; $wait_count = $get_count - $success_count; $wait_time = $avg_get_time * $wait_count; if (function_exists('php_set')) { $memory = 100 * (get_memory() / php_set('memory_limit')); $memory = $memory || $memory != 0 ? sprintf('%.0f%%', $memory) : milu_lang('un_know'); } $show_arr = array('pro' => $pro, 'wait_time' => $wait_time, 'memory' => $memory, 'wait_count' => $wait_count, 'now' => $now_get + 1); $temp_cache_data['now_get'] = $now_get; if (is_array($re)) { DB::update('strayer_member', array('public_dateline' => $_G['timestamp'], 'data_uid' => $re['uid']), array('uid' => $v['uid'])); $success_count++; $temp_cache_data['success_count'] = $success_count; $show_arr['wait_count'] = $wait_count - 1; $show_arr['pro'] = ceil(100 * ($success_count / $get_count)); show_pick_info(milu_lang('reg_finsh'), 'success', $show_arr); } else { DB::update('strayer_member', array('data_uid' => -1), array('uid' => $v['uid'])); //标记 show_pick_info($re, 'err', $show_arr); } if ($success_count == $get_count || $success_count > $get_count) { break; } $temp_cache_data['start_dateline'] = $start_dateline; if (is_int($now_get / $info['reg_jump_num']) && $now_get != 0 && $success_count < $get_count) { cache_data('member_public', $temp_cache_data, 3600); data_go('member&myac=member_public&submit=1'); exit; } } $all_get_time = TIMESTAMP - $start_dateline; $avg_get_time = $all_get_time / $success_count; if ($success_count < $get_count && $info['reg_num']) { if ($info['reg_jump_num'] > $get_count) { if (member_count('WHERE data_uid=0') > 0) { cache_data('member_public', $temp_cache_data, 3600); data_go('member&myac=member_public&submit=1'); exit; } } show_pick_info(milu_lang('no_member_reg'), 'finsh'); } $all_get_time_str = diff_time($all_get_time, 1); $all_get_time_str = $all_get_time_str ? $all_get_time_str : ceil($all_get_time) . milu_lang('sec'); $finsh_output = milu_lang('reg_over', array('n' => $now_get, 's' => $success_count, 'n_s' => $now_get - $success_count, 'all' => $all_get_time_str, 'avg' => sprintf('%.3f', $avg_get_time))); cache_del('member_public'); $show_arr['wait_count'] = $show_arr['wait_time'] = 0; $show_arr['pro'] = 100; $show_arr['memory'] = $memory; show_pick_info($finsh_output, 'finsh', $show_arr); } }
function pick_download() { $client_info = get_client_info(); $version_md5total = $_GET['md5_total']; $new_version_md5total = $_GET['new_md5_total']; $key = $_GET['key']; $version = $_GET['version']; $version_dateline = $_GET['version_dateline']; $i = intval($_GET['i']); if (!$client_info) { cpmsg_error(milu_lang('lan_upgrage')); } $p = intval($_GET['p']); $count = $_GET['count']; $file_md5 = $_GET['file_md5']; $tmpdir = DISCUZ_ROOT . './data/download/dxc_temp'; pload('C:cache'); $md5s = array(); $str = $_SERVER['QUERY_STRING']; if ($p == 0) { dir_clear($tmpdir); dmkdir($tmpdir, 0777, false); cpmsg(milu_lang('diff_upgrade_file'), PICK_GO . 'pick_info&ac=pick_download&key=' . $key . '&p=1', 'loading', '', false); } else { if ($p == 1) { $url = GET_URL . 'plugin.php?id=pick_user:upgrade&myac=download_file&php_version=' . phpversion() . '&tpl=no&domain=' . urlencode($client_info['domain']) . '&key=' . $key . '&file_md5=' . $file_md5; $data = get_contents($url, array('cache' => -1)); if (!$data || $data == '-1') { cpmsg_error(milu_lang('no_normal_get')); } $msg_arr = (array) json_decode(base64_decode($data)); if (!$_GET['file_md5']) { $download_file_data = upgrade_file_diff($msg_arr['md5']); $md5_temp_arr = array_keys($download_file_data); $version_md5total = md5(implode('', $md5_temp_arr)); $count = count($download_file_data); $version = $version ? $version : $msg_arr['Version']; $version_dateline = $version_dateline ? $version_dateline : $msg_arr['version_dateline']; } else { $download_file_data = load_cache('download_file_data'); $filename = $tmpdir . '/' . $msg_arr['file'] . '._addons_'; $dirname = dirname($filename); dmkdir($dirname, 0777, false); $fp = fopen($filename, 'w'); if (!$fp) { cpmsg('cloudaddons_download_write_error', '', 'error'); } fwrite($fp, gzuncompress(base64_decode($msg_arr['text']))); fclose($fp); if ($msg_arr['MD5']) { $new_version_md5total .= $msg_arr['MD5']; if ($msg_arr['MD5'] != md5_file($filename)) { dir_clear($tmpdir); cpmsg(milu_lang('cloudaddons_download_error'), '', 'error'); //数据下载错误 } } } $file_md5_arr = array_keys($download_file_data); $file_md5 = $file_md5_arr[$i]; $file = $download_file_data[$file_md5]; $p = $i == $count ? 2 : 1; $percent = $i / $count; $percent = sprintf("%01.0f", $percent * 100) . '%'; cache_data('download_file_data', $download_file_data); cpmsg(milu_lang('pick_upgrade_downloading_file', array('file' => $file, 'percent' => $percent)), PICK_GO . 'pick_info&ac=pick_download&i=' . ($i + 1) . '&md5_total=' . $version_md5total . '&new_md5_total=' . $new_version_md5total . '&key=' . $key . '&p=' . $p . '&version=' . $version . '&version_dateline=' . $version_dateline . '&count=' . $count . '&file_md5=' . $file_md5, 'loading', '', false); } else { if ($p == 2) { if ($new_version_md5total !== '' && md5($new_version_md5total) !== $version_md5total) { dir_clear($tmpdir); cpmsg(milu_lang('cloudaddons_download_error'), '', 'error'); //数据下载错误 } cpmsg(milu_lang('DXC_installing'), PICK_GO . 'pick_info&ac=pick_install&version=' . $version . '&version_dateline=' . $version_dateline, 'loading', '', false); } } } }
function DB_GetDataSetCached($tablename, $keyvalue, $keyname = '', $options = array()) { return cache_data($tablename . ':' . $keyvalue . ':' . $keyname, function () use($tablename, $keyvalue, $keyname, $options) { return DB_GetDataset($tablename, $keyvalue, $keyname, $options); }); }
function blog_archives_list() { global $blog_directory; global $date_format; $yearmo = ""; $prev_year = ""; if (file_exists($blog_directory)) { $page_data = cache_retrieve("blog_archives"); if ($page_data == NULL) { $article_list = glob($blog_directory . '/*.md'); foreach ($article_list as $key => $article) { $file_part = pathinfo($article); $year = substr($file_part['filename'], 0, 4); if (!($year === $prev_year)) { $page_data = $page_data . '<h2>' . $year . '</h2>'; $prev_year = $year; } $month = substr($file_part['filename'], 4, 2); if (!($year . $month === $yearmo)) { $page_data = $page_data . '<h3><a href=index.php?p=Blog&bp=archive&ayr=' . $year . '&amo=' . $month . '>'; $page_data = $page_data . date('F', mktime(0, 0, 0, $month, 10)); $page_data = $page_data . '</a></h3>'; $yearmo = $year . $month; } } echo $page_data; cache_data($page_data, "blog_archives"); } else { echo $page_data; } } else { show_error(404); } }
function flip() { $get_count = $this->pick_cache_data['get_count'] + 1; if (($this->i == $get_count || $this->i > $get_count) && $get_count > 1) { $this->finsh(); return FALSE; } if (intval($this->pick_config['pick_config']['max_memory_per']) < intval($this->status_arr['memory'])) { show_pick_info(milu_lang('to_max_memory'), 'finsh', $this->status_arr); $this->finsh(); exit; } $jump_num = $this->p_arr['jump_num'] ? $this->p_arr['jump_num'] : $pick_config['pick_num']; $j = intval($this->i) - 1; if (is_int($j / $jump_num) && $j != 0 && $this->msg_args['is_cron'] != 1) { if ($this->p_arr['stop_time'][1]) { sleep($this->p_arr['stop_time'][1]); } cache_data('pick' . $this->pid, $this->pick_cache_data); data_go('picker_manage&pid=' . $this->pid . '&myaction=get_article&submit=1&no_check_url=' . $_GET['no_check_url']); exit; } return TRUE; }