function tpl_function_qishi_get_salary_data_salary_pie($params, &$smarty) { global $db, $_CFG; $arr = explode(',', $params['set']); foreach ($arr as $str) { $a = explode(':', $str); switch ($a[0]) { case "调用名称": $aset['alias'] = $a[1]; break; case "列表名": $aset['listname'] = $a[1]; break; case "地区": $aset['district'] = $a[1]; break; case "职位": $aset['category'] = $a[1]; break; } } $filename = urlencode($aset['district'] . '_' . $aset['category']) . '_salary_pie.cache'; $result = check_cache($filename, 'salary', 7); if (!$result) { $result = dfopen("http://www.74cms.com/salary/get_salary_data_salary_pie.php?district=" . $aset['district'] . "&category=" . $aset['category'] . "&certification=" . $_SERVER['SERVER_NAME']); write_cache($filename, $result, 'salary'); } $smarty->assign($aset['listname'], $result); }
$filters = get_request("f", ""); if ($new_width == 0 && $new_height == 0) { $new_width = 100; $new_height = 100; } // set path to cache directory (default is ./cache) // this can be changed to a different location $cache_dir = './cache'; // get mime type of src $mime_type = mime_type($src); // check to see if this image is in the cache already check_cache( $cache_dir, $mime_type ); // if not in cache then clear some space and generate a new file cleanCache(); ini_set('memory_limit', "30M"); // make sure that the src is gif/jpg/png if(!valid_src_mime_type($mime_type)) { displayError("Invalid src mime type: " .$mime_type); } // check to see if GD function exist if(!function_exists('imagecreatetruecolor')) { displayError("GD Library Error: imagecreatetruecolor does not exist"); }
/** * Destructor * Here we'll write out the internal file path caches to an external cache of some sort. */ public function __destruct() { // Bug 28309 - Set the current directory to one which we expect it to be (i.e. the root directory of the install set_include_path(realpath(dirname(__FILE__) . '/../..') . PATH_SEPARATOR . get_include_path()); chdir(realpath(dirname(__FILE__) . '/../..')); // Bug 30807/30808 - Re-setup the external cache since the object isn't there when calling this method. $GLOBALS['external_cache_checked'] = false; check_cache(); // clear out the cache on destroy if we are asked to if ($this->_clearCacheOnDestroy) { if (is_file($GLOBALS['sugar_config']['cache_dir'] . $this->getFilePath() . '/pathCache.php')) { unlink($GLOBALS['sugar_config']['cache_dir'] . $this->getFilePath() . '/pathCache.php'); } if ($GLOBALS['external_cache_enabled'] && $GLOBALS['external_cache_type'] != 'base-in-memory') { sugar_cache_clear('theme_' . $this->dirName . '_jsCache'); sugar_cache_clear('theme_' . $this->dirName . '_cssCache'); sugar_cache_clear('theme_' . $this->dirName . '_imageCache'); sugar_cache_clear('theme_' . $this->dirName . '_templateCache'); } } elseif (!inDeveloperMode()) { // push our cache into the sugar cache if ($GLOBALS['external_cache_enabled'] && $GLOBALS['external_cache_type'] != 'base-in-memory') { // only update the caches if they have been changed in this request if (count($this->_jsCache) != $this->_initialCacheSize['jsCache']) { sugar_cache_put('theme_' . $this->dirName . '_jsCache', $this->_jsCache); } if (count($this->_cssCache) != $this->_initialCacheSize['cssCache']) { sugar_cache_put('theme_' . $this->dirName . '_cssCache', $this->_cssCache); } if (count($this->_imageCache) != $this->_initialCacheSize['imageCache']) { sugar_cache_put('theme_' . $this->dirName . '_imageCache', $this->_imageCache); } if (count($this->_templateCache) != $this->_initialCacheSize['templateCache']) { sugar_cache_put('theme_' . $this->dirName . '_templateCache', $this->_templateCache); } } elseif (count($this->_jsCache) != $this->_initialCacheSize['jsCache'] || count($this->_cssCache) != $this->_initialCacheSize['cssCache'] || count($this->_imageCache) != $this->_initialCacheSize['imageCache'] || count($this->_templateCache) != $this->_initialCacheSize['templateCache']) { sugar_file_put_contents(create_cache_directory($this->getFilePath() . '/pathCache.php'), serialize(array('jsCache' => $this->_jsCache, 'cssCache' => $this->_cssCache, 'imageCache' => $this->_imageCache, 'templateCache' => $this->_templateCache))); } } elseif ($GLOBALS['external_cache_enabled']) { sugar_cache_clear('theme_' . $this->dirName . '_jsCache'); sugar_cache_clear('theme_' . $this->dirName . '_cssCache'); sugar_cache_clear('theme_' . $this->dirName . '_imageCache'); sugar_cache_clear('theme_' . $this->dirName . '_templateCache'); } }
} //独立ip数据单独统计 $arr['yesterday'][4] = $db->get_total("SELECT COUNT(distinct ip) AS num FROM " . table('company_praise') . " WHERE company_id={$company_profile['id']} AND addtime={$yesterday} "); $arr['week'][4] = $db->get_total("SELECT COUNT(distinct ip) AS num FROM " . table('company_praise') . " WHERE company_id={$company_profile['id']} AND addtime={$week} "); $arr['last_week'][4] = $db->get_total("SELECT COUNT(distinct ip) AS num FROM " . table('company_praise') . " WHERE company_id={$company_profile['id']} AND addtime>={$last_week_day_begin} AND addtime<={$last_week_day_end} "); $arr['month'][4] = $db->get_total("SELECT COUNT(distinct ip) AS num FROM " . table('company_praise') . " WHERE company_id={$company_profile['id']} AND addtime={$month_day} "); $arr['last_month'][4] = $db->get_total("SELECT COUNT(distinct ip) AS num FROM " . table('company_praise') . " WHERE company_id={$company_profile['id']} AND addtime>={$month_day_begin} AND addtime<={$month_day_end} "); $arr['total'][4] = $db->get_total("SELECT COUNT(distinct ip) AS num FROM " . table('company_praise') . " WHERE company_id={$company_profile['id']} "); write_cache('u' . $_SESSION['uid'] . '_wzp_tabledata.cache', json_encode($arr), 'wzp'); } /** * 图表统计start **/ $filter = intval($_GET['settr']) > 0 ? intval($_GET['settr']) : 7; $check_categories_cache = check_cache('u' . $_SESSION['uid'] . '_wzp_categories_' . $filter . '.cache', 'wzp'); $check_dataset_cache = check_cache('u' . $_SESSION['uid'] . '_wzp_dataset_' . $filter . '.cache', 'wzp'); if ($check_categories_cache && $check_dataset_cache) { $categories = $check_categories_cache; $dataset = $check_dataset_cache; } else { for ($i = $filter; $i > 0; $i--) { $labelArr[] = strtotime(date('Y-m-d', time() - $i * 86400)); } $line_data = $db->getall("select * from " . table('company_praise') . " where company_id = {$company_profile['id']} AND addtime>" . strtotime(date('Y-m-d', time() - $filter * 86400)) . " order by addtime asc"); foreach ($line_data as $key => $value) { $line[$value['click_type']][$value['addtime']] += 1; } $item = 0; foreach ($labelArr as $key => $value) { $label[$item]['label'] = date('m-d', $value); $lineData[0][$item]['value'] = intval($line[1][$value]);
function display_message($msg) { global $contents; $contents .= $msg; echo $msg; } function check_cache() { if (file_exists('postinstall_results.res')) { if (time() - filemtime('postinstall_results.res') < 120) { echo file_get_contents('postinstall_results.res'); exit; } } } check_cache(); $contents = ''; //Check username and private key display_message("Checking username and private key... "); if (empty($openinviter_settings['username']) or empty($openinviter_settings['private_key'])) { display_message("Username or private key missing.Get your own at <a href='http://openinviter.com/register.php'>OpenInviter</a><br>\n"); exit; } else { display_message("*OK*<br>\n"); } //Check PHP version display_message("Checking PHP version... "); if (version_compare(PHP_VERSION, '5.0.0', '<')) { display_message("*NOT OK* - OpenInviter requires PHP5, your server has PHP " . PHP_VERSION . " installed"); exit; } else {
$template->assign_vars(array('L_PNPHPBB2_OPTIONS' => $lang['pnphpbb2_options'], 'L_YES' => $lang['Yes'], 'L_NO' => $lang['No'], 'L_SUBMIT' => $lang['Submit'], 'L_RESET' => $lang['Reset'], 'L_FIRST_POST' => $lang['First_Post'], 'L_LAST_POST' => $lang['Last_Post'], 'L_CONFIGURATION_TITLE' => $lang['pnphpbb2_settings'], 'L_CONFIGURATION_EXPLAIN' => $lang['pnphpbb2_settings_explain'], 'L_PNPHPBB2_LOGO_ON' => "<b>" . $lang['pnphpbb2_logo_on'] . "</b>", 'L_PNPHPBB2_LOGO_ON_EXPLAIN' => $lang['pnphpbb2_logo_on_explain'], 'L_PNPHPBB2_QUICKREPLY' => "<b>" . $lang['pnphpbb2_quickreply'] . "</b>", 'L_PNPHPBB2_QUICKREPLY_EXPLAIN' => $lang['pnphpbb2_quickreply_explain'], 'L_PNPHPBB2_QUICKREPLY_ADV' => $lang['Advanced_mode'], 'L_PNPHPBB2_SHORTURLS' => "<b>" . $lang['pnphpbb2_shorturls'] . "</b>", 'L_PNPHPBB2_SHORTURLS_EXPLAIN' => $lang['pnphpbb2_shorturls_explain'], 'L_PNPHPBB2_POST_CONFIRM' => "<b>" . $lang['pnphpbb2_post_confirm'] . "</b>", 'L_PNPHPBB2_POST_CONFIRM_EXPLAIN' => $lang['pnphpbb2_post_confirm_explain'], 'L_PNPHPBB2_POST_ORDER' => "<b>" . $lang['pnphpbb2_post_order'] . "</b>", 'L_PNPHPBB2_POST_ORDER_EXPLAIN' => $lang['pnphpbb2_post_order_explain'], 'L_PNPHPBB2_ALLOW_FULL_PAGE' => "<b>" . $lang['pnphpbb2_allow_full_page'] . "</b>", 'L_PNPHPBB2_ALLOW_FULL_PAGE_EXPLAIN' => $lang['pnphpbb2_allow_full_page_explain'], 'L_PNPHPBB2_FULL_PAGE' => "<b>" . $lang['pnphpbb2_full_page'] . "</b>", 'L_PNPHPBB2_FULL_PAGE_EXPLAIN' => $lang['pnphpbb2_full_page_explain'], 'L_PNPHPBB2_PN_PM' => "<b>" . $lang['pnphpbb2_pn_pm'] . "</b>", 'L_PNPHPBB2_PN_PM_EXPLAIN' => $lang['pnphpbb2_pn_pm_explain'], 'L_PNPHPBB2_PN_LINK' => "<b>" . $lang['pnphpbb2_pn_link'] . "</b>", 'L_PNPHPBB2_PN_LINK_EXPLAIN' => $lang['pnphpbb2_pn_link_explain'], 'L_PNPHPBB2_PN_TEXT' => "<b>" . $lang['pnphpbb2_pn_text'] . "</b>", 'L_PNPHPBB2_PN_TEXT_EXPLAIN' => $lang['pnphpbb2_pn_text_explain'], 'L_PNPHPBB2_TEMPLATE_COMPILER' => "<b>" . $lang['pnphpbb2_template_compiler'] . "</b>", 'L_PNPHPBB2_TEMPLATE_COMPILER_EXPLAIN' => $lang['pnphpbb2_template_compiler_explain'], 'L_PNPHPBB2_MEMBERS_ONLINE' => "<b>" . $lang['pnphpbb2_members_online'] . "</b>", 'L_PNPHPBB2_MEMBERS_ONLINE_EXPLAIN' => $lang['pnphpbb2_members_online_explain'], 'L_PNPHPBB2_MEMBERS_ONLINE_ANNON' => "<b>" . $lang['pnphpbb2_members_online_annon'] . "</b>", 'L_PNPHPBB2_MEMBERS_ONLINE_ANNON_EXPLAIN' => $lang['pnphpbb2_members_online_annon_explain'], 'L_PNPHPBB2_ALLOW_SUB_CHANGE' => "<b>" . $lang['pnphpbb2_allow_sub_change'] . "</b>", 'L_PNPHPBB2_ALLOW_SUB_CHANGE_EXPLAIN' => $lang['pnphpbb2_allow_sub_change_explain'], 'PNPHPBB2_LOGO_ON' => intval($board_config['pnphpbb2_logo_on']), 'PNPHPBB2_MEMBERS_ONLINE' => intval($board_config['pnphpbb2_members_online']), 'PNPHPBB2_QUICKREPLY' => intval($board_config['pnphpbb2_quickreply']), 'PNPHPBB2_SHORTURLS' => intval($board_config['pnphpbb2_shorturls']), 'PNPHPBB2_POST_CONFIRM' => intval($board_config['pnphpbb2_post_confirm']), 'PNPHPBB2_POST_ORDER' => intval($board_config['pnphpbb2_post_order']), 'PNPHPBB2_FULL_PAGE' => intval($board_config['pnphpbb2_full_page']), 'PNPHPBB2_ALLOW_FULL_PAGE' => intval($board_config['pnphpbb2_allow_full_page']), 'PNPHPBB2_PN_PM' => intval($board_config['pnphpbb2_pn_pm']), 'PNPHPBB2_PN_LINK' => htmlspecialchars($board_config['pnphpbb2_pn_link']), 'PNPHPBB2_PN_TEXT' => htmlspecialchars($board_config['pnphpbb2_pn_text']), 'PNPHPBB2_TEMPLATE_COMPILER' => intval($board_config['pnphpbb2_template_compiler']), 'PNPHPBB2_MEMBERS_ONLINE' => intval($board_config['pnphpbb2_members_online']), 'PNPHPBB2_MEMBERS_ONLINE_ANNON' => intval($board_config['pnphpbb2_members_online_annon']), 'PNPHPBB2_ALLOW_SUB_CHANGE' => intval($board_config['pnphpbb2_allow_sub_change']), 'S_PNPHPBB2_LOGO_ON_YES' => $board_config['pnphpbb2_logo_on'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_LOGO_ON_NO' => !$board_config['pnphpbb2_logo_on'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_QUICKREPLY_YES' => $board_config['pnphpbb2_quickreply'] == 1 ? "checked=\"checked\"" : "", 'S_PNPHPBB2_QUICKREPLY_NO' => $board_config['pnphpbb2_quickreply'] == 0 ? "checked=\"checked\"" : "", 'S_PNPHPBB2_QUICKREPLY_ADV' => $board_config['pnphpbb2_quickreply'] == 2 ? "checked=\"checked\"" : "", 'S_PNPHPBB2_SHORTURLS_YES' => $board_config['pnphpbb2_shorturls'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_SHORTURLS_NO' => !$board_config['pnphpbb2_shorturls'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_POST_ORDER_NEWEST' => $board_config['pnphpbb2_post_order'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_POST_ORDER_OLDEST' => !$board_config['pnphpbb2_post_order'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_POST_CONFIRM_YES' => $board_config['pnphpbb2_post_confirm'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_POST_CONFIRM_NO' => !$board_config['pnphpbb2_post_confirm'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_ALLOW_FULL_PAGE_YES' => $board_config['pnphpbb2_allow_full_page'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_ALLOW_FULL_PAGE_NO' => !$board_config['pnphpbb2_allow_full_page'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_FULL_PAGE_YES' => $board_config['pnphpbb2_full_page'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_FULL_PAGE_NO' => !$board_config['pnphpbb2_full_page'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_PN_PM_YES' => $board_config['pnphpbb2_pn_pm'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_PN_PM_NO' => !$board_config['pnphpbb2_pn_pm'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_PN_LINK' => htmlspecialchars($board_config['pnphpbb2_pn_link']), 'S_PNPHPBB2_PN_TEXT' => htmlspecialchars($board_config['pnphpbb2_pn_text']), 'S_PNPHPBB2_TEMPLATE_COMPILER_YES' => $board_config['pnphpbb2_template_compiler'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_TEMPLATE_COMPILER_NO' => !$board_config['pnphpbb2_template_compiler'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_MEMBERS_ONLINE_YES' => $board_config['pnphpbb2_members_online'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_MEMBERS_ONLINE_NO' => !$board_config['pnphpbb2_members_online'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_MEMBERS_ONLINE_ANNON_YES' => $board_config['pnphpbb2_members_online_annon'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_MEMBERS_ONLINE_ANNON_NO' => !$board_config['pnphpbb2_members_online_annon'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_ALLOW_SUB_CHANGE_YES' => $board_config['pnphpbb2_allow_sub_change'] ? "checked=\"checked\"" : "", 'S_PNPHPBB2_ALLOW_SUB_CHANGE_NO' => !$board_config['pnphpbb2_allow_sub_change'] ? "checked=\"checked\"" : "", 'L_THEME_MATCHING' => '<b>' . $lang['theme_matching'] . '</b>', 'L_THEME_MATCHING_EXPLAIN' => $lang['theme_matching_explain'], 'THEME_MATCHING' => intval($board_config['theme_matching']), 'S_THEME_MATCHING_YES' => $board_config['theme_matching'] ? "checked=\"checked\"" : "", 'S_THEME_MATCHING_NO' => !$board_config['theme_matching'] ? "checked=\"checked\"" : "", 'L_EDIT_TIME' => '<b>' . $lang['edit_time'] . '</b>', 'L_EDIT_TIME_EXPLAIN' => $lang['edit_time_explain'], 'EDIT_TIME' => intval($board_config['edit_time']), "L_PNPHPBB2_ANNOUNCEMENT_SETTINGS" => $lang['announce_settings'], "L_PNPHPBB2_ENABLE_ACCOUNCE" => "<b>" . $lang['enable_announce'] . "</b>", "L_PNPHPBB2_ENABLE_ACCOUNCE_EXPLAIN" => $lang['enable_announce_explain'], "PNPHPBB2_ENABLE_ACCOUNCE" => intval($board_config['pnphpbb2_enable_announce']), "PNPHPBB2_ENABLE_ACCOUNCE_YES" => $board_config['pnphpbb2_enable_announce'] ? "checked=\"checked\"" : "", "PNPHPBB2_ENABLE_ACCOUNCE_NO" => !$board_config['pnphpbb2_enable_announce'] ? "checked=\"checked\"" : "", "L_PNPHPBB2_ANNOUNCEMENT_DURATION" => "<b>" . $lang['announcement_duration'] . "</b>", "L_PNPHPBB2_ANNOUNCEMENT_DURATION_EXPLAIN" => $lang['announcement_duration_explain'], "PNPHPBB2_ANNOUNCEMENT_DURATION" => intval($board_config['pnphpbb2_announcement_duration']), "L_PNPHPBB2_SPLIT_GLOBAL_ANNOUNCE" => "<b>" . $lang['split_global_announce'] . "</b>", "PNPHPBB2_SPLIT_GLOBAL_ANNOUNCE" => intval($board_config['pnphpbb2_split_global_announce']), "PNPHPBB2_SPLIT_GLOBAL_ANNOUNCE_YES" => $board_config['pnphpbb2_split_global_announce'] ? "checked=\"checked\"" : "", "PNPHPBB2_SPLIT_GLOBAL_ANNOUNCE_NO" => !$board_config['pnphpbb2_split_global_announce'] ? "checked=\"checked\"" : "", "L_PNPHPBB2_SPLIT_ANNOUNCE" => "<b>" . $lang['split_announce'] . "</b>", "PNPHPBB2_SPLIT_ANNOUNCE" => intval($board_config['pnphpbb2_split_announce']), "PNPHPBB2_SPLIT_ANNOUNCE_YES" => $board_config['pnphpbb2_split_announce'] ? "checked=\"checked\"" : "", "PNPHPBB2_SPLIT_ANNOUNCE_NO" => !$board_config['pnphpbb2_split_announce'] ? "checked=\"checked\"" : "", "L_PNPHPBB2_SPLIT_STICKY" => "<b>" . $lang['split_sticky'] . "</b>", "PNPHPBB2_SPLIT_STICKY" => intval($board_config['pnphpbb2_split_sticky']), "PNPHPBB2_SPLIT_STICKY_YES" => $board_config['pnphpbb2_split_sticky'] ? "checked=\"checked\"" : "", "PNPHPBB2_SPLIT_STICKY_NO" => !$board_config['pnphpbb2_split_sticky'] ? "checked=\"checked\"" : "", "L_PNPHPBB2_SUB_FORUM" => "<b>" . $lang['Use_sub_forum'] . "</b>", "L_PNPHPBB2_SUB_FORUM_EXPLAIN" => $lang['Use_sub_forum_explain'], "PNPHPBB2_SUB_FORUM_YES" => $board_config['pnphpbb2_sub_forum'] ? "checked=\"checked\"" : "", "PNPHPBB2_SUB_FORUM_NO" => !$board_config['pnphpbb2_sub_forum'] ? "checked=\"checked\"" : "", "PNPHPBB2_SUB_FORUM" => intval($board_config['pnphpbb2_sub_forum']), "L_PNPHPBB2_HIERARCHY_SETTINGS" => $lang['Hierarchy_setting'], 'S_MODE_ACTION' => append_sid('admin_pnphpbb2.' . $phpEx))); if ($board_config['pnphpbb2_template_compiler'] == 1) { // test cache $filename = $template->make_filename('_xs_test.tpl'); $filename2 = $template->make_filename_cache($filename); $str = ''; if (!check_cache($filename2)) { $template->assign_block_vars('switch_xs_warning', array()); } @unlink($filename2); $debug1 = $str; // test cache $filename3 = $template->make_filename('admin/_admin_xs_test.tpl'); $filename4 = $template->make_filename_cache($filename3); $str = ''; check_cache($filename4); @unlink($filename4); $debug2 = $str; // add realpath if (@function_exists('realpath') && @realpath($phpbb_root_path . 'includes/template.' . $phpEx)) { $str = @realpath($filename); if ($str && $str !== $filename) { $filename = $filename . '<br />(' . $str . ')'; } $str = @realpath($filename2); if ($str && $str !== $filename2) { $filename2 = $filename2 . '<br />(' . $str . ')'; } $str = @realpath($filename3); if ($str && $str !== $filename3) { $filename3 = $filename3 . '<br />(' . $str . ')';
function ss_get_by_ssh($options) { global $debug, $cache_dir, $poll_time; # Build and test the type-specific function names. $caching_func = "{$options['type']}_cachefile"; $cmdline_func = "{$options['type']}_cmdline"; $parsing_func = "{$options['type']}_parse"; $getting_func = "{$options['type']}_get"; debug("Functions: '{$caching_func}', '{$cmdline_func}', '{$parsing_func}'"); if (!function_exists($cmdline_func)) { die("The parsing function '{$cmdline_func}' does not exist"); } if (!function_exists($parsing_func)) { die("The parsing function '{$parsing_func}' does not exist"); } # Check the cache. $fp = null; if (!isset($options['file']) && $cache_dir && !isset($options['nocache']) && function_exists($caching_func)) { $cache_file = call_user_func($caching_func, $options); $cache_res = check_cache($cache_dir, $poll_time, $cache_file, $options); if ($cache_res[1]) { debug("The cache is usable."); return extract_desired($options, $cache_res[1]); } elseif ($cache_res[0]) { $fp = $cache_res[0]; debug("Got a filehandle to the cache file"); } } if (!$fp) { debug("Caching is disabled."); } # There might be a custom function that overrides the SSH fetch. if (!isset($options['file']) && function_exists($getting_func)) { debug("{$getting_func}() is defined, will call it"); $output = call_user_func($getting_func, $options); } else { # Get the command-line to fetch the data, then fetch and parse the data. debug("No getting_func(), will use normal code path"); $cmd = call_user_func($cmdline_func, $options); debug($cmd); $output = get_command_result($cmd, $options); } debug($output); $result = call_user_func($parsing_func, $options, $output); # Define the variables to output. I use shortened variable names so maybe # it'll all fit in 1024 bytes for Cactid and Spine's benefit. This list must # come right after the word MAGIC_VARS_DEFINITIONS. The Perl script parses # it and uses it as a Perl variable. $keys = array('Requests' => 'a0', 'Bytes_sent' => 'a1', 'Idle_workers' => 'a2', 'Busy_workers' => 'a3', 'CPU_Load' => 'a4', 'Waiting_for_connection' => 'a5', 'Starting_up' => 'a6', 'Reading_request' => 'a7', 'Sending_reply' => 'a8', 'Keepalive' => 'a9', 'DNS_lookup' => 'aa', 'Closing_connection' => 'ab', 'Logging' => 'ac', 'Gracefully_finishing' => 'ad', 'Idle_cleanup' => 'ae', 'Open_slot' => 'af', 'STAT_CPU_user' => 'ag', 'STAT_CPU_nice' => 'ah', 'STAT_CPU_system' => 'ai', 'STAT_CPU_idle' => 'aj', 'STAT_CPU_iowait' => 'ak', 'STAT_CPU_irq' => 'al', 'STAT_CPU_softirq' => 'am', 'STAT_CPU_steal' => 'an', 'STAT_CPU_guest' => 'ao', 'STAT_interrupts' => 'ap', 'STAT_context_switches' => 'aq', 'STAT_forks' => 'ar', 'STAT_loadavg' => 'as', 'STAT_numusers' => 'at', 'STAT_memcached' => 'au', 'STAT_membuffer' => 'av', 'STAT_memshared' => 'aw', 'STAT_memfree' => 'ax', 'STAT_memused' => 'ay', 'NGINX_active_connections' => 'az', 'NGINX_server_accepts' => 'b0', 'NGINX_server_handled' => 'b1', 'NGINX_server_requests' => 'b2', 'NGINX_reading' => 'b3', 'NGINX_writing' => 'b4', 'NGINX_waiting' => 'b5', 'MEMC_rusage_user' => 'b6', 'MEMC_rusage_system' => 'b7', 'MEMC_curr_items' => 'b8', 'MEMC_total_items' => 'b9', 'MEMC_bytes' => 'ba', 'MEMC_curr_connections' => 'bb', 'MEMC_total_connections' => 'bc', 'MEMC_cmd_get' => 'bd', 'MEMC_cmd_set' => 'be', 'MEMC_get_misses' => 'bf', 'MEMC_evictions' => 'bg', 'MEMC_bytes_read' => 'bh', 'MEMC_bytes_written' => 'bi', 'DISK_reads' => 'bj', 'DISK_reads_merged' => 'bk', 'DISK_sectors_read' => 'bl', 'DISK_time_spent_reading' => 'bm', 'DISK_writes' => 'bn', 'DISK_writes_merged' => 'bo', 'DISK_sectors_written' => 'bp', 'DISK_time_spent_writing' => 'bq', 'DISK_io_ops_in_progress' => 'br', 'DISK_io_time' => 'bs', 'DISK_io_time_weighted' => 'bt', 'OPVZ_kmemsize_held' => 'bu', 'OPVZ_kmemsize_failcnt' => 'bv', 'OPVZ_lockedpages_held' => 'bw', 'OPVZ_lockedpages_failcnt' => 'bx', 'OPVZ_privvmpages_held' => 'by', 'OPVZ_privvmpages_failcnt' => 'bz', 'OPVZ_shmpages_held' => 'c0', 'OPVZ_shmpages_failcnt' => 'c1', 'OPVZ_numproc_held' => 'c2', 'OPVZ_numproc_failcnt' => 'c3', 'OPVZ_physpages_held' => 'c4', 'OPVZ_physpages_failcnt' => 'c5', 'OPVZ_vmguarpages_held' => 'c6', 'OPVZ_vmguarpages_failcnt' => 'c7', 'OPVZ_oomguarpages_held' => 'c8', 'OPVZ_oomguarpages_failcnt' => 'c9', 'OPVZ_numtcpsock_held' => 'ca', 'OPVZ_numtcpsock_failcnt' => 'cb', 'OPVZ_numflock_held' => 'cc', 'OPVZ_numflock_failcnt' => 'cd', 'OPVZ_numpty_held' => 'ce', 'OPVZ_numpty_failcnt' => 'cf', 'OPVZ_numsiginfo_held' => 'cg', 'OPVZ_numsiginfo_failcnt' => 'ch', 'OPVZ_tcpsndbuf_held' => 'ci', 'OPVZ_tcpsndbuf_failcnt' => 'cj', 'OPVZ_tcprcvbuf_held' => 'ck', 'OPVZ_tcprcvbuf_failcnt' => 'cl', 'OPVZ_othersockbuf_held' => 'cm', 'OPVZ_othersockbuf_failcnt' => 'cn', 'OPVZ_dgramrcvbuf_held' => 'co', 'OPVZ_dgramrcvbuf_failcnt' => 'cp', 'OPVZ_numothersock_held' => 'cq', 'OPVZ_numothersock_failcnt' => 'cr', 'OPVZ_dcachesize_held' => 'cs', 'OPVZ_dcachesize_failcnt' => 'ct', 'OPVZ_numfile_held' => 'cu', 'OPVZ_numfile_failcnt' => 'cv', 'OPVZ_numiptent_held' => 'cw', 'OPVZ_numiptent_failcnt' => 'cx', 'REDIS_connected_clients' => 'cy', 'REDIS_connected_slaves' => 'cz', 'REDIS_used_memory' => 'd0', 'REDIS_changes_since_last_save' => 'd1', 'REDIS_total_connections_received' => 'd2', 'REDIS_total_commands_processed' => 'd3', 'JMX_heap_memory_used' => 'd4', 'JMX_heap_memory_committed' => 'd5', 'JMX_heap_memory_max' => 'd6', 'JMX_non_heap_memory_used' => 'd7', 'JMX_non_heap_memory_committed' => 'd8', 'JMX_non_heap_memory_max' => 'd9', 'JMX_open_file_descriptors' => 'da', 'JMX_max_file_descriptors' => 'db', 'MONGODB_connected_clients' => 'dc', 'MONGODB_used_resident_memory' => 'dd', 'MONGODB_used_mapped_memory' => 'de', 'MONGODB_used_virtual_memory' => 'df', 'MONGODB_index_accesses' => 'dg', 'MONGODB_index_hits' => 'dh', 'MONGODB_index_misses' => 'di', 'MONGODB_index_resets' => 'dj', 'MONGODB_back_flushes' => 'dk', 'MONGODB_back_total_ms' => 'dl', 'MONGODB_back_average_ms' => 'dm', 'MONGODB_back_last_ms' => 'dn', 'MONGODB_op_inserts' => 'do', 'MONGODB_op_queries' => 'dp', 'MONGODB_op_updates' => 'dq', 'MONGODB_op_deletes' => 'dr', 'MONGODB_op_getmores' => 'ds', 'MONGODB_op_commands' => 'dt', 'MONGODB_slave_lag' => 'du'); # Prepare and return the output. The output we have right now is the whole # info, and we need that -- to write it to the cache file -- but what we # return should be only the desired items. $output = array(); foreach ($keys as $key => $short) { # If the value isn't defined, return -1 which is lower than (most graphs') # minimum value of 0, so it'll be regarded as a missing value. $val = isset($result[$key]) ? $result[$key] : -1; $output[] = "{$short}:{$val}"; } $result = implode(' ', $output); if ($fp) { if (fwrite($fp, $result) === FALSE) { die("Cannot write to '{$cache_file}'"); } fclose($fp); } return extract_desired($options, $result); }
* Xunsearch PHP-SDK 运行条件检测 * * @author hightman * @link http://www.xunsearch.com/ * @copyright Copyright © 2011 HangZhou YunSheng Network Technology Co., Ltd. * @license http://www.xunsearch.com/license/ * @version $Id$ */ require_once dirname(__FILE__) . '/../lib/XS.php'; require dirname(__FILE__) . '/XSUtil.class.php'; // magick output charset XSUtil::parseOpt(array('c', 'charset')); $charset = XSUtil::getOpt('c', 'charset'); XSUtil::setCharset($charset); // result number record $result = array('PHP 版本' => array('type' => (version_compare(PHP_VERSION, '5.2.0', '>=') ? '' : 'ERROR:') . PHP_VERSION, 'used' => 'XS(core)', 'note' => 'PHP 5.2.0 或更高版本是必须的。'), 'SPL 扩展' => array('type' => extension_loaded('spl') ? 'OK' : 'ERROR', 'used' => 'XS(core)', 'note' => 'SPL 扩展用于自动加载和对象戏法'), 'PCRE 扩展' => array('type' => extension_loaded('pcre') ? 'OK' : 'ERROR', 'used' => 'XSDocument, XSSearch', 'note' => '用于字符串切割、判断'), '编码转换' => array('type' => check_conv(), 'used' => 'XSDocument, XSSearch', 'note' => '用于支持非 UTF-8 字符集'), '缓存模块' => array('type' => check_cache(), 'used' => 'XS', 'note' => '用于缓存项目配置文件的解析结果'), 'JSON 扩展' => array('type' => extension_loaded('json') ? 'OK' : 'WARNING', 'used' => 'util.Quest, util.Indexer', 'note' => '用于读取或输出 JSON 格式的数据'), 'XML 扩展' => array('type' => extension_loaded('xml') ? 'OK' : 'WARNING', 'used' => 'util.Indexer', 'note' => '用于读取导入 XML 格式的数据'), 'MySQL 扩展' => array('type' => check_mysql(), 'used' => 'util.Indexer', 'note' => '用于读取导入 MySQL 的数据库'), 'SQLite 扩展' => array('type' => check_sqlite(), 'used' => 'util.Indexer', 'note' => '用于读取导入 SQLite 的数据库')); // output ?> Xunsearch PHP-SDK 运行需求检查 ============================== 检查内容 -------- 本程序用于确认您的服务器配置是否能满足运行 Xunsearch PHP-SDK 的要求。 它将检查服务器所运行的 PHP 版本,查看是否安装了合适的PHP扩展模块,以及 确认 php.ini 文件是否正确设置。 <?php out_line(); out_line('项目', '结果', '用于', '备注');
/** * Clear a key from the cache. This is used to invalidate a single key. * * @param String $key -- Key from global namespace */ function sugar_cache_clear($key) { if ($GLOBALS['external_cache_checked'] == false) { check_cache(); } $GLOBALS['external_cache_object']->__unset($key); }
/* Rough take on Twitter oEmbed for VeloRooms by L'arri : voici.l.arriviste@gmail.com 27 October 2014 Packaged and modified by SMFHacks.com -vbgamer45 */ // I used SMF items where possible for database interactions and required includes. global $ssi_guest_access; $ssi_guest_access = 1; require dirname(__FILE__) . '/SSI.php'; global $smcFunc; $_GET = filter_input_array(INPUT_GET, FILTER_SANITIZE_NUMBER_INT); $qv = $_GET['id']; if (!empty($qv)) { check_cache($qv); } else { echo '{"html":"<p style=\\"color: #666; border: 1px dotted #666; padding: 5px; width: 490px;\\">' . $txt['autotwitter_blankid'] . '</p>"}'; } function check_cache($tweet) { global $smcFunc; if (!is_numeric($tweet)) { return; } $request = $smcFunc['db_query']('', 'SELECT html from {db_prefix}tweet_cache where tweetid = {raw:tweet}', array('tweet' => $tweet)); if ($smcFunc['db_num_rows']($request) == 0) { add_cache($tweet);
function elephante($tumblr_url, $cachefile="cache/mytumblr.json"){ $cache = check_cache($cachefile); if($cache){ $newtumblr = get_tumblr($tumblr_url,"", $cache["modtime"]); if($newtumblr["status"] == 200){ // a new tumblr file was loaded, now update cache time $cache["modtime"] = $newtumblr["modtime"]; $firstpostid = $cache["posts"][0]["id"]; for( $i=0; $i < count($newtumblr["tumblr"]["posts"]) && $newtumblr["tumblr"]["posts"][$i]["id"] !== $firstpostid; $i += 1){ $thispost = $newtumblr["tumblr"]["posts"][$i]; if($thispost["id"] > $firstpostid){ // add this post $cache["posts"] = array_merge(array($thispost), $cache["posts"]); } if($thispost["id"] < $firstpostid){ // this new post is older than our first saved post // weird state problem, so maybe should force recrawl? } } // do low-key consistency check here and then save or recrawl if($newtumblr["tumblr"]["posts-total"] == count($cache["posts"])){ file_put_contents($cachefile, json_encode($cache)); }else{ crawl_tumblr($tumblr_url, $cachefile); } }else if($newtumblr["status"] == 304){ // nothing's changed }else{ // uh oh (likely api/tumblr fail), return cache } }else{ // the cache is borked, try crawling? // also, this assumes that cachefile is writable, but doesn't // give an error if it's not :( // TODO break nicely, maybe add a post that says "it's broken!" crawl_tumblr($tumblr_url, $cachefile); return check_cache($cachefile); } return $cache; }
/** * Reset opcode cache if present */ function sugar_clean_opcodes() { if ($GLOBALS['external_cache_checked'] == false) { check_cache(); } if ($GLOBALS['external_cache_object']) { $GLOBALS['external_cache_object']->clean_opcodes(); } }
$sample_map = unserialize(sample_map); foreach ($sample_map as $mapkey => $mapvalue) { if (startswith($filename, $mapkey)) { return_cached($mapvalue, "samples"); } } } if (!isset($_REQUEST['uri'])) { die("No URI Specified!"); } $uri = $_REQUEST['uri']; if (empty($uri)) { die("No URI Specified!"); } check_samples($uri); check_cache($uri); $custom_headers = []; $req = curl_init($uri); if (isset($_SERVER['HTTP_ACCEPT'])) { $custom_headers[] = "Accept: " . $_SERVER['HTTP_ACCEPT']; } else { die('Cannot process the Accept headers!'); } if (isset($_SERVER['HTTP_USER_AGENT'])) { $custom_headers[] = "User-Agent: " . $_SERVER['HTTP_USER_AGENT']; } curl_setopt($req, CURLOPT_HTTPHEADER, $custom_headers); curl_setopt($req, CURLOPT_RETURNTRANSFER, 1); curl_setopt($req, CURLOPT_VERBOSE, 1); curl_setopt($req, CURLOPT_HEADER, 1); curl_setopt($req, CURLOPT_FOLLOWLOCATION, true);
$cache = check_cache('eep', $hash); if (is_null($cache)) { // no cache $file = generate_eep_file($matrix_rows, $matrix_cols, $matrix_size, $max_layers, $max_fns, $keymaps, $fn_actions, $eep_size, $eep_start, $additional); write_cache('eep', $hash, $file); } else { // has cache $file = $cache; } } // make c file if ($filetype == 'c') { $filename = 'keymap.c'; $hash = sha1(serialize(array('matrix_rows' => $matrix_rows, 'matrix_cols' => $matrix_cols, 'max_layers' => $max_layers, 'max_fns' => $max_fns, 'keymaps' => $keymaps, 'fn_actions' => $fn_actions))); // check cache $cache = check_cache('c', $hash); if (is_null($cache)) { // no cache $file = generate_c_file($matrix_rows, $matrix_cols, $max_layers, $max_fns, $keymaps, $fn_actions); write_cache('c', $hash, $file); } else { // has cache $file = $cache; } // prepend header $header = generate_c_header(); $file = $header . $file; } // download header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $filename . '"');
// make sure this is writeable for www server $config['cache']['request_file'] = 'dashboard.raw.xml'; $config['cache']['output_file'] = 'dashboard.rss.xml'; $config['feed']['img_size'] = 5; // 0-5 (0 is original or large, 5 is small) //$config['feed']['post_format'] = '[%1$s] %4$s (%2$s) - %3$s'; // [type] longname (shortname) - entry $config['feed']['post_format'] = '%3$s (%2$s) - %4$s [%1$s]'; // longname (shortname) - entry [type] /** read config ... if available */ if (file_exists('config.ini')) { $config = parse_ini_file('config.ini', TRUE); } // set GMT/UTC required for proper cache dates & feed validation date_default_timezone_set('GMT'); // and away we go ... if ($config['cache']['request'] && check_cache()) { $result = file_get_contents($config['cache']['dir'] . DIRECTORY_SEPARATOR . $config['cache']['request_file']); $posts = read_xml($result); output_rss($posts); } else { fetch_tumblr_dashboard_xml($config['tumblr']['email'], $config['tumblr']['password']); } /** Functions ------------------------------------- */ /** * Tumbler Dashboard API Read * * @param string $email tumblr account email address * @param string $password tumblr account password * @return void */
function currency_converted($total) { /* $currency_selected = Keywords::find(5); $currency_sel = $currency_selected->keyword; */ $currency_sel = Config::get('app.generic_keywords.Currency'); if ($currency_sel == '$') { $currency_sel = "USD"; } else { $currency_sel = Config::get('app.generic_keywords.Currency'); } if ($currency_sel != 'USD') { $check = check_cache($currency_sel); if (!$check) { $url = "http://currency-api.appspot.com/api/USD/" . $currency_sel . ".json?key=65d69f1a909b37e41272574dcd20c30fb2fbb06e"; $result = file_get_contents($url); $result = json_decode($result); $rate = $result->rate; update_cache($currency_sel, $rate); $total = $total * $rate; } else { $rate = Cash::where('key', 'like', '%' . $currency_sel . '%')->first(); $total = $total * $rate->value; } } else { $total = $total; } return $total; }
function check_for_torrent(&$item, $key, $opts) { global $matched, $test_run, $config_values; if (!(strtolower($item['Feed']) == 'all' || $item['Feed'] === '' || $item['Feed'] == $opts['URL'])) { return; } $rs = $opts['Obj']; $title = strtolower($rs['title']); switch (_isset($config_values['Settings'], 'MatchStyle')) { case 'simple': $hit = $item['Filter'] != '' && strpos(strtr($title, " .", "__"), strtr(strtolower($item['Filter']), " .", "__")) === 0 && ($item['Not'] == '' or my_strpos($title, strtolower($item['Not'])) === FALSE) && ($item['Quality'] == 'All' or $item['Quality'] == '' or my_strpos($title, strtolower($item['Quality'])) !== FALSE); break; case 'glob': $hit = $item['Filter'] != '' && fnmatch(strtolower($item['Filter']), $title) && ($item['Not'] == '' or !fnmatch(strtolower($item['Not']), $title)) && ($item['Quality'] == 'All' or $item['Quality'] == '' or strpos($title, strtolower($item['Quality'])) !== FALSE); break; case 'regexp': default: $hit = $item['Filter'] != '' && preg_match('/\\b' . strtolower(str_replace(' ', '[\\s._]', $item['Filter'])) . '\\b/', $title) && ($item['Not'] == '' or !preg_match('/' . strtolower($item['Not']) . '/', $title)) && ($item['Quality'] == 'All' or $item['Quality'] == '' or preg_match('/' . strtolower($item['Quality']) . '/', $title)); break; } if (strtolower($item['Filter']) == "any") { $hit = 1; $any = 1; } if ($hit) { $guess = guess_match($title, TRUE); } if ($hit && episode_filter($guess, $item['Episodes']) == true) { $matched = 'match'; if (preg_match('/^\\d+p$/', $item['Episode'])) { $item['Episode'] = preg_replace('/^(\\d+)p/', '\\1', $item['Episode']); $PROPER = 1; } if (check_cache($rs['title'])) { if (!$any && _isset($config_values['Settings'], 'Only Newer') == 1) { if (!empty($guess['episode']) && preg_match('/^(\\d+)x(\\d+)p?$|^(\\d{8})p?$/i', $guess['episode'], $regs)) { if (isset($regs[3]) && preg_match('/^(\\d{8})$/', $regs[3]) && $item['Episode'] >= $regs[3]) { _debug($item['Name'] . ": " . $item['Episode'] . ' >= ' . $regs[3] . "\r\n", 1); $matched = "old"; return FALSE; } else { if (isset($regs[1]) && preg_match('/^(\\d{1,3})$/', $regs[1]) && $item['Season'] > $regs[1]) { _debug($item['Name'] . ": " . $item['Season'] . ' > ' . $regs[1] . "\r\n", 1); $matched = "old"; return FALSE; } else { if (isset($regs[2]) && preg_match('/^(\\d{1,3})$/', $regs[1]) && $item['Season'] == $regs[1] && $item['Episode'] >= $regs[2]) { if (!preg_match('/proper|repack|rerip/i', $rs['title'])) { _debug($item['Name'] . ": " . $item['Episode'] . ' >= ' . $regs[2] . "\r\n", 1); $matched = "old"; return FALSE; } else { if ($PROPER == 1) { _debug("Allready downloaded this Proper, Repack or Rerip of " . $item['Name'] . " {$regs['1']}x{$regs['2']}{$regs['3']}\r\n"); $matched = "old"; return FALSE; } } } } } } else { if ($guess['episode'] == 'fullSeason') { $matched = "season"; return FALSE; } else { if ($guess['episode'] != 'noShow' && !preg_match('/^(\\d{1,2} \\d{1,2} \\d{2,4})$/', $guess['episode']) || $config_values['Settings']['Require Episode Info'] == 1) { _debug("{$item} is not in a workable format."); $matched = "nomatch"; return FALSE; } } } } _debug('Match found for ' . $rs['title'] . "\n"); if ($test_run) { $matched = 'test'; return; } if ($link = get_torrent_link($rs)) { $response = client_add_torrent($link, NULL, $rs['title'], $opts['URL'], $item); if (preg_match('/^Error:/', $response)) { _debug("Failed adding torrent {$link}\n", -1); return FALSE; } else { add_cache($rs['title']); } } else { _debug("Unable to find URL for " . $rs['title'] . "\n", -1); $matched = "nourl"; } } } }
function include_url($url) { // include given URL but only take content between <body></body> global $include_urlparts; if (is_string($url)) { $url = array(1 => $url); } elseif (!isset($url[1])) { return ''; } $k = ''; $url = trim($url[1]); $url = explode(' ', $url); $cache = isset($url[1]) ? intval(str_replace('CACHE=', '', strtoupper($url[1]))) : 0; $url = $url[0]; $cache_status = 'MISSING'; if ($url && $cache) { $cache_filename = md5($url) . '-url'; // set cache file name $cache_file = PHPWCMS_CONTENT . 'tmp/' . $cache_filename; // set caching file $cache_status = check_cache($cache_file, $cache); // ceck existence if ($cache_status == 'VALID') { // read cache $k = read_textfile($cache_file); $k = trim($k); if (empty($k)) { $cache_status == 'EXPIRED'; // check if cache content is available } } } if ($cache_status != 'VALID' && $url) { // cache file is missing or outdated $include_urlparts = parse_url($url); if (!empty($include_urlparts['path'])) { $include_urlparts['path'] = dirname($include_urlparts['path']); $include_urlparts['path'] = str_replace('\\', '/', $include_urlparts['path']); } $k = @file_get_contents($url); if ($k) { // now check against charset if (preg_match('/charset=(.*?)"/i', $k, $match)) { $charset = $match[1]; $charset = str_replace(array('"', "'", '/'), '', $charset); $charset = strtolower(trim($charset)); } elseif (preg_match('/http-equiv="{0,1}Content-Type"{0,1}\\s{1,}(content="{0,1}.*?"{0,1}.{0,3}>)/i', $k, $match)) { $charset = ''; if (!empty($match[1])) { $charset = strtolower($match[1]); $charset = trim(str_replace(array('"', "'", '/', 'content=', ' ', '>'), '', $charset)); } } else { $charset = false; } if (preg_match('/<body[^>]*?' . '>(.*)<\\/body>/is', $k, $match)) { $k = $match[1]; } $k = str_replace(array('<?', '?>', '<%', '%>'), array('<?', '?>', '<%', '%>'), $k); $k = preg_replace_callback('/(href|src|action)=[\'|"]{0,1}(.*?)[\'|"]{0,1}( .*?){0,1}>/i', 'make_absoluteURL', $k); $k = htmlfilter_sanitize(trim($k), array(false, 'link', 'meta'), array(), array('img', 'br', 'hr', 'input'), true); if ($charset != false) { $k = makeCharsetConversion($k, $charset, PHPWCMS_CHARSET, 1); } // now write or update cache file in case there is timeout or content if ($cache && $k) { @write_textfile($cache_file, $k); } } $include_urlparts = ''; } return $k; }
require_once QISHI_ROOT_PATH . 'include/mysql.class.php'; require_once QISHI_ROOT_PATH . 'include/fun_personal.php'; $smarty->cache = false; $db = new mysql($dbhost, $dbuser, $dbpass, $dbname); $act = !empty($_REQUEST['act']) ? trim($_REQUEST['act']) : 'salary'; $smarty->cache = false; $filename = urlencode($_GET['district'] . '_' . $_GET['category']) . '_all_salary.cache'; $result = check_cache($filename, 'salary', 7); if (!$result) { $result = dfopen("http://www.74cms.com/salary/get_salary_data_all_salary.php?district=" . $_GET['district'] . "&category=" . $_GET['category'] . "&certification=" . $_SERVER['SERVER_NAME']); write_cache($filename, $result, 'salary'); } if ($result != "-1") { $result = json_decode($result, true); } else { $result = "error"; } $str1 = $_GET['district'] != '' ? $_GET['district'] : '全国'; $str2 = $_GET['category'] != '' ? $_GET['category'] : '职工'; $str3 = $_GET['category'] != '' ? $_GET['category'] : '企业'; $smarty->assign('str', $str1 . $str2); $smarty->assign('str2', $str1 . $str3); $smarty->assign('all_salary', $result); $filename = urlencode($_GET['district'] . '_' . $_GET['category']) . '_salary_barchart.cache'; $result = check_cache($filename, 'salary', 7); if (!$result) { $result = dfopen("http://www.74cms.com/salary/get_salary_data_salary_barchart.php?district=" . $_GET['district'] . "&category=" . $_GET['category'] . "&certification=" . $_SERVER['SERVER_NAME']); write_cache($filename, $result, 'salary'); } $smarty->assign('salary_barchart_experience', $result); $smarty->display("m/m-salary.html");
function ss_get_by_ssh($options) { global $debug, $cache_dir, $poll_time; # Build and test the type-specific function names. $caching_func = "{$options['type']}_cachefile"; $cmdline_func = "{$options['type']}_cmdline"; $parsing_func = "{$options['type']}_parse"; $getting_func = "{$options['type']}_get"; debug("Functions: '{$caching_func}', '{$cmdline_func}', '{$parsing_func}'"); if (!function_exists($cmdline_func)) { die("The parsing function '{$cmdline_func}' does not exist"); } if (!function_exists($parsing_func)) { die("The parsing function '{$parsing_func}' does not exist"); } # Check the cache. $fp = null; if (!isset($options['file']) && $cache_dir && !array_key_exists('nocache', $options) && function_exists($caching_func)) { $cache_file = call_user_func($caching_func, $options); $cache_res = check_cache($cache_dir, $poll_time, $cache_file, $options); if ($cache_res[1]) { debug("The cache is usable."); return extract_desired($options, $cache_res[1]); } elseif ($cache_res[0]) { $fp = $cache_res[0]; debug("Got a filehandle to the cache file"); } } if (!$fp) { debug("Caching is disabled."); } # There might be a custom function that overrides the SSH fetch. if (!isset($options['file']) && function_exists($getting_func)) { debug("{$getting_func}() is defined, will call it"); $output = call_user_func($getting_func, $options); } else { # Get the command-line to fetch the data, then fetch and parse the data. debug("No getting_func(), will use normal code path"); $cmd = call_user_func($cmdline_func, $options); debug($cmd); $output = get_command_result($cmd, $options); } debug($output); $result = call_user_func($parsing_func, $options, $output); # Define the variables to output. I use shortened variable names so maybe # it'll all fit in 1024 bytes for Cactid and Spine's benefit. However, don't # use things that have only hex characters, thus begin with 'gg' to avoid a # bug in Cacti. This list must come right after the word # MAGIC_VARS_DEFINITIONS. The Perl script parses it and uses it as a Perl # variable. $keys = array('APACHE_Requests' => 'gg', 'APACHE_Bytes_sent' => 'gh', 'APACHE_Idle_workers' => 'gi', 'APACHE_Busy_workers' => 'gj', 'APACHE_CPU_Load' => 'gk', 'APACHE_Waiting_for_connection' => 'gl', 'APACHE_Starting_up' => 'gm', 'APACHE_Reading_request' => 'gn', 'APACHE_Sending_reply' => 'go', 'APACHE_Keepalive' => 'gp', 'APACHE_DNS_lookup' => 'gq', 'APACHE_Closing_connection' => 'gr', 'APACHE_Logging' => 'gs', 'APACHE_Gracefully_finishing' => 'gt', 'APACHE_Idle_cleanup' => 'gu', 'APACHE_Open_slot' => 'gv', 'STAT_CPU_user' => 'gw', 'STAT_CPU_nice' => 'gx', 'STAT_CPU_system' => 'gy', 'STAT_CPU_idle' => 'gz', 'STAT_CPU_iowait' => 'hg', 'STAT_CPU_irq' => 'hh', 'STAT_CPU_softirq' => 'hi', 'STAT_CPU_steal' => 'hj', 'STAT_CPU_guest' => 'hk', 'STAT_interrupts' => 'hl', 'STAT_context_switches' => 'hm', 'STAT_forks' => 'hn', 'STAT_loadavg' => 'ho', 'STAT_numusers' => 'hp', 'STAT_memcached' => 'hq', 'STAT_membuffer' => 'hr', 'STAT_memshared' => 'hs', 'STAT_memfree' => 'ht', 'STAT_memused' => 'hu', 'STAT_memtotal' => 'hv', 'NGINX_active_connections' => 'hw', 'NGINX_server_accepts' => 'hx', 'NGINX_server_handled' => 'hy', 'NGINX_server_requests' => 'hz', 'NGINX_reading' => 'ig', 'NGINX_writing' => 'ih', 'NGINX_waiting' => 'ii', 'MEMC_rusage_user' => 'ij', 'MEMC_rusage_system' => 'ik', 'MEMC_curr_items' => 'il', 'MEMC_total_items' => 'im', 'MEMC_bytes' => 'in', 'MEMC_curr_connections' => 'io', 'MEMC_total_connections' => 'ip', 'MEMC_cmd_get' => 'iq', 'MEMC_cmd_set' => 'ir', 'MEMC_get_misses' => 'is', 'MEMC_evictions' => 'it', 'MEMC_bytes_read' => 'iu', 'MEMC_bytes_written' => 'iv', 'DISK_reads' => 'iw', 'DISK_reads_merged' => 'ix', 'DISK_sectors_read' => 'iy', 'DISK_time_spent_reading' => 'iz', 'DISK_writes' => 'jg', 'DISK_writes_merged' => 'jh', 'DISK_sectors_written' => 'ji', 'DISK_time_spent_writing' => 'jj', 'DISK_io_ops' => 'jk', 'DISK_io_time' => 'jl', 'DISK_io_time_weighted' => 'jm', 'OPVZ_kmemsize_held' => 'jn', 'OPVZ_kmemsize_failcnt' => 'jo', 'OPVZ_lockedpages_held' => 'jp', 'OPVZ_lockedpages_failcnt' => 'jq', 'OPVZ_privvmpages_held' => 'jr', 'OPVZ_privvmpages_failcnt' => 'js', 'OPVZ_shmpages_held' => 'jt', 'OPVZ_shmpages_failcnt' => 'ju', 'OPVZ_numproc_held' => 'jv', 'OPVZ_numproc_failcnt' => 'jw', 'OPVZ_physpages_held' => 'jx', 'OPVZ_physpages_failcnt' => 'jy', 'OPVZ_vmguarpages_held' => 'jz', 'OPVZ_vmguarpages_failcnt' => 'kg', 'OPVZ_oomguarpages_held' => 'kh', 'OPVZ_oomguarpages_failcnt' => 'ki', 'OPVZ_numtcpsock_held' => 'kj', 'OPVZ_numtcpsock_failcnt' => 'kk', 'OPVZ_numflock_held' => 'kl', 'OPVZ_numflock_failcnt' => 'km', 'OPVZ_numpty_held' => 'kn', 'OPVZ_numpty_failcnt' => 'ko', 'OPVZ_numsiginfo_held' => 'kp', 'OPVZ_numsiginfo_failcnt' => 'kq', 'OPVZ_tcpsndbuf_held' => 'kr', 'OPVZ_tcpsndbuf_failcnt' => 'ks', 'OPVZ_tcprcvbuf_held' => 'kt', 'OPVZ_tcprcvbuf_failcnt' => 'ku', 'OPVZ_othersockbuf_held' => 'kv', 'OPVZ_othersockbuf_failcnt' => 'kw', 'OPVZ_dgramrcvbuf_held' => 'kx', 'OPVZ_dgramrcvbuf_failcnt' => 'ky', 'OPVZ_numothersock_held' => 'kz', 'OPVZ_numothersock_failcnt' => 'lg', 'OPVZ_dcachesize_held' => 'lh', 'OPVZ_dcachesize_failcnt' => 'li', 'OPVZ_numfile_held' => 'lj', 'OPVZ_numfile_failcnt' => 'lk', 'OPVZ_numiptent_held' => 'll', 'OPVZ_numiptent_failcnt' => 'lm', 'REDIS_connected_clients' => 'ln', 'REDIS_connected_slaves' => 'lo', 'REDIS_used_memory' => 'lp', 'REDIS_changes_since_last_save' => 'lq', 'REDIS_total_connections_received' => 'lr', 'REDIS_total_commands_processed' => 'ls', 'JMX_heap_memory_used' => 'lt', 'JMX_heap_memory_committed' => 'lu', 'JMX_heap_memory_max' => 'lv', 'JMX_non_heap_memory_used' => 'lw', 'JMX_non_heap_memory_committed' => 'lx', 'JMX_non_heap_memory_max' => 'ly', 'JMX_open_file_descriptors' => 'lz', 'JMX_max_file_descriptors' => 'mg', 'JMX_current_threads_busy' => 'mh', 'JMX_current_thread_count' => 'mi', 'JMX_max_threads' => 'mj', 'MONGODB_connected_clients' => 'mk', 'MONGODB_used_resident_memory' => 'ml', 'MONGODB_used_mapped_memory' => 'mm', 'MONGODB_used_virtual_memory' => 'mn', 'MONGODB_index_accesses' => 'mo', 'MONGODB_index_hits' => 'mp', 'MONGODB_index_misses' => 'mq', 'MONGODB_index_resets' => 'mr', 'MONGODB_back_flushes' => 'ms', 'MONGODB_back_total_ms' => 'mt', 'MONGODB_back_average_ms' => 'mu', 'MONGODB_back_last_ms' => 'mv', 'MONGODB_op_inserts' => 'mw', 'MONGODB_op_queries' => 'mx', 'MONGODB_op_updates' => 'my', 'MONGODB_op_deletes' => 'mz', 'MONGODB_op_getmores' => 'ng', 'MONGODB_op_commands' => 'nh', 'MONGODB_slave_lag' => 'ni', 'DISKFREE_used' => 'nj', 'DISKFREE_available' => 'nk', 'NETDEV_inbound' => 'nl', 'NETDEV_rxerrs' => 'nm', 'NETDEV_rxdrop' => 'nn', 'NETDEV_rxfifo' => 'no', 'NETDEV_rxframe' => 'np', 'NETDEV_outbound' => 'nq', 'NETDEV_txerrs' => 'nr', 'NETDEV_txdrop' => 'ns', 'NETDEV_txfifo' => 'nt', 'NETDEV_txcolls' => 'nu', 'NETDEV_txcarrier' => 'nv', 'NETSTAT_established' => 'nw', 'NETSTAT_syn_sent' => 'nx', 'NETSTAT_syn_recv' => 'ny', 'NETSTAT_fin_wait1' => 'nz', 'NETSTAT_fin_wait2' => 'og', 'NETSTAT_time_wait' => 'oh', 'NETSTAT_close' => 'oi', 'NETSTAT_close_wait' => 'oj', 'NETSTAT_last_ack' => 'ok', 'NETSTAT_listen' => 'ol', 'NETSTAT_closing' => 'om', 'NETSTAT_unknown' => 'on', 'VMSTAT_pswpin' => 'oo', 'VMSTAT_pswpout' => 'op'); # Prepare and return the output. The output we have right now is the whole # info, and we need that -- to write it to the cache file -- but what we # return should be only the desired items. $output = array(); foreach ($keys as $key => $short) { # If the value isn't defined, return -1 which is lower than (most graphs') # minimum value of 0, so it'll be regarded as a missing value. $val = isset($result[$key]) ? $result[$key] : -1; $output[] = "{$short}:{$val}"; } $result = implode(' ', $output); if ($fp) { if (fwrite($fp, $result) === FALSE) { die("Cannot write to '{$cache_file}'"); } fclose($fp); } return extract_desired($options, $result); }
$lastModified = filemtime($src); // get properties $new_width = preg_replace("/[^0-9]+/", '', get_request('w', 0)); $new_height = preg_replace("/[^0-9]+/", '', get_request('h', 0)); $zoom_crop = preg_replace("/[^0-9]+/", '', get_request('zc', 1)); $quality = preg_replace("/[^0-9]+/", '', get_request('q', 80)); $filters = get_request('f', ''); $sharpen = get_request('s', 0); if ($new_width == 0 && $new_height == 0) { $new_width = 100; $new_height = 100; } // get mime type of src $mime_type = mime_type($src); // check to see if this image is in the cache already check_cache($mime_type); // if not in cache then clear some space and generate a new file cleanCache(); ini_set('memory_limit', '50M'); // make sure that the src is gif/jpg/png if (!valid_src_mime_type($mime_type)) { displayError('Invalid src mime type: ' . $mime_type); } if (strlen($src) && file_exists($src)) { // open the existing image $image = open_image($mime_type, $src); if ($image === false) { displayError('Unable to open image : ' . $src); } // Get original width and height $width = imagesx($image);
/** * Put a value in the cache under a key * * @param String $key -- Global namespace cache. Key for the data. * @param Serializable $value -- The value to store in the cache. */ function sugar_cache_put($key, $value) { if (!$GLOBALS['external_cache_checked']) { check_cache(); } if (EXTERNAL_CACHE_DEBUG) { echo "<HR>1 Adding key to APC cache {$key} with value ({$value})<HR>"; } if (empty($value)) { $value = EXTERNAL_CACHE_NULL_VALUE; } if (EXTERNAL_CACHE_DEBUG) { echo "<HR>2 Adding key to APC cache {$key} with value ({$value})<HR>"; } $GLOBALS['cache_local_store'][$key] = $value; if ($GLOBALS['external_cache_enabled']) { $external_key = $GLOBALS['sugar_config']['unique_key'] . $key; if ($GLOBALS['external_cache_type'] == 'zend') { output_cache_put($external_key, $value); } elseif ($GLOBALS['external_cache_type'] == 'apc') { $test_time = EXTERNAL_CACHE_INTERVAL_SECONDS; $return = apc_store($external_key, $value, $test_time); if (EXTERNAL_CACHE_DEBUG) { echo "<HR>Adding key to APC cache {$external_key} with value ({$value}) to be stored for {$test_time} seconds<HR>"; } } } }