/** * @param $args */ function eventCoreFooterEnd($args) { global $resourcesModule, $resourcesConfigsList; if (empty($resourcesModule)) { if (is_a($resourcesModule = xoops_gethandler('module')->getByDirname(basename(dirname(__DIR__))), "XoopsModule")) { if (empty($resourcesConfigsList)) { $resourcesConfigsList = xoops_gethandler('config')->getConfigsList($resourcesModule->getVar('mid')); } } } xoops_load("XoopsCache"); xoops_load("XoopsLists"); if (!($themes = XoopsCache::read(basename(dirname(__DIR__)) . '.available.themes'))) { $themes = json_decode(getURIData(sprintf(_MI_RESOURCES_THEMES, _RESOURCES_SUPPORTING)), true); if (!empty($themes)) { XoopsCache::write(basename(dirname(__DIR__)) . '.available.themes', $themes, 3600 * mt_rand(2.99999, 12.99999)); } } if (!($modules = XoopsCache::read(basename(dirname(__DIR__)) . '.available.modules'))) { $modules = json_decode(getURIData(sprintf(_MI_RESOURCES_MODULES, _RESOURCES_SUPPORTING)), true); if (!empty($themes)) { XoopsCache::write(basename(dirname(__DIR__)) . '.available.modules', $modules, 3600 * mt_rand(2.99999, 12.99999)); } } if (!($peers = XoopsCache::read(basename(dirname(__DIR__)) . '.available.peers'))) { $peers = json_decode(getURIData(sprintf(_MI_RESOURCES_PEERS, _RESOURCES_SUPPORTING)), true); if (!empty($themes)) { XoopsCache::write(basename(dirname(__DIR__)) . '.available.peers', $peers, 3600 * 24 * mt_rand(5.99999, 24.99999)); } } if (!($modules = XoopsCache::read(basename(dirname(__DIR__)) . '.modules.delays') && $resourcesConfigsList['harvester'])) { XoopsCache::write(basename(dirname(__DIR__)) . '.modules', true, 3600 * 24 * 29); XoopsCache::write(basename(dirname(__DIR__)) . '.modules.delays', $modules = XoopsLists::getModulesList(), 3600 * 24 * 31); foreach ($modules as $module) { $map = getFolderMap($GLOBALS['xoops']->path('/modules/' . $module)); XoopsCache::write(basename(dirname(__DIR__)) . '.module' . $module, true, $seconds = 3600 * 24 * mt_rand(21.69999, 42.998876)); XoopsCache::write(basename(dirname(__DIR__)) . '.module' . $module . '.delays', $map, $seconds + 3600 * 4); if (is_dir(XOOPS_PATH . '/modules/' . $module)) { $map = getFolderMap(XOOPS_PATH . '/modules/' . $module, XOOPS_PATH); XoopsCache::write(basename(dirname(__DIR__)) . '.xoopslib' . $module, true, $seconds); XoopsCache::write(basename(dirname(__DIR__)) . '.xoopslib' . $module . '.delays', $map, $seconds + 3600 * 4); } } } if (!($themes = XoopsCache::read(basename(dirname(__DIR__)) . '.themes.delays') && $resourcesConfigsList['harvester'])) { XoopsCache::write(basename(dirname(__DIR__)) . '.themes', true, 3600 * 24 * 29); XoopsCache::write(basename(dirname(__DIR__)) . '.themes.delays', $themes = XoopsLists::getThemesList(), 3600 * 24 * 31); foreach ($themes as $theme) { $map = getFolderMap($GLOBALS['xoops']->path('/themes/' . $theme)); XoopsCache::write(basename(dirname(__DIR__)) . '.theme' . $theme, true, $seconds = 3600 * 24 * mt_rand(21.69999, 42.998876)); XoopsCache::write(basename(dirname(__DIR__)) . '.theme' . $theme . '.delays', $map, $seconds + 3600 * 4); } } }
function mod_loadFile($name, $dirname = null, $root_path = XOOPS_CACHE_PATH) { global $xoopsModule; $data = null; if (empty($name)) { return $data; } $dirname = $dirname ? $dirname : (is_object($xoopsModule) ? $xoopsModule->getVar("dirname", "n") : "system"); xoops_load('XoopsCache'); $key = "{$dirname}_{$name}"; return XoopsCache::read($key); }
/** * @access private */ function loadMenu() { if ($this->menu) { return $this->menu; } xoops_load('XoopsCache'); if (!($this->menu = XoopsCache::read("adminmenu_" . __CLASS__))) { $this->generateMenu(); } $this->menu = XoopsCache::read("adminmenu_" . __CLASS__); return $this->menu; }
function &catalog_getTplPageList($page = "", $refresh = true) { $list = null; $cache_file = empty($page) ? "template-list" : "template-article"; xoops_load("cache"); $key = "catalog_{$cache_file}"; $list = XoopsCache::read($key); if (!is_array($list) || $refresh) { $list = catalog_template_lookup(!empty($page)); } $ret = empty($page) ? $list : @$list[$page]; return $ret; }
/** * @param $args */ function eventCoreIncludeCommonEnd($args) { xoops_load("XoopsCache"); global $resourcesModule, $resourcesConfigsList; if (empty($resourcesModule)) { if (is_a($resourcesModule = xoops_gethandler('module')->getByDirname(basename(dirname(__DIR__))), "XoopsModule")) { if (empty($resourcesConfigsList)) { $resourcesConfigsList = xoops_gethandler('config')->getConfigsList($resourcesModule->getVar('mid')); } } } if ($resourcesConfigsList['scheduling'] == 'preloader') { if (!($jobs = XoopsCache::read(basename(dirname(__DIR__)) . '.cron.jobs'))) { XoopsCache::write(basename(dirname(__DIR__)) . '.cron.jobs', array('harvest-modules.php' => microtime(true) + 3600 * 24 * mt_rand(10, 24), 'harvest-themes.php' => microtime(true) + 3600 * 24 * mt_rand(10, 24), 'send-reports.php' => microtime(true) + 3600 * 24 * mt_rand(2, 6), 'harvest-push.php' => microtime(true) + mt_rand(10, 25), 'updates-pull.php' => microtime(true) + mt_rand(10, 25), 'find-updates.php' => microtime(true) + 1800 * mt_rand(10, 60)), 3600 * 24); } else { $execute = array(); foreach ($jobs as $job => $when) { if ($when < microtime(true)) { switch ($job) { case "harvest-modules.php": case "harvest-themes.php": $jobs[$job] = microtime(true) + 3600 * 24 * mt_rand(10, 24); break; case "send-reports.php": $jobs[$job] = microtime(true) + 3600 * 24 * mt_rand(2, 6); break; case "updates-pull.php": case "harvest-push.php": $jobs[$job] = microtime(true) + mt_rand(10, 25); break; case "find-updates.php": $jobs[$job] = microtime(true) + 1800 * mt_rand(10, 60); break; } if (file_exists($exec = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'jobs' . DIRECTORY_SEPARATOR . $job)) { $execute[] = $exec; } } } XoopsCache::write(basename(dirname(__DIR__)) . '.cron.jobs', $jobs, 3600 * 24); // Executes Schedule Tasks on XOOPS Event Handler if (count($execute) > 0) { foreach ($execute as $exec) { @(include $exec); } } } } return true; }
function insert($obj, $force = true) { error_reporting(E_ALL); xoops_load('cache'); $read = XoopsCache::read('spider_id%%' . $obj->getVar('id')); if (!is_array($read)) { $value = '0A'; } else { $value = $read['value']; } $value++; $read = XoopsCache::delete('spider_id%%' . $obj->getVar('id')); $read = XoopsCache::write('spider_id%%' . $obj->getVar('id'), array('value' => $value)); $modulehandler =& xoops_gethandler('module'); $confighandler =& xoops_gethandler('config'); $xoModule = $modulehandler->getByDirname('spiders'); $xoConfig = $confighandler->getConfigList($xoModule->getVar('mid'), false); if ($xoConfig['xortify_shareme'] == true) { // Connect to API $api = $this->apimethod(); include_once $GLOBALS['xoops']->path('/modules/spiders/class/' . $api . '.php'); $func = strtoupper($api) . 'SpidersExchange'; $exchange = new $func(); //Form Associated Array $spiders_handler =& xoops_getmodulehandler('spiders', 'spiders'); $spider = $spiders_handler->get($obj->getVar('id')); $ret = array(); $ret['useragent'] = $obj->getVar('useragent'); $ret['netaddy'] = $obj->getVar('netaddy'); $ret['ip'] = $obj->getVar('ip'); $ret['server-ip'] = isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR']; $obj->setVar('server-ip', isset($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR']); $ret['when'] = $obj->getVar('when'); $ret['uri'] = $obj->getVar('uri'); $ret['sitename'] = $GLOBALS['xoopsConfig']['sitename']; $ret['robot-name'] = $spider->getVar('robot-name'); $ret['robot-id'] = $spider->getVar('robot-id'); //Send to API $exchange->sendStatistic($ret); } // Clear Statistics - Save on database size $modulehandler = xoops_gethandler('module'); $confighandler = xoops_gethandler('config'); $xoMod = $modulehandler->getByDirname('spiders'); $xoConfig = $confighandler->getConfigList($xoMod->getVar('mid')); $criteria = new Criteria('when', time() - $xoConfig['weeks_stats'] * (60 * 60 * 24 * 7), '<'); $this->deleteAll($criteria, true); return parent::insert($obj, $force); }
/** * Get available preloads information and set them to go! * * @return void */ function setPreloads() { //$modules_list = XoopsLists::getDirListAsArray(XOOPS_ROOT_PATH . "/modules/"); if ($modules_list = XoopsCache::read('system_modules_active')) { $i = 0; foreach ($modules_list as $module) { if (is_dir($dir = XOOPS_ROOT_PATH . "/modules/{$module}/preloads/")) { $file_list = XoopsLists::getFileListAsArray($dir); foreach ($file_list as $file) { if (preg_match('/(\\.php)$/i', $file)) { $file = substr($file, 0, -4); $this->_preloads[$i]['module'] = $module; $this->_preloads[$i]['file'] = $file; $i++; } } } } } }
/** * @package smarty xoopsplugin * * @author Hu Zhenghui <*****@*****.**> * * how to use * The following code inserted in the template * * @param module string module dirname * @param file string block funciton file * @param show_func string show block function * @param options= string show block function's option * @param cachetime int cachetime Unit for seconds * @param user mix Generate cache solution <{freeBlkTpl id=1}> <link rel="stylesheet" href="<{$xoops_url}>/modules/tag/templates/style.css" /> <div class="tag-cloud" style="line-height: 150%; padding: 5px;"> <{foreach item=tag from=$block.tags}> <span class="tag-level-<{$tag.level}>" style="font-size: <{$tag.font}>%; display: inline; padding-right: 5px;"> <a href="<{$xoops_url}>/modules/<{$block.tag_dirname}>/view.tag.php<{$smarty.const.URL_DELIMITER}><{$tag.id}>/" title="<{$tag.term}>"><{$tag.term}></a> </span> <{/foreach}> </div> <{/freeBlkTpl}> */ function smarty_block_freeBlkTpl($params, $content, &$smarty, &$repeat) { static $old_block; if (empty($content)) { $old_block = $smarty->get_template_vars('block'); if (!isset($params['id'])) { return; } $block_id = intval($params['id']); static $block_objs; $blockObj = $GLOBALS['xoopsTpl']->_tpl_vars['ezblocks'][$block_id]; // ezsky hack if (empty($blockObj)) { return false; } $xoopsLogger =& XoopsLogger::instance(); $template =& $GLOBALS['xoopsTpl']; xoops_load("cache"); $cache_key = 'xoBlkTpl_' . md5(var_export($params, true)); $bcachetime = intval($blockObj->getVar('bcachetime')); if (!$bcachetime || !($bresult = XoopsCache::read($cache_key))) { $xoopsLogger->addBlock($blockObj->getVar('name')); if (!($bresult = $blockObj->buildBlock())) { return; } if (isset($bcachetime)) { XoopsCache::write($cache_key, $bresult, $bcachetime); } } else { $xoopsLogger->addBlock($blockObj->getVar('name'), true, $bcachetime); } $old_block = $smarty->get_template_vars('block'); $smarty->assign('block', $bresult); } else { echo $content; $smarty->assign('block', $old_block); } }
/** * Load configs of a module * * * @param string $dirname module dirname * @return array */ function mod_loadConfig($dirname = '') { if (empty($dirname) && empty($GLOBALS['xoopsModule'])) { return null; } $dirname = !empty($dirname) ? $dirname : $GLOBALS['xoopsModule']->getVar('dirname'); if (isset($GLOBALS['xoopsModule']) && is_object($GLOBALS['xoopsModule']) && $GLOBALS['xoopsModule']->getVar('dirname', 'n') == $dirname) { if (isset($GLOBALS['xoopsModuleConfig'])) { $moduleConfig =& $GLOBALS['xoopsModuleConfig']; } else { return null; } } else { xoops_load('XoopsCache'); if (!($moduleConfig = XoopsCache::read("{$dirname}_config"))) { $moduleConfig = mod_fetchConfig($dirname); XoopsCache::write("{$dirname}_config", $moduleConfig); } } if ($customConfig = @(include XOOPS_ROOT_PATH . "/modules/{$dirname}/include/plugin.php")) { $moduleConfig = array_merge($moduleConfig, $customConfig); } return $moduleConfig; }
$ret = array(); $total = $robots_handler->getCount(NULL); xoops_load('pagenav'); $pagenav = new XoopsPageNav($total, $limit, $start, 'start', 'num=' . $limit . '&op=' . $_REQUEST['op']); if (is_object($pagenav)) { $ret['pagenav'] = $pagenav->renderNav(); } $criteria = new Criteria(1, 1); $criteria->setStart($start); $criteria->setLimit($limit); $xoopsOption['template_main'] = 'spiders_robots.html'; include $GLOBALS['xoops']->path('/header.php'); $robots = $robots_handler->getObjects($criteria); foreach ($robots as $id => $obj) { $suser = $user_handler->get($obj->getVar('id')); $read = XoopsCache::read('spider_id%%' . $obj->getVar('id')); if (!is_array($read)) { $value = '0A'; } else { $value = $read['value']; } $name = sprintf(_MA_SPIDERS_SPF_NAME, XOOPS_URL, $suser->getVar('uid'), $obj->getVar('robot-name')); $url = parse_url(XOOPS_URL); $herelast = sprintf(_MA_SPIDERS_LASTINSEO, XOOPS_URL, $url['host']); $criteria = new CriteriaCompo(new Criteria('server-ip', '')); $criteria->add(new Criteria('id', $obj->getVar('id'))); $criteria->setOrder('`when`'); if ($statistics_handler->getCount($criteria) > 0) { $criteria->setStart(0); $criteria->setLimit(1); $statistics = $statistics_handler->getObjects($criteria, false);
if ($ext == "curl") { return $ext; } } return 'json'; } } if (is_object($GLOBALS['xoopsUser'])) { $modulehandler =& xoops_gethandler('module'); $confighandler =& xoops_gethandler('config'); $xoModule = $modulehandler->getByDirname('spiders'); $xoConfig = $confighandler->getConfigList($xoModule->getVar('mid'), false); if (in_array($xoConfig['bot_group'], $GLOBALS['xoopsUser']->getGroups())) { if ($xoConfig['xortify_shareme'] == true) { xoops_load('cache'); if (!($result = XoopsCache::read('spider_uid%%' . $GLOBALS['xoopsUser']->getVar('uid') . '%%' . $xoConfig['bot_group']))) { // Connect to API $api = spiders_apimethod(); include_once $GLOBALS['xoops']->path('/modules/spiders/class/' . $api . '.php'); $func = strtoupper($api) . 'SpidersExchange'; $exchange = new $func(); //Recieve From API $result = $exchange->getSEOLinks(); XoopsCache::write('spider_uid%%' . $GLOBALS['xoopsUser']->getVar('uid') . '%%' . $xoConfig['bot_group'], $result, 1200); } $GLOBALS['spiderTpl'] = new XoopsTpl(); $GLOBALS['spiderTpl']->assign('spiderseo', $result); $GLOBALS['spiderTpl']->display('db:spiders_footer_seo.html'); } } }
/** * XoopsEditorHandler::getList() * * @param mixed $noHtml * * @return array */ function getList($noHtml = false) { /* Do NOT use this method statically, please use $editor_handler = XoopsEditorHandler::getInstance(); $result = array_flip($editor_handler->getList()); */ if (!isset($this->root_path)) { $this->root_path = XOOPS_ROOT_PATH . '/class/xoopseditor'; $GLOBALS['xoopsLogger']->addDeprecated(__CLASS__ . '::' . __FUNCTION__ . '() should not be called statically.'); } xoops_load('XoopsCache'); $list = XoopsCache::read('editorlist'); if (empty($list)) { $list = array(); $order = array(); xoops_load('XoopsLists'); $_list = XoopsLists::getDirListAsArray($this->root_path . '/'); foreach ($_list as $item) { if (file_exists($file = $this->root_path . '/' . $item . '/language/' . $GLOBALS['xoopsConfig']['language'] . '.php')) { include_once $file; } else { if (file_exists($file = $this->root_path . '/' . $item . '/language/english.php')) { include_once $file; } } if (file_exists($file = $this->root_path . '/' . $item . '/editor_registry.php')) { include $file; if (empty($config['order'])) { continue; } $order[] = $config['order']; $list[$item] = array('title' => $config['title'], 'nohtml' => $config['nohtml']); } } array_multisort($order, $list); XoopsCache::write('editorlist', $list); } $editors = array_keys($list); if (!empty($this->allowed_editors)) { $editors = array_intersect($editors, $this->allowed_editors); } $_list = array(); foreach ($editors as $name) { if (!empty($noHtml) && empty($list[$name]['nohtml'])) { continue; } $_list[$name] = $list[$name]['title']; } return $_list; }
break; } } else { // No id, no url, no src parameters header('Content-type: image/gif'); readfile(XOOPS_ROOT_PATH . '/uploads/blank.gif'); exit; } /* * Use Xoops cache */ // Get image_data from the Xoops cache only if the edited image has been cached after the latest modification // of the original image xoops_load('XoopsCache'); $edited_image_filename = 'editedimage_' . md5($_SERVER['REQUEST_URI']) . '_' . $imageFilename; $cached_image = XoopsCache::read($edited_image_filename); if (!isset($_GET['nocache']) && !isset($_GET['noservercache']) && !empty($cached_image) && $cached_image['cached_time'] >= $imageCreatedTime) { header("Content-type: {$imageMimetype}"); header('Content-Length: ' . strlen($cached_image['image_data'])); echo $cached_image['image_data']; exit; } /* * Get/check editing parameters */ // width, height $max_width = isset($_GET['width']) ? (int) $_GET['width'] : false; $max_height = isset($_GET['height']) ? (int) $_GET['height'] : false; // If either a max width or max height are not specified, we default to something large so the unspecified // dimension isn't a constraint on our resized image. // If neither are specified but the color is, we aren't going to be resizing at all, just coloring.
/** * xoops_getActiveModules() * * Get active modules from cache file * * @return array */ function xoops_getActiveModules() { static $modules_active; if (is_array($modules_active)) { return $modules_active; } xoops_load('XoopsCache'); if (!($modules_active = XoopsCache::read('system_modules_active'))) { $modules_active = xoops_setActiveModules(); } return $modules_active; }
$xoopsTpl->assign('items_width', $xoopsModuleConfig['picturewidth']); // get bread xoops_load("cache"); if (!($menu = XoopsCache::read('config_menu_categories'))) { $menu = $cat_handler->getAll(null, null, false); $menu = XoopsCache::write('config_menu_categories', $menu); } //$menu = $cat_handler->getAll(null, null, false); $beand = array_reverse($cat_handler->getBread($menu, $cat_id), true); if (!empty($beand)) { foreach ($beand as $k => $v) { if ($k != $cat_id) { $xoBreadcrumbs[] = array("title" => $v, 'link' => XOOPS_URL . '/modules/catalog/itemlist.php?cat_id=' . $k); } else { $xoBreadcrumbs[] = array("title" => $v); } $tree_open[$k] = $k; } $xoopsTpl->assign('tree_open', $tree_open); } xoops_load("cache"); if (!($categories = XoopsCache::read('config_categories'))) { $categories =& $cat_handler->getTrees($pid = 0, $prefix = "--"); $categories = XoopsCache::write('config_categories', $categories); } foreach ($categories as $id => $cat) { $cat_options[$id] = $cat["prefix"] . $cat["cat_name"]; } $xoopsTpl->assign('cat_options', $cat_options); $xoopsTpl->assign('cat_id', $cat_id); include 'footer.php';
$filedata = array(); } foreach ($harvest as $key => $values) { if ($values['required'] == true) { mkdir($buildpath = $path . DIRECTORY_SEPARATOR . $values['session'], 0777, true); foreach ($values['modmap'] as $key => $file) { mkdir($buildpath . DIRECTORY_SEPARATOR . $file['path'], 0777, true); copyfile($GLOBALS['xoops']->path($file['path'] . DIRECTORY_SEPARATOR . $file['file']), $buildpath . DIRECTORY_SEPARATOR . $file['path'] . DIRECTORY_SEPARATOR . $file['file']); } foreach ($values['libmap'] as $key => $file) { mkdir($buildpath . DIRECTORY_SEPARATOR . 'xoops_lib' . DIRECTORY_SEPARATOR . $file['path'], 0777, true); copyfile(XOOPS_PATH . $file['path'] . DIRECTORY_SEPARATOR . $file['file'], $buildpath . DIRECTORY_SEPARATOR . 'xoops_lib' . DIRECTORY_SEPARATOR . $file['path'] . DIRECTORY_SEPARATOR . $file['file']); } $filedata[$values['session']] = array('harvest' => $values, 'peer' => $peers['harvest'][$key]); } } if (!empty($filedata)) { writeRawFile($ffile, json_encode($filedata)); } else { unlink($ffile); } } else { XoopsCache::write(basename(dirname(dirname(__DIR__))) . '.module' . $module . '.old', $modmap, 3600 * 24 * 31 * 4); if ($libmap = XoopsCache::read(basename(dirname(dirname(__DIR__))) . '.xoopslib' . $module . '.delays')) { XoopsCache::write(basename(dirname(dirname(__DIR__))) . '.xoopslib' . $module . '.old', $libmap, 3600 * 24 * 31 * 4); } } } } } return true;
function getList($noHtml = false) { xoops_load("cache"); $list = XoopsCache::read("editorlist"); if (empty($list)) { $list = array(); $order = array(); xoops_load("XoopsLists"); $_list = XoopsLists::getDirListAsArray($this->root_path . '/'); foreach ($_list as $item) { if (!@(include_once $this->root_path . '/' . $item . "/language/" . $GLOBALS["xoopsConfig"]['language'] . ".php")) { include_once $this->root_path . '/' . $item . "/language/english.php"; } if (include $this->root_path . '/' . $item . '/editor_registry.php') { if (empty($config['order'])) { continue; } $order[] = $config['order']; $list[$item] = array("title" => $config["title"], "nohtml" => @$config["nohtml"]); } } array_multisort($order, $list); XoopsCache::write("editorlist", $list); } $editors = array_keys($list); if (!empty($this->allowed_editors)) { $editors = array_intersect($editors, $this->allowed_editors); } $_list = array(); foreach ($editors as $name) { if (!empty($noHtml) && empty($list[$name]['nohtml'])) { continue; } $_list[$name] = $list[$name]['title']; } return $_list; }
/** * load all local filters for the object * * Filter distribution: * In each module folder there is a folder "filter" containing filter files with, * filename: [name_of_target_class][.][function/action_name][.php]; * function name: [dirname][_][name_of_target_class][_][function/action_name]; * parameter: the target object * * @param string $method function or action name * @access public */ function loadFilters($method) { $this->_loadFilters(); xoops_load("cache"); $class = get_class($this); if (!($modules_active = XoopsCache::read("system_modules_active"))) { $module_handler =& xoops_gethandler('module'); $modules_obj = $module_handler->getObjects(new Criteria('isactive', 1)); $modules_active = array(); foreach (array_keys($modules_obj) as $key) { $modules_active[] = $modules_obj[$key]->getVar("dirname"); } unset($modules_obj); XoopsCache::write("system_modules_active", $modules_active); } foreach ($modules_active as $dirname) { if (!@(include_once XOOPS_ROOT_PATH . "/modules/{$dirname}/filter/{$class}.{$method}.php")) { continue; } if (function_exists("{$dirname}_{$class}_{$method}")) { call_user_func_array("{$dirname}_{$class}_{$method}", array(&$this)); } } }
echo '<br />'; } } if (!empty($_GET['xoopsorgnews'])) { // Multiple feeds $myts =& MyTextSanitizer::getInstance(); $rssurl = array(); $rssurl[] = 'http://sourceforge.net/export/rss2_projnews.php?group_id=41586&rss_fulltext=1'; $rssurl[] = 'http://www.xoops.org/backend.php'; if ($URLs = (include $GLOBALS['xoops']->path('language/' . xoops_getConfigOption('language') . '/backend.php'))) { $rssurl = array_unique(array_merge($rssurl, $URLs)); } $rssfile = 'adminnews-' . xoops_getConfigOption('language'); xoops_load('XoopsCache'); $items = array(); if (!($items = XoopsCache::read($rssfile))) { require_once $GLOBALS['xoops']->path('class/snoopy.php'); include_once $GLOBALS['xoops']->path('class/xml/rss/xmlrss2parser.php'); xoops_load('XoopsLocal'); $snoopy = new Snoopy(); $cnt = 0; foreach ($rssurl as $url) { if ($snoopy->fetch($url)) { $rssdata = $snoopy->results; $rss2parser = new XoopsXmlRss2Parser($rssdata); if (false != $rss2parser->parse()) { $_items = $rss2parser->getItems(); $count = count($_items); for ($i = 0; $i < $count; $i++) { $_items[$i]['title'] = XoopsLocal::convert_encoding($_items[$i]['title'], _CHARSET, 'UTF-8'); $_items[$i]['description'] = XoopsLocal::convert_encoding($_items[$i]['description'], _CHARSET, 'UTF-8');
function mark_for_lock($function_file, $username, $password) { xoops_load('cache'); $userip = xoops_getUserIP(); $result = array(); if ($result = XoopsCache::read('lock_' . $function_file . '_' . $username)) { $result[] = $userip; XoopsCache::delete('lock_' . $function_file . '_' . $username); XoopsCache::write('lock_' . $function_file . '_' . $username, $result, $GLOBALS['cache_seconds']); return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in'); } else { $result[] = $userip; XoopsCache::delete('lock_' . $function_file . '_' . $username); XoopsCache::write('lock_' . $function_file . '_' . $username, $result, $GLOBALS['cache_seconds']); return array('ErrNum' => 9, "ErrDesc" => 'No Permission for plug-in'); } }
if (!XoopsCache::read(basename(dirname(dirname(__DIR__))) . '.theme' . $theme)) { if ($monthmap = XoopsCache::read(basename(dirname(dirname(__DIR__))) . '.theme' . $theme . '.old')) { foreach ($monthmap as $key => $values) { if (isset($thememap[$key]) && $thememap[$key]['is'] == 'file') { unset($thememap[$key]); } elseif (isset($thememap[$key]) && $thememap[$key]['is'] == 'folder') { unset($thememap[$key]); } } if (count($thememap) > 0) { $thememap = getMapFingering($thememap, $theme, 'theme'); } else { $thememap = array(); } // Get Harvest Comparison Request on Peers API's if ($peers = XoopsCache::read(basename(dirname(dirname(__DIR__))) . '.available.peers')) { $uris = $peers['harvest']['themes']['uris']; shuffle($uris); foreach ($uris as $uri) { $harvest[md5($uri)] = json_decode(getURIData($uri, array('theme' => $theme, 'url' => XOOPS_URL, 'salt' => sha1(_RESOURCES_SALT_BLOWFISH), 'thememap' => $thememap, 'mode' => 'theme', 'timezone' => date_default_timezone_get(), 'microtime' => microtime(true))), true); } } mkdirSecure(XOOPS_VAR_PATH . DIRECTORY_SEPARATOR . basename(__DIR__)); mkdirSecure($path = XOOPS_VAR_PATH . DIRECTORY_SEPARATOR . basename(__DIR__) . DIRECTORY_SEPARATOR . 'harvest'); if (file_exists($ffile = XOOPS_VAR_PATH . DIRECTORY_SEPARATOR . basename(__DIR__) . DIRECTORY_SEPARATOR . "harvest.json")) { $filedata = json_decode(readRawFile($ffile), true); } else { $filedata = array(); } foreach ($harvest as $key => $values) { if ($values['required'] == true) {
/** * load all local filters for the object * * Filter distribution: * In each module folder there is a folder "filter" containing filter files with, * filename: [name_of_target_class][.][function/action_name][.php]; * function name: [dirname][_][name_of_target_class][_][function/action_name]; * parameter: the target object * * @param string $method function or action name * @access public */ function loadFilters($method) { $this->_loadFilters(); xoops_load('XoopsCache'); $class = get_class($this); if (!($modules_active = XoopsCache::read('system_modules_active'))) { $module_handler =& xoops_gethandler('module'); $modules_obj = $module_handler->getObjects(new Criteria('isactive', 1)); $modules_active = array(); foreach (array_keys($modules_obj) as $key) { $modules_active[] = $modules_obj[$key]->getVar('dirname'); } unset($modules_obj); XoopsCache::write('system_modules_active', $modules_active); } foreach ($modules_active as $dirname) { if (file_exists($file = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/filter/' . $class . '.' . $method . '.php')) { include_once $file; if (function_exists($class . '_' . $method)) { call_user_func_array($dirname . '_' . $class . '_' . $method, array(&$this)); } } } }
function getList($name, $extension = "") { $items = array(); xoops_load('XoopsCache'); if ($items = XoopsCache::read("captcha_captcha_{$name}")) { return $items; } require_once XOOPS_ROOT_PATH . "/class/xoopslists.php"; $file_path = $this->config["rootpath"] . "/{$name}"; $files = XoopsLists::getFileListAsArray($file_path); foreach ($files as $item) { if (empty($extension) || preg_match("/(\\.{$extension})\$/i", $item)) { $items[] = $item; } } XoopsCache::write("captcha_captcha_{$name}", $items); return $items; }
$catbrand_obj->setVar('brand_id', $brand_ids); $catbrand_obj->setVar('brand_name', $brand_name); $catbrand_handler->insert($catbrand_obj); unset($catbrand_obj); } redirect_header('admin.category.php', 3, _AM_CATALOG_ACTIVSUCCESS); } else { redirect_header('admin.category.php', 3, _AM_CATALOG_ACTIVEERROR); } break; case 'delete': xoops_load("cache"); if (XoopsCache::read('config_categories')) { XoopsCache::delete('config_categories'); } if (XoopsCache::read('config_menu_categories')) { XoopsCache::delete('config_menu_categories'); } $category_obj =& $category_handler->get($cat_id); if (isset($_REQUEST['ok']) && $_REQUEST['ok'] == 1) { if (!$GLOBALS['xoopsSecurity']->check()) { redirect_header('admin.category.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors())); } $category_image = $category_obj->getVar('cat_image'); $logo_dir = XOOPS_ROOT_PATH . "/uploads/"; $criteria = new CriteriaCompo(); $criteria->add(new Criteria('cat_pid', $cat_id)); $criteria1 = new CriteriaCompo(); $criteria1->add(new Criteria('cat_id', $cat_id), 'OR'); $criteria1->add(new Criteria('cat_pid', $cat_id), 'OR'); if ($category_handler->getCount($criteria) > 0 || $item_handler->getCount($criteria1) > 0) {
/** * Constructor * * @param string $caption form element caption * @param string $name form element name * @param bool $includeAnonymous Include user "anonymous"? * @param mixed $value Pre-selected value (or array of them). * For an item with massive members, such as "Registered Users", "$value" * should be used to store selected temporary users only instead of all * members of that item * @param int $size Number or rows. "1" makes a drop-down-list. * @param bool $multiple Allow multiple selections? */ public function __construct($caption, $name, $includeAnonymous = false, $value = null, $size = 1, $multiple = false) { /** * @var mixed array|false - cache any result for this session. * Some modules use multiple copies of this element on a single page, so this call will * be made multiple times. This is only used when $value is null. * @todo this should be replaced with better interface, with autocomplete style search * and user specific MRU cache */ static $queryCache = false; /** * @var int - limit to this many rows */ $limit = 200; /** * @var string - cache time to live - will be interpreted by strtotime() */ $cachettl = '+5 minutes'; /** * @var string - cache key */ $cachekey = 'formselectuser'; $select_element = new XoopsFormSelect('', $name, $value, $size, $multiple); if ($includeAnonymous) { $select_element->addOption(0, $GLOBALS['xoopsConfig']['anonymous']); } $member_handler = xoops_getHandler('member'); $value = is_array($value) ? $value : (empty($value) ? array() : array($value)); $selectedUsers = array(); if (count($value) > 0) { // fetch the set of uids in $value $criteria = new Criteria('uid', '(' . implode(',', $value) . ')', 'IN'); $criteria->setSort('uname'); $criteria->setOrder('ASC'); $selectedUsers = $member_handler->getUserList($criteria); } // get the full selection list // we will always cache this version to reduce expense if (empty($queryCache)) { XoopsLoad::load('XoopsCache'); $queryCache = XoopsCache::read($cachekey); if ($queryCache === false) { $criteria = new CriteriaCompo(); if ($limit <= $member_handler->getUserCount()) { // if we have more than $limit users, we will select who to show based on last_login $criteria->setLimit($limit); $criteria->setSort('last_login'); $criteria->setOrder('DESC'); } else { $criteria->setSort('uname'); $criteria->setOrder('ASC'); } $queryCache = $member_handler->getUserList($criteria); asort($queryCache); XoopsCache::write($cachekey, $queryCache, $cachettl); // won't do anything different if write fails } } // merge with selected $users = $selectedUsers + $queryCache; $select_element->addOptionArray($users); if ($limit > count($users)) { parent::__construct($caption, '', $name); $this->addElement($select_element); return null; } xoops_loadLanguage('findusers'); $js_addusers = "<script type='text/javascript'>\n function addusers(opts)\n {\n var num = opts.substring(0, opts.indexOf(':'));\n opts = opts.substring(opts.indexOf(':')+1, opts.length);\n var sel = xoopsGetElementById('" . $name . "');\n var arr = new Array(num);\n for (var n=0; n < num; n++) {\n var nm = opts.substring(0, opts.indexOf(':'));\n opts = opts.substring(opts.indexOf(':')+1, opts.length);\n var val = opts.substring(0, opts.indexOf(':'));\n opts = opts.substring(opts.indexOf(':')+1, opts.length);\n var txt = opts.substring(0, nm - val.length);\n opts = opts.substring(nm - val.length, opts.length);\n var added = false;\n for (var k = 0; k < sel.options.length; k++) {\n if (sel.options[k].value == val) {\n added = true;\n break;\n }\n }\n if (added == false) {\n sel.options[k] = new Option(txt, val);\n sel.options[k].selected = true;\n }\n }\n\n return true;\n }\n </script>"; $token = $GLOBALS['xoopsSecurity']->createToken(); $action_tray = new XoopsFormElementTray('', ' | '); $action_tray->addElement(new XoopsFormLabel('', '<a href="#" onclick="var sel = xoopsGetElementById(\'' . $name . '\');for (var i = sel.options.length-1; i >= 0; i--) {if (!sel.options[i].selected) {sel.options[i] = null;}}; return false;">' . _MA_USER_REMOVE . '</a>')); $action_tray->addElement(new XoopsFormLabel('', '<a href="#" onclick="openWithSelfMain(\'' . XOOPS_URL . '/include/findusers.php?target=' . $name . '&multiple=' . $multiple . '&token=' . $token . '\', \'userselect\', 800, 600, null); return false;" >' . _MA_USER_MORE . '</a>' . $js_addusers)); parent::__construct($caption, '<br><br>', $name); $this->addElement($select_element); $this->addElement($action_tray); }
/** * Function to get a list of template files of a page, indexed by style * * @var string $page page name * * @return array */ function &art_getTplPageList($page = "", $refresh = true) { $list = null; $cache_file = empty($page) ? "template-list" : "template-page"; /* load_functions("cache"); $list = mod_loadCacheFile($cache_file, $GLOBALS["artdirname"]); */ xoops_load("cache"); $key = $GLOBALS["artdirname"] . "_{$cache_file}"; $list = XoopsCache::read($key); if (!is_array($list) || $refresh) { $list = art_template_lookup(!empty($page)); } $ret = empty($page) ? $list : @$list[$page]; return $ret; }
/** * Load module configs * * @param string $dirname dirname of a module * @param int $category ID of a category * * @return array Associative array of name=>value pairs. */ public function loadModuleConfig($dirname = "", $category = 0) { if (empty($dirname) && !empty($GLOBALS["xoopsModule"])) { $dirname = $GLOBALS["xoopsModule"]->getVar("dirname"); } if (empty($dirname)) { return null; } xoops_load("cache"); $key = "config_{$dirname}_{$category}"; if (!($_cachedConfigs = XoopsCache::read($key))) { $module = 0; if ($dirname == "system") { $module = 0; } elseif (!empty($GLOBALS["xoopsModule"]) && $dirname == $GLOBALS["xoopsModule"]->getVar("dirname")) { $module = $GLOBALS["xoopsModule"]->getVar("mid"); } else { $module_obj = xoops_getHandler("module")->getByDirname($dirname); if ($module_obj) { $module = $module_obj->getVar("mid"); } else { return null; } } $_cachedConfigs = $this->getConfigsByCat($category, $module); XoopsCache::write($key, $_cachedConfigs); } return $_cachedConfigs; }
/** * load all local filters for the object * * Filter distribution: * In each module folder there is a folder "filter" containing filter files with, * filename: [name_of_target_class][.][function/action_name][.php]; * function name: [dirname][_][name_of_target_class][_][function/action_name]; * parameter: the target object * * @param string $method function or action name * * @deprecated \XoopsObject::loadFilters is deprecated since XOOPS 2.5.8 and will be removed in the next major release */ public function loadFilters($method) { $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 1); trigger_error("XoopsObject::loadFilters() is deprecated, called from {$trace[0]['file']} line {$trace[0]['line']},"); $this->_loadFilters(); xoops_load('XoopsCache'); $class = get_class($this); if (!($modules_active = XoopsCache::read('system_modules_active'))) { $module_handler = xoops_getHandler('module'); $modules_obj = $module_handler->getObjects(new Criteria('isactive', 1)); $modules_active = array(); foreach (array_keys($modules_obj) as $key) { $modules_active[] = $modules_obj[$key]->getVar('dirname'); } unset($modules_obj); XoopsCache::write('system_modules_active', $modules_active); } foreach ($modules_active as $dirname) { if (file_exists($file = XOOPS_ROOT_PATH . '/modules/' . $dirname . '/filter/' . $class . '.' . $method . '.php')) { include_once $file; if (function_exists($class . '_' . $method)) { call_user_func_array($dirname . '_' . $class . '_' . $method, array(&$this)); } } } }
/** * Read value for a key from the cache * * @param string $key Identifier for the data * @param mixed $default default value to return if config $key is not set * * @return mixed value if key was set, false not set or expired */ public function read($key, $default = false) { $value = $this->cache->read($this->prefix($key)); return false !== $value ? $value : $default; }