Completed
Push — master ( 3a6ebc...3a5a05 )
by Michael
04:13
created
xoops_trust_path/libs/altsys/class/D3LanguageManager.class.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -35,6 +35,9 @@
 block discarded – undo
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' ;
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -3,102 +3,102 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
xoops_trust_path/libs/altsys/class/d3utilities.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -261,6 +261,9 @@
 block discarded – undo
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" ;
Please login to merge, or discard this patch.
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -3,40 +3,40 @@  discard block
 block discarded – undo
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(__DIR__)) ;
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)) {
20
+        $db = XoopsDatabaseFactory::getDatabaseConnection();
21
+
22
+        $this->dirname = basename(dirname(__DIR__));
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 30
             $this->mid = (int)$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
 
@@ -46,22 +46,22 @@  discard block
 block discarded – undo
46 46
             case 'text' :
47 47
             case 'blob' :
48 48
                 $length = empty($col['length']) ? 65535 : (int)$col['length'];
49
-                return "`{$col['name']}`='".addslashes(xoops_substr($value, 0, $length))."'" ;
49
+                return "`{$col['name']}`='".addslashes(xoops_substr($value, 0, $length))."'";
50 50
             case 'char' :
51 51
             case 'varchar' :
52 52
             case 'string' :
53 53
                 $length = empty($col['length']) ? 255 : (int)$col['length'];
54
-                return "`{$col['name']}`='".addslashes(xoops_substr($value, 0, $length))."'" ;
54
+                return "`{$col['name']}`='".addslashes(xoops_substr($value, 0, $length))."'";
55 55
             case 'int' :
56 56
             case 'integer' :
57 57
                 $value = (int)$value;
58
-                if (! empty($col['max'])) {
59
-                    $value = min($value, (int)$col['max']) ;
58
+                if (!empty($col['max'])) {
59
+                    $value = min($value, (int)$col['max']);
60 60
                 }
61
-                if (! empty($col['min'])) {
62
-                    $value = max($value, (int)$col['min']) ;
61
+                if (!empty($col['min'])) {
62
+                    $value = max($value, (int)$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
 block discarded – undo
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
 block discarded – undo
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 = (int)$id;    // primary_key should be 'integer'
119
-            $set4sql = '' ;
118
+            $id = (int)$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 = (int)$id;    // primary_key should be 'integer'
151
-            $result = $db->query("SELECT * FROM $this->table WHERE $this->primary_key=$id") ;
150
+            $id = (int)$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 177
             $id = (int)$_GET['id'];
178
-            $rs = $db->query("SELECT * FROM $this->table WHERE $this->primary_key=$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 226
                     $size = empty($col['edit_size']) ? 32 : (int)$col['edit_size'];
227 227
                     $length = empty($col['length']) ? 255 : (int)$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 ;
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
 block discarded – undo
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 268
             $selected = $val == $current_value ? "selected='selected'" : '';
269
-            $ret .= "<option value='".htmlspecialchars($key, ENT_QUOTES)."' $selected>".htmlspecialchars($val, ENT_QUOTES)."</option>\n" ;
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
 }
Please login to merge, or discard this patch.
xoops_trust_path/libs/altsys/class/MyBlocksAdmin.class.php 3 patches
Doc Comments   +24 added lines patch added patch discarded remove patch
@@ -488,6 +488,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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) ;
Please login to merge, or discard this patch.
Switch Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -308,30 +308,30 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
1051 1051
     {
1052 1052
         $bid = (int)(@$_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
 }
Please login to merge, or discard this patch.
Spacing   +353 added lines, -353 removed lines patch added patch discarded remove patch
@@ -4,16 +4,16 @@  discard block
 block discarded – undo
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
 block discarded – undo
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 ,
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 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 ,
43
+        'H' => _MD_A_MYBLOCKSADMIN_CTYPE_HTML,
44
+        'T' => _MD_A_MYBLOCKSADMIN_CTYPE_NOSMILE,
45
+        'S' => _MD_A_MYBLOCKSADMIN_CTYPE_SMILE,
46 46
         'P' => _MD_A_MYBLOCKSADMIN_CTYPE_PHP
47
-    ) ;
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' ,
50
+        'C' => 'custom block',
51
+        'E' => 'cloned custom block',
52
+        'M' => 'module\'s block',
53
+        'D' => 'cloned module\'s block',
54 54
         'S' => 'system block'
55
-    ) ;
55
+    );
56 56
     }
57 57
 
58 58
 //HACK by domifara for php5.3+
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
@@ -87,52 +87,52 @@  discard block
 block discarded – undo
87 87
     if ($xoopsModule->getVar('dirname') == 'altsys') {
88 88
         // set target_module if specified by $_GET['dirname']
89 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) ;
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') . '&nbsp;' . 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').'&nbsp;'.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&amp;lib=altsys&amp;page=myblocksadmin', '_MI_ALTSYS_MENU_MYBLOCKSADMIN') ;
104
-            $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&amp;lib=altsys&amp;page=myblocksadmin&amp;dirname='.$this->target_dirname, $this->target_mname) ;
102
+            $breadcrumbsObj = & AltsysBreadcrumbs::getInstance();
103
+            $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&amp;lib=altsys&amp;page=myblocksadmin', '_MI_ALTSYS_MENU_MYBLOCKSADMIN');
104
+            $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&amp;lib=altsys&amp;page=myblocksadmin&amp;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&amp;lib=altsys&amp;page=myblocksadmin', '_MI_ALTSYS_MENU_MYBLOCKSADMIN') ;
113
-            $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&amp;lib=altsys&amp;page=myblocksadmin&amp;dirname='.$this->target_dirname, '_MI_ALTSYS_MENU_CUSTOMBLOCKS') ;
111
+            $breadcrumbsObj = & AltsysBreadcrumbs::getInstance();
112
+            $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&amp;lib=altsys&amp;page=myblocksadmin', '_MI_ALTSYS_MENU_MYBLOCKSADMIN');
113
+            $breadcrumbsObj->appendPath(XOOPS_URL.'/modules/altsys/admin/index.php?mode=admin&amp;lib=altsys&amp;page=myblocksadmin&amp;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') . '&nbsp;' . 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&amp;lib=altsys&amp;page=myblocksadmin', _MD_A_MYBLOCKSADMIN_BLOCKADMIN) ;
117
+        $this->target_mid = $xoopsModule->getVar('mid');
118
+        $this->target_mname = $xoopsModule->getVar('name').'&nbsp;'.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&amp;lib=altsys&amp;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
 block discarded – undo
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
 block discarded – undo
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
 
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
 //HACK by domifara
186 186
     if (defined('XOOPS_CUBE_LEGACY')) {
187 187
         $handler = xoops_gethandler('block');
188
-        $block =& $handler->create(false) ;
189
-        $block->load($bid) ;
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
 
@@ -203,16 +203,16 @@  discard block
 block discarded – undo
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 212
             $selected_mids[] = (int)$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
 
@@ -221,25 +221,25 @@  discard block
 block discarded – undo
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
 
@@ -252,41 +252,41 @@  discard block
 block discarded – undo
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 261
             $selected_gids[] = (int)$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 269
     $group_handler = xoops_gethandler('group');
270
-    $groups = $group_handler->getObjects() ;
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
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
     $sseln = $ssel0 = $ssel1 = $ssel2 = $ssel3 = $ssel4 = '';
302 302
     $scoln = $scol0 = $scol1 = $scol2 = $scol3 = $scol4 = 'unselected';
303 303
     $stextbox = 'unselected';
304
-    $value4extra_side = '' ;
304
+    $value4extra_side = '';
305 305
 
306 306
     if ($visible != 1) {
307 307
         $sseln = " checked='checked'";
@@ -311,27 +311,27 @@  discard block
 block discarded – undo
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 ;
332
+            $value4extra_side = $side;
333 333
             $stextbox = 'selected';
334
-            break ;
334
+            break;
335 335
     }
336 336
     }
337 337
 
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 				<div class='blockposition $scoln'>
362 362
 					<input type='radio' name='sides[$bid]' value='-1' class='blockposition' $sseln onclick='document.getElementById(\"extra_side_$bid\").value=-1;' />
363 363
 				</div>
364
-                <div style='float:"._GLOBAL_LEFT.";'>"._NONE . '</div>
364
+                <div style='float:"._GLOBAL_LEFT.";'>"._NONE.'</div>
365 365
     ';
366 366
 }
367 367
 
@@ -369,58 +369,58 @@  discard block
 block discarded – undo
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 401
             'bid' => (int)$block->getVar('bid'),
402
-            'name' => $block->getVar('name', 'n') ,
403
-            'title' => $block->getVar('title', 'n') ,
402
+            'name' => $block->getVar('name', 'n'),
403
+            'title' => $block->getVar('title', 'n'),
404 404
             'weight' => (int)$block->getVar('weight'),
405 405
             'bcachetime' => (int)$block->getVar('bcachetime'),
406 406
             'side' => (int)$block->getVar('side'),
407 407
             'visible' => (int)$block->getVar('visible'),
408
-            'can_edit' => $this->canEdit($block) ,
409
-            'can_delete' => $this->canDelete($block) ,
408
+            'can_edit' => $this->canEdit($block),
409
+            'can_delete' => $this->canDelete($block),
410 410
             'can_clone' => $this->canClone($block)
411
-        ) ;
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) ,
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 417
             'cell_group_perm' =>  $this->renderCell4BlockReadGroupPerm($block_data)
418
-        ) + $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
 block discarded – undo
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
 block discarded – undo
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 497
         $handler = xoops_gethandler('block');
498
-        $block =& $handler->create(false) ;
499
-        $block->load($bid) ;
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
 block discarded – undo
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,7 +542,7 @@  discard block
 block discarded – undo
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
 
@@ -550,14 +550,14 @@  discard block
 block discarded – undo
550 550
 public function updateBlockModuleLink($bid, $bmodules)
551 551
 {
552 552
     $bid = (int)$bid;
553
-    $table = $this->db->prefix('block_module_link') ;
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 558
         $mid = (int)$mid;
559
-        $sql = "INSERT INTO `$table` (`block_id`,`module_id`) VALUES ($bid,$mid)" ;
560
-        $this->db->query($sql) ;
559
+        $sql = "INSERT INTO `$table` (`block_id`,`module_id`) VALUES ($bid,$mid)";
560
+        $this->db->query($sql);
561 561
     }
562 562
 }
563 563
 
@@ -566,83 +566,83 @@  discard block
 block discarded – undo
566 566
 public function updateBlockReadGroupPerm($bid, $req_gids)
567 567
 {
568 568
     $bid = (int)$bid;
569
-    $table = $this->db->prefix('group_permission') ;
570
-    $req_gids = array_map('intval', $req_gids) ;
571
-    sort($req_gids) ;
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 591
         $gid = (int)$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) ;
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 619
         $bid = (int)$bid;
620
-        (method_exists('MyTextSanitizer', 'sGetInstance') and $myts =& MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance() ;
620
+        (method_exists('MyTextSanitizer', 'sGetInstance') and $myts = & MyTextSanitizer::sGetInstance()) || $myts = MyTextSanitizer::getInstance();
621 621
 
622 622
         if (@$_POST['extra_sides'][$bid] > 0) {
623 623
             $_POST['sides'][$bid] = (int)$_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 ,
634
+        'bid' => $bid,
635 635
             'side' => (int)(@$_POST['sides'][$bid]),
636 636
             'weight' => (int)(@$_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]) ,
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 641
             'bcachetime' => (int)(@$_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() ,
642
+        'bmodule' => is_array(@$_POST['bmodules'][$bid]) ? $_POST['bmodules'][$bid] : array(0),
643
+        'bgroup' => is_array(@$_POST['bgroups'][$bid]) ? $_POST['bgroups'][$bid] : array(),
644 644
         'options' => is_array(@$_POST['options'][$bid]) ? $_POST['options'][$bid] : array()
645
-    ) ;
645
+    );
646 646
     }
647 647
 
648 648
 
@@ -653,30 +653,30 @@  discard block
 block discarded – undo
653 653
 //HACK by domifara
654 654
     if (defined('XOOPS_CUBE_LEGACY')) {
655 655
         $handler = xoops_gethandler('block');
656
-        $block =& $handler->create(false) ;
657
-        $block->load($bid) ;
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 676
     $bid = (int)$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) ;
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)
@@ -687,24 +687,24 @@  discard block
 block discarded – undo
687 687
 //HACK by domifara
688 688
     if (defined('XOOPS_CUBE_LEGACY')) {
689 689
         $handler = xoops_gethandler('block');
690
-        $block =& $handler->create(false) ;
691
-        $block->load($bid) ;
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&amp;lib=altsys&amp;page=myblocksadmin&amp;dirname=$this->target_dirname&amp;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&amp;lib=altsys&amp;page=myblocksadmin&amp;dirname=$this->target_dirname&amp;bid=$bid", sprintf(_MD_A_MYBLOCKSADMIN_FMT_REMOVEBLOCK, $block->getVar('title')));
708 708
     }
709 709
 
710 710
 
@@ -712,30 +712,30 @@  discard block
 block discarded – undo
712 712
     {
713 713
         $bid = (int)$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 719
         $handler = xoops_gethandler('block');
720
-        $block =& $handler->create(false) ;
721
-        $block->load($bid) ;
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,46 +743,46 @@  discard block
 block discarded – undo
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=' . (int)$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='.(int)$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
 
@@ -796,36 +796,36 @@  discard block
 block discarded – undo
796 796
 //HACK by domifara
797 797
     if (defined('XOOPS_CUBE_LEGACY')) {
798 798
         $handler = xoops_gethandler('block');
799
-        $new_block =& $handler->create(false) ;
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
-            $sql = 'INSERT INTO ' . $this->db->prefix('group_permission') . " (gperm_groupid, gperm_itemid, gperm_modid, gperm_name) VALUES ($gid, $bid, 1, 'block_read')";
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
 
@@ -836,57 +836,57 @@  discard block
 block discarded – undo
836 836
 //HACK by domifara
837 837
     if (defined('XOOPS_CUBE_LEGACY')) {
838 838
         $handler = xoops_gethandler('block');
839
-        $block =& $handler->create(false) ;
840
-        $block->load($bid) ;
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 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' ;
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
 block discarded – undo
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') ,
898
+        'bid' => $bid,
899
+        'name' => $block->getVar('name', 'n'),
900
+        'title' => $block->getVar('title', 'n'),
901 901
             'weight' => (int)$block->getVar('weight'),
902 902
             'bcachetime' => (int)$block->getVar('bcachetime'),
903 903
             'side' => (int)$block->getVar('side'),
904 904
             'visible' => (int)$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') ,
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 911
         'ctype' => $block->getVar('c_type')
912
-    ) ;
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) ,
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 922
         'content_preview' => $this->previewContent($block_data)
923
-    ) + $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
 block discarded – undo
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()
@@ -965,16 +965,16 @@  discard block
 block discarded – undo
965 965
     {
966 966
         $bid = (int)$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,68 +982,68 @@  discard block
 block discarded – undo
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 ,
1003
+        'H' => _MD_A_MYBLOCKSADMIN_CTYPE_HTML,
1004
+        'S' => _MD_A_MYBLOCKSADMIN_CTYPE_SMILE,
1005
+        'N' => _MD_A_MYBLOCKSADMIN_CTYPE_NOSMILE,
1006 1006
         'P' => _MD_A_MYBLOCKSADMIN_CTYPE_PHP
1007
-    ) ;
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 = '' ;
1020
+        $msg = '';
1021 1021
         $bid = (int)(@$_GET['bid']);
1022
-        if (! empty($_POST['preview'])) {
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(__DIR__).'/include/mygroupperm.php' ;
1042
-            $msg = _MD_A_MYBLOCKSADMIN_PERMUPDATED ;
1041
+        include dirname(__DIR__).'/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
 
@@ -1052,22 +1052,22 @@  discard block
 block discarded – undo
1052 1052
         $bid = (int)(@$_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
 }
Please login to merge, or discard this patch.
xoops_trust_path/libs/altsys/class/MyBlocksAdminForX20S.class.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -69,6 +69,9 @@
 block discarded – undo
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']) ;
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-require_once __DIR__.'/MyBlocksAdmin.class.php' ;
3
+require_once __DIR__.'/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
 block discarded – undo
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 ,
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 29
         9 => _AM_CBBOTTOM
30
-    ) ;
30
+    );
31 31
     }
32 32
 
33 33
 //HACK by domifara for php5.3+
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
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
 }
@@ -50,19 +50,19 @@  discard block
 block discarded – undo
50 50
     return "
51 51
 	<table style='width:80px;'>
52 52
 		<tr>
53
-            <td rowspan='2'>".$this->renderRadio4BlockPosition(0, $block_data) . '</td>
54
-            <td>' . $this->renderRadio4BlockPosition(3, $block_data) . '</td>
55
-            <td>' . $this->renderRadio4BlockPosition(5, $block_data) . '</td>
56
-            <td>' . $this->renderRadio4BlockPosition(4, $block_data) . "</td>
57
-            <td rowspan='2'>".$this->renderRadio4BlockPosition(1, $block_data) . '</td>
53
+            <td rowspan='2'>".$this->renderRadio4BlockPosition(0, $block_data).'</td>
54
+            <td>' . $this->renderRadio4BlockPosition(3, $block_data).'</td>
55
+            <td>' . $this->renderRadio4BlockPosition(5, $block_data).'</td>
56
+            <td>' . $this->renderRadio4BlockPosition(4, $block_data)."</td>
57
+            <td rowspan='2'>".$this->renderRadio4BlockPosition(1, $block_data).'</td>
58 58
 		</tr>
59 59
 		<tr>
60
-            <td>' . $this->renderRadio4BlockPosition(7, $block_data) . '</td>
61
-            <td>' . $this->renderRadio4BlockPosition(9, $block_data) . '</td>
62
-            <td>' . $this->renderRadio4BlockPosition(8, $block_data) . "</td>
60
+            <td>' . $this->renderRadio4BlockPosition(7, $block_data).'</td>
61
+            <td>' . $this->renderRadio4BlockPosition(9, $block_data).'</td>
62
+            <td>' . $this->renderRadio4BlockPosition(8, $block_data)."</td>
63 63
 		</tr>
64 64
 		<tr>
65
-            <td colspan='5'>".$this->renderRadio4BlockPosition(-1, $block_data)._NONE . '</td>
65
+            <td colspan='5'>".$this->renderRadio4BlockPosition(-1, $block_data)._NONE.'</td>
66 66
 		</tr>
67 67
     </table>';
68 68
 }
@@ -73,18 +73,18 @@  discard block
 block discarded – undo
73 73
 {
74 74
     $bid = (int)$block_data['bid'];
75 75
     $visible = (int)$block_data['visible'];
76
-    $current_side = $visible ? (int)$block_data['side'] : -1 ;
76
+    $current_side = $visible ? (int)$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'" ;
81
+        $checked = "checked='checked'";
82 82
         $divstyle = $target_side == -1 ? 'disabled' : 'selected';
83 83
     } else {
84 84
         $checked = '';
85 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
 }
