コード例 #1
0
ファイル: yr.no.php プロジェクト: terryhoax/smartvisu
 /**
  * retrieve the content
  */
 public function run()
 {
     // api call
     $cache = new class_cache('yr.no_' . substr(strrchr($this->location, '/'), 1) . '.xml');
     if ($cache->hit()) {
         $content = $cache->read();
     } else {
         $url = 'http://www.yr.no/place/' . rawurlencode($this->location) . '/forecast.xml';
         $content = file_get_contents($url);
     }
     if (substr($content, 0, 5) == '<?xml') {
         // write cache
         $cache->write($content);
         $xml = simplexml_load_string($content);
         $this->debug($xml);
         // today
         $this->data['city'] = (string) $xml->location->name;
         // forecast
         $i = 0;
         foreach ($xml->forecast->tabular->time as $day) {
             if (config_lang == 'de') {
                 $windspeed = ' mit ' . round((string) $day->windSpeed->attributes()->mps * 3.6, 1) . ' km/h';
             } elseif (config_lang == 'nl') {
                 $windspeed = ' met ' . round((string) $day->windSpeed->attributes()->mps * 3.6, 1) . ' km/u';
             } else {
                 $windspeed = ' at ' . round((string) $day->windSpeed->attributes()->mps * 2.24, 1) . ' MPH';
             }
             if ($i == 0) {
                 $this->data['current']['date'] = (string) $day->attributes()->from;
                 $this->data['current']['conditions'] = translate((string) $day->symbol->attributes()->name, 'yr.no');
                 $this->data['current']['wind'] = translate((string) $day->windSpeed->attributes()->name . ' from ' . (string) $day->windDirection->attributes()->code, 'yr.no') . $windspeed;
                 $this->data['current']['icon'] = $this->icon((string) $day->symbol->attributes()->number, $this->icon_sm);
                 $this->data['current']['temp'] = (double) $day->temperature->attributes()->value . '&deg;C';
                 $this->data['current']['more'] = (int) $day->pressure->attributes()->value . ' hPa';
                 $i++;
             }
             if ($i < 5 and $day->attributes()->period == 2) {
                 $this->data['forecast'][$i]['date'] = (string) $day->attributes()->from;
                 $this->data['forecast'][$i]['conditions'] = translate((string) $day->symbol->attributes()->name, 'yr.no');
                 $this->data['forecast'][$i]['wind'] = translate((string) $day->windSpeed->attributes()->name . ' from ' . (string) $day->windDirection->attributes()->code, 'yr.no') . $windspeed;
                 $this->data['forecast'][$i]['icon'] = $this->icon((string) $day->symbol->attributes()->number);
                 $this->data['forecast'][$i]['temp'] = (double) $day->temperature->attributes()->value . '&deg;C';
                 $this->data['forecast'][$i]['more'] = (int) $day->pressure->attributes()->value . ' hPa';
                 $i++;
             }
         }
     } else {
         $this->error('Weather: yr.no', 'Read request failed!');
     }
 }
 /**
  * Triggered as soon as a record is updated
  *
  * @param string $strEventName
  * @param array $arrArguments
  *
  * @return bool
  */
 public function handleEvent($strEventName, array $arrArguments)
 {
     $objRecord = $arrArguments[0];
     if ($objRecord instanceof class_module_packagemanager_template) {
         if ($objRecord->getIntRecordStatus() == 1) {
             $objOrm = new class_orm_objectlist();
             $objOrm->addWhereRestriction(new class_orm_objectlist_systemstatus_restriction(class_orm_comparator_enum::Equal(), 1));
             $arrPacks = $objOrm->getObjectList("class_module_packagemanager_template");
             foreach ($arrPacks as $objPack) {
                 if ($objPack->getSystemid() != $objRecord->getSystemid()) {
                     $objPack->setIntRecordStatus(0);
                     $objPack->updateObjectToDb();
                 }
             }
             //update the active-pack constant
             $objSetting = class_module_system_setting::getConfigByName("_packagemanager_defaulttemplate_");
             if ($objSetting !== null) {
                 $objSetting->setStrValue($objRecord->getStrName());
                 $objSetting->updateObjectToDb();
             }
             class_cache::flushCache("class_element_portal");
         }
     }
     return true;
 }
