@@ -1,6 +1,9 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | class altsysUtils |
| 3 | 3 | { |
| 4 | + /** |
|
| 5 | + * @param string $name |
|
| 6 | + */ |
|
| 4 | 7 | public static function getDelegateCallbackClassNames($name, $doRegist = true) |
| 5 | 8 | { |
| 6 | 9 | $names = array(); |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | { |
| 6 | 6 | $names = array(); |
| 7 | 7 | |
| 8 | - if (! class_exists('XCube_Delegate')) { |
|
| 8 | + if (!class_exists('XCube_Delegate')) { |
|
| 9 | 9 | return $names; |
| 10 | 10 | } |
| 11 | 11 | |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | foreach (array_keys($callbacks) as $priority) { |
| 24 | 24 | foreach (array_keys($callbacks[$priority]) as $idx) { |
| 25 | 25 | $callback = $callbacks[$priority][$idx][0]; |
| 26 | - $_name = (is_array($callback))? ((is_object($callback[0]))? get_class($callback[0]) : $callback[0]) : $callback; |
|
| 26 | + $_name = (is_array($callback)) ? ((is_object($callback[0])) ? get_class($callback[0]) : $callback[0]) : $callback; |
|
| 27 | 27 | $names[$priority] = $_name; |
| 28 | 28 | } |
| 29 | 29 | } |
@@ -54,13 +54,13 @@ discard block |
||
| 54 | 54 | $php523 = version_compare(PHP_VERSION, '5.2.3', '>='); |
| 55 | 55 | } |
| 56 | 56 | if (is_null($encoding)) { |
| 57 | - $encoding = (defined('_CHARSET'))? _CHARSET : ''; |
|
| 57 | + $encoding = (defined('_CHARSET')) ? _CHARSET : ''; |
|
| 58 | 58 | } |
| 59 | 59 | if ($php523) { |
| 60 | 60 | return htmlspecialchars($str, $flags, $encoding, $double_encode); |
| 61 | 61 | } else { |
| 62 | 62 | $ret = htmlspecialchars($str, $flags, $encoding); |
| 63 | - if (! $double_encode) { |
|
| 63 | + if (!$double_encode) { |
|
| 64 | 64 | $ret = str_replace('&amp;', '&', $ret); |
| 65 | 65 | } |
| 66 | 66 | return $ret; |
@@ -35,6 +35,9 @@ |
||
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | |
| 38 | + /** |
|
| 39 | + * @param string $resource |
|
| 40 | + */ |
|
| 38 | 41 | public function read($resource, $mydirname, $mytrustdirname = null, $read_once = true) |
| 39 | 42 | { |
| 40 | 43 | $d3file = XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/mytrustdirname.php' ; |
@@ -3,102 +3,102 @@ discard block |
||
| 3 | 3 | class D3LanguageManager |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | - public $default_language = 'english' ; |
|
| 7 | - public $language = 'english' ; |
|
| 8 | - public $salt ; |
|
| 9 | - public $cache_path ; |
|
| 10 | - public $cache_prefix = 'lang' ; |
|
| 11 | - public $my_language = false ; |
|
| 6 | + public $default_language = 'english'; |
|
| 7 | + public $language = 'english'; |
|
| 8 | + public $salt; |
|
| 9 | + public $cache_path; |
|
| 10 | + public $cache_prefix = 'lang'; |
|
| 11 | + public $my_language = false; |
|
| 12 | 12 | |
| 13 | 13 | |
| 14 | 14 | //HACK by domifara |
| 15 | 15 | //public function D3LanguageManager() |
| 16 | 16 | public function __construct() |
| 17 | 17 | { |
| 18 | - $this->language = preg_replace('/[^0-9a-zA-Z_-]/', '', @$GLOBALS['xoopsConfig']['language']) ; |
|
| 19 | - $this->salt = substr(md5(XOOPS_ROOT_PATH . XOOPS_DB_USER . XOOPS_DB_PREFIX), 0, 6) ; |
|
| 20 | - $this->cache_path = XOOPS_TRUST_PATH.'/cache' ; |
|
| 18 | + $this->language = preg_replace('/[^0-9a-zA-Z_-]/', '', @$GLOBALS['xoopsConfig']['language']); |
|
| 19 | + $this->salt = substr(md5(XOOPS_ROOT_PATH.XOOPS_DB_USER.XOOPS_DB_PREFIX), 0, 6); |
|
| 20 | + $this->cache_path = XOOPS_TRUST_PATH.'/cache'; |
|
| 21 | 21 | |
| 22 | 22 | if (defined('ALTSYS_MYLANGUAGE_ROOT_PATH') && file_exists(ALTSYS_MYLANGUAGE_ROOT_PATH)) { |
| 23 | - $this->my_language = ALTSYS_MYLANGUAGE_ROOT_PATH ; |
|
| 23 | + $this->my_language = ALTSYS_MYLANGUAGE_ROOT_PATH; |
|
| 24 | 24 | } |
| 25 | 25 | } |
| 26 | 26 | //HACK by domifara for php5.3+ |
| 27 | 27 | //function &getInstance( $conn = null ) |
| 28 | 28 | public static function &getInstance($conn = null) |
| 29 | 29 | { |
| 30 | - static $instance ; |
|
| 31 | - if (! isset($instance)) { |
|
| 32 | - $instance = new D3LanguageManager() ; |
|
| 30 | + static $instance; |
|
| 31 | + if (!isset($instance)) { |
|
| 32 | + $instance = new D3LanguageManager(); |
|
| 33 | 33 | } |
| 34 | - return $instance ; |
|
| 34 | + return $instance; |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | |
| 38 | 38 | public function read($resource, $mydirname, $mytrustdirname = null, $read_once = true) |
| 39 | 39 | { |
| 40 | - $d3file = XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/mytrustdirname.php' ; |
|
| 40 | + $d3file = XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/mytrustdirname.php'; |
|
| 41 | 41 | |
| 42 | 42 | if (empty($mytrustdirname) && file_exists($d3file)) { |
| 43 | - require $d3file ; |
|
| 43 | + require $d3file; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | if (empty($this->language)) { |
| 47 | - $this->language = preg_replace('/[^0-9a-zA-Z_-]/', '', @$GLOBALS['xoopsConfig']['language']) ; |
|
| 47 | + $this->language = preg_replace('/[^0-9a-zA-Z_-]/', '', @$GLOBALS['xoopsConfig']['language']); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - $cache_file = $this->getCacheFileName($resource, $mydirname) ; |
|
| 51 | - $root_file = XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/language/'.$this->language.'/'.$resource ; |
|
| 50 | + $cache_file = $this->getCacheFileName($resource, $mydirname); |
|
| 51 | + $root_file = XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/language/'.$this->language.'/'.$resource; |
|
| 52 | 52 | |
| 53 | 53 | // language overriding by XOOPS_ROOT_PATH/my_language |
| 54 | 54 | if ($this->my_language) { |
| 55 | - $mylang_file = $this->my_language.'/modules/'.$mydirname.'/'.$this->language.'/'.$resource ; |
|
| 55 | + $mylang_file = $this->my_language.'/modules/'.$mydirname.'/'.$this->language.'/'.$resource; |
|
| 56 | 56 | if (file_exists($mylang_file)) { |
| 57 | - require_once $mylang_file ; |
|
| 57 | + require_once $mylang_file; |
|
| 58 | 58 | } |
| 59 | - $original_error_level = error_reporting() ; |
|
| 60 | - error_reporting($original_error_level & ~ E_NOTICE) ; |
|
| 59 | + $original_error_level = error_reporting(); |
|
| 60 | + error_reporting($original_error_level & ~ E_NOTICE); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | if (empty($mytrustdirname)) { |
| 64 | 64 | // conventional module |
| 65 | - $default_file = XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/language/'.$this->default_language.'/'.$resource ; |
|
| 65 | + $default_file = XOOPS_ROOT_PATH.'/modules/'.$mydirname.'/language/'.$this->default_language.'/'.$resource; |
|
| 66 | 66 | |
| 67 | 67 | if (file_exists($cache_file)) { |
| 68 | - require_once $cache_file ; |
|
| 68 | + require_once $cache_file; |
|
| 69 | 69 | } elseif (file_exists($root_file)) { |
| 70 | - require_once $root_file ; |
|
| 70 | + require_once $root_file; |
|
| 71 | 71 | } elseif (file_exists($default_file)) { |
| 72 | 72 | // fall back english |
| 73 | - require_once $default_file ; |
|
| 73 | + require_once $default_file; |
|
| 74 | 74 | } |
| 75 | 75 | } else { |
| 76 | 76 | // D3 modules |
| 77 | - $trust_file = XOOPS_TRUST_PATH.'/modules/'.$mytrustdirname.'/language/'.$this->language.'/'.$resource ; |
|
| 78 | - $default_file = XOOPS_TRUST_PATH.'/modules/'.$mytrustdirname.'/language/'.$this->default_language.'/'.$resource ; |
|
| 77 | + $trust_file = XOOPS_TRUST_PATH.'/modules/'.$mytrustdirname.'/language/'.$this->language.'/'.$resource; |
|
| 78 | + $default_file = XOOPS_TRUST_PATH.'/modules/'.$mytrustdirname.'/language/'.$this->default_language.'/'.$resource; |
|
| 79 | 79 | |
| 80 | 80 | if (file_exists($cache_file)) { |
| 81 | - require_once $cache_file ; |
|
| 81 | + require_once $cache_file; |
|
| 82 | 82 | } elseif (file_exists($root_file)) { |
| 83 | - require_once $root_file ; |
|
| 83 | + require_once $root_file; |
|
| 84 | 84 | } elseif (file_exists($trust_file)) { |
| 85 | 85 | if ($read_once) { |
| 86 | - require_once $trust_file ; |
|
| 86 | + require_once $trust_file; |
|
| 87 | 87 | } else { |
| 88 | - require $trust_file ; |
|
| 88 | + require $trust_file; |
|
| 89 | 89 | } |
| 90 | 90 | } elseif (file_exists($default_file)) { |
| 91 | 91 | // fall back english |
| 92 | 92 | if ($read_once) { |
| 93 | - require_once $default_file ; |
|
| 93 | + require_once $default_file; |
|
| 94 | 94 | } else { |
| 95 | - require $default_file ; |
|
| 95 | + require $default_file; |
|
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | if ($this->my_language) { |
| 101 | - error_reporting($original_error_level) ; |
|
| 101 | + error_reporting($original_error_level); |
|
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
@@ -106,8 +106,8 @@ discard block |
||
| 106 | 106 | public function getCacheFileName($resource, $mydirname, $language = null) |
| 107 | 107 | { |
| 108 | 108 | if (empty($language)) { |
| 109 | - $language = $this->language ; |
|
| 109 | + $language = $this->language; |
|
| 110 | 110 | } |
| 111 | - return $this->cache_path . '/' . $this->cache_prefix . '_' . $this->salt . '_' . $mydirname . '_' . $language . '_' . $resource ; |
|
| 111 | + return $this->cache_path.'/'.$this->cache_prefix.'_'.$this->salt.'_'.$mydirname.'_'.$language.'_'.$resource; |
|
| 112 | 112 | } |
| 113 | 113 | } |
@@ -261,6 +261,9 @@ |
||
| 261 | 261 | </form>\n" ; |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | + /** |
|
| 265 | + * @param string $name |
|
| 266 | + */ |
|
| 264 | 267 | public function get_select($name, $options, $current_value) |
| 265 | 268 | { |
| 266 | 269 | $ret = "<select name='".htmlspecialchars($name, ENT_QUOTES)."'>\n" ; |
@@ -3,40 +3,40 @@ discard block |
||
| 3 | 3 | class d3utilities |
| 4 | 4 | { |
| 5 | 5 | |
| 6 | - public $dirname = '' ; // directory name under xoops_trust_path |
|
| 7 | - public $mydirname = '' ; // each directory name under xoops_root_path |
|
| 8 | - public $mid = 0 ; // id of each module instance |
|
| 9 | - public $table = '' ; // table with prefix and dirname |
|
| 10 | - public $primary_key = '' ; // column for primary_key |
|
| 11 | - public $cols = array() ; // settings of each columns |
|
| 12 | - public $form_mode = 'new' ; // 'new','edit' are available |
|
| 13 | - public $page_name = '' ; // controller's name eg) page=(controller) in URI |
|
| 14 | - public $action_base_hiddens = array() ; |
|
| 6 | + public $dirname = ''; // directory name under xoops_trust_path |
|
| 7 | + public $mydirname = ''; // each directory name under xoops_root_path |
|
| 8 | + public $mid = 0; // id of each module instance |
|
| 9 | + public $table = ''; // table with prefix and dirname |
|
| 10 | + public $primary_key = ''; // column for primary_key |
|
| 11 | + public $cols = array(); // settings of each columns |
|
| 12 | + public $form_mode = 'new'; // 'new','edit' are available |
|
| 13 | + public $page_name = ''; // controller's name eg) page=(controller) in URI |
|
| 14 | + public $action_base_hiddens = array(); |
|
| 15 | 15 | |
| 16 | 16 | //HACK by domifara |
| 17 | 17 | // public function D3Utilities( $mydirname , $table_body , $primary_key , $cols , $page_name , $action_base_hiddens ) |
| 18 | 18 | public function __construct($mydirname, $table_body, $primary_key, $cols, $page_name, $action_base_hiddens) |
| 19 | 19 | { |
| 20 | - $db =& XoopsDatabaseFactory::getDatabaseConnection() ; |
|
| 21 | - |
|
| 22 | - $this->dirname = basename(dirname(dirname(__FILE__))) ; |
|
| 23 | - $this->mydirname = $mydirname ; |
|
| 24 | - $this->table = $db->prefix($mydirname ? $mydirname . '_' . $table_body : $table_body) ; |
|
| 25 | - $this->primary_key = $primary_key ; |
|
| 26 | - $this->cols = $cols ; |
|
| 27 | - $module_handler =& xoops_gethandler('module') ; |
|
| 28 | - $module =& $module_handler->getByDirname($this->mydirname) ; |
|
| 29 | - if (! empty($module)) { |
|
| 30 | - $this->mid = intval($module->getVar('mid')) ; |
|
| 20 | + $db = & XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 21 | + |
|
| 22 | + $this->dirname = basename(dirname(dirname(__FILE__))); |
|
| 23 | + $this->mydirname = $mydirname; |
|
| 24 | + $this->table = $db->prefix($mydirname ? $mydirname.'_'.$table_body : $table_body); |
|
| 25 | + $this->primary_key = $primary_key; |
|
| 26 | + $this->cols = $cols; |
|
| 27 | + $module_handler = & xoops_gethandler('module'); |
|
| 28 | + $module = & $module_handler->getByDirname($this->mydirname); |
|
| 29 | + if (!empty($module)) { |
|
| 30 | + $this->mid = intval($module->getVar('mid')); |
|
| 31 | 31 | } |
| 32 | - $this->page_name = $page_name ; |
|
| 33 | - $this->action_base_hiddens = $action_base_hiddens ; |
|
| 32 | + $this->page_name = $page_name; |
|
| 33 | + $this->action_base_hiddens = $action_base_hiddens; |
|
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | public function get_language_constant($name) |
| 38 | 38 | { |
| 39 | - return constant(strtoupper('_MD_A_' . $this->dirname . '_' . $this->page_name . '_' . $name)) ; |
|
| 39 | + return constant(strtoupper('_MD_A_'.$this->dirname.'_'.$this->page_name.'_'.$name)); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | |
@@ -45,23 +45,23 @@ discard block |
||
| 45 | 45 | switch ($col['type']) { |
| 46 | 46 | case 'text' : |
| 47 | 47 | case 'blob' : |
| 48 | - $length = empty($col['length']) ? 65535 : intval($col['length']) ; |
|
| 49 | - return "`{$col['name']}`='".addslashes(xoops_substr($value, 0, $length))."'" ; |
|
| 48 | + $length = empty($col['length']) ? 65535 : intval($col['length']); |
|
| 49 | + return "`{$col['name']}`='".addslashes(xoops_substr($value, 0, $length))."'"; |
|
| 50 | 50 | case 'char' : |
| 51 | 51 | case 'varchar' : |
| 52 | 52 | case 'string' : |
| 53 | - $length = empty($col['length']) ? 255 : intval($col['length']) ; |
|
| 54 | - return "`{$col['name']}`='".addslashes(xoops_substr($value, 0, $length))."'" ; |
|
| 53 | + $length = empty($col['length']) ? 255 : intval($col['length']); |
|
| 54 | + return "`{$col['name']}`='".addslashes(xoops_substr($value, 0, $length))."'"; |
|
| 55 | 55 | case 'int' : |
| 56 | 56 | case 'integer' : |
| 57 | - $value = intval($value) ; |
|
| 58 | - if (! empty($col['max'])) { |
|
| 59 | - $value = min($value, intval($col['max'])) ; |
|
| 57 | + $value = intval($value); |
|
| 58 | + if (!empty($col['max'])) { |
|
| 59 | + $value = min($value, intval($col['max'])); |
|
| 60 | 60 | } |
| 61 | - if (! empty($col['min'])) { |
|
| 62 | - $value = max($value, intval($col['min'])) ; |
|
| 61 | + if (!empty($col['min'])) { |
|
| 62 | + $value = max($value, intval($col['min'])); |
|
| 63 | 63 | } |
| 64 | - return "`{$col['name']}`=$value" ; |
|
| 64 | + return "`{$col['name']}`=$value"; |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
@@ -69,29 +69,29 @@ discard block |
||
| 69 | 69 | // single update or insert |
| 70 | 70 | public function insert() |
| 71 | 71 | { |
| 72 | - $db =& XoopsDatabaseFactory::getDatabaseConnection() ; |
|
| 72 | + $db = & XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 73 | 73 | |
| 74 | - $id = $this->init_default_values() ; |
|
| 74 | + $id = $this->init_default_values(); |
|
| 75 | 75 | |
| 76 | - $set4sql = '' ; |
|
| 76 | + $set4sql = ''; |
|
| 77 | 77 | foreach ($this->cols as $col) { |
| 78 | 78 | if (empty($col['edit_edit'])) { |
| 79 | - continue ; |
|
| 79 | + continue; |
|
| 80 | 80 | } |
| 81 | 81 | if ($col['name'] == $this->primary_key) { |
| 82 | - continue ; |
|
| 82 | + continue; |
|
| 83 | 83 | } |
| 84 | - $set4sql .= $this->get_set4sql(@$_POST[ $col['name'] ], $col) . ',' ; |
|
| 84 | + $set4sql .= $this->get_set4sql(@$_POST[$col['name']], $col).','; |
|
| 85 | 85 | } |
| 86 | - if (! empty($set4sql)) { |
|
| 86 | + if (!empty($set4sql)) { |
|
| 87 | 87 | if ($id > 0) { |
| 88 | 88 | // UPDATE |
| 89 | - $db->queryF("UPDATE $this->table SET ".substr($set4sql, 0, -1)." WHERE $this->primary_key='".addslashes($id)."'") ; |
|
| 90 | - return array( $id , 'update' ) ; |
|
| 89 | + $db->queryF("UPDATE $this->table SET ".substr($set4sql, 0, -1)." WHERE $this->primary_key='".addslashes($id)."'"); |
|
| 90 | + return array($id, 'update'); |
|
| 91 | 91 | } else { |
| 92 | 92 | // INSERT |
| 93 | - $db->queryF("INSERT INTO $this->table SET ".substr($set4sql, 0, -1)) ; |
|
| 94 | - return array( $db->getInsertId() , 'insert' ) ; |
|
| 93 | + $db->queryF("INSERT INTO $this->table SET ".substr($set4sql, 0, -1)); |
|
| 94 | + return array($db->getInsertId(), 'insert'); |
|
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | } |
@@ -100,156 +100,156 @@ discard block |
||
| 100 | 100 | // multiple update |
| 101 | 101 | public function update() |
| 102 | 102 | { |
| 103 | - $db =& XoopsDatabaseFactory::getDatabaseConnection() ; |
|
| 103 | + $db = & XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 104 | 104 | |
| 105 | 105 | // search appropriate column for getting primary_key |
| 106 | 106 | foreach ($this->cols as $col) { |
| 107 | - if (in_array(@$col['list_edit'], array( 'text', 'textarea', 'hidden' ))) { |
|
| 108 | - $column4key = $col['name'] ; |
|
| 109 | - break ; |
|
| 107 | + if (in_array(@$col['list_edit'], array('text', 'textarea', 'hidden'))) { |
|
| 108 | + $column4key = $col['name']; |
|
| 109 | + break; |
|
| 110 | 110 | } |
| 111 | 111 | } |
| 112 | 112 | if (empty($column4key)) { |
| 113 | - $column4key = $this->cols[0]['name'] ; |
|
| 113 | + $column4key = $this->cols[0]['name']; |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $ret = array() ; |
|
| 116 | + $ret = array(); |
|
| 117 | 117 | foreach (array_keys($_POST[$column4key]) as $id) { |
| 118 | - $id = intval($id) ; // primary_key should be 'integer' |
|
| 119 | - $set4sql = '' ; |
|
| 118 | + $id = intval($id); // primary_key should be 'integer' |
|
| 119 | + $set4sql = ''; |
|
| 120 | 120 | foreach ($this->cols as $col) { |
| 121 | 121 | if (empty($col['list_edit'])) { |
| 122 | - continue ; |
|
| 122 | + continue; |
|
| 123 | 123 | } |
| 124 | 124 | if ($col['name'] == $this->primary_key) { |
| 125 | - continue ; |
|
| 125 | + continue; |
|
| 126 | 126 | } |
| 127 | - $set4sql .= $this->get_set4sql(@$_POST[ $col['name'] ][$id], $col) . ',' ; |
|
| 127 | + $set4sql .= $this->get_set4sql(@$_POST[$col['name']][$id], $col).','; |
|
| 128 | 128 | } |
| 129 | - if (! empty($set4sql)) { |
|
| 130 | - $result = $db->query("SELECT * FROM $this->table WHERE $this->primary_key=$id") ; |
|
| 129 | + if (!empty($set4sql)) { |
|
| 130 | + $result = $db->query("SELECT * FROM $this->table WHERE $this->primary_key=$id"); |
|
| 131 | 131 | if ($db->getRowsNum($result) == 1) { |
| 132 | - $db->queryF("UPDATE $this->table SET ".substr($set4sql, 0, -1)." WHERE $this->primary_key=$id") ; |
|
| 132 | + $db->queryF("UPDATE $this->table SET ".substr($set4sql, 0, -1)." WHERE $this->primary_key=$id"); |
|
| 133 | 133 | if ($db->getAffectedRows() == 1) { |
| 134 | - $ret[ $id ] = $db->fetchArray($result) ; |
|
| 134 | + $ret[$id] = $db->fetchArray($result); |
|
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | } |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - return $ret ; |
|
| 140 | + return $ret; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | |
| 144 | 144 | public function delete($delete_comments = false, $delete_notifications = false) |
| 145 | 145 | { |
| 146 | - $db =& XoopsDatabaseFactory::getDatabaseConnection() ; |
|
| 146 | + $db = & XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 147 | 147 | |
| 148 | - $ret = array() ; |
|
| 148 | + $ret = array(); |
|
| 149 | 149 | foreach (array_keys($_POST['admin_main_checkboxes']) as $id) { |
| 150 | - $id = intval($id) ; // primary_key should be 'integer' |
|
| 151 | - $result = $db->query("SELECT * FROM $this->table WHERE $this->primary_key=$id") ; |
|
| 150 | + $id = intval($id); // primary_key should be 'integer' |
|
| 151 | + $result = $db->query("SELECT * FROM $this->table WHERE $this->primary_key=$id"); |
|
| 152 | 152 | if ($db->getRowsNum($result) == 1) { |
| 153 | - $ret[ $id ] = $db->fetchArray($result) ; |
|
| 153 | + $ret[$id] = $db->fetchArray($result); |
|
| 154 | 154 | |
| 155 | - $db->queryF("DELETE FROM $this->table WHERE $this->primary_key=$id") ; |
|
| 155 | + $db->queryF("DELETE FROM $this->table WHERE $this->primary_key=$id"); |
|
| 156 | 156 | if ($delete_comments) { |
| 157 | 157 | // remove comments |
| 158 | - $db->queryF("DELETE FROM ".$db->prefix("xoopscomments")." WHERE com_modid=$this->mid AND com_itemid=$id") ; |
|
| 158 | + $db->queryF("DELETE FROM ".$db->prefix("xoopscomments")." WHERE com_modid=$this->mid AND com_itemid=$id"); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | if ($delete_notifications) { |
| 162 | 162 | // remove notifications |
| 163 | - $db->queryF("DELETE FROM ".$db->prefix("xoopsnotifications")." WHERE not_modid=$this->mid AND not_itemid=$id") ; |
|
| 163 | + $db->queryF("DELETE FROM ".$db->prefix("xoopsnotifications")." WHERE not_modid=$this->mid AND not_itemid=$id"); |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - return $ret ; |
|
| 168 | + return $ret; |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | |
| 172 | 172 | public function init_default_values() |
| 173 | 173 | { |
| 174 | - $db =& XoopsDatabaseFactory::getDatabaseConnection() ; |
|
| 174 | + $db = & XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 175 | 175 | |
| 176 | 176 | if (@$_GET['id']) { |
| 177 | - $id = intval($_GET['id']) ; |
|
| 178 | - $rs = $db->query("SELECT * FROM $this->table WHERE $this->primary_key=$id") ; |
|
| 177 | + $id = intval($_GET['id']); |
|
| 178 | + $rs = $db->query("SELECT * FROM $this->table WHERE $this->primary_key=$id"); |
|
| 179 | 179 | if ($db->getRowsNum($rs) == 1) { |
| 180 | - $row = $db->fetchArray($rs) ; |
|
| 180 | + $row = $db->fetchArray($rs); |
|
| 181 | 181 | foreach (array_keys($this->cols) as $key) { |
| 182 | 182 | if (empty($this->cols[$key]['edit_show'])) { |
| 183 | - continue ; |
|
| 183 | + continue; |
|
| 184 | 184 | } |
| 185 | - $this->cols[$key]['default_value'] = $row[ $this->cols[$key]['name'] ] ; |
|
| 185 | + $this->cols[$key]['default_value'] = $row[$this->cols[$key]['name']]; |
|
| 186 | 186 | } |
| 187 | - $this->form_mode = 'edit' ; |
|
| 188 | - return $id ; |
|
| 187 | + $this->form_mode = 'edit'; |
|
| 188 | + return $id; |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - $this->form_mode = 'new' ; |
|
| 193 | - return 0 ; |
|
| 192 | + $this->form_mode = 'new'; |
|
| 193 | + return 0; |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | |
| 197 | 197 | public function get_view_edit() |
| 198 | 198 | { |
| 199 | - $id = $this->init_default_values() ; |
|
| 199 | + $id = $this->init_default_values(); |
|
| 200 | 200 | |
| 201 | - $lines = array() ; |
|
| 201 | + $lines = array(); |
|
| 202 | 202 | foreach ($this->cols as $col) { |
| 203 | 203 | if (empty($col['edit_show'])) { |
| 204 | - continue ; |
|
| 204 | + continue; |
|
| 205 | 205 | } |
| 206 | - if (! isset($col['default_value'])) { |
|
| 206 | + if (!isset($col['default_value'])) { |
|
| 207 | 207 | switch ($col['type']) { |
| 208 | 208 | case 'int' : |
| 209 | 209 | case 'integer' : |
| 210 | - $col['default_value'] = 0 ; |
|
| 211 | - break ; |
|
| 210 | + $col['default_value'] = 0; |
|
| 211 | + break; |
|
| 212 | 212 | default : |
| 213 | - $col['default_value'] = '' ; |
|
| 214 | - break ; |
|
| 213 | + $col['default_value'] = ''; |
|
| 214 | + break; |
|
| 215 | 215 | } |
| 216 | 216 | } |
| 217 | 217 | switch ($col['edit_edit']) { |
| 218 | 218 | case 'checkbox' : |
| 219 | - $checked = empty($col['default_value']) ? '' : "checked='checked'" ; |
|
| 220 | - $value = empty($col['checkbox_value']) ? 1 : htmlspecialchars($col['checkbox_value'], ENT_QUOTES) ; |
|
| 219 | + $checked = empty($col['default_value']) ? '' : "checked='checked'"; |
|
| 220 | + $value = empty($col['checkbox_value']) ? 1 : htmlspecialchars($col['checkbox_value'], ENT_QUOTES); |
|
| 221 | 221 | |
| 222 | - $lines[ $col['name'] ] = "<input type='checkbox' name='{$col['name']}' value='$value' $checked />" ; |
|
| 223 | - break ; |
|
| 222 | + $lines[$col['name']] = "<input type='checkbox' name='{$col['name']}' value='$value' $checked />"; |
|
| 223 | + break; |
|
| 224 | 224 | case 'text' : |
| 225 | 225 | default : |
| 226 | - $size = empty($col['edit_size']) ? 32 : intval($col['edit_size']) ; |
|
| 227 | - $length = empty($col['length']) ? 255 : intval($col['length']) ; |
|
| 228 | - $lines[ $col['name'] ] = "<input type='text' name='{$col['name']}' size='$size' maxlength='$length' value='".htmlspecialchars($col['default_value'], ENT_QUOTES)."' />" ; |
|
| 229 | - break ; |
|
| 226 | + $size = empty($col['edit_size']) ? 32 : intval($col['edit_size']); |
|
| 227 | + $length = empty($col['length']) ? 255 : intval($col['length']); |
|
| 228 | + $lines[$col['name']] = "<input type='text' name='{$col['name']}' size='$size' maxlength='$length' value='".htmlspecialchars($col['default_value'], ENT_QUOTES)."' />"; |
|
| 229 | + break; |
|
| 230 | 230 | case false : |
| 231 | - $lines[ $col['name'] ] = htmlspecialchars($col['default_value'], ENT_QUOTES) ; |
|
| 232 | - break ; |
|
| 231 | + $lines[$col['name']] = htmlspecialchars($col['default_value'], ENT_QUOTES); |
|
| 232 | + break; |
|
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 | |
| 236 | - return array( $id , $lines ) ; |
|
| 236 | + return array($id, $lines); |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | |
| 240 | 240 | public function get_control_form($controllers) |
| 241 | 241 | { |
| 242 | - $hiddens = '' ; |
|
| 242 | + $hiddens = ''; |
|
| 243 | 243 | foreach ($this->action_base_hiddens as $key => $val) { |
| 244 | - $key4disp = htmlspecialchars($key, ENT_QUOTES) ; |
|
| 245 | - $val4disp = htmlspecialchars($val, ENT_QUOTES) ; |
|
| 246 | - $hiddens .= "<input type='hidden' name='$key4disp' value='$val4disp' />\n" ; |
|
| 244 | + $key4disp = htmlspecialchars($key, ENT_QUOTES); |
|
| 245 | + $val4disp = htmlspecialchars($val, ENT_QUOTES); |
|
| 246 | + $hiddens .= "<input type='hidden' name='$key4disp' value='$val4disp' />\n"; |
|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - $controllers_html = '' ; |
|
| 249 | + $controllers_html = ''; |
|
| 250 | 250 | foreach ($controllers as $type => $body) { |
| 251 | 251 | if ($type == 'num') { |
| 252 | - $controllers_html .= $this->get_select('num', $body, $GLOBALS['num']) ; |
|
| 252 | + $controllers_html .= $this->get_select('num', $body, $GLOBALS['num']); |
|
| 253 | 253 | } |
| 254 | 254 | } |
| 255 | 255 | |
@@ -263,13 +263,13 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | public function get_select($name, $options, $current_value) |
| 265 | 265 | { |
| 266 | - $ret = "<select name='".htmlspecialchars($name, ENT_QUOTES)."'>\n" ; |
|
| 266 | + $ret = "<select name='".htmlspecialchars($name, ENT_QUOTES)."'>\n"; |
|
| 267 | 267 | foreach ($options as $key => $val) { |
| 268 | - $selected = $val == $current_value ? "selected='selected'" : "" ; |
|
| 269 | - $ret .= "<option value='".htmlspecialchars($key, ENT_QUOTES)."' $selected>".htmlspecialchars($val, ENT_QUOTES)."</option>\n" ; |
|
| 268 | + $selected = $val == $current_value ? "selected='selected'" : ""; |
|
| 269 | + $ret .= "<option value='".htmlspecialchars($key, ENT_QUOTES)."' $selected>".htmlspecialchars($val, ENT_QUOTES)."</option>\n"; |
|
| 270 | 270 | } |
| 271 | - $ret .= "</select>\n" ; |
|
| 271 | + $ret .= "</select>\n"; |
|
| 272 | 272 | |
| 273 | - return $ret ; |
|
| 273 | + return $ret; |
|
| 274 | 274 | } |
| 275 | 275 | } |
@@ -488,6 +488,12 @@ discard block |
||
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | |
| 491 | + /** |
|
| 492 | + * @param integer $bside |
|
| 493 | + * @param integer $bweight |
|
| 494 | + * @param integer $bvisible |
|
| 495 | + * @param integer $bcachetime |
|
| 496 | + */ |
|
| 491 | 497 | public function update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $options=array()) |
| 492 | 498 | { |
| 493 | 499 | global $xoopsConfig; |
@@ -646,6 +652,9 @@ discard block |
||
| 646 | 652 | } |
| 647 | 653 | |
| 648 | 654 | |
| 655 | + /** |
|
| 656 | + * @param integer $bid |
|
| 657 | + */ |
|
| 649 | 658 | public function do_delete($bid) |
| 650 | 659 | { |
| 651 | 660 | $bid = intval($bid) ; |
@@ -671,6 +680,9 @@ discard block |
||
| 671 | 680 | } |
| 672 | 681 | |
| 673 | 682 | //HACK add by domifara |
| 683 | +/** |
|
| 684 | + * @param integer $bid |
|
| 685 | + */ |
|
| 674 | 686 | public function do_deleteBlockReadGroupPerm($bid) |
| 675 | 687 | { |
| 676 | 688 | $bid = intval($bid) ; |
@@ -679,6 +691,9 @@ discard block |
||
| 679 | 691 | $this->db->query($sql) ; |
| 680 | 692 | } |
| 681 | 693 | |
| 694 | + /** |
|
| 695 | + * @param integer $bid |
|
| 696 | + */ |
|
| 682 | 697 | public function form_delete($bid) |
| 683 | 698 | { |
| 684 | 699 | $bid = intval($bid) ; |
@@ -708,6 +723,9 @@ discard block |
||
| 708 | 723 | } |
| 709 | 724 | |
| 710 | 725 | |
| 726 | + /** |
|
| 727 | + * @param integer $bid |
|
| 728 | + */ |
|
| 711 | 729 | public function do_clone($bid) |
| 712 | 730 | { |
| 713 | 731 | $bid = intval($bid) ; |
@@ -786,6 +804,9 @@ discard block |
||
| 786 | 804 | } |
| 787 | 805 | |
| 788 | 806 | |
| 807 | + /** |
|
| 808 | + * @param integer $bid |
|
| 809 | + */ |
|
| 789 | 810 | public function do_edit($bid) |
| 790 | 811 | { |
| 791 | 812 | $bid = intval($bid) ; |
@@ -829,6 +850,9 @@ discard block |
||
| 829 | 850 | } |
| 830 | 851 | |
| 831 | 852 | |
| 853 | + /** |
|
| 854 | + * @param integer $bid |
|
| 855 | + */ |
|
| 832 | 856 | public function form_edit($bid, $mode = 'edit') |
| 833 | 857 | { |
| 834 | 858 | $bid = intval($bid) ; |
@@ -308,30 +308,30 @@ discard block |
||
| 308 | 308 | $scoln = "disabled"; |
| 309 | 309 | } else { |
| 310 | 310 | switch ($side) { |
| 311 | - case XOOPS_SIDEBLOCK_LEFT : |
|
| 312 | - $ssel0 = " checked='checked'"; |
|
| 313 | - $scol0 = "selected"; |
|
| 314 | - break ; |
|
| 315 | - case XOOPS_SIDEBLOCK_RIGHT : |
|
| 316 | - $ssel1 = " checked='checked'"; |
|
| 317 | - $scol1 = "selected"; |
|
| 318 | - break ; |
|
| 319 | - case XOOPS_CENTERBLOCK_LEFT : |
|
| 320 | - $ssel2 = " checked='checked'"; |
|
| 321 | - $scol2 = "selected"; |
|
| 322 | - break ; |
|
| 323 | - case XOOPS_CENTERBLOCK_RIGHT : |
|
| 324 | - $ssel4 = " checked='checked'"; |
|
| 325 | - $scol4 = "selected"; |
|
| 326 | - break ; |
|
| 327 | - case XOOPS_CENTERBLOCK_CENTER : |
|
| 328 | - $ssel3 = " checked='checked'"; |
|
| 329 | - $scol3 = "selected"; |
|
| 330 | - break ; |
|
| 331 | - default : |
|
| 332 | - $value4extra_side = $side ; |
|
| 333 | - $stextbox = "selected" ; |
|
| 334 | - break ; |
|
| 311 | + case XOOPS_SIDEBLOCK_LEFT : |
|
| 312 | + $ssel0 = " checked='checked'"; |
|
| 313 | + $scol0 = "selected"; |
|
| 314 | + break ; |
|
| 315 | + case XOOPS_SIDEBLOCK_RIGHT : |
|
| 316 | + $ssel1 = " checked='checked'"; |
|
| 317 | + $scol1 = "selected"; |
|
| 318 | + break ; |
|
| 319 | + case XOOPS_CENTERBLOCK_LEFT : |
|
| 320 | + $ssel2 = " checked='checked'"; |
|
| 321 | + $scol2 = "selected"; |
|
| 322 | + break ; |
|
| 323 | + case XOOPS_CENTERBLOCK_RIGHT : |
|
| 324 | + $ssel4 = " checked='checked'"; |
|
| 325 | + $scol4 = "selected"; |
|
| 326 | + break ; |
|
| 327 | + case XOOPS_CENTERBLOCK_CENTER : |
|
| 328 | + $ssel3 = " checked='checked'"; |
|
| 329 | + $scol3 = "selected"; |
|
| 330 | + break ; |
|
| 331 | + default : |
|
| 332 | + $value4extra_side = $side ; |
|
| 333 | + $stextbox = "selected" ; |
|
| 334 | + break ; |
|
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | |
@@ -851,31 +851,31 @@ discard block |
||
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | switch ($mode) { |
| 854 | - case 'clone' : |
|
| 855 | - $form_title = _MD_A_MYBLOCKSADMIN_CLONEFORM ; |
|
| 856 | - $button_value = _MD_A_MYBLOCKSADMIN_BTN_CLONE ; |
|
| 857 | - $next_op = 'clone_ok' ; |
|
| 858 | - // breadcrumbs |
|
| 859 | - $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
| 860 | - $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_CLONEFORM) ; |
|
| 861 | - break ; |
|
| 862 | - case 'new' : |
|
| 863 | - $form_title = _MD_A_MYBLOCKSADMIN_NEWFORM ; |
|
| 864 | - $button_value = _MD_A_MYBLOCKSADMIN_BTN_NEW ; |
|
| 865 | - $next_op = 'new_ok' ; |
|
| 866 | - // breadcrumbs |
|
| 867 | - $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
| 868 | - $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_NEWFORM) ; |
|
| 869 | - break ; |
|
| 870 | - case 'edit' : |
|
| 871 | - default : |
|
| 872 | - $form_title = _MD_A_MYBLOCKSADMIN_EDITFORM ; |
|
| 873 | - $button_value = _MD_A_MYBLOCKSADMIN_BTN_EDIT ; |
|
| 874 | - $next_op = 'edit_ok' ; |
|
| 875 | - // breadcrumbs |
|
| 876 | - $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
| 877 | - $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_EDITFORM) ; |
|
| 878 | - break ; |
|
| 854 | + case 'clone' : |
|
| 855 | + $form_title = _MD_A_MYBLOCKSADMIN_CLONEFORM ; |
|
| 856 | + $button_value = _MD_A_MYBLOCKSADMIN_BTN_CLONE ; |
|
| 857 | + $next_op = 'clone_ok' ; |
|
| 858 | + // breadcrumbs |
|
| 859 | + $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
| 860 | + $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_CLONEFORM) ; |
|
| 861 | + break ; |
|
| 862 | + case 'new' : |
|
| 863 | + $form_title = _MD_A_MYBLOCKSADMIN_NEWFORM ; |
|
| 864 | + $button_value = _MD_A_MYBLOCKSADMIN_BTN_NEW ; |
|
| 865 | + $next_op = 'new_ok' ; |
|
| 866 | + // breadcrumbs |
|
| 867 | + $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
| 868 | + $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_NEWFORM) ; |
|
| 869 | + break ; |
|
| 870 | + case 'edit' : |
|
| 871 | + default : |
|
| 872 | + $form_title = _MD_A_MYBLOCKSADMIN_EDITFORM ; |
|
| 873 | + $button_value = _MD_A_MYBLOCKSADMIN_BTN_EDIT ; |
|
| 874 | + $next_op = 'edit_ok' ; |
|
| 875 | + // breadcrumbs |
|
| 876 | + $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
| 877 | + $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_EDITFORM) ; |
|
| 878 | + break ; |
|
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | $is_custom = in_array($block->getVar('block_type'), array( 'C', 'E' )) ? true : false ; |
@@ -1051,23 +1051,23 @@ discard block |
||
| 1051 | 1051 | { |
| 1052 | 1052 | $bid = intval(@$_GET['bid']) ; |
| 1053 | 1053 | switch (@$_GET['op']) { |
| 1054 | - case 'clone' : |
|
| 1055 | - $this->form_edit($bid, 'clone') ; |
|
| 1056 | - break ; |
|
| 1057 | - case 'new' : |
|
| 1058 | - case 'edit' : |
|
| 1059 | - $this->form_edit($bid, 'edit') ; |
|
| 1060 | - break ; |
|
| 1061 | - case 'delete' : |
|
| 1062 | - $this->form_delete($bid) ; |
|
| 1063 | - break ; |
|
| 1064 | - case 'list' : |
|
| 1065 | - default : |
|
| 1066 | - // the first form (blocks) |
|
| 1067 | - $this->list_blocks() ; |
|
| 1068 | - // the second form (groups) |
|
| 1069 | - $this->list_groups() ; |
|
| 1070 | - break ; |
|
| 1054 | + case 'clone' : |
|
| 1055 | + $this->form_edit($bid, 'clone') ; |
|
| 1056 | + break ; |
|
| 1057 | + case 'new' : |
|
| 1058 | + case 'edit' : |
|
| 1059 | + $this->form_edit($bid, 'edit') ; |
|
| 1060 | + break ; |
|
| 1061 | + case 'delete' : |
|
| 1062 | + $this->form_delete($bid) ; |
|
| 1063 | + break ; |
|
| 1064 | + case 'list' : |
|
| 1065 | + default : |
|
| 1066 | + // the first form (blocks) |
|
| 1067 | + $this->list_blocks() ; |
|
| 1068 | + // the second form (groups) |
|
| 1069 | + $this->list_groups() ; |
|
| 1070 | + break ; |
|
| 1071 | 1071 | } |
| 1072 | 1072 | } |
| 1073 | 1073 | } |
@@ -4,16 +4,16 @@ discard block |
||
| 4 | 4 | class MyBlocksAdmin |
| 5 | 5 | { |
| 6 | 6 | |
| 7 | - public $db ; |
|
| 8 | - public $lang ; |
|
| 9 | - public $cachetime_options = array() ; |
|
| 10 | - public $ctype_options = array() ; |
|
| 11 | - public $type_options = array() ; |
|
| 12 | - public $target_mid = 0 ; |
|
| 13 | - public $target_dirname = '' ; |
|
| 14 | - public $target_mname = '' ; |
|
| 15 | - public $block_configs = array() ; |
|
| 16 | - public $preview_request = array() ; |
|
| 7 | + public $db; |
|
| 8 | + public $lang; |
|
| 9 | + public $cachetime_options = array(); |
|
| 10 | + public $ctype_options = array(); |
|
| 11 | + public $type_options = array(); |
|
| 12 | + public $target_mid = 0; |
|
| 13 | + public $target_dirname = ''; |
|
| 14 | + public $target_mname = ''; |
|
| 15 | + public $block_configs = array(); |
|
| 16 | + public $preview_request = array(); |
|
| 17 | 17 | |
| 18 | 18 | public function MyBlocksAadmin() |
| 19 | 19 | { |
@@ -22,37 +22,37 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | public function construct() |
| 24 | 24 | { |
| 25 | - $this->db =& XoopsDatabaseFactory::getDatabaseConnection() ; |
|
| 26 | - $this->lang = @$GLOBALS['xoopsConfig']['language'] ; |
|
| 25 | + $this->db = & XoopsDatabaseFactory::getDatabaseConnection(); |
|
| 26 | + $this->lang = @$GLOBALS['xoopsConfig']['language']; |
|
| 27 | 27 | |
| 28 | 28 | $this->cachetime_options = array( |
| 29 | - 0 => _NOCACHE , |
|
| 30 | - 30 => sprintf(_SECONDS, 30) , |
|
| 31 | - 60 => _MINUTE , |
|
| 32 | - 300 => sprintf(_MINUTES, 5) , |
|
| 33 | - 1800 => sprintf(_MINUTES, 30) , |
|
| 34 | - 3600 => _HOUR , |
|
| 35 | - 18000 => sprintf(_HOURS, 5) , |
|
| 36 | - 86400 => _DAY , |
|
| 37 | - 259200 => sprintf(_DAYS, 3) , |
|
| 38 | - 604800 => _WEEK , |
|
| 39 | - 2592000 => _MONTH , |
|
| 29 | + 0 => _NOCACHE, |
|
| 30 | + 30 => sprintf(_SECONDS, 30), |
|
| 31 | + 60 => _MINUTE, |
|
| 32 | + 300 => sprintf(_MINUTES, 5), |
|
| 33 | + 1800 => sprintf(_MINUTES, 30), |
|
| 34 | + 3600 => _HOUR, |
|
| 35 | + 18000 => sprintf(_HOURS, 5), |
|
| 36 | + 86400 => _DAY, |
|
| 37 | + 259200 => sprintf(_DAYS, 3), |
|
| 38 | + 604800 => _WEEK, |
|
| 39 | + 2592000 => _MONTH, |
|
| 40 | 40 | ); |
| 41 | 41 | |
| 42 | 42 | $this->ctype_options = array( |
| 43 | - 'H' => _MD_A_MYBLOCKSADMIN_CTYPE_HTML , |
|
| 44 | - 'T' => _MD_A_MYBLOCKSADMIN_CTYPE_NOSMILE , |
|
| 45 | - 'S' => _MD_A_MYBLOCKSADMIN_CTYPE_SMILE , |
|
| 46 | - 'P' => _MD_A_MYBLOCKSADMIN_CTYPE_PHP , |
|
| 47 | - ) ; |
|
| 43 | + 'H' => _MD_A_MYBLOCKSADMIN_CTYPE_HTML, |
|
| 44 | + 'T' => _MD_A_MYBLOCKSADMIN_CTYPE_NOSMILE, |
|
| 45 | + 'S' => _MD_A_MYBLOCKSADMIN_CTYPE_SMILE, |
|
| 46 | + 'P' => _MD_A_MYBLOCKSADMIN_CTYPE_PHP, |
|
| 47 | + ); |
|
| 48 | 48 | |
| 49 | 49 | $this->type_options = array( |
| 50 | - 'C' => 'custom block' , |
|
| 51 | - 'E' => 'cloned custom block' , |
|
| 52 | - 'M' => 'module\'s block' , |
|
| 53 | - 'D' => 'cloned module\'s block' , |
|
| 54 | - 'S' => 'system block' , |
|
| 55 | - ) ; |
|
| 50 | + 'C' => 'custom block', |
|
| 51 | + 'E' => 'cloned custom block', |
|
| 52 | + 'M' => 'module\'s block', |
|
| 53 | + 'D' => 'cloned module\'s block', |
|
| 54 | + 'S' => 'system block', |
|
| 55 | + ); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | //HACK by domifara for php5.3+ |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | { |
| 62 | 62 | static $instance; |
| 63 | 63 | if (!isset($instance)) { |
| 64 | - $instance = new MyBlocksAdmin() ; |
|
| 65 | - $instance->construct() ; |
|
| 64 | + $instance = new MyBlocksAdmin(); |
|
| 65 | + $instance->construct(); |
|
| 66 | 66 | } |
| 67 | 67 | return $instance; |
| 68 | 68 | } |
@@ -72,11 +72,11 @@ discard block |
||
| 72 | 72 | public function checkPermission() |
| 73 | 73 | { |
| 74 | 74 | // only groups have 'module_admin' of 'altsys' can do that. |
| 75 | - $module_handler =& xoops_gethandler('module') ; |
|
| 76 | - $module =& $module_handler->getByDirname('altsys') ; |
|
| 77 | - $moduleperm_handler =& xoops_gethandler('groupperm') ; |
|
| 78 | - if (! is_object(@$GLOBALS['xoopsUser']) || ! $moduleperm_handler->checkRight('module_admin', $module->getVar('mid'), $GLOBALS['xoopsUser']->getGroups())) { |
|
| 79 | - die('only admin of altsys can access this area') ; |
|
| 75 | + $module_handler = & xoops_gethandler('module'); |
|
| 76 | + $module = & $module_handler->getByDirname('altsys'); |
|
| 77 | + $moduleperm_handler = & xoops_gethandler('groupperm'); |
|
| 78 | + if (!is_object(@$GLOBALS['xoopsUser']) || !$moduleperm_handler->checkRight('module_admin', $module->getVar('mid'), $GLOBALS['xoopsUser']->getGroups())) { |
|
| 79 | + die('only admin of altsys can access this area'); |
|
| 80 | 80 | } |
| 81 | 81 | } |
| 82 | 82 | |
@@ -86,53 +86,53 @@ discard block |
||
| 86 | 86 | // altsys "module" MODE |
| 87 | 87 | if ($xoopsModule->getVar('dirname') == 'altsys') { |
| 88 | 88 | // set target_module if specified by $_GET['dirname'] |
| 89 | - $module_handler =& xoops_gethandler('module'); |
|
| 90 | - if (! empty($_GET['dirname'])) { |
|
| 91 | - $dirname = preg_replace('/[^0-9a-zA-Z_-]/', '', $_GET['dirname']) ; |
|
| 92 | - $target_module =& $module_handler->getByDirname($dirname) ; |
|
| 89 | + $module_handler = & xoops_gethandler('module'); |
|
| 90 | + if (!empty($_GET['dirname'])) { |
|
| 91 | + $dirname = preg_replace('/[^0-9a-zA-Z_-]/', '', $_GET['dirname']); |
|
| 92 | + $target_module = & $module_handler->getByDirname($dirname); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | if (is_object(@$target_module)) { |
| 96 | 96 | // module's blocks |
| 97 | - $this->target_mid = $target_module->getVar('mid') ; |
|
| 98 | - $this->target_mname = $target_module->getVar('name') . " " . sprintf("(%2.2f)", $target_module->getVar('version') / 100.0) ; |
|
| 99 | - $this->target_dirname = $target_module->getVar('dirname') ; |
|
| 100 | - $modinfo = $target_module->getInfo() ; |
|
| 97 | + $this->target_mid = $target_module->getVar('mid'); |
|
| 98 | + $this->target_mname = $target_module->getVar('name')." ".sprintf("(%2.2f)", $target_module->getVar('version') / 100.0); |
|
| 99 | + $this->target_dirname = $target_module->getVar('dirname'); |
|
| 100 | + $modinfo = $target_module->getInfo(); |
|
| 101 | 101 | // breadcrumbs |
| 102 | - $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
| 103 | - $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&lib=altsys&page=myblocksadmin', '_MI_ALTSYS_MENU_MYBLOCKSADMIN') ; |
|
| 104 | - $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&lib=altsys&page=myblocksadmin&dirname='.$this->target_dirname, $this->target_mname) ; |
|
| 102 | + $breadcrumbsObj = & AltsysBreadcrumbs::getInstance(); |
|
| 103 | + $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&lib=altsys&page=myblocksadmin', '_MI_ALTSYS_MENU_MYBLOCKSADMIN'); |
|
| 104 | + $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&lib=altsys&page=myblocksadmin&dirname='.$this->target_dirname, $this->target_mname); |
|
| 105 | 105 | } else { |
| 106 | 106 | // custom blocks |
| 107 | - $this->target_mid = 0 ; |
|
| 108 | - $this->target_mname = _MI_ALTSYS_MENU_CUSTOMBLOCKS ; |
|
| 109 | - $this->target_dirname = '__CustomBlocks__' ; |
|
| 107 | + $this->target_mid = 0; |
|
| 108 | + $this->target_mname = _MI_ALTSYS_MENU_CUSTOMBLOCKS; |
|
| 109 | + $this->target_dirname = '__CustomBlocks__'; |
|
| 110 | 110 | // breadcrumbs |
| 111 | - $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
| 112 | - $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&lib=altsys&page=myblocksadmin', '_MI_ALTSYS_MENU_MYBLOCKSADMIN') ; |
|
| 113 | - $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&lib=altsys&page=myblocksadmin&dirname='.$this->target_dirname, '_MI_ALTSYS_MENU_CUSTOMBLOCKS') ; |
|
| 111 | + $breadcrumbsObj = & AltsysBreadcrumbs::getInstance(); |
|
| 112 | + $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&lib=altsys&page=myblocksadmin', '_MI_ALTSYS_MENU_MYBLOCKSADMIN'); |
|
| 113 | + $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&lib=altsys&page=myblocksadmin&dirname='.$this->target_dirname, '_MI_ALTSYS_MENU_CUSTOMBLOCKS'); |
|
| 114 | 114 | } |
| 115 | 115 | } else { |
| 116 | 116 | // myblocksadmin as a library |
| 117 | - $this->target_mid = $xoopsModule->getVar('mid') ; |
|
| 118 | - $this->target_mname = $xoopsModule->getVar('name') . " " . sprintf("(%2.2f)", $xoopsModule->getVar('version') / 100.0) ; |
|
| 119 | - $this->target_dirname = $xoopsModule->getVar('dirname') ; |
|
| 120 | - $mod_url = XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname') ; |
|
| 121 | - $modinfo = $xoopsModule->getInfo() ; |
|
| 122 | - $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
| 123 | - $breadcrumbsObj->appendPath($mod_url.'/'.@$modinfo['adminindex'], $this->target_mname) ; |
|
| 124 | - $breadcrumbsObj->appendPath($mod_url.'/admin/index.php?mode=admin&lib=altsys&page=myblocksadmin', _MD_A_MYBLOCKSADMIN_BLOCKADMIN) ; |
|
| 117 | + $this->target_mid = $xoopsModule->getVar('mid'); |
|
| 118 | + $this->target_mname = $xoopsModule->getVar('name')." ".sprintf("(%2.2f)", $xoopsModule->getVar('version') / 100.0); |
|
| 119 | + $this->target_dirname = $xoopsModule->getVar('dirname'); |
|
| 120 | + $mod_url = XOOPS_URL.'/modules/'.$xoopsModule->getVar('dirname'); |
|
| 121 | + $modinfo = $xoopsModule->getInfo(); |
|
| 122 | + $breadcrumbsObj = & AltsysBreadcrumbs::getInstance(); |
|
| 123 | + $breadcrumbsObj->appendPath($mod_url.'/'.@$modinfo['adminindex'], $this->target_mname); |
|
| 124 | + $breadcrumbsObj->appendPath($mod_url.'/admin/index.php?mode=admin&lib=altsys&page=myblocksadmin', _MD_A_MYBLOCKSADMIN_BLOCKADMIN); |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // read xoops_version.php of the target |
| 128 | - $this->block_configs = $this->get_block_configs() ; |
|
| 128 | + $this->block_configs = $this->get_block_configs(); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | |
| 132 | 132 | // virtual |
| 133 | 133 | public function canEdit($block) |
| 134 | 134 | { |
| 135 | - return true ; |
|
| 135 | + return true; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | |
@@ -141,9 +141,9 @@ discard block |
||
| 141 | 141 | { |
| 142 | 142 | // can delete if it is a cloned block |
| 143 | 143 | if ($block->getVar("block_type") == 'D' || $block->getVar("block_type") == 'C') { |
| 144 | - return true ; |
|
| 144 | + return true; |
|
| 145 | 145 | } else { |
| 146 | - return false ; |
|
| 146 | + return false; |
|
| 147 | 147 | } |
| 148 | 148 | } |
| 149 | 149 | |
@@ -156,23 +156,23 @@ discard block |
||
| 156 | 156 | { |
| 157 | 157 | // can clone link if it is marked as cloneable block |
| 158 | 158 | if ($block->getVar("block_type") == 'D' || $block->getVar("block_type") == 'C') { |
| 159 | - return 2 ; |
|
| 159 | + return 2; |
|
| 160 | 160 | } else { |
| 161 | 161 | // $modversion['blocks'][n]['can_clone'] |
| 162 | 162 | foreach ($this->block_configs as $bconf) { |
| 163 | 163 | if ($block->getVar("show_func") == @$bconf['show_func'] && $block->getVar("func_file") == @$bconf['file'] && (empty($bconf['template']) || $block->getVar("template") == @$bconf['template'])) { |
| 164 | - if (! empty($bconf['can_clone'])) { |
|
| 165 | - return 2 ; |
|
| 164 | + if (!empty($bconf['can_clone'])) { |
|
| 165 | + return 2; |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if (! empty($GLOBALS['altsysModuleConfig']['enable_force_clone'])) { |
|
| 172 | - return 1 ; |
|
| 171 | + if (!empty($GLOBALS['altsysModuleConfig']['enable_force_clone'])) { |
|
| 172 | + return 1; |
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - return 0 ; |
|
| 175 | + return 0; |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | 178 | |
@@ -180,17 +180,17 @@ discard block |
||
| 180 | 180 | // options |
| 181 | 181 | public function renderCell4BlockOptions($block_data) |
| 182 | 182 | { |
| 183 | - $bid = intval($block_data['bid']) ; |
|
| 183 | + $bid = intval($block_data['bid']); |
|
| 184 | 184 | |
| 185 | 185 | //HACK by domifara |
| 186 | 186 | if (defined('XOOPS_CUBE_LEGACY')) { |
| 187 | - $handler =& xoops_gethandler('block'); |
|
| 188 | - $block =& $handler->create(false) ; |
|
| 189 | - $block->load($bid) ; |
|
| 187 | + $handler = & xoops_gethandler('block'); |
|
| 188 | + $block = & $handler->create(false); |
|
| 189 | + $block->load($bid); |
|
| 190 | 190 | } else { |
| 191 | - $block = new XoopsBlock($bid) ; |
|
| 191 | + $block = new XoopsBlock($bid); |
|
| 192 | 192 | } |
| 193 | - return $block->getOptions() ; |
|
| 193 | + return $block->getOptions(); |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | |
@@ -198,48 +198,48 @@ discard block |
||
| 198 | 198 | // link blocks - modules |
| 199 | 199 | public function renderCell4BlockModuleLink($block_data) |
| 200 | 200 | { |
| 201 | - $bid = intval($block_data['bid']) ; |
|
| 201 | + $bid = intval($block_data['bid']); |
|
| 202 | 202 | |
| 203 | 203 | // get selected targets |
| 204 | 204 | if (is_array(@$block_data['bmodule'])) { |
| 205 | 205 | // bmodule origined from request (preview etc.) |
| 206 | - $selected_mids = $block_data['bmodule'] ; |
|
| 206 | + $selected_mids = $block_data['bmodule']; |
|
| 207 | 207 | } else { |
| 208 | 208 | // origined from the table of `block_module_link` |
| 209 | - $result = $this->db->query("SELECT module_id FROM ".$this->db->prefix('block_module_link')." WHERE block_id='$bid'") ; |
|
| 209 | + $result = $this->db->query("SELECT module_id FROM ".$this->db->prefix('block_module_link')." WHERE block_id='$bid'"); |
|
| 210 | 210 | $selected_mids = array(); |
| 211 | 211 | while (list($selected_mid) = $this->db->fetchRow($result)) { |
| 212 | - $selected_mids[] = intval($selected_mid) ; |
|
| 212 | + $selected_mids[] = intval($selected_mid); |
|
| 213 | 213 | } |
| 214 | 214 | if (empty($selected_mids)) { |
| 215 | - $selected_mids = array( 0 ) ; |
|
| 215 | + $selected_mids = array(0); |
|
| 216 | 216 | } // all pages |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | // get all targets |
| 220 | - $module_handler =& xoops_gethandler('module'); |
|
| 220 | + $module_handler = & xoops_gethandler('module'); |
|
| 221 | 221 | $criteria = new CriteriaCompo(new Criteria('hasmain', 1)); |
| 222 | 222 | $criteria->add(new Criteria('isactive', 1)); |
| 223 | 223 | $module_list = $module_handler->getList($criteria); |
| 224 | - $module_list= array( -1 => _MD_A_MYBLOCKSADMIN_TOPPAGE , 0 => _MD_A_MYBLOCKSADMIN_ALLPAGES ) + $module_list ; |
|
| 224 | + $module_list = array( -1 => _MD_A_MYBLOCKSADMIN_TOPPAGE, 0 => _MD_A_MYBLOCKSADMIN_ALLPAGES ) + $module_list; |
|
| 225 | 225 | |
| 226 | 226 | // build options |
| 227 | - $module_options = '' ; |
|
| 227 | + $module_options = ''; |
|
| 228 | 228 | foreach ($module_list as $mid => $mname) { |
| 229 | - $mname = htmlspecialchars($mname) ; |
|
| 229 | + $mname = htmlspecialchars($mname); |
|
| 230 | 230 | if (in_array($mid, $selected_mids)) { |
| 231 | - $module_options .= "<option value='$mid' selected='selected'>$mname</option>\n" ; |
|
| 231 | + $module_options .= "<option value='$mid' selected='selected'>$mname</option>\n"; |
|
| 232 | 232 | } else { |
| 233 | - $module_options .= "<option value='$mid'>$mname</option>\n" ; |
|
| 233 | + $module_options .= "<option value='$mid'>$mname</option>\n"; |
|
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | $ret = " |
| 238 | 238 | <select name='bmodules[$bid][]' size='5' multiple='multiple'> |
| 239 | 239 | $module_options |
| 240 | - </select>" ; |
|
| 240 | + </select>"; |
|
| 241 | 241 | |
| 242 | - return $ret ; |
|
| 242 | + return $ret; |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | |
@@ -247,46 +247,46 @@ discard block |
||
| 247 | 247 | // group_permission - 'block_read' |
| 248 | 248 | public function renderCell4BlockReadGroupPerm($block_data) |
| 249 | 249 | { |
| 250 | - $bid = intval($block_data['bid']) ; |
|
| 250 | + $bid = intval($block_data['bid']); |
|
| 251 | 251 | |
| 252 | 252 | // get selected targets |
| 253 | 253 | if (is_array(@$block_data['bgroup'])) { |
| 254 | 254 | // bgroup origined from request (preview etc.) |
| 255 | - $selected_gids = $block_data['bgroup'] ; |
|
| 255 | + $selected_gids = $block_data['bgroup']; |
|
| 256 | 256 | } else { |
| 257 | 257 | // origined from the table of `group_perm` |
| 258 | - $result = $this->db->query("SELECT gperm_groupid FROM ".$this->db->prefix('group_permission')." WHERE gperm_itemid='$bid' AND gperm_name='block_read'") ; |
|
| 258 | + $result = $this->db->query("SELECT gperm_groupid FROM ".$this->db->prefix('group_permission')." WHERE gperm_itemid='$bid' AND gperm_name='block_read'"); |
|
| 259 | 259 | $selected_gids = array(); |
| 260 | 260 | while (list($selected_gid) = $this->db->fetchRow($result)) { |
| 261 | - $selected_gids[] = intval($selected_gid) ; |
|
| 261 | + $selected_gids[] = intval($selected_gid); |
|
| 262 | 262 | } |
| 263 | 263 | if ($bid == 0 && empty($selected_gids)) { |
| 264 | - $selected_gids = $GLOBALS['xoopsUser']->getGroups() ; |
|
| 264 | + $selected_gids = $GLOBALS['xoopsUser']->getGroups(); |
|
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | // get all targets |
| 269 | - $group_handler =& xoops_gethandler('group'); |
|
| 270 | - $groups = $group_handler->getObjects() ; |
|
| 269 | + $group_handler = & xoops_gethandler('group'); |
|
| 270 | + $groups = $group_handler->getObjects(); |
|
| 271 | 271 | |
| 272 | 272 | // build options |
| 273 | - $group_options = '' ; |
|
| 273 | + $group_options = ''; |
|
| 274 | 274 | foreach ($groups as $group) { |
| 275 | - $gid = $group->getVar('groupid') ; |
|
| 276 | - $gname = $group->getVar('name', 's') ; |
|
| 275 | + $gid = $group->getVar('groupid'); |
|
| 276 | + $gname = $group->getVar('name', 's'); |
|
| 277 | 277 | if (in_array($gid, $selected_gids)) { |
| 278 | - $group_options .= "<option value='$gid' selected='selected'>$gname</option>\n" ; |
|
| 278 | + $group_options .= "<option value='$gid' selected='selected'>$gname</option>\n"; |
|
| 279 | 279 | } else { |
| 280 | - $group_options .= "<option value='$gid'>$gname</option>\n" ; |
|
| 280 | + $group_options .= "<option value='$gid'>$gname</option>\n"; |
|
| 281 | 281 | } |
| 282 | 282 | } |
| 283 | 283 | |
| 284 | 284 | $ret = " |
| 285 | 285 | <select name='bgroups[$bid][]' size='5' multiple='multiple'> |
| 286 | 286 | $group_options |
| 287 | - </select>" ; |
|
| 287 | + </select>"; |
|
| 288 | 288 | |
| 289 | - return $ret ; |
|
| 289 | + return $ret; |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | |
@@ -294,14 +294,14 @@ discard block |
||
| 294 | 294 | // visible and side |
| 295 | 295 | public function renderCell4BlockPosition($block_data) |
| 296 | 296 | { |
| 297 | - $bid = intval($block_data['bid']) ; |
|
| 298 | - $side = intval($block_data['side']) ; |
|
| 299 | - $visible = intval($block_data['visible']) ; |
|
| 297 | + $bid = intval($block_data['bid']); |
|
| 298 | + $side = intval($block_data['side']); |
|
| 299 | + $visible = intval($block_data['visible']); |
|
| 300 | 300 | |
| 301 | 301 | $sseln = $ssel0 = $ssel1 = $ssel2 = $ssel3 = $ssel4 = ""; |
| 302 | 302 | $scoln = $scol0 = $scol1 = $scol2 = $scol3 = $scol4 = "unselected"; |
| 303 | - $stextbox = "unselected" ; |
|
| 304 | - $value4extra_side = '' ; |
|
| 303 | + $stextbox = "unselected"; |
|
| 304 | + $value4extra_side = ''; |
|
| 305 | 305 | |
| 306 | 306 | if ($visible != 1) { |
| 307 | 307 | $sseln = " checked='checked'"; |
@@ -311,27 +311,27 @@ discard block |
||
| 311 | 311 | case XOOPS_SIDEBLOCK_LEFT : |
| 312 | 312 | $ssel0 = " checked='checked'"; |
| 313 | 313 | $scol0 = "selected"; |
| 314 | - break ; |
|
| 314 | + break; |
|
| 315 | 315 | case XOOPS_SIDEBLOCK_RIGHT : |
| 316 | 316 | $ssel1 = " checked='checked'"; |
| 317 | 317 | $scol1 = "selected"; |
| 318 | - break ; |
|
| 318 | + break; |
|
| 319 | 319 | case XOOPS_CENTERBLOCK_LEFT : |
| 320 | 320 | $ssel2 = " checked='checked'"; |
| 321 | 321 | $scol2 = "selected"; |
| 322 | - break ; |
|
| 322 | + break; |
|
| 323 | 323 | case XOOPS_CENTERBLOCK_RIGHT : |
| 324 | 324 | $ssel4 = " checked='checked'"; |
| 325 | 325 | $scol4 = "selected"; |
| 326 | - break ; |
|
| 326 | + break; |
|
| 327 | 327 | case XOOPS_CENTERBLOCK_CENTER : |
| 328 | 328 | $ssel3 = " checked='checked'"; |
| 329 | 329 | $scol3 = "selected"; |
| 330 | - break ; |
|
| 330 | + break; |
|
| 331 | 331 | default : |
| 332 | - $value4extra_side = $side ; |
|
| 333 | - $stextbox = "selected" ; |
|
| 334 | - break ; |
|
| 332 | + $value4extra_side = $side; |
|
| 333 | + $stextbox = "selected"; |
|
| 334 | + break; |
|
| 335 | 335 | } |
| 336 | 336 | } |
| 337 | 337 | |
@@ -369,58 +369,58 @@ discard block |
||
| 369 | 369 | // public |
| 370 | 370 | public function list_blocks() |
| 371 | 371 | { |
| 372 | - global $xoopsGTicket ; |
|
| 372 | + global $xoopsGTicket; |
|
| 373 | 373 | |
| 374 | 374 | // main query |
| 375 | - $sql = "SELECT * FROM ".$this->db->prefix("newblocks")." WHERE mid='$this->target_mid' ORDER BY visible DESC,side,weight" ; |
|
| 376 | - $result = $this->db->query($sql) ; |
|
| 377 | - $block_arr = array() ; |
|
| 375 | + $sql = "SELECT * FROM ".$this->db->prefix("newblocks")." WHERE mid='$this->target_mid' ORDER BY visible DESC,side,weight"; |
|
| 376 | + $result = $this->db->query($sql); |
|
| 377 | + $block_arr = array(); |
|
| 378 | 378 | //HACK by domifara |
| 379 | 379 | if (defined('XOOPS_CUBE_LEGACY')) { |
| 380 | - $handler =& xoops_gethandler('block');//add |
|
| 380 | + $handler = & xoops_gethandler('block'); //add |
|
| 381 | 381 | } |
| 382 | 382 | while ($myrow = $this->db->fetchArray($result)) { |
| 383 | 383 | |
| 384 | 384 | //HACK by domifara |
| 385 | 385 | if (defined('XOOPS_CUBE_LEGACY')) { |
| 386 | - $block_one =& $handler->create(false) ; |
|
| 386 | + $block_one = & $handler->create(false); |
|
| 387 | 387 | $block_one->assignVars($myrow); |
| 388 | - $block_arr[] =& $block_one ; |
|
| 388 | + $block_arr[] = & $block_one; |
|
| 389 | 389 | } else { |
| 390 | - $block_arr[] = new XoopsBlock($myrow) ; |
|
| 390 | + $block_arr[] = new XoopsBlock($myrow); |
|
| 391 | 391 | } |
| 392 | 392 | } |
| 393 | 393 | if (empty($block_arr)) { |
| 394 | - return ; |
|
| 394 | + return; |
|
| 395 | 395 | } |
| 396 | 396 | |
| 397 | 397 | // blocks rendering loop |
| 398 | - $blocks4assign = array() ; |
|
| 398 | + $blocks4assign = array(); |
|
| 399 | 399 | foreach ($block_arr as $i => $block) { |
| 400 | 400 | $block_data = array( |
| 401 | - 'bid' => intval($block->getVar('bid')) , |
|
| 402 | - 'name' => $block->getVar('name', 'n') , |
|
| 403 | - 'title' => $block->getVar('title', 'n') , |
|
| 404 | - 'weight' => intval($block->getVar('weight')) , |
|
| 405 | - 'bcachetime' => intval($block->getVar('bcachetime')) , |
|
| 406 | - 'side' => intval($block->getVar('side')) , |
|
| 407 | - 'visible' => intval($block->getVar('visible')) , |
|
| 408 | - 'can_edit' => $this->canEdit($block) , |
|
| 409 | - 'can_delete' => $this->canDelete($block) , |
|
| 410 | - 'can_clone' => $this->canClone($block) , |
|
| 411 | - ) ; |
|
| 401 | + 'bid' => intval($block->getVar('bid')), |
|
| 402 | + 'name' => $block->getVar('name', 'n'), |
|
| 403 | + 'title' => $block->getVar('title', 'n'), |
|
| 404 | + 'weight' => intval($block->getVar('weight')), |
|
| 405 | + 'bcachetime' => intval($block->getVar('bcachetime')), |
|
| 406 | + 'side' => intval($block->getVar('side')), |
|
| 407 | + 'visible' => intval($block->getVar('visible')), |
|
| 408 | + 'can_edit' => $this->canEdit($block), |
|
| 409 | + 'can_delete' => $this->canDelete($block), |
|
| 410 | + 'can_clone' => $this->canClone($block), |
|
| 411 | + ); |
|
| 412 | 412 | $blocks4assign[] = array( |
| 413 | - 'name_raw' => $block_data['name'] , |
|
| 414 | - 'title_raw' => $block_data['title'] , |
|
| 415 | - 'cell_position' => $this->renderCell4BlockPosition($block_data) , |
|
| 416 | - 'cell_module_link' => $this->renderCell4BlockModuleLink($block_data) , |
|
| 417 | - 'cell_group_perm' => $this->renderCell4BlockReadGroupPerm($block_data) , |
|
| 418 | - ) + $block_data ; |
|
| 413 | + 'name_raw' => $block_data['name'], |
|
| 414 | + 'title_raw' => $block_data['title'], |
|
| 415 | + 'cell_position' => $this->renderCell4BlockPosition($block_data), |
|
| 416 | + 'cell_module_link' => $this->renderCell4BlockModuleLink($block_data), |
|
| 417 | + 'cell_group_perm' => $this->renderCell4BlockReadGroupPerm($block_data), |
|
| 418 | + ) + $block_data; |
|
| 419 | 419 | } |
| 420 | 420 | |
| 421 | 421 | // display |
| 422 | - require_once XOOPS_TRUST_PATH.'/libs/altsys/class/D3Tpl.class.php' ; |
|
| 423 | - $tpl = new D3Tpl() ; |
|
| 422 | + require_once XOOPS_TRUST_PATH.'/libs/altsys/class/D3Tpl.class.php'; |
|
| 423 | + $tpl = new D3Tpl(); |
|
| 424 | 424 | $tpl->assign(array( |
| 425 | 425 | 'target_mid' => $this->target_mid, |
| 426 | 426 | 'target_dirname' => $this->target_dirname, |
@@ -429,22 +429,22 @@ discard block |
||
| 429 | 429 | 'cachetime_options' => $this->cachetime_options, |
| 430 | 430 | 'blocks' => $blocks4assign, |
| 431 | 431 | 'gticket_hidden' => $xoopsGTicket->getTicketHtml(__LINE__, 1800, 'myblocksadmin'), |
| 432 | - )) ; |
|
| 433 | - $tpl->display('db:altsys_main_myblocksadmin_list.html') ; |
|
| 432 | + )); |
|
| 433 | + $tpl->display('db:altsys_main_myblocksadmin_list.html'); |
|
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | |
| 437 | 437 | public function get_block_configs() |
| 438 | 438 | { |
| 439 | 439 | if ($this->target_mid <= 0) { |
| 440 | - return array() ; |
|
| 440 | + return array(); |
|
| 441 | 441 | } |
| 442 | - include XOOPS_ROOT_PATH.'/modules/'.$this->target_dirname.'/xoops_version.php' ; |
|
| 442 | + include XOOPS_ROOT_PATH.'/modules/'.$this->target_dirname.'/xoops_version.php'; |
|
| 443 | 443 | |
| 444 | 444 | if (empty($modversion['blocks'])) { |
| 445 | - return array() ; |
|
| 445 | + return array(); |
|
| 446 | 446 | } else { |
| 447 | - return $modversion['blocks'] ; |
|
| 447 | + return $modversion['blocks']; |
|
| 448 | 448 | } |
| 449 | 449 | } |
| 450 | 450 | |
@@ -452,51 +452,51 @@ discard block |
||
| 452 | 452 | public function list_groups() |
| 453 | 453 | { |
| 454 | 454 | // query for getting blocks |
| 455 | - $sql = "SELECT * FROM ".$this->db->prefix("newblocks")." WHERE mid='$this->target_mid' ORDER BY visible DESC,side,weight" ; |
|
| 456 | - $result = $this->db->query($sql) ; |
|
| 457 | - $block_arr = array() ; |
|
| 455 | + $sql = "SELECT * FROM ".$this->db->prefix("newblocks")." WHERE mid='$this->target_mid' ORDER BY visible DESC,side,weight"; |
|
| 456 | + $result = $this->db->query($sql); |
|
| 457 | + $block_arr = array(); |
|
| 458 | 458 | //HACK by domifara |
| 459 | 459 | if (defined('XOOPS_CUBE_LEGACY')) { |
| 460 | - $handler =& xoops_gethandler('block');//add |
|
| 460 | + $handler = & xoops_gethandler('block'); //add |
|
| 461 | 461 | } |
| 462 | 462 | while ($myrow = $this->db->fetchArray($result)) { |
| 463 | 463 | //HACK by domifara |
| 464 | 464 | if (defined('XOOPS_CUBE_LEGACY')) { |
| 465 | - $block_one =& $handler->create(false) ; |
|
| 465 | + $block_one = & $handler->create(false); |
|
| 466 | 466 | $block_one->assignVars($myrow); |
| 467 | - $block_arr[] =& $block_one ; |
|
| 467 | + $block_arr[] = & $block_one; |
|
| 468 | 468 | } else { |
| 469 | - $block_arr[] = new XoopsBlock($myrow) ; |
|
| 469 | + $block_arr[] = new XoopsBlock($myrow); |
|
| 470 | 470 | } |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - $item_list = array() ; |
|
| 473 | + $item_list = array(); |
|
| 474 | 474 | foreach (array_keys($block_arr) as $i) { |
| 475 | - $item_list[ $block_arr[$i]->getVar("bid") ] = $block_arr[$i]->getVar("title") ; |
|
| 475 | + $item_list[$block_arr[$i]->getVar("bid")] = $block_arr[$i]->getVar("title"); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | - $form = new MyXoopsGroupPermForm(_MD_A_MYBLOCKSADMIN_PERMFORM, 1, 'block_read', '') ; |
|
| 478 | + $form = new MyXoopsGroupPermForm(_MD_A_MYBLOCKSADMIN_PERMFORM, 1, 'block_read', ''); |
|
| 479 | 479 | // skip system (TODO) |
| 480 | 480 | if ($this->target_mid > 1) { |
| 481 | - $form->addAppendix('module_admin', $this->target_mid, $this->target_mname . ' ' . _MD_A_MYBLOCKSADMIN_PERM_MADMIN) ; |
|
| 482 | - $form->addAppendix('module_read', $this->target_mid, $this->target_mname .' ' . _MD_A_MYBLOCKSADMIN_PERM_MREAD) ; |
|
| 481 | + $form->addAppendix('module_admin', $this->target_mid, $this->target_mname.' '._MD_A_MYBLOCKSADMIN_PERM_MADMIN); |
|
| 482 | + $form->addAppendix('module_read', $this->target_mid, $this->target_mname.' '._MD_A_MYBLOCKSADMIN_PERM_MREAD); |
|
| 483 | 483 | } |
| 484 | 484 | foreach ($item_list as $item_id => $item_name) { |
| 485 | - $form->addItem($item_id, $item_name) ; |
|
| 485 | + $form->addItem($item_id, $item_name); |
|
| 486 | 486 | } |
| 487 | - echo $form->render() ; |
|
| 487 | + echo $form->render(); |
|
| 488 | 488 | } |
| 489 | 489 | |
| 490 | 490 | |
| 491 | - public function update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $options=array()) |
|
| 491 | + public function update_block($bid, $bside, $bweight, $bvisible, $btitle, $bcontent, $bctype, $bcachetime, $options = array()) |
|
| 492 | 492 | { |
| 493 | 493 | global $xoopsConfig; |
| 494 | 494 | |
| 495 | 495 | //HACK by domifara |
| 496 | 496 | if (defined('XOOPS_CUBE_LEGACY')) { |
| 497 | - $handler =& xoops_gethandler('block'); |
|
| 498 | - $block =& $handler->create(false) ; |
|
| 499 | - $block->load($bid) ; |
|
| 497 | + $handler = & xoops_gethandler('block'); |
|
| 498 | + $block = & $handler->create(false); |
|
| 499 | + $block->load($bid); |
|
| 500 | 500 | } else { |
| 501 | 501 | $block = new XoopsBlock($bid); |
| 502 | 502 | } |
@@ -515,10 +515,10 @@ discard block |
||
| 515 | 515 | } |
| 516 | 516 | $block->setVar('bcachetime', $bcachetime); |
| 517 | 517 | if (is_array($options) && count($options) > 0) { |
| 518 | - $block->setVar('options', implode('|', $options)) ; |
|
| 518 | + $block->setVar('options', implode('|', $options)); |
|
| 519 | 519 | } |
| 520 | 520 | if ($block->getVar('block_type') == 'C') { |
| 521 | - $name = $this->get_blockname_from_ctype($block->getVar('c_type')) ; |
|
| 521 | + $name = $this->get_blockname_from_ctype($block->getVar('c_type')); |
|
| 522 | 522 | $block->setVar('name', $name); |
| 523 | 523 | } |
| 524 | 524 | $msg = _MD_A_MYBLOCKSADMIN_DBUPDATED; |
@@ -542,22 +542,22 @@ discard block |
||
| 542 | 542 | } else { |
| 543 | 543 | $msg = 'Failed update of block. ID:'.$bid; |
| 544 | 544 | } |
| 545 | - return $msg ; |
|
| 545 | + return $msg; |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | |
| 549 | 549 | // virtual |
| 550 | 550 | public function updateBlockModuleLink($bid, $bmodules) |
| 551 | 551 | { |
| 552 | - $bid = intval($bid) ; |
|
| 553 | - $table = $this->db->prefix("block_module_link") ; |
|
| 552 | + $bid = intval($bid); |
|
| 553 | + $table = $this->db->prefix("block_module_link"); |
|
| 554 | 554 | |
| 555 | - $sql = "DELETE FROM `$table` WHERE `block_id`=$bid" ; |
|
| 556 | - $this->db->query($sql) ; |
|
| 555 | + $sql = "DELETE FROM `$table` WHERE `block_id`=$bid"; |
|
| 556 | + $this->db->query($sql); |
|
| 557 | 557 | foreach ($bmodules as $mid) { |
| 558 | - $mid = intval($mid) ; |
|
| 559 | - $sql = "INSERT INTO `$table` (`block_id`,`module_id`) VALUES ($bid,$mid)" ; |
|
| 560 | - $this->db->query($sql) ; |
|
| 558 | + $mid = intval($mid); |
|
| 559 | + $sql = "INSERT INTO `$table` (`block_id`,`module_id`) VALUES ($bid,$mid)"; |
|
| 560 | + $this->db->query($sql); |
|
| 561 | 561 | } |
| 562 | 562 | } |
| 563 | 563 | |
@@ -565,177 +565,177 @@ discard block |
||
| 565 | 565 | // virtual |
| 566 | 566 | public function updateBlockReadGroupPerm($bid, $req_gids) |
| 567 | 567 | { |
| 568 | - $bid = intval($bid) ; |
|
| 569 | - $table = $this->db->prefix("group_permission") ; |
|
| 570 | - $req_gids = array_map('intval', $req_gids) ; |
|
| 571 | - sort($req_gids) ; |
|
| 568 | + $bid = intval($bid); |
|
| 569 | + $table = $this->db->prefix("group_permission"); |
|
| 570 | + $req_gids = array_map('intval', $req_gids); |
|
| 571 | + sort($req_gids); |
|
| 572 | 572 | |
| 573 | 573 | // compare group ids from request and the records. |
| 574 | - $sql = "SELECT `gperm_groupid` FROM `$table` WHERE gperm_name='block_read' AND `gperm_itemid`=$bid" ; |
|
| 575 | - $result = $this->db->query($sql) ; |
|
| 576 | - $db_gids = array() ; |
|
| 574 | + $sql = "SELECT `gperm_groupid` FROM `$table` WHERE gperm_name='block_read' AND `gperm_itemid`=$bid"; |
|
| 575 | + $result = $this->db->query($sql); |
|
| 576 | + $db_gids = array(); |
|
| 577 | 577 | while (list($gid) = $this->db->fetchRow($result)) { |
| 578 | - $db_gids[] = $gid ; |
|
| 578 | + $db_gids[] = $gid; |
|
| 579 | 579 | } |
| 580 | - $db_gids = array_map('intval', $db_gids) ; |
|
| 581 | - sort($db_gids) ; |
|
| 580 | + $db_gids = array_map('intval', $db_gids); |
|
| 581 | + sort($db_gids); |
|
| 582 | 582 | |
| 583 | 583 | // if they are identical, just return (prevent increase of gperm_id) |
| 584 | 584 | if (serialize($req_gids) == serialize($db_gids)) { |
| 585 | - return ; |
|
| 585 | + return; |
|
| 586 | 586 | } |
| 587 | 587 | |
| 588 | - $sql = "DELETE FROM `$table` WHERE gperm_name='block_read' AND `gperm_itemid`=$bid" ; |
|
| 589 | - $this->db->query($sql) ; |
|
| 588 | + $sql = "DELETE FROM `$table` WHERE gperm_name='block_read' AND `gperm_itemid`=$bid"; |
|
| 589 | + $this->db->query($sql); |
|
| 590 | 590 | foreach ($req_gids as $gid) { |
| 591 | - $gid = intval($gid) ; |
|
| 592 | - $sql = "INSERT INTO `$table` (`gperm_groupid`,`gperm_itemid`,`gperm_modid`,`gperm_name`) VALUES ($gid,$bid,1,'block_read')" ; |
|
| 593 | - $this->db->query($sql) ; |
|
| 591 | + $gid = intval($gid); |
|
| 592 | + $sql = "INSERT INTO `$table` (`gperm_groupid`,`gperm_itemid`,`gperm_modid`,`gperm_name`) VALUES ($gid,$bid,1,'block_read')"; |
|
| 593 | + $this->db->query($sql); |
|
| 594 | 594 | } |
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | |
| 598 | 598 | public function do_order() |
| 599 | 599 | { |
| 600 | - $sides = is_array(@$_POST['sides']) ? $_POST['sides'] : array() ; |
|
| 600 | + $sides = is_array(@$_POST['sides']) ? $_POST['sides'] : array(); |
|
| 601 | 601 | foreach (array_keys($sides) as $bid) { |
| 602 | - $request = $this->fetchRequest4Block($bid) ; |
|
| 602 | + $request = $this->fetchRequest4Block($bid); |
|
| 603 | 603 | |
| 604 | 604 | // update the block |
| 605 | - $this->update_block($request['bid'], $request['side'], $request['weight'], $request['visible'], $request['title'], null, null, $request['bcachetime'], array()) ; |
|
| 605 | + $this->update_block($request['bid'], $request['side'], $request['weight'], $request['visible'], $request['title'], null, null, $request['bcachetime'], array()); |
|
| 606 | 606 | |
| 607 | 607 | // block_module_link update |
| 608 | - $this->updateBlockModuleLink($bid, $request['bmodule']) ; |
|
| 608 | + $this->updateBlockModuleLink($bid, $request['bmodule']); |
|
| 609 | 609 | |
| 610 | 610 | // group_permission update |
| 611 | - $this->updateBlockReadGroupPerm($bid, $request['bgroup']) ; |
|
| 611 | + $this->updateBlockReadGroupPerm($bid, $request['bgroup']); |
|
| 612 | 612 | } |
| 613 | - return _MD_A_MYBLOCKSADMIN_DBUPDATED ; |
|
| 613 | + return _MD_A_MYBLOCKSADMIN_DBUPDATED; |
|
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | |
| 617 | 617 | public function fetchRequest4Block($bid) |
| 618 | 618 | { |
| 619 | - $bid = intval($bid) ; |
|
| 620 | - (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || $myts =& MyTextSanitizer::getInstance() ; |
|
| 619 | + $bid = intval($bid); |
|
| 620 | + (method_exists('MyTextSanitizer', 'sGetInstance') and $myts = & MyTextSanitizer::sGetInstance()) || $myts = & MyTextSanitizer::getInstance(); |
|
| 621 | 621 | |
| 622 | 622 | if (@$_POST['extra_sides'][$bid] > 0) { |
| 623 | - $_POST['sides'][$bid] = intval($_POST['extra_sides'][$bid]) ; |
|
| 623 | + $_POST['sides'][$bid] = intval($_POST['extra_sides'][$bid]); |
|
| 624 | 624 | } |
| 625 | 625 | |
| 626 | 626 | if (@$_POST['sides'][$bid] < 0) { |
| 627 | - $visible = 0 ; |
|
| 628 | - $_POST['sides'][$bid] = -1 ; |
|
| 627 | + $visible = 0; |
|
| 628 | + $_POST['sides'][$bid] = -1; |
|
| 629 | 629 | } else { |
| 630 | - $visible = 1 ; |
|
| 630 | + $visible = 1; |
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | return array( |
| 634 | - 'bid' => $bid , |
|
| 635 | - 'side' => intval(@$_POST['sides'][$bid]) , |
|
| 636 | - 'weight' => intval(@$_POST['weights'][$bid]) , |
|
| 637 | - 'visible' => $visible , |
|
| 638 | - 'title' => $myts->stripSlashesGPC(@$_POST['titles'][$bid]) , |
|
| 639 | - 'content' => $myts->stripSlashesGPC(@$_POST['contents'][$bid]) , |
|
| 640 | - 'ctype' => preg_replace('/[^A-Z]/', '', @$_POST['ctypes'][$bid]) , |
|
| 641 | - 'bcachetime' => intval(@$_POST['bcachetimes'][$bid]) , |
|
| 642 | - 'bmodule' => is_array(@$_POST['bmodules'][$bid]) ? $_POST['bmodules'][$bid] : array( 0 ) , |
|
| 643 | - 'bgroup' => is_array(@$_POST['bgroups'][$bid]) ? $_POST['bgroups'][$bid] : array() , |
|
| 644 | - 'options' => is_array(@$_POST['options'][$bid]) ? $_POST['options'][$bid] : array() , |
|
| 645 | - ) ; |
|
| 634 | + 'bid' => $bid, |
|
| 635 | + 'side' => intval(@$_POST['sides'][$bid]), |
|
| 636 | + 'weight' => intval(@$_POST['weights'][$bid]), |
|
| 637 | + 'visible' => $visible, |
|
| 638 | + 'title' => $myts->stripSlashesGPC(@$_POST['titles'][$bid]), |
|
| 639 | + 'content' => $myts->stripSlashesGPC(@$_POST['contents'][$bid]), |
|
| 640 | + 'ctype' => preg_replace('/[^A-Z]/', '', @$_POST['ctypes'][$bid]), |
|
| 641 | + 'bcachetime' => intval(@$_POST['bcachetimes'][$bid]), |
|
| 642 | + 'bmodule' => is_array(@$_POST['bmodules'][$bid]) ? $_POST['bmodules'][$bid] : array(0), |
|
| 643 | + 'bgroup' => is_array(@$_POST['bgroups'][$bid]) ? $_POST['bgroups'][$bid] : array(), |
|
| 644 | + 'options' => is_array(@$_POST['options'][$bid]) ? $_POST['options'][$bid] : array(), |
|
| 645 | + ); |
|
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | |
| 649 | 649 | public function do_delete($bid) |
| 650 | 650 | { |
| 651 | - $bid = intval($bid) ; |
|
| 651 | + $bid = intval($bid); |
|
| 652 | 652 | |
| 653 | 653 | //HACK by domifara |
| 654 | 654 | if (defined('XOOPS_CUBE_LEGACY')) { |
| 655 | - $handler =& xoops_gethandler('block'); |
|
| 656 | - $block =& $handler->create(false) ; |
|
| 657 | - $block->load($bid) ; |
|
| 655 | + $handler = & xoops_gethandler('block'); |
|
| 656 | + $block = & $handler->create(false); |
|
| 657 | + $block->load($bid); |
|
| 658 | 658 | } else { |
| 659 | - $block = new XoopsBlock($bid) ; |
|
| 659 | + $block = new XoopsBlock($bid); |
|
| 660 | 660 | } |
| 661 | 661 | |
| 662 | - if (! is_object($block)) { |
|
| 663 | - die('Invalid bid') ; |
|
| 662 | + if (!is_object($block)) { |
|
| 663 | + die('Invalid bid'); |
|
| 664 | 664 | } |
| 665 | - if (! $this->canDelete($block)) { |
|
| 666 | - die('Cannot delete this block') ; |
|
| 665 | + if (!$this->canDelete($block)) { |
|
| 666 | + die('Cannot delete this block'); |
|
| 667 | 667 | } |
| 668 | 668 | $this->do_deleteBlockReadGroupPerm($bid); //HACK add by domifara |
| 669 | - $block->delete() ; |
|
| 670 | - return _MD_A_MYBLOCKSADMIN_DBUPDATED ; |
|
| 669 | + $block->delete(); |
|
| 670 | + return _MD_A_MYBLOCKSADMIN_DBUPDATED; |
|
| 671 | 671 | } |
| 672 | 672 | |
| 673 | 673 | //HACK add by domifara |
| 674 | 674 | public function do_deleteBlockReadGroupPerm($bid) |
| 675 | 675 | { |
| 676 | - $bid = intval($bid) ; |
|
| 677 | - $table = $this->db->prefix("group_permission") ; |
|
| 678 | - $sql = "DELETE FROM `$table` WHERE gperm_name='block_read' AND `gperm_itemid`=$bid" ; |
|
| 679 | - $this->db->query($sql) ; |
|
| 676 | + $bid = intval($bid); |
|
| 677 | + $table = $this->db->prefix("group_permission"); |
|
| 678 | + $sql = "DELETE FROM `$table` WHERE gperm_name='block_read' AND `gperm_itemid`=$bid"; |
|
| 679 | + $this->db->query($sql); |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | public function form_delete($bid) |
| 683 | 683 | { |
| 684 | - $bid = intval($bid) ; |
|
| 684 | + $bid = intval($bid); |
|
| 685 | 685 | |
| 686 | 686 | //HACK by domifara |
| 687 | 687 | //HACK by domifara |
| 688 | 688 | if (defined('XOOPS_CUBE_LEGACY')) { |
| 689 | - $handler =& xoops_gethandler('block'); |
|
| 690 | - $block =& $handler->create(false) ; |
|
| 691 | - $block->load($bid) ; |
|
| 689 | + $handler = & xoops_gethandler('block'); |
|
| 690 | + $block = & $handler->create(false); |
|
| 691 | + $block->load($bid); |
|
| 692 | 692 | } else { |
| 693 | - $block = new XoopsBlock($bid) ; |
|
| 693 | + $block = new XoopsBlock($bid); |
|
| 694 | 694 | } |
| 695 | 695 | |
| 696 | - if (! is_object($block)) { |
|
| 697 | - die('Invalid bid') ; |
|
| 696 | + if (!is_object($block)) { |
|
| 697 | + die('Invalid bid'); |
|
| 698 | 698 | } |
| 699 | - if (! $this->canDelete($block)) { |
|
| 700 | - die('Cannot delete this block') ; |
|
| 699 | + if (!$this->canDelete($block)) { |
|
| 700 | + die('Cannot delete this block'); |
|
| 701 | 701 | } |
| 702 | 702 | |
| 703 | 703 | // breadcrumbs |
| 704 | - $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
| 705 | - $breadcrumbsObj->appendPath('', _DELETE) ; |
|
| 704 | + $breadcrumbsObj = & AltsysBreadcrumbs::getInstance(); |
|
| 705 | + $breadcrumbsObj->appendPath('', _DELETE); |
|
| 706 | 706 | |
| 707 | - xoops_confirm(array( 'op' => 'delete_ok' ) + $GLOBALS['xoopsGTicket']->getTicketArray(__LINE__, 1800, 'myblocksadmin'), "?mode=admin&lib=altsys&page=myblocksadmin&dirname=$this->target_dirname&bid=$bid", sprintf(_MD_A_MYBLOCKSADMIN_FMT_REMOVEBLOCK, $block->getVar('title'))) ; |
|
| 707 | + xoops_confirm(array('op' => 'delete_ok') + $GLOBALS['xoopsGTicket']->getTicketArray(__LINE__, 1800, 'myblocksadmin'), "?mode=admin&lib=altsys&page=myblocksadmin&dirname=$this->target_dirname&bid=$bid", sprintf(_MD_A_MYBLOCKSADMIN_FMT_REMOVEBLOCK, $block->getVar('title'))); |
|
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | |
| 711 | 711 | public function do_clone($bid) |
| 712 | 712 | { |
| 713 | - $bid = intval($bid) ; |
|
| 713 | + $bid = intval($bid); |
|
| 714 | 714 | |
| 715 | - $request = $this->fetchRequest4Block($bid) ; |
|
| 715 | + $request = $this->fetchRequest4Block($bid); |
|
| 716 | 716 | |
| 717 | 717 | //HACK by domifara |
| 718 | 718 | if (defined('XOOPS_CUBE_LEGACY')) { |
| 719 | - $handler =& xoops_gethandler('block'); |
|
| 720 | - $block =& $handler->create(false) ; |
|
| 721 | - $block->load($bid) ; |
|
| 719 | + $handler = & xoops_gethandler('block'); |
|
| 720 | + $block = & $handler->create(false); |
|
| 721 | + $block->load($bid); |
|
| 722 | 722 | } else { |
| 723 | - $block = new XoopsBlock($bid) ; |
|
| 723 | + $block = new XoopsBlock($bid); |
|
| 724 | 724 | } |
| 725 | 725 | |
| 726 | - if (! $block->getVar('bid')) { |
|
| 727 | - die('Invalid bid') ; |
|
| 726 | + if (!$block->getVar('bid')) { |
|
| 727 | + die('Invalid bid'); |
|
| 728 | 728 | } |
| 729 | - if (! $this->canClone($block)) { |
|
| 730 | - die('Invalid block_type') ; |
|
| 729 | + if (!$this->canClone($block)) { |
|
| 730 | + die('Invalid block_type'); |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | if (empty($_POST['options'])) { |
| 734 | - $options = array() ; |
|
| 734 | + $options = array(); |
|
| 735 | 735 | } elseif (is_array($_POST['options'])) { |
| 736 | - $options = $_POST['options'] ; |
|
| 736 | + $options = $_POST['options']; |
|
| 737 | 737 | } else { |
| 738 | - $options = explode('|', $_POST['options']) ; |
|
| 738 | + $options = explode('|', $_POST['options']); |
|
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | // for backward compatibility |
@@ -743,150 +743,150 @@ discard block |
||
| 743 | 743 | |
| 744 | 744 | //HACK by domifara |
| 745 | 745 | if (defined('XOOPS_CUBE_LEGACY')) { |
| 746 | - $cblock =& $handler->create(false) ; |
|
| 746 | + $cblock = & $handler->create(false); |
|
| 747 | 747 | } else { |
| 748 | - $cblock = new XoopsBlock() ; |
|
| 748 | + $cblock = new XoopsBlock(); |
|
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | foreach ($block->vars as $k => $v) { |
| 752 | - $cblock->assignVar($k, $v['value']) ; |
|
| 752 | + $cblock->assignVar($k, $v['value']); |
|
| 753 | 753 | } |
| 754 | 754 | $cblock->setNew(); |
| 755 | 755 | $cblock->setVar('bid', 0); |
| 756 | 756 | $cblock->setVar('block_type', $block->getVar('block_type') == 'C' ? 'C' : 'D'); |
| 757 | - $cblock->setVar('func_num', $this->find_func_num_vacancy($block->getVar('mid'))) ; |
|
| 757 | + $cblock->setVar('func_num', $this->find_func_num_vacancy($block->getVar('mid'))); |
|
| 758 | 758 | // store the block into DB as a new one |
| 759 | - $newbid = $cblock->store() ; |
|
| 760 | - if (! $newbid) { |
|
| 761 | - return $cblock->getHtmlErrors() ; |
|
| 759 | + $newbid = $cblock->store(); |
|
| 760 | + if (!$newbid) { |
|
| 761 | + return $cblock->getHtmlErrors(); |
|
| 762 | 762 | } |
| 763 | 763 | |
| 764 | 764 | // update the block by the request |
| 765 | - $this->update_block($newbid, $request['side'], $request['weight'], $request['visible'], $request['title'], $request['content'], $request['ctype'], $request['bcachetime'], is_array(@$_POST['options']) ? $_POST['options'] : array()) ; |
|
| 765 | + $this->update_block($newbid, $request['side'], $request['weight'], $request['visible'], $request['title'], $request['content'], $request['ctype'], $request['bcachetime'], is_array(@$_POST['options']) ? $_POST['options'] : array()); |
|
| 766 | 766 | |
| 767 | 767 | // block_module_link update |
| 768 | - $this->updateBlockModuleLink($newbid, $request['bmodule']) ; |
|
| 768 | + $this->updateBlockModuleLink($newbid, $request['bmodule']); |
|
| 769 | 769 | |
| 770 | 770 | // group_permission update |
| 771 | - $this->updateBlockReadGroupPerm($newbid, $request['bgroup']) ; |
|
| 771 | + $this->updateBlockReadGroupPerm($newbid, $request['bgroup']); |
|
| 772 | 772 | |
| 773 | - return _MD_A_MYBLOCKSADMIN_DBUPDATED ; |
|
| 773 | + return _MD_A_MYBLOCKSADMIN_DBUPDATED; |
|
| 774 | 774 | } |
| 775 | 775 | |
| 776 | 776 | |
| 777 | 777 | public function find_func_num_vacancy($mid) |
| 778 | 778 | { |
| 779 | - $func_num = 256 ; |
|
| 779 | + $func_num = 256; |
|
| 780 | 780 | do { |
| 781 | - $func_num -- ; |
|
| 782 | - list($count) = $this->db->fetchRow($this->db->query("SELECT COUNT(*) FROM ".$this->db->prefix("newblocks")." WHERE mid=".intval($mid)." AND func_num=".$func_num)) ; |
|
| 783 | - } while ($count > 0) ; |
|
| 781 | + $func_num--; |
|
| 782 | + list($count) = $this->db->fetchRow($this->db->query("SELECT COUNT(*) FROM ".$this->db->prefix("newblocks")." WHERE mid=".intval($mid)." AND func_num=".$func_num)); |
|
| 783 | + } while ($count > 0); |
|
| 784 | 784 | |
| 785 | - return $func_num > 128 ? $func_num : 255 ; |
|
| 785 | + return $func_num > 128 ? $func_num : 255; |
|
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | |
| 789 | 789 | public function do_edit($bid) |
| 790 | 790 | { |
| 791 | - $bid = intval($bid) ; |
|
| 791 | + $bid = intval($bid); |
|
| 792 | 792 | |
| 793 | 793 | if ($bid <= 0) { |
| 794 | 794 | // new custom block |
| 795 | 795 | |
| 796 | 796 | //HACK by domifara |
| 797 | 797 | if (defined('XOOPS_CUBE_LEGACY')) { |
| 798 | - $handler =& xoops_gethandler('block'); |
|
| 799 | - $new_block =& $handler->create(false) ; |
|
| 798 | + $handler = & xoops_gethandler('block'); |
|
| 799 | + $new_block = & $handler->create(false); |
|
| 800 | 800 | } else { |
| 801 | - $new_block = new XoopsBlock() ; |
|
| 801 | + $new_block = new XoopsBlock(); |
|
| 802 | 802 | } |
| 803 | 803 | |
| 804 | - $new_block->setNew() ; |
|
| 805 | - $new_block->setVar('name', $this->get_blockname_from_ctype('C')) ; |
|
| 806 | - $new_block->setVar('block_type', 'C') ; |
|
| 807 | - $new_block->setVar('func_num', 0) ; |
|
| 808 | - $bid = $new_block->store() ; |
|
| 809 | - $request = $this->fetchRequest4Block(0) ; |
|
| 804 | + $new_block->setNew(); |
|
| 805 | + $new_block->setVar('name', $this->get_blockname_from_ctype('C')); |
|
| 806 | + $new_block->setVar('block_type', 'C'); |
|
| 807 | + $new_block->setVar('func_num', 0); |
|
| 808 | + $bid = $new_block->store(); |
|
| 809 | + $request = $this->fetchRequest4Block(0); |
|
| 810 | 810 | // permission copy |
| 811 | 811 | foreach ($GLOBALS['xoopsUser']->getGroups() as $gid) { |
| 812 | 812 | $sql = "INSERT INTO ".$this->db->prefix('group_permission')." (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES ($gid, $bid, 1, 'block_read')"; |
| 813 | 813 | $this->db->query($sql); |
| 814 | 814 | } |
| 815 | 815 | } else { |
| 816 | - $request = $this->fetchRequest4Block($bid) ; |
|
| 816 | + $request = $this->fetchRequest4Block($bid); |
|
| 817 | 817 | } |
| 818 | 818 | |
| 819 | 819 | // update the block by the request |
| 820 | - $msg = $this->update_block($bid, $request['side'], $request['weight'], $request['visible'], $request['title'], $request['content'], $request['ctype'], $request['bcachetime'], is_array(@$_POST['options']) ? $_POST['options'] : array()) ; |
|
| 820 | + $msg = $this->update_block($bid, $request['side'], $request['weight'], $request['visible'], $request['title'], $request['content'], $request['ctype'], $request['bcachetime'], is_array(@$_POST['options']) ? $_POST['options'] : array()); |
|
| 821 | 821 | |
| 822 | 822 | // block_module_link update |
| 823 | - $this->updateBlockModuleLink($bid, $request['bmodule']) ; |
|
| 823 | + $this->updateBlockModuleLink($bid, $request['bmodule']); |
|
| 824 | 824 | |
| 825 | 825 | // group_permission update |
| 826 | - $this->updateBlockReadGroupPerm($bid, $request['bgroup']) ; |
|
| 826 | + $this->updateBlockReadGroupPerm($bid, $request['bgroup']); |
|
| 827 | 827 | |
| 828 | - return $msg ; |
|
| 828 | + return $msg; |
|
| 829 | 829 | } |
| 830 | 830 | |
| 831 | 831 | |
| 832 | 832 | public function form_edit($bid, $mode = 'edit') |
| 833 | 833 | { |
| 834 | - $bid = intval($bid) ; |
|
| 834 | + $bid = intval($bid); |
|
| 835 | 835 | |
| 836 | 836 | //HACK by domifara |
| 837 | 837 | if (defined('XOOPS_CUBE_LEGACY')) { |
| 838 | - $handler =& xoops_gethandler('block'); |
|
| 839 | - $block =& $handler->create(false) ; |
|
| 840 | - $block->load($bid) ; |
|
| 838 | + $handler = & xoops_gethandler('block'); |
|
| 839 | + $block = & $handler->create(false); |
|
| 840 | + $block->load($bid); |
|
| 841 | 841 | } else { |
| 842 | - $block = new XoopsBlock($bid) ; |
|
| 842 | + $block = new XoopsBlock($bid); |
|
| 843 | 843 | } |
| 844 | 844 | |
| 845 | - if (! $block->getVar('bid')) { |
|
| 845 | + if (!$block->getVar('bid')) { |
|
| 846 | 846 | // new defaults |
| 847 | - $bid = 0 ; |
|
| 848 | - $mode = 'new' ; |
|
| 849 | - $block->setVar('mid', 0) ; |
|
| 850 | - $block->setVar('block_type', 'C') ; |
|
| 847 | + $bid = 0; |
|
| 848 | + $mode = 'new'; |
|
| 849 | + $block->setVar('mid', 0); |
|
| 850 | + $block->setVar('block_type', 'C'); |
|
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | switch ($mode) { |
| 854 | 854 | case 'clone' : |
| 855 | - $form_title = _MD_A_MYBLOCKSADMIN_CLONEFORM ; |
|
| 856 | - $button_value = _MD_A_MYBLOCKSADMIN_BTN_CLONE ; |
|
| 857 | - $next_op = 'clone_ok' ; |
|
| 855 | + $form_title = _MD_A_MYBLOCKSADMIN_CLONEFORM; |
|
| 856 | + $button_value = _MD_A_MYBLOCKSADMIN_BTN_CLONE; |
|
| 857 | + $next_op = 'clone_ok'; |
|
| 858 | 858 | // breadcrumbs |
| 859 | - $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
| 860 | - $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_CLONEFORM) ; |
|
| 861 | - break ; |
|
| 859 | + $breadcrumbsObj = & AltsysBreadcrumbs::getInstance(); |
|
| 860 | + $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_CLONEFORM); |
|
| 861 | + break; |
|
| 862 | 862 | case 'new' : |
| 863 | - $form_title = _MD_A_MYBLOCKSADMIN_NEWFORM ; |
|
| 864 | - $button_value = _MD_A_MYBLOCKSADMIN_BTN_NEW ; |
|
| 865 | - $next_op = 'new_ok' ; |
|
| 863 | + $form_title = _MD_A_MYBLOCKSADMIN_NEWFORM; |
|
| 864 | + $button_value = _MD_A_MYBLOCKSADMIN_BTN_NEW; |
|
| 865 | + $next_op = 'new_ok'; |
|
| 866 | 866 | // breadcrumbs |
| 867 | - $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
| 868 | - $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_NEWFORM) ; |
|
| 869 | - break ; |
|
| 867 | + $breadcrumbsObj = & AltsysBreadcrumbs::getInstance(); |
|
| 868 | + $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_NEWFORM); |
|
| 869 | + break; |
|
| 870 | 870 | case 'edit' : |
| 871 | 871 | default : |
| 872 | - $form_title = _MD_A_MYBLOCKSADMIN_EDITFORM ; |
|
| 873 | - $button_value = _MD_A_MYBLOCKSADMIN_BTN_EDIT ; |
|
| 874 | - $next_op = 'edit_ok' ; |
|
| 872 | + $form_title = _MD_A_MYBLOCKSADMIN_EDITFORM; |
|
| 873 | + $button_value = _MD_A_MYBLOCKSADMIN_BTN_EDIT; |
|
| 874 | + $next_op = 'edit_ok'; |
|
| 875 | 875 | // breadcrumbs |
| 876 | - $breadcrumbsObj =& AltsysBreadcrumbs::getInstance() ; |
|
| 877 | - $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_EDITFORM) ; |
|
| 878 | - break ; |
|
| 876 | + $breadcrumbsObj = & AltsysBreadcrumbs::getInstance(); |
|
| 877 | + $breadcrumbsObj->appendPath('', _MD_A_MYBLOCKSADMIN_EDITFORM); |
|
| 878 | + break; |
|
| 879 | 879 | } |
| 880 | 880 | |
| 881 | - $is_custom = in_array($block->getVar('block_type'), array( 'C', 'E' )) ? true : false ; |
|
| 882 | - $block_template = $block->getVar('template', 'n') ; |
|
| 883 | - $block_template_tplset = '' ; |
|
| 881 | + $is_custom = in_array($block->getVar('block_type'), array('C', 'E')) ? true : false; |
|
| 882 | + $block_template = $block->getVar('template', 'n'); |
|
| 883 | + $block_template_tplset = ''; |
|
| 884 | 884 | |
| 885 | - if (! $is_custom && $block_template) { |
|
| 885 | + if (!$is_custom && $block_template) { |
|
| 886 | 886 | // find template of the block |
| 887 | - $tplfile_handler =& xoops_gethandler('tplfile'); |
|
| 888 | - $found_templates = $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', null, null, $block_template) ; |
|
| 889 | - $block_template_tplset = count($found_templates) > 0 ? $GLOBALS['xoopsConfig']['template_set'] : 'default' ; |
|
| 887 | + $tplfile_handler = & xoops_gethandler('tplfile'); |
|
| 888 | + $found_templates = $tplfile_handler->find($GLOBALS['xoopsConfig']['template_set'], 'block', null, null, $block_template); |
|
| 889 | + $block_template_tplset = count($found_templates) > 0 ? $GLOBALS['xoopsConfig']['template_set'] : 'default'; |
|
| 890 | 890 | } |
| 891 | 891 | //HACK by domifara |
| 892 | 892 | /* |
@@ -895,43 +895,43 @@ discard block |
||
| 895 | 895 | } |
| 896 | 896 | */ |
| 897 | 897 | $block_data = $this->preview_request + array( |
| 898 | - 'bid' => $bid , |
|
| 899 | - 'name' => $block->getVar('name', 'n') , |
|
| 900 | - 'title' => $block->getVar('title', 'n') , |
|
| 901 | - 'weight' => intval($block->getVar('weight')) , |
|
| 902 | - 'bcachetime' => intval($block->getVar('bcachetime')) , |
|
| 903 | - 'side' => intval($block->getVar('side')) , |
|
| 904 | - 'visible' => intval($block->getVar('visible')) , |
|
| 905 | - 'template' => $block_template , |
|
| 906 | - 'template_tplset' => $block_template_tplset , |
|
| 907 | - 'options' => $block->getVar('options') , |
|
| 908 | - 'content' => $block->getVar('content', 'n') , |
|
| 909 | - 'is_custom' => $is_custom , |
|
| 910 | - 'type' => $block->getVar('block_type') , |
|
| 911 | - 'ctype' => $block->getVar('c_type') , |
|
| 912 | - ) ; |
|
| 898 | + 'bid' => $bid, |
|
| 899 | + 'name' => $block->getVar('name', 'n'), |
|
| 900 | + 'title' => $block->getVar('title', 'n'), |
|
| 901 | + 'weight' => intval($block->getVar('weight')), |
|
| 902 | + 'bcachetime' => intval($block->getVar('bcachetime')), |
|
| 903 | + 'side' => intval($block->getVar('side')), |
|
| 904 | + 'visible' => intval($block->getVar('visible')), |
|
| 905 | + 'template' => $block_template, |
|
| 906 | + 'template_tplset' => $block_template_tplset, |
|
| 907 | + 'options' => $block->getVar('options'), |
|
| 908 | + 'content' => $block->getVar('content', 'n'), |
|
| 909 | + 'is_custom' => $is_custom, |
|
| 910 | + 'type' => $block->getVar('block_type'), |
|
| 911 | + 'ctype' => $block->getVar('c_type'), |
|
| 912 | + ); |
|
| 913 | 913 | |
| 914 | 914 | $block4assign = array( |
| 915 | - 'name_raw' => $block_data['name'] , |
|
| 916 | - 'title_raw' => $block_data['title'] , |
|
| 917 | - 'content_raw' => $block_data['content'] , |
|
| 918 | - 'cell_position' => $this->renderCell4BlockPosition($block_data) , |
|
| 919 | - 'cell_module_link' => $this->renderCell4BlockModuleLink($block_data) , |
|
| 920 | - 'cell_group_perm' => $this->renderCell4BlockReadGroupPerm($block_data) , |
|
| 921 | - 'cell_options' => $this->renderCell4BlockOptions($block_data) , |
|
| 922 | - 'content_preview' => $this->previewContent($block_data) , |
|
| 923 | - ) + $block_data ; |
|
| 915 | + 'name_raw' => $block_data['name'], |
|
| 916 | + 'title_raw' => $block_data['title'], |
|
| 917 | + 'content_raw' => $block_data['content'], |
|
| 918 | + 'cell_position' => $this->renderCell4BlockPosition($block_data), |
|
| 919 | + 'cell_module_link' => $this->renderCell4BlockModuleLink($block_data), |
|
| 920 | + 'cell_group_perm' => $this->renderCell4BlockReadGroupPerm($block_data), |
|
| 921 | + 'cell_options' => $this->renderCell4BlockOptions($block_data), |
|
| 922 | + 'content_preview' => $this->previewContent($block_data), |
|
| 923 | + ) + $block_data; |
|
| 924 | 924 | |
| 925 | 925 | // display |
| 926 | - require_once XOOPS_TRUST_PATH.'/libs/altsys/class/D3Tpl.class.php' ; |
|
| 927 | - $tpl = new D3Tpl() ; |
|
| 926 | + require_once XOOPS_TRUST_PATH.'/libs/altsys/class/D3Tpl.class.php'; |
|
| 927 | + $tpl = new D3Tpl(); |
|
| 928 | 928 | |
| 929 | 929 | //HACK by domifara |
| 930 | 930 | if (defined('XOOPS_CUBE_LEGACY')) { |
| 931 | - $tpl->assign('xoops_cube_legacy', true) ; |
|
| 931 | + $tpl->assign('xoops_cube_legacy', true); |
|
| 932 | 932 | include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php'; |
| 933 | 933 | } else { |
| 934 | - $tpl->assign('xoops_cube_legacy', false) ; |
|
| 934 | + $tpl->assign('xoops_cube_legacy', false); |
|
| 935 | 935 | } |
| 936 | 936 | |
| 937 | 937 | $tpl->assign(array( |
@@ -946,14 +946,14 @@ discard block |
||
| 946 | 946 | 'submit_button' => $button_value, |
| 947 | 947 | 'common_fck_installed' => $this->checkFck(), |
| 948 | 948 | 'gticket_hidden' => $GLOBALS['xoopsGTicket']->getTicketHtml(__LINE__, 1800, 'myblocksadmin'), |
| 949 | - )) ; |
|
| 949 | + )); |
|
| 950 | 950 | |
| 951 | 951 | if (defined('XOOPS_CUBE_LEGACY')) { |
| 952 | - $tpl->display('db:altsys_main_myblocksadmin_edit_4legacy.html') ; |
|
| 952 | + $tpl->display('db:altsys_main_myblocksadmin_edit_4legacy.html'); |
|
| 953 | 953 | } else { |
| 954 | - $tpl->display('db:altsys_main_myblocksadmin_edit.html') ; |
|
| 954 | + $tpl->display('db:altsys_main_myblocksadmin_edit.html'); |
|
| 955 | 955 | } |
| 956 | - return ; |
|
| 956 | + return; |
|
| 957 | 957 | } |
| 958 | 958 | |
| 959 | 959 | public function checkFck() |
@@ -963,18 +963,18 @@ discard block |
||
| 963 | 963 | |
| 964 | 964 | public function previewContent($block_data) |
| 965 | 965 | { |
| 966 | - $bid = intval($block_data['bid']) ; |
|
| 966 | + $bid = intval($block_data['bid']); |
|
| 967 | 967 | |
| 968 | - if (! $block_data['is_custom']) { |
|
| 969 | - return '' ; |
|
| 968 | + if (!$block_data['is_custom']) { |
|
| 969 | + return ''; |
|
| 970 | 970 | } |
| 971 | 971 | if (empty($this->preview_request)) { |
| 972 | - return '' ; |
|
| 972 | + return ''; |
|
| 973 | 973 | } |
| 974 | 974 | |
| 975 | 975 | //HACK by domifara |
| 976 | 976 | //TODO : need no hook block at this |
| 977 | - $block = new XoopsBlock($bid) ; |
|
| 977 | + $block = new XoopsBlock($bid); |
|
| 978 | 978 | /* |
| 979 | 979 | $handler =& xoops_gethandler('block'); |
| 980 | 980 | $block =& $handler->create(false) ; |
@@ -982,92 +982,92 @@ discard block |
||
| 982 | 982 | */ |
| 983 | 983 | |
| 984 | 984 | if ($block->getVar('mid')) { |
| 985 | - return '' ; |
|
| 985 | + return ''; |
|
| 986 | 986 | } |
| 987 | 987 | |
| 988 | - $block->setVar('title', $block_data['title']) ; |
|
| 989 | - $block->setVar('content', $block_data['content']) ; |
|
| 988 | + $block->setVar('title', $block_data['title']); |
|
| 989 | + $block->setVar('content', $block_data['content']); |
|
| 990 | 990 | |
| 991 | - restore_error_handler() ; |
|
| 992 | - $original_level = error_reporting(E_ALL) ; |
|
| 993 | - $ret = $block->getContent('S', $block_data['ctype']) ; |
|
| 994 | - error_reporting($original_level) ; |
|
| 991 | + restore_error_handler(); |
|
| 992 | + $original_level = error_reporting(E_ALL); |
|
| 993 | + $ret = $block->getContent('S', $block_data['ctype']); |
|
| 994 | + error_reporting($original_level); |
|
| 995 | 995 | |
| 996 | - return $ret ; |
|
| 996 | + return $ret; |
|
| 997 | 997 | } |
| 998 | 998 | |
| 999 | 999 | |
| 1000 | 1000 | public function get_blockname_from_ctype($bctype) |
| 1001 | 1001 | { |
| 1002 | 1002 | $ctypes = array( |
| 1003 | - 'H' => _MD_A_MYBLOCKSADMIN_CTYPE_HTML , |
|
| 1004 | - 'S' => _MD_A_MYBLOCKSADMIN_CTYPE_SMILE , |
|
| 1005 | - 'N' => _MD_A_MYBLOCKSADMIN_CTYPE_NOSMILE , |
|
| 1006 | - 'P' => _MD_A_MYBLOCKSADMIN_CTYPE_PHP , |
|
| 1007 | - ) ; |
|
| 1003 | + 'H' => _MD_A_MYBLOCKSADMIN_CTYPE_HTML, |
|
| 1004 | + 'S' => _MD_A_MYBLOCKSADMIN_CTYPE_SMILE, |
|
| 1005 | + 'N' => _MD_A_MYBLOCKSADMIN_CTYPE_NOSMILE, |
|
| 1006 | + 'P' => _MD_A_MYBLOCKSADMIN_CTYPE_PHP, |
|
| 1007 | + ); |
|
| 1008 | 1008 | |
| 1009 | - return isset($ctypes[$bctype]) ? $ctypes[$bctype] : _MD_A_MYBLOCKSADMIN_CTYPE_SMILE ; |
|
| 1009 | + return isset($ctypes[$bctype]) ? $ctypes[$bctype] : _MD_A_MYBLOCKSADMIN_CTYPE_SMILE; |
|
| 1010 | 1010 | } |
| 1011 | 1011 | |
| 1012 | 1012 | |
| 1013 | 1013 | public function processPost() |
| 1014 | 1014 | { |
| 1015 | 1015 | // Ticket Check |
| 1016 | - if (! $GLOBALS['xoopsGTicket']->check(true, 'myblocksadmin')) { |
|
| 1016 | + if (!$GLOBALS['xoopsGTicket']->check(true, 'myblocksadmin')) { |
|
| 1017 | 1017 | redirect_header(XOOPS_URL.'/', 3, $GLOBALS['xoopsGTicket']->getErrors()); |
| 1018 | 1018 | } |
| 1019 | 1019 | |
| 1020 | - $msg = '' ; |
|
| 1021 | - $bid = intval(@$_GET['bid']) ; |
|
| 1022 | - if (! empty($_POST['preview'])) { |
|
| 1020 | + $msg = ''; |
|
| 1021 | + $bid = intval(@$_GET['bid']); |
|
| 1022 | + if (!empty($_POST['preview'])) { |
|
| 1023 | 1023 | // preview |
| 1024 | - $this->preview_request = $this->fetchRequest4Block($bid) ; |
|
| 1025 | - $_GET['op'] = str_replace('_ok', '', @$_POST['op']) ; |
|
| 1026 | - return ; // continue ; |
|
| 1024 | + $this->preview_request = $this->fetchRequest4Block($bid); |
|
| 1025 | + $_GET['op'] = str_replace('_ok', '', @$_POST['op']); |
|
| 1026 | + return; // continue ; |
|
| 1027 | 1027 | } elseif (@$_POST['op'] == 'order') { |
| 1028 | 1028 | // order ok |
| 1029 | - $msg = $this->do_order() ; |
|
| 1029 | + $msg = $this->do_order(); |
|
| 1030 | 1030 | } elseif (@$_POST['op'] == 'delete_ok') { |
| 1031 | 1031 | // delete ok |
| 1032 | - $msg = $this->do_delete($bid) ; |
|
| 1032 | + $msg = $this->do_delete($bid); |
|
| 1033 | 1033 | } elseif (@$_POST['op'] == 'clone_ok') { |
| 1034 | 1034 | // clone ok |
| 1035 | - $msg = $this->do_clone($bid) ; |
|
| 1035 | + $msg = $this->do_clone($bid); |
|
| 1036 | 1036 | } elseif (@$_POST['op'] == 'edit_ok' || @$_POST['op'] == 'new_ok') { |
| 1037 | 1037 | // edit ok |
| 1038 | - $msg = $this->do_edit($bid) ; |
|
| 1039 | - } elseif (! empty($_POST['submit'])) { |
|
| 1038 | + $msg = $this->do_edit($bid); |
|
| 1039 | + } elseif (!empty($_POST['submit'])) { |
|
| 1040 | 1040 | // update module_admin,module_read,block_read |
| 1041 | - include dirname(dirname(__FILE__)).'/include/mygroupperm.php' ; |
|
| 1042 | - $msg = _MD_A_MYBLOCKSADMIN_PERMUPDATED ; |
|
| 1041 | + include dirname(dirname(__FILE__)).'/include/mygroupperm.php'; |
|
| 1042 | + $msg = _MD_A_MYBLOCKSADMIN_PERMUPDATED; |
|
| 1043 | 1043 | } |
| 1044 | 1044 | |
| 1045 | - redirect_header('?mode=admin&lib=altsys&page=myblocksadmin&dirname='.$this->target_dirname, 1, $msg) ; |
|
| 1046 | - exit ; |
|
| 1045 | + redirect_header('?mode=admin&lib=altsys&page=myblocksadmin&dirname='.$this->target_dirname, 1, $msg); |
|
| 1046 | + exit; |
|
| 1047 | 1047 | } |
| 1048 | 1048 | |
| 1049 | 1049 | |
| 1050 | 1050 | public function processGet() |
| 1051 | 1051 | { |
| 1052 | - $bid = intval(@$_GET['bid']) ; |
|
| 1052 | + $bid = intval(@$_GET['bid']); |
|
| 1053 | 1053 | switch (@$_GET['op']) { |
| 1054 | 1054 | case 'clone' : |
| 1055 | - $this->form_edit($bid, 'clone') ; |
|
| 1056 | - break ; |
|
| 1055 | + $this->form_edit($bid, 'clone'); |
|
| 1056 | + break; |
|
| 1057 | 1057 | case 'new' : |
| 1058 | 1058 | case 'edit' : |
| 1059 | - $this->form_edit($bid, 'edit') ; |
|
| 1060 | - break ; |
|
| 1059 | + $this->form_edit($bid, 'edit'); |
|
| 1060 | + break; |
|
| 1061 | 1061 | case 'delete' : |
| 1062 | - $this->form_delete($bid) ; |
|
| 1063 | - break ; |
|
| 1062 | + $this->form_delete($bid); |
|
| 1063 | + break; |
|
| 1064 | 1064 | case 'list' : |
| 1065 | 1065 | default : |
| 1066 | 1066 | // the first form (blocks) |
| 1067 | - $this->list_blocks() ; |
|
| 1067 | + $this->list_blocks(); |
|
| 1068 | 1068 | // the second form (groups) |
| 1069 | - $this->list_groups() ; |
|
| 1070 | - break ; |
|
| 1069 | + $this->list_groups(); |
|
| 1070 | + break; |
|
| 1071 | 1071 | } |
| 1072 | 1072 | } |
| 1073 | 1073 | } |
@@ -92,6 +92,9 @@ |
||
| 92 | 92 | |
| 93 | 93 | |
| 94 | 94 | // private |
| 95 | +/** |
|
| 96 | + * @param integer $target_side |
|
| 97 | + */ |
|
| 95 | 98 | public function renderRadio4BlockPosition($target_side, $block_data) |
| 96 | 99 | { |
| 97 | 100 | $bid = intval($block_data['bid']) ; |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once dirname(__FILE__).'/MyBlocksAdmin.class.php' ; |
|
| 3 | +require_once dirname(__FILE__).'/MyBlocksAdmin.class.php'; |
|
| 4 | 4 | |
| 5 | 5 | class MyBlocksAdminForICMS extends MyBlocksAdmin |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - public $block_positions = array() ; |
|
| 8 | + public $block_positions = array(); |
|
| 9 | 9 | |
| 10 | 10 | public function MyBlocksAadminForICMS() |
| 11 | 11 | { |
@@ -14,14 +14,14 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | public function construct() |
| 16 | 16 | { |
| 17 | - parent::construct() ; |
|
| 17 | + parent::construct(); |
|
| 18 | 18 | |
| 19 | - @include_once XOOPS_ROOT_PATH.'/modules/system/language/'.$this->lang.'/admin/blocksadmin.php' ; |
|
| 20 | - $result = $this->db->query("SELECT id,pname,title FROM ".$this->db->prefix("block_positions")) ; |
|
| 19 | + @include_once XOOPS_ROOT_PATH.'/modules/system/language/'.$this->lang.'/admin/blocksadmin.php'; |
|
| 20 | + $result = $this->db->query("SELECT id,pname,title FROM ".$this->db->prefix("block_positions")); |
|
| 21 | 21 | while (list($id, $pname, $title) = $this->db->fetchRow($result)) { |
| 22 | - $this->block_positions[ $id ] = defined($title) ? constant($title) : $title ; |
|
| 22 | + $this->block_positions[$id] = defined($title) ? constant($title) : $title; |
|
| 23 | 23 | } |
| 24 | - $this->block_positions[ -1 ] = _NONE ; |
|
| 24 | + $this->block_positions[ -1] = _NONE; |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | //HACK by domifara for php5.3+ |
@@ -31,7 +31,7 @@ discard block |
||
| 31 | 31 | static $instance; |
| 32 | 32 | if (!isset($instance)) { |
| 33 | 33 | $instance = new MyBlocksAdminForICMS(); |
| 34 | - $instance->construct() ; |
|
| 34 | + $instance->construct(); |
|
| 35 | 35 | } |
| 36 | 36 | return $instance; |
| 37 | 37 | } |
@@ -41,28 +41,28 @@ discard block |
||
| 41 | 41 | // link blocks - modules - pages |
| 42 | 42 | public function renderCell4BlockModuleLink($block_data) |
| 43 | 43 | { |
| 44 | - $bid = intval($block_data['bid']) ; |
|
| 44 | + $bid = intval($block_data['bid']); |
|
| 45 | 45 | |
| 46 | 46 | // get selected targets |
| 47 | 47 | if (is_array(@$block_data['bmodule'])) { |
| 48 | 48 | // bmodule origined from request (preview etc.) |
| 49 | - $selected_pages = $block_data['bmodule'] ; |
|
| 49 | + $selected_pages = $block_data['bmodule']; |
|
| 50 | 50 | } else { |
| 51 | 51 | // origined from the table of `block_module_link` |
| 52 | - $result = $this->db->query("SELECT module_id,page_id FROM ".$this->db->prefix('block_module_link')." WHERE block_id='$bid'") ; |
|
| 52 | + $result = $this->db->query("SELECT module_id,page_id FROM ".$this->db->prefix('block_module_link')." WHERE block_id='$bid'"); |
|
| 53 | 53 | $selected_pages = array(); |
| 54 | 54 | while (list($mid, $pid) = $this->db->fetchRow($result)) { |
| 55 | - $selected_pages[] = intval($mid) . '-' . intval($pid) ; |
|
| 55 | + $selected_pages[] = intval($mid).'-'.intval($pid); |
|
| 56 | 56 | } |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - $page_handler =& xoops_gethandler('page'); |
|
| 59 | + $page_handler = & xoops_gethandler('page'); |
|
| 60 | 60 | $ret = " |
| 61 | 61 | <select name='bmodules[$bid][]' size='5' multiple='multiple'> |
| 62 | 62 | ".$page_handler->getPageSelOptions($selected_pages)." |
| 63 | 63 | </select>" ; |
| 64 | 64 | |
| 65 | - return $ret ; |
|
| 65 | + return $ret; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
@@ -94,68 +94,68 @@ discard block |
||
| 94 | 94 | // private |
| 95 | 95 | public function renderRadio4BlockPosition($target_side, $block_data) |
| 96 | 96 | { |
| 97 | - $bid = intval($block_data['bid']) ; |
|
| 98 | - $visible = intval($block_data['visible']) ; |
|
| 99 | - $current_side = $visible ? intval($block_data['side']) : -1 ; |
|
| 97 | + $bid = intval($block_data['bid']); |
|
| 98 | + $visible = intval($block_data['visible']); |
|
| 99 | + $current_side = $visible ? intval($block_data['side']) : -1; |
|
| 100 | 100 | |
| 101 | - $label4disp = htmlspecialchars($this->block_positions[ $target_side ], ENT_QUOTES) ; |
|
| 101 | + $label4disp = htmlspecialchars($this->block_positions[$target_side], ENT_QUOTES); |
|
| 102 | 102 | |
| 103 | 103 | if ($current_side == $target_side) { |
| 104 | - $checked = "checked='checked'" ; |
|
| 105 | - $divstyle = $target_side == -1 ? "disabled" : "selected" ; |
|
| 104 | + $checked = "checked='checked'"; |
|
| 105 | + $divstyle = $target_side == -1 ? "disabled" : "selected"; |
|
| 106 | 106 | } else { |
| 107 | - $checked = "" ; |
|
| 108 | - $divstyle = "unselected" ; |
|
| 107 | + $checked = ""; |
|
| 108 | + $divstyle = "unselected"; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - return "<div class='blockposition $divstyle' title='$label4disp'><input type='radio' name='sides[$bid]' value='$target_side' class='blockposition' $checked /></div>" ; |
|
| 111 | + return "<div class='blockposition $divstyle' title='$label4disp'><input type='radio' name='sides[$bid]' value='$target_side' class='blockposition' $checked /></div>"; |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | |
| 115 | 115 | // private |
| 116 | 116 | public function renderRadio4BlockPositions($block_data, $skip_sides = array()) |
| 117 | 117 | { |
| 118 | - $bid = intval($block_data['bid']) ; |
|
| 119 | - $visible = intval($block_data['visible']) ; |
|
| 120 | - $current_side = $visible ? intval($block_data['side']) : -1 ; |
|
| 118 | + $bid = intval($block_data['bid']); |
|
| 119 | + $visible = intval($block_data['visible']); |
|
| 120 | + $current_side = $visible ? intval($block_data['side']) : -1; |
|
| 121 | 121 | |
| 122 | - $ret = '' ; |
|
| 122 | + $ret = ''; |
|
| 123 | 123 | foreach ($this->block_positions as $target_side => $label) { |
| 124 | 124 | if (in_array($target_side, $skip_sides)) { |
| 125 | - continue ; |
|
| 125 | + continue; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $label4disp = htmlspecialchars($label, ENT_QUOTES) ; |
|
| 128 | + $label4disp = htmlspecialchars($label, ENT_QUOTES); |
|
| 129 | 129 | |
| 130 | 130 | if ($current_side == $target_side) { |
| 131 | - $checked = "checked='checked'" ; |
|
| 132 | - $divstyle = $target_side == -1 ? "disabled" : "selected" ; |
|
| 131 | + $checked = "checked='checked'"; |
|
| 132 | + $divstyle = $target_side == -1 ? "disabled" : "selected"; |
|
| 133 | 133 | } else { |
| 134 | - $checked = "" ; |
|
| 135 | - $divstyle = "unselected" ; |
|
| 134 | + $checked = ""; |
|
| 135 | + $divstyle = "unselected"; |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - $ret .= "<div style='clear:both;'><div class='blockposition $divstyle' title='$label4disp'><input type='radio' name='sides[$bid]' id='sides_{$bid}_{$target_side}' value='$target_side' class='blockposition' $checked /></div><label for='sides_{$bid}_{$target_side}'>$label4disp</label></label></div>" ; |
|
| 138 | + $ret .= "<div style='clear:both;'><div class='blockposition $divstyle' title='$label4disp'><input type='radio' name='sides[$bid]' id='sides_{$bid}_{$target_side}' value='$target_side' class='blockposition' $checked /></div><label for='sides_{$bid}_{$target_side}'>$label4disp</label></label></div>"; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - return $ret ; |
|
| 141 | + return $ret; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | |
| 145 | 145 | // virtual |
| 146 | 146 | public function updateBlockModuleLink($bid, $bmodules) |
| 147 | 147 | { |
| 148 | - $bid = intval($bid) ; |
|
| 149 | - $table = $this->db->prefix("block_module_link") ; |
|
| 148 | + $bid = intval($bid); |
|
| 149 | + $table = $this->db->prefix("block_module_link"); |
|
| 150 | 150 | |
| 151 | - $sql = "DELETE FROM `$table` WHERE `block_id`=$bid" ; |
|
| 152 | - $this->db->query($sql) ; |
|
| 151 | + $sql = "DELETE FROM `$table` WHERE `block_id`=$bid"; |
|
| 152 | + $this->db->query($sql); |
|
| 153 | 153 | foreach ($bmodules as $mid) { |
| 154 | - $regs = explode('-', $mid) ; |
|
| 155 | - $module_id = intval(@$regs[0]) ; |
|
| 156 | - $page_id = intval(@$regs[1]) ; |
|
| 157 | - $sql = "INSERT INTO `$table` (`block_id`,`module_id`,`page_id`) VALUES ($bid,$module_id,$page_id)" ; |
|
| 158 | - $this->db->query($sql) ; |
|
| 154 | + $regs = explode('-', $mid); |
|
| 155 | + $module_id = intval(@$regs[0]); |
|
| 156 | + $page_id = intval(@$regs[1]); |
|
| 157 | + $sql = "INSERT INTO `$table` (`block_id`,`module_id`,`page_id`) VALUES ($bid,$module_id,$page_id)"; |
|
| 158 | + $this->db->query($sql); |
|
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | } |
@@ -69,6 +69,9 @@ |
||
| 69 | 69 | |
| 70 | 70 | |
| 71 | 71 | // private |
| 72 | +/** |
|
| 73 | + * @param integer $target_side |
|
| 74 | + */ |
|
| 72 | 75 | public function renderRadio4BlockPosition($target_side, $block_data) |
| 73 | 76 | { |
| 74 | 77 | $bid = intval($block_data['bid']) ; |
@@ -1,11 +1,11 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -require_once dirname(__FILE__).'/MyBlocksAdmin.class.php' ; |
|
| 3 | +require_once dirname(__FILE__).'/MyBlocksAdmin.class.php'; |
|
| 4 | 4 | |
| 5 | 5 | class MyBlocksAdminForX20S extends MyBlocksAdmin |
| 6 | 6 | { |
| 7 | 7 | |
| 8 | - public $block_positions = array() ; |
|
| 8 | + public $block_positions = array(); |
|
| 9 | 9 | |
| 10 | 10 | public function MyBlocksAadminForX20S() |
| 11 | 11 | { |
@@ -14,20 +14,20 @@ discard block |
||
| 14 | 14 | |
| 15 | 15 | public function construct() |
| 16 | 16 | { |
| 17 | - parent::construct() ; |
|
| 17 | + parent::construct(); |
|
| 18 | 18 | |
| 19 | - @include_once XOOPS_ROOT_PATH.'/modules/system/language/'.$this->lang.'/admin/blocksadmin.php' ; |
|
| 19 | + @include_once XOOPS_ROOT_PATH.'/modules/system/language/'.$this->lang.'/admin/blocksadmin.php'; |
|
| 20 | 20 | $this->block_positions = array( |
| 21 | - -1 => _NONE , |
|
| 22 | - 0 => _AM_SBLEFT , |
|
| 23 | - 1 => _AM_SBRIGHT , |
|
| 24 | - 3 => _AM_CBLEFT , |
|
| 25 | - 4 => _AM_CBRIGHT , |
|
| 26 | - 5 => _AM_CBCENTER , |
|
| 27 | - 7 => _AM_CBBOTTOMLEFT , |
|
| 28 | - 8 => _AM_CBBOTTOMRIGHT , |
|
| 29 | - 9 => _AM_CBBOTTOM , |
|
| 30 | - ) ; |
|
| 21 | + -1 => _NONE, |
|
| 22 | + 0 => _AM_SBLEFT, |
|
| 23 | + 1 => _AM_SBRIGHT, |
|
| 24 | + 3 => _AM_CBLEFT, |
|
| 25 | + 4 => _AM_CBRIGHT, |
|
| 26 | + 5 => _AM_CBCENTER, |
|
| 27 | + 7 => _AM_CBBOTTOMLEFT, |
|
| 28 | + 8 => _AM_CBBOTTOMRIGHT, |
|
| 29 | + 9 => _AM_CBBOTTOM, |
|
| 30 | + ); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | //HACK by domifara for php5.3+ |
@@ -37,7 +37,7 @@ discard block |
||
| 37 | 37 | static $instance; |
| 38 | 38 | if (!isset($instance)) { |
| 39 | 39 | $instance = new MyBlocksAdminForX20S(); |
| 40 | - $instance->construct() ; |
|
| 40 | + $instance->construct(); |
|
| 41 | 41 | } |
| 42 | 42 | return $instance; |
| 43 | 43 | } |
@@ -71,20 +71,20 @@ discard block |
||
| 71 | 71 | // private |
| 72 | 72 | public function renderRadio4BlockPosition($target_side, $block_data) |
| 73 | 73 | { |
| 74 | - $bid = intval($block_data['bid']) ; |
|
| 75 | - $visible = intval($block_data['visible']) ; |
|
| 76 | - $current_side = $visible ? intval($block_data['side']) : -1 ; |
|
| 74 | + $bid = intval($block_data['bid']); |
|
| 75 | + $visible = intval($block_data['visible']); |
|
| 76 | + $current_side = $visible ? intval($block_data['side']) : -1; |
|
| 77 | 77 | |
| 78 | - $label4disp = htmlspecialchars($this->block_positions[ $target_side ], ENT_QUOTES) ; |
|
| 78 | + $label4disp = htmlspecialchars($this->block_positions[$target_side], ENT_QUOTES); |
|
| 79 | 79 | |
| 80 | 80 | if ($current_side == $target_side) { |
| 81 | - $checked = "checked='checked'" ; |
|
| 82 | - $divstyle = $target_side == -1 ? "disabled" : "selected" ; |
|
| 81 | + $checked = "checked='checked'"; |
|
| 82 | + $divstyle = $target_side == -1 ? "disabled" : "selected"; |
|
| 83 | 83 | } else { |
| 84 | - $checked = "" ; |
|
| 85 | - $divstyle = "unselected" ; |
|
| 84 | + $checked = ""; |
|
| 85 | + $divstyle = "unselected"; |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - return "<div class='blockposition $divstyle' title='$label4disp'><input type='radio' name='sides[$bid]' value='$target_side' class='blockposition' $checked /></div>" ; |
|
| 88 | + return "<div class='blockposition $divstyle' title='$label4disp'><input type='radio' name='sides[$bid]' value='$target_side' class='blockposition' $checked /></div>"; |
|
| 89 | 89 | } |
| 90 | 90 | } |
@@ -47,6 +47,10 @@ |
||
| 47 | 47 | parent::prepare(); |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | + /** |
|
| 51 | + * @param string $dirname |
|
| 52 | + * @param string $fileBodyName |
|
| 53 | + */ |
|
| 50 | 54 | public function _loadLanguage($dirname, $fileBodyName) |
| 51 | 55 | { |
| 52 | 56 | // read/check once (selected_theme)/language/(lang).php |
@@ -1,15 +1,15 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (! defined('XOOPS_ROOT_PATH')) { |
|
| 4 | - exit ; |
|
| 3 | +if (!defined('XOOPS_ROOT_PATH')) { |
|
| 4 | + exit; |
|
| 5 | 5 | } |
| 6 | 6 | |
| 7 | -if (! defined('XOOPS_TRUST_PATH') || XOOPS_TRUST_PATH == '') { |
|
| 8 | - header('Location: '.XOOPS_URL.'/modules/altsys/setup_xoops_trust_path.php') ; |
|
| 9 | - exit ; |
|
| 7 | +if (!defined('XOOPS_TRUST_PATH') || XOOPS_TRUST_PATH == '') { |
|
| 8 | + header('Location: '.XOOPS_URL.'/modules/altsys/setup_xoops_trust_path.php'); |
|
| 9 | + exit; |
|
| 10 | 10 | } |
| 11 | 11 | |
| 12 | -define('ALTSYS_MYLANGUAGE_ROOT_PATH', XOOPS_ROOT_PATH . '/my_language'); |
|
| 12 | +define('ALTSYS_MYLANGUAGE_ROOT_PATH', XOOPS_ROOT_PATH.'/my_language'); |
|
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | class SetupAltsysLangMgr extends XCube_ActionFilter |
@@ -26,23 +26,23 @@ discard block |
||
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | |
| 29 | -require_once XOOPS_ROOT_PATH . "/core/XCube_LanguageManager.class.php"; |
|
| 30 | -require_once XOOPS_ROOT_PATH . "/modules/legacy/kernel/Legacy_LanguageManager.class.php"; |
|
| 29 | +require_once XOOPS_ROOT_PATH."/core/XCube_LanguageManager.class.php"; |
|
| 30 | +require_once XOOPS_ROOT_PATH."/modules/legacy/kernel/Legacy_LanguageManager.class.php"; |
|
| 31 | 31 | |
| 32 | 32 | class AltsysLangMgr_LanguageManager extends Legacy_LanguageManager |
| 33 | 33 | { |
| 34 | - public $langman = null ; |
|
| 35 | - public $theme_lang_checked = false ; |
|
| 34 | + public $langman = null; |
|
| 35 | + public $theme_lang_checked = false; |
|
| 36 | 36 | |
| 37 | 37 | public function prepare() |
| 38 | 38 | { |
| 39 | - $langmanpath = XOOPS_TRUST_PATH.'/libs/altsys/class/D3LanguageManager.class.php' ; |
|
| 40 | - if (! file_exists($langmanpath)) { |
|
| 41 | - die('install the latest altsys') ; |
|
| 39 | + $langmanpath = XOOPS_TRUST_PATH.'/libs/altsys/class/D3LanguageManager.class.php'; |
|
| 40 | + if (!file_exists($langmanpath)) { |
|
| 41 | + die('install the latest altsys'); |
|
| 42 | 42 | } |
| 43 | - require_once($langmanpath) ; |
|
| 44 | - $this->langman =& D3LanguageManager::getInstance() ; |
|
| 45 | - $this->langman->language = $this->mLanguageName ; |
|
| 43 | + require_once($langmanpath); |
|
| 44 | + $this->langman = & D3LanguageManager::getInstance(); |
|
| 45 | + $this->langman->language = $this->mLanguageName; |
|
| 46 | 46 | |
| 47 | 47 | parent::prepare(); |
| 48 | 48 | } |
@@ -50,40 +50,40 @@ discard block |
||
| 50 | 50 | public function _loadLanguage($dirname, $fileBodyName) |
| 51 | 51 | { |
| 52 | 52 | // read/check once (selected_theme)/language/(lang).php |
| 53 | - if (! $this->theme_lang_checked) { |
|
| 54 | - $root =& XCube_Root::getSingleton() ; |
|
| 55 | - if (! empty($root->mContext->mXoopsConfig['theme_set'])) { |
|
| 56 | - $langdir = XOOPS_THEME_PATH.'/'.$root->mContext->mXoopsConfig['theme_set'].'/language' ; |
|
| 53 | + if (!$this->theme_lang_checked) { |
|
| 54 | + $root = & XCube_Root::getSingleton(); |
|
| 55 | + if (!empty($root->mContext->mXoopsConfig['theme_set'])) { |
|
| 56 | + $langdir = XOOPS_THEME_PATH.'/'.$root->mContext->mXoopsConfig['theme_set'].'/language'; |
|
| 57 | 57 | if (file_exists($langdir)) { |
| 58 | - $langfile = $langdir.'/'.$this->mLanguageName.'.php' ; |
|
| 59 | - $engfile = $langdir.'/english.php' ; |
|
| 58 | + $langfile = $langdir.'/'.$this->mLanguageName.'.php'; |
|
| 59 | + $engfile = $langdir.'/english.php'; |
|
| 60 | 60 | if (file_exists($langfile)) { |
| 61 | - require_once $langfile ; |
|
| 61 | + require_once $langfile; |
|
| 62 | 62 | } elseif (file_exists($engfile)) { |
| 63 | - require_once $engfile ; |
|
| 63 | + require_once $engfile; |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | - $this->theme_lang_checked = true ; |
|
| 66 | + $this->theme_lang_checked = true; |
|
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // read normal |
| 71 | - $this->langman->read($fileBodyName.'.php', $dirname) ; |
|
| 71 | + $this->langman->read($fileBodyName.'.php', $dirname); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | public function loadPageTypeMessageCatalog($type) |
| 75 | 75 | { |
| 76 | 76 | // I dare not to use langman... |
| 77 | 77 | if (strpos($type, '.') === false && $this->langman->my_language) { |
| 78 | - $mylang_file = $this->langman->my_language.'/'.$this->mLanguageName.'/'.$type.'.php' ; |
|
| 78 | + $mylang_file = $this->langman->my_language.'/'.$this->mLanguageName.'/'.$type.'.php'; |
|
| 79 | 79 | if (file_exists($mylang_file)) { |
| 80 | - require_once $mylang_file ; |
|
| 80 | + require_once $mylang_file; |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | - $original_error_level = error_reporting() ; |
|
| 84 | - error_reporting($original_error_level & ~ E_NOTICE) ; |
|
| 83 | + $original_error_level = error_reporting(); |
|
| 84 | + error_reporting($original_error_level & ~ E_NOTICE); |
|
| 85 | 85 | parent::loadPageTypeMessageCatalog($type); |
| 86 | - error_reporting($original_error_level) ; |
|
| 86 | + error_reporting($original_error_level); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | public function loadGlobalMessageCatalog() |
@@ -91,7 +91,7 @@ discard block |
||
| 91 | 91 | /* if (!$this->_loadFile(XOOPS_ROOT_PATH . "/modules/legacy/language/" . $this->mLanguageName . "/global.php")) { |
| 92 | 92 | $this->_loadFile(XOOPS_ROOT_PATH . "/modules/legacy/language/english/global.php"); |
| 93 | 93 | } */ |
| 94 | - $this->_loadLanguage('legacy', 'global') ; |
|
| 94 | + $this->_loadLanguage('legacy', 'global'); |
|
| 95 | 95 | |
| 96 | 96 | // |
| 97 | 97 | // Now, if XOOPS_USE_MULTIBYTES isn't defined, set zero to it. |
@@ -103,6 +103,12 @@ |
||
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | |
| 106 | +/** |
|
| 107 | + * @param integer $mid |
|
| 108 | + * @param integer $coretype |
|
| 109 | + * |
|
| 110 | + * @return string |
|
| 111 | + */ |
|
| 106 | 112 | function altsys_get_link2modpreferences($mid, $coretype) |
| 107 | 113 | { |
| 108 | 114 | switch ($coretype) { |
@@ -1,46 +1,46 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -altsys_set_module_config() ; |
|
| 3 | +altsys_set_module_config(); |
|
| 4 | 4 | |
| 5 | 5 | function altsys_set_module_config() |
| 6 | 6 | { |
| 7 | - global $altsysModuleConfig , $altsysModuleId ; |
|
| 7 | + global $altsysModuleConfig, $altsysModuleId; |
|
| 8 | 8 | |
| 9 | - $module_handler =& xoops_gethandler('module') ; |
|
| 10 | - $module =& $module_handler->getByDirname('altsys') ; |
|
| 9 | + $module_handler = & xoops_gethandler('module'); |
|
| 10 | + $module = & $module_handler->getByDirname('altsys'); |
|
| 11 | 11 | if (is_object($module)) { |
| 12 | - $config_handler =& xoops_gethandler('config') ; |
|
| 13 | - $altsysModuleConfig = $config_handler->getConfigList($module->getVar('mid')) ; |
|
| 14 | - $altsysModuleId = $module->getVar('mid') ; |
|
| 12 | + $config_handler = & xoops_gethandler('config'); |
|
| 13 | + $altsysModuleConfig = $config_handler->getConfigList($module->getVar('mid')); |
|
| 14 | + $altsysModuleId = $module->getVar('mid'); |
|
| 15 | 15 | } else { |
| 16 | - $altsysModuleConfig = array() ; |
|
| 17 | - $altsysModuleId = 0 ; |
|
| 16 | + $altsysModuleConfig = array(); |
|
| 17 | + $altsysModuleId = 0; |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | // for RTL users |
| 21 | - @define('_GLOBAL_LEFT', @_ADM_USE_RTL == 1 ? 'right' : 'left') ; |
|
| 22 | - @define('_GLOBAL_RIGHT', @_ADM_USE_RTL == 1 ? 'left' : 'right') ; |
|
| 21 | + @define('_GLOBAL_LEFT', @_ADM_USE_RTL == 1 ? 'right' : 'left'); |
|
| 22 | + @define('_GLOBAL_RIGHT', @_ADM_USE_RTL == 1 ? 'left' : 'right'); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | function altsys_include_mymenu() |
| 27 | 27 | { |
| 28 | - global $xoopsModule , $xoopsConfig , $mydirname , $mydirpath , $mytrustdirname , $mytrustdirpath , $mymenu_fake_uri ; |
|
| 28 | + global $xoopsModule, $xoopsConfig, $mydirname, $mydirpath, $mytrustdirname, $mytrustdirpath, $mymenu_fake_uri; |
|
| 29 | 29 | |
| 30 | 30 | $mymenu_find_paths = array( |
| 31 | - $mydirpath.'/admin/mymenu.php' , |
|
| 32 | - $mydirpath.'/mymenu.php' , |
|
| 33 | - $mytrustdirpath.'/admin/mymenu.php' , |
|
| 34 | - $mytrustdirpath.'/mymenu.php' , |
|
| 35 | - ) ; |
|
| 31 | + $mydirpath.'/admin/mymenu.php', |
|
| 32 | + $mydirpath.'/mymenu.php', |
|
| 33 | + $mytrustdirpath.'/admin/mymenu.php', |
|
| 34 | + $mytrustdirpath.'/mymenu.php', |
|
| 35 | + ); |
|
| 36 | 36 | |
| 37 | 37 | foreach ($mymenu_find_paths as $mymenu_find_path) { |
| 38 | 38 | if (file_exists($mymenu_find_path)) { |
| 39 | - include $mymenu_find_path ; |
|
| 40 | - include_once dirname(__FILE__).'/adminmenu_functions.php' ; |
|
| 41 | - altsys_adminmenu_insert_mymenu($xoopsModule) ; |
|
| 42 | - altsys_adminmenu_hack_ft() ; |
|
| 43 | - break ; |
|
| 39 | + include $mymenu_find_path; |
|
| 40 | + include_once dirname(__FILE__).'/adminmenu_functions.php'; |
|
| 41 | + altsys_adminmenu_insert_mymenu($xoopsModule); |
|
| 42 | + altsys_adminmenu_hack_ft(); |
|
| 43 | + break; |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | } |
@@ -48,58 +48,58 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | function altsys_include_language_file($type) |
| 50 | 50 | { |
| 51 | - $mylang = $GLOBALS['xoopsConfig']['language'] ; |
|
| 51 | + $mylang = $GLOBALS['xoopsConfig']['language']; |
|
| 52 | 52 | |
| 53 | 53 | if (file_exists(XOOPS_ROOT_PATH.'/modules/altsys/language/'.$mylang.'/'.$type.'.php')) { |
| 54 | - include_once XOOPS_ROOT_PATH.'/modules/altsys/language/'.$mylang.'/'.$type.'.php' ; |
|
| 54 | + include_once XOOPS_ROOT_PATH.'/modules/altsys/language/'.$mylang.'/'.$type.'.php'; |
|
| 55 | 55 | } elseif (file_exists(XOOPS_TRUST_PATH.'/libs/altsys/language/'.$mylang.'/'.$type.'.php')) { |
| 56 | - include_once XOOPS_TRUST_PATH.'/libs/altsys/language/'.$mylang.'/'.$type.'.php' ; |
|
| 56 | + include_once XOOPS_TRUST_PATH.'/libs/altsys/language/'.$mylang.'/'.$type.'.php'; |
|
| 57 | 57 | } elseif (file_exists(XOOPS_ROOT_PATH.'/modules/altsys/language/english/'.$type.'.php')) { |
| 58 | - include_once XOOPS_ROOT_PATH.'/modules/altsys/language/english/'.$type.'.php' ; |
|
| 58 | + include_once XOOPS_ROOT_PATH.'/modules/altsys/language/english/'.$type.'.php'; |
|
| 59 | 59 | } elseif (file_exists(XOOPS_TRUST_PATH.'/libs/altsys/language/english/'.$type.'.php')) { |
| 60 | - include_once XOOPS_TRUST_PATH.'/libs/altsys/language/english/'.$type.'.php' ; |
|
| 60 | + include_once XOOPS_TRUST_PATH.'/libs/altsys/language/english/'.$type.'.php'; |
|
| 61 | 61 | } |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | |
| 65 | -define('ALTSYS_CORE_TYPE_X20', 1) ; // 2.0.0-2.0.13 and 2.0.x-JP |
|
| 66 | -define('ALTSYS_CORE_TYPE_X20S', 2) ; // 2.0.14- from xoops.org (Skalpa's S) |
|
| 67 | -define('ALTSYS_CORE_TYPE_ORE', 4) ; // ORETEKI by marijuana |
|
| 68 | -define('ALTSYS_CORE_TYPE_X22', 8) ; // 2.2 from xoops.org |
|
| 69 | -define('ALTSYS_CORE_TYPE_X23P', 10) ; // 2.3 from xoops.org (phppp's P) |
|
| 70 | -define('ALTSYS_CORE_TYPE_X25', 11) ; // 2.5 from xoops.org |
|
| 71 | -define('ALTSYS_CORE_TYPE_ICMS', 12) ; // ImpressCMS |
|
| 72 | -define('ALTSYS_CORE_TYPE_XCL21', 16) ; // XOOPS Cube 2.1 Legacy |
|
| 65 | +define('ALTSYS_CORE_TYPE_X20', 1); // 2.0.0-2.0.13 and 2.0.x-JP |
|
| 66 | +define('ALTSYS_CORE_TYPE_X20S', 2); // 2.0.14- from xoops.org (Skalpa's S) |
|
| 67 | +define('ALTSYS_CORE_TYPE_ORE', 4); // ORETEKI by marijuana |
|
| 68 | +define('ALTSYS_CORE_TYPE_X22', 8); // 2.2 from xoops.org |
|
| 69 | +define('ALTSYS_CORE_TYPE_X23P', 10); // 2.3 from xoops.org (phppp's P) |
|
| 70 | +define('ALTSYS_CORE_TYPE_X25', 11); // 2.5 from xoops.org |
|
| 71 | +define('ALTSYS_CORE_TYPE_ICMS', 12); // ImpressCMS |
|
| 72 | +define('ALTSYS_CORE_TYPE_XCL21', 16); // XOOPS Cube 2.1 Legacy |
|
| 73 | 73 | |
| 74 | 74 | function altsys_get_core_type() |
| 75 | 75 | { |
| 76 | - static $result = null ; |
|
| 76 | + static $result = null; |
|
| 77 | 77 | |
| 78 | 78 | if (empty($result)) { |
| 79 | 79 | if (defined('XOOPS_ORETEKI')) { |
| 80 | - $result = ALTSYS_CORE_TYPE_ORE ; |
|
| 80 | + $result = ALTSYS_CORE_TYPE_ORE; |
|
| 81 | 81 | } elseif (defined('XOOPS_CUBE_LEGACY')) { |
| 82 | - $result = ALTSYS_CORE_TYPE_XCL21 ; |
|
| 82 | + $result = ALTSYS_CORE_TYPE_XCL21; |
|
| 83 | 83 | } elseif (defined('ICMS_VERSION_NAME')) { |
| 84 | - $result = ALTSYS_CORE_TYPE_ICMS ; |
|
| 84 | + $result = ALTSYS_CORE_TYPE_ICMS; |
|
| 85 | 85 | } elseif (strstr(XOOPS_VERSION, 'JP')) { |
| 86 | - $result = ALTSYS_CORE_TYPE_X20 ; |
|
| 86 | + $result = ALTSYS_CORE_TYPE_X20; |
|
| 87 | 87 | } else { |
| 88 | - $versions = array_map('intval', explode('.', preg_replace('/[^0-9.]/', '', XOOPS_VERSION))) ; |
|
| 88 | + $versions = array_map('intval', explode('.', preg_replace('/[^0-9.]/', '', XOOPS_VERSION))); |
|
| 89 | 89 | if ($versions[0] == 2 && $versions[1] == 2) { |
| 90 | - $result = ALTSYS_CORE_TYPE_X22 ; |
|
| 90 | + $result = ALTSYS_CORE_TYPE_X22; |
|
| 91 | 91 | } elseif ($versions[0] == 2 && $versions[1] == 0 && $versions[2] > 13) { |
| 92 | - $result = ALTSYS_CORE_TYPE_X20S ; |
|
| 92 | + $result = ALTSYS_CORE_TYPE_X20S; |
|
| 93 | 93 | } elseif ($versions[0] == 2 && $versions[1] >= 5) { |
| 94 | - $result = ALTSYS_CORE_TYPE_X25 ; |
|
| 94 | + $result = ALTSYS_CORE_TYPE_X25; |
|
| 95 | 95 | } elseif ($versions[0] == 2 && $versions[1] > 2) { |
| 96 | - $result = ALTSYS_CORE_TYPE_X23P ; |
|
| 96 | + $result = ALTSYS_CORE_TYPE_X23P; |
|
| 97 | 97 | } else { |
| 98 | - $result = ALTSYS_CORE_TYPE_X20 ; |
|
| 98 | + $result = ALTSYS_CORE_TYPE_X20; |
|
| 99 | 99 | } |
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | - return $result ; |
|
| 102 | + return $result; |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | |
@@ -113,36 +113,36 @@ discard block |
||
| 113 | 113 | case ALTSYS_CORE_TYPE_X23P : |
| 114 | 114 | case ALTSYS_CORE_TYPE_ICMS : |
| 115 | 115 | default : |
| 116 | - return XOOPS_URL.'/modules/system/admin.php?fct=preferences&op=showmod&mod='.$mid ; |
|
| 116 | + return XOOPS_URL.'/modules/system/admin.php?fct=preferences&op=showmod&mod='.$mid; |
|
| 117 | 117 | case ALTSYS_CORE_TYPE_XCL21 : |
| 118 | - return XOOPS_URL.'/modules/legacy/admin/index.php?action=PreferenceEdit&confmod_id='.$mid ; |
|
| 118 | + return XOOPS_URL.'/modules/legacy/admin/index.php?action=PreferenceEdit&confmod_id='.$mid; |
|
| 119 | 119 | } |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | |
| 123 | 123 | function altsys_template_touch($tpl_id) |
| 124 | 124 | { |
| 125 | - if (in_array(altsys_get_core_type(), array( ALTSYS_CORE_TYPE_X20S, ALTSYS_CORE_TYPE_X23P, ALTSYS_CORE_TYPE_X25 ))) { |
|
| 125 | + if (in_array(altsys_get_core_type(), array(ALTSYS_CORE_TYPE_X20S, ALTSYS_CORE_TYPE_X23P, ALTSYS_CORE_TYPE_X25))) { |
|
| 126 | 126 | // need to delete all files under templates_c/ |
| 127 | - altsys_clear_templates_c() ; |
|
| 127 | + altsys_clear_templates_c(); |
|
| 128 | 128 | } else { |
| 129 | 129 | // just touch the template |
| 130 | - xoops_template_touch($tpl_id) ; |
|
| 130 | + xoops_template_touch($tpl_id); |
|
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | |
| 135 | 135 | function altsys_clear_templates_c() |
| 136 | 136 | { |
| 137 | - $dh = opendir(XOOPS_COMPILE_PATH) ; |
|
| 137 | + $dh = opendir(XOOPS_COMPILE_PATH); |
|
| 138 | 138 | while ($file = readdir($dh)) { |
| 139 | 139 | if (substr($file, 0, 1) == '.') { |
| 140 | - continue ; |
|
| 140 | + continue; |
|
| 141 | 141 | } |
| 142 | 142 | if (substr($file, -4) != '.php') { |
| 143 | - continue ; |
|
| 143 | + continue; |
|
| 144 | 144 | } |
| 145 | - @unlink(XOOPS_COMPILE_PATH.'/'.$file) ; |
|
| 145 | + @unlink(XOOPS_COMPILE_PATH.'/'.$file); |
|
| 146 | 146 | } |
| 147 | - closedir($dh) ; |
|
| 147 | + closedir($dh); |
|
| 148 | 148 | } |
@@ -136,6 +136,9 @@ discard block |
||
| 136 | 136 | */ |
| 137 | 137 | //HACK by domifara |
| 138 | 138 | // function Archive_Zip($p_zipname) |
| 139 | + /** |
|
| 140 | + * @param string $p_zipname |
|
| 141 | + */ |
|
| 139 | 142 | public function __construct($p_zipname) |
| 140 | 143 | { |
| 141 | 144 | |
@@ -177,7 +180,7 @@ discard block |
||
| 177 | 180 | * @param mixed $p_filelist The list of the files or folders to add. |
| 178 | 181 | * It can be a string with filenames separated |
| 179 | 182 | * by a comma, or an array of filenames. |
| 180 | - * @param mixed $p_params An array of variable parameters and values. |
|
| 183 | + * @param integer $p_params An array of variable parameters and values. |
|
| 181 | 184 | * @return mixed An array of file description on success, |
| 182 | 185 | * an error code on error |
| 183 | 186 | */ |
@@ -248,7 +251,7 @@ discard block |
||
| 248 | 251 | * @param mixed $p_filelist The list of the files or folders to add. |
| 249 | 252 | * It can be a string with filenames separated |
| 250 | 253 | * by a comma, or an array of filenames. |
| 251 | - * @param mixed $p_params An array of variable parameters and values. |
|
| 254 | + * @param integer $p_params An array of variable parameters and values. |
|
| 252 | 255 | * @return mixed An array of file description on success, |
| 253 | 256 | * 0 on an unrecoverable failure, an error code is logged. |
| 254 | 257 | */ |
@@ -399,7 +402,7 @@ discard block |
||
| 399 | 402 | * each entry extraction. |
| 400 | 403 | * |
| 401 | 404 | * @access public |
| 402 | - * @param mixed $p_params An array of variable parameters and values. |
|
| 405 | + * @param integer $p_params An array of variable parameters and values. |
|
| 403 | 406 | * @return mixed An array of file description on success, |
| 404 | 407 | * 0 on an unrecoverable failure, an error code is logged. |
| 405 | 408 | */ |
@@ -514,7 +517,6 @@ discard block |
||
| 514 | 517 | * status : not_exist, ok |
| 515 | 518 | * |
| 516 | 519 | * @access public |
| 517 | - * @param mixed $p_params {Description} |
|
| 518 | 520 | * @return mixed An array with the global properties or 0 on error. |
| 519 | 521 | */ |
| 520 | 522 | public function properties() |
@@ -1000,6 +1002,7 @@ discard block |
||
| 1000 | 1002 | * |
| 1001 | 1003 | * { Description } |
| 1002 | 1004 | * |
| 1005 | + * @param string $p_mode |
|
| 1003 | 1006 | */ |
| 1004 | 1007 | public function _openFd($p_mode) |
| 1005 | 1008 | { |
@@ -1571,6 +1574,7 @@ discard block |
||
| 1571 | 1574 | * |
| 1572 | 1575 | * { Description } |
| 1573 | 1576 | * |
| 1577 | + * @param string $p_comment |
|
| 1574 | 1578 | */ |
| 1575 | 1579 | public function _writeCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) |
| 1576 | 1580 | { |
@@ -3148,8 +3152,6 @@ discard block |
||
| 3148 | 3152 | * |
| 3149 | 3153 | * { Description } |
| 3150 | 3154 | * |
| 3151 | - * @param integer $p_error_code |
|
| 3152 | - * @param string $p_error_string |
|
| 3153 | 3155 | */ |
| 3154 | 3156 | public function _check_parameters(&$p_params, $p_default) |
| 3155 | 3157 | { |
@@ -3379,6 +3381,8 @@ discard block |
||
| 3379 | 3381 | * { Description } |
| 3380 | 3382 | * |
| 3381 | 3383 | * @param integer $p_mode |
| 3384 | + * @param integer $p_src |
|
| 3385 | + * @param integer $p_dest |
|
| 3382 | 3386 | */ |
| 3383 | 3387 | public function _tool_CopyBlock($p_src, $p_dest, $p_size, $p_mode=0) |
| 3384 | 3388 | { |
@@ -3440,6 +3444,8 @@ discard block |
||
| 3440 | 3444 | * |
| 3441 | 3445 | * { Description } |
| 3442 | 3446 | * |
| 3447 | + * @param string $p_src |
|
| 3448 | + * @param string $p_dest |
|
| 3443 | 3449 | */ |
| 3444 | 3450 | public function _tool_Rename($p_src, $p_dest) |
| 3445 | 3451 | { |
@@ -27,63 +27,63 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | // require_once 'PEAR.php'; // GIJ |
| 29 | 29 | |
| 30 | - // ----- Constants |
|
| 31 | - define('ARCHIVE_ZIP_READ_BLOCK_SIZE', 2048); |
|
| 32 | - |
|
| 33 | - // ----- File list separator |
|
| 34 | - define('ARCHIVE_ZIP_SEPARATOR', ','); |
|
| 35 | - |
|
| 36 | - // ----- Optional static temporary directory |
|
| 37 | - // By default temporary files are generated in the script current |
|
| 38 | - // path. |
|
| 39 | - // If defined : |
|
| 40 | - // - MUST BE terminated by a '/'. |
|
| 41 | - // - MUST be a valid, already created directory |
|
| 42 | - // Samples : |
|
| 43 | - // define( 'ARCHIVE_ZIP_TEMPORARY_DIR', '/temp/' ); |
|
| 44 | - // define( 'ARCHIVE_ZIP_TEMPORARY_DIR', 'C:/Temp/' ); |
|
| 45 | - define('ARCHIVE_ZIP_TEMPORARY_DIR', ''); |
|
| 46 | - |
|
| 47 | - // ----- Error codes |
|
| 48 | - define('ARCHIVE_ZIP_ERR_NO_ERROR', 0); |
|
| 49 | - define('ARCHIVE_ZIP_ERR_WRITE_OPEN_FAIL', -1); |
|
| 50 | - define('ARCHIVE_ZIP_ERR_READ_OPEN_FAIL', -2); |
|
| 51 | - define('ARCHIVE_ZIP_ERR_INVALID_PARAMETER', -3); |
|
| 52 | - define('ARCHIVE_ZIP_ERR_MISSING_FILE', -4); |
|
| 53 | - define('ARCHIVE_ZIP_ERR_FILENAME_TOO_LONG', -5); |
|
| 54 | - define('ARCHIVE_ZIP_ERR_INVALID_ZIP', -6); |
|
| 55 | - define('ARCHIVE_ZIP_ERR_BAD_EXTRACTED_FILE', -7); |
|
| 56 | - define('ARCHIVE_ZIP_ERR_DIR_CREATE_FAIL', -8); |
|
| 57 | - define('ARCHIVE_ZIP_ERR_BAD_EXTENSION', -9); |
|
| 58 | - define('ARCHIVE_ZIP_ERR_BAD_FORMAT', -10); |
|
| 59 | - define('ARCHIVE_ZIP_ERR_DELETE_FILE_FAIL', -11); |
|
| 60 | - define('ARCHIVE_ZIP_ERR_RENAME_FILE_FAIL', -12); |
|
| 61 | - define('ARCHIVE_ZIP_ERR_BAD_CHECKSUM', -13); |
|
| 62 | - define('ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP', -14); |
|
| 63 | - define('ARCHIVE_ZIP_ERR_MISSING_OPTION_VALUE', -15); |
|
| 64 | - define('ARCHIVE_ZIP_ERR_INVALID_PARAM_VALUE', -16); |
|
| 65 | - |
|
| 66 | - // ----- Warning codes |
|
| 67 | - define('ARCHIVE_ZIP_WARN_NO_WARNING', 0); |
|
| 68 | - define('ARCHIVE_ZIP_WARN_FILE_EXIST', 1); |
|
| 69 | - |
|
| 70 | - // ----- Methods parameters |
|
| 71 | - define('ARCHIVE_ZIP_PARAM_PATH', 'path'); |
|
| 72 | - define('ARCHIVE_ZIP_PARAM_ADD_PATH', 'add_path'); |
|
| 73 | - define('ARCHIVE_ZIP_PARAM_REMOVE_PATH', 'remove_path'); |
|
| 74 | - define('ARCHIVE_ZIP_PARAM_REMOVE_ALL_PATH', 'remove_all_path'); |
|
| 75 | - define('ARCHIVE_ZIP_PARAM_SET_CHMOD', 'set_chmod'); |
|
| 76 | - define('ARCHIVE_ZIP_PARAM_EXTRACT_AS_STRING', 'extract_as_string'); |
|
| 77 | - define('ARCHIVE_ZIP_PARAM_NO_COMPRESSION', 'no_compression'); |
|
| 78 | - define('ARCHIVE_ZIP_PARAM_BY_NAME', 'by_name'); |
|
| 79 | - define('ARCHIVE_ZIP_PARAM_BY_INDEX', 'by_index'); |
|
| 80 | - define('ARCHIVE_ZIP_PARAM_BY_EREG', 'by_ereg'); |
|
| 81 | - define('ARCHIVE_ZIP_PARAM_BY_PREG', 'by_preg'); |
|
| 82 | - |
|
| 83 | - define('ARCHIVE_ZIP_PARAM_PRE_EXTRACT', 'callback_pre_extract'); |
|
| 84 | - define('ARCHIVE_ZIP_PARAM_POST_EXTRACT', 'callback_post_extract'); |
|
| 85 | - define('ARCHIVE_ZIP_PARAM_PRE_ADD', 'callback_pre_add'); |
|
| 86 | - define('ARCHIVE_ZIP_PARAM_POST_ADD', 'callback_post_add'); |
|
| 30 | + // ----- Constants |
|
| 31 | + define('ARCHIVE_ZIP_READ_BLOCK_SIZE', 2048); |
|
| 32 | + |
|
| 33 | + // ----- File list separator |
|
| 34 | + define('ARCHIVE_ZIP_SEPARATOR', ','); |
|
| 35 | + |
|
| 36 | + // ----- Optional static temporary directory |
|
| 37 | + // By default temporary files are generated in the script current |
|
| 38 | + // path. |
|
| 39 | + // If defined : |
|
| 40 | + // - MUST BE terminated by a '/'. |
|
| 41 | + // - MUST be a valid, already created directory |
|
| 42 | + // Samples : |
|
| 43 | + // define( 'ARCHIVE_ZIP_TEMPORARY_DIR', '/temp/' ); |
|
| 44 | + // define( 'ARCHIVE_ZIP_TEMPORARY_DIR', 'C:/Temp/' ); |
|
| 45 | + define('ARCHIVE_ZIP_TEMPORARY_DIR', ''); |
|
| 46 | + |
|
| 47 | + // ----- Error codes |
|
| 48 | + define('ARCHIVE_ZIP_ERR_NO_ERROR', 0); |
|
| 49 | + define('ARCHIVE_ZIP_ERR_WRITE_OPEN_FAIL', -1); |
|
| 50 | + define('ARCHIVE_ZIP_ERR_READ_OPEN_FAIL', -2); |
|
| 51 | + define('ARCHIVE_ZIP_ERR_INVALID_PARAMETER', -3); |
|
| 52 | + define('ARCHIVE_ZIP_ERR_MISSING_FILE', -4); |
|
| 53 | + define('ARCHIVE_ZIP_ERR_FILENAME_TOO_LONG', -5); |
|
| 54 | + define('ARCHIVE_ZIP_ERR_INVALID_ZIP', -6); |
|
| 55 | + define('ARCHIVE_ZIP_ERR_BAD_EXTRACTED_FILE', -7); |
|
| 56 | + define('ARCHIVE_ZIP_ERR_DIR_CREATE_FAIL', -8); |
|
| 57 | + define('ARCHIVE_ZIP_ERR_BAD_EXTENSION', -9); |
|
| 58 | + define('ARCHIVE_ZIP_ERR_BAD_FORMAT', -10); |
|
| 59 | + define('ARCHIVE_ZIP_ERR_DELETE_FILE_FAIL', -11); |
|
| 60 | + define('ARCHIVE_ZIP_ERR_RENAME_FILE_FAIL', -12); |
|
| 61 | + define('ARCHIVE_ZIP_ERR_BAD_CHECKSUM', -13); |
|
| 62 | + define('ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP', -14); |
|
| 63 | + define('ARCHIVE_ZIP_ERR_MISSING_OPTION_VALUE', -15); |
|
| 64 | + define('ARCHIVE_ZIP_ERR_INVALID_PARAM_VALUE', -16); |
|
| 65 | + |
|
| 66 | + // ----- Warning codes |
|
| 67 | + define('ARCHIVE_ZIP_WARN_NO_WARNING', 0); |
|
| 68 | + define('ARCHIVE_ZIP_WARN_FILE_EXIST', 1); |
|
| 69 | + |
|
| 70 | + // ----- Methods parameters |
|
| 71 | + define('ARCHIVE_ZIP_PARAM_PATH', 'path'); |
|
| 72 | + define('ARCHIVE_ZIP_PARAM_ADD_PATH', 'add_path'); |
|
| 73 | + define('ARCHIVE_ZIP_PARAM_REMOVE_PATH', 'remove_path'); |
|
| 74 | + define('ARCHIVE_ZIP_PARAM_REMOVE_ALL_PATH', 'remove_all_path'); |
|
| 75 | + define('ARCHIVE_ZIP_PARAM_SET_CHMOD', 'set_chmod'); |
|
| 76 | + define('ARCHIVE_ZIP_PARAM_EXTRACT_AS_STRING', 'extract_as_string'); |
|
| 77 | + define('ARCHIVE_ZIP_PARAM_NO_COMPRESSION', 'no_compression'); |
|
| 78 | + define('ARCHIVE_ZIP_PARAM_BY_NAME', 'by_name'); |
|
| 79 | + define('ARCHIVE_ZIP_PARAM_BY_INDEX', 'by_index'); |
|
| 80 | + define('ARCHIVE_ZIP_PARAM_BY_EREG', 'by_ereg'); |
|
| 81 | + define('ARCHIVE_ZIP_PARAM_BY_PREG', 'by_preg'); |
|
| 82 | + |
|
| 83 | + define('ARCHIVE_ZIP_PARAM_PRE_EXTRACT', 'callback_pre_extract'); |
|
| 84 | + define('ARCHIVE_ZIP_PARAM_POST_EXTRACT', 'callback_post_extract'); |
|
| 85 | + define('ARCHIVE_ZIP_PARAM_PRE_ADD', 'callback_pre_add'); |
|
| 86 | + define('ARCHIVE_ZIP_PARAM_POST_ADD', 'callback_post_add'); |
|
| 87 | 87 | |
| 88 | 88 | |
| 89 | 89 | |
@@ -102,56 +102,56 @@ discard block |
||
| 102 | 102 | class Archive_Zip |
| 103 | 103 | { |
| 104 | 104 | /** |
| 105 | - * The filename of the zip archive. |
|
| 106 | - * |
|
| 107 | - * @var string Name of the Zip file |
|
| 108 | - */ |
|
| 105 | + * The filename of the zip archive. |
|
| 106 | + * |
|
| 107 | + * @var string Name of the Zip file |
|
| 108 | + */ |
|
| 109 | 109 | public $_zipname=''; |
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | - * File descriptor of the opened Zip file. |
|
| 113 | - * |
|
| 114 | - * @var int Internal zip file descriptor |
|
| 115 | - */ |
|
| 112 | + * File descriptor of the opened Zip file. |
|
| 113 | + * |
|
| 114 | + * @var int Internal zip file descriptor |
|
| 115 | + */ |
|
| 116 | 116 | public $_zip_fd=0; |
| 117 | 117 | |
| 118 | 118 | /** |
| 119 | - * @var int last error code |
|
| 120 | - */ |
|
| 119 | + * @var int last error code |
|
| 120 | + */ |
|
| 121 | 121 | public $_error_code=1; |
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | - * @var string Last error description |
|
| 125 | - */ |
|
| 124 | + * @var string Last error description |
|
| 125 | + */ |
|
| 126 | 126 | public $_error_string=''; |
| 127 | 127 | |
| 128 | 128 | // {{{ constructor |
| 129 | 129 | /** |
| 130 | - * Archive_Zip Class constructor. This flavour of the constructor only |
|
| 131 | - * declare a new Archive_Zip object, identifying it by the name of the |
|
| 132 | - * zip file. |
|
| 133 | - * |
|
| 134 | - * @param string $p_zipname The name of the zip archive to create |
|
| 135 | - * @access public |
|
| 136 | - */ |
|
| 130 | + * Archive_Zip Class constructor. This flavour of the constructor only |
|
| 131 | + * declare a new Archive_Zip object, identifying it by the name of the |
|
| 132 | + * zip file. |
|
| 133 | + * |
|
| 134 | + * @param string $p_zipname The name of the zip archive to create |
|
| 135 | + * @access public |
|
| 136 | + */ |
|
| 137 | 137 | //HACK by domifara |
| 138 | 138 | // function Archive_Zip($p_zipname) |
| 139 | 139 | public function __construct($p_zipname) |
| 140 | 140 | { |
| 141 | 141 | |
| 142 | - // ----- Check the zlib |
|
| 142 | + // ----- Check the zlib |
|
| 143 | 143 | /* if (!extension_loaded('zlib')) { |
| 144 | 144 | PEAR::loadExtension('zlib'); |
| 145 | 145 | }*/ // GIJ |
| 146 | - if (!extension_loaded('zlib')) { |
|
| 147 | - die("The extension 'zlib' couldn't be found.\n". |
|
| 148 | - "Please make sure your version of PHP was built ". |
|
| 149 | - "with 'zlib' support.\n"); |
|
| 150 | - return false; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - // ----- Set the attributes |
|
| 154 | - $this->_zipname = $p_zipname; |
|
| 146 | + if (!extension_loaded('zlib')) { |
|
| 147 | + die("The extension 'zlib' couldn't be found.\n". |
|
| 148 | + "Please make sure your version of PHP was built ". |
|
| 149 | + "with 'zlib' support.\n"); |
|
| 150 | + return false; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + // ----- Set the attributes |
|
| 154 | + $this->_zipname = $p_zipname; |
|
| 155 | 155 | $this->_zip_fd = 0; |
| 156 | 156 | |
| 157 | 157 | return; |
@@ -160,27 +160,27 @@ discard block |
||
| 160 | 160 | |
| 161 | 161 | // {{{ create() |
| 162 | 162 | /** |
| 163 | - * This method creates a Zip Archive with the filename set with |
|
| 164 | - * the constructor. |
|
| 165 | - * The files and directories indicated in $p_filelist |
|
| 166 | - * are added in the archive. |
|
| 167 | - * When a directory is in the list, the directory and its content is added |
|
| 168 | - * in the archive. |
|
| 169 | - * The methods takes a variable list of parameters in $p_params. |
|
| 170 | - * The supported parameters for this method are : |
|
| 171 | - * 'add_path' : Add a path to the archived files. |
|
| 172 | - * 'remove_path' : Remove the specified 'root' path of the archived files. |
|
| 173 | - * 'remove_all_path' : Remove all the path of the archived files. |
|
| 174 | - * 'no_compression' : The archived files will not be compressed. |
|
| 175 | - * |
|
| 176 | - * @access public |
|
| 177 | - * @param mixed $p_filelist The list of the files or folders to add. |
|
| 178 | - * It can be a string with filenames separated |
|
| 179 | - * by a comma, or an array of filenames. |
|
| 180 | - * @param mixed $p_params An array of variable parameters and values. |
|
| 181 | - * @return mixed An array of file description on success, |
|
| 182 | - * an error code on error |
|
| 183 | - */ |
|
| 163 | + * This method creates a Zip Archive with the filename set with |
|
| 164 | + * the constructor. |
|
| 165 | + * The files and directories indicated in $p_filelist |
|
| 166 | + * are added in the archive. |
|
| 167 | + * When a directory is in the list, the directory and its content is added |
|
| 168 | + * in the archive. |
|
| 169 | + * The methods takes a variable list of parameters in $p_params. |
|
| 170 | + * The supported parameters for this method are : |
|
| 171 | + * 'add_path' : Add a path to the archived files. |
|
| 172 | + * 'remove_path' : Remove the specified 'root' path of the archived files. |
|
| 173 | + * 'remove_all_path' : Remove all the path of the archived files. |
|
| 174 | + * 'no_compression' : The archived files will not be compressed. |
|
| 175 | + * |
|
| 176 | + * @access public |
|
| 177 | + * @param mixed $p_filelist The list of the files or folders to add. |
|
| 178 | + * It can be a string with filenames separated |
|
| 179 | + * by a comma, or an array of filenames. |
|
| 180 | + * @param mixed $p_params An array of variable parameters and values. |
|
| 181 | + * @return mixed An array of file description on success, |
|
| 182 | + * an error code on error |
|
| 183 | + */ |
|
| 184 | 184 | public function create($p_filelist, $p_params=0) |
| 185 | 185 | { |
| 186 | 186 | $this->_errorReset(); |
@@ -190,10 +190,10 @@ discard block |
||
| 190 | 190 | $p_params = array(); |
| 191 | 191 | } |
| 192 | 192 | if ($this->_check_parameters($p_params, |
| 193 | - array('no_compression' => false, |
|
| 194 | - 'add_path' => "", |
|
| 195 | - 'remove_path' => "", |
|
| 196 | - 'remove_all_path' => false)) != 1) { |
|
| 193 | + array('no_compression' => false, |
|
| 194 | + 'add_path' => "", |
|
| 195 | + 'remove_path' => "", |
|
| 196 | + 'remove_all_path' => false)) != 1) { |
|
| 197 | 197 | return 0; |
| 198 | 198 | } |
| 199 | 199 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | // ----- Invalid variable |
| 215 | 215 | else { |
| 216 | 216 | $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, |
| 217 | - 'Invalid variable type p_filelist'); |
|
| 217 | + 'Invalid variable type p_filelist'); |
|
| 218 | 218 | $v_result = ARCHIVE_ZIP_ERR_INVALID_PARAMETER; |
| 219 | 219 | } |
| 220 | 220 | |
@@ -228,30 +228,30 @@ discard block |
||
| 228 | 228 | |
| 229 | 229 | // {{{ add() |
| 230 | 230 | /** |
| 231 | - * This method add files or directory in an existing Zip Archive. |
|
| 232 | - * If the Zip Archive does not exist it is created. |
|
| 233 | - * The files and directories to add are indicated in $p_filelist. |
|
| 234 | - * When a directory is in the list, the directory and its content is added |
|
| 235 | - * in the archive. |
|
| 236 | - * The methods takes a variable list of parameters in $p_params. |
|
| 237 | - * The supported parameters for this method are : |
|
| 238 | - * 'add_path' : Add a path to the archived files. |
|
| 239 | - * 'remove_path' : Remove the specified 'root' path of the archived files. |
|
| 240 | - * 'remove_all_path' : Remove all the path of the archived files. |
|
| 241 | - * 'no_compression' : The archived files will not be compressed. |
|
| 242 | - * 'callback_pre_add' : A callback function that will be called before |
|
| 243 | - * each entry archiving. |
|
| 244 | - * 'callback_post_add' : A callback function that will be called after |
|
| 245 | - * each entry archiving. |
|
| 246 | - * |
|
| 247 | - * @access public |
|
| 248 | - * @param mixed $p_filelist The list of the files or folders to add. |
|
| 249 | - * It can be a string with filenames separated |
|
| 250 | - * by a comma, or an array of filenames. |
|
| 251 | - * @param mixed $p_params An array of variable parameters and values. |
|
| 252 | - * @return mixed An array of file description on success, |
|
| 253 | - * 0 on an unrecoverable failure, an error code is logged. |
|
| 254 | - */ |
|
| 231 | + * This method add files or directory in an existing Zip Archive. |
|
| 232 | + * If the Zip Archive does not exist it is created. |
|
| 233 | + * The files and directories to add are indicated in $p_filelist. |
|
| 234 | + * When a directory is in the list, the directory and its content is added |
|
| 235 | + * in the archive. |
|
| 236 | + * The methods takes a variable list of parameters in $p_params. |
|
| 237 | + * The supported parameters for this method are : |
|
| 238 | + * 'add_path' : Add a path to the archived files. |
|
| 239 | + * 'remove_path' : Remove the specified 'root' path of the archived files. |
|
| 240 | + * 'remove_all_path' : Remove all the path of the archived files. |
|
| 241 | + * 'no_compression' : The archived files will not be compressed. |
|
| 242 | + * 'callback_pre_add' : A callback function that will be called before |
|
| 243 | + * each entry archiving. |
|
| 244 | + * 'callback_post_add' : A callback function that will be called after |
|
| 245 | + * each entry archiving. |
|
| 246 | + * |
|
| 247 | + * @access public |
|
| 248 | + * @param mixed $p_filelist The list of the files or folders to add. |
|
| 249 | + * It can be a string with filenames separated |
|
| 250 | + * by a comma, or an array of filenames. |
|
| 251 | + * @param mixed $p_params An array of variable parameters and values. |
|
| 252 | + * @return mixed An array of file description on success, |
|
| 253 | + * 0 on an unrecoverable failure, an error code is logged. |
|
| 254 | + */ |
|
| 255 | 255 | public function add($p_filelist, $p_params=0) |
| 256 | 256 | { |
| 257 | 257 | $this->_errorReset(); |
@@ -261,11 +261,11 @@ discard block |
||
| 261 | 261 | $p_params = array(); |
| 262 | 262 | } |
| 263 | 263 | if ($this->_check_parameters($p_params, |
| 264 | - array('no_compression' => false, |
|
| 264 | + array('no_compression' => false, |
|
| 265 | 265 | 'add_path' => '', |
| 266 | 266 | 'remove_path' => '', |
| 267 | 267 | 'remove_all_path' => false, |
| 268 | - 'callback_pre_add' => '', |
|
| 268 | + 'callback_pre_add' => '', |
|
| 269 | 269 | 'callback_post_add' => '')) != 1) { |
| 270 | 270 | return 0; |
| 271 | 271 | } |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | // ----- Invalid variable |
| 290 | 290 | else { |
| 291 | 291 | $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, |
| 292 | - "add() : Invalid variable type p_filelist"); |
|
| 292 | + "add() : Invalid variable type p_filelist"); |
|
| 293 | 293 | $v_result = ARCHIVE_ZIP_ERR_INVALID_PARAMETER; |
| 294 | 294 | } |
| 295 | 295 | |
@@ -304,48 +304,48 @@ discard block |
||
| 304 | 304 | |
| 305 | 305 | // {{{ listContent() |
| 306 | 306 | /** |
| 307 | - * This method gives the names and properties of the files and directories |
|
| 308 | - * which are present in the zip archive. |
|
| 309 | - * The properties of each entries in the list are : |
|
| 310 | - * filename : Name of the file. |
|
| 311 | - * For create() or add() it's the filename given by the user. |
|
| 312 | - * For an extract() it's the filename of the extracted file. |
|
| 313 | - * stored_filename : Name of the file / directory stored in the archive. |
|
| 314 | - * size : Size of the stored file. |
|
| 315 | - * compressed_size : Size of the file's data compressed in the archive |
|
| 316 | - * (without the zip headers overhead) |
|
| 317 | - * mtime : Last known modification date of the file (UNIX timestamp) |
|
| 318 | - * comment : Comment associated with the file |
|
| 319 | - * folder : true | false (indicates if the entry is a folder) |
|
| 320 | - * index : index of the file in the archive (-1 when not available) |
|
| 321 | - * status : status of the action on the entry (depending of the action) : |
|
| 322 | - * Values are : |
|
| 323 | - * ok : OK ! |
|
| 324 | - * filtered : the file/dir was not extracted (filtered by user) |
|
| 325 | - * already_a_directory : the file can't be extracted because a |
|
| 326 | - * directory with the same name already |
|
| 327 | - * exists |
|
| 328 | - * write_protected : the file can't be extracted because a file |
|
| 329 | - * with the same name already exists and is |
|
| 330 | - * write protected |
|
| 331 | - * newer_exist : the file was not extracted because a newer |
|
| 332 | - * file already exists |
|
| 333 | - * path_creation_fail : the file is not extracted because the |
|
| 334 | - * folder does not exists and can't be |
|
| 335 | - * created |
|
| 336 | - * write_error : the file was not extracted because there was a |
|
| 337 | - * error while writing the file |
|
| 338 | - * read_error : the file was not extracted because there was a |
|
| 339 | - * error while reading the file |
|
| 340 | - * invalid_header : the file was not extracted because of an |
|
| 341 | - * archive format error (bad file header) |
|
| 342 | - * Note that each time a method can continue operating when there |
|
| 343 | - * is an error on a single file, the error is only logged in the file status. |
|
| 344 | - * |
|
| 345 | - * @access public |
|
| 346 | - * @return mixed An array of file description on success, |
|
| 347 | - * 0 on an unrecoverable failure, an error code is logged. |
|
| 348 | - */ |
|
| 307 | + * This method gives the names and properties of the files and directories |
|
| 308 | + * which are present in the zip archive. |
|
| 309 | + * The properties of each entries in the list are : |
|
| 310 | + * filename : Name of the file. |
|
| 311 | + * For create() or add() it's the filename given by the user. |
|
| 312 | + * For an extract() it's the filename of the extracted file. |
|
| 313 | + * stored_filename : Name of the file / directory stored in the archive. |
|
| 314 | + * size : Size of the stored file. |
|
| 315 | + * compressed_size : Size of the file's data compressed in the archive |
|
| 316 | + * (without the zip headers overhead) |
|
| 317 | + * mtime : Last known modification date of the file (UNIX timestamp) |
|
| 318 | + * comment : Comment associated with the file |
|
| 319 | + * folder : true | false (indicates if the entry is a folder) |
|
| 320 | + * index : index of the file in the archive (-1 when not available) |
|
| 321 | + * status : status of the action on the entry (depending of the action) : |
|
| 322 | + * Values are : |
|
| 323 | + * ok : OK ! |
|
| 324 | + * filtered : the file/dir was not extracted (filtered by user) |
|
| 325 | + * already_a_directory : the file can't be extracted because a |
|
| 326 | + * directory with the same name already |
|
| 327 | + * exists |
|
| 328 | + * write_protected : the file can't be extracted because a file |
|
| 329 | + * with the same name already exists and is |
|
| 330 | + * write protected |
|
| 331 | + * newer_exist : the file was not extracted because a newer |
|
| 332 | + * file already exists |
|
| 333 | + * path_creation_fail : the file is not extracted because the |
|
| 334 | + * folder does not exists and can't be |
|
| 335 | + * created |
|
| 336 | + * write_error : the file was not extracted because there was a |
|
| 337 | + * error while writing the file |
|
| 338 | + * read_error : the file was not extracted because there was a |
|
| 339 | + * error while reading the file |
|
| 340 | + * invalid_header : the file was not extracted because of an |
|
| 341 | + * archive format error (bad file header) |
|
| 342 | + * Note that each time a method can continue operating when there |
|
| 343 | + * is an error on a single file, the error is only logged in the file status. |
|
| 344 | + * |
|
| 345 | + * @access public |
|
| 346 | + * @return mixed An array of file description on success, |
|
| 347 | + * 0 on an unrecoverable failure, an error code is logged. |
|
| 348 | + */ |
|
| 349 | 349 | public function listContent() |
| 350 | 350 | { |
| 351 | 351 | $this->_errorReset(); |
@@ -367,42 +367,42 @@ discard block |
||
| 367 | 367 | |
| 368 | 368 | // {{{ extract() |
| 369 | 369 | /** |
| 370 | - * This method extract the files and folders which are in the zip archive. |
|
| 371 | - * It can extract all the archive or a part of the archive by using filter |
|
| 372 | - * feature (extract by name, by index, by ereg, by preg). The extraction |
|
| 373 | - * can occur in the current path or an other path. |
|
| 374 | - * All the advanced features are activated by the use of variable |
|
| 375 | - * parameters. |
|
| 376 | - * The return value is an array of entry descriptions which gives |
|
| 377 | - * information on extracted files (See listContent()). |
|
| 378 | - * The method may return a success value (an array) even if some files |
|
| 379 | - * are not correctly extracted (see the file status in listContent()). |
|
| 380 | - * The supported variable parameters for this method are : |
|
| 381 | - * 'add_path' : Path where the files and directories are to be extracted |
|
| 382 | - * 'remove_path' : First part ('root' part) of the memorized path |
|
| 383 | - * (if similar) to remove while extracting. |
|
| 384 | - * 'remove_all_path' : Remove all the memorized path while extracting. |
|
| 385 | - * 'extract_as_string' : |
|
| 386 | - * 'set_chmod' : After the extraction of the file the indicated mode |
|
| 387 | - * will be set. |
|
| 388 | - * 'by_name' : It can be a string with file/dir names separated by ',', |
|
| 389 | - * or an array of file/dir names to extract from the archive. |
|
| 390 | - * 'by_index' : A string with range of indexes separated by ',', |
|
| 391 | - * (sample "1,3-5,12"). |
|
| 392 | - * 'by_ereg' : A regular expression (ereg) that must match the extracted |
|
| 393 | - * filename. |
|
| 394 | - * 'by_preg' : A regular expression (preg) that must match the extracted |
|
| 395 | - * filename. |
|
| 396 | - * 'callback_pre_extract' : A callback function that will be called before |
|
| 397 | - * each entry extraction. |
|
| 398 | - * 'callback_post_extract' : A callback function that will be called after |
|
| 399 | - * each entry extraction. |
|
| 400 | - * |
|
| 401 | - * @access public |
|
| 402 | - * @param mixed $p_params An array of variable parameters and values. |
|
| 403 | - * @return mixed An array of file description on success, |
|
| 404 | - * 0 on an unrecoverable failure, an error code is logged. |
|
| 405 | - */ |
|
| 370 | + * This method extract the files and folders which are in the zip archive. |
|
| 371 | + * It can extract all the archive or a part of the archive by using filter |
|
| 372 | + * feature (extract by name, by index, by ereg, by preg). The extraction |
|
| 373 | + * can occur in the current path or an other path. |
|
| 374 | + * All the advanced features are activated by the use of variable |
|
| 375 | + * parameters. |
|
| 376 | + * The return value is an array of entry descriptions which gives |
|
| 377 | + * information on extracted files (See listContent()). |
|
| 378 | + * The method may return a success value (an array) even if some files |
|
| 379 | + * are not correctly extracted (see the file status in listContent()). |
|
| 380 | + * The supported variable parameters for this method are : |
|
| 381 | + * 'add_path' : Path where the files and directories are to be extracted |
|
| 382 | + * 'remove_path' : First part ('root' part) of the memorized path |
|
| 383 | + * (if similar) to remove while extracting. |
|
| 384 | + * 'remove_all_path' : Remove all the memorized path while extracting. |
|
| 385 | + * 'extract_as_string' : |
|
| 386 | + * 'set_chmod' : After the extraction of the file the indicated mode |
|
| 387 | + * will be set. |
|
| 388 | + * 'by_name' : It can be a string with file/dir names separated by ',', |
|
| 389 | + * or an array of file/dir names to extract from the archive. |
|
| 390 | + * 'by_index' : A string with range of indexes separated by ',', |
|
| 391 | + * (sample "1,3-5,12"). |
|
| 392 | + * 'by_ereg' : A regular expression (ereg) that must match the extracted |
|
| 393 | + * filename. |
|
| 394 | + * 'by_preg' : A regular expression (preg) that must match the extracted |
|
| 395 | + * filename. |
|
| 396 | + * 'callback_pre_extract' : A callback function that will be called before |
|
| 397 | + * each entry extraction. |
|
| 398 | + * 'callback_post_extract' : A callback function that will be called after |
|
| 399 | + * each entry extraction. |
|
| 400 | + * |
|
| 401 | + * @access public |
|
| 402 | + * @param mixed $p_params An array of variable parameters and values. |
|
| 403 | + * @return mixed An array of file description on success, |
|
| 404 | + * 0 on an unrecoverable failure, an error code is logged. |
|
| 405 | + */ |
|
| 406 | 406 | public function extract($p_params=0) |
| 407 | 407 | { |
| 408 | 408 | $this->_errorReset(); |
@@ -417,11 +417,11 @@ discard block |
||
| 417 | 417 | $p_params = array(); |
| 418 | 418 | } |
| 419 | 419 | if ($this->_check_parameters($p_params, |
| 420 | - array('extract_as_string' => false, |
|
| 420 | + array('extract_as_string' => false, |
|
| 421 | 421 | 'add_path' => '', |
| 422 | 422 | 'remove_path' => '', |
| 423 | 423 | 'remove_all_path' => false, |
| 424 | - 'callback_pre_extract' => '', |
|
| 424 | + 'callback_pre_extract' => '', |
|
| 425 | 425 | 'callback_post_extract' => '', |
| 426 | 426 | 'set_chmod' => 0, |
| 427 | 427 | 'by_name' => '', |
@@ -445,26 +445,26 @@ discard block |
||
| 445 | 445 | |
| 446 | 446 | // {{{ delete() |
| 447 | 447 | /** |
| 448 | - * This methods delete archive entries in the zip archive. |
|
| 449 | - * Notice that at least one filtering rule (set by the variable parameter |
|
| 450 | - * list) must be set. |
|
| 451 | - * Also notice that if you delete a folder entry, only the folder entry |
|
| 452 | - * is deleted, not all the files bellonging to this folder. |
|
| 453 | - * The supported variable parameters for this method are : |
|
| 454 | - * 'by_name' : It can be a string with file/dir names separated by ',', |
|
| 455 | - * or an array of file/dir names to delete from the archive. |
|
| 456 | - * 'by_index' : A string with range of indexes separated by ',', |
|
| 457 | - * (sample "1,3-5,12"). |
|
| 458 | - * 'by_ereg' : A regular expression (ereg) that must match the extracted |
|
| 459 | - * filename. |
|
| 460 | - * 'by_preg' : A regular expression (preg) that must match the extracted |
|
| 461 | - * filename. |
|
| 462 | - * |
|
| 463 | - * @access public |
|
| 464 | - * @param mixed $p_params An array of variable parameters and values. |
|
| 465 | - * @return mixed An array of file description on success, |
|
| 466 | - * 0 on an unrecoverable failure, an error code is logged. |
|
| 467 | - */ |
|
| 448 | + * This methods delete archive entries in the zip archive. |
|
| 449 | + * Notice that at least one filtering rule (set by the variable parameter |
|
| 450 | + * list) must be set. |
|
| 451 | + * Also notice that if you delete a folder entry, only the folder entry |
|
| 452 | + * is deleted, not all the files bellonging to this folder. |
|
| 453 | + * The supported variable parameters for this method are : |
|
| 454 | + * 'by_name' : It can be a string with file/dir names separated by ',', |
|
| 455 | + * or an array of file/dir names to delete from the archive. |
|
| 456 | + * 'by_index' : A string with range of indexes separated by ',', |
|
| 457 | + * (sample "1,3-5,12"). |
|
| 458 | + * 'by_ereg' : A regular expression (ereg) that must match the extracted |
|
| 459 | + * filename. |
|
| 460 | + * 'by_preg' : A regular expression (preg) that must match the extracted |
|
| 461 | + * filename. |
|
| 462 | + * |
|
| 463 | + * @access public |
|
| 464 | + * @param mixed $p_params An array of variable parameters and values. |
|
| 465 | + * @return mixed An array of file description on success, |
|
| 466 | + * 0 on an unrecoverable failure, an error code is logged. |
|
| 467 | + */ |
|
| 468 | 468 | public function delete($p_params) |
| 469 | 469 | { |
| 470 | 470 | $this->_errorReset(); |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | |
| 477 | 477 | // ----- Set default values |
| 478 | 478 | if ($this->_check_parameters($p_params, |
| 479 | - array('by_name' => '', |
|
| 479 | + array('by_name' => '', |
|
| 480 | 480 | 'by_index' => '', |
| 481 | 481 | 'by_ereg' => '', |
| 482 | 482 | 'by_preg' => '')) != 1) { |
@@ -489,8 +489,8 @@ discard block |
||
| 489 | 489 | && ($p_params['by_ereg'] == '') |
| 490 | 490 | && ($p_params['by_preg'] == '')) { |
| 491 | 491 | $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, |
| 492 | - 'At least one filtering rule must' |
|
| 493 | - .' be set as parameter'); |
|
| 492 | + 'At least one filtering rule must' |
|
| 493 | + .' be set as parameter'); |
|
| 494 | 494 | return 0; |
| 495 | 495 | } |
| 496 | 496 | |
@@ -507,16 +507,16 @@ discard block |
||
| 507 | 507 | |
| 508 | 508 | // {{{ properties() |
| 509 | 509 | /** |
| 510 | - * This method gives the global properties of the archive. |
|
| 511 | - * The properties are : |
|
| 512 | - * nb : Number of files in the archive |
|
| 513 | - * comment : Comment associated with the archive file |
|
| 514 | - * status : not_exist, ok |
|
| 515 | - * |
|
| 516 | - * @access public |
|
| 517 | - * @param mixed $p_params {Description} |
|
| 518 | - * @return mixed An array with the global properties or 0 on error. |
|
| 519 | - */ |
|
| 510 | + * This method gives the global properties of the archive. |
|
| 511 | + * The properties are : |
|
| 512 | + * nb : Number of files in the archive |
|
| 513 | + * comment : Comment associated with the archive file |
|
| 514 | + * status : not_exist, ok |
|
| 515 | + * |
|
| 516 | + * @access public |
|
| 517 | + * @param mixed $p_params {Description} |
|
| 518 | + * @return mixed An array with the global properties or 0 on error. |
|
| 519 | + */ |
|
| 520 | 520 | public function properties() |
| 521 | 521 | { |
| 522 | 522 | $this->_errorReset(); |
@@ -537,8 +537,8 @@ discard block |
||
| 537 | 537 | // ----- Open the zip file |
| 538 | 538 | if (($this->_zip_fd = @fopen($this->_zipname, 'rb')) == 0) { |
| 539 | 539 | $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, |
| 540 | - 'Unable to open archive \''.$this->_zipname |
|
| 541 | - .'\' in binary read mode'); |
|
| 540 | + 'Unable to open archive \''.$this->_zipname |
|
| 541 | + .'\' in binary read mode'); |
|
| 542 | 542 | return 0; |
| 543 | 543 | } |
| 544 | 544 | |
@@ -563,15 +563,15 @@ discard block |
||
| 563 | 563 | |
| 564 | 564 | // {{{ duplicate() |
| 565 | 565 | /** |
| 566 | - * This method creates an archive by copying the content of an other one. |
|
| 567 | - * If the archive already exist, it is replaced by the new one without |
|
| 568 | - * any warning. |
|
| 569 | - * |
|
| 570 | - * @access public |
|
| 571 | - * @param mixed $p_archive It can be a valid Archive_Zip object or |
|
| 572 | - * the filename of a valid zip archive. |
|
| 573 | - * @return integer 1 on success, 0 on failure. |
|
| 574 | - */ |
|
| 566 | + * This method creates an archive by copying the content of an other one. |
|
| 567 | + * If the archive already exist, it is replaced by the new one without |
|
| 568 | + * any warning. |
|
| 569 | + * |
|
| 570 | + * @access public |
|
| 571 | + * @param mixed $p_archive It can be a valid Archive_Zip object or |
|
| 572 | + * the filename of a valid zip archive. |
|
| 573 | + * @return integer 1 on success, 0 on failure. |
|
| 574 | + */ |
|
| 575 | 575 | public function duplicate($p_archive) |
| 576 | 576 | { |
| 577 | 577 | $this->_errorReset(); |
@@ -588,7 +588,7 @@ discard block |
||
| 588 | 588 | // TBC : Should also check the archive format |
| 589 | 589 | if (!is_file($p_archive)) { |
| 590 | 590 | $this->_errorLog(ARCHIVE_ZIP_ERR_MISSING_FILE, |
| 591 | - "No file with filename '".$p_archive."'"); |
|
| 591 | + "No file with filename '".$p_archive."'"); |
|
| 592 | 592 | $v_result = ARCHIVE_ZIP_ERR_MISSING_FILE; |
| 593 | 593 | } else { |
| 594 | 594 | $v_result = $this->_duplicate($p_archive); |
@@ -598,7 +598,7 @@ discard block |
||
| 598 | 598 | // ----- Invalid variable |
| 599 | 599 | else { |
| 600 | 600 | $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, |
| 601 | - "Invalid variable type p_archive_to_add"); |
|
| 601 | + "Invalid variable type p_archive_to_add"); |
|
| 602 | 602 | $v_result = ARCHIVE_ZIP_ERR_INVALID_PARAMETER; |
| 603 | 603 | } |
| 604 | 604 | |
@@ -608,16 +608,16 @@ discard block |
||
| 608 | 608 | |
| 609 | 609 | // {{{ merge() |
| 610 | 610 | /** |
| 611 | - * This method merge a valid zip archive at the end of the |
|
| 612 | - * archive identified by the Archive_Zip object. |
|
| 613 | - * If the archive ($this) does not exist, the merge becomes a duplicate. |
|
| 614 | - * If the archive to add does not exist, the merge is a success. |
|
| 615 | - * |
|
| 616 | - * @access public |
|
| 617 | - * @param mixed $p_archive_to_add It can be a valid Archive_Zip object or |
|
| 618 | - * the filename of a valid zip archive. |
|
| 619 | - * @return integer 1 on success, 0 on failure. |
|
| 620 | - */ |
|
| 611 | + * This method merge a valid zip archive at the end of the |
|
| 612 | + * archive identified by the Archive_Zip object. |
|
| 613 | + * If the archive ($this) does not exist, the merge becomes a duplicate. |
|
| 614 | + * If the archive to add does not exist, the merge is a success. |
|
| 615 | + * |
|
| 616 | + * @access public |
|
| 617 | + * @param mixed $p_archive_to_add It can be a valid Archive_Zip object or |
|
| 618 | + * the filename of a valid zip archive. |
|
| 619 | + * @return integer 1 on success, 0 on failure. |
|
| 620 | + */ |
|
| 621 | 621 | public function merge($p_archive_to_add) |
| 622 | 622 | { |
| 623 | 623 | $v_result = 1; |
@@ -646,7 +646,7 @@ discard block |
||
| 646 | 646 | // ----- Invalid variable |
| 647 | 647 | else { |
| 648 | 648 | $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, |
| 649 | - "Invalid variable type p_archive_to_add"); |
|
| 649 | + "Invalid variable type p_archive_to_add"); |
|
| 650 | 650 | $v_result = ARCHIVE_ZIP_ERR_INVALID_PARAMETER; |
| 651 | 651 | } |
| 652 | 652 | |
@@ -656,11 +656,11 @@ discard block |
||
| 656 | 656 | |
| 657 | 657 | // {{{ errorCode() |
| 658 | 658 | /** |
| 659 | - * Method that gives the lastest error code. |
|
| 660 | - * |
|
| 661 | - * @access public |
|
| 662 | - * @return integer The error code value. |
|
| 663 | - */ |
|
| 659 | + * Method that gives the lastest error code. |
|
| 660 | + * |
|
| 661 | + * @access public |
|
| 662 | + * @return integer The error code value. |
|
| 663 | + */ |
|
| 664 | 664 | public function errorCode() |
| 665 | 665 | { |
| 666 | 666 | return($this->_error_code); |
@@ -669,19 +669,19 @@ discard block |
||
| 669 | 669 | |
| 670 | 670 | // {{{ errorName() |
| 671 | 671 | /** |
| 672 | - * This method gives the latest error code name. |
|
| 673 | - * |
|
| 674 | - * @access public |
|
| 675 | - * @param boolean $p_with_code If true, gives the name and the int value. |
|
| 676 | - * @return string The error name. |
|
| 677 | - */ |
|
| 672 | + * This method gives the latest error code name. |
|
| 673 | + * |
|
| 674 | + * @access public |
|
| 675 | + * @param boolean $p_with_code If true, gives the name and the int value. |
|
| 676 | + * @return string The error name. |
|
| 677 | + */ |
|
| 678 | 678 | public function errorName($p_with_code=false) |
| 679 | 679 | { |
| 680 | 680 | $v_const_list = get_defined_constants(); |
| 681 | 681 | |
| 682 | - // ----- Extract error constants from all const. |
|
| 682 | + // ----- Extract error constants from all const. |
|
| 683 | 683 | for (reset($v_const_list); |
| 684 | - list($v_key, $v_value) = each($v_const_list);) { |
|
| 684 | + list($v_key, $v_value) = each($v_const_list);) { |
|
| 685 | 685 | if (substr($v_key, 0, strlen('ARCHIVE_ZIP_ERR_')) |
| 686 | 686 | =='ARCHIVE_ZIP_ERR_') { |
| 687 | 687 | $v_error_list[$v_key] = $v_value; |
@@ -706,15 +706,15 @@ discard block |
||
| 706 | 706 | |
| 707 | 707 | // {{{ errorInfo() |
| 708 | 708 | /** |
| 709 | - * This method returns the description associated with the latest error. |
|
| 710 | - * |
|
| 711 | - * @access public |
|
| 712 | - * @param boolean $p_full If set to true gives the description with the |
|
| 713 | - * error code, the name and the description. |
|
| 714 | - * If set to false gives only the description |
|
| 715 | - * and the error code. |
|
| 716 | - * @return string The error description. |
|
| 717 | - */ |
|
| 709 | + * This method returns the description associated with the latest error. |
|
| 710 | + * |
|
| 711 | + * @access public |
|
| 712 | + * @param boolean $p_full If set to true gives the description with the |
|
| 713 | + * error code, the name and the description. |
|
| 714 | + * If set to false gives only the description |
|
| 715 | + * and the error code. |
|
| 716 | + * @return string The error description. |
|
| 717 | + */ |
|
| 718 | 718 | public function errorInfo($p_full=false) |
| 719 | 719 | { |
| 720 | 720 | if ($p_full) { |
@@ -732,30 +732,30 @@ discard block |
||
| 732 | 732 | // ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY ***** |
| 733 | 733 | // ----------------------------------------------------------------------------- |
| 734 | 734 | |
| 735 | - // --------------------------------------------------------------------------- |
|
| 736 | - // Function : _checkFormat() |
|
| 737 | - // Description : |
|
| 738 | - // This method check that the archive exists and is a valid zip archive. |
|
| 739 | - // Several level of check exists. (futur) |
|
| 740 | - // Parameters : |
|
| 741 | - // $p_level : Level of check. Default 0. |
|
| 742 | - // 0 : Check the first bytes (magic codes) (default value)) |
|
| 743 | - // 1 : 0 + Check the central directory (futur) |
|
| 744 | - // 2 : 1 + Check each file header (futur) |
|
| 745 | - // Return Values : |
|
| 746 | - // true on success, |
|
| 747 | - // false on error, the error code is set. |
|
| 748 | - // --------------------------------------------------------------------------- |
|
| 749 | - /** |
|
| 750 | - * Archive_Zip::_checkFormat() |
|
| 751 | - * |
|
| 752 | - * { Description } |
|
| 753 | - * |
|
| 754 | - * @param integer $p_level |
|
| 755 | - */ |
|
| 756 | - public function _checkFormat($p_level=0) |
|
| 757 | - { |
|
| 758 | - $v_result = true; |
|
| 735 | + // --------------------------------------------------------------------------- |
|
| 736 | + // Function : _checkFormat() |
|
| 737 | + // Description : |
|
| 738 | + // This method check that the archive exists and is a valid zip archive. |
|
| 739 | + // Several level of check exists. (futur) |
|
| 740 | + // Parameters : |
|
| 741 | + // $p_level : Level of check. Default 0. |
|
| 742 | + // 0 : Check the first bytes (magic codes) (default value)) |
|
| 743 | + // 1 : 0 + Check the central directory (futur) |
|
| 744 | + // 2 : 1 + Check each file header (futur) |
|
| 745 | + // Return Values : |
|
| 746 | + // true on success, |
|
| 747 | + // false on error, the error code is set. |
|
| 748 | + // --------------------------------------------------------------------------- |
|
| 749 | + /** |
|
| 750 | + * Archive_Zip::_checkFormat() |
|
| 751 | + * |
|
| 752 | + * { Description } |
|
| 753 | + * |
|
| 754 | + * @param integer $p_level |
|
| 755 | + */ |
|
| 756 | + public function _checkFormat($p_level=0) |
|
| 757 | + { |
|
| 758 | + $v_result = true; |
|
| 759 | 759 | |
| 760 | 760 | // ----- Reset the error handler |
| 761 | 761 | $this->_errorReset(); |
@@ -763,16 +763,16 @@ discard block |
||
| 763 | 763 | // ----- Look if the file exits |
| 764 | 764 | if (!is_file($this->_zipname)) { |
| 765 | 765 | // ----- Error log |
| 766 | - $this->_errorLog(ARCHIVE_ZIP_ERR_MISSING_FILE, |
|
| 767 | - "Missing archive file '".$this->_zipname."'"); |
|
| 766 | + $this->_errorLog(ARCHIVE_ZIP_ERR_MISSING_FILE, |
|
| 767 | + "Missing archive file '".$this->_zipname."'"); |
|
| 768 | 768 | return(false); |
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | // ----- Check that the file is readeable |
| 772 | 772 | if (!is_readable($this->_zipname)) { |
| 773 | 773 | // ----- Error log |
| 774 | - $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, |
|
| 775 | - "Unable to read archive '".$this->_zipname."'"); |
|
| 774 | + $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, |
|
| 775 | + "Unable to read archive '".$this->_zipname."'"); |
|
| 776 | 776 | return(false); |
| 777 | 777 | } |
| 778 | 778 | |
@@ -787,34 +787,34 @@ discard block |
||
| 787 | 787 | |
| 788 | 788 | // ----- Return |
| 789 | 789 | return $v_result; |
| 790 | - } |
|
| 791 | - // --------------------------------------------------------------------------- |
|
| 792 | - |
|
| 793 | - // --------------------------------------------------------------------------- |
|
| 794 | - // Function : _create() |
|
| 795 | - // Description : |
|
| 796 | - // Parameters : |
|
| 797 | - // Return Values : |
|
| 798 | - // --------------------------------------------------------------------------- |
|
| 799 | - /** |
|
| 800 | - * Archive_Zip::_create() |
|
| 801 | - * |
|
| 802 | - * { Description } |
|
| 803 | - * |
|
| 804 | - */ |
|
| 805 | - public function _create($p_list, &$p_result_list, &$p_params) |
|
| 806 | - { |
|
| 807 | - $v_result=1; |
|
| 808 | - $v_list_detail = array(); |
|
| 809 | - |
|
| 810 | - $p_add_dir = $p_params['add_path']; |
|
| 811 | - $p_remove_dir = $p_params['remove_path']; |
|
| 812 | - $p_remove_all_dir = $p_params['remove_all_path']; |
|
| 790 | + } |
|
| 791 | + // --------------------------------------------------------------------------- |
|
| 792 | + |
|
| 793 | + // --------------------------------------------------------------------------- |
|
| 794 | + // Function : _create() |
|
| 795 | + // Description : |
|
| 796 | + // Parameters : |
|
| 797 | + // Return Values : |
|
| 798 | + // --------------------------------------------------------------------------- |
|
| 799 | + /** |
|
| 800 | + * Archive_Zip::_create() |
|
| 801 | + * |
|
| 802 | + * { Description } |
|
| 803 | + * |
|
| 804 | + */ |
|
| 805 | + public function _create($p_list, &$p_result_list, &$p_params) |
|
| 806 | + { |
|
| 807 | + $v_result=1; |
|
| 808 | + $v_list_detail = array(); |
|
| 809 | + |
|
| 810 | + $p_add_dir = $p_params['add_path']; |
|
| 811 | + $p_remove_dir = $p_params['remove_path']; |
|
| 812 | + $p_remove_all_dir = $p_params['remove_all_path']; |
|
| 813 | 813 | |
| 814 | 814 | // ----- Open the file in write mode |
| 815 | 815 | if (($v_result = $this->_openFd('wb')) != 1) { |
| 816 | 816 | // ----- Return |
| 817 | - return $v_result; |
|
| 817 | + return $v_result; |
|
| 818 | 818 | } |
| 819 | 819 | |
| 820 | 820 | // ----- Add the list of files |
@@ -825,29 +825,29 @@ discard block |
||
| 825 | 825 | |
| 826 | 826 | // ----- Return |
| 827 | 827 | return $v_result; |
| 828 | - } |
|
| 829 | - // --------------------------------------------------------------------------- |
|
| 830 | - |
|
| 831 | - // --------------------------------------------------------------------------- |
|
| 832 | - // Function : _add() |
|
| 833 | - // Description : |
|
| 834 | - // Parameters : |
|
| 835 | - // Return Values : |
|
| 836 | - // --------------------------------------------------------------------------- |
|
| 837 | - /** |
|
| 838 | - * Archive_Zip::_add() |
|
| 839 | - * |
|
| 840 | - * { Description } |
|
| 841 | - * |
|
| 842 | - */ |
|
| 843 | - public function _add($p_list, &$p_result_list, &$p_params) |
|
| 844 | - { |
|
| 845 | - $v_result=1; |
|
| 846 | - $v_list_detail = array(); |
|
| 847 | - |
|
| 848 | - $p_add_dir = $p_params['add_path']; |
|
| 849 | - $p_remove_dir = $p_params['remove_path']; |
|
| 850 | - $p_remove_all_dir = $p_params['remove_all_path']; |
|
| 828 | + } |
|
| 829 | + // --------------------------------------------------------------------------- |
|
| 830 | + |
|
| 831 | + // --------------------------------------------------------------------------- |
|
| 832 | + // Function : _add() |
|
| 833 | + // Description : |
|
| 834 | + // Parameters : |
|
| 835 | + // Return Values : |
|
| 836 | + // --------------------------------------------------------------------------- |
|
| 837 | + /** |
|
| 838 | + * Archive_Zip::_add() |
|
| 839 | + * |
|
| 840 | + * { Description } |
|
| 841 | + * |
|
| 842 | + */ |
|
| 843 | + public function _add($p_list, &$p_result_list, &$p_params) |
|
| 844 | + { |
|
| 845 | + $v_result=1; |
|
| 846 | + $v_list_detail = array(); |
|
| 847 | + |
|
| 848 | + $p_add_dir = $p_params['add_path']; |
|
| 849 | + $p_remove_dir = $p_params['remove_path']; |
|
| 850 | + $p_remove_all_dir = $p_params['remove_all_path']; |
|
| 851 | 851 | |
| 852 | 852 | // ----- Look if the archive exists or is empty and need to be created |
| 853 | 853 | if ((!is_file($this->_zipname)) || (filesize($this->_zipname) == 0)) { |
@@ -862,10 +862,10 @@ discard block |
||
| 862 | 862 | |
| 863 | 863 | // ----- Read the central directory informations |
| 864 | 864 | $v_central_dir = array(); |
| 865 | - if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
| 866 | - $this->_closeFd(); |
|
| 867 | - return $v_result; |
|
| 868 | - } |
|
| 865 | + if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
| 866 | + $this->_closeFd(); |
|
| 867 | + return $v_result; |
|
| 868 | + } |
|
| 869 | 869 | |
| 870 | 870 | // ----- Go to beginning of File |
| 871 | 871 | @rewind($this->_zip_fd); |
@@ -878,8 +878,8 @@ discard block |
||
| 878 | 878 | $this->_closeFd(); |
| 879 | 879 | |
| 880 | 880 | $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, |
| 881 | - 'Unable to open temporary file \'' |
|
| 882 | - .$v_zip_temp_name.'\' in binary write mode'); |
|
| 881 | + 'Unable to open temporary file \'' |
|
| 882 | + .$v_zip_temp_name.'\' in binary write mode'); |
|
| 883 | 883 | return Archive_Zip::errorCode(); |
| 884 | 884 | } |
| 885 | 885 | |
@@ -887,64 +887,64 @@ discard block |
||
| 887 | 887 | // TBC : Here I should better append the file and go back to erase the |
| 888 | 888 | // central dir |
| 889 | 889 | $v_size = $v_central_dir['offset']; |
| 890 | - while ($v_size != 0) { |
|
| 891 | - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 890 | + while ($v_size != 0) { |
|
| 891 | + $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 892 | 892 | ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
| 893 | - $v_buffer = fread($this->_zip_fd, $v_read_size); |
|
| 894 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 895 | - $v_size -= $v_read_size; |
|
| 896 | - } |
|
| 893 | + $v_buffer = fread($this->_zip_fd, $v_read_size); |
|
| 894 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 895 | + $v_size -= $v_read_size; |
|
| 896 | + } |
|
| 897 | 897 | |
| 898 | 898 | // ----- Swap the file descriptor |
| 899 | 899 | // Here is a trick : I swap the temporary fd with the zip fd, in order to |
| 900 | 900 | // use the following methods on the temporary fil and not the real archive |
| 901 | 901 | $v_swap = $this->_zip_fd; |
| 902 | - $this->_zip_fd = $v_zip_temp_fd; |
|
| 903 | - $v_zip_temp_fd = $v_swap; |
|
| 902 | + $this->_zip_fd = $v_zip_temp_fd; |
|
| 903 | + $v_zip_temp_fd = $v_swap; |
|
| 904 | 904 | |
| 905 | 905 | // ----- Add the files |
| 906 | 906 | $v_header_list = array(); |
| 907 | - if (($v_result = $this->_addFileList($p_list, $v_header_list, |
|
| 908 | - $p_add_dir, $p_remove_dir, |
|
| 909 | - $p_remove_all_dir, $p_params)) != 1) { |
|
| 910 | - fclose($v_zip_temp_fd); |
|
| 911 | - $this->_closeFd(); |
|
| 912 | - @unlink($v_zip_temp_name); |
|
| 907 | + if (($v_result = $this->_addFileList($p_list, $v_header_list, |
|
| 908 | + $p_add_dir, $p_remove_dir, |
|
| 909 | + $p_remove_all_dir, $p_params)) != 1) { |
|
| 910 | + fclose($v_zip_temp_fd); |
|
| 911 | + $this->_closeFd(); |
|
| 912 | + @unlink($v_zip_temp_name); |
|
| 913 | 913 | |
| 914 | - // ----- Return |
|
| 915 | - return $v_result; |
|
| 916 | - } |
|
| 914 | + // ----- Return |
|
| 915 | + return $v_result; |
|
| 916 | + } |
|
| 917 | 917 | |
| 918 | 918 | // ----- Store the offset of the central dir |
| 919 | 919 | $v_offset = @ftell($this->_zip_fd); |
| 920 | 920 | |
| 921 | 921 | // ----- Copy the block of file headers from the old archive |
| 922 | 922 | $v_size = $v_central_dir['size']; |
| 923 | - while ($v_size != 0) { |
|
| 924 | - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 923 | + while ($v_size != 0) { |
|
| 924 | + $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 925 | 925 | ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
| 926 | - $v_buffer = @fread($v_zip_temp_fd, $v_read_size); |
|
| 927 | - @fwrite($this->_zip_fd, $v_buffer, $v_read_size); |
|
| 928 | - $v_size -= $v_read_size; |
|
| 929 | - } |
|
| 926 | + $v_buffer = @fread($v_zip_temp_fd, $v_read_size); |
|
| 927 | + @fwrite($this->_zip_fd, $v_buffer, $v_read_size); |
|
| 928 | + $v_size -= $v_read_size; |
|
| 929 | + } |
|
| 930 | 930 | |
| 931 | 931 | // ----- Create the Central Dir files header |
| 932 | 932 | for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++) { |
| 933 | 933 | // ----- Create the file header |
| 934 | - if ($v_header_list[$i]['status'] == 'ok') { |
|
| 935 | - if (($v_result=$this->_writeCentralFileHeader($v_header_list[$i]))!=1) { |
|
| 936 | - fclose($v_zip_temp_fd); |
|
| 937 | - $this->_closeFd(); |
|
| 938 | - @unlink($v_zip_temp_name); |
|
| 934 | + if ($v_header_list[$i]['status'] == 'ok') { |
|
| 935 | + if (($v_result=$this->_writeCentralFileHeader($v_header_list[$i]))!=1) { |
|
| 936 | + fclose($v_zip_temp_fd); |
|
| 937 | + $this->_closeFd(); |
|
| 938 | + @unlink($v_zip_temp_name); |
|
| 939 | 939 | |
| 940 | - // ----- Return |
|
| 941 | - return $v_result; |
|
| 942 | - } |
|
| 943 | - $v_count++; |
|
| 944 | - } |
|
| 940 | + // ----- Return |
|
| 941 | + return $v_result; |
|
| 942 | + } |
|
| 943 | + $v_count++; |
|
| 944 | + } |
|
| 945 | 945 | |
| 946 | - // ----- Transform the header to a 'usable' info |
|
| 947 | - $this->_convertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 946 | + // ----- Transform the header to a 'usable' info |
|
| 947 | + $this->_convertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 948 | 948 | } |
| 949 | 949 | |
| 950 | 950 | // ----- Zip file comment |
@@ -959,16 +959,16 @@ discard block |
||
| 959 | 959 | $v_size, $v_offset, |
| 960 | 960 | $v_comment)) != 1) { |
| 961 | 961 | // ----- Reset the file list |
| 962 | - unset($v_header_list); |
|
| 962 | + unset($v_header_list); |
|
| 963 | 963 | |
| 964 | - // ----- Return |
|
| 965 | - return $v_result; |
|
| 964 | + // ----- Return |
|
| 965 | + return $v_result; |
|
| 966 | 966 | } |
| 967 | 967 | |
| 968 | 968 | // ----- Swap back the file descriptor |
| 969 | 969 | $v_swap = $this->_zip_fd; |
| 970 | - $this->_zip_fd = $v_zip_temp_fd; |
|
| 971 | - $v_zip_temp_fd = $v_swap; |
|
| 970 | + $this->_zip_fd = $v_zip_temp_fd; |
|
| 971 | + $v_zip_temp_fd = $v_swap; |
|
| 972 | 972 | |
| 973 | 973 | // ----- Close |
| 974 | 974 | $this->_closeFd(); |
@@ -987,100 +987,100 @@ discard block |
||
| 987 | 987 | |
| 988 | 988 | // ----- Return |
| 989 | 989 | return $v_result; |
| 990 | - } |
|
| 991 | - // --------------------------------------------------------------------------- |
|
| 992 | - |
|
| 993 | - // --------------------------------------------------------------------------- |
|
| 994 | - // Function : _openFd() |
|
| 995 | - // Description : |
|
| 996 | - // Parameters : |
|
| 997 | - // --------------------------------------------------------------------------- |
|
| 998 | - /** |
|
| 999 | - * Archive_Zip::_openFd() |
|
| 1000 | - * |
|
| 1001 | - * { Description } |
|
| 1002 | - * |
|
| 1003 | - */ |
|
| 1004 | - public function _openFd($p_mode) |
|
| 1005 | - { |
|
| 1006 | - $v_result=1; |
|
| 990 | + } |
|
| 991 | + // --------------------------------------------------------------------------- |
|
| 992 | + |
|
| 993 | + // --------------------------------------------------------------------------- |
|
| 994 | + // Function : _openFd() |
|
| 995 | + // Description : |
|
| 996 | + // Parameters : |
|
| 997 | + // --------------------------------------------------------------------------- |
|
| 998 | + /** |
|
| 999 | + * Archive_Zip::_openFd() |
|
| 1000 | + * |
|
| 1001 | + * { Description } |
|
| 1002 | + * |
|
| 1003 | + */ |
|
| 1004 | + public function _openFd($p_mode) |
|
| 1005 | + { |
|
| 1006 | + $v_result=1; |
|
| 1007 | 1007 | |
| 1008 | 1008 | // ----- Look if already open |
| 1009 | 1009 | if ($this->_zip_fd != 0) { |
| 1010 | 1010 | $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, |
| 1011 | - 'Zip file \''.$this->_zipname.'\' already open'); |
|
| 1011 | + 'Zip file \''.$this->_zipname.'\' already open'); |
|
| 1012 | 1012 | return Archive_Zip::errorCode(); |
| 1013 | 1013 | } |
| 1014 | 1014 | |
| 1015 | 1015 | // ----- Open the zip file |
| 1016 | 1016 | if (($this->_zip_fd = @fopen($this->_zipname, $p_mode)) == 0) { |
| 1017 | 1017 | $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, |
| 1018 | - 'Unable to open archive \''.$this->_zipname |
|
| 1019 | - .'\' in '.$p_mode.' mode'); |
|
| 1018 | + 'Unable to open archive \''.$this->_zipname |
|
| 1019 | + .'\' in '.$p_mode.' mode'); |
|
| 1020 | 1020 | return Archive_Zip::errorCode(); |
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | 1023 | // ----- Return |
| 1024 | 1024 | return $v_result; |
| 1025 | - } |
|
| 1026 | - // --------------------------------------------------------------------------- |
|
| 1027 | - |
|
| 1028 | - // --------------------------------------------------------------------------- |
|
| 1029 | - // Function : _closeFd() |
|
| 1030 | - // Description : |
|
| 1031 | - // Parameters : |
|
| 1032 | - // --------------------------------------------------------------------------- |
|
| 1033 | - /** |
|
| 1034 | - * Archive_Zip::_closeFd() |
|
| 1035 | - * |
|
| 1036 | - * { Description } |
|
| 1037 | - * |
|
| 1038 | - */ |
|
| 1039 | - public function _closeFd() |
|
| 1040 | - { |
|
| 1041 | - $v_result=1; |
|
| 1042 | - |
|
| 1043 | - if ($this->_zip_fd != 0) { |
|
| 1044 | - @fclose($this->_zip_fd); |
|
| 1045 | - } |
|
| 1046 | - $this->_zip_fd = 0; |
|
| 1025 | + } |
|
| 1026 | + // --------------------------------------------------------------------------- |
|
| 1027 | + |
|
| 1028 | + // --------------------------------------------------------------------------- |
|
| 1029 | + // Function : _closeFd() |
|
| 1030 | + // Description : |
|
| 1031 | + // Parameters : |
|
| 1032 | + // --------------------------------------------------------------------------- |
|
| 1033 | + /** |
|
| 1034 | + * Archive_Zip::_closeFd() |
|
| 1035 | + * |
|
| 1036 | + * { Description } |
|
| 1037 | + * |
|
| 1038 | + */ |
|
| 1039 | + public function _closeFd() |
|
| 1040 | + { |
|
| 1041 | + $v_result=1; |
|
| 1042 | + |
|
| 1043 | + if ($this->_zip_fd != 0) { |
|
| 1044 | + @fclose($this->_zip_fd); |
|
| 1045 | + } |
|
| 1046 | + $this->_zip_fd = 0; |
|
| 1047 | 1047 | |
| 1048 | 1048 | // ----- Return |
| 1049 | 1049 | return $v_result; |
| 1050 | - } |
|
| 1051 | - // --------------------------------------------------------------------------- |
|
| 1052 | - |
|
| 1053 | - // --------------------------------------------------------------------------- |
|
| 1054 | - // Function : _addList() |
|
| 1055 | - // Description : |
|
| 1056 | - // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is |
|
| 1057 | - // different from the real path of the file. This is usefull if you want to have PclTar |
|
| 1058 | - // running in any directory, and memorize relative path from an other directory. |
|
| 1059 | - // Parameters : |
|
| 1060 | - // $p_list : An array containing the file or directory names to add in the tar |
|
| 1061 | - // $p_result_list : list of added files with their properties (specially the status field) |
|
| 1062 | - // $p_add_dir : Path to add in the filename path archived |
|
| 1063 | - // $p_remove_dir : Path to remove in the filename path archived |
|
| 1064 | - // Return Values : |
|
| 1065 | - // --------------------------------------------------------------------------- |
|
| 1066 | - /** |
|
| 1067 | - * Archive_Zip::_addList() |
|
| 1068 | - * |
|
| 1069 | - * { Description } |
|
| 1070 | - * |
|
| 1071 | - */ |
|
| 1072 | - public function _addList($p_list, &$p_result_list, |
|
| 1050 | + } |
|
| 1051 | + // --------------------------------------------------------------------------- |
|
| 1052 | + |
|
| 1053 | + // --------------------------------------------------------------------------- |
|
| 1054 | + // Function : _addList() |
|
| 1055 | + // Description : |
|
| 1056 | + // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is |
|
| 1057 | + // different from the real path of the file. This is usefull if you want to have PclTar |
|
| 1058 | + // running in any directory, and memorize relative path from an other directory. |
|
| 1059 | + // Parameters : |
|
| 1060 | + // $p_list : An array containing the file or directory names to add in the tar |
|
| 1061 | + // $p_result_list : list of added files with their properties (specially the status field) |
|
| 1062 | + // $p_add_dir : Path to add in the filename path archived |
|
| 1063 | + // $p_remove_dir : Path to remove in the filename path archived |
|
| 1064 | + // Return Values : |
|
| 1065 | + // --------------------------------------------------------------------------- |
|
| 1066 | + /** |
|
| 1067 | + * Archive_Zip::_addList() |
|
| 1068 | + * |
|
| 1069 | + * { Description } |
|
| 1070 | + * |
|
| 1071 | + */ |
|
| 1072 | + public function _addList($p_list, &$p_result_list, |
|
| 1073 | 1073 | $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params) |
| 1074 | - { |
|
| 1075 | - $v_result=1; |
|
| 1074 | + { |
|
| 1075 | + $v_result=1; |
|
| 1076 | 1076 | |
| 1077 | 1077 | // ----- Add the files |
| 1078 | 1078 | $v_header_list = array(); |
| 1079 | - if (($v_result = $this->_addFileList($p_list, $v_header_list, |
|
| 1080 | - $p_add_dir, $p_remove_dir, |
|
| 1081 | - $p_remove_all_dir, $p_params)) != 1) { |
|
| 1082 | - return $v_result; |
|
| 1083 | - } |
|
| 1079 | + if (($v_result = $this->_addFileList($p_list, $v_header_list, |
|
| 1080 | + $p_add_dir, $p_remove_dir, |
|
| 1081 | + $p_remove_all_dir, $p_params)) != 1) { |
|
| 1082 | + return $v_result; |
|
| 1083 | + } |
|
| 1084 | 1084 | |
| 1085 | 1085 | // ----- Store the offset of the central dir |
| 1086 | 1086 | $v_offset = @ftell($this->_zip_fd); |
@@ -1088,15 +1088,15 @@ discard block |
||
| 1088 | 1088 | // ----- Create the Central Dir files header |
| 1089 | 1089 | for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++) { |
| 1090 | 1090 | // ----- Create the file header |
| 1091 | - if ($v_header_list[$i]['status'] == 'ok') { |
|
| 1092 | - if (($v_result = $this->_writeCentralFileHeader($v_header_list[$i])) != 1) { |
|
| 1093 | - return $v_result; |
|
| 1094 | - } |
|
| 1095 | - $v_count++; |
|
| 1096 | - } |
|
| 1091 | + if ($v_header_list[$i]['status'] == 'ok') { |
|
| 1092 | + if (($v_result = $this->_writeCentralFileHeader($v_header_list[$i])) != 1) { |
|
| 1093 | + return $v_result; |
|
| 1094 | + } |
|
| 1095 | + $v_count++; |
|
| 1096 | + } |
|
| 1097 | 1097 | |
| 1098 | - // ----- Transform the header to a 'usable' info |
|
| 1099 | - $this->_convertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 1098 | + // ----- Transform the header to a 'usable' info |
|
| 1099 | + $this->_convertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]); |
|
| 1100 | 1100 | } |
| 1101 | 1101 | |
| 1102 | 1102 | // ----- Zip file comment |
@@ -1109,42 +1109,42 @@ discard block |
||
| 1109 | 1109 | if (($v_result = $this->_writeCentralHeader($v_count, $v_size, $v_offset, |
| 1110 | 1110 | $v_comment)) != 1) { |
| 1111 | 1111 | // ----- Reset the file list |
| 1112 | - unset($v_header_list); |
|
| 1112 | + unset($v_header_list); |
|
| 1113 | 1113 | |
| 1114 | - // ----- Return |
|
| 1115 | - return $v_result; |
|
| 1114 | + // ----- Return |
|
| 1115 | + return $v_result; |
|
| 1116 | 1116 | } |
| 1117 | 1117 | |
| 1118 | 1118 | // ----- Return |
| 1119 | 1119 | return $v_result; |
| 1120 | - } |
|
| 1121 | - // --------------------------------------------------------------------------- |
|
| 1122 | - |
|
| 1123 | - // --------------------------------------------------------------------------- |
|
| 1124 | - // Function : _addFileList() |
|
| 1125 | - // Description : |
|
| 1126 | - // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is |
|
| 1127 | - // different from the real path of the file. This is usefull if you want to |
|
| 1128 | - // run the lib in any directory, and memorize relative path from an other directory. |
|
| 1129 | - // Parameters : |
|
| 1130 | - // $p_list : An array containing the file or directory names to add in the tar |
|
| 1131 | - // $p_result_list : list of added files with their properties (specially the status field) |
|
| 1132 | - // $p_add_dir : Path to add in the filename path archived |
|
| 1133 | - // $p_remove_dir : Path to remove in the filename path archived |
|
| 1134 | - // Return Values : |
|
| 1135 | - // --------------------------------------------------------------------------- |
|
| 1136 | - /** |
|
| 1137 | - * Archive_Zip::_addFileList() |
|
| 1138 | - * |
|
| 1139 | - * { Description } |
|
| 1140 | - * |
|
| 1141 | - */ |
|
| 1142 | - public function _addFileList($p_list, &$p_result_list, |
|
| 1120 | + } |
|
| 1121 | + // --------------------------------------------------------------------------- |
|
| 1122 | + |
|
| 1123 | + // --------------------------------------------------------------------------- |
|
| 1124 | + // Function : _addFileList() |
|
| 1125 | + // Description : |
|
| 1126 | + // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is |
|
| 1127 | + // different from the real path of the file. This is usefull if you want to |
|
| 1128 | + // run the lib in any directory, and memorize relative path from an other directory. |
|
| 1129 | + // Parameters : |
|
| 1130 | + // $p_list : An array containing the file or directory names to add in the tar |
|
| 1131 | + // $p_result_list : list of added files with their properties (specially the status field) |
|
| 1132 | + // $p_add_dir : Path to add in the filename path archived |
|
| 1133 | + // $p_remove_dir : Path to remove in the filename path archived |
|
| 1134 | + // Return Values : |
|
| 1135 | + // --------------------------------------------------------------------------- |
|
| 1136 | + /** |
|
| 1137 | + * Archive_Zip::_addFileList() |
|
| 1138 | + * |
|
| 1139 | + * { Description } |
|
| 1140 | + * |
|
| 1141 | + */ |
|
| 1142 | + public function _addFileList($p_list, &$p_result_list, |
|
| 1143 | 1143 | $p_add_dir, $p_remove_dir, $p_remove_all_dir, |
| 1144 | 1144 | &$p_params) |
| 1145 | - { |
|
| 1146 | - $v_result=1; |
|
| 1147 | - $v_header = array(); |
|
| 1145 | + { |
|
| 1146 | + $v_result=1; |
|
| 1147 | + $v_header = array(); |
|
| 1148 | 1148 | |
| 1149 | 1149 | // ----- Recuperate the current number of elt in list |
| 1150 | 1150 | $v_nb = sizeof($p_result_list); |
@@ -1152,34 +1152,34 @@ discard block |
||
| 1152 | 1152 | // ----- Loop on the files |
| 1153 | 1153 | for ($j=0; ($j<count($p_list)) && ($v_result==1); $j++) { |
| 1154 | 1154 | // ----- Recuperate the filename |
| 1155 | - $p_filename = $this->_tool_TranslateWinPath($p_list[$j], false); |
|
| 1156 | - |
|
| 1157 | - // ----- Skip empty file names |
|
| 1158 | - if ($p_filename == "") { |
|
| 1159 | - continue; |
|
| 1160 | - } |
|
| 1161 | - |
|
| 1162 | - // ----- Check the filename |
|
| 1163 | - if (!file_exists($p_filename)) { |
|
| 1164 | - $this->_errorLog(ARCHIVE_ZIP_ERR_MISSING_FILE, |
|
| 1165 | - "File '$p_filename' does not exists"); |
|
| 1166 | - return Archive_Zip::errorCode(); |
|
| 1167 | - } |
|
| 1168 | - |
|
| 1169 | - // ----- Look if it is a file or a dir with no all pathnre move |
|
| 1170 | - if ((is_file($p_filename)) || ((is_dir($p_filename)) && !$p_remove_all_dir)) { |
|
| 1171 | - // ----- Add the file |
|
| 1155 | + $p_filename = $this->_tool_TranslateWinPath($p_list[$j], false); |
|
| 1156 | + |
|
| 1157 | + // ----- Skip empty file names |
|
| 1158 | + if ($p_filename == "") { |
|
| 1159 | + continue; |
|
| 1160 | + } |
|
| 1161 | + |
|
| 1162 | + // ----- Check the filename |
|
| 1163 | + if (!file_exists($p_filename)) { |
|
| 1164 | + $this->_errorLog(ARCHIVE_ZIP_ERR_MISSING_FILE, |
|
| 1165 | + "File '$p_filename' does not exists"); |
|
| 1166 | + return Archive_Zip::errorCode(); |
|
| 1167 | + } |
|
| 1168 | + |
|
| 1169 | + // ----- Look if it is a file or a dir with no all pathnre move |
|
| 1170 | + if ((is_file($p_filename)) || ((is_dir($p_filename)) && !$p_remove_all_dir)) { |
|
| 1171 | + // ----- Add the file |
|
| 1172 | 1172 | if (($v_result = $this->_addFile($p_filename, $v_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_params)) != 1) { |
| 1173 | 1173 | // ----- Return status |
| 1174 | - return $v_result; |
|
| 1174 | + return $v_result; |
|
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | 1177 | // ----- Store the file infos |
| 1178 | 1178 | $p_result_list[$v_nb++] = $v_header; |
| 1179 | - } |
|
| 1179 | + } |
|
| 1180 | 1180 | |
| 1181 | - // ----- Look for directory |
|
| 1182 | - if (is_dir($p_filename)) { |
|
| 1181 | + // ----- Look for directory |
|
| 1182 | + if (is_dir($p_filename)) { |
|
| 1183 | 1183 | |
| 1184 | 1184 | // ----- Look for path |
| 1185 | 1185 | if ($p_filename != ".") { |
@@ -1190,69 +1190,69 @@ discard block |
||
| 1190 | 1190 | |
| 1191 | 1191 | // ----- Read the directory for files and sub-directories |
| 1192 | 1192 | $p_hdir = opendir($p_filename); |
| 1193 | - $p_hitem = readdir($p_hdir); // '.' directory |
|
| 1193 | + $p_hitem = readdir($p_hdir); // '.' directory |
|
| 1194 | 1194 | $p_hitem = readdir($p_hdir); // '..' directory |
| 1195 | 1195 | while ($p_hitem = readdir($p_hdir)) { |
| 1196 | 1196 | |
| 1197 | - // ----- Look for a file |
|
| 1198 | - if (is_file($v_path.$p_hitem)) { |
|
| 1197 | + // ----- Look for a file |
|
| 1198 | + if (is_file($v_path.$p_hitem)) { |
|
| 1199 | 1199 | |
| 1200 | 1200 | // ----- Add the file |
| 1201 | 1201 | if (($v_result = $this->_addFile($v_path.$p_hitem, $v_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_params)) != 1) { |
| 1202 | 1202 | // ----- Return status |
| 1203 | - return $v_result; |
|
| 1203 | + return $v_result; |
|
| 1204 | 1204 | } |
| 1205 | 1205 | |
| 1206 | 1206 | // ----- Store the file infos |
| 1207 | 1207 | $p_result_list[$v_nb++] = $v_header; |
| 1208 | - } |
|
| 1208 | + } |
|
| 1209 | 1209 | |
| 1210 | - // ----- Recursive call to _addFileList() |
|
| 1211 | - else { |
|
| 1210 | + // ----- Recursive call to _addFileList() |
|
| 1211 | + else { |
|
| 1212 | 1212 | |
| 1213 | 1213 | // ----- Need an array as parameter |
| 1214 | 1214 | $p_temp_list[0] = $v_path.$p_hitem; |
| 1215 | - $v_result = $this->_addFileList($p_temp_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_params); |
|
| 1215 | + $v_result = $this->_addFileList($p_temp_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_params); |
|
| 1216 | 1216 | |
| 1217 | 1217 | // ----- Update the number of elements of the list |
| 1218 | 1218 | $v_nb = sizeof($p_result_list); |
| 1219 | - } |
|
| 1219 | + } |
|
| 1220 | 1220 | } |
| 1221 | 1221 | |
| 1222 | 1222 | // ----- Free memory for the recursive loop |
| 1223 | 1223 | unset($p_temp_list); |
| 1224 | - unset($p_hdir); |
|
| 1225 | - unset($p_hitem); |
|
| 1226 | - } |
|
| 1227 | - } |
|
| 1228 | - |
|
| 1229 | - return $v_result; |
|
| 1230 | - } |
|
| 1231 | - // --------------------------------------------------------------------------- |
|
| 1232 | - |
|
| 1233 | - // --------------------------------------------------------------------------- |
|
| 1234 | - // Function : _addFile() |
|
| 1235 | - // Description : |
|
| 1236 | - // Parameters : |
|
| 1237 | - // Return Values : |
|
| 1238 | - // --------------------------------------------------------------------------- |
|
| 1239 | - /** |
|
| 1240 | - * Archive_Zip::_addFile() |
|
| 1241 | - * |
|
| 1242 | - * { Description } |
|
| 1243 | - * |
|
| 1244 | - */ |
|
| 1245 | - public function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params) |
|
| 1246 | - { |
|
| 1247 | - $v_result=1; |
|
| 1248 | - |
|
| 1249 | - if ($p_filename == "") { |
|
| 1250 | - // ----- Error log |
|
| 1251 | - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)"); |
|
| 1224 | + unset($p_hdir); |
|
| 1225 | + unset($p_hitem); |
|
| 1226 | + } |
|
| 1227 | + } |
|
| 1252 | 1228 | |
| 1253 | - // ----- Return |
|
| 1254 | - return Archive_Zip::errorCode(); |
|
| 1255 | - } |
|
| 1229 | + return $v_result; |
|
| 1230 | + } |
|
| 1231 | + // --------------------------------------------------------------------------- |
|
| 1232 | + |
|
| 1233 | + // --------------------------------------------------------------------------- |
|
| 1234 | + // Function : _addFile() |
|
| 1235 | + // Description : |
|
| 1236 | + // Parameters : |
|
| 1237 | + // Return Values : |
|
| 1238 | + // --------------------------------------------------------------------------- |
|
| 1239 | + /** |
|
| 1240 | + * Archive_Zip::_addFile() |
|
| 1241 | + * |
|
| 1242 | + * { Description } |
|
| 1243 | + * |
|
| 1244 | + */ |
|
| 1245 | + public function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params) |
|
| 1246 | + { |
|
| 1247 | + $v_result=1; |
|
| 1248 | + |
|
| 1249 | + if ($p_filename == "") { |
|
| 1250 | + // ----- Error log |
|
| 1251 | + $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)"); |
|
| 1252 | + |
|
| 1253 | + // ----- Return |
|
| 1254 | + return Archive_Zip::errorCode(); |
|
| 1255 | + } |
|
| 1256 | 1256 | |
| 1257 | 1257 | // ----- Calculate the stored filename |
| 1258 | 1258 | $v_stored_filename = $p_filename; |
@@ -1315,51 +1315,51 @@ discard block |
||
| 1315 | 1315 | |
| 1316 | 1316 | // ----- Set the file properties |
| 1317 | 1317 | clearstatcache(); |
| 1318 | - $p_header['version'] = 20; |
|
| 1319 | - $p_header['version_extracted'] = 10; |
|
| 1320 | - $p_header['flag'] = 0; |
|
| 1321 | - $p_header['compression'] = 0; |
|
| 1322 | - $p_header['mtime'] = filemtime($p_filename); |
|
| 1323 | - $p_header['crc'] = 0; |
|
| 1324 | - $p_header['compressed_size'] = 0; |
|
| 1325 | - $p_header['size'] = filesize($p_filename); |
|
| 1326 | - $p_header['filename_len'] = strlen($p_filename); |
|
| 1327 | - $p_header['extra_len'] = 0; |
|
| 1328 | - $p_header['comment_len'] = 0; |
|
| 1329 | - $p_header['disk'] = 0; |
|
| 1330 | - $p_header['internal'] = 0; |
|
| 1331 | - $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010); |
|
| 1332 | - $p_header['offset'] = 0; |
|
| 1333 | - $p_header['filename'] = $p_filename; |
|
| 1334 | - $p_header['stored_filename'] = $v_stored_filename; |
|
| 1335 | - $p_header['extra'] = ''; |
|
| 1336 | - $p_header['comment'] = ''; |
|
| 1337 | - $p_header['status'] = 'ok'; |
|
| 1338 | - $p_header['index'] = -1; |
|
| 1318 | + $p_header['version'] = 20; |
|
| 1319 | + $p_header['version_extracted'] = 10; |
|
| 1320 | + $p_header['flag'] = 0; |
|
| 1321 | + $p_header['compression'] = 0; |
|
| 1322 | + $p_header['mtime'] = filemtime($p_filename); |
|
| 1323 | + $p_header['crc'] = 0; |
|
| 1324 | + $p_header['compressed_size'] = 0; |
|
| 1325 | + $p_header['size'] = filesize($p_filename); |
|
| 1326 | + $p_header['filename_len'] = strlen($p_filename); |
|
| 1327 | + $p_header['extra_len'] = 0; |
|
| 1328 | + $p_header['comment_len'] = 0; |
|
| 1329 | + $p_header['disk'] = 0; |
|
| 1330 | + $p_header['internal'] = 0; |
|
| 1331 | + $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010); |
|
| 1332 | + $p_header['offset'] = 0; |
|
| 1333 | + $p_header['filename'] = $p_filename; |
|
| 1334 | + $p_header['stored_filename'] = $v_stored_filename; |
|
| 1335 | + $p_header['extra'] = ''; |
|
| 1336 | + $p_header['comment'] = ''; |
|
| 1337 | + $p_header['status'] = 'ok'; |
|
| 1338 | + $p_header['index'] = -1; |
|
| 1339 | 1339 | |
| 1340 | 1340 | // ----- Look for pre-add callback |
| 1341 | 1341 | if ((isset($p_params[ARCHIVE_ZIP_PARAM_PRE_ADD])) |
| 1342 | 1342 | && ($p_params[ARCHIVE_ZIP_PARAM_PRE_ADD] != '')) { |
| 1343 | 1343 | |
| 1344 | - // ----- Generate a local information |
|
| 1345 | - $v_local_header = array(); |
|
| 1344 | + // ----- Generate a local information |
|
| 1345 | + $v_local_header = array(); |
|
| 1346 | 1346 | $this->_convertHeader2FileInfo($p_header, $v_local_header); |
| 1347 | 1347 | |
| 1348 | - // ----- Call the callback |
|
| 1349 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 1350 | - // header. |
|
| 1351 | - eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_PRE_ADD].'(ARCHIVE_ZIP_PARAM_PRE_ADD, $v_local_header);'); |
|
| 1348 | + // ----- Call the callback |
|
| 1349 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 1350 | + // header. |
|
| 1351 | + eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_PRE_ADD].'(ARCHIVE_ZIP_PARAM_PRE_ADD, $v_local_header);'); |
|
| 1352 | 1352 | if ($v_result == 0) { |
| 1353 | 1353 | // ----- Change the file status |
| 1354 | 1354 | $p_header['status'] = "skipped"; |
| 1355 | 1355 | $v_result = 1; |
| 1356 | 1356 | } |
| 1357 | 1357 | |
| 1358 | - // ----- Update the informations |
|
| 1359 | - // Only some fields can be modified |
|
| 1360 | - if ($p_header['stored_filename'] != $v_local_header['stored_filename']) { |
|
| 1361 | - $p_header['stored_filename'] = $this->_tool_PathReduction($v_local_header['stored_filename']); |
|
| 1362 | - } |
|
| 1358 | + // ----- Update the informations |
|
| 1359 | + // Only some fields can be modified |
|
| 1360 | + if ($p_header['stored_filename'] != $v_local_header['stored_filename']) { |
|
| 1361 | + $p_header['stored_filename'] = $this->_tool_PathReduction($v_local_header['stored_filename']); |
|
| 1362 | + } |
|
| 1363 | 1363 | } |
| 1364 | 1364 | |
| 1365 | 1365 | // ----- Look for empty stored filename |
@@ -1375,34 +1375,34 @@ discard block |
||
| 1375 | 1375 | // ----- Look if no error, or file not skipped |
| 1376 | 1376 | if ($p_header['status'] == 'ok') { |
| 1377 | 1377 | |
| 1378 | - // ----- Look for a file |
|
| 1379 | - if (is_file($p_filename)) { |
|
| 1380 | - // ----- Open the source file |
|
| 1378 | + // ----- Look for a file |
|
| 1379 | + if (is_file($p_filename)) { |
|
| 1380 | + // ----- Open the source file |
|
| 1381 | 1381 | if (($v_file = @fopen($p_filename, "rb")) == 0) { |
| 1382 | 1382 | $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode"); |
| 1383 | 1383 | return Archive_Zip::errorCode(); |
| 1384 | 1384 | } |
| 1385 | 1385 | |
| 1386 | - if ($p_params['no_compression']) { |
|
| 1387 | - // ----- Read the file content |
|
| 1388 | - $v_content_compressed = @fread($v_file, $p_header['size']); |
|
| 1386 | + if ($p_params['no_compression']) { |
|
| 1387 | + // ----- Read the file content |
|
| 1388 | + $v_content_compressed = @fread($v_file, $p_header['size']); |
|
| 1389 | 1389 | |
| 1390 | - // ----- Calculate the CRC |
|
| 1391 | - $p_header['crc'] = crc32($v_content_compressed); |
|
| 1392 | - } else { |
|
| 1393 | - // ----- Read the file content |
|
| 1394 | - $v_content = @fread($v_file, $p_header['size']); |
|
| 1390 | + // ----- Calculate the CRC |
|
| 1391 | + $p_header['crc'] = crc32($v_content_compressed); |
|
| 1392 | + } else { |
|
| 1393 | + // ----- Read the file content |
|
| 1394 | + $v_content = @fread($v_file, $p_header['size']); |
|
| 1395 | 1395 | |
| 1396 | - // ----- Calculate the CRC |
|
| 1397 | - $p_header['crc'] = crc32($v_content); |
|
| 1396 | + // ----- Calculate the CRC |
|
| 1397 | + $p_header['crc'] = crc32($v_content); |
|
| 1398 | 1398 | |
| 1399 | - // ----- Compress the file |
|
| 1400 | - $v_content_compressed = gzdeflate($v_content); |
|
| 1401 | - } |
|
| 1399 | + // ----- Compress the file |
|
| 1400 | + $v_content_compressed = gzdeflate($v_content); |
|
| 1401 | + } |
|
| 1402 | 1402 | |
| 1403 | 1403 | // ----- Set header parameters |
| 1404 | 1404 | $p_header['compressed_size'] = strlen($v_content_compressed); |
| 1405 | - $p_header['compression'] = 8; |
|
| 1405 | + $p_header['compression'] = 8; |
|
| 1406 | 1406 | |
| 1407 | 1407 | // ----- Call the header generation |
| 1408 | 1408 | if (($v_result = $this->_writeFileHeader($p_header)) != 1) { |
@@ -1412,68 +1412,68 @@ discard block |
||
| 1412 | 1412 | |
| 1413 | 1413 | // ----- Write the compressed content |
| 1414 | 1414 | $v_binary_data = pack('a'.$p_header['compressed_size'], $v_content_compressed); |
| 1415 | - @fwrite($this->_zip_fd, $v_binary_data, $p_header['compressed_size']); |
|
| 1415 | + @fwrite($this->_zip_fd, $v_binary_data, $p_header['compressed_size']); |
|
| 1416 | 1416 | |
| 1417 | 1417 | // ----- Close the file |
| 1418 | 1418 | @fclose($v_file); |
| 1419 | - } |
|
| 1419 | + } |
|
| 1420 | 1420 | |
| 1421 | - // ----- Look for a directory |
|
| 1422 | - else { |
|
| 1423 | - // ----- Set the file properties |
|
| 1421 | + // ----- Look for a directory |
|
| 1422 | + else { |
|
| 1423 | + // ----- Set the file properties |
|
| 1424 | 1424 | $p_header['filename'] .= '/'; |
| 1425 | - $p_header['filename_len']++; |
|
| 1426 | - $p_header['size'] = 0; |
|
| 1427 | - $p_header['external'] = 0x41FF0010; // Value for a folder : to be checked |
|
| 1425 | + $p_header['filename_len']++; |
|
| 1426 | + $p_header['size'] = 0; |
|
| 1427 | + $p_header['external'] = 0x41FF0010; // Value for a folder : to be checked |
|
| 1428 | 1428 | |
| 1429 | 1429 | // ----- Call the header generation |
| 1430 | 1430 | if (($v_result = $this->_writeFileHeader($p_header)) != 1) { |
| 1431 | 1431 | return $v_result; |
| 1432 | 1432 | } |
| 1433 | - } |
|
| 1433 | + } |
|
| 1434 | 1434 | } |
| 1435 | 1435 | |
| 1436 | 1436 | // ----- Look for pre-add callback |
| 1437 | 1437 | if ((isset($p_params[ARCHIVE_ZIP_PARAM_POST_ADD])) |
| 1438 | 1438 | && ($p_params[ARCHIVE_ZIP_PARAM_POST_ADD] != '')) { |
| 1439 | 1439 | |
| 1440 | - // ----- Generate a local information |
|
| 1441 | - $v_local_header = array(); |
|
| 1440 | + // ----- Generate a local information |
|
| 1441 | + $v_local_header = array(); |
|
| 1442 | 1442 | $this->_convertHeader2FileInfo($p_header, $v_local_header); |
| 1443 | 1443 | |
| 1444 | - // ----- Call the callback |
|
| 1445 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 1446 | - // header. |
|
| 1447 | - eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_POST_ADD].'(ARCHIVE_ZIP_PARAM_POST_ADD, $v_local_header);'); |
|
| 1444 | + // ----- Call the callback |
|
| 1445 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 1446 | + // header. |
|
| 1447 | + eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_POST_ADD].'(ARCHIVE_ZIP_PARAM_POST_ADD, $v_local_header);'); |
|
| 1448 | 1448 | if ($v_result == 0) { |
| 1449 | 1449 | // ----- Ignored |
| 1450 | 1450 | $v_result = 1; |
| 1451 | 1451 | } |
| 1452 | 1452 | |
| 1453 | - // ----- Update the informations |
|
| 1454 | - // Nothing can be modified |
|
| 1453 | + // ----- Update the informations |
|
| 1454 | + // Nothing can be modified |
|
| 1455 | 1455 | } |
| 1456 | 1456 | |
| 1457 | 1457 | // ----- Return |
| 1458 | 1458 | return $v_result; |
| 1459 | - } |
|
| 1460 | - // --------------------------------------------------------------------------- |
|
| 1461 | - |
|
| 1462 | - // --------------------------------------------------------------------------- |
|
| 1463 | - // Function : _writeFileHeader() |
|
| 1464 | - // Description : |
|
| 1465 | - // Parameters : |
|
| 1466 | - // Return Values : |
|
| 1467 | - // --------------------------------------------------------------------------- |
|
| 1468 | - /** |
|
| 1469 | - * Archive_Zip::_writeFileHeader() |
|
| 1470 | - * |
|
| 1471 | - * { Description } |
|
| 1472 | - * |
|
| 1473 | - */ |
|
| 1474 | - public function _writeFileHeader(&$p_header) |
|
| 1475 | - { |
|
| 1476 | - $v_result=1; |
|
| 1459 | + } |
|
| 1460 | + // --------------------------------------------------------------------------- |
|
| 1461 | + |
|
| 1462 | + // --------------------------------------------------------------------------- |
|
| 1463 | + // Function : _writeFileHeader() |
|
| 1464 | + // Description : |
|
| 1465 | + // Parameters : |
|
| 1466 | + // Return Values : |
|
| 1467 | + // --------------------------------------------------------------------------- |
|
| 1468 | + /** |
|
| 1469 | + * Archive_Zip::_writeFileHeader() |
|
| 1470 | + * |
|
| 1471 | + * { Description } |
|
| 1472 | + * |
|
| 1473 | + */ |
|
| 1474 | + public function _writeFileHeader(&$p_header) |
|
| 1475 | + { |
|
| 1476 | + $v_result=1; |
|
| 1477 | 1477 | |
| 1478 | 1478 | // TBC |
| 1479 | 1479 | //for(reset($p_header); $key = key($p_header); next($p_header)) { |
@@ -1484,14 +1484,14 @@ discard block |
||
| 1484 | 1484 | |
| 1485 | 1485 | // ----- Transform UNIX mtime to DOS format mdate/mtime |
| 1486 | 1486 | $v_date = getdate($p_header['mtime']); |
| 1487 | - $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 1488 | - $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 1487 | + $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 1488 | + $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 1489 | 1489 | |
| 1490 | 1490 | // ----- Packed data |
| 1491 | 1491 | $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, $p_header['version'], $p_header['flag'], |
| 1492 | - $p_header['compression'], $v_mtime, $v_mdate, |
|
| 1493 | - $p_header['crc'], $p_header['compressed_size'], $p_header['size'], |
|
| 1494 | - strlen($p_header['stored_filename']), $p_header['extra_len']); |
|
| 1492 | + $p_header['compression'], $v_mtime, $v_mdate, |
|
| 1493 | + $p_header['crc'], $p_header['compressed_size'], $p_header['size'], |
|
| 1494 | + strlen($p_header['stored_filename']), $p_header['extra_len']); |
|
| 1495 | 1495 | |
| 1496 | 1496 | // ----- Write the first 148 bytes of the header in the archive |
| 1497 | 1497 | fputs($this->_zip_fd, $v_binary_data, 30); |
@@ -1500,30 +1500,30 @@ discard block |
||
| 1500 | 1500 | if (strlen($p_header['stored_filename']) != 0) { |
| 1501 | 1501 | fputs($this->_zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); |
| 1502 | 1502 | } |
| 1503 | - if ($p_header['extra_len'] != 0) { |
|
| 1504 | - fputs($this->_zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
| 1505 | - } |
|
| 1503 | + if ($p_header['extra_len'] != 0) { |
|
| 1504 | + fputs($this->_zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
| 1505 | + } |
|
| 1506 | 1506 | |
| 1507 | 1507 | // ----- Return |
| 1508 | 1508 | return $v_result; |
| 1509 | - } |
|
| 1510 | - // --------------------------------------------------------------------------- |
|
| 1511 | - |
|
| 1512 | - // --------------------------------------------------------------------------- |
|
| 1513 | - // Function : _writeCentralFileHeader() |
|
| 1514 | - // Description : |
|
| 1515 | - // Parameters : |
|
| 1516 | - // Return Values : |
|
| 1517 | - // --------------------------------------------------------------------------- |
|
| 1518 | - /** |
|
| 1519 | - * Archive_Zip::_writeCentralFileHeader() |
|
| 1520 | - * |
|
| 1521 | - * { Description } |
|
| 1522 | - * |
|
| 1523 | - */ |
|
| 1524 | - public function _writeCentralFileHeader(&$p_header) |
|
| 1525 | - { |
|
| 1526 | - $v_result=1; |
|
| 1509 | + } |
|
| 1510 | + // --------------------------------------------------------------------------- |
|
| 1511 | + |
|
| 1512 | + // --------------------------------------------------------------------------- |
|
| 1513 | + // Function : _writeCentralFileHeader() |
|
| 1514 | + // Description : |
|
| 1515 | + // Parameters : |
|
| 1516 | + // Return Values : |
|
| 1517 | + // --------------------------------------------------------------------------- |
|
| 1518 | + /** |
|
| 1519 | + * Archive_Zip::_writeCentralFileHeader() |
|
| 1520 | + * |
|
| 1521 | + * { Description } |
|
| 1522 | + * |
|
| 1523 | + */ |
|
| 1524 | + public function _writeCentralFileHeader(&$p_header) |
|
| 1525 | + { |
|
| 1526 | + $v_result=1; |
|
| 1527 | 1527 | |
| 1528 | 1528 | // TBC |
| 1529 | 1529 | //for(reset($p_header); $key = key($p_header); next($p_header)) { |
@@ -1531,15 +1531,15 @@ discard block |
||
| 1531 | 1531 | |
| 1532 | 1532 | // ----- Transform UNIX mtime to DOS format mdate/mtime |
| 1533 | 1533 | $v_date = getdate($p_header['mtime']); |
| 1534 | - $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 1535 | - $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 1534 | + $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 1535 | + $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 1536 | 1536 | |
| 1537 | 1537 | // ----- Packed data |
| 1538 | 1538 | $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, $p_header['version'], $p_header['version_extracted'], |
| 1539 | - $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'], |
|
| 1540 | - $p_header['compressed_size'], $p_header['size'], |
|
| 1541 | - strlen($p_header['stored_filename']), $p_header['extra_len'], $p_header['comment_len'], |
|
| 1542 | - $p_header['disk'], $p_header['internal'], $p_header['external'], $p_header['offset']); |
|
| 1539 | + $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'], |
|
| 1540 | + $p_header['compressed_size'], $p_header['size'], |
|
| 1541 | + strlen($p_header['stored_filename']), $p_header['extra_len'], $p_header['comment_len'], |
|
| 1542 | + $p_header['disk'], $p_header['internal'], $p_header['external'], $p_header['offset']); |
|
| 1543 | 1543 | |
| 1544 | 1544 | // ----- Write the 42 bytes of the header in the zip file |
| 1545 | 1545 | fputs($this->_zip_fd, $v_binary_data, 46); |
@@ -1548,33 +1548,33 @@ discard block |
||
| 1548 | 1548 | if (strlen($p_header['stored_filename']) != 0) { |
| 1549 | 1549 | fputs($this->_zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename'])); |
| 1550 | 1550 | } |
| 1551 | - if ($p_header['extra_len'] != 0) { |
|
| 1552 | - fputs($this->_zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
| 1553 | - } |
|
| 1554 | - if ($p_header['comment_len'] != 0) { |
|
| 1555 | - fputs($this->_zip_fd, $p_header['comment'], $p_header['comment_len']); |
|
| 1556 | - } |
|
| 1551 | + if ($p_header['extra_len'] != 0) { |
|
| 1552 | + fputs($this->_zip_fd, $p_header['extra'], $p_header['extra_len']); |
|
| 1553 | + } |
|
| 1554 | + if ($p_header['comment_len'] != 0) { |
|
| 1555 | + fputs($this->_zip_fd, $p_header['comment'], $p_header['comment_len']); |
|
| 1556 | + } |
|
| 1557 | 1557 | |
| 1558 | 1558 | // ----- Return |
| 1559 | 1559 | return $v_result; |
| 1560 | - } |
|
| 1561 | - // --------------------------------------------------------------------------- |
|
| 1562 | - |
|
| 1563 | - // --------------------------------------------------------------------------- |
|
| 1564 | - // Function : _writeCentralHeader() |
|
| 1565 | - // Description : |
|
| 1566 | - // Parameters : |
|
| 1567 | - // Return Values : |
|
| 1568 | - // --------------------------------------------------------------------------- |
|
| 1569 | - /** |
|
| 1570 | - * Archive_Zip::_writeCentralHeader() |
|
| 1571 | - * |
|
| 1572 | - * { Description } |
|
| 1573 | - * |
|
| 1574 | - */ |
|
| 1575 | - public function _writeCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) |
|
| 1576 | - { |
|
| 1577 | - $v_result=1; |
|
| 1560 | + } |
|
| 1561 | + // --------------------------------------------------------------------------- |
|
| 1562 | + |
|
| 1563 | + // --------------------------------------------------------------------------- |
|
| 1564 | + // Function : _writeCentralHeader() |
|
| 1565 | + // Description : |
|
| 1566 | + // Parameters : |
|
| 1567 | + // Return Values : |
|
| 1568 | + // --------------------------------------------------------------------------- |
|
| 1569 | + /** |
|
| 1570 | + * Archive_Zip::_writeCentralHeader() |
|
| 1571 | + * |
|
| 1572 | + * { Description } |
|
| 1573 | + * |
|
| 1574 | + */ |
|
| 1575 | + public function _writeCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) |
|
| 1576 | + { |
|
| 1577 | + $v_result=1; |
|
| 1578 | 1578 | |
| 1579 | 1579 | // ----- Packed data |
| 1580 | 1580 | $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, $p_nb_entries, $p_size, $p_offset, strlen($p_comment)); |
@@ -1589,60 +1589,60 @@ discard block |
||
| 1589 | 1589 | |
| 1590 | 1590 | // ----- Return |
| 1591 | 1591 | return $v_result; |
| 1592 | - } |
|
| 1593 | - // --------------------------------------------------------------------------- |
|
| 1594 | - |
|
| 1595 | - // --------------------------------------------------------------------------- |
|
| 1596 | - // Function : _list() |
|
| 1597 | - // Description : |
|
| 1598 | - // Parameters : |
|
| 1599 | - // Return Values : |
|
| 1600 | - // --------------------------------------------------------------------------- |
|
| 1601 | - /** |
|
| 1602 | - * Archive_Zip::_list() |
|
| 1603 | - * |
|
| 1604 | - * { Description } |
|
| 1605 | - * |
|
| 1606 | - */ |
|
| 1607 | - public function _list(&$p_list) |
|
| 1608 | - { |
|
| 1609 | - $v_result=1; |
|
| 1592 | + } |
|
| 1593 | + // --------------------------------------------------------------------------- |
|
| 1594 | + |
|
| 1595 | + // --------------------------------------------------------------------------- |
|
| 1596 | + // Function : _list() |
|
| 1597 | + // Description : |
|
| 1598 | + // Parameters : |
|
| 1599 | + // Return Values : |
|
| 1600 | + // --------------------------------------------------------------------------- |
|
| 1601 | + /** |
|
| 1602 | + * Archive_Zip::_list() |
|
| 1603 | + * |
|
| 1604 | + * { Description } |
|
| 1605 | + * |
|
| 1606 | + */ |
|
| 1607 | + public function _list(&$p_list) |
|
| 1608 | + { |
|
| 1609 | + $v_result=1; |
|
| 1610 | 1610 | |
| 1611 | 1611 | // ----- Open the zip file |
| 1612 | 1612 | if (($this->_zip_fd = @fopen($this->_zipname, 'rb')) == 0) { |
| 1613 | 1613 | // ----- Error log |
| 1614 | - $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->_zipname.'\' in binary read mode'); |
|
| 1614 | + $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->_zipname.'\' in binary read mode'); |
|
| 1615 | 1615 | |
| 1616 | - // ----- Return |
|
| 1617 | - return Archive_Zip::errorCode(); |
|
| 1616 | + // ----- Return |
|
| 1617 | + return Archive_Zip::errorCode(); |
|
| 1618 | 1618 | } |
| 1619 | 1619 | |
| 1620 | 1620 | // ----- Read the central directory informations |
| 1621 | 1621 | $v_central_dir = array(); |
| 1622 | - if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
| 1623 | - return $v_result; |
|
| 1624 | - } |
|
| 1622 | + if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
| 1623 | + return $v_result; |
|
| 1624 | + } |
|
| 1625 | 1625 | |
| 1626 | 1626 | // ----- Go to beginning of Central Dir |
| 1627 | 1627 | @rewind($this->_zip_fd); |
| 1628 | - if (@fseek($this->_zip_fd, $v_central_dir['offset'])) { |
|
| 1629 | - // ----- Error log |
|
| 1630 | - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 1628 | + if (@fseek($this->_zip_fd, $v_central_dir['offset'])) { |
|
| 1629 | + // ----- Error log |
|
| 1630 | + $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 1631 | 1631 | |
| 1632 | - // ----- Return |
|
| 1633 | - return Archive_Zip::errorCode(); |
|
| 1634 | - } |
|
| 1632 | + // ----- Return |
|
| 1633 | + return Archive_Zip::errorCode(); |
|
| 1634 | + } |
|
| 1635 | 1635 | |
| 1636 | 1636 | // ----- Read each entry |
| 1637 | 1637 | for ($i=0; $i<$v_central_dir['entries']; $i++) { |
| 1638 | 1638 | // ----- Read the file header |
| 1639 | - if (($v_result = $this->_readCentralFileHeader($v_header)) != 1) { |
|
| 1640 | - return $v_result; |
|
| 1641 | - } |
|
| 1639 | + if (($v_result = $this->_readCentralFileHeader($v_header)) != 1) { |
|
| 1640 | + return $v_result; |
|
| 1641 | + } |
|
| 1642 | 1642 | $v_header['index'] = $i; |
| 1643 | 1643 | |
| 1644 | - // ----- Get the only interesting attributes |
|
| 1645 | - $this->_convertHeader2FileInfo($v_header, $p_list[$i]); |
|
| 1644 | + // ----- Get the only interesting attributes |
|
| 1645 | + $this->_convertHeader2FileInfo($v_header, $p_list[$i]); |
|
| 1646 | 1646 | unset($v_header); |
| 1647 | 1647 | } |
| 1648 | 1648 | |
@@ -1651,82 +1651,82 @@ discard block |
||
| 1651 | 1651 | |
| 1652 | 1652 | // ----- Return |
| 1653 | 1653 | return $v_result; |
| 1654 | - } |
|
| 1655 | - // --------------------------------------------------------------------------- |
|
| 1656 | - |
|
| 1657 | - // --------------------------------------------------------------------------- |
|
| 1658 | - // Function : _convertHeader2FileInfo() |
|
| 1659 | - // Description : |
|
| 1660 | - // This function takes the file informations from the central directory |
|
| 1661 | - // entries and extract the interesting parameters that will be given back. |
|
| 1662 | - // The resulting file infos are set in the array $p_info |
|
| 1663 | - // $p_info['filename'] : Filename with full path. Given by user (add), |
|
| 1664 | - // extracted in the filesystem (extract). |
|
| 1665 | - // $p_info['stored_filename'] : Stored filename in the archive. |
|
| 1666 | - // $p_info['size'] = Size of the file. |
|
| 1667 | - // $p_info['compressed_size'] = Compressed size of the file. |
|
| 1668 | - // $p_info['mtime'] = Last modification date of the file. |
|
| 1669 | - // $p_info['comment'] = Comment associated with the file. |
|
| 1670 | - // $p_info['folder'] = true/false : indicates if the entry is a folder or not. |
|
| 1671 | - // $p_info['status'] = status of the action on the file. |
|
| 1672 | - // Parameters : |
|
| 1673 | - // Return Values : |
|
| 1674 | - // --------------------------------------------------------------------------- |
|
| 1675 | - /** |
|
| 1676 | - * Archive_Zip::_convertHeader2FileInfo() |
|
| 1677 | - * |
|
| 1678 | - * { Description } |
|
| 1679 | - * |
|
| 1680 | - */ |
|
| 1681 | - public function _convertHeader2FileInfo($p_header, &$p_info) |
|
| 1682 | - { |
|
| 1683 | - $v_result=1; |
|
| 1654 | + } |
|
| 1655 | + // --------------------------------------------------------------------------- |
|
| 1656 | + |
|
| 1657 | + // --------------------------------------------------------------------------- |
|
| 1658 | + // Function : _convertHeader2FileInfo() |
|
| 1659 | + // Description : |
|
| 1660 | + // This function takes the file informations from the central directory |
|
| 1661 | + // entries and extract the interesting parameters that will be given back. |
|
| 1662 | + // The resulting file infos are set in the array $p_info |
|
| 1663 | + // $p_info['filename'] : Filename with full path. Given by user (add), |
|
| 1664 | + // extracted in the filesystem (extract). |
|
| 1665 | + // $p_info['stored_filename'] : Stored filename in the archive. |
|
| 1666 | + // $p_info['size'] = Size of the file. |
|
| 1667 | + // $p_info['compressed_size'] = Compressed size of the file. |
|
| 1668 | + // $p_info['mtime'] = Last modification date of the file. |
|
| 1669 | + // $p_info['comment'] = Comment associated with the file. |
|
| 1670 | + // $p_info['folder'] = true/false : indicates if the entry is a folder or not. |
|
| 1671 | + // $p_info['status'] = status of the action on the file. |
|
| 1672 | + // Parameters : |
|
| 1673 | + // Return Values : |
|
| 1674 | + // --------------------------------------------------------------------------- |
|
| 1675 | + /** |
|
| 1676 | + * Archive_Zip::_convertHeader2FileInfo() |
|
| 1677 | + * |
|
| 1678 | + * { Description } |
|
| 1679 | + * |
|
| 1680 | + */ |
|
| 1681 | + public function _convertHeader2FileInfo($p_header, &$p_info) |
|
| 1682 | + { |
|
| 1683 | + $v_result=1; |
|
| 1684 | 1684 | |
| 1685 | 1685 | // ----- Get the interesting attributes |
| 1686 | 1686 | $p_info['filename'] = $p_header['filename']; |
| 1687 | - $p_info['stored_filename'] = $p_header['stored_filename']; |
|
| 1688 | - $p_info['size'] = $p_header['size']; |
|
| 1689 | - $p_info['compressed_size'] = $p_header['compressed_size']; |
|
| 1690 | - $p_info['mtime'] = $p_header['mtime']; |
|
| 1691 | - $p_info['comment'] = $p_header['comment']; |
|
| 1692 | - $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); |
|
| 1693 | - $p_info['index'] = $p_header['index']; |
|
| 1694 | - $p_info['status'] = $p_header['status']; |
|
| 1687 | + $p_info['stored_filename'] = $p_header['stored_filename']; |
|
| 1688 | + $p_info['size'] = $p_header['size']; |
|
| 1689 | + $p_info['compressed_size'] = $p_header['compressed_size']; |
|
| 1690 | + $p_info['mtime'] = $p_header['mtime']; |
|
| 1691 | + $p_info['comment'] = $p_header['comment']; |
|
| 1692 | + $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); |
|
| 1693 | + $p_info['index'] = $p_header['index']; |
|
| 1694 | + $p_info['status'] = $p_header['status']; |
|
| 1695 | 1695 | |
| 1696 | 1696 | // ----- Return |
| 1697 | 1697 | return $v_result; |
| 1698 | - } |
|
| 1699 | - // --------------------------------------------------------------------------- |
|
| 1700 | - |
|
| 1701 | - // --------------------------------------------------------------------------- |
|
| 1702 | - // Function : _extractByRule() |
|
| 1703 | - // Description : |
|
| 1704 | - // Extract a file or directory depending of rules (by index, by name, ...) |
|
| 1705 | - // Parameters : |
|
| 1706 | - // $p_file_list : An array where will be placed the properties of each |
|
| 1707 | - // extracted file |
|
| 1708 | - // $p_path : Path to add while writing the extracted files |
|
| 1709 | - // $p_remove_path : Path to remove (from the file memorized path) while writing the |
|
| 1710 | - // extracted files. If the path does not match the file path, |
|
| 1711 | - // the file is extracted with its memorized path. |
|
| 1712 | - // $p_remove_path does not apply to 'list' mode. |
|
| 1713 | - // $p_path and $p_remove_path are commulative. |
|
| 1714 | - // Return Values : |
|
| 1715 | - // 1 on success,0 or less on error (see error code list) |
|
| 1716 | - // --------------------------------------------------------------------------- |
|
| 1717 | - /** |
|
| 1718 | - * Archive_Zip::_extractByRule() |
|
| 1719 | - * |
|
| 1720 | - * { Description } |
|
| 1721 | - * |
|
| 1722 | - */ |
|
| 1723 | - public function _extractByRule(&$p_file_list, &$p_params) |
|
| 1724 | - { |
|
| 1725 | - $v_result=1; |
|
| 1726 | - |
|
| 1727 | - $p_path = $p_params['add_path']; |
|
| 1728 | - $p_remove_path = $p_params['remove_path']; |
|
| 1729 | - $p_remove_all_path = $p_params['remove_all_path']; |
|
| 1698 | + } |
|
| 1699 | + // --------------------------------------------------------------------------- |
|
| 1700 | + |
|
| 1701 | + // --------------------------------------------------------------------------- |
|
| 1702 | + // Function : _extractByRule() |
|
| 1703 | + // Description : |
|
| 1704 | + // Extract a file or directory depending of rules (by index, by name, ...) |
|
| 1705 | + // Parameters : |
|
| 1706 | + // $p_file_list : An array where will be placed the properties of each |
|
| 1707 | + // extracted file |
|
| 1708 | + // $p_path : Path to add while writing the extracted files |
|
| 1709 | + // $p_remove_path : Path to remove (from the file memorized path) while writing the |
|
| 1710 | + // extracted files. If the path does not match the file path, |
|
| 1711 | + // the file is extracted with its memorized path. |
|
| 1712 | + // $p_remove_path does not apply to 'list' mode. |
|
| 1713 | + // $p_path and $p_remove_path are commulative. |
|
| 1714 | + // Return Values : |
|
| 1715 | + // 1 on success,0 or less on error (see error code list) |
|
| 1716 | + // --------------------------------------------------------------------------- |
|
| 1717 | + /** |
|
| 1718 | + * Archive_Zip::_extractByRule() |
|
| 1719 | + * |
|
| 1720 | + * { Description } |
|
| 1721 | + * |
|
| 1722 | + */ |
|
| 1723 | + public function _extractByRule(&$p_file_list, &$p_params) |
|
| 1724 | + { |
|
| 1725 | + $v_result=1; |
|
| 1726 | + |
|
| 1727 | + $p_path = $p_params['add_path']; |
|
| 1728 | + $p_remove_path = $p_params['remove_path']; |
|
| 1729 | + $p_remove_all_path = $p_params['remove_all_path']; |
|
| 1730 | 1730 | |
| 1731 | 1731 | // ----- Check the path |
| 1732 | 1732 | if (($p_path == "") |
@@ -1738,16 +1738,16 @@ discard block |
||
| 1738 | 1738 | // ----- Reduce the path last (and duplicated) '/' |
| 1739 | 1739 | if (($p_path != "./") && ($p_path != "/")) { |
| 1740 | 1740 | // ----- Look for the path end '/' |
| 1741 | - while (substr($p_path, -1) == "/") { |
|
| 1742 | - $p_path = substr($p_path, 0, strlen($p_path)-1); |
|
| 1743 | - } |
|
| 1741 | + while (substr($p_path, -1) == "/") { |
|
| 1742 | + $p_path = substr($p_path, 0, strlen($p_path)-1); |
|
| 1743 | + } |
|
| 1744 | 1744 | } |
| 1745 | 1745 | |
| 1746 | 1746 | // ----- Look for path to remove format (should end by /) |
| 1747 | 1747 | if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/')) { |
| 1748 | 1748 | $p_remove_path .= '/'; |
| 1749 | 1749 | } |
| 1750 | - $p_remove_path_size = strlen($p_remove_path); |
|
| 1750 | + $p_remove_path_size = strlen($p_remove_path); |
|
| 1751 | 1751 | |
| 1752 | 1752 | // ----- Open the zip file |
| 1753 | 1753 | if (($v_result = $this->_openFd('rb')) != 1) { |
@@ -1756,202 +1756,202 @@ discard block |
||
| 1756 | 1756 | |
| 1757 | 1757 | // ----- Read the central directory informations |
| 1758 | 1758 | $v_central_dir = array(); |
| 1759 | - if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
| 1760 | - // ----- Close the zip file |
|
| 1761 | - $this->_closeFd(); |
|
| 1759 | + if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
| 1760 | + // ----- Close the zip file |
|
| 1761 | + $this->_closeFd(); |
|
| 1762 | 1762 | |
| 1763 | - return $v_result; |
|
| 1764 | - } |
|
| 1763 | + return $v_result; |
|
| 1764 | + } |
|
| 1765 | 1765 | |
| 1766 | 1766 | // ----- Start at beginning of Central Dir |
| 1767 | 1767 | $v_pos_entry = $v_central_dir['offset']; |
| 1768 | 1768 | |
| 1769 | 1769 | // ----- Read each entry |
| 1770 | 1770 | $j_start = 0; |
| 1771 | - for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) { |
|
| 1772 | - // ----- Read next Central dir entry |
|
| 1773 | - @rewind($this->_zip_fd); |
|
| 1774 | - if (@fseek($this->_zip_fd, $v_pos_entry)) { |
|
| 1775 | - $this->_closeFd(); |
|
| 1771 | + for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) { |
|
| 1772 | + // ----- Read next Central dir entry |
|
| 1773 | + @rewind($this->_zip_fd); |
|
| 1774 | + if (@fseek($this->_zip_fd, $v_pos_entry)) { |
|
| 1775 | + $this->_closeFd(); |
|
| 1776 | 1776 | |
| 1777 | - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, |
|
| 1778 | - 'Invalid archive size'); |
|
| 1777 | + $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, |
|
| 1778 | + 'Invalid archive size'); |
|
| 1779 | 1779 | |
| 1780 | - return Archive_Zip::errorCode(); |
|
| 1781 | - } |
|
| 1780 | + return Archive_Zip::errorCode(); |
|
| 1781 | + } |
|
| 1782 | 1782 | |
| 1783 | - // ----- Read the file header |
|
| 1784 | - $v_header = array(); |
|
| 1785 | - if (($v_result = $this->_readCentralFileHeader($v_header)) != 1) { |
|
| 1786 | - $this->_closeFd(); |
|
| 1783 | + // ----- Read the file header |
|
| 1784 | + $v_header = array(); |
|
| 1785 | + if (($v_result = $this->_readCentralFileHeader($v_header)) != 1) { |
|
| 1786 | + $this->_closeFd(); |
|
| 1787 | 1787 | |
| 1788 | - return $v_result; |
|
| 1789 | - } |
|
| 1788 | + return $v_result; |
|
| 1789 | + } |
|
| 1790 | 1790 | |
| 1791 | - // ----- Store the index |
|
| 1792 | - $v_header['index'] = $i; |
|
| 1791 | + // ----- Store the index |
|
| 1792 | + $v_header['index'] = $i; |
|
| 1793 | 1793 | |
| 1794 | - // ----- Store the file position |
|
| 1795 | - $v_pos_entry = ftell($this->_zip_fd); |
|
| 1794 | + // ----- Store the file position |
|
| 1795 | + $v_pos_entry = ftell($this->_zip_fd); |
|
| 1796 | 1796 | |
| 1797 | - // ----- Look for the specific extract rules |
|
| 1798 | - $v_extract = false; |
|
| 1797 | + // ----- Look for the specific extract rules |
|
| 1798 | + $v_extract = false; |
|
| 1799 | 1799 | |
| 1800 | - // ----- Look for extract by name rule |
|
| 1801 | - if ((isset($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])) |
|
| 1800 | + // ----- Look for extract by name rule |
|
| 1801 | + if ((isset($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])) |
|
| 1802 | 1802 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_NAME] != 0)) { |
| 1803 | 1803 | |
| 1804 | - // ----- Look if the filename is in the list |
|
| 1805 | - for ($j=0; |
|
| 1806 | - ($j<sizeof($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])) |
|
| 1804 | + // ----- Look if the filename is in the list |
|
| 1805 | + for ($j=0; |
|
| 1806 | + ($j<sizeof($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])) |
|
| 1807 | 1807 | && (!$v_extract); |
| 1808 | - $j++) { |
|
| 1808 | + $j++) { |
|
| 1809 | 1809 | |
| 1810 | - // ----- Look for a directory |
|
| 1811 | - if (substr($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j], -1) == "/") { |
|
| 1810 | + // ----- Look for a directory |
|
| 1811 | + if (substr($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j], -1) == "/") { |
|
| 1812 | 1812 | |
| 1813 | - // ----- Look if the directory is in the filename path |
|
| 1814 | - if ((strlen($v_header['stored_filename']) > strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) |
|
| 1813 | + // ----- Look if the directory is in the filename path |
|
| 1814 | + if ((strlen($v_header['stored_filename']) > strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) |
|
| 1815 | 1815 | && (substr($v_header['stored_filename'], 0, strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) { |
| 1816 | - $v_extract = true; |
|
| 1817 | - } |
|
| 1818 | - } |
|
| 1819 | - // ----- Look for a filename |
|
| 1820 | - elseif ($v_header['stored_filename'] == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]) { |
|
| 1821 | - $v_extract = true; |
|
| 1822 | - } |
|
| 1823 | - } |
|
| 1824 | - } |
|
| 1825 | - |
|
| 1826 | - // ----- Look for extract by ereg rule |
|
| 1827 | - elseif ((isset($p_params[ARCHIVE_ZIP_PARAM_BY_EREG])) |
|
| 1816 | + $v_extract = true; |
|
| 1817 | + } |
|
| 1818 | + } |
|
| 1819 | + // ----- Look for a filename |
|
| 1820 | + elseif ($v_header['stored_filename'] == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]) { |
|
| 1821 | + $v_extract = true; |
|
| 1822 | + } |
|
| 1823 | + } |
|
| 1824 | + } |
|
| 1825 | + |
|
| 1826 | + // ----- Look for extract by ereg rule |
|
| 1827 | + elseif ((isset($p_params[ARCHIVE_ZIP_PARAM_BY_EREG])) |
|
| 1828 | 1828 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_EREG] != "")) { |
| 1829 | - if (ereg($p_params[ARCHIVE_ZIP_PARAM_BY_EREG], $v_header['stored_filename'])) { |
|
| 1830 | - $v_extract = true; |
|
| 1831 | - } |
|
| 1832 | - } |
|
| 1829 | + if (ereg($p_params[ARCHIVE_ZIP_PARAM_BY_EREG], $v_header['stored_filename'])) { |
|
| 1830 | + $v_extract = true; |
|
| 1831 | + } |
|
| 1832 | + } |
|
| 1833 | 1833 | |
| 1834 | - // ----- Look for extract by preg rule |
|
| 1835 | - elseif ((isset($p_params[ARCHIVE_ZIP_PARAM_BY_PREG])) |
|
| 1834 | + // ----- Look for extract by preg rule |
|
| 1835 | + elseif ((isset($p_params[ARCHIVE_ZIP_PARAM_BY_PREG])) |
|
| 1836 | 1836 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_PREG] != "")) { |
| 1837 | - if (preg_match($p_params[ARCHIVE_ZIP_PARAM_BY_PREG], $v_header['stored_filename'])) { |
|
| 1838 | - $v_extract = true; |
|
| 1839 | - } |
|
| 1840 | - } |
|
| 1837 | + if (preg_match($p_params[ARCHIVE_ZIP_PARAM_BY_PREG], $v_header['stored_filename'])) { |
|
| 1838 | + $v_extract = true; |
|
| 1839 | + } |
|
| 1840 | + } |
|
| 1841 | 1841 | |
| 1842 | - // ----- Look for extract by index rule |
|
| 1843 | - elseif ((isset($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) |
|
| 1842 | + // ----- Look for extract by index rule |
|
| 1843 | + elseif ((isset($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) |
|
| 1844 | 1844 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX] != 0)) { |
| 1845 | 1845 | |
| 1846 | - // ----- Look if the index is in the list |
|
| 1847 | - for ($j=$j_start; ($j<sizeof($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) && (!$v_extract); $j++) { |
|
| 1848 | - if (($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']) && ($i<=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) { |
|
| 1849 | - $v_extract = true; |
|
| 1850 | - } |
|
| 1851 | - if ($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) { |
|
| 1852 | - $j_start = $j+1; |
|
| 1853 | - } |
|
| 1854 | - |
|
| 1855 | - if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']>$i) { |
|
| 1856 | - break; |
|
| 1857 | - } |
|
| 1858 | - } |
|
| 1859 | - } |
|
| 1846 | + // ----- Look if the index is in the list |
|
| 1847 | + for ($j=$j_start; ($j<sizeof($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) && (!$v_extract); $j++) { |
|
| 1848 | + if (($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']) && ($i<=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) { |
|
| 1849 | + $v_extract = true; |
|
| 1850 | + } |
|
| 1851 | + if ($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) { |
|
| 1852 | + $j_start = $j+1; |
|
| 1853 | + } |
|
| 1854 | + |
|
| 1855 | + if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']>$i) { |
|
| 1856 | + break; |
|
| 1857 | + } |
|
| 1858 | + } |
|
| 1859 | + } |
|
| 1860 | 1860 | |
| 1861 | - // ----- Look for no rule, which means extract all the archive |
|
| 1862 | - else { |
|
| 1863 | - $v_extract = true; |
|
| 1864 | - } |
|
| 1861 | + // ----- Look for no rule, which means extract all the archive |
|
| 1862 | + else { |
|
| 1863 | + $v_extract = true; |
|
| 1864 | + } |
|
| 1865 | 1865 | |
| 1866 | 1866 | |
| 1867 | - // ----- Look for real extraction |
|
| 1868 | - if ($v_extract) { |
|
| 1867 | + // ----- Look for real extraction |
|
| 1868 | + if ($v_extract) { |
|
| 1869 | 1869 | |
| 1870 | 1870 | // ----- Go to the file position |
| 1871 | 1871 | @rewind($this->_zip_fd); |
| 1872 | - if (@fseek($this->_zip_fd, $v_header['offset'])) { |
|
| 1873 | - // ----- Close the zip file |
|
| 1874 | - $this->_closeFd(); |
|
| 1872 | + if (@fseek($this->_zip_fd, $v_header['offset'])) { |
|
| 1873 | + // ----- Close the zip file |
|
| 1874 | + $this->_closeFd(); |
|
| 1875 | 1875 | |
| 1876 | - // ----- Error log |
|
| 1877 | - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 1876 | + // ----- Error log |
|
| 1877 | + $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size'); |
|
| 1878 | 1878 | |
| 1879 | - // ----- Return |
|
| 1880 | - return Archive_Zip::errorCode(); |
|
| 1881 | - } |
|
| 1879 | + // ----- Return |
|
| 1880 | + return Archive_Zip::errorCode(); |
|
| 1881 | + } |
|
| 1882 | 1882 | |
| 1883 | 1883 | // ----- Look for extraction as string |
| 1884 | 1884 | if ($p_params[ARCHIVE_ZIP_PARAM_EXTRACT_AS_STRING]) { |
| 1885 | 1885 | |
| 1886 | - // ----- Extracting the file |
|
| 1887 | - if (($v_result = $this->_extractFileAsString($v_header, $v_string)) != 1) { |
|
| 1888 | - // ----- Close the zip file |
|
| 1886 | + // ----- Extracting the file |
|
| 1887 | + if (($v_result = $this->_extractFileAsString($v_header, $v_string)) != 1) { |
|
| 1888 | + // ----- Close the zip file |
|
| 1889 | 1889 | $this->_closeFd(); |
| 1890 | 1890 | |
| 1891 | - return $v_result; |
|
| 1892 | - } |
|
| 1891 | + return $v_result; |
|
| 1892 | + } |
|
| 1893 | 1893 | |
| 1894 | - // ----- Get the only interesting attributes |
|
| 1895 | - if (($v_result = $this->_convertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) { |
|
| 1896 | - // ----- Close the zip file |
|
| 1894 | + // ----- Get the only interesting attributes |
|
| 1895 | + if (($v_result = $this->_convertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) { |
|
| 1896 | + // ----- Close the zip file |
|
| 1897 | 1897 | $this->_closeFd(); |
| 1898 | 1898 | |
| 1899 | - return $v_result; |
|
| 1900 | - } |
|
| 1899 | + return $v_result; |
|
| 1900 | + } |
|
| 1901 | 1901 | |
| 1902 | - // ----- Set the file content |
|
| 1903 | - $p_file_list[$v_nb_extracted]['content'] = $v_string; |
|
| 1902 | + // ----- Set the file content |
|
| 1903 | + $p_file_list[$v_nb_extracted]['content'] = $v_string; |
|
| 1904 | 1904 | |
| 1905 | - // ----- Next extracted file |
|
| 1906 | - $v_nb_extracted++; |
|
| 1905 | + // ----- Next extracted file |
|
| 1906 | + $v_nb_extracted++; |
|
| 1907 | 1907 | } else { |
| 1908 | 1908 | // ----- Extracting the file |
| 1909 | - if (($v_result = $this->_extractFile($v_header, $p_path, $p_remove_path, $p_remove_all_path, $p_params)) != 1) { |
|
| 1910 | - // ----- Close the zip file |
|
| 1909 | + if (($v_result = $this->_extractFile($v_header, $p_path, $p_remove_path, $p_remove_all_path, $p_params)) != 1) { |
|
| 1910 | + // ----- Close the zip file |
|
| 1911 | 1911 | $this->_closeFd(); |
| 1912 | 1912 | |
| 1913 | - return $v_result; |
|
| 1914 | - } |
|
| 1913 | + return $v_result; |
|
| 1914 | + } |
|
| 1915 | 1915 | |
| 1916 | - // ----- Get the only interesting attributes |
|
| 1917 | - if (($v_result = $this->_convertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) { |
|
| 1918 | - // ----- Close the zip file |
|
| 1916 | + // ----- Get the only interesting attributes |
|
| 1917 | + if (($v_result = $this->_convertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) { |
|
| 1918 | + // ----- Close the zip file |
|
| 1919 | 1919 | $this->_closeFd(); |
| 1920 | 1920 | |
| 1921 | - return $v_result; |
|
| 1922 | - } |
|
| 1921 | + return $v_result; |
|
| 1922 | + } |
|
| 1923 | + } |
|
| 1924 | + } |
|
| 1923 | 1925 | } |
| 1924 | - } |
|
| 1925 | - } |
|
| 1926 | 1926 | |
| 1927 | 1927 | // ----- Close the zip file |
| 1928 | 1928 | $this->_closeFd(); |
| 1929 | 1929 | |
| 1930 | 1930 | // ----- Return |
| 1931 | 1931 | return $v_result; |
| 1932 | - } |
|
| 1933 | - // --------------------------------------------------------------------------- |
|
| 1934 | - |
|
| 1935 | - // --------------------------------------------------------------------------- |
|
| 1936 | - // Function : _extractFile() |
|
| 1937 | - // Description : |
|
| 1938 | - // Parameters : |
|
| 1939 | - // Return Values : |
|
| 1940 | - // --------------------------------------------------------------------------- |
|
| 1941 | - /** |
|
| 1942 | - * Archive_Zip::_extractFile() |
|
| 1943 | - * |
|
| 1944 | - * { Description } |
|
| 1945 | - * |
|
| 1946 | - */ |
|
| 1947 | - public function _extractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_params) |
|
| 1948 | - { |
|
| 1949 | - $v_result=1; |
|
| 1932 | + } |
|
| 1933 | + // --------------------------------------------------------------------------- |
|
| 1934 | + |
|
| 1935 | + // --------------------------------------------------------------------------- |
|
| 1936 | + // Function : _extractFile() |
|
| 1937 | + // Description : |
|
| 1938 | + // Parameters : |
|
| 1939 | + // Return Values : |
|
| 1940 | + // --------------------------------------------------------------------------- |
|
| 1941 | + /** |
|
| 1942 | + * Archive_Zip::_extractFile() |
|
| 1943 | + * |
|
| 1944 | + * { Description } |
|
| 1945 | + * |
|
| 1946 | + */ |
|
| 1947 | + public function _extractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_params) |
|
| 1948 | + { |
|
| 1949 | + $v_result=1; |
|
| 1950 | 1950 | |
| 1951 | 1951 | // ----- Read the file header |
| 1952 | 1952 | if (($v_result = $this->_readFileHeader($v_header)) != 1) { |
| 1953 | 1953 | // ----- Return |
| 1954 | - return $v_result; |
|
| 1954 | + return $v_result; |
|
| 1955 | 1955 | } |
| 1956 | 1956 | |
| 1957 | 1957 | |
@@ -1967,14 +1967,14 @@ discard block |
||
| 1967 | 1967 | // ----- Look for path to remove |
| 1968 | 1968 | elseif ($p_remove_path != "") { |
| 1969 | 1969 | //if (strcmp($p_remove_path, $p_entry['filename'])==0) |
| 1970 | - if ($this->_tool_PathInclusion($p_remove_path, $p_entry['filename']) == 2) { |
|
| 1970 | + if ($this->_tool_PathInclusion($p_remove_path, $p_entry['filename']) == 2) { |
|
| 1971 | 1971 | |
| 1972 | 1972 | // ----- Change the file status |
| 1973 | 1973 | $p_entry['status'] = "filtered"; |
| 1974 | 1974 | |
| 1975 | 1975 | // ----- Return |
| 1976 | 1976 | return $v_result; |
| 1977 | - } |
|
| 1977 | + } |
|
| 1978 | 1978 | |
| 1979 | 1979 | $p_remove_path_size = strlen($p_remove_path); |
| 1980 | 1980 | if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) { |
@@ -1993,23 +1993,23 @@ discard block |
||
| 1993 | 1993 | if ((isset($p_params[ARCHIVE_ZIP_PARAM_PRE_EXTRACT])) |
| 1994 | 1994 | && ($p_params[ARCHIVE_ZIP_PARAM_PRE_EXTRACT] != '')) { |
| 1995 | 1995 | |
| 1996 | - // ----- Generate a local information |
|
| 1997 | - $v_local_header = array(); |
|
| 1996 | + // ----- Generate a local information |
|
| 1997 | + $v_local_header = array(); |
|
| 1998 | 1998 | $this->_convertHeader2FileInfo($p_entry, $v_local_header); |
| 1999 | 1999 | |
| 2000 | - // ----- Call the callback |
|
| 2001 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 2002 | - // header. |
|
| 2003 | - eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_PRE_EXTRACT].'(ARCHIVE_ZIP_PARAM_PRE_EXTRACT, $v_local_header);'); |
|
| 2000 | + // ----- Call the callback |
|
| 2001 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 2002 | + // header. |
|
| 2003 | + eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_PRE_EXTRACT].'(ARCHIVE_ZIP_PARAM_PRE_EXTRACT, $v_local_header);'); |
|
| 2004 | 2004 | if ($v_result == 0) { |
| 2005 | 2005 | // ----- Change the file status |
| 2006 | 2006 | $p_entry['status'] = "skipped"; |
| 2007 | 2007 | $v_result = 1; |
| 2008 | 2008 | } |
| 2009 | 2009 | |
| 2010 | - // ----- Update the informations |
|
| 2011 | - // Only some fields can be modified |
|
| 2012 | - $p_entry['filename'] = $v_local_header['filename']; |
|
| 2010 | + // ----- Update the informations |
|
| 2011 | + // Only some fields can be modified |
|
| 2012 | + $p_entry['filename'] = $v_local_header['filename']; |
|
| 2013 | 2013 | } |
| 2014 | 2014 | |
| 2015 | 2015 | // ----- Trace |
@@ -2020,34 +2020,34 @@ discard block |
||
| 2020 | 2020 | // ----- Look for specific actions while the file exist |
| 2021 | 2021 | if (file_exists($p_entry['filename'])) { |
| 2022 | 2022 | |
| 2023 | - // ----- Look if file is a directory |
|
| 2024 | - if (is_dir($p_entry['filename'])) { |
|
| 2023 | + // ----- Look if file is a directory |
|
| 2024 | + if (is_dir($p_entry['filename'])) { |
|
| 2025 | 2025 | |
| 2026 | 2026 | // ----- Change the file status |
| 2027 | 2027 | $p_entry['status'] = "already_a_directory"; |
| 2028 | 2028 | |
| 2029 | 2029 | // ----- Return |
| 2030 | 2030 | //return $v_result; |
| 2031 | - } |
|
| 2032 | - // ----- Look if file is write protected |
|
| 2033 | - elseif (!is_writeable($p_entry['filename'])) { |
|
| 2031 | + } |
|
| 2032 | + // ----- Look if file is write protected |
|
| 2033 | + elseif (!is_writeable($p_entry['filename'])) { |
|
| 2034 | 2034 | |
| 2035 | 2035 | // ----- Change the file status |
| 2036 | 2036 | $p_entry['status'] = "write_protected"; |
| 2037 | 2037 | |
| 2038 | 2038 | // ----- Return |
| 2039 | 2039 | //return $v_result; |
| 2040 | - } |
|
| 2040 | + } |
|
| 2041 | 2041 | |
| 2042 | - // ----- Look if the extracted file is older |
|
| 2043 | - elseif (filemtime($p_entry['filename']) > $p_entry['mtime']) { |
|
| 2042 | + // ----- Look if the extracted file is older |
|
| 2043 | + elseif (filemtime($p_entry['filename']) > $p_entry['mtime']) { |
|
| 2044 | 2044 | |
| 2045 | 2045 | // ----- Change the file status |
| 2046 | 2046 | $p_entry['status'] = "newer_exist"; |
| 2047 | 2047 | |
| 2048 | 2048 | // ----- Return |
| 2049 | 2049 | //return $v_result; |
| 2050 | - } |
|
| 2050 | + } |
|
| 2051 | 2051 | } |
| 2052 | 2052 | |
| 2053 | 2053 | // ----- Check the directory availability and create it if necessary |
@@ -2075,25 +2075,25 @@ discard block |
||
| 2075 | 2075 | // ----- Look if extraction should be done |
| 2076 | 2076 | if ($p_entry['status'] == 'ok') { |
| 2077 | 2077 | |
| 2078 | - // ----- Do the extraction (if not a folder) |
|
| 2079 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
|
| 2078 | + // ----- Do the extraction (if not a folder) |
|
| 2079 | + if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
|
| 2080 | 2080 | |
| 2081 | 2081 | // ----- Look for not compressed file |
| 2082 | 2082 | if ($p_entry['compressed_size'] == $p_entry['size']) { |
| 2083 | 2083 | |
| 2084 | - // ----- Opening destination file |
|
| 2085 | - if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { |
|
| 2084 | + // ----- Opening destination file |
|
| 2085 | + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { |
|
| 2086 | 2086 | |
| 2087 | 2087 | // ----- Change the file status |
| 2088 | 2088 | $p_entry['status'] = "write_error"; |
| 2089 | 2089 | |
| 2090 | 2090 | // ----- Return |
| 2091 | 2091 | return $v_result; |
| 2092 | - } |
|
| 2092 | + } |
|
| 2093 | 2093 | |
| 2094 | 2094 | |
| 2095 | - // ----- Read the file by ARCHIVE_ZIP_READ_BLOCK_SIZE octets blocks |
|
| 2096 | - $v_size = $p_entry['compressed_size']; |
|
| 2095 | + // ----- Read the file by ARCHIVE_ZIP_READ_BLOCK_SIZE octets blocks |
|
| 2096 | + $v_size = $p_entry['compressed_size']; |
|
| 2097 | 2097 | while ($v_size != 0) { |
| 2098 | 2098 | $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
| 2099 | 2099 | $v_buffer = fread($this->_zip_fd, $v_read_size); |
@@ -2102,93 +2102,93 @@ discard block |
||
| 2102 | 2102 | $v_size -= $v_read_size; |
| 2103 | 2103 | } |
| 2104 | 2104 | |
| 2105 | - // ----- Closing the destination file |
|
| 2106 | - fclose($v_dest_file); |
|
| 2105 | + // ----- Closing the destination file |
|
| 2106 | + fclose($v_dest_file); |
|
| 2107 | 2107 | |
| 2108 | - // ----- Change the file mtime |
|
| 2109 | - touch($p_entry['filename'], $p_entry['mtime']); |
|
| 2108 | + // ----- Change the file mtime |
|
| 2109 | + touch($p_entry['filename'], $p_entry['mtime']); |
|
| 2110 | 2110 | } else { |
| 2111 | 2111 | // ----- Trace |
| 2112 | 2112 | |
| 2113 | - // ----- Opening destination file |
|
| 2114 | - if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { |
|
| 2113 | + // ----- Opening destination file |
|
| 2114 | + if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) { |
|
| 2115 | 2115 | |
| 2116 | 2116 | // ----- Change the file status |
| 2117 | 2117 | $p_entry['status'] = "write_error"; |
| 2118 | 2118 | |
| 2119 | - return $v_result; |
|
| 2120 | - } |
|
| 2119 | + return $v_result; |
|
| 2120 | + } |
|
| 2121 | 2121 | |
| 2122 | 2122 | |
| 2123 | - // ----- Read the compressed file in a buffer (one shot) |
|
| 2124 | - $v_buffer = @fread($this->_zip_fd, $p_entry['compressed_size']); |
|
| 2123 | + // ----- Read the compressed file in a buffer (one shot) |
|
| 2124 | + $v_buffer = @fread($this->_zip_fd, $p_entry['compressed_size']); |
|
| 2125 | 2125 | |
| 2126 | - // ----- Decompress the file |
|
| 2127 | - $v_file_content = gzinflate($v_buffer); |
|
| 2126 | + // ----- Decompress the file |
|
| 2127 | + $v_file_content = gzinflate($v_buffer); |
|
| 2128 | 2128 | unset($v_buffer); |
| 2129 | 2129 | |
| 2130 | - // ----- Write the uncompressed data |
|
| 2131 | - @fwrite($v_dest_file, $v_file_content, $p_entry['size']); |
|
| 2130 | + // ----- Write the uncompressed data |
|
| 2131 | + @fwrite($v_dest_file, $v_file_content, $p_entry['size']); |
|
| 2132 | 2132 | unset($v_file_content); |
| 2133 | 2133 | |
| 2134 | - // ----- Closing the destination file |
|
| 2135 | - @fclose($v_dest_file); |
|
| 2134 | + // ----- Closing the destination file |
|
| 2135 | + @fclose($v_dest_file); |
|
| 2136 | 2136 | |
| 2137 | - // ----- Change the file mtime |
|
| 2138 | - touch($p_entry['filename'], $p_entry['mtime']); |
|
| 2137 | + // ----- Change the file mtime |
|
| 2138 | + touch($p_entry['filename'], $p_entry['mtime']); |
|
| 2139 | 2139 | } |
| 2140 | 2140 | |
| 2141 | 2141 | // ----- Look for chmod option |
| 2142 | 2142 | if ((isset($p_params[ARCHIVE_ZIP_PARAM_SET_CHMOD])) |
| 2143 | 2143 | && ($p_params[ARCHIVE_ZIP_PARAM_SET_CHMOD] != 0)) { |
| 2144 | 2144 | |
| 2145 | - // ----- Change the mode of the file |
|
| 2146 | - chmod($p_entry['filename'], $p_params[ARCHIVE_ZIP_PARAM_SET_CHMOD]); |
|
| 2145 | + // ----- Change the mode of the file |
|
| 2146 | + chmod($p_entry['filename'], $p_params[ARCHIVE_ZIP_PARAM_SET_CHMOD]); |
|
| 2147 | + } |
|
| 2147 | 2148 | } |
| 2148 | - } |
|
| 2149 | 2149 | } |
| 2150 | 2150 | |
| 2151 | 2151 | // ----- Look for post-extract callback |
| 2152 | 2152 | if ((isset($p_params[ARCHIVE_ZIP_PARAM_POST_EXTRACT])) |
| 2153 | 2153 | && ($p_params[ARCHIVE_ZIP_PARAM_POST_EXTRACT] != '')) { |
| 2154 | 2154 | |
| 2155 | - // ----- Generate a local information |
|
| 2156 | - $v_local_header = array(); |
|
| 2155 | + // ----- Generate a local information |
|
| 2156 | + $v_local_header = array(); |
|
| 2157 | 2157 | $this->_convertHeader2FileInfo($p_entry, $v_local_header); |
| 2158 | 2158 | |
| 2159 | - // ----- Call the callback |
|
| 2160 | - // Here I do not use call_user_func() because I need to send a reference to the |
|
| 2161 | - // header. |
|
| 2162 | - eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_POST_EXTRACT].'(ARCHIVE_ZIP_PARAM_POST_EXTRACT, $v_local_header);'); |
|
| 2159 | + // ----- Call the callback |
|
| 2160 | + // Here I do not use call_user_func() because I need to send a reference to the |
|
| 2161 | + // header. |
|
| 2162 | + eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_POST_EXTRACT].'(ARCHIVE_ZIP_PARAM_POST_EXTRACT, $v_local_header);'); |
|
| 2163 | 2163 | } |
| 2164 | 2164 | |
| 2165 | 2165 | // ----- Return |
| 2166 | 2166 | return $v_result; |
| 2167 | - } |
|
| 2168 | - // --------------------------------------------------------------------------- |
|
| 2169 | - |
|
| 2170 | - // --------------------------------------------------------------------------- |
|
| 2171 | - // Function : _extractFileAsString() |
|
| 2172 | - // Description : |
|
| 2173 | - // Parameters : |
|
| 2174 | - // Return Values : |
|
| 2175 | - // --------------------------------------------------------------------------- |
|
| 2176 | - /** |
|
| 2177 | - * Archive_Zip::_extractFileAsString() |
|
| 2178 | - * |
|
| 2179 | - * { Description } |
|
| 2180 | - * |
|
| 2181 | - */ |
|
| 2182 | - public function _extractFileAsString(&$p_entry, &$p_string) |
|
| 2183 | - { |
|
| 2184 | - $v_result=1; |
|
| 2167 | + } |
|
| 2168 | + // --------------------------------------------------------------------------- |
|
| 2169 | + |
|
| 2170 | + // --------------------------------------------------------------------------- |
|
| 2171 | + // Function : _extractFileAsString() |
|
| 2172 | + // Description : |
|
| 2173 | + // Parameters : |
|
| 2174 | + // Return Values : |
|
| 2175 | + // --------------------------------------------------------------------------- |
|
| 2176 | + /** |
|
| 2177 | + * Archive_Zip::_extractFileAsString() |
|
| 2178 | + * |
|
| 2179 | + * { Description } |
|
| 2180 | + * |
|
| 2181 | + */ |
|
| 2182 | + public function _extractFileAsString(&$p_entry, &$p_string) |
|
| 2183 | + { |
|
| 2184 | + $v_result=1; |
|
| 2185 | 2185 | |
| 2186 | 2186 | // ----- Read the file header |
| 2187 | 2187 | $v_header = array(); |
| 2188 | - if (($v_result = $this->_readFileHeader($v_header)) != 1) { |
|
| 2189 | - // ----- Return |
|
| 2190 | - return $v_result; |
|
| 2191 | - } |
|
| 2188 | + if (($v_result = $this->_readFileHeader($v_header)) != 1) { |
|
| 2189 | + // ----- Return |
|
| 2190 | + return $v_result; |
|
| 2191 | + } |
|
| 2192 | 2192 | |
| 2193 | 2193 | |
| 2194 | 2194 | // ----- Check that the file header is coherent with $p_entry info |
@@ -2199,59 +2199,59 @@ discard block |
||
| 2199 | 2199 | // ----- Do the extraction (if not a folder) |
| 2200 | 2200 | if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
| 2201 | 2201 | // ----- Look for not compressed file |
| 2202 | - if ($p_entry['compressed_size'] == $p_entry['size']) { |
|
| 2203 | - // ----- Trace |
|
| 2202 | + if ($p_entry['compressed_size'] == $p_entry['size']) { |
|
| 2203 | + // ----- Trace |
|
| 2204 | 2204 | |
| 2205 | 2205 | // ----- Reading the file |
| 2206 | 2206 | $p_string = fread($this->_zip_fd, $p_entry['compressed_size']); |
| 2207 | - } else { |
|
| 2208 | - // ----- Trace |
|
| 2207 | + } else { |
|
| 2208 | + // ----- Trace |
|
| 2209 | 2209 | |
| 2210 | 2210 | // ----- Reading the file |
| 2211 | 2211 | $v_data = fread($this->_zip_fd, $p_entry['compressed_size']); |
| 2212 | 2212 | |
| 2213 | 2213 | // ----- Decompress the file |
| 2214 | 2214 | $p_string = gzinflate($v_data); |
| 2215 | - } |
|
| 2215 | + } |
|
| 2216 | 2216 | |
| 2217 | - // ----- Trace |
|
| 2217 | + // ----- Trace |
|
| 2218 | 2218 | } else { |
| 2219 | 2219 | // TBC : error : can not extract a folder in a string |
| 2220 | 2220 | } |
| 2221 | 2221 | |
| 2222 | 2222 | // ----- Return |
| 2223 | 2223 | return $v_result; |
| 2224 | - } |
|
| 2225 | - // --------------------------------------------------------------------------- |
|
| 2226 | - |
|
| 2227 | - // --------------------------------------------------------------------------- |
|
| 2228 | - // Function : _readFileHeader() |
|
| 2229 | - // Description : |
|
| 2230 | - // Parameters : |
|
| 2231 | - // Return Values : |
|
| 2232 | - // --------------------------------------------------------------------------- |
|
| 2233 | - /** |
|
| 2234 | - * Archive_Zip::_readFileHeader() |
|
| 2235 | - * |
|
| 2236 | - * { Description } |
|
| 2237 | - * |
|
| 2238 | - */ |
|
| 2239 | - public function _readFileHeader(&$p_header) |
|
| 2240 | - { |
|
| 2241 | - $v_result=1; |
|
| 2224 | + } |
|
| 2225 | + // --------------------------------------------------------------------------- |
|
| 2226 | + |
|
| 2227 | + // --------------------------------------------------------------------------- |
|
| 2228 | + // Function : _readFileHeader() |
|
| 2229 | + // Description : |
|
| 2230 | + // Parameters : |
|
| 2231 | + // Return Values : |
|
| 2232 | + // --------------------------------------------------------------------------- |
|
| 2233 | + /** |
|
| 2234 | + * Archive_Zip::_readFileHeader() |
|
| 2235 | + * |
|
| 2236 | + * { Description } |
|
| 2237 | + * |
|
| 2238 | + */ |
|
| 2239 | + public function _readFileHeader(&$p_header) |
|
| 2240 | + { |
|
| 2241 | + $v_result=1; |
|
| 2242 | 2242 | |
| 2243 | 2243 | // ----- Read the 4 bytes signature |
| 2244 | 2244 | $v_binary_data = @fread($this->_zip_fd, 4); |
| 2245 | - $v_data = unpack('Vid', $v_binary_data); |
|
| 2245 | + $v_data = unpack('Vid', $v_binary_data); |
|
| 2246 | 2246 | |
| 2247 | 2247 | // ----- Check signature |
| 2248 | 2248 | if ($v_data['id'] != 0x04034b50) { |
| 2249 | 2249 | |
| 2250 | - // ----- Error log |
|
| 2251 | - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
| 2250 | + // ----- Error log |
|
| 2251 | + $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
| 2252 | 2252 | |
| 2253 | - // ----- Return |
|
| 2254 | - return Archive_Zip::errorCode(); |
|
| 2253 | + // ----- Return |
|
| 2254 | + return Archive_Zip::errorCode(); |
|
| 2255 | 2255 | } |
| 2256 | 2256 | |
| 2257 | 2257 | // ----- Read the first 42 bytes of the header |
@@ -2262,11 +2262,11 @@ discard block |
||
| 2262 | 2262 | $p_header['filename'] = ""; |
| 2263 | 2263 | $p_header['status'] = "invalid_header"; |
| 2264 | 2264 | |
| 2265 | - // ----- Error log |
|
| 2266 | - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); |
|
| 2265 | + // ----- Error log |
|
| 2266 | + $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); |
|
| 2267 | 2267 | |
| 2268 | - // ----- Return |
|
| 2269 | - return Archive_Zip::errorCode(); |
|
| 2268 | + // ----- Return |
|
| 2269 | + return Archive_Zip::errorCode(); |
|
| 2270 | 2270 | } |
| 2271 | 2271 | |
| 2272 | 2272 | // ----- Extract the values |
@@ -2284,30 +2284,30 @@ discard block |
||
| 2284 | 2284 | |
| 2285 | 2285 | // ----- Extract properties |
| 2286 | 2286 | $p_header['compression'] = $v_data['compression']; |
| 2287 | - $p_header['size'] = $v_data['size']; |
|
| 2288 | - $p_header['compressed_size'] = $v_data['compressed_size']; |
|
| 2289 | - $p_header['crc'] = $v_data['crc']; |
|
| 2290 | - $p_header['flag'] = $v_data['flag']; |
|
| 2287 | + $p_header['size'] = $v_data['size']; |
|
| 2288 | + $p_header['compressed_size'] = $v_data['compressed_size']; |
|
| 2289 | + $p_header['crc'] = $v_data['crc']; |
|
| 2290 | + $p_header['flag'] = $v_data['flag']; |
|
| 2291 | 2291 | |
| 2292 | 2292 | // ----- Recuperate date in UNIX format |
| 2293 | 2293 | $p_header['mdate'] = $v_data['mdate']; |
| 2294 | - $p_header['mtime'] = $v_data['mtime']; |
|
| 2295 | - if ($p_header['mdate'] && $p_header['mtime']) { |
|
| 2296 | - // ----- Extract time |
|
| 2297 | - $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
| 2298 | - $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
|
| 2299 | - $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 2300 | - |
|
| 2301 | - // ----- Extract date |
|
| 2302 | - $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
| 2303 | - $v_month = ($p_header['mdate'] & 0x01E0) >> 5; |
|
| 2304 | - $v_day = $p_header['mdate'] & 0x001F; |
|
| 2305 | - |
|
| 2306 | - // ----- Get UNIX date format |
|
| 2307 | - $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
| 2308 | - } else { |
|
| 2309 | - $p_header['mtime'] = time(); |
|
| 2310 | - } |
|
| 2294 | + $p_header['mtime'] = $v_data['mtime']; |
|
| 2295 | + if ($p_header['mdate'] && $p_header['mtime']) { |
|
| 2296 | + // ----- Extract time |
|
| 2297 | + $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
| 2298 | + $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
|
| 2299 | + $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 2300 | + |
|
| 2301 | + // ----- Extract date |
|
| 2302 | + $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
| 2303 | + $v_month = ($p_header['mdate'] & 0x01E0) >> 5; |
|
| 2304 | + $v_day = $p_header['mdate'] & 0x001F; |
|
| 2305 | + |
|
| 2306 | + // ----- Get UNIX date format |
|
| 2307 | + $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
| 2308 | + } else { |
|
| 2309 | + $p_header['mtime'] = time(); |
|
| 2310 | + } |
|
| 2311 | 2311 | |
| 2312 | 2312 | // ----- Other informations |
| 2313 | 2313 | |
@@ -2323,37 +2323,37 @@ discard block |
||
| 2323 | 2323 | |
| 2324 | 2324 | // ----- Return |
| 2325 | 2325 | return $v_result; |
| 2326 | - } |
|
| 2327 | - // --------------------------------------------------------------------------- |
|
| 2328 | - |
|
| 2329 | - // --------------------------------------------------------------------------- |
|
| 2330 | - // Function : _readCentralFileHeader() |
|
| 2331 | - // Description : |
|
| 2332 | - // Parameters : |
|
| 2333 | - // Return Values : |
|
| 2334 | - // --------------------------------------------------------------------------- |
|
| 2335 | - /** |
|
| 2336 | - * Archive_Zip::_readCentralFileHeader() |
|
| 2337 | - * |
|
| 2338 | - * { Description } |
|
| 2339 | - * |
|
| 2340 | - */ |
|
| 2341 | - public function _readCentralFileHeader(&$p_header) |
|
| 2342 | - { |
|
| 2343 | - $v_result=1; |
|
| 2326 | + } |
|
| 2327 | + // --------------------------------------------------------------------------- |
|
| 2328 | + |
|
| 2329 | + // --------------------------------------------------------------------------- |
|
| 2330 | + // Function : _readCentralFileHeader() |
|
| 2331 | + // Description : |
|
| 2332 | + // Parameters : |
|
| 2333 | + // Return Values : |
|
| 2334 | + // --------------------------------------------------------------------------- |
|
| 2335 | + /** |
|
| 2336 | + * Archive_Zip::_readCentralFileHeader() |
|
| 2337 | + * |
|
| 2338 | + * { Description } |
|
| 2339 | + * |
|
| 2340 | + */ |
|
| 2341 | + public function _readCentralFileHeader(&$p_header) |
|
| 2342 | + { |
|
| 2343 | + $v_result=1; |
|
| 2344 | 2344 | |
| 2345 | 2345 | // ----- Read the 4 bytes signature |
| 2346 | 2346 | $v_binary_data = @fread($this->_zip_fd, 4); |
| 2347 | - $v_data = unpack('Vid', $v_binary_data); |
|
| 2347 | + $v_data = unpack('Vid', $v_binary_data); |
|
| 2348 | 2348 | |
| 2349 | 2349 | // ----- Check signature |
| 2350 | 2350 | if ($v_data['id'] != 0x02014b50) { |
| 2351 | 2351 | |
| 2352 | - // ----- Error log |
|
| 2353 | - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
| 2352 | + // ----- Error log |
|
| 2353 | + $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid archive structure'); |
|
| 2354 | 2354 | |
| 2355 | - // ----- Return |
|
| 2356 | - return Archive_Zip::errorCode(); |
|
| 2355 | + // ----- Return |
|
| 2356 | + return Archive_Zip::errorCode(); |
|
| 2357 | 2357 | } |
| 2358 | 2358 | |
| 2359 | 2359 | // ----- Read the first 42 bytes of the header |
@@ -2364,11 +2364,11 @@ discard block |
||
| 2364 | 2364 | $p_header['filename'] = ""; |
| 2365 | 2365 | $p_header['status'] = "invalid_header"; |
| 2366 | 2366 | |
| 2367 | - // ----- Error log |
|
| 2368 | - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); |
|
| 2367 | + // ----- Error log |
|
| 2368 | + $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data)); |
|
| 2369 | 2369 | |
| 2370 | - // ----- Return |
|
| 2371 | - return Archive_Zip::errorCode(); |
|
| 2370 | + // ----- Return |
|
| 2371 | + return Archive_Zip::errorCode(); |
|
| 2372 | 2372 | } |
| 2373 | 2373 | |
| 2374 | 2374 | // ----- Extract the values |
@@ -2400,17 +2400,17 @@ discard block |
||
| 2400 | 2400 | // ----- Recuperate date in UNIX format |
| 2401 | 2401 | if ($p_header['mdate'] && $p_header['mtime']) { |
| 2402 | 2402 | // ----- Extract time |
| 2403 | - $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
| 2403 | + $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
|
| 2404 | 2404 | $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
| 2405 | 2405 | $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
| 2406 | 2406 | |
| 2407 | - // ----- Extract date |
|
| 2408 | - $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
| 2407 | + // ----- Extract date |
|
| 2408 | + $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
|
| 2409 | 2409 | $v_month = ($p_header['mdate'] & 0x01E0) >> 5; |
| 2410 | 2410 | $v_day = $p_header['mdate'] & 0x001F; |
| 2411 | 2411 | |
| 2412 | - // ----- Get UNIX date format |
|
| 2413 | - $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
| 2412 | + // ----- Get UNIX date format |
|
| 2413 | + $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year); |
|
| 2414 | 2414 | } else { |
| 2415 | 2415 | $p_header['mtime'] = time(); |
| 2416 | 2416 | } |
@@ -2429,76 +2429,76 @@ discard block |
||
| 2429 | 2429 | |
| 2430 | 2430 | // ----- Return |
| 2431 | 2431 | return $v_result; |
| 2432 | - } |
|
| 2433 | - // --------------------------------------------------------------------------- |
|
| 2434 | - |
|
| 2435 | - // --------------------------------------------------------------------------- |
|
| 2436 | - // Function : _readEndCentralDir() |
|
| 2437 | - // Description : |
|
| 2438 | - // Parameters : |
|
| 2439 | - // Return Values : |
|
| 2440 | - // --------------------------------------------------------------------------- |
|
| 2441 | - /** |
|
| 2442 | - * Archive_Zip::_readEndCentralDir() |
|
| 2443 | - * |
|
| 2444 | - * { Description } |
|
| 2445 | - * |
|
| 2446 | - */ |
|
| 2447 | - public function _readEndCentralDir(&$p_central_dir) |
|
| 2448 | - { |
|
| 2449 | - $v_result=1; |
|
| 2432 | + } |
|
| 2433 | + // --------------------------------------------------------------------------- |
|
| 2434 | + |
|
| 2435 | + // --------------------------------------------------------------------------- |
|
| 2436 | + // Function : _readEndCentralDir() |
|
| 2437 | + // Description : |
|
| 2438 | + // Parameters : |
|
| 2439 | + // Return Values : |
|
| 2440 | + // --------------------------------------------------------------------------- |
|
| 2441 | + /** |
|
| 2442 | + * Archive_Zip::_readEndCentralDir() |
|
| 2443 | + * |
|
| 2444 | + * { Description } |
|
| 2445 | + * |
|
| 2446 | + */ |
|
| 2447 | + public function _readEndCentralDir(&$p_central_dir) |
|
| 2448 | + { |
|
| 2449 | + $v_result=1; |
|
| 2450 | 2450 | |
| 2451 | 2451 | // ----- Go to the end of the zip file |
| 2452 | 2452 | $v_size = filesize($this->_zipname); |
| 2453 | - @fseek($this->_zip_fd, $v_size); |
|
| 2454 | - if (@ftell($this->_zip_fd) != $v_size) { |
|
| 2455 | - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, |
|
| 2456 | - 'Unable to go to the end of the archive \'' |
|
| 2457 | - .$this->_zipname.'\''); |
|
| 2458 | - return Archive_Zip::errorCode(); |
|
| 2459 | - } |
|
| 2453 | + @fseek($this->_zip_fd, $v_size); |
|
| 2454 | + if (@ftell($this->_zip_fd) != $v_size) { |
|
| 2455 | + $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, |
|
| 2456 | + 'Unable to go to the end of the archive \'' |
|
| 2457 | + .$this->_zipname.'\''); |
|
| 2458 | + return Archive_Zip::errorCode(); |
|
| 2459 | + } |
|
| 2460 | 2460 | |
| 2461 | 2461 | // ----- First try : look if this is an archive with no commentaries |
| 2462 | 2462 | // (most of the time) |
| 2463 | 2463 | // in this case the end of central dir is at 22 bytes of the file end |
| 2464 | 2464 | $v_found = 0; |
| 2465 | - if ($v_size > 26) { |
|
| 2466 | - @fseek($this->_zip_fd, $v_size-22); |
|
| 2467 | - if (($v_pos = @ftell($this->_zip_fd)) != ($v_size-22)) { |
|
| 2468 | - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, |
|
| 2469 | - 'Unable to seek back to the middle of the archive \'' |
|
| 2470 | - .$this->_zipname.'\''); |
|
| 2471 | - return Archive_Zip::errorCode(); |
|
| 2472 | - } |
|
| 2473 | - |
|
| 2474 | - // ----- Read for bytes |
|
| 2475 | - $v_binary_data = @fread($this->_zip_fd, 4); |
|
| 2476 | - $v_data = unpack('Vid', $v_binary_data); |
|
| 2477 | - |
|
| 2478 | - // ----- Check signature |
|
| 2479 | - if ($v_data['id'] == 0x06054b50) { |
|
| 2480 | - $v_found = 1; |
|
| 2481 | - } |
|
| 2482 | - |
|
| 2483 | - $v_pos = ftell($this->_zip_fd); |
|
| 2484 | - } |
|
| 2465 | + if ($v_size > 26) { |
|
| 2466 | + @fseek($this->_zip_fd, $v_size-22); |
|
| 2467 | + if (($v_pos = @ftell($this->_zip_fd)) != ($v_size-22)) { |
|
| 2468 | + $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, |
|
| 2469 | + 'Unable to seek back to the middle of the archive \'' |
|
| 2470 | + .$this->_zipname.'\''); |
|
| 2471 | + return Archive_Zip::errorCode(); |
|
| 2472 | + } |
|
| 2473 | + |
|
| 2474 | + // ----- Read for bytes |
|
| 2475 | + $v_binary_data = @fread($this->_zip_fd, 4); |
|
| 2476 | + $v_data = unpack('Vid', $v_binary_data); |
|
| 2477 | + |
|
| 2478 | + // ----- Check signature |
|
| 2479 | + if ($v_data['id'] == 0x06054b50) { |
|
| 2480 | + $v_found = 1; |
|
| 2481 | + } |
|
| 2482 | + |
|
| 2483 | + $v_pos = ftell($this->_zip_fd); |
|
| 2484 | + } |
|
| 2485 | 2485 | |
| 2486 | 2486 | // ----- Go back to the maximum possible size of the Central Dir End Record |
| 2487 | 2487 | if (!$v_found) { |
| 2488 | 2488 | $v_maximum_size = 65557; // 0xFFFF + 22; |
| 2489 | - if ($v_maximum_size > $v_size) { |
|
| 2490 | - $v_maximum_size = $v_size; |
|
| 2491 | - } |
|
| 2489 | + if ($v_maximum_size > $v_size) { |
|
| 2490 | + $v_maximum_size = $v_size; |
|
| 2491 | + } |
|
| 2492 | 2492 | @fseek($this->_zip_fd, $v_size-$v_maximum_size); |
| 2493 | 2493 | if (@ftell($this->_zip_fd) != ($v_size-$v_maximum_size)) { |
| 2494 | 2494 | $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, |
| 2495 | - 'Unable to seek back to the middle of the archive \'' |
|
| 2496 | - .$this->_zipname.'\''); |
|
| 2495 | + 'Unable to seek back to the middle of the archive \'' |
|
| 2496 | + .$this->_zipname.'\''); |
|
| 2497 | 2497 | return Archive_Zip::errorCode(); |
| 2498 | 2498 | } |
| 2499 | 2499 | |
| 2500 | - // ----- Read byte per byte in order to find the signature |
|
| 2501 | - $v_pos = ftell($this->_zip_fd); |
|
| 2500 | + // ----- Read byte per byte in order to find the signature |
|
| 2501 | + $v_pos = ftell($this->_zip_fd); |
|
| 2502 | 2502 | $v_bytes = 0x00000000; |
| 2503 | 2503 | while ($v_pos < $v_size) { |
| 2504 | 2504 | // ----- Read a byte |
@@ -2516,12 +2516,12 @@ discard block |
||
| 2516 | 2516 | $v_pos++; |
| 2517 | 2517 | } |
| 2518 | 2518 | |
| 2519 | - // ----- Look if not found end of central dir |
|
| 2520 | - if ($v_pos == $v_size) { |
|
| 2521 | - $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, |
|
| 2522 | - "Unable to find End of Central Dir Record signature"); |
|
| 2523 | - return Archive_Zip::errorCode(); |
|
| 2524 | - } |
|
| 2519 | + // ----- Look if not found end of central dir |
|
| 2520 | + if ($v_pos == $v_size) { |
|
| 2521 | + $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, |
|
| 2522 | + "Unable to find End of Central Dir Record signature"); |
|
| 2523 | + return Archive_Zip::errorCode(); |
|
| 2524 | + } |
|
| 2525 | 2525 | } |
| 2526 | 2526 | |
| 2527 | 2527 | // ----- Read the first 18 bytes of the header |
@@ -2530,8 +2530,8 @@ discard block |
||
| 2530 | 2530 | // ----- Look for invalid block size |
| 2531 | 2531 | if (strlen($v_binary_data) != 18) { |
| 2532 | 2532 | $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, |
| 2533 | - "Invalid End of Central Dir Record size : " |
|
| 2534 | - .strlen($v_binary_data)); |
|
| 2533 | + "Invalid End of Central Dir Record size : " |
|
| 2534 | + .strlen($v_binary_data)); |
|
| 2535 | 2535 | return Archive_Zip::errorCode(); |
| 2536 | 2536 | } |
| 2537 | 2537 | |
@@ -2541,7 +2541,7 @@ discard block |
||
| 2541 | 2541 | // ----- Check the global size |
| 2542 | 2542 | if (($v_pos + $v_data['comment_size'] + 18) != $v_size) { |
| 2543 | 2543 | $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, |
| 2544 | - "Fail to find the right signature"); |
|
| 2544 | + "Fail to find the right signature"); |
|
| 2545 | 2545 | return Archive_Zip::errorCode(); |
| 2546 | 2546 | } |
| 2547 | 2547 | |
@@ -2552,47 +2552,47 @@ discard block |
||
| 2552 | 2552 | $p_central_dir['comment'] = ''; |
| 2553 | 2553 | } |
| 2554 | 2554 | |
| 2555 | - $p_central_dir['entries'] = $v_data['entries']; |
|
| 2556 | - $p_central_dir['disk_entries'] = $v_data['disk_entries']; |
|
| 2557 | - $p_central_dir['offset'] = $v_data['offset']; |
|
| 2558 | - $p_central_dir['size'] = $v_data['size']; |
|
| 2559 | - $p_central_dir['disk'] = $v_data['disk']; |
|
| 2560 | - $p_central_dir['disk_start'] = $v_data['disk_start']; |
|
| 2555 | + $p_central_dir['entries'] = $v_data['entries']; |
|
| 2556 | + $p_central_dir['disk_entries'] = $v_data['disk_entries']; |
|
| 2557 | + $p_central_dir['offset'] = $v_data['offset']; |
|
| 2558 | + $p_central_dir['size'] = $v_data['size']; |
|
| 2559 | + $p_central_dir['disk'] = $v_data['disk']; |
|
| 2560 | + $p_central_dir['disk_start'] = $v_data['disk_start']; |
|
| 2561 | 2561 | |
| 2562 | 2562 | // ----- Return |
| 2563 | 2563 | return $v_result; |
| 2564 | - } |
|
| 2565 | - // --------------------------------------------------------------------------- |
|
| 2566 | - |
|
| 2567 | - // --------------------------------------------------------------------------- |
|
| 2568 | - // Function : _deleteByRule() |
|
| 2569 | - // Description : |
|
| 2570 | - // Parameters : |
|
| 2571 | - // Return Values : |
|
| 2572 | - // --------------------------------------------------------------------------- |
|
| 2573 | - /** |
|
| 2574 | - * Archive_Zip::_deleteByRule() |
|
| 2575 | - * |
|
| 2576 | - * { Description } |
|
| 2577 | - * |
|
| 2578 | - */ |
|
| 2579 | - public function _deleteByRule(&$p_result_list, &$p_params) |
|
| 2580 | - { |
|
| 2581 | - $v_result=1; |
|
| 2582 | - $v_list_detail = array(); |
|
| 2564 | + } |
|
| 2565 | + // --------------------------------------------------------------------------- |
|
| 2566 | + |
|
| 2567 | + // --------------------------------------------------------------------------- |
|
| 2568 | + // Function : _deleteByRule() |
|
| 2569 | + // Description : |
|
| 2570 | + // Parameters : |
|
| 2571 | + // Return Values : |
|
| 2572 | + // --------------------------------------------------------------------------- |
|
| 2573 | + /** |
|
| 2574 | + * Archive_Zip::_deleteByRule() |
|
| 2575 | + * |
|
| 2576 | + * { Description } |
|
| 2577 | + * |
|
| 2578 | + */ |
|
| 2579 | + public function _deleteByRule(&$p_result_list, &$p_params) |
|
| 2580 | + { |
|
| 2581 | + $v_result=1; |
|
| 2582 | + $v_list_detail = array(); |
|
| 2583 | 2583 | |
| 2584 | 2584 | // ----- Open the zip file |
| 2585 | 2585 | if (($v_result=$this->_openFd('rb')) != 1) { |
| 2586 | 2586 | // ----- Return |
| 2587 | - return $v_result; |
|
| 2587 | + return $v_result; |
|
| 2588 | 2588 | } |
| 2589 | 2589 | |
| 2590 | 2590 | // ----- Read the central directory informations |
| 2591 | 2591 | $v_central_dir = array(); |
| 2592 | - if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
| 2593 | - $this->_closeFd(); |
|
| 2594 | - return $v_result; |
|
| 2595 | - } |
|
| 2592 | + if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
| 2593 | + $this->_closeFd(); |
|
| 2594 | + return $v_result; |
|
| 2595 | + } |
|
| 2596 | 2596 | |
| 2597 | 2597 | // ----- Go to beginning of File |
| 2598 | 2598 | @rewind($this->_zip_fd); |
@@ -2600,123 +2600,123 @@ discard block |
||
| 2600 | 2600 | // ----- Scan all the files |
| 2601 | 2601 | // ----- Start at beginning of Central Dir |
| 2602 | 2602 | $v_pos_entry = $v_central_dir['offset']; |
| 2603 | - @rewind($this->_zip_fd); |
|
| 2604 | - if (@fseek($this->_zip_fd, $v_pos_entry)) { |
|
| 2605 | - // ----- Clean |
|
| 2606 | - $this->_closeFd(); |
|
| 2603 | + @rewind($this->_zip_fd); |
|
| 2604 | + if (@fseek($this->_zip_fd, $v_pos_entry)) { |
|
| 2605 | + // ----- Clean |
|
| 2606 | + $this->_closeFd(); |
|
| 2607 | 2607 | |
| 2608 | - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, |
|
| 2609 | - 'Invalid archive size'); |
|
| 2610 | - return Archive_Zip::errorCode(); |
|
| 2611 | - } |
|
| 2608 | + $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, |
|
| 2609 | + 'Invalid archive size'); |
|
| 2610 | + return Archive_Zip::errorCode(); |
|
| 2611 | + } |
|
| 2612 | 2612 | |
| 2613 | 2613 | // ----- Read each entry |
| 2614 | 2614 | $v_header_list = array(); |
| 2615 | - $j_start = 0; |
|
| 2616 | - for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) { |
|
| 2615 | + $j_start = 0; |
|
| 2616 | + for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) { |
|
| 2617 | 2617 | |
| 2618 | - // ----- Read the file header |
|
| 2619 | - $v_header_list[$v_nb_extracted] = array(); |
|
| 2620 | - $v_result |
|
| 2618 | + // ----- Read the file header |
|
| 2619 | + $v_header_list[$v_nb_extracted] = array(); |
|
| 2620 | + $v_result |
|
| 2621 | 2621 | = $this->_readCentralFileHeader($v_header_list[$v_nb_extracted]); |
| 2622 | - if ($v_result != 1) { |
|
| 2623 | - // ----- Clean |
|
| 2622 | + if ($v_result != 1) { |
|
| 2623 | + // ----- Clean |
|
| 2624 | 2624 | $this->_closeFd(); |
| 2625 | 2625 | |
| 2626 | - return $v_result; |
|
| 2627 | - } |
|
| 2626 | + return $v_result; |
|
| 2627 | + } |
|
| 2628 | 2628 | |
| 2629 | - // ----- Store the index |
|
| 2630 | - $v_header_list[$v_nb_extracted]['index'] = $i; |
|
| 2629 | + // ----- Store the index |
|
| 2630 | + $v_header_list[$v_nb_extracted]['index'] = $i; |
|
| 2631 | 2631 | |
| 2632 | - // ----- Look for the specific extract rules |
|
| 2633 | - $v_found = false; |
|
| 2632 | + // ----- Look for the specific extract rules |
|
| 2633 | + $v_found = false; |
|
| 2634 | 2634 | |
| 2635 | - // ----- Look for extract by name rule |
|
| 2636 | - if ((isset($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])) |
|
| 2635 | + // ----- Look for extract by name rule |
|
| 2636 | + if ((isset($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])) |
|
| 2637 | 2637 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_NAME] != 0)) { |
| 2638 | 2638 | |
| 2639 | - // ----- Look if the filename is in the list |
|
| 2640 | - for ($j=0; |
|
| 2641 | - ($j<sizeof($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])) |
|
| 2639 | + // ----- Look if the filename is in the list |
|
| 2640 | + for ($j=0; |
|
| 2641 | + ($j<sizeof($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])) |
|
| 2642 | 2642 | && (!$v_found); |
| 2643 | - $j++) { |
|
| 2643 | + $j++) { |
|
| 2644 | 2644 | |
| 2645 | - // ----- Look for a directory |
|
| 2646 | - if (substr($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j], -1) == "/") { |
|
| 2645 | + // ----- Look for a directory |
|
| 2646 | + if (substr($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j], -1) == "/") { |
|
| 2647 | 2647 | |
| 2648 | - // ----- Look if the directory is in the filename path |
|
| 2649 | - if ((strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) |
|
| 2648 | + // ----- Look if the directory is in the filename path |
|
| 2649 | + if ((strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) |
|
| 2650 | 2650 | && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) { |
| 2651 | - $v_found = true; |
|
| 2652 | - } elseif ((($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
| 2651 | + $v_found = true; |
|
| 2652 | + } elseif ((($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
| 2653 | 2653 | && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) { |
| 2654 | - $v_found = true; |
|
| 2655 | - } |
|
| 2656 | - } |
|
| 2657 | - // ----- Look for a filename |
|
| 2658 | - elseif ($v_header_list[$v_nb_extracted]['stored_filename'] |
|
| 2659 | - == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]) { |
|
| 2660 | - $v_found = true; |
|
| 2661 | - } |
|
| 2662 | - } |
|
| 2663 | - } |
|
| 2664 | - |
|
| 2665 | - // ----- Look for extract by ereg rule |
|
| 2666 | - elseif ((isset($p_params[ARCHIVE_ZIP_PARAM_BY_EREG])) |
|
| 2654 | + $v_found = true; |
|
| 2655 | + } |
|
| 2656 | + } |
|
| 2657 | + // ----- Look for a filename |
|
| 2658 | + elseif ($v_header_list[$v_nb_extracted]['stored_filename'] |
|
| 2659 | + == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]) { |
|
| 2660 | + $v_found = true; |
|
| 2661 | + } |
|
| 2662 | + } |
|
| 2663 | + } |
|
| 2664 | + |
|
| 2665 | + // ----- Look for extract by ereg rule |
|
| 2666 | + elseif ((isset($p_params[ARCHIVE_ZIP_PARAM_BY_EREG])) |
|
| 2667 | 2667 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_EREG] != "")) { |
| 2668 | - if (ereg($p_params[ARCHIVE_ZIP_PARAM_BY_EREG], |
|
| 2669 | - $v_header_list[$v_nb_extracted]['stored_filename'])) { |
|
| 2670 | - $v_found = true; |
|
| 2671 | - } |
|
| 2672 | - } |
|
| 2673 | - |
|
| 2674 | - // ----- Look for extract by preg rule |
|
| 2675 | - elseif ((isset($p_params[ARCHIVE_ZIP_PARAM_BY_PREG])) |
|
| 2668 | + if (ereg($p_params[ARCHIVE_ZIP_PARAM_BY_EREG], |
|
| 2669 | + $v_header_list[$v_nb_extracted]['stored_filename'])) { |
|
| 2670 | + $v_found = true; |
|
| 2671 | + } |
|
| 2672 | + } |
|
| 2673 | + |
|
| 2674 | + // ----- Look for extract by preg rule |
|
| 2675 | + elseif ((isset($p_params[ARCHIVE_ZIP_PARAM_BY_PREG])) |
|
| 2676 | 2676 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_PREG] != "")) { |
| 2677 | - if (preg_match($p_params[ARCHIVE_ZIP_PARAM_BY_PREG], |
|
| 2678 | - $v_header_list[$v_nb_extracted]['stored_filename'])) { |
|
| 2679 | - $v_found = true; |
|
| 2680 | - } |
|
| 2681 | - } |
|
| 2682 | - |
|
| 2683 | - // ----- Look for extract by index rule |
|
| 2684 | - elseif ((isset($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) |
|
| 2677 | + if (preg_match($p_params[ARCHIVE_ZIP_PARAM_BY_PREG], |
|
| 2678 | + $v_header_list[$v_nb_extracted]['stored_filename'])) { |
|
| 2679 | + $v_found = true; |
|
| 2680 | + } |
|
| 2681 | + } |
|
| 2682 | + |
|
| 2683 | + // ----- Look for extract by index rule |
|
| 2684 | + elseif ((isset($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) |
|
| 2685 | 2685 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX] != 0)) { |
| 2686 | 2686 | |
| 2687 | - // ----- Look if the index is in the list |
|
| 2688 | - for ($j=$j_start; |
|
| 2689 | - ($j<sizeof($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) |
|
| 2687 | + // ----- Look if the index is in the list |
|
| 2688 | + for ($j=$j_start; |
|
| 2689 | + ($j<sizeof($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) |
|
| 2690 | 2690 | && (!$v_found); |
| 2691 | - $j++) { |
|
| 2692 | - if (($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']) |
|
| 2691 | + $j++) { |
|
| 2692 | + if (($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']) |
|
| 2693 | 2693 | && ($i<=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) { |
| 2694 | - $v_found = true; |
|
| 2695 | - } |
|
| 2696 | - if ($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) { |
|
| 2697 | - $j_start = $j+1; |
|
| 2698 | - } |
|
| 2699 | - |
|
| 2700 | - if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']>$i) { |
|
| 2701 | - break; |
|
| 2702 | - } |
|
| 2703 | - } |
|
| 2704 | - } |
|
| 2705 | - |
|
| 2706 | - // ----- Look for deletion |
|
| 2707 | - if ($v_found) { |
|
| 2708 | - unset($v_header_list[$v_nb_extracted]); |
|
| 2709 | - } else { |
|
| 2710 | - $v_nb_extracted++; |
|
| 2711 | - } |
|
| 2712 | - } |
|
| 2694 | + $v_found = true; |
|
| 2695 | + } |
|
| 2696 | + if ($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) { |
|
| 2697 | + $j_start = $j+1; |
|
| 2698 | + } |
|
| 2699 | + |
|
| 2700 | + if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']>$i) { |
|
| 2701 | + break; |
|
| 2702 | + } |
|
| 2703 | + } |
|
| 2704 | + } |
|
| 2705 | + |
|
| 2706 | + // ----- Look for deletion |
|
| 2707 | + if ($v_found) { |
|
| 2708 | + unset($v_header_list[$v_nb_extracted]); |
|
| 2709 | + } else { |
|
| 2710 | + $v_nb_extracted++; |
|
| 2711 | + } |
|
| 2712 | + } |
|
| 2713 | 2713 | |
| 2714 | 2714 | // ----- Look if something need to be deleted |
| 2715 | 2715 | if ($v_nb_extracted > 0) { |
| 2716 | 2716 | |
| 2717 | 2717 | // ----- Creates a temporay file |
| 2718 | 2718 | $v_zip_temp_name = ARCHIVE_ZIP_TEMPORARY_DIR.uniqid('archive_zip-') |
| 2719 | - .'.tmp'; |
|
| 2719 | + .'.tmp'; |
|
| 2720 | 2720 | |
| 2721 | 2721 | // ----- Creates a temporary zip archive |
| 2722 | 2722 | $v_temp_zip = new Archive_Zip($v_zip_temp_name); |
@@ -2741,7 +2741,7 @@ discard block |
||
| 2741 | 2741 | @unlink($v_zip_temp_name); |
| 2742 | 2742 | |
| 2743 | 2743 | $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, |
| 2744 | - 'Invalid archive size'); |
|
| 2744 | + 'Invalid archive size'); |
|
| 2745 | 2745 | return Archive_Zip::errorCode(); |
| 2746 | 2746 | } |
| 2747 | 2747 | |
@@ -2768,8 +2768,8 @@ discard block |
||
| 2768 | 2768 | |
| 2769 | 2769 | // ----- Read/write the data block |
| 2770 | 2770 | $v_result = $this->_tool_CopyBlock($this->_zip_fd, |
| 2771 | - $v_temp_zip->_zip_fd, |
|
| 2772 | - $v_header_list[$i]['compressed_size']); |
|
| 2771 | + $v_temp_zip->_zip_fd, |
|
| 2772 | + $v_header_list[$i]['compressed_size']); |
|
| 2773 | 2773 | if ($v_result != 1) { |
| 2774 | 2774 | // ----- Clean |
| 2775 | 2775 | $this->_closeFd(); |
@@ -2798,7 +2798,7 @@ discard block |
||
| 2798 | 2798 | |
| 2799 | 2799 | // ----- Transform the header to a 'usable' info |
| 2800 | 2800 | $v_temp_zip->_convertHeader2FileInfo($v_header_list[$i], |
| 2801 | - $p_result_list[$i]); |
|
| 2801 | + $p_result_list[$i]); |
|
| 2802 | 2802 | } |
| 2803 | 2803 | |
| 2804 | 2804 | |
@@ -2810,8 +2810,8 @@ discard block |
||
| 2810 | 2810 | |
| 2811 | 2811 | // ----- Create the central dir footer |
| 2812 | 2812 | $v_result = $v_temp_zip->_writeCentralHeader(sizeof($v_header_list), |
| 2813 | - $v_size, $v_offset, |
|
| 2814 | - $v_comment); |
|
| 2813 | + $v_size, $v_offset, |
|
| 2814 | + $v_comment); |
|
| 2815 | 2815 | if ($v_result != 1) { |
| 2816 | 2816 | // ----- Clean |
| 2817 | 2817 | unset($v_header_list); |
@@ -2841,30 +2841,30 @@ discard block |
||
| 2841 | 2841 | |
| 2842 | 2842 | // ----- Return |
| 2843 | 2843 | return $v_result; |
| 2844 | - } |
|
| 2845 | - // --------------------------------------------------------------------------- |
|
| 2846 | - |
|
| 2847 | - // --------------------------------------------------------------------------- |
|
| 2848 | - // Function : _dirCheck() |
|
| 2849 | - // Description : |
|
| 2850 | - // Check if a directory exists, if not it creates it and all the parents directory |
|
| 2851 | - // which may be useful. |
|
| 2852 | - // Parameters : |
|
| 2853 | - // $p_dir : Directory path to check. |
|
| 2854 | - // Return Values : |
|
| 2855 | - // 1 : OK |
|
| 2856 | - // -1 : Unable to create directory |
|
| 2857 | - // --------------------------------------------------------------------------- |
|
| 2858 | - /** |
|
| 2859 | - * Archive_Zip::_dirCheck() |
|
| 2860 | - * |
|
| 2861 | - * { Description } |
|
| 2862 | - * |
|
| 2863 | - * @param [type] $p_is_dir |
|
| 2864 | - */ |
|
| 2865 | - public function _dirCheck($p_dir, $p_is_dir=false) |
|
| 2866 | - { |
|
| 2867 | - $v_result = 1; |
|
| 2844 | + } |
|
| 2845 | + // --------------------------------------------------------------------------- |
|
| 2846 | + |
|
| 2847 | + // --------------------------------------------------------------------------- |
|
| 2848 | + // Function : _dirCheck() |
|
| 2849 | + // Description : |
|
| 2850 | + // Check if a directory exists, if not it creates it and all the parents directory |
|
| 2851 | + // which may be useful. |
|
| 2852 | + // Parameters : |
|
| 2853 | + // $p_dir : Directory path to check. |
|
| 2854 | + // Return Values : |
|
| 2855 | + // 1 : OK |
|
| 2856 | + // -1 : Unable to create directory |
|
| 2857 | + // --------------------------------------------------------------------------- |
|
| 2858 | + /** |
|
| 2859 | + * Archive_Zip::_dirCheck() |
|
| 2860 | + * |
|
| 2861 | + * { Description } |
|
| 2862 | + * |
|
| 2863 | + * @param [type] $p_is_dir |
|
| 2864 | + */ |
|
| 2865 | + public function _dirCheck($p_dir, $p_is_dir=false) |
|
| 2866 | + { |
|
| 2867 | + $v_result = 1; |
|
| 2868 | 2868 | |
| 2869 | 2869 | // ----- Remove the final '/' |
| 2870 | 2870 | if (($p_is_dir) && (substr($p_dir, -1)=='/')) { |
@@ -2882,52 +2882,52 @@ discard block |
||
| 2882 | 2882 | // ----- Just a check |
| 2883 | 2883 | if ($p_parent_dir != $p_dir) { |
| 2884 | 2884 | // ----- Look for parent directory |
| 2885 | - if ($p_parent_dir != "") { |
|
| 2886 | - if (($v_result = $this->_dirCheck($p_parent_dir)) != 1) { |
|
| 2887 | - return $v_result; |
|
| 2888 | - } |
|
| 2889 | - } |
|
| 2885 | + if ($p_parent_dir != "") { |
|
| 2886 | + if (($v_result = $this->_dirCheck($p_parent_dir)) != 1) { |
|
| 2887 | + return $v_result; |
|
| 2888 | + } |
|
| 2889 | + } |
|
| 2890 | 2890 | } |
| 2891 | 2891 | |
| 2892 | 2892 | // ----- Create the directory |
| 2893 | 2893 | if (!@mkdir($p_dir, 0777)) { |
| 2894 | 2894 | $this->_errorLog(ARCHIVE_ZIP_ERR_DIR_CREATE_FAIL, |
| 2895 | - "Unable to create directory '$p_dir'"); |
|
| 2895 | + "Unable to create directory '$p_dir'"); |
|
| 2896 | 2896 | return Archive_Zip::errorCode(); |
| 2897 | 2897 | } |
| 2898 | 2898 | |
| 2899 | 2899 | // ----- Return |
| 2900 | 2900 | return $v_result; |
| 2901 | - } |
|
| 2902 | - // --------------------------------------------------------------------------- |
|
| 2903 | - |
|
| 2904 | - // --------------------------------------------------------------------------- |
|
| 2905 | - // Function : _merge() |
|
| 2906 | - // Description : |
|
| 2907 | - // If $p_archive_to_add does not exist, the function exit with a success result. |
|
| 2908 | - // Parameters : |
|
| 2909 | - // Return Values : |
|
| 2910 | - // --------------------------------------------------------------------------- |
|
| 2911 | - /** |
|
| 2912 | - * Archive_Zip::_merge() |
|
| 2913 | - * |
|
| 2914 | - * { Description } |
|
| 2915 | - * |
|
| 2916 | - */ |
|
| 2917 | - public function _merge(&$p_archive_to_add) |
|
| 2918 | - { |
|
| 2919 | - $v_result=1; |
|
| 2901 | + } |
|
| 2902 | + // --------------------------------------------------------------------------- |
|
| 2903 | + |
|
| 2904 | + // --------------------------------------------------------------------------- |
|
| 2905 | + // Function : _merge() |
|
| 2906 | + // Description : |
|
| 2907 | + // If $p_archive_to_add does not exist, the function exit with a success result. |
|
| 2908 | + // Parameters : |
|
| 2909 | + // Return Values : |
|
| 2910 | + // --------------------------------------------------------------------------- |
|
| 2911 | + /** |
|
| 2912 | + * Archive_Zip::_merge() |
|
| 2913 | + * |
|
| 2914 | + * { Description } |
|
| 2915 | + * |
|
| 2916 | + */ |
|
| 2917 | + public function _merge(&$p_archive_to_add) |
|
| 2918 | + { |
|
| 2919 | + $v_result=1; |
|
| 2920 | 2920 | |
| 2921 | 2921 | // ----- Look if the archive_to_add exists |
| 2922 | 2922 | if (!is_file($p_archive_to_add->_zipname)) { |
| 2923 | 2923 | // ----- Nothing to merge, so merge is a success |
| 2924 | - return 1; |
|
| 2924 | + return 1; |
|
| 2925 | 2925 | } |
| 2926 | 2926 | |
| 2927 | 2927 | // ----- Look if the archive exists |
| 2928 | 2928 | if (!is_file($this->_zipname)) { |
| 2929 | 2929 | // ----- Do a duplicate |
| 2930 | - $v_result = $this->_duplicate($p_archive_to_add->_zipname); |
|
| 2930 | + $v_result = $this->_duplicate($p_archive_to_add->_zipname); |
|
| 2931 | 2931 | |
| 2932 | 2932 | return $v_result; |
| 2933 | 2933 | } |
@@ -2939,10 +2939,10 @@ discard block |
||
| 2939 | 2939 | |
| 2940 | 2940 | // ----- Read the central directory informations |
| 2941 | 2941 | $v_central_dir = array(); |
| 2942 | - if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
| 2943 | - $this->_closeFd(); |
|
| 2944 | - return $v_result; |
|
| 2945 | - } |
|
| 2942 | + if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) { |
|
| 2943 | + $this->_closeFd(); |
|
| 2944 | + return $v_result; |
|
| 2945 | + } |
|
| 2946 | 2946 | |
| 2947 | 2947 | // ----- Go to beginning of File |
| 2948 | 2948 | @rewind($this->_zip_fd); |
@@ -2955,12 +2955,12 @@ discard block |
||
| 2955 | 2955 | |
| 2956 | 2956 | // ----- Read the central directory informations |
| 2957 | 2957 | $v_central_dir_to_add = array(); |
| 2958 | - $v_result = $p_archive_to_add->_readEndCentralDir($v_central_dir_to_add); |
|
| 2959 | - if ($v_result != 1) { |
|
| 2960 | - $this->_closeFd(); |
|
| 2961 | - $p_archive_to_add->_closeFd(); |
|
| 2962 | - return $v_result; |
|
| 2963 | - } |
|
| 2958 | + $v_result = $p_archive_to_add->_readEndCentralDir($v_central_dir_to_add); |
|
| 2959 | + if ($v_result != 1) { |
|
| 2960 | + $this->_closeFd(); |
|
| 2961 | + $p_archive_to_add->_closeFd(); |
|
| 2962 | + return $v_result; |
|
| 2963 | + } |
|
| 2964 | 2964 | |
| 2965 | 2965 | // ----- Go to beginning of File |
| 2966 | 2966 | @rewind($p_archive_to_add->_zip_fd); |
@@ -2973,8 +2973,8 @@ discard block |
||
| 2973 | 2973 | $this->_closeFd(); |
| 2974 | 2974 | $p_archive_to_add->_closeFd(); |
| 2975 | 2975 | $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, |
| 2976 | - 'Unable to open temporary file \'' |
|
| 2977 | - .$v_zip_temp_name.'\' in binary write mode'); |
|
| 2976 | + 'Unable to open temporary file \'' |
|
| 2977 | + .$v_zip_temp_name.'\' in binary write mode'); |
|
| 2978 | 2978 | return Archive_Zip::errorCode(); |
| 2979 | 2979 | } |
| 2980 | 2980 | |
@@ -2982,46 +2982,46 @@ discard block |
||
| 2982 | 2982 | // TBC : Here I should better append the file and go back to erase the |
| 2983 | 2983 | // central dir |
| 2984 | 2984 | $v_size = $v_central_dir['offset']; |
| 2985 | - while ($v_size != 0) { |
|
| 2986 | - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 2985 | + while ($v_size != 0) { |
|
| 2986 | + $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 2987 | 2987 | ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
| 2988 | - $v_buffer = fread($this->_zip_fd, $v_read_size); |
|
| 2989 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 2990 | - $v_size -= $v_read_size; |
|
| 2991 | - } |
|
| 2988 | + $v_buffer = fread($this->_zip_fd, $v_read_size); |
|
| 2989 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 2990 | + $v_size -= $v_read_size; |
|
| 2991 | + } |
|
| 2992 | 2992 | |
| 2993 | 2993 | // ----- Copy the files from the archive_to_add into the temporary file |
| 2994 | 2994 | $v_size = $v_central_dir_to_add['offset']; |
| 2995 | - while ($v_size != 0) { |
|
| 2996 | - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 2995 | + while ($v_size != 0) { |
|
| 2996 | + $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 2997 | 2997 | ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
| 2998 | - $v_buffer = fread($p_archive_to_add->_zip_fd, $v_read_size); |
|
| 2999 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 3000 | - $v_size -= $v_read_size; |
|
| 3001 | - } |
|
| 2998 | + $v_buffer = fread($p_archive_to_add->_zip_fd, $v_read_size); |
|
| 2999 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 3000 | + $v_size -= $v_read_size; |
|
| 3001 | + } |
|
| 3002 | 3002 | |
| 3003 | 3003 | // ----- Store the offset of the central dir |
| 3004 | 3004 | $v_offset = @ftell($v_zip_temp_fd); |
| 3005 | 3005 | |
| 3006 | 3006 | // ----- Copy the block of file headers from the old archive |
| 3007 | 3007 | $v_size = $v_central_dir['size']; |
| 3008 | - while ($v_size != 0) { |
|
| 3009 | - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 3008 | + while ($v_size != 0) { |
|
| 3009 | + $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 3010 | 3010 | ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
| 3011 | - $v_buffer = @fread($this->_zip_fd, $v_read_size); |
|
| 3012 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 3013 | - $v_size -= $v_read_size; |
|
| 3014 | - } |
|
| 3011 | + $v_buffer = @fread($this->_zip_fd, $v_read_size); |
|
| 3012 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 3013 | + $v_size -= $v_read_size; |
|
| 3014 | + } |
|
| 3015 | 3015 | |
| 3016 | 3016 | // ----- Copy the block of file headers from the archive_to_add |
| 3017 | 3017 | $v_size = $v_central_dir_to_add['size']; |
| 3018 | - while ($v_size != 0) { |
|
| 3019 | - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 3018 | + while ($v_size != 0) { |
|
| 3019 | + $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 3020 | 3020 | ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
| 3021 | - $v_buffer = @fread($p_archive_to_add->_zip_fd, $v_read_size); |
|
| 3022 | - @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 3023 | - $v_size -= $v_read_size; |
|
| 3024 | - } |
|
| 3021 | + $v_buffer = @fread($p_archive_to_add->_zip_fd, $v_read_size); |
|
| 3022 | + @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size); |
|
| 3023 | + $v_size -= $v_read_size; |
|
| 3024 | + } |
|
| 3025 | 3025 | |
| 3026 | 3026 | // ----- Zip file comment |
| 3027 | 3027 | // TBC : I should merge the two comments |
@@ -3034,8 +3034,8 @@ discard block |
||
| 3034 | 3034 | // Here is a trick : I swap the temporary fd with the zip fd, in order to use |
| 3035 | 3035 | // the following methods on the temporary fil and not the real archive fd |
| 3036 | 3036 | $v_swap = $this->_zip_fd; |
| 3037 | - $this->_zip_fd = $v_zip_temp_fd; |
|
| 3038 | - $v_zip_temp_fd = $v_swap; |
|
| 3037 | + $this->_zip_fd = $v_zip_temp_fd; |
|
| 3038 | + $v_zip_temp_fd = $v_swap; |
|
| 3039 | 3039 | |
| 3040 | 3040 | // ----- Create the central dir footer |
| 3041 | 3041 | if (($v_result = $this->_writeCentralHeader($v_central_dir['entries'] |
@@ -3047,21 +3047,21 @@ discard block |
||
| 3047 | 3047 | @fclose($v_zip_temp_fd); |
| 3048 | 3048 | $this->_zip_fd = null; |
| 3049 | 3049 | |
| 3050 | - // ----- Reset the file list |
|
| 3051 | - unset($v_header_list); |
|
| 3050 | + // ----- Reset the file list |
|
| 3051 | + unset($v_header_list); |
|
| 3052 | 3052 | |
| 3053 | - // ----- Return |
|
| 3054 | - return $v_result; |
|
| 3053 | + // ----- Return |
|
| 3054 | + return $v_result; |
|
| 3055 | 3055 | } |
| 3056 | 3056 | |
| 3057 | 3057 | // ----- Swap back the file descriptor |
| 3058 | 3058 | $v_swap = $this->_zip_fd; |
| 3059 | - $this->_zip_fd = $v_zip_temp_fd; |
|
| 3060 | - $v_zip_temp_fd = $v_swap; |
|
| 3059 | + $this->_zip_fd = $v_zip_temp_fd; |
|
| 3060 | + $v_zip_temp_fd = $v_swap; |
|
| 3061 | 3061 | |
| 3062 | 3062 | // ----- Close |
| 3063 | 3063 | $this->_closeFd(); |
| 3064 | - $p_archive_to_add->_closeFd(); |
|
| 3064 | + $p_archive_to_add->_closeFd(); |
|
| 3065 | 3065 | |
| 3066 | 3066 | // ----- Close the temporary file |
| 3067 | 3067 | @fclose($v_zip_temp_fd); |
@@ -3077,47 +3077,47 @@ discard block |
||
| 3077 | 3077 | |
| 3078 | 3078 | // ----- Return |
| 3079 | 3079 | return $v_result; |
| 3080 | - } |
|
| 3081 | - // --------------------------------------------------------------------------- |
|
| 3082 | - |
|
| 3083 | - // --------------------------------------------------------------------------- |
|
| 3084 | - // Function : _duplicate() |
|
| 3085 | - // Description : |
|
| 3086 | - // Parameters : |
|
| 3087 | - // Return Values : |
|
| 3088 | - // --------------------------------------------------------------------------- |
|
| 3089 | - /** |
|
| 3090 | - * Archive_Zip::_duplicate() |
|
| 3091 | - * |
|
| 3092 | - * { Description } |
|
| 3093 | - * |
|
| 3094 | - */ |
|
| 3095 | - public function _duplicate($p_archive_filename) |
|
| 3096 | - { |
|
| 3097 | - $v_result=1; |
|
| 3080 | + } |
|
| 3081 | + // --------------------------------------------------------------------------- |
|
| 3082 | + |
|
| 3083 | + // --------------------------------------------------------------------------- |
|
| 3084 | + // Function : _duplicate() |
|
| 3085 | + // Description : |
|
| 3086 | + // Parameters : |
|
| 3087 | + // Return Values : |
|
| 3088 | + // --------------------------------------------------------------------------- |
|
| 3089 | + /** |
|
| 3090 | + * Archive_Zip::_duplicate() |
|
| 3091 | + * |
|
| 3092 | + * { Description } |
|
| 3093 | + * |
|
| 3094 | + */ |
|
| 3095 | + public function _duplicate($p_archive_filename) |
|
| 3096 | + { |
|
| 3097 | + $v_result=1; |
|
| 3098 | 3098 | |
| 3099 | 3099 | // ----- Look if the $p_archive_filename exists |
| 3100 | 3100 | if (!is_file($p_archive_filename)) { |
| 3101 | 3101 | |
| 3102 | - // ----- Nothing to duplicate, so duplicate is a success. |
|
| 3103 | - $v_result = 1; |
|
| 3102 | + // ----- Nothing to duplicate, so duplicate is a success. |
|
| 3103 | + $v_result = 1; |
|
| 3104 | 3104 | |
| 3105 | - // ----- Return |
|
| 3106 | - return $v_result; |
|
| 3105 | + // ----- Return |
|
| 3106 | + return $v_result; |
|
| 3107 | 3107 | } |
| 3108 | 3108 | |
| 3109 | 3109 | // ----- Open the zip file |
| 3110 | 3110 | if (($v_result=$this->_openFd('wb')) != 1) { |
| 3111 | 3111 | // ----- Return |
| 3112 | - return $v_result; |
|
| 3112 | + return $v_result; |
|
| 3113 | 3113 | } |
| 3114 | 3114 | |
| 3115 | 3115 | // ----- Open the temporary file in write mode |
| 3116 | 3116 | if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) { |
| 3117 | 3117 | $this->_closeFd(); |
| 3118 | 3118 | $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, |
| 3119 | - 'Unable to open archive file \'' |
|
| 3120 | - .$p_archive_filename.'\' in binary write mode'); |
|
| 3119 | + 'Unable to open archive file \'' |
|
| 3120 | + .$p_archive_filename.'\' in binary write mode'); |
|
| 3121 | 3121 | return Archive_Zip::errorCode(); |
| 3122 | 3122 | } |
| 3123 | 3123 | |
@@ -3125,13 +3125,13 @@ discard block |
||
| 3125 | 3125 | // TBC : Here I should better append the file and go back to erase the |
| 3126 | 3126 | // central dir |
| 3127 | 3127 | $v_size = filesize($p_archive_filename); |
| 3128 | - while ($v_size != 0) { |
|
| 3129 | - $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 3128 | + while ($v_size != 0) { |
|
| 3129 | + $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 3130 | 3130 | ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
| 3131 | - $v_buffer = fread($v_zip_temp_fd, $v_read_size); |
|
| 3132 | - @fwrite($this->_zip_fd, $v_buffer, $v_read_size); |
|
| 3133 | - $v_size -= $v_read_size; |
|
| 3134 | - } |
|
| 3131 | + $v_buffer = fread($v_zip_temp_fd, $v_read_size); |
|
| 3132 | + @fwrite($this->_zip_fd, $v_buffer, $v_read_size); |
|
| 3133 | + $v_size -= $v_read_size; |
|
| 3134 | + } |
|
| 3135 | 3135 | |
| 3136 | 3136 | // ----- Close |
| 3137 | 3137 | $this->_closeFd(); |
@@ -3139,25 +3139,25 @@ discard block |
||
| 3139 | 3139 | // ----- Close the temporary file |
| 3140 | 3140 | @fclose($v_zip_temp_fd); |
| 3141 | 3141 | |
| 3142 | - return $v_result; |
|
| 3143 | - } |
|
| 3144 | - // --------------------------------------------------------------------------- |
|
| 3145 | - |
|
| 3146 | - /** |
|
| 3147 | - * Archive_Zip::_check_parameters() |
|
| 3148 | - * |
|
| 3149 | - * { Description } |
|
| 3150 | - * |
|
| 3151 | - * @param integer $p_error_code |
|
| 3152 | - * @param string $p_error_string |
|
| 3153 | - */ |
|
| 3154 | - public function _check_parameters(&$p_params, $p_default) |
|
| 3155 | - { |
|
| 3142 | + return $v_result; |
|
| 3143 | + } |
|
| 3144 | + // --------------------------------------------------------------------------- |
|
| 3145 | + |
|
| 3146 | + /** |
|
| 3147 | + * Archive_Zip::_check_parameters() |
|
| 3148 | + * |
|
| 3149 | + * { Description } |
|
| 3150 | + * |
|
| 3151 | + * @param integer $p_error_code |
|
| 3152 | + * @param string $p_error_string |
|
| 3153 | + */ |
|
| 3154 | + public function _check_parameters(&$p_params, $p_default) |
|
| 3155 | + { |
|
| 3156 | 3156 | |
| 3157 | 3157 | // ----- Check that param is an array |
| 3158 | 3158 | if (!is_array($p_params)) { |
| 3159 | 3159 | $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, |
| 3160 | - 'Unsupported parameter, waiting for an array'); |
|
| 3160 | + 'Unsupported parameter, waiting for an array'); |
|
| 3161 | 3161 | return Archive_Zip::errorCode(); |
| 3162 | 3162 | } |
| 3163 | 3163 | |
@@ -3165,7 +3165,7 @@ discard block |
||
| 3165 | 3165 | for (reset($p_params); list($v_key, $v_value) = each($p_params);) { |
| 3166 | 3166 | if (!isset($p_default[$v_key])) { |
| 3167 | 3167 | $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, |
| 3168 | - 'Unsupported parameter with key \''.$v_key.'\''); |
|
| 3168 | + 'Unsupported parameter with key \''.$v_key.'\''); |
|
| 3169 | 3169 | |
| 3170 | 3170 | return Archive_Zip::errorCode(); |
| 3171 | 3171 | } |
@@ -3180,170 +3180,170 @@ discard block |
||
| 3180 | 3180 | |
| 3181 | 3181 | // ----- Check specific parameters |
| 3182 | 3182 | $v_callback_list = array('callback_pre_add', 'callback_post_add', |
| 3183 | - 'callback_pre_extract', 'callback_post_extract'); |
|
| 3184 | - for ($i=0; $i<sizeof($v_callback_list); $i++) { |
|
| 3185 | - $v_key=$v_callback_list[$i]; |
|
| 3186 | - if ((isset($p_params[$v_key])) && ($p_params[$v_key] != '')) { |
|
| 3187 | - if (!function_exists($p_params[$v_key])) { |
|
| 3188 | - $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAM_VALUE, |
|
| 3189 | - "Callback '".$p_params[$v_key] |
|
| 3190 | - ."()' is not an existing function for " |
|
| 3191 | - ."parameter '".$v_key."'"); |
|
| 3192 | - return Archive_Zip::errorCode(); |
|
| 3193 | - } |
|
| 3194 | - } |
|
| 3195 | - } |
|
| 3196 | - |
|
| 3197 | - return(1); |
|
| 3198 | - } |
|
| 3199 | - // --------------------------------------------------------------------------- |
|
| 3200 | - |
|
| 3201 | - // --------------------------------------------------------------------------- |
|
| 3202 | - // Function : _errorLog() |
|
| 3203 | - // Description : |
|
| 3204 | - // Parameters : |
|
| 3205 | - // --------------------------------------------------------------------------- |
|
| 3206 | - /** |
|
| 3207 | - * Archive_Zip::_errorLog() |
|
| 3208 | - * |
|
| 3209 | - * { Description } |
|
| 3210 | - * |
|
| 3211 | - * @param integer $p_error_code |
|
| 3212 | - * @param string $p_error_string |
|
| 3213 | - */ |
|
| 3214 | - public function _errorLog($p_error_code=0, $p_error_string='') |
|
| 3215 | - { |
|
| 3216 | - $this->_error_code = $p_error_code; |
|
| 3217 | - $this->_error_string = $p_error_string; |
|
| 3218 | - } |
|
| 3219 | - // --------------------------------------------------------------------------- |
|
| 3220 | - |
|
| 3221 | - // --------------------------------------------------------------------------- |
|
| 3222 | - // Function : _errorReset() |
|
| 3223 | - // Description : |
|
| 3224 | - // Parameters : |
|
| 3225 | - // --------------------------------------------------------------------------- |
|
| 3226 | - /** |
|
| 3227 | - * Archive_Zip::_errorReset() |
|
| 3228 | - * |
|
| 3229 | - * { Description } |
|
| 3230 | - * |
|
| 3231 | - */ |
|
| 3232 | - public function _errorReset() |
|
| 3233 | - { |
|
| 3234 | - $this->_error_code = 1; |
|
| 3235 | - $this->_error_string = ''; |
|
| 3236 | - } |
|
| 3237 | - // --------------------------------------------------------------------------- |
|
| 3238 | - |
|
| 3239 | - // --------------------------------------------------------------------------- |
|
| 3240 | - // Function : $this->_tool_PathReduction() |
|
| 3241 | - // Description : |
|
| 3242 | - // Parameters : |
|
| 3243 | - // Return Values : |
|
| 3244 | - // --------------------------------------------------------------------------- |
|
| 3245 | - /** |
|
| 3246 | - * _tool_PathReduction() |
|
| 3247 | - * |
|
| 3248 | - * { Description } |
|
| 3249 | - * |
|
| 3250 | - */ |
|
| 3251 | - public function _tool_PathReduction($p_dir) |
|
| 3252 | - { |
|
| 3253 | - $v_result = ""; |
|
| 3183 | + 'callback_pre_extract', 'callback_post_extract'); |
|
| 3184 | + for ($i=0; $i<sizeof($v_callback_list); $i++) { |
|
| 3185 | + $v_key=$v_callback_list[$i]; |
|
| 3186 | + if ((isset($p_params[$v_key])) && ($p_params[$v_key] != '')) { |
|
| 3187 | + if (!function_exists($p_params[$v_key])) { |
|
| 3188 | + $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAM_VALUE, |
|
| 3189 | + "Callback '".$p_params[$v_key] |
|
| 3190 | + ."()' is not an existing function for " |
|
| 3191 | + ."parameter '".$v_key."'"); |
|
| 3192 | + return Archive_Zip::errorCode(); |
|
| 3193 | + } |
|
| 3194 | + } |
|
| 3195 | + } |
|
| 3196 | + |
|
| 3197 | + return(1); |
|
| 3198 | + } |
|
| 3199 | + // --------------------------------------------------------------------------- |
|
| 3200 | + |
|
| 3201 | + // --------------------------------------------------------------------------- |
|
| 3202 | + // Function : _errorLog() |
|
| 3203 | + // Description : |
|
| 3204 | + // Parameters : |
|
| 3205 | + // --------------------------------------------------------------------------- |
|
| 3206 | + /** |
|
| 3207 | + * Archive_Zip::_errorLog() |
|
| 3208 | + * |
|
| 3209 | + * { Description } |
|
| 3210 | + * |
|
| 3211 | + * @param integer $p_error_code |
|
| 3212 | + * @param string $p_error_string |
|
| 3213 | + */ |
|
| 3214 | + public function _errorLog($p_error_code=0, $p_error_string='') |
|
| 3215 | + { |
|
| 3216 | + $this->_error_code = $p_error_code; |
|
| 3217 | + $this->_error_string = $p_error_string; |
|
| 3218 | + } |
|
| 3219 | + // --------------------------------------------------------------------------- |
|
| 3220 | + |
|
| 3221 | + // --------------------------------------------------------------------------- |
|
| 3222 | + // Function : _errorReset() |
|
| 3223 | + // Description : |
|
| 3224 | + // Parameters : |
|
| 3225 | + // --------------------------------------------------------------------------- |
|
| 3226 | + /** |
|
| 3227 | + * Archive_Zip::_errorReset() |
|
| 3228 | + * |
|
| 3229 | + * { Description } |
|
| 3230 | + * |
|
| 3231 | + */ |
|
| 3232 | + public function _errorReset() |
|
| 3233 | + { |
|
| 3234 | + $this->_error_code = 1; |
|
| 3235 | + $this->_error_string = ''; |
|
| 3236 | + } |
|
| 3237 | + // --------------------------------------------------------------------------- |
|
| 3238 | + |
|
| 3239 | + // --------------------------------------------------------------------------- |
|
| 3240 | + // Function : $this->_tool_PathReduction() |
|
| 3241 | + // Description : |
|
| 3242 | + // Parameters : |
|
| 3243 | + // Return Values : |
|
| 3244 | + // --------------------------------------------------------------------------- |
|
| 3245 | + /** |
|
| 3246 | + * _tool_PathReduction() |
|
| 3247 | + * |
|
| 3248 | + * { Description } |
|
| 3249 | + * |
|
| 3250 | + */ |
|
| 3251 | + public function _tool_PathReduction($p_dir) |
|
| 3252 | + { |
|
| 3253 | + $v_result = ""; |
|
| 3254 | 3254 | |
| 3255 | 3255 | // ----- Look for not empty path |
| 3256 | 3256 | if ($p_dir != "") { |
| 3257 | 3257 | // ----- Explode path by directory names |
| 3258 | - $v_list = explode("/", $p_dir); |
|
| 3258 | + $v_list = explode("/", $p_dir); |
|
| 3259 | 3259 | |
| 3260 | - // ----- Study directories from last to first |
|
| 3261 | - for ($i=sizeof($v_list)-1; $i>=0; $i--) { |
|
| 3262 | - // ----- Look for current path |
|
| 3260 | + // ----- Study directories from last to first |
|
| 3261 | + for ($i=sizeof($v_list)-1; $i>=0; $i--) { |
|
| 3262 | + // ----- Look for current path |
|
| 3263 | 3263 | if ($v_list[$i] == ".") { |
| 3264 | 3264 | // ----- Ignore this directory |
| 3265 | - // Should be the first $i=0, but no check is done |
|
| 3265 | + // Should be the first $i=0, but no check is done |
|
| 3266 | 3266 | } elseif ($v_list[$i] == "..") { |
| 3267 | 3267 | // ----- Ignore it and ignore the $i-1 |
| 3268 | - $i--; |
|
| 3268 | + $i--; |
|
| 3269 | 3269 | } elseif (($v_list[$i] == "") && ($i!=(sizeof($v_list)-1)) && ($i!=0)) { |
| 3270 | 3270 | // ----- Ignore only the double '//' in path, |
| 3271 | - // but not the first and last '/' |
|
| 3271 | + // but not the first and last '/' |
|
| 3272 | 3272 | } else { |
| 3273 | 3273 | $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); |
| 3274 | 3274 | } |
| 3275 | - } |
|
| 3275 | + } |
|
| 3276 | 3276 | } |
| 3277 | 3277 | |
| 3278 | 3278 | // ----- Return |
| 3279 | 3279 | return $v_result; |
| 3280 | - } |
|
| 3281 | - // --------------------------------------------------------------------------- |
|
| 3282 | - |
|
| 3283 | - // --------------------------------------------------------------------------- |
|
| 3284 | - // Function : $this->_tool_PathInclusion() |
|
| 3285 | - // Description : |
|
| 3286 | - // This function indicates if the path $p_path is under the $p_dir tree. Or, |
|
| 3287 | - // said in an other way, if the file or sub-dir $p_path is inside the dir |
|
| 3288 | - // $p_dir. |
|
| 3289 | - // The function indicates also if the path is exactly the same as the dir. |
|
| 3290 | - // This function supports path with duplicated '/' like '//', but does not |
|
| 3291 | - // support '.' or '..' statements. |
|
| 3292 | - // Parameters : |
|
| 3293 | - // Return Values : |
|
| 3294 | - // 0 if $p_path is not inside directory $p_dir |
|
| 3295 | - // 1 if $p_path is inside directory $p_dir |
|
| 3296 | - // 2 if $p_path is exactly the same as $p_dir |
|
| 3297 | - // --------------------------------------------------------------------------- |
|
| 3298 | - /** |
|
| 3299 | - * _tool_PathInclusion() |
|
| 3300 | - * |
|
| 3301 | - * { Description } |
|
| 3302 | - * |
|
| 3303 | - */ |
|
| 3304 | - public function _tool_PathInclusion($p_dir, $p_path) |
|
| 3305 | - { |
|
| 3306 | - $v_result = 1; |
|
| 3280 | + } |
|
| 3281 | + // --------------------------------------------------------------------------- |
|
| 3282 | + |
|
| 3283 | + // --------------------------------------------------------------------------- |
|
| 3284 | + // Function : $this->_tool_PathInclusion() |
|
| 3285 | + // Description : |
|
| 3286 | + // This function indicates if the path $p_path is under the $p_dir tree. Or, |
|
| 3287 | + // said in an other way, if the file or sub-dir $p_path is inside the dir |
|
| 3288 | + // $p_dir. |
|
| 3289 | + // The function indicates also if the path is exactly the same as the dir. |
|
| 3290 | + // This function supports path with duplicated '/' like '//', but does not |
|
| 3291 | + // support '.' or '..' statements. |
|
| 3292 | + // Parameters : |
|
| 3293 | + // Return Values : |
|
| 3294 | + // 0 if $p_path is not inside directory $p_dir |
|
| 3295 | + // 1 if $p_path is inside directory $p_dir |
|
| 3296 | + // 2 if $p_path is exactly the same as $p_dir |
|
| 3297 | + // --------------------------------------------------------------------------- |
|
| 3298 | + /** |
|
| 3299 | + * _tool_PathInclusion() |
|
| 3300 | + * |
|
| 3301 | + * { Description } |
|
| 3302 | + * |
|
| 3303 | + */ |
|
| 3304 | + public function _tool_PathInclusion($p_dir, $p_path) |
|
| 3305 | + { |
|
| 3306 | + $v_result = 1; |
|
| 3307 | 3307 | |
| 3308 | 3308 | // ----- Explode dir and path by directory separator |
| 3309 | 3309 | $v_list_dir = explode("/", $p_dir); |
| 3310 | - $v_list_dir_size = sizeof($v_list_dir); |
|
| 3311 | - $v_list_path = explode("/", $p_path); |
|
| 3312 | - $v_list_path_size = sizeof($v_list_path); |
|
| 3310 | + $v_list_dir_size = sizeof($v_list_dir); |
|
| 3311 | + $v_list_path = explode("/", $p_path); |
|
| 3312 | + $v_list_path_size = sizeof($v_list_path); |
|
| 3313 | 3313 | |
| 3314 | 3314 | // ----- Study directories paths |
| 3315 | 3315 | $i = 0; |
| 3316 | - $j = 0; |
|
| 3317 | - while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) { |
|
| 3318 | - |
|
| 3319 | - // ----- Look for empty dir (path reduction) |
|
| 3320 | - if ($v_list_dir[$i] == '') { |
|
| 3321 | - $i++; |
|
| 3322 | - continue; |
|
| 3323 | - } |
|
| 3324 | - if ($v_list_path[$j] == '') { |
|
| 3325 | - $j++; |
|
| 3326 | - continue; |
|
| 3327 | - } |
|
| 3328 | - |
|
| 3329 | - // ----- Compare the items |
|
| 3330 | - if (($v_list_dir[$i] != $v_list_path[$j]) |
|
| 3316 | + $j = 0; |
|
| 3317 | + while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) { |
|
| 3318 | + |
|
| 3319 | + // ----- Look for empty dir (path reduction) |
|
| 3320 | + if ($v_list_dir[$i] == '') { |
|
| 3321 | + $i++; |
|
| 3322 | + continue; |
|
| 3323 | + } |
|
| 3324 | + if ($v_list_path[$j] == '') { |
|
| 3325 | + $j++; |
|
| 3326 | + continue; |
|
| 3327 | + } |
|
| 3328 | + |
|
| 3329 | + // ----- Compare the items |
|
| 3330 | + if (($v_list_dir[$i] != $v_list_path[$j]) |
|
| 3331 | 3331 | && ($v_list_dir[$i] != '') |
| 3332 | 3332 | && ($v_list_path[$j] != '')) { |
| 3333 | - $v_result = 0; |
|
| 3334 | - } |
|
| 3333 | + $v_result = 0; |
|
| 3334 | + } |
|
| 3335 | 3335 | |
| 3336 | - // ----- Next items |
|
| 3337 | - $i++; |
|
| 3338 | - $j++; |
|
| 3339 | - } |
|
| 3336 | + // ----- Next items |
|
| 3337 | + $i++; |
|
| 3338 | + $j++; |
|
| 3339 | + } |
|
| 3340 | 3340 | |
| 3341 | 3341 | // ----- Look if everything seems to be the same |
| 3342 | 3342 | if ($v_result) { |
| 3343 | 3343 | // ----- Skip all the empty items |
| 3344 | - while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) { |
|
| 3345 | - $j++; |
|
| 3346 | - } |
|
| 3344 | + while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) { |
|
| 3345 | + $j++; |
|
| 3346 | + } |
|
| 3347 | 3347 | while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) { |
| 3348 | 3348 | $i++; |
| 3349 | 3349 | } |
@@ -3359,142 +3359,142 @@ discard block |
||
| 3359 | 3359 | |
| 3360 | 3360 | // ----- Return |
| 3361 | 3361 | return $v_result; |
| 3362 | - } |
|
| 3363 | - // --------------------------------------------------------------------------- |
|
| 3364 | - |
|
| 3365 | - // --------------------------------------------------------------------------- |
|
| 3366 | - // Function : $this->_tool_CopyBlock() |
|
| 3367 | - // Description : |
|
| 3368 | - // Parameters : |
|
| 3369 | - // $p_mode : read/write compression mode |
|
| 3370 | - // 0 : src & dest normal |
|
| 3371 | - // 1 : src gzip, dest normal |
|
| 3372 | - // 2 : src normal, dest gzip |
|
| 3373 | - // 3 : src & dest gzip |
|
| 3374 | - // Return Values : |
|
| 3375 | - // --------------------------------------------------------------------------- |
|
| 3376 | - /** |
|
| 3377 | - * _tool_CopyBlock() |
|
| 3378 | - * |
|
| 3379 | - * { Description } |
|
| 3380 | - * |
|
| 3381 | - * @param integer $p_mode |
|
| 3382 | - */ |
|
| 3383 | - public function _tool_CopyBlock($p_src, $p_dest, $p_size, $p_mode=0) |
|
| 3384 | - { |
|
| 3385 | - $v_result = 1; |
|
| 3386 | - |
|
| 3387 | - if ($p_mode==0) { |
|
| 3388 | - while ($p_size != 0) { |
|
| 3389 | - $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 3362 | + } |
|
| 3363 | + // --------------------------------------------------------------------------- |
|
| 3364 | + |
|
| 3365 | + // --------------------------------------------------------------------------- |
|
| 3366 | + // Function : $this->_tool_CopyBlock() |
|
| 3367 | + // Description : |
|
| 3368 | + // Parameters : |
|
| 3369 | + // $p_mode : read/write compression mode |
|
| 3370 | + // 0 : src & dest normal |
|
| 3371 | + // 1 : src gzip, dest normal |
|
| 3372 | + // 2 : src normal, dest gzip |
|
| 3373 | + // 3 : src & dest gzip |
|
| 3374 | + // Return Values : |
|
| 3375 | + // --------------------------------------------------------------------------- |
|
| 3376 | + /** |
|
| 3377 | + * _tool_CopyBlock() |
|
| 3378 | + * |
|
| 3379 | + * { Description } |
|
| 3380 | + * |
|
| 3381 | + * @param integer $p_mode |
|
| 3382 | + */ |
|
| 3383 | + public function _tool_CopyBlock($p_src, $p_dest, $p_size, $p_mode=0) |
|
| 3384 | + { |
|
| 3385 | + $v_result = 1; |
|
| 3386 | + |
|
| 3387 | + if ($p_mode==0) { |
|
| 3388 | + while ($p_size != 0) { |
|
| 3389 | + $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 3390 | 3390 | ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
| 3391 | - $v_buffer = @fread($p_src, $v_read_size); |
|
| 3392 | - @fwrite($p_dest, $v_buffer, $v_read_size); |
|
| 3393 | - $p_size -= $v_read_size; |
|
| 3394 | - } |
|
| 3395 | - } elseif ($p_mode==1) { |
|
| 3396 | - while ($p_size != 0) { |
|
| 3397 | - $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 3391 | + $v_buffer = @fread($p_src, $v_read_size); |
|
| 3392 | + @fwrite($p_dest, $v_buffer, $v_read_size); |
|
| 3393 | + $p_size -= $v_read_size; |
|
| 3394 | + } |
|
| 3395 | + } elseif ($p_mode==1) { |
|
| 3396 | + while ($p_size != 0) { |
|
| 3397 | + $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 3398 | 3398 | ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
| 3399 | - $v_buffer = @gzread($p_src, $v_read_size); |
|
| 3400 | - @fwrite($p_dest, $v_buffer, $v_read_size); |
|
| 3401 | - $p_size -= $v_read_size; |
|
| 3402 | - } |
|
| 3403 | - } elseif ($p_mode==2) { |
|
| 3404 | - while ($p_size != 0) { |
|
| 3405 | - $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 3399 | + $v_buffer = @gzread($p_src, $v_read_size); |
|
| 3400 | + @fwrite($p_dest, $v_buffer, $v_read_size); |
|
| 3401 | + $p_size -= $v_read_size; |
|
| 3402 | + } |
|
| 3403 | + } elseif ($p_mode==2) { |
|
| 3404 | + while ($p_size != 0) { |
|
| 3405 | + $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 3406 | 3406 | ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
| 3407 | - $v_buffer = @fread($p_src, $v_read_size); |
|
| 3408 | - @gzwrite($p_dest, $v_buffer, $v_read_size); |
|
| 3409 | - $p_size -= $v_read_size; |
|
| 3410 | - } |
|
| 3411 | - } elseif ($p_mode==3) { |
|
| 3412 | - while ($p_size != 0) { |
|
| 3413 | - $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 3407 | + $v_buffer = @fread($p_src, $v_read_size); |
|
| 3408 | + @gzwrite($p_dest, $v_buffer, $v_read_size); |
|
| 3409 | + $p_size -= $v_read_size; |
|
| 3410 | + } |
|
| 3411 | + } elseif ($p_mode==3) { |
|
| 3412 | + while ($p_size != 0) { |
|
| 3413 | + $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
|
| 3414 | 3414 | ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
| 3415 | - $v_buffer = @gzread($p_src, $v_read_size); |
|
| 3416 | - @gzwrite($p_dest, $v_buffer, $v_read_size); |
|
| 3417 | - $p_size -= $v_read_size; |
|
| 3418 | - } |
|
| 3419 | - } |
|
| 3415 | + $v_buffer = @gzread($p_src, $v_read_size); |
|
| 3416 | + @gzwrite($p_dest, $v_buffer, $v_read_size); |
|
| 3417 | + $p_size -= $v_read_size; |
|
| 3418 | + } |
|
| 3419 | + } |
|
| 3420 | 3420 | |
| 3421 | 3421 | // ----- Return |
| 3422 | 3422 | return $v_result; |
| 3423 | - } |
|
| 3424 | - // --------------------------------------------------------------------------- |
|
| 3425 | - |
|
| 3426 | - // --------------------------------------------------------------------------- |
|
| 3427 | - // Function : $this->_tool_Rename() |
|
| 3428 | - // Description : |
|
| 3429 | - // This function tries to do a simple rename() function. If it fails, it |
|
| 3430 | - // tries to copy the $p_src file in a new $p_dest file and then unlink the |
|
| 3431 | - // first one. |
|
| 3432 | - // Parameters : |
|
| 3433 | - // $p_src : Old filename |
|
| 3434 | - // $p_dest : New filename |
|
| 3435 | - // Return Values : |
|
| 3436 | - // 1 on success, 0 on failure. |
|
| 3437 | - // --------------------------------------------------------------------------- |
|
| 3438 | - /** |
|
| 3439 | - * _tool_Rename() |
|
| 3440 | - * |
|
| 3441 | - * { Description } |
|
| 3442 | - * |
|
| 3443 | - */ |
|
| 3444 | - public function _tool_Rename($p_src, $p_dest) |
|
| 3445 | - { |
|
| 3446 | - $v_result = 1; |
|
| 3423 | + } |
|
| 3424 | + // --------------------------------------------------------------------------- |
|
| 3425 | + |
|
| 3426 | + // --------------------------------------------------------------------------- |
|
| 3427 | + // Function : $this->_tool_Rename() |
|
| 3428 | + // Description : |
|
| 3429 | + // This function tries to do a simple rename() function. If it fails, it |
|
| 3430 | + // tries to copy the $p_src file in a new $p_dest file and then unlink the |
|
| 3431 | + // first one. |
|
| 3432 | + // Parameters : |
|
| 3433 | + // $p_src : Old filename |
|
| 3434 | + // $p_dest : New filename |
|
| 3435 | + // Return Values : |
|
| 3436 | + // 1 on success, 0 on failure. |
|
| 3437 | + // --------------------------------------------------------------------------- |
|
| 3438 | + /** |
|
| 3439 | + * _tool_Rename() |
|
| 3440 | + * |
|
| 3441 | + * { Description } |
|
| 3442 | + * |
|
| 3443 | + */ |
|
| 3444 | + public function _tool_Rename($p_src, $p_dest) |
|
| 3445 | + { |
|
| 3446 | + $v_result = 1; |
|
| 3447 | 3447 | |
| 3448 | 3448 | // ----- Try to rename the files |
| 3449 | 3449 | if (!@rename($p_src, $p_dest)) { |
| 3450 | 3450 | |
| 3451 | - // ----- Try to copy & unlink the src |
|
| 3452 | - if (!@copy($p_src, $p_dest)) { |
|
| 3453 | - $v_result = 0; |
|
| 3454 | - } elseif (!@unlink($p_src)) { |
|
| 3455 | - $v_result = 0; |
|
| 3456 | - } |
|
| 3451 | + // ----- Try to copy & unlink the src |
|
| 3452 | + if (!@copy($p_src, $p_dest)) { |
|
| 3453 | + $v_result = 0; |
|
| 3454 | + } elseif (!@unlink($p_src)) { |
|
| 3455 | + $v_result = 0; |
|
| 3456 | + } |
|
| 3457 | 3457 | } |
| 3458 | 3458 | |
| 3459 | 3459 | // ----- Return |
| 3460 | 3460 | return $v_result; |
| 3461 | - } |
|
| 3462 | - // --------------------------------------------------------------------------- |
|
| 3463 | - |
|
| 3464 | - // --------------------------------------------------------------------------- |
|
| 3465 | - // Function : $this->_tool_TranslateWinPath() |
|
| 3466 | - // Description : |
|
| 3467 | - // Translate windows path by replacing '\' by '/' and optionally removing |
|
| 3468 | - // drive letter. |
|
| 3469 | - // Parameters : |
|
| 3470 | - // $p_path : path to translate. |
|
| 3471 | - // $p_remove_disk_letter : true | false |
|
| 3472 | - // Return Values : |
|
| 3473 | - // The path translated. |
|
| 3474 | - // --------------------------------------------------------------------------- |
|
| 3475 | - /** |
|
| 3476 | - * _tool_TranslateWinPath() |
|
| 3477 | - * |
|
| 3478 | - * { Description } |
|
| 3479 | - * |
|
| 3480 | - * @param [type] $p_remove_disk_letter |
|
| 3481 | - */ |
|
| 3482 | - public function _tool_TranslateWinPath($p_path, $p_remove_disk_letter=true) |
|
| 3483 | - { |
|
| 3484 | - if (stristr(php_uname(), 'windows')) { |
|
| 3485 | - // ----- Look for potential disk letter |
|
| 3486 | - if (($p_remove_disk_letter) |
|
| 3461 | + } |
|
| 3462 | + // --------------------------------------------------------------------------- |
|
| 3463 | + |
|
| 3464 | + // --------------------------------------------------------------------------- |
|
| 3465 | + // Function : $this->_tool_TranslateWinPath() |
|
| 3466 | + // Description : |
|
| 3467 | + // Translate windows path by replacing '\' by '/' and optionally removing |
|
| 3468 | + // drive letter. |
|
| 3469 | + // Parameters : |
|
| 3470 | + // $p_path : path to translate. |
|
| 3471 | + // $p_remove_disk_letter : true | false |
|
| 3472 | + // Return Values : |
|
| 3473 | + // The path translated. |
|
| 3474 | + // --------------------------------------------------------------------------- |
|
| 3475 | + /** |
|
| 3476 | + * _tool_TranslateWinPath() |
|
| 3477 | + * |
|
| 3478 | + * { Description } |
|
| 3479 | + * |
|
| 3480 | + * @param [type] $p_remove_disk_letter |
|
| 3481 | + */ |
|
| 3482 | + public function _tool_TranslateWinPath($p_path, $p_remove_disk_letter=true) |
|
| 3483 | + { |
|
| 3484 | + if (stristr(php_uname(), 'windows')) { |
|
| 3485 | + // ----- Look for potential disk letter |
|
| 3486 | + if (($p_remove_disk_letter) |
|
| 3487 | 3487 | && (($v_position = strpos($p_path, ':')) != false)) { |
| 3488 | - $p_path = substr($p_path, $v_position+1); |
|
| 3489 | - } |
|
| 3490 | - // ----- Change potential windows directory separator |
|
| 3491 | - if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) { |
|
| 3492 | - $p_path = strtr($p_path, '\\', '/'); |
|
| 3493 | - } |
|
| 3494 | - } |
|
| 3495 | - return $p_path; |
|
| 3496 | - } |
|
| 3497 | - // --------------------------------------------------------------------------- |
|
| 3488 | + $p_path = substr($p_path, $v_position+1); |
|
| 3489 | + } |
|
| 3490 | + // ----- Change potential windows directory separator |
|
| 3491 | + if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) { |
|
| 3492 | + $p_path = strtr($p_path, '\\', '/'); |
|
| 3493 | + } |
|
| 3494 | + } |
|
| 3495 | + return $p_path; |
|
| 3496 | + } |
|
| 3497 | + // --------------------------------------------------------------------------- |
|
| 3498 | 3498 | } |
| 3499 | - // End of class |
|
| 3499 | + // End of class |
|
| 3500 | 3500 | ; |
@@ -106,24 +106,24 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @var string Name of the Zip file |
| 108 | 108 | */ |
| 109 | - public $_zipname=''; |
|
| 109 | + public $_zipname = ''; |
|
| 110 | 110 | |
| 111 | 111 | /** |
| 112 | 112 | * File descriptor of the opened Zip file. |
| 113 | 113 | * |
| 114 | 114 | * @var int Internal zip file descriptor |
| 115 | 115 | */ |
| 116 | - public $_zip_fd=0; |
|
| 116 | + public $_zip_fd = 0; |
|
| 117 | 117 | |
| 118 | 118 | /** |
| 119 | 119 | * @var int last error code |
| 120 | 120 | */ |
| 121 | - public $_error_code=1; |
|
| 121 | + public $_error_code = 1; |
|
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | 124 | * @var string Last error description |
| 125 | 125 | */ |
| 126 | - public $_error_string=''; |
|
| 126 | + public $_error_string = ''; |
|
| 127 | 127 | |
| 128 | 128 | // {{{ constructor |
| 129 | 129 | /** |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | * @return mixed An array of file description on success, |
| 182 | 182 | * an error code on error |
| 183 | 183 | */ |
| 184 | - public function create($p_filelist, $p_params=0) |
|
| 184 | + public function create($p_filelist, $p_params = 0) |
|
| 185 | 185 | { |
| 186 | 186 | $this->_errorReset(); |
| 187 | 187 | |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * @return mixed An array of file description on success, |
| 253 | 253 | * 0 on an unrecoverable failure, an error code is logged. |
| 254 | 254 | */ |
| 255 | - public function add($p_filelist, $p_params=0) |
|
| 255 | + public function add($p_filelist, $p_params = 0) |
|
| 256 | 256 | { |
| 257 | 257 | $this->_errorReset(); |
| 258 | 258 | |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | * @return mixed An array of file description on success, |
| 404 | 404 | * 0 on an unrecoverable failure, an error code is logged. |
| 405 | 405 | */ |
| 406 | - public function extract($p_params=0) |
|
| 406 | + public function extract($p_params = 0) |
|
| 407 | 407 | { |
| 408 | 408 | $this->_errorReset(); |
| 409 | 409 | |
@@ -675,7 +675,7 @@ discard block |
||
| 675 | 675 | * @param boolean $p_with_code If true, gives the name and the int value. |
| 676 | 676 | * @return string The error name. |
| 677 | 677 | */ |
| 678 | - public function errorName($p_with_code=false) |
|
| 678 | + public function errorName($p_with_code = false) |
|
| 679 | 679 | { |
| 680 | 680 | $v_const_list = get_defined_constants(); |
| 681 | 681 | |
@@ -689,8 +689,8 @@ discard block |
||
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | // ----- Search the name form the code value |
| 692 | - $v_key=array_search($this->_error_code, $v_error_list, true); |
|
| 693 | - if ($v_key!=false) { |
|
| 692 | + $v_key = array_search($this->_error_code, $v_error_list, true); |
|
| 693 | + if ($v_key != false) { |
|
| 694 | 694 | $v_value = $v_key; |
| 695 | 695 | } else { |
| 696 | 696 | $v_value = 'NoName'; |
@@ -715,7 +715,7 @@ discard block |
||
| 715 | 715 | * and the error code. |
| 716 | 716 | * @return string The error description. |
| 717 | 717 | */ |
| 718 | - public function errorInfo($p_full=false) |
|
| 718 | + public function errorInfo($p_full = false) |
|
| 719 | 719 | { |
| 720 | 720 | if ($p_full) { |
| 721 | 721 | return($this->errorName(true)." : ".$this->_error_string); |
@@ -753,7 +753,7 @@ discard block |
||
| 753 | 753 | * |
| 754 | 754 | * @param integer $p_level |
| 755 | 755 | */ |
| 756 | - public function _checkFormat($p_level=0) |
|
| 756 | + public function _checkFormat($p_level = 0) |
|
| 757 | 757 | { |
| 758 | 758 | $v_result = true; |
| 759 | 759 | |
@@ -804,7 +804,7 @@ discard block |
||
| 804 | 804 | */ |
| 805 | 805 | public function _create($p_list, &$p_result_list, &$p_params) |
| 806 | 806 | { |
| 807 | - $v_result=1; |
|
| 807 | + $v_result = 1; |
|
| 808 | 808 | $v_list_detail = array(); |
| 809 | 809 | |
| 810 | 810 | $p_add_dir = $p_params['add_path']; |
@@ -842,7 +842,7 @@ discard block |
||
| 842 | 842 | */ |
| 843 | 843 | public function _add($p_list, &$p_result_list, &$p_params) |
| 844 | 844 | { |
| 845 | - $v_result=1; |
|
| 845 | + $v_result = 1; |
|
| 846 | 846 | $v_list_detail = array(); |
| 847 | 847 | |
| 848 | 848 | $p_add_dir = $p_params['add_path']; |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | // ----- Open the zip file |
| 859 | - if (($v_result=$this->_openFd('rb')) != 1) { |
|
| 859 | + if (($v_result = $this->_openFd('rb')) != 1) { |
|
| 860 | 860 | return $v_result; |
| 861 | 861 | } |
| 862 | 862 | |
@@ -929,10 +929,10 @@ discard block |
||
| 929 | 929 | } |
| 930 | 930 | |
| 931 | 931 | // ----- Create the Central Dir files header |
| 932 | - for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++) { |
|
| 932 | + for ($i = 0, $v_count = 0; $i < sizeof($v_header_list); $i++) { |
|
| 933 | 933 | // ----- Create the file header |
| 934 | 934 | if ($v_header_list[$i]['status'] == 'ok') { |
| 935 | - if (($v_result=$this->_writeCentralFileHeader($v_header_list[$i]))!=1) { |
|
| 935 | + if (($v_result = $this->_writeCentralFileHeader($v_header_list[$i])) != 1) { |
|
| 936 | 936 | fclose($v_zip_temp_fd); |
| 937 | 937 | $this->_closeFd(); |
| 938 | 938 | @unlink($v_zip_temp_name); |
@@ -951,7 +951,7 @@ discard block |
||
| 951 | 951 | $v_comment = ''; |
| 952 | 952 | |
| 953 | 953 | // ----- Calculate the size of the central header |
| 954 | - $v_size = @ftell($this->_zip_fd)-$v_offset; |
|
| 954 | + $v_size = @ftell($this->_zip_fd) - $v_offset; |
|
| 955 | 955 | |
| 956 | 956 | // ----- Create the central dir footer |
| 957 | 957 | if (($v_result = $this->_writeCentralHeader($v_count |
@@ -1003,7 +1003,7 @@ discard block |
||
| 1003 | 1003 | */ |
| 1004 | 1004 | public function _openFd($p_mode) |
| 1005 | 1005 | { |
| 1006 | - $v_result=1; |
|
| 1006 | + $v_result = 1; |
|
| 1007 | 1007 | |
| 1008 | 1008 | // ----- Look if already open |
| 1009 | 1009 | if ($this->_zip_fd != 0) { |
@@ -1038,7 +1038,7 @@ discard block |
||
| 1038 | 1038 | */ |
| 1039 | 1039 | public function _closeFd() |
| 1040 | 1040 | { |
| 1041 | - $v_result=1; |
|
| 1041 | + $v_result = 1; |
|
| 1042 | 1042 | |
| 1043 | 1043 | if ($this->_zip_fd != 0) { |
| 1044 | 1044 | @fclose($this->_zip_fd); |
@@ -1072,7 +1072,7 @@ discard block |
||
| 1072 | 1072 | public function _addList($p_list, &$p_result_list, |
| 1073 | 1073 | $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params) |
| 1074 | 1074 | { |
| 1075 | - $v_result=1; |
|
| 1075 | + $v_result = 1; |
|
| 1076 | 1076 | |
| 1077 | 1077 | // ----- Add the files |
| 1078 | 1078 | $v_header_list = array(); |
@@ -1086,7 +1086,7 @@ discard block |
||
| 1086 | 1086 | $v_offset = @ftell($this->_zip_fd); |
| 1087 | 1087 | |
| 1088 | 1088 | // ----- Create the Central Dir files header |
| 1089 | - for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++) { |
|
| 1089 | + for ($i = 0, $v_count = 0; $i < sizeof($v_header_list); $i++) { |
|
| 1090 | 1090 | // ----- Create the file header |
| 1091 | 1091 | if ($v_header_list[$i]['status'] == 'ok') { |
| 1092 | 1092 | if (($v_result = $this->_writeCentralFileHeader($v_header_list[$i])) != 1) { |
@@ -1103,7 +1103,7 @@ discard block |
||
| 1103 | 1103 | $v_comment = ''; |
| 1104 | 1104 | |
| 1105 | 1105 | // ----- Calculate the size of the central header |
| 1106 | - $v_size = @ftell($this->_zip_fd)-$v_offset; |
|
| 1106 | + $v_size = @ftell($this->_zip_fd) - $v_offset; |
|
| 1107 | 1107 | |
| 1108 | 1108 | // ----- Create the central dir footer |
| 1109 | 1109 | if (($v_result = $this->_writeCentralHeader($v_count, $v_size, $v_offset, |
@@ -1143,14 +1143,14 @@ discard block |
||
| 1143 | 1143 | $p_add_dir, $p_remove_dir, $p_remove_all_dir, |
| 1144 | 1144 | &$p_params) |
| 1145 | 1145 | { |
| 1146 | - $v_result=1; |
|
| 1146 | + $v_result = 1; |
|
| 1147 | 1147 | $v_header = array(); |
| 1148 | 1148 | |
| 1149 | 1149 | // ----- Recuperate the current number of elt in list |
| 1150 | 1150 | $v_nb = sizeof($p_result_list); |
| 1151 | 1151 | |
| 1152 | 1152 | // ----- Loop on the files |
| 1153 | - for ($j=0; ($j<count($p_list)) && ($v_result==1); $j++) { |
|
| 1153 | + for ($j = 0; ($j < count($p_list)) && ($v_result == 1); $j++) { |
|
| 1154 | 1154 | // ----- Recuperate the filename |
| 1155 | 1155 | $p_filename = $this->_tool_TranslateWinPath($p_list[$j], false); |
| 1156 | 1156 | |
@@ -1244,7 +1244,7 @@ discard block |
||
| 1244 | 1244 | */ |
| 1245 | 1245 | public function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params) |
| 1246 | 1246 | { |
| 1247 | - $v_result=1; |
|
| 1247 | + $v_result = 1; |
|
| 1248 | 1248 | |
| 1249 | 1249 | if ($p_filename == "") { |
| 1250 | 1250 | // ----- Error log |
@@ -1328,7 +1328,7 @@ discard block |
||
| 1328 | 1328 | $p_header['comment_len'] = 0; |
| 1329 | 1329 | $p_header['disk'] = 0; |
| 1330 | 1330 | $p_header['internal'] = 0; |
| 1331 | - $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010); |
|
| 1331 | + $p_header['external'] = (is_file($p_filename) ? 0xFE49FFE0 : 0x41FF0010); |
|
| 1332 | 1332 | $p_header['offset'] = 0; |
| 1333 | 1333 | $p_header['filename'] = $p_filename; |
| 1334 | 1334 | $p_header['stored_filename'] = $v_stored_filename; |
@@ -1424,7 +1424,7 @@ discard block |
||
| 1424 | 1424 | $p_header['filename'] .= '/'; |
| 1425 | 1425 | $p_header['filename_len']++; |
| 1426 | 1426 | $p_header['size'] = 0; |
| 1427 | - $p_header['external'] = 0x41FF0010; // Value for a folder : to be checked |
|
| 1427 | + $p_header['external'] = 0x41FF0010; // Value for a folder : to be checked |
|
| 1428 | 1428 | |
| 1429 | 1429 | // ----- Call the header generation |
| 1430 | 1430 | if (($v_result = $this->_writeFileHeader($p_header)) != 1) { |
@@ -1473,7 +1473,7 @@ discard block |
||
| 1473 | 1473 | */ |
| 1474 | 1474 | public function _writeFileHeader(&$p_header) |
| 1475 | 1475 | { |
| 1476 | - $v_result=1; |
|
| 1476 | + $v_result = 1; |
|
| 1477 | 1477 | |
| 1478 | 1478 | // TBC |
| 1479 | 1479 | //for(reset($p_header); $key = key($p_header); next($p_header)) { |
@@ -1484,8 +1484,8 @@ discard block |
||
| 1484 | 1484 | |
| 1485 | 1485 | // ----- Transform UNIX mtime to DOS format mdate/mtime |
| 1486 | 1486 | $v_date = getdate($p_header['mtime']); |
| 1487 | - $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 1488 | - $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 1487 | + $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2; |
|
| 1488 | + $v_mdate = (($v_date['year'] - 1980) << 9) + ($v_date['mon'] << 5) + $v_date['mday']; |
|
| 1489 | 1489 | |
| 1490 | 1490 | // ----- Packed data |
| 1491 | 1491 | $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50, $p_header['version'], $p_header['flag'], |
@@ -1523,7 +1523,7 @@ discard block |
||
| 1523 | 1523 | */ |
| 1524 | 1524 | public function _writeCentralFileHeader(&$p_header) |
| 1525 | 1525 | { |
| 1526 | - $v_result=1; |
|
| 1526 | + $v_result = 1; |
|
| 1527 | 1527 | |
| 1528 | 1528 | // TBC |
| 1529 | 1529 | //for(reset($p_header); $key = key($p_header); next($p_header)) { |
@@ -1531,8 +1531,8 @@ discard block |
||
| 1531 | 1531 | |
| 1532 | 1532 | // ----- Transform UNIX mtime to DOS format mdate/mtime |
| 1533 | 1533 | $v_date = getdate($p_header['mtime']); |
| 1534 | - $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2; |
|
| 1535 | - $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday']; |
|
| 1534 | + $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2; |
|
| 1535 | + $v_mdate = (($v_date['year'] - 1980) << 9) + ($v_date['mon'] << 5) + $v_date['mday']; |
|
| 1536 | 1536 | |
| 1537 | 1537 | // ----- Packed data |
| 1538 | 1538 | $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50, $p_header['version'], $p_header['version_extracted'], |
@@ -1574,7 +1574,7 @@ discard block |
||
| 1574 | 1574 | */ |
| 1575 | 1575 | public function _writeCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment) |
| 1576 | 1576 | { |
| 1577 | - $v_result=1; |
|
| 1577 | + $v_result = 1; |
|
| 1578 | 1578 | |
| 1579 | 1579 | // ----- Packed data |
| 1580 | 1580 | $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries, $p_nb_entries, $p_size, $p_offset, strlen($p_comment)); |
@@ -1606,7 +1606,7 @@ discard block |
||
| 1606 | 1606 | */ |
| 1607 | 1607 | public function _list(&$p_list) |
| 1608 | 1608 | { |
| 1609 | - $v_result=1; |
|
| 1609 | + $v_result = 1; |
|
| 1610 | 1610 | |
| 1611 | 1611 | // ----- Open the zip file |
| 1612 | 1612 | if (($this->_zip_fd = @fopen($this->_zipname, 'rb')) == 0) { |
@@ -1634,7 +1634,7 @@ discard block |
||
| 1634 | 1634 | } |
| 1635 | 1635 | |
| 1636 | 1636 | // ----- Read each entry |
| 1637 | - for ($i=0; $i<$v_central_dir['entries']; $i++) { |
|
| 1637 | + for ($i = 0; $i < $v_central_dir['entries']; $i++) { |
|
| 1638 | 1638 | // ----- Read the file header |
| 1639 | 1639 | if (($v_result = $this->_readCentralFileHeader($v_header)) != 1) { |
| 1640 | 1640 | return $v_result; |
@@ -1680,7 +1680,7 @@ discard block |
||
| 1680 | 1680 | */ |
| 1681 | 1681 | public function _convertHeader2FileInfo($p_header, &$p_info) |
| 1682 | 1682 | { |
| 1683 | - $v_result=1; |
|
| 1683 | + $v_result = 1; |
|
| 1684 | 1684 | |
| 1685 | 1685 | // ----- Get the interesting attributes |
| 1686 | 1686 | $p_info['filename'] = $p_header['filename']; |
@@ -1689,7 +1689,7 @@ discard block |
||
| 1689 | 1689 | $p_info['compressed_size'] = $p_header['compressed_size']; |
| 1690 | 1690 | $p_info['mtime'] = $p_header['mtime']; |
| 1691 | 1691 | $p_info['comment'] = $p_header['comment']; |
| 1692 | - $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010); |
|
| 1692 | + $p_info['folder'] = (($p_header['external'] & 0x00000010) == 0x00000010); |
|
| 1693 | 1693 | $p_info['index'] = $p_header['index']; |
| 1694 | 1694 | $p_info['status'] = $p_header['status']; |
| 1695 | 1695 | |
@@ -1722,7 +1722,7 @@ discard block |
||
| 1722 | 1722 | */ |
| 1723 | 1723 | public function _extractByRule(&$p_file_list, &$p_params) |
| 1724 | 1724 | { |
| 1725 | - $v_result=1; |
|
| 1725 | + $v_result = 1; |
|
| 1726 | 1726 | |
| 1727 | 1727 | $p_path = $p_params['add_path']; |
| 1728 | 1728 | $p_remove_path = $p_params['remove_path']; |
@@ -1731,7 +1731,7 @@ discard block |
||
| 1731 | 1731 | // ----- Check the path |
| 1732 | 1732 | if (($p_path == "") |
| 1733 | 1733 | || ((substr($p_path, 0, 1) != "/") |
| 1734 | - && (substr($p_path, 0, 3) != "../") && (substr($p_path, 1, 2)!=":/"))) { |
|
| 1734 | + && (substr($p_path, 0, 3) != "../") && (substr($p_path, 1, 2) != ":/"))) { |
|
| 1735 | 1735 | $p_path = "./".$p_path; |
| 1736 | 1736 | } |
| 1737 | 1737 | |
@@ -1739,7 +1739,7 @@ discard block |
||
| 1739 | 1739 | if (($p_path != "./") && ($p_path != "/")) { |
| 1740 | 1740 | // ----- Look for the path end '/' |
| 1741 | 1741 | while (substr($p_path, -1) == "/") { |
| 1742 | - $p_path = substr($p_path, 0, strlen($p_path)-1); |
|
| 1742 | + $p_path = substr($p_path, 0, strlen($p_path) - 1); |
|
| 1743 | 1743 | } |
| 1744 | 1744 | } |
| 1745 | 1745 | |
@@ -1768,7 +1768,7 @@ discard block |
||
| 1768 | 1768 | |
| 1769 | 1769 | // ----- Read each entry |
| 1770 | 1770 | $j_start = 0; |
| 1771 | - for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) { |
|
| 1771 | + for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++) { |
|
| 1772 | 1772 | // ----- Read next Central dir entry |
| 1773 | 1773 | @rewind($this->_zip_fd); |
| 1774 | 1774 | if (@fseek($this->_zip_fd, $v_pos_entry)) { |
@@ -1802,8 +1802,8 @@ discard block |
||
| 1802 | 1802 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_NAME] != 0)) { |
| 1803 | 1803 | |
| 1804 | 1804 | // ----- Look if the filename is in the list |
| 1805 | - for ($j=0; |
|
| 1806 | - ($j<sizeof($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])) |
|
| 1805 | + for ($j = 0; |
|
| 1806 | + ($j < sizeof($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])) |
|
| 1807 | 1807 | && (!$v_extract); |
| 1808 | 1808 | $j++) { |
| 1809 | 1809 | |
@@ -1844,15 +1844,15 @@ discard block |
||
| 1844 | 1844 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX] != 0)) { |
| 1845 | 1845 | |
| 1846 | 1846 | // ----- Look if the index is in the list |
| 1847 | - for ($j=$j_start; ($j<sizeof($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) && (!$v_extract); $j++) { |
|
| 1848 | - if (($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']) && ($i<=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) { |
|
| 1847 | + for ($j = $j_start; ($j < sizeof($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) && (!$v_extract); $j++) { |
|
| 1848 | + if (($i >= $p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']) && ($i <= $p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) { |
|
| 1849 | 1849 | $v_extract = true; |
| 1850 | 1850 | } |
| 1851 | - if ($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) { |
|
| 1852 | - $j_start = $j+1; |
|
| 1851 | + if ($i >= $p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) { |
|
| 1852 | + $j_start = $j + 1; |
|
| 1853 | 1853 | } |
| 1854 | 1854 | |
| 1855 | - if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']>$i) { |
|
| 1855 | + if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start'] > $i) { |
|
| 1856 | 1856 | break; |
| 1857 | 1857 | } |
| 1858 | 1858 | } |
@@ -1946,7 +1946,7 @@ discard block |
||
| 1946 | 1946 | */ |
| 1947 | 1947 | public function _extractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_params) |
| 1948 | 1948 | { |
| 1949 | - $v_result=1; |
|
| 1949 | + $v_result = 1; |
|
| 1950 | 1950 | |
| 1951 | 1951 | // ----- Read the file header |
| 1952 | 1952 | if (($v_result = $this->_readFileHeader($v_header)) != 1) { |
@@ -2052,7 +2052,7 @@ discard block |
||
| 2052 | 2052 | |
| 2053 | 2053 | // ----- Check the directory availability and create it if necessary |
| 2054 | 2054 | else { |
| 2055 | - if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) { |
|
| 2055 | + if ((($p_entry['external'] & 0x00000010) == 0x00000010) || (substr($p_entry['filename'], -1) == '/')) { |
|
| 2056 | 2056 | $v_dir_to_check = $p_entry['filename']; |
| 2057 | 2057 | } elseif (!strstr($p_entry['filename'], "/")) { |
| 2058 | 2058 | $v_dir_to_check = ""; |
@@ -2060,7 +2060,7 @@ discard block |
||
| 2060 | 2060 | $v_dir_to_check = dirname($p_entry['filename']); |
| 2061 | 2061 | } |
| 2062 | 2062 | |
| 2063 | - if (($v_result = $this->_dirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) { |
|
| 2063 | + if (($v_result = $this->_dirCheck($v_dir_to_check, (($p_entry['external'] & 0x00000010) == 0x00000010))) != 1) { |
|
| 2064 | 2064 | |
| 2065 | 2065 | // ----- Change the file status |
| 2066 | 2066 | $p_entry['status'] = "path_creation_fail"; |
@@ -2076,7 +2076,7 @@ discard block |
||
| 2076 | 2076 | if ($p_entry['status'] == 'ok') { |
| 2077 | 2077 | |
| 2078 | 2078 | // ----- Do the extraction (if not a folder) |
| 2079 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
|
| 2079 | + if (!(($p_entry['external'] & 0x00000010) == 0x00000010)) { |
|
| 2080 | 2080 | |
| 2081 | 2081 | // ----- Look for not compressed file |
| 2082 | 2082 | if ($p_entry['compressed_size'] == $p_entry['size']) { |
@@ -2181,7 +2181,7 @@ discard block |
||
| 2181 | 2181 | */ |
| 2182 | 2182 | public function _extractFileAsString(&$p_entry, &$p_string) |
| 2183 | 2183 | { |
| 2184 | - $v_result=1; |
|
| 2184 | + $v_result = 1; |
|
| 2185 | 2185 | |
| 2186 | 2186 | // ----- Read the file header |
| 2187 | 2187 | $v_header = array(); |
@@ -2197,7 +2197,7 @@ discard block |
||
| 2197 | 2197 | // ----- Trace |
| 2198 | 2198 | |
| 2199 | 2199 | // ----- Do the extraction (if not a folder) |
| 2200 | - if (!(($p_entry['external']&0x00000010)==0x00000010)) { |
|
| 2200 | + if (!(($p_entry['external'] & 0x00000010) == 0x00000010)) { |
|
| 2201 | 2201 | // ----- Look for not compressed file |
| 2202 | 2202 | if ($p_entry['compressed_size'] == $p_entry['size']) { |
| 2203 | 2203 | // ----- Trace |
@@ -2238,7 +2238,7 @@ discard block |
||
| 2238 | 2238 | */ |
| 2239 | 2239 | public function _readFileHeader(&$p_header) |
| 2240 | 2240 | { |
| 2241 | - $v_result=1; |
|
| 2241 | + $v_result = 1; |
|
| 2242 | 2242 | |
| 2243 | 2243 | // ----- Read the 4 bytes signature |
| 2244 | 2244 | $v_binary_data = @fread($this->_zip_fd, 4); |
@@ -2296,7 +2296,7 @@ discard block |
||
| 2296 | 2296 | // ----- Extract time |
| 2297 | 2297 | $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
| 2298 | 2298 | $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
| 2299 | - $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 2299 | + $v_seconde = ($p_header['mtime'] & 0x001F) * 2; |
|
| 2300 | 2300 | |
| 2301 | 2301 | // ----- Extract date |
| 2302 | 2302 | $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
@@ -2340,7 +2340,7 @@ discard block |
||
| 2340 | 2340 | */ |
| 2341 | 2341 | public function _readCentralFileHeader(&$p_header) |
| 2342 | 2342 | { |
| 2343 | - $v_result=1; |
|
| 2343 | + $v_result = 1; |
|
| 2344 | 2344 | |
| 2345 | 2345 | // ----- Read the 4 bytes signature |
| 2346 | 2346 | $v_binary_data = @fread($this->_zip_fd, 4); |
@@ -2402,7 +2402,7 @@ discard block |
||
| 2402 | 2402 | // ----- Extract time |
| 2403 | 2403 | $v_hour = ($p_header['mtime'] & 0xF800) >> 11; |
| 2404 | 2404 | $v_minute = ($p_header['mtime'] & 0x07E0) >> 5; |
| 2405 | - $v_seconde = ($p_header['mtime'] & 0x001F)*2; |
|
| 2405 | + $v_seconde = ($p_header['mtime'] & 0x001F) * 2; |
|
| 2406 | 2406 | |
| 2407 | 2407 | // ----- Extract date |
| 2408 | 2408 | $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980; |
@@ -2446,7 +2446,7 @@ discard block |
||
| 2446 | 2446 | */ |
| 2447 | 2447 | public function _readEndCentralDir(&$p_central_dir) |
| 2448 | 2448 | { |
| 2449 | - $v_result=1; |
|
| 2449 | + $v_result = 1; |
|
| 2450 | 2450 | |
| 2451 | 2451 | // ----- Go to the end of the zip file |
| 2452 | 2452 | $v_size = filesize($this->_zipname); |
@@ -2463,8 +2463,8 @@ discard block |
||
| 2463 | 2463 | // in this case the end of central dir is at 22 bytes of the file end |
| 2464 | 2464 | $v_found = 0; |
| 2465 | 2465 | if ($v_size > 26) { |
| 2466 | - @fseek($this->_zip_fd, $v_size-22); |
|
| 2467 | - if (($v_pos = @ftell($this->_zip_fd)) != ($v_size-22)) { |
|
| 2466 | + @fseek($this->_zip_fd, $v_size - 22); |
|
| 2467 | + if (($v_pos = @ftell($this->_zip_fd)) != ($v_size - 22)) { |
|
| 2468 | 2468 | $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, |
| 2469 | 2469 | 'Unable to seek back to the middle of the archive \'' |
| 2470 | 2470 | .$this->_zipname.'\''); |
@@ -2489,8 +2489,8 @@ discard block |
||
| 2489 | 2489 | if ($v_maximum_size > $v_size) { |
| 2490 | 2490 | $v_maximum_size = $v_size; |
| 2491 | 2491 | } |
| 2492 | - @fseek($this->_zip_fd, $v_size-$v_maximum_size); |
|
| 2493 | - if (@ftell($this->_zip_fd) != ($v_size-$v_maximum_size)) { |
|
| 2492 | + @fseek($this->_zip_fd, $v_size - $v_maximum_size); |
|
| 2493 | + if (@ftell($this->_zip_fd) != ($v_size - $v_maximum_size)) { |
|
| 2494 | 2494 | $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, |
| 2495 | 2495 | 'Unable to seek back to the middle of the archive \'' |
| 2496 | 2496 | .$this->_zipname.'\''); |
@@ -2578,11 +2578,11 @@ discard block |
||
| 2578 | 2578 | */ |
| 2579 | 2579 | public function _deleteByRule(&$p_result_list, &$p_params) |
| 2580 | 2580 | { |
| 2581 | - $v_result=1; |
|
| 2581 | + $v_result = 1; |
|
| 2582 | 2582 | $v_list_detail = array(); |
| 2583 | 2583 | |
| 2584 | 2584 | // ----- Open the zip file |
| 2585 | - if (($v_result=$this->_openFd('rb')) != 1) { |
|
| 2585 | + if (($v_result = $this->_openFd('rb')) != 1) { |
|
| 2586 | 2586 | // ----- Return |
| 2587 | 2587 | return $v_result; |
| 2588 | 2588 | } |
@@ -2613,7 +2613,7 @@ discard block |
||
| 2613 | 2613 | // ----- Read each entry |
| 2614 | 2614 | $v_header_list = array(); |
| 2615 | 2615 | $j_start = 0; |
| 2616 | - for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) { |
|
| 2616 | + for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++) { |
|
| 2617 | 2617 | |
| 2618 | 2618 | // ----- Read the file header |
| 2619 | 2619 | $v_header_list[$v_nb_extracted] = array(); |
@@ -2637,8 +2637,8 @@ discard block |
||
| 2637 | 2637 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_NAME] != 0)) { |
| 2638 | 2638 | |
| 2639 | 2639 | // ----- Look if the filename is in the list |
| 2640 | - for ($j=0; |
|
| 2641 | - ($j<sizeof($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])) |
|
| 2640 | + for ($j = 0; |
|
| 2641 | + ($j < sizeof($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])) |
|
| 2642 | 2642 | && (!$v_found); |
| 2643 | 2643 | $j++) { |
| 2644 | 2644 | |
@@ -2649,7 +2649,7 @@ discard block |
||
| 2649 | 2649 | if ((strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) |
| 2650 | 2650 | && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) { |
| 2651 | 2651 | $v_found = true; |
| 2652 | - } elseif ((($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */ |
|
| 2652 | + } elseif ((($v_header_list[$v_nb_extracted]['external'] & 0x00000010) == 0x00000010) /* Indicates a folder */ |
|
| 2653 | 2653 | && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) { |
| 2654 | 2654 | $v_found = true; |
| 2655 | 2655 | } |
@@ -2685,19 +2685,19 @@ discard block |
||
| 2685 | 2685 | && ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX] != 0)) { |
| 2686 | 2686 | |
| 2687 | 2687 | // ----- Look if the index is in the list |
| 2688 | - for ($j=$j_start; |
|
| 2689 | - ($j<sizeof($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) |
|
| 2688 | + for ($j = $j_start; |
|
| 2689 | + ($j < sizeof($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) |
|
| 2690 | 2690 | && (!$v_found); |
| 2691 | 2691 | $j++) { |
| 2692 | - if (($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']) |
|
| 2693 | - && ($i<=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) { |
|
| 2692 | + if (($i >= $p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']) |
|
| 2693 | + && ($i <= $p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) { |
|
| 2694 | 2694 | $v_found = true; |
| 2695 | 2695 | } |
| 2696 | - if ($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) { |
|
| 2697 | - $j_start = $j+1; |
|
| 2696 | + if ($i >= $p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) { |
|
| 2697 | + $j_start = $j + 1; |
|
| 2698 | 2698 | } |
| 2699 | 2699 | |
| 2700 | - if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']>$i) { |
|
| 2700 | + if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start'] > $i) { |
|
| 2701 | 2701 | break; |
| 2702 | 2702 | } |
| 2703 | 2703 | } |
@@ -2730,11 +2730,11 @@ discard block |
||
| 2730 | 2730 | } |
| 2731 | 2731 | |
| 2732 | 2732 | // ----- Look which file need to be kept |
| 2733 | - for ($i=0; $i<sizeof($v_header_list); $i++) { |
|
| 2733 | + for ($i = 0; $i < sizeof($v_header_list); $i++) { |
|
| 2734 | 2734 | |
| 2735 | 2735 | // ----- Calculate the position of the header |
| 2736 | 2736 | @rewind($this->_zip_fd); |
| 2737 | - if (@fseek($this->_zip_fd, $v_header_list[$i]['offset'])) { |
|
| 2737 | + if (@fseek($this->_zip_fd, $v_header_list[$i]['offset'])) { |
|
| 2738 | 2738 | // ----- Clean |
| 2739 | 2739 | $this->_closeFd(); |
| 2740 | 2740 | $v_temp_zip->_closeFd(); |
@@ -2784,9 +2784,9 @@ discard block |
||
| 2784 | 2784 | $v_offset = @ftell($v_temp_zip->_zip_fd); |
| 2785 | 2785 | |
| 2786 | 2786 | // ----- Re-Create the Central Dir files header |
| 2787 | - for ($i=0; $i<sizeof($v_header_list); $i++) { |
|
| 2787 | + for ($i = 0; $i < sizeof($v_header_list); $i++) { |
|
| 2788 | 2788 | // ----- Create the file header |
| 2789 | - $v_result=$v_temp_zip->_writeCentralFileHeader($v_header_list[$i]); |
|
| 2789 | + $v_result = $v_temp_zip->_writeCentralFileHeader($v_header_list[$i]); |
|
| 2790 | 2790 | if ($v_result != 1) { |
| 2791 | 2791 | // ----- Clean |
| 2792 | 2792 | $v_temp_zip->_closeFd(); |
@@ -2806,7 +2806,7 @@ discard block |
||
| 2806 | 2806 | $v_comment = ''; |
| 2807 | 2807 | |
| 2808 | 2808 | // ----- Calculate the size of the central header |
| 2809 | - $v_size = @ftell($v_temp_zip->_zip_fd)-$v_offset; |
|
| 2809 | + $v_size = @ftell($v_temp_zip->_zip_fd) - $v_offset; |
|
| 2810 | 2810 | |
| 2811 | 2811 | // ----- Create the central dir footer |
| 2812 | 2812 | $v_result = $v_temp_zip->_writeCentralHeader(sizeof($v_header_list), |
@@ -2862,13 +2862,13 @@ discard block |
||
| 2862 | 2862 | * |
| 2863 | 2863 | * @param [type] $p_is_dir |
| 2864 | 2864 | */ |
| 2865 | - public function _dirCheck($p_dir, $p_is_dir=false) |
|
| 2865 | + public function _dirCheck($p_dir, $p_is_dir = false) |
|
| 2866 | 2866 | { |
| 2867 | 2867 | $v_result = 1; |
| 2868 | 2868 | |
| 2869 | 2869 | // ----- Remove the final '/' |
| 2870 | - if (($p_is_dir) && (substr($p_dir, -1)=='/')) { |
|
| 2871 | - $p_dir = substr($p_dir, 0, strlen($p_dir)-1); |
|
| 2870 | + if (($p_is_dir) && (substr($p_dir, -1) == '/')) { |
|
| 2871 | + $p_dir = substr($p_dir, 0, strlen($p_dir) - 1); |
|
| 2872 | 2872 | } |
| 2873 | 2873 | |
| 2874 | 2874 | // ----- Check the directory availability |
@@ -2916,7 +2916,7 @@ discard block |
||
| 2916 | 2916 | */ |
| 2917 | 2917 | public function _merge(&$p_archive_to_add) |
| 2918 | 2918 | { |
| 2919 | - $v_result=1; |
|
| 2919 | + $v_result = 1; |
|
| 2920 | 2920 | |
| 2921 | 2921 | // ----- Look if the archive_to_add exists |
| 2922 | 2922 | if (!is_file($p_archive_to_add->_zipname)) { |
@@ -2933,7 +2933,7 @@ discard block |
||
| 2933 | 2933 | } |
| 2934 | 2934 | |
| 2935 | 2935 | // ----- Open the zip file |
| 2936 | - if (($v_result=$this->_openFd('rb')) != 1) { |
|
| 2936 | + if (($v_result = $this->_openFd('rb')) != 1) { |
|
| 2937 | 2937 | return $v_result; |
| 2938 | 2938 | } |
| 2939 | 2939 | |
@@ -2948,7 +2948,7 @@ discard block |
||
| 2948 | 2948 | @rewind($this->_zip_fd); |
| 2949 | 2949 | |
| 2950 | 2950 | // ----- Open the archive_to_add file |
| 2951 | - if (($v_result=$p_archive_to_add->_openFd('rb')) != 1) { |
|
| 2951 | + if (($v_result = $p_archive_to_add->_openFd('rb')) != 1) { |
|
| 2952 | 2952 | $this->_closeFd(); |
| 2953 | 2953 | return $v_result; |
| 2954 | 2954 | } |
@@ -3028,7 +3028,7 @@ discard block |
||
| 3028 | 3028 | $v_comment = ''; |
| 3029 | 3029 | |
| 3030 | 3030 | // ----- Calculate the size of the (new) central header |
| 3031 | - $v_size = @ftell($v_zip_temp_fd)-$v_offset; |
|
| 3031 | + $v_size = @ftell($v_zip_temp_fd) - $v_offset; |
|
| 3032 | 3032 | |
| 3033 | 3033 | // ----- Swap the file descriptor |
| 3034 | 3034 | // Here is a trick : I swap the temporary fd with the zip fd, in order to use |
@@ -3094,7 +3094,7 @@ discard block |
||
| 3094 | 3094 | */ |
| 3095 | 3095 | public function _duplicate($p_archive_filename) |
| 3096 | 3096 | { |
| 3097 | - $v_result=1; |
|
| 3097 | + $v_result = 1; |
|
| 3098 | 3098 | |
| 3099 | 3099 | // ----- Look if the $p_archive_filename exists |
| 3100 | 3100 | if (!is_file($p_archive_filename)) { |
@@ -3107,7 +3107,7 @@ discard block |
||
| 3107 | 3107 | } |
| 3108 | 3108 | |
| 3109 | 3109 | // ----- Open the zip file |
| 3110 | - if (($v_result=$this->_openFd('wb')) != 1) { |
|
| 3110 | + if (($v_result = $this->_openFd('wb')) != 1) { |
|
| 3111 | 3111 | // ----- Return |
| 3112 | 3112 | return $v_result; |
| 3113 | 3113 | } |
@@ -3181,8 +3181,8 @@ discard block |
||
| 3181 | 3181 | // ----- Check specific parameters |
| 3182 | 3182 | $v_callback_list = array('callback_pre_add', 'callback_post_add', |
| 3183 | 3183 | 'callback_pre_extract', 'callback_post_extract'); |
| 3184 | - for ($i=0; $i<sizeof($v_callback_list); $i++) { |
|
| 3185 | - $v_key=$v_callback_list[$i]; |
|
| 3184 | + for ($i = 0; $i < sizeof($v_callback_list); $i++) { |
|
| 3185 | + $v_key = $v_callback_list[$i]; |
|
| 3186 | 3186 | if ((isset($p_params[$v_key])) && ($p_params[$v_key] != '')) { |
| 3187 | 3187 | if (!function_exists($p_params[$v_key])) { |
| 3188 | 3188 | $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAM_VALUE, |
@@ -3211,7 +3211,7 @@ discard block |
||
| 3211 | 3211 | * @param integer $p_error_code |
| 3212 | 3212 | * @param string $p_error_string |
| 3213 | 3213 | */ |
| 3214 | - public function _errorLog($p_error_code=0, $p_error_string='') |
|
| 3214 | + public function _errorLog($p_error_code = 0, $p_error_string = '') |
|
| 3215 | 3215 | { |
| 3216 | 3216 | $this->_error_code = $p_error_code; |
| 3217 | 3217 | $this->_error_string = $p_error_string; |
@@ -3258,7 +3258,7 @@ discard block |
||
| 3258 | 3258 | $v_list = explode("/", $p_dir); |
| 3259 | 3259 | |
| 3260 | 3260 | // ----- Study directories from last to first |
| 3261 | - for ($i=sizeof($v_list)-1; $i>=0; $i--) { |
|
| 3261 | + for ($i = sizeof($v_list) - 1; $i >= 0; $i--) { |
|
| 3262 | 3262 | // ----- Look for current path |
| 3263 | 3263 | if ($v_list[$i] == ".") { |
| 3264 | 3264 | // ----- Ignore this directory |
@@ -3266,11 +3266,11 @@ discard block |
||
| 3266 | 3266 | } elseif ($v_list[$i] == "..") { |
| 3267 | 3267 | // ----- Ignore it and ignore the $i-1 |
| 3268 | 3268 | $i--; |
| 3269 | - } elseif (($v_list[$i] == "") && ($i!=(sizeof($v_list)-1)) && ($i!=0)) { |
|
| 3269 | + } elseif (($v_list[$i] == "") && ($i != (sizeof($v_list) - 1)) && ($i != 0)) { |
|
| 3270 | 3270 | // ----- Ignore only the double '//' in path, |
| 3271 | 3271 | // but not the first and last '/' |
| 3272 | 3272 | } else { |
| 3273 | - $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:""); |
|
| 3273 | + $v_result = $v_list[$i].($i != (sizeof($v_list) - 1) ? "/".$v_result : ""); |
|
| 3274 | 3274 | } |
| 3275 | 3275 | } |
| 3276 | 3276 | } |
@@ -3380,11 +3380,11 @@ discard block |
||
| 3380 | 3380 | * |
| 3381 | 3381 | * @param integer $p_mode |
| 3382 | 3382 | */ |
| 3383 | - public function _tool_CopyBlock($p_src, $p_dest, $p_size, $p_mode=0) |
|
| 3383 | + public function _tool_CopyBlock($p_src, $p_dest, $p_size, $p_mode = 0) |
|
| 3384 | 3384 | { |
| 3385 | 3385 | $v_result = 1; |
| 3386 | 3386 | |
| 3387 | - if ($p_mode==0) { |
|
| 3387 | + if ($p_mode == 0) { |
|
| 3388 | 3388 | while ($p_size != 0) { |
| 3389 | 3389 | $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
| 3390 | 3390 | ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
@@ -3392,7 +3392,7 @@ discard block |
||
| 3392 | 3392 | @fwrite($p_dest, $v_buffer, $v_read_size); |
| 3393 | 3393 | $p_size -= $v_read_size; |
| 3394 | 3394 | } |
| 3395 | - } elseif ($p_mode==1) { |
|
| 3395 | + } elseif ($p_mode == 1) { |
|
| 3396 | 3396 | while ($p_size != 0) { |
| 3397 | 3397 | $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
| 3398 | 3398 | ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
@@ -3400,7 +3400,7 @@ discard block |
||
| 3400 | 3400 | @fwrite($p_dest, $v_buffer, $v_read_size); |
| 3401 | 3401 | $p_size -= $v_read_size; |
| 3402 | 3402 | } |
| 3403 | - } elseif ($p_mode==2) { |
|
| 3403 | + } elseif ($p_mode == 2) { |
|
| 3404 | 3404 | while ($p_size != 0) { |
| 3405 | 3405 | $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
| 3406 | 3406 | ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
@@ -3408,7 +3408,7 @@ discard block |
||
| 3408 | 3408 | @gzwrite($p_dest, $v_buffer, $v_read_size); |
| 3409 | 3409 | $p_size -= $v_read_size; |
| 3410 | 3410 | } |
| 3411 | - } elseif ($p_mode==3) { |
|
| 3411 | + } elseif ($p_mode == 3) { |
|
| 3412 | 3412 | while ($p_size != 0) { |
| 3413 | 3413 | $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE |
| 3414 | 3414 | ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE); |
@@ -3479,13 +3479,13 @@ discard block |
||
| 3479 | 3479 | * |
| 3480 | 3480 | * @param [type] $p_remove_disk_letter |
| 3481 | 3481 | */ |
| 3482 | - public function _tool_TranslateWinPath($p_path, $p_remove_disk_letter=true) |
|
| 3482 | + public function _tool_TranslateWinPath($p_path, $p_remove_disk_letter = true) |
|
| 3483 | 3483 | { |
| 3484 | 3484 | if (stristr(php_uname(), 'windows')) { |
| 3485 | 3485 | // ----- Look for potential disk letter |
| 3486 | 3486 | if (($p_remove_disk_letter) |
| 3487 | 3487 | && (($v_position = strpos($p_path, ':')) != false)) { |
| 3488 | - $p_path = substr($p_path, $v_position+1); |
|
| 3488 | + $p_path = substr($p_path, $v_position + 1); |
|
| 3489 | 3489 | } |
| 3490 | 3490 | // ----- Change potential windows directory separator |
| 3491 | 3491 | if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) { |