Esempio n. 1
0
 public function render($runData)
 {
     $site = $runData->getTemp("site");
     $pl = $runData->getParameterList();
     $parmHash = md5(serialize($pl->asArray()));
     $key = 'siterecentrevisions_v..' . $site->getUnixName() . '..' . $parmHash;
     $tkey = 'siterevisions_lc..' . $site->getSiteId();
     // last change timestamp
     $mc = OZONE::$memcache;
     $struct = $mc->get($key);
     $changeTimestamp = $mc->get($tkey);
     if ($struct) {
         // check the times
         $cacheTimestamp = $struct['timestamp'];
         // afford 1 minute delay
         if ($changeTimestamp && $changeTimestamp <= $cacheTimestamp) {
             return $struct['content'];
         }
     }
     $out = parent::render($runData);
     // and store the data now
     $struct = array();
     $now = time();
     $struct['timestamp'] = $now;
     $struct['content'] = $out;
     $mc->set($key, $struct, 0, 600);
     if (!$changeTimestamp) {
         $changeTimestamp = $now;
         $mc->set($tkey, $changeTimestamp, 0, 3600);
     }
     return $out;
 }
 public function render($runData)
 {
     $site = $runData->getTemp("site");
     $pl = $runData->getParameterList();
     $threadId = $pl->getParameterValue("t");
     $parmHash = md5(serialize($pl->asArray()));
     $key = 'list_pages_by_tags_v..' . $site->getSiteId() . '..' . $parmHash;
     $tkey = 'page_tags_lc..' . $site->getSiteId();
     // last change timestamp
     $mc = OZONE::$memcache;
     $struct = $mc->get($key);
     $cacheTimestamp = $struct['timestamp'];
     $changeTimestamp = $mc->get($tkey);
     if ($struct) {
         // check the times
         if ($changeTimestamp && $changeTimestamp <= $cacheTimestamp) {
             $out = $struct['content'];
             return $out;
         }
     }
     $out = parent::render($runData);
     // and store the data now
     $struct = array();
     $now = time();
     $struct['timestamp'] = $now;
     $struct['content'] = $out;
     $mc->set($key, $struct, 0, 1000);
     if (!$changeTimestamp) {
         $changeTimestamp = $now;
         $mc->set($tkey, $changeTimestamp, 0, 3600);
     }
     return $out;
 }
Esempio n. 3
0
 public function render($runData)
 {
     $site = $runData->getTemp("site");
     $pl = $runData->getParameterList();
     $categoryIds = $pl->getParameterValue("category");
     $parmHash = md5(serialize($pl->asArray()));
     $key = 'frontforum_v..' . $site->getUnixName() . '..' . $categoryIds . '..' . $parmHash;
     $valid = true;
     $mc = OZONE::$memcache;
     $struct = $mc->get($key);
     if (!$struct) {
         $valid = false;
     }
     $cacheTimestamp = $struct['timestamp'];
     $now = time();
     // now check lc for ALL categories involved
     $cats = preg_split('/[,;] ?/', $categoryIds);
     foreach ($cats as $cat) {
         $tkey = 'forumcategory_lc..' . $site->getUnixName() . '..' . $cat;
         // last change timestamp
         $changeTimestamp = $mc->get($tkey);
         if ($changeTimestamp && $cacheTimestamp && $changeTimestamp <= $cacheTimestamp) {
             //cache valid
         } else {
             $valid = false;
             if (!$changeTimestamp) {
                 // 	put timestamp
                 $mc->set($tkey, $now, 0, 864000);
                 $valid = false;
             }
         }
     }
     $akey = 'forumall_lc..' . $site->getUnixName();
     $allForumTimestamp = $mc->get($akey);
     if ($allForumTimestamp && $allForumTimestamp <= $cacheTimestamp) {
         //cache valid
     } else {
         $valid = false;
     }
     if (!$allForumTimestamp) {
         $mc->set($akey, $now, 0, 864000);
     }
     if ($valid) {
         $this->vars = $struct['vars'];
         return $struct['content'];
     }
     $out = parent::render($runData);
     // and store the data now
     $struct = array();
     $now = time();
     $struct['timestamp'] = $now;
     $struct['content'] = $out;
     $struct['vars'] = $this->vars;
     $mc->set($key, $struct, 0, 864000);
     return $out;
 }