コード例 #3
0
ファイル: debug.php プロジェクト: jinshana/kajonacms
 public function debugHelper()
 {
     echo "<pre>";
     echo "<b>Kajona V4 Debug Subsystem</b>\n\n";
     if (getGet("debugfile") != "") {
         echo "Loading path for " . getGet("debugfile") . "\n";
         $strPath = array_search(getGet("debugfile"), class_resourceloader::getInstance()->getFolderContent("/debug", array(".php")));
         if ($strPath !== false) {
             echo "Passing request to " . $strPath . "\n\n";
             include _realpath_ . $strPath;
         }
     } else {
         echo "Searching for debug-scripts available...\n";
         $arrFiles = class_resourceloader::getInstance()->getFolderContent("/debug", array(".php"));
         echo "<ul>";
         foreach ($arrFiles as $strPath => $strOneFile) {
             echo "<li><a href='?debugfile=" . $strOneFile . "' >" . $strOneFile . "</a> <br />" . $strPath . "</li>";
         }
         echo "</ul>";
     }
     $arrTimestampEnde = gettimeofday();
     $intTimeUsed = ($arrTimestampEnde['sec'] * 1000000 + $arrTimestampEnde['usec'] - ($this->arrTimestampStart['sec'] * 1000000 + $this->arrTimestampStart['usec'])) / 1000000;
     echo "\n\n<b>PHP-Time:</b>                              " . number_format($intTimeUsed, 6) . " sec \n";
     echo "<b>Queries db/cachesize/cached/fired:</b>     " . class_carrier::getInstance()->getObjDB()->getNumber() . "/" . class_carrier::getInstance()->getObjDB()->getCacheSize() . "/" . class_carrier::getInstance()->getObjDB()->getNumberCache() . "/" . (class_carrier::getInstance()->getObjDB()->getNumber() - class_carrier::getInstance()->getObjDB()->getNumberCache()) . "\n";
     echo "<b>Templates cached:</b>                      " . class_carrier::getInstance()->getObjTemplate()->getNumberCacheSize() . " \n";
     echo "<b>Memory/Max Memory:</b>                     " . bytesToString(memory_get_usage()) . "/" . bytesToString(memory_get_peak_usage()) . " \n";
     echo "<b>Classes Loaded:</b>                        " . class_classloader::getInstance()->getIntNumberOfClassesLoaded() . " \n";
     echo "<b>Cache requests/hits/saves/cachesize:</b>   " . class_cache::getIntRequests() . "/" . class_cache::getIntHits() . "/" . class_cache::getIntSaves() . "/" . class_cache::getIntCachesize() . " \n";
     echo "</pre>";
 }
 /**
  * Invokes the installer, if given.
  * The installer itself is capable of detecting whether an update or a plain installation is required.
  *
  * @throws class_exception
  * @return string
  */
 public function installOrUpdate()
 {
     $strReturn = "";
     if (uniStrpos($this->getObjMetadata()->getStrPath(), "core") === false) {
         throw new class_exception("Current module not located at /core*.", class_exception::$level_ERROR);
     }
     if (!$this->isInstallable()) {
         throw new class_exception("Current module isn't installable, not all requirements are given", class_exception::$level_ERROR);
     }
     //search for an existing installer
     $objFilesystem = new class_filesystem();
     $arrInstaller = $objFilesystem->getFilelist($this->objMetadata->getStrPath() . "/installer/", array(".php"));
     if ($arrInstaller === false) {
         $strReturn .= "Updating default template pack...\n";
         $this->updateDefaultTemplate();
         class_cache::flushCache();
         return $strReturn;
     }
     //proceed with elements
     foreach ($arrInstaller as $strOneInstaller) {
         //skip samplecontent files
         if (uniStrpos($strOneInstaller, "element") !== false) {
             class_logger::getInstance(class_logger::PACKAGEMANAGEMENT)->addLogRow("triggering updateOrInstall() on installer " . $strOneInstaller . ", all requirements given", class_logger::$levelInfo);
             //trigger update or install
             $strName = uniSubstr($strOneInstaller, 0, -4);
             /** @var $objInstaller interface_installer */
             $objInstaller = new $strName();
             $strReturn .= $objInstaller->installOrUpdate();
         }
     }
     $strReturn .= "Updating default template pack...\n";
     $this->updateDefaultTemplate();
     return $strReturn;
 }
コード例 #5
0
 /**
  * @see interface_admin_systemtask::getAdminForm()
  * @return string
  */
 public function getAdminForm()
 {
     $strReturn = "";
     //show dropdown to select cache-source
     $arrSources = class_cache::getCacheSources();
     $arrOptions = array();
     $arrOptions[""] = $this->getLang("systemtask_flushcache_all");
     foreach ($arrSources as $strOneSource) {
         $arrOptions[$strOneSource] = $strOneSource;
     }
     $strReturn .= $this->objToolkit->formInputDropdown("cacheSource", $arrOptions, $this->getLang("systemtask_cacheSource_source"));
     return $strReturn;
 }
コード例 #6
0
ファイル: rss.php プロジェクト: bjko/smartvisu-cleaninstall
 /**
  * retrieve the content
  */
 public function run()
 {
     // api call
     $cache = new class_cache('rss_' . strtolower($this->url));
     if ($cache->hit()) {
         $xml = simplexml_load_string($cache->read());
     } else {
         $xml = simplexml_load_string($cache->write(file_get_contents('http://' . $this->url)));
     }
     if ($xml) {
         $i = 1;
         // the entries
         foreach ($xml->channel->item as $item) {
             $item = (array) $item;
             // media?
             if (isset($item['enclosure']) && ((string) $item['enclosure']->attributes()->type == 'image/jpeg' || (string) $item['enclosure']->attributes()->type == 'image/jpg')) {
                 unset($item['image']);
                 $item['image']['url'] = (string) $item['enclosure']->attributes()->url;
             }
             unset($item['enclosure']);
             // description
             $item["description"] = (string) $item["description"];
             $this->data['entry'][] = $item;
             if ($i++ >= $this->limit) {
                 break;
             }
         }
         // the channel
         $channel = (array) $xml->channel;
         if (isset($channel['image'])) {
             $channel['image'] = array('url' => (string) $channel['image']->url, 'title' => (string) $channel['image']->title, 'link' => (string) $channel['image']->link);
         }
         unset($channel['item']);
         $this->data['channel'] = $channel;
     } else {
         $this->error('RSS', 'Read request failed \'' . $this->url . '\'');
     }
 }
コード例 #7
0
ファイル: test_cacheTest.php プロジェクト: jinshana/kajonacms
 public function testCacheFlushing()
 {
     $objCache = class_cache::createNewInstance(self::$strCacheSource);
     $objCache->setStrHash1("testClean");
     $objCache->setStrContent("test");
     $objCache->setIntLeasetime(time() + 2);
     $objCache->updateObjectToDb();
     $this->flushDBCache();
     $objEntry = class_cache::getCachedEntry(self::$strCacheSource, "testClean");
     $this->assertNotNull($objEntry);
     $this->flushDBCache();
     class_cache::flushCache(self::$strCacheSource);
     $this->flushDBCache();
     $objEntry = class_cache::getCachedEntry(self::$strCacheSource, "testClean");
     $this->assertNull($objEntry);
 }
コード例 #8
0
ファイル: class_testbase.php プロジェクト: jinshana/kajonacms
 protected function printDebugValues()
 {
     $strDebug = "";
     $arrTimestampEnde = gettimeofday();
     $intTimeUsed = ($arrTimestampEnde['sec'] * 1000000 + $arrTimestampEnde['usec'] - ($this->arrTestStartDate['sec'] * 1000000 + $this->arrTestStartDate['usec'])) / 1000000;
     $strDebug .= "PHP-Time:                            " . number_format($intTimeUsed, 6) . " sec \n";
     //Hows about the queries?
     $strDebug .= "Queries db/cachesize/cached/fired:   " . class_carrier::getInstance()->getObjDB()->getNumber() . "/" . class_carrier::getInstance()->getObjDB()->getCacheSize() . "/" . class_carrier::getInstance()->getObjDB()->getNumberCache() . "/" . (class_carrier::getInstance()->getObjDB()->getNumber() - class_carrier::getInstance()->getObjDB()->getNumberCache()) . " \n";
     //anything to say about the templates?
     $strDebug .= "Templates cached:                    " . class_carrier::getInstance()->getObjTemplate()->getNumberCacheSize() . " \n";
     //memory
     $strDebug .= "Memory/Max Memory:                   " . bytesToString(memory_get_usage()) . "/" . bytesToString(memory_get_peak_usage()) . " \n";
     $strDebug .= "Classes Loaded:                      " . class_classloader::getInstance()->getIntNumberOfClassesLoaded() . " \n";
     //and check the cache-stats
     $strDebug .= "Cache requests/hits/saves/cachesize: " . class_cache::getIntRequests() . "/" . class_cache::getIntHits() . "/" . class_cache::getIntSaves() . "/" . class_cache::getIntCachesize() . " \n";
     //echo get_called_class()."\n".$strDebug."\n";
 }