Please login to merge, or discard this patch.
xoops_trust_path/libs/altsys/class/SetupAltsysLangMgr.class.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -47,6 +47,10 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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.
Please login to merge, or discard this patch.
xoops_trust_path/libs/altsys/include/altsys_functions.php 2 patches
Doc Comments   +6 added lines patch added patch discarded remove patch
@@ -103,6 +103,12 @@
 block discarded – undo
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) {
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -1,46 +1,46 @@  discard block
 block discarded – undo
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' ,
31
+        $mydirpath.'/admin/mymenu.php',
32
+        $mydirpath.'/mymenu.php',
33
+        $mytrustdirpath.'/admin/mymenu.php',
34 34
         $mytrustdirpath.'/mymenu.php'
35
-    ) ;
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 __DIR__.'/adminmenu_functions.php' ;
41
-            altsys_adminmenu_insert_mymenu($xoopsModule) ;
42
-            altsys_adminmenu_hack_ft() ;
43
-            break ;
39
+            include $mymenu_find_path;
40
+            include_once __DIR__.'/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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
xoops_trust_path/libs/altsys/include/Archive_Zip.php 3 patches
Doc Comments   +12 added lines, -6 removed lines patch added patch discarded remove patch
@@ -136,6 +136,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
   {
Please login to merge, or discard this patch.
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -106,24 +106,24 @@  discard block
 block discarded – undo
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
     /**
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
           PEAR::loadExtension('zlib');
145 145
       }*/ // GIJ
146 146
       if (!extension_loaded('zlib')) {
147
-          die("The extension 'zlib' couldn't be found.\n". 'Please make sure your version of PHP was built ' .
147
+          die("The extension 'zlib' couldn't be found.\n".'Please make sure your version of PHP was built '.
148 148
               "with 'zlib' support.\n");
149 149
           return false;
150 150
       }
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
     * @return mixed An array of file description on success,
181 181
     *               an error code on error
182 182
     */
183
-    public function create($p_filelist, $p_params=0)
183
+    public function create($p_filelist, $p_params = 0)
184 184
     {
185 185
         $this->_errorReset();
186 186
 
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
     * @return mixed An array of file description on success,
252 252
     *               0 on an unrecoverable failure, an error code is logged.
253 253
     */
254
-    public function add($p_filelist, $p_params=0)
254
+    public function add($p_filelist, $p_params = 0)
255 255
     {
256 256
         $this->_errorReset();
257 257
 
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
     * @return mixed An array of file description on success,
402 402
     *               0 on an unrecoverable failure, an error code is logged.
403 403
     */
404
-    public function extract($p_params=0)
404
+    public function extract($p_params = 0)
405 405
     {
406 406
         $this->_errorReset();
407 407
 
@@ -671,7 +671,7 @@  discard block
 block discarded – undo
671 671
     * @param  boolean $p_with_code  If true, gives the name and the int value.
672 672
     * @return string The error name.
673 673
     */
674
-    public function errorName($p_with_code=false)
674
+    public function errorName($p_with_code = false)
675 675
     {
676 676
         $v_const_list = get_defined_constants();
677 677
 
@@ -685,8 +685,8 @@  discard block
 block discarded – undo
685 685
         }
686 686
 
687 687
         // ----- Search the name form the code value
688
-        $v_key=array_search($this->_error_code, $v_error_list, true);
689
-        if ($v_key!=false) {
688
+        $v_key = array_search($this->_error_code, $v_error_list, true);
689
+        if ($v_key != false) {
690 690
             $v_value = $v_key;
691 691
         } else {
692 692
             $v_value = 'NoName';
@@ -711,12 +711,12 @@  discard block
 block discarded – undo
711 711
     *                         and the error code.
712 712
     * @return string The error description.
713 713
     */
714
-    public function errorInfo($p_full=false)
714
+    public function errorInfo($p_full = false)
715 715
     {
716 716
         if ($p_full) {
717
-            return($this->errorName(true) . ' : ' . $this->_error_string);
717
+            return($this->errorName(true).' : '.$this->_error_string);
718 718
         } else {
719
-            return($this->_error_string . ' [code ' . $this->_error_code . ']');
719
+            return($this->_error_string.' [code '.$this->_error_code.']');
720 720
         }
721 721
     }
722 722
     // }}}
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
   *
750 750
   * @param integer $p_level
751 751
   */
752
-  public function _checkFormat($p_level=0)
752
+  public function _checkFormat($p_level = 0)
753 753
   {
754 754
       $v_result = true;
755 755
 
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
   */
801 801
   public function _create($p_list, &$p_result_list, &$p_params)
802 802
   {
803
-      $v_result=1;
803
+      $v_result = 1;
804 804
       $v_list_detail = array();
805 805
 
806 806
       $p_add_dir = $p_params['add_path'];
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
   */
839 839
   public function _add($p_list, &$p_result_list, &$p_params)
840 840
   {
841
-      $v_result=1;
841
+      $v_result = 1;
842 842
       $v_list_detail = array();
843 843
 
844 844
       $p_add_dir = $p_params['add_path'];
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
     }
853 853
 
854 854
     // ----- Open the zip file
855
-    if (($v_result=$this->_openFd('rb')) != 1) {
855
+    if (($v_result = $this->_openFd('rb')) != 1) {
856 856
         return $v_result;
857 857
     }
858 858
 
@@ -925,10 +925,10 @@  discard block
 block discarded – undo
925 925
       }
926 926
 
927 927
     // ----- Create the Central Dir files header
928
-    for ($i=0, $v_count=0; $i < count($v_header_list); $i++) {
928
+    for ($i = 0, $v_count = 0; $i < count($v_header_list); $i++) {
929 929
         // ----- Create the file header
930 930
       if ($v_header_list[$i]['status'] == 'ok') {
931
-          if (($v_result=$this->_writeCentralFileHeader($v_header_list[$i]))!=1) {
931
+          if (($v_result = $this->_writeCentralFileHeader($v_header_list[$i])) != 1) {
932 932
               fclose($v_zip_temp_fd);
933 933
               $this->_closeFd();
934 934
               @unlink($v_zip_temp_name);
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
     $v_comment = '';
948 948
 
949 949
     // ----- Calculate the size of the central header
950
-    $v_size = @ftell($this->_zip_fd)-$v_offset;
950
+    $v_size = @ftell($this->_zip_fd) - $v_offset;
951 951
 
952 952
     // ----- Create the central dir footer
953 953
     if (($v_result = $this->_writeCentralHeader($v_count
@@ -999,7 +999,7 @@  discard block
 block discarded – undo
999 999
   */
1000 1000
   public function _openFd($p_mode)
1001 1001
   {
1002
-      $v_result=1;
1002
+      $v_result = 1;
1003 1003
 
1004 1004
     // ----- Look if already open
1005 1005
     if ($this->_zip_fd != 0) {
@@ -1034,7 +1034,7 @@  discard block
 block discarded – undo
1034 1034
   */
1035 1035
   public function _closeFd()
1036 1036
   {
1037
-      $v_result=1;
1037
+      $v_result = 1;
1038 1038
 
1039 1039
       if ($this->_zip_fd != 0) {
1040 1040
           @fclose($this->_zip_fd);
@@ -1068,7 +1068,7 @@  discard block
 block discarded – undo
1068 1068
   public function _addList($p_list, &$p_result_list,
1069 1069
                     $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params)
1070 1070
   {
1071
-      $v_result=1;
1071
+      $v_result = 1;
1072 1072
 
1073 1073
     // ----- Add the files
1074 1074
     $v_header_list = array();
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
     $v_offset = @ftell($this->_zip_fd);
1083 1083
 
1084 1084
     // ----- Create the Central Dir files header
1085
-    for ($i=0, $v_count=0; $i < count($v_header_list); $i++) {
1085
+    for ($i = 0, $v_count = 0; $i < count($v_header_list); $i++) {
1086 1086
         // ----- Create the file header
1087 1087
       if ($v_header_list[$i]['status'] == 'ok') {
1088 1088
           if (($v_result = $this->_writeCentralFileHeader($v_header_list[$i])) != 1) {
@@ -1099,7 +1099,7 @@  discard block
 block discarded – undo
1099 1099
     $v_comment = '';
1100 1100
 
1101 1101
     // ----- Calculate the size of the central header
1102
-    $v_size = @ftell($this->_zip_fd)-$v_offset;
1102
+    $v_size = @ftell($this->_zip_fd) - $v_offset;
1103 1103
 
1104 1104
     // ----- Create the central dir footer
1105 1105
     if (($v_result = $this->_writeCentralHeader($v_count, $v_size, $v_offset,
@@ -1139,14 +1139,14 @@  discard block
 block discarded – undo
1139 1139
                         $p_add_dir, $p_remove_dir, $p_remove_all_dir,
1140 1140
                         &$p_params)
1141 1141
   {
1142
-      $v_result=1;
1142
+      $v_result = 1;
1143 1143
       $v_header = array();
1144 1144
 
1145 1145
     // ----- Recuperate the current number of elt in list
1146 1146
     $v_nb = count($p_result_list);
1147 1147
 
1148 1148
     // ----- Loop on the files
1149
-    for ($j=0; ($j<count($p_list)) && ($v_result==1); $j++) {
1149
+    for ($j = 0; ($j < count($p_list)) && ($v_result == 1); $j++) {
1150 1150
         // ----- Recuperate the filename
1151 1151
       $p_filename = $this->_tool_TranslateWinPath($p_list[$j], false);
1152 1152
 
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
 
1180 1180
         // ----- Look for path
1181 1181
         if ($p_filename != '.') {
1182
-            $v_path = $p_filename . '/';
1182
+            $v_path = $p_filename.'/';
1183 1183
         } else {
1184 1184
             $v_path = '';
1185 1185
         }
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
   */
1241 1241
   public function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params)
1242 1242
   {
1243
-      $v_result=1;
1243
+      $v_result = 1;
1244 1244
 
1245 1245
       if ($p_filename == '') {
1246 1246
           // ----- Error log
@@ -1265,7 +1265,7 @@  discard block
 block discarded – undo
1265 1265
 
1266 1266
         if ((substr($p_filename, 0, 2) == './') || (substr($p_remove_dir, 0, 2) == './')) {
1267 1267
             if ((substr($p_filename, 0, 2) == './') && (substr($p_remove_dir, 0, 2) != './')) {
1268
-                $p_remove_dir = './' . $p_remove_dir;
1268
+                $p_remove_dir = './'.$p_remove_dir;
1269 1269
             }
1270 1270
             if ((substr($p_filename, 0, 2) != './') && (substr($p_remove_dir, 0, 2) == './')) {
1271 1271
                 $p_remove_dir = substr($p_remove_dir, 2);
@@ -1289,7 +1289,7 @@  discard block
 block discarded – undo
1289 1289
         if (substr($p_add_dir, -1) == '/') {
1290 1290
             $v_stored_filename = $p_add_dir.$v_stored_filename;
1291 1291
         } else {
1292
-            $v_stored_filename = $p_add_dir . '/' . $v_stored_filename;
1292
+            $v_stored_filename = $p_add_dir.'/'.$v_stored_filename;
1293 1293
         }
1294 1294
     }
1295 1295
 
@@ -1324,7 +1324,7 @@  discard block
 block discarded – undo
1324 1324
       $p_header['comment_len'] = 0;
1325 1325
       $p_header['disk'] = 0;
1326 1326
       $p_header['internal'] = 0;
1327
-      $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010);
1327
+      $p_header['external'] = (is_file($p_filename) ? 0xFE49FFE0 : 0x41FF0010);
1328 1328
       $p_header['offset'] = 0;
1329 1329
       $p_header['filename'] = $p_filename;
1330 1330
       $p_header['stored_filename'] = $v_stored_filename;
@@ -1420,7 +1420,7 @@  discard block
 block discarded – undo
1420 1420
         $p_header['filename'] .= '/';
1421 1421
           $p_header['filename_len']++;
1422 1422
           $p_header['size'] = 0;
1423
-          $p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked
1423
+          $p_header['external'] = 0x41FF0010; // Value for a folder : to be checked
1424 1424
 
1425 1425
         // ----- Call the header generation
1426 1426
         if (($v_result = $this->_writeFileHeader($p_header)) != 1) {
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
   */
1470 1470
   public function _writeFileHeader(&$p_header)
1471 1471
   {
1472
-      $v_result=1;
1472
+      $v_result = 1;
1473 1473
 
1474 1474
     // TBC
1475 1475
     //for(reset($p_header); $key = key($p_header); next($p_header)) {
@@ -1480,8 +1480,8 @@  discard block
 block discarded – undo
1480 1480
 
1481 1481
     // ----- Transform UNIX mtime to DOS format mdate/mtime
1482 1482
     $v_date = getdate($p_header['mtime']);
1483
-      $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
1484
-      $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
1483
+      $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2;
1484
+      $v_mdate = (($v_date['year'] - 1980) << 9) + ($v_date['mon'] << 5) + $v_date['mday'];
1485 1485
 
1486 1486
     // ----- Packed data
1487 1487
     $v_binary_data = pack('VvvvvvVVVvv', 0x04034b50, $p_header['version'], $p_header['flag'],
@@ -1519,7 +1519,7 @@  discard block
 block discarded – undo
1519 1519
   */
1520 1520
   public function _writeCentralFileHeader(&$p_header)
1521 1521
   {
1522
-      $v_result=1;
1522
+      $v_result = 1;
1523 1523
 
1524 1524
     // TBC
1525 1525
     //for(reset($p_header); $key = key($p_header); next($p_header)) {
@@ -1527,8 +1527,8 @@  discard block
 block discarded – undo
1527 1527
 
1528 1528
     // ----- Transform UNIX mtime to DOS format mdate/mtime
1529 1529
     $v_date = getdate($p_header['mtime']);
1530
-      $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
1531
-      $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
1530
+      $v_mtime = ($v_date['hours'] << 11) + ($v_date['minutes'] << 5) + $v_date['seconds'] / 2;
1531
+      $v_mdate = (($v_date['year'] - 1980) << 9) + ($v_date['mon'] << 5) + $v_date['mday'];
1532 1532
 
1533 1533
     // ----- Packed data
1534 1534
     $v_binary_data = pack('VvvvvvvVVVvvvvvVV', 0x02014b50, $p_header['version'], $p_header['version_extracted'],
@@ -1570,7 +1570,7 @@  discard block
 block discarded – undo
1570 1570
   */
1571 1571
   public function _writeCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
1572 1572
   {
1573
-      $v_result=1;
1573
+      $v_result = 1;
1574 1574
 
1575 1575
     // ----- Packed data
1576 1576
     $v_binary_data = pack('VvvvvVVv', 0x06054b50, 0, 0, $p_nb_entries, $p_nb_entries, $p_size, $p_offset, strlen($p_comment));
@@ -1602,7 +1602,7 @@  discard block
 block discarded – undo
1602 1602
   */
1603 1603
   public function _list(&$p_list)
1604 1604
   {
1605
-      $v_result=1;
1605
+      $v_result = 1;
1606 1606
 
1607 1607
     // ----- Open the zip file
1608 1608
     if (($this->_zip_fd = @fopen($this->_zipname, 'rb')) == 0) {
@@ -1630,7 +1630,7 @@  discard block
 block discarded – undo
1630 1630
       }
1631 1631
 
1632 1632
     // ----- Read each entry
1633
-    for ($i=0; $i<$v_central_dir['entries']; $i++) {
1633
+    for ($i = 0; $i < $v_central_dir['entries']; $i++) {
1634 1634
         // ----- Read the file header
1635 1635
       if (($v_result = $this->_readCentralFileHeader($v_header)) != 1) {
1636 1636
           return $v_result;
@@ -1676,7 +1676,7 @@  discard block
 block discarded – undo
1676 1676
   */
1677 1677
   public function _convertHeader2FileInfo($p_header, &$p_info)
1678 1678
   {
1679
-      $v_result=1;
1679
+      $v_result = 1;
1680 1680
 
1681 1681
     // ----- Get the interesting attributes
1682 1682
     $p_info['filename'] = $p_header['filename'];
@@ -1685,7 +1685,7 @@  discard block
 block discarded – undo
1685 1685
       $p_info['compressed_size'] = $p_header['compressed_size'];
1686 1686
       $p_info['mtime'] = $p_header['mtime'];
1687 1687
       $p_info['comment'] = $p_header['comment'];
1688
-      $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
1688
+      $p_info['folder'] = (($p_header['external'] & 0x00000010) == 0x00000010);
1689 1689
       $p_info['index'] = $p_header['index'];
1690 1690
       $p_info['status'] = $p_header['status'];
1691 1691
 
@@ -1718,7 +1718,7 @@  discard block
 block discarded – undo
1718 1718
   */
1719 1719
   public function _extractByRule(&$p_file_list, &$p_params)
1720 1720
   {
1721
-      $v_result=1;
1721
+      $v_result = 1;
1722 1722
 
1723 1723
       $p_path = $p_params['add_path'];
1724 1724
       $p_remove_path = $p_params['remove_path'];
@@ -1728,14 +1728,14 @@  discard block
 block discarded – undo
1728 1728
     if (($p_path == '')
1729 1729
         || ((substr($p_path, 0, 1) != '/')
1730 1730
         && (substr($p_path, 0, 3) != '../') && (substr($p_path, 1, 2) != ':/'))) {
1731
-        $p_path = './' . $p_path;
1731
+        $p_path = './'.$p_path;
1732 1732
     }
1733 1733
 
1734 1734
     // ----- Reduce the path last (and duplicated) '/'
1735 1735
     if (($p_path != './') && ($p_path != '/')) {
1736 1736
         // ----- Look for the path end '/'
1737 1737
       while (substr($p_path, -1) == '/') {
1738
-          $p_path = substr($p_path, 0, strlen($p_path)-1);
1738
+          $p_path = substr($p_path, 0, strlen($p_path) - 1);
1739 1739
       }
1740 1740
     }
1741 1741
 
@@ -1764,7 +1764,7 @@  discard block
 block discarded – undo
1764 1764
 
1765 1765
     // ----- Read each entry
1766 1766
     $j_start = 0;
1767
-      for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) {
1767
+      for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++) {
1768 1768
           // ----- Read next Central dir entry
1769 1769
       @rewind($this->_zip_fd);
1770 1770
           if (@fseek($this->_zip_fd, $v_pos_entry)) {
@@ -1798,7 +1798,7 @@  discard block
 block discarded – undo
1798 1798
           && ($p_params[ARCHIVE_ZIP_PARAM_BY_NAME] != 0)) {
1799 1799
 
1800 1800
           // ----- Look if the filename is in the list
1801
-          for ($j=0;
1801
+          for ($j = 0;
1802 1802
                   ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_NAME]))
1803 1803
                && (!$v_extract);
1804 1804
                $j++) {
@@ -1840,15 +1840,15 @@  discard block
 block discarded – undo
1840 1840
                && ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX] != 0)) {
1841 1841
 
1842 1842
           // ----- Look if the index is in the list
1843
-          for ($j=$j_start; ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) && (!$v_extract); $j++) {
1844
-              if (($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']) && ($i<=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) {
1843
+          for ($j = $j_start; ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) && (!$v_extract); $j++) {
1844
+              if (($i >= $p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']) && ($i <= $p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) {
1845 1845
                   $v_extract = true;
1846 1846
               }
1847
-              if ($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) {
1848
-                  $j_start = $j+1;
1847
+              if ($i >= $p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) {
1848
+                  $j_start = $j + 1;
1849 1849
               }
1850 1850
 
1851
-              if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']>$i) {
1851
+              if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start'] > $i) {
1852 1852
                   break;
1853 1853
               }
1854 1854
           }
@@ -1942,7 +1942,7 @@  discard block
 block discarded – undo
1942 1942
   */
1943 1943
   public function _extractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_params)
1944 1944
   {
1945
-      $v_result=1;
1945
+      $v_result = 1;
1946 1946
 
1947 1947
     // ----- Read the file header
1948 1948
     if (($v_result = $this->_readFileHeader($v_header)) != 1) {
@@ -1982,7 +1982,7 @@  discard block
 block discarded – undo
1982 1982
 
1983 1983
     // ----- Add the path
1984 1984
     if ($p_path != '') {
1985
-        $p_entry['filename'] = $p_path . '/' . $p_entry['filename'];
1985
+        $p_entry['filename'] = $p_path.'/'.$p_entry['filename'];
1986 1986
     }
1987 1987
 
1988 1988
     // ----- Look for pre-extract callback
@@ -2048,7 +2048,7 @@  discard block
 block discarded – undo
2048 2048
 
2049 2049
     // ----- Check the directory availability and create it if necessary
2050 2050
     else {
2051
-        if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/')) {
2051
+        if ((($p_entry['external'] & 0x00000010) == 0x00000010) || (substr($p_entry['filename'], -1) == '/')) {
2052 2052
             $v_dir_to_check = $p_entry['filename'];
2053 2053
         } elseif (!strstr($p_entry['filename'], '/')) {
2054 2054
             $v_dir_to_check = '';
@@ -2072,7 +2072,7 @@  discard block
 block discarded – undo
2072 2072
     if ($p_entry['status'] == 'ok') {
2073 2073
 
2074 2074
       // ----- Do the extraction (if not a folder)
2075
-      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
2075
+      if (!(($p_entry['external'] & 0x00000010) == 0x00000010)) {
2076 2076
 
2077 2077
         // ----- Look for not compressed file
2078 2078
         if ($p_entry['compressed_size'] == $p_entry['size']) {
@@ -2177,7 +2177,7 @@  discard block
 block discarded – undo
2177 2177
   */
2178 2178
   public function _extractFileAsString(&$p_entry, &$p_string)
2179 2179
   {
2180
-      $v_result=1;
2180
+      $v_result = 1;
2181 2181
 
2182 2182
     // ----- Read the file header
2183 2183
     $v_header = array();
@@ -2193,7 +2193,7 @@  discard block
 block discarded – undo
2193 2193
     // ----- Trace
2194 2194
 
2195 2195
     // ----- Do the extraction (if not a folder)
2196
-    if (!(($p_entry['external']&0x00000010)==0x00000010)) {
2196
+    if (!(($p_entry['external'] & 0x00000010) == 0x00000010)) {
2197 2197
         // ----- Look for not compressed file
2198 2198
       if ($p_entry['compressed_size'] == $p_entry['size']) {
2199 2199
           // ----- Trace
@@ -2234,7 +2234,7 @@  discard block
 block discarded – undo
2234 2234
   */
2235 2235
   public function _readFileHeader(&$p_header)
2236 2236
   {
2237
-      $v_result=1;
2237
+      $v_result = 1;
2238 2238
 
2239 2239
     // ----- Read the 4 bytes signature
2240 2240
     $v_binary_data = @fread($this->_zip_fd, 4);
@@ -2259,7 +2259,7 @@  discard block
 block discarded – undo
2259 2259
         $p_header['status'] = 'invalid_header';
2260 2260
 
2261 2261
       // ----- Error log
2262
-      $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid block size : ' . strlen($v_binary_data));
2262
+      $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid block size : '.strlen($v_binary_data));
2263 2263
 
2264 2264
       // ----- Return
2265 2265
       return Archive_Zip::errorCode();
@@ -2292,7 +2292,7 @@  discard block
 block discarded – undo
2292 2292
           // ----- Extract time
2293 2293
       $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
2294 2294
           $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
2295
-          $v_seconde = ($p_header['mtime'] & 0x001F)*2;
2295
+          $v_seconde = ($p_header['mtime'] & 0x001F) * 2;
2296 2296
 
2297 2297
       // ----- Extract date
2298 2298
       $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
@@ -2336,7 +2336,7 @@  discard block
 block discarded – undo
2336 2336
   */
2337 2337
   public function _readCentralFileHeader(&$p_header)
2338 2338
   {
2339
-      $v_result=1;
2339
+      $v_result = 1;
2340 2340
 
2341 2341
     // ----- Read the 4 bytes signature
2342 2342
     $v_binary_data = @fread($this->_zip_fd, 4);
@@ -2361,7 +2361,7 @@  discard block
 block discarded – undo
2361 2361
         $p_header['status'] = 'invalid_header';
2362 2362
 
2363 2363
       // ----- Error log
2364
-      $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid block size : ' . strlen($v_binary_data));
2364
+      $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid block size : '.strlen($v_binary_data));
2365 2365
 
2366 2366
       // ----- Return
2367 2367
       return Archive_Zip::errorCode();
@@ -2398,7 +2398,7 @@  discard block
 block discarded – undo
2398 2398
         // ----- Extract time
2399 2399
       $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
2400 2400
         $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
2401
-        $v_seconde = ($p_header['mtime'] & 0x001F)*2;
2401
+        $v_seconde = ($p_header['mtime'] & 0x001F) * 2;
2402 2402
 
2403 2403
       // ----- Extract date
2404 2404
       $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
@@ -2442,7 +2442,7 @@  discard block
 block discarded – undo
2442 2442
   */
2443 2443
   public function _readEndCentralDir(&$p_central_dir)
2444 2444
   {
2445
-      $v_result=1;
2445
+      $v_result = 1;
2446 2446
 
2447 2447
     // ----- Go to the end of the zip file
2448 2448
     $v_size = filesize($this->_zipname);
@@ -2459,8 +2459,8 @@  discard block
 block discarded – undo
2459 2459
     // in this case the end of central dir is at 22 bytes of the file end
2460 2460
     $v_found = 0;
2461 2461
       if ($v_size > 26) {
2462
-          @fseek($this->_zip_fd, $v_size-22);
2463
-          if (($v_pos = @ftell($this->_zip_fd)) != ($v_size-22)) {
2462
+          @fseek($this->_zip_fd, $v_size - 22);
2463
+          if (($v_pos = @ftell($this->_zip_fd)) != ($v_size - 22)) {
2464 2464
               $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT,
2465 2465
                          'Unable to seek back to the middle of the archive \''
2466 2466
                          .$this->_zipname.'\'');
@@ -2485,8 +2485,8 @@  discard block
 block discarded – undo
2485 2485
       if ($v_maximum_size > $v_size) {
2486 2486
           $v_maximum_size = $v_size;
2487 2487
       }
2488
-        @fseek($this->_zip_fd, $v_size-$v_maximum_size);
2489
-        if (@ftell($this->_zip_fd) != ($v_size-$v_maximum_size)) {
2488
+        @fseek($this->_zip_fd, $v_size - $v_maximum_size);
2489
+        if (@ftell($this->_zip_fd) != ($v_size - $v_maximum_size)) {
2490 2490
             $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT,
2491 2491
                          'Unable to seek back to the middle of the archive \''
2492 2492
                          .$this->_zipname.'\'');
@@ -2572,11 +2572,11 @@  discard block
 block discarded – undo
2572 2572
   */
2573 2573
   public function _deleteByRule(&$p_result_list, &$p_params)
2574 2574
   {
2575
-      $v_result=1;
2575
+      $v_result = 1;
2576 2576
       $v_list_detail = array();
2577 2577
 
2578 2578
     // ----- Open the zip file
2579
-    if (($v_result=$this->_openFd('rb')) != 1) {
2579
+    if (($v_result = $this->_openFd('rb')) != 1) {
2580 2580
         // ----- Return
2581 2581
       return $v_result;
2582 2582
     }
@@ -2607,7 +2607,7 @@  discard block
 block discarded – undo
2607 2607
     // ----- Read each entry
2608 2608
     $v_header_list = array();
2609 2609
       $j_start = 0;
2610
-      for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) {
2610
+      for ($i = 0, $v_nb_extracted = 0; $i < $v_central_dir['entries']; $i++) {
2611 2611
 
2612 2612
       // ----- Read the file header
2613 2613
       $v_header_list[$v_nb_extracted] = array();
@@ -2631,7 +2631,7 @@  discard block
 block discarded – undo
2631 2631
           && ($p_params[ARCHIVE_ZIP_PARAM_BY_NAME] != 0)) {
2632 2632
 
2633 2633
           // ----- Look if the filename is in the list
2634
-          for ($j=0;
2634
+          for ($j = 0;
2635 2635
                ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_NAME]))
2636 2636
                  && (!$v_found);
2637 2637
                $j++) {
@@ -2643,7 +2643,7 @@  discard block
 block discarded – undo
2643 2643
                   if ((strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]))
2644 2644
                       && (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])) {
2645 2645
                       $v_found = true;
2646
-                  } elseif ((($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
2646
+                  } elseif ((($v_header_list[$v_nb_extracted]['external'] & 0x00000010) == 0x00000010) /* Indicates a folder */
2647 2647
                           && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) {
2648 2648
                       $v_found = true;
2649 2649
                   }
@@ -2679,19 +2679,19 @@  discard block
 block discarded – undo
2679 2679
                && ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX] != 0)) {
2680 2680
 
2681 2681
           // ----- Look if the index is in the list
2682
-          for ($j=$j_start;
2682
+          for ($j = $j_start;
2683 2683
                ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX]))
2684 2684
                  && (!$v_found);
2685 2685
                $j++) {
2686
-              if (($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start'])
2687
-                  && ($i<=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) {
2686
+              if (($i >= $p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start'])
2687
+                  && ($i <= $p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) {
2688 2688
                   $v_found = true;
2689 2689
               }
2690
-              if ($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) {
2691
-                  $j_start = $j+1;
2690
+              if ($i >= $p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) {
2691
+                  $j_start = $j + 1;
2692 2692
               }
2693 2693
 
2694
-              if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']>$i) {
2694
+              if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start'] > $i) {
2695 2695
                   break;
2696 2696
               }
2697 2697
           }
@@ -2724,11 +2724,11 @@  discard block
 block discarded – undo
2724 2724
         }
2725 2725
 
2726 2726
         // ----- Look which file need to be kept
2727
-        for ($i=0; $i < count($v_header_list); $i++) {
2727
+        for ($i = 0; $i < count($v_header_list); $i++) {
2728 2728
 
2729 2729
             // ----- Calculate the position of the header
2730 2730
             @rewind($this->_zip_fd);
2731
-            if (@fseek($this->_zip_fd,  $v_header_list[$i]['offset'])) {
2731
+            if (@fseek($this->_zip_fd, $v_header_list[$i]['offset'])) {
2732 2732
                 // ----- Clean
2733 2733
                 $this->_closeFd();
2734 2734
                 $v_temp_zip->_closeFd();
@@ -2778,9 +2778,9 @@  discard block
 block discarded – undo
2778 2778
         $v_offset = @ftell($v_temp_zip->_zip_fd);
2779 2779
 
2780 2780
         // ----- Re-Create the Central Dir files header
2781
-        for ($i=0; $i < count($v_header_list); $i++) {
2781
+        for ($i = 0; $i < count($v_header_list); $i++) {
2782 2782
             // ----- Create the file header
2783
-            $v_result=$v_temp_zip->_writeCentralFileHeader($v_header_list[$i]);
2783
+            $v_result = $v_temp_zip->_writeCentralFileHeader($v_header_list[$i]);
2784 2784
             if ($v_result != 1) {
2785 2785
                 // ----- Clean
2786 2786
                 $v_temp_zip->_closeFd();
@@ -2800,7 +2800,7 @@  discard block
 block discarded – undo
2800 2800
         $v_comment = '';
2801 2801
 
2802 2802
         // ----- Calculate the size of the central header
2803
-        $v_size = @ftell($v_temp_zip->_zip_fd)-$v_offset;
2803
+        $v_size = @ftell($v_temp_zip->_zip_fd) - $v_offset;
2804 2804
 
2805 2805
         // ----- Create the central dir footer
2806 2806
         $v_result = $v_temp_zip->_writeCentralHeader(count($v_header_list),
@@ -2856,13 +2856,13 @@  discard block
 block discarded – undo
2856 2856
   *
2857 2857
   * @param [type] $p_is_dir
2858 2858
   */
2859
-  public function _dirCheck($p_dir, $p_is_dir=false)
2859
+  public function _dirCheck($p_dir, $p_is_dir = false)
2860 2860
   {
2861 2861
       $v_result = 1;
2862 2862
 
2863 2863
     // ----- Remove the final '/'
2864 2864
     if ($p_is_dir && (substr($p_dir, -1) == '/')) {
2865
-        $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
2865
+        $p_dir = substr($p_dir, 0, strlen($p_dir) - 1);
2866 2866
     }
2867 2867
 
2868 2868
     // ----- Check the directory availability
@@ -2910,7 +2910,7 @@  discard block
 block discarded – undo
2910 2910
   */
2911 2911
   public function _merge(&$p_archive_to_add)
2912 2912
   {
2913
-      $v_result=1;
2913
+      $v_result = 1;
2914 2914
 
2915 2915
     // ----- Look if the archive_to_add exists
2916 2916
     if (!is_file($p_archive_to_add->_zipname)) {
@@ -2927,7 +2927,7 @@  discard block
 block discarded – undo
2927 2927
     }
2928 2928
 
2929 2929
     // ----- Open the zip file
2930
-    if (($v_result=$this->_openFd('rb')) != 1) {
2930
+    if (($v_result = $this->_openFd('rb')) != 1) {
2931 2931
         return $v_result;
2932 2932
     }
2933 2933
 
@@ -2942,7 +2942,7 @@  discard block
 block discarded – undo
2942 2942
     @rewind($this->_zip_fd);
2943 2943
 
2944 2944
     // ----- Open the archive_to_add file
2945
-    if (($v_result=$p_archive_to_add->_openFd('rb')) != 1) {
2945
+    if (($v_result = $p_archive_to_add->_openFd('rb')) != 1) {
2946 2946
         $this->_closeFd();
2947 2947
         return $v_result;
2948 2948
     }
@@ -3022,7 +3022,7 @@  discard block
 block discarded – undo
3022 3022
     $v_comment = '';
3023 3023
 
3024 3024
     // ----- Calculate the size of the (new) central header
3025
-    $v_size = @ftell($v_zip_temp_fd)-$v_offset;
3025
+    $v_size = @ftell($v_zip_temp_fd) - $v_offset;
3026 3026
 
3027 3027
     // ----- Swap the file descriptor
3028 3028
     // Here is a trick : I swap the temporary fd with the zip fd, in order to use
@@ -3088,7 +3088,7 @@  discard block
 block discarded – undo
3088 3088
   */
3089 3089
   public function _duplicate($p_archive_filename)
3090 3090
   {
3091
-      $v_result=1;
3091
+      $v_result = 1;
3092 3092
 
3093 3093
     // ----- Look if the $p_archive_filename exists
3094 3094
     if (!is_file($p_archive_filename)) {
@@ -3101,7 +3101,7 @@  discard block
 block discarded – undo
3101 3101
     }
3102 3102
 
3103 3103
     // ----- Open the zip file
3104
-    if (($v_result=$this->_openFd('wb')) != 1) {
3104
+    if (($v_result = $this->_openFd('wb')) != 1) {
3105 3105
         // ----- Return
3106 3106
       return $v_result;
3107 3107
     }
@@ -3175,8 +3175,8 @@  discard block
 block discarded – undo
3175 3175
     // ----- Check specific parameters
3176 3176
     $v_callback_list = array('callback_pre_add', 'callback_post_add',
3177 3177
                               'callback_pre_extract', 'callback_post_extract');
3178
-      for ($i=0; $i < count($v_callback_list); $i++) {
3179
-          $v_key=$v_callback_list[$i];
3178
+      for ($i = 0; $i < count($v_callback_list); $i++) {
3179
+          $v_key = $v_callback_list[$i];
3180 3180
           if (isset($p_params[$v_key]) && ($p_params[$v_key] != '')) {
3181 3181
               if (!function_exists($p_params[$v_key])) {
3182 3182
                   $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAM_VALUE,
@@ -3205,7 +3205,7 @@  discard block
 block discarded – undo
3205 3205
   * @param integer $p_error_code
3206 3206
   * @param string $p_error_string
3207 3207
   */
3208
-  public function _errorLog($p_error_code=0, $p_error_string='')
3208
+  public function _errorLog($p_error_code = 0, $p_error_string = '')
3209 3209
   {
3210 3210
       $this->_error_code = $p_error_code;
3211 3211
       $this->_error_string = $p_error_string;
@@ -3252,7 +3252,7 @@  discard block
 block discarded – undo
3252 3252
       $v_list = explode('/', $p_dir);
3253 3253
 
3254 3254
       // ----- Study directories from last to first
3255
-      for ($i= count($v_list) - 1; $i >= 0; $i--) {
3255
+      for ($i = count($v_list) - 1; $i >= 0; $i--) {
3256 3256
           // ----- Look for current path
3257 3257
         if ($v_list[$i] == '.') {
3258 3258
             // ----- Ignore this directory
@@ -3264,7 +3264,7 @@  discard block
 block discarded – undo
3264 3264
             // ----- Ignore only the double '//' in path,
3265 3265
           // but not the first and last '/'
3266 3266
         } else {
3267
-            $v_result = $v_list[$i].($i!=(count($v_list) - 1)? '/' . $v_result: '');
3267
+            $v_result = $v_list[$i].($i != (count($v_list) - 1) ? '/'.$v_result : '');
3268 3268
         }
3269 3269
       }
3270 3270
     }
@@ -3374,11 +3374,11 @@  discard block
 block discarded – undo
3374 3374
   *
3375 3375
   * @param integer $p_mode
3376 3376
   */
3377
-  public function _tool_CopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
3377
+  public function _tool_CopyBlock($p_src, $p_dest, $p_size, $p_mode = 0)
3378 3378
   {
3379 3379
       $v_result = 1;
3380 3380
 
3381
-      if ($p_mode==0) {
3381
+      if ($p_mode == 0) {
3382 3382
           while ($p_size != 0) {
3383 3383
               $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
3384 3384
                         ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE);
@@ -3386,7 +3386,7 @@  discard block
 block discarded – undo
3386 3386
               @fwrite($p_dest, $v_buffer, $v_read_size);
3387 3387
               $p_size -= $v_read_size;
3388 3388
           }
3389
-      } elseif ($p_mode==1) {
3389
+      } elseif ($p_mode == 1) {
3390 3390
           while ($p_size != 0) {
3391 3391
               $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
3392 3392
                         ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE);
@@ -3394,7 +3394,7 @@  discard block
 block discarded – undo
3394 3394
               @fwrite($p_dest, $v_buffer, $v_read_size);
3395 3395
               $p_size -= $v_read_size;
3396 3396
           }
3397
-      } elseif ($p_mode==2) {
3397
+      } elseif ($p_mode == 2) {
3398 3398
           while ($p_size != 0) {
3399 3399
               $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
3400 3400
                         ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE);
@@ -3402,7 +3402,7 @@  discard block
 block discarded – undo
3402 3402
               @gzwrite($p_dest, $v_buffer, $v_read_size);
3403 3403
               $p_size -= $v_read_size;
3404 3404
           }
3405
-      } elseif ($p_mode==3) {
3405
+      } elseif ($p_mode == 3) {
3406 3406
           while ($p_size != 0) {
3407 3407
               $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
3408 3408
                         ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE);
@@ -3473,13 +3473,13 @@  discard block
 block discarded – undo
3473 3473
   *
3474 3474
   * @param [type] $p_remove_disk_letter
3475 3475
   */
3476
-  public function _tool_TranslateWinPath($p_path, $p_remove_disk_letter=true)
3476
+  public function _tool_TranslateWinPath($p_path, $p_remove_disk_letter = true)
3477 3477
   {
3478 3478
       if (stristr(php_uname(), 'windows')) {
3479 3479
           // ----- Look for potential disk letter
3480 3480
       if ($p_remove_disk_letter
3481 3481
           && (($v_position = strpos($p_path, ':')) != false)) {
3482
-          $p_path = substr($p_path, $v_position+1);
3482
+          $p_path = substr($p_path, $v_position + 1);
3483 3483
       }
3484 3484
       // ----- Change potential windows directory separator
3485 3485
       if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) {
Please login to merge, or discard this patch.
Indentation   +1705 added lines, -1705 removed lines patch added patch discarded remove patch
@@ -27,63 +27,63 @@  discard block
 block discarded – undo
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,55 +102,55 @@  discard block
 block discarded – undo
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". 'Please make sure your version of PHP was built ' .
148
-              "with 'zlib' support.\n");
149
-          return false;
150
-      }
151
-
152
-      // ----- Set the attributes
153
-      $this->_zipname = $p_zipname;
146
+        if (!extension_loaded('zlib')) {
147
+            die("The extension 'zlib' couldn't be found.\n". 'Please make sure your version of PHP was built ' .
148
+                "with 'zlib' support.\n");
149
+            return false;
150
+        }
151
+
152
+        // ----- Set the attributes
153
+        $this->_zipname = $p_zipname;
154 154
         $this->_zip_fd = 0;
155 155
 
156 156
         return;
@@ -159,27 +159,27 @@  discard block
 block discarded – undo
159 159
 
160 160
     // {{{ create()
161 161
     /**
162
-    * This method creates a Zip Archive with the filename set with
163
-    * the constructor.
164
-    * The files and directories indicated in $p_filelist
165
-    * are added in the archive.
166
-    * When a directory is in the list, the directory and its content is added
167
-    * in the archive.
168
-    * The methods takes a variable list of parameters in $p_params.
169
-    * The supported parameters for this method are :
170
-    *   'add_path' : Add a path to the archived files.
171
-    *   'remove_path' : Remove the specified 'root' path of the archived files.
172
-    *   'remove_all_path' : Remove all the path of the archived files.
173
-    *   'no_compression' : The archived files will not be compressed.
174
-    *
175
-    * @access public
176
-    * @param  mixed  $p_filelist  The list of the files or folders to add.
177
-    *                             It can be a string with filenames separated
178
-    *                             by a comma, or an array of filenames.
179
-    * @param  mixed  $p_params  An array of variable parameters and values.
180
-    * @return mixed An array of file description on success,
181
-    *               an error code on error
182
-    */
162
+     * This method creates a Zip Archive with the filename set with
163
+     * the constructor.
164
+     * The files and directories indicated in $p_filelist
165
+     * are added in the archive.
166
+     * When a directory is in the list, the directory and its content is added
167
+     * in the archive.
168
+     * The methods takes a variable list of parameters in $p_params.
169
+     * The supported parameters for this method are :
170
+     *   'add_path' : Add a path to the archived files.
171
+     *   'remove_path' : Remove the specified 'root' path of the archived files.
172
+     *   'remove_all_path' : Remove all the path of the archived files.
173
+     *   'no_compression' : The archived files will not be compressed.
174
+     *
175
+     * @access public
176
+     * @param  mixed  $p_filelist  The list of the files or folders to add.
177
+     *                             It can be a string with filenames separated
178
+     *                             by a comma, or an array of filenames.
179
+     * @param  mixed  $p_params  An array of variable parameters and values.
180
+     * @return mixed An array of file description on success,
181
+     *               an error code on error
182
+     */
183 183
     public function create($p_filelist, $p_params=0)
184 184
     {
185 185
         $this->_errorReset();
@@ -189,10 +189,10 @@  discard block
 block discarded – undo
189 189
             $p_params = array();
190 190
         }
191 191
         if ($this->_check_parameters($p_params,
192
-                                     array('no_compression' => false,
193
-                                           'add_path' => '',
194
-                                           'remove_path' => '',
195
-                                           'remove_all_path' => false)) != 1) {
192
+                                        array('no_compression' => false,
193
+                                            'add_path' => '',
194
+                                            'remove_path' => '',
195
+                                            'remove_all_path' => false)) != 1) {
196 196
             return 0;
197 197
         }
198 198
 
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
         // ----- Invalid variable
214 214
         else {
215 215
             $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER,
216
-                             'Invalid variable type p_filelist');
216
+                                'Invalid variable type p_filelist');
217 217
             $v_result = ARCHIVE_ZIP_ERR_INVALID_PARAMETER;
218 218
         }
219 219
 
@@ -227,30 +227,30 @@  discard block
 block discarded – undo
227 227
 
228 228
     // {{{ add()
229 229
     /**
230
-    * This method add files or directory in an existing Zip Archive.
231
-    * If the Zip Archive does not exist it is created.
232
-    * The files and directories to add are indicated in $p_filelist.
233
-    * When a directory is in the list, the directory and its content is added
234
-    * in the archive.
235
-    * The methods takes a variable list of parameters in $p_params.
236
-    * The supported parameters for this method are :
237
-    *   'add_path' : Add a path to the archived files.
238
-    *   'remove_path' : Remove the specified 'root' path of the archived files.
239
-    *   'remove_all_path' : Remove all the path of the archived files.
240
-    *   'no_compression' : The archived files will not be compressed.
241
-    *   'callback_pre_add' : A callback function that will be called before
242
-    *                        each entry archiving.
243
-    *   'callback_post_add' : A callback function that will be called after
244
-    *                         each entry archiving.
245
-    *
246
-    * @access public
247
-    * @param    mixed  $p_filelist  The list of the files or folders to add.
248
-    *                               It can be a string with filenames separated
249
-    *                               by a comma, or an array of filenames.
250
-    * @param    mixed  $p_params  An array of variable parameters and values.
251
-    * @return mixed An array of file description on success,
252
-    *               0 on an unrecoverable failure, an error code is logged.
253
-    */
230
+     * This method add files or directory in an existing Zip Archive.
231
+     * If the Zip Archive does not exist it is created.
232
+     * The files and directories to add are indicated in $p_filelist.
233
+     * When a directory is in the list, the directory and its content is added
234
+     * in the archive.
235
+     * The methods takes a variable list of parameters in $p_params.
236
+     * The supported parameters for this method are :
237
+     *   'add_path' : Add a path to the archived files.
238
+     *   'remove_path' : Remove the specified 'root' path of the archived files.
239
+     *   'remove_all_path' : Remove all the path of the archived files.
240
+     *   'no_compression' : The archived files will not be compressed.
241
+     *   'callback_pre_add' : A callback function that will be called before
242
+     *                        each entry archiving.
243
+     *   'callback_post_add' : A callback function that will be called after
244
+     *                         each entry archiving.
245
+     *
246
+     * @access public
247
+     * @param    mixed  $p_filelist  The list of the files or folders to add.
248
+     *                               It can be a string with filenames separated
249
+     *                               by a comma, or an array of filenames.
250
+     * @param    mixed  $p_params  An array of variable parameters and values.
251
+     * @return mixed An array of file description on success,
252
+     *               0 on an unrecoverable failure, an error code is logged.
253
+     */
254 254
     public function add($p_filelist, $p_params=0)
255 255
     {
256 256
         $this->_errorReset();
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
             $p_params = array();
261 261
         }
262 262
         if ($this->_check_parameters($p_params,
263
-                                     array('no_compression' => false,
263
+                                        array('no_compression' => false,
264 264
                                             'add_path' => '',
265 265
                                             'remove_path' => '',
266 266
                                             'remove_all_path' => false,
267
-                                             'callback_pre_add' => '',
267
+                                                'callback_pre_add' => '',
268 268
                                             'callback_post_add' => '')) != 1) {
269 269
             return 0;
270 270
         }
@@ -302,48 +302,48 @@  discard block
 block discarded – undo
302 302
 
303 303
     // {{{ listContent()
304 304
     /**
305
-    * This method gives the names and properties of the files and directories
306
-    * which are present in the zip archive.
307
-    * The properties of each entries in the list are :
308
-    *   filename : Name of the file.
309
-    *              For create() or add() it's the filename given by the user.
310
-    *              For an extract() it's the filename of the extracted file.
311
-    *   stored_filename : Name of the file / directory stored in the archive.
312
-    *   size : Size of the stored file.
313
-    *   compressed_size : Size of the file's data compressed in the archive
314
-    *                     (without the zip headers overhead)
315
-    *   mtime : Last known modification date of the file (UNIX timestamp)
316
-    *   comment : Comment associated with the file
317
-    *   folder : true | false (indicates if the entry is a folder)
318
-    *   index : index of the file in the archive (-1 when not available)
319
-    *   status : status of the action on the entry (depending of the action) :
320
-    *            Values are :
321
-    *              ok : OK !
322
-    *              filtered : the file/dir was not extracted (filtered by user)
323
-    *              already_a_directory : the file can't be extracted because a
324
-    *                                    directory with the same name already
325
-    *                                    exists
326
-    *              write_protected : the file can't be extracted because a file
327
-    *                                with the same name already exists and is
328
-    *                                write protected
329
-    *              newer_exist : the file was not extracted because a newer
330
-    *                            file already exists
331
-    *              path_creation_fail : the file is not extracted because the
332
-    *                                   folder does not exists and can't be
333
-    *                                   created
334
-    *              write_error : the file was not extracted because there was a
335
-    *                            error while writing the file
336
-    *              read_error : the file was not extracted because there was a
337
-    *                           error while reading the file
338
-    *              invalid_header : the file was not extracted because of an
339
-    *                               archive format error (bad file header)
340
-    * Note that each time a method can continue operating when there
341
-    * is an error on a single file, the error is only logged in the file status.
342
-    *
343
-    * @access public
344
-    * @return mixed An array of file description on success,
345
-    *               0 on an unrecoverable failure, an error code is logged.
346
-    */
305
+     * This method gives the names and properties of the files and directories
306
+     * which are present in the zip archive.
307
+     * The properties of each entries in the list are :
308
+     *   filename : Name of the file.
309
+     *              For create() or add() it's the filename given by the user.
310
+     *              For an extract() it's the filename of the extracted file.
311
+     *   stored_filename : Name of the file / directory stored in the archive.
312
+     *   size : Size of the stored file.
313
+     *   compressed_size : Size of the file's data compressed in the archive
314
+     *                     (without the zip headers overhead)
315
+     *   mtime : Last known modification date of the file (UNIX timestamp)
316
+     *   comment : Comment associated with the file
317
+     *   folder : true | false (indicates if the entry is a folder)
318
+     *   index : index of the file in the archive (-1 when not available)
319
+     *   status : status of the action on the entry (depending of the action) :
320
+     *            Values are :
321
+     *              ok : OK !
322
+     *              filtered : the file/dir was not extracted (filtered by user)
323
+     *              already_a_directory : the file can't be extracted because a
324
+     *                                    directory with the same name already
325
+     *                                    exists
326
+     *              write_protected : the file can't be extracted because a file
327
+     *                                with the same name already exists and is
328
+     *                                write protected
329
+     *              newer_exist : the file was not extracted because a newer
330
+     *                            file already exists
331
+     *              path_creation_fail : the file is not extracted because the
332
+     *                                   folder does not exists and can't be
333
+     *                                   created
334
+     *              write_error : the file was not extracted because there was a
335
+     *                            error while writing the file
336
+     *              read_error : the file was not extracted because there was a
337
+     *                           error while reading the file
338
+     *              invalid_header : the file was not extracted because of an
339
+     *                               archive format error (bad file header)
340
+     * Note that each time a method can continue operating when there
341
+     * is an error on a single file, the error is only logged in the file status.
342
+     *
343
+     * @access public
344
+     * @return mixed An array of file description on success,
345
+     *               0 on an unrecoverable failure, an error code is logged.
346
+     */
347 347
     public function listContent()
348 348
     {
349 349
         $this->_errorReset();
@@ -365,42 +365,42 @@  discard block
 block discarded – undo
365 365
 
366 366
     // {{{ extract()
367 367
     /**
368
-    * This method extract the files and folders which are in the zip archive.
369
-    * It can extract all the archive or a part of the archive by using filter
370
-    * feature (extract by name, by index, by ereg, by preg). The extraction
371
-    * can occur in the current path or an other path.
372
-    * All the advanced features are activated by the use of variable
373
-    * parameters.
374
-    * The return value is an array of entry descriptions which gives
375
-    * information on extracted files (See listContent()).
376
-    * The method may return a success value (an array) even if some files
377
-    * are not correctly extracted (see the file status in listContent()).
378
-    * The supported variable parameters for this method are :
379
-    *   'add_path' : Path where the files and directories are to be extracted
380
-    *   'remove_path' : First part ('root' part) of the memorized path
381
-    *                   (if similar) to remove while extracting.
382
-    *   'remove_all_path' : Remove all the memorized path while extracting.
383
-    *   'extract_as_string' :
384
-    *   'set_chmod' : After the extraction of the file the indicated mode
385
-    *                 will be set.
386
-    *   'by_name' : It can be a string with file/dir names separated by ',',
387
-    *               or an array of file/dir names to extract from the archive.
388
-    *   'by_index' : A string with range of indexes separated by ',',
389
-    *                (sample "1,3-5,12").
390
-    *   'by_ereg' : A regular expression (ereg) that must match the extracted
391
-    *               filename.
392
-    *   'by_preg' : A regular expression (preg) that must match the extracted
393
-    *               filename.
394
-    *   'callback_pre_extract' : A callback function that will be called before
395
-    *                            each entry extraction.
396
-    *   'callback_post_extract' : A callback function that will be called after
397
-    *                            each entry extraction.
398
-    *
399
-    * @access public
400
-    * @param    mixed  $p_params  An array of variable parameters and values.
401
-    * @return mixed An array of file description on success,
402
-    *               0 on an unrecoverable failure, an error code is logged.
403
-    */
368
+     * This method extract the files and folders which are in the zip archive.
369
+     * It can extract all the archive or a part of the archive by using filter
370
+     * feature (extract by name, by index, by ereg, by preg). The extraction
371
+     * can occur in the current path or an other path.
372
+     * All the advanced features are activated by the use of variable
373
+     * parameters.
374
+     * The return value is an array of entry descriptions which gives
375
+     * information on extracted files (See listContent()).
376
+     * The method may return a success value (an array) even if some files
377
+     * are not correctly extracted (see the file status in listContent()).
378
+     * The supported variable parameters for this method are :
379
+     *   'add_path' : Path where the files and directories are to be extracted
380
+     *   'remove_path' : First part ('root' part) of the memorized path
381
+     *                   (if similar) to remove while extracting.
382
+     *   'remove_all_path' : Remove all the memorized path while extracting.
383
+     *   'extract_as_string' :
384
+     *   'set_chmod' : After the extraction of the file the indicated mode
385
+     *                 will be set.
386
+     *   'by_name' : It can be a string with file/dir names separated by ',',
387
+     *               or an array of file/dir names to extract from the archive.
388
+     *   'by_index' : A string with range of indexes separated by ',',
389
+     *                (sample "1,3-5,12").
390
+     *   'by_ereg' : A regular expression (ereg) that must match the extracted
391
+     *               filename.
392
+     *   'by_preg' : A regular expression (preg) that must match the extracted
393
+     *               filename.
394
+     *   'callback_pre_extract' : A callback function that will be called before
395
+     *                            each entry extraction.
396
+     *   'callback_post_extract' : A callback function that will be called after
397
+     *                            each entry extraction.
398
+     *
399
+     * @access public
400
+     * @param    mixed  $p_params  An array of variable parameters and values.
401
+     * @return mixed An array of file description on success,
402
+     *               0 on an unrecoverable failure, an error code is logged.
403
+     */
404 404
     public function extract($p_params=0)
405 405
     {
406 406
         $this->_errorReset();
@@ -415,11 +415,11 @@  discard block
 block discarded – undo
415 415
             $p_params = array();
416 416
         }
417 417
         if ($this->_check_parameters($p_params,
418
-                                     array('extract_as_string' => false,
418
+                                        array('extract_as_string' => false,
419 419
                                             'add_path' => '',
420 420
                                             'remove_path' => '',
421 421
                                             'remove_all_path' => false,
422
-                                             'callback_pre_extract' => '',
422
+                                                'callback_pre_extract' => '',
423 423
                                             'callback_post_extract' => '',
424 424
                                             'set_chmod' => 0,
425 425
                                             'by_name' => '',
@@ -443,26 +443,26 @@  discard block
 block discarded – undo
443 443
 
444 444
     // {{{ delete()
445 445
     /**
446
-    * This methods delete archive entries in the zip archive.
447
-    * Notice that at least one filtering rule (set by the variable parameter
448
-    * list) must be set.
449
-    * Also notice that if you delete a folder entry, only the folder entry
450
-    * is deleted, not all the files bellonging to this folder.
451
-    * The supported variable parameters for this method are :
452
-    *   'by_name' : It can be a string with file/dir names separated by ',',
453
-    *               or an array of file/dir names to delete from the archive.
454
-    *   'by_index' : A string with range of indexes separated by ',',
455
-    *                (sample "1,3-5,12").
456
-    *   'by_ereg' : A regular expression (ereg) that must match the extracted
457
-    *               filename.
458
-    *   'by_preg' : A regular expression (preg) that must match the extracted
459
-    *               filename.
460
-    *
461
-    * @access public
462
-    * @param    mixed  $p_params  An array of variable parameters and values.
463
-    * @return mixed An array of file description on success,
464
-    *               0 on an unrecoverable failure, an error code is logged.
465
-    */
446
+     * This methods delete archive entries in the zip archive.
447
+     * Notice that at least one filtering rule (set by the variable parameter
448
+     * list) must be set.
449
+     * Also notice that if you delete a folder entry, only the folder entry
450
+     * is deleted, not all the files bellonging to this folder.
451
+     * The supported variable parameters for this method are :
452
+     *   'by_name' : It can be a string with file/dir names separated by ',',
453
+     *               or an array of file/dir names to delete from the archive.
454
+     *   'by_index' : A string with range of indexes separated by ',',
455
+     *                (sample "1,3-5,12").
456
+     *   'by_ereg' : A regular expression (ereg) that must match the extracted
457
+     *               filename.
458
+     *   'by_preg' : A regular expression (preg) that must match the extracted
459
+     *               filename.
460
+     *
461
+     * @access public
462
+     * @param    mixed  $p_params  An array of variable parameters and values.
463
+     * @return mixed An array of file description on success,
464
+     *               0 on an unrecoverable failure, an error code is logged.
465
+     */
466 466
     public function delete($p_params)
467 467
     {
468 468
         $this->_errorReset();
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 
475 475
         // ----- Set default values
476 476
         if ($this->_check_parameters($p_params,
477
-                                     array('by_name' => '',
477
+                                        array('by_name' => '',
478 478
                                             'by_index' => '',
479 479
                                             'by_ereg' => '',
480 480
                                             'by_preg' => '')) != 1) {
@@ -487,8 +487,8 @@  discard block
 block discarded – undo
487 487
             && ($p_params['by_ereg'] == '')
488 488
             && ($p_params['by_preg'] == '')) {
489 489
             $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER,
490
-                             'At least one filtering rule must'
491
-                             .' be set as parameter');
490
+                                'At least one filtering rule must'
491
+                                .' be set as parameter');
492 492
             return 0;
493 493
         }
494 494
 
@@ -505,16 +505,16 @@  discard block
 block discarded – undo
505 505
 
506 506
     // {{{ properties()
507 507
     /**
508
-    * This method gives the global properties of the archive.
509
-    *  The properties are :
510
-    *    nb : Number of files in the archive
511
-    *    comment : Comment associated with the archive file
512
-    *    status : not_exist, ok
513
-    *
514
-    * @access public
515
-    * @param    mixed  $p_params  {Description}
516
-    * @return mixed An array with the global properties or 0 on error.
517
-    */
508
+     * This method gives the global properties of the archive.
509
+     *  The properties are :
510
+     *    nb : Number of files in the archive
511
+     *    comment : Comment associated with the archive file
512
+     *    status : not_exist, ok
513
+     *
514
+     * @access public
515
+     * @param    mixed  $p_params  {Description}
516
+     * @return mixed An array with the global properties or 0 on error.
517
+     */
518 518
     public function properties()
519 519
     {
520 520
         $this->_errorReset();
@@ -535,8 +535,8 @@  discard block
 block discarded – undo
535 535
             // ----- Open the zip file
536 536
             if (($this->_zip_fd = @fopen($this->_zipname, 'rb')) == 0) {
537 537
                 $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL,
538
-                                 'Unable to open archive \''.$this->_zipname
539
-                                 .'\' in binary read mode');
538
+                                    'Unable to open archive \''.$this->_zipname
539
+                                    .'\' in binary read mode');
540 540
                 return 0;
541 541
             }
542 542
 
@@ -561,15 +561,15 @@  discard block
 block discarded – undo
561 561
 
562 562
     // {{{ duplicate()
563 563
     /**
564
-    * This method creates an archive by copying the content of an other one.
565
-    * If the archive already exist, it is replaced by the new one without
566
-    * any warning.
567
-    *
568
-    * @access public
569
-    * @param  mixed  $p_archive  It can be a valid Archive_Zip object or
570
-    *                            the filename of a valid zip archive.
571
-    * @return integer 1 on success, 0 on failure.
572
-    */
564
+     * This method creates an archive by copying the content of an other one.
565
+     * If the archive already exist, it is replaced by the new one without
566
+     * any warning.
567
+     *
568
+     * @access public
569
+     * @param  mixed  $p_archive  It can be a valid Archive_Zip object or
570
+     *                            the filename of a valid zip archive.
571
+     * @return integer 1 on success, 0 on failure.
572
+     */
573 573
     public function duplicate($p_archive)
574 574
     {
575 575
         $this->_errorReset();
@@ -586,7 +586,7 @@  discard block
 block discarded – undo
586 586
             // TBC : Should also check the archive format
587 587
             if (!is_file($p_archive)) {
588 588
                 $this->_errorLog(ARCHIVE_ZIP_ERR_MISSING_FILE,
589
-                                 "No file with filename '".$p_archive."'");
589
+                                    "No file with filename '".$p_archive."'");
590 590
                 $v_result = ARCHIVE_ZIP_ERR_MISSING_FILE;
591 591
             } else {
592 592
                 $v_result = $this->_duplicate($p_archive);
@@ -605,16 +605,16 @@  discard block
 block discarded – undo
605 605
 
606 606
     // {{{ merge()
607 607
     /**
608
-    *  This method merge a valid zip archive at the end of the
609
-    *  archive identified by the Archive_Zip object.
610
-    *  If the archive ($this) does not exist, the merge becomes a duplicate.
611
-    *  If the archive to add does not exist, the merge is a success.
612
-    *
613
-    * @access public
614
-    * @param mixed $p_archive_to_add  It can be a valid Archive_Zip object or
615
-    *                                 the filename of a valid zip archive.
616
-    * @return integer 1 on success, 0 on failure.
617
-    */
608
+     *  This method merge a valid zip archive at the end of the
609
+     *  archive identified by the Archive_Zip object.
610
+     *  If the archive ($this) does not exist, the merge becomes a duplicate.
611
+     *  If the archive to add does not exist, the merge is a success.
612
+     *
613
+     * @access public
614
+     * @param mixed $p_archive_to_add  It can be a valid Archive_Zip object or
615
+     *                                 the filename of a valid zip archive.
616
+     * @return integer 1 on success, 0 on failure.
617
+     */
618 618
     public function merge($p_archive_to_add)
619 619
     {
620 620
         $v_result = 1;
@@ -652,11 +652,11 @@  discard block
 block discarded – undo
652 652
 
653 653
     // {{{ errorCode()
654 654
     /**
655
-    * Method that gives the lastest error code.
656
-    *
657
-    * @access public
658
-    * @return integer The error code value.
659
-    */
655
+     * Method that gives the lastest error code.
656
+     *
657
+     * @access public
658
+     * @return integer The error code value.
659
+     */
660 660
     public function errorCode()
661 661
     {
662 662
         return $this->_error_code;
@@ -665,19 +665,19 @@  discard block
 block discarded – undo
665 665
 
666 666
     // {{{ errorName()
667 667
     /**
668
-    * This method gives the latest error code name.
669
-    *
670
-    * @access public
671
-    * @param  boolean $p_with_code  If true, gives the name and the int value.
672
-    * @return string The error name.
673
-    */
668
+     * This method gives the latest error code name.
669
+     *
670
+     * @access public
671
+     * @param  boolean $p_with_code  If true, gives the name and the int value.
672
+     * @return string The error name.
673
+     */
674 674
     public function errorName($p_with_code=false)
675 675
     {
676 676
         $v_const_list = get_defined_constants();
677 677
 
678
-          // ----- Extract error constants from all const.
678
+            // ----- Extract error constants from all const.
679 679
         for (reset($v_const_list);
680
-             list($v_key, $v_value) = each($v_const_list);) {
680
+                list($v_key, $v_value) = each($v_const_list);) {
681 681
             if (substr($v_key, 0, strlen('ARCHIVE_ZIP_ERR_'))
682 682
                 =='ARCHIVE_ZIP_ERR_') {
683 683
                 $v_error_list[$v_key] = $v_value;
@@ -702,15 +702,15 @@  discard block
 block discarded – undo
702 702
 
703 703
     // {{{ errorInfo()
704 704
     /**
705
-    * This method returns the description associated with the latest error.
706
-    *
707
-    * @access public
708
-    * @param  boolean $p_full If set to true gives the description with the
709
-    *                         error code, the name and the description.
710
-    *                         If set to false gives only the description
711
-    *                         and the error code.
712
-    * @return string The error description.
713
-    */
705
+     * This method returns the description associated with the latest error.
706
+     *
707
+     * @access public
708
+     * @param  boolean $p_full If set to true gives the description with the
709
+     *                         error code, the name and the description.
710
+     *                         If set to false gives only the description
711
+     *                         and the error code.
712
+     * @return string The error description.
713
+     */
714 714
     public function errorInfo($p_full=false)
715 715
     {
716 716
         if ($p_full) {
@@ -728,30 +728,30 @@  discard block
 block discarded – undo
728 728
 // *****       THESES FUNCTIONS MUST NOT BE USED DIRECTLY       *****
729 729
 // -----------------------------------------------------------------------------
730 730
 
731
-  // ---------------------------------------------------------------------------
732
-  // Function : _checkFormat()
733
-  // Description :
734
-  //   This method check that the archive exists and is a valid zip archive.
735
-  //   Several level of check exists. (futur)
736
-  // Parameters :
737
-  //   $p_level : Level of check. Default 0.
738
-  //              0 : Check the first bytes (magic codes) (default value))
739
-  //              1 : 0 + Check the central directory (futur)
740
-  //              2 : 1 + Check each file header (futur)
741
-  // Return Values :
742
-  //   true on success,
743
-  //   false on error, the error code is set.
744
-  // ---------------------------------------------------------------------------
745
-  /**
746
-  * Archive_Zip::_checkFormat()
747
-  *
748
-  * { Description }
749
-  *
750
-  * @param integer $p_level
751
-  */
752
-  public function _checkFormat($p_level=0)
753
-  {
754
-      $v_result = true;
731
+    // ---------------------------------------------------------------------------
732
+    // Function : _checkFormat()
733
+    // Description :
734
+    //   This method check that the archive exists and is a valid zip archive.
735
+    //   Several level of check exists. (futur)
736
+    // Parameters :
737
+    //   $p_level : Level of check. Default 0.
738
+    //              0 : Check the first bytes (magic codes) (default value))
739
+    //              1 : 0 + Check the central directory (futur)
740
+    //              2 : 1 + Check each file header (futur)
741
+    // Return Values :
742
+    //   true on success,
743
+    //   false on error, the error code is set.
744
+    // ---------------------------------------------------------------------------
745
+    /**
746
+     * Archive_Zip::_checkFormat()
747
+     *
748
+     * { Description }
749
+     *
750
+     * @param integer $p_level
751
+     */
752
+    public function _checkFormat($p_level=0)
753
+    {
754
+        $v_result = true;
755 755
 
756 756
     // ----- Reset the error handler
757 757
     $this->_errorReset();
@@ -759,16 +759,16 @@  discard block
 block discarded – undo
759 759
     // ----- Look if the file exits
760 760
     if (!is_file($this->_zipname)) {
761 761
         // ----- Error log
762
-      $this->_errorLog(ARCHIVE_ZIP_ERR_MISSING_FILE,
763
-                       "Missing archive file '".$this->_zipname."'");
762
+        $this->_errorLog(ARCHIVE_ZIP_ERR_MISSING_FILE,
763
+                        "Missing archive file '".$this->_zipname."'");
764 764
         return false;
765 765
     }
766 766
 
767 767
     // ----- Check that the file is readeable
768 768
     if (!is_readable($this->_zipname)) {
769 769
         // ----- Error log
770
-      $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL,
771
-                       "Unable to read archive '".$this->_zipname."'");
770
+        $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL,
771
+                        "Unable to read archive '".$this->_zipname."'");
772 772
         return false;
773 773
     }
774 774
 
@@ -783,34 +783,34 @@  discard block
 block discarded – undo
783 783
 
784 784
     // ----- Return
785 785
     return $v_result;
786
-  }
787
-  // ---------------------------------------------------------------------------
788
-
789
-  // ---------------------------------------------------------------------------
790
-  // Function : _create()
791
-  // Description :
792
-  // Parameters :
793
-  // Return Values :
794
-  // ---------------------------------------------------------------------------
795
-  /**
796
-  * Archive_Zip::_create()
797
-  *
798
-  * { Description }
799
-  *
800
-  */
801
-  public function _create($p_list, &$p_result_list, &$p_params)
802
-  {
803
-      $v_result=1;
804
-      $v_list_detail = array();
805
-
806
-      $p_add_dir = $p_params['add_path'];
807
-      $p_remove_dir = $p_params['remove_path'];
808
-      $p_remove_all_dir = $p_params['remove_all_path'];
786
+    }
787
+    // ---------------------------------------------------------------------------
788
+
789
+    // ---------------------------------------------------------------------------
790
+    // Function : _create()
791
+    // Description :
792
+    // Parameters :
793
+    // Return Values :
794
+    // ---------------------------------------------------------------------------
795
+    /**
796
+     * Archive_Zip::_create()
797
+     *
798
+     * { Description }
799
+     *
800
+     */
801
+    public function _create($p_list, &$p_result_list, &$p_params)
802
+    {
803
+        $v_result=1;
804
+        $v_list_detail = array();
805
+
806
+        $p_add_dir = $p_params['add_path'];
807
+        $p_remove_dir = $p_params['remove_path'];
808
+        $p_remove_all_dir = $p_params['remove_all_path'];
809 809
 
810 810
     // ----- Open the file in write mode
811 811
     if (($v_result = $this->_openFd('wb')) != 1) {
812 812
         // ----- Return
813
-      return $v_result;
813
+        return $v_result;
814 814
     }
815 815
 
816 816
     // ----- Add the list of files
@@ -821,29 +821,29 @@  discard block
 block discarded – undo
821 821
 
822 822
     // ----- Return
823 823
     return $v_result;
824
-  }
825
-  // ---------------------------------------------------------------------------
826
-
827
-  // ---------------------------------------------------------------------------
828
-  // Function : _add()
829
-  // Description :
830
-  // Parameters :
831
-  // Return Values :
832
-  // ---------------------------------------------------------------------------
833
-  /**
834
-  * Archive_Zip::_add()
835
-  *
836
-  * { Description }
837
-  *
838
-  */
839
-  public function _add($p_list, &$p_result_list, &$p_params)
840
-  {
841
-      $v_result=1;
842
-      $v_list_detail = array();
843
-
844
-      $p_add_dir = $p_params['add_path'];
845
-      $p_remove_dir = $p_params['remove_path'];
846
-      $p_remove_all_dir = $p_params['remove_all_path'];
824
+    }
825
+    // ---------------------------------------------------------------------------
826
+
827
+    // ---------------------------------------------------------------------------
828
+    // Function : _add()
829
+    // Description :
830
+    // Parameters :
831
+    // Return Values :
832
+    // ---------------------------------------------------------------------------
833
+    /**
834
+     * Archive_Zip::_add()
835
+     *
836
+     * { Description }
837
+     *
838
+     */
839
+    public function _add($p_list, &$p_result_list, &$p_params)
840
+    {
841
+        $v_result=1;
842
+        $v_list_detail = array();
843
+
844
+        $p_add_dir = $p_params['add_path'];
845
+        $p_remove_dir = $p_params['remove_path'];
846
+        $p_remove_all_dir = $p_params['remove_all_path'];
847 847
 
848 848
     // ----- Look if the archive exists or is empty and need to be created
849 849
     if ((!is_file($this->_zipname)) || (filesize($this->_zipname) == 0)) {
@@ -858,10 +858,10 @@  discard block
 block discarded – undo
858 858
 
859 859
     // ----- Read the central directory informations
860 860
     $v_central_dir = array();
861
-      if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) {
862
-          $this->_closeFd();
863
-          return $v_result;
864
-      }
861
+        if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) {
862
+            $this->_closeFd();
863
+            return $v_result;
864
+        }
865 865
 
866 866
     // ----- Go to beginning of File
867 867
     @rewind($this->_zip_fd);
@@ -874,8 +874,8 @@  discard block
 block discarded – undo
874 874
         $this->_closeFd();
875 875
 
876 876
         $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL,
877
-                       'Unable to open temporary file \''
878
-                       .$v_zip_temp_name.'\' in binary write mode');
877
+                        'Unable to open temporary file \''
878
+                        .$v_zip_temp_name.'\' in binary write mode');
879 879
         return Archive_Zip::errorCode();
880 880
     }
881 881
 
@@ -883,64 +883,64 @@  discard block
 block discarded – undo
883 883
     // TBC : Here I should better append the file and go back to erase the
884 884
     // central dir
885 885
     $v_size = $v_central_dir['offset'];
886
-      while ($v_size != 0) {
887
-          $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
886
+        while ($v_size != 0) {
887
+            $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
888 888
                       ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE);
889
-          $v_buffer = fread($this->_zip_fd, $v_read_size);
890
-          @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
891
-          $v_size -= $v_read_size;
892
-      }
889
+            $v_buffer = fread($this->_zip_fd, $v_read_size);
890
+            @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
891
+            $v_size -= $v_read_size;
892
+        }
893 893
 
894 894
     // ----- Swap the file descriptor
895 895
     // Here is a trick : I swap the temporary fd with the zip fd, in order to
896 896
     // use the following methods on the temporary fil and not the real archive
897 897
     $v_swap = $this->_zip_fd;
898
-      $this->_zip_fd = $v_zip_temp_fd;
899
-      $v_zip_temp_fd = $v_swap;
898
+        $this->_zip_fd = $v_zip_temp_fd;
899
+        $v_zip_temp_fd = $v_swap;
900 900
 
901 901
     // ----- Add the files
902 902
     $v_header_list = array();
903
-      if (($v_result = $this->_addFileList($p_list, $v_header_list,
904
-                                         $p_add_dir, $p_remove_dir,
905
-                                         $p_remove_all_dir, $p_params)) != 1) {
906
-          fclose($v_zip_temp_fd);
907
-          $this->_closeFd();
908
-          @unlink($v_zip_temp_name);
903
+        if (($v_result = $this->_addFileList($p_list, $v_header_list,
904
+                                            $p_add_dir, $p_remove_dir,
905
+                                            $p_remove_all_dir, $p_params)) != 1) {
906
+            fclose($v_zip_temp_fd);
907
+            $this->_closeFd();
908
+            @unlink($v_zip_temp_name);
909 909
 
910
-      // ----- Return
911
-      return $v_result;
912
-      }
910
+        // ----- Return
911
+        return $v_result;
912
+        }
913 913
 
914 914
     // ----- Store the offset of the central dir
915 915
     $v_offset = @ftell($this->_zip_fd);
916 916
 
917 917
     // ----- Copy the block of file headers from the old archive
918 918
     $v_size = $v_central_dir['size'];
919
-      while ($v_size != 0) {
920
-          $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
919
+        while ($v_size != 0) {
920
+            $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
921 921
                       ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE);
922
-          $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
923
-          @fwrite($this->_zip_fd, $v_buffer, $v_read_size);
924
-          $v_size -= $v_read_size;
925
-      }
922
+            $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
923
+            @fwrite($this->_zip_fd, $v_buffer, $v_read_size);
924
+            $v_size -= $v_read_size;
925
+        }
926 926
 
927 927
     // ----- Create the Central Dir files header
928 928
     for ($i=0, $v_count=0; $i < count($v_header_list); $i++) {
929 929
         // ----- Create the file header
930
-      if ($v_header_list[$i]['status'] == 'ok') {
931
-          if (($v_result=$this->_writeCentralFileHeader($v_header_list[$i]))!=1) {
932
-              fclose($v_zip_temp_fd);
933
-              $this->_closeFd();
934
-              @unlink($v_zip_temp_name);
930
+        if ($v_header_list[$i]['status'] == 'ok') {
931
+            if (($v_result=$this->_writeCentralFileHeader($v_header_list[$i]))!=1) {
932
+                fclose($v_zip_temp_fd);
933
+                $this->_closeFd();
934
+                @unlink($v_zip_temp_name);
935 935
 
936
-          // ----- Return
937
-          return $v_result;
938
-          }
939
-          $v_count++;
940
-      }
936
+            // ----- Return
937
+            return $v_result;
938
+            }
939
+            $v_count++;
940
+        }
941 941
 
942
-      // ----- Transform the header to a 'usable' info
943
-      $this->_convertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
942
+        // ----- Transform the header to a 'usable' info
943
+        $this->_convertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
944 944
     }
945 945
 
946 946
     // ----- Zip file comment
@@ -955,16 +955,16 @@  discard block
 block discarded – undo
955 955
                                                 $v_size, $v_offset,
956 956
                                                 $v_comment)) != 1) {
957 957
         // ----- Reset the file list
958
-      unset($v_header_list);
958
+        unset($v_header_list);
959 959
 
960
-      // ----- Return
961
-      return $v_result;
960
+        // ----- Return
961
+        return $v_result;
962 962
     }
963 963
 
964 964
     // ----- Swap back the file descriptor
965 965
     $v_swap = $this->_zip_fd;
966
-      $this->_zip_fd = $v_zip_temp_fd;
967
-      $v_zip_temp_fd = $v_swap;
966
+        $this->_zip_fd = $v_zip_temp_fd;
967
+        $v_zip_temp_fd = $v_swap;
968 968
 
969 969
     // ----- Close
970 970
     $this->_closeFd();
@@ -983,100 +983,100 @@  discard block
 block discarded – undo
983 983
 
984 984
     // ----- Return
985 985
     return $v_result;
986
-  }
987
-  // ---------------------------------------------------------------------------
988
-
989
-  // ---------------------------------------------------------------------------
990
-  // Function : _openFd()
991
-  // Description :
992
-  // Parameters :
993
-  // ---------------------------------------------------------------------------
994
-  /**
995
-  * Archive_Zip::_openFd()
996
-  *
997
-  * { Description }
998
-  *
999
-  */
1000
-  public function _openFd($p_mode)
1001
-  {
1002
-      $v_result=1;
986
+    }
987
+    // ---------------------------------------------------------------------------
988
+
989
+    // ---------------------------------------------------------------------------
990
+    // Function : _openFd()
991
+    // Description :
992
+    // Parameters :
993
+    // ---------------------------------------------------------------------------
994
+    /**
995
+     * Archive_Zip::_openFd()
996
+     *
997
+     * { Description }
998
+     *
999
+     */
1000
+    public function _openFd($p_mode)
1001
+    {
1002
+        $v_result=1;
1003 1003
 
1004 1004
     // ----- Look if already open
1005 1005
     if ($this->_zip_fd != 0) {
1006 1006
         $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL,
1007
-                       'Zip file \''.$this->_zipname.'\' already open');
1007
+                        'Zip file \''.$this->_zipname.'\' already open');
1008 1008
         return Archive_Zip::errorCode();
1009 1009
     }
1010 1010
 
1011 1011
     // ----- Open the zip file
1012 1012
     if (($this->_zip_fd = @fopen($this->_zipname, $p_mode)) == 0) {
1013 1013
         $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL,
1014
-                       'Unable to open archive \''.$this->_zipname
1015
-                       .'\' in '.$p_mode.' mode');
1014
+                        'Unable to open archive \''.$this->_zipname
1015
+                        .'\' in '.$p_mode.' mode');
1016 1016
         return Archive_Zip::errorCode();
1017 1017
     }
1018 1018
 
1019 1019
     // ----- Return
1020 1020
     return $v_result;
1021
-  }
1022
-  // ---------------------------------------------------------------------------
1023
-
1024
-  // ---------------------------------------------------------------------------
1025
-  // Function : _closeFd()
1026
-  // Description :
1027
-  // Parameters :
1028
-  // ---------------------------------------------------------------------------
1029
-  /**
1030
-  * Archive_Zip::_closeFd()
1031
-  *
1032
-  * { Description }
1033
-  *
1034
-  */
1035
-  public function _closeFd()
1036
-  {
1037
-      $v_result=1;
1038
-
1039
-      if ($this->_zip_fd != 0) {
1040
-          @fclose($this->_zip_fd);
1041
-      }
1042
-      $this->_zip_fd = 0;
1021
+    }
1022
+    // ---------------------------------------------------------------------------
1023
+
1024
+    // ---------------------------------------------------------------------------
1025
+    // Function : _closeFd()
1026
+    // Description :
1027
+    // Parameters :
1028
+    // ---------------------------------------------------------------------------
1029
+    /**
1030
+     * Archive_Zip::_closeFd()
1031
+     *
1032
+     * { Description }
1033
+     *
1034
+     */
1035
+    public function _closeFd()
1036
+    {
1037
+        $v_result=1;
1038
+
1039
+        if ($this->_zip_fd != 0) {
1040
+            @fclose($this->_zip_fd);
1041
+        }
1042
+        $this->_zip_fd = 0;
1043 1043
 
1044 1044
     // ----- Return
1045 1045
     return $v_result;
1046
-  }
1047
-  // ---------------------------------------------------------------------------
1048
-
1049
-  // ---------------------------------------------------------------------------
1050
-  // Function : _addList()
1051
-  // Description :
1052
-  //   $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
1053
-  //   different from the real path of the file. This is usefull if you want to have PclTar
1054
-  //   running in any directory, and memorize relative path from an other directory.
1055
-  // Parameters :
1056
-  //   $p_list : An array containing the file or directory names to add in the tar
1057
-  //   $p_result_list : list of added files with their properties (specially the status field)
1058
-  //   $p_add_dir : Path to add in the filename path archived
1059
-  //   $p_remove_dir : Path to remove in the filename path archived
1060
-  // Return Values :
1061
-  // ---------------------------------------------------------------------------
1062
-  /**
1063
-  * Archive_Zip::_addList()
1064
-  *
1065
-  * { Description }
1066
-  *
1067
-  */
1068
-  public function _addList($p_list, &$p_result_list,
1046
+    }
1047
+    // ---------------------------------------------------------------------------
1048
+
1049
+    // ---------------------------------------------------------------------------
1050
+    // Function : _addList()
1051
+    // Description :
1052
+    //   $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
1053
+    //   different from the real path of the file. This is usefull if you want to have PclTar
1054
+    //   running in any directory, and memorize relative path from an other directory.
1055
+    // Parameters :
1056
+    //   $p_list : An array containing the file or directory names to add in the tar
1057
+    //   $p_result_list : list of added files with their properties (specially the status field)
1058
+    //   $p_add_dir : Path to add in the filename path archived
1059
+    //   $p_remove_dir : Path to remove in the filename path archived
1060
+    // Return Values :
1061
+    // ---------------------------------------------------------------------------
1062
+    /**
1063
+     * Archive_Zip::_addList()
1064
+     *
1065
+     * { Description }
1066
+     *
1067
+     */
1068
+    public function _addList($p_list, &$p_result_list,
1069 1069
                     $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params)
1070
-  {
1071
-      $v_result=1;
1070
+    {
1071
+        $v_result=1;
1072 1072
 
1073 1073
     // ----- Add the files
1074 1074
     $v_header_list = array();
1075
-      if (($v_result = $this->_addFileList($p_list, $v_header_list,
1076
-                                         $p_add_dir, $p_remove_dir,
1077
-                                         $p_remove_all_dir, $p_params)) != 1) {
1078
-          return $v_result;
1079
-      }
1075
+        if (($v_result = $this->_addFileList($p_list, $v_header_list,
1076
+                                            $p_add_dir, $p_remove_dir,
1077
+                                            $p_remove_all_dir, $p_params)) != 1) {
1078
+            return $v_result;
1079
+        }
1080 1080
 
1081 1081
     // ----- Store the offset of the central dir
1082 1082
     $v_offset = @ftell($this->_zip_fd);
@@ -1084,15 +1084,15 @@  discard block
 block discarded – undo
1084 1084
     // ----- Create the Central Dir files header
1085 1085
     for ($i=0, $v_count=0; $i < count($v_header_list); $i++) {
1086 1086
         // ----- Create the file header
1087
-      if ($v_header_list[$i]['status'] == 'ok') {
1088
-          if (($v_result = $this->_writeCentralFileHeader($v_header_list[$i])) != 1) {
1089
-              return $v_result;
1090
-          }
1091
-          $v_count++;
1092
-      }
1087
+        if ($v_header_list[$i]['status'] == 'ok') {
1088
+            if (($v_result = $this->_writeCentralFileHeader($v_header_list[$i])) != 1) {
1089
+                return $v_result;
1090
+            }
1091
+            $v_count++;
1092
+        }
1093 1093
 
1094
-      // ----- Transform the header to a 'usable' info
1095
-      $this->_convertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
1094
+        // ----- Transform the header to a 'usable' info
1095
+        $this->_convertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
1096 1096
     }
1097 1097
 
1098 1098
     // ----- Zip file comment
@@ -1105,42 +1105,42 @@  discard block
 block discarded – undo
1105 1105
     if (($v_result = $this->_writeCentralHeader($v_count, $v_size, $v_offset,
1106 1106
                                                 $v_comment)) != 1) {
1107 1107
         // ----- Reset the file list
1108
-      unset($v_header_list);
1108
+        unset($v_header_list);
1109 1109
 
1110
-      // ----- Return
1111
-      return $v_result;
1110
+        // ----- Return
1111
+        return $v_result;
1112 1112
     }
1113 1113
 
1114 1114
     // ----- Return
1115 1115
     return $v_result;
1116
-  }
1117
-  // ---------------------------------------------------------------------------
1118
-
1119
-  // ---------------------------------------------------------------------------
1120
-  // Function : _addFileList()
1121
-  // Description :
1122
-  //   $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
1123
-  //   different from the real path of the file. This is usefull if you want to
1124
-  //   run the lib in any directory, and memorize relative path from an other directory.
1125
-  // Parameters :
1126
-  //   $p_list : An array containing the file or directory names to add in the tar
1127
-  //   $p_result_list : list of added files with their properties (specially the status field)
1128
-  //   $p_add_dir : Path to add in the filename path archived
1129
-  //   $p_remove_dir : Path to remove in the filename path archived
1130
-  // Return Values :
1131
-  // ---------------------------------------------------------------------------
1132
-  /**
1133
-  * Archive_Zip::_addFileList()
1134
-  *
1135
-  * { Description }
1136
-  *
1137
-  */
1138
-  public function _addFileList($p_list, &$p_result_list,
1116
+    }
1117
+    // ---------------------------------------------------------------------------
1118
+
1119
+    // ---------------------------------------------------------------------------
1120
+    // Function : _addFileList()
1121
+    // Description :
1122
+    //   $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
1123
+    //   different from the real path of the file. This is usefull if you want to
1124
+    //   run the lib in any directory, and memorize relative path from an other directory.
1125
+    // Parameters :
1126
+    //   $p_list : An array containing the file or directory names to add in the tar
1127
+    //   $p_result_list : list of added files with their properties (specially the status field)
1128
+    //   $p_add_dir : Path to add in the filename path archived
1129
+    //   $p_remove_dir : Path to remove in the filename path archived
1130
+    // Return Values :
1131
+    // ---------------------------------------------------------------------------
1132
+    /**
1133
+     * Archive_Zip::_addFileList()
1134
+     *
1135
+     * { Description }
1136
+     *
1137
+     */
1138
+    public function _addFileList($p_list, &$p_result_list,
1139 1139
                         $p_add_dir, $p_remove_dir, $p_remove_all_dir,
1140 1140
                         &$p_params)
1141
-  {
1142
-      $v_result=1;
1143
-      $v_header = array();
1141
+    {
1142
+        $v_result=1;
1143
+        $v_header = array();
1144 1144
 
1145 1145
     // ----- Recuperate the current number of elt in list
1146 1146
     $v_nb = count($p_result_list);
@@ -1148,34 +1148,34 @@  discard block
 block discarded – undo
1148 1148
     // ----- Loop on the files
1149 1149
     for ($j=0; ($j<count($p_list)) && ($v_result==1); $j++) {
1150 1150
         // ----- Recuperate the filename
1151
-      $p_filename = $this->_tool_TranslateWinPath($p_list[$j], false);
1152
-
1153
-      // ----- Skip empty file names
1154
-      if ($p_filename == '') {
1155
-          continue;
1156
-      }
1157
-
1158
-      // ----- Check the filename
1159
-      if (!file_exists($p_filename)) {
1160
-          $this->_errorLog(ARCHIVE_ZIP_ERR_MISSING_FILE,
1161
-                         "File '$p_filename' does not exists");
1162
-          return Archive_Zip::errorCode();
1163
-      }
1164
-
1165
-      // ----- Look if it is a file or a dir with no all pathnre move
1166
-      if (is_file($p_filename) || (is_dir($p_filename) && !$p_remove_all_dir)) {
1167
-          // ----- Add the file
1151
+        $p_filename = $this->_tool_TranslateWinPath($p_list[$j], false);
1152
+
1153
+        // ----- Skip empty file names
1154
+        if ($p_filename == '') {
1155
+            continue;
1156
+        }
1157
+
1158
+        // ----- Check the filename
1159
+        if (!file_exists($p_filename)) {
1160
+            $this->_errorLog(ARCHIVE_ZIP_ERR_MISSING_FILE,
1161
+                            "File '$p_filename' does not exists");
1162
+            return Archive_Zip::errorCode();
1163
+        }
1164
+
1165
+        // ----- Look if it is a file or a dir with no all pathnre move
1166
+        if (is_file($p_filename) || (is_dir($p_filename) && !$p_remove_all_dir)) {
1167
+            // ----- Add the file
1168 1168
         if (($v_result = $this->_addFile($p_filename, $v_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_params)) != 1) {
1169 1169
             // ----- Return status
1170
-          return $v_result;
1170
+            return $v_result;
1171 1171
         }
1172 1172
 
1173 1173
         // ----- Store the file infos
1174 1174
         $p_result_list[$v_nb++] = $v_header;
1175
-      }
1175
+        }
1176 1176
 
1177
-      // ----- Look for directory
1178
-      if (is_dir($p_filename)) {
1177
+        // ----- Look for directory
1178
+        if (is_dir($p_filename)) {
1179 1179
 
1180 1180
         // ----- Look for path
1181 1181
         if ($p_filename != '.') {
@@ -1186,67 +1186,67 @@  discard block
 block discarded – undo
1186 1186
 
1187 1187
         // ----- Read the directory for files and sub-directories
1188 1188
         $p_hdir = opendir($p_filename);
1189
-          $p_hitem = readdir($p_hdir); // '.' directory
1189
+            $p_hitem = readdir($p_hdir); // '.' directory
1190 1190
         $p_hitem = readdir($p_hdir); // '..' directory
1191 1191
         while ($p_hitem = readdir($p_hdir)) {
1192 1192
 
1193
-          // ----- Look for a file
1194
-          if (is_file($v_path.$p_hitem)) {
1193
+            // ----- Look for a file
1194
+            if (is_file($v_path.$p_hitem)) {
1195 1195
 
1196 1196
             // ----- Add the file
1197 1197
             if (($v_result = $this->_addFile($v_path.$p_hitem, $v_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_params)) != 1) {
1198 1198
                 // ----- Return status
1199
-              return $v_result;
1199
+                return $v_result;
1200 1200
             }
1201 1201
 
1202 1202
             // ----- Store the file infos
1203 1203
             $p_result_list[$v_nb++] = $v_header;
1204
-          }
1204
+            }
1205 1205
 
1206
-          // ----- Recursive call to _addFileList()
1207
-          else {
1206
+            // ----- Recursive call to _addFileList()
1207
+            else {
1208 1208
 
1209 1209
             // ----- Need an array as parameter
1210 1210
             $p_temp_list[0] = $v_path.$p_hitem;
1211
-              $v_result = $this->_addFileList($p_temp_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_params);
1211
+                $v_result = $this->_addFileList($p_temp_list, $p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, $p_params);
1212 1212
 
1213 1213
             // ----- Update the number of elements of the list
1214 1214
             $v_nb = count($p_result_list);
1215
-          }
1215
+            }
1216 1216
         }
1217 1217
 
1218 1218
         // ----- Free memory for the recursive loop
1219 1219
         unset($p_temp_list, $p_hdir, $p_hitem);
1220
-      }
1221
-    }
1222
-
1223
-      return $v_result;
1224
-  }
1225
-  // ---------------------------------------------------------------------------
1226
-
1227
-  // ---------------------------------------------------------------------------
1228
-  // Function : _addFile()
1229
-  // Description :
1230
-  // Parameters :
1231
-  // Return Values :
1232
-  // ---------------------------------------------------------------------------
1233
-  /**
1234
-  * Archive_Zip::_addFile()
1235
-  *
1236
-  * { Description }
1237
-  *
1238
-  */
1239
-  public function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params)
1240
-  {
1241
-      $v_result=1;
1242
-
1243
-      if ($p_filename == '') {
1244
-          // ----- Error log
1245
-      $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, 'Invalid file list parameter (invalid or empty list)');
1220
+        }
1221
+    }
1246 1222
 
1247
-      // ----- Return
1248
-      return Archive_Zip::errorCode();
1249
-      }
1223
+        return $v_result;
1224
+    }
1225
+    // ---------------------------------------------------------------------------
1226
+
1227
+    // ---------------------------------------------------------------------------
1228
+    // Function : _addFile()
1229
+    // Description :
1230
+    // Parameters :
1231
+    // Return Values :
1232
+    // ---------------------------------------------------------------------------
1233
+    /**
1234
+     * Archive_Zip::_addFile()
1235
+     *
1236
+     * { Description }
1237
+     *
1238
+     */
1239
+    public function _addFile($p_filename, &$p_header, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_params)
1240
+    {
1241
+        $v_result=1;
1242
+
1243
+        if ($p_filename == '') {
1244
+            // ----- Error log
1245
+        $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER, 'Invalid file list parameter (invalid or empty list)');
1246
+
1247
+        // ----- Return
1248
+        return Archive_Zip::errorCode();
1249
+        }
1250 1250
 
1251 1251
     // ----- Calculate the stored filename
1252 1252
     $v_stored_filename = $p_filename;
@@ -1309,51 +1309,51 @@  discard block
 block discarded – undo
1309 1309
 
1310 1310
     // ----- Set the file properties
1311 1311
     clearstatcache();
1312
-      $p_header['version'] = 20;
1313
-      $p_header['version_extracted'] = 10;
1314
-      $p_header['flag'] = 0;
1315
-      $p_header['compression'] = 0;
1316
-      $p_header['mtime'] = filemtime($p_filename);
1317
-      $p_header['crc'] = 0;
1318
-      $p_header['compressed_size'] = 0;
1319
-      $p_header['size'] = filesize($p_filename);
1320
-      $p_header['filename_len'] = strlen($p_filename);
1321
-      $p_header['extra_len'] = 0;
1322
-      $p_header['comment_len'] = 0;
1323
-      $p_header['disk'] = 0;
1324
-      $p_header['internal'] = 0;
1325
-      $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010);
1326
-      $p_header['offset'] = 0;
1327
-      $p_header['filename'] = $p_filename;
1328
-      $p_header['stored_filename'] = $v_stored_filename;
1329
-      $p_header['extra'] = '';
1330
-      $p_header['comment'] = '';
1331
-      $p_header['status'] = 'ok';
1332
-      $p_header['index'] = -1;
1312
+        $p_header['version'] = 20;
1313
+        $p_header['version_extracted'] = 10;
1314
+        $p_header['flag'] = 0;
1315
+        $p_header['compression'] = 0;
1316
+        $p_header['mtime'] = filemtime($p_filename);
1317
+        $p_header['crc'] = 0;
1318
+        $p_header['compressed_size'] = 0;
1319
+        $p_header['size'] = filesize($p_filename);
1320
+        $p_header['filename_len'] = strlen($p_filename);
1321
+        $p_header['extra_len'] = 0;
1322
+        $p_header['comment_len'] = 0;
1323
+        $p_header['disk'] = 0;
1324
+        $p_header['internal'] = 0;
1325
+        $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010);
1326
+        $p_header['offset'] = 0;
1327
+        $p_header['filename'] = $p_filename;
1328
+        $p_header['stored_filename'] = $v_stored_filename;
1329
+        $p_header['extra'] = '';
1330
+        $p_header['comment'] = '';
1331
+        $p_header['status'] = 'ok';
1332
+        $p_header['index'] = -1;
1333 1333
 
1334 1334
     // ----- Look for pre-add callback
1335 1335
     if (isset($p_params[ARCHIVE_ZIP_PARAM_PRE_ADD])
1336 1336
         && ($p_params[ARCHIVE_ZIP_PARAM_PRE_ADD] != '')) {
1337 1337
 
1338
-      // ----- Generate a local information
1339
-      $v_local_header = array();
1338
+        // ----- Generate a local information
1339
+        $v_local_header = array();
1340 1340
         $this->_convertHeader2FileInfo($p_header, $v_local_header);
1341 1341
 
1342
-      // ----- Call the callback
1343
-      // Here I do not use call_user_func() because I need to send a reference to the
1344
-      // header.
1345
-      eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_PRE_ADD].'(ARCHIVE_ZIP_PARAM_PRE_ADD, $v_local_header);');
1342
+        // ----- Call the callback
1343
+        // Here I do not use call_user_func() because I need to send a reference to the
1344
+        // header.
1345
+        eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_PRE_ADD].'(ARCHIVE_ZIP_PARAM_PRE_ADD, $v_local_header);');
1346 1346
         if ($v_result == 0) {
1347 1347
             // ----- Change the file status
1348 1348
         $p_header['status'] = 'skipped';
1349 1349
             $v_result = 1;
1350 1350
         }
1351 1351
 
1352
-      // ----- Update the informations
1353
-      // Only some fields can be modified
1354
-      if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
1355
-          $p_header['stored_filename'] = $this->_tool_PathReduction($v_local_header['stored_filename']);
1356
-      }
1352
+        // ----- Update the informations
1353
+        // Only some fields can be modified
1354
+        if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
1355
+            $p_header['stored_filename'] = $this->_tool_PathReduction($v_local_header['stored_filename']);
1356
+        }
1357 1357
     }
1358 1358
 
1359 1359
     // ----- Look for empty stored filename
@@ -1369,34 +1369,34 @@  discard block
 block discarded – undo
1369 1369
     // ----- Look if no error, or file not skipped
1370 1370
     if ($p_header['status'] == 'ok') {
1371 1371
 
1372
-      // ----- Look for a file
1373
-      if (is_file($p_filename)) {
1374
-          // ----- Open the source file
1372
+        // ----- Look for a file
1373
+        if (is_file($p_filename)) {
1374
+            // ----- Open the source file
1375 1375
         if (($v_file = @fopen($p_filename, 'rb')) == 0) {
1376 1376
             $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
1377 1377
             return Archive_Zip::errorCode();
1378 1378
         }
1379 1379
 
1380
-          if ($p_params['no_compression']) {
1381
-              // ----- Read the file content
1382
-          $v_content_compressed = @fread($v_file, $p_header['size']);
1380
+            if ($p_params['no_compression']) {
1381
+                // ----- Read the file content
1382
+            $v_content_compressed = @fread($v_file, $p_header['size']);
1383 1383
 
1384
-          // ----- Calculate the CRC
1385
-          $p_header['crc'] = crc32($v_content_compressed);
1386
-          } else {
1387
-              // ----- Read the file content
1388
-          $v_content = @fread($v_file, $p_header['size']);
1384
+            // ----- Calculate the CRC
1385
+            $p_header['crc'] = crc32($v_content_compressed);
1386
+            } else {
1387
+                // ----- Read the file content
1388
+            $v_content = @fread($v_file, $p_header['size']);
1389 1389
 
1390
-          // ----- Calculate the CRC
1391
-          $p_header['crc'] = crc32($v_content);
1390
+            // ----- Calculate the CRC
1391
+            $p_header['crc'] = crc32($v_content);
1392 1392
 
1393
-          // ----- Compress the file
1394
-          $v_content_compressed = gzdeflate($v_content);
1395
-          }
1393
+            // ----- Compress the file
1394
+            $v_content_compressed = gzdeflate($v_content);
1395
+            }
1396 1396
 
1397 1397
         // ----- Set header parameters
1398 1398
         $p_header['compressed_size'] = strlen($v_content_compressed);
1399
-          $p_header['compression'] = 8;
1399
+            $p_header['compression'] = 8;
1400 1400
 
1401 1401
         // ----- Call the header generation
1402 1402
         if (($v_result = $this->_writeFileHeader($p_header)) != 1) {
@@ -1406,68 +1406,68 @@  discard block
 block discarded – undo
1406 1406
 
1407 1407
         // ----- Write the compressed content
1408 1408
         $v_binary_data = pack('a'.$p_header['compressed_size'], $v_content_compressed);
1409
-          @fwrite($this->_zip_fd, $v_binary_data, $p_header['compressed_size']);
1409
+            @fwrite($this->_zip_fd, $v_binary_data, $p_header['compressed_size']);
1410 1410
 
1411 1411
         // ----- Close the file
1412 1412
         @fclose($v_file);
1413
-      }
1413
+        }
1414 1414
 
1415
-      // ----- Look for a directory
1416
-      else {
1417
-          // ----- Set the file properties
1415
+        // ----- Look for a directory
1416
+        else {
1417
+            // ----- Set the file properties
1418 1418
         $p_header['filename'] .= '/';
1419
-          $p_header['filename_len']++;
1420
-          $p_header['size'] = 0;
1421
-          $p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked
1419
+            $p_header['filename_len']++;
1420
+            $p_header['size'] = 0;
1421
+            $p_header['external'] = 0x41FF0010;   // Value for a folder : to be checked
1422 1422
 
1423 1423
         // ----- Call the header generation
1424 1424
         if (($v_result = $this->_writeFileHeader($p_header)) != 1) {
1425 1425
             return $v_result;
1426 1426
         }
1427
-      }
1427
+        }
1428 1428
     }
1429 1429
 
1430 1430
     // ----- Look for pre-add callback
1431 1431
     if (isset($p_params[ARCHIVE_ZIP_PARAM_POST_ADD])
1432 1432
         && ($p_params[ARCHIVE_ZIP_PARAM_POST_ADD] != '')) {
1433 1433
 
1434
-      // ----- Generate a local information
1435
-      $v_local_header = array();
1434
+        // ----- Generate a local information
1435
+        $v_local_header = array();
1436 1436
         $this->_convertHeader2FileInfo($p_header, $v_local_header);
1437 1437
 
1438
-      // ----- Call the callback
1439
-      // Here I do not use call_user_func() because I need to send a reference to the
1440
-      // header.
1441
-      eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_POST_ADD].'(ARCHIVE_ZIP_PARAM_POST_ADD, $v_local_header);');
1438
+        // ----- Call the callback
1439
+        // Here I do not use call_user_func() because I need to send a reference to the
1440
+        // header.
1441
+        eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_POST_ADD].'(ARCHIVE_ZIP_PARAM_POST_ADD, $v_local_header);');
1442 1442
         if ($v_result == 0) {
1443 1443
             // ----- Ignored
1444 1444
         $v_result = 1;
1445 1445
         }
1446 1446
 
1447
-      // ----- Update the informations
1448
-      // Nothing can be modified
1447
+        // ----- Update the informations
1448
+        // Nothing can be modified
1449 1449
     }
1450 1450
 
1451 1451
     // ----- Return
1452 1452
     return $v_result;
1453
-  }
1454
-  // ---------------------------------------------------------------------------
1455
-
1456
-  // ---------------------------------------------------------------------------
1457
-  // Function : _writeFileHeader()
1458
-  // Description :
1459
-  // Parameters :
1460
-  // Return Values :
1461
-  // ---------------------------------------------------------------------------
1462
-  /**
1463
-  * Archive_Zip::_writeFileHeader()
1464
-  *
1465
-  * { Description }
1466
-  *
1467
-  */
1468
-  public function _writeFileHeader(&$p_header)
1469
-  {
1470
-      $v_result=1;
1453
+    }
1454
+    // ---------------------------------------------------------------------------
1455
+
1456
+    // ---------------------------------------------------------------------------
1457
+    // Function : _writeFileHeader()
1458
+    // Description :
1459
+    // Parameters :
1460
+    // Return Values :
1461
+    // ---------------------------------------------------------------------------
1462
+    /**
1463
+     * Archive_Zip::_writeFileHeader()
1464
+     *
1465
+     * { Description }
1466
+     *
1467
+     */
1468
+    public function _writeFileHeader(&$p_header)
1469
+    {
1470
+        $v_result=1;
1471 1471
 
1472 1472
     // TBC
1473 1473
     //for(reset($p_header); $key = key($p_header); next($p_header)) {
@@ -1478,14 +1478,14 @@  discard block
 block discarded – undo
1478 1478
 
1479 1479
     // ----- Transform UNIX mtime to DOS format mdate/mtime
1480 1480
     $v_date = getdate($p_header['mtime']);
1481
-      $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
1482
-      $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
1481
+        $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
1482
+        $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
1483 1483
 
1484 1484
     // ----- Packed data
1485 1485
     $v_binary_data = pack('VvvvvvVVVvv', 0x04034b50, $p_header['version'], $p_header['flag'],
1486
-                          $p_header['compression'], $v_mtime, $v_mdate,
1487
-                          $p_header['crc'], $p_header['compressed_size'], $p_header['size'],
1488
-                          strlen($p_header['stored_filename']), $p_header['extra_len']);
1486
+                            $p_header['compression'], $v_mtime, $v_mdate,
1487
+                            $p_header['crc'], $p_header['compressed_size'], $p_header['size'],
1488
+                            strlen($p_header['stored_filename']), $p_header['extra_len']);
1489 1489
 
1490 1490
     // ----- Write the first 148 bytes of the header in the archive
1491 1491
     fwrite($this->_zip_fd, $v_binary_data, 30);
@@ -1494,30 +1494,30 @@  discard block
 block discarded – undo
1494 1494
     if (strlen($p_header['stored_filename']) != 0) {
1495 1495
         fwrite($this->_zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
1496 1496
     }
1497
-      if ($p_header['extra_len'] != 0) {
1498
-          fwrite($this->_zip_fd, $p_header['extra'], $p_header['extra_len']);
1499
-      }
1497
+        if ($p_header['extra_len'] != 0) {
1498
+            fwrite($this->_zip_fd, $p_header['extra'], $p_header['extra_len']);
1499
+        }
1500 1500
 
1501 1501
     // ----- Return
1502 1502
     return $v_result;
1503
-  }
1504
-  // ---------------------------------------------------------------------------
1505
-
1506
-  // ---------------------------------------------------------------------------
1507
-  // Function : _writeCentralFileHeader()
1508
-  // Description :
1509
-  // Parameters :
1510
-  // Return Values :
1511
-  // ---------------------------------------------------------------------------
1512
-  /**
1513
-  * Archive_Zip::_writeCentralFileHeader()
1514
-  *
1515
-  * { Description }
1516
-  *
1517
-  */
1518
-  public function _writeCentralFileHeader(&$p_header)
1519
-  {
1520
-      $v_result=1;
1503
+    }
1504
+    // ---------------------------------------------------------------------------
1505
+
1506
+    // ---------------------------------------------------------------------------
1507
+    // Function : _writeCentralFileHeader()
1508
+    // Description :
1509
+    // Parameters :
1510
+    // Return Values :
1511
+    // ---------------------------------------------------------------------------
1512
+    /**
1513
+     * Archive_Zip::_writeCentralFileHeader()
1514
+     *
1515
+     * { Description }
1516
+     *
1517
+     */
1518
+    public function _writeCentralFileHeader(&$p_header)
1519
+    {
1520
+        $v_result=1;
1521 1521
 
1522 1522
     // TBC
1523 1523
     //for(reset($p_header); $key = key($p_header); next($p_header)) {
@@ -1525,15 +1525,15 @@  discard block
 block discarded – undo
1525 1525
 
1526 1526
     // ----- Transform UNIX mtime to DOS format mdate/mtime
1527 1527
     $v_date = getdate($p_header['mtime']);
1528
-      $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
1529
-      $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
1528
+        $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
1529
+        $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
1530 1530
 
1531 1531
     // ----- Packed data
1532 1532
     $v_binary_data = pack('VvvvvvvVVVvvvvvVV', 0x02014b50, $p_header['version'], $p_header['version_extracted'],
1533
-                          $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'],
1534
-                          $p_header['compressed_size'], $p_header['size'],
1535
-                          strlen($p_header['stored_filename']), $p_header['extra_len'], $p_header['comment_len'],
1536
-                          $p_header['disk'], $p_header['internal'], $p_header['external'], $p_header['offset']);
1533
+                            $p_header['flag'], $p_header['compression'], $v_mtime, $v_mdate, $p_header['crc'],
1534
+                            $p_header['compressed_size'], $p_header['size'],
1535
+                            strlen($p_header['stored_filename']), $p_header['extra_len'], $p_header['comment_len'],
1536
+                            $p_header['disk'], $p_header['internal'], $p_header['external'], $p_header['offset']);
1537 1537
 
1538 1538
     // ----- Write the 42 bytes of the header in the zip file
1539 1539
     fwrite($this->_zip_fd, $v_binary_data, 46);
@@ -1542,33 +1542,33 @@  discard block
 block discarded – undo
1542 1542
     if (strlen($p_header['stored_filename']) != 0) {
1543 1543
         fwrite($this->_zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
1544 1544
     }
1545
-      if ($p_header['extra_len'] != 0) {
1546
-          fwrite($this->_zip_fd, $p_header['extra'], $p_header['extra_len']);
1547
-      }
1548
-      if ($p_header['comment_len'] != 0) {
1549
-          fwrite($this->_zip_fd, $p_header['comment'], $p_header['comment_len']);
1550
-      }
1545
+        if ($p_header['extra_len'] != 0) {
1546
+            fwrite($this->_zip_fd, $p_header['extra'], $p_header['extra_len']);
1547
+        }
1548
+        if ($p_header['comment_len'] != 0) {
1549
+            fwrite($this->_zip_fd, $p_header['comment'], $p_header['comment_len']);
1550
+        }
1551 1551
 
1552 1552
     // ----- Return
1553 1553
     return $v_result;
1554
-  }
1555
-  // ---------------------------------------------------------------------------
1556
-
1557
-  // ---------------------------------------------------------------------------
1558
-  // Function : _writeCentralHeader()
1559
-  // Description :
1560
-  // Parameters :
1561
-  // Return Values :
1562
-  // ---------------------------------------------------------------------------
1563
-  /**
1564
-  * Archive_Zip::_writeCentralHeader()
1565
-  *
1566
-  * { Description }
1567
-  *
1568
-  */
1569
-  public function _writeCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
1570
-  {
1571
-      $v_result=1;
1554
+    }
1555
+    // ---------------------------------------------------------------------------
1556
+
1557
+    // ---------------------------------------------------------------------------
1558
+    // Function : _writeCentralHeader()
1559
+    // Description :
1560
+    // Parameters :
1561
+    // Return Values :
1562
+    // ---------------------------------------------------------------------------
1563
+    /**
1564
+     * Archive_Zip::_writeCentralHeader()
1565
+     *
1566
+     * { Description }
1567
+     *
1568
+     */
1569
+    public function _writeCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
1570
+    {
1571
+        $v_result=1;
1572 1572
 
1573 1573
     // ----- Packed data
1574 1574
     $v_binary_data = pack('VvvvvVVv', 0x06054b50, 0, 0, $p_nb_entries, $p_nb_entries, $p_size, $p_offset, strlen($p_comment));
@@ -1583,60 +1583,60 @@  discard block
 block discarded – undo
1583 1583
 
1584 1584
     // ----- Return
1585 1585
     return $v_result;
1586
-  }
1587
-  // ---------------------------------------------------------------------------
1588
-
1589
-  // ---------------------------------------------------------------------------
1590
-  // Function : _list()
1591
-  // Description :
1592
-  // Parameters :
1593
-  // Return Values :
1594
-  // ---------------------------------------------------------------------------
1595
-  /**
1596
-  * Archive_Zip::_list()
1597
-  *
1598
-  * { Description }
1599
-  *
1600
-  */
1601
-  public function _list(&$p_list)
1602
-  {
1603
-      $v_result=1;
1586
+    }
1587
+    // ---------------------------------------------------------------------------
1588
+
1589
+    // ---------------------------------------------------------------------------
1590
+    // Function : _list()
1591
+    // Description :
1592
+    // Parameters :
1593
+    // Return Values :
1594
+    // ---------------------------------------------------------------------------
1595
+    /**
1596
+     * Archive_Zip::_list()
1597
+     *
1598
+     * { Description }
1599
+     *
1600
+     */
1601
+    public function _list(&$p_list)
1602
+    {
1603
+        $v_result=1;
1604 1604
 
1605 1605
     // ----- Open the zip file
1606 1606
     if (($this->_zip_fd = @fopen($this->_zipname, 'rb')) == 0) {
1607 1607
         // ----- Error log
1608
-      $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->_zipname.'\' in binary read mode');
1608
+        $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->_zipname.'\' in binary read mode');
1609 1609
 
1610
-      // ----- Return
1611
-      return Archive_Zip::errorCode();
1610
+        // ----- Return
1611
+        return Archive_Zip::errorCode();
1612 1612
     }
1613 1613
 
1614 1614
     // ----- Read the central directory informations
1615 1615
     $v_central_dir = array();
1616
-      if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) {
1617
-          return $v_result;
1618
-      }
1616
+        if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) {
1617
+            return $v_result;
1618
+        }
1619 1619
 
1620 1620
     // ----- Go to beginning of Central Dir
1621 1621
     @rewind($this->_zip_fd);
1622
-      if (@fseek($this->_zip_fd, $v_central_dir['offset'])) {
1623
-          // ----- Error log
1624
-      $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
1622
+        if (@fseek($this->_zip_fd, $v_central_dir['offset'])) {
1623
+            // ----- Error log
1624
+        $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
1625 1625
 
1626
-      // ----- Return
1627
-      return Archive_Zip::errorCode();
1628
-      }
1626
+        // ----- Return
1627
+        return Archive_Zip::errorCode();
1628
+        }
1629 1629
 
1630 1630
     // ----- Read each entry
1631 1631
     for ($i=0; $i<$v_central_dir['entries']; $i++) {
1632 1632
         // ----- Read the file header
1633
-      if (($v_result = $this->_readCentralFileHeader($v_header)) != 1) {
1634
-          return $v_result;
1635
-      }
1633
+        if (($v_result = $this->_readCentralFileHeader($v_header)) != 1) {
1634
+            return $v_result;
1635
+        }
1636 1636
         $v_header['index'] = $i;
1637 1637
 
1638
-      // ----- Get the only interesting attributes
1639
-      $this->_convertHeader2FileInfo($v_header, $p_list[$i]);
1638
+        // ----- Get the only interesting attributes
1639
+        $this->_convertHeader2FileInfo($v_header, $p_list[$i]);
1640 1640
         unset($v_header);
1641 1641
     }
1642 1642
 
@@ -1645,82 +1645,82 @@  discard block
 block discarded – undo
1645 1645
 
1646 1646
     // ----- Return
1647 1647
     return $v_result;
1648
-  }
1649
-  // ---------------------------------------------------------------------------
1650
-
1651
-  // ---------------------------------------------------------------------------
1652
-  // Function : _convertHeader2FileInfo()
1653
-  // Description :
1654
-  //   This function takes the file informations from the central directory
1655
-  //   entries and extract the interesting parameters that will be given back.
1656
-  //   The resulting file infos are set in the array $p_info
1657
-  //     $p_info['filename'] : Filename with full path. Given by user (add),
1658
-  //                           extracted in the filesystem (extract).
1659
-  //     $p_info['stored_filename'] : Stored filename in the archive.
1660
-  //     $p_info['size'] = Size of the file.
1661
-  //     $p_info['compressed_size'] = Compressed size of the file.
1662
-  //     $p_info['mtime'] = Last modification date of the file.
1663
-  //     $p_info['comment'] = Comment associated with the file.
1664
-  //     $p_info['folder'] = true/false : indicates if the entry is a folder or not.
1665
-  //     $p_info['status'] = status of the action on the file.
1666
-  // Parameters :
1667
-  // Return Values :
1668
-  // ---------------------------------------------------------------------------
1669
-  /**
1670
-  * Archive_Zip::_convertHeader2FileInfo()
1671
-  *
1672
-  * { Description }
1673
-  *
1674
-  */
1675
-  public function _convertHeader2FileInfo($p_header, &$p_info)
1676
-  {
1677
-      $v_result=1;
1648
+    }
1649
+    // ---------------------------------------------------------------------------
1650
+
1651
+    // ---------------------------------------------------------------------------
1652
+    // Function : _convertHeader2FileInfo()
1653
+    // Description :
1654
+    //   This function takes the file informations from the central directory
1655
+    //   entries and extract the interesting parameters that will be given back.
1656
+    //   The resulting file infos are set in the array $p_info
1657
+    //     $p_info['filename'] : Filename with full path. Given by user (add),
1658
+    //                           extracted in the filesystem (extract).
1659
+    //     $p_info['stored_filename'] : Stored filename in the archive.
1660
+    //     $p_info['size'] = Size of the file.
1661
+    //     $p_info['compressed_size'] = Compressed size of the file.
1662
+    //     $p_info['mtime'] = Last modification date of the file.
1663
+    //     $p_info['comment'] = Comment associated with the file.
1664
+    //     $p_info['folder'] = true/false : indicates if the entry is a folder or not.
1665
+    //     $p_info['status'] = status of the action on the file.
1666
+    // Parameters :
1667
+    // Return Values :
1668
+    // ---------------------------------------------------------------------------
1669
+    /**
1670
+     * Archive_Zip::_convertHeader2FileInfo()
1671
+     *
1672
+     * { Description }
1673
+     *
1674
+     */
1675
+    public function _convertHeader2FileInfo($p_header, &$p_info)
1676
+    {
1677
+        $v_result=1;
1678 1678
 
1679 1679
     // ----- Get the interesting attributes
1680 1680
     $p_info['filename'] = $p_header['filename'];
1681
-      $p_info['stored_filename'] = $p_header['stored_filename'];
1682
-      $p_info['size'] = $p_header['size'];
1683
-      $p_info['compressed_size'] = $p_header['compressed_size'];
1684
-      $p_info['mtime'] = $p_header['mtime'];
1685
-      $p_info['comment'] = $p_header['comment'];
1686
-      $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
1687
-      $p_info['index'] = $p_header['index'];
1688
-      $p_info['status'] = $p_header['status'];
1681
+        $p_info['stored_filename'] = $p_header['stored_filename'];
1682
+        $p_info['size'] = $p_header['size'];
1683
+        $p_info['compressed_size'] = $p_header['compressed_size'];
1684
+        $p_info['mtime'] = $p_header['mtime'];
1685
+        $p_info['comment'] = $p_header['comment'];
1686
+        $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
1687
+        $p_info['index'] = $p_header['index'];
1688
+        $p_info['status'] = $p_header['status'];
1689 1689
 
1690 1690
     // ----- Return
1691 1691
     return $v_result;
1692
-  }
1693
-  // ---------------------------------------------------------------------------
1694
-
1695
-  // ---------------------------------------------------------------------------
1696
-  // Function : _extractByRule()
1697
-  // Description :
1698
-  //   Extract a file or directory depending of rules (by index, by name, ...)
1699
-  // Parameters :
1700
-  //   $p_file_list : An array where will be placed the properties of each
1701
-  //                  extracted file
1702
-  //   $p_path : Path to add while writing the extracted files
1703
-  //   $p_remove_path : Path to remove (from the file memorized path) while writing the
1704
-  //                    extracted files. If the path does not match the file path,
1705
-  //                    the file is extracted with its memorized path.
1706
-  //                    $p_remove_path does not apply to 'list' mode.
1707
-  //                    $p_path and $p_remove_path are commulative.
1708
-  // Return Values :
1709
-  //   1 on success,0 or less on error (see error code list)
1710
-  // ---------------------------------------------------------------------------
1711
-  /**
1712
-  * Archive_Zip::_extractByRule()
1713
-  *
1714
-  * { Description }
1715
-  *
1716
-  */
1717
-  public function _extractByRule(&$p_file_list, &$p_params)
1718
-  {
1719
-      $v_result=1;
1720
-
1721
-      $p_path = $p_params['add_path'];
1722
-      $p_remove_path = $p_params['remove_path'];
1723
-      $p_remove_all_path = $p_params['remove_all_path'];
1692
+    }
1693
+    // ---------------------------------------------------------------------------
1694
+
1695
+    // ---------------------------------------------------------------------------
1696
+    // Function : _extractByRule()
1697
+    // Description :
1698
+    //   Extract a file or directory depending of rules (by index, by name, ...)
1699
+    // Parameters :
1700
+    //   $p_file_list : An array where will be placed the properties of each
1701
+    //                  extracted file
1702
+    //   $p_path : Path to add while writing the extracted files
1703
+    //   $p_remove_path : Path to remove (from the file memorized path) while writing the
1704
+    //                    extracted files. If the path does not match the file path,
1705
+    //                    the file is extracted with its memorized path.
1706
+    //                    $p_remove_path does not apply to 'list' mode.
1707
+    //                    $p_path and $p_remove_path are commulative.
1708
+    // Return Values :
1709
+    //   1 on success,0 or less on error (see error code list)
1710
+    // ---------------------------------------------------------------------------
1711
+    /**
1712
+     * Archive_Zip::_extractByRule()
1713
+     *
1714
+     * { Description }
1715
+     *
1716
+     */
1717
+    public function _extractByRule(&$p_file_list, &$p_params)
1718
+    {
1719
+        $v_result=1;
1720
+
1721
+        $p_path = $p_params['add_path'];
1722
+        $p_remove_path = $p_params['remove_path'];
1723
+        $p_remove_all_path = $p_params['remove_all_path'];
1724 1724
 
1725 1725
     // ----- Check the path
1726 1726
     if (($p_path == '')
@@ -1732,16 +1732,16 @@  discard block
 block discarded – undo
1732 1732
     // ----- Reduce the path last (and duplicated) '/'
1733 1733
     if (($p_path != './') && ($p_path != '/')) {
1734 1734
         // ----- Look for the path end '/'
1735
-      while (substr($p_path, -1) == '/') {
1736
-          $p_path = substr($p_path, 0, strlen($p_path)-1);
1737
-      }
1735
+        while (substr($p_path, -1) == '/') {
1736
+            $p_path = substr($p_path, 0, strlen($p_path)-1);
1737
+        }
1738 1738
     }
1739 1739
 
1740 1740
     // ----- Look for path to remove format (should end by /)
1741 1741
     if (($p_remove_path != '') && (substr($p_remove_path, -1) != '/')) {
1742 1742
         $p_remove_path .= '/';
1743 1743
     }
1744
-      $p_remove_path_size = strlen($p_remove_path);
1744
+        $p_remove_path_size = strlen($p_remove_path);
1745 1745
 
1746 1746
     // ----- Open the zip file
1747 1747
     if (($v_result = $this->_openFd('rb')) != 1) {
@@ -1750,202 +1750,202 @@  discard block
 block discarded – undo
1750 1750
 
1751 1751
     // ----- Read the central directory informations
1752 1752
     $v_central_dir = array();
1753
-      if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) {
1754
-          // ----- Close the zip file
1755
-      $this->_closeFd();
1753
+        if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) {
1754
+            // ----- Close the zip file
1755
+        $this->_closeFd();
1756 1756
 
1757
-          return $v_result;
1758
-      }
1757
+            return $v_result;
1758
+        }
1759 1759
 
1760 1760
     // ----- Start at beginning of Central Dir
1761 1761
     $v_pos_entry = $v_central_dir['offset'];
1762 1762
 
1763 1763
     // ----- Read each entry
1764 1764
     $j_start = 0;
1765
-      for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) {
1766
-          // ----- Read next Central dir entry
1767
-      @rewind($this->_zip_fd);
1768
-          if (@fseek($this->_zip_fd, $v_pos_entry)) {
1769
-              $this->_closeFd();
1765
+        for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) {
1766
+            // ----- Read next Central dir entry
1767
+        @rewind($this->_zip_fd);
1768
+            if (@fseek($this->_zip_fd, $v_pos_entry)) {
1769
+                $this->_closeFd();
1770 1770
 
1771
-              $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP,
1772
-                         'Invalid archive size');
1771
+                $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP,
1772
+                            'Invalid archive size');
1773 1773
 
1774
-              return Archive_Zip::errorCode();
1775
-          }
1774
+                return Archive_Zip::errorCode();
1775
+            }
1776 1776
 
1777
-      // ----- Read the file header
1778
-      $v_header = array();
1779
-          if (($v_result = $this->_readCentralFileHeader($v_header)) != 1) {
1780
-              $this->_closeFd();
1777
+        // ----- Read the file header
1778
+        $v_header = array();
1779
+            if (($v_result = $this->_readCentralFileHeader($v_header)) != 1) {
1780
+                $this->_closeFd();
1781 1781
 
1782
-              return $v_result;
1783
-          }
1782
+                return $v_result;
1783
+            }
1784 1784
 
1785
-      // ----- Store the index
1786
-      $v_header['index'] = $i;
1785
+        // ----- Store the index
1786
+        $v_header['index'] = $i;
1787 1787
 
1788
-      // ----- Store the file position
1789
-      $v_pos_entry = ftell($this->_zip_fd);
1788
+        // ----- Store the file position
1789
+        $v_pos_entry = ftell($this->_zip_fd);
1790 1790
 
1791
-      // ----- Look for the specific extract rules
1792
-      $v_extract = false;
1791
+        // ----- Look for the specific extract rules
1792
+        $v_extract = false;
1793 1793
 
1794
-      // ----- Look for extract by name rule
1795
-      if (isset($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])
1794
+        // ----- Look for extract by name rule
1795
+        if (isset($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])
1796 1796
           && ($p_params[ARCHIVE_ZIP_PARAM_BY_NAME] != 0)) {
1797 1797
 
1798
-          // ----- Look if the filename is in the list
1799
-          for ($j=0;
1800
-                  ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_NAME]))
1798
+            // ----- Look if the filename is in the list
1799
+            for ($j=0;
1800
+                    ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_NAME]))
1801 1801
                && (!$v_extract);
1802
-               $j++) {
1802
+                $j++) {
1803 1803
 
1804
-              // ----- Look for a directory
1805
-              if (substr($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j], -1) == '/') {
1804
+                // ----- Look for a directory
1805
+                if (substr($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j], -1) == '/') {
1806 1806
 
1807
-                  // ----- Look if the directory is in the filename path
1808
-                  if ((strlen($v_header['stored_filename']) > strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]))
1807
+                    // ----- Look if the directory is in the filename path
1808
+                    if ((strlen($v_header['stored_filename']) > strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]))
1809 1809
                       && (substr($v_header['stored_filename'], 0, strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) {
1810
-                      $v_extract = true;
1811
-                  }
1812
-              }
1813
-              // ----- Look for a filename
1814
-              elseif ($v_header['stored_filename'] == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]) {
1815
-                  $v_extract = true;
1816
-              }
1817
-          }
1818
-      }
1819
-
1820
-      // ----- Look for extract by ereg rule
1821
-      elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_EREG])
1810
+                        $v_extract = true;
1811
+                    }
1812
+                }
1813
+                // ----- Look for a filename
1814
+                elseif ($v_header['stored_filename'] == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]) {
1815
+                    $v_extract = true;
1816
+                }
1817
+            }
1818
+        }
1819
+
1820
+        // ----- Look for extract by ereg rule
1821
+        elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_EREG])
1822 1822
               && ($p_params[ARCHIVE_ZIP_PARAM_BY_EREG] != '')) {
1823
-          if (ereg($p_params[ARCHIVE_ZIP_PARAM_BY_EREG], $v_header['stored_filename'])) {
1824
-              $v_extract = true;
1825
-          }
1826
-      }
1823
+            if (ereg($p_params[ARCHIVE_ZIP_PARAM_BY_EREG], $v_header['stored_filename'])) {
1824
+                $v_extract = true;
1825
+            }
1826
+        }
1827 1827
 
1828
-      // ----- Look for extract by preg rule
1829
-      elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_PREG])
1828
+        // ----- Look for extract by preg rule
1829
+        elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_PREG])
1830 1830
               && ($p_params[ARCHIVE_ZIP_PARAM_BY_PREG] != '')) {
1831
-          if (preg_match($p_params[ARCHIVE_ZIP_PARAM_BY_PREG], $v_header['stored_filename'])) {
1832
-              $v_extract = true;
1833
-          }
1834
-      }
1831
+            if (preg_match($p_params[ARCHIVE_ZIP_PARAM_BY_PREG], $v_header['stored_filename'])) {
1832
+                $v_extract = true;
1833
+            }
1834
+        }
1835 1835
 
1836
-      // ----- Look for extract by index rule
1837
-      elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])
1836
+        // ----- Look for extract by index rule
1837
+        elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])
1838 1838
               && ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX] != 0)) {
1839 1839
 
1840
-          // ----- Look if the index is in the list
1841
-          for ($j=$j_start; ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) && (!$v_extract); $j++) {
1842
-              if (($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']) && ($i<=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) {
1843
-                  $v_extract = true;
1844
-              }
1845
-              if ($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) {
1846
-                  $j_start = $j+1;
1847
-              }
1848
-
1849
-              if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']>$i) {
1850
-                  break;
1851
-              }
1852
-          }
1853
-      }
1840
+            // ----- Look if the index is in the list
1841
+            for ($j=$j_start; ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])) && (!$v_extract); $j++) {
1842
+                if (($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']) && ($i<=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) {
1843
+                    $v_extract = true;
1844
+                }
1845
+                if ($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) {
1846
+                    $j_start = $j+1;
1847
+                }
1848
+
1849
+                if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']>$i) {
1850
+                    break;
1851
+                }
1852
+            }
1853
+        }
1854 1854
 
1855
-      // ----- Look for no rule, which means extract all the archive
1856
-      else {
1857
-          $v_extract = true;
1858
-      }
1855
+        // ----- Look for no rule, which means extract all the archive
1856
+        else {
1857
+            $v_extract = true;
1858
+        }
1859 1859
 
1860 1860
 
1861
-      // ----- Look for real extraction
1862
-      if ($v_extract) {
1861
+        // ----- Look for real extraction
1862
+        if ($v_extract) {
1863 1863
 
1864 1864
         // ----- Go to the file position
1865 1865
         @rewind($this->_zip_fd);
1866
-          if (@fseek($this->_zip_fd, $v_header['offset'])) {
1867
-              // ----- Close the zip file
1868
-          $this->_closeFd();
1866
+            if (@fseek($this->_zip_fd, $v_header['offset'])) {
1867
+                // ----- Close the zip file
1868
+            $this->_closeFd();
1869 1869
 
1870
-          // ----- Error log
1871
-          $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
1870
+            // ----- Error log
1871
+            $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
1872 1872
 
1873
-          // ----- Return
1874
-          return Archive_Zip::errorCode();
1875
-          }
1873
+            // ----- Return
1874
+            return Archive_Zip::errorCode();
1875
+            }
1876 1876
 
1877 1877
         // ----- Look for extraction as string
1878 1878
         if ($p_params[ARCHIVE_ZIP_PARAM_EXTRACT_AS_STRING]) {
1879 1879
 
1880
-          // ----- Extracting the file
1881
-          if (($v_result = $this->_extractFileAsString($v_header, $v_string)) != 1) {
1882
-              // ----- Close the zip file
1880
+            // ----- Extracting the file
1881
+            if (($v_result = $this->_extractFileAsString($v_header, $v_string)) != 1) {
1882
+                // ----- Close the zip file
1883 1883
             $this->_closeFd();
1884 1884
 
1885
-              return $v_result;
1886
-          }
1885
+                return $v_result;
1886
+            }
1887 1887
 
1888
-          // ----- Get the only interesting attributes
1889
-          if (($v_result = $this->_convertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) {
1890
-              // ----- Close the zip file
1888
+            // ----- Get the only interesting attributes
1889
+            if (($v_result = $this->_convertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1) {
1890
+                // ----- Close the zip file
1891 1891
             $this->_closeFd();
1892 1892
 
1893
-              return $v_result;
1894
-          }
1893
+                return $v_result;
1894
+            }
1895 1895
 
1896
-          // ----- Set the file content
1897
-          $p_file_list[$v_nb_extracted]['content'] = $v_string;
1896
+            // ----- Set the file content
1897
+            $p_file_list[$v_nb_extracted]['content'] = $v_string;
1898 1898
 
1899
-          // ----- Next extracted file
1900
-          $v_nb_extracted++;
1899
+            // ----- Next extracted file
1900
+            $v_nb_extracted++;
1901 1901
         } else {
1902 1902
             // ----- Extracting the file
1903
-          if (($v_result = $this->_extractFile($v_header, $p_path, $p_remove_path, $p_remove_all_path, $p_params)) != 1) {
1904
-              // ----- Close the zip file
1903
+            if (($v_result = $this->_extractFile($v_header, $p_path, $p_remove_path, $p_remove_all_path, $p_params)) != 1) {
1904
+                // ----- Close the zip file
1905 1905
             $this->_closeFd();
1906 1906
 
1907
-              return $v_result;
1908
-          }
1907
+                return $v_result;
1908
+            }
1909 1909
 
1910
-          // ----- Get the only interesting attributes
1911
-          if (($v_result = $this->_convertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
1912
-              // ----- Close the zip file
1910
+            // ----- Get the only interesting attributes
1911
+            if (($v_result = $this->_convertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
1912
+                // ----- Close the zip file
1913 1913
             $this->_closeFd();
1914 1914
 
1915
-              return $v_result;
1916
-          }
1915
+                return $v_result;
1916
+            }
1917
+        }
1918
+        }
1917 1919
         }
1918
-      }
1919
-      }
1920 1920
 
1921 1921
     // ----- Close the zip file
1922 1922
     $this->_closeFd();
1923 1923
 
1924 1924
     // ----- Return
1925 1925
     return $v_result;
1926
-  }
1927
-  // ---------------------------------------------------------------------------
1928
-
1929
-  // ---------------------------------------------------------------------------
1930
-  // Function : _extractFile()
1931
-  // Description :
1932
-  // Parameters :
1933
-  // Return Values :
1934
-  // ---------------------------------------------------------------------------
1935
-  /**
1936
-  * Archive_Zip::_extractFile()
1937
-  *
1938
-  * { Description }
1939
-  *
1940
-  */
1941
-  public function _extractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_params)
1942
-  {
1943
-      $v_result=1;
1926
+    }
1927
+    // ---------------------------------------------------------------------------
1928
+
1929
+    // ---------------------------------------------------------------------------
1930
+    // Function : _extractFile()
1931
+    // Description :
1932
+    // Parameters :
1933
+    // Return Values :
1934
+    // ---------------------------------------------------------------------------
1935
+    /**
1936
+     * Archive_Zip::_extractFile()
1937
+     *
1938
+     * { Description }
1939
+     *
1940
+     */
1941
+    public function _extractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_params)
1942
+    {
1943
+        $v_result=1;
1944 1944
 
1945 1945
     // ----- Read the file header
1946 1946
     if (($v_result = $this->_readFileHeader($v_header)) != 1) {
1947 1947
         // ----- Return
1948
-      return $v_result;
1948
+        return $v_result;
1949 1949
     }
1950 1950
 
1951 1951
 
@@ -1961,14 +1961,14 @@  discard block
 block discarded – undo
1961 1961
     // ----- Look for path to remove
1962 1962
     elseif ($p_remove_path != '') {
1963 1963
         //if (strcmp($p_remove_path, $p_entry['filename'])==0)
1964
-      if ($this->_tool_PathInclusion($p_remove_path, $p_entry['filename']) == 2) {
1964
+        if ($this->_tool_PathInclusion($p_remove_path, $p_entry['filename']) == 2) {
1965 1965
 
1966 1966
         // ----- Change the file status
1967 1967
         $p_entry['status'] = 'filtered';
1968 1968
 
1969 1969
         // ----- Return
1970 1970
         return $v_result;
1971
-      }
1971
+        }
1972 1972
 
1973 1973
         $p_remove_path_size = strlen($p_remove_path);
1974 1974
         if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path) {
@@ -1987,23 +1987,23 @@  discard block
 block discarded – undo
1987 1987
     if (isset($p_params[ARCHIVE_ZIP_PARAM_PRE_EXTRACT])
1988 1988
         && ($p_params[ARCHIVE_ZIP_PARAM_PRE_EXTRACT] != '')) {
1989 1989
 
1990
-      // ----- Generate a local information
1991
-      $v_local_header = array();
1990
+        // ----- Generate a local information
1991
+        $v_local_header = array();
1992 1992
         $this->_convertHeader2FileInfo($p_entry, $v_local_header);
1993 1993
 
1994
-      // ----- Call the callback
1995
-      // Here I do not use call_user_func() because I need to send a reference to the
1996
-      // header.
1997
-      eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_PRE_EXTRACT].'(ARCHIVE_ZIP_PARAM_PRE_EXTRACT, $v_local_header);');
1994
+        // ----- Call the callback
1995
+        // Here I do not use call_user_func() because I need to send a reference to the
1996
+        // header.
1997
+        eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_PRE_EXTRACT].'(ARCHIVE_ZIP_PARAM_PRE_EXTRACT, $v_local_header);');
1998 1998
         if ($v_result == 0) {
1999 1999
             // ----- Change the file status
2000 2000
         $p_entry['status'] = 'skipped';
2001 2001
             $v_result = 1;
2002 2002
         }
2003 2003
 
2004
-      // ----- Update the informations
2005
-      // Only some fields can be modified
2006
-      $p_entry['filename'] = $v_local_header['filename'];
2004
+        // ----- Update the informations
2005
+        // Only some fields can be modified
2006
+        $p_entry['filename'] = $v_local_header['filename'];
2007 2007
     }
2008 2008
 
2009 2009
     // ----- Trace
@@ -2014,34 +2014,34 @@  discard block
 block discarded – undo
2014 2014
     // ----- Look for specific actions while the file exist
2015 2015
     if (file_exists($p_entry['filename'])) {
2016 2016
 
2017
-      // ----- Look if file is a directory
2018
-      if (is_dir($p_entry['filename'])) {
2017
+        // ----- Look if file is a directory
2018
+        if (is_dir($p_entry['filename'])) {
2019 2019
 
2020 2020
         // ----- Change the file status
2021 2021
         $p_entry['status'] = 'already_a_directory';
2022 2022
 
2023 2023
         // ----- Return
2024 2024
         //return $v_result;
2025
-      }
2026
-      // ----- Look if file is write protected
2027
-      elseif (!is_writable($p_entry['filename'])) {
2025
+        }
2026
+        // ----- Look if file is write protected
2027
+        elseif (!is_writable($p_entry['filename'])) {
2028 2028
 
2029 2029
         // ----- Change the file status
2030 2030
         $p_entry['status'] = 'write_protected';
2031 2031
 
2032 2032
         // ----- Return
2033 2033
         //return $v_result;
2034
-      }
2034
+        }
2035 2035
 
2036
-      // ----- Look if the extracted file is older
2037
-      elseif (filemtime($p_entry['filename']) > $p_entry['mtime']) {
2036
+        // ----- Look if the extracted file is older
2037
+        elseif (filemtime($p_entry['filename']) > $p_entry['mtime']) {
2038 2038
 
2039 2039
         // ----- Change the file status
2040 2040
         $p_entry['status'] = 'newer_exist';
2041 2041
 
2042 2042
         // ----- Return
2043 2043
         //return $v_result;
2044
-      }
2044
+        }
2045 2045
     }
2046 2046
 
2047 2047
     // ----- Check the directory availability and create it if necessary
@@ -2069,25 +2069,25 @@  discard block
 block discarded – undo
2069 2069
     // ----- Look if extraction should be done
2070 2070
     if ($p_entry['status'] == 'ok') {
2071 2071
 
2072
-      // ----- Do the extraction (if not a folder)
2073
-      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
2072
+        // ----- Do the extraction (if not a folder)
2073
+        if (!(($p_entry['external']&0x00000010)==0x00000010)) {
2074 2074
 
2075 2075
         // ----- Look for not compressed file
2076 2076
         if ($p_entry['compressed_size'] == $p_entry['size']) {
2077 2077
 
2078
-          // ----- Opening destination file
2079
-          if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
2078
+            // ----- Opening destination file
2079
+            if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
2080 2080
 
2081 2081
             // ----- Change the file status
2082 2082
             $p_entry['status'] = 'write_error';
2083 2083
 
2084 2084
             // ----- Return
2085 2085
             return $v_result;
2086
-          }
2086
+            }
2087 2087
 
2088 2088
 
2089
-          // ----- Read the file by ARCHIVE_ZIP_READ_BLOCK_SIZE octets blocks
2090
-          $v_size = $p_entry['compressed_size'];
2089
+            // ----- Read the file by ARCHIVE_ZIP_READ_BLOCK_SIZE octets blocks
2090
+            $v_size = $p_entry['compressed_size'];
2091 2091
             while ($v_size != 0) {
2092 2092
                 $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE);
2093 2093
                 $v_buffer = fread($this->_zip_fd, $v_read_size);
@@ -2096,93 +2096,93 @@  discard block
 block discarded – undo
2096 2096
                 $v_size -= $v_read_size;
2097 2097
             }
2098 2098
 
2099
-          // ----- Closing the destination file
2100
-          fclose($v_dest_file);
2099
+            // ----- Closing the destination file
2100
+            fclose($v_dest_file);
2101 2101
 
2102
-          // ----- Change the file mtime
2103
-          touch($p_entry['filename'], $p_entry['mtime']);
2102
+            // ----- Change the file mtime
2103
+            touch($p_entry['filename'], $p_entry['mtime']);
2104 2104
         } else {
2105 2105
             // ----- Trace
2106 2106
 
2107
-          // ----- Opening destination file
2108
-          if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
2107
+            // ----- Opening destination file
2108
+            if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
2109 2109
 
2110 2110
             // ----- Change the file status
2111 2111
             $p_entry['status'] = 'write_error';
2112 2112
 
2113
-              return $v_result;
2114
-          }
2113
+                return $v_result;
2114
+            }
2115 2115
 
2116 2116
 
2117
-          // ----- Read the compressed file in a buffer (one shot)
2118
-          $v_buffer = @fread($this->_zip_fd, $p_entry['compressed_size']);
2117
+            // ----- Read the compressed file in a buffer (one shot)
2118
+            $v_buffer = @fread($this->_zip_fd, $p_entry['compressed_size']);
2119 2119
 
2120
-          // ----- Decompress the file
2121
-          $v_file_content = gzinflate($v_buffer);
2120
+            // ----- Decompress the file
2121
+            $v_file_content = gzinflate($v_buffer);
2122 2122
             unset($v_buffer);
2123 2123
 
2124
-          // ----- Write the uncompressed data
2125
-          @fwrite($v_dest_file, $v_file_content, $p_entry['size']);
2124
+            // ----- Write the uncompressed data
2125
+            @fwrite($v_dest_file, $v_file_content, $p_entry['size']);
2126 2126
             unset($v_file_content);
2127 2127
 
2128
-          // ----- Closing the destination file
2129
-          @fclose($v_dest_file);
2128
+            // ----- Closing the destination file
2129
+            @fclose($v_dest_file);
2130 2130
 
2131
-          // ----- Change the file mtime
2132
-          touch($p_entry['filename'], $p_entry['mtime']);
2131
+            // ----- Change the file mtime
2132
+            touch($p_entry['filename'], $p_entry['mtime']);
2133 2133
         }
2134 2134
 
2135 2135
         // ----- Look for chmod option
2136 2136
         if (isset($p_params[ARCHIVE_ZIP_PARAM_SET_CHMOD])
2137 2137
             && ($p_params[ARCHIVE_ZIP_PARAM_SET_CHMOD] != 0)) {
2138 2138
 
2139
-          // ----- Change the mode of the file
2140
-          chmod($p_entry['filename'], $p_params[ARCHIVE_ZIP_PARAM_SET_CHMOD]);
2139
+            // ----- Change the mode of the file
2140
+            chmod($p_entry['filename'], $p_params[ARCHIVE_ZIP_PARAM_SET_CHMOD]);
2141
+        }
2141 2142
         }
2142
-      }
2143 2143
     }
2144 2144
 
2145 2145
     // ----- Look for post-extract callback
2146 2146
     if (isset($p_params[ARCHIVE_ZIP_PARAM_POST_EXTRACT])
2147 2147
         && ($p_params[ARCHIVE_ZIP_PARAM_POST_EXTRACT] != '')) {
2148 2148
 
2149
-      // ----- Generate a local information
2150
-      $v_local_header = array();
2149
+        // ----- Generate a local information
2150
+        $v_local_header = array();
2151 2151
         $this->_convertHeader2FileInfo($p_entry, $v_local_header);
2152 2152
 
2153
-      // ----- Call the callback
2154
-      // Here I do not use call_user_func() because I need to send a reference to the
2155
-      // header.
2156
-      eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_POST_EXTRACT].'(ARCHIVE_ZIP_PARAM_POST_EXTRACT, $v_local_header);');
2153
+        // ----- Call the callback
2154
+        // Here I do not use call_user_func() because I need to send a reference to the
2155
+        // header.
2156
+        eval('$v_result = '.$p_params[ARCHIVE_ZIP_PARAM_POST_EXTRACT].'(ARCHIVE_ZIP_PARAM_POST_EXTRACT, $v_local_header);');
2157 2157
     }
2158 2158
 
2159 2159
     // ----- Return
2160 2160
     return $v_result;
2161
-  }
2162
-  // ---------------------------------------------------------------------------
2163
-
2164
-  // ---------------------------------------------------------------------------
2165
-  // Function : _extractFileAsString()
2166
-  // Description :
2167
-  // Parameters :
2168
-  // Return Values :
2169
-  // ---------------------------------------------------------------------------
2170
-  /**
2171
-  * Archive_Zip::_extractFileAsString()
2172
-  *
2173
-  * { Description }
2174
-  *
2175
-  */
2176
-  public function _extractFileAsString(&$p_entry, &$p_string)
2177
-  {
2178
-      $v_result=1;
2161
+    }
2162
+    // ---------------------------------------------------------------------------
2163
+
2164
+    // ---------------------------------------------------------------------------
2165
+    // Function : _extractFileAsString()
2166
+    // Description :
2167
+    // Parameters :
2168
+    // Return Values :
2169
+    // ---------------------------------------------------------------------------
2170
+    /**
2171
+     * Archive_Zip::_extractFileAsString()
2172
+     *
2173
+     * { Description }
2174
+     *
2175
+     */
2176
+    public function _extractFileAsString(&$p_entry, &$p_string)
2177
+    {
2178
+        $v_result=1;
2179 2179
 
2180 2180
     // ----- Read the file header
2181 2181
     $v_header = array();
2182
-      if (($v_result = $this->_readFileHeader($v_header)) != 1) {
2183
-          // ----- Return
2184
-      return $v_result;
2185
-      }
2182
+        if (($v_result = $this->_readFileHeader($v_header)) != 1) {
2183
+            // ----- Return
2184
+        return $v_result;
2185
+        }
2186 2186
 
2187 2187
 
2188 2188
     // ----- Check that the file header is coherent with $p_entry info
@@ -2193,59 +2193,59 @@  discard block
 block discarded – undo
2193 2193
     // ----- Do the extraction (if not a folder)
2194 2194
     if (!(($p_entry['external']&0x00000010)==0x00000010)) {
2195 2195
         // ----- Look for not compressed file
2196
-      if ($p_entry['compressed_size'] == $p_entry['size']) {
2197
-          // ----- Trace
2196
+        if ($p_entry['compressed_size'] == $p_entry['size']) {
2197
+            // ----- Trace
2198 2198
 
2199 2199
         // ----- Reading the file
2200 2200
         $p_string = fread($this->_zip_fd, $p_entry['compressed_size']);
2201
-      } else {
2202
-          // ----- Trace
2201
+        } else {
2202
+            // ----- Trace
2203 2203
 
2204 2204
         // ----- Reading the file
2205 2205
         $v_data = fread($this->_zip_fd, $p_entry['compressed_size']);
2206 2206
 
2207 2207
         // ----- Decompress the file
2208 2208
         $p_string = gzinflate($v_data);
2209
-      }
2209
+        }
2210 2210
 
2211
-      // ----- Trace
2211
+        // ----- Trace
2212 2212
     } else {
2213 2213
         // TBC : error : can not extract a folder in a string
2214 2214
     }
2215 2215
 
2216 2216
     // ----- Return
2217 2217
     return $v_result;
2218
-  }
2219
-  // ---------------------------------------------------------------------------
2220
-
2221
-  // ---------------------------------------------------------------------------
2222
-  // Function : _readFileHeader()
2223
-  // Description :
2224
-  // Parameters :
2225
-  // Return Values :
2226
-  // ---------------------------------------------------------------------------
2227
-  /**
2228
-  * Archive_Zip::_readFileHeader()
2229
-  *
2230
-  * { Description }
2231
-  *
2232
-  */
2233
-  public function _readFileHeader(&$p_header)
2234
-  {
2235
-      $v_result=1;
2218
+    }
2219
+    // ---------------------------------------------------------------------------
2220
+
2221
+    // ---------------------------------------------------------------------------
2222
+    // Function : _readFileHeader()
2223
+    // Description :
2224
+    // Parameters :
2225
+    // Return Values :
2226
+    // ---------------------------------------------------------------------------
2227
+    /**
2228
+     * Archive_Zip::_readFileHeader()
2229
+     *
2230
+     * { Description }
2231
+     *
2232
+     */
2233
+    public function _readFileHeader(&$p_header)
2234
+    {
2235
+        $v_result=1;
2236 2236
 
2237 2237
     // ----- Read the 4 bytes signature
2238 2238
     $v_binary_data = @fread($this->_zip_fd, 4);
2239
-      $v_data = unpack('Vid', $v_binary_data);
2239
+        $v_data = unpack('Vid', $v_binary_data);
2240 2240
 
2241 2241
     // ----- Check signature
2242 2242
     if ($v_data['id'] != 0x04034b50) {
2243 2243
 
2244
-      // ----- Error log
2245
-      $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
2244
+        // ----- Error log
2245
+        $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
2246 2246
 
2247
-      // ----- Return
2248
-      return Archive_Zip::errorCode();
2247
+        // ----- Return
2248
+        return Archive_Zip::errorCode();
2249 2249
     }
2250 2250
 
2251 2251
     // ----- Read the first 42 bytes of the header
@@ -2256,11 +2256,11 @@  discard block
 block discarded – undo
2256 2256
         $p_header['filename'] = '';
2257 2257
         $p_header['status'] = 'invalid_header';
2258 2258
 
2259
-      // ----- Error log
2260
-      $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid block size : ' . strlen($v_binary_data));
2259
+        // ----- Error log
2260
+        $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid block size : ' . strlen($v_binary_data));
2261 2261
 
2262
-      // ----- Return
2263
-      return Archive_Zip::errorCode();
2262
+        // ----- Return
2263
+        return Archive_Zip::errorCode();
2264 2264
     }
2265 2265
 
2266 2266
     // ----- Extract the values
@@ -2278,30 +2278,30 @@  discard block
 block discarded – undo
2278 2278
 
2279 2279
     // ----- Extract properties
2280 2280
     $p_header['compression'] = $v_data['compression'];
2281
-      $p_header['size'] = $v_data['size'];
2282
-      $p_header['compressed_size'] = $v_data['compressed_size'];
2283
-      $p_header['crc'] = $v_data['crc'];
2284
-      $p_header['flag'] = $v_data['flag'];
2281
+        $p_header['size'] = $v_data['size'];
2282
+        $p_header['compressed_size'] = $v_data['compressed_size'];
2283
+        $p_header['crc'] = $v_data['crc'];
2284
+        $p_header['flag'] = $v_data['flag'];
2285 2285
 
2286 2286
     // ----- Recuperate date in UNIX format
2287 2287
     $p_header['mdate'] = $v_data['mdate'];
2288
-      $p_header['mtime'] = $v_data['mtime'];
2289
-      if ($p_header['mdate'] && $p_header['mtime']) {
2290
-          // ----- Extract time
2291
-      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
2292
-          $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
2293
-          $v_seconde = ($p_header['mtime'] & 0x001F)*2;
2294
-
2295
-      // ----- Extract date
2296
-      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
2297
-          $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
2298
-          $v_day = $p_header['mdate'] & 0x001F;
2299
-
2300
-      // ----- Get UNIX date format
2301
-      $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
2302
-      } else {
2303
-          $p_header['mtime'] = time();
2304
-      }
2288
+        $p_header['mtime'] = $v_data['mtime'];
2289
+        if ($p_header['mdate'] && $p_header['mtime']) {
2290
+            // ----- Extract time
2291
+        $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
2292
+            $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
2293
+            $v_seconde = ($p_header['mtime'] & 0x001F)*2;
2294
+
2295
+        // ----- Extract date
2296
+        $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
2297
+            $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
2298
+            $v_day = $p_header['mdate'] & 0x001F;
2299
+
2300
+        // ----- Get UNIX date format
2301
+        $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
2302
+        } else {
2303
+            $p_header['mtime'] = time();
2304
+        }
2305 2305
 
2306 2306
     // ----- Other informations
2307 2307
 
@@ -2317,37 +2317,37 @@  discard block
 block discarded – undo
2317 2317
 
2318 2318
     // ----- Return
2319 2319
     return $v_result;
2320
-  }
2321
-  // ---------------------------------------------------------------------------
2322
-
2323
-  // ---------------------------------------------------------------------------
2324
-  // Function : _readCentralFileHeader()
2325
-  // Description :
2326
-  // Parameters :
2327
-  // Return Values :
2328
-  // ---------------------------------------------------------------------------
2329
-  /**
2330
-  * Archive_Zip::_readCentralFileHeader()
2331
-  *
2332
-  * { Description }
2333
-  *
2334
-  */
2335
-  public function _readCentralFileHeader(&$p_header)
2336
-  {
2337
-      $v_result=1;
2320
+    }
2321
+    // ---------------------------------------------------------------------------
2322
+
2323
+    // ---------------------------------------------------------------------------
2324
+    // Function : _readCentralFileHeader()
2325
+    // Description :
2326
+    // Parameters :
2327
+    // Return Values :
2328
+    // ---------------------------------------------------------------------------
2329
+    /**
2330
+     * Archive_Zip::_readCentralFileHeader()
2331
+     *
2332
+     * { Description }
2333
+     *
2334
+     */
2335
+    public function _readCentralFileHeader(&$p_header)
2336
+    {
2337
+        $v_result=1;
2338 2338
 
2339 2339
     // ----- Read the 4 bytes signature
2340 2340
     $v_binary_data = @fread($this->_zip_fd, 4);
2341
-      $v_data = unpack('Vid', $v_binary_data);
2341
+        $v_data = unpack('Vid', $v_binary_data);
2342 2342
 
2343 2343
     // ----- Check signature
2344 2344
     if ($v_data['id'] != 0x02014b50) {
2345 2345
 
2346
-      // ----- Error log
2347
-      $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
2346
+        // ----- Error log
2347
+        $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
2348 2348
 
2349
-      // ----- Return
2350
-      return Archive_Zip::errorCode();
2349
+        // ----- Return
2350
+        return Archive_Zip::errorCode();
2351 2351
     }
2352 2352
 
2353 2353
     // ----- Read the first 42 bytes of the header
@@ -2358,11 +2358,11 @@  discard block
 block discarded – undo
2358 2358
         $p_header['filename'] = '';
2359 2359
         $p_header['status'] = 'invalid_header';
2360 2360
 
2361
-      // ----- Error log
2362
-      $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid block size : ' . strlen($v_binary_data));
2361
+        // ----- Error log
2362
+        $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Invalid block size : ' . strlen($v_binary_data));
2363 2363
 
2364
-      // ----- Return
2365
-      return Archive_Zip::errorCode();
2364
+        // ----- Return
2365
+        return Archive_Zip::errorCode();
2366 2366
     }
2367 2367
 
2368 2368
     // ----- Extract the values
@@ -2394,17 +2394,17 @@  discard block
 block discarded – undo
2394 2394
     // ----- Recuperate date in UNIX format
2395 2395
     if ($p_header['mdate'] && $p_header['mtime']) {
2396 2396
         // ----- Extract time
2397
-      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
2397
+        $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
2398 2398
         $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
2399 2399
         $v_seconde = ($p_header['mtime'] & 0x001F)*2;
2400 2400
 
2401
-      // ----- Extract date
2402
-      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
2401
+        // ----- Extract date
2402
+        $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
2403 2403
         $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
2404 2404
         $v_day = $p_header['mdate'] & 0x001F;
2405 2405
 
2406
-      // ----- Get UNIX date format
2407
-      $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
2406
+        // ----- Get UNIX date format
2407
+        $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
2408 2408
     } else {
2409 2409
         $p_header['mtime'] = time();
2410 2410
     }
@@ -2423,76 +2423,76 @@  discard block
 block discarded – undo
2423 2423
 
2424 2424
     // ----- Return
2425 2425
     return $v_result;
2426
-  }
2427
-  // ---------------------------------------------------------------------------
2428
-
2429
-  // ---------------------------------------------------------------------------
2430
-  // Function : _readEndCentralDir()
2431
-  // Description :
2432
-  // Parameters :
2433
-  // Return Values :
2434
-  // ---------------------------------------------------------------------------
2435
-  /**
2436
-  * Archive_Zip::_readEndCentralDir()
2437
-  *
2438
-  * { Description }
2439
-  *
2440
-  */
2441
-  public function _readEndCentralDir(&$p_central_dir)
2442
-  {
2443
-      $v_result=1;
2426
+    }
2427
+    // ---------------------------------------------------------------------------
2428
+
2429
+    // ---------------------------------------------------------------------------
2430
+    // Function : _readEndCentralDir()
2431
+    // Description :
2432
+    // Parameters :
2433
+    // Return Values :
2434
+    // ---------------------------------------------------------------------------
2435
+    /**
2436
+     * Archive_Zip::_readEndCentralDir()
2437
+     *
2438
+     * { Description }
2439
+     *
2440
+     */
2441
+    public function _readEndCentralDir(&$p_central_dir)
2442
+    {
2443
+        $v_result=1;
2444 2444
 
2445 2445
     // ----- Go to the end of the zip file
2446 2446
     $v_size = filesize($this->_zipname);
2447
-      @fseek($this->_zip_fd, $v_size);
2448
-      if (@ftell($this->_zip_fd) != $v_size) {
2449
-          $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT,
2450
-                       'Unable to go to the end of the archive \''
2451
-                       .$this->_zipname.'\'');
2452
-          return Archive_Zip::errorCode();
2453
-      }
2447
+        @fseek($this->_zip_fd, $v_size);
2448
+        if (@ftell($this->_zip_fd) != $v_size) {
2449
+            $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT,
2450
+                        'Unable to go to the end of the archive \''
2451
+                        .$this->_zipname.'\'');
2452
+            return Archive_Zip::errorCode();
2453
+        }
2454 2454
 
2455 2455
     // ----- First try : look if this is an archive with no commentaries
2456 2456
     // (most of the time)
2457 2457
     // in this case the end of central dir is at 22 bytes of the file end
2458 2458
     $v_found = 0;
2459
-      if ($v_size > 26) {
2460
-          @fseek($this->_zip_fd, $v_size-22);
2461
-          if (($v_pos = @ftell($this->_zip_fd)) != ($v_size-22)) {
2462
-              $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT,
2463
-                         'Unable to seek back to the middle of the archive \''
2464
-                         .$this->_zipname.'\'');
2465
-              return Archive_Zip::errorCode();
2466
-          }
2467
-
2468
-      // ----- Read for bytes
2469
-      $v_binary_data = @fread($this->_zip_fd, 4);
2470
-          $v_data = unpack('Vid', $v_binary_data);
2471
-
2472
-      // ----- Check signature
2473
-      if ($v_data['id'] == 0x06054b50) {
2474
-          $v_found = 1;
2475
-      }
2476
-
2477
-          $v_pos = ftell($this->_zip_fd);
2478
-      }
2459
+        if ($v_size > 26) {
2460
+            @fseek($this->_zip_fd, $v_size-22);
2461
+            if (($v_pos = @ftell($this->_zip_fd)) != ($v_size-22)) {
2462
+                $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT,
2463
+                            'Unable to seek back to the middle of the archive \''
2464
+                            .$this->_zipname.'\'');
2465
+                return Archive_Zip::errorCode();
2466
+            }
2467
+
2468
+        // ----- Read for bytes
2469
+        $v_binary_data = @fread($this->_zip_fd, 4);
2470
+            $v_data = unpack('Vid', $v_binary_data);
2471
+
2472
+        // ----- Check signature
2473
+        if ($v_data['id'] == 0x06054b50) {
2474
+            $v_found = 1;
2475
+        }
2476
+
2477
+            $v_pos = ftell($this->_zip_fd);
2478
+        }
2479 2479
 
2480 2480
     // ----- Go back to the maximum possible size of the Central Dir End Record
2481 2481
     if (!$v_found) {
2482 2482
         $v_maximum_size = 65557; // 0xFFFF + 22;
2483
-      if ($v_maximum_size > $v_size) {
2484
-          $v_maximum_size = $v_size;
2485
-      }
2483
+        if ($v_maximum_size > $v_size) {
2484
+            $v_maximum_size = $v_size;
2485
+        }
2486 2486
         @fseek($this->_zip_fd, $v_size-$v_maximum_size);
2487 2487
         if (@ftell($this->_zip_fd) != ($v_size-$v_maximum_size)) {
2488 2488
             $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT,
2489
-                         'Unable to seek back to the middle of the archive \''
2490
-                         .$this->_zipname.'\'');
2489
+                            'Unable to seek back to the middle of the archive \''
2490
+                            .$this->_zipname.'\'');
2491 2491
             return Archive_Zip::errorCode();
2492 2492
         }
2493 2493
 
2494
-      // ----- Read byte per byte in order to find the signature
2495
-      $v_pos = ftell($this->_zip_fd);
2494
+        // ----- Read byte per byte in order to find the signature
2495
+        $v_pos = ftell($this->_zip_fd);
2496 2496
         $v_bytes = 0x00000000;
2497 2497
         while ($v_pos < $v_size) {
2498 2498
             // ----- Read a byte
@@ -2510,11 +2510,11 @@  discard block
 block discarded – undo
2510 2510
             $v_pos++;
2511 2511
         }
2512 2512
 
2513
-      // ----- Look if not found end of central dir
2514
-      if ($v_pos == $v_size) {
2515
-          $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Unable to find End of Central Dir Record signature');
2516
-          return Archive_Zip::errorCode();
2517
-      }
2513
+        // ----- Look if not found end of central dir
2514
+        if ($v_pos == $v_size) {
2515
+            $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT, 'Unable to find End of Central Dir Record signature');
2516
+            return Archive_Zip::errorCode();
2517
+        }
2518 2518
     }
2519 2519
 
2520 2520
     // ----- Read the first 18 bytes of the header
@@ -2523,8 +2523,8 @@  discard block
 block discarded – undo
2523 2523
     // ----- Look for invalid block size
2524 2524
     if (strlen($v_binary_data) != 18) {
2525 2525
         $this->_errorLog(ARCHIVE_ZIP_ERR_BAD_FORMAT,
2526
-                         'Invalid End of Central Dir Record size : '
2527
-                         . strlen($v_binary_data));
2526
+                            'Invalid End of Central Dir Record size : '
2527
+                            . strlen($v_binary_data));
2528 2528
         return Archive_Zip::errorCode();
2529 2529
     }
