Passed
Push — 1.10.x ( 04397c...5e25f1 )
by Angel Fernando Quiroz
181:14 queued 130:00
created
main/inc/lib/blog.lib.php 1 patch
Indentation   +1845 added lines, -1846 removed lines patch added patch discarded remove patch
@@ -6,115 +6,114 @@  discard block
 block discarded – undo
6 6
  *
7 7
  * Contains several functions dealing with displaying,
8 8
  * editing,... of a blog
9
-
10 9
  * @package chamilo.blogs
11 10
  * @author Toon Keppens <[email protected]>
12 11
  * @author Julio Montoya - Cleaning code
13 12
  */
14 13
 class Blog
15 14
 {
16
-	/**
17
-	 * Get the title of a blog
18
-	 * @author Toon Keppens
19
-	 *
20
-	 * @param int $blog_id
21
-	 *
22
-	 * @return String Blog Title
23
-	 */
24
-	public static function get_blog_title ($blog_id)
25
-	{
26
-	    $course_id = api_get_course_int_id();
27
-
28
-		if (is_numeric($blog_id)) {
29
-			// init
30
-			$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
31
-
32
-			$sql = "SELECT blog_name
15
+    /**
16
+     * Get the title of a blog
17
+     * @author Toon Keppens
18
+     *
19
+     * @param int $blog_id
20
+     *
21
+     * @return String Blog Title
22
+     */
23
+    public static function get_blog_title ($blog_id)
24
+    {
25
+        $course_id = api_get_course_int_id();
26
+
27
+        if (is_numeric($blog_id)) {
28
+            // init
29
+            $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
30
+
31
+            $sql = "SELECT blog_name
33 32
 					FROM " . $tbl_blogs . "
34 33
 					WHERE c_id = $course_id AND blog_id = " . intval($blog_id);
35 34
 
36
-			$result = Database::query($sql);
37
-			$blog = Database::fetch_array($result);
38
-			return stripslashes($blog['blog_name']);
39
-		}
40
-	}
41
-
42
-
43
-	/**
44
-	 * Get the description of a blog
45
-	 * @author Toon Keppens
46
-	 *
47
-	 * @param Integer $blog_id
48
-	 *
49
-	 * @return String Blog description
50
-	 */
51
-	public static function get_blog_subtitle($blog_id)
52
-	{
53
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
54
-	  	$course_id = api_get_course_int_id();
55
-		$sql = "SELECT blog_subtitle FROM $tbl_blogs
35
+            $result = Database::query($sql);
36
+            $blog = Database::fetch_array($result);
37
+            return stripslashes($blog['blog_name']);
38
+        }
39
+    }
40
+
41
+
42
+    /**
43
+     * Get the description of a blog
44
+     * @author Toon Keppens
45
+     *
46
+     * @param Integer $blog_id
47
+     *
48
+     * @return String Blog description
49
+     */
50
+    public static function get_blog_subtitle($blog_id)
51
+    {
52
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
53
+            $course_id = api_get_course_int_id();
54
+        $sql = "SELECT blog_subtitle FROM $tbl_blogs
56 55
 				WHERE c_id = $course_id AND blog_id ='".intval($blog_id)."'";
57
-		$result = Database::query($sql);
58
-		$blog = Database::fetch_array($result);
59
-
60
-		return stripslashes($blog['blog_subtitle']);
61
-	}
62
-
63
-	/**
64
-	 * Get the users of a blog
65
-	 * @author Toon Keppens
66
-	 *
67
-	 * @param Integer $blog_id
68
-	 *
69
-	 * @return Array Returns an array with [userid]=>[username]
70
-	 */
71
-	public static function get_blog_users($blog_id)
72
-	{
73
-		// Database table definitions
74
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
75
-		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
76
-
77
-		$course_id = api_get_course_int_id();
78
-
79
-		// Get blog members
80
-		$sql = "SELECT user.user_id, user.firstname, user.lastname
56
+        $result = Database::query($sql);
57
+        $blog = Database::fetch_array($result);
58
+
59
+        return stripslashes($blog['blog_subtitle']);
60
+    }
61
+
62
+    /**
63
+     * Get the users of a blog
64
+     * @author Toon Keppens
65
+     *
66
+     * @param Integer $blog_id
67
+     *
68
+     * @return Array Returns an array with [userid]=>[username]
69
+     */
70
+    public static function get_blog_users($blog_id)
71
+    {
72
+        // Database table definitions
73
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
74
+        $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
75
+
76
+        $course_id = api_get_course_int_id();
77
+
78
+        // Get blog members
79
+        $sql = "SELECT user.user_id, user.firstname, user.lastname
81 80
 				FROM " . $tbl_blogs_rel_user . " blogs_rel_user
82 81
 				INNER JOIN " . $tbl_users . " user
83 82
 				ON blogs_rel_user.user_id = user.user_id
84 83
 				WHERE
85 84
 				    blogs_rel_user.c_id = $course_id AND
86 85
 					blogs_rel_user.blog_id = '" . (int)$blog_id."'";
87
-		$result = Database::query($sql);
88
-		$blog_members = array ();
89
-		while($user = Database::fetch_array($result)) {
90
-			$blog_members[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
91
-		}
92
-
93
-		return $blog_members;
94
-	}
95
-
96
-	/**
97
-	 * Creates a new blog in the given course
98
-	 * @author Toon Keppens
99
-	 * @param Integer $course_id Id
100
-	 * @param String $title
101
-	 * @param Text $description
102
-	 */
103
-	public static function create_blog($title, $subtitle)
104
-	{
105
-		$_user = api_get_user_info();
86
+        $result = Database::query($sql);
87
+        $blog_members = array ();
88
+        while($user = Database::fetch_array($result)) {
89
+            $blog_members[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
90
+        }
91
+
92
+        return $blog_members;
93
+    }
94
+
95
+    /**
96
+     * Creates a new blog in the given course
97
+     * @author Toon Keppens
98
+     * @param Integer $course_id Id
99
+     * @param String $title
100
+     * @param Text $description
101
+     */
102
+    public static function create_blog($title, $subtitle)
103
+    {
104
+        $_user = api_get_user_info();
106 105
         $course_id = api_get_course_int_id();
107 106
 
108
-		$current_date=date('Y-m-d H:i:s',time());
109
-		$session_id = api_get_session_id();
110
-		// Tabel definitions
107
+        $current_date=date('Y-m-d H:i:s',time());
108
+        $session_id = api_get_session_id();
109
+        // Tabel definitions
111 110
         $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
112 111
         $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
113 112
         $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
114 113
         $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
115 114
 
116
-		//verified if exist blog
117
-		$sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.'
115
+        //verified if exist blog
116
+        $sql = 'SELECT COUNT(*) as count FROM '.$tbl_blogs.'
118 117
 			  	WHERE
119 118
 			  	    c_id = '.$course_id.' AND
120 119
 			  	    blog_name="'.Database::escape_string($title).'" AND
@@ -123,9 +122,9 @@  discard block
 block discarded – undo
123 122
         $info_count = Database::result($res, 0, 0);
124 123
 
125 124
         if ($info_count == 0) {
126
-			// Create the blog
125
+            // Create the blog
127 126
             $params = [
128
-				'blog_id' => 0,
127
+                'blog_id' => 0,
129 128
                 'c_id' => $course_id,
130 129
                 'blog_name' => $title,
131 130
                 'blog_subtitle' =>  $subtitle,
@@ -133,14 +132,14 @@  discard block
 block discarded – undo
133 132
                 'visibility' => 1 ,
134 133
                 'session_id' => $session_id,
135 134
             ];
136
-			$this_blog_id = Database::insert($tbl_blogs, $params);
135
+            $this_blog_id = Database::insert($tbl_blogs, $params);
137 136
 
138
-			if ($this_blog_id > 0) {
137
+            if ($this_blog_id > 0) {
139 138
 
140 139
                 $sql = "UPDATE $tbl_blogs SET blog_id = iid WHERE iid = $this_blog_id";
141 140
                 Database::query($sql);
142 141
 
143
-				// insert into item_property
142
+                // insert into item_property
144 143
                 api_item_property_update(
145 144
                     api_get_course_info(),
146 145
                     TOOL_BLOGS,
@@ -148,12 +147,12 @@  discard block
 block discarded – undo
148 147
                     'BlogAdded',
149 148
                     api_get_user_id()
150 149
                 );
151
-			}
150
+            }
152 151
 
153
-			// Make first post. :)
152
+            // Make first post. :)
154 153
 
155 154
             $params = [
156
-				'post_id' => 0,
155
+                'post_id' => 0,
157 156
                 'c_id' => $course_id,
158 157
                 'title' => get_lang("Welcome"),
159 158
                 'full_text' => get_lang('FirstPostText'),
@@ -167,10 +166,10 @@  discard block
 block discarded – undo
167 166
                 Database::query($sql);
168 167
             }
169 168
 
170
-			// Put it on course homepage
171
-			$sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id)
169
+            // Put it on course homepage
170
+            $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, session_id)
172 171
 					VALUES ($course_id, '".Database::escape_string($title)."','blog/blog.php?blog_id=".(int)$this_blog_id."','blog.gif','1','0','pastillegris.gif',0,'$session_id')";
173
-			Database::query($sql);
172
+            Database::query($sql);
174 173
 
175 174
             $toolId = Database::insert_id();
176 175
             if ($toolId) {
@@ -178,37 +177,37 @@  discard block
 block discarded – undo
178 177
                 Database::query($sql);
179 178
             }
180 179
 
181
-			// Subscribe the teacher to this blog
182
-			Blog::set_user_subscribed($this_blog_id, $_user['user_id']);
183
-		}
184
-	}
185
-
186
-	/**
187
-	 * Update title and subtitle of a blog in the given course
188
-	 * @author Toon Keppens
189
-	 * @param Integer $course_id Id
190
-	 * @param String $title
191
-	 * @param Text $description
192
-	 */
193
-	public static function edit_blog($blog_id, $title, $subtitle)
194
-	{
195
-		// Table definitions
196
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
197
-		$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
180
+            // Subscribe the teacher to this blog
181
+            Blog::set_user_subscribed($this_blog_id, $_user['user_id']);
182
+        }
183
+    }
184
+
185
+    /**
186
+     * Update title and subtitle of a blog in the given course
187
+     * @author Toon Keppens
188
+     * @param Integer $course_id Id
189
+     * @param String $title
190
+     * @param Text $description
191
+     */
192
+    public static function edit_blog($blog_id, $title, $subtitle)
193
+    {
194
+        // Table definitions
195
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
196
+        $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
198 197
 
199 198
         $course_id = api_get_course_int_id();
200 199
 
201
-		// Update the blog
202
-		$sql = "UPDATE $tbl_blogs SET
200
+        // Update the blog
201
+        $sql = "UPDATE $tbl_blogs SET
203 202
 		        blog_name = '".Database::escape_string($title)."',
204 203
 		        blog_subtitle = '".Database::escape_string($subtitle)."'
205 204
 		        WHERE
206 205
 		            c_id = $course_id AND
207 206
 		            blog_id ='".Database::escape_string((int)$blog_id)."'
208 207
                 LIMIT 1";
209
-		Database::query($sql);
208
+        Database::query($sql);
210 209
 
211
-		//update item_property (update)
210
+        //update item_property (update)
212 211
         api_item_property_update(
213 212
             api_get_course_info(),
214 213
             TOOL_BLOGS,
@@ -217,60 +216,60 @@  discard block
 block discarded – undo
217 216
             api_get_user_id()
218 217
         );
219 218
 
220
-		// Update course homepage link
221
-		$sql = "UPDATE $tbl_tool SET
219
+        // Update course homepage link
220
+        $sql = "UPDATE $tbl_tool SET
222 221
 		        name = '".Database::escape_string($title)."'
223 222
 		        WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".(int)$blog_id."' LIMIT 1";
224
-		Database::query($sql);
225
-	}
226
-
227
-	/**
228
-	 * Deletes a blog and it's posts from the course database
229
-	 * @author Toon Keppens
230
-	 * @param Integer $blog_id
231
-	 */
232
-	public static function delete_blog($blog_id)
233
-	{
234
-		// Init
223
+        Database::query($sql);
224
+    }
225
+
226
+    /**
227
+     * Deletes a blog and it's posts from the course database
228
+     * @author Toon Keppens
229
+     * @param Integer $blog_id
230
+     */
231
+    public static function delete_blog($blog_id)
232
+    {
233
+        // Init
235 234
         $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
236 235
         $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
237 236
         $tbl_blogs_comment = Database::get_course_table(TABLE_BLOGS_COMMENTS);
238 237
         $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
239 238
         $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
240 239
         $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
241
-		$tbl_blogs_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
240
+        $tbl_blogs_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
242 241
 
243 242
         $course_id = api_get_course_int_id();
244 243
         $blog_id = intval($blog_id);
245 244
 
246
-		// Delete posts from DB and the attachments
247
-		delete_all_blog_attachment($blog_id);
245
+        // Delete posts from DB and the attachments
246
+        delete_all_blog_attachment($blog_id);
248 247
 
249
-		//Delete comments
250
-		$sql = "DELETE FROM $tbl_blogs_comment WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
251
-   		Database::query($sql);
248
+        //Delete comments
249
+        $sql = "DELETE FROM $tbl_blogs_comment WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
250
+            Database::query($sql);
252 251
 
253
-		// Delete posts
254
-   		$sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
255
-   		Database::query($sql);
252
+        // Delete posts
253
+            $sql = "DELETE FROM $tbl_blogs_posts WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
254
+            Database::query($sql);
256 255
 
257
-		// Delete tasks
258
-		$sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
259
-		Database::query($sql);
256
+        // Delete tasks
257
+        $sql = "DELETE FROM $tbl_blogs_tasks WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
258
+        Database::query($sql);
260 259
 
261
-		// Delete ratings
262
-		$sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
263
-		Database::query($sql);
260
+        // Delete ratings
261
+        $sql = "DELETE FROM $tbl_blogs_rating WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
262
+        Database::query($sql);
264 263
 
265
-		// Delete blog
266
-		$sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
267
-		Database::query($sql);
264
+        // Delete blog
265
+        $sql ="DELETE FROM $tbl_blogs WHERE c_id = $course_id AND blog_id ='".$blog_id."'";
266
+        Database::query($sql);
268 267
 
269
-		// Delete from course homepage
270
-		$sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".$blog_id."'";
271
-		Database::query($sql);
268
+        // Delete from course homepage
269
+        $sql = "DELETE FROM $tbl_tool WHERE c_id = $course_id AND link = 'blog/blog.php?blog_id=".$blog_id."'";
270
+        Database::query($sql);
272 271
 
273
-		//update item_property (delete)
272
+        //update item_property (delete)
274 273
         api_item_property_update(
275 274
             api_get_course_info(),
276 275
             TOOL_BLOGS,
@@ -278,152 +277,152 @@  discard block
 block discarded – undo
278 277
             'delete',
279 278
             api_get_user_id()
280 279
         );
281
-	}
282
-
283
-	/**
284
-	 * Creates a new post in a given blog
285
-	 * @author Toon Keppens
286
-	 * @param String $title
287
-	 * @param String $full_text
288
-	 * @param Integer $blog_id
289
-	 */
290
-	public static function create_post($title, $full_text, $file_comment, $blog_id)
291
-	{
292
-		$_user = api_get_user_info();
293
-		$_course = api_get_course_info();
294
-		$course_id = $_course['real_id'];
295
-
296
-		$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
297
-		$upload_ok=true;
298
-		$has_attachment=false;
299
-		$current_date = api_get_utc_datetime();
300
-
301
-		if (!empty($_FILES['user_upload']['name'])) {
302
-			$upload_ok = process_uploaded_file($_FILES['user_upload']);
303
-			$has_attachment=true;
304
-		}
305
-
306
-		if ($upload_ok) {
307
-			// Table Definitions
308
-			$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
309
-
310
-			// Create the post
311
-			$sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id )
280
+    }
281
+
282
+    /**
283
+     * Creates a new post in a given blog
284
+     * @author Toon Keppens
285
+     * @param String $title
286
+     * @param String $full_text
287
+     * @param Integer $blog_id
288
+     */
289
+    public static function create_post($title, $full_text, $file_comment, $blog_id)
290
+    {
291
+        $_user = api_get_user_info();
292
+        $_course = api_get_course_info();
293
+        $course_id = $_course['real_id'];
294
+
295
+        $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
296
+        $upload_ok=true;
297
+        $has_attachment=false;
298
+        $current_date = api_get_utc_datetime();
299
+
300
+        if (!empty($_FILES['user_upload']['name'])) {
301
+            $upload_ok = process_uploaded_file($_FILES['user_upload']);
302
+            $has_attachment=true;
303
+        }
304
+
305
+        if ($upload_ok) {
306
+            // Table Definitions
307
+            $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
308
+
309
+            // Create the post
310
+            $sql = "INSERT INTO $tbl_blogs_posts (c_id, title, full_text, date_creation, blog_id, author_id )
312 311
 					VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."','".$current_date."', '".(int)$blog_id."', '".(int)$_user['user_id']."');";
313 312
 
314
-			Database::query($sql);
315
-			$last_post_id = Database::insert_id();
313
+            Database::query($sql);
314
+            $last_post_id = Database::insert_id();
316 315
 
317 316
             if ($last_post_id) {
318 317
                 $sql = "UPDATE $tbl_blogs_posts SET post_id = iid WHERE iid = $last_post_id";
319 318
                 Database::query($sql);
320 319
             }
321 320
 
322
-			if ($has_attachment) {
323
-				$courseDir   = $_course['path'].'/upload/blog';
324
-				$sys_course_path = api_get_path(SYS_COURSE_PATH);
325
-				$updir = $sys_course_path.$courseDir;
326
-
327
-				// Try to add an extension to the file if it hasn't one
328
-				$new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']);
329
-
330
-				// user's file name
331
-				$file_name = $_FILES['user_upload']['name'];
332
-
333
-				if (!filter_extension($new_file_name)) {
334
-					Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
335
-				} else {
336
-					$new_file_name = uniqid('');
337
-					$new_path = $updir.'/'.$new_file_name;
338
-					$result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
339
-					$comment = Database::escape_string($file_comment);
340
-
341
-					// Storing the attachments if any
342
-					if ($result) {
343
-						$sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '.
344
-							   "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."',  '".$blog_id."', '0' )";
345
-						Database::query($sql);
321
+            if ($has_attachment) {
322
+                $courseDir   = $_course['path'].'/upload/blog';
323
+                $sys_course_path = api_get_path(SYS_COURSE_PATH);
324
+                $updir = $sys_course_path.$courseDir;
325
+
326
+                // Try to add an extension to the file if it hasn't one
327
+                $new_file_name = add_ext_on_mime(stripslashes($_FILES['user_upload']['name']), $_FILES['user_upload']['type']);
328
+
329
+                // user's file name
330
+                $file_name = $_FILES['user_upload']['name'];
331
+
332
+                if (!filter_extension($new_file_name)) {
333
+                    Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
334
+                } else {
335
+                    $new_file_name = uniqid('');
336
+                    $new_path = $updir.'/'.$new_file_name;
337
+                    $result = @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
338
+                    $comment = Database::escape_string($file_comment);
339
+
340
+                    // Storing the attachments if any
341
+                    if ($result) {
342
+                        $sql = 'INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size, blog_id,comment_id) '.
343
+                                "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$last_post_id."', '".intval($_FILES['user_upload']['size'])."',  '".$blog_id."', '0' )";
344
+                        Database::query($sql);
346 345
                         $id = Database::insert_id();
347 346
                         if ($id) {
348 347
                             $sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id";
349 348
                             Database::query($sql);
350 349
                         }
351
-					}
352
-				}
353
-			}
354
-		} else {
355
-			Display::display_error_message(get_lang('UplNoFileUploaded'));
356
-		}
357
-	}
358
-
359
-	/**
360
-	 * Edits a post in a given blog
361
-	 * @author Toon Keppens
362
-	 * @param Integer $blog_id
363
-	 * @param String $title
364
-	 * @param String $full_text
365
-	 * @param Integer $blog_id
366
-	 */
367
-	public static function edit_post($post_id, $title, $full_text, $blog_id)
368
-	{
369
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
350
+                    }
351
+                }
352
+            }
353
+        } else {
354
+            Display::display_error_message(get_lang('UplNoFileUploaded'));
355
+        }
356
+    }
357
+
358
+    /**
359
+     * Edits a post in a given blog
360
+     * @author Toon Keppens
361
+     * @param Integer $blog_id
362
+     * @param String $title
363
+     * @param String $full_text
364
+     * @param Integer $blog_id
365
+     */
366
+    public static function edit_post($post_id, $title, $full_text, $blog_id)
367
+    {
368
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
370 369
         $course_id = api_get_course_int_id();
371 370
 
372
-		// Create the post
373
-		$sql = "UPDATE $tbl_blogs_posts SET
371
+        // Create the post
372
+        $sql = "UPDATE $tbl_blogs_posts SET
374 373
 		        title = '" . Database::escape_string($title)."',
375 374
 		        full_text = '" . Database::escape_string($full_text)."'
376 375
 		        WHERE c_id = $course_id AND post_id ='".(int)$post_id."' AND blog_id ='".(int)$blog_id."'
377 376
 		        LIMIT 1 ";
378
-		Database::query($sql);
379
-	}
380
-
381
-	/**
382
-	 * Deletes an article and it's comments
383
-	 * @author Toon Keppens
384
-	 * @param int $blog_id
385
-	 * @param int $post_id
386
-	 */
387
-	public static function delete_post($blog_id, $post_id)
388
-	{
389
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
390
-		$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
391
-		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
377
+        Database::query($sql);
378
+    }
379
+
380
+    /**
381
+     * Deletes an article and it's comments
382
+     * @author Toon Keppens
383
+     * @param int $blog_id
384
+     * @param int $post_id
385
+     */
386
+    public static function delete_post($blog_id, $post_id)
387
+    {
388
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
389
+        $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
390
+        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
392 391
 
393 392
         $course_id = api_get_course_int_id();
394 393
 
395
-		// Delete ratings on this comment
396
-		$sql = "DELETE FROM $tbl_blogs_rating
394
+        // Delete ratings on this comment
395
+        $sql = "DELETE FROM $tbl_blogs_rating
397 396
 				WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND item_id = '".(int)$post_id."' AND rating_type = 'post'";
398
-		Database::query($sql);
397
+        Database::query($sql);
399 398
 
400
-		// Delete the post
401
-		$sql = "DELETE FROM $tbl_blogs_posts
399
+        // Delete the post
400
+        $sql = "DELETE FROM $tbl_blogs_posts
402 401
 				WHERE c_id = $course_id AND post_id = '".(int)$post_id."'";
403
-		Database::query($sql);
402
+        Database::query($sql);
404 403
 
405
-		// Delete the comments
406
-		$sql = "DELETE FROM $tbl_blogs_comments
404
+        // Delete the comments
405
+        $sql = "DELETE FROM $tbl_blogs_comments
407 406
 				WHERE c_id = $course_id AND post_id = '".(int)$post_id."' AND blog_id = '".(int)$blog_id."'";
408
-		Database::query($sql);
409
-
410
-		// Delete posts and attachments
411
-		delete_all_blog_attachment($blog_id,$post_id);
412
-	}
413
-
414
-	/**
415
-	 * Creates a comment on a post in a given blog
416
-	 * @author Toon Keppens
417
-	 * @param String $title
418
-	 * @param String $full_text
419
-	 * @param Integer $blog_id
420
-	 * @param Integer $post_id
421
-	 * @param Integer $parent_id
422
-	 */
423
-	public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL')
424
-	{
425
-		$_user = api_get_user_info();
426
-		$_course = api_get_course_info();
407
+        Database::query($sql);
408
+
409
+        // Delete posts and attachments
410
+        delete_all_blog_attachment($blog_id,$post_id);
411
+    }
412
+
413
+    /**
414
+     * Creates a comment on a post in a given blog
415
+     * @author Toon Keppens
416
+     * @param String $title
417
+     * @param String $full_text
418
+     * @param Integer $blog_id
419
+     * @param Integer $post_id
420
+     * @param Integer $parent_id
421
+     */
422
+    public static function create_comment($title, $full_text, $file_comment, $blog_id, $post_id, $parent_id, $task_id = 'NULL')
423
+    {
424
+        $_user = api_get_user_info();
425
+        $_course = api_get_course_info();
427 426
         $blog_table_attachment 	= Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
428 427
 
429 428
         $upload_ok = true;
@@ -431,55 +430,55 @@  discard block
 block discarded – undo
431 430
         $current_date = api_get_utc_datetime();
432 431
         $course_id = api_get_course_int_id();
433 432
 
434
-		if (!empty($_FILES['user_upload']['name'])) {
435
-			$upload_ok = process_uploaded_file($_FILES['user_upload']);
436
-			$has_attachment=true;
437
-		}
433
+        if (!empty($_FILES['user_upload']['name'])) {
434
+            $upload_ok = process_uploaded_file($_FILES['user_upload']);
435
+            $has_attachment=true;
436
+        }
438 437
 
439
-		if ($upload_ok) {
440
-			// Table Definition
441
-			$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
438
+        if ($upload_ok) {
439
+            // Table Definition
440
+            $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
442 441
 
443
-			// Create the comment
444
-			$sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id )
442
+            // Create the comment
443
+            $sql = "INSERT INTO $tbl_blogs_comments (c_id, title, comment, author_id, date_creation, blog_id, post_id, parent_comment_id, task_id )
445 444
 					VALUES ($course_id, '".Database::escape_string($title)."', '".Database::escape_string($full_text)."', '".(int)$_user['user_id']."','".$current_date."', '".(int)$blog_id."', '".(int)$post_id."', '".(int)$parent_id."', '".(int)$task_id."')";
446
-			Database::query($sql);
445
+            Database::query($sql);
447 446
 
448
-			// Empty post values, or they are shown on the page again
449
-			$last_id = Database::insert_id();
447
+            // Empty post values, or they are shown on the page again
448
+            $last_id = Database::insert_id();
450 449
 
451 450
             if ($last_id) {
452 451
                 $sql = "UPDATE $tbl_blogs_comments SET comment_id = iid WHERE iid = $last_id";
453 452
                 Database::query($sql);
454 453
             }
455 454
 
456
-			if ($has_attachment) {
457
-				$courseDir   = $_course['path'].'/upload/blog';
458
-				$sys_course_path = api_get_path(SYS_COURSE_PATH);
459
-				$updir = $sys_course_path.$courseDir;
460
-
461
-				// Try to add an extension to the file if it hasn't one
462
-				$new_file_name = add_ext_on_mime(
463
-					stripslashes($_FILES['user_upload']['name']),
464
-					$_FILES['user_upload']['type']
465
-				);
466
-
467
-				// user's file name
468
-				$file_name =$_FILES['user_upload']['name'];
469
-
470
-				if (!filter_extension($new_file_name)) {
471
-					Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
472
-				} else {
473
-					$new_file_name = uniqid('');
474
-					$new_path=$updir.'/'.$new_file_name;
475
-					$result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
476
-					$comment = Database::escape_string($file_comment);
477
-
478
-					// Storing the attachments if any
479
-					if ($result) {
480
-						$sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '.
481
-							 "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."',  '".$blog_id."', '".$last_id."'  )";
482
-						Database::query($sql);
455
+            if ($has_attachment) {
456
+                $courseDir   = $_course['path'].'/upload/blog';
457
+                $sys_course_path = api_get_path(SYS_COURSE_PATH);
458
+                $updir = $sys_course_path.$courseDir;
459
+
460
+                // Try to add an extension to the file if it hasn't one
461
+                $new_file_name = add_ext_on_mime(
462
+                    stripslashes($_FILES['user_upload']['name']),
463
+                    $_FILES['user_upload']['type']
464
+                );
465
+
466
+                // user's file name
467
+                $file_name =$_FILES['user_upload']['name'];
468
+
469
+                if (!filter_extension($new_file_name)) {
470
+                    Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
471
+                } else {
472
+                    $new_file_name = uniqid('');
473
+                    $new_path=$updir.'/'.$new_file_name;
474
+                    $result= @move_uploaded_file($_FILES['user_upload']['tmp_name'], $new_path);
475
+                    $comment = Database::escape_string($file_comment);
476
+
477
+                    // Storing the attachments if any
478
+                    if ($result) {
479
+                        $sql='INSERT INTO '.$blog_table_attachment.'(c_id, filename,comment, path, post_id,size,blog_id,comment_id) '.
480
+                                "VALUES ($course_id, '".Database::escape_string($file_name)."', '".$comment."', '".Database::escape_string($new_file_name)."' , '".$post_id."', '".$_FILES['user_upload']['size']."',  '".$blog_id."', '".$last_id."'  )";
481
+                        Database::query($sql);
483 482
 
484 483
                         $id = Database::insert_id();
485 484
 
@@ -487,92 +486,92 @@  discard block
 block discarded – undo
487 486
                             $sql = "UPDATE $blog_table_attachment SET id = iid WHERE iid = $id";
488 487
                             Database::query($sql);
489 488
                         }
490
-					}
491
-				}
492
-			}
493
-		}
494
-	}
495
-
496
-	/**
497
-	 * Deletes a comment from a blogpost
498
-	 * @author Toon Keppens
499
-	 * @param int $blog_id
500
-	 * @param int $comment_id
501
-	 */
502
-	public static function delete_comment($blog_id, $post_id, $comment_id)
503
-	{
504
-		$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
505
-		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
506
-		$blog_id = intval($blog_id);
507
-		$post_id = intval($post_id);
508
-		$comment_id = intval($comment_id);
489
+                    }
490
+                }
491
+            }
492
+        }
493
+    }
494
+
495
+    /**
496
+     * Deletes a comment from a blogpost
497
+     * @author Toon Keppens
498
+     * @param int $blog_id
499
+     * @param int $comment_id
500
+     */
501
+    public static function delete_comment($blog_id, $post_id, $comment_id)
502
+    {
503
+        $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
504
+        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
505
+        $blog_id = intval($blog_id);
506
+        $post_id = intval($post_id);
507
+        $comment_id = intval($comment_id);
509 508
         $course_id = api_get_course_int_id();
510 509
 
511
-		delete_all_blog_attachment($blog_id, $post_id, $comment_id);
510
+        delete_all_blog_attachment($blog_id, $post_id, $comment_id);
512 511
 
513
-		// Delete ratings on this comment
514
-		$sql = "DELETE FROM $tbl_blogs_rating
512
+        // Delete ratings on this comment
513
+        $sql = "DELETE FROM $tbl_blogs_rating
515 514
 				WHERE
516 515
 				    c_id = $course_id AND
517 516
 				    blog_id = '".$blog_id."' AND
518 517
 				    item_id = '".$comment_id."' AND
519 518
 				    rating_type = 'comment'";
520
-		Database::query($sql);
519
+        Database::query($sql);
521 520
 
522
-		// select comments that have the selected comment as their parent
523
-		$sql = "SELECT comment_id FROM $tbl_blogs_comments
521
+        // select comments that have the selected comment as their parent
522
+        $sql = "SELECT comment_id FROM $tbl_blogs_comments
524 523
 				WHERE c_id = $course_id AND parent_comment_id = '".$comment_id."'";
525
-		$result = Database::query($sql);
524
+        $result = Database::query($sql);
526 525
 
527
-		// Delete them recursively
528
-		while ($comment = Database::fetch_array($result)) {
529
-			Blog::delete_comment($blog_id,$post_id,$comment['comment_id']);
530
-		}
526
+        // Delete them recursively
527
+        while ($comment = Database::fetch_array($result)) {
528
+            Blog::delete_comment($blog_id,$post_id,$comment['comment_id']);
529
+        }
531 530
 
532
-		// Finally, delete the selected comment to
533
-		$sql = "DELETE FROM $tbl_blogs_comments
531
+        // Finally, delete the selected comment to
532
+        $sql = "DELETE FROM $tbl_blogs_comments
534 533
 				WHERE c_id = $course_id AND comment_id = '".$comment_id."'";
535
-		Database::query($sql);
536
-	}
537
-
538
-	/**
539
-	 * Creates a new task in a blog
540
-	 * @author Toon Keppens
541
-	 * @param Integer $blog_id
542
-	 * @param String $title
543
-	 * @param String $description
544
-	 * @param String $color
545
-	 */
546
-	public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color)
547
-	{
548
-		// Init
549
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
550
-		$tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
551
-
552
-		$course_id = api_get_course_int_id();
553
-
554
-		// Create the task
555
-		$sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task)
534
+        Database::query($sql);
535
+    }
536
+
537
+    /**
538
+     * Creates a new task in a blog
539
+     * @author Toon Keppens
540
+     * @param Integer $blog_id
541
+     * @param String $title
542
+     * @param String $description
543
+     * @param String $color
544
+     */
545
+    public static function create_task($blog_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color)
546
+    {
547
+        // Init
548
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
549
+        $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
550
+
551
+        $course_id = api_get_course_int_id();
552
+
553
+        // Create the task
554
+        $sql = "INSERT INTO $tbl_blogs_tasks (c_id, blog_id, title, description, color, system_task)
556 555
 				VALUES ($course_id , '".(int)$blog_id."', '" . Database::escape_string($title)."', '" . Database::escape_string($description)."', '" . Database::escape_string($color)."', '0');";
557
-		Database::query($sql);
556
+        Database::query($sql);
558 557
 
559
-		$task_id = Database::insert_id();
558
+        $task_id = Database::insert_id();
560 559
 
561 560
         if ($task_id) {
562 561
             $sql = "UPDATE $tbl_blogs_tasks SET task_id = iid WHERE iid = $task_id";
563 562
             Database::query($sql);
564 563
         }
565 564
 
566
-		$tool = 'BLOG_' . $blog_id;
565
+        $tool = 'BLOG_' . $blog_id;
567 566
 
568
-		if ($articleDelete == 'on') {
569
-			$sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id,  task_id, tool, action) VALUES (
567
+        if ($articleDelete == 'on') {
568
+            $sql = " INSERT INTO " . $tbl_tasks_permissions . " ( c_id,  task_id, tool, action) VALUES (
570 569
 					'" . (int)$course_id . "',
571 570
 					'" . (int)$task_id . "',
572 571
 					'" . Database::escape_string($tool) . "',
573 572
 					'article_delete'
574 573
 				)";
575
-			Database::query($sql);
574
+            Database::query($sql);
576 575
 
577 576
             $id = Database::insert_id();
578 577
 
@@ -582,172 +581,172 @@  discard block
 block discarded – undo
582 581
             }
583 582
         }
584 583
 
585
-		if ($articleEdit == 'on') {
586
-			$sql = "
584
+        if ($articleEdit == 'on') {
585
+            $sql = "
587 586
 				INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES (
588 587
 					'" . (int)$course_id . "',
589 588
 					'" . (int)$task_id . "',
590 589
 					'" . Database::escape_string($tool) . "',
591 590
 					'article_edit'
592 591
 				)";
593
-			Database::query($sql);
592
+            Database::query($sql);
594 593
             $id = Database::insert_id();
595 594
 
596 595
             if ($id) {
597 596
                 $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id";
598 597
                 Database::query($sql);
599 598
             }
600
-		}
599
+        }
601 600
 
602
-		if ($commentsDelete == 'on') {
603
-			$sql = "
601
+        if ($commentsDelete == 'on') {
602
+            $sql = "
604 603
 				INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action ) VALUES (
605 604
 					'" . (int)$course_id . "',
606 605
 					'" . (int)$task_id . "',
607 606
 					'" . Database::escape_string($tool) . "',
608 607
 					'article_comments_delete'
609 608
 				)";
610
-			Database::query($sql);
609
+            Database::query($sql);
611 610
             $id = Database::insert_id();
612 611
 
613 612
             if ($id) {
614 613
                 $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id";
615 614
                 Database::query($sql);
616 615
             }
617
-		}
618
-	}
619
-
620
-	/**
621
-	 * Edit a task in a blog
622
-	 * @author Toon Keppens
623
-	 * @param Integer $task_id
624
-	 * @param String $title
625
-	 * @param String $description
626
-	 * @param String $color
627
-	 */
628
-	public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color)
629
-	{
630
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
631
-		$tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
616
+        }
617
+    }
618
+
619
+    /**
620
+     * Edit a task in a blog
621
+     * @author Toon Keppens
622
+     * @param Integer $task_id
623
+     * @param String $title
624
+     * @param String $description
625
+     * @param String $color
626
+     */
627
+    public static function edit_task($blog_id, $task_id, $title, $description, $articleDelete, $articleEdit, $commentsDelete, $color)
628
+    {
629
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
630
+        $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
632 631
 
633 632
         $course_id = api_get_course_int_id();
634 633
 
635
-		// Create the task
636
-		$sql = "UPDATE $tbl_blogs_tasks SET
634
+        // Create the task
635
+        $sql = "UPDATE $tbl_blogs_tasks SET
637 636
 					title = '".Database::escape_string($title)."',
638 637
 					description = '".Database::escape_string($description)."',
639 638
 					color = '".Database::escape_string($color)."'
640 639
 				WHERE c_id = $course_id AND task_id ='".(int)$task_id."' LIMIT 1";
641
-		Database::query($sql);
640
+        Database::query($sql);
642 641
 
643
-		$tool = 'BLOG_' . $blog_id;
642
+        $tool = 'BLOG_' . $blog_id;
644 643
 
645
-		$sql = "DELETE FROM " . $tbl_tasks_permissions . "
644
+        $sql = "DELETE FROM " . $tbl_tasks_permissions . "
646 645
 				WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'";
647
-		Database::query($sql);
646
+        Database::query($sql);
648 647
 
649
-		if ($articleDelete == 'on') {
650
-			$sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES (
648
+        if ($articleDelete == 'on') {
649
+            $sql = "INSERT INTO " . $tbl_tasks_permissions . " ( c_id, task_id, tool, action) VALUES (
651 650
 					'" . (int)$course_id . "',
652 651
 					'" . (int)$task_id . "',
653 652
 					'" . Database::escape_string($tool) . "',
654 653
 					'article_delete'
655 654
 				)";
656
-			Database::query($sql);
655
+            Database::query($sql);
657 656
             $id = Database::insert_id();
658 657
 
659 658
             if ($id) {
660 659
                 $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id";
661 660
                 Database::query($sql);
662 661
             }
663
-		}
662
+        }
664 663
 
665
-		if ($articleEdit == 'on') {
666
-			$sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES (
664
+        if ($articleEdit == 'on') {
665
+            $sql = "INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES (
667 666
 					'" . (int)$course_id . "',
668 667
 					'" . (int)$task_id . "',
669 668
 					'" . Database::escape_string($tool) . "',
670 669
 					'article_edit'
671 670
 				)";
672
-			Database::query($sql);
671
+            Database::query($sql);
673 672
             $id = Database::insert_id();
674 673
 
675 674
             if ($id) {
676 675
                 $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id";
677 676
                 Database::query($sql);
678 677
             }
679
-		}
678
+        }
680 679
 
681
-		if ($commentsDelete == 'on') {
682
-			$sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES (
680
+        if ($commentsDelete == 'on') {
681
+            $sql = " INSERT INTO " . $tbl_tasks_permissions . " (c_id, task_id, tool, action) VALUES (
683 682
 					'" . (int)$course_id . "',
684 683
 					'" . (int)$task_id . "',
685 684
 					'" . Database::escape_string($tool) . "',
686 685
 					'article_comments_delete'
687 686
 				)";
688
-			Database::query($sql);
687
+            Database::query($sql);
689 688
             $id = Database::insert_id();
690 689
 
691 690
             if ($id) {
692 691
                 $sql = "UPDATE $tbl_tasks_permissions SET id = iid WHERE iid = $id";
693 692
                 Database::query($sql);
694 693
             }
695
-		}
696
-	}
697
-
698
-	/**
699
-	 * Deletes a task from a blog
700
-	 * @param Integer $blog_id
701
-	 * @param Integer $task_id
702
-	 */
703
-	public static function delete_task($blog_id, $task_id)
704
-	{
705
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
706
-		$course_id = api_get_course_int_id();
707
-
708
-		// Delete posts
709
-		$sql = "DELETE FROM $tbl_blogs_tasks
694
+        }
695
+    }
696
+
697
+    /**
698
+     * Deletes a task from a blog
699
+     * @param Integer $blog_id
700
+     * @param Integer $task_id
701
+     */
702
+    public static function delete_task($blog_id, $task_id)
703
+    {
704
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
705
+        $course_id = api_get_course_int_id();
706
+
707
+        // Delete posts
708
+        $sql = "DELETE FROM $tbl_blogs_tasks
710 709
 				WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND task_id = '".(int)$task_id."'";
711
-		Database::query($sql);
712
-	}
713
-
714
-	/**
715
-	 * Deletes an assigned task from a blog
716
-	 * @param Integer $blog_id
717
-	 * @param Integer $assignment_id
718
-	 */
719
-	public static function delete_assigned_task($blog_id, $task_id, $user_id)
720
-	{
721
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
710
+        Database::query($sql);
711
+    }
712
+
713
+    /**
714
+     * Deletes an assigned task from a blog
715
+     * @param Integer $blog_id
716
+     * @param Integer $assignment_id
717
+     */
718
+    public static function delete_assigned_task($blog_id, $task_id, $user_id)
719
+    {
720
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
722 721
         $course_id = api_get_course_int_id();
723 722
 
724
-		// Delete posts
725
-		$sql = "DELETE FROM $tbl_blogs_tasks_rel_user
723
+        // Delete posts
724
+        $sql = "DELETE FROM $tbl_blogs_tasks_rel_user
726 725
 				WHERE
727 726
 				    c_id = $course_id AND
728 727
 				    blog_id = '".(int)$blog_id."' AND
729 728
 				    task_id = '".(int)$task_id."' AND
730 729
 				    user_id = '".(int)$user_id."'";
731
-		Database::query($sql);
732
-	}
733
-
734
-	/**
735
-	 * Get personal task list
736
-	 * @author Toon Keppens
737
-	 * @return Returns an unsorted list (<ul></ul>) with the users' tasks
738
-	 */
739
-	public static function get_personal_task_list()
740
-	{
741
-		$_user = api_get_user_info();
742
-
743
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
744
-		$tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
745
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
746
-
747
-		$course_id = api_get_course_int_id();
748
-
749
-		if ($_user['user_id']) {
750
-			$sql = "SELECT task_rel_user.*, task.title, blog.blog_name
730
+        Database::query($sql);
731
+    }
732
+
733
+    /**
734
+     * Get personal task list
735
+     * @author Toon Keppens
736
+     * @return Returns an unsorted list (<ul></ul>) with the users' tasks
737
+     */
738
+    public static function get_personal_task_list()
739
+    {
740
+        $_user = api_get_user_info();
741
+
742
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
743
+        $tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
744
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
745
+
746
+        $course_id = api_get_course_int_id();
747
+
748
+        if ($_user['user_id']) {
749
+            $sql = "SELECT task_rel_user.*, task.title, blog.blog_name
751 750
                     FROM $tbl_blogs_tasks_rel_user task_rel_user
752 751
                     INNER JOIN $tbl_blogs_tasks task
753 752
                     ON task_rel_user.task_id = task.task_id
@@ -761,85 +760,85 @@  discard block
 block discarded – undo
761 760
                         task_rel_user.user_id = ".(int)$_user['user_id']."
762 761
                     ORDER BY target_date ASC";
763 762
 
764
-			$result = Database::query($sql);
765
-
766
-			if (Database::num_rows($result) > 0) {
767
-				echo '<ul>';
768
-				while ($mytask = Database::fetch_array($result)) {
769
-					echo '<li><a href="blog.php?action=execute_task&blog_id=' . $mytask['blog_id'] . '&task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>';
770
-				}
771
-				echo '<ul>';
772
-			} else {
773
-				echo get_lang('NoTasks');
774
-			}
775
-		} else {
776
-			echo get_lang('NoTasks');
777
-		}
778
-	}
779
-
780
-	/**
781
-	 * Changes the visibility of a blog
782
-	 * @author Toon Keppens
783
-	 * @param Integer $blog_id
784
-	 */
785
-	public static function change_blog_visibility($blog_id)
786
-	{
787
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
788
-		$tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
789
-		$course_id = api_get_course_int_id();
790
-
791
-		// Get blog properties
792
-		$sql = "SELECT blog_name, visibility FROM $tbl_blogs
763
+            $result = Database::query($sql);
764
+
765
+            if (Database::num_rows($result) > 0) {
766
+                echo '<ul>';
767
+                while ($mytask = Database::fetch_array($result)) {
768
+                    echo '<li><a href="blog.php?action=execute_task&blog_id=' . $mytask['blog_id'] . '&task_id='.stripslashes($mytask['task_id']) . '" title="[Blog: '.stripslashes($mytask['blog_name']) . '] ' . get_lang('ExecuteThisTask') . '">'.stripslashes($mytask['title']) . '</a></li>';
769
+                }
770
+                echo '<ul>';
771
+            } else {
772
+                echo get_lang('NoTasks');
773
+            }
774
+        } else {
775
+            echo get_lang('NoTasks');
776
+        }
777
+    }
778
+
779
+    /**
780
+     * Changes the visibility of a blog
781
+     * @author Toon Keppens
782
+     * @param Integer $blog_id
783
+     */
784
+    public static function change_blog_visibility($blog_id)
785
+    {
786
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
787
+        $tbl_tool = Database::get_course_table(TABLE_TOOL_LIST);
788
+        $course_id = api_get_course_int_id();
789
+
790
+        // Get blog properties
791
+        $sql = "SELECT blog_name, visibility FROM $tbl_blogs
793 792
 				WHERE c_id = $course_id AND blog_id='".(int)$blog_id."'";
794
-		$result = Database::query($sql);
795
-		$blog = Database::fetch_array($result);
796
-		$visibility = $blog['visibility'];
797
-		$title = $blog['blog_name'];
798
-
799
-		if ($visibility == 1) {
800
-			// Change visibility state, remove from course home.
801
-			$sql = "UPDATE $tbl_blogs SET visibility = '0'
793
+        $result = Database::query($sql);
794
+        $blog = Database::fetch_array($result);
795
+        $visibility = $blog['visibility'];
796
+        $title = $blog['blog_name'];
797
+
798
+        if ($visibility == 1) {
799
+            // Change visibility state, remove from course home.
800
+            $sql = "UPDATE $tbl_blogs SET visibility = '0'
802 801
 					WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1";
803
-			Database::query($sql);
802
+            Database::query($sql);
804 803
 
805
-			$sql = "DELETE FROM $tbl_tool
804
+            $sql = "DELETE FROM $tbl_tool
806 805
 					WHERE c_id = $course_id AND name = '".Database::escape_string($title)."' LIMIT 1";
807
-			Database::query($sql);
808
-		} else {
809
-			// Change visibility state, add to course home.
810
-			$sql = "UPDATE $tbl_blogs SET visibility = '1'
806
+            Database::query($sql);
807
+        } else {
808
+            // Change visibility state, add to course home.
809
+            $sql = "UPDATE $tbl_blogs SET visibility = '1'
811 810
 					WHERE c_id = $course_id AND blog_id ='".(int)$blog_id."' LIMIT 1";
812
-			Database::query($sql);
811
+            Database::query($sql);
813 812
 
814
-			$sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target )
813
+            $sql = "INSERT INTO $tbl_tool (c_id, name, link, image, visibility, admin, address, added_tool, target )
815 814
 					VALUES ($course_id, '".Database::escape_string($title)."', 'blog/blog.php?blog_id=".(int)$blog_id."', 'blog.gif', '1', '0', 'pastillegris.gif', '0', '_self')";
816
-			Database::query($sql);
815
+            Database::query($sql);
817 816
             $id = Database::insert_id();
818 817
 
819 818
             if ($id) {
820 819
                 $sql = "UPDATE $tbl_tool SET id = iid WHERE iid = $id";
821 820
                 Database::query($sql);
822 821
             }
823
-		}
824
-	}
825
-
826
-	/**
827
-	 * Shows the posts of a blog
828
-	 * @author Toon Keppens
829
-	 *
830
-	 * @param Integer $blog_id
831
-	 */
832
-	public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20)
822
+        }
823
+    }
824
+
825
+    /**
826
+     * Shows the posts of a blog
827
+     * @author Toon Keppens
828
+     *
829
+     * @param Integer $blog_id
830
+     */
831
+    public static function display_blog_posts($blog_id, $filter = '1=1', $max_number_of_posts = 20)
833 832
     {
834
-		// Init
835
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
836
-		$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
837
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
833
+        // Init
834
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
835
+        $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
836
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
838 837
 
839
-		$course_id = api_get_course_int_id();
838
+        $course_id = api_get_course_int_id();
840 839
 
841
-		// Get posts and authors
842
-		$sql = "SELECT post.*, user.lastname, user.firstname, user.username
840
+        // Get posts and authors
841
+        $sql = "SELECT post.*, user.lastname, user.firstname, user.username
843 842
 		        FROM $tbl_blogs_posts post
844 843
                 INNER JOIN $tbl_users user
845 844
                 ON post.author_id = user.user_id
@@ -847,131 +846,131 @@  discard block
 block discarded – undo
847 846
 						post.c_id = $course_id AND
848 847
 						$filter
849 848
 				ORDER BY post_id DESC LIMIT 0,".(int)$max_number_of_posts;
850
-		$result = Database::query($sql);
851
-
852
-		// Display
853
-		if(Database::num_rows($result) > 0) {
854
-		    $limit = 200;
855
-			while ($blog_post = Database::fetch_array($result)) {
856
-				// Get number of comments
857
-				$sql = "SELECT COUNT(1) as number_of_comments
849
+        $result = Database::query($sql);
850
+
851
+        // Display
852
+        if(Database::num_rows($result) > 0) {
853
+            $limit = 200;
854
+            while ($blog_post = Database::fetch_array($result)) {
855
+                // Get number of comments
856
+                $sql = "SELECT COUNT(1) as number_of_comments
858 857
 						FROM $tbl_blogs_comments
859 858
 						WHERE
860 859
 						    c_id = $course_id AND
861 860
 						    blog_id = '".(int)$blog_id."' AND
862 861
 						    post_id = '" . (int)$blog_post['post_id']."'";
863
-				$tmp = Database::query($sql);
864
-				$blog_post_comments = Database::fetch_array($tmp);
865
-
866
-				// Prepare data
867
-				$blog_post_id = $blog_post['post_id'];
868
-				$blog_post_text = make_clickable(stripslashes($blog_post['full_text']));
869
-				$blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get());
870
-
871
-				// Create an introduction text (but keep FULL sentences)
872
-				$words = 0;
873
-				$blog_post_text_cut = cut($blog_post_text, $limit) ;
874
-				$words = strlen($blog_post_text);
875
-
876
-				if ($words >= $limit) {
877
-					$readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_' . $blog_post_id . '\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_' . $blog_post_id . '\').style.display=\'none\'">' . get_lang('ReadMore') . '</div>';
878
-					$introduction_text = $blog_post_text_cut;
879
-				} else {
880
-				    $introduction_text = $blog_post_text;
881
-					$readMoreLink = '';
882
-				}
883
-
884
-				$introduction_text = stripslashes($introduction_text);
885
-
886
-				echo '<div class="blogpost">';
887
-				echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>';
888
-				echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>';
889
-				echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>';
890
-				echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>';
891
-
892
-				$file_name_array = get_blog_attachment($blog_id,$blog_post_id,0);
893
-
894
-				if (!empty($file_name_array)) {
895
-					echo '<br /><br />';
896
-					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
897
-					echo '<a href="download.php?file=';
898
-					echo $file_name_array['path'];
899
-					echo ' "> '.$file_name_array['filename'].' </a><br />';
900
-					echo '</span>';
901
-				}
902
-				$username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
903
-				echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>';
904
-				echo '</div>';
905
-			}
906
-		} else {
907
-			if($filter == '1=1') {
908
-				echo get_lang('NoArticles');
909
-			} else {
910
-				echo get_lang('NoArticleMatches');
911
-			}
912
-		}
862
+                $tmp = Database::query($sql);
863
+                $blog_post_comments = Database::fetch_array($tmp);
864
+
865
+                // Prepare data
866
+                $blog_post_id = $blog_post['post_id'];
867
+                $blog_post_text = make_clickable(stripslashes($blog_post['full_text']));
868
+                $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get());
869
+
870
+                // Create an introduction text (but keep FULL sentences)
871
+                $words = 0;
872
+                $blog_post_text_cut = cut($blog_post_text, $limit) ;
873
+                $words = strlen($blog_post_text);
874
+
875
+                if ($words >= $limit) {
876
+                    $readMoreLink = ' <div class="link" onclick="document.getElementById(\'blogpost_text_' . $blog_post_id . '\').style.display=\'block\'; document.getElementById(\'blogpost_introduction_' . $blog_post_id . '\').style.display=\'none\'">' . get_lang('ReadMore') . '</div>';
877
+                    $introduction_text = $blog_post_text_cut;
878
+                } else {
879
+                    $introduction_text = $blog_post_text;
880
+                    $readMoreLink = '';
881
+                }
882
+
883
+                $introduction_text = stripslashes($introduction_text);
884
+
885
+                echo '<div class="blogpost">';
886
+                echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>';
887
+                echo '<span class="blogpost_date"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . $blog_post_date . '</a></span>';
888
+                echo '<div class="blogpost_introduction" id="blogpost_introduction_'.$blog_post_id.'">' . $introduction_text.$readMoreLink.'</div>';
889
+                echo '<div class="blogpost_text" id="blogpost_text_' . $blog_post_id . '" style="display: none">' . $blog_post_text . '</div>';
890
+
891
+                $file_name_array = get_blog_attachment($blog_id,$blog_post_id,0);
892
+
893
+                if (!empty($file_name_array)) {
894
+                    echo '<br /><br />';
895
+                    echo Display::return_icon('attachment.gif',get_lang('Attachment'));
896
+                    echo '<a href="download.php?file=';
897
+                    echo $file_name_array['path'];
898
+                    echo ' "> '.$file_name_array['filename'].' </a><br />';
899
+                    echo '</span>';
900
+                }
901
+                $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
902
+                echo '<span class="blogpost_info">' . get_lang('Author') . ': ' . Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)) .' - <a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '#add_comment" title="' . get_lang('ReadPost') . '" >' . get_lang('Comments') . ': ' . $blog_post_comments['number_of_comments'] . '</a></span>';
903
+                echo '</div>';
904
+            }
905
+        } else {
906
+            if($filter == '1=1') {
907
+                echo get_lang('NoArticles');
908
+            } else {
909
+                echo get_lang('NoArticleMatches');
910
+            }
911
+        }
913 912
 }
914 913
 
915
-	/**
916
-	 * Display the search results
917
-	 *
918
-	 * @param Integer $blog_id
919
-	 * @param String $query_string
920
-	 */
921
-	public static function display_search_results ($blog_id, $query_string)
922
-	{
923
-		// Init
924
-		$query_string = Database::escape_string($query_string);
925
-		$query_string_parts = explode(' ',$query_string);
926
-		$query_string = array();
927
-		foreach ($query_string_parts as $query_part) {
928
-			$query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' ";
929
-		}
930
-		$query_string = '('.implode('OR',$query_string) . ')';
931
-
932
-		// Display the posts
933
-		echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>';
934
-		Blog::display_blog_posts($blog_id, $query_string);
935
-	}
936
-
937
-	/**
938
-	 * Display posts from a certain date
939
-	 *
940
-	 * @param Integer $blog_id
941
-	 * @param String $query_string
942
-	 */
943
-	public static function display_day_results($blog_id, $query_string)
944
-	{
945
-		$date_output = $query_string;
946
-		$date = explode('-',$query_string);
947
-		$query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]);
948
-
949
-		// Put date in correct output format
950
-		$date_output = api_format_date($date_output, DATE_FORMAT_LONG);
951
-
952
-		// Display the posts
953
-		echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>';
954
-		Blog::display_blog_posts($blog_id, $query_string);
955
-	}
956
-
957
-	/**
958
-	 * Displays a post and his comments
959
-	 *
960
-	 * @param Integer $blog_id
961
-	 * @param Integer $post_id
962
-	 */
963
-	public static function display_post($blog_id, $post_id)
964
-	{
965
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
966
-		$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
967
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
968
-
969
-		global $charset, $dateFormatLong;
970
-
971
-		$course_id = api_get_course_int_id();
972
-
973
-		// Get posts and author
974
-		$sql = "SELECT post.*, user.lastname, user.firstname, user.username
914
+    /**
915
+     * Display the search results
916
+     *
917
+     * @param Integer $blog_id
918
+     * @param String $query_string
919
+     */
920
+    public static function display_search_results ($blog_id, $query_string)
921
+    {
922
+        // Init
923
+        $query_string = Database::escape_string($query_string);
924
+        $query_string_parts = explode(' ',$query_string);
925
+        $query_string = array();
926
+        foreach ($query_string_parts as $query_part) {
927
+            $query_string[] = " full_text LIKE '%" . $query_part."%' OR title LIKE '%" . $query_part."%' ";
928
+        }
929
+        $query_string = '('.implode('OR',$query_string) . ')';
930
+
931
+        // Display the posts
932
+        echo '<span class="blogpost_title">' . get_lang('SearchResults') . '</span>';
933
+        Blog::display_blog_posts($blog_id, $query_string);
934
+    }
935
+
936
+    /**
937
+     * Display posts from a certain date
938
+     *
939
+     * @param Integer $blog_id
940
+     * @param String $query_string
941
+     */
942
+    public static function display_day_results($blog_id, $query_string)
943
+    {
944
+        $date_output = $query_string;
945
+        $date = explode('-',$query_string);
946
+        $query_string = ' DAYOFMONTH(date_creation) =' . intval($date[2]) . ' AND MONTH(date_creation) =' . intval($date[1]) . ' AND YEAR(date_creation) =' . intval($date[0]);
947
+
948
+        // Put date in correct output format
949
+        $date_output = api_format_date($date_output, DATE_FORMAT_LONG);
950
+
951
+        // Display the posts
952
+        echo '<span class="blogpost_title">' . get_lang('PostsOf') . ': ' . $date_output . '</span>';
953
+        Blog::display_blog_posts($blog_id, $query_string);
954
+    }
955
+
956
+    /**
957
+     * Displays a post and his comments
958
+     *
959
+     * @param Integer $blog_id
960
+     * @param Integer $post_id
961
+     */
962
+    public static function display_post($blog_id, $post_id)
963
+    {
964
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
965
+        $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
966
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
967
+
968
+        global $charset, $dateFormatLong;
969
+
970
+        $course_id = api_get_course_int_id();
971
+
972
+        // Get posts and author
973
+        $sql = "SELECT post.*, user.lastname, user.firstname, user.username
975 974
 		        FROM $tbl_blogs_posts post
976 975
 					INNER JOIN $tbl_users user
977 976
 					ON post.author_id = user.user_id
@@ -980,107 +979,107 @@  discard block
 block discarded – undo
980 979
                     post.blog_id = '".(int)$blog_id."' AND
981 980
                     post.post_id = '".(int)$post_id."'
982 981
                 ORDER BY post_id DESC";
983
-		$result = Database::query($sql);
984
-		$blog_post = Database::fetch_array($result);
982
+        $result = Database::query($sql);
983
+        $blog_post = Database::fetch_array($result);
985 984
 
986
-		// Get number of comments
987
-		$sql = "SELECT COUNT(1) as number_of_comments
985
+        // Get number of comments
986
+        $sql = "SELECT COUNT(1) as number_of_comments
988 987
 		        FROM $tbl_blogs_comments
989 988
 				WHERE c_id = $course_id AND blog_id = '".(int)$blog_id."' AND post_id = '".(int)$post_id."'";
990
-		$result = Database::query($sql);
991
-		$blog_post_comments = Database::fetch_array($result);
989
+        $result = Database::query($sql);
990
+        $blog_post_comments = Database::fetch_array($result);
992 991
 
993
-		// Prepare data
994
-		$blog_post_text = make_clickable(stripslashes($blog_post['full_text']));
995
-		$blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get());
996
-		$blog_post_actions = "";
992
+        // Prepare data
993
+        $blog_post_text = make_clickable(stripslashes($blog_post['full_text']));
994
+        $blog_post_date = api_convert_and_format_date($blog_post['date_creation'], null, date_default_timezone_get());
995
+        $blog_post_actions = "";
997 996
 
998
-		$task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0;
997
+        $task_id = (isset($_GET['task_id']) && is_numeric($_GET['task_id'])) ? intval($_GET['task_id']) : 0;
999 998
 
1000
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id))
1001
-			$blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('EditThisPost') . '"><img src="../img/edit.gif" /></a>';
999
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_edit', $task_id))
1000
+            $blog_post_actions .= '<a href="blog.php?action=edit_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('EditThisPost') . '"><img src="../img/edit.gif" /></a>';
1002 1001
 
1003
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id))
1004
-			$blog_post_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_article&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisArticle') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"><img src="../img/delete.gif" border="0" /></a>';
1002
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_delete', $task_id))
1003
+            $blog_post_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_article&article_id=' . $blog_post['post_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisArticle') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"><img src="../img/delete.gif" border="0" /></a>';
1005 1004
 
1006
-		if(api_is_allowed('BLOG_' . $blog_id, 'article_rate'))
1007
-			$rating_select = Blog::display_rating_form('post',$blog_id,$post_id);
1005
+        if(api_is_allowed('BLOG_' . $blog_id, 'article_rate'))
1006
+            $rating_select = Blog::display_rating_form('post',$blog_id,$post_id);
1008 1007
 
1009
-		$blog_post_text=stripslashes($blog_post_text);
1008
+        $blog_post_text=stripslashes($blog_post_text);
1010 1009
 
1011
-		// Display post
1012
-		echo '<div class="blogpost">';
1013
-		echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>';
1014
-		echo '<span class="blogpost_date">' . $blog_post_date . '</span>';
1015
-		echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />';
1010
+        // Display post
1011
+        echo '<div class="blogpost">';
1012
+        echo '<span class="blogpost_title"><a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $blog_post['post_id'] . '" title="' . get_lang('ReadPost') . '" >'.stripslashes($blog_post['title']) . '</a></span>';
1013
+        echo '<span class="blogpost_date">' . $blog_post_date . '</span>';
1014
+        echo '<span class="blogpost_text">' . $blog_post_text . '</span><br />';
1016 1015
 
1017
-		$file_name_array = get_blog_attachment($blog_id, $post_id);
1016
+        $file_name_array = get_blog_attachment($blog_id, $post_id);
1018 1017
 
1019 1018
         if (!empty($file_name_array)) {
1020
-			echo ' <br />';
1021
-			echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1022
-			echo '<a href="download.php?file=';
1023
-			echo $file_name_array['path'];
1024
-			echo ' "> '.$file_name_array['filename'].' </a>';
1025
-			echo '</span>';
1026
-			echo '<span class="attachment_comment">';
1027
-			echo $file_name_array['comment'];
1028
-			echo '</span>';
1029
-			echo '<br />';
1030
-		}
1019
+            echo ' <br />';
1020
+            echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1021
+            echo '<a href="download.php?file=';
1022
+            echo $file_name_array['path'];
1023
+            echo ' "> '.$file_name_array['filename'].' </a>';
1024
+            echo '</span>';
1025
+            echo '<span class="attachment_comment">';
1026
+            echo $file_name_array['comment'];
1027
+            echo '</span>';
1028
+            echo '<br />';
1029
+        }
1031 1030
         $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
1032
-		echo '<span class="blogpost_info">'.get_lang('Author').': ' .Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post',$blog_id,$post_id).$rating_select.'</span>';
1033
-		echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>';
1034
-		echo '</div>';
1035
-
1036
-		// Display comments if there are any
1037
-		if($blog_post_comments['number_of_comments'] > 0) {
1038
-			echo '<div class="comments">';
1039
-				echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />';
1040
-				Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id);
1041
-			echo '</div>';
1042
-		}
1043
-
1044
-		// Display comment form
1045
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) {
1046
-			Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']);
1047
-		}
1048
-	}
1049
-
1050
-	/**
1051
-	 * Adds rating to a certain post or comment
1052
-	 * @author Toon Keppens
1053
-	 *
1054
-	 * @param String $type
1055
-	 * @param Integer $blog_id
1056
-	 * @param Integer $item_id
1057
-	 * @param Integer $rating
1058
-	 *
1059
-	 * @return Boolean success
1060
-	 */
1061
-	public static function add_rating($type, $blog_id, $item_id, $rating)
1062
-	{
1063
-		$_user = api_get_user_info();
1064
-
1065
-		// Init
1066
-		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1067
-		$course_id = api_get_course_int_id();
1068
-
1069
-		// Check if the user has already rated this post/comment
1070
-		$sql = "SELECT rating_id FROM $tbl_blogs_rating
1031
+        echo '<span class="blogpost_info">'.get_lang('Author').': ' .Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username)).' - '.get_lang('Comments').': '.$blog_post_comments['number_of_comments'].' - '.get_lang('Rating').': '.Blog::display_rating('post',$blog_id,$post_id).$rating_select.'</span>';
1032
+        echo '<span class="blogpost_actions">' . $blog_post_actions . '</span>';
1033
+        echo '</div>';
1034
+
1035
+        // Display comments if there are any
1036
+        if($blog_post_comments['number_of_comments'] > 0) {
1037
+            echo '<div class="comments">';
1038
+                echo '<span class="blogpost_title">' . get_lang('Comments') . '</span><br />';
1039
+                Blog::get_threaded_comments(0, 0, $blog_id, $post_id, $task_id);
1040
+            echo '</div>';
1041
+        }
1042
+
1043
+        // Display comment form
1044
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_comments_add')) {
1045
+            Blog::display_new_comment_form($blog_id, $post_id, $blog_post['title']);
1046
+        }
1047
+    }
1048
+
1049
+    /**
1050
+     * Adds rating to a certain post or comment
1051
+     * @author Toon Keppens
1052
+     *
1053
+     * @param String $type
1054
+     * @param Integer $blog_id
1055
+     * @param Integer $item_id
1056
+     * @param Integer $rating
1057
+     *
1058
+     * @return Boolean success
1059
+     */
1060
+    public static function add_rating($type, $blog_id, $item_id, $rating)
1061
+    {
1062
+        $_user = api_get_user_info();
1063
+
1064
+        // Init
1065
+        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1066
+        $course_id = api_get_course_int_id();
1067
+
1068
+        // Check if the user has already rated this post/comment
1069
+        $sql = "SELECT rating_id FROM $tbl_blogs_rating
1071 1070
                 WHERE
1072 1071
                     c_id = $course_id AND
1073 1072
                     blog_id = '".(int)$blog_id."' AND
1074 1073
                     item_id = '".(int)$item_id."' AND
1075 1074
                     rating_type = '".Database::escape_string($type)."' AND
1076 1075
                     user_id = '".(int)$_user['user_id']."'";
1077
-		$result = Database::query($sql);
1076
+        $result = Database::query($sql);
1078 1077
 
1079 1078
         // Add rating
1080
-		if (Database::num_rows($result) == 0) {
1081
-			$sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating )
1079
+        if (Database::num_rows($result) == 0) {
1080
+            $sql = "INSERT INTO $tbl_blogs_rating (c_id, blog_id, rating_type, item_id, user_id, rating )
1082 1081
 					VALUES ($course_id, '".(int)$blog_id."', '".Database::escape_string($type)."', '".(int)$item_id."', '".(int)$_user['user_id']."', '".Database::escape_string($rating)."')";
1083
-			Database::query($sql);
1082
+            Database::query($sql);
1084 1083
 
1085 1084
             $id = Database::insert_id();
1086 1085
             if ($id) {
@@ -1088,107 +1087,107 @@  discard block
 block discarded – undo
1088 1087
                 Database::query($sql);
1089 1088
             }
1090 1089
 
1091
-			return true;
1090
+            return true;
1092 1091
         } else {
1093
-			return false;
1094
-		}
1095
-	}
1096
-
1097
-	/**
1098
-	 * Shows the rating of user
1099
-	 *
1100
-	 * @param String $type
1101
-	 * @param Integer $blog_id
1102
-	 * @param Integer $item_id
1103
-	 *
1104
-	 * @return array()
1105
-	 */
1106
-	public static function display_rating($type, $blog_id, $item_id)
1107
-	{
1108
-		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1109
-		$course_id = api_get_course_int_id();
1110
-
1111
-		// Calculate rating
1112
-		$sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating
1092
+            return false;
1093
+        }
1094
+    }
1095
+
1096
+    /**
1097
+     * Shows the rating of user
1098
+     *
1099
+     * @param String $type
1100
+     * @param Integer $blog_id
1101
+     * @param Integer $item_id
1102
+     *
1103
+     * @return array()
1104
+     */
1105
+    public static function display_rating($type, $blog_id, $item_id)
1106
+    {
1107
+        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1108
+        $course_id = api_get_course_int_id();
1109
+
1110
+        // Calculate rating
1111
+        $sql = "SELECT AVG(rating) as rating FROM $tbl_blogs_rating
1113 1112
 				WHERE
1114 1113
 				    c_id = $course_id AND
1115 1114
 				    blog_id = '".(int)$blog_id."' AND
1116 1115
 				    item_id = '".(int)$item_id."' AND
1117 1116
 				    rating_type = '".Database::escape_string($type)."' ";
1118
-		$result = Database::query($sql);
1119
-		$result = Database::fetch_array($result);
1120
-		return round($result['rating'], 2);
1121
-	}
1122
-
1123
-	/**
1124
-	 * Shows the rating form if not already rated by that user
1125
-	 * @author Toon Keppens
1126
-	 *
1127
-	 * @param String $type
1128
-	 * @param Integer $blog_id
1129
-	 * @param Integer $item_id
1130
-	 *
1131
-	 *@return String
1132
-	 */
1133
-	public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL)
1134
-	{
1135
-		$_user = api_get_user_info();
1136
-		$tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1117
+        $result = Database::query($sql);
1118
+        $result = Database::fetch_array($result);
1119
+        return round($result['rating'], 2);
1120
+    }
1121
+
1122
+    /**
1123
+     * Shows the rating form if not already rated by that user
1124
+     * @author Toon Keppens
1125
+     *
1126
+     * @param String $type
1127
+     * @param Integer $blog_id
1128
+     * @param Integer $item_id
1129
+     *
1130
+     *@return String
1131
+     */
1132
+    public static function display_rating_form ($type, $blog_id, $post_id, $comment_id = NULL)
1133
+    {
1134
+        $_user = api_get_user_info();
1135
+        $tbl_blogs_rating = Database::get_course_table(TABLE_BLOGS_RATING);
1137 1136
         $course_id = api_get_course_int_id();
1138 1137
 
1139 1138
         if ($type == 'post') {
1140
-			// Check if the user has already rated this post
1141
-			$sql = "SELECT rating_id FROM $tbl_blogs_rating
1139
+            // Check if the user has already rated this post
1140
+            $sql = "SELECT rating_id FROM $tbl_blogs_rating
1142 1141
 					WHERE c_id = $course_id AND
1143 1142
 					blog_id = '".(int)$blog_id."'
1144 1143
 					AND item_id = '".(int)$post_id."'
1145 1144
 					AND rating_type = '".Database::escape_string($type)."'
1146 1145
 					AND user_id = '".(int)$_user['user_id']."'";
1147
-			$result = Database::query($sql);
1146
+            $result = Database::query($sql);
1148 1147
             // Add rating
1149 1148
             if (Database::num_rows($result) == 0) {
1150
-				return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $post_id . '" name="frm_rating_' . $type . '_' . $post_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $post_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /></form>';
1149
+                return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $post_id . '" name="frm_rating_' . $type . '_' . $post_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $post_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /></form>';
1151 1150
             } else {
1152
-				return '';
1153
-			}
1154
-		}
1151
+                return '';
1152
+            }
1153
+        }
1155 1154
 
1156 1155
         if ($type = 'comment') {
1157
-			// Check if the user has already rated this comment
1158
-			$sql = "SELECT rating_id FROM $tbl_blogs_rating
1156
+            // Check if the user has already rated this comment
1157
+            $sql = "SELECT rating_id FROM $tbl_blogs_rating
1159 1158
 					WHERE c_id = $course_id AND blog_id = '".(int)$blog_id ."'
1160 1159
 					AND item_id = '".(int)$comment_id."'
1161 1160
 					AND rating_type = '".Database::escape_string($type)."'
1162 1161
 					AND user_id = '".(int)$_user['user_id']."'";
1163
-			$result = Database::query($sql);
1162
+            $result = Database::query($sql);
1164 1163
 
1165 1164
             if (Database::num_rows($result) == 0) {
1166
-				return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $comment_id . '" name="frm_rating_' . $type . '_' . $comment_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $comment_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /><input type="hidden" name="comment_id" value="' . $comment_id . '" /></form>';
1165
+                return ' - ' . get_lang('RateThis') . ': <form method="get" action="blog.php" style="display: inline" id="frm_rating_' . $type . '_' . $comment_id . '" name="frm_rating_' . $type . '_' . $comment_id . '"><select name="rating" onchange="document.forms[\'frm_rating_' . $type . '_' . $comment_id . '\'].submit()"><option value="">-</option><option value="1">1</option><option value="2">2</option><option value="3">3</option><option value="4">4</option><option value="5">5</option><option value="6">6</option><option value="7">7</option><option value="8">8</option><option value="9">9</option><option value="10">10</option></select><input type="hidden" name="action" value="view_post" /><input type="hidden" name="type" value="' . $type . '" /><input type="hidden" name="do" value="rate" /><input type="hidden" name="blog_id" value="' . $blog_id . '" /><input type="hidden" name="post_id" value="' . $post_id . '" /><input type="hidden" name="comment_id" value="' . $comment_id . '" /></form>';
1167 1166
             } else {
1168
-				return '';
1169
-			}
1170
-		}
1171
-	}
1172
-
1173
-	/**
1174
-	 * This functions gets all replys to a post, threaded.
1175
-	 *
1176
-	 * @param Integer $current
1177
-	 * @param Integer $current_level
1178
-	 * @param Integer $blog_id
1179
-	 * @param Integer $post_id
1180
-	 */
1181
-	public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0)
1182
-	{
1183
-		$tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
1184
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1185
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1186
-		global $charset;
1187
-
1188
-		$course_id = api_get_course_int_id();
1189
-
1190
-		// Select top level comments
1191
-		$next_level = $current_level + 1;
1167
+                return '';
1168
+            }
1169
+        }
1170
+    }
1171
+
1172
+    /**
1173
+     * This functions gets all replys to a post, threaded.
1174
+     *
1175
+     * @param Integer $current
1176
+     * @param Integer $current_level
1177
+     * @param Integer $blog_id
1178
+     * @param Integer $post_id
1179
+     */
1180
+    public static function get_threaded_comments($current = 0, $current_level = 0, $blog_id, $post_id, $task_id = 0)
1181
+    {
1182
+        $tbl_blogs_comments = Database::get_course_table(TABLE_BLOGS_COMMENTS);
1183
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1184
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1185
+        global $charset;
1186
+
1187
+        $course_id = api_get_course_int_id();
1188
+
1189
+        // Select top level comments
1190
+        $next_level = $current_level + 1;
1192 1191
         $sql = "SELECT comments.*, user.lastname, user.firstname, user.username, task.color
1193 1192
                 FROM $tbl_blogs_comments comments
1194 1193
                 INNER JOIN $tbl_users user
@@ -1200,11 +1199,11 @@  discard block
 block discarded – undo
1200 1199
                     parent_comment_id = $current AND
1201 1200
                     comments.blog_id = '".(int)$blog_id."' AND
1202 1201
                     comments.post_id = '".(int)$post_id."'";
1203
-		$result = Database::query($sql);
1202
+        $result = Database::query($sql);
1204 1203
 
1205
-		while($comment = Database::fetch_array($result)) {
1206
-			// Select the children recursivly
1207
-			$tmp = "SELECT comments.*, user.lastname, user.firstname, user.username
1204
+        while($comment = Database::fetch_array($result)) {
1205
+            // Select the children recursivly
1206
+            $tmp = "SELECT comments.*, user.lastname, user.firstname, user.username
1208 1207
 			        FROM $tbl_blogs_comments comments
1209 1208
 					INNER JOIN $tbl_users user
1210 1209
 					ON comments.author_id = user.user_id
@@ -1213,104 +1212,104 @@  discard block
 block discarded – undo
1213 1212
 						comment_id = $current
1214 1213
 						AND blog_id = '".(int)$blog_id."'
1215 1214
 						AND post_id = '".(int)$post_id."'";
1216
-			$tmp = Database::query($tmp);
1217
-			$tmp = Database::fetch_array($tmp);
1218
-			$parent_cat = $tmp['parent_comment_id'];
1219
-			$border_color = '';
1220
-
1221
-			// Prepare data
1222
-			$comment_text = make_clickable(stripslashes($comment['comment']));
1223
-			$blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get());
1224
-			$blog_comment_actions = "";
1225
-			if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_delete', $task_id)) { $blog_comment_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_comment&comment_id=' . $comment['comment_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisComment') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"><img src="../img/delete.gif" border="0" /></a>'; }
1226
-			if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_rate')) { $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']); }
1227
-
1228
-			if (!is_null($comment['task_id'])) {
1229
-				$border_color = ' border-left: 3px solid #' . $comment['color'];
1230
-			}
1231
-
1232
-			$comment_text = stripslashes($comment_text);
1233
-
1234
-			// Output...
1235
-			$margin = $current_level * 30;
1236
-			echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">';
1237
-				echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\'' . $comment['comment_id'] . '\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']) . '\'" title="' . get_lang('ReplyToThisComment') . '" >'.stripslashes($comment['title']) . '</a></span>';
1238
-				echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>';
1239
-				echo '<span class="blogpost_text">' . $comment_text . '</span>';
1240
-
1241
-				$file_name_array=get_blog_attachment($blog_id,$post_id, $comment['comment_id']);
1242
-				if (!empty($file_name_array)) {
1243
-					echo '<br /><br />';
1244
-					echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1245
-					echo '<a href="download.php?file=';
1246
-					echo $file_name_array['path'];
1247
-					echo ' "> '.$file_name_array['filename'].' </a>';
1248
-					echo '<span class="attachment_comment">';
1249
-					echo $file_name_array['comment'];
1250
-					echo '</span><br />';
1251
-				}
1215
+            $tmp = Database::query($tmp);
1216
+            $tmp = Database::fetch_array($tmp);
1217
+            $parent_cat = $tmp['parent_comment_id'];
1218
+            $border_color = '';
1219
+
1220
+            // Prepare data
1221
+            $comment_text = make_clickable(stripslashes($comment['comment']));
1222
+            $blog_comment_date = api_convert_and_format_date($comment['date_creation'], null, date_default_timezone_get());
1223
+            $blog_comment_actions = "";
1224
+            if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_delete', $task_id)) { $blog_comment_actions .= '<a href="blog.php?action=view_post&blog_id=' . $blog_id . '&post_id=' . $post_id . '&do=delete_comment&comment_id=' . $comment['comment_id'] . '&task_id=' . $task_id . '" title="' . get_lang('DeleteThisComment') . '" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"><img src="../img/delete.gif" border="0" /></a>'; }
1225
+            if(api_is_allowed('BLOG_' . $blog_id, 'article_comments_rate')) { $rating_select = Blog::display_rating_form('comment', $blog_id, $post_id, $comment['comment_id']); }
1226
+
1227
+            if (!is_null($comment['task_id'])) {
1228
+                $border_color = ' border-left: 3px solid #' . $comment['color'];
1229
+            }
1230
+
1231
+            $comment_text = stripslashes($comment_text);
1232
+
1233
+            // Output...
1234
+            $margin = $current_level * 30;
1235
+            echo '<div class="blogpost_comment" style="margin-left: ' . $margin . 'px;' . $border_color . '">';
1236
+                echo '<span class="blogpost_comment_title"><a href="#add_comment" onclick="document.getElementById(\'comment_parent_id\').value=\'' . $comment['comment_id'] . '\'; document.getElementById(\'comment_title\').value=\'Re: '.addslashes($comment['title']) . '\'" title="' . get_lang('ReplyToThisComment') . '" >'.stripslashes($comment['title']) . '</a></span>';
1237
+                echo '<span class="blogpost_comment_date">' . $blog_comment_date . '</span>';
1238
+                echo '<span class="blogpost_text">' . $comment_text . '</span>';
1239
+
1240
+                $file_name_array=get_blog_attachment($blog_id,$post_id, $comment['comment_id']);
1241
+                if (!empty($file_name_array)) {
1242
+                    echo '<br /><br />';
1243
+                    echo Display::return_icon('attachment.gif',get_lang('Attachment'));
1244
+                    echo '<a href="download.php?file=';
1245
+                    echo $file_name_array['path'];
1246
+                    echo ' "> '.$file_name_array['filename'].' </a>';
1247
+                    echo '<span class="attachment_comment">';
1248
+                    echo $file_name_array['comment'];
1249
+                    echo '</span><br />';
1250
+                }
1252 1251
                 $username = api_htmlentities(sprintf(get_lang('LoginX'), $comment['username']), ENT_QUOTES);
1253
-				echo '<span class="blogpost_comment_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($comment['firstname'], $comment['lastname']), array('title'=>$username)).' - '.get_lang('Rating').': '.Blog::display_rating('comment', $blog_id, $comment['comment_id']).$rating_select.'</span>';
1254
-				echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>';
1255
-			echo '</div>';
1256
-
1257
-			// Go further down the tree.
1258
-			Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id);
1259
-		}
1260
-	}
1261
-
1262
-	/**
1263
-	 * Displays the form to create a new post
1264
-	 * @author Toon Keppens
1265
-	 *
1266
-	 * @param Integer $blog_id
1267
-	 */
1268
-	public static function display_form_new_post($blog_id)
1269
-	{
1270
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1271
-			$form = new FormValidator(
1272
-				'add_post',
1273
-				'post',
1274
-				api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(),
1275
-				null,
1276
-				array('enctype' => 'multipart/form-data')
1277
-			);
1278
-			$form->addHidden('post_title_edited', 'false');
1279
-			$form->addHeader(get_lang('NewPost'));
1280
-			$form->addText('title', get_lang('Title'));
1281
-			$config = array();
1282
-			if (!api_is_allowed_to_edit()) {
1283
-				$config['ToolbarSet'] = 'ProjectStudent';
1284
-			} else {
1285
-				$config['ToolbarSet'] = 'Project';
1286
-			}
1287
-			$form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config);
1288
-			$form->addFile('user_upload', get_lang('AddAnAttachment'));
1289
-			$form->addTextarea('post_file_comment', get_lang('FileComment'));
1290
-			$form->addHidden('new_post_submit', 'true');
1291
-			$form->addButton('save', get_lang('Save'));
1292
-
1293
-			$form->display();
1294
-		} else {
1295
-			api_not_allowed();
1296
-		}
1297
-	}
1298
-
1299
-	/**
1300
-	 * Displays the form to edit a post
1301
-	 * @author Toon Keppens
1302
-	 *
1303
-	 * @param Integer $blog_id
1304
-	 */
1305
-	public static function display_form_edit_post($blog_id, $post_id)
1306
-	{
1307
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
1308
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1309
-
1310
-		$course_id = api_get_course_int_id();
1311
-
1312
-		// Get posts and author
1313
-		$sql = "SELECT post.*, user.lastname, user.firstname
1252
+                echo '<span class="blogpost_comment_info">'.get_lang('Author').': '.Display::tag('span', api_get_person_name($comment['firstname'], $comment['lastname']), array('title'=>$username)).' - '.get_lang('Rating').': '.Blog::display_rating('comment', $blog_id, $comment['comment_id']).$rating_select.'</span>';
1253
+                echo '<span class="blogpost_actions">' . $blog_comment_actions . '</span>';
1254
+            echo '</div>';
1255
+
1256
+            // Go further down the tree.
1257
+            Blog::get_threaded_comments($comment['comment_id'], $next_level, $blog_id, $post_id);
1258
+        }
1259
+    }
1260
+
1261
+    /**
1262
+     * Displays the form to create a new post
1263
+     * @author Toon Keppens
1264
+     *
1265
+     * @param Integer $blog_id
1266
+     */
1267
+    public static function display_form_new_post($blog_id)
1268
+    {
1269
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1270
+            $form = new FormValidator(
1271
+                'add_post',
1272
+                'post',
1273
+                api_get_path(WEB_CODE_PATH)."blog/blog.php?action=new_post&blog_id=" . $blog_id . "&" . api_get_cidreq(),
1274
+                null,
1275
+                array('enctype' => 'multipart/form-data')
1276
+            );
1277
+            $form->addHidden('post_title_edited', 'false');
1278
+            $form->addHeader(get_lang('NewPost'));
1279
+            $form->addText('title', get_lang('Title'));
1280
+            $config = array();
1281
+            if (!api_is_allowed_to_edit()) {
1282
+                $config['ToolbarSet'] = 'ProjectStudent';
1283
+            } else {
1284
+                $config['ToolbarSet'] = 'Project';
1285
+            }
1286
+            $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config);
1287
+            $form->addFile('user_upload', get_lang('AddAnAttachment'));
1288
+            $form->addTextarea('post_file_comment', get_lang('FileComment'));
1289
+            $form->addHidden('new_post_submit', 'true');
1290
+            $form->addButton('save', get_lang('Save'));
1291
+
1292
+            $form->display();
1293
+        } else {
1294
+            api_not_allowed();
1295
+        }
1296
+    }
1297
+
1298
+    /**
1299
+     * Displays the form to edit a post
1300
+     * @author Toon Keppens
1301
+     *
1302
+     * @param Integer $blog_id
1303
+     */
1304
+    public static function display_form_edit_post($blog_id, $post_id)
1305
+    {
1306
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
1307
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1308
+
1309
+        $course_id = api_get_course_int_id();
1310
+
1311
+        // Get posts and author
1312
+        $sql = "SELECT post.*, user.lastname, user.firstname
1314 1313
 				FROM $tbl_blogs_posts post
1315 1314
 				INNER JOIN $tbl_users user ON post.author_id = user.user_id
1316 1315
 				WHERE
@@ -1318,69 +1317,69 @@  discard block
 block discarded – undo
1318 1317
 				post.blog_id 		= '".(int)$blog_id ."'
1319 1318
 				AND post.post_id	= '".(int)$post_id."'
1320 1319
 				ORDER BY post_id DESC";
1321
-		$result = Database::query($sql);
1322
-		$blog_post = Database::fetch_array($result);
1323
-
1324
-		// Form
1325
-		$form = new FormValidator(
1326
-			'edit_post',
1327
-			'post',
1328
-			api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id=' . intval($_GET['post_id']) . '&blog_id=' . intval($blog_id) . '&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id'])
1329
-		);
1330
-
1331
-		$form->addHeader(get_lang('EditPost'));
1332
-		$form->addText('title', get_lang('Title'));
1333
-
1334
-		if (!api_is_allowed_to_edit()) {
1335
-			$config['ToolbarSet'] = 'ProjectStudent';
1336
-		} else {
1337
-			$config['ToolbarSet'] = 'Project';
1338
-		}
1339
-		$form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config);
1340
-
1341
-		$form->addHidden('action', '');
1342
-		$form->addHidden('edit_post_submit', 'true');
1343
-		$form->addHidden('post_id', intval($_GET['post_id']));
1344
-		$form->addButton('save', get_lang('Save'));
1345
-		$form->setDefaults($blog_post);
1346
-		$form->display();
1347
-	}
1348
-
1349
-	/**
1350
-	 * Displays a list of tasks in this blog
1351
-	 * @author Toon Keppens
1352
-	 *
1353
-	 * @param Integer $blog_id
1354
-	 */
1355
-	public static function display_task_list($blog_id)
1320
+        $result = Database::query($sql);
1321
+        $blog_post = Database::fetch_array($result);
1322
+
1323
+        // Form
1324
+        $form = new FormValidator(
1325
+            'edit_post',
1326
+            'post',
1327
+            api_get_path(WEB_CODE_PATH).'blog/blog.php?action=edit_post&post_id=' . intval($_GET['post_id']) . '&blog_id=' . intval($blog_id) . '&article_id='.intval($_GET['article_id']).'&task_id='.intval($_GET['task_id'])
1328
+        );
1329
+
1330
+        $form->addHeader(get_lang('EditPost'));
1331
+        $form->addText('title', get_lang('Title'));
1332
+
1333
+        if (!api_is_allowed_to_edit()) {
1334
+            $config['ToolbarSet'] = 'ProjectStudent';
1335
+        } else {
1336
+            $config['ToolbarSet'] = 'Project';
1337
+        }
1338
+        $form->addHtmlEditor('full_text', get_lang('Content'), false, false, $config);
1339
+
1340
+        $form->addHidden('action', '');
1341
+        $form->addHidden('edit_post_submit', 'true');
1342
+        $form->addHidden('post_id', intval($_GET['post_id']));
1343
+        $form->addButton('save', get_lang('Save'));
1344
+        $form->setDefaults($blog_post);
1345
+        $form->display();
1346
+    }
1347
+
1348
+    /**
1349
+     * Displays a list of tasks in this blog
1350
+     * @author Toon Keppens
1351
+     *
1352
+     * @param Integer $blog_id
1353
+     */
1354
+    public static function display_task_list($blog_id)
1356 1355
     {
1357
-		global $charset;
1356
+        global $charset;
1358 1357
         $course_id = api_get_course_int_id();
1359 1358
 
1360
-		if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1361
-			$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1362
-			$counter = 0;
1363
-			global $color2;
1359
+        if (api_is_allowed('BLOG_' . $blog_id, 'article_add')) {
1360
+            $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1361
+            $counter = 0;
1362
+            global $color2;
1364 1363
 
1365
-			echo '<div class="actions">';
1366
-			echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add"><img src="../img/blog_newtasks.gif" border="0" align="middle" alt="'.get_lang('AddTasks').'" />' . get_lang('AddTasks') . '</a> ';
1367
-			echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign"><img src="../img/blog_task.gif" border="0" align="middle" alt="'.get_lang('AssignTasks').'" />' . get_lang('AssignTasks') . '</a>';
1368
-			?>
1364
+            echo '<div class="actions">';
1365
+            echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=add"><img src="../img/blog_newtasks.gif" border="0" align="middle" alt="'.get_lang('AddTasks').'" />' . get_lang('AddTasks') . '</a> ';
1366
+            echo '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $blog_id . '&do=assign"><img src="../img/blog_task.gif" border="0" align="middle" alt="'.get_lang('AssignTasks').'" />' . get_lang('AssignTasks') . '</a>';
1367
+            ?>
1369 1368
 				<a href="<?php echo api_get_self(); ?>?action=manage_rights&blog_id=<?php echo $blog_id ?>" title="<?php echo get_lang('ManageRights') ?>"><?php echo Display::return_icon('blog_admin_users.png', get_lang('RightsManager'),'',ICON_SIZE_SMALL). get_lang('RightsManager') ?></a>
1370 1369
 			<?php
1371
-			echo '</div>';
1370
+            echo '</div>';
1372 1371
 
1373
-			echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />';
1374
-			echo "<table class=\"data_table\">";
1375
-			echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1376
-					 "<th width='240'><b>",get_lang('Title'),"</b></th>\n",
1377
-					 "<th><b>",get_lang('Description'),"</b></th>\n",
1378
-					 "<th><b>",get_lang('Color'),"</b></th>\n",
1379
-					 "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
1380
-				"</tr>\n";
1372
+            echo '<span class="blogpost_title">' . get_lang('TaskList') . '</span><br />';
1373
+            echo "<table class=\"data_table\">";
1374
+            echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1375
+                        "<th width='240'><b>",get_lang('Title'),"</b></th>\n",
1376
+                        "<th><b>",get_lang('Description'),"</b></th>\n",
1377
+                        "<th><b>",get_lang('Color'),"</b></th>\n",
1378
+                        "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
1379
+                "</tr>\n";
1381 1380
 
1382 1381
 
1383
-			$sql = " SELECT
1382
+            $sql = " SELECT
1384 1383
                         blog_id,
1385 1384
                         task_id,
1386 1385
                         blog_id,
@@ -1391,64 +1390,64 @@  discard block
 block discarded – undo
1391 1390
                     FROM " . $tbl_blogs_tasks . "
1392 1391
                     WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . "
1393 1392
                     ORDER BY system_task, title";
1394
-			$result = Database::query($sql);
1395
-
1396
-
1397
-			while($task = Database::fetch_array($result)) {
1398
-				$counter++;
1399
-				$css_class = (($counter % 2) == 0) ? "row_odd" : "row_even";
1400
-				$delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
1401
-				$delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1402
-				$delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id'];
1403
-				$delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1404
-
1405
-				echo	'<tr class="' . $css_class . '" valign="top">',
1406
-							 '<td width="240">' . Security::remove_XSS($task['title']) . '</td>',
1407
-							 '<td>' . Security::remove_XSS($task['description']) . '</td>',
1408
-							 '<td><span style="background-color: #' . $task['color'] . '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>',
1409
-							 '<td width="50">',
1410
-							 	'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=edit&task_id=' . $task['task_id'] . '">',
1411
-								'<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
1412
-								"</a>\n",
1413
-								'<a href="' . $delete_link . '"',
1414
-								$delete_confirm,
1415
-								'><img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
1416
-								"</a>\n",
1417
-							 '</td>',
1418
-						'</tr>';
1419
-			}
1420
-			echo "</table>";
1421
-		}
1422
-	}
1423
-
1424
-	/**
1425
-	 * Displays a list of tasks assigned to a user in this blog
1426
-	 * @author Toon Keppens
1427
-	 *
1428
-	 * @param Integer $blog_id
1429
-	 */
1430
-	public static function display_assigned_task_list ($blog_id)
1393
+            $result = Database::query($sql);
1394
+
1395
+
1396
+            while($task = Database::fetch_array($result)) {
1397
+                $counter++;
1398
+                $css_class = (($counter % 2) == 0) ? "row_odd" : "row_even";
1399
+                $delete_icon = ($task['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
1400
+                $delete_title = ($task['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1401
+                $delete_link = ($task['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=delete&task_id=' . $task['task_id'];
1402
+                $delete_confirm = ($task['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1403
+
1404
+                echo	'<tr class="' . $css_class . '" valign="top">',
1405
+                                '<td width="240">' . Security::remove_XSS($task['title']) . '</td>',
1406
+                                '<td>' . Security::remove_XSS($task['description']) . '</td>',
1407
+                                '<td><span style="background-color: #' . $task['color'] . '">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td>',
1408
+                                '<td width="50">',
1409
+                                    '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $task['blog_id'] . '&do=edit&task_id=' . $task['task_id'] . '">',
1410
+                                '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
1411
+                                "</a>\n",
1412
+                                '<a href="' . $delete_link . '"',
1413
+                                $delete_confirm,
1414
+                                '><img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
1415
+                                "</a>\n",
1416
+                                '</td>',
1417
+                        '</tr>';
1418
+            }
1419
+            echo "</table>";
1420
+        }
1421
+    }
1422
+
1423
+    /**
1424
+     * Displays a list of tasks assigned to a user in this blog
1425
+     * @author Toon Keppens
1426
+     *
1427
+     * @param Integer $blog_id
1428
+     */
1429
+    public static function display_assigned_task_list ($blog_id)
1431 1430
     {
1432
-		// Init
1433
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1434
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1435
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1436
-		$counter = 0;
1437
-		global $charset,$color2;
1438
-
1439
-		echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />';
1440
-		echo "<table class=\"data_table\">";
1441
-		echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1442
-				 "<th width='240'><b>",get_lang('Member'),"</b></th>\n",
1443
-				 "<th><b>",get_lang('Task'),"</b></th>\n",
1444
-				 "<th><b>",get_lang('Description'),"</b></th>\n",
1445
-				 "<th><b>",get_lang('TargetDate'),"</b></th>\n",
1446
-				 "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
1447
-			"</tr>";
1448
-
1449
-		$course_id = api_get_course_int_id();
1450
-
1451
-		$sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id
1431
+        // Init
1432
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1433
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1434
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1435
+        $counter = 0;
1436
+        global $charset,$color2;
1437
+
1438
+        echo '<span class="blogpost_title">' . get_lang('AssignedTasks') . '</span><br />';
1439
+        echo "<table class=\"data_table\">";
1440
+        echo	"<tr bgcolor=\"$color2\" align=\"center\" valign=\"top\">",
1441
+                    "<th width='240'><b>",get_lang('Member'),"</b></th>\n",
1442
+                    "<th><b>",get_lang('Task'),"</b></th>\n",
1443
+                    "<th><b>",get_lang('Description'),"</b></th>\n",
1444
+                    "<th><b>",get_lang('TargetDate'),"</b></th>\n",
1445
+                    "<th width='50'><b>",get_lang('Modify'),"</b></th>\n",
1446
+            "</tr>";
1447
+
1448
+        $course_id = api_get_course_int_id();
1449
+
1450
+        $sql = "SELECT task_rel_user.*, task.title, user.firstname, user.lastname, user.username, task.description, task.system_task, task.blog_id, task.task_id
1452 1451
 				FROM $tbl_blogs_tasks_rel_user task_rel_user
1453 1452
 				INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id
1454 1453
 				INNER JOIN $tbl_users user ON task_rel_user.user_id = user.user_id
@@ -1457,45 +1456,45 @@  discard block
 block discarded – undo
1457 1456
 					task.c_id = $course_id AND
1458 1457
 					task_rel_user.blog_id = '".(int)$blog_id."'
1459 1458
 				ORDER BY target_date ASC";
1460
-		$result = Database::query($sql);
1459
+        $result = Database::query($sql);
1461 1460
 
1462
-		while ($assignment = Database::fetch_array($result)) {
1463
-			$counter++;
1464
-			$css_class = (($counter % 2)==0) ? "row_odd" : "row_even";
1465
-			$delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
1466
-			$delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1467
-			$delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id'];
1468
-			$delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1461
+        while ($assignment = Database::fetch_array($result)) {
1462
+            $counter++;
1463
+            $css_class = (($counter % 2)==0) ? "row_odd" : "row_even";
1464
+            $delete_icon = ($assignment['system_task'] == '1') ? "delete_na.gif" : "delete.gif";
1465
+            $delete_title = ($assignment['system_task'] == '1') ? get_lang('DeleteSystemTask') : get_lang('DeleteTask');
1466
+            $delete_link = ($assignment['system_task'] == '1') ? '#' : api_get_self() . '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete&task_id=' . $assignment['task_id'];
1467
+            $delete_confirm = ($assignment['system_task'] == '1') ? '' : 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"';
1469 1468
 
1470 1469
             $username = api_htmlentities(sprintf(get_lang('LoginX'), $assignment['username']), ENT_QUOTES);
1471 1470
 
1472
-			echo	'<tr class="' . $css_class . '" valign="top">',
1473
-						 '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>',
1474
-						 '<td>'.stripslashes($assignment['title']) . '</td>',
1475
-						 '<td>'.stripslashes($assignment['description']) . '</td>',
1476
-						 '<td>' . $assignment['target_date'] . '</td>',
1477
-						 '<td width="50">',
1478
-						 	'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=edit_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '">',
1479
-							'<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
1480
-							"</a>\n",
1481
-							'<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '" ',
1482
-							'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"',
1483
-							'<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
1484
-							"</a>\n",
1485
-						 '</td>',
1486
-					'</tr>';
1487
-		}
1488
-		echo "</table>";
1489
-	}
1490
-
1491
-	/**
1492
-	 * Displays new task form
1493
-	 * @author Toon Keppens
1494
-	 *
1495
-	 */
1496
-	public static function display_new_task_form ($blog_id)
1497
-	{
1498
-		// Init
1471
+            echo	'<tr class="' . $css_class . '" valign="top">',
1472
+                            '<td width="240">' . Display::tag('span', api_get_person_name($assignment['firstname'], $assignment['lastname']), array('title'=>$username)) . '</td>',
1473
+                            '<td>'.stripslashes($assignment['title']) . '</td>',
1474
+                            '<td>'.stripslashes($assignment['description']) . '</td>',
1475
+                            '<td>' . $assignment['target_date'] . '</td>',
1476
+                            '<td width="50">',
1477
+                                '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=edit_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '">',
1478
+                            '<img src="../img/edit.gif" border="0" title="' . get_lang('EditTask') . '" />',
1479
+                            "</a>\n",
1480
+                            '<a href="' .api_get_self(). '?action=manage_tasks&blog_id=' . $assignment['blog_id'] . '&do=delete_assignment&task_id=' . $assignment['task_id'] . '&user_id=' . $assignment['user_id'] . '" ',
1481
+                            'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;"',
1482
+                            '<img src="../img/' . $delete_icon . '" border="0" title="' . $delete_title . '" />',
1483
+                            "</a>\n",
1484
+                            '</td>',
1485
+                    '</tr>';
1486
+        }
1487
+        echo "</table>";
1488
+    }
1489
+
1490
+    /**
1491
+     * Displays new task form
1492
+     * @author Toon Keppens
1493
+     *
1494
+     */
1495
+    public static function display_new_task_form ($blog_id)
1496
+    {
1497
+        // Init
1499 1498
         $colors = array(
1500 1499
             'FFFFFF',
1501 1500
             'FFFF99',
@@ -1514,14 +1513,14 @@  discard block
 block discarded – undo
1514 1513
             '000000'
1515 1514
         );
1516 1515
 
1517
-		// form
1518
-		echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">';
1516
+        // form
1517
+        echo '<form name="add_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">';
1519 1518
 
1520
-		// form title
1521
-		echo '<legend>'.get_lang('AddTask').'</legend>';
1519
+        // form title
1520
+        echo '<legend>'.get_lang('AddTask').'</legend>';
1522 1521
 
1523
-		// task title
1524
-		echo '	<div class="control-group">
1522
+        // task title
1523
+        echo '	<div class="control-group">
1525 1524
 					<label class="control-label">
1526 1525
 						<span class="form_required">*</span>' . get_lang('Title') . '
1527 1526
 					</label>
@@ -1530,8 +1529,8 @@  discard block
 block discarded – undo
1530 1529
 					</div>
1531 1530
 				</div>';
1532 1531
 
1533
-		// task comment
1534
-		echo '	<div class="control-group">
1532
+        // task comment
1533
+        echo '	<div class="control-group">
1535 1534
 					<label class="control-label">
1536 1535
 						' . get_lang('Description') . '
1537 1536
 					</label>
@@ -1540,8 +1539,8 @@  discard block
 block discarded – undo
1540 1539
 					</div>
1541 1540
 				</div>';
1542 1541
 
1543
-		// task management
1544
-		echo '	<div class="control-group">
1542
+        // task management
1543
+        echo '	<div class="control-group">
1545 1544
 					<label class="control-label">
1546 1545
 						' . get_lang('TaskManager') . '
1547 1546
 					</label>
@@ -1562,12 +1561,12 @@  discard block
 block discarded – undo
1562 1561
                         echo '<td style="border:1px dotted #808080; text-align:center;"><input id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>';
1563 1562
                     echo '</tr>';
1564 1563
                 echo '</table>';
1565
-		echo '		</div>
1564
+        echo '		</div>
1566 1565
 				</div>';
1567 1566
 
1568 1567
 
1569
-		// task color
1570
-		echo '	<div class="control-group">
1568
+        // task color
1569
+        echo '	<div class="control-group">
1571 1570
 					<label class="control-label">
1572 1571
 						' . get_lang('Color') . '
1573 1572
 					</label>
@@ -1578,40 +1577,40 @@  discard block
 block discarded – undo
1578 1577
                     echo '<option value="' . $color . '" ' . $style . '>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1579 1578
                 }
1580 1579
         echo '</select>';
1581
-		echo '		</div>
1580
+        echo '		</div>
1582 1581
 				</div>';
1583 1582
 
1584
-		// submit
1585
-		echo '	<div class="control-group">
1583
+        // submit
1584
+        echo '	<div class="control-group">
1586 1585
 					<div class="controls">
1587 1586
 							<input type="hidden" name="action" value="" />
1588 1587
 							<input type="hidden" name="new_task_submit" value="true" />
1589 1588
 						<button class="save" type="submit" name="Submit">' . get_lang('Save') . '</button>
1590 1589
 					</div>
1591 1590
 				</div>';
1592
-		echo '</form>';
1591
+        echo '</form>';
1593 1592
 
1594
-		echo '<div style="clear:both; margin-bottom: 10px;"></div>';
1595
-	}
1593
+        echo '<div style="clear:both; margin-bottom: 10px;"></div>';
1594
+    }
1596 1595
 
1597 1596
 
1598
-	/**
1599
-	 * Displays edit task form
1600
-	 * @author Toon Keppens
1601
-	 *
1602
-	 */
1603
-	public static function display_edit_task_form ($blog_id, $task_id) {
1604
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1597
+    /**
1598
+     * Displays edit task form
1599
+     * @author Toon Keppens
1600
+     *
1601
+     */
1602
+    public static function display_edit_task_form ($blog_id, $task_id) {
1603
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1605 1604
         $course_id = api_get_course_int_id();
1606 1605
 
1607
-		$colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000');
1606
+        $colors = array('FFFFFF','FFFF99','FFCC99','FF9933','FF6699','CCFF99','CC9966','66FF00', '9966FF', 'CF3F3F', '990033','669933','0033FF','003366','000000');
1608 1607
 
1609
-		$sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'";
1610
-		$result = Database::query($sql);
1611
-		$task = Database::fetch_array($result);
1608
+        $sql = "SELECT blog_id, task_id, title, description, color FROM $tbl_blogs_tasks WHERE c_id = $course_id AND task_id = '".(int)$task_id."'";
1609
+        $result = Database::query($sql);
1610
+        $task = Database::fetch_array($result);
1612 1611
 
1613
-		// Display
1614
-		echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">
1612
+        // Display
1613
+        echo '<form name="edit_task" method="post" action="blog.php?action=manage_tasks&blog_id=' . $blog_id . '">
1615 1614
 					<legend>' . get_lang('EditTask') . '</legend>
1616 1615
 					<table width="100%" border="0" cellspacing="2">
1617 1616
 						<tr>
@@ -1623,42 +1622,42 @@  discard block
 block discarded – undo
1623 1622
 					   <td><textarea name="task_description" cols="45">'.Security::remove_XSS($task['description']).'</textarea></td>
1624 1623
 						</tr>';
1625 1624
 
1626
-						/* edit by Kevin Van Den Haute ([email protected]) */
1627
-						$tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
1625
+                        /* edit by Kevin Van Den Haute ([email protected]) */
1626
+                        $tbl_tasks_permissions = Database::get_course_table(TABLE_BLOGS_TASKS_PERMISSIONS);
1628 1627
 
1629
-						$sql = " SELECT id, action FROM " . $tbl_tasks_permissions . "
1628
+                        $sql = " SELECT id, action FROM " . $tbl_tasks_permissions . "
1630 1629
 							     WHERE c_id = $course_id AND task_id = '" . (int)$task_id."'";
1631
-						$result = Database::query($sql);
1632
-
1633
-						$arrPermissions = array();
1634
-
1635
-						while ($row = Database::fetch_array($result))
1636
-							$arrPermissions[] = $row['action'];
1637
-
1638
-						    echo '<tr>';
1639
-							echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ':&nbsp;&nbsp;</td>';
1640
-							echo '<td>';
1641
-								echo '<table  class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">';
1642
-									echo '<tr>';
1643
-										echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>';
1644
-										echo '<th width:223px;>' . get_lang('CommentManager') . '</th>';
1645
-									echo '</tr>';
1646
-									echo '<tr>';
1647
-										echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>';
1648
-										echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>';
1649
-										echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>';
1650
-									echo '</tr>';
1651
-									echo '<tr>';
1652
-										echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>';
1653
-										echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>';
1654
-										echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>';
1655
-									echo '</tr>';
1656
-								echo '</table>';
1657
-							echo '</td>';
1658
-						echo '</tr>';
1659
-						/* end of edit */
1660
-
1661
-						echo '<tr>
1630
+                        $result = Database::query($sql);
1631
+
1632
+                        $arrPermissions = array();
1633
+
1634
+                        while ($row = Database::fetch_array($result))
1635
+                            $arrPermissions[] = $row['action'];
1636
+
1637
+                            echo '<tr>';
1638
+                            echo '<td style="text-align:right; vertical-align:top;">' . get_lang('TaskManager') . ':&nbsp;&nbsp;</td>';
1639
+                            echo '<td>';
1640
+                                echo '<table  class="data_table" cellspacing="0" style="border-collapse:collapse; width:446px;">';
1641
+                                    echo '<tr>';
1642
+                                        echo '<th colspan="2" style="width:223px;">' . get_lang('ArticleManager') . '</th>';
1643
+                                        echo '<th width:223px;>' . get_lang('CommentManager') . '</th>';
1644
+                                    echo '</tr>';
1645
+                                    echo '<tr>';
1646
+                                        echo '<th style="width:111px;"><label for="articleDelete">' . get_lang('Delete') . '</label></th>';
1647
+                                        echo '<th style="width:112px;"><label for="articleEdit">' . get_lang('Edit') . '</label></th>';
1648
+                                        echo '<th style="width:223px;"><label for="commentsDelete">' . get_lang('Delete') . '</label></th>';
1649
+                                    echo '</tr>';
1650
+                                    echo '<tr>';
1651
+                                        echo '<td style="text-align:center;"><input ' . ((in_array('article_delete', $arrPermissions)) ? 'checked ' : '') . 'id="articleDelete" name="chkArticleDelete" type="checkbox" /></td>';
1652
+                                        echo '<td style="text-align:center;"><input ' . ((in_array('article_edit', $arrPermissions)) ? 'checked ' : '') . 'id="articleEdit" name="chkArticleEdit" type="checkbox" /></td>';
1653
+                                        echo '<td style="text-align:center;"><input ' . ((in_array('article_comments_delete', $arrPermissions)) ? 'checked ' : '') . 'id="commentsDelete" name="chkCommentsDelete" type="checkbox" /></td>';
1654
+                                    echo '</tr>';
1655
+                                echo '</table>';
1656
+                            echo '</td>';
1657
+                        echo '</tr>';
1658
+                        /* end of edit */
1659
+
1660
+                        echo '<tr>
1662 1661
 					   <td align="right">' . get_lang('Color') . ':&nbsp;&nbsp;</td>
1663 1662
 					   <td>
1664 1663
 					   	<select name="task_color" id="color" style="width: 150px; background-color: #' . $task['color'] . '" onchange="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value" onkeypress="document.getElementById(\'color\').style.backgroundColor=\'#\'+document.getElementById(\'color\').value">';
@@ -1667,7 +1666,7 @@  discard block
 block discarded – undo
1667 1666
                                 $style = 'style="background-color: #' . $color . '"';
1668 1667
                                 echo '<option value="' . $color . '" ' . $style . ' ' . $selected . ' >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</option>';
1669 1668
                             }
1670
-		echo '			   </select>
1669
+        echo '			   </select>
1671 1670
 						  </td>
1672 1671
 						</tr>
1673 1672
 						<tr>
@@ -1680,34 +1679,34 @@  discard block
 block discarded – undo
1680 1679
 						</tr>
1681 1680
 					</table>
1682 1681
 				</form>';
1683
-	}
1684
-
1685
-	/**
1686
-	 * @param $blog_id
1687
-	 * @return FormValidator
1688
-	 */
1689
-	public static function getTaskForm($blog_id)
1690
-	{
1691
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1692
-		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
1693
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1694
-		$course_id = api_get_course_int_id();
1695
-
1696
-		// Get users in this blog / make select list of it
1697
-		$sql = "SELECT user.user_id, user.firstname, user.lastname, user.username
1682
+    }
1683
+
1684
+    /**
1685
+     * @param $blog_id
1686
+     * @return FormValidator
1687
+     */
1688
+    public static function getTaskForm($blog_id)
1689
+    {
1690
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1691
+        $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
1692
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1693
+        $course_id = api_get_course_int_id();
1694
+
1695
+        // Get users in this blog / make select list of it
1696
+        $sql = "SELECT user.user_id, user.firstname, user.lastname, user.username
1698 1697
 				FROM $tbl_users user
1699 1698
 				INNER JOIN $tbl_blogs_rel_user blogs_rel_user
1700 1699
 				ON user.user_id = blogs_rel_user.user_id
1701 1700
 				WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".(int)$blog_id."'";
1702
-		$result = Database::query($sql);
1701
+        $result = Database::query($sql);
1703 1702
 
1704
-		$options = array();
1705
-		while ($user = Database::fetch_array($result)) {
1706
-			$options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
1707
-		}
1703
+        $options = array();
1704
+        while ($user = Database::fetch_array($result)) {
1705
+            $options[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']);
1706
+        }
1708 1707
 
1709
-		// Get tasks in this blog / make select list of it
1710
-		$sql = "
1708
+        // Get tasks in this blog / make select list of it
1709
+        $sql = "
1711 1710
 			SELECT
1712 1711
 				blog_id,
1713 1712
 				task_id,
@@ -1719,97 +1718,97 @@  discard block
 block discarded – undo
1719 1718
 			FROM $tbl_blogs_tasks
1720 1719
 			WHERE c_id = $course_id AND blog_id = " . (int)$blog_id . "
1721 1720
 			ORDER BY system_task, title";
1722
-		$result = Database::query($sql);
1723
-
1724
-		$taskOptions = array();
1725
-		while ($task = Database::fetch_array($result)) {
1726
-			$taskOptions[$task['task_id']] = stripslashes($task['title']);
1727
-		}
1728
-
1729
-		$form = new FormValidator(
1730
-			'assign_task',
1731
-			'post',
1732
-			api_get_path(
1733
-				WEB_CODE_PATH
1734
-			).'blog/blog.php?action=manage_tasks&blog_id='.$blog_id
1735
-		);
1736
-
1737
-		$form->addHeader(get_lang('AssignTask'));
1738
-		$form->addSelect('task_user_id', get_lang('SelectUser'), $options);
1739
-		$form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions);
1740
-		$form->addDatePicker('task_day', get_lang('SelectTargetDate'));
1741
-
1742
-		$form->addHidden('action', '');
1743
-		$form->addButtonSave(get_lang('Ok'));
1744
-
1745
-		return $form;
1746
-	}
1747
-
1748
-	/**
1749
-	 * Displays assign task form
1750
-	 * @author Toon Keppens
1751
-	 *
1752
-	 */
1753
-	public static function display_assign_task_form($blog_id)
1754
-	{
1755
-		$form = self::getTaskForm($blog_id);
1756
-		$form->addHidden('assign_task_submit', 'true');
1757
-		$form->display();
1758
-		echo '<div style="clear: both; margin-bottom:10px;"></div>';
1759
-	}
1760
-
1761
-	/**
1762
-	 * Displays assign task form
1763
-	 * @author Toon Keppens
1764
-	 *
1765
-	 */
1766
-	public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id)
1767
-	{
1768
-		$tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1769
-
1770
-		$course_id = api_get_course_int_id();
1771
-
1772
-		// Get assignd date;
1773
-		$sql = "
1721
+        $result = Database::query($sql);
1722
+
1723
+        $taskOptions = array();
1724
+        while ($task = Database::fetch_array($result)) {
1725
+            $taskOptions[$task['task_id']] = stripslashes($task['title']);
1726
+        }
1727
+
1728
+        $form = new FormValidator(
1729
+            'assign_task',
1730
+            'post',
1731
+            api_get_path(
1732
+                WEB_CODE_PATH
1733
+            ).'blog/blog.php?action=manage_tasks&blog_id='.$blog_id
1734
+        );
1735
+
1736
+        $form->addHeader(get_lang('AssignTask'));
1737
+        $form->addSelect('task_user_id', get_lang('SelectUser'), $options);
1738
+        $form->addSelect('task_task_id', get_lang('SelectTask'), $taskOptions);
1739
+        $form->addDatePicker('task_day', get_lang('SelectTargetDate'));
1740
+
1741
+        $form->addHidden('action', '');
1742
+        $form->addButtonSave(get_lang('Ok'));
1743
+
1744
+        return $form;
1745
+    }
1746
+
1747
+    /**
1748
+     * Displays assign task form
1749
+     * @author Toon Keppens
1750
+     *
1751
+     */
1752
+    public static function display_assign_task_form($blog_id)
1753
+    {
1754
+        $form = self::getTaskForm($blog_id);
1755
+        $form->addHidden('assign_task_submit', 'true');
1756
+        $form->display();
1757
+        echo '<div style="clear: both; margin-bottom:10px;"></div>';
1758
+    }
1759
+
1760
+    /**
1761
+     * Displays assign task form
1762
+     * @author Toon Keppens
1763
+     *
1764
+     */
1765
+    public static function display_edit_assigned_task_form($blog_id, $task_id, $user_id)
1766
+    {
1767
+        $tbl_blogs_tasks_rel_user 	= Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1768
+
1769
+        $course_id = api_get_course_int_id();
1770
+
1771
+        // Get assignd date;
1772
+        $sql = "
1774 1773
 			SELECT target_date
1775 1774
 			FROM $tbl_blogs_tasks_rel_user
1776 1775
 			WHERE c_id = $course_id AND
1777 1776
 			      blog_id = '".(int)$blog_id."' AND
1778 1777
 			      user_id = '".(int)$user_id."' AND
1779 1778
 			      task_id = '".(int)$task_id."'";
1780
-		$result = Database::query($sql);
1781
-		$row = Database::fetch_assoc($result);
1782
-
1783
-		$date = $row['target_date'];
1784
-
1785
-		$defaults = [
1786
-			'task_user_id' => $user_id,
1787
-			'task_task_id' => $task_id,
1788
-			'task_day' => $date
1789
-		];
1790
-		$form = self::getTaskForm($blog_id);
1791
-		$form->addHidden('old_task_id', $task_id);
1792
-		$form->addHidden('old_user_id', $user_id);
1793
-		$form->addHidden('old_target_date', $date);
1794
-		$form->addHidden('assign_task_edit_submit', 'true');
1795
-		$form->setDefaults($defaults);
1796
-		$form->display();
1797
-	}
1798
-
1799
-	/**
1800
-	 * Assigns a task to a user in a blog
1801
-	 *
1802
-	 * @param Integer $blog_id
1803
-	 * @param Integer $user_id
1804
-	 * @param Integer $task_id
1805
-	 * @param Date $target_date
1806
-	 */
1807
-	public static function assign_task($blog_id, $user_id, $task_id, $target_date)
1808
-	{
1809
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1810
-		$course_id = api_get_course_int_id();
1811
-
1812
-		$sql = "
1779
+        $result = Database::query($sql);
1780
+        $row = Database::fetch_assoc($result);
1781
+
1782
+        $date = $row['target_date'];
1783
+
1784
+        $defaults = [
1785
+            'task_user_id' => $user_id,
1786
+            'task_task_id' => $task_id,
1787
+            'task_day' => $date
1788
+        ];
1789
+        $form = self::getTaskForm($blog_id);
1790
+        $form->addHidden('old_task_id', $task_id);
1791
+        $form->addHidden('old_user_id', $user_id);
1792
+        $form->addHidden('old_target_date', $date);
1793
+        $form->addHidden('assign_task_edit_submit', 'true');
1794
+        $form->setDefaults($defaults);
1795
+        $form->display();
1796
+    }
1797
+
1798
+    /**
1799
+     * Assigns a task to a user in a blog
1800
+     *
1801
+     * @param Integer $blog_id
1802
+     * @param Integer $user_id
1803
+     * @param Integer $task_id
1804
+     * @param Date $target_date
1805
+     */
1806
+    public static function assign_task($blog_id, $user_id, $task_id, $target_date)
1807
+    {
1808
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1809
+        $course_id = api_get_course_int_id();
1810
+
1811
+        $sql = "
1813 1812
 			SELECT COUNT(*) as 'number'
1814 1813
 			FROM " . $tbl_blogs_tasks_rel_user . "
1815 1814
 			WHERE c_id = $course_id AND
@@ -1818,11 +1817,11 @@  discard block
 block discarded – undo
1818 1817
 			AND	task_id = " . (int)$task_id . "
1819 1818
 		";
1820 1819
 
1821
-		$result = Database::query($sql);
1822
-		$row = Database::fetch_assoc($result);
1820
+        $result = Database::query($sql);
1821
+        $row = Database::fetch_assoc($result);
1823 1822
 
1824
-		if ($row['number'] == 0) {
1825
-			$sql = "
1823
+        if ($row['number'] == 0) {
1824
+            $sql = "
1826 1825
 				INSERT INTO " . $tbl_blogs_tasks_rel_user . " (
1827 1826
 					c_id,
1828 1827
 					blog_id,
@@ -1837,9 +1836,9 @@  discard block
 block discarded – undo
1837 1836
 					'" . Database::escape_string($target_date) . "'
1838 1837
 				)";
1839 1838
 
1840
-			Database::query($sql);
1841
-		}
1842
-	}
1839
+            Database::query($sql);
1840
+        }
1841
+    }
1843 1842
 
1844 1843
     /**
1845 1844
      * @param $blog_id
@@ -1859,11 +1858,11 @@  discard block
 block discarded – undo
1859 1858
         $old_task_id,
1860 1859
         $old_target_date
1861 1860
     ) {
1862
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1861
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
1863 1862
 
1864
-		$course_id = api_get_course_int_id();
1863
+        $course_id = api_get_course_int_id();
1865 1864
 
1866
-		$sql = "SELECT COUNT(*) as 'number'
1865
+        $sql = "SELECT COUNT(*) as 'number'
1867 1866
                 FROM " . $tbl_blogs_tasks_rel_user . "
1868 1867
                 WHERE
1869 1868
                     c_id = $course_id AND
@@ -1872,11 +1871,11 @@  discard block
 block discarded – undo
1872 1871
                     task_id = " . (int)$task_id . "
1873 1872
             ";
1874 1873
 
1875
-		$result = Database::query($sql);
1876
-		$row = Database::fetch_assoc($result);
1874
+        $result = Database::query($sql);
1875
+        $row = Database::fetch_assoc($result);
1877 1876
 
1878
-		if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) {
1879
-			$sql = "
1877
+        if ($row['number'] == 0 || ($row['number'] != 0 && $task_id == $old_task_id && $user_id == $old_user_id)) {
1878
+            $sql = "
1880 1879
 				UPDATE " . $tbl_blogs_tasks_rel_user . "
1881 1880
 				SET
1882 1881
 					user_id = " . (int)$user_id . ",
@@ -1889,76 +1888,76 @@  discard block
 block discarded – undo
1889 1888
 					task_id = " . (int)$old_task_id . " AND
1890 1889
 					target_date = '" . Database::escape_string($old_target_date) . "'
1891 1890
 			";
1892
-			Database::query($sql);
1893
-		}
1894
-	}
1895
-
1896
-	/**
1897
-	 * Displays a list with posts a user can select to execute his task.
1898
-	 *
1899
-	 * @param Integer $blog_id
1900
-	 * @param unknown_type $task_id
1901
-	 */
1902
-	public static function display_select_task_post($blog_id, $task_id)
1891
+            Database::query($sql);
1892
+        }
1893
+    }
1894
+
1895
+    /**
1896
+     * Displays a list with posts a user can select to execute his task.
1897
+     *
1898
+     * @param Integer $blog_id
1899
+     * @param unknown_type $task_id
1900
+     */
1901
+    public static function display_select_task_post($blog_id, $task_id)
1903 1902
     {
1904
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1905
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
1906
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1907
-		$course_id = api_get_course_int_id();
1903
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
1904
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
1905
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
1906
+        $course_id = api_get_course_int_id();
1908 1907
 
1909 1908
 
1910
-		$sql = "SELECT title, description FROM $tbl_blogs_tasks
1909
+        $sql = "SELECT title, description FROM $tbl_blogs_tasks
1911 1910
 				WHERE task_id = '".(int)$task_id."'
1912 1911
 				AND c_id = $course_id";
1913
-		$result = Database::query($sql);
1914
-		$row = Database::fetch_assoc($result);
1915
-		// Get posts and authors
1916
-		$sql = "SELECT post.*, user.lastname, user.firstname, user.username
1912
+        $result = Database::query($sql);
1913
+        $row = Database::fetch_assoc($result);
1914
+        // Get posts and authors
1915
+        $sql = "SELECT post.*, user.lastname, user.firstname, user.username
1917 1916
 				FROM $tbl_blogs_posts post
1918 1917
 				INNER JOIN $tbl_users user ON post.author_id = user.user_id
1919 1918
 				WHERE post.blog_id = '".(int)$blog_id."' AND post.c_id = $course_id
1920 1919
 				ORDER BY post_id DESC
1921 1920
 				LIMIT 0, 100";
1922
-		$result = Database::query($sql);
1921
+        $result = Database::query($sql);
1923 1922
 
1924
-		// Display
1925
-		echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>';
1926
-		echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>';
1923
+        // Display
1924
+        echo '<span class="blogpost_title">' . get_lang('SelectTaskArticle') . ' "' . stripslashes($row['title']) . '"</span>';
1925
+        echo '<span style="font-style: italic;"">'.stripslashes($row['description']) . '</span><br><br>';
1927 1926
 
1928
-		if (Database::num_rows($result) > 0) {
1929
-			while($blog_post = Database::fetch_array($result)) {
1930
-			    $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
1931
-				echo '<a href="blog.php?action=execute_task&blog_id=' . $blog_id . '&task_id=' . $task_id . '&post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />';
1932
-			}
1927
+        if (Database::num_rows($result) > 0) {
1928
+            while($blog_post = Database::fetch_array($result)) {
1929
+                $username = api_htmlentities(sprintf(get_lang('LoginX'), $blog_post['username']), ENT_QUOTES);
1930
+                echo '<a href="blog.php?action=execute_task&blog_id=' . $blog_id . '&task_id=' . $task_id . '&post_id=' . $blog_post['post_id'] . '#add_comment">'.stripslashes($blog_post['title']) . '</a>, ' . get_lang('WrittenBy') . ' ' . stripslashes(Display::tag('span', api_get_person_name($blog_post['firstname'], $blog_post['lastname']), array('title'=>$username))) . '<br />';
1931
+            }
1933 1932
         } else {
1934 1933
             echo get_lang('NoArticles');
1935 1934
         }
1936
-	}
1937
-
1938
-	/**
1939
-	 * Subscribes a user to a given blog
1940
-	 * @author Toon Keppens
1941
-	 *
1942
-	 * @param Integer $blog_id
1943
-	 * @param Integer $user_id
1944
-	 */
1945
-	public static function set_user_subscribed($blog_id, $user_id)
1935
+    }
1936
+
1937
+    /**
1938
+     * Subscribes a user to a given blog
1939
+     * @author Toon Keppens
1940
+     *
1941
+     * @param Integer $blog_id
1942
+     * @param Integer $user_id
1943
+     */
1944
+    public static function set_user_subscribed($blog_id, $user_id)
1946 1945
     {
1947
-		// Init
1948
-		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
1949
-		$tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER);
1946
+        // Init
1947
+        $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
1948
+        $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER);
1950 1949
 
1951
-		$course_id = api_get_course_int_id();
1950
+        $course_id = api_get_course_int_id();
1952 1951
 
1953
-		// Subscribe the user
1954
-		$sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id )
1952
+        // Subscribe the user
1953
+        $sql = "INSERT INTO $tbl_blogs_rel_user (c_id, blog_id, user_id )
1955 1954
 		        VALUES ($course_id, '".(int)$blog_id."', '".(int)$user_id."');";
1956
-		Database::query($sql);
1955
+        Database::query($sql);
1957 1956
 
1958
-		// Give this user basic rights
1959
-		$sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
1957
+        // Give this user basic rights
1958
+        $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
1960 1959
 		        VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_add')";
1961
-		Database::query($sql);
1960
+        Database::query($sql);
1962 1961
 
1963 1962
         $id = Database::insert_id();
1964 1963
         if ($id) {
@@ -1966,9 +1965,9 @@  discard block
 block discarded – undo
1966 1965
             Database::query($sql);
1967 1966
         }
1968 1967
 
1969
-		$sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
1968
+        $sql = "INSERT INTO $tbl_user_permissions (c_id, user_id,tool,action)
1970 1969
 		        VALUES ($course_id, '".(int)$user_id."','BLOG_" . (int)$blog_id."','article_comments_add')";
1971
-		Database::query($sql);
1970
+        Database::query($sql);
1972 1971
 
1973 1972
         $id = Database::insert_id();
1974 1973
         if ($id) {
@@ -1976,197 +1975,197 @@  discard block
 block discarded – undo
1976 1975
             Database::query($sql);
1977 1976
         }
1978 1977
 
1979
-	}
1978
+    }
1980 1979
 
1981
-	/**
1982
-	 * Unsubscribe a user from a given blog
1983
-	 * @author Toon Keppens
1984
-	 *
1985
-	 * @param Integer $blog_id
1986
-	 * @param Integer $user_id
1987
-	 */
1988
-	public static function set_user_unsubscribed($blog_id, $user_id)
1980
+    /**
1981
+     * Unsubscribe a user from a given blog
1982
+     * @author Toon Keppens
1983
+     *
1984
+     * @param Integer $blog_id
1985
+     * @param Integer $user_id
1986
+     */
1987
+    public static function set_user_unsubscribed($blog_id, $user_id)
1989 1988
     {
1990
-		// Init
1989
+        // Init
1991 1990
         $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
1992 1991
         $tbl_user_permissions = Database::get_course_table(TABLE_PERMISSION_USER);
1993 1992
 
1994
-		// Unsubscribe the user
1995
-		$sql = "DELETE FROM $tbl_blogs_rel_user
1993
+        // Unsubscribe the user
1994
+        $sql = "DELETE FROM $tbl_blogs_rel_user
1996 1995
 		        WHERE blog_id = '".(int)$blog_id."' AND user_id = '".(int)$user_id."'";
1997
-		Database::query($sql);
1996
+        Database::query($sql);
1998 1997
 
1999
-		// Remove this user's permissions.
2000
-		$sql = "DELETE FROM $tbl_user_permissions
1998
+        // Remove this user's permissions.
1999
+        $sql = "DELETE FROM $tbl_user_permissions
2001 2000
 		        WHERE user_id = '".(int)$user_id."'";
2002
-		Database::query($sql);
2003
-	}
2004
-
2005
-	/**
2006
-	 * Displays the form to register users in a blog (in a course)
2007
-	 * The listed users are users subcribed in the course.
2008
-	 * @author Toon Keppens
2009
-	 *
2010
-	 * @param Integer $blog_id
2011
-	 *
2012
-	 * @return Html Form with sortable table with users to subcribe in a blog, in a course.
2013
-	 */
2014
-	public static function display_form_user_subscribe($blog_id)
2015
-	{
2016
-		$_course = api_get_course_info();
2017
-		$is_western_name_order = api_is_western_name_order();
2018
-		$session_id = api_get_session_id();
2019
-		$course_id = $_course['real_id'];
2020
-
2021
-		$currentCourse = $_course['code'];
2022
-		$tbl_users 			= Database::get_main_table(TABLE_MAIN_USER);
2023
-		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2024
-
2025
-		echo '<legend>'.get_lang('SubscribeMembers').'</legend>';
2026
-
2027
-		$properties["width"] = "100%";
2028
-
2029
-		// Get blog members' id.
2030
-		$sql = "SELECT user.user_id FROM $tbl_users user
2001
+        Database::query($sql);
2002
+    }
2003
+
2004
+    /**
2005
+     * Displays the form to register users in a blog (in a course)
2006
+     * The listed users are users subcribed in the course.
2007
+     * @author Toon Keppens
2008
+     *
2009
+     * @param Integer $blog_id
2010
+     *
2011
+     * @return Html Form with sortable table with users to subcribe in a blog, in a course.
2012
+     */
2013
+    public static function display_form_user_subscribe($blog_id)
2014
+    {
2015
+        $_course = api_get_course_info();
2016
+        $is_western_name_order = api_is_western_name_order();
2017
+        $session_id = api_get_session_id();
2018
+        $course_id = $_course['real_id'];
2019
+
2020
+        $currentCourse = $_course['code'];
2021
+        $tbl_users 			= Database::get_main_table(TABLE_MAIN_USER);
2022
+        $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2023
+
2024
+        echo '<legend>'.get_lang('SubscribeMembers').'</legend>';
2025
+
2026
+        $properties["width"] = "100%";
2027
+
2028
+        // Get blog members' id.
2029
+        $sql = "SELECT user.user_id FROM $tbl_users user
2031 2030
 				INNER JOIN $tbl_blogs_rel_user blogs_rel_user
2032 2031
 				ON user.user_id = blogs_rel_user.user_id
2033 2032
 				WHERE blogs_rel_user.c_id = $course_id AND blogs_rel_user.blog_id = '".intval($blog_id)."'";
2034
-		$result = Database::query($sql);
2035
-
2036
-		$blog_member_ids = array();
2037
-		while($user = Database::fetch_array($result)) {
2038
-			$blog_member_ids[] = $user['user_id'];
2039
-		}
2040
-
2041
-		// Set table headers
2042
-		$column_header[] = array ('', false, '');
2043
-		if ($is_western_name_order) {
2044
-			$column_header[] = array(get_lang('FirstName'), true, '');
2045
-			$column_header[] = array(get_lang('LastName'), true, '');
2046
-		} else {
2047
-			$column_header[] = array(get_lang('LastName'), true, '');
2048
-			$column_header[] = array(get_lang('FirstName'), true, '');
2049
-		}
2050
-		$column_header[] = array(get_lang('Email'), false, '');
2051
-		$column_header[] = array(get_lang('Register'), false, '');
2033
+        $result = Database::query($sql);
2034
+
2035
+        $blog_member_ids = array();
2036
+        while($user = Database::fetch_array($result)) {
2037
+            $blog_member_ids[] = $user['user_id'];
2038
+        }
2039
+
2040
+        // Set table headers
2041
+        $column_header[] = array ('', false, '');
2042
+        if ($is_western_name_order) {
2043
+            $column_header[] = array(get_lang('FirstName'), true, '');
2044
+            $column_header[] = array(get_lang('LastName'), true, '');
2045
+        } else {
2046
+            $column_header[] = array(get_lang('LastName'), true, '');
2047
+            $column_header[] = array(get_lang('FirstName'), true, '');
2048
+        }
2049
+        $column_header[] = array(get_lang('Email'), false, '');
2050
+        $column_header[] = array(get_lang('Register'), false, '');
2052 2051
 
2053 2052
         $student_list = CourseManager:: get_student_list_from_course_code(
2054 2053
             $currentCourse,
2055 2054
             false,
2056 2055
             $session_id
2057 2056
         );
2058
-		$user_data = array();
2059
-
2060
-		// Add users that are not in this blog to the list.
2061
-		foreach ($student_list as $key=>$user) {
2062
-			if(isset($user['id_user'])) {
2063
-				$user['user_id'] = $user['id_user'];
2064
-			}
2065
-			if(!in_array($user['user_id'],$blog_member_ids)) {
2066
-				$a_infosUser = api_get_user_info($user['user_id']);
2067
-				$row = array ();
2068
-				$row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>';
2069
-				$username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES);
2070
-				if ($is_western_name_order) {
2071
-					$row[] = $a_infosUser["firstname"];
2072
-					$row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username));
2073
-				} else {
2074
-					$row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username));
2075
-					$row[] = $a_infosUser["firstname"];
2076
-				}
2077
-				$row[] = Display::icon_mailto_link($a_infosUser["email"]);
2078
-
2079
-				//Link to register users
2080
-				if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){
2081
-					$row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&register=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>";
2082
-				} else {
2083
-					$row[] = '';
2084
-				}
2085
-				$user_data[] = $row;
2086
-			}
2087
-		}
2088
-
2089
-		// Display
2090
-		$query_vars['action'] = 'manage_members';
2091
-		$query_vars['blog_id'] = $blog_id;
2092
-		echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
2093
-			Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2094
-			$link = '';
2095
-			$link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : '';
2096
-			$link .= "blog_id=$blog_id&";
2097
-
2098
-			echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - ';
2099
-			echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
2100
-			echo get_lang('WithSelected') . ' : ';
2101
-			echo '<select name="action">';
2102
-			echo '<option value="select_subscribe">' . get_lang('Register') . '</option>';
2103
-			echo '</select>';
2104
-			echo '<input type="hidden" name="register" value="true" />';
2105
-			echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2106
-		echo '</form>';
2107
-	}
2108
-
2109
-	/**
2110
-	 * Displays the form to register users in a blog (in a course)
2111
-	 * The listed users are users subcribed in the course.
2112
-	 * @author Toon Keppens
2113
-	 *
2114
-	 * @param Integer $blog_id
2115
-	 *
2116
-	 * @return Html Form with sortable table with users to unsubcribe from a blog.
2117
-	 */
2118
-	public static function display_form_user_unsubscribe ($blog_id)
2119
-	{
2120
-		$_user = api_get_user_info();
2121
-		$is_western_name_order = api_is_western_name_order();
2122
-
2123
-		// Init
2124
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2125
-		$tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2126
-
2127
-		echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>';
2128
-
2129
-		$properties["width"] = "100%";
2130
-		//table column titles
2131
-		$column_header[] = array ('', false, '');
2132
-		if ($is_western_name_order) {
2133
-			$column_header[] = array (get_lang('FirstName'), true, '');
2134
-			$column_header[] = array (get_lang('LastName'), true, '');
2135
-		} else {
2136
-			$column_header[] = array (get_lang('LastName'), true, '');
2137
-			$column_header[] = array (get_lang('FirstName'), true, '');
2138
-		}
2139
-		$column_header[] = array (get_lang('Email'), false, '');
2140
-		$column_header[] = array (get_lang('TaskManager'), true, '');
2141
-		$column_header[] = array (get_lang('UnRegister'), false, '');
2142
-
2143
-		$course_id = api_get_course_int_id();
2144
-
2145
-		$sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username
2057
+        $user_data = array();
2058
+
2059
+        // Add users that are not in this blog to the list.
2060
+        foreach ($student_list as $key=>$user) {
2061
+            if(isset($user['id_user'])) {
2062
+                $user['user_id'] = $user['id_user'];
2063
+            }
2064
+            if(!in_array($user['user_id'],$blog_member_ids)) {
2065
+                $a_infosUser = api_get_user_info($user['user_id']);
2066
+                $row = array ();
2067
+                $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "subscribe") ? ' checked="checked" ' : '') . '/>';
2068
+                $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES);
2069
+                if ($is_western_name_order) {
2070
+                    $row[] = $a_infosUser["firstname"];
2071
+                    $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username));
2072
+                } else {
2073
+                    $row[] = Display::tag('span', $a_infosUser["lastname"], array('title'=>$username));
2074
+                    $row[] = $a_infosUser["firstname"];
2075
+                }
2076
+                $row[] = Display::icon_mailto_link($a_infosUser["email"]);
2077
+
2078
+                //Link to register users
2079
+                if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']){
2080
+                    $row[] = "<a class=\"btn btn-primary \" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&register=yes&user_id=" . $a_infosUser["user_id"]."\">" . get_lang('Register')."</a>";
2081
+                } else {
2082
+                    $row[] = '';
2083
+                }
2084
+                $user_data[] = $row;
2085
+            }
2086
+        }
2087
+
2088
+        // Display
2089
+        $query_vars['action'] = 'manage_members';
2090
+        $query_vars['blog_id'] = $blog_id;
2091
+        echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
2092
+            Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2093
+            $link = '';
2094
+            $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : '';
2095
+            $link .= "blog_id=$blog_id&";
2096
+
2097
+            echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - ';
2098
+            echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
2099
+            echo get_lang('WithSelected') . ' : ';
2100
+            echo '<select name="action">';
2101
+            echo '<option value="select_subscribe">' . get_lang('Register') . '</option>';
2102
+            echo '</select>';
2103
+            echo '<input type="hidden" name="register" value="true" />';
2104
+            echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2105
+        echo '</form>';
2106
+    }
2107
+
2108
+    /**
2109
+     * Displays the form to register users in a blog (in a course)
2110
+     * The listed users are users subcribed in the course.
2111
+     * @author Toon Keppens
2112
+     *
2113
+     * @param Integer $blog_id
2114
+     *
2115
+     * @return Html Form with sortable table with users to unsubcribe from a blog.
2116
+     */
2117
+    public static function display_form_user_unsubscribe ($blog_id)
2118
+    {
2119
+        $_user = api_get_user_info();
2120
+        $is_western_name_order = api_is_western_name_order();
2121
+
2122
+        // Init
2123
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2124
+        $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER);
2125
+
2126
+        echo '<legend>'.get_lang('UnsubscribeMembers').'</legend>';
2127
+
2128
+        $properties["width"] = "100%";
2129
+        //table column titles
2130
+        $column_header[] = array ('', false, '');
2131
+        if ($is_western_name_order) {
2132
+            $column_header[] = array (get_lang('FirstName'), true, '');
2133
+            $column_header[] = array (get_lang('LastName'), true, '');
2134
+        } else {
2135
+            $column_header[] = array (get_lang('LastName'), true, '');
2136
+            $column_header[] = array (get_lang('FirstName'), true, '');
2137
+        }
2138
+        $column_header[] = array (get_lang('Email'), false, '');
2139
+        $column_header[] = array (get_lang('TaskManager'), true, '');
2140
+        $column_header[] = array (get_lang('UnRegister'), false, '');
2141
+
2142
+        $course_id = api_get_course_int_id();
2143
+
2144
+        $sql = "SELECT user.user_id, user.lastname, user.firstname, user.email, user.username
2146 2145
                 FROM $tbl_users user INNER JOIN $tbl_blogs_rel_user blogs_rel_user
2147 2146
                 ON user.user_id = blogs_rel_user.user_id
2148 2147
                 WHERE blogs_rel_user.c_id = $course_id AND  blogs_rel_user.blog_id = '".(int)$blog_id."'";
2149 2148
 
2150
-		if (!($sql_result = Database::query($sql))) {
2151
-			return false;
2152
-		}
2153
-
2154
-		$user_data = array ();
2155
-
2156
-		while ($myrow = Database::fetch_array($sql_result)) {
2157
-			$row = array ();
2158
-			$row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>';
2159
-			$username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES);
2160
-			if ($is_western_name_order) {
2161
-				$row[] = $myrow["firstname"];
2162
-				$row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username));
2163
-			} else {
2164
-				$row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username));
2165
-				$row[] = $myrow["firstname"];
2166
-			}
2167
-			$row[] = Display::icon_mailto_link($myrow["email"]);
2168
-
2169
-			$sql = "SELECT bt.title task
2149
+        if (!($sql_result = Database::query($sql))) {
2150
+            return false;
2151
+        }
2152
+
2153
+        $user_data = array ();
2154
+
2155
+        while ($myrow = Database::fetch_array($sql_result)) {
2156
+            $row = array ();
2157
+            $row[] = '<input type="checkbox" name="user[]" value="' . $myrow['user_id'] . '" '.((isset($_GET['selectall']) && $_GET['selectall'] == "unsubscribe") ? ' checked="checked" ' : '') . '/>';
2158
+            $username = api_htmlentities(sprintf(get_lang('LoginX'), $myrow["username"]), ENT_QUOTES);
2159
+            if ($is_western_name_order) {
2160
+                $row[] = $myrow["firstname"];
2161
+                $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username));
2162
+            } else {
2163
+                $row[] = Display::tag('span', $myrow["lastname"], array('title'=>$username));
2164
+                $row[] = $myrow["firstname"];
2165
+            }
2166
+            $row[] = Display::icon_mailto_link($myrow["email"]);
2167
+
2168
+            $sql = "SELECT bt.title task
2170 2169
 					FROM " . Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER) . " btu
2171 2170
 					INNER JOIN " . Database::get_course_table(TABLE_BLOGS_TASKS) . " bt
2172 2171
 					ON btu.task_id = bt.task_id
@@ -2174,158 +2173,158 @@  discard block
 block discarded – undo
2174 2173
 							bt.c_id 	= $course_id  AND
2175 2174
 							btu.blog_id = $blog_id AND
2176 2175
 							btu.user_id = " . $myrow['user_id'];
2177
-			$sql_res = Database::query($sql);
2178
-
2179
-			$task = '';
2180
-
2181
-			while($r = Database::fetch_array($sql_res)) {
2182
-				$task .= stripslashes($r['task']) . ', ';
2183
-			}
2184
-			//echo $task;
2185
-			$task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader');
2186
-			$row[] = $task;
2187
-			//Link to register users
2188
-
2189
-			if ($myrow["user_id"] != $_user['user_id']) {
2190
-				$row[] = "<a class=\"btn btn-primary\" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=" . $myrow['user_id']."\">" . get_lang('UnRegister')."</a>";
2191
-			} else {
2192
-				$row[] = '';
2193
-			}
2194
-
2195
-			$user_data[] = $row;
2196
-		}
2197
-
2198
-		$query_vars['action'] = 'manage_members';
2199
-		$query_vars['blog_id'] = $blog_id;
2200
-		echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
2201
-		Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2202
-		$link = '';
2203
-		$link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : '';
2204
-		$link .= "blog_id=$blog_id&";
2205
-
2206
-		echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - ';
2207
-		echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
2208
-		echo get_lang('WithSelected') . ' : ';
2209
-		echo '<select name="action">';
2210
-		echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>';
2211
-		echo '</select>';
2212
-		echo '<input type="hidden" name="unregister" value="true" />';
2213
-		echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2214
-		echo '</form>';
2215
-	}
2216
-
2217
-	/**
2218
-	 * Displays a matrix with selectboxes. On the left: users, on top: possible rights.
2219
-	 * The blog admin can thus select what a certain user can do in the current blog
2220
-	 *
2221
-	 * @param Integer $blog_id
2222
-	 */
2223
-	public static function display_form_user_rights ($blog_id)
2176
+            $sql_res = Database::query($sql);
2177
+
2178
+            $task = '';
2179
+
2180
+            while($r = Database::fetch_array($sql_res)) {
2181
+                $task .= stripslashes($r['task']) . ', ';
2182
+            }
2183
+            //echo $task;
2184
+            $task = (api_strlen(trim($task)) != 0) ? api_substr($task, 0, api_strlen($task) - 2) : get_lang('Reader');
2185
+            $row[] = $task;
2186
+            //Link to register users
2187
+
2188
+            if ($myrow["user_id"] != $_user['user_id']) {
2189
+                $row[] = "<a class=\"btn btn-primary\" href=\"" .api_get_self()."?action=manage_members&blog_id=$blog_id&unregister=yes&user_id=" . $myrow['user_id']."\">" . get_lang('UnRegister')."</a>";
2190
+            } else {
2191
+                $row[] = '';
2192
+            }
2193
+
2194
+            $user_data[] = $row;
2195
+        }
2196
+
2197
+        $query_vars['action'] = 'manage_members';
2198
+        $query_vars['blog_id'] = $blog_id;
2199
+        echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">';
2200
+        Display::display_sortable_table($column_header, $user_data,null,null,$query_vars);
2201
+        $link = '';
2202
+        $link .= isset ($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']). '&' : '';
2203
+        $link .= "blog_id=$blog_id&";
2204
+
2205
+        echo '<a href="blog.php?' . $link . 'selectall=unsubscribe">' . get_lang('SelectAll') . '</a> - ';
2206
+        echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> ';
2207
+        echo get_lang('WithSelected') . ' : ';
2208
+        echo '<select name="action">';
2209
+        echo '<option value="select_unsubscribe">' . get_lang('UnRegister') . '</option>';
2210
+        echo '</select>';
2211
+        echo '<input type="hidden" name="unregister" value="true" />';
2212
+        echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>';
2213
+        echo '</form>';
2214
+    }
2215
+
2216
+    /**
2217
+     * Displays a matrix with selectboxes. On the left: users, on top: possible rights.
2218
+     * The blog admin can thus select what a certain user can do in the current blog
2219
+     *
2220
+     * @param Integer $blog_id
2221
+     */
2222
+    public static function display_form_user_rights ($blog_id)
2223
+    {
2224
+        echo '<legend>'.get_lang('RightsManager').'</legend>';
2225
+        echo '<br />';
2226
+
2227
+        // Integration of patricks permissions system.
2228
+        require_once api_get_path(SYS_CODE_PATH).'permissions/blog_permissions.inc.php';
2229
+    }
2230
+
2231
+    /**
2232
+     * Displays the form to create a new post
2233
+     * @author Toon Keppens
2234
+     *
2235
+     * @param Integer $blog_id
2236
+     */
2237
+    public static function display_new_comment_form($blog_id, $post_id, $title)
2238
+    {
2239
+        $form = new FormValidator(
2240
+            'add_post',
2241
+            'post',
2242
+            api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=" . intval($blog_id)  . "&post_id=".intval($post_id)."&".api_get_cidreq(),
2243
+            null,
2244
+            array('enctype' => 'multipart/form-data')
2245
+        );
2246
+
2247
+        $header = get_lang('AddNewComment');
2248
+        if (isset($_GET['task_id'])) {
2249
+            $header = get_lang('ExecuteThisTask');
2250
+        }
2251
+        $form->addHeader($header);
2252
+        $form->addText('title', get_lang('Title'));
2253
+
2254
+        $config = array();
2255
+        if (!api_is_allowed_to_edit()) {
2256
+            $config['ToolbarSet'] = 'ProjectComment';
2257
+        } else {
2258
+            $config['ToolbarSet'] = 'ProjectCommentStudent';
2259
+        }
2260
+        $form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config);
2261
+        $form->addFile('user_upload', get_lang('AddAnAttachment'));
2262
+
2263
+        $form->addTextarea('post_file_comment', get_lang('FileComment'));
2264
+
2265
+        $form->addHidden('action', null);
2266
+        $form->addHidden('comment_parent_id', 0);
2267
+
2268
+        if (isset($_GET['task_id'])) {
2269
+            $form->addHidden('new_task_execution_submit', 'true');
2270
+            $form->addHidden('task_id', intval($_GET['task_id']));
2271
+        } else {
2272
+            $form->addHidden('new_comment_submit', 'true');
2273
+        }
2274
+        $form->addButton('save', get_lang('Save'));
2275
+        $form->display();
2276
+    }
2277
+
2278
+
2279
+    /**
2280
+     * show the calender of the given month
2281
+     * @author Patrick Cool
2282
+     * @author Toon Keppens
2283
+     *
2284
+     * @param Array $blogitems an array containing all the blog items for the given month
2285
+     * @param Integer $month: the integer value of the month we are viewing
2286
+     * @param Integer $year: the 4-digit year indication e.g. 2005
2287
+     * @param String $monthName: the language variable for the mont name
2288
+     *
2289
+     * @return html code
2290
+     */
2291
+    public static function display_minimonthcalendar($month, $year, $blog_id)
2224 2292
     {
2225
-		echo '<legend>'.get_lang('RightsManager').'</legend>';
2226
-		echo '<br />';
2227
-
2228
-		// Integration of patricks permissions system.
2229
-		require_once api_get_path(SYS_CODE_PATH).'permissions/blog_permissions.inc.php';
2230
-	}
2231
-
2232
-	/**
2233
-	 * Displays the form to create a new post
2234
-	 * @author Toon Keppens
2235
-	 *
2236
-	 * @param Integer $blog_id
2237
-	 */
2238
-	public static function display_new_comment_form($blog_id, $post_id, $title)
2239
-	{
2240
-		$form = new FormValidator(
2241
-			'add_post',
2242
-			'post',
2243
-			api_get_path(WEB_CODE_PATH)."blog/blog.php?action=view_post&blog_id=" . intval($blog_id)  . "&post_id=".intval($post_id)."&".api_get_cidreq(),
2244
-			null,
2245
-			array('enctype' => 'multipart/form-data')
2246
-		);
2247
-
2248
-		$header = get_lang('AddNewComment');
2249
-		if (isset($_GET['task_id'])) {
2250
-			$header = get_lang('ExecuteThisTask');
2251
-		}
2252
-		$form->addHeader($header);
2253
-		$form->addText('title', get_lang('Title'));
2254
-
2255
-		$config = array();
2256
-		if (!api_is_allowed_to_edit()) {
2257
-			$config['ToolbarSet'] = 'ProjectComment';
2258
-		} else {
2259
-			$config['ToolbarSet'] = 'ProjectCommentStudent';
2260
-		}
2261
-		$form->addHtmlEditor('comment', get_lang('Comment'), false, false, $config);
2262
-		$form->addFile('user_upload', get_lang('AddAnAttachment'));
2263
-
2264
-		$form->addTextarea('post_file_comment', get_lang('FileComment'));
2265
-
2266
-		$form->addHidden('action', null);
2267
-		$form->addHidden('comment_parent_id', 0);
2268
-
2269
-		if (isset($_GET['task_id'])) {
2270
-			$form->addHidden('new_task_execution_submit', 'true');
2271
-			$form->addHidden('task_id', intval($_GET['task_id']));
2272
-		} else {
2273
-			$form->addHidden('new_comment_submit', 'true');
2274
-		}
2275
-		$form->addButton('save', get_lang('Save'));
2276
-		$form->display();
2277
-	}
2278
-
2279
-
2280
-	/**
2281
-	 * show the calender of the given month
2282
-	 * @author Patrick Cool
2283
-	 * @author Toon Keppens
2284
-	 *
2285
-	 * @param Array $blogitems an array containing all the blog items for the given month
2286
-	 * @param Integer $month: the integer value of the month we are viewing
2287
-	 * @param Integer $year: the 4-digit year indication e.g. 2005
2288
-	 * @param String $monthName: the language variable for the mont name
2289
-	 *
2290
-	 * @return html code
2291
-	*/
2292
-	public static function display_minimonthcalendar($month, $year, $blog_id)
2293
-	{
2294
-		// Init
2295
-		$_user = api_get_user_info();
2296
-		global $DaysShort;
2297
-		global $MonthsLong;
2298
-
2299
-		$posts = array();
2300
-		$tasks = array();
2301
-
2302
-		$tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2303
-		$tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
2304
-		$tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
2305
-		$tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
2306
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2307
-
2308
-		$course_id = api_get_course_int_id();
2309
-
2310
-		//Handle leap year
2311
-		$numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
2312
-
2313
-		if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
2314
-			$numberofdays[2] = 29;
2315
-
2316
-		//Get the first day of the month
2317
-		$dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
2318
-		$monthName = $MonthsLong[$month-1];
2319
-
2320
-		//Start the week on monday
2321
-		$startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
2322
-		$blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null;
2323
-		$filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null;
2324
-		$backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year);
2325
-		$forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year);
2326
-
2327
-		// Get posts for this month
2328
-		$sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname
2293
+        // Init
2294
+        $_user = api_get_user_info();
2295
+        global $DaysShort;
2296
+        global $MonthsLong;
2297
+
2298
+        $posts = array();
2299
+        $tasks = array();
2300
+
2301
+        $tbl_users = Database::get_main_table(TABLE_MAIN_USER);
2302
+        $tbl_blogs_posts = Database::get_course_table(TABLE_BLOGS_POSTS);
2303
+        $tbl_blogs_tasks = Database::get_course_table(TABLE_BLOGS_TASKS);
2304
+        $tbl_blogs_tasks_rel_user = Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER);
2305
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2306
+
2307
+        $course_id = api_get_course_int_id();
2308
+
2309
+        //Handle leap year
2310
+        $numberofdays = array (0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
2311
+
2312
+        if(($year % 400 == 0) or ($year % 4 == 0 and $year % 100 <> 0))
2313
+            $numberofdays[2] = 29;
2314
+
2315
+        //Get the first day of the month
2316
+        $dayone = getdate(mktime(0, 0, 0, $month, 1, $year));
2317
+        $monthName = $MonthsLong[$month-1];
2318
+
2319
+        //Start the week on monday
2320
+        $startdayofweek = $dayone['wday'] <> 0 ? ($dayone['wday'] - 1) : 6;
2321
+        $blogId = isset($_GET['blog_id']) ? intval($_GET['blog_id']) : null;
2322
+        $filter = isset($_GET['filter']) ? Security::remove_XSS($_GET['filter']) : null;
2323
+        $backwardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 1 ? 12 : $month -1)."&year=". ($month == 1 ? $year -1 : $year);
2324
+        $forewardsURL = api_get_self()."?blog_id=" . $blogId."&filter=" . $filter."&month=". ($month == 12 ? 1 : $month +1)."&year=". ($month == 12 ? $year +1 : $year);
2325
+
2326
+        // Get posts for this month
2327
+        $sql = "SELECT post.*, DAYOFMONTH(date_creation) as post_day, user.lastname, user.firstname
2329 2328
 				FROM $tbl_blogs_posts post
2330 2329
 				INNER JOIN $tbl_users user
2331 2330
 				ON post.author_id = user.user_id
@@ -2335,20 +2334,20 @@  discard block
 block discarded – undo
2335 2334
 					MONTH(date_creation) = '".(int)$month."' AND
2336 2335
 					YEAR(date_creation) = '".(int)$year."'
2337 2336
 				ORDER BY date_creation";
2338
-		$result = Database::query($sql);
2339
-
2340
-		// We will create an array of days on which there are posts.
2341
-		if( Database::num_rows($result) > 0) {
2342
-			while($blog_post = Database::fetch_array($result)) {
2343
-				// If the day of this post is not yet in the array, add it.
2344
-				if (!in_array($blog_post['post_day'], $posts))
2345
-					$posts[] = $blog_post['post_day'];
2346
-			}
2347
-		}
2348
-
2349
-		// Get tasks for this month
2350
-		if ($_user['user_id']) {
2351
-			$sql = " SELECT task_rel_user.*,  DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name
2337
+        $result = Database::query($sql);
2338
+
2339
+        // We will create an array of days on which there are posts.
2340
+        if( Database::num_rows($result) > 0) {
2341
+            while($blog_post = Database::fetch_array($result)) {
2342
+                // If the day of this post is not yet in the array, add it.
2343
+                if (!in_array($blog_post['post_day'], $posts))
2344
+                    $posts[] = $blog_post['post_day'];
2345
+            }
2346
+        }
2347
+
2348
+        // Get tasks for this month
2349
+        if ($_user['user_id']) {
2350
+            $sql = " SELECT task_rel_user.*,  DAYOFMONTH(target_date) as task_day, task.title, blog.blog_name
2352 2351
 				FROM $tbl_blogs_tasks_rel_user task_rel_user
2353 2352
 				INNER JOIN $tbl_blogs_tasks task ON task_rel_user.task_id = task.task_id
2354 2353
 				INNER JOIN $tbl_blogs blog ON task_rel_user.blog_id = blog.blog_id
@@ -2360,84 +2359,84 @@  discard block
 block discarded – undo
2360 2359
 					MONTH(target_date) = '".(int)$month."' AND
2361 2360
 					YEAR(target_date) = '".(int)$year."'
2362 2361
 				ORDER BY target_date ASC";
2363
-			$result = Database::query($sql);
2364
-
2365
-			if (Database::num_rows($result) > 0) {
2366
-				while ($mytask = Database::fetch_array($result)) {
2367
-					$tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id'];
2368
-					$tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title'];
2369
-					$tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id'];
2370
-					$tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name'];
2371
-					$tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day'];
2372
-				}
2373
-			}
2374
-		}
2375
-
2376
-		echo 	'<table id="smallcalendar" class="table table-responsive">',
2377
-				"<tr id=\"title\">\n",
2378
-				"<th width=\"10%\"><a href=\"", $backwardsURL, "\">&laquo;</a></th>\n",
2379
-				"<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>\n",
2380
-				"<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">&raquo;</a></th>\n", "</tr>";
2381
-
2382
-		echo "<tr>\n";
2383
-
2384
-		for($ii = 1; $ii < 8; $ii ++)
2385
-			echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
2386
-
2387
-		echo "</tr>";
2388
-
2389
-		$curday = -1;
2390
-		$today = getdate();
2391
-
2392
-		while ($curday <= $numberofdays[$month]) {
2393
-			echo "<tr>";
2394
-			for ($ii = 0; $ii < 7; $ii ++) {
2395
-				if (($curday == -1) && ($ii == $startdayofweek))
2396
-					$curday = 1;
2397
-
2398
-			 	if (($curday > 0) && ($curday <= $numberofdays[$month])) {
2399
-					$bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\"";
2400
-					$dayheader = "$curday";
2401
-
2402
-					if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) {
2403
-						$dayheader = "$curday";
2404
-						$class = "class=\"days_today\"";
2405
-					}
2406
-
2407
-					echo "<td " . $class.">";
2408
-
2409
-					// If there are posts on this day, create a filter link.
2410
-					if(in_array($curday, $posts))
2411
-						echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>';
2412
-					else
2413
-						echo $dayheader;
2414
-
2415
-					if (count($tasks) > 0) {
2416
-						if (isset($tasks[$curday]) && is_array($tasks[$curday])) {
2417
-							// Add tasks to calendar
2418
-							foreach ($tasks[$curday] as $task) {
2419
-								echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '">
2362
+            $result = Database::query($sql);
2363
+
2364
+            if (Database::num_rows($result) > 0) {
2365
+                while ($mytask = Database::fetch_array($result)) {
2366
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['task_id'] = $mytask['task_id'];
2367
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['title'] = $mytask['title'];
2368
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['blog_id'] = $mytask['blog_id'];
2369
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['blog_name'] = $mytask['blog_name'];
2370
+                    $tasks[$mytask['task_day']][$mytask['task_id']]['day'] = $mytask['task_day'];
2371
+                }
2372
+            }
2373
+        }
2374
+
2375
+        echo 	'<table id="smallcalendar" class="table table-responsive">',
2376
+                "<tr id=\"title\">\n",
2377
+                "<th width=\"10%\"><a href=\"", $backwardsURL, "\">&laquo;</a></th>\n",
2378
+                "<th align=\"center\" width=\"80%\" colspan=\"5\">", $monthName, " ", $year, "</th>\n",
2379
+                "<th width=\"10%\" align=\"right\"><a href=\"", $forewardsURL, "\">&raquo;</a></th>\n", "</tr>";
2380
+
2381
+        echo "<tr>\n";
2382
+
2383
+        for($ii = 1; $ii < 8; $ii ++)
2384
+            echo "<td class=\"weekdays\">", $DaysShort[$ii % 7], "</td>";
2385
+
2386
+        echo "</tr>";
2387
+
2388
+        $curday = -1;
2389
+        $today = getdate();
2390
+
2391
+        while ($curday <= $numberofdays[$month]) {
2392
+            echo "<tr>";
2393
+            for ($ii = 0; $ii < 7; $ii ++) {
2394
+                if (($curday == -1) && ($ii == $startdayofweek))
2395
+                    $curday = 1;
2396
+
2397
+                    if (($curday > 0) && ($curday <= $numberofdays[$month])) {
2398
+                    $bgcolor = $ii < 5 ? $class="class=\"days_week\"" : $class="class=\"days_weekend\"";
2399
+                    $dayheader = "$curday";
2400
+
2401
+                    if(($curday == $today['mday']) && ($year == $today['year']) && ($month == $today['mon'])) {
2402
+                        $dayheader = "$curday";
2403
+                        $class = "class=\"days_today\"";
2404
+                    }
2405
+
2406
+                    echo "<td " . $class.">";
2407
+
2408
+                    // If there are posts on this day, create a filter link.
2409
+                    if(in_array($curday, $posts))
2410
+                        echo '<a href="blog.php?blog_id=' . $blog_id . '&filter=' . $year . '-' . $month . '-' . $curday . '&month=' . $month . '&year=' . $year . '" title="' . get_lang('ViewPostsOfThisDay') . '">' . $curday . '</a>';
2411
+                    else
2412
+                        echo $dayheader;
2413
+
2414
+                    if (count($tasks) > 0) {
2415
+                        if (isset($tasks[$curday]) && is_array($tasks[$curday])) {
2416
+                            // Add tasks to calendar
2417
+                            foreach ($tasks[$curday] as $task) {
2418
+                                echo '<a href="blog.php?action=execute_task&blog_id=' . $task['blog_id'] . '&task_id='.stripslashes($task['task_id']) . '" title="' . $task['title'] . ' : ' . get_lang('InBlog') . ' : ' . $task['blog_name'] . ' - ' . get_lang('ExecuteThisTask') . '">
2420 2419
 								<img src="../img/blog_task.gif" alt="Task" title="' . get_lang('ExecuteThisTask') . '" /></a>';
2421
-							}
2422
-						}
2423
-					}
2424
-
2425
-					echo "</td>";
2426
-					$curday ++;
2427
-				} else
2428
-					echo "<td>&nbsp;</td>";
2429
-			}
2430
-			echo "</tr>";
2431
-		}
2432
-		echo "</table>";
2433
-	}
2434
-
2435
-	/**
2436
-	 * Blog admin | Display the form to add a new blog.
2437
-	 *
2438
-	 */
2439
-	public static function display_new_blog_form()
2440
-	{
2420
+                            }
2421
+                        }
2422
+                    }
2423
+
2424
+                    echo "</td>";
2425
+                    $curday ++;
2426
+                } else
2427
+                    echo "<td>&nbsp;</td>";
2428
+            }
2429
+            echo "</tr>";
2430
+        }
2431
+        echo "</table>";
2432
+    }
2433
+
2434
+    /**
2435
+     * Blog admin | Display the form to add a new blog.
2436
+     *
2437
+     */
2438
+    public static function display_new_blog_form()
2439
+    {
2441 2440
         $form = new FormValidator('add_blog', 'post', 'blog_admin.php?action=add');
2442 2441
         $form->addElement('header', get_lang('AddBlog'));
2443 2442
         $form->addElement('text', 'blog_name', get_lang('Title'));
@@ -2447,34 +2446,34 @@  discard block
 block discarded – undo
2447 2446
         $form->addButtonSave(get_lang('SaveProject'));
2448 2447
 
2449 2448
         $defaults = array(
2450
-			'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null,
2451
-        	'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null
2452
-		);
2449
+            'blog_name' => isset($_POST['blog_name']) ? Security::remove_XSS($_POST['blog_name']) : null,
2450
+            'blog_subtitle' => isset($_POST['blog_subtitle']) ? Security::remove_XSS($_POST['blog_subtitle']) : null
2451
+        );
2453 2452
         $form->setDefaults($defaults);
2454 2453
         $form->display();
2455
-	}
2456
-
2457
-	/**
2458
-	 * Blog admin | Display the form to edit a blog.
2459
-	 *
2460
-	 */
2461
-	public static function display_edit_blog_form($blog_id)
2462
-	{
2463
-	    $course_id = api_get_course_int_id();
2464
-		$blog_id= intval($blog_id);
2465
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2466
-
2467
-		$sql = "SELECT blog_id, blog_name, blog_subtitle
2454
+    }
2455
+
2456
+    /**
2457
+     * Blog admin | Display the form to edit a blog.
2458
+     *
2459
+     */
2460
+    public static function display_edit_blog_form($blog_id)
2461
+    {
2462
+        $course_id = api_get_course_int_id();
2463
+        $blog_id= intval($blog_id);
2464
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2465
+
2466
+        $sql = "SELECT blog_id, blog_name, blog_subtitle
2468 2467
 		        FROM $tbl_blogs
2469 2468
 		        WHERE c_id = $course_id AND blog_id = '".$blog_id."'";
2470
-		$result = Database::query($sql);
2471
-		$blog = Database::fetch_array($result);
2469
+        $result = Database::query($sql);
2470
+        $blog = Database::fetch_array($result);
2472 2471
 
2473
-		// the form contained errors but we do not want to lose the changes the user already did
2474
-		if ($_POST) {
2475
-			$blog['blog_name'] = Security::remove_XSS($_POST['blog_name']);
2476
-			$blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']);
2477
-		}
2472
+        // the form contained errors but we do not want to lose the changes the user already did
2473
+        if ($_POST) {
2474
+            $blog['blog_name'] = Security::remove_XSS($_POST['blog_name']);
2475
+            $blog['blog_subtitle'] = Security::remove_XSS($_POST['blog_subtitle']);
2476
+        }
2478 2477
 
2479 2478
         $form = new FormValidator('edit_blog', 'post','blog_admin.php?action=edit&blog_id='.intval($_GET['blog_id']));
2480 2479
         $form->addElement('header', get_lang('EditBlog'));
@@ -2490,82 +2489,82 @@  discard block
 block discarded – undo
2490 2489
         $defaults['blog_subtitle'] = $blog['blog_subtitle'];
2491 2490
         $form->setDefaults($defaults);
2492 2491
         $form->display();
2493
-	}
2492
+    }
2494 2493
 
2495
-	/**
2496
-	 * Blog admin | Returns table with blogs in this course
2497
-	 */
2498
-	public static function display_blog_list()
2494
+    /**
2495
+     * Blog admin | Returns table with blogs in this course
2496
+     */
2497
+    public static function display_blog_list()
2499 2498
     {
2500
-		global $charset;
2501
-		$_user = api_get_user_info();
2499
+        global $charset;
2500
+        $_user = api_get_user_info();
2502 2501
         $course_id = api_get_course_int_id();
2503 2502
 
2504
-		$tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2503
+        $tbl_blogs = Database::get_course_table(TABLE_BLOGS);
2505 2504
 
2506
-		//condition for the session
2507
-		$session_id = api_get_session_id();
2508
-		$condition_session = api_get_session_condition($session_id, false);
2505
+        //condition for the session
2506
+        $session_id = api_get_session_id();
2507
+        $condition_session = api_get_session_condition($session_id, false);
2509 2508
 
2510
-		$sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id
2509
+        $sql = "SELECT blog_name, blog_subtitle, visibility, blog_id, session_id
2511 2510
 				FROM $tbl_blogs WHERE c_id = $course_id
2512 2511
 				ORDER BY date_creation DESC";
2513
-		$result = Database::query($sql);
2514
-		$list_info = array();
2515
-		if (Database::num_rows($result)) {
2516
-			while ($row_project=Database::fetch_row($result)) {
2517
-				$list_info[]=$row_project;
2518
-			}
2519
-		}
2520
-
2521
-		$list_content_blog = array();
2522
-		$list_body_blog = array();
2523
-
2524
-		if (is_array($list_info)) {
2525
-			foreach ($list_info as $key => $info_log) {
2526
-				// Validation when belongs to a session
2527
-				$session_img = api_get_session_image($info_log[4], $_user['status']);
2528
-
2529
-				$url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq();
2530
-				$title = $info_log[0];
2512
+        $result = Database::query($sql);
2513
+        $list_info = array();
2514
+        if (Database::num_rows($result)) {
2515
+            while ($row_project=Database::fetch_row($result)) {
2516
+                $list_info[]=$row_project;
2517
+            }
2518
+        }
2519
+
2520
+        $list_content_blog = array();
2521
+        $list_body_blog = array();
2522
+
2523
+        if (is_array($list_info)) {
2524
+            foreach ($list_info as $key => $info_log) {
2525
+                // Validation when belongs to a session
2526
+                $session_img = api_get_session_image($info_log[4], $_user['status']);
2527
+
2528
+                $url_start_blog = 'blog.php' ."?". "blog_id=".$info_log[3]. "&".api_get_cidreq();
2529
+                $title = $info_log[0];
2531 2530
                         $image = Display::return_icon('blog.png', $title);
2532
-    			$list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">' . $image . '</a></div><a href="'.$url_start_blog.'">' .$title. '</a>' . $session_img;
2531
+                $list_name = '<div style="float: left; width: 35px; height: 22px;"><a href="'.$url_start_blog.'">' . $image . '</a></div><a href="'.$url_start_blog.'">' .$title. '</a>' . $session_img;
2533 2532
 
2534
-				$list_body_blog[] = $list_name;
2535
-				$list_body_blog[] = $info_log[1];
2533
+                $list_body_blog[] = $list_name;
2534
+                $list_body_blog[] = $info_log[1];
2536 2535
 
2537
-				$visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible';
2538
-				$visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible';
2539
-			 	$my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">';
2536
+                $visibility_icon=($info_log[2]==0) ? 'invisible' : 'visible';
2537
+                $visibility_info=($info_log[2]==0) ? 'Visible' : 'Invisible';
2538
+                    $my_image = '<a href="' .api_get_self(). '?action=edit&blog_id=' . $info_log[3] . '">';
2540 2539
                                 $my_image.= Display::return_icon('edit.png', get_lang('EditBlog'));
2541 2540
 
2542
-				$my_image.= "</a>\n";
2543
-				$my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" ';
2544
-				$my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >';
2541
+                $my_image.= "</a>\n";
2542
+                $my_image.= '<a href="' .api_get_self(). '?action=delete&blog_id=' . $info_log[3] . '" ';
2543
+                $my_image.= 'onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES,$charset)). '\')) return false;" >';
2545 2544
                                 $my_image.= Display::return_icon('delete.png', get_lang('DeleteBlog'));
2546 2545
 
2547
-				$my_image.= "</a>\n";
2548
-				$my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">';
2546
+                $my_image.= "</a>\n";
2547
+                $my_image.= '<a href="' .api_get_self(). '?action=visibility&blog_id=' . $info_log[3] . '">';
2549 2548
                                 $my_image.= Display::return_icon($visibility_icon . '.gif', get_lang($visibility_info));
2550 2549
 
2551
-				$my_image.= "</a>\n";
2550
+                $my_image.= "</a>\n";
2552 2551
 
2553
-				$list_body_blog[]=$my_image;
2552
+                $list_body_blog[]=$my_image;
2554 2553
 
2555
-				$list_content_blog[]=$list_body_blog;
2556
-				$list_body_blog = array();
2554
+                $list_content_blog[]=$list_body_blog;
2555
+                $list_body_blog = array();
2557 2556
 
2558
-			}
2559
-			$parameters='';
2560
-			//$parameters=array('action'=>Security::remove_XSS($_GET['action']));
2561
-			$table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project');
2562
-			//$table->set_additional_parameters($parameters);
2563
-			$table->set_header(0, get_lang('Title'));
2564
-			$table->set_header(1, get_lang('SubTitle'));
2565
-			$table->set_header(2, get_lang('Modify'));
2566
-			$table->display();
2567
-		}
2568
-	}
2557
+            }
2558
+            $parameters='';
2559
+            //$parameters=array('action'=>Security::remove_XSS($_GET['action']));
2560
+            $table = new SortableTableFromArrayConfig($list_content_blog, 1,20,'project');
2561
+            //$table->set_additional_parameters($parameters);
2562
+            $table->set_header(0, get_lang('Title'));
2563
+            $table->set_header(1, get_lang('SubTitle'));
2564
+            $table->set_header(2, get_lang('Modify'));
2565
+            $table->display();
2566
+        }
2567
+    }
2569 2568
 }
2570 2569
 
2571 2570
 /**
@@ -2585,34 +2584,34 @@  discard block
 block discarded – undo
2585 2584
  */
2586 2585
 function get_blog_attachment($blog_id, $post_id=null,$comment_id=null)
2587 2586
 {
2588
-	$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2589
-
2590
-	$blog_id = intval($blog_id);
2591
-	$comment_id = intval($comment_id);
2592
-	$post_id = intval($post_id);
2593
-	$row=array();
2594
-	$where='';
2595
-	if (!empty ($post_id) && is_numeric($post_id)) {
2596
-		$where.=' AND post_id ="'.$post_id.'" ';
2597
-	}
2598
-
2599
-	if (!empty ($comment_id) && is_numeric($comment_id)) {
2600
-		if (!empty ($post_id)) {
2601
-			$where.= ' AND ';
2602
-		}
2603
-		$where.=' comment_id ="'.$comment_id.'" ';
2604
-	}
2587
+    $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2588
+
2589
+    $blog_id = intval($blog_id);
2590
+    $comment_id = intval($comment_id);
2591
+    $post_id = intval($post_id);
2592
+    $row=array();
2593
+    $where='';
2594
+    if (!empty ($post_id) && is_numeric($post_id)) {
2595
+        $where.=' AND post_id ="'.$post_id.'" ';
2596
+    }
2597
+
2598
+    if (!empty ($comment_id) && is_numeric($comment_id)) {
2599
+        if (!empty ($post_id)) {
2600
+            $where.= ' AND ';
2601
+        }
2602
+        $where.=' comment_id ="'.$comment_id.'" ';
2603
+    }
2605 2604
 
2606 2605
     $course_id = api_get_course_int_id();
2607 2606
 
2608
-	$sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.'
2607
+    $sql = 'SELECT path, filename, comment FROM '. $blog_table_attachment.'
2609 2608
 	        WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'"  '.$where;
2610 2609
 
2611
-	$result=Database::query($sql);
2612
-	if (Database::num_rows($result)!=0) {
2613
-		$row=Database::fetch_array($result);
2614
-	}
2615
-	return $row;
2610
+    $result=Database::query($sql);
2611
+    if (Database::num_rows($result)!=0) {
2612
+        $row=Database::fetch_array($result);
2613
+    }
2614
+    return $row;
2616 2615
 }
2617 2616
 
2618 2617
 /**
@@ -2626,16 +2625,16 @@  discard block
 block discarded – undo
2626 2625
 
2627 2626
 function delete_all_blog_attachment($blog_id,$post_id=null,$comment_id=null)
2628 2627
 {
2629
-	$_course = api_get_course_info();
2630
-	$blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2631
-	$blog_id = intval($blog_id);
2632
-	$comment_id = intval($comment_id);
2633
-	$post_id = intval($post_id);
2628
+    $_course = api_get_course_info();
2629
+    $blog_table_attachment = Database::get_course_table(TABLE_BLOGS_ATTACHMENT);
2630
+    $blog_id = intval($blog_id);
2631
+    $comment_id = intval($comment_id);
2632
+    $post_id = intval($post_id);
2634 2633
 
2635 2634
     $course_id = api_get_course_int_id();
2636
-	$where = null;
2635
+    $where = null;
2637 2636
 
2638
-	// delete files in DB
2637
+    // delete files in DB
2639 2638
     if (!empty ($post_id) && is_numeric($post_id)) {
2640 2639
         $where .= ' AND post_id ="'.$post_id.'" ';
2641 2640
     }
@@ -2647,25 +2646,25 @@  discard block
 block discarded – undo
2647 2646
         $where .= ' comment_id ="'.$comment_id.'" ';
2648 2647
     }
2649 2648
 
2650
-	// delete all files in directory
2651
-	$courseDir   = $_course['path'].'/upload/blog';
2652
-	$sys_course_path = api_get_path(SYS_COURSE_PATH);
2653
-	$updir = $sys_course_path.$courseDir;
2649
+    // delete all files in directory
2650
+    $courseDir   = $_course['path'].'/upload/blog';
2651
+    $sys_course_path = api_get_path(SYS_COURSE_PATH);
2652
+    $updir = $sys_course_path.$courseDir;
2654 2653
 
2655
-	$sql = 'SELECT path FROM '.$blog_table_attachment.'
2654
+    $sql = 'SELECT path FROM '.$blog_table_attachment.'
2656 2655
 	        WHERE c_id = '.$course_id.' AND blog_id ="'.intval($blog_id).'"  '.$where;
2657
-	$result=Database::query($sql);
2658
-
2659
-	while ($row=Database::fetch_row($result)) {
2660
-		$file=$updir.'/'.$row[0];
2661
-		if (Security::check_abs_path($file,$updir) )
2662
-		{
2663
-			@ unlink($file);
2664
-		}
2665
-	}
2666
-	$sql = 'DELETE FROM '. $blog_table_attachment.'
2656
+    $result=Database::query($sql);
2657
+
2658
+    while ($row=Database::fetch_row($result)) {
2659
+        $file=$updir.'/'.$row[0];
2660
+        if (Security::check_abs_path($file,$updir) )
2661
+        {
2662
+            @ unlink($file);
2663
+        }
2664
+    }
2665
+    $sql = 'DELETE FROM '. $blog_table_attachment.'
2667 2666
 	        WHERE c_id = '.$course_id.' AND  blog_id ="'.intval($blog_id).'"  '.$where;
2668
-	Database::query($sql);
2667
+    Database::query($sql);
2669 2668
 }
2670 2669
 
2671 2670
 /**
@@ -2675,12 +2674,12 @@  discard block
 block discarded – undo
2675 2674
  */
2676 2675
 function get_blog_post_from_user($course_code, $user_id)
2677 2676
 {
2678
-	$tbl_blogs 		= Database::get_course_table(TABLE_BLOGS);
2679
-	$tbl_blog_post 	= Database::get_course_table(TABLE_BLOGS_POSTS);
2680
-	$course_info 	= api_get_course_info($course_code);
2681
-	$course_id 		= $course_info['real_id'];
2677
+    $tbl_blogs 		= Database::get_course_table(TABLE_BLOGS);
2678
+    $tbl_blog_post 	= Database::get_course_table(TABLE_BLOGS_POSTS);
2679
+    $course_info 	= api_get_course_info($course_code);
2680
+    $course_id 		= $course_info['real_id'];
2682 2681
 
2683
-	$sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation
2682
+    $sql = "SELECT DISTINCT blog.blog_id, post_id, title, full_text, post.date_creation
2684 2683
 			FROM $tbl_blogs blog
2685 2684
 			INNER JOIN  $tbl_blog_post post
2686 2685
 			ON (blog.blog_id = post.blog_id)
@@ -2689,19 +2688,19 @@  discard block
 block discarded – undo
2689 2688
 				post.c_id = $course_id AND
2690 2689
 				author_id =  $user_id AND visibility = 1
2691 2690
 			ORDER BY post.date_creation DESC ";
2692
-	$result = Database::query($sql);
2693
-	$return_data = '';
2694
-
2695
-	if (Database::num_rows($result)!=0) {
2696
-		while ($row=Database::fetch_array($result)) {
2697
-			$return_data.=  '<div class="clear"></div><br />';
2698
-			$return_data.=  '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>';
2699
-			$return_data.=  '<br / >';
2700
-			$return_data.= $row['full_text'];
2701
-			$return_data.= '<br /><br />';
2702
-		}
2703
-	}
2704
-	return $return_data;
2691
+    $result = Database::query($sql);
2692
+    $return_data = '';
2693
+
2694
+    if (Database::num_rows($result)!=0) {
2695
+        while ($row=Database::fetch_array($result)) {
2696
+            $return_data.=  '<div class="clear"></div><br />';
2697
+            $return_data.=  '<div class="actions" style="margin-left:5px;margin-right:5px;">'.Display::return_icon('blog_article.png',get_lang('BlogPosts')).' '.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.$my_course_id.' " >'.get_lang('SeeBlog').'</a></div></div>';
2698
+            $return_data.=  '<br / >';
2699
+            $return_data.= $row['full_text'];
2700
+            $return_data.= '<br /><br />';
2701
+        }
2702
+    }
2703
+    return $return_data;
2705 2704
 }
2706 2705
 
2707 2706
 /**
@@ -2718,7 +2717,7 @@  discard block
 block discarded – undo
2718 2717
     $course_info = api_get_course_info($course_code);
2719 2718
     $course_id = $course_info['real_id'];
2720 2719
 
2721
-	$sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation
2720
+    $sql = "SELECT DISTINCT blog.blog_id, comment_id, title, comment, comment.date_creation
2722 2721
 			FROM $tbl_blogs blog INNER JOIN  $tbl_blog_comment comment
2723 2722
 			ON (blog.blog_id = comment.blog_id)
2724 2723
 			WHERE 	blog.c_id = $course_id AND
@@ -2726,18 +2725,18 @@  discard block
 block discarded – undo
2726 2725
 					author_id =  $user_id AND
2727 2726
 					visibility = 1
2728 2727
 			ORDER BY blog_name";
2729
-	$result = Database::query($sql);
2730
-	$return_data = '';
2731
-	if (Database::num_rows($result)!=0) {
2732
-		while ($row=Database::fetch_array($result)) {
2733
-			$return_data.=  '<div class="clear"></div><br />';
2734
-			$return_data.=  '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>';
2735
-			$return_data.=  '<br / >';
2736
-			//$return_data.=  '<strong>'.$row['title'].'</strong>'; echo '<br>';*/
2737
-			$return_data.=  $row['comment'];
2738
-			$return_data.=  '<br />';
2739
-		}
2740
-	}
2741
-	return $return_data;
2728
+    $result = Database::query($sql);
2729
+    $return_data = '';
2730
+    if (Database::num_rows($result)!=0) {
2731
+        while ($row=Database::fetch_array($result)) {
2732
+            $return_data.=  '<div class="clear"></div><br />';
2733
+            $return_data.=  '<div class="actions" style="margin-left:5px;margin-right:5px;">'.$row['title'].'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div style="float:right;margin-top:-18px"><a href="../blog/blog.php?blog_id='.$row['blog_id'].'&gidReq=&cidReq='.Security::remove_XSS($course_code).' " >'.get_lang('SeeBlog').'</a></div></div>';
2734
+            $return_data.=  '<br / >';
2735
+            //$return_data.=  '<strong>'.$row['title'].'</strong>'; echo '<br>';*/
2736
+            $return_data.=  $row['comment'];
2737
+            $return_data.=  '<br />';
2738
+        }
2739
+    }
2740
+    return $return_data;
2742 2741
 }
2743 2742
 
Please login to merge, or discard this patch.
main/inc/lib/plugin.class.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -591,13 +591,13 @@
 block discarded – undo
591 591
 
592 592
     }
593 593
 
594
-   /**
595
-    * Add a tab to platform
596
-    * @param string   $tabName
597
-    * @param string   $url
598
-    *
599
-    * @return boolean
600
-    */
594
+    /**
595
+     * Add a tab to platform
596
+     * @param string   $tabName
597
+     * @param string   $url
598
+     *
599
+     * @return boolean
600
+     */
601 601
     public function addTab($tabName, $url)
602 602
     {
603 603
         $sql = "SELECT * FROM settings_current
Please login to merge, or discard this patch.
main/inc/lib/course.lib.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1679,7 +1679,7 @@  discard block
 block discarded – undo
1679 1679
 
1680 1680
         // We get the coach for the given course in a given session.
1681 1681
         $sql = 'SELECT user_id FROM ' . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) .
1682
-               ' WHERE session_id ="' . $session_id . '" AND c_id="' . $courseId . '" AND status = 2';
1682
+                ' WHERE session_id ="' . $session_id . '" AND c_id="' . $courseId . '" AND status = 2';
1683 1683
         $rs = Database::query($sql);
1684 1684
         while ($user = Database::fetch_array($rs)) {
1685 1685
             $user_info = api_get_user_info($user['user_id']);
@@ -3972,7 +3972,7 @@  discard block
 block discarded – undo
3972 3972
         }
3973 3973
 
3974 3974
         $session_title .= isset($course['special_course']) ? ' ' .
3975
-                          Display::return_icon('klipper.png', get_lang('CourseAutoRegister')) : '';
3975
+                            Display::return_icon('klipper.png', get_lang('CourseAutoRegister')) : '';
3976 3976
 
3977 3977
         $params['title'] = $session_title;
3978 3978
         $params['extra'] = '';
Please login to merge, or discard this patch.
main/inc/lib/access_url_edit_courses_to_url_functions.lib.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /* For licensing terms, see /license.txt */
3 3
 /**
4
- * Definition of the Accessurleditcoursestourl class
5
- * @package chamilo.library
6
- */
4
+     * Definition of the Accessurleditcoursestourl class
5
+     * @package chamilo.library
6
+     */
7 7
 
8 8
 /**
9 9
  * Access_url_edit_courses_to_url class
@@ -38,17 +38,17 @@  discard block
 block discarded – undo
38 38
             $needle = Database::escape_string($needle);
39 39
             // search courses where username or firstname or lastname begins likes $needle
40 40
             $sql = 'SELECT code, title FROM '.$tbl_course.' u '.
41
-                   ' WHERE (title LIKE "'.$needle.'%" '.
42
-                   ' OR code LIKE "'.$needle.'%" '.
43
-                   ' ) '.
44
-                   ' ORDER BY title, code '.
45
-                   ' LIMIT 11';
41
+                    ' WHERE (title LIKE "'.$needle.'%" '.
42
+                    ' OR code LIKE "'.$needle.'%" '.
43
+                    ' ) '.
44
+                    ' ORDER BY title, code '.
45
+                    ' LIMIT 11';
46 46
             $rs = Database::query($sql);
47 47
             $i=0;
48 48
             while ($course = Database :: fetch_array($rs)) {
49 49
                 $i++;
50 50
                 if ($i<=10) {
51
-                     $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($course['code']).'\',\''.addslashes($course['title']).' ('.addslashes($course['code']).')'.'\')">'.$course['title'].' ('.$course['code'].')</a><br />';
51
+                        $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($course['code']).'\',\''.addslashes($course['title']).' ('.addslashes($course['code']).')'.'\')">'.$course['title'].' ('.$course['code'].')</a><br />';
52 52
                 } else {
53 53
                     $return .= '...<br />';
54 54
                 }
Please login to merge, or discard this patch.
main/inc/lib/social.lib.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
         if ($course_visibility != COURSE_VISIBILITY_HIDDEN &&
511 511
             ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER)
512 512
         ) {
513
-           $result .= '<span class="title">' . $course_title . '<span>';
513
+            $result .= '<span class="title">' . $course_title . '<span>';
514 514
         } else {
515 515
             $result .= $course_title." "." ".get_lang('CourseClosed')."";
516 516
         }
@@ -1414,7 +1414,7 @@  discard block
 block discarded – undo
1414 1414
             }
1415 1415
             $media .= '<div class="user-image">';
1416 1416
             $media .= '<a href="'.$url.'" ><img src="'. $users[$userIdLoop]['avatar'] .
1417
-                       '" alt="'.$users[$userIdLoop]['complete_name'].'" class="avatar-thumb"></a>';
1417
+                        '" alt="'.$users[$userIdLoop]['complete_name'].'" class="avatar-thumb"></a>';
1418 1418
             $media .= '</div>';
1419 1419
             $media .= '<div class="user-data">';
1420 1420
             $media .= '<div class="username">' . '<a href="'.$url.'">'.$nameComplete.'</a></div>';
@@ -1645,10 +1645,10 @@  discard block
 block discarded – undo
1645 1645
         return $name;
1646 1646
     }
1647 1647
     /**
1648
-    * Delete messages delete logic
1649
-    * @param int $id id message to delete.
1650
-    * @return bool status query
1651
-    */
1648
+     * Delete messages delete logic
1649
+     * @param int $id id message to delete.
1650
+     * @return bool status query
1651
+     */
1652 1652
     public static function deleteMessage($id)
1653 1653
     {
1654 1654
         $id = intval($id);
Please login to merge, or discard this patch.
main/inc/lib/message.lib.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1532,7 +1532,7 @@
 block discarded – undo
1532 1532
 
1533 1533
         if (isset($_REQUEST['action'])) {
1534 1534
             switch ($_REQUEST['action']) {
1535
-                 case 'mark_as_unread' :
1535
+                    case 'mark_as_unread' :
1536 1536
                     $number_of_selected_messages = count($_POST['id']);
1537 1537
                     if (is_array($_POST['id'])) {
1538 1538
                         foreach ($_POST['id'] as $index => $message_id) {
Please login to merge, or discard this patch.
main/inc/lib/skill.lib.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
     }
34 34
 
35 35
     /**
36
-    * This function is for editing profile info from profile_id.
37
-    * @param int    $profileId
38
-    * @param string $name
39
-    * @param string $description
40
-    */
36
+     * This function is for editing profile info from profile_id.
37
+     * @param int    $profileId
38
+     * @param string $name
39
+     * @param string $description
40
+     */
41 41
     public function updateProfileInfo($profileId, $name, $description)
42 42
     {
43 43
         $profileId = intval($profileId);
@@ -128,9 +128,9 @@  discard block
 block discarded – undo
128 128
     }
129 129
 
130 130
     /**
131
-    * This function is for getting profile info from profile_id.
132
-    * @param int $profileId
133
-    */
131
+     * This function is for getting profile info from profile_id.
132
+     * @param int $profileId
133
+     */
134 134
 
135 135
     public function getProfileInfo($profileId)
136 136
     {
Please login to merge, or discard this patch.
main/inc/lib/baker.lib.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -150,7 +150,7 @@
 block discarded – undo
150 150
                 $data = substr($png,$ipos,$chunk['size']);
151 151
                 $sections = explode("\0", $data);
152 152
                 if ($sections[0] == $key) {
153
-                   return $sections;
153
+                    return $sections;
154 154
                 }
155 155
             }
156 156
             // Extract the data and the CRC
Please login to merge, or discard this patch.
main/inc/lib/pclzip/pclzip.lib.php 1 patch
Indentation   +2654 added lines, -2654 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * @package chamilo.include
4
- */
3
+     * @package chamilo.include
4
+     */
5 5
 /**
6
- * Code
7
- */
6
+     * Code
7
+     */
8 8
 // --------------------------------------------------------------------------------
9 9
 // PhpConcept Library - Zip Module 2.8.2
10 10
 // --------------------------------------------------------------------------------
@@ -39,154 +39,154 @@  discard block
 block discarded – undo
39 39
 // http://php.net/manual/en/function.gzopen.php
40 40
 // --------------------------------------------------------------------------------
41 41
 if (!function_exists('gzopen') && function_exists('gzopen64')) {
42
-	function gzopen($filename, $mode, $use_include_path = 0) {
43
-		return gzopen64($filename, $mode, $use_include_path);
44
-	}
42
+    function gzopen($filename, $mode, $use_include_path = 0) {
43
+        return gzopen64($filename, $mode, $use_include_path);
44
+    }
45 45
 }
46 46
 // --------------------------------------------------------------------------------
47 47
 
48
-  // ----- Constants
49
-  if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
48
+    // ----- Constants
49
+    if (!defined('PCLZIP_READ_BLOCK_SIZE')) {
50 50
     define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
51
-  }
52
-
53
-  // ----- File list separator
54
-  // In version 1.x of PclZip, the separator for file list is a space
55
-  // (which is not a very smart choice, specifically for windows paths !).
56
-  // A better separator should be a comma (,). This constant gives you the
57
-  // abilty to change that.
58
-  // However notice that changing this value, may have impact on existing
59
-  // scripts, using space separated filenames.
60
-  // Recommanded values for compatibility with older versions :
61
-  //define( 'PCLZIP_SEPARATOR', ' ' );
62
-  // Recommanded values for smart separation of filenames.
63
-  if (!defined('PCLZIP_SEPARATOR')) {
51
+    }
52
+
53
+    // ----- File list separator
54
+    // In version 1.x of PclZip, the separator for file list is a space
55
+    // (which is not a very smart choice, specifically for windows paths !).
56
+    // A better separator should be a comma (,). This constant gives you the
57
+    // abilty to change that.
58
+    // However notice that changing this value, may have impact on existing
59
+    // scripts, using space separated filenames.
60
+    // Recommanded values for compatibility with older versions :
61
+    //define( 'PCLZIP_SEPARATOR', ' ' );
62
+    // Recommanded values for smart separation of filenames.
63
+    if (!defined('PCLZIP_SEPARATOR')) {
64 64
     define( 'PCLZIP_SEPARATOR', '|' );
65
-  }
66
-
67
-  // ----- Error configuration
68
-  // 0 : PclZip Class integrated error handling
69
-  // 1 : PclError external library error handling. By enabling this
70
-  //     you must ensure that you have included PclError library.
71
-  // [2,...] : reserved for futur use
72
-  if (!defined('PCLZIP_ERROR_EXTERNAL')) {
65
+    }
66
+
67
+    // ----- Error configuration
68
+    // 0 : PclZip Class integrated error handling
69
+    // 1 : PclError external library error handling. By enabling this
70
+    //     you must ensure that you have included PclError library.
71
+    // [2,...] : reserved for futur use
72
+    if (!defined('PCLZIP_ERROR_EXTERNAL')) {
73 73
     define( 'PCLZIP_ERROR_EXTERNAL', 0 );
74
-  }
75
-
76
-  // ----- Optional static temporary directory
77
-  //       By default temporary files are generated in the script current
78
-  //       path.
79
-  //       If defined :
80
-  //       - MUST BE terminated by a '/'.
81
-  //       - MUST be a valid, already created directory
82
-  //       Samples :
83
-  // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
84
-  // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
85
-  if (!defined('PCLZIP_TEMPORARY_DIR')) {
74
+    }
75
+
76
+    // ----- Optional static temporary directory
77
+    //       By default temporary files are generated in the script current
78
+    //       path.
79
+    //       If defined :
80
+    //       - MUST BE terminated by a '/'.
81
+    //       - MUST be a valid, already created directory
82
+    //       Samples :
83
+    // define( 'PCLZIP_TEMPORARY_DIR', '/temp/' );
84
+    // define( 'PCLZIP_TEMPORARY_DIR', 'C:/Temp/' );
85
+    if (!defined('PCLZIP_TEMPORARY_DIR')) {
86 86
     define( 'PCLZIP_TEMPORARY_DIR', '' );
87
-  }
88
-
89
-  // ----- Optional threshold ratio for use of temporary files
90
-  //       Pclzip sense the size of the file to add/extract and decide to
91
-  //       use or not temporary file. The algorythm is looking for
92
-  //       memory_limit of PHP and apply a ratio.
93
-  //       threshold = memory_limit * ratio.
94
-  //       Recommended values are under 0.5. Default 0.47.
95
-  //       Samples :
96
-  // define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 );
97
-  if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
87
+    }
88
+
89
+    // ----- Optional threshold ratio for use of temporary files
90
+    //       Pclzip sense the size of the file to add/extract and decide to
91
+    //       use or not temporary file. The algorythm is looking for
92
+    //       memory_limit of PHP and apply a ratio.
93
+    //       threshold = memory_limit * ratio.
94
+    //       Recommended values are under 0.5. Default 0.47.
95
+    //       Samples :
96
+    // define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.5 );
97
+    if (!defined('PCLZIP_TEMPORARY_FILE_RATIO')) {
98 98
     define( 'PCLZIP_TEMPORARY_FILE_RATIO', 0.47 );
99
-  }
99
+    }
100 100
 
101 101
 // --------------------------------------------------------------------------------
102 102
 // ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****
103 103
 // --------------------------------------------------------------------------------
104 104
 
105
-  // ----- Global variables
106
-  $g_pclzip_version = "2.8.2";
107
-
108
-  // ----- Error codes
109
-  //   -1 : Unable to open file in binary write mode
110
-  //   -2 : Unable to open file in binary read mode
111
-  //   -3 : Invalid parameters
112
-  //   -4 : File does not exist
113
-  //   -5 : Filename is too long (max. 255)
114
-  //   -6 : Not a valid zip file
115
-  //   -7 : Invalid extracted file size
116
-  //   -8 : Unable to create directory
117
-  //   -9 : Invalid archive extension
118
-  //  -10 : Invalid archive format
119
-  //  -11 : Unable to delete file (unlink)
120
-  //  -12 : Unable to rename file (rename)
121
-  //  -13 : Invalid header checksum
122
-  //  -14 : Invalid archive size
123
-  define( 'PCLZIP_ERR_USER_ABORTED', 2 );
124
-  define( 'PCLZIP_ERR_NO_ERROR', 0 );
125
-  define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
126
-  define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );
127
-  define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );
128
-  define( 'PCLZIP_ERR_MISSING_FILE', -4 );
129
-  define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
130
-  define( 'PCLZIP_ERR_INVALID_ZIP', -6 );
131
-  define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
132
-  define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
133
-  define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );
134
-  define( 'PCLZIP_ERR_BAD_FORMAT', -10 );
135
-  define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
136
-  define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
137
-  define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );
138
-  define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
139
-  define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
140
-  define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
141
-  define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 );
142
-  define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 );
143
-  define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 );
144
-  define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 );
145
-  define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 );
146
-
147
-  // ----- Options values
148
-  define( 'PCLZIP_OPT_PATH', 77001 );
149
-  define( 'PCLZIP_OPT_ADD_PATH', 77002 );
150
-  define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );
151
-  define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
152
-  define( 'PCLZIP_OPT_SET_CHMOD', 77005 );
153
-  define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
154
-  define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );
155
-  define( 'PCLZIP_OPT_BY_NAME', 77008 );
156
-  define( 'PCLZIP_OPT_BY_INDEX', 77009 );
157
-  define( 'PCLZIP_OPT_BY_EREG', 77010 );
158
-  define( 'PCLZIP_OPT_BY_PREG', 77011 );
159
-  define( 'PCLZIP_OPT_COMMENT', 77012 );
160
-  define( 'PCLZIP_OPT_ADD_COMMENT', 77013 );
161
-  define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 );
162
-  define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 );
163
-  define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 );
164
-  define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 );
165
-  // Having big trouble with crypt. Need to multiply 2 long int
166
-  // which is not correctly supported by PHP ...
167
-  //define( 'PCLZIP_OPT_CRYPT', 77018 );
168
-  define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
169
-  define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 );
170
-  define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias
171
-  define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 );
172
-  define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias
173
-  define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
174
-  define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
175
-
176
-  // ----- File description attributes
177
-  define( 'PCLZIP_ATT_FILE_NAME', 79001 );
178
-  define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
179
-  define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
180
-  define( 'PCLZIP_ATT_FILE_MTIME', 79004 );
181
-  define( 'PCLZIP_ATT_FILE_CONTENT', 79005 );
182
-  define( 'PCLZIP_ATT_FILE_COMMENT', 79006 );
183
-
184
-  // ----- Call backs values
185
-  define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
186
-  define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
187
-  define( 'PCLZIP_CB_PRE_ADD', 78003 );
188
-  define( 'PCLZIP_CB_POST_ADD', 78004 );
189
-  /* For futur use
105
+    // ----- Global variables
106
+    $g_pclzip_version = "2.8.2";
107
+
108
+    // ----- Error codes
109
+    //   -1 : Unable to open file in binary write mode
110
+    //   -2 : Unable to open file in binary read mode
111
+    //   -3 : Invalid parameters
112
+    //   -4 : File does not exist
113
+    //   -5 : Filename is too long (max. 255)
114
+    //   -6 : Not a valid zip file
115
+    //   -7 : Invalid extracted file size
116
+    //   -8 : Unable to create directory
117
+    //   -9 : Invalid archive extension
118
+    //  -10 : Invalid archive format
119
+    //  -11 : Unable to delete file (unlink)
120
+    //  -12 : Unable to rename file (rename)
121
+    //  -13 : Invalid header checksum
122
+    //  -14 : Invalid archive size
123
+    define( 'PCLZIP_ERR_USER_ABORTED', 2 );
124
+    define( 'PCLZIP_ERR_NO_ERROR', 0 );
125
+    define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
126
+    define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );
127
+    define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );
128
+    define( 'PCLZIP_ERR_MISSING_FILE', -4 );
129
+    define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
130
+    define( 'PCLZIP_ERR_INVALID_ZIP', -6 );
131
+    define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
132
+    define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
133
+    define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );
134
+    define( 'PCLZIP_ERR_BAD_FORMAT', -10 );
135
+    define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
136
+    define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
137
+    define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );
138
+    define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
139
+    define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
140
+    define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
141
+    define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 );
142
+    define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 );
143
+    define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 );
144
+    define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 );
145
+    define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 );
146
+
147
+    // ----- Options values
148
+    define( 'PCLZIP_OPT_PATH', 77001 );
149
+    define( 'PCLZIP_OPT_ADD_PATH', 77002 );
150
+    define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );
151
+    define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
152
+    define( 'PCLZIP_OPT_SET_CHMOD', 77005 );
153
+    define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
154
+    define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );
155
+    define( 'PCLZIP_OPT_BY_NAME', 77008 );
156
+    define( 'PCLZIP_OPT_BY_INDEX', 77009 );
157
+    define( 'PCLZIP_OPT_BY_EREG', 77010 );
158
+    define( 'PCLZIP_OPT_BY_PREG', 77011 );
159
+    define( 'PCLZIP_OPT_COMMENT', 77012 );
160
+    define( 'PCLZIP_OPT_ADD_COMMENT', 77013 );
161
+    define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 );
162
+    define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 );
163
+    define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 );
164
+    define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 );
165
+    // Having big trouble with crypt. Need to multiply 2 long int
166
+    // which is not correctly supported by PHP ...
167
+    //define( 'PCLZIP_OPT_CRYPT', 77018 );
168
+    define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
169
+    define( 'PCLZIP_OPT_TEMP_FILE_THRESHOLD', 77020 );
170
+    define( 'PCLZIP_OPT_ADD_TEMP_FILE_THRESHOLD', 77020 ); // alias
171
+    define( 'PCLZIP_OPT_TEMP_FILE_ON', 77021 );
172
+    define( 'PCLZIP_OPT_ADD_TEMP_FILE_ON', 77021 ); // alias
173
+    define( 'PCLZIP_OPT_TEMP_FILE_OFF', 77022 );
174
+    define( 'PCLZIP_OPT_ADD_TEMP_FILE_OFF', 77022 ); // alias
175
+
176
+    // ----- File description attributes
177
+    define( 'PCLZIP_ATT_FILE_NAME', 79001 );
178
+    define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
179
+    define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
180
+    define( 'PCLZIP_ATT_FILE_MTIME', 79004 );
181
+    define( 'PCLZIP_ATT_FILE_CONTENT', 79005 );
182
+    define( 'PCLZIP_ATT_FILE_COMMENT', 79006 );
183
+
184
+    // ----- Call backs values
185
+    define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
186
+    define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
187
+    define( 'PCLZIP_CB_PRE_ADD', 78003 );
188
+    define( 'PCLZIP_CB_POST_ADD', 78004 );
189
+    /* For futur use
190 190
   define( 'PCLZIP_CB_PRE_LIST', 78005 );
191 191
   define( 'PCLZIP_CB_POST_LIST', 78006 );
192 192
   define( 'PCLZIP_CB_PRE_DELETE', 78007 );
@@ -224,21 +224,21 @@  discard block
 block discarded – undo
224 224
     // The class can then disable the magic_quotes and reset it after
225 225
     var $magic_quotes_status;
226 226
 
227
-  // --------------------------------------------------------------------------------
228
-  // Function : PclZip()
229
-  // Description :
230
-  //   Creates a PclZip object and set the name of the associated Zip archive
231
-  //   filename.
232
-  //   Note that no real action is taken, if the archive does not exist it is not
233
-  //   created. Use create() for that.
234
-  // --------------------------------------------------------------------------------
235
-  function PclZip($p_zipname)
236
-  {
227
+    // --------------------------------------------------------------------------------
228
+    // Function : PclZip()
229
+    // Description :
230
+    //   Creates a PclZip object and set the name of the associated Zip archive
231
+    //   filename.
232
+    //   Note that no real action is taken, if the archive does not exist it is not
233
+    //   created. Use create() for that.
234
+    // --------------------------------------------------------------------------------
235
+    function PclZip($p_zipname)
236
+    {
237 237
 
238 238
     // ----- Tests the zlib
239 239
     if (!function_exists('gzopen'))
240 240
     {
241
-      die('Abort '.basename(__FILE__).' : Missing zlib extensions');
241
+        die('Abort '.basename(__FILE__).' : Missing zlib extensions');
242 242
     }
243 243
 
244 244
     // ----- Set the attributes
@@ -248,48 +248,48 @@  discard block
 block discarded – undo
248 248
 
249 249
     // ----- Return
250 250
     return;
251
-  }
252
-  // --------------------------------------------------------------------------------
253
-
254
-  // --------------------------------------------------------------------------------
255
-  // Function :
256
-  //   create($p_filelist, $p_add_dir="", $p_remove_dir="")
257
-  //   create($p_filelist, $p_option, $p_option_value, ...)
258
-  // Description :
259
-  //   This method supports two different synopsis. The first one is historical.
260
-  //   This method creates a Zip Archive. The Zip file is created in the
261
-  //   filesystem. The files and directories indicated in $p_filelist
262
-  //   are added in the archive. See the parameters description for the
263
-  //   supported format of $p_filelist.
264
-  //   When a directory is in the list, the directory and its content is added
265
-  //   in the archive.
266
-  //   In this synopsis, the function takes an optional variable list of
267
-  //   options. See bellow the supported options.
268
-  // Parameters :
269
-  //   $p_filelist : An array containing file or directory names, or
270
-  //                 a string containing one filename or one directory name, or
271
-  //                 a string containing a list of filenames and/or directory
272
-  //                 names separated by spaces.
273
-  //   $p_add_dir : A path to add before the real path of the archived file,
274
-  //                in order to have it memorized in the archive.
275
-  //   $p_remove_dir : A path to remove from the real path of the file to archive,
276
-  //                   in order to have a shorter path memorized in the archive.
277
-  //                   When $p_add_dir and $p_remove_dir are set, $p_remove_dir
278
-  //                   is removed first, before $p_add_dir is added.
279
-  // Options :
280
-  //   PCLZIP_OPT_ADD_PATH :
281
-  //   PCLZIP_OPT_REMOVE_PATH :
282
-  //   PCLZIP_OPT_REMOVE_ALL_PATH :
283
-  //   PCLZIP_OPT_COMMENT :
284
-  //   PCLZIP_CB_PRE_ADD :
285
-  //   PCLZIP_CB_POST_ADD :
286
-  // Return Values :
287
-  //   0 on failure,
288
-  //   The list of the added files, with a status of the add action.
289
-  //   (see PclZip::listContent() for list entry format)
290
-  // --------------------------------------------------------------------------------
291
-  function create($p_filelist)
292
-  {
251
+    }
252
+    // --------------------------------------------------------------------------------
253
+
254
+    // --------------------------------------------------------------------------------
255
+    // Function :
256
+    //   create($p_filelist, $p_add_dir="", $p_remove_dir="")
257
+    //   create($p_filelist, $p_option, $p_option_value, ...)
258
+    // Description :
259
+    //   This method supports two different synopsis. The first one is historical.
260
+    //   This method creates a Zip Archive. The Zip file is created in the
261
+    //   filesystem. The files and directories indicated in $p_filelist
262
+    //   are added in the archive. See the parameters description for the
263
+    //   supported format of $p_filelist.
264
+    //   When a directory is in the list, the directory and its content is added
265
+    //   in the archive.
266
+    //   In this synopsis, the function takes an optional variable list of
267
+    //   options. See bellow the supported options.
268
+    // Parameters :
269
+    //   $p_filelist : An array containing file or directory names, or
270
+    //                 a string containing one filename or one directory name, or
271
+    //                 a string containing a list of filenames and/or directory
272
+    //                 names separated by spaces.
273
+    //   $p_add_dir : A path to add before the real path of the archived file,
274
+    //                in order to have it memorized in the archive.
275
+    //   $p_remove_dir : A path to remove from the real path of the file to archive,
276
+    //                   in order to have a shorter path memorized in the archive.
277
+    //                   When $p_add_dir and $p_remove_dir are set, $p_remove_dir
278
+    //                   is removed first, before $p_add_dir is added.
279
+    // Options :
280
+    //   PCLZIP_OPT_ADD_PATH :
281
+    //   PCLZIP_OPT_REMOVE_PATH :
282
+    //   PCLZIP_OPT_REMOVE_ALL_PATH :
283
+    //   PCLZIP_OPT_COMMENT :
284
+    //   PCLZIP_CB_PRE_ADD :
285
+    //   PCLZIP_CB_POST_ADD :
286
+    // Return Values :
287
+    //   0 on failure,
288
+    //   The list of the added files, with a status of the add action.
289
+    //   (see PclZip::listContent() for list entry format)
290
+    // --------------------------------------------------------------------------------
291
+    function create($p_filelist)
292
+    {
293 293
     $v_result=1;
294 294
 
295 295
     // ----- Reset the error handler
@@ -304,53 +304,53 @@  discard block
 block discarded – undo
304 304
 
305 305
     // ----- Look for arguments
306 306
     if ($v_size > 1) {
307
-      // ----- Get the arguments
308
-      $v_arg_list = func_get_args();
307
+        // ----- Get the arguments
308
+        $v_arg_list = func_get_args();
309 309
 
310
-      // ----- Remove from the options list the first argument
311
-      array_shift($v_arg_list);
312
-      $v_size--;
310
+        // ----- Remove from the options list the first argument
311
+        array_shift($v_arg_list);
312
+        $v_size--;
313 313
 
314
-      // ----- Look for first arg
315
-      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
314
+        // ----- Look for first arg
315
+        if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
316 316
 
317 317
         // ----- Parse the options
318 318
         $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
319 319
                                             array (PCLZIP_OPT_REMOVE_PATH => 'optional',
320
-                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
321
-                                                   PCLZIP_OPT_ADD_PATH => 'optional',
322
-                                                   PCLZIP_CB_PRE_ADD => 'optional',
323
-                                                   PCLZIP_CB_POST_ADD => 'optional',
324
-                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional',
325
-                                                   PCLZIP_OPT_COMMENT => 'optional',
326
-                                                   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
327
-                                                   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
328
-                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
329
-                                                   //, PCLZIP_OPT_CRYPT => 'optional'
330
-                                             ));
320
+                                                    PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
321
+                                                    PCLZIP_OPT_ADD_PATH => 'optional',
322
+                                                    PCLZIP_CB_PRE_ADD => 'optional',
323
+                                                    PCLZIP_CB_POST_ADD => 'optional',
324
+                                                    PCLZIP_OPT_NO_COMPRESSION => 'optional',
325
+                                                    PCLZIP_OPT_COMMENT => 'optional',
326
+                                                    PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
327
+                                                    PCLZIP_OPT_TEMP_FILE_ON => 'optional',
328
+                                                    PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
329
+                                                    //, PCLZIP_OPT_CRYPT => 'optional'
330
+                                                ));
331 331
         if ($v_result != 1) {
332
-          return 0;
332
+            return 0;
333
+        }
333 334
         }
334
-      }
335 335
 
336
-      // ----- Look for 2 args
337
-      // Here we need to support the first historic synopsis of the
338
-      // method.
339
-      else {
336
+        // ----- Look for 2 args
337
+        // Here we need to support the first historic synopsis of the
338
+        // method.
339
+        else {
340 340
 
341 341
         // ----- Get the first argument
342 342
         $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
343 343
 
344 344
         // ----- Look for the optional second argument
345 345
         if ($v_size == 2) {
346
-          $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
346
+            $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
347 347
         }
348 348
         else if ($v_size > 2) {
349
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
350
-		                       "Invalid number / type of arguments");
351
-          return 0;
349
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
350
+                                "Invalid number / type of arguments");
351
+            return 0;
352
+        }
352 353
         }
353
-      }
354 354
     }
355 355
 
356 356
     // ----- Look for default option values
@@ -365,114 +365,114 @@  discard block
 block discarded – undo
365 365
     // ----- Look if the $p_filelist is really an array
366 366
     if (is_array($p_filelist)) {
367 367
 
368
-      // ----- Look if the first element is also an array
369
-      //       This will mean that this is a file description entry
370
-      if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
368
+        // ----- Look if the first element is also an array
369
+        //       This will mean that this is a file description entry
370
+        if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
371 371
         $v_att_list = $p_filelist;
372
-      }
372
+        }
373 373
 
374
-      // ----- The list is a list of string names
375
-      else {
374
+        // ----- The list is a list of string names
375
+        else {
376 376
         $v_string_list = $p_filelist;
377
-      }
377
+        }
378 378
     }
379 379
 
380 380
     // ----- Look if the $p_filelist is a string
381 381
     else if (is_string($p_filelist)) {
382
-      // ----- Create a list from the string
383
-      $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
382
+        // ----- Create a list from the string
383
+        $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
384 384
     }
385 385
 
386 386
     // ----- Invalid variable type for $p_filelist
387 387
     else {
388
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
389
-      return 0;
388
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
389
+        return 0;
390 390
     }
391 391
 
392 392
     // ----- Reformat the string list
393 393
     if (sizeof($v_string_list) != 0) {
394
-      foreach ($v_string_list as $v_string) {
394
+        foreach ($v_string_list as $v_string) {
395 395
         if ($v_string != '') {
396
-          $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
396
+            $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
397 397
         }
398 398
         else {
399 399
         }
400
-      }
400
+        }
401 401
     }
402 402
 
403 403
     // ----- For each file in the list check the attributes
404 404
     $v_supported_attributes
405 405
     = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
406
-             ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
407
-             ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
408
-             ,PCLZIP_ATT_FILE_MTIME => 'optional'
409
-             ,PCLZIP_ATT_FILE_CONTENT => 'optional'
410
-             ,PCLZIP_ATT_FILE_COMMENT => 'optional'
411
-						);
406
+                ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
407
+                ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
408
+                ,PCLZIP_ATT_FILE_MTIME => 'optional'
409
+                ,PCLZIP_ATT_FILE_CONTENT => 'optional'
410
+                ,PCLZIP_ATT_FILE_COMMENT => 'optional'
411
+                        );
412 412
     foreach ($v_att_list as $v_entry) {
413
-      $v_result = $this->privFileDescrParseAtt($v_entry,
414
-                                               $v_filedescr_list[],
415
-                                               $v_options,
416
-                                               $v_supported_attributes);
417
-      if ($v_result != 1) {
413
+        $v_result = $this->privFileDescrParseAtt($v_entry,
414
+                                                $v_filedescr_list[],
415
+                                                $v_options,
416
+                                                $v_supported_attributes);
417
+        if ($v_result != 1) {
418 418
         return 0;
419
-      }
419
+        }
420 420
     }
421 421
 
422 422
     // ----- Expand the filelist (expand directories)
423 423
     $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
424 424
     if ($v_result != 1) {
425
-      return 0;
425
+        return 0;
426 426
     }
427 427
 
428 428
     // ----- Call the create fct
429 429
     $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
430 430
     if ($v_result != 1) {
431
-      return 0;
431
+        return 0;
432 432
     }
433 433
 
434 434
     // ----- Return
435 435
     return $p_result_list;
436
-  }
437
-  // --------------------------------------------------------------------------------
438
-
439
-  // --------------------------------------------------------------------------------
440
-  // Function :
441
-  //   add($p_filelist, $p_add_dir="", $p_remove_dir="")
442
-  //   add($p_filelist, $p_option, $p_option_value, ...)
443
-  // Description :
444
-  //   This method supports two synopsis. The first one is historical.
445
-  //   This methods add the list of files in an existing archive.
446
-  //   If a file with the same name already exists, it is added at the end of the
447
-  //   archive, the first one is still present.
448
-  //   If the archive does not exist, it is created.
449
-  // Parameters :
450
-  //   $p_filelist : An array containing file or directory names, or
451
-  //                 a string containing one filename or one directory name, or
452
-  //                 a string containing a list of filenames and/or directory
453
-  //                 names separated by spaces.
454
-  //   $p_add_dir : A path to add before the real path of the archived file,
455
-  //                in order to have it memorized in the archive.
456
-  //   $p_remove_dir : A path to remove from the real path of the file to archive,
457
-  //                   in order to have a shorter path memorized in the archive.
458
-  //                   When $p_add_dir and $p_remove_dir are set, $p_remove_dir
459
-  //                   is removed first, before $p_add_dir is added.
460
-  // Options :
461
-  //   PCLZIP_OPT_ADD_PATH :
462
-  //   PCLZIP_OPT_REMOVE_PATH :
463
-  //   PCLZIP_OPT_REMOVE_ALL_PATH :
464
-  //   PCLZIP_OPT_COMMENT :
465
-  //   PCLZIP_OPT_ADD_COMMENT :
466
-  //   PCLZIP_OPT_PREPEND_COMMENT :
467
-  //   PCLZIP_CB_PRE_ADD :
468
-  //   PCLZIP_CB_POST_ADD :
469
-  // Return Values :
470
-  //   0 on failure,
471
-  //   The list of the added files, with a status of the add action.
472
-  //   (see PclZip::listContent() for list entry format)
473
-  // --------------------------------------------------------------------------------
474
-  function add($p_filelist)
475
-  {
436
+    }
437
+    // --------------------------------------------------------------------------------
438
+
439
+    // --------------------------------------------------------------------------------
440
+    // Function :
441
+    //   add($p_filelist, $p_add_dir="", $p_remove_dir="")
442
+    //   add($p_filelist, $p_option, $p_option_value, ...)
443
+    // Description :
444
+    //   This method supports two synopsis. The first one is historical.
445
+    //   This methods add the list of files in an existing archive.
446
+    //   If a file with the same name already exists, it is added at the end of the
447
+    //   archive, the first one is still present.
448
+    //   If the archive does not exist, it is created.
449
+    // Parameters :
450
+    //   $p_filelist : An array containing file or directory names, or
451
+    //                 a string containing one filename or one directory name, or
452
+    //                 a string containing a list of filenames and/or directory
453
+    //                 names separated by spaces.
454
+    //   $p_add_dir : A path to add before the real path of the archived file,
455
+    //                in order to have it memorized in the archive.
456
+    //   $p_remove_dir : A path to remove from the real path of the file to archive,
457
+    //                   in order to have a shorter path memorized in the archive.
458
+    //                   When $p_add_dir and $p_remove_dir are set, $p_remove_dir
459
+    //                   is removed first, before $p_add_dir is added.
460
+    // Options :
461
+    //   PCLZIP_OPT_ADD_PATH :
462
+    //   PCLZIP_OPT_REMOVE_PATH :
463
+    //   PCLZIP_OPT_REMOVE_ALL_PATH :
464
+    //   PCLZIP_OPT_COMMENT :
465
+    //   PCLZIP_OPT_ADD_COMMENT :
466
+    //   PCLZIP_OPT_PREPEND_COMMENT :
467
+    //   PCLZIP_CB_PRE_ADD :
468
+    //   PCLZIP_CB_POST_ADD :
469
+    // Return Values :
470
+    //   0 on failure,
471
+    //   The list of the added files, with a status of the add action.
472
+    //   (see PclZip::listContent() for list entry format)
473
+    // --------------------------------------------------------------------------------
474
+    function add($p_filelist)
475
+    {
476 476
     $v_result=1;
477 477
 
478 478
     // ----- Reset the error handler
@@ -487,57 +487,57 @@  discard block
 block discarded – undo
487 487
 
488 488
     // ----- Look for arguments
489 489
     if ($v_size > 1) {
490
-      // ----- Get the arguments
491
-      $v_arg_list = func_get_args();
490
+        // ----- Get the arguments
491
+        $v_arg_list = func_get_args();
492 492
 
493
-      // ----- Remove form the options list the first argument
494
-      array_shift($v_arg_list);
495
-      $v_size--;
493
+        // ----- Remove form the options list the first argument
494
+        array_shift($v_arg_list);
495
+        $v_size--;
496 496
 
497
-      // ----- Look for first arg
498
-      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
497
+        // ----- Look for first arg
498
+        if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
499 499
 
500 500
         // ----- Parse the options
501 501
         $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
502 502
                                             array (PCLZIP_OPT_REMOVE_PATH => 'optional',
503
-                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
504
-                                                   PCLZIP_OPT_ADD_PATH => 'optional',
505
-                                                   PCLZIP_CB_PRE_ADD => 'optional',
506
-                                                   PCLZIP_CB_POST_ADD => 'optional',
507
-                                                   PCLZIP_OPT_NO_COMPRESSION => 'optional',
508
-                                                   PCLZIP_OPT_COMMENT => 'optional',
509
-                                                   PCLZIP_OPT_ADD_COMMENT => 'optional',
510
-                                                   PCLZIP_OPT_PREPEND_COMMENT => 'optional',
511
-                                                   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
512
-                                                   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
513
-                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
514
-                                                   //, PCLZIP_OPT_CRYPT => 'optional'
515
-												   ));
503
+                                                    PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
504
+                                                    PCLZIP_OPT_ADD_PATH => 'optional',
505
+                                                    PCLZIP_CB_PRE_ADD => 'optional',
506
+                                                    PCLZIP_CB_POST_ADD => 'optional',
507
+                                                    PCLZIP_OPT_NO_COMPRESSION => 'optional',
508
+                                                    PCLZIP_OPT_COMMENT => 'optional',
509
+                                                    PCLZIP_OPT_ADD_COMMENT => 'optional',
510
+                                                    PCLZIP_OPT_PREPEND_COMMENT => 'optional',
511
+                                                    PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
512
+                                                    PCLZIP_OPT_TEMP_FILE_ON => 'optional',
513
+                                                    PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
514
+                                                    //, PCLZIP_OPT_CRYPT => 'optional'
515
+                                                    ));
516 516
         if ($v_result != 1) {
517
-          return 0;
517
+            return 0;
518
+        }
518 519
         }
519
-      }
520 520
 
521
-      // ----- Look for 2 args
522
-      // Here we need to support the first historic synopsis of the
523
-      // method.
524
-      else {
521
+        // ----- Look for 2 args
522
+        // Here we need to support the first historic synopsis of the
523
+        // method.
524
+        else {
525 525
 
526 526
         // ----- Get the first argument
527 527
         $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
528 528
 
529 529
         // ----- Look for the optional second argument
530 530
         if ($v_size == 2) {
531
-          $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
531
+            $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
532 532
         }
533 533
         else if ($v_size > 2) {
534
-          // ----- Error log
535
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
534
+            // ----- Error log
535
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
536 536
 
537
-          // ----- Return
538
-          return 0;
537
+            // ----- Return
538
+            return 0;
539
+        }
539 540
         }
540
-      }
541 541
     }
542 542
 
543 543
     // ----- Look for default option values
@@ -552,116 +552,116 @@  discard block
 block discarded – undo
552 552
     // ----- Look if the $p_filelist is really an array
553 553
     if (is_array($p_filelist)) {
554 554
 
555
-      // ----- Look if the first element is also an array
556
-      //       This will mean that this is a file description entry
557
-      if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
555
+        // ----- Look if the first element is also an array
556
+        //       This will mean that this is a file description entry
557
+        if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
558 558
         $v_att_list = $p_filelist;
559
-      }
559
+        }
560 560
 
561
-      // ----- The list is a list of string names
562
-      else {
561
+        // ----- The list is a list of string names
562
+        else {
563 563
         $v_string_list = $p_filelist;
564
-      }
564
+        }
565 565
     }
566 566
 
567 567
     // ----- Look if the $p_filelist is a string
568 568
     else if (is_string($p_filelist)) {
569
-      // ----- Create a list from the string
570
-      $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
569
+        // ----- Create a list from the string
570
+        $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
571 571
     }
572 572
 
573 573
     // ----- Invalid variable type for $p_filelist
574 574
     else {
575
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
576
-      return 0;
575
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
576
+        return 0;
577 577
     }
578 578
 
579 579
     // ----- Reformat the string list
580 580
     if (sizeof($v_string_list) != 0) {
581
-      foreach ($v_string_list as $v_string) {
581
+        foreach ($v_string_list as $v_string) {
582 582
         $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
583
-      }
583
+        }
584 584
     }
585 585
 
586 586
     // ----- For each file in the list check the attributes
587 587
     $v_supported_attributes
588 588
     = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
589
-             ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
590
-             ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
591
-             ,PCLZIP_ATT_FILE_MTIME => 'optional'
592
-             ,PCLZIP_ATT_FILE_CONTENT => 'optional'
593
-             ,PCLZIP_ATT_FILE_COMMENT => 'optional'
594
-						);
589
+                ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
590
+                ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
591
+                ,PCLZIP_ATT_FILE_MTIME => 'optional'
592
+                ,PCLZIP_ATT_FILE_CONTENT => 'optional'
593
+                ,PCLZIP_ATT_FILE_COMMENT => 'optional'
594
+                        );
595 595
     foreach ($v_att_list as $v_entry) {
596
-      $v_result = $this->privFileDescrParseAtt($v_entry,
597
-                                               $v_filedescr_list[],
598
-                                               $v_options,
599
-                                               $v_supported_attributes);
600
-      if ($v_result != 1) {
596
+        $v_result = $this->privFileDescrParseAtt($v_entry,
597
+                                                $v_filedescr_list[],
598
+                                                $v_options,
599
+                                                $v_supported_attributes);
600
+        if ($v_result != 1) {
601 601
         return 0;
602
-      }
602
+        }
603 603
     }
604 604
 
605 605
     // ----- Expand the filelist (expand directories)
606 606
     $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
607 607
     if ($v_result != 1) {
608
-      return 0;
608
+        return 0;
609 609
     }
610 610
 
611 611
     // ----- Call the create fct
612 612
     $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
613 613
     if ($v_result != 1) {
614
-      return 0;
614
+        return 0;
615 615
     }
616 616
 
617 617
     // ----- Return
618 618
     return $p_result_list;
619
-  }
620
-  // --------------------------------------------------------------------------------
621
-
622
-  // --------------------------------------------------------------------------------
623
-  // Function : listContent()
624
-  // Description :
625
-  //   This public method, gives the list of the files and directories, with their
626
-  //   properties.
627
-  //   The properties of each entries in the list are (used also in other functions) :
628
-  //     filename : Name of the file. For a create or add action it is the filename
629
-  //                given by the user. For an extract function it is the filename
630
-  //                of the extracted file.
631
-  //     stored_filename : Name of the file / directory stored in the archive.
632
-  //     size : Size of the stored file.
633
-  //     compressed_size : Size of the file's data compressed in the archive
634
-  //                       (without the headers overhead)
635
-  //     mtime : Last known modification date of the file (UNIX timestamp)
636
-  //     comment : Comment associated with the file
637
-  //     folder : true | false
638
-  //     index : index of the file in the archive
639
-  //     status : status of the action (depending of the action) :
640
-  //              Values are :
641
-  //                ok : OK !
642
-  //                filtered : the file / dir is not extracted (filtered by user)
643
-  //                already_a_directory : the file can not be extracted because a
644
-  //                                      directory with the same name already exists
645
-  //                write_protected : the file can not be extracted because a file
646
-  //                                  with the same name already exists and is
647
-  //                                  write protected
648
-  //                newer_exist : the file was not extracted because a newer file exists
649
-  //                path_creation_fail : the file is not extracted because the folder
650
-  //                                     does not exist and can not be created
651
-  //                write_error : the file was not extracted because there was a
652
-  //                              error while writing the file
653
-  //                read_error : the file was not extracted because there was a error
654
-  //                             while reading the file
655
-  //                invalid_header : the file was not extracted because of an archive
656
-  //                                 format error (bad file header)
657
-  //   Note that each time a method can continue operating when there
658
-  //   is an action error on a file, the error is only logged in the file status.
659
-  // Return Values :
660
-  //   0 on an unrecoverable failure,
661
-  //   The list of the files in the archive.
662
-  // --------------------------------------------------------------------------------
663
-  function listContent()
664
-  {
619
+    }
620
+    // --------------------------------------------------------------------------------
621
+
622
+    // --------------------------------------------------------------------------------
623
+    // Function : listContent()
624
+    // Description :
625
+    //   This public method, gives the list of the files and directories, with their
626
+    //   properties.
627
+    //   The properties of each entries in the list are (used also in other functions) :
628
+    //     filename : Name of the file. For a create or add action it is the filename
629
+    //                given by the user. For an extract function it is the filename
630
+    //                of the extracted file.
631
+    //     stored_filename : Name of the file / directory stored in the archive.
632
+    //     size : Size of the stored file.
633
+    //     compressed_size : Size of the file's data compressed in the archive
634
+    //                       (without the headers overhead)
635
+    //     mtime : Last known modification date of the file (UNIX timestamp)
636
+    //     comment : Comment associated with the file
637
+    //     folder : true | false
638
+    //     index : index of the file in the archive
639
+    //     status : status of the action (depending of the action) :
640
+    //              Values are :
641
+    //                ok : OK !
642
+    //                filtered : the file / dir is not extracted (filtered by user)
643
+    //                already_a_directory : the file can not be extracted because a
644
+    //                                      directory with the same name already exists
645
+    //                write_protected : the file can not be extracted because a file
646
+    //                                  with the same name already exists and is
647
+    //                                  write protected
648
+    //                newer_exist : the file was not extracted because a newer file exists
649
+    //                path_creation_fail : the file is not extracted because the folder
650
+    //                                     does not exist and can not be created
651
+    //                write_error : the file was not extracted because there was a
652
+    //                              error while writing the file
653
+    //                read_error : the file was not extracted because there was a error
654
+    //                             while reading the file
655
+    //                invalid_header : the file was not extracted because of an archive
656
+    //                                 format error (bad file header)
657
+    //   Note that each time a method can continue operating when there
658
+    //   is an action error on a file, the error is only logged in the file status.
659
+    // Return Values :
660
+    //   0 on an unrecoverable failure,
661
+    //   The list of the files in the archive.
662
+    // --------------------------------------------------------------------------------
663
+    function listContent()
664
+    {
665 665
     $v_result=1;
666 666
 
667 667
     // ----- Reset the error handler
@@ -669,56 +669,56 @@  discard block
 block discarded – undo
669 669
 
670 670
     // ----- Check archive
671 671
     if (!$this->privCheckFormat()) {
672
-      return(0);
672
+        return(0);
673 673
     }
674 674
 
675 675
     // ----- Call the extracting fct
676 676
     $p_list = array();
677 677
     if (($v_result = $this->privList($p_list)) != 1)
678 678
     {
679
-      unset($p_list);
680
-      return(0);
679
+        unset($p_list);
680
+        return(0);
681 681
     }
682 682
 
683 683
     // ----- Return
684 684
     return $p_list;
685
-  }
686
-  // --------------------------------------------------------------------------------
687
-
688
-  // --------------------------------------------------------------------------------
689
-  // Function :
690
-  //   extract($p_path="./", $p_remove_path="")
691
-  //   extract([$p_option, $p_option_value, ...])
692
-  // Description :
693
-  //   This method supports two synopsis. The first one is historical.
694
-  //   This method extract all the files / directories from the archive to the
695
-  //   folder indicated in $p_path.
696
-  //   If you want to ignore the 'root' part of path of the memorized files
697
-  //   you can indicate this in the optional $p_remove_path parameter.
698
-  //   By default, if a newer file with the same name already exists, the
699
-  //   file is not extracted.
700
-  //
701
-  //   If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
702
-  //   are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
703
-  //   at the end of the path value of PCLZIP_OPT_PATH.
704
-  // Parameters :
705
-  //   $p_path : Path where the files and directories are to be extracted
706
-  //   $p_remove_path : First part ('root' part) of the memorized path
707
-  //                    (if any similar) to remove while extracting.
708
-  // Options :
709
-  //   PCLZIP_OPT_PATH :
710
-  //   PCLZIP_OPT_ADD_PATH :
711
-  //   PCLZIP_OPT_REMOVE_PATH :
712
-  //   PCLZIP_OPT_REMOVE_ALL_PATH :
713
-  //   PCLZIP_CB_PRE_EXTRACT :
714
-  //   PCLZIP_CB_POST_EXTRACT :
715
-  // Return Values :
716
-  //   0 or a negative value on failure,
717
-  //   The list of the extracted files, with a status of the action.
718
-  //   (see PclZip::listContent() for list entry format)
719
-  // --------------------------------------------------------------------------------
720
-  function extract()
721
-  {
685
+    }
686
+    // --------------------------------------------------------------------------------
687
+
688
+    // --------------------------------------------------------------------------------
689
+    // Function :
690
+    //   extract($p_path="./", $p_remove_path="")
691
+    //   extract([$p_option, $p_option_value, ...])
692
+    // Description :
693
+    //   This method supports two synopsis. The first one is historical.
694
+    //   This method extract all the files / directories from the archive to the
695
+    //   folder indicated in $p_path.
696
+    //   If you want to ignore the 'root' part of path of the memorized files
697
+    //   you can indicate this in the optional $p_remove_path parameter.
698
+    //   By default, if a newer file with the same name already exists, the
699
+    //   file is not extracted.
700
+    //
701
+    //   If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
702
+    //   are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
703
+    //   at the end of the path value of PCLZIP_OPT_PATH.
704
+    // Parameters :
705
+    //   $p_path : Path where the files and directories are to be extracted
706
+    //   $p_remove_path : First part ('root' part) of the memorized path
707
+    //                    (if any similar) to remove while extracting.
708
+    // Options :
709
+    //   PCLZIP_OPT_PATH :
710
+    //   PCLZIP_OPT_ADD_PATH :
711
+    //   PCLZIP_OPT_REMOVE_PATH :
712
+    //   PCLZIP_OPT_REMOVE_ALL_PATH :
713
+    //   PCLZIP_CB_PRE_EXTRACT :
714
+    //   PCLZIP_CB_POST_EXTRACT :
715
+    // Return Values :
716
+    //   0 or a negative value on failure,
717
+    //   The list of the extracted files, with a status of the action.
718
+    //   (see PclZip::listContent() for list entry format)
719
+    // --------------------------------------------------------------------------------
720
+    function extract()
721
+    {
722 722
     $v_result=1;
723 723
 
724 724
     // ----- Reset the error handler
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 
727 727
     // ----- Check archive
728 728
     if (!$this->privCheckFormat()) {
729
-      return(0);
729
+        return(0);
730 730
     }
731 731
 
732 732
     // ----- Set default values
@@ -744,77 +744,77 @@  discard block
 block discarded – undo
744 744
 
745 745
     // ----- Look for arguments
746 746
     if ($v_size > 0) {
747
-      // ----- Get the arguments
748
-      $v_arg_list = func_get_args();
747
+        // ----- Get the arguments
748
+        $v_arg_list = func_get_args();
749 749
 
750
-      // ----- Look for first arg
751
-      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
750
+        // ----- Look for first arg
751
+        if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
752 752
 
753 753
         // ----- Parse the options
754 754
         $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
755 755
                                             array (PCLZIP_OPT_PATH => 'optional',
756
-                                                   PCLZIP_OPT_REMOVE_PATH => 'optional',
757
-                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
758
-                                                   PCLZIP_OPT_ADD_PATH => 'optional',
759
-                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',
760
-                                                   PCLZIP_CB_POST_EXTRACT => 'optional',
761
-                                                   PCLZIP_OPT_SET_CHMOD => 'optional',
762
-                                                   PCLZIP_OPT_BY_NAME => 'optional',
763
-                                                   PCLZIP_OPT_BY_EREG => 'optional',
764
-                                                   PCLZIP_OPT_BY_PREG => 'optional',
765
-                                                   PCLZIP_OPT_BY_INDEX => 'optional',
766
-                                                   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
767
-                                                   PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
768
-                                                   PCLZIP_OPT_REPLACE_NEWER => 'optional'
769
-                                                   ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
770
-                                                   ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
771
-                                                   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
772
-                                                   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
773
-                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
774
-												    ));
756
+                                                    PCLZIP_OPT_REMOVE_PATH => 'optional',
757
+                                                    PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
758
+                                                    PCLZIP_OPT_ADD_PATH => 'optional',
759
+                                                    PCLZIP_CB_PRE_EXTRACT => 'optional',
760
+                                                    PCLZIP_CB_POST_EXTRACT => 'optional',
761
+                                                    PCLZIP_OPT_SET_CHMOD => 'optional',
762
+                                                    PCLZIP_OPT_BY_NAME => 'optional',
763
+                                                    PCLZIP_OPT_BY_EREG => 'optional',
764
+                                                    PCLZIP_OPT_BY_PREG => 'optional',
765
+                                                    PCLZIP_OPT_BY_INDEX => 'optional',
766
+                                                    PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
767
+                                                    PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
768
+                                                    PCLZIP_OPT_REPLACE_NEWER => 'optional'
769
+                                                    ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
770
+                                                    ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
771
+                                                    PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
772
+                                                    PCLZIP_OPT_TEMP_FILE_ON => 'optional',
773
+                                                    PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
774
+                                                    ));
775 775
         if ($v_result != 1) {
776
-          return 0;
776
+            return 0;
777 777
         }
778 778
 
779 779
         // ----- Set the arguments
780 780
         if (isset($v_options[PCLZIP_OPT_PATH])) {
781
-          $v_path = $v_options[PCLZIP_OPT_PATH];
781
+            $v_path = $v_options[PCLZIP_OPT_PATH];
782 782
         }
783 783
         if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
784
-          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
784
+            $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
785 785
         }
786 786
         if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
787
-          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
787
+            $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
788 788
         }
789 789
         if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
790
-          // ----- Check for '/' in last path char
791
-          if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
790
+            // ----- Check for '/' in last path char
791
+            if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
792 792
             $v_path .= '/';
793
-          }
794
-          $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
793
+            }
794
+            $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
795
+        }
795 796
         }
796
-      }
797 797
 
798
-      // ----- Look for 2 args
799
-      // Here we need to support the first historic synopsis of the
800
-      // method.
801
-      else {
798
+        // ----- Look for 2 args
799
+        // Here we need to support the first historic synopsis of the
800
+        // method.
801
+        else {
802 802
 
803 803
         // ----- Get the first argument
804 804
         $v_path = $v_arg_list[0];
805 805
 
806 806
         // ----- Look for the optional second argument
807 807
         if ($v_size == 2) {
808
-          $v_remove_path = $v_arg_list[1];
808
+            $v_remove_path = $v_arg_list[1];
809 809
         }
810 810
         else if ($v_size > 2) {
811
-          // ----- Error log
812
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
811
+            // ----- Error log
812
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
813 813
 
814
-          // ----- Return
815
-          return 0;
814
+            // ----- Return
815
+            return 0;
816
+        }
816 817
         }
817
-      }
818 818
     }
819 819
 
820 820
     // ----- Look for default option values
@@ -825,57 +825,57 @@  discard block
 block discarded – undo
825 825
     // ----- Call the extracting fct
826 826
     $p_list = array();
827 827
     $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path,
828
-	                                     $v_remove_all_path, $v_options);
828
+                                            $v_remove_all_path, $v_options);
829 829
     if ($v_result < 1) {
830
-      unset($p_list);
831
-      return(0);
830
+        unset($p_list);
831
+        return(0);
832 832
     }
833 833
 
834 834
     // ----- Return
835 835
     return $p_list;
836
-  }
837
-  // --------------------------------------------------------------------------------
838
-
839
-
840
-  // --------------------------------------------------------------------------------
841
-  // Function :
842
-  //   extractByIndex($p_index, $p_path="./", $p_remove_path="")
843
-  //   extractByIndex($p_index, [$p_option, $p_option_value, ...])
844
-  // Description :
845
-  //   This method supports two synopsis. The first one is historical.
846
-  //   This method is doing a partial extract of the archive.
847
-  //   The extracted files or folders are identified by their index in the
848
-  //   archive (from 0 to n).
849
-  //   Note that if the index identify a folder, only the folder entry is
850
-  //   extracted, not all the files included in the archive.
851
-  // Parameters :
852
-  //   $p_index : A single index (integer) or a string of indexes of files to
853
-  //              extract. The form of the string is "0,4-6,8-12" with only numbers
854
-  //              and '-' for range or ',' to separate ranges. No spaces or ';'
855
-  //              are allowed.
856
-  //   $p_path : Path where the files and directories are to be extracted
857
-  //   $p_remove_path : First part ('root' part) of the memorized path
858
-  //                    (if any similar) to remove while extracting.
859
-  // Options :
860
-  //   PCLZIP_OPT_PATH :
861
-  //   PCLZIP_OPT_ADD_PATH :
862
-  //   PCLZIP_OPT_REMOVE_PATH :
863
-  //   PCLZIP_OPT_REMOVE_ALL_PATH :
864
-  //   PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and
865
-  //     not as files.
866
-  //     The resulting content is in a new field 'content' in the file
867
-  //     structure.
868
-  //     This option must be used alone (any other options are ignored).
869
-  //   PCLZIP_CB_PRE_EXTRACT :
870
-  //   PCLZIP_CB_POST_EXTRACT :
871
-  // Return Values :
872
-  //   0 on failure,
873
-  //   The list of the extracted files, with a status of the action.
874
-  //   (see PclZip::listContent() for list entry format)
875
-  // --------------------------------------------------------------------------------
876
-  //function extractByIndex($p_index, options...)
877
-  function extractByIndex($p_index)
878
-  {
836
+    }
837
+    // --------------------------------------------------------------------------------
838
+
839
+
840
+    // --------------------------------------------------------------------------------
841
+    // Function :
842
+    //   extractByIndex($p_index, $p_path="./", $p_remove_path="")
843
+    //   extractByIndex($p_index, [$p_option, $p_option_value, ...])
844
+    // Description :
845
+    //   This method supports two synopsis. The first one is historical.
846
+    //   This method is doing a partial extract of the archive.
847
+    //   The extracted files or folders are identified by their index in the
848
+    //   archive (from 0 to n).
849
+    //   Note that if the index identify a folder, only the folder entry is
850
+    //   extracted, not all the files included in the archive.
851
+    // Parameters :
852
+    //   $p_index : A single index (integer) or a string of indexes of files to
853
+    //              extract. The form of the string is "0,4-6,8-12" with only numbers
854
+    //              and '-' for range or ',' to separate ranges. No spaces or ';'
855
+    //              are allowed.
856
+    //   $p_path : Path where the files and directories are to be extracted
857
+    //   $p_remove_path : First part ('root' part) of the memorized path
858
+    //                    (if any similar) to remove while extracting.
859
+    // Options :
860
+    //   PCLZIP_OPT_PATH :
861
+    //   PCLZIP_OPT_ADD_PATH :
862
+    //   PCLZIP_OPT_REMOVE_PATH :
863
+    //   PCLZIP_OPT_REMOVE_ALL_PATH :
864
+    //   PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and
865
+    //     not as files.
866
+    //     The resulting content is in a new field 'content' in the file
867
+    //     structure.
868
+    //     This option must be used alone (any other options are ignored).
869
+    //   PCLZIP_CB_PRE_EXTRACT :
870
+    //   PCLZIP_CB_POST_EXTRACT :
871
+    // Return Values :
872
+    //   0 on failure,
873
+    //   The list of the extracted files, with a status of the action.
874
+    //   (see PclZip::listContent() for list entry format)
875
+    // --------------------------------------------------------------------------------
876
+    //function extractByIndex($p_index, options...)
877
+    function extractByIndex($p_index)
878
+    {
879 879
     $v_result=1;
880 880
 
881 881
     // ----- Reset the error handler
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
 
884 884
     // ----- Check archive
885 885
     if (!$this->privCheckFormat()) {
886
-      return(0);
886
+        return(0);
887 887
     }
888 888
 
889 889
     // ----- Set default values
@@ -901,81 +901,81 @@  discard block
 block discarded – undo
901 901
 
902 902
     // ----- Look for arguments
903 903
     if ($v_size > 1) {
904
-      // ----- Get the arguments
905
-      $v_arg_list = func_get_args();
904
+        // ----- Get the arguments
905
+        $v_arg_list = func_get_args();
906 906
 
907
-      // ----- Remove form the options list the first argument
908
-      array_shift($v_arg_list);
909
-      $v_size--;
907
+        // ----- Remove form the options list the first argument
908
+        array_shift($v_arg_list);
909
+        $v_size--;
910 910
 
911
-      // ----- Look for first arg
912
-      if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
911
+        // ----- Look for first arg
912
+        if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
913 913
 
914 914
         // ----- Parse the options
915 915
         $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
916 916
                                             array (PCLZIP_OPT_PATH => 'optional',
917
-                                                   PCLZIP_OPT_REMOVE_PATH => 'optional',
918
-                                                   PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
919
-                                                   PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
920
-                                                   PCLZIP_OPT_ADD_PATH => 'optional',
921
-                                                   PCLZIP_CB_PRE_EXTRACT => 'optional',
922
-                                                   PCLZIP_CB_POST_EXTRACT => 'optional',
923
-                                                   PCLZIP_OPT_SET_CHMOD => 'optional',
924
-                                                   PCLZIP_OPT_REPLACE_NEWER => 'optional'
925
-                                                   ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
926
-                                                   ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
927
-                                                   PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
928
-                                                   PCLZIP_OPT_TEMP_FILE_ON => 'optional',
929
-                                                   PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
930
-												   ));
917
+                                                    PCLZIP_OPT_REMOVE_PATH => 'optional',
918
+                                                    PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
919
+                                                    PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
920
+                                                    PCLZIP_OPT_ADD_PATH => 'optional',
921
+                                                    PCLZIP_CB_PRE_EXTRACT => 'optional',
922
+                                                    PCLZIP_CB_POST_EXTRACT => 'optional',
923
+                                                    PCLZIP_OPT_SET_CHMOD => 'optional',
924
+                                                    PCLZIP_OPT_REPLACE_NEWER => 'optional'
925
+                                                    ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
926
+                                                    ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional',
927
+                                                    PCLZIP_OPT_TEMP_FILE_THRESHOLD => 'optional',
928
+                                                    PCLZIP_OPT_TEMP_FILE_ON => 'optional',
929
+                                                    PCLZIP_OPT_TEMP_FILE_OFF => 'optional'
930
+                                                    ));
931 931
         if ($v_result != 1) {
932
-          return 0;
932
+            return 0;
933 933
         }
934 934
 
935 935
         // ----- Set the arguments
936 936
         if (isset($v_options[PCLZIP_OPT_PATH])) {
937
-          $v_path = $v_options[PCLZIP_OPT_PATH];
937
+            $v_path = $v_options[PCLZIP_OPT_PATH];
938 938
         }
939 939
         if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
940
-          $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
940
+            $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
941 941
         }
942 942
         if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
943
-          $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
943
+            $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
944 944
         }
945 945
         if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
946
-          // ----- Check for '/' in last path char
947
-          if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
946
+            // ----- Check for '/' in last path char
947
+            if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
948 948
             $v_path .= '/';
949
-          }
950
-          $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
949
+            }
950
+            $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
951 951
         }
952 952
         if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
953
-          $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
953
+            $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
954 954
         }
955 955
         else {
956 956
         }
957
-      }
957
+        }
958 958
 
959
-      // ----- Look for 2 args
960
-      // Here we need to support the first historic synopsis of the
961
-      // method.
962
-      else {
959
+        // ----- Look for 2 args
960
+        // Here we need to support the first historic synopsis of the
961
+        // method.
962
+        else {
963 963
 
964 964
         // ----- Get the first argument
965 965
         $v_path = $v_arg_list[0];
966 966
 
967 967
         // ----- Look for the optional second argument
968 968
         if ($v_size == 2) {
969
-          $v_remove_path = $v_arg_list[1];
969
+            $v_remove_path = $v_arg_list[1];
970 970
         }
971 971
         else if ($v_size > 2) {
972
-          // ----- Error log
973
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
972
+            // ----- Error log
973
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
974 974
 
975
-          // ----- Return
976
-          return 0;
975
+            // ----- Return
976
+            return 0;
977
+        }
977 978
         }
978
-      }
979 979
     }
980 980
 
981 981
     // ----- Trace
@@ -1002,29 +1002,29 @@  discard block
 block discarded – undo
1002 1002
 
1003 1003
     // ----- Return
1004 1004
     return $p_list;
1005
-  }
1006
-  // --------------------------------------------------------------------------------
1007
-
1008
-  // --------------------------------------------------------------------------------
1009
-  // Function :
1010
-  //   delete([$p_option, $p_option_value, ...])
1011
-  // Description :
1012
-  //   This method removes files from the archive.
1013
-  //   If no parameters are given, then all the archive is emptied.
1014
-  // Parameters :
1015
-  //   None or optional arguments.
1016
-  // Options :
1017
-  //   PCLZIP_OPT_BY_INDEX :
1018
-  //   PCLZIP_OPT_BY_NAME :
1019
-  //   PCLZIP_OPT_BY_EREG :
1020
-  //   PCLZIP_OPT_BY_PREG :
1021
-  // Return Values :
1022
-  //   0 on failure,
1023
-  //   The list of the files which are still present in the archive.
1024
-  //   (see PclZip::listContent() for list entry format)
1025
-  // --------------------------------------------------------------------------------
1026
-  function delete()
1027
-  {
1005
+    }
1006
+    // --------------------------------------------------------------------------------
1007
+
1008
+    // --------------------------------------------------------------------------------
1009
+    // Function :
1010
+    //   delete([$p_option, $p_option_value, ...])
1011
+    // Description :
1012
+    //   This method removes files from the archive.
1013
+    //   If no parameters are given, then all the archive is emptied.
1014
+    // Parameters :
1015
+    //   None or optional arguments.
1016
+    // Options :
1017
+    //   PCLZIP_OPT_BY_INDEX :
1018
+    //   PCLZIP_OPT_BY_NAME :
1019
+    //   PCLZIP_OPT_BY_EREG :
1020
+    //   PCLZIP_OPT_BY_PREG :
1021
+    // Return Values :
1022
+    //   0 on failure,
1023
+    //   The list of the files which are still present in the archive.
1024
+    //   (see PclZip::listContent() for list entry format)
1025
+    // --------------------------------------------------------------------------------
1026
+    function delete()
1027
+    {
1028 1028
     $v_result=1;
1029 1029
 
1030 1030
     // ----- Reset the error handler
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
 
1033 1033
     // ----- Check archive
1034 1034
     if (!$this->privCheckFormat()) {
1035
-      return(0);
1035
+        return(0);
1036 1036
     }
1037 1037
 
1038 1038
     // ----- Set default values
@@ -1043,18 +1043,18 @@  discard block
 block discarded – undo
1043 1043
 
1044 1044
     // ----- Look for arguments
1045 1045
     if ($v_size > 0) {
1046
-      // ----- Get the arguments
1047
-      $v_arg_list = func_get_args();
1046
+        // ----- Get the arguments
1047
+        $v_arg_list = func_get_args();
1048 1048
 
1049
-      // ----- Parse the options
1050
-      $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
1049
+        // ----- Parse the options
1050
+        $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
1051 1051
                                         array (PCLZIP_OPT_BY_NAME => 'optional',
1052
-                                               PCLZIP_OPT_BY_EREG => 'optional',
1053
-                                               PCLZIP_OPT_BY_PREG => 'optional',
1054
-                                               PCLZIP_OPT_BY_INDEX => 'optional' ));
1055
-      if ($v_result != 1) {
1056
-          return 0;
1057
-      }
1052
+                                                PCLZIP_OPT_BY_EREG => 'optional',
1053
+                                                PCLZIP_OPT_BY_PREG => 'optional',
1054
+                                                PCLZIP_OPT_BY_INDEX => 'optional' ));
1055
+        if ($v_result != 1) {
1056
+            return 0;
1057
+        }
1058 1058
     }
1059 1059
 
1060 1060
     // ----- Magic quotes trick
@@ -1063,9 +1063,9 @@  discard block
 block discarded – undo
1063 1063
     // ----- Call the delete fct
1064 1064
     $v_list = array();
1065 1065
     if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
1066
-      $this->privSwapBackMagicQuotes();
1067
-      unset($v_list);
1068
-      return(0);
1066
+        $this->privSwapBackMagicQuotes();
1067
+        unset($v_list);
1068
+        return(0);
1069 1069
     }
1070 1070
 
1071 1071
     // ----- Magic quotes trick
@@ -1073,41 +1073,41 @@  discard block
 block discarded – undo
1073 1073
 
1074 1074
     // ----- Return
1075 1075
     return $v_list;
1076
-  }
1077
-  // --------------------------------------------------------------------------------
1078
-
1079
-  // --------------------------------------------------------------------------------
1080
-  // Function : deleteByIndex()
1081
-  // Description :
1082
-  //   ***** Deprecated *****
1083
-  //   delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered.
1084
-  // --------------------------------------------------------------------------------
1085
-  function deleteByIndex($p_index)
1086
-  {
1076
+    }
1077
+    // --------------------------------------------------------------------------------
1078
+
1079
+    // --------------------------------------------------------------------------------
1080
+    // Function : deleteByIndex()
1081
+    // Description :
1082
+    //   ***** Deprecated *****
1083
+    //   delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered.
1084
+    // --------------------------------------------------------------------------------
1085
+    function deleteByIndex($p_index)
1086
+    {
1087 1087
 
1088 1088
     $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
1089 1089
 
1090 1090
     // ----- Return
1091 1091
     return $p_list;
1092
-  }
1093
-  // --------------------------------------------------------------------------------
1094
-
1095
-  // --------------------------------------------------------------------------------
1096
-  // Function : properties()
1097
-  // Description :
1098
-  //   This method gives the properties of the archive.
1099
-  //   The properties are :
1100
-  //     nb : Number of files in the archive
1101
-  //     comment : Comment associated with the archive file
1102
-  //     status : not_exist, ok
1103
-  // Parameters :
1104
-  //   None
1105
-  // Return Values :
1106
-  //   0 on failure,
1107
-  //   An array with the archive properties.
1108
-  // --------------------------------------------------------------------------------
1109
-  function properties()
1110
-  {
1092
+    }
1093
+    // --------------------------------------------------------------------------------
1094
+
1095
+    // --------------------------------------------------------------------------------
1096
+    // Function : properties()
1097
+    // Description :
1098
+    //   This method gives the properties of the archive.
1099
+    //   The properties are :
1100
+    //     nb : Number of files in the archive
1101
+    //     comment : Comment associated with the archive file
1102
+    //     status : not_exist, ok
1103
+    // Parameters :
1104
+    //   None
1105
+    // Return Values :
1106
+    //   0 on failure,
1107
+    //   An array with the archive properties.
1108
+    // --------------------------------------------------------------------------------
1109
+    function properties()
1110
+    {
1111 1111
 
1112 1112
     // ----- Reset the error handler
1113 1113
     $this->privErrorReset();
@@ -1117,8 +1117,8 @@  discard block
 block discarded – undo
1117 1117
 
1118 1118
     // ----- Check archive
1119 1119
     if (!$this->privCheckFormat()) {
1120
-      $this->privSwapBackMagicQuotes();
1121
-      return(0);
1120
+        $this->privSwapBackMagicQuotes();
1121
+        return(0);
1122 1122
     }
1123 1123
 
1124 1124
     // ----- Default properties
@@ -1130,9 +1130,9 @@  discard block
 block discarded – undo
1130 1130
     // ----- Look if file exists
1131 1131
     if (@is_file($this->zipname))
1132 1132
     {
1133
-      // ----- Open the zip file
1134
-      if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
1135
-      {
1133
+        // ----- Open the zip file
1134
+        if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
1135
+        {
1136 1136
         $this->privSwapBackMagicQuotes();
1137 1137
 
1138 1138
         // ----- Error log
@@ -1140,23 +1140,23 @@  discard block
 block discarded – undo
1140 1140
 
1141 1141
         // ----- Return
1142 1142
         return 0;
1143
-      }
1143
+        }
1144 1144
 
1145
-      // ----- Read the central directory informations
1146
-      $v_central_dir = array();
1147
-      if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
1148
-      {
1145
+        // ----- Read the central directory informations
1146
+        $v_central_dir = array();
1147
+        if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
1148
+        {
1149 1149
         $this->privSwapBackMagicQuotes();
1150 1150
         return 0;
1151
-      }
1151
+        }
1152 1152
 
1153
-      // ----- Close the zip file
1154
-      $this->privCloseFd();
1153
+        // ----- Close the zip file
1154
+        $this->privCloseFd();
1155 1155
 
1156
-      // ----- Set the user attributes
1157
-      $v_prop['comment'] = $v_central_dir['comment'];
1158
-      $v_prop['nb'] = $v_central_dir['entries'];
1159
-      $v_prop['status'] = 'ok';
1156
+        // ----- Set the user attributes
1157
+        $v_prop['comment'] = $v_central_dir['comment'];
1158
+        $v_prop['nb'] = $v_central_dir['entries'];
1159
+        $v_prop['status'] = 'ok';
1160 1160
     }
1161 1161
 
1162 1162
     // ----- Magic quotes trick
@@ -1164,23 +1164,23 @@  discard block
 block discarded – undo
1164 1164
 
1165 1165
     // ----- Return
1166 1166
     return $v_prop;
1167
-  }
1168
-  // --------------------------------------------------------------------------------
1169
-
1170
-  // --------------------------------------------------------------------------------
1171
-  // Function : duplicate()
1172
-  // Description :
1173
-  //   This method creates an archive by copying the content of an other one. If
1174
-  //   the archive already exist, it is replaced by the new one without any warning.
1175
-  // Parameters :
1176
-  //   $p_archive : The filename of a valid archive, or
1177
-  //                a valid PclZip object.
1178
-  // Return Values :
1179
-  //   1 on success.
1180
-  //   0 or a negative value on error (error code).
1181
-  // --------------------------------------------------------------------------------
1182
-  function duplicate($p_archive)
1183
-  {
1167
+    }
1168
+    // --------------------------------------------------------------------------------
1169
+
1170
+    // --------------------------------------------------------------------------------
1171
+    // Function : duplicate()
1172
+    // Description :
1173
+    //   This method creates an archive by copying the content of an other one. If
1174
+    //   the archive already exist, it is replaced by the new one without any warning.
1175
+    // Parameters :
1176
+    //   $p_archive : The filename of a valid archive, or
1177
+    //                a valid PclZip object.
1178
+    // Return Values :
1179
+    //   1 on success.
1180
+    //   0 or a negative value on error (error code).
1181
+    // --------------------------------------------------------------------------------
1182
+    function duplicate($p_archive)
1183
+    {
1184 1184
     $v_result = 1;
1185 1185
 
1186 1186
     // ----- Reset the error handler
@@ -1190,56 +1190,56 @@  discard block
 block discarded – undo
1190 1190
     if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
1191 1191
     {
1192 1192
 
1193
-      // ----- Duplicate the archive
1194
-      $v_result = $this->privDuplicate($p_archive->zipname);
1193
+        // ----- Duplicate the archive
1194
+        $v_result = $this->privDuplicate($p_archive->zipname);
1195 1195
     }
1196 1196
 
1197 1197
     // ----- Look if the $p_archive is a string (so a filename)
1198 1198
     else if (is_string($p_archive))
1199 1199
     {
1200 1200
 
1201
-      // ----- Check that $p_archive is a valid zip file
1202
-      // TBC : Should also check the archive format
1203
-      if (!is_file($p_archive)) {
1201
+        // ----- Check that $p_archive is a valid zip file
1202
+        // TBC : Should also check the archive format
1203
+        if (!is_file($p_archive)) {
1204 1204
         // ----- Error log
1205 1205
         PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
1206 1206
         $v_result = PCLZIP_ERR_MISSING_FILE;
1207
-      }
1208
-      else {
1207
+        }
1208
+        else {
1209 1209
         // ----- Duplicate the archive
1210 1210
         $v_result = $this->privDuplicate($p_archive);
1211
-      }
1211
+        }
1212 1212
     }
1213 1213
 
1214 1214
     // ----- Invalid variable
1215 1215
     else
1216 1216
     {
1217
-      // ----- Error log
1218
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1219
-      $v_result = PCLZIP_ERR_INVALID_PARAMETER;
1217
+        // ----- Error log
1218
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1219
+        $v_result = PCLZIP_ERR_INVALID_PARAMETER;
1220 1220
     }
1221 1221
 
1222 1222
     // ----- Return
1223 1223
     return $v_result;
1224
-  }
1225
-  // --------------------------------------------------------------------------------
1226
-
1227
-  // --------------------------------------------------------------------------------
1228
-  // Function : merge()
1229
-  // Description :
1230
-  //   This method merge the $p_archive_to_add archive at the end of the current
1231
-  //   one ($this).
1232
-  //   If the archive ($this) does not exist, the merge becomes a duplicate.
1233
-  //   If the $p_archive_to_add archive does not exist, the merge is a success.
1234
-  // Parameters :
1235
-  //   $p_archive_to_add : It can be directly the filename of a valid zip archive,
1236
-  //                       or a PclZip object archive.
1237
-  // Return Values :
1238
-  //   1 on success,
1239
-  //   0 or negative values on error (see below).
1240
-  // --------------------------------------------------------------------------------
1241
-  function merge($p_archive_to_add)
1242
-  {
1224
+    }
1225
+    // --------------------------------------------------------------------------------
1226
+
1227
+    // --------------------------------------------------------------------------------
1228
+    // Function : merge()
1229
+    // Description :
1230
+    //   This method merge the $p_archive_to_add archive at the end of the current
1231
+    //   one ($this).
1232
+    //   If the archive ($this) does not exist, the merge becomes a duplicate.
1233
+    //   If the $p_archive_to_add archive does not exist, the merge is a success.
1234
+    // Parameters :
1235
+    //   $p_archive_to_add : It can be directly the filename of a valid zip archive,
1236
+    //                       or a PclZip object archive.
1237
+    // Return Values :
1238
+    //   1 on success,
1239
+    //   0 or negative values on error (see below).
1240
+    // --------------------------------------------------------------------------------
1241
+    function merge($p_archive_to_add)
1242
+    {
1243 1243
     $v_result = 1;
1244 1244
 
1245 1245
     // ----- Reset the error handler
@@ -1247,125 +1247,125 @@  discard block
 block discarded – undo
1247 1247
 
1248 1248
     // ----- Check archive
1249 1249
     if (!$this->privCheckFormat()) {
1250
-      return(0);
1250
+        return(0);
1251 1251
     }
1252 1252
 
1253 1253
     // ----- Look if the $p_archive_to_add is a PclZip object
1254 1254
     if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
1255 1255
     {
1256 1256
 
1257
-      // ----- Merge the archive
1258
-      $v_result = $this->privMerge($p_archive_to_add);
1257
+        // ----- Merge the archive
1258
+        $v_result = $this->privMerge($p_archive_to_add);
1259 1259
     }
1260 1260
 
1261 1261
     // ----- Look if the $p_archive_to_add is a string (so a filename)
1262 1262
     else if (is_string($p_archive_to_add))
1263 1263
     {
1264 1264
 
1265
-      // ----- Create a temporary archive
1266
-      $v_object_archive = new PclZip($p_archive_to_add);
1265
+        // ----- Create a temporary archive
1266
+        $v_object_archive = new PclZip($p_archive_to_add);
1267 1267
 
1268
-      // ----- Merge the archive
1269
-      $v_result = $this->privMerge($v_object_archive);
1268
+        // ----- Merge the archive
1269
+        $v_result = $this->privMerge($v_object_archive);
1270 1270
     }
1271 1271
 
1272 1272
     // ----- Invalid variable
1273 1273
     else
1274 1274
     {
1275
-      // ----- Error log
1276
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1277
-      $v_result = PCLZIP_ERR_INVALID_PARAMETER;
1275
+        // ----- Error log
1276
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1277
+        $v_result = PCLZIP_ERR_INVALID_PARAMETER;
1278 1278
     }
1279 1279
 
1280 1280
     // ----- Return
1281 1281
     return $v_result;
1282
-  }
1283
-  // --------------------------------------------------------------------------------
1282
+    }
1283
+    // --------------------------------------------------------------------------------
1284 1284
 
1285 1285
 
1286 1286
 
1287
-  // --------------------------------------------------------------------------------
1288
-  // Function : errorCode()
1289
-  // Description :
1290
-  // Parameters :
1291
-  // --------------------------------------------------------------------------------
1292
-  function errorCode()
1293
-  {
1287
+    // --------------------------------------------------------------------------------
1288
+    // Function : errorCode()
1289
+    // Description :
1290
+    // Parameters :
1291
+    // --------------------------------------------------------------------------------
1292
+    function errorCode()
1293
+    {
1294 1294
     if (PCLZIP_ERROR_EXTERNAL == 1) {
1295
-      return(PclErrorCode());
1295
+        return(PclErrorCode());
1296 1296
     }
1297 1297
     else {
1298
-      return($this->error_code);
1299
-    }
1300
-  }
1301
-  // --------------------------------------------------------------------------------
1302
-
1303
-  // --------------------------------------------------------------------------------
1304
-  // Function : errorName()
1305
-  // Description :
1306
-  // Parameters :
1307
-  // --------------------------------------------------------------------------------
1308
-  function errorName($p_with_code=false)
1309
-  {
1298
+        return($this->error_code);
1299
+    }
1300
+    }
1301
+    // --------------------------------------------------------------------------------
1302
+
1303
+    // --------------------------------------------------------------------------------
1304
+    // Function : errorName()
1305
+    // Description :
1306
+    // Parameters :
1307
+    // --------------------------------------------------------------------------------
1308
+    function errorName($p_with_code=false)
1309
+    {
1310 1310
     $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
1311
-                      PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
1312
-                      PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
1313
-                      PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
1314
-                      PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
1315
-                      PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
1316
-                      PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
1317
-                      PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
1318
-                      PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
1319
-                      PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
1320
-                      PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
1321
-                      PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
1322
-                      PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
1323
-                      PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
1324
-                      PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
1325
-                      PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
1326
-                      PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
1327
-                      PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
1328
-                      PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION'
1329
-                      ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE'
1330
-                      ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION'
1311
+                        PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
1312
+                        PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
1313
+                        PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
1314
+                        PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
1315
+                        PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
1316
+                        PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
1317
+                        PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
1318
+                        PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
1319
+                        PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
1320
+                        PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
1321
+                        PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
1322
+                        PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
1323
+                        PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
1324
+                        PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
1325
+                        PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
1326
+                        PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
1327
+                        PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
1328
+                        PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION'
1329
+                        ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE'
1330
+                        ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION'
1331 1331
                     );
1332 1332
 
1333 1333
     if (isset($v_name[$this->error_code])) {
1334
-      $v_value = $v_name[$this->error_code];
1334
+        $v_value = $v_name[$this->error_code];
1335 1335
     }
1336 1336
     else {
1337
-      $v_value = 'NoName';
1337
+        $v_value = 'NoName';
1338 1338
     }
1339 1339
 
1340 1340
     if ($p_with_code) {
1341
-      return($v_value.' ('.$this->error_code.')');
1341
+        return($v_value.' ('.$this->error_code.')');
1342 1342
     }
1343 1343
     else {
1344
-      return($v_value);
1345
-    }
1346
-  }
1347
-  // --------------------------------------------------------------------------------
1348
-
1349
-  // --------------------------------------------------------------------------------
1350
-  // Function : errorInfo()
1351
-  // Description :
1352
-  // Parameters :
1353
-  // --------------------------------------------------------------------------------
1354
-  function errorInfo($p_full=false)
1355
-  {
1344
+        return($v_value);
1345
+    }
1346
+    }
1347
+    // --------------------------------------------------------------------------------
1348
+
1349
+    // --------------------------------------------------------------------------------
1350
+    // Function : errorInfo()
1351
+    // Description :
1352
+    // Parameters :
1353
+    // --------------------------------------------------------------------------------
1354
+    function errorInfo($p_full=false)
1355
+    {
1356 1356
     if (PCLZIP_ERROR_EXTERNAL == 1) {
1357
-      return(PclErrorString());
1357
+        return(PclErrorString());
1358 1358
     }
1359 1359
     else {
1360
-      if ($p_full) {
1360
+        if ($p_full) {
1361 1361
         return($this->errorName(true)." : ".$this->error_string);
1362
-      }
1363
-      else {
1362
+        }
1363
+        else {
1364 1364
         return($this->error_string." [code ".$this->error_code."]");
1365
-      }
1365
+        }
1366
+    }
1366 1367
     }
1367
-  }
1368
-  // --------------------------------------------------------------------------------
1368
+    // --------------------------------------------------------------------------------
1369 1369
 
1370 1370
 
1371 1371
 // --------------------------------------------------------------------------------
@@ -1376,25 +1376,25 @@  discard block
 block discarded – undo
1376 1376
 
1377 1377
 
1378 1378
 
1379
-  // --------------------------------------------------------------------------------
1380
-  // Function : privCheckFormat()
1381
-  // Description :
1382
-  //   This method check that the archive exists and is a valid zip archive.
1383
-  //   Several level of check exists. (futur)
1384
-  // Parameters :
1385
-  //   $p_level : Level of check. Default 0.
1386
-  //              0 : Check the first bytes (magic codes) (default value))
1387
-  //              1 : 0 + Check the central directory (futur)
1388
-  //              2 : 1 + Check each file header (futur)
1389
-  // Return Values :
1390
-  //   true on success,
1391
-  //   false on error, the error code is set.
1392
-  // --------------------------------------------------------------------------------
1393
-  function privCheckFormat($p_level=0)
1394
-  {
1379
+    // --------------------------------------------------------------------------------
1380
+    // Function : privCheckFormat()
1381
+    // Description :
1382
+    //   This method check that the archive exists and is a valid zip archive.
1383
+    //   Several level of check exists. (futur)
1384
+    // Parameters :
1385
+    //   $p_level : Level of check. Default 0.
1386
+    //              0 : Check the first bytes (magic codes) (default value))
1387
+    //              1 : 0 + Check the central directory (futur)
1388
+    //              2 : 1 + Check each file header (futur)
1389
+    // Return Values :
1390
+    //   true on success,
1391
+    //   false on error, the error code is set.
1392
+    // --------------------------------------------------------------------------------
1393
+    function privCheckFormat($p_level=0)
1394
+    {
1395 1395
     $v_result = true;
1396 1396
 
1397
-	// ----- Reset the file system cache
1397
+    // ----- Reset the file system cache
1398 1398
     clearstatcache();
1399 1399
 
1400 1400
     // ----- Reset the error handler
@@ -1402,16 +1402,16 @@  discard block
 block discarded – undo
1402 1402
 
1403 1403
     // ----- Look if the file exits
1404 1404
     if (!is_file($this->zipname)) {
1405
-      // ----- Error log
1406
-      PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
1407
-      return(false);
1405
+        // ----- Error log
1406
+        PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
1407
+        return(false);
1408 1408
     }
1409 1409
 
1410 1410
     // ----- Check that the file is readeable
1411 1411
     if (!is_readable($this->zipname)) {
1412
-      // ----- Error log
1413
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
1414
-      return(false);
1412
+        // ----- Error log
1413
+        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
1414
+        return(false);
1415 1415
     }
1416 1416
 
1417 1417
     // ----- Check the magic code
@@ -1425,43 +1425,43 @@  discard block
 block discarded – undo
1425 1425
 
1426 1426
     // ----- Return
1427 1427
     return $v_result;
1428
-  }
1429
-  // --------------------------------------------------------------------------------
1430
-
1431
-  // --------------------------------------------------------------------------------
1432
-  // Function : privParseOptions()
1433
-  // Description :
1434
-  //   This internal methods reads the variable list of arguments ($p_options_list,
1435
-  //   $p_size) and generate an array with the options and values ($v_result_list).
1436
-  //   $v_requested_options contains the options that can be present and those that
1437
-  //   must be present.
1438
-  //   $v_requested_options is an array, with the option value as key, and 'optional',
1439
-  //   or 'mandatory' as value.
1440
-  // Parameters :
1441
-  //   See above.
1442
-  // Return Values :
1443
-  //   1 on success.
1444
-  //   0 on failure.
1445
-  // --------------------------------------------------------------------------------
1446
-  function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
1447
-  {
1428
+    }
1429
+    // --------------------------------------------------------------------------------
1430
+
1431
+    // --------------------------------------------------------------------------------
1432
+    // Function : privParseOptions()
1433
+    // Description :
1434
+    //   This internal methods reads the variable list of arguments ($p_options_list,
1435
+    //   $p_size) and generate an array with the options and values ($v_result_list).
1436
+    //   $v_requested_options contains the options that can be present and those that
1437
+    //   must be present.
1438
+    //   $v_requested_options is an array, with the option value as key, and 'optional',
1439
+    //   or 'mandatory' as value.
1440
+    // Parameters :
1441
+    //   See above.
1442
+    // Return Values :
1443
+    //   1 on success.
1444
+    //   0 on failure.
1445
+    // --------------------------------------------------------------------------------
1446
+    function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
1447
+    {
1448 1448
     $v_result=1;
1449 1449
 
1450 1450
     // ----- Read the options
1451 1451
     $i=0;
1452 1452
     while ($i<$p_size) {
1453 1453
 
1454
-      // ----- Check if the option is supported
1455
-      if (!isset($v_requested_options[$p_options_list[$i]])) {
1454
+        // ----- Check if the option is supported
1455
+        if (!isset($v_requested_options[$p_options_list[$i]])) {
1456 1456
         // ----- Error log
1457 1457
         PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
1458 1458
 
1459 1459
         // ----- Return
1460 1460
         return PclZip::errorCode();
1461
-      }
1461
+        }
1462 1462
 
1463
-      // ----- Look for next option
1464
-      switch ($p_options_list[$i]) {
1463
+        // ----- Look for next option
1464
+        switch ($p_options_list[$i]) {
1465 1465
         // ----- Look for options that request a path value
1466 1466
         case PCLZIP_OPT_PATH :
1467 1467
         case PCLZIP_OPT_REMOVE_PATH :
@@ -1473,11 +1473,11 @@  discard block
 block discarded – undo
1473 1473
 
1474 1474
             // ----- Return
1475 1475
             return PclZip::errorCode();
1476
-          }
1476
+            }
1477 1477
 
1478
-          // ----- Get the value
1479
-          $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1480
-          $i++;
1478
+            // ----- Get the value
1479
+            $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1480
+            $i++;
1481 1481
         break;
1482 1482
 
1483 1483
         case PCLZIP_OPT_TEMP_FILE_THRESHOLD :
@@ -1485,24 +1485,24 @@  discard block
 block discarded – undo
1485 1485
           if (($i+1) >= $p_size) {
1486 1486
             PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1487 1487
             return PclZip::errorCode();
1488
-          }
1488
+            }
1489 1489
 
1490
-          // ----- Check for incompatible options
1491
-          if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
1490
+            // ----- Check for incompatible options
1491
+            if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
1492 1492
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
1493 1493
             return PclZip::errorCode();
1494
-          }
1494
+            }
1495 1495
 
1496
-          // ----- Check the value
1497
-          $v_value = $p_options_list[$i+1];
1498
-          if ((!is_integer($v_value)) || ($v_value<0)) {
1496
+            // ----- Check the value
1497
+            $v_value = $p_options_list[$i+1];
1498
+            if ((!is_integer($v_value)) || ($v_value<0)) {
1499 1499
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Integer expected for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1500 1500
             return PclZip::errorCode();
1501
-          }
1501
+            }
1502 1502
 
1503
-          // ----- Get the value (and convert it in bytes)
1504
-          $v_result_list[$p_options_list[$i]] = $v_value*1048576;
1505
-          $i++;
1503
+            // ----- Get the value (and convert it in bytes)
1504
+            $v_result_list[$p_options_list[$i]] = $v_value*1048576;
1505
+            $i++;
1506 1506
         break;
1507 1507
 
1508 1508
         case PCLZIP_OPT_TEMP_FILE_ON :
@@ -1510,9 +1510,9 @@  discard block
 block discarded – undo
1510 1510
           if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_OFF])) {
1511 1511
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_OFF'");
1512 1512
             return PclZip::errorCode();
1513
-          }
1513
+            }
1514 1514
 
1515
-          $v_result_list[$p_options_list[$i]] = true;
1515
+            $v_result_list[$p_options_list[$i]] = true;
1516 1516
         break;
1517 1517
 
1518 1518
         case PCLZIP_OPT_TEMP_FILE_OFF :
@@ -1520,14 +1520,14 @@  discard block
 block discarded – undo
1520 1520
           if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_ON])) {
1521 1521
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_ON'");
1522 1522
             return PclZip::errorCode();
1523
-          }
1524
-          // ----- Check for incompatible options
1525
-          if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1523
+            }
1524
+            // ----- Check for incompatible options
1525
+            if (isset($v_result_list[PCLZIP_OPT_TEMP_FILE_THRESHOLD])) {
1526 1526
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Option '".PclZipUtilOptionText($p_options_list[$i])."' can not be used with option 'PCLZIP_OPT_TEMP_FILE_THRESHOLD'");
1527 1527
             return PclZip::errorCode();
1528
-          }
1528
+            }
1529 1529
 
1530
-          $v_result_list[$p_options_list[$i]] = true;
1530
+            $v_result_list[$p_options_list[$i]] = true;
1531 1531
         break;
1532 1532
 
1533 1533
         case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
@@ -1538,16 +1538,16 @@  discard block
 block discarded – undo
1538 1538
 
1539 1539
             // ----- Return
1540 1540
             return PclZip::errorCode();
1541
-          }
1541
+            }
1542 1542
 
1543
-          // ----- Get the value
1544
-          if (   is_string($p_options_list[$i+1])
1543
+            // ----- Get the value
1544
+            if (   is_string($p_options_list[$i+1])
1545 1545
               && ($p_options_list[$i+1] != '')) {
1546 1546
             $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], FALSE);
1547 1547
             $i++;
1548
-          }
1549
-          else {
1550
-          }
1548
+            }
1549
+            else {
1550
+            }
1551 1551
         break;
1552 1552
 
1553 1553
         // ----- Look for options that request an array of string for value
@@ -1559,23 +1559,23 @@  discard block
 block discarded – undo
1559 1559
 
1560 1560
             // ----- Return
1561 1561
             return PclZip::errorCode();
1562
-          }
1562
+            }
1563 1563
 
1564
-          // ----- Get the value
1565
-          if (is_string($p_options_list[$i+1])) {
1566
-              $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
1567
-          }
1568
-          else if (is_array($p_options_list[$i+1])) {
1569
-              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1570
-          }
1571
-          else {
1564
+            // ----- Get the value
1565
+            if (is_string($p_options_list[$i+1])) {
1566
+                $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
1567
+            }
1568
+            else if (is_array($p_options_list[$i+1])) {
1569
+                $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1570
+            }
1571
+            else {
1572 1572
             // ----- Error log
1573 1573
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1574 1574
 
1575 1575
             // ----- Return
1576 1576
             return PclZip::errorCode();
1577
-          }
1578
-          $i++;
1577
+            }
1578
+            $i++;
1579 1579
         break;
1580 1580
 
1581 1581
         // ----- Look for options that request an EREG or PREG expression
@@ -1592,20 +1592,20 @@  discard block
 block discarded – undo
1592 1592
 
1593 1593
             // ----- Return
1594 1594
             return PclZip::errorCode();
1595
-          }
1595
+            }
1596 1596
 
1597
-          // ----- Get the value
1598
-          if (is_string($p_options_list[$i+1])) {
1599
-              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1600
-          }
1601
-          else {
1597
+            // ----- Get the value
1598
+            if (is_string($p_options_list[$i+1])) {
1599
+                $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1600
+            }
1601
+            else {
1602 1602
             // ----- Error log
1603 1603
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1604 1604
 
1605 1605
             // ----- Return
1606 1606
             return PclZip::errorCode();
1607
-          }
1608
-          $i++;
1607
+            }
1608
+            $i++;
1609 1609
         break;
1610 1610
 
1611 1611
         // ----- Look for options that takes a string
@@ -1616,29 +1616,29 @@  discard block
 block discarded – undo
1616 1616
           if (($i+1) >= $p_size) {
1617 1617
             // ----- Error log
1618 1618
             PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,
1619
-			                     "Missing parameter value for option '"
1620
-								 .PclZipUtilOptionText($p_options_list[$i])
1621
-								 ."'");
1619
+                                    "Missing parameter value for option '"
1620
+                                    .PclZipUtilOptionText($p_options_list[$i])
1621
+                                    ."'");
1622 1622
 
1623 1623
             // ----- Return
1624 1624
             return PclZip::errorCode();
1625
-          }
1625
+            }
1626 1626
 
1627
-          // ----- Get the value
1628
-          if (is_string($p_options_list[$i+1])) {
1629
-              $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1630
-          }
1631
-          else {
1627
+            // ----- Get the value
1628
+            if (is_string($p_options_list[$i+1])) {
1629
+                $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1630
+            }
1631
+            else {
1632 1632
             // ----- Error log
1633 1633
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,
1634
-			                     "Wrong parameter value for option '"
1635
-								 .PclZipUtilOptionText($p_options_list[$i])
1636
-								 ."'");
1634
+                                    "Wrong parameter value for option '"
1635
+                                    .PclZipUtilOptionText($p_options_list[$i])
1636
+                                    ."'");
1637 1637
 
1638 1638
             // ----- Return
1639 1639
             return PclZip::errorCode();
1640
-          }
1641
-          $i++;
1640
+            }
1641
+            $i++;
1642 1642
         break;
1643 1643
 
1644 1644
         // ----- Look for options that request an array of index
@@ -1650,87 +1650,87 @@  discard block
 block discarded – undo
1650 1650
 
1651 1651
             // ----- Return
1652 1652
             return PclZip::errorCode();
1653
-          }
1653
+            }
1654 1654
 
1655
-          // ----- Get the value
1656
-          $v_work_list = array();
1657
-          if (is_string($p_options_list[$i+1])) {
1655
+            // ----- Get the value
1656
+            $v_work_list = array();
1657
+            if (is_string($p_options_list[$i+1])) {
1658 1658
 
1659
-              // ----- Remove spaces
1660
-              $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
1659
+                // ----- Remove spaces
1660
+                $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
1661 1661
 
1662
-              // ----- Parse items
1663
-              $v_work_list = explode(",", $p_options_list[$i+1]);
1664
-          }
1665
-          else if (is_integer($p_options_list[$i+1])) {
1666
-              $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
1667
-          }
1668
-          else if (is_array($p_options_list[$i+1])) {
1669
-              $v_work_list = $p_options_list[$i+1];
1670
-          }
1671
-          else {
1662
+                // ----- Parse items
1663
+                $v_work_list = explode(",", $p_options_list[$i+1]);
1664
+            }
1665
+            else if (is_integer($p_options_list[$i+1])) {
1666
+                $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
1667
+            }
1668
+            else if (is_array($p_options_list[$i+1])) {
1669
+                $v_work_list = $p_options_list[$i+1];
1670
+            }
1671
+            else {
1672 1672
             // ----- Error log
1673 1673
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1674 1674
 
1675 1675
             // ----- Return
1676 1676
             return PclZip::errorCode();
1677
-          }
1677
+            }
1678 1678
 
1679
-          // ----- Reduce the index list
1680
-          // each index item in the list must be a couple with a start and
1681
-          // an end value : [0,3], [5-5], [8-10], ...
1682
-          // ----- Check the format of each item
1683
-          $v_sort_flag=false;
1684
-          $v_sort_value=0;
1685
-          for ($j=0; $j<sizeof($v_work_list); $j++) {
1686
-              // ----- Explode the item
1687
-              $v_item_list = explode("-", $v_work_list[$j]);
1688
-              $v_size_item_list = sizeof($v_item_list);
1689
-
1690
-              // ----- TBC : Here we might check that each item is a
1691
-              // real integer ...
1692
-
1693
-              // ----- Look for single value
1694
-              if ($v_size_item_list == 1) {
1695
-                  // ----- Set the option value
1696
-                  $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1697
-                  $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
1698
-              }
1699
-              elseif ($v_size_item_list == 2) {
1700
-                  // ----- Set the option value
1701
-                  $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1702
-                  $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
1703
-              }
1704
-              else {
1705
-                  // ----- Error log
1706
-                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1707
-
1708
-                  // ----- Return
1709
-                  return PclZip::errorCode();
1710
-              }
1711
-
1712
-
1713
-              // ----- Look for list sort
1714
-              if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
1715
-                  $v_sort_flag=true;
1716
-
1717
-                  // ----- TBC : An automatic sort should be writen ...
1718
-                  // ----- Error log
1719
-                  PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1720
-
1721
-                  // ----- Return
1722
-                  return PclZip::errorCode();
1723
-              }
1724
-              $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
1725
-          }
1679
+            // ----- Reduce the index list
1680
+            // each index item in the list must be a couple with a start and
1681
+            // an end value : [0,3], [5-5], [8-10], ...
1682
+            // ----- Check the format of each item
1683
+            $v_sort_flag=false;
1684
+            $v_sort_value=0;
1685
+            for ($j=0; $j<sizeof($v_work_list); $j++) {
1686
+                // ----- Explode the item
1687
+                $v_item_list = explode("-", $v_work_list[$j]);
1688
+                $v_size_item_list = sizeof($v_item_list);
1689
+
1690
+                // ----- TBC : Here we might check that each item is a
1691
+                // real integer ...
1692
+
1693
+                // ----- Look for single value
1694
+                if ($v_size_item_list == 1) {
1695
+                    // ----- Set the option value
1696
+                    $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1697
+                    $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
1698
+                }
1699
+                elseif ($v_size_item_list == 2) {
1700
+                    // ----- Set the option value
1701
+                    $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1702
+                    $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
1703
+                }
1704
+                else {
1705
+                    // ----- Error log
1706
+                    PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1707
+
1708
+                    // ----- Return
1709
+                    return PclZip::errorCode();
1710
+                }
1711
+
1712
+
1713
+                // ----- Look for list sort
1714
+                if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
1715
+                    $v_sort_flag=true;
1716
+
1717
+                    // ----- TBC : An automatic sort should be writen ...
1718
+                    // ----- Error log
1719
+                    PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1720
+
1721
+                    // ----- Return
1722
+                    return PclZip::errorCode();
1723
+                }
1724
+                $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
1725
+            }
1726 1726
 
1727
-          // ----- Sort the items
1728
-          if ($v_sort_flag) {
1729
-              // TBC : To Be Completed
1730
-          }
1727
+            // ----- Sort the items
1728
+            if ($v_sort_flag) {
1729
+                // TBC : To Be Completed
1730
+            }
1731 1731
 
1732
-          // ----- Next option
1733
-          $i++;
1732
+            // ----- Next option
1733
+            $i++;
1734 1734
         break;
1735 1735
 
1736 1736
         // ----- Look for options that request no value
@@ -1752,11 +1752,11 @@  discard block
 block discarded – undo
1752 1752
 
1753 1753
             // ----- Return
1754 1754
             return PclZip::errorCode();
1755
-          }
1755
+            }
1756 1756
 
1757
-          // ----- Get the value
1758
-          $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1759
-          $i++;
1757
+            // ----- Get the value
1758
+            $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1759
+            $i++;
1760 1760
         break;
1761 1761
 
1762 1762
         // ----- Look for options that request a call-back
@@ -1777,54 +1777,54 @@  discard block
 block discarded – undo
1777 1777
 
1778 1778
             // ----- Return
1779 1779
             return PclZip::errorCode();
1780
-          }
1780
+            }
1781 1781
 
1782
-          // ----- Get the value
1783
-          $v_function_name = $p_options_list[$i+1];
1782
+            // ----- Get the value
1783
+            $v_function_name = $p_options_list[$i+1];
1784 1784
 
1785
-          // ----- Check that the value is a valid existing function
1786
-          if (!function_exists($v_function_name)) {
1785
+            // ----- Check that the value is a valid existing function
1786
+            if (!function_exists($v_function_name)) {
1787 1787
             // ----- Error log
1788 1788
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1789 1789
 
1790 1790
             // ----- Return
1791 1791
             return PclZip::errorCode();
1792
-          }
1792
+            }
1793 1793
 
1794
-          // ----- Set the attribute
1795
-          $v_result_list[$p_options_list[$i]] = $v_function_name;
1796
-          $i++;
1794
+            // ----- Set the attribute
1795
+            $v_result_list[$p_options_list[$i]] = $v_function_name;
1796
+            $i++;
1797 1797
         break;
1798 1798
 
1799 1799
         default :
1800 1800
           // ----- Error log
1801 1801
           PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1802
-		                       "Unknown parameter '"
1803
-							   .$p_options_list[$i]."'");
1802
+                                "Unknown parameter '"
1803
+                                .$p_options_list[$i]."'");
1804 1804
 
1805
-          // ----- Return
1806
-          return PclZip::errorCode();
1807
-      }
1805
+            // ----- Return
1806
+            return PclZip::errorCode();
1807
+        }
1808 1808
 
1809
-      // ----- Next options
1810
-      $i++;
1809
+        // ----- Next options
1810
+        $i++;
1811 1811
     }
1812 1812
 
1813 1813
     // ----- Look for mandatory options
1814 1814
     if ($v_requested_options !== false) {
1815
-      for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1815
+        for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1816 1816
         // ----- Look for mandatory option
1817 1817
         if ($v_requested_options[$key] == 'mandatory') {
1818
-          // ----- Look if present
1819
-          if (!isset($v_result_list[$key])) {
1818
+            // ----- Look if present
1819
+            if (!isset($v_result_list[$key])) {
1820 1820
             // ----- Error log
1821 1821
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1822 1822
 
1823 1823
             // ----- Return
1824 1824
             return PclZip::errorCode();
1825
-          }
1825
+            }
1826
+        }
1826 1827
         }
1827
-      }
1828 1828
     }
1829 1829
 
1830 1830
     // ----- Look for default values
@@ -1834,22 +1834,22 @@  discard block
 block discarded – undo
1834 1834
 
1835 1835
     // ----- Return
1836 1836
     return $v_result;
1837
-  }
1838
-  // --------------------------------------------------------------------------------
1839
-
1840
-  // --------------------------------------------------------------------------------
1841
-  // Function : privOptionDefaultThreshold()
1842
-  // Description :
1843
-  // Parameters :
1844
-  // Return Values :
1845
-  // --------------------------------------------------------------------------------
1846
-  function privOptionDefaultThreshold(&$p_options)
1847
-  {
1837
+    }
1838
+    // --------------------------------------------------------------------------------
1839
+
1840
+    // --------------------------------------------------------------------------------
1841
+    // Function : privOptionDefaultThreshold()
1842
+    // Description :
1843
+    // Parameters :
1844
+    // Return Values :
1845
+    // --------------------------------------------------------------------------------
1846
+    function privOptionDefaultThreshold(&$p_options)
1847
+    {
1848 1848
     $v_result=1;
1849 1849
 
1850 1850
     if (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
1851 1851
         || isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF])) {
1852
-      return $v_result;
1852
+        return $v_result;
1853 1853
     }
1854 1854
 
1855 1855
     // ----- Get 'memory_limit' configuration value
@@ -1871,52 +1871,52 @@  discard block
 block discarded – undo
1871 1871
 
1872 1872
     // ----- Sanity check : No threshold if value lower than 1M
1873 1873
     if ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] < 1048576) {
1874
-      unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
1874
+        unset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD]);
1875 1875
     }
1876 1876
 
1877 1877
     // ----- Return
1878 1878
     return $v_result;
1879
-  }
1880
-  // --------------------------------------------------------------------------------
1881
-
1882
-  // --------------------------------------------------------------------------------
1883
-  // Function : privFileDescrParseAtt()
1884
-  // Description :
1885
-  // Parameters :
1886
-  // Return Values :
1887
-  //   1 on success.
1888
-  //   0 on failure.
1889
-  // --------------------------------------------------------------------------------
1890
-  function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
1891
-  {
1879
+    }
1880
+    // --------------------------------------------------------------------------------
1881
+
1882
+    // --------------------------------------------------------------------------------
1883
+    // Function : privFileDescrParseAtt()
1884
+    // Description :
1885
+    // Parameters :
1886
+    // Return Values :
1887
+    //   1 on success.
1888
+    //   0 on failure.
1889
+    // --------------------------------------------------------------------------------
1890
+    function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
1891
+    {
1892 1892
     $v_result=1;
1893 1893
 
1894 1894
     // ----- For each file in the list check the attributes
1895 1895
     foreach ($p_file_list as $v_key => $v_value) {
1896 1896
 
1897
-      // ----- Check if the option is supported
1898
-      if (!isset($v_requested_options[$v_key])) {
1897
+        // ----- Check if the option is supported
1898
+        if (!isset($v_requested_options[$v_key])) {
1899 1899
         // ----- Error log
1900 1900
         PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
1901 1901
 
1902 1902
         // ----- Return
1903 1903
         return PclZip::errorCode();
1904
-      }
1904
+        }
1905 1905
 
1906
-      // ----- Look for attribute
1907
-      switch ($v_key) {
1906
+        // ----- Look for attribute
1907
+        switch ($v_key) {
1908 1908
         case PCLZIP_ATT_FILE_NAME :
1909 1909
           if (!is_string($v_value)) {
1910 1910
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1911 1911
             return PclZip::errorCode();
1912
-          }
1912
+            }
1913 1913
 
1914
-          $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
1914
+            $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
1915 1915
 
1916
-          if ($p_filedescr['filename'] == '') {
1916
+            if ($p_filedescr['filename'] == '') {
1917 1917
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
1918 1918
             return PclZip::errorCode();
1919
-          }
1919
+            }
1920 1920
 
1921 1921
         break;
1922 1922
 
@@ -1924,28 +1924,28 @@  discard block
 block discarded – undo
1924 1924
           if (!is_string($v_value)) {
1925 1925
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1926 1926
             return PclZip::errorCode();
1927
-          }
1927
+            }
1928 1928
 
1929
-          $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
1929
+            $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
1930 1930
 
1931
-          if ($p_filedescr['new_short_name'] == '') {
1931
+            if ($p_filedescr['new_short_name'] == '') {
1932 1932
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
1933 1933
             return PclZip::errorCode();
1934
-          }
1934
+            }
1935 1935
         break;
1936 1936
 
1937 1937
         case PCLZIP_ATT_FILE_NEW_FULL_NAME :
1938 1938
           if (!is_string($v_value)) {
1939 1939
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1940 1940
             return PclZip::errorCode();
1941
-          }
1941
+            }
1942 1942
 
1943
-          $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
1943
+            $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
1944 1944
 
1945
-          if ($p_filedescr['new_full_name'] == '') {
1945
+            if ($p_filedescr['new_full_name'] == '') {
1946 1946
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
1947 1947
             return PclZip::errorCode();
1948
-          }
1948
+            }
1949 1949
         break;
1950 1950
 
1951 1951
         // ----- Look for options that takes a string
@@ -1953,18 +1953,18 @@  discard block
 block discarded – undo
1953 1953
           if (!is_string($v_value)) {
1954 1954
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1955 1955
             return PclZip::errorCode();
1956
-          }
1956
+            }
1957 1957
 
1958
-          $p_filedescr['comment'] = $v_value;
1958
+            $p_filedescr['comment'] = $v_value;
1959 1959
         break;
1960 1960
 
1961 1961
         case PCLZIP_ATT_FILE_MTIME :
1962 1962
           if (!is_integer($v_value)) {
1963 1963
             PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". Integer expected for attribute '".PclZipUtilOptionText($v_key)."'");
1964 1964
             return PclZip::errorCode();
1965
-          }
1965
+            }
1966 1966
 
1967
-          $p_filedescr['mtime'] = $v_value;
1967
+            $p_filedescr['mtime'] = $v_value;
1968 1968
         break;
1969 1969
 
1970 1970
         case PCLZIP_ATT_FILE_CONTENT :
@@ -1974,50 +1974,50 @@  discard block
 block discarded – undo
1974 1974
         default :
1975 1975
           // ----- Error log
1976 1976
           PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1977
-		                           "Unknown parameter '".$v_key."'");
1977
+                                    "Unknown parameter '".$v_key."'");
1978 1978
 
1979
-          // ----- Return
1980
-          return PclZip::errorCode();
1981
-      }
1979
+            // ----- Return
1980
+            return PclZip::errorCode();
1981
+        }
1982 1982
 
1983
-      // ----- Look for mandatory options
1984
-      if ($v_requested_options !== false) {
1983
+        // ----- Look for mandatory options
1984
+        if ($v_requested_options !== false) {
1985 1985
         for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1986
-          // ----- Look for mandatory option
1987
-          if ($v_requested_options[$key] == 'mandatory') {
1986
+            // ----- Look for mandatory option
1987
+            if ($v_requested_options[$key] == 'mandatory') {
1988 1988
             // ----- Look if present
1989 1989
             if (!isset($p_file_list[$key])) {
1990
-              PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1991
-              return PclZip::errorCode();
1990
+                PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1991
+                return PclZip::errorCode();
1992
+            }
1992 1993
             }
1993
-          }
1994 1994
         }
1995
-      }
1995
+        }
1996 1996
 
1997 1997
     // end foreach
1998 1998
     }
1999 1999
 
2000 2000
     // ----- Return
2001 2001
     return $v_result;
2002
-  }
2003
-  // --------------------------------------------------------------------------------
2004
-
2005
-  // --------------------------------------------------------------------------------
2006
-  // Function : privFileDescrExpand()
2007
-  // Description :
2008
-  //   This method look for each item of the list to see if its a file, a folder
2009
-  //   or a string to be added as file. For any other type of files (link, other)
2010
-  //   just ignore the item.
2011
-  //   Then prepare the information that will be stored for that file.
2012
-  //   When its a folder, expand the folder with all the files that are in that
2013
-  //   folder (recursively).
2014
-  // Parameters :
2015
-  // Return Values :
2016
-  //   1 on success.
2017
-  //   0 on failure.
2018
-  // --------------------------------------------------------------------------------
2019
-  function privFileDescrExpand(&$p_filedescr_list, &$p_options)
2020
-  {
2002
+    }
2003
+    // --------------------------------------------------------------------------------
2004
+
2005
+    // --------------------------------------------------------------------------------
2006
+    // Function : privFileDescrExpand()
2007
+    // Description :
2008
+    //   This method look for each item of the list to see if its a file, a folder
2009
+    //   or a string to be added as file. For any other type of files (link, other)
2010
+    //   just ignore the item.
2011
+    //   Then prepare the information that will be stored for that file.
2012
+    //   When its a folder, expand the folder with all the files that are in that
2013
+    //   folder (recursively).
2014
+    // Parameters :
2015
+    // Return Values :
2016
+    //   1 on success.
2017
+    //   0 on failure.
2018
+    // --------------------------------------------------------------------------------
2019
+    function privFileDescrExpand(&$p_filedescr_list, &$p_options)
2020
+    {
2021 2021
     $v_result=1;
2022 2022
 
2023 2023
     // ----- Create a result list
@@ -2026,58 +2026,58 @@  discard block
 block discarded – undo
2026 2026
     // ----- Look each entry
2027 2027
     for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
2028 2028
 
2029
-      // ----- Get filedescr
2030
-      $v_descr = $p_filedescr_list[$i];
2029
+        // ----- Get filedescr
2030
+        $v_descr = $p_filedescr_list[$i];
2031 2031
 
2032
-      // ----- Reduce the filename
2033
-      $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
2034
-      $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
2032
+        // ----- Reduce the filename
2033
+        $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename'], false);
2034
+        $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
2035 2035
 
2036
-      // ----- Look for real file or folder
2037
-      if (file_exists($v_descr['filename'])) {
2036
+        // ----- Look for real file or folder
2037
+        if (file_exists($v_descr['filename'])) {
2038 2038
         if (@is_file($v_descr['filename'])) {
2039
-          $v_descr['type'] = 'file';
2039
+            $v_descr['type'] = 'file';
2040 2040
         }
2041 2041
         else if (@is_dir($v_descr['filename'])) {
2042
-          $v_descr['type'] = 'folder';
2042
+            $v_descr['type'] = 'folder';
2043 2043
         }
2044 2044
         else if (@is_link($v_descr['filename'])) {
2045
-          // skip
2046
-          continue;
2045
+            // skip
2046
+            continue;
2047 2047
         }
2048 2048
         else {
2049
-          // skip
2050
-          continue;
2049
+            // skip
2050
+            continue;
2051
+        }
2051 2052
         }
2052
-      }
2053 2053
 
2054
-      // ----- Look for string added as file
2055
-      else if (isset($v_descr['content'])) {
2054
+        // ----- Look for string added as file
2055
+        else if (isset($v_descr['content'])) {
2056 2056
         $v_descr['type'] = 'virtual_file';
2057
-      }
2057
+        }
2058 2058
 
2059
-      // ----- Missing file
2060
-      else {
2059
+        // ----- Missing file
2060
+        else {
2061 2061
         // ----- Error log
2062 2062
         PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exist");
2063 2063
 
2064 2064
         // ----- Return
2065 2065
         return PclZip::errorCode();
2066
-      }
2066
+        }
2067 2067
 
2068
-      // ----- Calculate the stored filename
2069
-      $this->privCalculateStoredFilename($v_descr, $p_options);
2068
+        // ----- Calculate the stored filename
2069
+        $this->privCalculateStoredFilename($v_descr, $p_options);
2070 2070
 
2071
-      // ----- Add the descriptor in result list
2072
-      $v_result_list[sizeof($v_result_list)] = $v_descr;
2071
+        // ----- Add the descriptor in result list
2072
+        $v_result_list[sizeof($v_result_list)] = $v_descr;
2073 2073
 
2074
-      // ----- Look for folder
2075
-      if ($v_descr['type'] == 'folder') {
2074
+        // ----- Look for folder
2075
+        if ($v_descr['type'] == 'folder') {
2076 2076
         // ----- List of items in folder
2077 2077
         $v_dirlist_descr = array();
2078 2078
         $v_dirlist_nb = 0;
2079 2079
         if ($v_folder_handler = @opendir($v_descr['filename'])) {
2080
-          while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
2080
+            while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
2081 2081
 
2082 2082
             // ----- Skip '.' and '..'
2083 2083
             if (($v_item_handler == '.') || ($v_item_handler == '..')) {
@@ -2092,39 +2092,39 @@  discard block
 block discarded – undo
2092 2092
             // files/sub-folders also change
2093 2093
             if (($v_descr['stored_filename'] != $v_descr['filename'])
2094 2094
                  && (!isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2095
-              if ($v_descr['stored_filename'] != '') {
2095
+                if ($v_descr['stored_filename'] != '') {
2096 2096
                 $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
2097
-              }
2098
-              else {
2097
+                }
2098
+                else {
2099 2099
                 $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_item_handler;
2100
-              }
2100
+                }
2101 2101
             }
2102 2102
 
2103 2103
             $v_dirlist_nb++;
2104
-          }
2104
+            }
2105 2105
 
2106
-          @closedir($v_folder_handler);
2106
+            @closedir($v_folder_handler);
2107 2107
         }
2108 2108
         else {
2109
-          // TBC : unable to open folder in read mode
2109
+            // TBC : unable to open folder in read mode
2110 2110
         }
2111 2111
 
2112 2112
         // ----- Expand each element of the list
2113 2113
         if ($v_dirlist_nb != 0) {
2114
-          // ----- Expand
2115
-          if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
2114
+            // ----- Expand
2115
+            if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
2116 2116
             return $v_result;
2117
-          }
2117
+            }
2118 2118
 
2119
-          // ----- Concat the resulting list
2120
-          $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
2119
+            // ----- Concat the resulting list
2120
+            $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
2121 2121
         }
2122 2122
         else {
2123 2123
         }
2124 2124
 
2125 2125
         // ----- Free local array
2126 2126
         unset($v_dirlist_descr);
2127
-      }
2127
+        }
2128 2128
     }
2129 2129
 
2130 2130
     // ----- Get the result list
@@ -2132,17 +2132,17 @@  discard block
 block discarded – undo
2132 2132
 
2133 2133
     // ----- Return
2134 2134
     return $v_result;
2135
-  }
2136
-  // --------------------------------------------------------------------------------
2137
-
2138
-  // --------------------------------------------------------------------------------
2139
-  // Function : privCreate()
2140
-  // Description :
2141
-  // Parameters :
2142
-  // Return Values :
2143
-  // --------------------------------------------------------------------------------
2144
-  function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
2145
-  {
2135
+    }
2136
+    // --------------------------------------------------------------------------------
2137
+
2138
+    // --------------------------------------------------------------------------------
2139
+    // Function : privCreate()
2140
+    // Description :
2141
+    // Parameters :
2142
+    // Return Values :
2143
+    // --------------------------------------------------------------------------------
2144
+    function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
2145
+    {
2146 2146
     $v_result=1;
2147 2147
     $v_list_detail = array();
2148 2148
 
@@ -2152,8 +2152,8 @@  discard block
 block discarded – undo
2152 2152
     // ----- Open the file in write mode
2153 2153
     if (($v_result = $this->privOpenFd('wb')) != 1)
2154 2154
     {
2155
-      // ----- Return
2156
-      return $v_result;
2155
+        // ----- Return
2156
+        return $v_result;
2157 2157
     }
2158 2158
 
2159 2159
     // ----- Add the list of files
@@ -2167,17 +2167,17 @@  discard block
 block discarded – undo
2167 2167
 
2168 2168
     // ----- Return
2169 2169
     return $v_result;
2170
-  }
2171
-  // --------------------------------------------------------------------------------
2172
-
2173
-  // --------------------------------------------------------------------------------
2174
-  // Function : privAdd()
2175
-  // Description :
2176
-  // Parameters :
2177
-  // Return Values :
2178
-  // --------------------------------------------------------------------------------
2179
-  function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
2180
-  {
2170
+    }
2171
+    // --------------------------------------------------------------------------------
2172
+
2173
+    // --------------------------------------------------------------------------------
2174
+    // Function : privAdd()
2175
+    // Description :
2176
+    // Parameters :
2177
+    // Return Values :
2178
+    // --------------------------------------------------------------------------------
2179
+    function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
2180
+    {
2181 2181
     $v_result=1;
2182 2182
     $v_list_detail = array();
2183 2183
 
@@ -2185,11 +2185,11 @@  discard block
 block discarded – undo
2185 2185
     if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
2186 2186
     {
2187 2187
 
2188
-      // ----- Do a create
2189
-      $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
2188
+        // ----- Do a create
2189
+        $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
2190 2190
 
2191
-      // ----- Return
2192
-      return $v_result;
2191
+        // ----- Return
2192
+        return $v_result;
2193 2193
     }
2194 2194
     // ----- Magic quotes trick
2195 2195
     $this->privDisableMagicQuotes();
@@ -2197,20 +2197,20 @@  discard block
 block discarded – undo
2197 2197
     // ----- Open the zip file
2198 2198
     if (($v_result=$this->privOpenFd('rb')) != 1)
2199 2199
     {
2200
-      // ----- Magic quotes trick
2201
-      $this->privSwapBackMagicQuotes();
2200
+        // ----- Magic quotes trick
2201
+        $this->privSwapBackMagicQuotes();
2202 2202
 
2203
-      // ----- Return
2204
-      return $v_result;
2203
+        // ----- Return
2204
+        return $v_result;
2205 2205
     }
2206 2206
 
2207 2207
     // ----- Read the central directory informations
2208 2208
     $v_central_dir = array();
2209 2209
     if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
2210 2210
     {
2211
-      $this->privCloseFd();
2212
-      $this->privSwapBackMagicQuotes();
2213
-      return $v_result;
2211
+        $this->privCloseFd();
2212
+        $this->privSwapBackMagicQuotes();
2213
+        return $v_result;
2214 2214
     }
2215 2215
 
2216 2216
     // ----- Go to beginning of File
@@ -2222,13 +2222,13 @@  discard block
 block discarded – undo
2222 2222
     // ----- Open the temporary file in write mode
2223 2223
     if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
2224 2224
     {
2225
-      $this->privCloseFd();
2226
-      $this->privSwapBackMagicQuotes();
2225
+        $this->privCloseFd();
2226
+        $this->privSwapBackMagicQuotes();
2227 2227
 
2228
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
2228
+        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
2229 2229
 
2230
-      // ----- Return
2231
-      return PclZip::errorCode();
2230
+        // ----- Return
2231
+        return PclZip::errorCode();
2232 2232
     }
2233 2233
 
2234 2234
     // ----- Copy the files from the archive to the temporary file
@@ -2236,10 +2236,10 @@  discard block
 block discarded – undo
2236 2236
     $v_size = $v_central_dir['offset'];
2237 2237
     while ($v_size != 0)
2238 2238
     {
2239
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2240
-      $v_buffer = fread($this->zip_fd, $v_read_size);
2241
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2242
-      $v_size -= $v_read_size;
2239
+        $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2240
+        $v_buffer = fread($this->zip_fd, $v_read_size);
2241
+        @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2242
+        $v_size -= $v_read_size;
2243 2243
     }
2244 2244
 
2245 2245
     // ----- Swap the file descriptor
@@ -2253,13 +2253,13 @@  discard block
 block discarded – undo
2253 2253
     $v_header_list = array();
2254 2254
     if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2255 2255
     {
2256
-      fclose($v_zip_temp_fd);
2257
-      $this->privCloseFd();
2258
-      @unlink($v_zip_temp_name);
2259
-      $this->privSwapBackMagicQuotes();
2256
+        fclose($v_zip_temp_fd);
2257
+        $this->privCloseFd();
2258
+        @unlink($v_zip_temp_name);
2259
+        $this->privSwapBackMagicQuotes();
2260 2260
 
2261
-      // ----- Return
2262
-      return $v_result;
2261
+        // ----- Return
2262
+        return $v_result;
2263 2263
     }
2264 2264
 
2265 2265
     // ----- Store the offset of the central dir
@@ -2269,43 +2269,43 @@  discard block
 block discarded – undo
2269 2269
     $v_size = $v_central_dir['size'];
2270 2270
     while ($v_size != 0)
2271 2271
     {
2272
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2273
-      $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
2274
-      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2275
-      $v_size -= $v_read_size;
2272
+        $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2273
+        $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
2274
+        @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2275
+        $v_size -= $v_read_size;
2276 2276
     }
2277 2277
 
2278 2278
     // ----- Create the Central Dir files header
2279 2279
     for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
2280 2280
     {
2281
-      // ----- Create the file header
2282
-      if ($v_header_list[$i]['status'] == 'ok') {
2281
+        // ----- Create the file header
2282
+        if ($v_header_list[$i]['status'] == 'ok') {
2283 2283
         if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2284
-          fclose($v_zip_temp_fd);
2285
-          $this->privCloseFd();
2286
-          @unlink($v_zip_temp_name);
2287
-          $this->privSwapBackMagicQuotes();
2284
+            fclose($v_zip_temp_fd);
2285
+            $this->privCloseFd();
2286
+            @unlink($v_zip_temp_name);
2287
+            $this->privSwapBackMagicQuotes();
2288 2288
 
2289
-          // ----- Return
2290
-          return $v_result;
2289
+            // ----- Return
2290
+            return $v_result;
2291 2291
         }
2292 2292
         $v_count++;
2293
-      }
2293
+        }
2294 2294
 
2295
-      // ----- Transform the header to a 'usable' info
2296
-      $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2295
+        // ----- Transform the header to a 'usable' info
2296
+        $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2297 2297
     }
2298 2298
 
2299 2299
     // ----- Zip file comment
2300 2300
     $v_comment = $v_central_dir['comment'];
2301 2301
     if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2302
-      $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2302
+        $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2303 2303
     }
2304 2304
     if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
2305
-      $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
2305
+        $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
2306 2306
     }
2307 2307
     if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
2308
-      $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
2308
+        $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
2309 2309
     }
2310 2310
 
2311 2311
     // ----- Calculate the size of the central header
@@ -2314,12 +2314,12 @@  discard block
 block discarded – undo
2314 2314
     // ----- Create the central dir footer
2315 2315
     if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
2316 2316
     {
2317
-      // ----- Reset the file list
2318
-      unset($v_header_list);
2319
-      $this->privSwapBackMagicQuotes();
2317
+        // ----- Reset the file list
2318
+        unset($v_header_list);
2319
+        $this->privSwapBackMagicQuotes();
2320 2320
 
2321
-      // ----- Return
2322
-      return $v_result;
2321
+        // ----- Return
2322
+        return $v_result;
2323 2323
     }
2324 2324
 
2325 2325
     // ----- Swap back the file descriptor
@@ -2347,85 +2347,85 @@  discard block
 block discarded – undo
2347 2347
 
2348 2348
     // ----- Return
2349 2349
     return $v_result;
2350
-  }
2351
-  // --------------------------------------------------------------------------------
2352
-
2353
-  // --------------------------------------------------------------------------------
2354
-  // Function : privOpenFd()
2355
-  // Description :
2356
-  // Parameters :
2357
-  // --------------------------------------------------------------------------------
2358
-  function privOpenFd($p_mode)
2359
-  {
2350
+    }
2351
+    // --------------------------------------------------------------------------------
2352
+
2353
+    // --------------------------------------------------------------------------------
2354
+    // Function : privOpenFd()
2355
+    // Description :
2356
+    // Parameters :
2357
+    // --------------------------------------------------------------------------------
2358
+    function privOpenFd($p_mode)
2359
+    {
2360 2360
     $v_result=1;
2361 2361
 
2362 2362
     // ----- Look if already open
2363 2363
     if ($this->zip_fd != 0)
2364 2364
     {
2365
-      // ----- Error log
2366
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
2365
+        // ----- Error log
2366
+        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
2367 2367
 
2368
-      // ----- Return
2369
-      return PclZip::errorCode();
2368
+        // ----- Return
2369
+        return PclZip::errorCode();
2370 2370
     }
2371 2371
 
2372 2372
     // ----- Open the zip file
2373 2373
     if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
2374 2374
     {
2375
-      // ----- Error log
2376
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
2375
+        // ----- Error log
2376
+        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
2377 2377
 
2378
-      // ----- Return
2379
-      return PclZip::errorCode();
2378
+        // ----- Return
2379
+        return PclZip::errorCode();
2380 2380
     }
2381 2381
 
2382 2382
     // ----- Return
2383 2383
     return $v_result;
2384
-  }
2385
-  // --------------------------------------------------------------------------------
2386
-
2387
-  // --------------------------------------------------------------------------------
2388
-  // Function : privCloseFd()
2389
-  // Description :
2390
-  // Parameters :
2391
-  // --------------------------------------------------------------------------------
2392
-  function privCloseFd()
2393
-  {
2384
+    }
2385
+    // --------------------------------------------------------------------------------
2386
+
2387
+    // --------------------------------------------------------------------------------
2388
+    // Function : privCloseFd()
2389
+    // Description :
2390
+    // Parameters :
2391
+    // --------------------------------------------------------------------------------
2392
+    function privCloseFd()
2393
+    {
2394 2394
     $v_result=1;
2395 2395
 
2396 2396
     if ($this->zip_fd != 0)
2397
-      @fclose($this->zip_fd);
2397
+        @fclose($this->zip_fd);
2398 2398
     $this->zip_fd = 0;
2399 2399
 
2400 2400
     // ----- Return
2401 2401
     return $v_result;
2402
-  }
2403
-  // --------------------------------------------------------------------------------
2404
-
2405
-  // --------------------------------------------------------------------------------
2406
-  // Function : privAddList()
2407
-  // Description :
2408
-  //   $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
2409
-  //   different from the real path of the file. This is usefull if you want to have PclTar
2410
-  //   running in any directory, and memorize relative path from an other directory.
2411
-  // Parameters :
2412
-  //   $p_list : An array containing the file or directory names to add in the tar
2413
-  //   $p_result_list : list of added files with their properties (specially the status field)
2414
-  //   $p_add_dir : Path to add in the filename path archived
2415
-  //   $p_remove_dir : Path to remove in the filename path archived
2416
-  // Return Values :
2417
-  // --------------------------------------------------------------------------------
2402
+    }
2403
+    // --------------------------------------------------------------------------------
2404
+
2405
+    // --------------------------------------------------------------------------------
2406
+    // Function : privAddList()
2407
+    // Description :
2408
+    //   $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
2409
+    //   different from the real path of the file. This is usefull if you want to have PclTar
2410
+    //   running in any directory, and memorize relative path from an other directory.
2411
+    // Parameters :
2412
+    //   $p_list : An array containing the file or directory names to add in the tar
2413
+    //   $p_result_list : list of added files with their properties (specially the status field)
2414
+    //   $p_add_dir : Path to add in the filename path archived
2415
+    //   $p_remove_dir : Path to remove in the filename path archived
2416
+    // Return Values :
2417
+    // --------------------------------------------------------------------------------
2418 2418
 //  function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
2419
-  function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
2420
-  {
2419
+    function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
2420
+    {
2421 2421
     $v_result=1;
2422 2422
 
2423 2423
     // ----- Add the files
2424 2424
     $v_header_list = array();
2425 2425
     if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2426 2426
     {
2427
-      // ----- Return
2428
-      return $v_result;
2427
+        // ----- Return
2428
+        return $v_result;
2429 2429
     }
2430 2430
 
2431 2431
     // ----- Store the offset of the central dir
@@ -2434,23 +2434,23 @@  discard block
 block discarded – undo
2434 2434
     // ----- Create the Central Dir files header
2435 2435
     for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
2436 2436
     {
2437
-      // ----- Create the file header
2438
-      if ($v_header_list[$i]['status'] == 'ok') {
2437
+        // ----- Create the file header
2438
+        if ($v_header_list[$i]['status'] == 'ok') {
2439 2439
         if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2440
-          // ----- Return
2441
-          return $v_result;
2440
+            // ----- Return
2441
+            return $v_result;
2442 2442
         }
2443 2443
         $v_count++;
2444
-      }
2444
+        }
2445 2445
 
2446
-      // ----- Transform the header to a 'usable' info
2447
-      $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2446
+        // ----- Transform the header to a 'usable' info
2447
+        $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2448 2448
     }
2449 2449
 
2450 2450
     // ----- Zip file comment
2451 2451
     $v_comment = '';
2452 2452
     if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2453
-      $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2453
+        $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2454 2454
     }
2455 2455
 
2456 2456
     // ----- Calculate the size of the central header
@@ -2459,29 +2459,29 @@  discard block
 block discarded – undo
2459 2459
     // ----- Create the central dir footer
2460 2460
     if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
2461 2461
     {
2462
-      // ----- Reset the file list
2463
-      unset($v_header_list);
2462
+        // ----- Reset the file list
2463
+        unset($v_header_list);
2464 2464
 
2465
-      // ----- Return
2466
-      return $v_result;
2465
+        // ----- Return
2466
+        return $v_result;
2467 2467
     }
2468 2468
 
2469 2469
     // ----- Return
2470 2470
     return $v_result;
2471
-  }
2472
-  // --------------------------------------------------------------------------------
2473
-
2474
-  // --------------------------------------------------------------------------------
2475
-  // Function : privAddFileList()
2476
-  // Description :
2477
-  // Parameters :
2478
-  //   $p_filedescr_list : An array containing the file description
2479
-  //                      or directory names to add in the zip
2480
-  //   $p_result_list : list of added files with their properties (specially the status field)
2481
-  // Return Values :
2482
-  // --------------------------------------------------------------------------------
2483
-  function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
2484
-  {
2471
+    }
2472
+    // --------------------------------------------------------------------------------
2473
+
2474
+    // --------------------------------------------------------------------------------
2475
+    // Function : privAddFileList()
2476
+    // Description :
2477
+    // Parameters :
2478
+    //   $p_filedescr_list : An array containing the file description
2479
+    //                      or directory names to add in the zip
2480
+    //   $p_result_list : list of added files with their properties (specially the status field)
2481
+    // Return Values :
2482
+    // --------------------------------------------------------------------------------
2483
+    function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
2484
+    {
2485 2485
     $v_result=1;
2486 2486
     $v_header = array();
2487 2487
 
@@ -2490,60 +2490,60 @@  discard block
 block discarded – undo
2490 2490
 
2491 2491
     // ----- Loop on the files
2492 2492
     for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
2493
-      // ----- Format the filename
2494
-      $p_filedescr_list[$j]['filename']
2495
-      = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
2493
+        // ----- Format the filename
2494
+        $p_filedescr_list[$j]['filename']
2495
+        = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
2496 2496
 
2497 2497
 
2498
-      // ----- Skip empty file names
2499
-      // TBC : Can this be possible ? not checked in DescrParseAtt ?
2500
-      if ($p_filedescr_list[$j]['filename'] == "") {
2498
+        // ----- Skip empty file names
2499
+        // TBC : Can this be possible ? not checked in DescrParseAtt ?
2500
+        if ($p_filedescr_list[$j]['filename'] == "") {
2501 2501
         continue;
2502
-      }
2502
+        }
2503 2503
 
2504
-      // ----- Check the filename
2505
-      if (   ($p_filedescr_list[$j]['type'] != 'virtual_file')
2504
+        // ----- Check the filename
2505
+        if (   ($p_filedescr_list[$j]['type'] != 'virtual_file')
2506 2506
           && (!file_exists($p_filedescr_list[$j]['filename']))) {
2507 2507
         PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exist");
2508 2508
         return PclZip::errorCode();
2509
-      }
2509
+        }
2510 2510
 
2511
-      // ----- Look if it is a file or a dir with no all path remove option
2512
-      // or a dir with all its path removed
2511
+        // ----- Look if it is a file or a dir with no all path remove option
2512
+        // or a dir with all its path removed
2513 2513
 //      if (   (is_file($p_filedescr_list[$j]['filename']))
2514 2514
 //          || (   is_dir($p_filedescr_list[$j]['filename'])
2515
-      if (   ($p_filedescr_list[$j]['type'] == 'file')
2515
+        if (   ($p_filedescr_list[$j]['type'] == 'file')
2516 2516
           || ($p_filedescr_list[$j]['type'] == 'virtual_file')
2517 2517
           || (   ($p_filedescr_list[$j]['type'] == 'folder')
2518 2518
               && (   !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
2519 2519
                   || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))
2520
-          ) {
2520
+            ) {
2521 2521
 
2522 2522
         // ----- Add the file
2523 2523
         $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
2524
-                                       $p_options);
2524
+                                        $p_options);
2525 2525
         if ($v_result != 1) {
2526
-          return $v_result;
2526
+            return $v_result;
2527 2527
         }
2528 2528
 
2529 2529
         // ----- Store the file infos
2530 2530
         $p_result_list[$v_nb++] = $v_header;
2531
-      }
2531
+        }
2532 2532
     }
2533 2533
 
2534 2534
     // ----- Return
2535 2535
     return $v_result;
2536
-  }
2537
-  // --------------------------------------------------------------------------------
2538
-
2539
-  // --------------------------------------------------------------------------------
2540
-  // Function : privAddFile()
2541
-  // Description :
2542
-  // Parameters :
2543
-  // Return Values :
2544
-  // --------------------------------------------------------------------------------
2545
-  function privAddFile($p_filedescr, &$p_header, &$p_options)
2546
-  {
2536
+    }
2537
+    // --------------------------------------------------------------------------------
2538
+
2539
+    // --------------------------------------------------------------------------------
2540
+    // Function : privAddFile()
2541
+    // Description :
2542
+    // Parameters :
2543
+    // Return Values :
2544
+    // --------------------------------------------------------------------------------
2545
+    function privAddFile($p_filedescr, &$p_header, &$p_options)
2546
+    {
2547 2547
     $v_result=1;
2548 2548
 
2549 2549
     // ----- Working variable
@@ -2551,11 +2551,11 @@  discard block
 block discarded – undo
2551 2551
 
2552 2552
     // TBC : Already done in the fileAtt check ... ?
2553 2553
     if ($p_filename == "") {
2554
-      // ----- Error log
2555
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
2554
+        // ----- Error log
2555
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
2556 2556
 
2557
-      // ----- Return
2558
-      return PclZip::errorCode();
2557
+        // ----- Return
2558
+        return PclZip::errorCode();
2559 2559
     }
2560 2560
 
2561 2561
     // ----- Look for a stored different filename
@@ -2590,94 +2590,94 @@  discard block
 block discarded – undo
2590 2590
 
2591 2591
     // ----- Look for regular file
2592 2592
     if ($p_filedescr['type']=='file') {
2593
-      $p_header['external'] = 0x00000000;
2594
-      $p_header['size'] = filesize($p_filename);
2593
+        $p_header['external'] = 0x00000000;
2594
+        $p_header['size'] = filesize($p_filename);
2595 2595
     }
2596 2596
 
2597 2597
     // ----- Look for regular folder
2598 2598
     else if ($p_filedescr['type']=='folder') {
2599
-      $p_header['external'] = 0x00000010;
2600
-      $p_header['mtime'] = filemtime($p_filename);
2601
-      $p_header['size'] = filesize($p_filename);
2599
+        $p_header['external'] = 0x00000010;
2600
+        $p_header['mtime'] = filemtime($p_filename);
2601
+        $p_header['size'] = filesize($p_filename);
2602 2602
     }
2603 2603
 
2604 2604
     // ----- Look for virtual file
2605 2605
     else if ($p_filedescr['type'] == 'virtual_file') {
2606
-      $p_header['external'] = 0x00000000;
2607
-      $p_header['size'] = strlen($p_filedescr['content']);
2606
+        $p_header['external'] = 0x00000000;
2607
+        $p_header['size'] = strlen($p_filedescr['content']);
2608 2608
     }
2609 2609
 
2610 2610
 
2611 2611
     // ----- Look for filetime
2612 2612
     if (isset($p_filedescr['mtime'])) {
2613
-      $p_header['mtime'] = $p_filedescr['mtime'];
2613
+        $p_header['mtime'] = $p_filedescr['mtime'];
2614 2614
     }
2615 2615
     else if ($p_filedescr['type'] == 'virtual_file') {
2616
-      $p_header['mtime'] = time();
2616
+        $p_header['mtime'] = time();
2617 2617
     }
2618 2618
     else {
2619
-      $p_header['mtime'] = filemtime($p_filename);
2619
+        $p_header['mtime'] = filemtime($p_filename);
2620 2620
     }
2621 2621
 
2622 2622
     // ------ Look for file comment
2623 2623
     if (isset($p_filedescr['comment'])) {
2624
-      $p_header['comment_len'] = strlen($p_filedescr['comment']);
2625
-      $p_header['comment'] = $p_filedescr['comment'];
2624
+        $p_header['comment_len'] = strlen($p_filedescr['comment']);
2625
+        $p_header['comment'] = $p_filedescr['comment'];
2626 2626
     }
2627 2627
     else {
2628
-      $p_header['comment_len'] = 0;
2629
-      $p_header['comment'] = '';
2628
+        $p_header['comment_len'] = 0;
2629
+        $p_header['comment'] = '';
2630 2630
     }
2631 2631
 
2632 2632
     // ----- Look for pre-add callback
2633 2633
     if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
2634 2634
 
2635
-      // ----- Generate a local information
2636
-      $v_local_header = array();
2637
-      $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2635
+        // ----- Generate a local information
2636
+        $v_local_header = array();
2637
+        $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2638 2638
 
2639
-      // ----- Call the callback
2640
-      // Here I do not use call_user_func() because I need to send a reference to the
2641
-      // header.
2639
+        // ----- Call the callback
2640
+        // Here I do not use call_user_func() because I need to send a reference to the
2641
+        // header.
2642 2642
 //      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);');
2643
-      $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
2644
-      if ($v_result == 0) {
2643
+        $v_result = $p_options[PCLZIP_CB_PRE_ADD](PCLZIP_CB_PRE_ADD, $v_local_header);
2644
+        if ($v_result == 0) {
2645 2645
         // ----- Change the file status
2646 2646
         $p_header['status'] = "skipped";
2647 2647
         $v_result = 1;
2648
-      }
2648
+        }
2649 2649
 
2650
-      // ----- Update the informations
2651
-      // Only some fields can be modified
2652
-      if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
2650
+        // ----- Update the informations
2651
+        // Only some fields can be modified
2652
+        if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
2653 2653
         $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
2654
-      }
2654
+        }
2655 2655
     }
2656 2656
 
2657 2657
     // ----- Look for empty stored filename
2658 2658
     if ($p_header['stored_filename'] == "") {
2659
-      $p_header['status'] = "filtered";
2659
+        $p_header['status'] = "filtered";
2660 2660
     }
2661 2661
 
2662 2662
     // ----- Check the path length
2663 2663
     if (strlen($p_header['stored_filename']) > 0xFF) {
2664
-      $p_header['status'] = 'filename_too_long';
2664
+        $p_header['status'] = 'filename_too_long';
2665 2665
     }
2666 2666
 
2667 2667
     // ----- Look if no error, or file not skipped
2668 2668
     if ($p_header['status'] == 'ok') {
2669 2669
 
2670
-      // ----- Look for a file
2671
-      if ($p_filedescr['type'] == 'file') {
2670
+        // ----- Look for a file
2671
+        if ($p_filedescr['type'] == 'file') {
2672 2672
         // ----- Look for using temporary file to zip
2673 2673
         if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
2674 2674
             && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
2675 2675
                 || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
2676 2676
                     && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_header['size'])) ) ) {
2677
-          $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
2678
-          if ($v_result < PCLZIP_ERR_NO_ERROR) {
2677
+            $v_result = $this->privAddFileUsingTempFile($p_filedescr, $p_header, $p_options);
2678
+            if ($v_result < PCLZIP_ERR_NO_ERROR) {
2679 2679
             return $v_result;
2680
-          }
2680
+            }
2681 2681
         }
2682 2682
 
2683 2683
         // ----- Use "in memory" zip algo
@@ -2685,8 +2685,8 @@  discard block
 block discarded – undo
2685 2685
 
2686 2686
         // ----- Open the source file
2687 2687
         if (($v_file = @fopen($p_filename, "rb")) == 0) {
2688
-          PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2689
-          return PclZip::errorCode();
2688
+            PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2689
+            return PclZip::errorCode();
2690 2690
         }
2691 2691
 
2692 2692
         // ----- Read the file content
@@ -2700,25 +2700,25 @@  discard block
 block discarded – undo
2700 2700
 
2701 2701
         // ----- Look for no compression
2702 2702
         if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
2703
-          // ----- Set header parameters
2704
-          $p_header['compressed_size'] = $p_header['size'];
2705
-          $p_header['compression'] = 0;
2703
+            // ----- Set header parameters
2704
+            $p_header['compressed_size'] = $p_header['size'];
2705
+            $p_header['compression'] = 0;
2706 2706
         }
2707 2707
 
2708 2708
         // ----- Look for normal compression
2709 2709
         else {
2710
-          // ----- Compress the content
2711
-          $v_content = @gzdeflate($v_content);
2710
+            // ----- Compress the content
2711
+            $v_content = @gzdeflate($v_content);
2712 2712
 
2713
-          // ----- Set header parameters
2714
-          $p_header['compressed_size'] = strlen($v_content);
2715
-          $p_header['compression'] = 8;
2713
+            // ----- Set header parameters
2714
+            $p_header['compressed_size'] = strlen($v_content);
2715
+            $p_header['compression'] = 8;
2716 2716
         }
2717 2717
 
2718 2718
         // ----- Call the header generation
2719 2719
         if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2720
-          @fclose($v_file);
2721
-          return $v_result;
2720
+            @fclose($v_file);
2721
+            return $v_result;
2722 2722
         }
2723 2723
 
2724 2724
         // ----- Write the compressed (or not) content
@@ -2726,10 +2726,10 @@  discard block
 block discarded – undo
2726 2726
 
2727 2727
         }
2728 2728
 
2729
-      }
2729
+        }
2730 2730
 
2731
-      // ----- Look for a virtual file (a file from string)
2732
-      else if ($p_filedescr['type'] == 'virtual_file') {
2731
+        // ----- Look for a virtual file (a file from string)
2732
+        else if ($p_filedescr['type'] == 'virtual_file') {
2733 2733
 
2734 2734
         $v_content = $p_filedescr['content'];
2735 2735
 
@@ -2738,36 +2738,36 @@  discard block
 block discarded – undo
2738 2738
 
2739 2739
         // ----- Look for no compression
2740 2740
         if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
2741
-          // ----- Set header parameters
2742
-          $p_header['compressed_size'] = $p_header['size'];
2743
-          $p_header['compression'] = 0;
2741
+            // ----- Set header parameters
2742
+            $p_header['compressed_size'] = $p_header['size'];
2743
+            $p_header['compression'] = 0;
2744 2744
         }
2745 2745
 
2746 2746
         // ----- Look for normal compression
2747 2747
         else {
2748
-          // ----- Compress the content
2749
-          $v_content = @gzdeflate($v_content);
2748
+            // ----- Compress the content
2749
+            $v_content = @gzdeflate($v_content);
2750 2750
 
2751
-          // ----- Set header parameters
2752
-          $p_header['compressed_size'] = strlen($v_content);
2753
-          $p_header['compression'] = 8;
2751
+            // ----- Set header parameters
2752
+            $p_header['compressed_size'] = strlen($v_content);
2753
+            $p_header['compression'] = 8;
2754 2754
         }
2755 2755
 
2756 2756
         // ----- Call the header generation
2757 2757
         if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2758
-          @fclose($v_file);
2759
-          return $v_result;
2758
+            @fclose($v_file);
2759
+            return $v_result;
2760 2760
         }
2761 2761
 
2762 2762
         // ----- Write the compressed (or not) content
2763 2763
         @fwrite($this->zip_fd, $v_content, $p_header['compressed_size']);
2764
-      }
2764
+        }
2765 2765
 
2766
-      // ----- Look for a directory
2767
-      else if ($p_filedescr['type'] == 'folder') {
2766
+        // ----- Look for a directory
2767
+        else if ($p_filedescr['type'] == 'folder') {
2768 2768
         // ----- Look for directory last '/'
2769 2769
         if (@substr($p_header['stored_filename'], -1) != '/') {
2770
-          $p_header['stored_filename'] .= '/';
2770
+            $p_header['stored_filename'] .= '/';
2771 2771
         }
2772 2772
 
2773 2773
         // ----- Set the file properties
@@ -2778,45 +2778,45 @@  discard block
 block discarded – undo
2778 2778
         // ----- Call the header generation
2779 2779
         if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
2780 2780
         {
2781
-          return $v_result;
2781
+            return $v_result;
2782
+        }
2782 2783
         }
2783
-      }
2784 2784
     }
2785 2785
 
2786 2786
     // ----- Look for post-add callback
2787 2787
     if (isset($p_options[PCLZIP_CB_POST_ADD])) {
2788 2788
 
2789
-      // ----- Generate a local information
2790
-      $v_local_header = array();
2791
-      $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2789
+        // ----- Generate a local information
2790
+        $v_local_header = array();
2791
+        $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2792 2792
 
2793
-      // ----- Call the callback
2794
-      // Here I do not use call_user_func() because I need to send a reference to the
2795
-      // header.
2793
+        // ----- Call the callback
2794
+        // Here I do not use call_user_func() because I need to send a reference to the
2795
+        // header.
2796 2796
 //      eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);');
2797
-      $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
2798
-      if ($v_result == 0) {
2797
+        $v_result = $p_options[PCLZIP_CB_POST_ADD](PCLZIP_CB_POST_ADD, $v_local_header);
2798
+        if ($v_result == 0) {
2799 2799
         // ----- Ignored
2800 2800
         $v_result = 1;
2801
-      }
2801
+        }
2802 2802
 
2803
-      // ----- Update the informations
2804
-      // Nothing can be modified
2803
+        // ----- Update the informations
2804
+        // Nothing can be modified
2805 2805
     }
2806 2806
 
2807 2807
     // ----- Return
2808 2808
     return $v_result;
2809
-  }
2810
-  // --------------------------------------------------------------------------------
2811
-
2812
-  // --------------------------------------------------------------------------------
2813
-  // Function : privAddFileUsingTempFile()
2814
-  // Description :
2815
-  // Parameters :
2816
-  // Return Values :
2817
-  // --------------------------------------------------------------------------------
2818
-  function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
2819
-  {
2809
+    }
2810
+    // --------------------------------------------------------------------------------
2811
+
2812
+    // --------------------------------------------------------------------------------
2813
+    // Function : privAddFileUsingTempFile()
2814
+    // Description :
2815
+    // Parameters :
2816
+    // Return Values :
2817
+    // --------------------------------------------------------------------------------
2818
+    function privAddFileUsingTempFile($p_filedescr, &$p_header, &$p_options)
2819
+    {
2820 2820
     $v_result=PCLZIP_ERR_NO_ERROR;
2821 2821
 
2822 2822
     // ----- Working variable
@@ -2825,26 +2825,26 @@  discard block
 block discarded – undo
2825 2825
 
2826 2826
     // ----- Open the source file
2827 2827
     if (($v_file = @fopen($p_filename, "rb")) == 0) {
2828
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2829
-      return PclZip::errorCode();
2828
+        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2829
+        return PclZip::errorCode();
2830 2830
     }
2831 2831
 
2832 2832
     // ----- Creates a compressed temporary file
2833 2833
     $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
2834 2834
     if (($v_file_compressed = @gzopen($v_gzip_temp_name, "wb")) == 0) {
2835
-      fclose($v_file);
2836
-      PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
2837
-      return PclZip::errorCode();
2835
+        fclose($v_file);
2836
+        PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
2837
+        return PclZip::errorCode();
2838 2838
     }
2839 2839
 
2840 2840
     // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
2841 2841
     $v_size = filesize($p_filename);
2842 2842
     while ($v_size != 0) {
2843
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2844
-      $v_buffer = @fread($v_file, $v_read_size);
2845
-      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2846
-      @gzputs($v_file_compressed, $v_buffer, $v_read_size);
2847
-      $v_size -= $v_read_size;
2843
+        $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2844
+        $v_buffer = @fread($v_file, $v_read_size);
2845
+        //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2846
+        @gzputs($v_file_compressed, $v_buffer, $v_read_size);
2847
+        $v_size -= $v_read_size;
2848 2848
     }
2849 2849
 
2850 2850
     // ----- Close the file
@@ -2853,14 +2853,14 @@  discard block
 block discarded – undo
2853 2853
 
2854 2854
     // ----- Check the minimum file size
2855 2855
     if (filesize($v_gzip_temp_name) < 18) {
2856
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
2857
-      return PclZip::errorCode();
2856
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'gzip temporary file \''.$v_gzip_temp_name.'\' has invalid filesize - should be minimum 18 bytes');
2857
+        return PclZip::errorCode();
2858 2858
     }
2859 2859
 
2860 2860
     // ----- Extract the compressed attributes
2861 2861
     if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0) {
2862
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2863
-      return PclZip::errorCode();
2862
+        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2863
+        return PclZip::errorCode();
2864 2864
     }
2865 2865
 
2866 2866
     // ----- Read the gzip file header
@@ -2886,14 +2886,14 @@  discard block
 block discarded – undo
2886 2886
 
2887 2887
     // ----- Call the header generation
2888 2888
     if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2889
-      return $v_result;
2889
+        return $v_result;
2890 2890
     }
2891 2891
 
2892 2892
     // ----- Add the compressed data
2893 2893
     if (($v_file_compressed = @fopen($v_gzip_temp_name, "rb")) == 0)
2894 2894
     {
2895
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2896
-      return PclZip::errorCode();
2895
+        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
2896
+        return PclZip::errorCode();
2897 2897
     }
2898 2898
 
2899 2899
     // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
@@ -2901,11 +2901,11 @@  discard block
 block discarded – undo
2901 2901
     $v_size = $p_header['compressed_size'];
2902 2902
     while ($v_size != 0)
2903 2903
     {
2904
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2905
-      $v_buffer = @fread($v_file_compressed, $v_read_size);
2906
-      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2907
-      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2908
-      $v_size -= $v_read_size;
2904
+        $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2905
+        $v_buffer = @fread($v_file_compressed, $v_read_size);
2906
+        //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
2907
+        @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2908
+        $v_size -= $v_read_size;
2909 2909
     }
2910 2910
 
2911 2911
     // ----- Close the file
@@ -2916,112 +2916,112 @@  discard block
 block discarded – undo
2916 2916
 
2917 2917
     // ----- Return
2918 2918
     return $v_result;
2919
-  }
2920
-  // --------------------------------------------------------------------------------
2921
-
2922
-  // --------------------------------------------------------------------------------
2923
-  // Function : privCalculateStoredFilename()
2924
-  // Description :
2925
-  //   Based on file descriptor properties and global options, this method
2926
-  //   calculate the filename that will be stored in the archive.
2927
-  // Parameters :
2928
-  // Return Values :
2929
-  // --------------------------------------------------------------------------------
2930
-  function privCalculateStoredFilename(&$p_filedescr, &$p_options)
2931
-  {
2919
+    }
2920
+    // --------------------------------------------------------------------------------
2921
+
2922
+    // --------------------------------------------------------------------------------
2923
+    // Function : privCalculateStoredFilename()
2924
+    // Description :
2925
+    //   Based on file descriptor properties and global options, this method
2926
+    //   calculate the filename that will be stored in the archive.
2927
+    // Parameters :
2928
+    // Return Values :
2929
+    // --------------------------------------------------------------------------------
2930
+    function privCalculateStoredFilename(&$p_filedescr, &$p_options)
2931
+    {
2932 2932
     $v_result=1;
2933 2933
 
2934 2934
     // ----- Working variables
2935 2935
     $p_filename = $p_filedescr['filename'];
2936 2936
     if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
2937
-      $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
2937
+        $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
2938 2938
     }
2939 2939
     else {
2940
-      $p_add_dir = '';
2940
+        $p_add_dir = '';
2941 2941
     }
2942 2942
     if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
2943
-      $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
2943
+        $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
2944 2944
     }
2945 2945
     else {
2946
-      $p_remove_dir = '';
2946
+        $p_remove_dir = '';
2947 2947
     }
2948 2948
     if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
2949
-      $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
2949
+        $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
2950 2950
     }
2951 2951
     else {
2952
-      $p_remove_all_dir = 0;
2952
+        $p_remove_all_dir = 0;
2953 2953
     }
2954 2954
 
2955 2955
 
2956 2956
     // ----- Look for full name change
2957 2957
     if (isset($p_filedescr['new_full_name'])) {
2958
-      // ----- Remove drive letter if any
2959
-      $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
2958
+        // ----- Remove drive letter if any
2959
+        $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
2960 2960
     }
2961 2961
 
2962 2962
     // ----- Look for path and/or short name change
2963 2963
     else {
2964 2964
 
2965
-      // ----- Look for short name change
2966
-      // Its when we cahnge just the filename but not the path
2967
-      if (isset($p_filedescr['new_short_name'])) {
2965
+        // ----- Look for short name change
2966
+        // Its when we cahnge just the filename but not the path
2967
+        if (isset($p_filedescr['new_short_name'])) {
2968 2968
         $v_path_info = pathinfo($p_filename);
2969 2969
         $v_dir = '';
2970 2970
         if ($v_path_info['dirname'] != '') {
2971
-          $v_dir = $v_path_info['dirname'].'/';
2971
+            $v_dir = $v_path_info['dirname'].'/';
2972 2972
         }
2973 2973
         $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
2974
-      }
2975
-      else {
2974
+        }
2975
+        else {
2976 2976
         // ----- Calculate the stored filename
2977 2977
         $v_stored_filename = $p_filename;
2978
-      }
2978
+        }
2979 2979
 
2980
-      // ----- Look for all path to remove
2981
-      if ($p_remove_all_dir) {
2980
+        // ----- Look for all path to remove
2981
+        if ($p_remove_all_dir) {
2982 2982
         $v_stored_filename = basename($p_filename);
2983
-      }
2984
-      // ----- Look for partial path remove
2985
-      else if ($p_remove_dir != "") {
2983
+        }
2984
+        // ----- Look for partial path remove
2985
+        else if ($p_remove_dir != "") {
2986 2986
         if (substr($p_remove_dir, -1) != '/')
2987
-          $p_remove_dir .= "/";
2987
+            $p_remove_dir .= "/";
2988 2988
 
2989 2989
         if (   (substr($p_filename, 0, 2) == "./")
2990 2990
             || (substr($p_remove_dir, 0, 2) == "./")) {
2991 2991
 
2992
-          if (   (substr($p_filename, 0, 2) == "./")
2992
+            if (   (substr($p_filename, 0, 2) == "./")
2993 2993
               && (substr($p_remove_dir, 0, 2) != "./")) {
2994 2994
             $p_remove_dir = "./".$p_remove_dir;
2995
-          }
2996
-          if (   (substr($p_filename, 0, 2) != "./")
2995
+            }
2996
+            if (   (substr($p_filename, 0, 2) != "./")
2997 2997
               && (substr($p_remove_dir, 0, 2) == "./")) {
2998 2998
             $p_remove_dir = substr($p_remove_dir, 2);
2999
-          }
2999
+            }
3000 3000
         }
3001 3001
 
3002 3002
         $v_compare = PclZipUtilPathInclusion($p_remove_dir,
3003
-                                             $v_stored_filename);
3003
+                                                $v_stored_filename);
3004 3004
         if ($v_compare > 0) {
3005
-          if ($v_compare == 2) {
3005
+            if ($v_compare == 2) {
3006 3006
             $v_stored_filename = "";
3007
-          }
3008
-          else {
3007
+            }
3008
+            else {
3009 3009
             $v_stored_filename = substr($v_stored_filename,
3010 3010
                                         strlen($p_remove_dir));
3011
-          }
3011
+            }
3012
+        }
3012 3013
         }
3013
-      }
3014 3014
 
3015
-      // ----- Remove drive letter if any
3016
-      $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
3015
+        // ----- Remove drive letter if any
3016
+        $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
3017 3017
 
3018
-      // ----- Look for path to add
3019
-      if ($p_add_dir != "") {
3018
+        // ----- Look for path to add
3019
+        if ($p_add_dir != "") {
3020 3020
         if (substr($p_add_dir, -1) == "/")
3021
-          $v_stored_filename = $p_add_dir.$v_stored_filename;
3021
+            $v_stored_filename = $p_add_dir.$v_stored_filename;
3022 3022
         else
3023
-          $v_stored_filename = $p_add_dir."/".$v_stored_filename;
3024
-      }
3023
+            $v_stored_filename = $p_add_dir."/".$v_stored_filename;
3024
+        }
3025 3025
     }
3026 3026
 
3027 3027
     // ----- Filename (reduce the path of stored name)
@@ -3030,17 +3030,17 @@  discard block
 block discarded – undo
3030 3030
 
3031 3031
     // ----- Return
3032 3032
     return $v_result;
3033
-  }
3034
-  // --------------------------------------------------------------------------------
3035
-
3036
-  // --------------------------------------------------------------------------------
3037
-  // Function : privWriteFileHeader()
3038
-  // Description :
3039
-  // Parameters :
3040
-  // Return Values :
3041
-  // --------------------------------------------------------------------------------
3042
-  function privWriteFileHeader(&$p_header)
3043
-  {
3033
+    }
3034
+    // --------------------------------------------------------------------------------
3035
+
3036
+    // --------------------------------------------------------------------------------
3037
+    // Function : privWriteFileHeader()
3038
+    // Description :
3039
+    // Parameters :
3040
+    // Return Values :
3041
+    // --------------------------------------------------------------------------------
3042
+    function privWriteFileHeader(&$p_header)
3043
+    {
3044 3044
     $v_result=1;
3045 3045
 
3046 3046
     // ----- Store the offset position of the file
@@ -3053,12 +3053,12 @@  discard block
 block discarded – undo
3053 3053
 
3054 3054
     // ----- Packed data
3055 3055
     $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
3056
-	                      $p_header['version_extracted'], $p_header['flag'],
3057
-                          $p_header['compression'], $v_mtime, $v_mdate,
3058
-                          $p_header['crc'], $p_header['compressed_size'],
3059
-						  $p_header['size'],
3060
-                          strlen($p_header['stored_filename']),
3061
-						  $p_header['extra_len']);
3056
+                            $p_header['version_extracted'], $p_header['flag'],
3057
+                            $p_header['compression'], $v_mtime, $v_mdate,
3058
+                            $p_header['crc'], $p_header['compressed_size'],
3059
+                            $p_header['size'],
3060
+                            strlen($p_header['stored_filename']),
3061
+                            $p_header['extra_len']);
3062 3062
 
3063 3063
     // ----- Write the first 148 bytes of the header in the archive
3064 3064
     fputs($this->zip_fd, $v_binary_data, 30);
@@ -3066,26 +3066,26 @@  discard block
 block discarded – undo
3066 3066
     // ----- Write the variable fields
3067 3067
     if (strlen($p_header['stored_filename']) != 0)
3068 3068
     {
3069
-      fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3069
+        fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3070 3070
     }
3071 3071
     if ($p_header['extra_len'] != 0)
3072 3072
     {
3073
-      fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3073
+        fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3074 3074
     }
3075 3075
 
3076 3076
     // ----- Return
3077 3077
     return $v_result;
3078
-  }
3079
-  // --------------------------------------------------------------------------------
3080
-
3081
-  // --------------------------------------------------------------------------------
3082
-  // Function : privWriteCentralFileHeader()
3083
-  // Description :
3084
-  // Parameters :
3085
-  // Return Values :
3086
-  // --------------------------------------------------------------------------------
3087
-  function privWriteCentralFileHeader(&$p_header)
3088
-  {
3078
+    }
3079
+    // --------------------------------------------------------------------------------
3080
+
3081
+    // --------------------------------------------------------------------------------
3082
+    // Function : privWriteCentralFileHeader()
3083
+    // Description :
3084
+    // Parameters :
3085
+    // Return Values :
3086
+    // --------------------------------------------------------------------------------
3087
+    function privWriteCentralFileHeader(&$p_header)
3088
+    {
3089 3089
     $v_result=1;
3090 3090
 
3091 3091
     // TBC
@@ -3100,14 +3100,14 @@  discard block
 block discarded – undo
3100 3100
 
3101 3101
     // ----- Packed data
3102 3102
     $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
3103
-	                      $p_header['version'], $p_header['version_extracted'],
3104
-                          $p_header['flag'], $p_header['compression'],
3105
-						  $v_mtime, $v_mdate, $p_header['crc'],
3106
-                          $p_header['compressed_size'], $p_header['size'],
3107
-                          strlen($p_header['stored_filename']),
3108
-						  $p_header['extra_len'], $p_header['comment_len'],
3109
-                          $p_header['disk'], $p_header['internal'],
3110
-						  $p_header['external'], $p_header['offset']);
3103
+                            $p_header['version'], $p_header['version_extracted'],
3104
+                            $p_header['flag'], $p_header['compression'],
3105
+                            $v_mtime, $v_mdate, $p_header['crc'],
3106
+                            $p_header['compressed_size'], $p_header['size'],
3107
+                            strlen($p_header['stored_filename']),
3108
+                            $p_header['extra_len'], $p_header['comment_len'],
3109
+                            $p_header['disk'], $p_header['internal'],
3110
+                            $p_header['external'], $p_header['offset']);
3111 3111
 
3112 3112
     // ----- Write the 42 bytes of the header in the zip file
3113 3113
     fputs($this->zip_fd, $v_binary_data, 46);
@@ -3115,36 +3115,36 @@  discard block
 block discarded – undo
3115 3115
     // ----- Write the variable fields
3116 3116
     if (strlen($p_header['stored_filename']) != 0)
3117 3117
     {
3118
-      fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3118
+        fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
3119 3119
     }
3120 3120
     if ($p_header['extra_len'] != 0)
3121 3121
     {
3122
-      fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3122
+        fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
3123 3123
     }
3124 3124
     if ($p_header['comment_len'] != 0)
3125 3125
     {
3126
-      fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
3126
+        fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
3127 3127
     }
3128 3128
 
3129 3129
     // ----- Return
3130 3130
     return $v_result;
3131
-  }
3132
-  // --------------------------------------------------------------------------------
3133
-
3134
-  // --------------------------------------------------------------------------------
3135
-  // Function : privWriteCentralHeader()
3136
-  // Description :
3137
-  // Parameters :
3138
-  // Return Values :
3139
-  // --------------------------------------------------------------------------------
3140
-  function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
3141
-  {
3131
+    }
3132
+    // --------------------------------------------------------------------------------
3133
+
3134
+    // --------------------------------------------------------------------------------
3135
+    // Function : privWriteCentralHeader()
3136
+    // Description :
3137
+    // Parameters :
3138
+    // Return Values :
3139
+    // --------------------------------------------------------------------------------
3140
+    function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
3141
+    {
3142 3142
     $v_result=1;
3143 3143
 
3144 3144
     // ----- Packed data
3145 3145
     $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
3146
-	                      $p_nb_entries, $p_size,
3147
-						  $p_offset, strlen($p_comment));
3146
+                            $p_nb_entries, $p_size,
3147
+                            $p_offset, strlen($p_comment));
3148 3148
 
3149 3149
     // ----- Write the 22 bytes of the header in the zip file
3150 3150
     fputs($this->zip_fd, $v_binary_data, 22);
@@ -3152,22 +3152,22 @@  discard block
 block discarded – undo
3152 3152
     // ----- Write the variable fields
3153 3153
     if (strlen($p_comment) != 0)
3154 3154
     {
3155
-      fputs($this->zip_fd, $p_comment, strlen($p_comment));
3155
+        fputs($this->zip_fd, $p_comment, strlen($p_comment));
3156 3156
     }
3157 3157
 
3158 3158
     // ----- Return
3159 3159
     return $v_result;
3160
-  }
3161
-  // --------------------------------------------------------------------------------
3162
-
3163
-  // --------------------------------------------------------------------------------
3164
-  // Function : privList()
3165
-  // Description :
3166
-  // Parameters :
3167
-  // Return Values :
3168
-  // --------------------------------------------------------------------------------
3169
-  function privList(&$p_list)
3170
-  {
3160
+    }
3161
+    // --------------------------------------------------------------------------------
3162
+
3163
+    // --------------------------------------------------------------------------------
3164
+    // Function : privList()
3165
+    // Description :
3166
+    // Parameters :
3167
+    // Return Values :
3168
+    // --------------------------------------------------------------------------------
3169
+    function privList(&$p_list)
3170
+    {
3171 3171
     $v_result=1;
3172 3172
 
3173 3173
     // ----- Magic quotes trick
@@ -3176,51 +3176,51 @@  discard block
 block discarded – undo
3176 3176
     // ----- Open the zip file
3177 3177
     if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
3178 3178
     {
3179
-      // ----- Magic quotes trick
3180
-      $this->privSwapBackMagicQuotes();
3179
+        // ----- Magic quotes trick
3180
+        $this->privSwapBackMagicQuotes();
3181 3181
 
3182
-      // ----- Error log
3183
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
3182
+        // ----- Error log
3183
+        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
3184 3184
 
3185
-      // ----- Return
3186
-      return PclZip::errorCode();
3185
+        // ----- Return
3186
+        return PclZip::errorCode();
3187 3187
     }
3188 3188
 
3189 3189
     // ----- Read the central directory informations
3190 3190
     $v_central_dir = array();
3191 3191
     if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3192 3192
     {
3193
-      $this->privSwapBackMagicQuotes();
3194
-      return $v_result;
3193
+        $this->privSwapBackMagicQuotes();
3194
+        return $v_result;
3195 3195
     }
3196 3196
 
3197 3197
     // ----- Go to beginning of Central Dir
3198 3198
     @rewind($this->zip_fd);
3199 3199
     if (@fseek($this->zip_fd, $v_central_dir['offset']))
3200 3200
     {
3201
-      $this->privSwapBackMagicQuotes();
3201
+        $this->privSwapBackMagicQuotes();
3202 3202
 
3203
-      // ----- Error log
3204
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3203
+        // ----- Error log
3204
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3205 3205
 
3206
-      // ----- Return
3207
-      return PclZip::errorCode();
3206
+        // ----- Return
3207
+        return PclZip::errorCode();
3208 3208
     }
3209 3209
 
3210 3210
     // ----- Read each entry
3211 3211
     for ($i=0; $i<$v_central_dir['entries']; $i++)
3212 3212
     {
3213
-      // ----- Read the file header
3214
-      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3215
-      {
3213
+        // ----- Read the file header
3214
+        if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3215
+        {
3216 3216
         $this->privSwapBackMagicQuotes();
3217 3217
         return $v_result;
3218
-      }
3219
-      $v_header['index'] = $i;
3218
+        }
3219
+        $v_header['index'] = $i;
3220 3220
 
3221
-      // ----- Get the only interesting attributes
3222
-      $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
3223
-      unset($v_header);
3221
+        // ----- Get the only interesting attributes
3222
+        $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
3223
+        unset($v_header);
3224 3224
     }
3225 3225
 
3226 3226
     // ----- Close the zip file
@@ -3231,30 +3231,30 @@  discard block
 block discarded – undo
3231 3231
 
3232 3232
     // ----- Return
3233 3233
     return $v_result;
3234
-  }
3235
-  // --------------------------------------------------------------------------------
3236
-
3237
-  // --------------------------------------------------------------------------------
3238
-  // Function : privConvertHeader2FileInfo()
3239
-  // Description :
3240
-  //   This function takes the file informations from the central directory
3241
-  //   entries and extract the interesting parameters that will be given back.
3242
-  //   The resulting file infos are set in the array $p_info
3243
-  //     $p_info['filename'] : Filename with full path. Given by user (add),
3244
-  //                           extracted in the filesystem (extract).
3245
-  //     $p_info['stored_filename'] : Stored filename in the archive.
3246
-  //     $p_info['size'] = Size of the file.
3247
-  //     $p_info['compressed_size'] = Compressed size of the file.
3248
-  //     $p_info['mtime'] = Last modification date of the file.
3249
-  //     $p_info['comment'] = Comment associated with the file.
3250
-  //     $p_info['folder'] = true/false : indicates if the entry is a folder or not.
3251
-  //     $p_info['status'] = status of the action on the file.
3252
-  //     $p_info['crc'] = CRC of the file content.
3253
-  // Parameters :
3254
-  // Return Values :
3255
-  // --------------------------------------------------------------------------------
3256
-  function privConvertHeader2FileInfo($p_header, &$p_info)
3257
-  {
3234
+    }
3235
+    // --------------------------------------------------------------------------------
3236
+
3237
+    // --------------------------------------------------------------------------------
3238
+    // Function : privConvertHeader2FileInfo()
3239
+    // Description :
3240
+    //   This function takes the file informations from the central directory
3241
+    //   entries and extract the interesting parameters that will be given back.
3242
+    //   The resulting file infos are set in the array $p_info
3243
+    //     $p_info['filename'] : Filename with full path. Given by user (add),
3244
+    //                           extracted in the filesystem (extract).
3245
+    //     $p_info['stored_filename'] : Stored filename in the archive.
3246
+    //     $p_info['size'] = Size of the file.
3247
+    //     $p_info['compressed_size'] = Compressed size of the file.
3248
+    //     $p_info['mtime'] = Last modification date of the file.
3249
+    //     $p_info['comment'] = Comment associated with the file.
3250
+    //     $p_info['folder'] = true/false : indicates if the entry is a folder or not.
3251
+    //     $p_info['status'] = status of the action on the file.
3252
+    //     $p_info['crc'] = CRC of the file content.
3253
+    // Parameters :
3254
+    // Return Values :
3255
+    // --------------------------------------------------------------------------------
3256
+    function privConvertHeader2FileInfo($p_header, &$p_info)
3257
+    {
3258 3258
     $v_result=1;
3259 3259
 
3260 3260
     // ----- Get the interesting attributes
@@ -3273,27 +3273,27 @@  discard block
 block discarded – undo
3273 3273
 
3274 3274
     // ----- Return
3275 3275
     return $v_result;
3276
-  }
3277
-  // --------------------------------------------------------------------------------
3278
-
3279
-  // --------------------------------------------------------------------------------
3280
-  // Function : privExtractByRule()
3281
-  // Description :
3282
-  //   Extract a file or directory depending of rules (by index, by name, ...)
3283
-  // Parameters :
3284
-  //   $p_file_list : An array where will be placed the properties of each
3285
-  //                  extracted file
3286
-  //   $p_path : Path to add while writing the extracted files
3287
-  //   $p_remove_path : Path to remove (from the file memorized path) while writing the
3288
-  //                    extracted files. If the path does not match the file path,
3289
-  //                    the file is extracted with its memorized path.
3290
-  //                    $p_remove_path does not apply to 'list' mode.
3291
-  //                    $p_path and $p_remove_path are commulative.
3292
-  // Return Values :
3293
-  //   1 on success,0 or less on error (see error code list)
3294
-  // --------------------------------------------------------------------------------
3295
-  function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3296
-  {
3276
+    }
3277
+    // --------------------------------------------------------------------------------
3278
+
3279
+    // --------------------------------------------------------------------------------
3280
+    // Function : privExtractByRule()
3281
+    // Description :
3282
+    //   Extract a file or directory depending of rules (by index, by name, ...)
3283
+    // Parameters :
3284
+    //   $p_file_list : An array where will be placed the properties of each
3285
+    //                  extracted file
3286
+    //   $p_path : Path to add while writing the extracted files
3287
+    //   $p_remove_path : Path to remove (from the file memorized path) while writing the
3288
+    //                    extracted files. If the path does not match the file path,
3289
+    //                    the file is extracted with its memorized path.
3290
+    //                    $p_remove_path does not apply to 'list' mode.
3291
+    //                    $p_path and $p_remove_path are commulative.
3292
+    // Return Values :
3293
+    //   1 on success,0 or less on error (see error code list)
3294
+    // --------------------------------------------------------------------------------
3295
+    function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3296
+    {
3297 3297
     $v_result=1;
3298 3298
 
3299 3299
     // ----- Magic quotes trick
@@ -3301,44 +3301,44 @@  discard block
 block discarded – undo
3301 3301
 
3302 3302
     // ----- Check the path
3303 3303
     if (   ($p_path == "")
3304
-	    || (   (substr($p_path, 0, 1) != "/")
3305
-		    && (substr($p_path, 0, 3) != "../")
3306
-			&& (substr($p_path,1,2)!=":/")))
3307
-      $p_path = "./".$p_path;
3304
+        || (   (substr($p_path, 0, 1) != "/")
3305
+            && (substr($p_path, 0, 3) != "../")
3306
+            && (substr($p_path,1,2)!=":/")))
3307
+        $p_path = "./".$p_path;
3308 3308
 
3309 3309
     // ----- Reduce the path last (and duplicated) '/'
3310 3310
     if (($p_path != "./") && ($p_path != "/"))
3311 3311
     {
3312
-      // ----- Look for the path end '/'
3313
-      while (substr($p_path, -1) == "/")
3314
-      {
3312
+        // ----- Look for the path end '/'
3313
+        while (substr($p_path, -1) == "/")
3314
+        {
3315 3315
         $p_path = substr($p_path, 0, strlen($p_path)-1);
3316
-      }
3316
+        }
3317 3317
     }
3318 3318
 
3319 3319
     // ----- Look for path to remove format (should end by /)
3320 3320
     if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))
3321 3321
     {
3322
-      $p_remove_path .= '/';
3322
+        $p_remove_path .= '/';
3323 3323
     }
3324 3324
     $p_remove_path_size = strlen($p_remove_path);
3325 3325
 
3326 3326
     // ----- Open the zip file
3327 3327
     if (($v_result = $this->privOpenFd('rb')) != 1)
3328 3328
     {
3329
-      $this->privSwapBackMagicQuotes();
3330
-      return $v_result;
3329
+        $this->privSwapBackMagicQuotes();
3330
+        return $v_result;
3331 3331
     }
3332 3332
 
3333 3333
     // ----- Read the central directory informations
3334 3334
     $v_central_dir = array();
3335 3335
     if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3336 3336
     {
3337
-      // ----- Close the zip file
3338
-      $this->privCloseFd();
3339
-      $this->privSwapBackMagicQuotes();
3337
+        // ----- Close the zip file
3338
+        $this->privCloseFd();
3339
+        $this->privSwapBackMagicQuotes();
3340 3340
 
3341
-      return $v_result;
3341
+        return $v_result;
3342 3342
     }
3343 3343
 
3344 3344
     // ----- Start at beginning of Central Dir
@@ -3349,10 +3349,10 @@  discard block
 block discarded – undo
3349 3349
     for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
3350 3350
     {
3351 3351
 
3352
-      // ----- Read next Central dir entry
3353
-      @rewind($this->zip_fd);
3354
-      if (@fseek($this->zip_fd, $v_pos_entry))
3355
-      {
3352
+        // ----- Read next Central dir entry
3353
+        @rewind($this->zip_fd);
3354
+        if (@fseek($this->zip_fd, $v_pos_entry))
3355
+        {
3356 3356
         // ----- Close the zip file
3357 3357
         $this->privCloseFd();
3358 3358
         $this->privSwapBackMagicQuotes();
@@ -3362,54 +3362,54 @@  discard block
 block discarded – undo
3362 3362
 
3363 3363
         // ----- Return
3364 3364
         return PclZip::errorCode();
3365
-      }
3365
+        }
3366 3366
 
3367
-      // ----- Read the file header
3368
-      $v_header = array();
3369
-      if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3370
-      {
3367
+        // ----- Read the file header
3368
+        $v_header = array();
3369
+        if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3370
+        {
3371 3371
         // ----- Close the zip file
3372 3372
         $this->privCloseFd();
3373 3373
         $this->privSwapBackMagicQuotes();
3374 3374
 
3375 3375
         return $v_result;
3376
-      }
3376
+        }
3377 3377
 
3378
-      // ----- Store the index
3379
-      $v_header['index'] = $i;
3378
+        // ----- Store the index
3379
+        $v_header['index'] = $i;
3380 3380
 
3381
-      // ----- Store the file position
3382
-      $v_pos_entry = ftell($this->zip_fd);
3381
+        // ----- Store the file position
3382
+        $v_pos_entry = ftell($this->zip_fd);
3383 3383
 
3384
-      // ----- Look for the specific extract rules
3385
-      $v_extract = false;
3384
+        // ----- Look for the specific extract rules
3385
+        $v_extract = false;
3386 3386
 
3387
-      // ----- Look for extract by name rule
3388
-      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
3387
+        // ----- Look for extract by name rule
3388
+        if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
3389 3389
           && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
3390 3390
 
3391
-          // ----- Look if the filename is in the list
3392
-          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
3391
+            // ----- Look if the filename is in the list
3392
+            for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
3393 3393
 
3394
-              // ----- Look for a directory
3395
-              if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
3394
+                // ----- Look for a directory
3395
+                if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
3396 3396
 
3397
-                  // ----- Look if the directory is in the filename path
3398
-                  if (   (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
3397
+                    // ----- Look if the directory is in the filename path
3398
+                    if (   (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
3399 3399
                       && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
3400
-                      $v_extract = true;
3401
-                  }
3402
-              }
3403
-              // ----- Look for a filename
3404
-              elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
3405
-                  $v_extract = true;
3406
-              }
3407
-          }
3408
-      }
3400
+                        $v_extract = true;
3401
+                    }
3402
+                }
3403
+                // ----- Look for a filename
3404
+                elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
3405
+                    $v_extract = true;
3406
+                }
3407
+            }
3408
+        }
3409 3409
 
3410
-      // ----- Look for extract by ereg rule
3411
-      // ereg() is deprecated with PHP 5.3
3412
-      /*
3410
+        // ----- Look for extract by ereg rule
3411
+        // ereg() is deprecated with PHP 5.3
3412
+        /*
3413 3413
       else if (   (isset($p_options[PCLZIP_OPT_BY_EREG]))
3414 3414
                && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
3415 3415
 
@@ -3419,199 +3419,199 @@  discard block
 block discarded – undo
3419 3419
       }
3420 3420
       */
3421 3421
 
3422
-      // ----- Look for extract by preg rule
3423
-      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
3422
+        // ----- Look for extract by preg rule
3423
+        else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
3424 3424
                && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
3425 3425
 
3426
-          if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
3427
-              $v_extract = true;
3428
-          }
3429
-      }
3426
+            if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
3427
+                $v_extract = true;
3428
+            }
3429
+        }
3430 3430
 
3431
-      // ----- Look for extract by index rule
3432
-      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
3431
+        // ----- Look for extract by index rule
3432
+        else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
3433 3433
                && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
3434 3434
 
3435
-          // ----- Look if the index is in the list
3436
-          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
3435
+            // ----- Look if the index is in the list
3436
+            for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
3437 3437
 
3438
-              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
3439
-                  $v_extract = true;
3440
-              }
3441
-              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
3442
-                  $j_start = $j+1;
3443
-              }
3438
+                if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
3439
+                    $v_extract = true;
3440
+                }
3441
+                if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
3442
+                    $j_start = $j+1;
3443
+                }
3444 3444
 
3445
-              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
3446
-                  break;
3447
-              }
3448
-          }
3449
-      }
3445
+                if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
3446
+                    break;
3447
+                }
3448
+            }
3449
+        }
3450 3450
 
3451
-      // ----- Look for no rule, which means extract all the archive
3452
-      else {
3453
-          $v_extract = true;
3454
-      }
3451
+        // ----- Look for no rule, which means extract all the archive
3452
+        else {
3453
+            $v_extract = true;
3454
+        }
3455 3455
 
3456
-	  // ----- Check compression method
3457
-	  if (   ($v_extract)
3458
-	      && (   ($v_header['compression'] != 8)
3459
-		      && ($v_header['compression'] != 0))) {
3460
-          $v_header['status'] = 'unsupported_compression';
3456
+        // ----- Check compression method
3457
+        if (   ($v_extract)
3458
+          && (   ($v_header['compression'] != 8)
3459
+              && ($v_header['compression'] != 0))) {
3460
+            $v_header['status'] = 'unsupported_compression';
3461 3461
 
3462
-          // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3463
-          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3464
-		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3462
+            // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3463
+            if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3464
+              && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3465 3465
 
3466
-              $this->privSwapBackMagicQuotes();
3466
+                $this->privSwapBackMagicQuotes();
3467 3467
 
3468
-              PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
3469
-			                       "Filename '".$v_header['stored_filename']."' is "
3470
-				  	    	  	   ."compressed by an unsupported compression "
3471
-				  	    	  	   ."method (".$v_header['compression'].") ");
3468
+                PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
3469
+                                    "Filename '".$v_header['stored_filename']."' is "
3470
+                                        ."compressed by an unsupported compression "
3471
+                                        ."method (".$v_header['compression'].") ");
3472 3472
 
3473
-              return PclZip::errorCode();
3474
-		  }
3475
-	  }
3473
+                return PclZip::errorCode();
3474
+            }
3475
+        }
3476 3476
 
3477
-	  // ----- Check encrypted files
3478
-	  if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
3479
-          $v_header['status'] = 'unsupported_encryption';
3477
+        // ----- Check encrypted files
3478
+        if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
3479
+            $v_header['status'] = 'unsupported_encryption';
3480 3480
 
3481
-          // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3482
-          if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3483
-		      && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3481
+            // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3482
+            if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3483
+              && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3484 3484
 
3485
-              $this->privSwapBackMagicQuotes();
3485
+                $this->privSwapBackMagicQuotes();
3486 3486
 
3487
-              PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
3488
-			                       "Unsupported encryption for "
3489
-				  	    	  	   ." filename '".$v_header['stored_filename']
3490
-								   ."'");
3487
+                PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
3488
+                                    "Unsupported encryption for "
3489
+                                        ." filename '".$v_header['stored_filename']
3490
+                                    ."'");
3491 3491
 
3492
-              return PclZip::errorCode();
3493
-		  }
3492
+                return PclZip::errorCode();
3493
+            }
3494 3494
     }
3495 3495
 
3496
-      // ----- Look for real extraction
3497
-      if (($v_extract) && ($v_header['status'] != 'ok')) {
3498
-          $v_result = $this->privConvertHeader2FileInfo($v_header,
3499
-		                                        $p_file_list[$v_nb_extracted++]);
3500
-          if ($v_result != 1) {
3501
-              $this->privCloseFd();
3502
-              $this->privSwapBackMagicQuotes();
3503
-              return $v_result;
3504
-          }
3496
+        // ----- Look for real extraction
3497
+        if (($v_extract) && ($v_header['status'] != 'ok')) {
3498
+            $v_result = $this->privConvertHeader2FileInfo($v_header,
3499
+                                                $p_file_list[$v_nb_extracted++]);
3500
+            if ($v_result != 1) {
3501
+                $this->privCloseFd();
3502
+                $this->privSwapBackMagicQuotes();
3503
+                return $v_result;
3504
+            }
3505 3505
 
3506
-          $v_extract = false;
3507
-      }
3506
+            $v_extract = false;
3507
+        }
3508 3508
 
3509
-      // ----- Look for real extraction
3510
-      if ($v_extract)
3511
-      {
3509
+        // ----- Look for real extraction
3510
+        if ($v_extract)
3511
+        {
3512 3512
 
3513 3513
         // ----- Go to the file position
3514 3514
         @rewind($this->zip_fd);
3515 3515
         if (@fseek($this->zip_fd, $v_header['offset']))
3516 3516
         {
3517
-          // ----- Close the zip file
3518
-          $this->privCloseFd();
3517
+            // ----- Close the zip file
3518
+            $this->privCloseFd();
3519 3519
 
3520
-          $this->privSwapBackMagicQuotes();
3520
+            $this->privSwapBackMagicQuotes();
3521 3521
 
3522
-          // ----- Error log
3523
-          PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3522
+            // ----- Error log
3523
+            PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3524 3524
 
3525
-          // ----- Return
3526
-          return PclZip::errorCode();
3525
+            // ----- Return
3526
+            return PclZip::errorCode();
3527 3527
         }
3528 3528
 
3529 3529
         // ----- Look for extraction as string
3530 3530
         if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
3531 3531
 
3532
-          $v_string = '';
3532
+            $v_string = '';
3533 3533
 
3534
-          // ----- Extracting the file
3535
-          $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
3536
-          if ($v_result1 < 1) {
3534
+            // ----- Extracting the file
3535
+            $v_result1 = $this->privExtractFileAsString($v_header, $v_string, $p_options);
3536
+            if ($v_result1 < 1) {
3537 3537
             $this->privCloseFd();
3538 3538
             $this->privSwapBackMagicQuotes();
3539 3539
             return $v_result1;
3540
-          }
3540
+            }
3541 3541
 
3542
-          // ----- Get the only interesting attributes
3543
-          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
3544
-          {
3542
+            // ----- Get the only interesting attributes
3543
+            if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
3544
+            {
3545 3545
             // ----- Close the zip file
3546 3546
             $this->privCloseFd();
3547 3547
             $this->privSwapBackMagicQuotes();
3548 3548
 
3549 3549
             return $v_result;
3550
-          }
3550
+            }
3551 3551
 
3552
-          // ----- Set the file content
3553
-          $p_file_list[$v_nb_extracted]['content'] = $v_string;
3552
+            // ----- Set the file content
3553
+            $p_file_list[$v_nb_extracted]['content'] = $v_string;
3554 3554
 
3555
-          // ----- Next extracted file
3556
-          $v_nb_extracted++;
3555
+            // ----- Next extracted file
3556
+            $v_nb_extracted++;
3557 3557
 
3558
-          // ----- Look for user callback abort
3559
-          if ($v_result1 == 2) {
3560
-          	break;
3561
-          }
3558
+            // ----- Look for user callback abort
3559
+            if ($v_result1 == 2) {
3560
+                break;
3561
+            }
3562 3562
         }
3563 3563
         // ----- Look for extraction in standard output
3564 3564
         elseif (   (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
3565
-		        && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
3566
-          // ----- Extracting the file in standard output
3567
-          $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
3568
-          if ($v_result1 < 1) {
3565
+                && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
3566
+            // ----- Extracting the file in standard output
3567
+            $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
3568
+            if ($v_result1 < 1) {
3569 3569
             $this->privCloseFd();
3570 3570
             $this->privSwapBackMagicQuotes();
3571 3571
             return $v_result1;
3572
-          }
3572
+            }
3573 3573
 
3574
-          // ----- Get the only interesting attributes
3575
-          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
3574
+            // ----- Get the only interesting attributes
3575
+            if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
3576 3576
             $this->privCloseFd();
3577 3577
             $this->privSwapBackMagicQuotes();
3578 3578
             return $v_result;
3579
-          }
3579
+            }
3580 3580
 
3581
-          // ----- Look for user callback abort
3582
-          if ($v_result1 == 2) {
3583
-          	break;
3584
-          }
3581
+            // ----- Look for user callback abort
3582
+            if ($v_result1 == 2) {
3583
+                break;
3584
+            }
3585 3585
         }
3586 3586
         // ----- Look for normal extraction
3587 3587
         else {
3588
-          // ----- Extracting the file
3589
-          $v_result1 = $this->privExtractFile($v_header,
3590
-		                                      $p_path, $p_remove_path,
3591
-											  $p_remove_all_path,
3592
-											  $p_options);
3593
-          if ($v_result1 < 1) {
3588
+            // ----- Extracting the file
3589
+            $v_result1 = $this->privExtractFile($v_header,
3590
+                                                $p_path, $p_remove_path,
3591
+                                                $p_remove_all_path,
3592
+                                                $p_options);
3593
+            if ($v_result1 < 1) {
3594 3594
             $this->privCloseFd();
3595 3595
             $this->privSwapBackMagicQuotes();
3596 3596
             return $v_result1;
3597
-          }
3597
+            }
3598 3598
 
3599
-          // ----- Get the only interesting attributes
3600
-          if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
3601
-          {
3599
+            // ----- Get the only interesting attributes
3600
+            if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
3601
+            {
3602 3602
             // ----- Close the zip file
3603 3603
             $this->privCloseFd();
3604 3604
             $this->privSwapBackMagicQuotes();
3605 3605
 
3606 3606
             return $v_result;
3607
-          }
3607
+            }
3608 3608
 
3609
-          // ----- Look for user callback abort
3610
-          if ($v_result1 == 2) {
3611
-          	break;
3612
-          }
3609
+            // ----- Look for user callback abort
3610
+            if ($v_result1 == 2) {
3611
+                break;
3612
+            }
3613
+        }
3613 3614
         }
3614
-      }
3615 3615
     }
3616 3616
 
3617 3617
     // ----- Close the zip file
@@ -3620,28 +3620,28 @@  discard block
 block discarded – undo
3620 3620
 
3621 3621
     // ----- Return
3622 3622
     return $v_result;
3623
-  }
3624
-  // --------------------------------------------------------------------------------
3625
-
3626
-  // --------------------------------------------------------------------------------
3627
-  // Function : privExtractFile()
3628
-  // Description :
3629
-  // Parameters :
3630
-  // Return Values :
3631
-  //
3632
-  // 1 : ... ?
3633
-  // PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback
3634
-  // --------------------------------------------------------------------------------
3635
-  function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3636
-  {
3623
+    }
3624
+    // --------------------------------------------------------------------------------
3625
+
3626
+    // --------------------------------------------------------------------------------
3627
+    // Function : privExtractFile()
3628
+    // Description :
3629
+    // Parameters :
3630
+    // Return Values :
3631
+    //
3632
+    // 1 : ... ?
3633
+    // PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback
3634
+    // --------------------------------------------------------------------------------
3635
+    function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3636
+    {
3637 3637
     $v_result=1;
3638 3638
 
3639 3639
     // ----- Read the file header
3640 3640
     if (($v_result = $this->privReadFileHeader($v_header)) != 1)
3641 3641
     {
3642
-      // ----- Return
3643
-      return $v_result;
3644
-    }
3642
+        // ----- Return
3643
+        return $v_result;
3644
+    }
3645 3645
 
3646 3646
 
3647 3647
     // ----- Check that the file header is coherent with $p_entry info
@@ -3666,74 +3666,74 @@  discard block
 block discarded – undo
3666 3666
     // ----- Look for path to remove
3667 3667
     else if ($p_remove_path != "")
3668 3668
     {
3669
-      if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
3670
-      {
3669
+        if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
3670
+        {
3671 3671
 
3672 3672
         // ----- Change the file status
3673 3673
         $p_entry['status'] = "filtered";
3674 3674
 
3675 3675
         // ----- Return
3676 3676
         return $v_result;
3677
-      }
3677
+        }
3678 3678
 
3679
-      $p_remove_path_size = strlen($p_remove_path);
3680
-      if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
3681
-      {
3679
+        $p_remove_path_size = strlen($p_remove_path);
3680
+        if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
3681
+        {
3682 3682
 
3683 3683
         // ----- Remove the path
3684 3684
         $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
3685 3685
 
3686
-      }
3686
+        }
3687 3687
     }
3688 3688
 
3689 3689
     // ----- Add the path
3690 3690
     if ($p_path != '') {
3691
-      $p_entry['filename'] = $p_path."/".$p_entry['filename'];
3691
+        $p_entry['filename'] = $p_path."/".$p_entry['filename'];
3692 3692
     }
3693 3693
 
3694 3694
     // ----- Check a base_dir_restriction
3695 3695
     if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
3696
-      $v_inclusion
3697
-      = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
3696
+        $v_inclusion
3697
+        = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
3698 3698
                                 $p_entry['filename']);
3699
-      if ($v_inclusion == 0) {
3699
+        if ($v_inclusion == 0) {
3700 3700
 
3701 3701
         PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
3702
-			                     "Filename '".$p_entry['filename']."' is "
3703
-								 ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
3702
+                                    "Filename '".$p_entry['filename']."' is "
3703
+                                    ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
3704 3704
 
3705 3705
         return PclZip::errorCode();
3706
-      }
3706
+        }
3707 3707
     }
3708 3708
 
3709 3709
     // ----- Look for pre-extract callback
3710 3710
     if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
3711 3711
 
3712
-      // ----- Generate a local information
3713
-      $v_local_header = array();
3714
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3712
+        // ----- Generate a local information
3713
+        $v_local_header = array();
3714
+        $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3715 3715
 
3716
-      // ----- Call the callback
3717
-      // Here I do not use call_user_func() because I need to send a reference to the
3718
-      // header.
3716
+        // ----- Call the callback
3717
+        // Here I do not use call_user_func() because I need to send a reference to the
3718
+        // header.
3719 3719
 //      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
3720
-      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
3721
-      if ($v_result == 0) {
3720
+        $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
3721
+        if ($v_result == 0) {
3722 3722
         // ----- Change the file status
3723 3723
         $p_entry['status'] = "skipped";
3724 3724
         $v_result = 1;
3725
-      }
3725
+        }
3726 3726
 
3727
-      // ----- Look for abort result
3728
-      if ($v_result == 2) {
3727
+        // ----- Look for abort result
3728
+        if ($v_result == 2) {
3729 3729
         // ----- This status is internal and will be changed in 'skipped'
3730 3730
         $p_entry['status'] = "aborted";
3731
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
3732
-      }
3731
+            $v_result = PCLZIP_ERR_USER_ABORTED;
3732
+        }
3733 3733
 
3734
-      // ----- Update the informations
3735
-      // Only some fields can be modified
3736
-      $p_entry['filename'] = $v_local_header['filename'];
3734
+        // ----- Update the informations
3735
+        // Only some fields can be modified
3736
+        $p_entry['filename'] = $v_local_header['filename'];
3737 3737
     }
3738 3738
 
3739 3739
 
@@ -3744,9 +3744,9 @@  discard block
 block discarded – undo
3744 3744
     if (file_exists($p_entry['filename']))
3745 3745
     {
3746 3746
 
3747
-      // ----- Look if file is a directory
3748
-      if (is_dir($p_entry['filename']))
3749
-      {
3747
+        // ----- Look if file is a directory
3748
+        if (is_dir($p_entry['filename']))
3749
+        {
3750 3750
 
3751 3751
         // ----- Change the file status
3752 3752
         $p_entry['status'] = "already_a_directory";
@@ -3755,18 +3755,18 @@  discard block
 block discarded – undo
3755 3755
         // For historical reason first PclZip implementation does not stop
3756 3756
         // when this kind of error occurs.
3757 3757
         if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3758
-		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3758
+            && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3759 3759
 
3760 3760
             PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
3761
-			                     "Filename '".$p_entry['filename']."' is "
3762
-								 ."already used by an existing directory");
3761
+                                    "Filename '".$p_entry['filename']."' is "
3762
+                                    ."already used by an existing directory");
3763 3763
 
3764 3764
             return PclZip::errorCode();
3765
-		    }
3766
-      }
3767
-      // ----- Look if file is write protected
3768
-      else if (!is_writeable($p_entry['filename']))
3769
-      {
3765
+            }
3766
+        }
3767
+        // ----- Look if file is write protected
3768
+        else if (!is_writeable($p_entry['filename']))
3769
+        {
3770 3770
 
3771 3771
         // ----- Change the file status
3772 3772
         $p_entry['status'] = "write_protected";
@@ -3775,90 +3775,90 @@  discard block
 block discarded – undo
3775 3775
         // For historical reason first PclZip implementation does not stop
3776 3776
         // when this kind of error occurs.
3777 3777
         if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3778
-		    && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3778
+            && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3779 3779
 
3780 3780
             PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3781
-			                     "Filename '".$p_entry['filename']."' exists "
3782
-								 ."and is write protected");
3781
+                                    "Filename '".$p_entry['filename']."' exists "
3782
+                                    ."and is write protected");
3783 3783
 
3784 3784
             return PclZip::errorCode();
3785
-		    }
3786
-      }
3785
+            }
3786
+        }
3787 3787
 
3788
-      // ----- Look if the extracted file is older
3789
-      else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
3790
-      {
3788
+        // ----- Look if the extracted file is older
3789
+        else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
3790
+        {
3791 3791
         // ----- Change the file status
3792 3792
         if (   (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3793
-		    && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
3794
-	  	  }
3795
-		    else {
3793
+            && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
3794
+            }
3795
+            else {
3796 3796
             $p_entry['status'] = "newer_exist";
3797 3797
 
3798 3798
             // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3799 3799
             // For historical reason first PclZip implementation does not stop
3800 3800
             // when this kind of error occurs.
3801 3801
             if (   (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3802
-		        && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3802
+                && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3803 3803
 
3804 3804
                 PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3805
-			             "Newer version of '".$p_entry['filename']."' exists "
3806
-					    ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
3805
+                            "Newer version of '".$p_entry['filename']."' exists "
3806
+                        ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
3807 3807
 
3808 3808
                 return PclZip::errorCode();
3809
-		      }
3810
-		    }
3811
-      }
3812
-      else {
3813
-      }
3809
+                }
3810
+            }
3811
+        }
3812
+        else {
3813
+        }
3814 3814
     }
3815 3815
 
3816 3816
     // ----- Check the directory availability and create it if necessary
3817 3817
     else {
3818
-      if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3818
+        if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3819 3819
         $v_dir_to_check = $p_entry['filename'];
3820
-      else if (!strstr($p_entry['filename'], "/"))
3820
+        else if (!strstr($p_entry['filename'], "/"))
3821 3821
         $v_dir_to_check = "";
3822
-      else
3822
+        else
3823 3823
         $v_dir_to_check = dirname($p_entry['filename']);
3824 3824
 
3825 3825
         if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
3826 3826
 
3827
-          // ----- Change the file status
3828
-          $p_entry['status'] = "path_creation_fail";
3827
+            // ----- Change the file status
3828
+            $p_entry['status'] = "path_creation_fail";
3829 3829
 
3830
-          // ----- Return
3831
-          //return $v_result;
3832
-          $v_result = 1;
3830
+            // ----- Return
3831
+            //return $v_result;
3832
+            $v_result = 1;
3833
+        }
3833 3834
         }
3834
-      }
3835 3835
     }
3836 3836
 
3837 3837
     // ----- Look if extraction should be done
3838 3838
     if ($p_entry['status'] == 'ok') {
3839 3839
 
3840
-      // ----- Do the extraction (if not a folder)
3841
-      if (!(($p_entry['external']&0x00000010)==0x00000010))
3842
-      {
3840
+        // ----- Do the extraction (if not a folder)
3841
+        if (!(($p_entry['external']&0x00000010)==0x00000010))
3842
+        {
3843 3843
         // ----- Look for not compressed file
3844 3844
         if ($p_entry['compression'] == 0) {
3845 3845
 
3846
-    		  // ----- Opening destination file
3847
-          if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
3848
-          {
3846
+                // ----- Opening destination file
3847
+            if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
3848
+            {
3849 3849
 
3850 3850
             // ----- Change the file status
3851 3851
             $p_entry['status'] = "write_error";
3852 3852
 
3853 3853
             // ----- Return
3854 3854
             return $v_result;
3855
-          }
3855
+            }
3856 3856
 
3857 3857
 
3858
-          // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3859
-          $v_size = $p_entry['compressed_size'];
3860
-          while ($v_size != 0)
3861
-          {
3858
+            // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3859
+            $v_size = $p_entry['compressed_size'];
3860
+            while ($v_size != 0)
3861
+            {
3862 3862
             $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3863 3863
             $v_buffer = @fread($this->zip_fd, $v_read_size);
3864 3864
             /* Try to speed up the code
@@ -3867,38 +3867,38 @@  discard block
 block discarded – undo
3867 3867
             */
3868 3868
             @fwrite($v_dest_file, $v_buffer, $v_read_size);
3869 3869
             $v_size -= $v_read_size;
3870
-          }
3870
+            }
3871 3871
 
3872
-          // ----- Closing the destination file
3873
-          fclose($v_dest_file);
3872
+            // ----- Closing the destination file
3873
+            fclose($v_dest_file);
3874 3874
 
3875
-          // ----- Change the file mtime
3876
-          touch($p_entry['filename'], $p_entry['mtime']);
3875
+            // ----- Change the file mtime
3876
+            touch($p_entry['filename'], $p_entry['mtime']);
3877 3877
 
3878 3878
 
3879 3879
         }
3880 3880
         else {
3881
-          // ----- TBC
3882
-          // Need to be finished
3883
-          if (($p_entry['flag'] & 1) == 1) {
3881
+            // ----- TBC
3882
+            // Need to be finished
3883
+            if (($p_entry['flag'] & 1) == 1) {
3884 3884
             PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION, 'File \''.$p_entry['filename'].'\' is encrypted. Encrypted files are not supported.');
3885 3885
             return PclZip::errorCode();
3886
-          }
3886
+            }
3887 3887
 
3888 3888
 
3889
-          // ----- Look for using temporary file to unzip
3890
-          if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
3889
+            // ----- Look for using temporary file to unzip
3890
+            if ( (!isset($p_options[PCLZIP_OPT_TEMP_FILE_OFF]))
3891 3891
               && (isset($p_options[PCLZIP_OPT_TEMP_FILE_ON])
3892 3892
                   || (isset($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD])
3893 3893
                       && ($p_options[PCLZIP_OPT_TEMP_FILE_THRESHOLD] <= $p_entry['size'])) ) ) {
3894 3894
             $v_result = $this->privExtractFileUsingTempFile($p_entry, $p_options);
3895 3895
             if ($v_result < PCLZIP_ERR_NO_ERROR) {
3896
-              return $v_result;
3896
+                return $v_result;
3897
+            }
3897 3898
             }
3898
-          }
3899 3899
 
3900
-          // ----- Look for extract in memory
3901
-          else {
3900
+            // ----- Look for extract in memory
3901
+            else {
3902 3902
 
3903 3903
 
3904 3904
             // ----- Read the compressed file in a buffer (one shot)
@@ -3909,20 +3909,20 @@  discard block
 block discarded – undo
3909 3909
             unset($v_buffer);
3910 3910
             if ($v_file_content === FALSE) {
3911 3911
 
3912
-              // ----- Change the file status
3913
-              // TBC
3914
-              $p_entry['status'] = "error";
3912
+                // ----- Change the file status
3913
+                // TBC
3914
+                $p_entry['status'] = "error";
3915 3915
 
3916
-              return $v_result;
3916
+                return $v_result;
3917 3917
             }
3918 3918
 
3919 3919
             // ----- Opening destination file
3920 3920
             if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
3921 3921
 
3922
-              // ----- Change the file status
3923
-              $p_entry['status'] = "write_error";
3922
+                // ----- Change the file status
3923
+                $p_entry['status'] = "write_error";
3924 3924
 
3925
-              return $v_result;
3925
+                return $v_result;
3926 3926
             }
3927 3927
 
3928 3928
             // ----- Write the uncompressed data
@@ -3932,67 +3932,67 @@  discard block
 block discarded – undo
3932 3932
             // ----- Closing the destination file
3933 3933
             @fclose($v_dest_file);
3934 3934
 
3935
-          }
3935
+            }
3936 3936
 
3937
-          // ----- Change the file mtime
3938
-          @touch($p_entry['filename'], $p_entry['mtime']);
3937
+            // ----- Change the file mtime
3938
+            @touch($p_entry['filename'], $p_entry['mtime']);
3939 3939
         }
3940 3940
 
3941 3941
         // ----- Look for chmod option
3942 3942
         if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
3943 3943
 
3944
-          // ----- Change the mode of the file
3945
-          @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
3944
+            // ----- Change the mode of the file
3945
+            @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
3946 3946
         }
3947 3947
 
3948
-      }
3948
+        }
3949 3949
     }
3950 3950
 
3951
-  	// ----- Change abort status
3952
-  	if ($p_entry['status'] == "aborted") {
3951
+        // ----- Change abort status
3952
+        if ($p_entry['status'] == "aborted") {
3953 3953
         $p_entry['status'] = "skipped";
3954
-  	}
3954
+        }
3955 3955
 
3956 3956
     // ----- Look for post-extract callback
3957 3957
     elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
3958 3958
 
3959
-      // ----- Generate a local information
3960
-      $v_local_header = array();
3961
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3959
+        // ----- Generate a local information
3960
+        $v_local_header = array();
3961
+        $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3962 3962
 
3963
-      // ----- Call the callback
3964
-      // Here I do not use call_user_func() because I need to send a reference to the
3965
-      // header.
3963
+        // ----- Call the callback
3964
+        // Here I do not use call_user_func() because I need to send a reference to the
3965
+        // header.
3966 3966
 //      eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
3967
-      $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
3967
+        $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
3968 3968
 
3969
-      // ----- Look for abort result
3970
-      if ($v_result == 2) {
3971
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
3972
-      }
3969
+        // ----- Look for abort result
3970
+        if ($v_result == 2) {
3971
+            $v_result = PCLZIP_ERR_USER_ABORTED;
3972
+        }
3973 3973
     }
3974 3974
 
3975 3975
     // ----- Return
3976 3976
     return $v_result;
3977
-  }
3978
-  // --------------------------------------------------------------------------------
3979
-
3980
-  // --------------------------------------------------------------------------------
3981
-  // Function : privExtractFileUsingTempFile()
3982
-  // Description :
3983
-  // Parameters :
3984
-  // Return Values :
3985
-  // --------------------------------------------------------------------------------
3986
-  function privExtractFileUsingTempFile(&$p_entry, &$p_options)
3987
-  {
3977
+    }
3978
+    // --------------------------------------------------------------------------------
3979
+
3980
+    // --------------------------------------------------------------------------------
3981
+    // Function : privExtractFileUsingTempFile()
3982
+    // Description :
3983
+    // Parameters :
3984
+    // Return Values :
3985
+    // --------------------------------------------------------------------------------
3986
+    function privExtractFileUsingTempFile(&$p_entry, &$p_options)
3987
+    {
3988 3988
     $v_result=1;
3989 3989
 
3990 3990
     // ----- Creates a temporary file
3991 3991
     $v_gzip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.gz';
3992 3992
     if (($v_dest_file = @fopen($v_gzip_temp_name, "wb")) == 0) {
3993
-      fclose($v_file);
3994
-      PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
3995
-      return PclZip::errorCode();
3993
+        fclose($v_file);
3994
+        PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary write mode');
3995
+        return PclZip::errorCode();
3996 3996
     }
3997 3997
 
3998 3998
 
@@ -4004,11 +4004,11 @@  discard block
 block discarded – undo
4004 4004
     $v_size = $p_entry['compressed_size'];
4005 4005
     while ($v_size != 0)
4006 4006
     {
4007
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
4008
-      $v_buffer = @fread($this->zip_fd, $v_read_size);
4009
-      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
4010
-      @fwrite($v_dest_file, $v_buffer, $v_read_size);
4011
-      $v_size -= $v_read_size;
4007
+        $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
4008
+        $v_buffer = @fread($this->zip_fd, $v_read_size);
4009
+        //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
4010
+        @fwrite($v_dest_file, $v_buffer, $v_read_size);
4011
+        $v_size -= $v_read_size;
4012 4012
     }
4013 4013
 
4014 4014
     // ----- Write gz file format footer
@@ -4020,27 +4020,27 @@  discard block
 block discarded – undo
4020 4020
 
4021 4021
     // ----- Opening destination file
4022 4022
     if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
4023
-      $p_entry['status'] = "write_error";
4024
-      return $v_result;
4023
+        $p_entry['status'] = "write_error";
4024
+        return $v_result;
4025 4025
     }
4026 4026
 
4027 4027
     // ----- Open the temporary gz file
4028 4028
     if (($v_src_file = @gzopen($v_gzip_temp_name, 'rb')) == 0) {
4029
-      @fclose($v_dest_file);
4030
-      $p_entry['status'] = "read_error";
4031
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
4032
-      return PclZip::errorCode();
4029
+        @fclose($v_dest_file);
4030
+        $p_entry['status'] = "read_error";
4031
+        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_gzip_temp_name.'\' in binary read mode');
4032
+        return PclZip::errorCode();
4033 4033
     }
4034 4034
 
4035 4035
 
4036 4036
     // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
4037 4037
     $v_size = $p_entry['size'];
4038 4038
     while ($v_size != 0) {
4039
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
4040
-      $v_buffer = @gzread($v_src_file, $v_read_size);
4041
-      //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
4042
-      @fwrite($v_dest_file, $v_buffer, $v_read_size);
4043
-      $v_size -= $v_read_size;
4039
+        $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
4040
+        $v_buffer = @gzread($v_src_file, $v_read_size);
4041
+        //$v_binary_data = pack('a'.$v_read_size, $v_buffer);
4042
+        @fwrite($v_dest_file, $v_buffer, $v_read_size);
4043
+        $v_size -= $v_read_size;
4044 4044
     }
4045 4045
     @fclose($v_dest_file);
4046 4046
     @gzclose($v_src_file);
@@ -4050,22 +4050,22 @@  discard block
 block discarded – undo
4050 4050
 
4051 4051
     // ----- Return
4052 4052
     return $v_result;
4053
-  }
4054
-  // --------------------------------------------------------------------------------
4055
-
4056
-  // --------------------------------------------------------------------------------
4057
-  // Function : privExtractFileInOutput()
4058
-  // Description :
4059
-  // Parameters :
4060
-  // Return Values :
4061
-  // --------------------------------------------------------------------------------
4062
-  function privExtractFileInOutput(&$p_entry, &$p_options)
4063
-  {
4053
+    }
4054
+    // --------------------------------------------------------------------------------
4055
+
4056
+    // --------------------------------------------------------------------------------
4057
+    // Function : privExtractFileInOutput()
4058
+    // Description :
4059
+    // Parameters :
4060
+    // Return Values :
4061
+    // --------------------------------------------------------------------------------
4062
+    function privExtractFileInOutput(&$p_entry, &$p_options)
4063
+    {
4064 4064
     $v_result=1;
4065 4065
 
4066 4066
     // ----- Read the file header
4067 4067
     if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
4068
-      return $v_result;
4068
+        return $v_result;
4069 4069
     }
4070 4070
 
4071 4071
 
@@ -4077,31 +4077,31 @@  discard block
 block discarded – undo
4077 4077
     // ----- Look for pre-extract callback
4078 4078
     if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4079 4079
 
4080
-      // ----- Generate a local information
4081
-      $v_local_header = array();
4082
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4080
+        // ----- Generate a local information
4081
+        $v_local_header = array();
4082
+        $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4083 4083
 
4084
-      // ----- Call the callback
4085
-      // Here I do not use call_user_func() because I need to send a reference to the
4086
-      // header.
4084
+        // ----- Call the callback
4085
+        // Here I do not use call_user_func() because I need to send a reference to the
4086
+        // header.
4087 4087
 //      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
4088
-      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4089
-      if ($v_result == 0) {
4088
+        $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4089
+        if ($v_result == 0) {
4090 4090
         // ----- Change the file status
4091 4091
         $p_entry['status'] = "skipped";
4092 4092
         $v_result = 1;
4093
-      }
4093
+        }
4094 4094
 
4095
-      // ----- Look for abort result
4096
-      if ($v_result == 2) {
4095
+        // ----- Look for abort result
4096
+        if ($v_result == 2) {
4097 4097
         // ----- This status is internal and will be changed in 'skipped'
4098 4098
         $p_entry['status'] = "aborted";
4099
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
4100
-      }
4099
+            $v_result = PCLZIP_ERR_USER_ABORTED;
4100
+        }
4101 4101
 
4102
-      // ----- Update the informations
4103
-      // Only some fields can be modified
4104
-      $p_entry['filename'] = $v_local_header['filename'];
4102
+        // ----- Update the informations
4103
+        // Only some fields can be modified
4104
+        $p_entry['filename'] = $v_local_header['filename'];
4105 4105
     }
4106 4106
 
4107 4107
     // ----- Trace
@@ -4109,78 +4109,78 @@  discard block
 block discarded – undo
4109 4109
     // ----- Look if extraction should be done
4110 4110
     if ($p_entry['status'] == 'ok') {
4111 4111
 
4112
-      // ----- Do the extraction (if not a folder)
4113
-      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4112
+        // ----- Do the extraction (if not a folder)
4113
+        if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4114 4114
         // ----- Look for not compressed file
4115 4115
         if ($p_entry['compressed_size'] == $p_entry['size']) {
4116 4116
 
4117
-          // ----- Read the file in a buffer (one shot)
4118
-          $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4117
+            // ----- Read the file in a buffer (one shot)
4118
+            $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4119 4119
 
4120
-          // ----- Send the file to the output
4121
-          echo $v_buffer;
4122
-          unset($v_buffer);
4120
+            // ----- Send the file to the output
4121
+            echo $v_buffer;
4122
+            unset($v_buffer);
4123 4123
         }
4124 4124
         else {
4125 4125
 
4126
-          // ----- Read the compressed file in a buffer (one shot)
4127
-          $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4126
+            // ----- Read the compressed file in a buffer (one shot)
4127
+            $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
4128 4128
 
4129
-          // ----- Decompress the file
4130
-          $v_file_content = gzinflate($v_buffer);
4131
-          unset($v_buffer);
4129
+            // ----- Decompress the file
4130
+            $v_file_content = gzinflate($v_buffer);
4131
+            unset($v_buffer);
4132 4132
 
4133
-          // ----- Send the file to the output
4134
-          echo $v_file_content;
4135
-          unset($v_file_content);
4133
+            // ----- Send the file to the output
4134
+            echo $v_file_content;
4135
+            unset($v_file_content);
4136
+        }
4136 4137
         }
4137
-      }
4138 4138
     }
4139 4139
 
4140
-	// ----- Change abort status
4141
-	if ($p_entry['status'] == "aborted") {
4142
-      $p_entry['status'] = "skipped";
4143
-	}
4140
+    // ----- Change abort status
4141
+    if ($p_entry['status'] == "aborted") {
4142
+        $p_entry['status'] = "skipped";
4143
+    }
4144 4144
 
4145 4145
     // ----- Look for post-extract callback
4146 4146
     elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4147 4147
 
4148
-      // ----- Generate a local information
4149
-      $v_local_header = array();
4150
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4148
+        // ----- Generate a local information
4149
+        $v_local_header = array();
4150
+        $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4151 4151
 
4152
-      // ----- Call the callback
4153
-      // Here I do not use call_user_func() because I need to send a reference to the
4154
-      // header.
4152
+        // ----- Call the callback
4153
+        // Here I do not use call_user_func() because I need to send a reference to the
4154
+        // header.
4155 4155
 //      eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
4156
-      $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4156
+        $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4157 4157
 
4158
-      // ----- Look for abort result
4159
-      if ($v_result == 2) {
4160
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
4161
-      }
4158
+        // ----- Look for abort result
4159
+        if ($v_result == 2) {
4160
+            $v_result = PCLZIP_ERR_USER_ABORTED;
4161
+        }
4162 4162
     }
4163 4163
 
4164 4164
     return $v_result;
4165
-  }
4166
-  // --------------------------------------------------------------------------------
4167
-
4168
-  // --------------------------------------------------------------------------------
4169
-  // Function : privExtractFileAsString()
4170
-  // Description :
4171
-  // Parameters :
4172
-  // Return Values :
4173
-  // --------------------------------------------------------------------------------
4174
-  function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
4175
-  {
4165
+    }
4166
+    // --------------------------------------------------------------------------------
4167
+
4168
+    // --------------------------------------------------------------------------------
4169
+    // Function : privExtractFileAsString()
4170
+    // Description :
4171
+    // Parameters :
4172
+    // Return Values :
4173
+    // --------------------------------------------------------------------------------
4174
+    function privExtractFileAsString(&$p_entry, &$p_string, &$p_options)
4175
+    {
4176 4176
     $v_result=1;
4177 4177
 
4178 4178
     // ----- Read the file header
4179 4179
     $v_header = array();
4180 4180
     if (($v_result = $this->privReadFileHeader($v_header)) != 1)
4181 4181
     {
4182
-      // ----- Return
4183
-      return $v_result;
4182
+        // ----- Return
4183
+        return $v_result;
4184 4184
     }
4185 4185
 
4186 4186
 
@@ -4192,110 +4192,110 @@  discard block
 block discarded – undo
4192 4192
     // ----- Look for pre-extract callback
4193 4193
     if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
4194 4194
 
4195
-      // ----- Generate a local information
4196
-      $v_local_header = array();
4197
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4195
+        // ----- Generate a local information
4196
+        $v_local_header = array();
4197
+        $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4198 4198
 
4199
-      // ----- Call the callback
4200
-      // Here I do not use call_user_func() because I need to send a reference to the
4201
-      // header.
4199
+        // ----- Call the callback
4200
+        // Here I do not use call_user_func() because I need to send a reference to the
4201
+        // header.
4202 4202
 //      eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
4203
-      $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4204
-      if ($v_result == 0) {
4203
+        $v_result = $p_options[PCLZIP_CB_PRE_EXTRACT](PCLZIP_CB_PRE_EXTRACT, $v_local_header);
4204
+        if ($v_result == 0) {
4205 4205
         // ----- Change the file status
4206 4206
         $p_entry['status'] = "skipped";
4207 4207
         $v_result = 1;
4208
-      }
4208
+        }
4209 4209
 
4210
-      // ----- Look for abort result
4211
-      if ($v_result == 2) {
4210
+        // ----- Look for abort result
4211
+        if ($v_result == 2) {
4212 4212
         // ----- This status is internal and will be changed in 'skipped'
4213 4213
         $p_entry['status'] = "aborted";
4214
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
4215
-      }
4214
+            $v_result = PCLZIP_ERR_USER_ABORTED;
4215
+        }
4216 4216
 
4217
-      // ----- Update the informations
4218
-      // Only some fields can be modified
4219
-      $p_entry['filename'] = $v_local_header['filename'];
4217
+        // ----- Update the informations
4218
+        // Only some fields can be modified
4219
+        $p_entry['filename'] = $v_local_header['filename'];
4220 4220
     }
4221 4221
 
4222 4222
 
4223 4223
     // ----- Look if extraction should be done
4224 4224
     if ($p_entry['status'] == 'ok') {
4225 4225
 
4226
-      // ----- Do the extraction (if not a folder)
4227
-      if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4226
+        // ----- Do the extraction (if not a folder)
4227
+        if (!(($p_entry['external']&0x00000010)==0x00000010)) {
4228 4228
         // ----- Look for not compressed file
4229
-  //      if ($p_entry['compressed_size'] == $p_entry['size'])
4229
+    //      if ($p_entry['compressed_size'] == $p_entry['size'])
4230 4230
         if ($p_entry['compression'] == 0) {
4231 4231
 
4232
-          // ----- Reading the file
4233
-          $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
4232
+            // ----- Reading the file
4233
+            $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
4234 4234
         }
4235 4235
         else {
4236 4236
 
4237
-          // ----- Reading the file
4238
-          $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
4237
+            // ----- Reading the file
4238
+            $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
4239 4239
 
4240
-          // ----- Decompress the file
4241
-          if (($p_string = @gzinflate($v_data)) === FALSE) {
4242
-              // TBC
4243
-          }
4240
+            // ----- Decompress the file
4241
+            if (($p_string = @gzinflate($v_data)) === FALSE) {
4242
+                // TBC
4243
+            }
4244 4244
         }
4245 4245
 
4246 4246
         // ----- Trace
4247
-      }
4248
-      else {
4249
-          // TBC : error : can not extract a folder in a string
4250
-      }
4247
+        }
4248
+        else {
4249
+            // TBC : error : can not extract a folder in a string
4250
+        }
4251 4251
 
4252 4252
     }
4253 4253
 
4254
-  	// ----- Change abort status
4255
-  	if ($p_entry['status'] == "aborted") {
4254
+        // ----- Change abort status
4255
+        if ($p_entry['status'] == "aborted") {
4256 4256
         $p_entry['status'] = "skipped";
4257
-  	}
4257
+        }
4258 4258
 
4259 4259
     // ----- Look for post-extract callback
4260 4260
     elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
4261 4261
 
4262
-      // ----- Generate a local information
4263
-      $v_local_header = array();
4264
-      $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4262
+        // ----- Generate a local information
4263
+        $v_local_header = array();
4264
+        $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
4265 4265
 
4266
-      // ----- Swap the content to header
4267
-      $v_local_header['content'] = $p_string;
4268
-      $p_string = '';
4266
+        // ----- Swap the content to header
4267
+        $v_local_header['content'] = $p_string;
4268
+        $p_string = '';
4269 4269
 
4270
-      // ----- Call the callback
4271
-      // Here I do not use call_user_func() because I need to send a reference to the
4272
-      // header.
4270
+        // ----- Call the callback
4271
+        // Here I do not use call_user_func() because I need to send a reference to the
4272
+        // header.
4273 4273
 //      eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
4274
-      $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4274
+        $v_result = $p_options[PCLZIP_CB_POST_EXTRACT](PCLZIP_CB_POST_EXTRACT, $v_local_header);
4275 4275
 
4276
-      // ----- Swap back the content to header
4277
-      $p_string = $v_local_header['content'];
4278
-      unset($v_local_header['content']);
4276
+        // ----- Swap back the content to header
4277
+        $p_string = $v_local_header['content'];
4278
+        unset($v_local_header['content']);
4279 4279
 
4280
-      // ----- Look for abort result
4281
-      if ($v_result == 2) {
4282
-      	$v_result = PCLZIP_ERR_USER_ABORTED;
4283
-      }
4280
+        // ----- Look for abort result
4281
+        if ($v_result == 2) {
4282
+            $v_result = PCLZIP_ERR_USER_ABORTED;
4283
+        }
4284 4284
     }
4285 4285
 
4286 4286
     // ----- Return
4287 4287
     return $v_result;
4288
-  }
4289
-  // --------------------------------------------------------------------------------
4290
-
4291
-  // --------------------------------------------------------------------------------
4292
-  // Function : privReadFileHeader()
4293
-  // Description :
4294
-  // Parameters :
4295
-  // Return Values :
4296
-  // --------------------------------------------------------------------------------
4297
-  function privReadFileHeader(&$p_header)
4298
-  {
4288
+    }
4289
+    // --------------------------------------------------------------------------------
4290
+
4291
+    // --------------------------------------------------------------------------------
4292
+    // Function : privReadFileHeader()
4293
+    // Description :
4294
+    // Parameters :
4295
+    // Return Values :
4296
+    // --------------------------------------------------------------------------------
4297
+    function privReadFileHeader(&$p_header)
4298
+    {
4299 4299
     $v_result=1;
4300 4300
 
4301 4301
     // ----- Read the 4 bytes signature
@@ -4306,11 +4306,11 @@  discard block
 block discarded – undo
4306 4306
     if ($v_data['id'] != 0x04034b50)
4307 4307
     {
4308 4308
 
4309
-      // ----- Error log
4310
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4309
+        // ----- Error log
4310
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4311 4311
 
4312
-      // ----- Return
4313
-      return PclZip::errorCode();
4312
+        // ----- Return
4313
+        return PclZip::errorCode();
4314 4314
     }
4315 4315
 
4316 4316
     // ----- Read the first 42 bytes of the header
@@ -4319,14 +4319,14 @@  discard block
 block discarded – undo
4319 4319
     // ----- Look for invalid block size
4320 4320
     if (strlen($v_binary_data) != 26)
4321 4321
     {
4322
-      $p_header['filename'] = "";
4323
-      $p_header['status'] = "invalid_header";
4322
+        $p_header['filename'] = "";
4323
+        $p_header['status'] = "invalid_header";
4324 4324
 
4325
-      // ----- Error log
4326
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4325
+        // ----- Error log
4326
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4327 4327
 
4328
-      // ----- Return
4329
-      return PclZip::errorCode();
4328
+        // ----- Return
4329
+        return PclZip::errorCode();
4330 4330
     }
4331 4331
 
4332 4332
     // ----- Extract the values
@@ -4337,10 +4337,10 @@  discard block
 block discarded – undo
4337 4337
 
4338 4338
     // ----- Get extra_fields
4339 4339
     if ($v_data['extra_len'] != 0) {
4340
-      $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
4340
+        $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
4341 4341
     }
4342 4342
     else {
4343
-      $p_header['extra'] = '';
4343
+        $p_header['extra'] = '';
4344 4344
     }
4345 4345
 
4346 4346
     // ----- Extract properties
@@ -4357,23 +4357,23 @@  discard block
 block discarded – undo
4357 4357
     $p_header['mtime'] = $v_data['mtime'];
4358 4358
     if ($p_header['mdate'] && $p_header['mtime'])
4359 4359
     {
4360
-      // ----- Extract time
4361
-      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4362
-      $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4363
-      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4360
+        // ----- Extract time
4361
+        $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4362
+        $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4363
+        $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4364 4364
 
4365
-      // ----- Extract date
4366
-      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4367
-      $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4368
-      $v_day = $p_header['mdate'] & 0x001F;
4365
+        // ----- Extract date
4366
+        $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4367
+        $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4368
+        $v_day = $p_header['mdate'] & 0x001F;
4369 4369
 
4370
-      // ----- Get UNIX date format
4371
-      $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4370
+        // ----- Get UNIX date format
4371
+        $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4372 4372
 
4373 4373
     }
4374 4374
     else
4375 4375
     {
4376
-      $p_header['mtime'] = time();
4376
+        $p_header['mtime'] = time();
4377 4377
     }
4378 4378
 
4379 4379
     // TBC
@@ -4388,17 +4388,17 @@  discard block
 block discarded – undo
4388 4388
 
4389 4389
     // ----- Return
4390 4390
     return $v_result;
4391
-  }
4392
-  // --------------------------------------------------------------------------------
4393
-
4394
-  // --------------------------------------------------------------------------------
4395
-  // Function : privReadCentralFileHeader()
4396
-  // Description :
4397
-  // Parameters :
4398
-  // Return Values :
4399
-  // --------------------------------------------------------------------------------
4400
-  function privReadCentralFileHeader(&$p_header)
4401
-  {
4391
+    }
4392
+    // --------------------------------------------------------------------------------
4393
+
4394
+    // --------------------------------------------------------------------------------
4395
+    // Function : privReadCentralFileHeader()
4396
+    // Description :
4397
+    // Parameters :
4398
+    // Return Values :
4399
+    // --------------------------------------------------------------------------------
4400
+    function privReadCentralFileHeader(&$p_header)
4401
+    {
4402 4402
     $v_result=1;
4403 4403
 
4404 4404
     // ----- Read the 4 bytes signature
@@ -4409,11 +4409,11 @@  discard block
 block discarded – undo
4409 4409
     if ($v_data['id'] != 0x02014b50)
4410 4410
     {
4411 4411
 
4412
-      // ----- Error log
4413
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4412
+        // ----- Error log
4413
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4414 4414
 
4415
-      // ----- Return
4416
-      return PclZip::errorCode();
4415
+        // ----- Return
4416
+        return PclZip::errorCode();
4417 4417
     }
4418 4418
 
4419 4419
     // ----- Read the first 42 bytes of the header
@@ -4422,14 +4422,14 @@  discard block
 block discarded – undo
4422 4422
     // ----- Look for invalid block size
4423 4423
     if (strlen($v_binary_data) != 42)
4424 4424
     {
4425
-      $p_header['filename'] = "";
4426
-      $p_header['status'] = "invalid_header";
4425
+        $p_header['filename'] = "";
4426
+        $p_header['status'] = "invalid_header";
4427 4427
 
4428
-      // ----- Error log
4429
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4428
+        // ----- Error log
4429
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4430 4430
 
4431
-      // ----- Return
4432
-      return PclZip::errorCode();
4431
+        // ----- Return
4432
+        return PclZip::errorCode();
4433 4433
     }
4434 4434
 
4435 4435
     // ----- Extract the values
@@ -4437,28 +4437,28 @@  discard block
 block discarded – undo
4437 4437
 
4438 4438
     // ----- Get filename
4439 4439
     if ($p_header['filename_len'] != 0)
4440
-      //
4441
-      // --------------------------------------------------------------------------------
4442
-      // A patch about stored filenames with backslash directory separator (Windows style).
4443
-      // Archives created by the utility IZArc 3.81 (possibly new versions too) need this patch.
4444
-      //$p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
4445
-      $p_header['filename'] = str_replace("\\", '/', fread($this->zip_fd, $p_header['filename_len']));
4446
-      // --------------------------------------------------------------------------------
4447
-      //
4440
+        //
4441
+        // --------------------------------------------------------------------------------
4442
+        // A patch about stored filenames with backslash directory separator (Windows style).
4443
+        // Archives created by the utility IZArc 3.81 (possibly new versions too) need this patch.
4444
+        //$p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
4445
+        $p_header['filename'] = str_replace("\\", '/', fread($this->zip_fd, $p_header['filename_len']));
4446
+        // --------------------------------------------------------------------------------
4447
+        //
4448 4448
     else
4449
-      $p_header['filename'] = '';
4449
+        $p_header['filename'] = '';
4450 4450
 
4451 4451
     // ----- Get extra
4452 4452
     if ($p_header['extra_len'] != 0)
4453
-      $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
4453
+        $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
4454 4454
     else
4455
-      $p_header['extra'] = '';
4455
+        $p_header['extra'] = '';
4456 4456
 
4457 4457
     // ----- Get comment
4458 4458
     if ($p_header['comment_len'] != 0)
4459
-      $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
4459
+        $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
4460 4460
     else
4461
-      $p_header['comment'] = '';
4461
+        $p_header['comment'] = '';
4462 4462
 
4463 4463
     // ----- Extract properties
4464 4464
 
@@ -4467,23 +4467,23 @@  discard block
 block discarded – undo
4467 4467
     // TBC : bug : this was ignoring time with 0/0/0
4468 4468
     if (1)
4469 4469
     {
4470
-      // ----- Extract time
4471
-      $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4472
-      $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4473
-      $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4470
+        // ----- Extract time
4471
+        $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4472
+        $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4473
+        $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4474 4474
 
4475
-      // ----- Extract date
4476
-      $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4477
-      $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4478
-      $v_day = $p_header['mdate'] & 0x001F;
4475
+        // ----- Extract date
4476
+        $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4477
+        $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4478
+        $v_day = $p_header['mdate'] & 0x001F;
4479 4479
 
4480
-      // ----- Get UNIX date format
4481
-      $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4480
+        // ----- Get UNIX date format
4481
+        $p_header['mtime'] = @mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4482 4482
 
4483 4483
     }
4484 4484
     else
4485 4485
     {
4486
-      $p_header['mtime'] = time();
4486
+        $p_header['mtime'] = time();
4487 4487
     }
4488 4488
 
4489 4489
     // ----- Set the stored filename
@@ -4494,63 +4494,63 @@  discard block
 block discarded – undo
4494 4494
 
4495 4495
     // ----- Look if it is a directory
4496 4496
     if (substr($p_header['filename'], -1) == '/') {
4497
-      //$p_header['external'] = 0x41FF0010;
4498
-      $p_header['external'] = 0x00000010;
4497
+        //$p_header['external'] = 0x41FF0010;
4498
+        $p_header['external'] = 0x00000010;
4499 4499
     }
4500 4500
 
4501 4501
 
4502 4502
     // ----- Return
4503 4503
     return $v_result;
4504
-  }
4505
-  // --------------------------------------------------------------------------------
4506
-
4507
-  // --------------------------------------------------------------------------------
4508
-  // Function : privCheckFileHeaders()
4509
-  // Description :
4510
-  // Parameters :
4511
-  // Return Values :
4512
-  //   1 on success,
4513
-  //   0 on error;
4514
-  // --------------------------------------------------------------------------------
4515
-  function privCheckFileHeaders(&$p_local_header, &$p_central_header)
4516
-  {
4504
+    }
4505
+    // --------------------------------------------------------------------------------
4506
+
4507
+    // --------------------------------------------------------------------------------
4508
+    // Function : privCheckFileHeaders()
4509
+    // Description :
4510
+    // Parameters :
4511
+    // Return Values :
4512
+    //   1 on success,
4513
+    //   0 on error;
4514
+    // --------------------------------------------------------------------------------
4515
+    function privCheckFileHeaders(&$p_local_header, &$p_central_header)
4516
+    {
4517 4517
     $v_result=1;
4518 4518
 
4519
-  	// ----- Check the static values
4520
-  	// TBC
4521
-  	if ($p_local_header['filename'] != $p_central_header['filename']) {
4522
-  	}
4523
-  	if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
4524
-  	}
4525
-  	if ($p_local_header['flag'] != $p_central_header['flag']) {
4526
-  	}
4527
-  	if ($p_local_header['compression'] != $p_central_header['compression']) {
4528
-  	}
4529
-  	if ($p_local_header['mtime'] != $p_central_header['mtime']) {
4530
-  	}
4531
-  	if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
4532
-  	}
4533
-
4534
-  	// ----- Look for flag bit 3
4535
-  	if (($p_local_header['flag'] & 8) == 8) {
4536
-          $p_local_header['size'] = $p_central_header['size'];
4537
-          $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
4538
-          $p_local_header['crc'] = $p_central_header['crc'];
4539
-  	}
4519
+        // ----- Check the static values
4520
+        // TBC
4521
+        if ($p_local_header['filename'] != $p_central_header['filename']) {
4522
+        }
4523
+        if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
4524
+        }
4525
+        if ($p_local_header['flag'] != $p_central_header['flag']) {
4526
+        }
4527
+        if ($p_local_header['compression'] != $p_central_header['compression']) {
4528
+        }
4529
+        if ($p_local_header['mtime'] != $p_central_header['mtime']) {
4530
+        }
4531
+        if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
4532
+        }
4533
+
4534
+        // ----- Look for flag bit 3
4535
+        if (($p_local_header['flag'] & 8) == 8) {
4536
+            $p_local_header['size'] = $p_central_header['size'];
4537
+            $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
4538
+            $p_local_header['crc'] = $p_central_header['crc'];
4539
+        }
4540 4540
 
4541 4541
     // ----- Return
4542 4542
     return $v_result;
4543
-  }
4544
-  // --------------------------------------------------------------------------------
4545
-
4546
-  // --------------------------------------------------------------------------------
4547
-  // Function : privReadEndCentralDir()
4548
-  // Description :
4549
-  // Parameters :
4550
-  // Return Values :
4551
-  // --------------------------------------------------------------------------------
4552
-  function privReadEndCentralDir(&$p_central_dir)
4553
-  {
4543
+    }
4544
+    // --------------------------------------------------------------------------------
4545
+
4546
+    // --------------------------------------------------------------------------------
4547
+    // Function : privReadEndCentralDir()
4548
+    // Description :
4549
+    // Parameters :
4550
+    // Return Values :
4551
+    // --------------------------------------------------------------------------------
4552
+    function privReadEndCentralDir(&$p_central_dir)
4553
+    {
4554 4554
     $v_result=1;
4555 4555
 
4556 4556
     // ----- Go to the end of the zip file
@@ -4558,59 +4558,59 @@  discard block
 block discarded – undo
4558 4558
     @fseek($this->zip_fd, $v_size);
4559 4559
     if (@ftell($this->zip_fd) != $v_size)
4560 4560
     {
4561
-      // ----- Error log
4562
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
4561
+        // ----- Error log
4562
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
4563 4563
 
4564
-      // ----- Return
4565
-      return PclZip::errorCode();
4564
+        // ----- Return
4565
+        return PclZip::errorCode();
4566 4566
     }
4567 4567
 
4568 4568
     // ----- First try : look if this is an archive with no commentaries (most of the time)
4569 4569
     // in this case the end of central dir is at 22 bytes of the file end
4570 4570
     $v_found = 0;
4571 4571
     if ($v_size > 26) {
4572
-      @fseek($this->zip_fd, $v_size-22);
4573
-      if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
4574
-      {
4572
+        @fseek($this->zip_fd, $v_size-22);
4573
+        if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
4574
+        {
4575 4575
         // ----- Error log
4576 4576
         PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4577 4577
 
4578 4578
         // ----- Return
4579 4579
         return PclZip::errorCode();
4580
-      }
4580
+        }
4581 4581
 
4582
-      // ----- Read for bytes
4583
-      $v_binary_data = @fread($this->zip_fd, 4);
4584
-      $v_data = @unpack('Vid', $v_binary_data);
4582
+        // ----- Read for bytes
4583
+        $v_binary_data = @fread($this->zip_fd, 4);
4584
+        $v_data = @unpack('Vid', $v_binary_data);
4585 4585
 
4586
-      // ----- Check signature
4587
-      if ($v_data['id'] == 0x06054b50) {
4586
+        // ----- Check signature
4587
+        if ($v_data['id'] == 0x06054b50) {
4588 4588
         $v_found = 1;
4589
-      }
4589
+        }
4590 4590
 
4591
-      $v_pos = ftell($this->zip_fd);
4591
+        $v_pos = ftell($this->zip_fd);
4592 4592
     }
4593 4593
 
4594 4594
     // ----- Go back to the maximum possible size of the Central Dir End Record
4595 4595
     if (!$v_found) {
4596
-      $v_maximum_size = 65557; // 0xFFFF + 22;
4597
-      if ($v_maximum_size > $v_size)
4596
+        $v_maximum_size = 65557; // 0xFFFF + 22;
4597
+        if ($v_maximum_size > $v_size)
4598 4598
         $v_maximum_size = $v_size;
4599
-      @fseek($this->zip_fd, $v_size-$v_maximum_size);
4600
-      if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
4601
-      {
4599
+        @fseek($this->zip_fd, $v_size-$v_maximum_size);
4600
+        if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
4601
+        {
4602 4602
         // ----- Error log
4603 4603
         PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4604 4604
 
4605 4605
         // ----- Return
4606 4606
         return PclZip::errorCode();
4607
-      }
4607
+        }
4608 4608
 
4609
-      // ----- Read byte per byte in order to find the signature
4610
-      $v_pos = ftell($this->zip_fd);
4611
-      $v_bytes = 0x00000000;
4612
-      while ($v_pos < $v_size)
4613
-      {
4609
+        // ----- Read byte per byte in order to find the signature
4610
+        $v_pos = ftell($this->zip_fd);
4611
+        $v_bytes = 0x00000000;
4612
+        while ($v_pos < $v_size)
4613
+        {
4614 4614
         // ----- Read a byte
4615 4615
         $v_byte = @fread($this->zip_fd, 1);
4616 4616
 
@@ -4623,23 +4623,23 @@  discard block
 block discarded – undo
4623 4623
         // ----- Compare the bytes
4624 4624
         if ($v_bytes == 0x504b0506)
4625 4625
         {
4626
-          $v_pos++;
4627
-          break;
4626
+            $v_pos++;
4627
+            break;
4628 4628
         }
4629 4629
 
4630 4630
         $v_pos++;
4631
-      }
4631
+        }
4632 4632
 
4633
-      // ----- Look if not found end of central dir
4634
-      if ($v_pos == $v_size)
4635
-      {
4633
+        // ----- Look if not found end of central dir
4634
+        if ($v_pos == $v_size)
4635
+        {
4636 4636
 
4637 4637
         // ----- Error log
4638 4638
         PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
4639 4639
 
4640 4640
         // ----- Return
4641 4641
         return PclZip::errorCode();
4642
-      }
4642
+        }
4643 4643
     }
4644 4644
 
4645 4645
     // ----- Read the first 18 bytes of the header
@@ -4649,11 +4649,11 @@  discard block
 block discarded – undo
4649 4649
     if (strlen($v_binary_data) != 18)
4650 4650
     {
4651 4651
 
4652
-      // ----- Error log
4653
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
4652
+        // ----- Error log
4653
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
4654 4654
 
4655
-      // ----- Return
4656
-      return PclZip::errorCode();
4655
+        // ----- Return
4656
+        return PclZip::errorCode();
4657 4657
     }
4658 4658
 
4659 4659
     // ----- Extract the values
@@ -4662,27 +4662,27 @@  discard block
 block discarded – undo
4662 4662
     // ----- Check the global size
4663 4663
     if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
4664 4664
 
4665
-	  // ----- Removed in release 2.2 see readme file
4666
-	  // The check of the file size is a little too strict.
4667
-	  // Some bugs where found when a zip is encrypted/decrypted with 'crypt'.
4668
-	  // While decrypted, zip has training 0 bytes
4669
-	  if (0) {
4670
-      // ----- Error log
4671
-      PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
4672
-	                       'The central dir is not at the end of the archive.'
4673
-						   .' Some trailing bytes exists after the archive.');
4665
+        // ----- Removed in release 2.2 see readme file
4666
+        // The check of the file size is a little too strict.
4667
+        // Some bugs where found when a zip is encrypted/decrypted with 'crypt'.
4668
+        // While decrypted, zip has training 0 bytes
4669
+        if (0) {
4670
+        // ----- Error log
4671
+        PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
4672
+                            'The central dir is not at the end of the archive.'
4673
+                            .' Some trailing bytes exists after the archive.');
4674 4674
 
4675
-      // ----- Return
4676
-      return PclZip::errorCode();
4677
-	  }
4675
+        // ----- Return
4676
+        return PclZip::errorCode();
4677
+        }
4678 4678
     }
4679 4679
 
4680 4680
     // ----- Get comment
4681 4681
     if ($v_data['comment_size'] != 0) {
4682
-      $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
4682
+        $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
4683 4683
     }
4684 4684
     else
4685
-      $p_central_dir['comment'] = '';
4685
+        $p_central_dir['comment'] = '';
4686 4686
 
4687 4687
     $p_central_dir['entries'] = $v_data['entries'];
4688 4688
     $p_central_dir['disk_entries'] = $v_data['disk_entries'];
@@ -4697,33 +4697,33 @@  discard block
 block discarded – undo
4697 4697
 
4698 4698
     // ----- Return
4699 4699
     return $v_result;
4700
-  }
4701
-  // --------------------------------------------------------------------------------
4702
-
4703
-  // --------------------------------------------------------------------------------
4704
-  // Function : privDeleteByRule()
4705
-  // Description :
4706
-  // Parameters :
4707
-  // Return Values :
4708
-  // --------------------------------------------------------------------------------
4709
-  function privDeleteByRule(&$p_result_list, &$p_options)
4710
-  {
4700
+    }
4701
+    // --------------------------------------------------------------------------------
4702
+
4703
+    // --------------------------------------------------------------------------------
4704
+    // Function : privDeleteByRule()
4705
+    // Description :
4706
+    // Parameters :
4707
+    // Return Values :
4708
+    // --------------------------------------------------------------------------------
4709
+    function privDeleteByRule(&$p_result_list, &$p_options)
4710
+    {
4711 4711
     $v_result=1;
4712 4712
     $v_list_detail = array();
4713 4713
 
4714 4714
     // ----- Open the zip file
4715 4715
     if (($v_result=$this->privOpenFd('rb')) != 1)
4716 4716
     {
4717
-      // ----- Return
4718
-      return $v_result;
4717
+        // ----- Return
4718
+        return $v_result;
4719 4719
     }
4720 4720
 
4721 4721
     // ----- Read the central directory informations
4722 4722
     $v_central_dir = array();
4723 4723
     if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
4724 4724
     {
4725
-      $this->privCloseFd();
4726
-      return $v_result;
4725
+        $this->privCloseFd();
4726
+        return $v_result;
4727 4727
     }
4728 4728
 
4729 4729
     // ----- Go to beginning of File
@@ -4735,14 +4735,14 @@  discard block
 block discarded – undo
4735 4735
     @rewind($this->zip_fd);
4736 4736
     if (@fseek($this->zip_fd, $v_pos_entry))
4737 4737
     {
4738
-      // ----- Close the zip file
4739
-      $this->privCloseFd();
4738
+        // ----- Close the zip file
4739
+        $this->privCloseFd();
4740 4740
 
4741
-      // ----- Error log
4742
-      PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4741
+        // ----- Error log
4742
+        PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4743 4743
 
4744
-      // ----- Return
4745
-      return PclZip::errorCode();
4744
+        // ----- Return
4745
+        return PclZip::errorCode();
4746 4746
     }
4747 4747
 
4748 4748
     // ----- Read each entry
@@ -4751,53 +4751,53 @@  discard block
 block discarded – undo
4751 4751
     for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
4752 4752
     {
4753 4753
 
4754
-      // ----- Read the file header
4755
-      $v_header_list[$v_nb_extracted] = array();
4756
-      if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
4757
-      {
4754
+        // ----- Read the file header
4755
+        $v_header_list[$v_nb_extracted] = array();
4756
+        if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
4757
+        {
4758 4758
         // ----- Close the zip file
4759 4759
         $this->privCloseFd();
4760 4760
 
4761 4761
         return $v_result;
4762
-      }
4762
+        }
4763 4763
 
4764 4764
 
4765
-      // ----- Store the index
4766
-      $v_header_list[$v_nb_extracted]['index'] = $i;
4765
+        // ----- Store the index
4766
+        $v_header_list[$v_nb_extracted]['index'] = $i;
4767 4767
 
4768
-      // ----- Look for the specific extract rules
4769
-      $v_found = false;
4768
+        // ----- Look for the specific extract rules
4769
+        $v_found = false;
4770 4770
 
4771
-      // ----- Look for extract by name rule
4772
-      if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
4771
+        // ----- Look for extract by name rule
4772
+        if (   (isset($p_options[PCLZIP_OPT_BY_NAME]))
4773 4773
           && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
4774 4774
 
4775
-          // ----- Look if the filename is in the list
4776
-          for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
4775
+            // ----- Look if the filename is in the list
4776
+            for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
4777 4777
 
4778
-              // ----- Look for a directory
4779
-              if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
4778
+                // ----- Look for a directory
4779
+                if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
4780 4780
 
4781
-                  // ----- Look if the directory is in the filename path
4782
-                  if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4781
+                    // ----- Look if the directory is in the filename path
4782
+                    if (   (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4783 4783
                       && (substr($v_header_list[$v_nb_extracted]['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4784
-                      $v_found = true;
4785
-                  }
4786
-                  elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4784
+                        $v_found = true;
4785
+                    }
4786
+                    elseif (   (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4787 4787
                           && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4788
-                      $v_found = true;
4789
-                  }
4790
-              }
4791
-              // ----- Look for a filename
4792
-              elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
4793
-                  $v_found = true;
4794
-              }
4795
-          }
4796
-      }
4788
+                        $v_found = true;
4789
+                    }
4790
+                }
4791
+                // ----- Look for a filename
4792
+                elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
4793
+                    $v_found = true;
4794
+                }
4795
+            }
4796
+        }
4797 4797
 
4798
-      // ----- Look for extract by ereg rule
4799
-      // ereg() is deprecated with PHP 5.3
4800
-      /*
4798
+        // ----- Look for extract by ereg rule
4799
+        // ereg() is deprecated with PHP 5.3
4800
+        /*
4801 4801
       else if (   (isset($p_options[PCLZIP_OPT_BY_EREG]))
4802 4802
                && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
4803 4803
 
@@ -4807,47 +4807,47 @@  discard block
 block discarded – undo
4807 4807
       }
4808 4808
       */
4809 4809
 
4810
-      // ----- Look for extract by preg rule
4811
-      else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
4810
+        // ----- Look for extract by preg rule
4811
+        else if (   (isset($p_options[PCLZIP_OPT_BY_PREG]))
4812 4812
                && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
4813 4813
 
4814
-          if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
4815
-              $v_found = true;
4816
-          }
4817
-      }
4814
+            if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
4815
+                $v_found = true;
4816
+            }
4817
+        }
4818 4818
 
4819
-      // ----- Look for extract by index rule
4820
-      else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
4819
+        // ----- Look for extract by index rule
4820
+        else if (   (isset($p_options[PCLZIP_OPT_BY_INDEX]))
4821 4821
                && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
4822 4822
 
4823
-          // ----- Look if the index is in the list
4824
-          for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
4823
+            // ----- Look if the index is in the list
4824
+            for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
4825 4825
 
4826
-              if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4827
-                  $v_found = true;
4828
-              }
4829
-              if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
4830
-                  $j_start = $j+1;
4831
-              }
4826
+                if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4827
+                    $v_found = true;
4828
+                }
4829
+                if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
4830
+                    $j_start = $j+1;
4831
+                }
4832 4832
 
4833
-              if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
4834
-                  break;
4835
-              }
4836
-          }
4837
-      }
4838
-      else {
4839
-      	$v_found = true;
4840
-      }
4833
+                if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
4834
+                    break;
4835
+                }
4836
+            }
4837
+        }
4838
+        else {
4839
+            $v_found = true;
4840
+        }
4841 4841
 
4842
-      // ----- Look for deletion
4843
-      if ($v_found)
4844
-      {
4842
+        // ----- Look for deletion
4843
+        if ($v_found)
4844
+        {
4845 4845
         unset($v_header_list[$v_nb_extracted]);
4846
-      }
4847
-      else
4848
-      {
4846
+        }
4847
+        else
4848
+        {
4849 4849
         $v_nb_extracted++;
4850
-      }
4850
+        }
4851 4851
     }
4852 4852
 
4853 4853
     // ----- Look if something need to be deleted
@@ -4899,7 +4899,7 @@  discard block
 block discarded – undo
4899 4899
 
4900 4900
             // ----- Check that local file header is same as central file header
4901 4901
             if ($this->privCheckFileHeaders($v_local_header,
4902
-			                                $v_header_list[$i]) != 1) {
4902
+                                            $v_header_list[$i]) != 1) {
4903 4903
                 // TBC
4904 4904
             }
4905 4905
             unset($v_local_header);
@@ -4950,7 +4950,7 @@  discard block
 block discarded – undo
4950 4950
         // ----- Zip file comment
4951 4951
         $v_comment = '';
4952 4952
         if (isset($p_options[PCLZIP_OPT_COMMENT])) {
4953
-          $v_comment = $p_options[PCLZIP_OPT_COMMENT];
4953
+            $v_comment = $p_options[PCLZIP_OPT_COMMENT];
4954 4954
         }
4955 4955
 
4956 4956
         // ----- Calculate the size of the central header
@@ -4990,11 +4990,11 @@  discard block
 block discarded – undo
4990 4990
         $this->privCloseFd();
4991 4991
 
4992 4992
         if (($v_result = $this->privOpenFd('wb')) != 1) {
4993
-          return $v_result;
4993
+            return $v_result;
4994 4994
         }
4995 4995
 
4996 4996
         if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
4997
-          return $v_result;
4997
+            return $v_result;
4998 4998
         }
4999 4999
 
5000 5000
         $this->privCloseFd();
@@ -5002,35 +5002,35 @@  discard block
 block discarded – undo
5002 5002
 
5003 5003
     // ----- Return
5004 5004
     return $v_result;
5005
-  }
5006
-  // --------------------------------------------------------------------------------
5007
-
5008
-  // --------------------------------------------------------------------------------
5009
-  // Function : privDirCheck()
5010
-  // Description :
5011
-  //   Check if a directory exists, if not it creates it and all the parents directory
5012
-  //   which may be useful.
5013
-  // Parameters :
5014
-  //   $p_dir : Directory path to check.
5015
-  // Return Values :
5016
-  //    1 : OK
5017
-  //   -1 : Unable to create directory
5018
-  // --------------------------------------------------------------------------------
5019
-  function privDirCheck($p_dir, $p_is_dir=false)
5020
-  {
5005
+    }
5006
+    // --------------------------------------------------------------------------------
5007
+
5008
+    // --------------------------------------------------------------------------------
5009
+    // Function : privDirCheck()
5010
+    // Description :
5011
+    //   Check if a directory exists, if not it creates it and all the parents directory
5012
+    //   which may be useful.
5013
+    // Parameters :
5014
+    //   $p_dir : Directory path to check.
5015
+    // Return Values :
5016
+    //    1 : OK
5017
+    //   -1 : Unable to create directory
5018
+    // --------------------------------------------------------------------------------
5019
+    function privDirCheck($p_dir, $p_is_dir=false)
5020
+    {
5021 5021
     $v_result = 1;
5022 5022
 
5023 5023
 
5024 5024
     // ----- Remove the final '/'
5025 5025
     if (($p_is_dir) && (substr($p_dir, -1)=='/'))
5026 5026
     {
5027
-      $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
5027
+        $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
5028 5028
     }
5029 5029
 
5030 5030
     // ----- Check the directory availability
5031 5031
     if ((is_dir($p_dir)) || ($p_dir == ""))
5032 5032
     {
5033
-      return 1;
5033
+        return 1;
5034 5034
     }
5035 5035
 
5036 5036
     // ----- Extract parent directory
@@ -5039,77 +5039,77 @@  discard block
 block discarded – undo
5039 5039
     // ----- Just a check
5040 5040
     if ($p_parent_dir != $p_dir)
5041 5041
     {
5042
-      // ----- Look for parent directory
5043
-      if ($p_parent_dir != "")
5044
-      {
5042
+        // ----- Look for parent directory
5043
+        if ($p_parent_dir != "")
5044
+        {
5045 5045
         if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
5046 5046
         {
5047
-          return $v_result;
5047
+            return $v_result;
5048
+        }
5048 5049
         }
5049
-      }
5050 5050
     }
5051 5051
 
5052 5052
     // ----- Create the directory
5053 5053
     if (!@mkdir($p_dir, 0777))
5054 5054
     {
5055
-      // ----- Error log
5056
-      PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
5055
+        // ----- Error log
5056
+        PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
5057 5057
 
5058
-      // ----- Return
5059
-      return PclZip::errorCode();
5058
+        // ----- Return
5059
+        return PclZip::errorCode();
5060 5060
     }
5061 5061
 
5062 5062
     // ----- Return
5063 5063
     return $v_result;
5064
-  }
5065
-  // --------------------------------------------------------------------------------
5066
-
5067
-  // --------------------------------------------------------------------------------
5068
-  // Function : privMerge()
5069
-  // Description :
5070
-  //   If $p_archive_to_add does not exist, the function exit with a success result.
5071
-  // Parameters :
5072
-  // Return Values :
5073
-  // --------------------------------------------------------------------------------
5074
-  function privMerge(&$p_archive_to_add)
5075
-  {
5064
+    }
5065
+    // --------------------------------------------------------------------------------
5066
+
5067
+    // --------------------------------------------------------------------------------
5068
+    // Function : privMerge()
5069
+    // Description :
5070
+    //   If $p_archive_to_add does not exist, the function exit with a success result.
5071
+    // Parameters :
5072
+    // Return Values :
5073
+    // --------------------------------------------------------------------------------
5074
+    function privMerge(&$p_archive_to_add)
5075
+    {
5076 5076
     $v_result=1;
5077 5077
 
5078 5078
     // ----- Look if the archive_to_add exists
5079 5079
     if (!is_file($p_archive_to_add->zipname))
5080 5080
     {
5081 5081
 
5082
-      // ----- Nothing to merge, so merge is a success
5083
-      $v_result = 1;
5082
+        // ----- Nothing to merge, so merge is a success
5083
+        $v_result = 1;
5084 5084
 
5085
-      // ----- Return
5086
-      return $v_result;
5085
+        // ----- Return
5086
+        return $v_result;
5087 5087
     }
5088 5088
 
5089 5089
     // ----- Look if the archive exists
5090 5090
     if (!is_file($this->zipname))
5091 5091
     {
5092 5092
 
5093
-      // ----- Do a duplicate
5094
-      $v_result = $this->privDuplicate($p_archive_to_add->zipname);
5093
+        // ----- Do a duplicate
5094
+        $v_result = $this->privDuplicate($p_archive_to_add->zipname);
5095 5095
 
5096
-      // ----- Return
5097
-      return $v_result;
5096
+        // ----- Return
5097
+        return $v_result;
5098 5098
     }
5099 5099
 
5100 5100
     // ----- Open the zip file
5101 5101
     if (($v_result=$this->privOpenFd('rb')) != 1)
5102 5102
     {
5103
-      // ----- Return
5104
-      return $v_result;
5103
+        // ----- Return
5104
+        return $v_result;
5105 5105
     }
5106 5106
 
5107 5107
     // ----- Read the central directory informations
5108 5108
     $v_central_dir = array();
5109 5109
     if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
5110 5110
     {
5111
-      $this->privCloseFd();
5112
-      return $v_result;
5111
+        $this->privCloseFd();
5112
+        return $v_result;
5113 5113
     }
5114 5114
 
5115 5115
     // ----- Go to beginning of File
@@ -5118,20 +5118,20 @@  discard block
 block discarded – undo
5118 5118
     // ----- Open the archive_to_add file
5119 5119
     if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
5120 5120
     {
5121
-      $this->privCloseFd();
5121
+        $this->privCloseFd();
5122 5122
 
5123
-      // ----- Return
5124
-      return $v_result;
5123
+        // ----- Return
5124
+        return $v_result;
5125 5125
     }
5126 5126
 
5127 5127
     // ----- Read the central directory informations
5128 5128
     $v_central_dir_to_add = array();
5129 5129
     if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
5130 5130
     {
5131
-      $this->privCloseFd();
5132
-      $p_archive_to_add->privCloseFd();
5131
+        $this->privCloseFd();
5132
+        $p_archive_to_add->privCloseFd();
5133 5133
 
5134
-      return $v_result;
5134
+        return $v_result;
5135 5135
     }
5136 5136
 
5137 5137
     // ----- Go to beginning of File
@@ -5143,13 +5143,13 @@  discard block
 block discarded – undo
5143 5143
     // ----- Open the temporary file in write mode
5144 5144
     if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
5145 5145
     {
5146
-      $this->privCloseFd();
5147
-      $p_archive_to_add->privCloseFd();
5146
+        $this->privCloseFd();
5147
+        $p_archive_to_add->privCloseFd();
5148 5148
 
5149
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
5149
+        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
5150 5150
 
5151
-      // ----- Return
5152
-      return PclZip::errorCode();
5151
+        // ----- Return
5152
+        return PclZip::errorCode();
5153 5153
     }
5154 5154
 
5155 5155
     // ----- Copy the files from the archive to the temporary file
@@ -5157,20 +5157,20 @@  discard block
 block discarded – undo
5157 5157
     $v_size = $v_central_dir['offset'];
5158 5158
     while ($v_size != 0)
5159 5159
     {
5160
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5161
-      $v_buffer = fread($this->zip_fd, $v_read_size);
5162
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5163
-      $v_size -= $v_read_size;
5160
+        $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5161
+        $v_buffer = fread($this->zip_fd, $v_read_size);
5162
+        @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5163
+        $v_size -= $v_read_size;
5164 5164
     }
5165 5165
 
5166 5166
     // ----- Copy the files from the archive_to_add into the temporary file
5167 5167
     $v_size = $v_central_dir_to_add['offset'];
5168 5168
     while ($v_size != 0)
5169 5169
     {
5170
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5171
-      $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
5172
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5173
-      $v_size -= $v_read_size;
5170
+        $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5171
+        $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
5172
+        @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5173
+        $v_size -= $v_read_size;
5174 5174
     }
5175 5175
 
5176 5176
     // ----- Store the offset of the central dir
@@ -5180,20 +5180,20 @@  discard block
 block discarded – undo
5180 5180
     $v_size = $v_central_dir['size'];
5181 5181
     while ($v_size != 0)
5182 5182
     {
5183
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5184
-      $v_buffer = @fread($this->zip_fd, $v_read_size);
5185
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5186
-      $v_size -= $v_read_size;
5183
+        $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5184
+        $v_buffer = @fread($this->zip_fd, $v_read_size);
5185
+        @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5186
+        $v_size -= $v_read_size;
5187 5187
     }
5188 5188
 
5189 5189
     // ----- Copy the block of file headers from the archive_to_add
5190 5190
     $v_size = $v_central_dir_to_add['size'];
5191 5191
     while ($v_size != 0)
5192 5192
     {
5193
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5194
-      $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
5195
-      @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5196
-      $v_size -= $v_read_size;
5193
+        $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5194
+        $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
5195
+        @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5196
+        $v_size -= $v_read_size;
5197 5197
     }
5198 5198
 
5199 5199
     // ----- Merge the file comments
@@ -5212,16 +5212,16 @@  discard block
 block discarded – undo
5212 5212
     // ----- Create the central dir footer
5213 5213
     if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
5214 5214
     {
5215
-      $this->privCloseFd();
5216
-      $p_archive_to_add->privCloseFd();
5217
-      @fclose($v_zip_temp_fd);
5218
-      $this->zip_fd = null;
5215
+        $this->privCloseFd();
5216
+        $p_archive_to_add->privCloseFd();
5217
+        @fclose($v_zip_temp_fd);
5218
+        $this->zip_fd = null;
5219 5219
 
5220
-      // ----- Reset the file list
5221
-      unset($v_header_list);
5220
+        // ----- Reset the file list
5221
+        unset($v_header_list);
5222 5222
 
5223
-      // ----- Return
5224
-      return $v_result;
5223
+        // ----- Return
5224
+        return $v_result;
5225 5225
     }
5226 5226
 
5227 5227
     // ----- Swap back the file descriptor
@@ -5247,46 +5247,46 @@  discard block
 block discarded – undo
5247 5247
 
5248 5248
     // ----- Return
5249 5249
     return $v_result;
5250
-  }
5251
-  // --------------------------------------------------------------------------------
5252
-
5253
-  // --------------------------------------------------------------------------------
5254
-  // Function : privDuplicate()
5255
-  // Description :
5256
-  // Parameters :
5257
-  // Return Values :
5258
-  // --------------------------------------------------------------------------------
5259
-  function privDuplicate($p_archive_filename)
5260
-  {
5250
+    }
5251
+    // --------------------------------------------------------------------------------
5252
+
5253
+    // --------------------------------------------------------------------------------
5254
+    // Function : privDuplicate()
5255
+    // Description :
5256
+    // Parameters :
5257
+    // Return Values :
5258
+    // --------------------------------------------------------------------------------
5259
+    function privDuplicate($p_archive_filename)
5260
+    {
5261 5261
     $v_result=1;
5262 5262
 
5263 5263
     // ----- Look if the $p_archive_filename exists
5264 5264
     if (!is_file($p_archive_filename))
5265 5265
     {
5266 5266
 
5267
-      // ----- Nothing to duplicate, so duplicate is a success.
5268
-      $v_result = 1;
5267
+        // ----- Nothing to duplicate, so duplicate is a success.
5268
+        $v_result = 1;
5269 5269
 
5270
-      // ----- Return
5271
-      return $v_result;
5270
+        // ----- Return
5271
+        return $v_result;
5272 5272
     }
5273 5273
 
5274 5274
     // ----- Open the zip file
5275 5275
     if (($v_result=$this->privOpenFd('wb')) != 1)
5276 5276
     {
5277
-      // ----- Return
5278
-      return $v_result;
5277
+        // ----- Return
5278
+        return $v_result;
5279 5279
     }
5280 5280
 
5281 5281
     // ----- Open the temporary file in write mode
5282 5282
     if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
5283 5283
     {
5284
-      $this->privCloseFd();
5284
+        $this->privCloseFd();
5285 5285
 
5286
-      PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
5286
+        PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
5287 5287
 
5288
-      // ----- Return
5289
-      return PclZip::errorCode();
5288
+        // ----- Return
5289
+        return PclZip::errorCode();
5290 5290
     }
5291 5291
 
5292 5292
     // ----- Copy the files from the archive to the temporary file
@@ -5294,10 +5294,10 @@  discard block
 block discarded – undo
5294 5294
     $v_size = filesize($p_archive_filename);
5295 5295
     while ($v_size != 0)
5296 5296
     {
5297
-      $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5298
-      $v_buffer = fread($v_zip_temp_fd, $v_read_size);
5299
-      @fwrite($this->zip_fd, $v_buffer, $v_read_size);
5300
-      $v_size -= $v_read_size;
5297
+        $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5298
+        $v_buffer = fread($v_zip_temp_fd, $v_read_size);
5299
+        @fwrite($this->zip_fd, $v_buffer, $v_read_size);
5300
+        $v_size -= $v_read_size;
5301 5301
     }
5302 5302
 
5303 5303
     // ----- Close
@@ -5308,211 +5308,211 @@  discard block
 block discarded – undo
5308 5308
 
5309 5309
     // ----- Return
5310 5310
     return $v_result;
5311
-  }
5312
-  // --------------------------------------------------------------------------------
5313
-
5314
-  // --------------------------------------------------------------------------------
5315
-  // Function : privErrorLog()
5316
-  // Description :
5317
-  // Parameters :
5318
-  // --------------------------------------------------------------------------------
5319
-  function privErrorLog($p_error_code=0, $p_error_string='')
5320
-  {
5311
+    }
5312
+    // --------------------------------------------------------------------------------
5313
+
5314
+    // --------------------------------------------------------------------------------
5315
+    // Function : privErrorLog()
5316
+    // Description :
5317
+    // Parameters :
5318
+    // --------------------------------------------------------------------------------
5319
+    function privErrorLog($p_error_code=0, $p_error_string='')
5320
+    {
5321 5321
     if (PCLZIP_ERROR_EXTERNAL == 1) {
5322
-      PclError($p_error_code, $p_error_string);
5322
+        PclError($p_error_code, $p_error_string);
5323 5323
     }
5324 5324
     else {
5325
-      $this->error_code = $p_error_code;
5326
-      $this->error_string = $p_error_string;
5327
-    }
5328
-  }
5329
-  // --------------------------------------------------------------------------------
5330
-
5331
-  // --------------------------------------------------------------------------------
5332
-  // Function : privErrorReset()
5333
-  // Description :
5334
-  // Parameters :
5335
-  // --------------------------------------------------------------------------------
5336
-  function privErrorReset()
5337
-  {
5325
+        $this->error_code = $p_error_code;
5326
+        $this->error_string = $p_error_string;
5327
+    }
5328
+    }
5329
+    // --------------------------------------------------------------------------------
5330
+
5331
+    // --------------------------------------------------------------------------------
5332
+    // Function : privErrorReset()
5333
+    // Description :
5334
+    // Parameters :
5335
+    // --------------------------------------------------------------------------------
5336
+    function privErrorReset()
5337
+    {
5338 5338
     if (PCLZIP_ERROR_EXTERNAL == 1) {
5339
-      PclErrorReset();
5339
+        PclErrorReset();
5340 5340
     }
5341 5341
     else {
5342
-      $this->error_code = 0;
5343
-      $this->error_string = '';
5344
-    }
5345
-  }
5346
-  // --------------------------------------------------------------------------------
5347
-
5348
-  // --------------------------------------------------------------------------------
5349
-  // Function : privDisableMagicQuotes()
5350
-  // Description :
5351
-  // Parameters :
5352
-  // Return Values :
5353
-  // --------------------------------------------------------------------------------
5354
-  function privDisableMagicQuotes()
5355
-  {
5342
+        $this->error_code = 0;
5343
+        $this->error_string = '';
5344
+    }
5345
+    }
5346
+    // --------------------------------------------------------------------------------
5347
+
5348
+    // --------------------------------------------------------------------------------
5349
+    // Function : privDisableMagicQuotes()
5350
+    // Description :
5351
+    // Parameters :
5352
+    // Return Values :
5353
+    // --------------------------------------------------------------------------------
5354
+    function privDisableMagicQuotes()
5355
+    {
5356 5356
     $v_result=1;
5357 5357
 
5358 5358
     // ----- Look if function exists
5359 5359
     if (   (!function_exists("get_magic_quotes_runtime"))
5360
-	    || (!function_exists("set_magic_quotes_runtime"))) {
5361
-      return $v_result;
5362
-	}
5360
+        || (!function_exists("set_magic_quotes_runtime"))) {
5361
+        return $v_result;
5362
+    }
5363 5363
 
5364 5364
     // ----- Look if already done
5365 5365
     if ($this->magic_quotes_status != -1) {
5366
-      return $v_result;
5367
-	}
5366
+        return $v_result;
5367
+    }
5368 5368
 
5369
-	// ----- Get and memorize the magic_quote value
5370
-	$this->magic_quotes_status = @get_magic_quotes_runtime();
5369
+    // ----- Get and memorize the magic_quote value
5370
+    $this->magic_quotes_status = @get_magic_quotes_runtime();
5371 5371
 
5372
-	// ----- Disable magic_quotes
5373
-	if ($this->magic_quotes_status == 1) {
5374
-	  @set_magic_quotes_runtime(0);
5375
-	}
5372
+    // ----- Disable magic_quotes
5373
+    if ($this->magic_quotes_status == 1) {
5374
+        @set_magic_quotes_runtime(0);
5375
+    }
5376 5376
 
5377 5377
     // ----- Return
5378 5378
     return $v_result;
5379
-  }
5380
-  // --------------------------------------------------------------------------------
5381
-
5382
-  // --------------------------------------------------------------------------------
5383
-  // Function : privSwapBackMagicQuotes()
5384
-  // Description :
5385
-  // Parameters :
5386
-  // Return Values :
5387
-  // --------------------------------------------------------------------------------
5388
-  function privSwapBackMagicQuotes()
5389
-  {
5379
+    }
5380
+    // --------------------------------------------------------------------------------
5381
+
5382
+    // --------------------------------------------------------------------------------
5383
+    // Function : privSwapBackMagicQuotes()
5384
+    // Description :
5385
+    // Parameters :
5386
+    // Return Values :
5387
+    // --------------------------------------------------------------------------------
5388
+    function privSwapBackMagicQuotes()
5389
+    {
5390 5390
     $v_result=1;
5391 5391
 
5392 5392
     // ----- Look if function exists
5393 5393
     if (   (!function_exists("get_magic_quotes_runtime"))
5394
-	    || (!function_exists("set_magic_quotes_runtime"))) {
5395
-      return $v_result;
5396
-	}
5394
+        || (!function_exists("set_magic_quotes_runtime"))) {
5395
+        return $v_result;
5396
+    }
5397 5397
 
5398 5398
     // ----- Look if something to do
5399 5399
     if ($this->magic_quotes_status != -1) {
5400
-      return $v_result;
5401
-	}
5400
+        return $v_result;
5401
+    }
5402 5402
 
5403
-	// ----- Swap back magic_quotes
5404
-	if ($this->magic_quotes_status == 1) {
5405
-  	  @set_magic_quotes_runtime($this->magic_quotes_status);
5406
-	}
5403
+    // ----- Swap back magic_quotes
5404
+    if ($this->magic_quotes_status == 1) {
5405
+        @set_magic_quotes_runtime($this->magic_quotes_status);
5406
+    }
5407 5407
 
5408 5408
     // ----- Return
5409 5409
     return $v_result;
5410
-  }
5411
-  // --------------------------------------------------------------------------------
5412
-
5413
-  }
5414
-  // End of class
5415
-  // --------------------------------------------------------------------------------
5416
-
5417
-  // --------------------------------------------------------------------------------
5418
-  // Function : PclZipUtilPathReduction()
5419
-  // Description :
5420
-  // Parameters :
5421
-  // Return Values :
5422
-  // --------------------------------------------------------------------------------
5423
-  function PclZipUtilPathReduction($p_dir)
5424
-  {
5410
+    }
5411
+    // --------------------------------------------------------------------------------
5412
+
5413
+    }
5414
+    // End of class
5415
+    // --------------------------------------------------------------------------------
5416
+
5417
+    // --------------------------------------------------------------------------------
5418
+    // Function : PclZipUtilPathReduction()
5419
+    // Description :
5420
+    // Parameters :
5421
+    // Return Values :
5422
+    // --------------------------------------------------------------------------------
5423
+    function PclZipUtilPathReduction($p_dir)
5424
+    {
5425 5425
     $v_result = "";
5426 5426
 
5427 5427
     // ----- Look for not empty path
5428 5428
     if ($p_dir != "") {
5429
-      // ----- Explode path by directory names
5430
-      $v_list = explode("/", $p_dir);
5429
+        // ----- Explode path by directory names
5430
+        $v_list = explode("/", $p_dir);
5431 5431
 
5432
-      // ----- Study directories from last to first
5433
-      $v_skip = 0;
5434
-      for ($i=sizeof($v_list)-1; $i>=0; $i--) {
5432
+        // ----- Study directories from last to first
5433
+        $v_skip = 0;
5434
+        for ($i=sizeof($v_list)-1; $i>=0; $i--) {
5435 5435
         // ----- Look for current path
5436 5436
         if ($v_list[$i] == ".") {
5437
-          // ----- Ignore this directory
5438
-          // Should be the first $i=0, but no check is done
5437
+            // ----- Ignore this directory
5438
+            // Should be the first $i=0, but no check is done
5439 5439
         }
5440 5440
         else if ($v_list[$i] == "..") {
5441
-		  $v_skip++;
5441
+            $v_skip++;
5442 5442
         }
5443 5443
         else if ($v_list[$i] == "") {
5444
-		  // ----- First '/' i.e. root slash
5445
-		  if ($i == 0) {
5444
+            // ----- First '/' i.e. root slash
5445
+            if ($i == 0) {
5446 5446
             $v_result = "/".$v_result;
5447
-		    if ($v_skip > 0) {
5448
-		        // ----- It is an invalid path, so the path is not modified
5449
-		        // TBC
5450
-		        $v_result = $p_dir;
5447
+            if ($v_skip > 0) {
5448
+                // ----- It is an invalid path, so the path is not modified
5449
+                // TBC
5450
+                $v_result = $p_dir;
5451 5451
                 $v_skip = 0;
5452
-		    }
5453
-		  }
5454
-		  // ----- Last '/' i.e. indicates a directory
5455
-		  else if ($i == (sizeof($v_list)-1)) {
5452
+            }
5453
+            }
5454
+            // ----- Last '/' i.e. indicates a directory
5455
+            else if ($i == (sizeof($v_list)-1)) {
5456 5456
             $v_result = $v_list[$i];
5457
-		  }
5458
-		  // ----- Double '/' inside the path
5459
-		  else {
5457
+            }
5458
+            // ----- Double '/' inside the path
5459
+            else {
5460 5460
             // ----- Ignore only the double '//' in path,
5461 5461
             // but not the first and last '/'
5462
-		  }
5462
+            }
5463 5463
         }
5464 5464
         else {
5465
-		  // ----- Look for item to skip
5466
-		  if ($v_skip > 0) {
5467
-		    $v_skip--;
5468
-		  }
5469
-		  else {
5465
+            // ----- Look for item to skip
5466
+            if ($v_skip > 0) {
5467
+            $v_skip--;
5468
+            }
5469
+            else {
5470 5470
             $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
5471
-		  }
5471
+            }
5472
+        }
5472 5473
         }
5473
-      }
5474 5474
 
5475
-      // ----- Look for skip
5476
-      if ($v_skip > 0) {
5475
+        // ----- Look for skip
5476
+        if ($v_skip > 0) {
5477 5477
         while ($v_skip > 0) {
5478 5478
             $v_result = '../'.$v_result;
5479 5479
             $v_skip--;
5480 5480
         }
5481
-      }
5481
+        }
5482 5482
     }
5483 5483
 
5484 5484
     // ----- Return
5485 5485
     return $v_result;
5486
-  }
5487
-  // --------------------------------------------------------------------------------
5488
-
5489
-  // --------------------------------------------------------------------------------
5490
-  // Function : PclZipUtilPathInclusion()
5491
-  // Description :
5492
-  //   This function indicates if the path $p_path is under the $p_dir tree. Or,
5493
-  //   said in an other way, if the file or sub-dir $p_path is inside the dir
5494
-  //   $p_dir.
5495
-  //   The function indicates also if the path is exactly the same as the dir.
5496
-  //   This function supports path with duplicated '/' like '//', but does not
5497
-  //   support '.' or '..' statements.
5498
-  // Parameters :
5499
-  // Return Values :
5500
-  //   0 if $p_path is not inside directory $p_dir
5501
-  //   1 if $p_path is inside directory $p_dir
5502
-  //   2 if $p_path is exactly the same as $p_dir
5503
-  // --------------------------------------------------------------------------------
5504
-  function PclZipUtilPathInclusion($p_dir, $p_path)
5505
-  {
5486
+    }
5487
+    // --------------------------------------------------------------------------------
5488
+
5489
+    // --------------------------------------------------------------------------------
5490
+    // Function : PclZipUtilPathInclusion()
5491
+    // Description :
5492
+    //   This function indicates if the path $p_path is under the $p_dir tree. Or,
5493
+    //   said in an other way, if the file or sub-dir $p_path is inside the dir
5494
+    //   $p_dir.
5495
+    //   The function indicates also if the path is exactly the same as the dir.
5496
+    //   This function supports path with duplicated '/' like '//', but does not
5497
+    //   support '.' or '..' statements.
5498
+    // Parameters :
5499
+    // Return Values :
5500
+    //   0 if $p_path is not inside directory $p_dir
5501
+    //   1 if $p_path is inside directory $p_dir
5502
+    //   2 if $p_path is exactly the same as $p_dir
5503
+    // --------------------------------------------------------------------------------
5504
+    function PclZipUtilPathInclusion($p_dir, $p_path)
5505
+    {
5506 5506
     $v_result = 1;
5507 5507
 
5508 5508
     // ----- Look for path beginning by ./
5509 5509
     if (   ($p_dir == '.')
5510 5510
         || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
5511
-      $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
5511
+        $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
5512 5512
     }
5513 5513
     if (   ($p_path == '.')
5514 5514
         || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
5515
-      $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
5515
+        $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
5516 5516
     }
5517 5517
 
5518 5518
     // ----- Explode dir and path by directory separator
@@ -5526,196 +5526,196 @@  discard block
 block discarded – undo
5526 5526
     $j = 0;
5527 5527
     while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
5528 5528
 
5529
-      // ----- Look for empty dir (path reduction)
5530
-      if ($v_list_dir[$i] == '') {
5529
+        // ----- Look for empty dir (path reduction)
5530
+        if ($v_list_dir[$i] == '') {
5531 5531
         $i++;
5532 5532
         continue;
5533
-      }
5534
-      if ($v_list_path[$j] == '') {
5533
+        }
5534
+        if ($v_list_path[$j] == '') {
5535 5535
         $j++;
5536 5536
         continue;
5537
-      }
5537
+        }
5538 5538
 
5539
-      // ----- Compare the items
5540
-      if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != ''))  {
5539
+        // ----- Compare the items
5540
+        if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != ''))  {
5541 5541
         $v_result = 0;
5542
-      }
5542
+        }
5543 5543
 
5544
-      // ----- Next items
5545
-      $i++;
5546
-      $j++;
5544
+        // ----- Next items
5545
+        $i++;
5546
+        $j++;
5547 5547
     }
5548 5548
 
5549 5549
     // ----- Look if everything seems to be the same
5550 5550
     if ($v_result) {
5551
-      // ----- Skip all the empty items
5552
-      while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
5553
-      while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
5551
+        // ----- Skip all the empty items
5552
+        while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
5553
+        while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
5554 5554
 
5555
-      if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
5555
+        if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
5556 5556
         // ----- There are exactly the same
5557 5557
         $v_result = 2;
5558
-      }
5559
-      else if ($i < $v_list_dir_size) {
5558
+        }
5559
+        else if ($i < $v_list_dir_size) {
5560 5560
         // ----- The path is shorter than the dir
5561 5561
         $v_result = 0;
5562
-      }
5562
+        }
5563 5563
     }
5564 5564
 
5565 5565
     // ----- Return
5566 5566
     return $v_result;
5567
-  }
5568
-  // --------------------------------------------------------------------------------
5569
-
5570
-  // --------------------------------------------------------------------------------
5571
-  // Function : PclZipUtilCopyBlock()
5572
-  // Description :
5573
-  // Parameters :
5574
-  //   $p_mode : read/write compression mode
5575
-  //             0 : src & dest normal
5576
-  //             1 : src gzip, dest normal
5577
-  //             2 : src normal, dest gzip
5578
-  //             3 : src & dest gzip
5579
-  // Return Values :
5580
-  // --------------------------------------------------------------------------------
5581
-  function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
5582
-  {
5567
+    }
5568
+    // --------------------------------------------------------------------------------
5569
+
5570
+    // --------------------------------------------------------------------------------
5571
+    // Function : PclZipUtilCopyBlock()
5572
+    // Description :
5573
+    // Parameters :
5574
+    //   $p_mode : read/write compression mode
5575
+    //             0 : src & dest normal
5576
+    //             1 : src gzip, dest normal
5577
+    //             2 : src normal, dest gzip
5578
+    //             3 : src & dest gzip
5579
+    // Return Values :
5580
+    // --------------------------------------------------------------------------------
5581
+    function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
5582
+    {
5583 5583
     $v_result = 1;
5584 5584
 
5585 5585
     if ($p_mode==0)
5586 5586
     {
5587
-      while ($p_size != 0)
5588
-      {
5587
+        while ($p_size != 0)
5588
+        {
5589 5589
         $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5590 5590
         $v_buffer = @fread($p_src, $v_read_size);
5591 5591
         @fwrite($p_dest, $v_buffer, $v_read_size);
5592 5592
         $p_size -= $v_read_size;
5593
-      }
5593
+        }
5594 5594
     }
5595 5595
     else if ($p_mode==1)
5596 5596
     {
5597
-      while ($p_size != 0)
5598
-      {
5597
+        while ($p_size != 0)
5598
+        {
5599 5599
         $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5600 5600
         $v_buffer = @gzread($p_src, $v_read_size);
5601 5601
         @fwrite($p_dest, $v_buffer, $v_read_size);
5602 5602
         $p_size -= $v_read_size;
5603
-      }
5603
+        }
5604 5604
     }
5605 5605
     else if ($p_mode==2)
5606 5606
     {
5607
-      while ($p_size != 0)
5608
-      {
5607
+        while ($p_size != 0)
5608
+        {
5609 5609
         $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5610 5610
         $v_buffer = @fread($p_src, $v_read_size);
5611 5611
         @gzwrite($p_dest, $v_buffer, $v_read_size);
5612 5612
         $p_size -= $v_read_size;
5613
-      }
5613
+        }
5614 5614
     }
5615 5615
     else if ($p_mode==3)
5616 5616
     {
5617
-      while ($p_size != 0)
5618
-      {
5617
+        while ($p_size != 0)
5618
+        {
5619 5619
         $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5620 5620
         $v_buffer = @gzread($p_src, $v_read_size);
5621 5621
         @gzwrite($p_dest, $v_buffer, $v_read_size);
5622 5622
         $p_size -= $v_read_size;
5623
-      }
5623
+        }
5624 5624
     }
5625 5625
 
5626 5626
     // ----- Return
5627 5627
     return $v_result;
5628
-  }
5629
-  // --------------------------------------------------------------------------------
5630
-
5631
-  // --------------------------------------------------------------------------------
5632
-  // Function : PclZipUtilRename()
5633
-  // Description :
5634
-  //   This function tries to do a simple rename() function. If it fails, it
5635
-  //   tries to copy the $p_src file in a new $p_dest file and then unlink the
5636
-  //   first one.
5637
-  // Parameters :
5638
-  //   $p_src : Old filename
5639
-  //   $p_dest : New filename
5640
-  // Return Values :
5641
-  //   1 on success, 0 on failure.
5642
-  // --------------------------------------------------------------------------------
5643
-  function PclZipUtilRename($p_src, $p_dest)
5644
-  {
5628
+    }
5629
+    // --------------------------------------------------------------------------------
5630
+
5631
+    // --------------------------------------------------------------------------------
5632
+    // Function : PclZipUtilRename()
5633
+    // Description :
5634
+    //   This function tries to do a simple rename() function. If it fails, it
5635
+    //   tries to copy the $p_src file in a new $p_dest file and then unlink the
5636
+    //   first one.
5637
+    // Parameters :
5638
+    //   $p_src : Old filename
5639
+    //   $p_dest : New filename
5640
+    // Return Values :
5641
+    //   1 on success, 0 on failure.
5642
+    // --------------------------------------------------------------------------------
5643
+    function PclZipUtilRename($p_src, $p_dest)
5644
+    {
5645 5645
     $v_result = 1;
5646 5646
 
5647 5647
     // ----- Try to rename the files
5648 5648
     if (!@rename($p_src, $p_dest)) {
5649 5649
 
5650
-      // ----- Try to copy & unlink the src
5651
-      if (!@copy($p_src, $p_dest)) {
5650
+        // ----- Try to copy & unlink the src
5651
+        if (!@copy($p_src, $p_dest)) {
5652 5652
         $v_result = 0;
5653
-      }
5654
-      else if (!@unlink($p_src)) {
5653
+        }
5654
+        else if (!@unlink($p_src)) {
5655 5655
         $v_result = 0;
5656
-      }
5656
+        }
5657 5657
     }
5658 5658
 
5659 5659
     // ----- Return
5660 5660
     return $v_result;
5661
-  }
5662
-  // --------------------------------------------------------------------------------
5663
-
5664
-  // --------------------------------------------------------------------------------
5665
-  // Function : PclZipUtilOptionText()
5666
-  // Description :
5667
-  //   Translate option value in text. Mainly for debug purpose.
5668
-  // Parameters :
5669
-  //   $p_option : the option value.
5670
-  // Return Values :
5671
-  //   The option text value.
5672
-  // --------------------------------------------------------------------------------
5673
-  function PclZipUtilOptionText($p_option)
5674
-  {
5661
+    }
5662
+    // --------------------------------------------------------------------------------
5663
+
5664
+    // --------------------------------------------------------------------------------
5665
+    // Function : PclZipUtilOptionText()
5666
+    // Description :
5667
+    //   Translate option value in text. Mainly for debug purpose.
5668
+    // Parameters :
5669
+    //   $p_option : the option value.
5670
+    // Return Values :
5671
+    //   The option text value.
5672
+    // --------------------------------------------------------------------------------
5673
+    function PclZipUtilOptionText($p_option)
5674
+    {
5675 5675
 
5676 5676
     $v_list = get_defined_constants();
5677 5677
     for (reset($v_list); $v_key = key($v_list); next($v_list)) {
5678
-	    $v_prefix = substr($v_key, 0, 10);
5679
-	    if ((   ($v_prefix == 'PCLZIP_OPT')
5678
+        $v_prefix = substr($v_key, 0, 10);
5679
+        if ((   ($v_prefix == 'PCLZIP_OPT')
5680 5680
            || ($v_prefix == 'PCLZIP_CB_')
5681 5681
            || ($v_prefix == 'PCLZIP_ATT'))
5682
-	        && ($v_list[$v_key] == $p_option)) {
5682
+            && ($v_list[$v_key] == $p_option)) {
5683 5683
         return $v_key;
5684
-	    }
5684
+        }
5685 5685
     }
5686 5686
 
5687 5687
     $v_result = 'Unknown';
5688 5688
 
5689 5689
     return $v_result;
5690
-  }
5691
-  // --------------------------------------------------------------------------------
5692
-
5693
-  // --------------------------------------------------------------------------------
5694
-  // Function : PclZipUtilTranslateWinPath()
5695
-  // Description :
5696
-  //   Translate windows path by replacing '\' by '/' and optionally removing
5697
-  //   drive letter.
5698
-  // Parameters :
5699
-  //   $p_path : path to translate.
5700
-  //   $p_remove_disk_letter : true | false
5701
-  // Return Values :
5702
-  //   The path translated.
5703
-  // --------------------------------------------------------------------------------
5704
-  function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
5705
-  {
5690
+    }
5691
+    // --------------------------------------------------------------------------------
5692
+
5693
+    // --------------------------------------------------------------------------------
5694
+    // Function : PclZipUtilTranslateWinPath()
5695
+    // Description :
5696
+    //   Translate windows path by replacing '\' by '/' and optionally removing
5697
+    //   drive letter.
5698
+    // Parameters :
5699
+    //   $p_path : path to translate.
5700
+    //   $p_remove_disk_letter : true | false
5701
+    // Return Values :
5702
+    //   The path translated.
5703
+    // --------------------------------------------------------------------------------
5704
+    function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
5705
+    {
5706 5706
     if (stristr(php_uname(), 'windows')) {
5707
-      // ----- Look for potential disk letter
5708
-      if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
5709
-          $p_path = substr($p_path, $v_position+1);
5710
-      }
5711
-      // ----- Change potential windows directory separator
5712
-      if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
5713
-          $p_path = strtr($p_path, '\\', '/');
5714
-      }
5707
+        // ----- Look for potential disk letter
5708
+        if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
5709
+            $p_path = substr($p_path, $v_position+1);
5710
+        }
5711
+        // ----- Change potential windows directory separator
5712
+        if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
5713
+            $p_path = strtr($p_path, '\\', '/');
5714
+        }
5715 5715
     }
5716 5716
     return $p_path;
5717
-  }
5718
-  // --------------------------------------------------------------------------------
5717
+    }
5718
+    // --------------------------------------------------------------------------------
5719 5719
 
5720 5720
 
5721 5721
 ?>
Please login to merge, or discard this patch.