コード例 #9
0
ファイル: admindiff.php プロジェクト: Rellfy/florensia-base
    }
    $tablelist[$i][$itemtables[0]]['searchkey'] = $florensia->get_columnname("itemid", "item");
    $tablelist[$i][$itemtables[0]]['columnnametable'] = "item";
    $tablelist[$i][$itemtables[0]]['ignore'] = "id,name_Korea,name_Japan,name_English,name_German,name_Italian,name_Spanish,name_Portuguese,name_French,name_Turkish,name_China";
    $i++;
}
$queryitemtables = MYSQL_QUERY("SHOW TABLES FROM florensia LIKE 'server_questtext_%'");
while ($itemtables = MYSQL_FETCH_ARRAY($queryitemtables)) {
    $tablelist[$i][$itemtables[0]]['searchkey'] = "questlistid";
    $tablelist[$i][$itemtables[0]]['ignore'] = "id";
    $i++;
}
/* */
//NOT IMPLEMENTED: server_skilltrees, server_items_idtable, server_upgraderule, server_seal_option
//missbrauch der cache-funktion -> einfacheres einschreiben und ggf. workarounds fuer keys mit nummern/sonderzeichen
$sqldiff = new class_cache();
$sqldiff->load_cache("sqldiff");
$sqldiff->write_cache("timestamp", date("U"));
$dbold = MYSQL_CONNECT($cfg['dbhost'], $cfg['dbuser'], $cfg['dbpasswd'], TRUE) or die("No Database connection");
MYSQL_SELECT_DB("{$oldtable}", $dbold) or die("No Database connection");
MYSQL_QUERY("SET NAMES 'utf8'", $dbold);
foreach ($tablelist as $globalkey => $value) {
    foreach ($tablelist[$globalkey] as $table => $tablesettings) {
        $diffentries = 0;
        $newentries = 0;
        unset($allentries, $exceptkeys, $content);
        $allentries = array();
        $querytabledata = MYSQL_QUERY("SELECT * FROM {$table} " . $tablelist[$globalkey][$table]['dbwhere'], $db);
        while ($tabledata = MYSQL_FETCH_ASSOC($querytabledata)) {
            $querytabledata_old = MYSQL_QUERY("SELECT * FROM {$table} WHERE " . $tablelist[$globalkey][$table]['searchkey'] . "='" . $tabledata[$tablelist[$globalkey][$table]['searchkey']] . "'", $dbold);
            if ($tabledata_old = MYSQL_FETCH_ASSOC($querytabledata_old)) {
コード例 #10
0
ファイル: class_cache.php プロジェクト: jinshana/kajonacms
 /**
  * Returns all cached entries.
  *
  * @param int $intStart
  * @param int $intEnd
  * @return array
  */
 public static function getAllCacheEntries($intStart = null, $intEnd = null)
 {
     //search in the database to find a matching entry
     $strQuery = "SELECT *\n                       FROM " . _dbprefix_ . "cache\n                       ORDER BY cache_leasetime DESC";
     $arrCaches = class_carrier::getInstance()->getObjDB()->getPArray($strQuery, array(), $intStart, $intEnd);
     $arrReturn = array();
     foreach ($arrCaches as $arrRow) {
         if (isset($arrRow["cache_id"])) {
             $objCacheEntry = new class_cache($arrRow["cache_source"], $arrRow["cache_hash1"], $arrRow["cache_hash2"], $arrRow["cache_language"], $arrRow["cache_content"], $arrRow["cache_leasetime"], $arrRow["cache_id"]);
             $objCacheEntry->setIntEntryHits($arrRow["cache_hits"]);
             $arrReturn[] = $objCacheEntry;
         }
     }
     return $arrReturn;
 }
コード例 #11
0
 /**
  * Deletes all entries currently saved to the cache
  *
  * @return bool
  */
 public function flushCache()
 {
     return class_cache::flushCache(__CLASS__);
 }
コード例 #12
0
 /**
  * Deletes the element from the system-tables, also from the foreign-element-tables.
  * This takes care of reordering the internal sort-ids.
  *
  * @return bool
  */
 public function deleteObjectFromDatabase()
 {
     //fix the internal sorting
     $arrElements = $this->getSortedElementsAtPlaceholder();
     $arrIds = array();
     $bitHit = false;
     foreach ($arrElements as $arrOneSibling) {
         if ($bitHit) {
             $arrIds[] = $arrOneSibling["system_id"];
         }
         if ($arrOneSibling["system_id"] == $this->getSystemid()) {
             $bitHit = true;
         }
     }
     if (count($arrIds) > 0) {
         $strQuery = "UPDATE " . _dbprefix_ . "system SET system_sort = system_sort-1 where system_id IN (" . implode(",", array_map(function ($strVal) {
             return "?";
         }, $arrIds)) . ")";
         $this->objDB->_pQuery($strQuery, $arrIds);
     }
     //Load the Element-Data
     $objElement = $this->getConcreteAdminInstance();
     if ($objElement != null) {
         //Fetch the table
         $strElementTable = $objElement->getTable();
         //Delete the entry in the Element-Table
         if ($strElementTable != "") {
             $strQuery = "DELETE FROM " . $strElementTable . " WHERE content_id= ?";
             if (!$this->objDB->_pQuery($strQuery, array($this->getSystemid()))) {
                 return false;
             }
         }
     }
     //Delete from page_element table
     parent::deleteObjectFromDatabase();
     //Loading the data of the corresponding site
     $objPage = new class_module_pages_page($this->getPrevId());
     class_cache::flushCache("class_element_portal", $objPage->getStrName());
     return true;
 }
コード例 #13
0
ファイル: class_root.php プロジェクト: jinshana/kajonacms
 /**
  * Removes one page from the cache
  *
  * @param string $strPagename
  * @return bool
  */
 public function flushPageFromPagesCache($strPagename)
 {
     return class_cache::flushCache("class_element_portal", $strPagename);
 }
コード例 #14
0
 /**
  * Saves the current element to the cache.
  * If passed, the value of the param $strElementOutput is used as content, otherwise
  * content-generation is triggered again.
  *
  * @param string $strElementOutput
  *
  * @since 3.3.1
  */
 public function saveElementToCache($strElementOutput = "")
 {
     //if no content was passed, rebuild the content
     if ($strElementOutput == "") {
         $strElementOutput = $this->getElementOutput();
     }
     //strip the data-editable values - no use case for regular page views
     $strElementOutput = preg_replace('/data-kajona-editable=\\"([a-zA-Z0-9#_]*)\\"/i', "", $strElementOutput);
     //load the matching cache-entry
     $objCacheEntry = class_cache::getCachedEntry(__CLASS__, $this->getCacheHash1(), $this->getCacheHash2(), $this->getStrPortalLanguage(), true);
     $objCacheEntry->setStrContent($strElementOutput);
     $objCacheEntry->setIntLeasetime(time() + $this->objElementData->getIntCachetime());
     $objCacheEntry->updateObjectToDb();
 }
コード例 #15
0
 /**
  * Generates debugging-infos, but only in non-xml mode
  *
  * @param string $strReturn
  *
  * @return string
  */
 private function getDebugInfo($strReturn)
 {
     $strDebug = "";
     if (_timedebug_ || _dbnumber_ || _templatenr_ || _memory_) {
         //Maybe we need the time used to generate this page
         if (_timedebug_ === true) {
             $arrTimestampEnde = gettimeofday();
             $intTimeUsed = ($arrTimestampEnde['sec'] * 1000000 + $arrTimestampEnde['usec'] - ($this->arrTimestampStart['sec'] * 1000000 + $this->arrTimestampStart['usec'])) / 1000000;
             $strDebug .= "<b>PHP-Time:</b> " . number_format($intTimeUsed, 6) . " sec ";
         }
         //Hows about the queries?
         if (_dbnumber_ === true) {
             $strDebug .= "<b>Queries db/cachesize/cached/fired:</b> " . class_carrier::getInstance()->getObjDB()->getNumber() . "/" . class_carrier::getInstance()->getObjDB()->getCacheSize() . "/" . class_carrier::getInstance()->getObjDB()->getNumberCache() . "/" . (class_carrier::getInstance()->getObjDB()->getNumber() - class_carrier::getInstance()->getObjDB()->getNumberCache()) . " ";
         }
         //anything to say about the templates?
         if (_templatenr_ === true) {
             $strDebug .= "<b>Templates cached:</b> " . class_carrier::getInstance()->getObjTemplate()->getNumberCacheSize() . " ";
         }
         //memory
         if (_memory_ === true) {
             $strDebug .= "<b>Memory/Max Memory:</b> " . bytesToString(memory_get_usage()) . "/" . bytesToString(memory_get_peak_usage()) . " ";
             $strDebug .= "<b>Classes Loaded:</b> " . class_classloader::getInstance()->getIntNumberOfClassesLoaded() . " ";
         }
         //and check the cache-stats
         if (_cache_ === true) {
             $strDebug .= "<b>Cache requests/hits/saves/cachesize:</b> " . class_cache::getIntRequests() . "/" . class_cache::getIntHits() . "/" . class_cache::getIntSaves() . "/" . class_cache::getIntCachesize() . " ";
         }
         if (_xmlLoader_ === true) {
             class_response_object::getInstance()->addHeader("Kajona Debug: " . $strDebug);
         } else {
             $strDebug = "<pre style='z-index: 2000000; position: fixed; background-color: white; width: 100%; top: 0px; font-size: 10px; padding: 0; margin: 0;'>Kajona Debug: " . $strDebug . "</pre>";
             $intBodyPos = uniStrpos($strReturn, "</body>");
             if ($intBodyPos !== false) {
                 $strReturn = uniSubstr($strReturn, 0, $intBodyPos) . $strDebug . uniSubstr($strReturn, $intBodyPos);
             } else {
                 $strReturn = $strDebug . $strReturn;
             }
         }
     }
     return $strReturn;
 }
コード例 #16
0
 /**
  * Handles the loading of a page, more in a functional than in an oop style
  *
  * @throws class_exception
  * @return string the generated page
  * @permissions view
  */
 protected function actionGeneratePage()
 {
     //Determine the pagename
     $objPageData = $this->getPageData();
     //react on portaleditor commands
     //pe to display, or pe to disable?
     if ($this->getParam("pe") == "false") {
         $this->objSession->setSession("pe_disable", "true");
     }
     if ($this->getParam("pe") == "true") {
         $this->objSession->setSession("pe_disable", "false");
     }
     //if using the pe, the cache shouldn't be used, otherwise strange things might happen.
     //the system could frighten your cat or eat up all your cheese with marshmallows...
     //get the current state of the portal editor
     $bitPeRequested = false;
     if (class_module_system_setting::getConfigValue("_pages_portaleditor_") == "true" && $this->objSession->getSession("pe_disable") != "true" && $this->objSession->isAdmin() && $objPageData->rightEdit()) {
         $bitPeRequested = true;
     }
     //If we reached up till here, we can begin loading the elements to fill
     if ($bitPeRequested) {
         $arrElementsOnPage = class_module_pages_pageelement::getElementsOnPage($objPageData->getSystemid(), false, $this->getStrPortalLanguage());
     } else {
         $arrElementsOnPage = class_module_pages_pageelement::getElementsOnPage($objPageData->getSystemid(), true, $this->getStrPortalLanguage());
     }
     //If there's a master-page, load elements on that, too
     $objMasterData = class_module_pages_page::getPageByName("master");
     $bitEditPermissionOnMasterPage = false;
     if ($objMasterData != null) {
         if ($bitPeRequested) {
             $arrElementsOnMaster = class_module_pages_pageelement::getElementsOnPage($objMasterData->getSystemid(), false, $this->getStrPortalLanguage());
         } else {
             $arrElementsOnMaster = class_module_pages_pageelement::getElementsOnPage($objMasterData->getSystemid(), true, $this->getStrPortalLanguage());
         }
         //and merge them
         $arrElementsOnPage = array_merge($arrElementsOnPage, $arrElementsOnMaster);
         if ($objMasterData->rightEdit()) {
             $bitEditPermissionOnMasterPage = true;
         }
     }
     //Load the template from the filesystem to get the placeholders
     $strTemplateID = $this->objTemplate->readTemplate("/module_pages/" . $objPageData->getStrTemplate(), "", false, true);
     //bit include the masters-elements!!
     $arrRawPlaceholders = array_merge($this->objTemplate->getElements($strTemplateID, 0), $this->objTemplate->getElements($strTemplateID, 1));
     $arrPlaceholders = array();
     //and retransform
     foreach ($arrRawPlaceholders as $arrOneRawPlaceholder) {
         $arrPlaceholders[] = $arrOneRawPlaceholder["placeholder"];
     }
     //Initialize the caches internal cache :)
     class_cache::fillInternalCache("class_element_portal", $this->getPagename(), null, $this->getStrPortalLanguage());
     //try to load the additional title from cache
     $strAdditionalTitleFromCache = "";
     $intMaxCacheDuration = 0;
     $objCachedTitle = class_cache::getCachedEntry(__CLASS__, $this->getPagename(), $this->generateHash2Sum(), $this->getStrPortalLanguage());
     if ($objCachedTitle != null) {
         $strAdditionalTitleFromCache = $objCachedTitle->getStrContent();
         self::$strAdditionalTitle = $strAdditionalTitleFromCache;
     }
     //copy for the portaleditor
     $arrPlaceholdersFilled = array();
     //Iterate over all elements and pass control to them
     //Get back the filled element
     //Build the array to fill the template
     $arrTemplate = array();
     /** @var class_module_pages_pageelement $objOneElementOnPage */
     foreach ($arrElementsOnPage as $objOneElementOnPage) {
         //element really available on the template?
         if (!in_array($objOneElementOnPage->getStrPlaceholder(), $arrPlaceholders)) {
             //next one, plz
             continue;
         } else {
             //create a protocol of placeholders filled
             //remove from pe-additional-array, pe code is injected by element directly
             $arrPlaceholdersFilled[] = array("placeholder" => $objOneElementOnPage->getStrPlaceholder(), "name" => $objOneElementOnPage->getStrName(), "element" => $objOneElementOnPage->getStrElement(), "repeatable" => $objOneElementOnPage->getIntRepeat());
         }
         //Build the class-name for the object
         /** @var  class_element_portal $objElement  */
         $objElement = $objOneElementOnPage->getConcretePortalInstance();
         //let the element do the work and earn the output
         if (!isset($arrTemplate[$objOneElementOnPage->getStrPlaceholder()])) {
             $arrTemplate[$objOneElementOnPage->getStrPlaceholder()] = "";
         }
         //cache-handling. load element from cache.
         //if the element is re-generated, save it back to cache.
         if (class_module_system_setting::getConfigValue("_pages_cacheenabled_") == "true" && $this->getParam("preview") != "1" && $objPageData->getStrName() != class_module_system_setting::getConfigValue("_pages_errorpage_")) {
             $strElementOutput = "";
             //if the portaleditor is disabled, do the regular cache lookups in storage. otherwise regenerate again and again :)
             if ($bitPeRequested) {
                 $strElementOutput = $objElement->getElementOutput();
             } else {
                 //pe not to be taken into account --> full support of caching
                 $strElementOutput = $objElement->getElementOutputFromCache();
                 if ($objOneElementOnPage->getIntCachetime() > $intMaxCacheDuration) {
                     $intMaxCacheDuration = $objOneElementOnPage->getIntCachetime();
                 }
                 if ($strElementOutput === false) {
                     $strElementOutput = $objElement->getElementOutput();
                     $objElement->saveElementToCache($strElementOutput);
                 }
             }
         } else {
             $strElementOutput = $objElement->getElementOutput();
         }
         //if element is disabled & the pe is requested, wrap the content
         if ($bitPeRequested && $objOneElementOnPage->getIntRecordStatus() == 0) {
             $arrPeElement = array();
             $arrPeElement["title"] = $this->getLang("pe_inactiveElement", "pages") . " (" . $objOneElementOnPage->getStrElement() . ")";
             $strElementOutput = $this->objToolkit->getPeInactiveElement($arrPeElement);
             $strElementOutput = class_element_portal::addPortalEditorSetActiveCode($strElementOutput, $objElement->getSystemid(), array());
         }
         $arrTemplate[$objOneElementOnPage->getStrPlaceholder()] .= $strElementOutput;
     }
     //pe-code to add new elements on unfilled placeholders --> only if pe is visible?
     if ($bitPeRequested) {
         //loop placeholders on template in order to remove already filled ones not being repeatable
         $arrRawPlaceholdersForPe = $arrRawPlaceholders;
         foreach ($arrPlaceholdersFilled as $arrOnePlaceholder) {
             foreach ($arrRawPlaceholdersForPe as &$arrOneRawPlaceholder) {
                 if ($arrOneRawPlaceholder["placeholder"] == $arrOnePlaceholder["placeholder"]) {
                     foreach ($arrOneRawPlaceholder["elementlist"] as $intElementKey => $arrOneRawElement) {
                         if ($arrOnePlaceholder["element"] == $arrOneRawElement["element"]) {
                             if (uniSubstr($arrOneRawElement["name"], 0, 5) == "master") {
                                 $arrOneRawPlaceholder["elementlist"][$intElementKey] = null;
                             } else {
                                 if ($arrOnePlaceholder["repeatable"] == "0") {
                                     $arrOneRawPlaceholder["elementlist"][$intElementKey] = null;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         //array is now set up. loop again to create new-buttons
         $arrPePlaceholdersDone = array();
         $arrPeNewButtons = array();
         foreach ($arrRawPlaceholdersForPe as $arrOneRawPlaceholderForPe) {
             $strPeNewPlaceholder = $arrOneRawPlaceholderForPe["placeholder"];
             foreach ($arrOneRawPlaceholderForPe["elementlist"] as $arrOnePeNewElement) {
                 if ($arrOnePeNewElement == null) {
                     continue;
                 }
                 //check if the linked element exists
                 $objPeNewElement = class_module_pages_element::getElement($arrOnePeNewElement["element"]);
                 if ($objPeNewElement == null) {
                     continue;
                 }
                 //placeholder processed before?
                 $strArrayKey = $strPeNewPlaceholder . $objPeNewElement->getStrName();
                 if (in_array($strArrayKey, $arrPePlaceholdersDone)) {
                     continue;
                 } else {
                     $arrPePlaceholdersDone[] = $strArrayKey;
                 }
                 //create and register the button to add a new element
                 if (!isset($arrPeNewButtons[$strPeNewPlaceholder])) {
                     $arrPeNewButtons[$strPeNewPlaceholder] = "";
                 }
                 if (uniStripos($strArrayKey, "master") !== false) {
                     $strLink = "";
                     if ($objMasterData !== null) {
                         $strLink = class_element_portal::getPortaleditorNewCode($objMasterData->getSystemid(), $strPeNewPlaceholder, $objPeNewElement);
                     }
                 } else {
                     $strLink = class_element_portal::getPortaleditorNewCode($objPageData->getSystemid(), $strPeNewPlaceholder, $objPeNewElement);
                 }
                 $arrPeNewButtons[$strPeNewPlaceholder] .= $strLink;
             }
         }
         //loop pe-new code in order to add the wrappers and assign the code to the matching placeholder
         foreach ($arrPeNewButtons as $strPlaceholderName => $strNewButtons) {
             if (!isset($arrTemplate[$strPlaceholderName])) {
                 $arrTemplate[$strPlaceholderName] = "";
             }
             if ($strNewButtons != "") {
                 $strNewButtons = class_element_portal::getPortaleditorNewWrapperCode($strPlaceholderName, $strNewButtons);
             }
             $arrTemplate[$strPlaceholderName] .= $strNewButtons;
         }
         // add placeholder wrapping
         foreach ($arrTemplate as $strPlaceholder => $strContent) {
             $arrTemplate[$strPlaceholder] = class_carrier::getInstance()->getObjToolkit("portal")->getPePlaceholderWrapper($strPlaceholder, $strContent);
         }
     }
     //check if the additional title has to be saved to the cache
     if (self::$strAdditionalTitle != "" && self::$strAdditionalTitle != $strAdditionalTitleFromCache) {
         $objCacheEntry = class_cache::getCachedEntry(__CLASS__, $this->getPagename(), $this->generateHash2Sum(), $this->getStrPortalLanguage(), true);
         $objCacheEntry->setStrContent(self::$strAdditionalTitle);
         $objCacheEntry->setIntLeasetime(time() + $intMaxCacheDuration);
         $objCacheEntry->updateObjectToDb();
     }
     $arrTemplate["description"] = $objPageData->getStrDesc();
     $arrTemplate["keywords"] = $objPageData->getStrKeywords();
     $arrTemplate["title"] = $objPageData->getStrBrowsername();
     $arrTemplate["additionalTitle"] = self::$strAdditionalTitle;
     $arrTemplate["canonicalUrl"] = class_link::getLinkPortalHref($objPageData->getStrName(), "", $this->getParam("action"), "", $this->getParam("systemid"));
     //Include the $arrGlobal Elements
     $arrGlobal = array();
     $strPath = class_resourceloader::getInstance()->getPathForFile("/portal/global_includes.php");
     if ($strPath !== false) {
         include _realpath_ . $strPath;
     }
     $arrTemplate = array_merge($arrTemplate, $arrGlobal);
     //fill the template. the template was read before
     $strPageContent = $this->fillTemplate($arrTemplate, $strTemplateID);
     $strPageContent = $this->renderPortalEditorCode($objPageData, $bitEditPermissionOnMasterPage, $strPageContent);
     //insert the copyright headers. Due to our licence, you are NOT allowed to remove those lines.
     $strHeader = "<!--\n";
     $strHeader .= "Website powered by Kajona Open Source Content Management Framework\n";
     $strHeader .= "For more information about Kajona see http://www.kajona.de\n";
     $strHeader .= "-->\n";
     $intBodyPos = uniStripos($strPageContent, "</head>");
     $intPosXml = uniStripos($strPageContent, "<?xml");
     if ($intBodyPos !== false) {
         $intBodyPos += 0;
         $strPageContent = uniSubstr($strPageContent, 0, $intBodyPos) . $strHeader . uniSubstr($strPageContent, $intBodyPos);
     } else {
         if ($intPosXml !== false) {
             $intBodyPos = uniStripos($strPageContent, "?>");
             $intBodyPos += 2;
             $strPageContent = uniSubstr($strPageContent, 0, $intBodyPos) . $strHeader . uniSubstr($strPageContent, $intBodyPos);
         } else {
             $strPageContent = $strHeader . $strPageContent;
         }
     }
     return $strPageContent;
 }
コード例 #17
0
ファイル: cacheview.php プロジェクト: jinshana/kajonacms
<?php

/*"******************************************************************************************************
*   (c) 2004-2006 by MulchProductions, www.mulchprod.de                                                 *
*   (c) 2007-2015 by Kajona, www.kajona.de                                                              *
*       Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt                                 *
*-------------------------------------------------------------------------------------------------------*
*   $Id$                                     *
********************************************************************************************************/
echo "+-------------------------------------------------------------------------------+\n";
echo "| Kajona Debug Subsystem                                                        |\n";
echo "|                                                                               |\n";
echo "| CACHEVIEW                                                                     |\n";
echo "|                                                                               |\n";
echo "+-------------------------------------------------------------------------------+\n";
$arrEntries = class_cache::getAllCacheEntries();
$arrData = array();
$arrHeader = array();
$objText = class_carrier::getInstance()->getObjLang();
$arrHeader[] = "Leasetime";
$arrHeader[] = "Source";
$arrHeader[] = "Language";
$arrHeader[] = "Hash 1";
$arrHeader[] = "Hash 2";
$arrHeader[] = "Hits";
$arrHeader[] = "Size";
foreach ($arrEntries as $objOneEntry) {
    $arrRowData = array();
    $arrRowData[] = timeToString($objOneEntry->getIntLeasetime());
    $arrRowData[] = $objOneEntry->getStrSourceName();
    $arrRowData[] = $objOneEntry->getStrLanguage();
コード例 #18
0
 /**
  * Deletes the complete Pages-Cache
  *
  * @return bool
  */
 public function flushCompletePagesCache()
 {
     return class_cache::flushCache("class_element_portal");
 }
コード例 #19
0
ファイル: diff.php プロジェクト: Rellfy/florensia-base
$flolang->load("versiondifferences");
require_once "./class_diff.php";
$difffiles = scandir("./diffs/", 1);
$selected_difffile[$_GET['diff']] = "selected='selected'";
foreach ($difffiles as $difffile) {
    if (!preg_match('/~$/', $difffile) && preg_match('/^sqldiff_([0-9]{10})\\.php$/', $difffile, $timestamp)) {
        if (!isset($_GET['diff'])) {
            $_GET['diff'] = $timestamp[1];
        }
        $files .= "<option value='" . $timestamp[1] . "' " . $selected_difffile[$timestamp[1]] . ">" . date("m.d.Y", $timestamp[1]) . "</option>";
    }
}
$selectform = "\n\t\t<form action='" . $florensia->escape($_SERVER['REQUEST_URI']) . "' method='GET'>\n\t\t\t<div class='small bordered' style='margin-bottom:10px;'>\n\t\t\t{$flolang->diff_select_title} \n\t\t\t\t<select name='diff'>{$files}</select>\n\t\t\t\t&nbsp;<input class='quicksubmit' type='submit' value=''>\n\t\t\t</div>\n\t\t</form>\n\t";
$selected_file = "{$florensia->root_abs}/diffs/sqldiff_" . $_GET['diff'] . ".php";
if (is_file($selected_file)) {
    $sqldiff = new class_cache();
    $sqldiff->load_cachefile($selected_file);
    if ($sqldiff->get_cache("timestamp")) {
        foreach ($sqldiff->get_cache("sql", FALSE) as $mainentry => $mainvalue) {
            foreach ($sqldiff->get_cache("sql,{$mainentry}", FALSE) as $subentry => $subvalue) {
                $diff->create_diff_overview($subentry, $subvalue);
            }
        }
        $content = "\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<table style='width:100%;'><tr>\n\t\t\t\t\t\t\t<td style='width:33%' class='diff_new'>{$flolang->diff_legend_newentries}</td>\n\t\t\t\t\t\t\t<td style='width:33%;' class='diff_changed'>{$flolang->diff_legend_changedentries}</td>\n\t\t\t\t\t\t\t<td class='diff_deleted'>{$flolang->diff_legend_removedentries}</td>\n\t\t\t\t\t\t</tr></table>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div class='subtitle' style='text-align:center; margin-bottom:5px; margin-top:10px;'>" . date("m.d.Y", $sqldiff->get_cache("timestamp")) . "</div>\n\t\t\t\t\t" . $diff->watch_diff_overview();
    } else {
        $florensia->notice($flolang->diff_error_loadfile, "warning");
    }
} else {
    $florensia->notice($flolang->diff_error_notfound, "warning");
}
$content = $selectform . $content;
コード例 #20
0
 /**
  * retrieve the content
  */
 public function run()
 {
     // api call
     $cache = new class_cache('wunderground_' . $this->location . '.json');
     if ($cache->hit()) {
         $content = $cache->read();
     } else {
         $url = 'http://api.wunderground.com/api/' . config_weather_key . '/conditions/forecast/lang:' . trans('wunderground', 'lang') . '/q/' . $this->location . '.json';
         $content = file_get_contents($url);
     }
     $parsed_json = json_decode($content);
     if ($parsed_json->{'forecast'}) {
         // write cache
         $cache->write($content);
         $this->debug($parsed_json);
         // today
         $this->data['city'] = (string) $parsed_json->{'current_observation'}->{'display_location'}->{'city'};
         if (substr(trans('format', 'temp'), -1, 1) != "F") {
             $this->data['current']['temp'] = transunit('temp', (double) $parsed_json->{'current_observation'}->{'temp_c'});
         } else {
             $this->data['current']['temp'] = transunit('temp', (double) $parsed_json->{'current_observation'}->{'temp_f'});
         }
         $this->data['current']['conditions'] = (string) $parsed_json->{'current_observation'}->{'weather'};
         $this->data['current']['icon'] = $this->icon((string) $parsed_json->{'current_observation'}->{'icon'}, $this->icon_sm);
         // get the good values by countries in km/h or mph for the wind and gusts
         if (trim(strrchr(trans('format', 'speed'), ' ')) != 'mph') {
             $wind_speed = transunit('speed', (double) $parsed_json->{'current_observation'}->{'wind_kph'});
             $wind_gust = transunit('speed', (double) $parsed_json->{'current_observation'}->{'wind_gust_kph'});
         } else {
             $wind_speed = transunit('speed', (double) $parsed_json->{'current_observation'}->{'wind_mph'});
             $wind_gust = transunit('speed', (double) $parsed_json->{'current_observation'}->{'wind_gust_mph'});
         }
         $wind_direction = translate((string) $parsed_json->{'current_observation'}->{'wind_dir'}, 'wunderground');
         // in french, there is a difference when the word stars with a vowel
         // de (from) becomes d' can be use if a language has the same exception
         if (config_lang == 'fr') {
             if (substr($wind_direction, 0, 1) == 'O' || substr($wind_direction, 0, 1) == 'E') {
                 $from = translate('from_ew', 'wunderground');
             } else {
                 $from = translate('from_ns', 'wunderground');
             }
         } else {
             $from = translate('from', 'wunderground');
         }
         // when the wind has no fix direction from is blank
         if ((string) $parsed_json->{'current_observation'}->{'wind_dir'} == 'Variable') {
             $from = '';
         }
         $this->data['current']['wind'] = translate('wind', 'wunderground') . " " . $from . " " . $wind_direction . ", " . translate('wind_speed', 'wunderground') . " " . $wind_speed;
         if ($wind_gust > 0) {
             $this->data['current']['wind'] .= ", " . translate('wind_gust', 'wunderground') . " " . $wind_gust;
         }
         $this->data['current']['more'] = translate('humidity', 'wunderground') . " " . (string) $parsed_json->{'current_observation'}->{'relative_humidity'};
         // forecast
         $i = 0;
         foreach ($parsed_json->{'forecast'}->{'simpleforecast'}->{'forecastday'} as $day) {
             $this->data['forecast'][$i]['date'] = (string) $day->{'date'}->{'year'} . '-' . (string) $day->{'date'}->{'month'} . '-' . (string) $day->{'date'}->{'day'};
             $this->data['forecast'][$i]['conditions'] = (string) $day->{'conditions'};
             $this->data['forecast'][$i]['icon'] = $this->icon((string) $day->{'icon'});
             if (substr(trans('format', 'temp'), -1, 1) != "F") {
                 $this->data['forecast'][$i]['temp'] = (double) $day->{'low'}->{'celsius'} . '&deg;/' . (double) $day->{'high'}->{'celsius'} . '&deg;';
             } else {
                 $this->data['forecast'][$i]['temp'] = (double) $day->{'low'}->{'fahrenheit'} . '&deg;/' . (double) $day->{'high'}->{'fahrenheit'} . '&deg;';
             }
             $i++;
         }
     } else {
         $add = $parsed_json->{'response'}->{'error'}->{'description'};
         $this->error('Weather: wounderground.com', 'Read request failed' . ($add ? ': ' . $add : '') . '!');
     }
 }
コード例 #21
0
ファイル: googleV3.php プロジェクト: aschwith/smartvisu
 public function run()
 {
     $cache = new class_cache('calendar_google.json');
     // check for cached data
     if ($cache->hit(3600)) {
         $cache_content = json_decode($cache->read(), true);
         if ($cache_content['accessTokenExpiry'] < time()) {
             // if token is not valid anymore reload everything cached
             unset($cache_content);
         }
     }
     if (!isset($cache_content['accessToken'])) {
         $token_url = 'https://accounts.google.com/o/oauth2/token';
         $post_data = array('client_secret' => self::CLIENT_SECRET, 'grant_type' => 'refresh_token', 'refresh_token' => self::REFRESH_TOKEN, 'client_id' => self::CLIENT_ID);
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $token_url);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         $result = curl_exec($ch);
         $token_object = json_decode($result);
         $cache_content['accessToken'] = $token_object->{'access_token'};
         $cache_content['accessTokenExpiry'] = time() + $token_object->{'expires_in'} - 60;
     }
     //---------------------------------------------------------------------
     // so now we have an access-token, let's use it to access the calendar
     $context = stream_context_create(array('http' => array('method' => "GET", 'header' => "Authorization: OAuth " . $cache_content['accessToken'])));
     // first let's retrieve the colors and cache them
     if (!isset($cache_content['calendarColors'])) {
         $resturl = 'https://www.googleapis.com/calendar/v3/colors';
         $content = @file_get_contents($resturl, false, $context);
         if ($content !== false) {
             $result = json_decode($content, true);
             $cache_content['calendarColors'] = $result["event"];
             //var_dump($cache_content['calendarColors']);
         }
     }
     // then retrieve the users calendars available and cache them, too
     // do only if more than one calendar specified
     if (count($this->calendar_ids) > 1 && !isset($cache_content['calendarList'])) {
         $resturl = 'https://www.googleapis.com/calendar/v3/users/me/calendarList';
         $content = @file_get_contents($resturl, false, $context);
         if ($content !== false) {
             $result = json_decode($content);
             $calendarList = array();
             foreach ($result->{'items'} as $entry) {
                 $cal = array();
                 $cal["description"] = $entry->{'summary'};
                 $cal["backgroundColor"] = $entry->{'backgroundColor'};
                 $calendarList[$entry->{'id'}] = $cal;
             }
             $cache_content['calendarList'] = $calendarList;
             //var_dump($cache_content['calendarList']);
         }
     }
     // retrieve the calendar entries from each calendar
     $events = array();
     foreach ($this->calendar_ids as $calendarid) {
         $resturl = 'https://www.googleapis.com/calendar/v3/calendars/' . urlencode($calendarid) . '/events?maxResults=' . $this->count . '&q=-%22%40visu+no%22&singleEvents=true&orderBy=startTime&timeMin=' . urlencode(date('c'));
         $content = @file_get_contents($resturl, false, $context);
         $this->debug($content);
         // for debugging purposes only
         // echo $content;
         // echo "###########";
         if ($content !== false) {
             $result = json_decode($content, true);
             foreach ($result["items"] as $entry) {
                 $startstamp = (string) $entry["start"]["dateTime"];
                 $endstamp = (string) $entry["end"]["dateTime"];
                 if ($startstamp == '') {
                     $startstamp = (string) $entry["start"]["date"];
                 }
                 if ($endstamp == '') {
                     $endstamp = (string) $entry["end"]["date"];
                 }
                 $start = strtotime($startstamp);
                 $end = strtotime($endstamp);
                 $color = '';
                 if ((string) $entry["colorId"] != '') {
                     $color = $cache_content['calendarColors'][(string) $entry["colorId"]]['background'];
                 } else {
                     if (count($this->calendar_ids) > 1) {
                         $color = $cache_content['calendarList'][$calendarid]['backgroundColor'];
                     }
                 }
                 $events[$start] = array('start' => date('y-m-d', $start) . ' ' . date('H:i:s', $start), 'end' => date('y-m-d', $end) . ' ' . date('H:i:s', $end), 'title' => (string) $entry["summary"], 'content' => (string) $entry["description"], 'where' => (string) $entry["location"], 'color' => $color, 'link' => (string) $entry["htmlLink"]);
             }
         } else {
             $this->error('Calendar: Google', 'Calendar ' . $calendarid . ' read request failed!');
         }
     }
     // finally re-order the events comming potentially from different calendars
     $i = 1;
     ksort($events);
     foreach ($events as $event) {
         $event['pos'] = $i++;
         $this->data[] = $event;
         if ($i > $this->count) {
             break;
         }
     }
     // at the end write back cache
     $cache->write(json_encode($cache_content));
 }