2530 2530
 
@@ -2544,47 +2544,47 @@  discard block
 block discarded – undo
2544 2544
         $p_central_dir['comment'] = '';
2545 2545
     }
2546 2546
 
2547
-      $p_central_dir['entries'] = $v_data['entries'];
2548
-      $p_central_dir['disk_entries'] = $v_data['disk_entries'];
2549
-      $p_central_dir['offset'] = $v_data['offset'];
2550
-      $p_central_dir['size'] = $v_data['size'];
2551
-      $p_central_dir['disk'] = $v_data['disk'];
2552
-      $p_central_dir['disk_start'] = $v_data['disk_start'];
2547
+        $p_central_dir['entries'] = $v_data['entries'];
2548
+        $p_central_dir['disk_entries'] = $v_data['disk_entries'];
2549
+        $p_central_dir['offset'] = $v_data['offset'];
2550
+        $p_central_dir['size'] = $v_data['size'];
2551
+        $p_central_dir['disk'] = $v_data['disk'];
2552
+        $p_central_dir['disk_start'] = $v_data['disk_start'];
2553 2553
 
2554 2554
     // ----- Return
2555 2555
     return $v_result;
2556
-  }
2557
-  // ---------------------------------------------------------------------------
2558
-
2559
-  // ---------------------------------------------------------------------------
2560
-  // Function : _deleteByRule()
2561
-  // Description :
2562
-  // Parameters :
2563
-  // Return Values :
2564
-  // ---------------------------------------------------------------------------
2565
-  /**
2566
-  * Archive_Zip::_deleteByRule()
2567
-  *
2568
-  * { Description }
2569
-  *
2570
-  */
2571
-  public function _deleteByRule(&$p_result_list, &$p_params)
2572
-  {
2573
-      $v_result=1;
2574
-      $v_list_detail = array();
2556
+    }
2557
+    // ---------------------------------------------------------------------------
2558
+
2559
+    // ---------------------------------------------------------------------------
2560
+    // Function : _deleteByRule()
2561
+    // Description :
2562
+    // Parameters :
2563
+    // Return Values :
2564
+    // ---------------------------------------------------------------------------
2565
+    /**
2566
+     * Archive_Zip::_deleteByRule()
2567
+     *
2568
+     * { Description }
2569
+     *
2570
+     */
2571
+    public function _deleteByRule(&$p_result_list, &$p_params)
2572
+    {
2573
+        $v_result=1;
2574
+        $v_list_detail = array();
2575 2575
 
2576 2576
     // ----- Open the zip file
2577 2577
     if (($v_result=$this->_openFd('rb')) != 1) {
2578 2578
         // ----- Return
2579
-      return $v_result;
2579
+        return $v_result;
2580 2580
     }
2581 2581
 
2582 2582
     // ----- Read the central directory informations
2583 2583
     $v_central_dir = array();
2584
-      if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) {
2585
-          $this->_closeFd();
2586
-          return $v_result;
2587
-      }
2584
+        if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) {
2585
+            $this->_closeFd();
2586
+            return $v_result;
2587
+        }
2588 2588
 
