diff --git a/e107_admin/cache.php b/e107_admin/cache.php index 8914a8b4a..3c1648559 100644 --- a/e107_admin/cache.php +++ b/e107_admin/cache.php @@ -8,10 +8,8 @@ * * Cache Administration Area * - * $Source: /cvs_backup/e107_0.8/e107_admin/cache.php,v $ - * $Revision$ - * $Date$ - * $Author$ + * $URL$ + * $Id$ * */ require_once("../class2.php"); diff --git a/e107_admin/image.php b/e107_admin/image.php index 4e2be8cdb..a2beb2cc0 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -8,10 +8,8 @@ * * Image Administration Area * - * $Source: /cvs_backup/e107_0.8/e107_admin/image.php,v $ - * $Revision$ - * $Date$ - * $Author$ + * $URL$ + * $Id$ * */ require_once("../class2.php"); @@ -39,7 +37,7 @@ $e_sub_cat = 'image'; require_once(e_HANDLER."userclass_class.php"); require_once(e_HANDLER."message_handler.php"); // $frm = new e_form(); //new form handler -$emessage = &eMessage::getInstance(); +$emessage = eMessage::getInstance(); class media_admin extends e_admin_dispatcher { @@ -56,8 +54,8 @@ class media_admin extends e_admin_dispatcher 'path' => null, 'ui' => 'faq_cat_form_ui', 'uipath' => null - ) - ); + ) + ); protected $adminMenu = array( @@ -68,11 +66,11 @@ class media_admin extends e_admin_dispatcher // 'cat/create' => array('caption'=> "Create Category", 'perm' => 'A'), 'main/icons' => array('caption'=> IMALAN_71, 'perm' => 'A'), 'main/settings' => array('caption'=> LAN_PREFS, 'perm' => 'A'), - - 'main/avatar' => array('caption'=> IMALAN_23, 'perm' => 'A') + + 'main/avatar' => array('caption'=> IMALAN_23, 'perm' => 'A') ); - -/* + +/* $var['main']['text'] = IMALAN_7; $var['main']['link'] = e_SELF; @@ -85,38 +83,38 @@ class media_admin extends e_admin_dispatcher $var['editor']['text'] = "Image Manipulation (future release)"; $var['editor']['link'] = e_SELF."?editor";*/ - + protected $adminMenuAliases = array( - 'main/edit' => 'main/list' - ); - + 'main/edit' => 'main/list' + ); + protected $menuTitle = LAN_MEDIAMANAGER; - + } class faq_cat_ui extends e_admin_ui -{ +{ protected $pluginTitle = 'Media Categories'; protected $pluginName = 'core'; protected $table = "core_media_cat"; protected $pid = "media_cat_id"; protected $perPage = 0; //no limit protected $batchDelete = false; - // protected $listQry = "SELECT * FROM #faq_info"; // without any Order or Limit. + // protected $listQry = "SELECT * FROM #faq_info"; // without any Order or Limit. // protected $editQry = "SELECT * FROM #faq_info WHERE faq_info_id = {ID}"; - + protected $fields = array( 'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'), - 'media_cat_id' => array('title'=> LAN_ID, 'type' => 'number', 'width' =>'5%', 'forced'=> TRUE, 'readonly'=>TRUE), - 'media_cat_nick' => array('title'=> "Nickname", 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>TRUE), - 'media_cat_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>TRUE), + 'media_cat_id' => array('title'=> LAN_ID, 'type' => 'number', 'width' =>'5%', 'forced'=> TRUE, 'readonly'=>TRUE), + 'media_cat_nick' => array('title'=> "Nickname", 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>TRUE), + 'media_cat_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'width' => 'auto', 'thclass' => 'left', 'readonly'=>TRUE), 'media_cat_diz' => array('title'=> LAN_DESCRIPTION, 'type' => 'bbarea', 'width' => '30%', 'readParms' => 'expand=...&truncate=50&bb=1','readonly'=>TRUE), // Display name 'media_cat_class' => array('title'=> LAN_VISIBILITY, 'type' => 'userclass', 'width' => 'auto', 'data' => 'int'), // 'options' => array('title'=> LAN_OPTIONS, 'type' => null, 'width' => '10%', 'forced'=>TRUE, 'thclass' => 'center last', 'class' => 'center') - ); - + ); + /** * Get FAQ Category data * @@ -128,14 +126,14 @@ class faq_cat_ui extends e_admin_ui { // TODO get faq category tree } - + } -class faq_cat_form_ui extends e_admin_form_ui +/*class faq_cat_form_ui extends e_admin_form_ui { public function faq_info_parent($curVal,$mode) { - // TODO - catlist combo without current cat ID in write mode, parents only for batch/filter + // TODO - catlist combo without current cat ID in write mode, parents only for batch/filter // Get UI instance $controller = $this->getController(); switch($mode) @@ -143,27 +141,27 @@ class faq_cat_form_ui extends e_admin_form_ui case 'read': return e107::getParser()->toHTML($controller->getFaqCategoryTree($curVal), false, 'TITLE'); break; - + case 'write': return $this->selectbox('faq_info_parent', $controller->getFaqCategoryTree(), $curVal); break; - + case 'filter': case 'batch': return $controller->getFaqCategoryTree(); break; } } -} +}*/ class media_form_ui extends e_admin_form_ui { - + private $cats = array(); - + function init() { $sql = e107::getDb(); @@ -172,30 +170,30 @@ class media_form_ui extends e_admin_form_ui while($row = $sql->db_Fetch()) { $cat = $row['media_cat_nick']; - $this->cats[$cat] = $row['media_cat_title']; + $this->cats[$cat] = $row['media_cat_title']; } asort($this->cats); } - - function media_category($curVal,$mode) // not really necessary since we can use 'dropdown' - but just an example of a custom function. + + function media_category($curVal,$mode) // not really necessary since we can use 'dropdown' - but just an example of a custom function. { - + if($mode == 'read') { return $this->cats[$curVal]; } - + if($mode == 'batch') // Custom Batch List for release_type { - return $this->cats; + return $this->cats; } - + if($mode == 'filter') // Custom Filter List for release_type { - return $this->cats; + return $this->cats; } - - + + $text = ""; foreach($types as $val) diff --git a/thumb.php b/thumb.php index 8763d1c9a..55314ff44 100644 --- a/thumb.php +++ b/thumb.php @@ -15,13 +15,21 @@ /** * @package e107 * @subpackage core + * @author secretr * @version $Id$ * + * @todo cache management - max age, max size, image cache manager (?), cron (?) + * * On-the-fly thumbnail generator */ define('e107_INIT', true); +//error_reporting(E_ALL); +//require_once './e107_handlers/benchmark.php'; +//$bench = new e_benchmark(); +//$bench->start(); + $thumbpage = new e_thumbpage(); if(!$thumbpage->checkSrc()) @@ -30,17 +38,28 @@ if(!$thumbpage->checkSrc()) } $thumbpage->sendImage(); -/** - * Handle on-the-fly created thumbnails - * - * @author secretr - * - */ +// Check your e_LOG folder +//$bench->end()->logResult('thumb.php', $_GET['src'].' - no cache'); +exit; + class e_thumbpage { + /** + * Page request + * @var array + */ protected $_request = array(); + + /** + * @var string image source path (e107 path shortcode) + */ protected $_src = null; + /** + * @var string source path modified/sanitized + */ + protected $_src_path = null; + /** * Constructor - init paths * @todo FIX e107 (new folder structure), simplify all this, e.g. e107::getInstance()->initMinimal($path_to_e107_config); @@ -80,7 +99,14 @@ class e_thumbpage 'CORE_DIRECTORY' ); $sql_info = array(); //compact('mySQLserver', 'mySQLuser', 'mySQLpassword', 'mySQLdefaultdb', 'mySQLprefix', 'mySQLcharset'); - e107::getInstance()->initCore($e107_paths, $self, $sql_info, varset($e107_CONFIG, array())); + //e107::getInstance()->initCore($e107_paths, $self, $sql_info, varset($e107_CONFIG, array())); + $e107 = e107::getInstance(); + $e107->setDirs($e107_paths, varset($e107_CONFIG, array())); + $e107->set_constants(); + $e107->set_paths(); + $e107->file_path = $e107->fix_windows_paths($self)."/"; + $e107->set_base_path(); + $e107->set_urls(); unset($tmp, $self); // parse request @@ -89,8 +115,9 @@ class e_thumbpage function parseRequest() { - parse_str(str_replace('&', '&', e_QUERY), $request); - $this->_request = $request; + //parse_str(str_replace('&', '&', e_QUERY), $this->_request); + parse_str($_SERVER['QUERY_STRING'], $this->_request); + return $this; } function checkSrc() @@ -119,7 +146,8 @@ class e_thumbpage return false; } - $path = $tp->replaceConstants($this->_src); + // should be safe enough + $path = $tp->replaceConstants(str_replace('..', '', $this->_src)); if(is_file($path) && is_readable($path)) { @@ -131,6 +159,7 @@ class e_thumbpage function sendImage() { + //global $bench; if(!$this->_src_path) { return $this; @@ -139,7 +168,7 @@ class e_thumbpage $thumbnfo = pathinfo($this->_src_path); $options = $this->getRequestOptions(); - $cache_str = md5(serialize($options).md5_file($this->_src_path)); + $cache_str = md5(serialize($options).$this->_src_path); $fname = strtolower('Thumb_'.$thumbnfo['filename'].'_'.$cache_str.'.'.$thumbnfo['extension']).'.cache.bin'; if(is_file(e_CACHE_IMAGE.$fname) && is_readable(e_CACHE_IMAGE.$fname)) @@ -152,6 +181,7 @@ class e_thumbpage if (@$_SERVER['HTTP_IF_MODIFIED_SINCE'] && ($thumbnfo['lmodified'] <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) && (isset($_SERVER['HTTP_IF_NONE_MATCH']) && trim($_SERVER['HTTP_IF_NONE_MATCH']) == $thumbnfo['md5s'])) { header('HTTP/1.1 304 Not Modified'); + //$bench->end()->logResult('thumb.php', $_GET['src'].' - 304 not modified'); exit; } @@ -159,6 +189,7 @@ class e_thumbpage $this->sendHeaders($thumbnfo); @readfile(e_CACHE_IMAGE.$fname); + //$bench->end()->logResult('thumb.php', $_GET['src'].' - retrieve cache'); exit; } @@ -189,7 +220,6 @@ class e_thumbpage // show thumb $thumb->show(); - exit; } function getRequestOptions() @@ -243,3 +273,5 @@ class e_thumbpage return null; } } + +?> \ No newline at end of file