Esempio n. 4
0
 public function render($runData)
 {
     $site = $runData->getTemp("site");
     $pl = $runData->getParameterList();
     $pageId = $pl->getParameterValue("pageId");
     $pageName = $runData->getTemp("pageUnixName");
     $parmHash = md5(serialize($pl->asArray()));
     if ($pageId !== null) {
         $key = 'pagecomments_v_pageid..' . $site->getUnixName() . '..' . $pageId . '..' . $parmHash;
     } else {
         $key = 'pagecomments_v_pagename..' . $site->getUnixName() . '..' . $pageName . '..' . $parmHash;
     }
     $akey = 'forumall_lc..' . $site->getUnixName();
     $uri = GlobalProperties::$MODULES_JS_URL . '/forum/ForumViewThreadModule.js';
     $this->extraJs[] = $uri;
     $mc = OZONE::$memcache;
     $struct = $mc->get($key);
     $allForumTimestamp = $mc->get($akey);
     if ($struct) {
         // check the times
         $cacheTimestamp = $struct['timestamp'];
         $threadId = $struct['threadId'];
         $tkey = 'forumthread_lc..' . $site->getUnixName() . '..' . $threadId;
         // last change timestamp
         $changeTimestamp = $mc->get($tkey);
         if ($changeTimestamp && $changeTimestamp <= $cacheTimestamp && $allForumTimestamp && $allForumTimestamp <= $cacheTimestamp) {
             $runData->ajaxResponseAdd("threadId", $threadId);
             return $struct['content'];
         }
     }
     $out = parent::render($runData);
     // and store the data now
     $struct = array();
     $now = time();
     $struct['timestamp'] = $now;
     $struct['content'] = $out;
     $struct['threadId'] = $this->threadId;
     if (!$changeTimestamp) {
         $tkey = 'forumthread_lc..' . $site->getUnixName() . '..' . $this->threadId;
         // last change timestamp
         $changeTimestamp = $mc->get($tkey);
     }
     $mc->set($key, $struct, 0, 864000);
     if (!$changeTimestamp) {
         $tkey = 'forumthread_lc..' . $site->getUnixName() . '..' . $this->threadId;
         $changeTimestamp = $now;
         $mc->set($tkey, $changeTimestamp, 0, 864000);
     }
     if (!$allForumTimestamp) {
         $allForumTimestamp = $now;
         $mc->set($akey, $allForumTimestamp, 0, 10000);
     }
     return $out;
 }
 public function render($runData)
 {
     $site = $runData->getTemp("site");
     $key = "module..0..RecentWPageRevisionsModule.." . $site->getSiteId() . '..' . md5(serialize($runData->getParameterList()->asArray()));
     $mc = OZONE::$memcache;
     $out = $mc->get($key);
     if (!$out) {
         $out = parent::render($runData);
         $mc->set($key, $out, 0, 120);
     }
     return $out;
 }
Esempio n. 6
0
 public function render($runData)
 {
     $pl = $runData->getParameterList();
     $site = $runData->getTemp("site");
     $range = $pl->getParameterValue("range", "AMODULE");
     $key = "module..0..MostActiveSitesModule.." . $site->getSiteId() . '..' . $range;
     $mc = OZONE::$memcache;
     $out = $mc->get($key);
     if (!$out) {
         $out = parent::render($runData);
         $mc->set($key, $out, 0, 3600);
     }
     return $out;
 }
Esempio n. 7
0
 public function render($runData)
 {
     $pl = $runData->getParameterList();
     $site = $runData->getTemp("site");
     $range = $pl->getParameterValue("range", "AMODULE");
     $key = "module..0..SomeGlobalStatsModule";
     $mc = OZONE::$memcache;
     $out = $mc->get($key);
     if (!$out) {
         $out = parent::render($runData);
         $mc->set($key, $out, 0, 600);
     }
     return $out;
 }
Esempio n. 8
0
 public function render($runData)
 {
     $site = $runData->getTemp("site");
     $pl = $runData->getParameterList();
     $threadId = $pl->getParameterValue("t");
     $parmHash = md5(serialize($pl->asArray()));
     $key = 'forumthread_v..' . $site->getUnixName() . '..' . $threadId . '..' . $parmHash;
     $tkey = 'forumthread_lc..' . $site->getUnixName() . '..' . $threadId;
     // last change timestamp
     $akey = 'forumall_lc..' . $site->getUnixName();
     $mc = OZONE::$memcache;
     $struct = $mc->get($key);
     $cacheTimestamp = $struct['timestamp'];
     $changeTimestamp = $mc->get($tkey);
     $allForumTimestamp = $mc->get($akey);
     if ($struct) {
         // check the times
         if ($changeTimestamp && $changeTimestamp <= $cacheTimestamp && $allForumTimestamp && $allForumTimestamp <= $cacheTimestamp) {
             $this->categoryName = $struct['categoryName'];
             $this->threadTitle = $struct['threadTitle'];
             $this->threadId = $struct['threadId'];
             $this->tpage = $struct['tpage'];
             $out = $struct['content'];
             $page = $GLOBALS['page'];
             return $out;
         }
     }
     $out = parent::render($runData);
     // and store the data now
     $struct = array();
     $now = time();
     $struct['timestamp'] = $now;
     $struct['content'] = $out;
     $struct['categoryName'] = $this->categoryName;
     $struct['threadTitle'] = $this->threadTitle;
     $struct['threadId'] = $this->threadId;
     $struct['tpage'] = $this->tpage;
     $mc->set($key, $struct, 0, 864000);
     if (!$changeTimestamp) {
         $changeTimestamp = $now;
         $mc->set($tkey, $changeTimestamp, 0, 864000);
     }
     if (!$allForumTimestamp) {
         $allForumTimestamp = $now;
         $mc->set($akey, $allForumTimestamp, 0, 864000);
     }
     return $out;
 }