2589 2589
     // ----- Go to beginning of File
2590 2590
     @rewind($this->_zip_fd);
@@ -2592,123 +2592,123 @@  discard block
 block discarded – undo
2592 2592
     // ----- Scan all the files
2593 2593
     // ----- Start at beginning of Central Dir
2594 2594
     $v_pos_entry = $v_central_dir['offset'];
2595
-      @rewind($this->_zip_fd);
2596
-      if (@fseek($this->_zip_fd, $v_pos_entry)) {
2597
-          // ----- Clean
2598
-      $this->_closeFd();
2595
+        @rewind($this->_zip_fd);
2596
+        if (@fseek($this->_zip_fd, $v_pos_entry)) {
2597
+            // ----- Clean
2598
+        $this->_closeFd();
2599 2599
 
2600
-          $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP,
2601
-                       'Invalid archive size');
2602
-          return Archive_Zip::errorCode();
2603
-      }
2600
+            $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP,
2601
+                        'Invalid archive size');
2602
+            return Archive_Zip::errorCode();
2603
+        }
2604 2604
 
2605 2605
     // ----- Read each entry
2606 2606
     $v_header_list = array();
2607
-      $j_start = 0;
2608
-      for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) {
2607
+        $j_start = 0;
2608
+        for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++) {
2609 2609
 
2610
-      // ----- Read the file header
2611
-      $v_header_list[$v_nb_extracted] = array();
2612
-          $v_result
2610
+        // ----- Read the file header
2611
+        $v_header_list[$v_nb_extracted] = array();
2612
+            $v_result
2613 2613
         = $this->_readCentralFileHeader($v_header_list[$v_nb_extracted]);
2614
-          if ($v_result != 1) {
2615
-              // ----- Clean
2614
+            if ($v_result != 1) {
2615
+                // ----- Clean
2616 2616
         $this->_closeFd();
2617 2617
 
2618
-              return $v_result;
2619
-          }
2618
+                return $v_result;
2619
+            }
2620 2620
 
2621
-      // ----- Store the index
2622
-      $v_header_list[$v_nb_extracted]['index'] = $i;
2621
+        // ----- Store the index
2622
+        $v_header_list[$v_nb_extracted]['index'] = $i;
2623 2623
 
2624
-      // ----- Look for the specific extract rules
2625
-      $v_found = false;
2624
+        // ----- Look for the specific extract rules
2625
+        $v_found = false;
2626 2626
 
2627
-      // ----- Look for extract by name rule
2628
-      if (isset($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])
2627
+        // ----- Look for extract by name rule
2628
+        if (isset($p_params[ARCHIVE_ZIP_PARAM_BY_NAME])
2629 2629
           && ($p_params[ARCHIVE_ZIP_PARAM_BY_NAME] != 0)) {
2630 2630
 
2631
-          // ----- Look if the filename is in the list
2632
-          for ($j=0;
2633
-               ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_NAME]))
2631
+            // ----- Look if the filename is in the list
2632
+            for ($j=0;
2633
+                ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_NAME]))
2634 2634
                  && (!$v_found);
