Ejemplo n.º 1
0
 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);
 }
Ejemplo n.º 2
0
 function flush()
 {
     xoops_load('XoopsCache');
     XoopsCache::delete("adminmenu_" . __CLASS__);
 }
Ejemplo n.º 3
0
 /**
  * clear config cache of a module
  *
  *
  * @param    string $dirname module dirname
  * @return    bool
  */
 function mod_clearConfig($dirname = '')
 {
     if (empty($dirname)) {
         return false;
     }
     xoops_load('XoopsCache');
     return XoopsCache::delete("{$dirname}_config");
 }
Ejemplo n.º 4
0
 /**
  * Clear config caches
  *
  * @param   mixed       $module     ID or dirname of a module
  * @param   int         $category   ID of a category
  *
  * @return  boolean     True on success, false on failure
  */
 public function flush($module = 0, $category = 0)
 {
     xoops_load("cache");
     $dirname = "";
     $mid = 0;
     if (is_int($module)) {
         $mid = intval($module);
         if (empty($mid)) {
             $dirname = "system";
         } else {
             if ($module_obj = xoops_getHandler("module")->get($mid)) {
                 $dirname = $module_obj->getVar("dirname");
             }
         }
     } else {
         $dirname = $module;
         if ("system" == $dirname) {
             $mid = 0;
         } else {
             if ($module_obj = xoops_getHandler("module")->getByDirname($dirname)) {
                 $mid = $module_obj->getVar("mid");
             }
         }
     }
     $key = "config_{$mid}_{$category}";
     XoopsCache::delete($key);
     $key = "config_{$dirname}_{$category}";
     XoopsCache::delete($key);
     return true;
 }
Ejemplo n.º 5
0
             $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) {
             redirect_header('admin.category.php', 3, _AM_CATALOG_DELETECATTIPS);
Ejemplo n.º 6
0
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');
    }
}
Ejemplo n.º 7
0
 /**
  * Delete a key from the cache
  *
  * @param string $key Identifier for the data
  *
  * @return void
  */
 public function delete($key)
 {
     $this->cache->delete($this->prefix($key));
 }