Esempio n. 9
0
 public function render($runData)
 {
     $site = $runData->getTemp("site");
     $pl = $runData->getParameterList();
     $parmArray = $pl->asArray();
     $parmHash = md5(serialize($parmArray) . $runData->getModuleTemplate());
     if ($this->keyFull) {
         $key = $this->keyFull;
     } else {
         $key = $this->keyBase . '_v..' . $site->getSiteId() . '..' . $parmHash;
     }
     if ($this->keyFullTimestamp) {
         $tkey = $this->keyFullTimestamp;
     } else {
         $tkey = $this->keyBase . '_lc..' . $site->getSiteId();
         // last change timestamp
     }
     $mc = OZONE::$memcache;
     $struct = $mc->get($key);
     $cacheTimestamp = $struct['timestamp'];
     $changeTimestamp = $mc->get($tkey);
     if ($struct) {
         // check the times
         if ($changeTimestamp && $changeTimestamp <= $cacheTimestamp + $this->delay) {
             $out = $struct['content'];
             return $out;
         }
     }
     $out = parent::render($runData);
     // and store the data now
     $struct = array();
     $now = time();
     $struct['timestamp'] = $now;
     $struct['content'] = $out;
     $mc->set($key, $struct, 0, $this->timeOut);
     if (!$changeTimestamp) {
         $changeTimestamp = $now;
         $mc->set($tkey, $changeTimestamp, 0, $this->timeOut);
     }
     return $out;
 }
Esempio n. 10
0
 /**
  * Overrides original method and adds caching mechanisms.
  */
 public function render($runData)
 {
     $pl = $runData->getParameterList();
     $site = $runData->getTemp("site");
     // first determine: to cache or not to cache:
     $uTimeOut = $pl->getParameterValue("timeout");
     if ($this->allowChangeTimeOut == true && $uTimeOut != null && $uTimeOut > 0) {
         $timeOut = $uTimeOut;
         // confront with max and min
         if ($timeOut > $this->maxTimeOut) {
             $timeOut = $this->maxTimeOut;
         }
         if ($timeOut < $this->minTimeOut) {
             $timeOut = $this->minTimeOut;
         }
     } else {
         $timeOut = $this->timeOut;
         // do not check max and min - we should trust this value and do not complicate things
     }
     if ($timeOut != null && $timeOut > 0) {
         // cacheable ;-)
         $parmSubKey = md5(serialize($pl->asArray()));
         $mcKey = 'module..' . $site->getSiteId() . '..' . get_class($this) . '..' . $parmSubKey;
         // get the content ;-)
         $mc = Ozone::$memcache;
         $out = $mc->get($mcKey);
         if ($out != false) {
             return $out;
         }
         $storeLater = true;
         $out = parent::render($runData);
         if ($storeLater) {
             $mc->set($mcKey, $out, 0, $timeOut);
         }
         return $out;
     } else {
         return parent::render($runData);
     }
 }
Esempio n. 11
0
 public function render($runData)
 {
     $site = $runData->getTemp("site");
     $pl = $runData->getParameterList();
     $parmHash = md5(serialize($pl->asArray()));
     $key = 'forumstart_v..' . $site->getUnixName() . '..' . $parmHash;
     $tkey = 'forumstart_lc..' . $site->getUnixName();
     // last change timestamp
     $akey = 'forumall_lc..' . $site->getUnixName();
     $mc = OZONE::$memcache;
     $struct = $mc->get($key);
     $cacheTimestamp = $struct['timestamp'];
     $changeTimestamp = $mc->get($tkey);
     $allForumTimestamp = $mc->get($akey);
     if ($struct) {
         // check the times
         if ($changeTimestamp && $changeTimestamp <= $cacheTimestamp && $allForumTimestamp && $allForumTimestamp <= $cacheTimestamp) {
             return $struct['content'];
         }
     }
     $out = parent::render($runData);
     // and store the data now
     $struct = array();
     $now = time();
     $struct['timestamp'] = $now;
     $struct['content'] = $out;
     $mc->set($key, $struct, 0, 864000);
     if (!$changeTimestamp) {
         $changeTimestamp = $now;
         $mc->set($tkey, $changeTimestamp, 0, 864000);
     }
     if (!$allForumTimestamp) {
         $allForumTimestamp = $now;
         $mc->set($akey, $allForumTimestamp, 0, 864000);
     }
     return $out;
 }