2635
-               $j++) {
2635
+                $j++) {
2636 2636
 
2637
-              // ----- Look for a directory
2638
-              if (substr($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j], -1) == '/') {
2637
+                // ----- Look for a directory
2638
+                if (substr($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j], -1) == '/') {
2639 2639
 
2640
-                  // ----- Look if the directory is in the filename path
2641
-                  if ((strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]))
2640
+                    // ----- Look if the directory is in the filename path
2641
+                    if ((strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]))
2642 2642
                       && (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])) {
2643
-                      $v_found = true;
2644
-                  } elseif ((($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
2643
+                        $v_found = true;
2644
+                    } elseif ((($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
2645 2645
                           && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j])) {
2646
-                      $v_found = true;
2647
-                  }
2648
-              }
2649
-              // ----- Look for a filename
2650
-              elseif ($v_header_list[$v_nb_extracted]['stored_filename']
2651
-                      == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]) {
2652
-                  $v_found = true;
2653
-              }
2654
-          }
2655
-      }
2656
-
2657
-      // ----- Look for extract by ereg rule
2658
-      elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_EREG])
2646
+                        $v_found = true;
2647
+                    }
2648
+                }
2649
+                // ----- Look for a filename
2650
+                elseif ($v_header_list[$v_nb_extracted]['stored_filename']
2651
+                        == $p_params[ARCHIVE_ZIP_PARAM_BY_NAME][$j]) {
2652
+                    $v_found = true;
2653
+                }
2654
+            }
2655
+        }
2656
+
2657
+        // ----- Look for extract by ereg rule
2658
+        elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_EREG])
2659 2659
               && ($p_params[ARCHIVE_ZIP_PARAM_BY_EREG] != '')) {
2660
-          if (ereg($p_params[ARCHIVE_ZIP_PARAM_BY_EREG],
2661
-                   $v_header_list[$v_nb_extracted]['stored_filename'])) {
2662
-              $v_found = true;
2663
-          }
2664
-      }
2665
-
2666
-      // ----- Look for extract by preg rule
2667
-      elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_PREG])
2660
+            if (ereg($p_params[ARCHIVE_ZIP_PARAM_BY_EREG],
2661
+                    $v_header_list[$v_nb_extracted]['stored_filename'])) {
2662
+                $v_found = true;
2663
+            }
2664
+        }
2665
+
2666
+        // ----- Look for extract by preg rule
2667
+        elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_PREG])
2668 2668
               && ($p_params[ARCHIVE_ZIP_PARAM_BY_PREG] != '')) {
2669
-          if (preg_match($p_params[ARCHIVE_ZIP_PARAM_BY_PREG],
2670
-                         $v_header_list[$v_nb_extracted]['stored_filename'])) {
2671
-              $v_found = true;
2672
-          }
2673
-      }
2674
-
2675
-      // ----- Look for extract by index rule
2676
-      elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])
2669
+            if (preg_match($p_params[ARCHIVE_ZIP_PARAM_BY_PREG],
2670
+                            $v_header_list[$v_nb_extracted]['stored_filename'])) {
2671
+                $v_found = true;
2672
+            }
2673
+        }
2674
+
2675
+        // ----- Look for extract by index rule
2676
+        elseif (isset($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX])
2677 2677
               && ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX] != 0)) {
2678 2678
 
2679
-          // ----- Look if the index is in the list
2680
-          for ($j=$j_start;
2681
-               ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX]))
2679
+            // ----- Look if the index is in the list
2680
+            for ($j=$j_start;
2681
+                ($j < count($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX]))
2682 2682
                  && (!$v_found);
