function setFile($tainted_file_path) { $file_path = AMP_pathFlip($tainted_file_path); $this->_path = $file_path; $this->_basename = basename($file_path); $this->_extension = $this->findExtension($file_path); $folders = split(DIRECTORY_SEPARATOR, dirname($file_path)); $this->_parent_folder = array_pop($folders); $this->id = $this->getName(); }
function __construct() { $folders = array(); $original_folder = AMP_pathFlip(AMP_LOCAL_PATH . AMP_IMAGE_PATH . AMP_IMAGE_CLASS_ORIGINAL); $original_dir = opendir($original_folder); while ($filename = readdir($original_dir)) { if (!(strpos($filename, '.') === FALSE)) { continue; } if (!is_dir($original_folder . DIRECTORY_SEPARATOR . $filename)) { continue; } $folders[$filename] = $filename; } $this->dataset = $folders; }
function AMP_cache_this_request($finalPageHtml) { if (!AMP_is_cacheable_url()) { return; } $cache_key = AMP_CACHE_TOKEN_URL_CONTENT . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; $user_id = defined('AMP_SYSTEM_USER_ID') && AMP_SYSTEM_USER_ID ? AMP_SYSTEM_USER_ID : null; AMP_cache_set($cache_key, $finalPageHtml, $user_id); //HTML caching code for apache redirection $url_values = AMP_url_read(); if ($url_values) { $section_okay = count($url_values) == 2 && isset($url_values['list']) && isset($url_values['type']); $class_okay = count($url_values) == 2 && isset($url_values['list']) && isset($url_values['class']); $article_okay = count($url_values) == 1 && isset($url_values['id']); $pretty_url_okay = count($url_values) == 1 && isset($url_values['q_url']); if (!($section_okay || $article_okay || $class_okay || $pretty_url_okay)) { //don't cache pages with any funny vars on them return; } } $cache_file = false; $cache_folder = false; $currentPage = AMPContent_Page::instance(); if ($currentPage->isArticle()) { $cache_folder = AMP_pathFlip(AMP_SYSTEM_CACHE_PATH . DIRECTORY_SEPARATOR . 'article'); $cache_file = $cache_folder . DIRECTORY_SEPARATOR . $currentPage->getArticleId() . '.html'; } if ($currentPage->isList('type')) { $cache_folder = AMP_pathFlip(AMP_SYSTEM_CACHE_PATH . DIRECTORY_SEPARATOR . 'section'); $cache_file = $cache_folder . DIRECTORY_SEPARATOR . $currentPage->getSectionId() . '.html'; } if ($currentPage->isList('index')) { $cache_folder = AMP_pathFlip(AMP_SYSTEM_CACHE_PATH); $cache_file = $cache_folder . DIRECTORY_SEPARATOR . 'index.html'; } if (isset($_GET['q_url']) && $_GET['q_url']) { $cache_folder = AMP_pathFlip(AMP_SYSTEM_CACHE_PATH . DIRECTORY_SEPARATOR . 'pretty_url'); $cache_file = $cache_folder . DIRECTORY_SEPARATOR . $_GET['q_url'] . '.html'; } if ($cache_folder) { AMP_mkdir($cache_folder); } if ($cache_file && !file_exists($cache_file)) { $cache_out = fopen($cache_file, 'w'); fwrite($cache_out, $finalPageHtml); fclose($cache_out); } }
function get_foldername() { $options = $this->getOptions(); return AMP_pathFlip(AMP_LOCAL_PATH . '/' . $options['save_to_folder']); }
function _getComponentPath($component_name) { if ("Item" == $component_name) { return AMP_pathFlip($this->getTargetPath() . '/' . $this->_scaffold_item . '.php'); } return AMP_pathFlip($this->getTargetPath() . '/' . $component_name . '.inc.php'); }
function getPath($image_type = AMP_IMAGE_CLASS_OPTIMIZED) { if (array_search($image_type, $this->getImageClasses()) === FALSE) { return false; } $file_path = AMP_LOCAL_PATH . $this->getURL($image_type); return AMP_pathFlip($file_path); }
function getPath() { return AMP_pathFlip(AMP_LOCAL_PATH . DIRECTORY_SEPARATOR . $this->_document_folder . DIRECTORY_SEPARATOR . $this->getFileName()); }