Esempio n. 12
0
 public function render($runData)
 {
     $uu = $runData->getUser();
     if ($uu) {
         $lang = $uu->getLanguage();
         switch ($lang) {
             case 'pl':
                 $glang = "pl_PL";
                 $wp = "pl";
                 break;
             case 'en':
                 $glang = "en_US";
                 $wp = "www";
                 break;
         }
         putenv("LANG={$glang}");
         putenv("LANGUAGE={$glang}");
         setlocale(LC_ALL, $glang . '.UTF-8');
     }
     $out = parent::render($runData);
     if ($uu) {
         $lang = $GLOBALS['lang'];
         switch ($lang) {
             case 'pl':
                 $glang = "pl_PL";
                 break;
             case 'en':
                 $glang = "en_US";
                 break;
         }
         putenv("LANG={$glang}");
         putenv("LANGUAGE={$glang}");
         setlocale(LC_ALL, $glang . '.UTF-8');
     }
     return $out;
 }
Esempio n. 13
0
 public function render($runData)
 {
     $site = $runData->getTemp("site");
     $pl = $runData->getParameterList();
     $this->_pl = $pl;
     $this->_parameterUrlPrefix = $pl->getParameterValue('urlAttrPrefix');
     /*
      * Read all parameters.
      */
     $categoryName = $this->_readParameter(array('category', 'categories'), false);
     $categoryName = strtolower($categoryName);
     $parmHash = md5(serialize($pl->asArrayAll()));
     $this->parameterhash = $parmHash;
     $valid = true;
     if (!$categoryName) {
         /* No category name specified, use the current category! */
         $pageUnixName = $runData->getTemp('pageUnixName');
         if (!$pageUnixName) {
             $pageUnixName = $pl->getParameterValue('page_unix_name');
             // from preview
         }
         if (strpos($pageUnixName, ":") != false) {
             $tmp0 = explode(':', $pageUnixName);
             $categoryName = $tmp0[0];
         } else {
             $categoryName = "_default";
         }
     }
     $key = 'pagecalendar_v..' . $site->getUnixName() . '..' . $categoryName . '..' . $parmHash;
     $mc = OZONE::$memcache;
     $struct = $mc->get($key);
     if (!$struct) {
         $valid = false;
     }
     $cacheTimestamp = $struct['timestamp'];
     $now = time();
     // now check lc for ALL categories involved
     $cats = preg_split('/[,;\\s]+?/', $categoryName);
     if ($categoryName != '*') {
         foreach ($cats as $cat) {
             $tkey = 'pagecategory_lc..' . $site->getUnixName() . '..' . $cat;
             // last change timestamp
             $changeTimestamp = $mc->get($tkey);
             if ($changeTimestamp && $cacheTimestamp && $changeTimestamp <= $cacheTimestamp) {
                 //cache valid
             } else {
                 $valid = false;
                 if (!$changeTimestamp) {
                     // 	put timestamp
                     $mc->set($tkey, $now, 0, 864000);
                     $valid = false;
                 }
             }
         }
     } else {
         $akey = 'pageall_lc..' . $site->getUnixName();
         $allPagesTimestamp = $mc->get($akey);
         if ($allPagesTimestamp && $cacheTimestamp && $allPagesTimestamp <= $cacheTimestamp) {
             //cache valid
         } else {
             $valid = false;
             if (!$allPagesTimestamp) {
                 // 	put timestamp
                 $mc->set($akey, $now, 0, 864000);
                 $valid = false;
             }
         }
     }
     if ($valid) {
         $this->_vars = $struct['vars'];
         //echo 'fromcache';
         return $struct['content'];
     }
     $out = parent::render($runData);
     // and store the data now
     $struct = array();
     $now = time();
     $struct['timestamp'] = $now;
     $struct['content'] = $out;
     $struct['vars'] = $this->_vars;
     $mc->set($key, $struct, 0, 864000);
     return $out;
 }