2683
-               $j++) {
2684
-              if (($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start'])
2683
+                $j++) {
2684
+                if (($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start'])
2685 2685
                   && ($i<=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end'])) {
2686
-                  $v_found = true;
2687
-              }
2688
-              if ($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) {
2689
-                  $j_start = $j+1;
2690
-              }
2691
-
2692
-              if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']>$i) {
2693
-                  break;
2694
-              }
2695
-          }
2696
-      }
2697
-
2698
-      // ----- Look for deletion
2699
-      if ($v_found) {
2700
-          unset($v_header_list[$v_nb_extracted]);
2701
-      } else {
2702
-          $v_nb_extracted++;
2703
-      }
2704
-      }
2686
+                    $v_found = true;
2687
+                }
2688
+                if ($i>=$p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['end']) {
2689
+                    $j_start = $j+1;
2690
+                }
2691
+
2692
+                if ($p_params[ARCHIVE_ZIP_PARAM_BY_INDEX][$j]['start']>$i) {
2693
+                    break;
2694
+                }
2695
+            }
2696
+        }
2697
+
2698
+        // ----- Look for deletion
2699
+        if ($v_found) {
2700
+            unset($v_header_list[$v_nb_extracted]);
2701
+        } else {
2702
+            $v_nb_extracted++;
2703
+        }
2704
+        }
2705 2705
 
2706 2706
     // ----- Look if something need to be deleted
2707 2707
     if ($v_nb_extracted > 0) {
2708 2708
 
2709 2709
         // ----- Creates a temporay file
2710 2710
         $v_zip_temp_name = ARCHIVE_ZIP_TEMPORARY_DIR.uniqid('archive_zip-')
2711
-                           .'.tmp';
2711
+                            .'.tmp';
2712 2712
 
2713 2713
         // ----- Creates a temporary zip archive
2714 2714
         $v_temp_zip = new Archive_Zip($v_zip_temp_name);
@@ -2733,7 +2733,7 @@  discard block
 block discarded – undo
2733 2733
                 @unlink($v_zip_temp_name);
2734 2734
 
2735 2735
                 $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_ARCHIVE_ZIP,
2736
-                                 'Invalid archive size');
2736
+                                    'Invalid archive size');
2737 2737
                 return Archive_Zip::errorCode();
2738 2738
             }
2739 2739
 
@@ -2760,8 +2760,8 @@  discard block
 block discarded – undo
2760 2760
 
2761 2761
             // ----- Read/write the data block
2762 2762
             $v_result = $this->_tool_CopyBlock($this->_zip_fd,
2763
-                                               $v_temp_zip->_zip_fd,
2764
-                                       $v_header_list[$i]['compressed_size']);
2763
+                                                $v_temp_zip->_zip_fd,
2764
+                                        $v_header_list[$i]['compressed_size']);
2765 2765
             if ($v_result != 1) {
2766 2766
                 // ----- Clean
2767 2767
                 $this->_closeFd();
@@ -2790,7 +2790,7 @@  discard block
 block discarded – undo
2790 2790
 
2791 2791
             // ----- Transform the header to a 'usable' info
2792 2792
             $v_temp_zip->_convertHeader2FileInfo($v_header_list[$i],
2793
-                                                 $p_result_list[$i]);
2793
+                                                    $p_result_list[$i]);
2794 2794
         }
2795 2795
 
2796 2796
 
@@ -2802,8 +2802,8 @@  discard block
 block discarded – undo
2802 2802
 
2803 2803
         // ----- Create the central dir footer
2804 2804
         $v_result = $v_temp_zip->_writeCentralHeader(count($v_header_list),
2805
-                                                     $v_size, $v_offset,
2806
-                                                     $v_comment);
2805
+                                                        $v_size, $v_offset,
2806
+                                                        $v_comment);
2807 2807
         if ($v_result != 1) {
2808 2808
             // ----- Clean
2809 2809
             unset($v_header_list);
@@ -2833,30 +2833,30 @@  discard block
 block discarded – undo
2833 2833
 
2834 2834
     // ----- Return
2835 2835
     return $v_result;
2836
-  }
2837
-  // ---------------------------------------------------------------------------
2838
-
2839
-  // ---------------------------------------------------------------------------
2840
-  // Function : _dirCheck()
2841
-  // Description :
2842
-  //   Check if a directory exists, if not it creates it and all the parents directory
2843
-  //   which may be useful.
2844
-  // Parameters :
2845
-  //   $p_dir : Directory path to check.
2846
-  // Return Values :
2847
-  //    1 : OK
2848
-  //   -1 : Unable to create directory
2849
-  // ---------------------------------------------------------------------------
2850
-  /**
2851
-  * Archive_Zip::_dirCheck()
2852
-  *
2853
-  * { Description }
2854
-  *
2855
-  * @param [type] $p_is_dir
2856
-  */
2857
-  public function _dirCheck($p_dir, $p_is_dir=false)
2858
-  {
2859
-      $v_result = 1;
2836
+    }
2837
+    // ---------------------------------------------------------------------------
2838
+
2839
+    // ---------------------------------------------------------------------------
2840
+    // Function : _dirCheck()
2841
+    // Description :
2842
+    //   Check if a directory exists, if not it creates it and all the parents directory
2843
+    //   which may be useful.
2844
+    // Parameters :
2845
+    //   $p_dir : Directory path to check.
2846
+    // Return Values :
2847
+    //    1 : OK
2848
+    //   -1 : Unable to create directory
2849
+    // ---------------------------------------------------------------------------
2850
+    /**
2851
+     * Archive_Zip::_dirCheck()
2852
+     *
2853
+     * { Description }
2854
+     *
2855
+     * @param [type] $p_is_dir
2856
+     */
2857
+    public function _dirCheck($p_dir, $p_is_dir=false)
2858
+    {
2859
+        $v_result = 1;
2860 2860
 
2861 2861
     // ----- Remove the final '/'
2862 2862
     if ($p_is_dir && (substr($p_dir, -1) == '/')) {
@@ -2874,52 +2874,52 @@  discard block
 block discarded – undo
2874 2874
     // ----- Just a check
2875 2875
     if ($p_parent_dir != $p_dir) {
2876 2876
         // ----- Look for parent directory
2877
-      if ($p_parent_dir != '') {
2878
-          if (($v_result = $this->_dirCheck($p_parent_dir)) != 1) {
2879
-              return $v_result;
2880
-          }
2881
-      }
2877
+        if ($p_parent_dir != '') {
2878
+            if (($v_result = $this->_dirCheck($p_parent_dir)) != 1) {
2879
+                return $v_result;
2880
+            }
2881
+        }
2882 2882
     }
2883 2883
 
2884 2884
     // ----- Create the directory
2885 2885
     if (!@mkdir($p_dir, 0777)) {
2886 2886
         $this->_errorLog(ARCHIVE_ZIP_ERR_DIR_CREATE_FAIL,
2887
-                       "Unable to create directory '$p_dir'");
2887
+                        "Unable to create directory '$p_dir'");
2888 2888
         return Archive_Zip::errorCode();
2889 2889
     }
2890 2890
 
2891 2891
     // ----- Return
2892 2892
     return $v_result;
2893
-  }
2894
-  // ---------------------------------------------------------------------------
2895
-
2896
-  // ---------------------------------------------------------------------------
2897
-  // Function : _merge()
2898
-  // Description :
2899
-  //   If $p_archive_to_add does not exist, the function exit with a success result.
2900
-  // Parameters :
2901
-  // Return Values :
2902
-  // ---------------------------------------------------------------------------
2903
-  /**
2904
-  * Archive_Zip::_merge()
2905
-  *
2906
-  * { Description }
2907
-  *
2908
-  */
2909
-  public function _merge(&$p_archive_to_add)
2910
-  {
2911
-      $v_result=1;
2893
+    }
2894
+    // ---------------------------------------------------------------------------
2895
+
2896
+    // ---------------------------------------------------------------------------
2897
+    // Function : _merge()
2898
+    // Description :
2899
+    //   If $p_archive_to_add does not exist, the function exit with a success result.
2900
+    // Parameters :
2901
+    // Return Values :
2902
+    // ---------------------------------------------------------------------------
2903
+    /**
2904
+     * Archive_Zip::_merge()
2905
+     *
2906
+     * { Description }
2907
+     *
2908
+     */
2909
+    public function _merge(&$p_archive_to_add)
2910
+    {
2911
+        $v_result=1;
2912 2912
 
2913 2913
     // ----- Look if the archive_to_add exists
2914 2914
     if (!is_file($p_archive_to_add->_zipname)) {
2915 2915
         // ----- Nothing to merge, so merge is a success
2916
-      return 1;
2916
+        return 1;
2917 2917
     }
2918 2918
 
2919 2919
     // ----- Look if the archive exists
2920 2920
     if (!is_file($this->_zipname)) {
2921 2921
         // ----- Do a duplicate
2922
-      $v_result = $this->_duplicate($p_archive_to_add->_zipname);
2922
+        $v_result = $this->_duplicate($p_archive_to_add->_zipname);
2923 2923
 
2924 2924
         return $v_result;
2925 2925
     }
@@ -2931,10 +2931,10 @@  discard block
 block discarded – undo
2931 2931
 
2932 2932
     // ----- Read the central directory informations
2933 2933
     $v_central_dir = array();
2934
-      if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) {
2935
-          $this->_closeFd();
2936
-          return $v_result;
2937
-      }
2934
+        if (($v_result = $this->_readEndCentralDir($v_central_dir)) != 1) {
2935
+            $this->_closeFd();
2936
+            return $v_result;
2937
+        }
2938 2938
 
2939 2939
     // ----- Go to beginning of File
2940 2940
     @rewind($this->_zip_fd);
@@ -2947,12 +2947,12 @@  discard block
 block discarded – undo
2947 2947
 
2948 2948
     // ----- Read the central directory informations
2949 2949
     $v_central_dir_to_add = array();
2950
-      $v_result = $p_archive_to_add->_readEndCentralDir($v_central_dir_to_add);
2951
-      if ($v_result != 1) {
2952
-          $this->_closeFd();
2953
-          $p_archive_to_add->_closeFd();
2954
-          return $v_result;
2955
-      }
2950
+        $v_result = $p_archive_to_add->_readEndCentralDir($v_central_dir_to_add);
2951
+        if ($v_result != 1) {
2952
+            $this->_closeFd();
2953
+            $p_archive_to_add->_closeFd();
2954
+            return $v_result;
2955
+        }
2956 2956
 
2957 2957
     // ----- Go to beginning of File
2958 2958
     @rewind($p_archive_to_add->_zip_fd);
@@ -2965,8 +2965,8 @@  discard block
 block discarded – undo
