/** * Get object Definition (CMS_poly_object_definition) * * @return CMS_poly_object_definition * @access public */ function getObjectDefinition() { //create cache object $cache = new CMS_cache('object' . $this->_objectID, 'atm-polymod-structure', 2592000, false); $datas = ''; if (!$cache->exist() || !($datas = $cache->load())) { //datas does not exists : load it $datas = CMS_poly_object_catalog::getObjectDefinition($this->_objectID); if ($cache) { $cache->save($datas, array('type' => 'object')); } } return $datas; }
// $Id: backtrace.php,v 1.3 2010/03/08 16:41:17 sebastien Exp $ /** * PHP page : Backtrace debug page * * @package Automne * @subpackage admin * @author Sébastien Pauchet <*****@*****.**> */ require_once dirname(__FILE__) . '/../../cms_rc_admin.php'; $dialog = new CMS_dialog(); $dialog->setTitle('Automne :: Debug :: BackTrace', 'pic_meta.gif'); $backTraceName = $_GET['bt']; if (!$backTraceName) { $content = 'Cannot backtrace, datas missing ...'; } else { //get backtrace from cache object $cache = new CMS_cache($backTraceName, 'atm-backtrace', 600, false); //load cache content if (!$cache->exist() || !($datas = $cache->load())) { $content = 'Cannot backtrace, datas missing ...'; } else { $content = ' <h3>Backtrace:</h3> ' . $datas['summary'] . '<br /> <h3>Backtrace Detail:</h3> <pre>' . io::htmlspecialchars($datas['backtrace']) . '</pre> '; } } $dialog->setContent($content); $dialog->show();
/** * Return all fields for a given object ID * * @param integer $objectID the object ID to get fields * @return array of CMS_object_fields * @access public * @static */ static function getFieldsDefinition($objectID, $reset = false) { static $datas; if (!$reset && isset($datas[$objectID])) { return $datas[$objectID]; } $datas[$objectID] = array(); if (sensitiveIO::isPositiveInteger($objectID)) { //create cache object $cache = new CMS_cache('fields' . $objectID, 'atm-polymod-structure', 2592000, false); if ($reset || !$cache->exist() || !($datas[$objectID] = $cache->load())) { //datas does not exists : load them $sql = "\n\t\t\t\t\tselect\n\t\t\t\t\t\t*\n\t\t\t\t\tfrom\n\t\t\t\t\t\tmod_object_field,\n\t\t\t\t\t\tmod_object_definition\n\t\t\t\t\twhere\n\t\t\t\t\t\tobject_id_mof = '" . $objectID . "'\n\t\t\t\t\t\tand object_id_mof = id_mod\n\t\t\t\t\torder by \n\t\t\t\t\t\torder_mof\n\t\t\t\t"; $q = new CMS_query($sql); while ($r = $q->getArray()) { $datas[$objectID][$r["id_mof"]] = new CMS_poly_object_field($r["id_mof"], $r); } if ($cache) { $cache->save($datas[$objectID], array('type' => 'fields')); } } } return $datas[$objectID]; }
/** * Retrieve current media datas from provider * * @return boolean * @access protected */ protected function _retrieveDatas() { if ($this->_datas) { return true; } //load provider if (!$this->_getProvider()) { return false; } //set cache lifetime $lifetime = 86400; //(default : 24 hours) //create cache id from files, compression status and last time files access $cacheId = md5(serialize(array('url' => $this->_url, 'maxwidth' => io::isPositiveInteger($this->_maxwidth) ? $this->_maxwidth : '', 'maxheight' => io::isPositiveInteger($this->_maxheight) ? $this->_maxheight : ''))); //create cache object $cache = new CMS_cache($cacheId, 'oembed', $lifetime, false); $datas = ''; if (!$cache->exist() || !($datas = $cache->load())) { try { $client = new Zend_Http_Client(); $client->setUri($this->getProvider()); //HTTP config $httpConfig = array('maxredirects' => 5, 'timeout' => 10, 'useragent' => 'Mozilla/5.0 (compatible; Automne/' . AUTOMNE_VERSION . '; +http://www.automne-cms.org)'); if (defined('APPLICATION_PROXY_HOST') && APPLICATION_PROXY_HOST) { $httpConfig['adapter'] = 'Zend_Http_Client_Adapter_Proxy'; $httpConfig['proxy_host'] = APPLICATION_PROXY_HOST; if (defined('APPLICATION_PROXY_PORT') && APPLICATION_PROXY_PORT) { $httpConfig['proxy_port'] = APPLICATION_PROXY_PORT; } } $client->setConfig($httpConfig); $client->setParameterGet(array('url' => $this->_url, 'format' => 'json')); if (io::isPositiveInteger($this->_maxwidth)) { $client->setParameterGet('maxwidth', $this->_maxwidth); } if (io::isPositiveInteger($this->_maxheight)) { $client->setParameterGet('maxheight', $this->_maxheight); } $client->request(); $response = $client->getLastResponse(); } catch (Zend_Http_Client_Exception $e) { $this->raiseError('Error for url: ' . $this->_url . ' - ' . $e->getMessage()); } if (isset($response) && $response->isSuccessful()) { $jsonString = $response->getBody(); $datas = json_decode($jsonString, true); } else { if (isset($response)) { $this->raiseError('Error for oembed url: ' . $this->_url . ' (Provider: ' . $this->getProvider() . ') - ' . $response->getStatus() . ' - ' . $response->getMessage()); } else { $this->raiseError('Error for oembed url: ' . $this->_url . ' (Provider: ' . $this->getProvider() . ') - no response object'); } //create error datas $datas = array('error' => isset($response) ? $response->getStatus() : '500', 'cache_age' => 7200, 'type' => 'error'); } if ($cache) { if (isset($datas['cache_age']) && io::isPositiveInteger($datas['cache_age']) && $datas['cache_age'] != 86400) { //create cache object with new lifetime $cache = new CMS_cache($cacheId, 'oembed', $datas['cache_age'], false); } $cache->save($datas, array('type' => 'oembed', 'provider' => $this->getProvider())); } } if (!$datas) { return false; } $this->_datas = $datas; return true; }
* @subpackage frontend * @author Sébastien Pauchet <*****@*****.**> */ if (!isset($_REQUEST['atm-previz'])) { define('SYSTEM_DEBUG', false); } //Include all needed classes require_once dirname(__FILE__) . '/../cms_rc_frontend.php'; //Get RSS object $error = 0; $ttl = '1440'; $data = $label = $rssTitle = $description = $link = $categoriesTags = $copyrightTag = $emailTag = ''; $namespaces = 'xmlns:media="http://search.yahoo.com/mrss/" xmlns:atom="http://www.w3.org/2005/Atom"'; $hash = md5(serialize($_REQUEST)); $cache = new CMS_cache($hash, 'polymod', 'auto', true); if ($cache->exist()) { //Get content from cache $content = $cache->load(); } else { $cache->start(); if (!isset($_REQUEST['id']) || !sensitiveIO::isPositiveInteger($_REQUEST['id'])) { $error = 1; } else { if (!CMS_poly_rss_definitions::exists($_REQUEST['id'])) { $error = 2; } else { $RSSDefinition = new CMS_poly_rss_definitions($_REQUEST['id']); if ($RSSDefinition->hasError()) { $error = 2; } //Create RSS Content
/** * Send a group of files to client (ie : JS or CSS files) * Provide coherent user caching infos (1 month) for files and allow gzip when possible * * @param array $files : array of files path to send to client (FS relative) * @param string $contentType : the content type to send to client (default : text/html) * @return void * @access public * @static */ static function sendFiles($files, $contentType = 'text/html') { //check for the closest last modification date $lastdate = ''; //check for included files in less files $includes = array(); if ($contentType == 'text/css') { foreach ($files as $key => $file) { if (pathinfo($file, PATHINFO_EXTENSION) == 'less') { $lessCache = new CMS_cache(md5($file), 'lessphp', 2592000, false); if ($lessCache->exist()) { $includes = array_merge($includes, $lessCache->load()); } } } } if ($includes) { foreach ($includes as $key => $file) { if (file_exists($file) && is_file($file)) { $lastdate = filemtime($file) > $lastdate ? filemtime($file) : $lastdate; } } } foreach ($files as $key => $file) { if (file_exists($file) && is_file($file)) { $lastdate = filemtime($file) > $lastdate ? filemtime($file) : $lastdate; } else { CMS_grandFather::raiseError('Can\'t find file : ' . $file . ', skip it.'); unset($files[$key]); } } if (file_exists($_SERVER['SCRIPT_FILENAME'])) { $lastdate = filemtime($_SERVER['SCRIPT_FILENAME']) > $lastdate ? filemtime($_SERVER['SCRIPT_FILENAME']) : $lastdate; } //check If-Modified-Since header if exists then return a 304 if needed if (isset($_SERVER['IF-MODIFIED-SINCE'])) { $ifModifiedSince = strtotime($_SERVER['IF-MODIFIED-SINCE']); } elseif (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) { $ifModifiedSince = strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']); } if (isset($ifModifiedSince) && $lastdate <= $ifModifiedSince) { header('HTTP/1.1 304 Not Modified'); header('Content-Type: ' . $contentType); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $lastdate) . ' GMT'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 2592000) . ' GMT'); //30 days header("Cache-Control: must-revalidate"); header("Pragma: public"); exit; } $compress = 'ob_gzhandler' != ini_get('output_handler') && extension_loaded('zlib') && !ini_get('zlib.output_compression') && strpos(strtolower(@$_SERVER['HTTP_ACCEPT_ENCODING']), 'gzip') !== false; //create cache id from files, compression status and last time files access $id = md5(implode(',', $files) . '-' . $compress . '-' . $lastdate); //create cache object $cache = new CMS_cache($id, $contentType, 2592000, false); $datas = ''; if (!$cache->exist() || !($datas = $cache->load())) { // datas cache missing so create it foreach ($files as $file) { $fileData = file_get_contents($file); //strip BOM from file if exists if (substr($fileData, 0, 3) === '') { $fileData = substr($fileData, 3); } //append file origin comment if ($contentType == 'text/javascript') { $fileData = '//<<' . "\n" . '//JS file: ' . str_replace(PATH_REALROOT_FS, '', $file) . '' . "\n" . '//!>>' . "\n" . $fileData; } //append file origin comment if ($contentType == 'text/css') { //compile less files if needed if (pathinfo($file, PATHINFO_EXTENSION) == 'less') { $less = new lessc($file); $fileData = $less->parse(); $lessIncludes = $less->allParsedFiles(); if (sizeof($lessIncludes) > 1) { $lessCache = new CMS_cache(md5($file), 'lessphp', 2592000, false); $lessCache->save(array_keys($lessIncludes), array('type' => 'lessphp')); } } $fileData = '/*<<*/' . "\n" . '/* CSS file: ' . str_replace(PATH_REALROOT_FS, '', $file) . ' */' . "\n" . '/*!>>*/' . "\n" . $fileData; } $datas .= $fileData . "\n"; } //minimize JS files if needed if (!SYSTEM_DEBUG && $contentType == 'text/javascript') { $datas = JSMin::minify($datas); } //minimize CSS files if needed if (!SYSTEM_DEBUG && $contentType == 'text/css') { $datas = cssmin::minify($datas); } //compres data if needed if ($compress) { $datas = gzencode($datas, 3); } if ($cache) { $cache->save($datas, array('type' => $contentType)); } } //send headers header('Content-Type: ' . $contentType); header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $lastdate) . ' GMT'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 2592000) . ' GMT'); //30 days header("Cache-Control: must-revalidate"); header("Pragma: public"); //send gzip header if needed if ($compress) { header('Vary: Accept-Encoding'); // Handle proxies header("Content-Encoding: gzip"); } //send content echo $datas; exit; }