public function run() { $needs_alert = false; $data = get_from_cache('events', 'SessionStart'); /* if the session didn't start we store the information; admin will * receive the alert only once. */ if ($data == NULL) { $data = array(); } $user = $this->ev->user->getAttribute('login'); if (isset($data[$user]) && $this->ev->ok) { unset($data[$user]); } if (!isset($data[$user]) && !$this->ev->ok) { $needs_alert = true; $data[$user] = false; } set_cache($data, 'events', 'SessionStart'); if ($needs_alert) { Logger::debug('main', 'SessionStartMail: sending alert'); $subject = sprintf(_('OVD Session alert: %s couldn\'t log in'), $user); if (isset($this->ev->error)) { $message = _("The following error happened:\n") . $this->ev->error; } else { $message = _('No error given'); } send_alert_mail($subject, $message); } return true; }
public function run() { Logger::debug('main', 'ServerStatusChangedTask::run'); $needs_cleanup = false; $data = get_from_cache('events', 'ServerStatusChanged'); if ($data == NULL) { $data[$this->ev->fqdn] = $this->ev->status; if ($this->ev->status != ServerStatusChanged::$ONLINE) { $needs_cleanup = true; } } else { if ($this->ev->status != ServerStatusChanged::$ONLINE) { $needs_cleanup = true; } } if ($needs_cleanup) { Logger::debug('main', 'ServerStatusChangedTask::run cleanup task for ' . $this->ev->fqdn); set_cache($data, 'events', 'ServerStatusChanged'); $tm = new Tasks_Manager(); $tm->load_from_server($this->ev->fqdn); foreach ($tm->tasks as $a_task) { $tm->remove($a_task->id); } } return true; }
public function cache_select() { $uid = $_SESSION['uid']; if (isset($GLOBALS['setcache'])) { $ids = get_cache('cache_all-' . $uid); } else { if (!isset($GLOBALS['ids']) || empty($GLOBALS['ids'])) { $where = array('keyid' => 'cache_all'); $result = $this->db->get_list('setting', $where, '*', 0, 100); $ids = array(); foreach ($result as $r) { $ids[] = $r['id']; } } else { $ids = array_map('intval', $GLOBALS['ids']); } set_cache('cache_all-' . $uid, $ids); } if (empty($ids)) { MSG('缓存更新完成', '?m=core&f=cache_all&v=index' . $this->su(), 2000); } $id = array_shift($ids); $r = $this->db->get_one('setting', array('id' => $id)); $caches = load_class($r['f'], $r['m']); if ($caches->{$r}['v']()) { set_cache('cache_all-' . $uid, $ids); MSG($r['data'] . L('update success'), '?m=core&f=cache_all&v=cache_select&setcache=1&' . $this->su(), 200); } else { MSG(L('operation failure')); } }
/** * 更新敏感词缓存,默认最多1万个敏感词 * @return bool */ public function cache_all() { $db = load_class('db'); $result = $db->get_list('admin_role', '', '*', 0, 100, 0, '', '', 'role'); set_cache('roles', $result); return true; }
public function indexAction() { $action = $this->get('action'); $size = $this->get('size'); if ($this->post('submit')) { $size = 2048; //每个分卷文件大小 $tables = $this->post('table'); if (empty($tables)) { $this->show_message('您还没有选择要备份的表。'); } set_cache('bakup_tables', array('tables' => $tables, 'time' => time())); $this->show_message('正在备份数据...', 1, url('database/index', array('action' => 1, 'size' => $size)), 100); } if ($action) { $fileid = $this->get('fileid'); $random = $this->get('random'); $tableid = $this->get('tableid'); $startfrom = $this->get('startfrom'); $this->export_database($size, $action, $fileid, $random, $tableid, $startfrom); } else { $dbname = $this->db->getdbName(); $dbprefix = $this->db->getTablePrefix(); $data = $this->db->query('SHOW TABLE STATUS FROM `' . $dbname . '`')->fetchAll(); foreach ($data as $key => $t) { $data[$key]['xiaosys'] = substr($t['Name'], 0, strlen($dbprefix)) != $dbprefix ? 0 : 1; } include $this->admin_tpl('database_list'); } }
public function run() { $needs_alert = false; $data = get_from_cache('events', 'SqlFailure'); if ($data == NULL) { $data[$this->ev->host] = $this->ev->status; if ($this->ev->status < 0) { $needs_alert = true; } } else { if (isset($data[$this->ev->host]) && $data[$this->ev->host] != $this->ev->status) { $data[$this->ev->host] = $this->ev->status; $needs_alert = true; } } if ($needs_alert) { set_cache($data, 'events', 'SqlFailure'); Logger::debug('main', 'SqlFailureMail: sending alert'); if ($this->ev->status < 0) { $subject = sprintf(_('OVD Alert: MySQL %s is offline'), $this->ev->host); } else { $subject = sprintf(_('OVD End Alert: MySQL %s is up again'), $this->ev->host); } send_alert_mail($subject, ''); } return true; }
/** * 列表 */ public function listing() { //0, $order = '', $group = '', $keyfield = '' $result = $this->db->get_list('site', '', '*', 0, 100, 0, '', '', 'siteid'); set_cache('sitelist', $result); include $this->template('site_listing'); }
public function run() { $needs_alert = false; $data = get_from_cache('events', 'ServerStatusChanged'); if ($data == NULL) { $data[$this->ev->fqdn] = $this->ev->status; if ($this->ev->status == ServerStatusChanged::$OFFLINE) { $needs_alert = true; } } else { if (isset($data[$this->ev->fqdn]) && $data[$this->ev->fqdn] != $this->ev->status) { $data[$this->ev->fqdn] = $this->ev->status; $needs_alert = true; } } if ($needs_alert) { Logger::debug('main', 'ServerStatusChangedMail: sending alert'); set_cache($data, 'events', 'ServerStatusChanged'); if ($this->ev->status == ServerStatusChanged::$OFFLINE) { $subject = sprintf(_('OVD Alert: %s is offline'), $this->ev->fqdn); } else { $subject = sprintf(_('OVD End Alert: %s is up again'), $this->ev->fqdn); } send_alert_mail($subject, ''); } return true; }
function track($data) { $cache_key = 'click_' . $data['h'] . ''; if (MAD_TRACK_UNIQUE_CLICKS) { $cache_result = get_cache($cache_key); if ($cache_result && $cache_result == 1) { return false; } else { set_cache($cache_key, 1, 500); } } if (!is_numeric($data['zone_id'])) { return false; } /* Get the Publication */ $query = "SELECT publication_id FROM md_zones WHERE entry_id='" . $data['zone_id'] . "'"; $zone_detail = simple_query_maindb($query, true, 1000); if (!$zone_detail or $zone_detail['publication_id'] < 1) { return false; } switch ($data['type']) { case 'normal': reporting_db_update($zone_detail['publication_id'], $data['zone_id'], $data['campaign_id'], $data['ad_id'], '', 0, 0, 0, 1); break; case 'network': reporting_db_update($zone_detail['publication_id'], $data['zone_id'], $data['campaign_id'], '', $data['network_id'], 0, 0, 0, 1); break; case 'backfill': reporting_db_update($zone_detail['publication_id'], $data['zone_id'], '', '', $data['network_id'], 0, 0, 0, 1); break; } }
/** * 更新内容模块栏目缓存 * @return bool */ public function cache_all() { $db = load_class('db'); $result = $db->get_list('category', '', '*', 0, 10000, 'sort ASC,cid ASC'); //所有内容模块栏目缓存,仅缓存name,url,cid,pid,child $all = array(); foreach ($result as $v) { $tmp = array(); $tmp['name'] = $v['name']; $tmp['pid'] = $v['pid']; $tmp['child'] = $v['child']; $tmp['modelid'] = $v['modelid']; $tmp['catdir'] = $v['catdir']; $tmp['url'] = $v['url']; $tmp['showloop'] = $v['showloop']; $tmp['type'] = $v['type']; $tmp['showhtml'] = $v['showhtml']; $tmp['listhtml'] = $v['listhtml']; $tmp['language'] = $v['language']; $tmp['siteid'] = $v['siteid']; $tmp['icon'] = $v['icon']; if ($v['domain']) { $tmp['domain'] = $v['domain']; } $all[$v['cid']] = $tmp; set_cache('category_' . $v['cid'], $v, 'content'); } set_cache('category', $all, 'content'); return true; }
public function myAction() { $userid = $this->admin['userid']; if ($this->post('submit')) { $data = $this->post('data'); if (!empty($data['password'])) { if (strlen($data['password']) < 6) { $this->show_message('密码最少6位数', 2); } $data['password'] = md5(md5($data['password'])); } else { unset($data['password']); } if ($data['auth']) { unset($data['auth']); } if ($data['roleid']) { unset($data['roleid']); } $this->db->setTableName('admin')->update($data, 'userid=?', $userid); $data = array(); foreach ($this->db->setTableName('admin')->findAll() as $t) { unset($t['password']); $data[$t['userid']] = $t; } set_cache('admin', $data); $this->show_message('修改成功', 1); } $data = $this->db->setTableName('admin')->find($userid); include $this->admin_tpl('my'); }
public function cacheAction() { $data = array(); foreach ($this->db->setTableName('block')->findAll() as $t) { $data[$t['id']] = $t; } set_cache('block', $data); }
public function cache() { $result = $this->db->get_list('linkage', '', '*', 0, 10000, 0, 'linkageid DESC'); foreach ($result as $r) { set_cache('config_' . $r['linkageid'], $r, 'linkage'); } return true; }
/** * 基本设置 */ public function init() { if (isset($GLOBALS['submit'])) { $setting = array_map('remove_xss', $GLOBALS['form']); set_cache('sms_config', $setting, 'sms'); MSG('更新成功', HTTP_REFERER); } else { $setting = get_cache('sms_config', 'sms'); include $this->template('setting'); } }
function save_page_data($page, $sort, $per_page) { $cache_key = build_cache_key($page, $sort); $result = get_cache($cache_key); if (!$result) { $data = get_products($page, $per_page, true); $ids = ''; foreach ($data as $product) { $ids .= $product[0] . ','; } set_cache($cache_key, substr($ids, 0, -1)); } }
function _update_gameworld_value() { global $game_kv; $gameworld_info = array(); $sql = "SELECT * FROM s_game_kv"; $rst = mysql_x_query($sql); while ($row = mysql_fetch_assoc($rst)) { $gameworld_info[$row['key']] = $row['value']; } set_cache('', 'gameworld_info', $gameworld_info); $game_kv = $gameworld_info; return $gameworld_info; }
public function find_resource($type_id, $id) { if (!isset($this->types[$type_id])) { return NULL; } $class_name = $this->types[$type_id]; $resource = get_cache($class_name, $class_name . '_id', $id); if (is_null($resource)) { $resource = new $class_name($id); set_cache($resource, $class_name . '_id', $id); } return $resource; }
/** * 更新敏感词缓存,默认最多1万个敏感词 * @return bool */ public function cache_all() { $db = load_class('db'); $result = $db->get_list('badword', '', 'word', 0, 10000); $tmp = "<?php return array("; foreach ($result as $rs) { $tmp .= "'" . $rs['word'] . "',"; } $tmp .= ")?>"; // print_r($tmp);exit; set_cache('badword', $tmp); return true; }
function is_set_cookie($str) { $cache_type = array('image/jpeg', 'image/gif', 'image/png', 'text/javascript', 'text/css'); $arr = split(": ", $str); if ($arr[0] == "Content-Type" && in_array(trim($arr[1]), $cache_type)) { set_cache(); } if ($arr[0] == "Set-Cookie") { to_set_cookie($arr[1]); return true; } else { return false; } }
function _update_all_areas() { global $g_xcache_enabled; $sql = "SELECT * FROM s_map_area"; $rst = mysql_x_query($sql); while ($row = mysql_fetch_assoc($rst)) { $all_areas[$row['area_type']][$row['area_id']] = $row; } if ($g_xcache_enabled) { set_xcache('sys', 'all_area', $all_areas, 0); } else { set_cache('sys', 'all_area', $all_areas, 0); } return $all_areas; }
function get_count_product() { $c = get_connection(); $result = get_cache('total_count'); if (!$result) { $q = 'SELECT product_stat.value FROM product_stat where name= "product_count"'; $res = mysqli_query($c, $q); $row = mysqli_fetch_row($res); if (empty($row[0])) { $row[0] = 0; } set_cache('total_count', $row[0]); return $row[0]; } return $result; }
/** * 积分配置 */ public function set() { if (isset($GLOBALS['submit'])) { $formdata = array_map('remove_xss', $GLOBALS['form']); set_cache('point_config', $formdata); $serialize_data = serialize($formdata); $updatetime = date('Y-m-d H:i:s', SYS_TIME); $this->db->update('setting', array('data' => $serialize_data, 'updatetime' => $updatetime), array('keyid' => 'configs', 'm' => 'credit')); MSG(L('edit success'), HTTP_REFERER); } else { $setting = array(); $r = $this->db->get_one('setting', array('keyid' => 'configs', 'm' => 'credit')); $setting = unserialize($r['data']); load_class('form'); include $this->template('set'); } }
function twitter_get_tweets($twitteruser) { global $consumer_key, $consumer_secret, $access_token, $access_tokensecret; $cache = get_cache(); if (is_array($cache) && array_key_exists($twitteruser, $cache)) { echo json_encode($cache[$twitteruser]); return; } if (empty($consumer_key) || empty($consumer_secret) || empty($access_token) || empty($access_tokensecret)) { echo 'Twitter is not configured.'; return; } $connection = getConnectionWithaccess_token($consumer_key, $consumer_secret, $access_token, $access_tokensecret); $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=" . $twitteruser); if (!is_array($cache)) { $cache = array(); } $cache[$twitteruser] = $tweets; set_cache($cache, 60); echo json_encode($tweets); }
public function create_scope($from, $to, $anchor_text_id = NULL, $webpage_id = NULL) { if (is_int($anchor_text_id) === FALSE) { $text = $anchor_text_id; $this->_CI_load('library', 'scope/Scope_anchor_text'); $anchor_text_id = $this->CI->scope_anchor_text->filter_anchor_text_id($text); } if (NULL !== $webpage_id) { $key = $from . '-' . $to; if (is_object($webpage_id)) { $webpage_id = $webpage_id->get_id(); } $value = $webpage_id; $scope = get_cache($this, $key, $value); if (is_null($scope)) { $data = $this->_create_cond($webpage_id, $from, $to, $anchor_text_id); $scope = $this->find($data); if (is_null($scope)) { //test_msg('Annotation_scope->create_scope() not find, before create', $data); $scope = $this->create($data); } set_cache($scope, $key, $value); } return $scope; } else { $key = $from; $value = $to; $scope = get_cache($this, $key, $value); if (is_null($scope)) { $scope = new Annotation_scope(); $scope->set_index($from, $to); if (NULL != $anchor_text_id) { $scope->set_anchor_text($anchor_text_id); } set_cache($scope, $key, $value); } return $scope; } }
function get_online_info($uid, $sid, $zeit) { //在线统计 $v_online = get_cache($uid, 'online', 1); if ($v_online == -1) { $online_id = gen_online_id($uid, $sid, $zeit); $online['online_id'] = $online_id; $online['sid'] = $sid; $online['last_update_db_online'] = $zeit; set_cache($uid, 'online', $online); $v_online = $online; } elseif ($v_online == -2) { $sql = "SELECT MAX(`id`) as max_id FROM `st_online_details` WHERE `uid`='{$uid}'"; $rst = mysql_query($sql); if ($row = mysql_fetch_assoc($rst)) { $online['online_id'] = $row['max_id']; } else { $online_id = gen_online_id($uid, $sid, $zeit); $online['online_id'] = $online_id; } $online['sid'] = $sid; $online['last_update_db_online'] = $zeit; set_cache($uid, 'online', $online); $v_online = $online; } elseif ($v_online['sync_memcache'] == 1) { $v_online = $v_online['data']; $sql = "UPDATE st_online_details SET last_online={$zeit} WHERE id={$v_online['online_id']}"; $rst = mysql_w_query($sql); $sql = "UPDATE u_user SET last_online={$zeit} WHERE uid={$uid}"; $rst = mysql_w_query($sql); } else { $v_online = $v_online['data']; } if ($v_online['sid'] != $sid) { set_cookie($uid, $v_online['sid'], 0); $sid = $v_online['sid']; } return $v_online; }
function get_etaturgence() { $etat_urgence = get_cache(); if (!empty($etat_urgence)) { return $etat_urgence; } $curl_connection = curl_init('https://estcequecestencoreletatdurgence.fr/'); curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false); $html = curl_exec($curl_connection); $dom = new DOMDocument(); $dom->loadHTML($html); $status_etat_urgence = get_tag_html($dom, '//h1'); $for_etat_urgence = get_tag_html($dom, '//p'); $subtitle_etat_urgence = get_tag_html($dom, '//small'); preg_match_all('!\\d+!', $for_etat_urgence, $matches); $for_int_etat_urgence = (int) $matches[0][0]; $etat_urgence = array('status' => $status_etat_urgence == "Oui" ? true : false, 'status_string' => $status_etat_urgence, 'for' => $for_int_etat_urgence, 'for_string' => $for_etat_urgence, 'subtitle' => $subtitle_etat_urgence); set_cache($etat_urgence); return $etat_urgence; }
function simple_query_maindb($query, $cache, $sec) { global $maindb; if ($cache) { $cache_result = get_cache($query); if ($cache_result) { return $cache_result; } } if ($exec = mysql_query($query, $maindb)) { //yay $result = mysql_fetch_array($exec); // DEFINE ARRAY OF USER DETAILS if ($cache) { set_cache($query, $result, $sec); } return $result; } else { return false; } }
/** * 建構子 * @param integer|Generic_object $id * @return Generic_collection */ function __construct($id = NULL) { parent::__construct(); if (is_int($id) or is_string($id)) { $this->set_id($id); } else { if (is_object($id)) { $this->set_index_object($id); } } if (isset($this->id) && isset($this->index_field)) { $key = $this->index_field; $value = $this->id; $coll = get_cache($this, $key, $value); if (isset($coll)) { $this->_import($coll); return $this; } else { set_cache($this, $key, $value); } } $this->_post_construct(); return $this; }
public function edit() { $blockid = intval($GLOBALS['blockid']); if (isset($GLOBALS['submit'])) { $formdata = array(); $formdata['type'] = intval($GLOBALS['type']); $formdata['modelid'] = intval($GLOBALS['modelid']); $formdata['codetype'] = intval($GLOBALS['codetype']); $formdata['name'] = remove_xss($GLOBALS['form']['name']); $formdata['max_number'] = 500; if ($formdata['type'] == 1) { $code = $GLOBALS['form']['template_code']; } elseif ($formdata['type'] == 2) { $code = $GLOBALS['form']['code']; } elseif ($formdata['type'] == 3) { $formdata['url'] = safe_htm($GLOBALS['form']['rssurl']); $code = $GLOBALS['form']['template_code']; } elseif ($formdata['type'] == 4) { $formdata['url'] = safe_htm($GLOBALS['form']['jsonurl']); $code = $GLOBALS['form']['template_code']; } $formdata['createhtml'] = intval($GLOBALS['createhtml']); $formdata['updatetime'] = SYS_TIME; $formdata['timing'] = SYS_TIME + 3600; $formdata['status'] = 9; //替换 #wz# if ($formdata['type'] == 1) { $str = 'type="1" blockid="' . $blockid . '"'; } elseif ($formdata['type'] == 2) { $str = 'type="2" blockid="' . $blockid . '"'; } elseif ($formdata['type'] == 3) { $str = 'type="3" blockid="' . $blockid . '" url="' . $formdata['url'] . '"'; } elseif ($formdata['type'] == 4) { $str = 'type="4" blockid="' . $blockid . '" url="' . $formdata['url'] . '"'; } $formdata['code'] = addslashes(str_replace('#wz#', $str, $code)); $this->db->update('block', $formdata, array('blockid' => $blockid)); set_cache('block_' . $blockid, $formdata, 'block'); //生成静态 if ($formdata['createhtml']) { $GLOBALS['blockids'] = array($blockid); $this->html(0); } MSG(L('edit success'), HTTP_REFERER); } else { $show_formjs = 1; $form = load_class('form'); $r = $this->db->get_one('block', array('blockid' => $blockid)); $r['code'] = stripslashes($r['code']); $models = $this->db->get_list('model', '', '*', 0, 100, 0, 'modelid ASC'); include $this->template('block_edit'); } }
/** * 编辑器配置项目 * * @author tuzwu * @createtime 2014-8-30 20:31:23 * @modifytime * @param * @return */ public function ueditor() { if (isset($GLOBALS['dosubmit'])) { $cache_in_db = cache_in_db($GLOBALS['setting'], V, M); set_cache(V, $GLOBALS['setting']); MSG(L('operation_success'), HTTP_REFERER, 3000); } else { $setting = get_cache(V); if (empty($setting)) { $setting = cache_in_db('', V, M); } include $this->template(V, M); } }