2965 2965
         $this->_closeFd();
2966 2966
         $p_archive_to_add->_closeFd();
2967 2967
         $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL,
2968
-                       'Unable to open temporary file \''
2969
-                       .$v_zip_temp_name.'\' in binary write mode');
2968
+                        'Unable to open temporary file \''
2969
+                        .$v_zip_temp_name.'\' in binary write mode');
2970 2970
         return Archive_Zip::errorCode();
2971 2971
     }
2972 2972
 
@@ -2974,46 +2974,46 @@  discard block
 block discarded – undo
2974 2974
     // TBC : Here I should better append the file and go back to erase the
2975 2975
     // central dir
2976 2976
     $v_size = $v_central_dir['offset'];
2977
-      while ($v_size != 0) {
2978
-          $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
2977
+        while ($v_size != 0) {
2978
+            $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
2979 2979
                       ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE);
2980
-          $v_buffer = fread($this->_zip_fd, $v_read_size);
2981
-          @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2982
-          $v_size -= $v_read_size;
2983
-      }
2980
+            $v_buffer = fread($this->_zip_fd, $v_read_size);
2981
+            @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2982
+            $v_size -= $v_read_size;
2983
+        }
2984 2984
 
2985 2985
     // ----- Copy the files from the archive_to_add into the temporary file
2986 2986
     $v_size = $v_central_dir_to_add['offset'];
2987
-      while ($v_size != 0) {
2988
-          $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
2987
+        while ($v_size != 0) {
2988
+            $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
2989 2989
                       ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE);
2990
-          $v_buffer = fread($p_archive_to_add->_zip_fd, $v_read_size);
2991
-          @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2992
-          $v_size -= $v_read_size;
2993
-      }
2990
+            $v_buffer = fread($p_archive_to_add->_zip_fd, $v_read_size);
2991
+            @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2992
+            $v_size -= $v_read_size;
2993
+        }
2994 2994
 
2995 2995
     // ----- Store the offset of the central dir
2996 2996
     $v_offset = @ftell($v_zip_temp_fd);
2997 2997
 
2998 2998
     // ----- Copy the block of file headers from the old archive
2999 2999
     $v_size = $v_central_dir['size'];
3000
-      while ($v_size != 0) {
3001
-          $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
3000
+        while ($v_size != 0) {
3001
+            $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
3002 3002
                       ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE);
3003
-          $v_buffer = @fread($this->_zip_fd, $v_read_size);
3004
-          @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
3005
-          $v_size -= $v_read_size;
3006
-      }
3003
+            $v_buffer = @fread($this->_zip_fd, $v_read_size);
3004
+            @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
3005
+            $v_size -= $v_read_size;
3006
+        }
3007 3007
 
3008 3008
     // ----- Copy the block of file headers from the archive_to_add
3009 3009
     $v_size = $v_central_dir_to_add['size'];
3010
-      while ($v_size != 0) {
3011
-          $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
3010
+        while ($v_size != 0) {
3011
+            $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
3012 3012
                       ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE);
3013
-          $v_buffer = @fread($p_archive_to_add->_zip_fd, $v_read_size);
3014
-          @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
3015
-          $v_size -= $v_read_size;
3016
-      }
3013
+            $v_buffer = @fread($p_archive_to_add->_zip_fd, $v_read_size);
3014
+            @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
3015
+            $v_size -= $v_read_size;
3016
+        }
3017 3017
 
3018 3018
     // ----- Zip file comment
3019 3019
     // TBC : I should merge the two comments
@@ -3026,8 +3026,8 @@  discard block
 block discarded – undo
3026 3026
     // Here is a trick : I swap the temporary fd with the zip fd, in order to use
3027 3027
     // the following methods on the temporary fil and not the real archive fd
3028 3028
     $v_swap = $this->_zip_fd;
3029
-      $this->_zip_fd = $v_zip_temp_fd;
3030
-      $v_zip_temp_fd = $v_swap;
3029
+        $this->_zip_fd = $v_zip_temp_fd;
3030
+        $v_zip_temp_fd = $v_swap;
3031 3031
 
3032 3032
     // ----- Create the central dir footer
3033 3033
     if (($v_result = $this->_writeCentralHeader($v_central_dir['entries']
@@ -3039,21 +3039,21 @@  discard block
 block discarded – undo
3039 3039
         @fclose($v_zip_temp_fd);
3040 3040
         $this->_zip_fd = null;
3041 3041
 
3042
-      // ----- Reset the file list
3043
-      unset($v_header_list);
3042
+        // ----- Reset the file list
3043
+        unset($v_header_list);
3044 3044
 
3045
-      // ----- Return
3046
-      return $v_result;
3045
+        // ----- Return
3046
+        return $v_result;
3047 3047
     }
3048 3048
 
3049 3049
     // ----- Swap back the file descriptor
3050 3050
     $v_swap = $this->_zip_fd;
3051
-      $this->_zip_fd = $v_zip_temp_fd;
3052
-      $v_zip_temp_fd = $v_swap;
3051
+        $this->_zip_fd = $v_zip_temp_fd;
3052
+        $v_zip_temp_fd = $v_swap;
3053 3053
 
3054 3054
     // ----- Close
3055 3055
     $this->_closeFd();
3056
-      $p_archive_to_add->_closeFd();
3056
+        $p_archive_to_add->_closeFd();
3057 3057
 
3058 3058
     // ----- Close the temporary file
3059 3059
     @fclose($v_zip_temp_fd);
@@ -3069,47 +3069,47 @@  discard block
 block discarded – undo
3069 3069
 
3070 3070
     // ----- Return
3071 3071
     return $v_result;
3072
-  }
3073
-  // ---------------------------------------------------------------------------
3074
-
3075
-  // ---------------------------------------------------------------------------
3076
-  // Function : _duplicate()
3077
-  // Description :
3078
-  // Parameters :
3079
-  // Return Values :
3080
-  // ---------------------------------------------------------------------------
3081
-  /**
3082
-  * Archive_Zip::_duplicate()
3083
-  *
3084
-  * { Description }
3085
-  *
3086
-  */
3087
-  public function _duplicate($p_archive_filename)
3088
-  {
3089
-      $v_result=1;
3072
+    }
3073
+    // ---------------------------------------------------------------------------
3074
+
3075
+    // ---------------------------------------------------------------------------
3076
+    // Function : _duplicate()
3077
+    // Description :
3078
+    // Parameters :
3079
+    // Return Values :
3080
+    // ---------------------------------------------------------------------------
3081
+    /**
3082
+     * Archive_Zip::_duplicate()
3083
+     *
3084
+     * { Description }
3085
+     *
3086
+     */
3087
+    public function _duplicate($p_archive_filename)
3088
+    {
3089
+        $v_result=1;
3090 3090
 
3091 3091
     // ----- Look if the $p_archive_filename exists
3092 3092
     if (!is_file($p_archive_filename)) {
3093 3093
 
3094
-      // ----- Nothing to duplicate, so duplicate is a success.
3095
-      $v_result = 1;
3094
+        // ----- Nothing to duplicate, so duplicate is a success.
3095
+        $v_result = 1;
3096 3096
 
3097
-      // ----- Return
3098
-      return $v_result;
3097
+        // ----- Return
3098
+        return $v_result;
3099 3099
     }
3100 3100
 
3101 3101
     // ----- Open the zip file
3102 3102
     if (($v_result=$this->_openFd('wb')) != 1) {
3103 3103
         // ----- Return
3104
-      return $v_result;
3104
+        return $v_result;
3105 3105
     }
3106 3106
 
3107 3107
     // ----- Open the temporary file in write mode
3108 3108
     if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0) {
3109 3109
         $this->_closeFd();
3110 3110
         $this->_errorLog(ARCHIVE_ZIP_ERR_READ_OPEN_FAIL,
3111
-                       'Unable to open archive file \''
3112
-                       .$p_archive_filename.'\' in binary write mode');
3111
+                        'Unable to open archive file \''
3112
+                        .$p_archive_filename.'\' in binary write mode');
3113 3113
         return Archive_Zip::errorCode();
3114 3114
     }
3115 3115
 
@@ -3117,13 +3117,13 @@  discard block
 block discarded – undo
3117 3117
     // TBC : Here I should better append the file and go back to erase the
3118 3118
     // central dir
3119 3119
     $v_size = filesize($p_archive_filename);
3120
-      while ($v_size != 0) {
3121
-          $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
3120
+        while ($v_size != 0) {
3121
+            $v_read_size = ($v_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
3122 3122
                       ? $v_size : ARCHIVE_ZIP_READ_BLOCK_SIZE);
3123
-          $v_buffer = fread($v_zip_temp_fd, $v_read_size);
3124
-          @fwrite($this->_zip_fd, $v_buffer, $v_read_size);
3125
-          $v_size -= $v_read_size;
3126
-      }
3123
+            $v_buffer = fread($v_zip_temp_fd, $v_read_size);
3124
+            @fwrite($this->_zip_fd, $v_buffer, $v_read_size);
3125
+            $v_size -= $v_read_size;
3126
+        }
3127 3127
 
3128 3128
     // ----- Close
3129 3129
     $this->_closeFd();
@@ -3131,25 +3131,25 @@  discard block
 block discarded – undo
3131 3131
     // ----- Close the temporary file
3132 3132
     @fclose($v_zip_temp_fd);
3133 3133
 
3134
-      return $v_result;
3135
-  }
3136
-  // ---------------------------------------------------------------------------
3137
-
3138
-  /**
3139
-  * Archive_Zip::_check_parameters()
3140
-  *
3141
-  * { Description }
3142
-  *
3143
-  * @param integer $p_error_code
3144
-  * @param string $p_error_string
3145
-  */
3146
-  public function _check_parameters(&$p_params, $p_default)
3147
-  {
3134
+        return $v_result;
3135
+    }
3136
+    // ---------------------------------------------------------------------------
3137
+
3138
+    /**
3139
+     * Archive_Zip::_check_parameters()
3140
+     *
3141
+     * { Description }
3142
+     *
3143
+     * @param integer $p_error_code
3144
+     * @param string $p_error_string
3145
+     */
3146
+    public function _check_parameters(&$p_params, $p_default)
3147
+    {
3148 3148
 
3149 3149
     // ----- Check that param is an array
3150 3150
     if (!is_array($p_params)) {
3151 3151
         $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER,
3152
-                         'Unsupported parameter, waiting for an array');
3152
+                            'Unsupported parameter, waiting for an array');
3153 3153
         return Archive_Zip::errorCode();
3154 3154
     }
3155 3155
 
@@ -3157,7 +3157,7 @@  discard block
 block discarded – undo
3157 3157
     for (reset($p_params); list($v_key, $v_value) = each($p_params);) {
3158 3158
         if (!isset($p_default[$v_key])) {
3159 3159
             $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAMETER,
3160
-                             'Unsupported parameter with key \''.$v_key.'\'');
3160
+                                'Unsupported parameter with key \''.$v_key.'\'');
3161 3161
 
3162 3162
             return Archive_Zip::errorCode();
3163 3163
         }
@@ -3172,170 +3172,170 @@  discard block
 block discarded – undo
3172 3172
 
3173 3173
     // ----- Check specific parameters
3174 3174
     $v_callback_list = array('callback_pre_add', 'callback_post_add',
3175
-                              'callback_pre_extract', 'callback_post_extract');
3176
-      for ($i=0; $i < count($v_callback_list); $i++) {
3177
-          $v_key=$v_callback_list[$i];
3178
-          if (isset($p_params[$v_key]) && ($p_params[$v_key] != '')) {
3179
-              if (!function_exists($p_params[$v_key])) {
3180
-                  $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAM_VALUE,
3181
-                                 "Callback '".$p_params[$v_key]
3182
-                                 ."()' is not an existing function for "
3183
-                                 ."parameter '".$v_key."'");
3184
-                  return Archive_Zip::errorCode();
3185
-              }
3186
-          }
3187
-      }
3188
-
3189
-      return 1;
3190
-  }
3191
-  // ---------------------------------------------------------------------------
3192
-
3193
-  // ---------------------------------------------------------------------------
3194
-  // Function : _errorLog()
3195
-  // Description :
3196
-  // Parameters :
3197
-  // ---------------------------------------------------------------------------
3198
-  /**
3199
-  * Archive_Zip::_errorLog()
3200
-  *
3201
-  * { Description }
3202
-  *
3203
-  * @param integer $p_error_code
3204
-  * @param string $p_error_string
3205
-  */
3206
-  public function _errorLog($p_error_code=0, $p_error_string='')
3207
-  {
3208
-      $this->_error_code = $p_error_code;
3209
-      $this->_error_string = $p_error_string;
3210
-  }
3211
-  // ---------------------------------------------------------------------------
3212
-
3213
-  // ---------------------------------------------------------------------------
3214
-  // Function : _errorReset()
3215
-  // Description :
3216
-  // Parameters :
3217
-  // ---------------------------------------------------------------------------
3218
-  /**
3219
-  * Archive_Zip::_errorReset()
3220
-  *
3221
-  * { Description }
3222
-  *
3223
-  */
3224
-  public function _errorReset()
3225
-  {
3226
-      $this->_error_code = 1;
3227
-      $this->_error_string = '';
3228
-  }
3229
-  // ---------------------------------------------------------------------------
3230
-
3231
-  // ---------------------------------------------------------------------------
3232
-  // Function : $this->_tool_PathReduction()
3233
-  // Description :
3234
-  // Parameters :
3235
-  // Return Values :
3236
-  // ---------------------------------------------------------------------------
3237
-  /**
3238
-  * _tool_PathReduction()
3239
-  *
3240
-  * { Description }
3241
-  *
3242
-  */
3243
-  public function _tool_PathReduction($p_dir)
3244
-  {
3245
-      $v_result = '';
3175
+                                'callback_pre_extract', 'callback_post_extract');
3176
+        for ($i=0; $i < count($v_callback_list); $i++) {
3177
+            $v_key=$v_callback_list[$i];
3178
+            if (isset($p_params[$v_key]) && ($p_params[$v_key] != '')) {
3179
+                if (!function_exists($p_params[$v_key])) {
3180
+                    $this->_errorLog(ARCHIVE_ZIP_ERR_INVALID_PARAM_VALUE,
3181
+                                    "Callback '".$p_params[$v_key]
3182
+                                    ."()' is not an existing function for "
3183
+                                    ."parameter '".$v_key."'");
3184
+                    return Archive_Zip::errorCode();
3185
+                }
3186
+            }
3187
+        }
3188
+
3189
+        return 1;
3190
+    }
3191
+    // ---------------------------------------------------------------------------
3192
+
3193
+    // ---------------------------------------------------------------------------
3194
+    // Function : _errorLog()
3195
+    // Description :
3196
+    // Parameters :
3197
+    // ---------------------------------------------------------------------------
3198
+    /**
3199
+     * Archive_Zip::_errorLog()
3200
+     *
3201
+     * { Description }
3202
+     *
3203
+     * @param integer $p_error_code
3204
+     * @param string $p_error_string
3205
+     */
3206
+    public function _errorLog($p_error_code=0, $p_error_string='')
3207
+    {
3208
+        $this->_error_code = $p_error_code;
3209
+        $this->_error_string = $p_error_string;
3210
+    }
3211
+    // ---------------------------------------------------------------------------
3212
+
3213
+    // ---------------------------------------------------------------------------
3214
+    // Function : _errorReset()
3215
+    // Description :
3216
+    // Parameters :
3217
+    // ---------------------------------------------------------------------------
3218
+    /**
3219
+     * Archive_Zip::_errorReset()
3220
+     *
3221
+     * { Description }
3222
+     *
3223
+     */
3224
+    public function _errorReset()
3225
+    {
3226
+        $this->_error_code = 1;
3227
+        $this->_error_string = '';
3228
+    }
3229
+    // ---------------------------------------------------------------------------
3230
+
3231
+    // ---------------------------------------------------------------------------
3232
+    // Function : $this->_tool_PathReduction()
3233
+    // Description :
3234
+    // Parameters :
3235
+    // Return Values :
3236
+    // ---------------------------------------------------------------------------
3237
+    /**
3238
+     * _tool_PathReduction()
3239
+     *
3240
+     * { Description }
3241
+     *
3242
+     */
3243
+    public function _tool_PathReduction($p_dir)
3244
+    {
3245
+        $v_result = '';
3246 3246
 
3247 3247
     // ----- Look for not empty path
3248 3248
     if ($p_dir != '') {
3249 3249
         // ----- Explode path by directory names
3250
-      $v_list = explode('/', $p_dir);
3250
+        $v_list = explode('/', $p_dir);
3251 3251
 
3252
-      // ----- Study directories from last to first
3253
-      for ($i= count($v_list) - 1; $i >= 0; $i--) {
3254
-          // ----- Look for current path
3252
+        // ----- Study directories from last to first
3253
+        for ($i= count($v_list) - 1; $i >= 0; $i--) {
3254
+            // ----- Look for current path
3255 3255
         if ($v_list[$i] == '.') {
3256 3256
             // ----- Ignore this directory
3257
-          // Should be the first $i=0, but no check is done
3257
+            // Should be the first $i=0, but no check is done
3258 3258
         } elseif ($v_list[$i] == '..') {
3259 3259
             // ----- Ignore it and ignore the $i-1
3260
-          $i--;
3260
+            $i--;
3261 3261
         } elseif (($v_list[$i] == '') && ($i != (count($v_list) - 1)) && ($i != 0)) {
3262 3262
             // ----- Ignore only the double '//' in path,
3263
-          // but not the first and last '/'
3263
+            // but not the first and last '/'
3264 3264
         } else {
3265 3265
             $v_result = $v_list[$i].($i!=(count($v_list) - 1)? '/' . $v_result: '');
3266 3266
         }
3267
-      }
3267
+        }
3268 3268
     }
3269 3269
 
3270 3270
     // ----- Return
3271 3271
     return $v_result;
3272
-  }
3273
-  // ---------------------------------------------------------------------------
3274
-
3275
-  // ---------------------------------------------------------------------------
3276
-  // Function : $this->_tool_PathInclusion()
3277
-  // Description :
3278
-  //   This function indicates if the path $p_path is under the $p_dir tree. Or,
3279
-  //   said in an other way, if the file or sub-dir $p_path is inside the dir
3280
-  //   $p_dir.
3281
-  //   The function indicates also if the path is exactly the same as the dir.
3282
-  //   This function supports path with duplicated '/' like '//', but does not
3283
-  //   support '.' or '..' statements.
3284
-  // Parameters :
3285
-  // Return Values :
3286
-  //   0 if $p_path is not inside directory $p_dir
3287
-  //   1 if $p_path is inside directory $p_dir
3288
-  //   2 if $p_path is exactly the same as $p_dir
3289
-  // ---------------------------------------------------------------------------
3290
-  /**
3291
-  * _tool_PathInclusion()
3292
-  *
3293
-  * { Description }
3294
-  *
3295
-  */
3296
-  public function _tool_PathInclusion($p_dir, $p_path)
3297
-  {
3298
-      $v_result = 1;
3272
+    }
3273
+    // ---------------------------------------------------------------------------
3274
+
3275
+    // ---------------------------------------------------------------------------
3276
+    // Function : $this->_tool_PathInclusion()
3277
+    // Description :
3278
+    //   This function indicates if the path $p_path is under the $p_dir tree. Or,
3279
+    //   said in an other way, if the file or sub-dir $p_path is inside the dir
3280
+    //   $p_dir.
3281
+    //   The function indicates also if the path is exactly the same as the dir.
3282
+    //   This function supports path with duplicated '/' like '//', but does not
3283
+    //   support '.' or '..' statements.
3284
+    // Parameters :
3285
+    // Return Values :
3286
+    //   0 if $p_path is not inside directory $p_dir
3287
+    //   1 if $p_path is inside directory $p_dir
3288
+    //   2 if $p_path is exactly the same as $p_dir
3289
+    // ---------------------------------------------------------------------------
3290
+    /**
3291
+     * _tool_PathInclusion()
3292
+     *
3293
+     * { Description }
3294
+     *
3295
+     */
3296
+    public function _tool_PathInclusion($p_dir, $p_path)
3297
+    {
3298
+        $v_result = 1;
3299 3299
 
3300 3300
     // ----- Explode dir and path by directory separator
3301 3301
     $v_list_dir = explode('/', $p_dir);
3302
-      $v_list_dir_size = count($v_list_dir);
3303
-      $v_list_path = explode('/', $p_path);
3304
-      $v_list_path_size = count($v_list_path);
3302
+        $v_list_dir_size = count($v_list_dir);
3303
+        $v_list_path = explode('/', $p_path);
3304
+        $v_list_path_size = count($v_list_path);
3305 3305
 
3306 3306
     // ----- Study directories paths
3307 3307
     $i = 0;
3308
-      $j = 0;
3309
-      while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && $v_result) {
3310
-
3311
-      // ----- Look for empty dir (path reduction)
3312
-      if ($v_list_dir[$i] == '') {
3313
-          $i++;
3314
-          continue;
3315
-      }
3316
-          if ($v_list_path[$j] == '') {
3317
-              $j++;
3318
-              continue;
3319
-          }
3320
-
3321
-      // ----- Compare the items
3322
-      if (($v_list_dir[$i] != $v_list_path[$j])
3308
+        $j = 0;
3309
+        while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && $v_result) {
3310
+
3311
+        // ----- Look for empty dir (path reduction)
3312
+        if ($v_list_dir[$i] == '') {
3313
+            $i++;
3314
+            continue;
3315
+        }
3316
+            if ($v_list_path[$j] == '') {
3317
+                $j++;
3318
+                continue;
3319
+            }
3320
+
3321
+        // ----- Compare the items
3322
+        if (($v_list_dir[$i] != $v_list_path[$j])
3323 3323
           && ($v_list_dir[$i] != '')
3324 3324
           && ($v_list_path[$j] != '')) {
3325
-          $v_result = 0;
3326
-      }
3325
+            $v_result = 0;
3326
+        }
3327 3327
 
3328
-      // ----- Next items
3329
-      $i++;
3330
-          $j++;
3331
-      }
3328
+        // ----- Next items
3329
+        $i++;
3330
+            $j++;
3331
+        }
3332 3332
 
3333 3333
     // ----- Look if everything seems to be the same
3334 3334
     if ($v_result) {
3335 3335
         // ----- Skip all the empty items
3336
-      while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) {
3337
-          $j++;
3338
-      }
3336
+        while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) {
3337
+            $j++;
3338
+        }
3339 3339
         while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) {
3340 3340
             $i++;
3341 3341
         }
@@ -3351,142 +3351,142 @@  discard block
 block discarded – undo
3351 3351
 
3352 3352
     // ----- Return
3353 3353
     return $v_result;
3354
-  }
3355
-  // ---------------------------------------------------------------------------
3356
-
3357
-  // ---------------------------------------------------------------------------
3358
-  // Function : $this->_tool_CopyBlock()
3359
-  // Description :
3360
-  // Parameters :
3361
-  //   $p_mode : read/write compression mode
3362
-  //             0 : src & dest normal
3363
-  //             1 : src gzip, dest normal
3364
-  //             2 : src normal, dest gzip
3365
-  //             3 : src & dest gzip
3366
-  // Return Values :
3367
-  // ---------------------------------------------------------------------------
3368
-  /**
3369
-  * _tool_CopyBlock()
3370
-  *
3371
-  * { Description }
3372
-  *
3373
-  * @param integer $p_mode
3374
-  */
3375
-  public function _tool_CopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
3376
-  {
3377
-      $v_result = 1;
3378
-
3379
-      if ($p_mode==0) {
3380
-          while ($p_size != 0) {
3381
-              $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
3354
+    }
3355
+    // ---------------------------------------------------------------------------
3356
+
3357
+    // ---------------------------------------------------------------------------
3358
+    // Function : $this->_tool_CopyBlock()
3359
+    // Description :
3360
+    // Parameters :
3361
+    //   $p_mode : read/write compression mode
3362
+    //             0 : src & dest normal
3363
+    //             1 : src gzip, dest normal
3364
+    //             2 : src normal, dest gzip
3365
+    //             3 : src & dest gzip
3366
+    // Return Values :
3367
+    // ---------------------------------------------------------------------------
3368
+    /**
3369
+     * _tool_CopyBlock()
3370
+     *
3371
+     * { Description }
3372
+     *
3373
+     * @param integer $p_mode
3374
+     */
3375
+    public function _tool_CopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
3376
+    {
3377
+        $v_result = 1;
3378
+
3379
+        if ($p_mode==0) {
3380
+            while ($p_size != 0) {
3381
+                $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
3382 3382
                         ? $p_size : ARCHIVE_ZIP_READ_BLOCK_SIZE);
3383
-              $v_buffer = @fread($p_src, $v_read_size);
3384
-              @fwrite($p_dest, $v_buffer, $v_read_size);
3385
-              $p_size -= $v_read_size;
3386
-          }
3387
-      } elseif ($p_mode==1) {
3388
-          while ($p_size != 0) {
3389
-              $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
3383
+                $v_buffer = @fread($p_src, $v_read_size);
3384
+                @fwrite($p_dest, $v_buffer, $v_read_size);
3385
+                $p_size -= $v_read_size;
3386
+            }
3387
+        } elseif ($p_mode==1) {
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 = @gzread($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==2) {
3396
-          while ($p_size != 0) {
3397
-              $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
3391
+                $v_buffer = @gzread($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==2) {
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 = @fread($p_src, $v_read_size);
3400
-              @gzwrite($p_dest, $v_buffer, $v_read_size);
3401
-              $p_size -= $v_read_size;
3402
-          }
3403
-      } elseif ($p_mode==3) {
3404
-          while ($p_size != 0) {
3405
-              $v_read_size = ($p_size < ARCHIVE_ZIP_READ_BLOCK_SIZE
3399
+                $v_buffer = @fread($p_src, $v_read_size);
3400
+                @gzwrite($p_dest, $v_buffer, $v_read_size);
3401
+                $p_size -= $v_read_size;
3402
+            }
3403
+        } elseif ($p_mode==3) {
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 = @gzread($p_src, $v_read_size);
3408
-              @gzwrite($p_dest, $v_buffer, $v_read_size);
3409
-              $p_size -= $v_read_size;
3410
-          }
3411
-      }
3407
+                $v_buffer = @gzread($p_src, $v_read_size);
3408
+                @gzwrite($p_dest, $v_buffer, $v_read_size);
3409
+                $p_size -= $v_read_size;
3410
+            }
3411
+        }
3412 3412
 
3413 3413
     // ----- Return
3414 3414
     return $v_result;
3415
-  }
3416
-  // ---------------------------------------------------------------------------
3417
-
3418
-  // ---------------------------------------------------------------------------
3419
-  // Function : $this->_tool_Rename()
3420
-  // Description :
3421
-  //   This function tries to do a simple rename() function. If it fails, it
3422
-  //   tries to copy the $p_src file in a new $p_dest file and then unlink the
3423
-  //   first one.
3424
-  // Parameters :
3425
-  //   $p_src : Old filename
3426
-  //   $p_dest : New filename
3427
-  // Return Values :
3428
-  //   1 on success, 0 on failure.
3429
-  // ---------------------------------------------------------------------------
3430
-  /**
3431
-  * _tool_Rename()
3432
-  *
3433
-  * { Description }
3434
-  *
3435
-  */
3436
-  public function _tool_Rename($p_src, $p_dest)
3437
-  {
3438
-      $v_result = 1;
3415
+    }
3416
+    // ---------------------------------------------------------------------------
3417
+
3418
+    // ---------------------------------------------------------------------------
3419
+    // Function : $this->_tool_Rename()
3420
+    // Description :
3421
+    //   This function tries to do a simple rename() function. If it fails, it
3422
+    //   tries to copy the $p_src file in a new $p_dest file and then unlink the
3423
+    //   first one.
3424
+    // Parameters :
3425
+    //   $p_src : Old filename
3426
+    //   $p_dest : New filename
3427
+    // Return Values :
3428
+    //   1 on success, 0 on failure.
3429
+    // ---------------------------------------------------------------------------
3430
+    /**
3431
+     * _tool_Rename()
3432
+     *
3433
+     * { Description }
3434
+     *
3435
+     */
3436
+    public function _tool_Rename($p_src, $p_dest)
3437
+    {
3438
+        $v_result = 1;
3439 3439
 
3440 3440
     // ----- Try to rename the files
3441 3441
     if (!@rename($p_src, $p_dest)) {
3442 3442
 
3443
-      // ----- Try to copy & unlink the src
3444
-      if (!@copy($p_src, $p_dest)) {
3445
-          $v_result = 0;
3446
-      } elseif (!@unlink($p_src)) {
3447
-          $v_result = 0;
3448
-      }
3443
+        // ----- Try to copy & unlink the src
3444
+        if (!@copy($p_src, $p_dest)) {
3445
+            $v_result = 0;
3446
+        } elseif (!@unlink($p_src)) {
3447
+            $v_result = 0;
3448
+        }
3449 3449
     }
3450 3450
 
3451 3451
     // ----- Return
3452 3452
     return $v_result;
3453
-  }
3454
-  // ---------------------------------------------------------------------------
3455
-
3456
-  // ---------------------------------------------------------------------------
3457
-  // Function : $this->_tool_TranslateWinPath()
3458
-  // Description :
3459
-  //   Translate windows path by replacing '\' by '/' and optionally removing
3460
-  //   drive letter.
3461
-  // Parameters :
3462
-  //   $p_path : path to translate.
3463
-  //   $p_remove_disk_letter : true | false
3464
-  // Return Values :
3465
-  //   The path translated.
3466
-  // ---------------------------------------------------------------------------
3467
-  /**
3468
-  * _tool_TranslateWinPath()
3469
-  *
3470
-  * { Description }
3471
-  *
3472
-  * @param [type] $p_remove_disk_letter
3473
-  */
3474
-  public function _tool_TranslateWinPath($p_path, $p_remove_disk_letter=true)
3475
-  {
3476
-      if (stristr(php_uname(), 'windows')) {
3477
-          // ----- Look for potential disk letter
3478
-      if ($p_remove_disk_letter
3453
+    }
3454
+    // ---------------------------------------------------------------------------
3455
+
3456
+    // ---------------------------------------------------------------------------
3457
+    // Function : $this->_tool_TranslateWinPath()
3458
+    // Description :
3459
+    //   Translate windows path by replacing '\' by '/' and optionally removing
3460
+    //   drive letter.
3461
+    // Parameters :
3462
+    //   $p_path : path to translate.
3463
+    //   $p_remove_disk_letter : true | false
3464
+    // Return Values :
3465
+    //   The path translated.
3466
+    // ---------------------------------------------------------------------------
3467
+    /**
3468
+     * _tool_TranslateWinPath()
3469
+     *
3470
+     * { Description }
3471
+     *
3472
+     * @param [type] $p_remove_disk_letter
3473
+     */
3474
+    public function _tool_TranslateWinPath($p_path, $p_remove_disk_letter=true)
3475
+    {
3476
+        if (stristr(php_uname(), 'windows')) {
3477
+            // ----- Look for potential disk letter
3478
+        if ($p_remove_disk_letter
3479 3479
           && (($v_position = strpos($p_path, ':')) != false)) {
3480
-          $p_path = substr($p_path, $v_position+1);
3481
-      }
3482
-      // ----- Change potential windows directory separator
3483
-      if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) {
3484
-          $p_path = strtr($p_path, '\\', '/');
3485
-      }
3486
-      }
3487
-      return $p_path;
3488
-  }
3489
-  // ---------------------------------------------------------------------------
3480
+            $p_path = substr($p_path, $v_position+1);
3481
+        }
3482
+        // ----- Change potential windows directory separator
3483
+        if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0, 1) == '\\')) {
3484
+            $p_path = strtr($p_path, '\\', '/');
3485
+        }
3486
+        }
3487
+        return $p_path;
3488
+    }
3489
+    // ---------------------------------------------------------------------------
3490 3490
 }
3491
-  // End of class
3491
+    // End of class
3492 3492
 
Please login to merge, or discard this patch.
xoops_trust_path/libs/altsys/include/gtickets.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -233,6 +233,9 @@
 block discarded – undo
233 233
         echo '<html><head><title>'.$this->messages['err_general'].'</title><style>table,td,th {border:solid black 1px; border-collapse:collapse;}</style></head><body>' . sprintf($this->messages['fmt_prompt4repost'], $this->getErrors()) . $table . $form . '</body></html>' ;
234 234
     }
235 235
 
236
+        /**
237
+         * @param string $key_name
238
+         */
236 239
         public function extract_post_recursive($key_name, $tmp_array)
237 240
         {
238 241
             $table = '' ;
Please login to merge, or discard this patch.
Spacing   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -2,147 +2,147 @@  discard block
 block discarded – undo
2 2
 // GIJOE's Ticket Class (based on Marijuana's Oreteki XOOPS)
3 3
 // nobunobu's suggestions are applied
4 4
 
5
-if (! class_exists('XoopsGTicket')) {
5
+if (!class_exists('XoopsGTicket')) {
6 6
     class XoopsGTicket
7 7
     {
8 8
 
9
-        public $_errors = array() ;
10
-        public $_latest_token = '' ;
11
-        public $messages = array() ;
9
+        public $_errors = array();
10
+        public $_latest_token = '';
11
+        public $messages = array();
12 12
 
13 13
         public function __construct()
14 14
         {
15
-            global $xoopsConfig ;
15
+            global $xoopsConfig;
16 16
 
17 17
         // language file
18
-        if (defined('XOOPS_ROOT_PATH') && ! empty($xoopsConfig['language']) && ! strstr($xoopsConfig['language'], '/')) {
19
-            if (file_exists(dirname(__DIR__) . '/language/' . $xoopsConfig['language'] . '/gticket_messages.phtml')) {
20
-                include dirname(__DIR__) . '/language/' . $xoopsConfig['language'] . '/gticket_messages.phtml' ;
18
+        if (defined('XOOPS_ROOT_PATH') && !empty($xoopsConfig['language']) && !strstr($xoopsConfig['language'], '/')) {
19
+            if (file_exists(dirname(__DIR__).'/language/'.$xoopsConfig['language'].'/gticket_messages.phtml')) {
20
+                include dirname(__DIR__).'/language/'.$xoopsConfig['language'].'/gticket_messages.phtml';
21 21
             }
22 22
         }
23 23
 
24 24
         // default messages
25 25
         if (empty($this->messages)) {
26 26
             $this->messages = array(
27
-            'err_general' => 'GTicket Error' ,
28
-            'err_nostubs' => 'No stubs found' ,
29
-            'err_noticket' => 'No ticket found' ,
30
-            'err_nopair' => 'No valid ticket-stub pair found' ,
31
-            'err_timeout' => 'Time out' ,
32
-            'err_areaorref' => 'Invalid area or referer' ,
33
-            'fmt_prompt4repost' => 'error(s) found:<br /><span style="background-color:red;font-weight:bold;color:white;">%s</span><br />Confirm it.<br />And do you want to post again?' ,
27
+            'err_general' => 'GTicket Error',
28
+            'err_nostubs' => 'No stubs found',
29
+            'err_noticket' => 'No ticket found',
30
+            'err_nopair' => 'No valid ticket-stub pair found',
31
+            'err_timeout' => 'Time out',
32
+            'err_areaorref' => 'Invalid area or referer',
33
+            'fmt_prompt4repost' => 'error(s) found:<br /><span style="background-color:red;font-weight:bold;color:white;">%s</span><br />Confirm it.<br />And do you want to post again?',
34 34
             'btn_repost' => 'repost'
35
-        ) ;
35
+        );
36 36
         }
37 37
         }
38 38
 
39 39
     // render form as plain html
40 40
     public function getTicketHtml($salt = '', $timeout = 1800, $area = '')
41 41
     {
42
-        return '<input type="hidden" name="XOOPS_G_TICKET" value="'.$this->issue($salt, $timeout, $area).'" />' ;
42
+        return '<input type="hidden" name="XOOPS_G_TICKET" value="'.$this->issue($salt, $timeout, $area).'" />';
43 43
     }
44 44
 
45 45
     // returns an object of XoopsFormHidden including theh ticket
46 46
     public function getTicketXoopsForm($salt = '', $timeout = 1800, $area = '')
47 47
     {
48
-        return new XoopsFormHidden('XOOPS_G_TICKET', $this->issue($salt, $timeout, $area)) ;
48
+        return new XoopsFormHidden('XOOPS_G_TICKET', $this->issue($salt, $timeout, $area));
49 49
     }
50 50
 
51 51
     // add a ticket as Hidden Element into XoopsForm
52 52
     public function addTicketXoopsFormElement(&$form, $salt = '', $timeout = 1800, $area = '')
53 53
     {
54
-        $form->addElement(new XoopsFormHidden('XOOPS_G_TICKET', $this->issue($salt, $timeout, $area))) ;
54
+        $form->addElement(new XoopsFormHidden('XOOPS_G_TICKET', $this->issue($salt, $timeout, $area)));
55 55
     }
56 56
 
57 57
     // returns an array for xoops_confirm() ;
58 58
     public function getTicketArray($salt = '', $timeout = 1800, $area = '')
59 59
     {
60
-        return array( 'XOOPS_G_TICKET' => $this->issue($salt, $timeout, $area) ) ;
60
+        return array('XOOPS_G_TICKET' => $this->issue($salt, $timeout, $area));
61 61
     }
62 62
 
63 63
     // return GET parameter string.
64
-    public function getTicketParamString($salt = '', $noamp = false, $timeout=1800, $area = '')
64
+    public function getTicketParamString($salt = '', $noamp = false, $timeout = 1800, $area = '')
65 65
     {
66
-        return ($noamp ? '' : '&amp;') . 'XOOPS_G_TICKET=' . $this->issue($salt, $timeout, $area) ;
66
+        return ($noamp ? '' : '&amp;').'XOOPS_G_TICKET='.$this->issue($salt, $timeout, $area);
67 67
     }
68 68
 
69 69
     // issue a ticket
70 70
     public function issue($salt = '', $timeout = 1800, $area = '')
71 71
     {
72
-        global $xoopsModule ;
72
+        global $xoopsModule;
73 73
 
74 74
         // create a token
75
-        list($usec, $sec) = explode(' ', microtime()) ;
76
-        $appendix_salt = empty($_SERVER['PATH']) ? XOOPS_DB_NAME : $_SERVER['PATH'] ;
77
-        $token = crypt($salt . $usec . $appendix_salt . $sec, XOOPS_DB_PREFIX) ;
78
-        $this->_latest_token = $token ;
75
+        list($usec, $sec) = explode(' ', microtime());
76
+        $appendix_salt = empty($_SERVER['PATH']) ? XOOPS_DB_NAME : $_SERVER['PATH'];
77
+        $token = crypt($salt.$usec.$appendix_salt.$sec, XOOPS_DB_PREFIX);
78
+        $this->_latest_token = $token;
79 79
 
80 80
         if (empty($_SESSION['XOOPS_G_STUBS'])) {
81
-            $_SESSION['XOOPS_G_STUBS'] = array() ;
81
+            $_SESSION['XOOPS_G_STUBS'] = array();
82 82
         }
83 83
 
84 84
         // limit max stubs 10
85 85
         if (count($_SESSION['XOOPS_G_STUBS']) > 10) {
86
-            $_SESSION['XOOPS_G_STUBS'] = array_slice($_SESSION['XOOPS_G_STUBS'], -10) ;
86
+            $_SESSION['XOOPS_G_STUBS'] = array_slice($_SESSION['XOOPS_G_STUBS'], -10);
87 87
         }
88 88
 
89 89
         // record referer if browser send it
90
-        $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['REQUEST_URI'] ;
90
+        $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['REQUEST_URI'];
91 91
 
92 92
         // area as module's dirname
93
-        if (! $area && is_object(@$xoopsModule)) {
94
-            $area = $xoopsModule->getVar('dirname') ;
93
+        if (!$area && is_object(@$xoopsModule)) {
94
+            $area = $xoopsModule->getVar('dirname');
95 95
         }
96 96
 
97 97
         // store stub
98 98
         $_SESSION['XOOPS_G_STUBS'][] = array(
99
-            'expire' => time() + $timeout ,
100
-            'referer' => $referer ,
101
-            'area' => $area ,
99
+            'expire' => time() + $timeout,
100
+            'referer' => $referer,
101
+            'area' => $area,
102 102
             'token' => $token
103
-        ) ;
103
+        );
104 104
 
105 105
         // paid md5ed token as a ticket
106
-        return md5($token . XOOPS_DB_PREFIX) ;
106
+        return md5($token.XOOPS_DB_PREFIX);
107 107
     }
108 108
 
109 109
     // check a ticket
110 110
     public function check($post = true, $area = '', $allow_repost = true)
111 111
     {
112
-        global $xoopsModule ;
112
+        global $xoopsModule;
113 113
 
114
-        $this->_errors = array() ;
114
+        $this->_errors = array();
115 115
 
116 116
         // CHECK: stubs are not stored in session
117
-        if (! is_array(@$_SESSION['XOOPS_G_STUBS'])) {
118
-            $this->_errors[] = $this->messages['err_nostubs'] ;
119
-            $_SESSION['XOOPS_G_STUBS'] = array() ;
117
+        if (!is_array(@$_SESSION['XOOPS_G_STUBS'])) {
118
+            $this->_errors[] = $this->messages['err_nostubs'];
119
+            $_SESSION['XOOPS_G_STUBS'] = array();
120 120
         }
121 121
 
122 122
         // get key&val of the ticket from a user's query
123
-        $ticket = $post ? @$_POST['XOOPS_G_TICKET'] : @$_GET['XOOPS_G_TICKET'] ;
123
+        $ticket = $post ? @$_POST['XOOPS_G_TICKET'] : @$_GET['XOOPS_G_TICKET'];
124 124
 
125 125
         // CHECK: no tickets found
126 126
         if (empty($ticket)) {
127
-            $this->_errors[] = $this->messages['err_noticket'] ;
127
+            $this->_errors[] = $this->messages['err_noticket'];
128 128
         }
129 129
 
130 130
         // gargage collection & find a right stub
131
-        $stubs_tmp = $_SESSION['XOOPS_G_STUBS'] ;
132
-        $_SESSION['XOOPS_G_STUBS'] = array() ;
131
+        $stubs_tmp = $_SESSION['XOOPS_G_STUBS'];
132
+        $_SESSION['XOOPS_G_STUBS'] = array();
133 133
         foreach ($stubs_tmp as $stub) {
134 134
             // default lifetime 30min
135 135
             if ($stub['expire'] >= time()) {
136
-                if (md5($stub['token'] . XOOPS_DB_PREFIX) === $ticket) {
137
-                    $found_stub = $stub ;
136
+                if (md5($stub['token'].XOOPS_DB_PREFIX) === $ticket) {
137
+                    $found_stub = $stub;
138 138
                 } else {
139 139
                     // store the other valid stubs into session
140
-                    $_SESSION['XOOPS_G_STUBS'][] = $stub ;
140
+                    $_SESSION['XOOPS_G_STUBS'][] = $stub;
141 141
                 }
142 142
             } else {
143
-                if (md5($stub['token'] . XOOPS_DB_PREFIX) === $ticket) {
143
+                if (md5($stub['token'].XOOPS_DB_PREFIX) === $ticket) {
144 144
                     // not CSRF but Time-Out
145
-                    $timeout_flag = true ;
145
+                    $timeout_flag = true;
146 146
                 }
147 147
             }
148 148
         }
@@ -150,40 +150,40 @@  discard block
 block discarded – undo
150 150
         // CHECK: the right stub found or not
151 151
         if (empty($found_stub)) {
152 152
             if (empty($timeout_flag)) {
153
-                $this->_errors[] = $this->messages['err_nopair'] ;
153
+                $this->_errors[] = $this->messages['err_nopair'];
154 154
             } else {
155
-                $this->_errors[] = $this->messages['err_timeout'] ;
155
+                $this->_errors[] = $this->messages['err_timeout'];
156 156
             }
157 157
         } else {
158 158
 
159 159
             // set area if necessary
160 160
             // area as module's dirname
161
-            if (! $area && is_object(@$xoopsModule)) {
162
-                $area = $xoopsModule->getVar('dirname') ;
161
+            if (!$area && is_object(@$xoopsModule)) {
162
+                $area = $xoopsModule->getVar('dirname');
163 163
             }
164 164
 
165 165
             // check area or referer
166 166
             if (@$found_stub['area'] == $area) {
167
-                $area_check = true ;
167
+                $area_check = true;
168 168
             }
169
-            if (! empty($found_stub['referer']) && strstr(@$_SERVER['HTTP_REFERER'], $found_stub['referer'])) {
170
-                $referer_check = true ;
169
+            if (!empty($found_stub['referer']) && strstr(@$_SERVER['HTTP_REFERER'], $found_stub['referer'])) {
170
+                $referer_check = true;
171 171
             }
172 172
 
173 173
             if (empty($area_check) && empty($referer_check)) { // loose
174
-                $this->_errors[] = $this->messages['err_areaorref'] ;
174
+                $this->_errors[] = $this->messages['err_areaorref'];
175 175
             }
176 176
         }
177 177
 
178
-        if (! empty($this->_errors)) {
178
+        if (!empty($this->_errors)) {
179 179
             if ($allow_repost) {
180 180
                 // repost form
181
-                $this->draw_repost_form($area) ;
182
-                exit ;
181
+                $this->draw_repost_form($area);
182
+                exit;
183 183
             } else {
184 184
                 // failed
185
-                $this->clear() ;
186
-                return false ;
185
+                $this->clear();
186
+                return false;
187 187
             }
188 188
         } else {
189 189
             // all green
@@ -196,78 +196,78 @@  discard block
 block discarded – undo
196 196
     {
197 197
         // Notify which file is broken
198 198
         if (headers_sent()) {
199
-            restore_error_handler() ;
200
-            set_error_handler(array( &$this, 'errorHandler4FindOutput' )) ;
201
-            header('Dummy: for warning') ;
202
-            restore_error_handler() ;
203
-            exit ;
199
+            restore_error_handler();
200
+            set_error_handler(array(&$this, 'errorHandler4FindOutput'));
201
+            header('Dummy: for warning');
202
+            restore_error_handler();
203
+            exit;
204 204
         }
205 205
 
206
-        $table = '<table>' ;
207
-        $form = '<form action="?'.htmlspecialchars(@$_SERVER['QUERY_STRING'], ENT_QUOTES).'" method="post" >' ;
206
+        $table = '<table>';
207
+        $form = '<form action="?'.htmlspecialchars(@$_SERVER['QUERY_STRING'], ENT_QUOTES).'" method="post" >';
208 208
         foreach ($_POST as $key => $val) {
209 209
             if ($key == 'XOOPS_G_TICKET') {
210
-                continue ;
210
+                continue;
211 211
             }
212 212
             if (get_magic_quotes_gpc()) {
213
-                $key = stripslashes($key) ;
213
+                $key = stripslashes($key);
214 214
             }
215 215
             if (is_array($val)) {
216
-                list($tmp_table, $tmp_form) = $this->extract_post_recursive(htmlspecialchars($key, ENT_QUOTES), $val) ;
217
-                $table .= $tmp_table ;
218
-                $form .= $tmp_form ;
216
+                list($tmp_table, $tmp_form) = $this->extract_post_recursive(htmlspecialchars($key, ENT_QUOTES), $val);
217
+                $table .= $tmp_table;
218
+                $form .= $tmp_form;
219 219
             } else {
220 220
                 if (get_magic_quotes_gpc()) {
221
-                    $val = stripslashes($val) ;
221
+                    $val = stripslashes($val);
222 222
                 }
223
-                $table .= '<tr><th>'.htmlspecialchars($key, ENT_QUOTES).'</th><td>'.htmlspecialchars($val, ENT_QUOTES).'</td></tr>'."\n" ;
224
-                $form .= '<input type="hidden" name="'.htmlspecialchars($key, ENT_QUOTES).'" value="'.htmlspecialchars($val, ENT_QUOTES).'" />'."\n" ;
223
+                $table .= '<tr><th>'.htmlspecialchars($key, ENT_QUOTES).'</th><td>'.htmlspecialchars($val, ENT_QUOTES).'</td></tr>'."\n";
224
+                $form .= '<input type="hidden" name="'.htmlspecialchars($key, ENT_QUOTES).'" value="'.htmlspecialchars($val, ENT_QUOTES).'" />'."\n";
225 225
             }
226 226
         }
227
-        $table .= '</table>' ;
228
-        $form .= $this->getTicketHtml(__LINE__, 300, $area).'<input type="submit" value="'.$this->messages['btn_repost'].'" /></form>' ;
227
+        $table .= '</table>';
228
+        $form .= $this->getTicketHtml(__LINE__, 300, $area).'<input type="submit" value="'.$this->messages['btn_repost'].'" /></form>';
229 229
 
230
-        error_reporting(0) ;
230
+        error_reporting(0);
231 231
         while (@ob_get_level() && @ob_end_clean());
232 232
 
233
-        echo '<html><head><title>'.$this->messages['err_general'].'</title><style>table,td,th {border:solid black 1px; border-collapse:collapse;}</style></head><body>' . sprintf($this->messages['fmt_prompt4repost'], $this->getErrors()) . $table . $form . '</body></html>' ;
233
+        echo '<html><head><title>'.$this->messages['err_general'].'</title><style>table,td,th {border:solid black 1px; border-collapse:collapse;}</style></head><body>'.sprintf($this->messages['fmt_prompt4repost'], $this->getErrors()).$table.$form.'</body></html>';
234 234
     }
235 235
 
236 236
         public function extract_post_recursive($key_name, $tmp_array)
237 237
         {
238
-            $table = '' ;
239
-            $form = '' ;
238
+            $table = '';
239
+            $form = '';
240 240
             foreach ($tmp_array as $key => $val) {
241 241
                 if (get_magic_quotes_gpc()) {
242
-                    $key = stripslashes($key) ;
242
+                    $key = stripslashes($key);
243 243
                 }
244 244
                 if (is_array($val)) {
245
-                    list($tmp_table, $tmp_form) = $this->extract_post_recursive($key_name.'['.htmlspecialchars($key, ENT_QUOTES).']', $val) ;
246
-                    $table .= $tmp_table ;
247
-                    $form .= $tmp_form ;
245
+                    list($tmp_table, $tmp_form) = $this->extract_post_recursive($key_name.'['.htmlspecialchars($key, ENT_QUOTES).']', $val);
246
+                    $table .= $tmp_table;
247
+                    $form .= $tmp_form;
248 248
                 } else {
249 249
                     if (get_magic_quotes_gpc()) {
250
-                        $val = stripslashes($val) ;
250
+                        $val = stripslashes($val);
251 251
                     }
252
-                    $table .= '<tr><th>'.$key_name.'['.htmlspecialchars($key, ENT_QUOTES).']</th><td>'.htmlspecialchars($val, ENT_QUOTES).'</td></tr>'."\n" ;
253
-                    $form .= '<input type="hidden" name="'.$key_name.'['.htmlspecialchars($key, ENT_QUOTES).']" value="'.htmlspecialchars($val, ENT_QUOTES).'" />'."\n" ;
252
+                    $table .= '<tr><th>'.$key_name.'['.htmlspecialchars($key, ENT_QUOTES).']</th><td>'.htmlspecialchars($val, ENT_QUOTES).'</td></tr>'."\n";
253
+                    $form .= '<input type="hidden" name="'.$key_name.'['.htmlspecialchars($key, ENT_QUOTES).']" value="'.htmlspecialchars($val, ENT_QUOTES).'" />'."\n";
254 254
                 }
255 255
             }
256
-            return array( $table , $form ) ;
256
+            return array($table, $form);
257 257
         }
258 258
 
259 259
 
260 260
     // clear all stubs
261 261
     public function clear()
262 262
     {
263
-        $_SESSION['XOOPS_G_STUBS'] = array() ;
263
+        $_SESSION['XOOPS_G_STUBS'] = array();
264 264
     }
265 265
 
266 266
 
267 267
     // Ticket Using
268 268
     public function using()
269 269
     {
270
-        if (! empty($_SESSION['XOOPS_G_STUBS'])) {
270
+        if (!empty($_SESSION['XOOPS_G_STUBS'])) {
271 271
             return true;
272 272
         } else {
273 273
             return false;
@@ -279,39 +279,39 @@  discard block
 block discarded – undo
279 279
     public function getErrors($ashtml = true)
280 280
     {
281 281
         if ($ashtml) {
282
-            $ret = '' ;
282
+            $ret = '';
283 283
             foreach ($this->_errors as $msg) {
284
-                $ret .= "$msg<br />\n" ;
284
+                $ret .= "$msg<br />\n";
285 285
             }
286 286
         } else {
287
-            $ret = $this->_errors ;
287
+            $ret = $this->_errors;
288 288
         }
289
-        return $ret ;
289
+        return $ret;
290 290
     }
291 291
 
292 292
         public function errorHandler4FindOutput($errNo, $errStr, $errFile, $errLine)
293 293
         {
294 294
             if (preg_match('?'.preg_quote(XOOPS_ROOT_PATH).'([^:]+)\:(\d+)?', $errStr, $regs)) {
295
-                echo 'Irregular output! check the file ' . htmlspecialchars($regs[1]) . ' line ' . htmlspecialchars($regs[2]) ;
295
+                echo 'Irregular output! check the file '.htmlspecialchars($regs[1]).' line '.htmlspecialchars($regs[2]);
296 296
             } else {
297 297
                 echo 'Irregular output! check language files etc.';
298 298
             }
299
-            return ;
299
+            return;
300 300
         }
301 301
 // end of class
302 302
     }
303 303
 
304 304
 // create a instance in global scope
305
-$GLOBALS['xoopsGTicket'] = new XoopsGTicket() ;
305
+$GLOBALS['xoopsGTicket'] = new XoopsGTicket();
306 306
 }
307 307
 
308
-if (! function_exists('admin_refcheck')) {
308
+if (!function_exists('admin_refcheck')) {
309 309
 
310 310
 //Admin Referer Check By Marijuana(Rev.011)
311 311
 function admin_refcheck($chkref = '')
312 312
 {
313 313
     if (empty($_SERVER['HTTP_REFERER'])) {
314
-        return true ;
314
+        return true;
315 315
     } else {
316 316
         $ref = $_SERVER['HTTP_REFERER'];
317 317
     }
Please login to merge, or discard this patch.
xoops_trust_path/libs/altsys/include/mygrouppermform.php 3 patches
Doc Comments   +10 added lines patch added patch discarded remove patch
@@ -82,6 +82,12 @@  discard block
 block discarded – undo
82 82
      */
83 83
 //HACK by domifara
84 84
 //	public function MyXoopsGroupPermForm($title, $modid, $permname, $permdesc)
85
+    /**
86
+     * @param string $title
87
+     * @param integer $modid
88
+     * @param string $permname
89
+     * @param string $permdesc
90
+     */
85 91
     public function __construct($title, $modid, $permname, $permdesc)
86 92
     {
87 93
         //		$this->XoopsForm($title, 'groupperm_form', XOOPS_URL.'/modules/system/admin/groupperm.php', 'post'); GIJ
@@ -112,6 +118,9 @@  discard block
 block discarded – undo
112 118
      * Add appendix
113 119
      *
114 120
      * @access public
121
+     * @param string $permName
122
+     * @param integer $itemId
123
+     * @param string $itemName
115 124
      */
116 125
     public function addAppendix($permName, $itemId, $itemName)
117 126
     {
@@ -251,6 +260,7 @@  discard block
 block discarded – undo
251 260
 
252 261
     /**
253 262
      * Constructor
263
+     * @param string $name
254 264
      */
255 265
     public function MyXoopsGroupFormCheckBox($caption, $name, $groupId, $values = null)
256 266
     {
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
     public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = array())
360 360
     {
361 361
         $tree .= $prefix."<input type=\"checkbox\" name=\"".$this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . "]\" id=\"" . $this->getName() . '[groups][' . $this->_groupId . ']['
362
-                 . $option['id'] . "]\" onclick=\"";
362
+                    . $option['id'] . "]\" onclick=\"";
363 363
         // If there are parent elements, add javascript that will
364 364
         // make them selecteded when this element is checked to make
365 365
         // sure permissions to parent items are added as well.
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
             $tree .= ' checked="checked"';
381 381
         }
382 382
         $tree .= ' />' . $option['name'] . "<input type=\"hidden\" name=\"" . $this->getName() . '[parents][' . $option['id'] . "]\" value=\"" . implode(':', $parentIds) . "\" /><input type=\"hidden\" name=\"" . $this->getName() . '[itemname]['
383
-                 . $option['id'] . "]\" value=\"" . htmlspecialchars($option['name']) . "\" /><br />\n";
383
+                    . $option['id'] . "]\" value=\"" . htmlspecialchars($option['name']) . "\" /><br />\n";
384 384
         if (isset($option['children'])) {
385 385
             foreach ($option['children'] as $child) {
386 386
                 array_push($parentIds, $option['id']);
Please login to merge, or discard this patch.
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 // Project: The XOOPS Project                                                //
30 30
 // ------------------------------------------------------------------------- //
31 31
 
32
-if (! defined('XOOPS_ROOT_PATH')) {
33
-    exit ;
32
+if (!defined('XOOPS_ROOT_PATH')) {
33
+    exit;
34 34
 }
35 35
 
36 36
 require_once XOOPS_ROOT_PATH.'/class/xoopsform/formelement.php';
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
      * Tree structure of items
61 61
      * @var array
62 62
      */
63
-    public $_itemTree = array() ;
63
+    public $_itemTree = array();
64 64
     /**
65 65
      * Name of permission
66 66
      * @var string
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      * Appendix
76 76
      * @var array ('permname'=>,'itemid'=>,'itemname'=>,'selected'=>)
77 77
      */
78
-    public $_appendix = array() ;
78
+    public $_appendix = array();
79 79
 
80 80
     /**
81 81
      * Constructor
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
      */
116 116
     public function addAppendix($permName, $itemId, $itemName)
117 117
     {
118
-        $this->_appendix[] = array('permname'=>$permName,'itemid'=>$itemId,'itemname'=>$itemName,'selected'=>false);
118
+        $this->_appendix[] = array('permname'=>$permName, 'itemid'=>$itemId, 'itemname'=>$itemName, 'selected'=>false);
119 119
     }
120 120
 
121 121
     /**
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
      */
150 150
     public function render()
151 151
     {
152
-        global $xoopsGTicket ;
152
+        global $xoopsGTicket;
153 153
 
154 154
         // load all child ids for javascript codes
155 155
         foreach (array_keys($this->_itemTree) as $item_id) {
@@ -166,11 +166,11 @@  discard block
 block discarded – undo
166 166
             $ele->setOptionTree($this->_itemTree);
167 167
 
168 168
             // GIJ start
169
-            $ele->setDescription('<input type="checkbox" onclick="with(document.groupperm_form){for(i=0;i<length;i++){if(elements[i].name.match(/^perms\[(module_admin|module_read|block_read)\]\[groups\]\['.$i.'\]/)){elements[i].checked=this.checked;}}};">') ;
169
+            $ele->setDescription('<input type="checkbox" onclick="with(document.groupperm_form){for(i=0;i<length;i++){if(elements[i].name.match(/^perms\[(module_admin|module_read|block_read)\]\[groups\]\['.$i.'\]/)){elements[i].checked=this.checked;}}};">');
170 170
             // GIJ_end
171 171
 
172 172
             foreach ($this->_appendix as $key => $append) {
173
-                $this->_appendix[$key]['selected'] = $gperm_handler->checkRight($append['permname'], $append['itemid'], $i, $this->_modid) ;
173
+                $this->_appendix[$key]['selected'] = $gperm_handler->checkRight($append['permname'], $append['itemid'], $i, $this->_modid);
174 174
             }
175 175
             $ele->setAppendix($this->_appendix);
176 176
             $this->addElement($ele);
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
         // GIJ start
181 181
         $jstray = new XoopsFormElementTray(' &nbsp; ');
182 182
         $jsuncheckbutton = new XoopsFormButton('', 'none', _NONE, 'button');
183
-        $jsuncheckbutton->setExtra("onclick=\"with(document.groupperm_form){for(i=0;i<length;i++){if(elements[i].type=='checkbox'){elements[i].checked=false;}}}\"") ;
183
+        $jsuncheckbutton->setExtra("onclick=\"with(document.groupperm_form){for(i=0;i<length;i++){if(elements[i].type=='checkbox'){elements[i].checked=false;}}}\"");
184 184
         $jscheckbutton = new XoopsFormButton('', 'all', _ALL, 'button');
185
-        $jscheckbutton->setExtra("onclick=\"with(document.groupperm_form){for(i=0;i<length;i++){if(elements[i].type=='checkbox' && (elements[i].name.indexOf('module_admin')<0 || elements[i].name.indexOf('[groups][1]')>=0)){elements[i].checked=true;}}}\"") ;
186
-        $jstray->addElement($jsuncheckbutton) ;
187
-        $jstray->addElement($jscheckbutton) ;
185
+        $jscheckbutton->setExtra("onclick=\"with(document.groupperm_form){for(i=0;i<length;i++){if(elements[i].type=='checkbox' && (elements[i].name.indexOf('module_admin')<0 || elements[i].name.indexOf('[groups][1]')>=0)){elements[i].checked=true;}}}\"");
186
+        $jstray->addElement($jsuncheckbutton);
187
+        $jstray->addElement($jscheckbutton);
188 188
         $this->addElement($jstray);
189 189
         // GIJ end
190 190
 
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 
196 196
         $ret = '<h4>'.$this->getTitle().'</h4>'.$this->_permDesc.'<br />';
197 197
         $ret .= "<form name='".$this->getName()."' id='".$this->getName()."' action='".$this->getAction()."' method='".$this->getMethod()."'".$this->getExtra().">\n<table width='100%' class='outer' cellspacing='1'>\n";
198
-        $elements =& $this->getElements();
198
+        $elements = & $this->getElements();
199 199
         foreach (array_keys($elements) as $i) {
200 200
             if (!is_object($elements[$i])) {
201 201
                 $ret .= $elements[$i];
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
                 $ret .= $elements[$i]->render();
212 212
             }
213 213
         }
214
-        $ret .= '</table>' . $xoopsGTicket->getTicketHtml(__LINE__, 1800, 'myblocksadmin') . '</form>';
214
+        $ret .= '</table>'.$xoopsGTicket->getTicketHtml(__LINE__, 1800, 'myblocksadmin').'</form>';
215 215
         return $ret;
216 216
     }
217 217
 }
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
      * Appendix
248 248
      * @var array ('permname'=>,'itemid'=>,'itemname'=>,'selected'=>)
249 249
      */
250
-    public $_appendix = array() ;
250
+    public $_appendix = array();
251 251
 
252 252
     /**
253 253
      * Constructor
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
      */
288 288
     public function setOptionTree(&$optionTree)
289 289
     {
290
-        $this->_optionTree =& $optionTree;
290
+        $this->_optionTree = & $optionTree;
291 291
     }
292 292
 
293 293
     /**
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
      */
298 298
     public function setAppendix($appendix)
299 299
     {
300
-        $this->_appendix = $appendix ;
300
+        $this->_appendix = $appendix;
301 301
     }
302 302
 
303 303
     /**
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
      */
309 309
     public function render()
310 310
     {
311
-        $ret = '' ;
311
+        $ret = '';
312 312
 
313 313
         if (count($this->_appendix) > 0) {
314 314
             $ret .= '<table class="outer"><tr>';
@@ -318,11 +318,11 @@  discard block
 block discarded – undo
318 318
                     $ret .= '</tr><tr>';
319 319
                     $cols = 1;
320 320
                 }
321
-                $checked = $append['selected'] ? 'checked="checked"' : '' ;
322
-                $name = 'perms['.$append['permname'].']' ;
323
-                $itemid = $append['itemid'] ;
324
-                $itemid = $append['itemid'] ;
325
-                $ret .= "<td class=\"odd\"><input type=\"checkbox\" name=\"{$name}[groups][$this->_groupId][$itemid]\" id=\"{$name}[groups][$this->_groupId][$itemid]\" value=\"1\" $checked />{$append['itemname']}<input type=\"hidden\" name=\"{$name}[parents][$itemid]\" value=\"\" /><input type=\"hidden\" name=\"{$name}[itemname][$itemid]\" value=\"{$append['itemname']}\" /><br /></td>" ;
321
+                $checked = $append['selected'] ? 'checked="checked"' : '';
322
+                $name = 'perms['.$append['permname'].']';
323
+                $itemid = $append['itemid'];
324
+                $itemid = $append['itemid'];
325
+                $ret .= "<td class=\"odd\"><input type=\"checkbox\" name=\"{$name}[groups][$this->_groupId][$itemid]\" id=\"{$name}[groups][$this->_groupId][$itemid]\" value=\"1\" $checked />{$append['itemname']}<input type=\"hidden\" name=\"{$name}[parents][$itemid]\" value=\"\" /><input type=\"hidden\" name=\"{$name}[itemname][$itemid]\" value=\"{$append['itemname']}\" /><br /></td>";
326 326
                 $cols++;
327 327
             }
328 328
             $ret .= '</tr></table>';
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 
331 331
         $ret .= '<table class="outer"><tr>';
332 332
         $cols = 1;
333
-        if (! empty($this->_optionTree[0]['children'])) {
333
+        if (!empty($this->_optionTree[0]['children'])) {
334 334
             foreach ($this->_optionTree[0]['children'] as $topitem) {
335 335
                 if ($cols > 4) {
336 336
                     $ret .= '</tr><tr>';
@@ -358,8 +358,8 @@  discard block
 block discarded – undo
358 358
      */
359 359
     public function _renderOptionTree(&$tree, $option, $prefix, $parentIds = array())
360 360
     {
361
-        $tree .= $prefix."<input type=\"checkbox\" name=\"".$this->getName() . '[groups][' . $this->_groupId . '][' . $option['id'] . "]\" id=\"" . $this->getName() . '[groups][' . $this->_groupId . ']['
362
-                 . $option['id'] . "]\" onclick=\"";
361
+        $tree .= $prefix."<input type=\"checkbox\" name=\"".$this->getName().'[groups]['.$this->_groupId.']['.$option['id']."]\" id=\"".$this->getName().'[groups]['.$this->_groupId.']['
362
+                 . $option['id']."]\" onclick=\"";
363 363
         // If there are parent elements, add javascript that will
364 364
         // make them selecteded when this element is checked to make
365 365
         // sure permissions to parent items are added as well.
@@ -379,8 +379,8 @@  discard block
 block discarded – undo
379 379
         if (isset($this->_value) && in_array($option['id'], $this->_value)) {
380 380
             $tree .= ' checked="checked"';
381 381
         }
382
-        $tree .= ' />' . $option['name'] . "<input type=\"hidden\" name=\"" . $this->getName() . '[parents][' . $option['id'] . "]\" value=\"" . implode(':', $parentIds) . "\" /><input type=\"hidden\" name=\"" . $this->getName() . '[itemname]['
383
-                 . $option['id'] . "]\" value=\"" . htmlspecialchars($option['name']) . "\" /><br />\n";
382
+        $tree .= ' />'.$option['name']."<input type=\"hidden\" name=\"".$this->getName().'[parents]['.$option['id']."]\" value=\"".implode(':', $parentIds)."\" /><input type=\"hidden\" name=\"".$this->getName().'[itemname]['
383
+                 . $option['id']."]\" value=\"".htmlspecialchars($option['name'])."\" /><br />\n";
384 384
         if (isset($option['children'])) {
385 385
             foreach ($option['children'] as $child) {
386 386
                 array_push($parentIds, $option['id']);
Please login to merge, or discard this patch.