All in One SEO Pack - Version 1.6.6

Version Description

Download this release

Release Info

Developer hallsofmontezuma
Plugin Icon 128x128 All in One SEO Pack
Version 1.6.6
Comparing to
See all releases

Code changes from version 1.6.5 to 1.6.6

aioseop.class.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  class All_in_One_SEO_Pack {
4
 
5
- var $version = "1.6.5";
6
 
7
  /** Max numbers of chars in auto-generated description */
8
  var $maximum_description_length = 160;
2
 
3
  class All_in_One_SEO_Pack {
4
 
5
+ var $version = "1.6.6";
6
 
7
  /** Max numbers of chars in auto-generated description */
8
  var $maximum_description_length = 160;
all_in_one_seo_pack.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: All in One SEO Pack
5
  Plugin URI: http://semperfiwebdesign.com
6
  Description: Out-of-the-box SEO for your Wordpress blog. <a href="options-general.php?page=all-in-one-seo-pack/aioseop.class.php">Options configuration panel</a> | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=mrtorbert%40gmail%2ecom&item_name=All%20In%20One%20SEO%20Pack&item_number=Support%20Open%20Source&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8">Donate</a> | <a href="http://semperfiwebdesign.com/forum/" >Support</a> | <a href="https://www.amazon.com/wishlist/1NFQ133FNCOOA/ref=wl_web" target="_blank" title="Amazon Wish List">Amazon Wishlist</a>
7
- Version: 1.6.5
8
  Author: Michael Torbert
9
  Author URI: http://michaeltorbert.com
10
  */
@@ -554,7 +554,7 @@ echo "<div class='updated fade' style='background-color:green;border-color:green
554
  }
555
 
556
  function aioseop_get_version(){
557
- return '1.6.5';
558
  }
559
 
560
 
@@ -613,8 +613,11 @@ echo "<div class='updated fade' style='background-color:green;border-color:green
613
 
614
  function aioseop_activation_notice(){
615
  global $aioseop_options;
 
616
  echo '<div class="error fade" style="background-color:red;"><p><strong>All in One SEO Pack must be configured. Go to <a href="' . admin_url( 'options-general.php?page=all-in-one-seo-pack/aioseop.class.php' ) . '">the admin page</a> to enable and configure the plugin.</strong></p></div>';
617
-
 
 
618
  }
619
 
620
  //add_action('after_plugin_row_all-in-one-seo-pack/all_in_one_seo_pack.php', 'add_plugin_row', 10, 2);
@@ -711,7 +714,7 @@ function aiosp_meta() {
711
  $title = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_title', true)));
712
  $description = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_description', true)));
713
  $aiosp_meta = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aiosp_meta', true)));
714
- $aiosp_disable = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aiosp_disable', true)));
715
  $aiosp_titleatr = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_titleatr', true)));
716
  $aiosp_menulabel = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_menulabel', true)));
717
  ?>
4
  Plugin Name: All in One SEO Pack
5
  Plugin URI: http://semperfiwebdesign.com
6
  Description: Out-of-the-box SEO for your Wordpress blog. <a href="options-general.php?page=all-in-one-seo-pack/aioseop.class.php">Options configuration panel</a> | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=mrtorbert%40gmail%2ecom&item_name=All%20In%20One%20SEO%20Pack&item_number=Support%20Open%20Source&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8">Donate</a> | <a href="http://semperfiwebdesign.com/forum/" >Support</a> | <a href="https://www.amazon.com/wishlist/1NFQ133FNCOOA/ref=wl_web" target="_blank" title="Amazon Wish List">Amazon Wishlist</a>
7
+ Version: 1.6.6
8
  Author: Michael Torbert
9
  Author URI: http://michaeltorbert.com
10
  */
554
  }
555
 
556
  function aioseop_get_version(){
557
+ return '1.6.6';
558
  }
559
 
560
 
613
 
614
  function aioseop_activation_notice(){
615
  global $aioseop_options;
616
+ if(function_exists('admin_url')){
617
  echo '<div class="error fade" style="background-color:red;"><p><strong>All in One SEO Pack must be configured. Go to <a href="' . admin_url( 'options-general.php?page=all-in-one-seo-pack/aioseop.class.php' ) . '">the admin page</a> to enable and configure the plugin.</strong></p></div>';
618
+ }else{
619
+ echo '<div class="error fade" style="background-color:red;"><p><strong>All in One SEO Pack must be configured. Go to <a href="' . get_option('siteurl') . 'options-general.php?page=all-in-one-seo-pack/aioseop.class.php' . '">the admin page</a> to enable and configure the plugin.</strong></p></div>';
620
+ }
621
  }
622
 
623
  //add_action('after_plugin_row_all-in-one-seo-pack/all_in_one_seo_pack.php', 'add_plugin_row', 10, 2);
714
  $title = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_title', true)));
715
  $description = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_description', true)));
716
  $aiosp_meta = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aiosp_meta', true)));
717
+ $aiosp_disable = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_disable', true)));
718
  $aiosp_titleatr = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_titleatr', true)));
719
  $aiosp_menulabel = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_menulabel', true)));
720
  ?>
trunk/aioseop.class.php DELETED
@@ -1,2091 +0,0 @@
1
- <?php
2
-
3
- class All_in_One_SEO_Pack {
4
-
5
- var $version = "1.6.5";
6
-
7
- /** Max numbers of chars in auto-generated description */
8
- var $maximum_description_length = 160;
9
-
10
- /** Minimum number of chars an excerpt should be so that it can be used
11
- * as description. Touch only if you know what you're doing
12
- */
13
- var $minimum_description_length = 1;
14
-
15
- var $ob_start_detected = false;
16
-
17
- var $title_start = -1;
18
-
19
- var $title_end = -1;
20
-
21
- /** The title before rewriting */
22
- var $orig_title = '';
23
-
24
- /** Temp filename for the latest version. */
25
- // var $upgrade_filename = 'temp.zip';
26
-
27
- /** Where to extract the downloaded newest version. */
28
- // var $upgrade_folder;
29
-
30
- /** Any error in upgrading. */
31
- // var $upgrade_error;
32
-
33
- /** Which zip to download in order to upgrade .*/
34
- // var $upgrade_url = 'http://downloads.wordpress.org/plugin/all-in-one-seo-pack.zip';
35
-
36
- /** Filename of log file. */
37
- var $log_file;
38
-
39
- /** Flag whether there should be logging. */
40
- var $do_log;
41
-
42
- var $wp_version;
43
-
44
- var $aioseop_op;
45
- //var $aioseop_options = get_option('aioseop_options');
46
-
47
- function All_in_One_SEO_Pack() {
48
- global $wp_version;
49
- global $aioseop_options;
50
- $this->wp_version = $wp_version;
51
-
52
- $this->log_file = dirname(__FILE__) . '/all_in_one_seo_pack.log';
53
- if ($aioseop_options['aiosp_do_log']) {
54
- $this->do_log = true;
55
- } else {
56
- $this->do_log = false;
57
- }
58
-
59
- // $this->upgrade_filename = dirname(__FILE__) . '/' . $this->upgrade_filename;
60
- // $this->upgrade_folder = dirname(__FILE__);
61
- }
62
-
63
- /**
64
- * Convert a string to lower case
65
- * Compatible with mb_strtolower(), an UTF-8 friendly replacement for strtolower()
66
- */
67
- function strtolower($str) {
68
- global $UTF8_TABLES;
69
- return strtr($str, $UTF8_TABLES['strtolower']);
70
- }
71
-
72
- /**
73
- * Convert a string to upper case
74
- * Compatible with mb_strtoupper(), an UTF-8 friendly replacement for strtoupper()
75
- */
76
- function strtoupper($str) {
77
- global $UTF8_TABLES;
78
- return strtr($str, $UTF8_TABLES['strtoupper']);
79
- }
80
-
81
-
82
- function template_redirect() {
83
- global $wp_query;
84
- global $aioseop_options;
85
-
86
- $post = $wp_query->get_queried_object();
87
-
88
- if( $this->aioseop_mrt_exclude_this_page()){
89
- return;
90
- }
91
-
92
- if (is_feed()) {
93
- return;
94
- }
95
-
96
- if (is_single() || is_page()) {
97
- $aiosp_disable = htmlspecialchars(stripcslashes(get_post_meta($post->ID, '_aioseop_disable', true)));
98
- if ($aiosp_disable) {
99
- return;
100
- }
101
- }
102
-
103
-
104
-
105
- if ($aioseop_options['aiosp_rewrite_titles']) {
106
- ob_start(array($this, 'output_callback_for_title'));
107
- }
108
- }
109
-
110
- function aioseop_mrt_exclude_this_page(){
111
- global $aioseop_options;
112
- $currenturl = trim($_SERVER['REQUEST_URI'],'/');
113
- /* echo "<br /><br />";
114
- echo $aioseop_options['aiosp_ex_pages'];
115
- echo "<br /><br />";
116
- */
117
-
118
- $excludedstuff = explode(',',$aioseop_options['aiosp_ex_pages']);
119
- foreach($excludedstuff as $exedd){
120
- //echo $exedd;
121
- if($excludedstuff){
122
- if(stristr($currenturl, trim($exedd))){
123
- return true;
124
- }
125
- }
126
- }
127
- return false;
128
- }
129
-
130
- function output_callback_for_title($content) {
131
- return $this->rewrite_title($content);
132
- }
133
-
134
-
135
-
136
-
137
-
138
-
139
- //
140
- //CHECK IF ARRAY EXISTS IN DB, IF SO, GET ARRAY, ADD EVERYTHING, CHECK FOR ISSET?
141
- //
142
- function init() {
143
- if (function_exists('load_plugin_textdomain')) {
144
- if ( !defined('WP_PLUGIN_DIR') ) {
145
- load_plugin_textdomain('all_in_one_seo_pack', str_replace( ABSPATH, '', dirname(__FILE__)));
146
- } else {
147
- load_plugin_textdomain('all_in_one_seo_pack', false, dirname(plugin_basename(__FILE__)));
148
- }
149
- }
150
-
151
-
152
- /*
153
- if (function_exists('load_plugin_textdomain')) {
154
- load_plugin_textdomain('all_in_one_seo_pack', WP_PLUGIN_DIR . '/all-in-one-seo-pack');
155
- }
156
- */
157
-
158
- }
159
-
160
- function is_static_front_page() {
161
- global $wp_query;
162
- global $aioseop_options;
163
- $post = $wp_query->get_queried_object();
164
- return get_option('show_on_front') == 'page' && is_page() && $post->ID == get_option('page_on_front');
165
- }
166
-
167
- function is_static_posts_page() {
168
- global $wp_query;
169
- $post = $wp_query->get_queried_object();
170
- return get_option('show_on_front') == 'page' && is_home() && $post->ID == get_option('page_for_posts');
171
- }
172
-
173
- function get_base() {
174
- return '/'.end(explode('/', str_replace(array('\\','/all_in_one_seo_pack.php'),array('/',''),__FILE__)));
175
- }
176
-
177
- function seo_mrt_admin_head() {
178
- $home = get_settings('siteurl');
179
- $stylesheet = WP_PLUGIN_URL . '/all-in-one-seo-pack/style.css';
180
- echo '<link rel="stylesheet" href="' . $stylesheet . '" type="text/css" media="screen" />';
181
- }
182
-
183
-
184
- function wp_head() {
185
- if (is_feed()) {
186
- return;
187
- }
188
-
189
- global $wp_query;
190
- global $aioseop_options;
191
- $post = $wp_query->get_queried_object();
192
- $meta_string = null;
193
- if($this->is_static_posts_page()){
194
- $title = strip_tags( apply_filters( 'single_post_title', $post->post_title ) );
195
-
196
- }
197
- //echo("wp_head() " . wp_title('', false) . " is_home() => " . is_home() . ", is_page() => " . is_page() . ", is_single() => " . is_single() . ", is_static_front_page() => " . $this->is_static_front_page() . ", is_static_posts_page() => " . $this->is_static_posts_page());
198
-
199
- if (is_single() || is_page()) {
200
- $aiosp_disable = htmlspecialchars(stripcslashes(get_post_meta($post->ID, '_aioseop_disable', true)));
201
- if ($aiosp_disable) {
202
- return;
203
- }
204
- }
205
-
206
- if( $this->aioseop_mrt_exclude_this_page()==TRUE ){
207
- return;
208
- }
209
-
210
- if ($aioseop_options['aiosp_rewrite_titles']) {
211
- // make the title rewrite as short as possible
212
- if (function_exists('ob_list_handlers')) {
213
- $active_handlers = ob_list_handlers();
214
- } else {
215
- $active_handlers = array();
216
- }
217
- if (sizeof($active_handlers) > 0 &&
218
- strtolower($active_handlers[sizeof($active_handlers) - 1]) ==
219
- strtolower('All_in_One_SEO_Pack::output_callback_for_title')) {
220
- ob_end_flush();
221
- } else {
222
- $this->log("another plugin interfering?");
223
- // if we get here there *could* be trouble with another plugin :(
224
- $this->ob_start_detected = true;
225
- if (function_exists('ob_list_handlers')) {
226
- foreach (ob_list_handlers() as $handler) {
227
- $this->log("detected output handler $handler");
228
- }
229
- }
230
- }
231
- }
232
-
233
- /*
234
-
235
- echo trim($_SERVER['REQUEST_URI'],'/');
236
- $currenturl = trim($_SERVER['REQUEST_URI'],'/');
237
- echo "<br /><br />";
238
-
239
- echo $aioseop_options['aiosp_ex_pages'];
240
-
241
- echo "<br /><br />";
242
-
243
- $excludedstuff = explode(',',$aioseop_options['aiosp_ex_pages']);
244
- foreach($excludedstuff as $exedd){
245
- echo $exedd;
246
- //echo "<br /><br />substring: ". stristr($currenturl,trim($exedd)) . "<br />";
247
- if(stristr($currenturl, trim($exedd))){
248
- echo "<br />match, should not display<br /><br />";
249
- }else{
250
- echo "<br />( " . $exedd . " was not found in " . $currenturl . " ) - no match<br /><br />";
251
- }
252
- }
253
- //print_r($excludedstuff);
254
- */
255
- echo "\n<!-- All in One SEO Pack $this->version by Michael Torbert of Semper Fi Web Design";
256
- if ($this->ob_start_detected) {
257
- echo "ob_start_detected ";
258
- }
259
- echo "[$this->title_start,$this->title_end] ";
260
- echo "-->\n";
261
- if ((is_home() && $aioseop_options['aiosp_home_keywords'] && !$this->is_static_posts_page()) || $this->is_static_front_page()) {
262
- $keywords = trim($this->internationalize($aioseop_options['aiosp_home_keywords']));
263
- } elseif($this->is_static_posts_page() && !$aioseop_options['aiosp_dynamic_postspage_keywords']){ // and if option = use page set keywords instead of keywords from recent posts
264
- //$keywords = "posts keyyysss" . stripcslashes(get_post_meta($post->ID,'keywords',true));
265
- $keywords = stripcslashes($this->internationalize(get_post_meta($post->ID, "_aioseop_keywords", true)));
266
-
267
- // $keywords = $this->get_unique_keywords($keywords);
268
-
269
- }else {
270
- $keywords = $this->get_all_keywords();
271
- }
272
- if (is_single() || is_page() || $this->is_static_posts_page()) {
273
- if ($this->is_static_front_page()) {
274
- $description = trim(stripcslashes($this->internationalize($aioseop_options['aiosp_home_description'])));
275
- } else {
276
- $description = $this->get_post_description($post);
277
- $description = apply_filters('aioseop_description',$description);
278
- }
279
- } else if (is_home()) {
280
- $description = trim(stripcslashes($this->internationalize($aioseop_options['aiosp_home_description'])));
281
- } else if (is_category()) {
282
- $description = $this->internationalize(category_description());
283
- }
284
-
285
- if (isset($description) && (strlen($description) > $this->minimum_description_length) && !(is_home() && is_paged())) {
286
- $description = trim(strip_tags($description));
287
- $description = str_replace('"', '', $description);
288
-
289
- // replace newlines on mac / windows?
290
- $description = str_replace("\r\n", ' ', $description);
291
-
292
- // maybe linux uses this alone
293
- $description = str_replace("\n", ' ', $description);
294
-
295
- if (isset($meta_string)) {
296
- //$meta_string .= "\n";
297
- } else {
298
- $meta_string = '';
299
- }
300
-
301
- // description format
302
- $description_format = $aioseop_options['aiosp_description_format'];
303
- if (!isset($description_format) || empty($description_format)) {
304
- $description_format = "%description%";
305
- }
306
- $description = str_replace('%description%', $description, $description_format);
307
- $description = str_replace('%blog_title%', get_bloginfo('name'), $description);
308
- $description = str_replace('%blog_description%', get_bloginfo('description'), $description);
309
- $description = str_replace('%wp_title%', $this->get_original_title(), $description);
310
- //$description = html_entity_decode($description, ENT_COMPAT, get_bloginfo('charset'));
311
- if($aioseop_options['aiosp_can'] && is_attachment()){
312
- $url = $this->aiosp_mrt_get_url($wp_query);
313
- if ($url) {
314
- preg_match_all('/(\d+)/', $url, $matches);
315
- if (is_array($matches)){
316
- $uniqueDesc = join('',$matches[0]);
317
- }
318
- }
319
- $description .= ' ' . $uniqueDesc;
320
- }
321
- $meta_string .= sprintf("<meta name=\"description\" content=\"%s\" />", $description);
322
- }
323
- $keywords = apply_filters('aioseop_keywords',$keywords);
324
- if (isset ($keywords) && !empty($keywords) && !(is_home() && is_paged())) {
325
- if (isset($meta_string)) {
326
- $meta_string .= "\n";
327
- }
328
- $meta_string .= sprintf("<meta name=\"keywords\" content=\"%s\" />", $keywords);
329
- }
330
-
331
- if (function_exists('is_tag')) {
332
- $is_tag = is_tag();
333
- }
334
-
335
- if ((is_category() && $aioseop_options['aiosp_category_noindex']) ||
336
- (!is_category() && is_archive() &&!$is_tag && $aioseop_options['aiosp_archive_noindex']) ||
337
- ($aioseop_options['aiosp_tags_noindex'] && $is_tag)) {
338
- if (isset($meta_string)) {
339
- $meta_string .= "\n";
340
- }
341
- $meta_string .= '<meta name="robots" content="noindex,follow" />';
342
- }
343
-
344
- $page_meta = stripcslashes($aioseop_options['aiosp_page_meta_tags']);
345
- $post_meta = stripcslashes($aioseop_options['aiosp_post_meta_tags']);
346
- $home_meta = stripcslashes($aioseop_options['aiosp_home_meta_tags']);
347
- if (is_page() && isset($page_meta) && !empty($page_meta) || $this->is_static_posts_page()) {
348
- if (isset($meta_string)) {
349
- $meta_string .= "\n";
350
- }
351
- echo "\n$page_meta";
352
- }
353
-
354
- if (is_single() && isset($post_meta) && !empty($post_meta)) {
355
- if (isset($meta_string)) {
356
- $meta_string .= "\n";
357
- }
358
- $meta_string .= "$post_meta";
359
- }
360
-
361
- if (is_home() && !empty($home_meta)) {
362
- if (isset($meta_string)) {
363
- $meta_string .= "\n";
364
- }
365
- $meta_string .= "$home_meta";
366
- }
367
-
368
- if ($meta_string != null) {
369
- echo "$meta_string\n";
370
- }
371
-
372
- if($aioseop_options['aiosp_can']){
373
- $url = $this->aiosp_mrt_get_url($wp_query);
374
- if ($url) {
375
- $url = apply_filters('aioseop_canonical_url',$url);
376
-
377
- echo "".'<link rel="canonical" href="'.$url.'" />'."\n";
378
- }
379
- }
380
-
381
- echo "<!-- /all in one seo pack -->\n";
382
- }
383
-
384
- // Thank you, Yoast de Valk, for much of this code.
385
-
386
- function aiosp_mrt_get_url($query) {
387
- global $aioseop_options;
388
- if ($query->is_404 || $query->is_search) {
389
- return false;
390
- }
391
- $haspost = count($query->posts) > 0;
392
- $has_ut = function_exists('user_trailingslashit');
393
-
394
- if (get_query_var('m')) {
395
- $m = preg_replace('/[^0-9]/', '', get_query_var('m'));
396
- switch (strlen($m)) {
397
- case 4:
398
- $link = get_year_link($m);
399
- break;
400
- case 6:
401
- $link = get_month_link(substr($m, 0, 4), substr($m, 4, 2));
402
- break;
403
- case 8:
404
- $link = get_day_link(substr($m, 0, 4), substr($m, 4, 2),
405
- substr($m, 6, 2));
406
- break;
407
- default:
408
- return false;
409
- }
410
- } elseif (($query->is_single || $query->is_page) && $haspost) {
411
- $post = $query->posts[0];
412
- $link = get_permalink($post->ID);
413
- $link = $this->yoast_get_paged($link);
414
- /* if ($page && $page > 1) {
415
- $link = trailingslashit($link) . "page/". "$page";
416
- if ($has_ut) {
417
- $link = user_trailingslashit($link, 'paged');
418
- } else {
419
- $link .= '/';
420
- }
421
- }
422
- if ($query->is_page && ('page' == get_option('show_on_front')) &&
423
- $post->ID == get_option('page_on_front'))
424
- {
425
- $link = trailingslashit($link);
426
- }*/
427
- } elseif ($query->is_author && $haspost) {
428
- global $wp_version;
429
- if ($wp_version >= '2') {
430
- $author = get_userdata(get_query_var('author'));
431
- if ($author === false)
432
- return false;
433
- $link = get_author_link(false, $author->ID,
434
- $author->user_nicename);
435
- } else {
436
- global $cache_userdata;
437
- $userid = get_query_var('author');
438
- $link = get_author_link(false, $userid,
439
- $cache_userdata[$userid]->user_nicename);
440
- }
441
- } elseif ($query->is_category && $haspost) {
442
- $link = get_category_link(get_query_var('cat'));
443
- $link = $this->yoast_get_paged($link);
444
- } else if ($query->is_tag && $haspost) {
445
- $tag = get_term_by('slug',get_query_var('tag'),'post_tag');
446
- if (!empty($tag->term_id)) {
447
- $link = get_tag_link($tag->term_id);
448
- }
449
- $link = $this->yoast_get_paged($link);
450
- } elseif ($query->is_day && $haspost) {
451
- $link = get_day_link(get_query_var('year'),
452
- get_query_var('monthnum'),
453
- get_query_var('day'));
454
- } elseif ($query->is_month && $haspost) {
455
- $link = get_month_link(get_query_var('year'),
456
- get_query_var('monthnum'));
457
- } elseif ($query->is_year && $haspost) {
458
- $link = get_year_link(get_query_var('year'));
459
- } elseif ($query->is_home) {
460
- if ((get_option('show_on_front') == 'page') &&
461
- ($pageid = get_option('page_for_posts')))
462
- {
463
- $link = get_permalink($pageid);
464
- $link = $this->yoast_get_paged($link);
465
- $link = trailingslashit($link);
466
- } else {
467
- $link = get_option('home');
468
- $link = $this->yoast_get_paged($link);
469
- $link = trailingslashit($link); }
470
- } else {
471
- return false;
472
- }
473
-
474
- return $link;
475
-
476
- }
477
-
478
-
479
- function yoast_get_paged($link) {
480
- $page = get_query_var('paged');
481
- if ($page && $page > 1) {
482
- $link = trailingslashit($link) ."page/". "$page";
483
- if ($has_ut) {
484
- $link = user_trailingslashit($link, 'paged');
485
- } else {
486
- $link .= '/';
487
- }
488
- }
489
- return $link;
490
- }
491
-
492
-
493
- function get_post_description($post) {
494
- global $aioseop_options;
495
- $description = trim(stripcslashes($this->internationalize(get_post_meta($post->ID, "_aioseop_description", true))));
496
- if (!$description) {
497
- $description = $this->trim_excerpt_without_filters_full_length($this->internationalize($post->post_excerpt));
498
- if (!$description && $aioseop_options["aiosp_generate_descriptions"]) {
499
- $description = $this->trim_excerpt_without_filters($this->internationalize($post->post_content));
500
- }
501
- }
502
-
503
- // "internal whitespace trim"
504
- $description = preg_replace("/\s\s+/", " ", $description);
505
-
506
- return $description;
507
- }
508
-
509
- function replace_title($content, $title) {
510
- $title = trim(strip_tags($title));
511
-
512
- $title_tag_start = "<title>";
513
- $title_tag_end = "</title>";
514
- $len_start = strlen($title_tag_start);
515
- $len_end = strlen($title_tag_end);
516
- $title = stripcslashes(trim($title));
517
- $start = strpos($content, $title_tag_start);
518
- $end = strpos($content, $title_tag_end);
519
-
520
- $this->title_start = $start;
521
- $this->title_end = $end;
522
- $this->orig_title = $title;
523
-
524
- if ($start && $end) {
525
- $header = substr($content, 0, $start + $len_start) . $title . substr($content, $end);
526
- } else {
527
- // this breaks some sitemap plugins (like wpg2)
528
- //$header = $content . "<title>$title</title>";
529
-
530
- $header = $content;
531
- }
532
-
533
- return $header;
534
- }
535
-
536
- function internationalize($in) {
537
- if (function_exists('langswitch_filter_langs_with_message')) {
538
- $in = langswitch_filter_langs_with_message($in);
539
- }
540
- if (function_exists('polyglot_filter')) {
541
- $in = polyglot_filter($in);
542
- }
543
- if (function_exists('qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage')) {
544
- $in = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage($in);
545
- }
546
- $in = apply_filters('localization', $in);
547
- return $in;
548
- }
549
-
550
- /** @return The original title as delivered by WP (well, in most cases) */
551
- function get_original_title() {
552
- global $wp_query;
553
- global $aioseop_options;
554
- if (!$wp_query) {
555
- return null;
556
- }
557
-
558
- $post = $wp_query->get_queried_object();
559
-
560
- // the_search_query() is not suitable, it cannot just return
561
- global $s;
562
-
563
- $title = null;
564
-
565
- if (is_home()) {
566
- $title = get_option('blogname');
567
- } else if (is_single()) {
568
- $title = $this->internationalize(wp_title('', false));
569
- } else if (is_search() && isset($s) && !empty($s)) {
570
- if (function_exists('attribute_escape')) {
571
- $search = attribute_escape(stripcslashes($s));
572
- } else {
573
- $search = wp_specialchars(stripcslashes($s), true);
574
- }
575
- $search = $this->capitalize($search);
576
- $title = $search;
577
- } else if (is_category() && !is_feed()) {
578
- $category_description = $this->internationalize(category_description());
579
- $category_name = ucwords($this->internationalize(single_cat_title('', false)));
580
- $title = $category_name;
581
- } else if (is_page()) {
582
- $title = $this->internationalize(wp_title('', false));
583
- } else if (function_exists('is_tag') && is_tag()) {
584
- global $utw;
585
- if ($utw) {
586
- $tags = $utw->GetCurrentTagSet();
587
- $tag = $tags[0]->tag;
588
- $tag = str_replace('-', ' ', $tag);
589
- } else {
590
- // wordpress > 2.3
591
- $tag = $this->internationalize(wp_title('', false));
592
- }
593
- if ($tag) {
594
- $title = $tag;
595
- }
596
- } else if (is_archive()) {
597
- $title = $this->internationalize(wp_title('', false));
598
- } else if (is_404()) {
599
- $title_format = $aioseop_options['aiosp_404_title_format'];
600
- $new_title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
601
- $new_title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $new_title);
602
- $new_title = str_replace('%request_url%', $_SERVER['REQUEST_URI'], $new_title);
603
- $new_title = str_replace('%request_words%', $this->request_as_words($_SERVER['REQUEST_URI']), $new_title);
604
- $title = $new_title;
605
- }
606
-
607
- return trim($title);
608
- }
609
-
610
- function paged_title($title) {
611
- // the page number if paged
612
- global $paged;
613
- global $aioseop_options;
614
- // simple tagging support
615
- global $STagging;
616
-
617
- if (is_paged() || (isset($STagging) && $STagging->is_tag_view() && $paged)) {
618
- $part = $this->internationalize($aioseop_options['aiosp_paged_format']);
619
- if (isset($part) || !empty($part)) {
620
- $part = " " . trim($part);
621
- $part = str_replace('%page%', $paged, $part);
622
- $this->log("paged_title() [$title] [$part]");
623
- $title .= $part;
624
- }
625
- }
626
- return $title;
627
- }
628
-
629
- function rewrite_title($header) {
630
- global $aioseop_options;
631
- global $wp_query;
632
- if (!$wp_query) {
633
- $header .= "<!-- no wp_query found! -->\n";
634
- return $header;
635
- }
636
-
637
- $post = $wp_query->get_queried_object();
638
-
639
- // the_search_query() is not suitable, it cannot just return
640
- global $s;
641
-
642
- global $STagging;
643
-
644
- if (is_home() && !$this->is_static_posts_page()) {
645
- $title = $this->internationalize($aioseop_options['aiosp_home_title']);
646
- if (empty($title)) {
647
- $title = $this->internationalize(get_option('blogname'));
648
- }
649
- $title = $this->paged_title($title);
650
- $header = $this->replace_title($header, $title);
651
- } else if (is_attachment()) {
652
- $title = get_the_title($post->post_parent).' '.$post->post_title.' – '.get_option('blogname');
653
- $header = $this->replace_title($header,$title);
654
- } else if (is_single()) {
655
- // we're not in the loop :(
656
- $authordata = get_userdata($post->post_author);
657
- $categories = get_the_category();
658
- $category = '';
659
- if (count($categories) > 0) {
660
- $category = $categories[0]->cat_name;
661
- }
662
- $title = $this->internationalize(get_post_meta($post->ID, "_aioseop_title", true));
663
- if (!$title) {
664
- $title = $this->internationalize(get_post_meta($post->ID, "title_tag", true));
665
- if (!$title) {
666
- $title = $this->internationalize(wp_title('', false));
667
- }
668
- }
669
- $title_format = $aioseop_options['aiosp_post_title_format'];
670
- $new_title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
671
- $new_title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $new_title);
672
- $new_title = str_replace('%post_title%', $title, $new_title);
673
- $new_title = str_replace('%category%', $category, $new_title);
674
- $new_title = str_replace('%category_title%', $category, $new_title);
675
- $new_title = str_replace('%post_author_login%', $authordata->user_login, $new_title);
676
- $new_title = str_replace('%post_author_nicename%', $authordata->user_nicename, $new_title);
677
- $new_title = str_replace('%post_author_firstname%', ucwords($authordata->first_name), $new_title);
678
- $new_title = str_replace('%post_author_lastname%', ucwords($authordata->last_name), $new_title);
679
- $title = $new_title;
680
- $title = trim($title);
681
- $title = apply_filters('aioseop_title_single',$title);
682
- $header = $this->replace_title($header, $title);
683
- } else if (is_search() && isset($s) && !empty($s)) {
684
- if (function_exists('attribute_escape')) {
685
- $search = attribute_escape(stripcslashes($s));
686
- } else {
687
- $search = wp_specialchars(stripcslashes($s), true);
688
- }
689
- $search = $this->capitalize($search);
690
- $title_format = $aioseop_options['aiosp_search_title_format'];
691
- $title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
692
- $title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $title);
693
- $title = str_replace('%search%', $search, $title);
694
- $header = $this->replace_title($header, $title);
695
- } else if (is_category() && !is_feed()) {
696
- $category_description = $this->internationalize(category_description());
697
- if($aioseop_options['aiosp_cap_cats']){
698
- $category_name = ucwords($this->internationalize(single_cat_title('', false)));
699
- }else{
700
- $category_name = $this->internationalize(single_cat_title('', false));
701
- }
702
- //$category_name = ucwords($this->internationalize(single_cat_title('', false)));
703
- $title_format = $aioseop_options['aiosp_category_title_format'];
704
- $title = str_replace('%category_title%', $category_name, $title_format);
705
- $title = str_replace('%category_description%', $category_description, $title);
706
- $title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title);
707
- $title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $title);
708
- $title = $this->paged_title($title);
709
- $header = $this->replace_title($header, $title);
710
- } else if (is_page() || $this->is_static_posts_page()) {
711
- // we're not in the loop :(
712
- $authordata = get_userdata($post->post_author);
713
- if ($this->is_static_front_page()) {
714
- if ($this->internationalize($aioseop_options['aiosp_home_title'])) {
715
- $header = $this->replace_title($header, $this->internationalize($aioseop_options['aiosp_home_title']));
716
- }
717
- } else {
718
- $title = $this->internationalize(get_post_meta($post->ID, "_aioseop_title", true));
719
- if (!$title) {
720
- $title = $this->internationalize(wp_title('', false));
721
- }
722
- $title_format = $aioseop_options['aiosp_page_title_format'];
723
- $new_title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
724
- $new_title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $new_title);
725
- $new_title = str_replace('%page_title%', $title, $new_title);
726
- $new_title = str_replace('%page_author_login%', $authordata->user_login, $new_title);
727
- $new_title = str_replace('%page_author_nicename%', $authordata->user_nicename, $new_title);
728
- $new_title = str_replace('%page_author_firstname%', ucwords($authordata->first_name), $new_title);
729
- $new_title = str_replace('%page_author_lastname%', ucwords($authordata->last_name), $new_title);
730
- $title = trim($new_title);
731
- $title = apply_filters('aioseop_title_page',$title);
732
- $header = $this->replace_title($header, $title);
733
- }
734
- } else if (function_exists('is_tag') && is_tag()) {
735
- global $utw;
736
- if ($utw) {
737
- $tags = $utw->GetCurrentTagSet();
738
- $tag = $tags[0]->tag;
739
- $tag = str_replace('-', ' ', $tag);
740
- } else {
741
- // wordpress > 2.3
742
- $tag = $this->internationalize(wp_title('', false));
743
- }
744
- if ($tag) {
745
- $tag = $this->capitalize($tag);
746
- $title_format = $aioseop_options['aiosp_tag_title_format'];
747
- $title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
748
- $title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $title);
749
- $title = str_replace('%tag%', $tag, $title);
750
- $title = $this->paged_title($title);
751
- $header = $this->replace_title($header, $title);
752
- }
753
- } else if (isset($STagging) && $STagging->is_tag_view()) { // simple tagging support
754
- $tag = $STagging->search_tag;
755
- if ($tag) {
756
- $tag = $this->capitalize($tag);
757
- $title_format = $aioseop_options['aiosp_tag_title_format'];
758
- $title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
759
- $title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $title);
760
- $title = str_replace('%tag%', $tag, $title);
761
- $title = $this->paged_title($title);
762
- $header = $this->replace_title($header, $title);
763
- }
764
- } else if (is_archive()) {
765
- $date = $this->internationalize(wp_title('', false));
766
- $title_format = $aioseop_options['aiosp_archive_title_format'];
767
- $new_title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
768
- $new_title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $new_title);
769
- $new_title = str_replace('%date%', $date, $new_title);
770
- $title = trim($new_title);
771
- $title = $this->paged_title($title);
772
- $header = $this->replace_title($header, $title);
773
- } else if (is_404()) {
774
- $title_format = $aioseop_options['aiosp_404_title_format'];
775
- $new_title = str_replace('%blog_title%', $this->internationalize(get_bloginfo('name')), $title_format);
776
- $new_title = str_replace('%blog_description%', $this->internationalize(get_bloginfo('description')), $new_title);
777
- $new_title = str_replace('%request_url%', $_SERVER['REQUEST_URI'], $new_title);
778
- $new_title = str_replace('%request_words%', $this->request_as_words($_SERVER['REQUEST_URI']), $new_title);
779
- $new_title = str_replace('%404_title%', $this->internationalize(wp_title('', false)), $new_title);
780
- $header = $this->replace_title($header, $new_title);
781
- }
782
-
783
- return $header;
784
-
785
- }
786
-
787
- /**
788
- * @return User-readable nice words for a given request.
789
- */
790
- function request_as_words($request) {
791
- $request = htmlspecialchars($request);
792
- $request = str_replace('.html', ' ', $request);
793
- $request = str_replace('.htm', ' ', $request);
794
- $request = str_replace('.', ' ', $request);
795
- $request = str_replace('/', ' ', $request);
796
- $request_a = explode(' ', $request);
797
- $request_new = array();
798
- foreach ($request_a as $token) {
799
- $request_new[] = ucwords(trim($token));
800
- }
801
- $request = implode(' ', $request_new);
802
- return $request;
803
- }
804
-
805
- function capitalize($s) {
806
- $s = trim($s);
807
- $tokens = explode(' ', $s);
808
- while (list($key, $val) = each($tokens)) {
809
- $tokens[$key] = trim($tokens[$key]);
810
- $tokens[$key] = strtoupper(substr($tokens[$key], 0, 1)) . substr($tokens[$key], 1);
811
- }
812
- $s = implode(' ', $tokens);
813
- return $s;
814
- }
815
-
816
- function trim_excerpt_without_filters($text) {
817
- $text = str_replace(']]>', ']]&gt;', $text);
818
- $text = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $text );
819
- $text = strip_tags($text);
820
- $max = $this->maximum_description_length;
821
-
822
- if ($max < strlen($text)) {
823
- while($text[$max] != ' ' && $max > $this->minimum_description_length) {
824
- $max--;
825
- }
826
- }
827
- $text = substr($text, 0, $max);
828
- return trim(stripcslashes($text));
829
- }
830
-
831
- function trim_excerpt_without_filters_full_length($text) {
832
- $text = str_replace(']]>', ']]&gt;', $text);
833
- $text = preg_replace( '|\[(.+?)\](.+?\[/\\1\])?|s', '', $text );
834
- $text = strip_tags($text);
835
- return trim(stripcslashes($text));
836
- }
837
-
838
- /**
839
- * @return comma-separated list of unique keywords
840
- */
841
- function get_all_keywords() {
842
- global $posts;
843
- global $aioseop_options;
844
-
845
- if (is_404()) {
846
- return null;
847
- }
848
-
849
- // if we are on synthetic pages
850
- if (!is_home() && !is_page() && !is_single() &&!$this->is_static_front_page() && !$this->is_static_posts_page()) {
851
- return null;
852
- }
853
-
854
- $keywords = array();
855
- if (is_array($posts)) {
856
- foreach ($posts as $post) {
857
- if ($post) {
858
-
859
- // custom field keywords
860
- $keywords_a = $keywords_i = null;
861
- $description_a = $description_i = null;
862
-
863
- $id = (is_attachment())?($post->post_parent):($post->ID); // if attachment then use parent post id
864
- $keywords_i = stripcslashes($this->internationalize(get_post_meta($id, "_aioseop_keywords", true)));
865
- //$id = $post->ID;
866
- //$keywords_i = stripcslashes($this->internationalize(get_post_meta($post->ID, "_aioseop_keywords", true)));
867
- $keywords_i = str_replace('"', '', $keywords_i);
868
- if (isset($keywords_i) && !empty($keywords_i)) {
869
- $traverse = explode(',', $keywords_i);
870
- foreach ($traverse as $keyword) {
871
- $keywords[] = $keyword;
872
- }
873
- }
874
-
875
- // WP 2.3 tags
876
- if (function_exists('get_the_tags')) {
877
- //$tags = get_the_tags($post->ID);
878
- $tags = get_the_tags($id);
879
- if ($tags && is_array($tags)) {
880
- foreach ($tags as $tag) {
881
- $keywords[] = $this->internationalize($tag->name);
882
- }
883
- }
884
- }
885
-
886
- // Ultimate Tag Warrior integration
887
- global $utw;
888
- if ($utw) {
889
- $tags = $utw->GetTagsForPost($post);
890
- if (is_array($tags)) {
891
- foreach ($tags as $tag) {
892
- $tag = $tag->tag;
893
- $tag = str_replace('_',' ', $tag);
894
- $tag = str_replace('-',' ',$tag);
895
- $tag = stripcslashes($tag);
896
- $keywords[] = $tag;
897
- }
898
- }
899
- }
900
-
901
- // autometa
902
- $autometa = stripcslashes(get_post_meta($id, 'autometa', true));
903
- //$autometa = stripcslashes(get_post_meta($post->ID, "autometa", true));
904
- if (isset($autometa) && !empty($autometa)) {
905
- $autometa_array = explode(' ', $autometa);
906
- foreach ($autometa_array as $e) {
907
- $keywords[] = $e;
908
- }
909
- }
910
-
911
- if ($aioseop_options['aiosp_use_categories'] && !is_page()) {
912
- $categories = get_the_category($id);
913
- //$categories = get_the_category($post->ID);
914
- foreach ($categories as $category) {
915
- $keywords[] = $this->internationalize($category->cat_name);
916
- }
917
- }
918
-
919
- }
920
- }
921
- }
922
-
923
- return $this->get_unique_keywords($keywords);
924
- }
925
-
926
- function get_meta_keywords() {
927
- global $posts;
928
-
929
- $keywords = array();
930
- if (is_array($posts)) {
931
- foreach ($posts as $post) {
932
- if ($post) {
933
- // custom field keywords
934
- $keywords_a = $keywords_i = null;
935
- $description_a = $description_i = null;
936
- $id = $post->ID;
937
- $keywords_i = stripcslashes(get_post_meta($post->ID, "_aioseop_keywords", true));
938
- $keywords_i = str_replace('"', '', $keywords_i);
939
- if (isset($keywords_i) && !empty($keywords_i)) {
940
- $keywords[] = $keywords_i;
941
- }
942
- }
943
- }
944
- }
945
-
946
- return $this->get_unique_keywords($keywords);
947
- }
948
-
949
- function get_unique_keywords($keywords) {
950
- $small_keywords = array();
951
- foreach ($keywords as $word) {
952
- if (function_exists('mb_strtolower'))
953
- $small_keywords[] = mb_strtolower($word, get_bloginfo('charset'));
954
- else
955
- $small_keywords[] = $this->strtolower($word);
956
- }
957
- $keywords_ar = array_unique($small_keywords);
958
- return implode(',', $keywords_ar);
959
- }
960
-
961
- function get_url($url) {
962
- if (function_exists('file_get_contents')) {
963
- $file = file_get_contents($url);
964
- } else {
965
- $curl = curl_init($url);
966
- curl_setopt($curl, CURLOPT_HEADER, 0);
967
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
968
- $file = curl_exec($curl);
969
- curl_close($curl);
970
- }
971
- return $file;
972
- }
973
-
974
- function log($message) {
975
- if ($this->do_log) {
976
- error_log(date('Y-m-d H:i:s') . " " . $message . "\n", 3, $this->log_file);
977
- }
978
- }
979
-
980
- function download_newest_version() {
981
- $success = true;
982
- $file_content = $this->get_url($this->upgrade_url);
983
- if ($file_content === false) {
984
- $this->upgrade_error = sprintf(__("Could not download distribution (%s)"), $this->upgrade_url);
985
- $success = false;
986
- } else if (strlen($file_content) < 100) {
987
- $this->upgrade_error = sprintf(__("Could not download distribution (%s): %s"), $this->upgrade_url, $file_content);
988
- $success = false;
989
- } else {
990
- $this->log(sprintf("filesize of download ZIP: %d", strlen($file_content)));
991
- $fh = @fopen($this->upgrade_filename, 'w');
992
- $this->log("fh is $fh");
993
- if (!$fh) {
994
- $this->upgrade_error = sprintf(__("Could not open %s for writing"), $this->upgrade_filename);
995
- $this->upgrade_error .= "<br />";
996
- $this->upgrade_error .= sprintf(__("Please make sure %s is writable"), $this->upgrade_folder);
997
- $success = false;
998
- } else {
999
- $bytes_written = @fwrite($fh, $file_content);
1000
- $this->log("wrote $bytes_written bytes");
1001
- if (!$bytes_written) {
1002
- $this->upgrade_error = sprintf(__("Could not write to %s"), $this->upgrade_filename);
1003
- $success = false;
1004
- }
1005
- }
1006
- if ($success) {
1007
- fclose($fh);
1008
- }
1009
- }
1010
- return $success;
1011
- }
1012
-
1013
- function install_newest_version() {
1014
- $success = $this->download_newest_version();
1015
- if ($success) {
1016
- $success = $this->extract_plugin();
1017
- unlink($this->upgrade_filename);
1018
- }
1019
- return $success;
1020
- }
1021
-
1022
- function extract_plugin() {
1023
- if (!class_exists('PclZip')) {
1024
- require_once ('pclzip.lib.php');
1025
- }
1026
- $archive = new PclZip($this->upgrade_filename);
1027
- $files = $archive->extract(PCLZIP_OPT_STOP_ON_ERROR, PCLZIP_OPT_REPLACE_NEWER, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_PATH, $this->upgrade_folder);
1028
- $this->log("files is $files");
1029
- if (is_array($files)) {
1030
- $num_extracted = sizeof($files);
1031
- $this->log("extracted $num_extracted files to $this->upgrade_folder");
1032
- $this->log(print_r($files, true));
1033
- return true;
1034
- } else {
1035
- $this->upgrade_error = $archive->errorInfo();
1036
- return false;
1037
- }
1038
- }
1039
-
1040
- /** crude approximization of whether current user is an admin */
1041
- function is_admin() {
1042
- return current_user_can('level_8');
1043
- }
1044
-
1045
-
1046
- function is_directory_writable($directory) {
1047
- $filename = $directory . '/' . 'tmp_file_' . time();
1048
- $fh = @fopen($filename, 'w');
1049
- if (!$fh) {
1050
- return false;
1051
- }
1052
-
1053
- $written = fwrite($fh, "test");
1054
- fclose($fh);
1055
- unlink($filename);
1056
- if ($written) {
1057
- return true;
1058
- } else {
1059
- return false;
1060
- }
1061
- }
1062
-
1063
-
1064
- function is_upgrade_directory_writable() {
1065
- //return $this->is_directory_writable($this->upgrade_folder);
1066
- // let's assume it is
1067
- return true;
1068
- }
1069
-
1070
-
1071
- function post_meta_tags($id) {
1072
- $awmp_edit = $_POST["aiosp_edit"];
1073
- $nonce = $_POST['nonce-aioseop-edit'];
1074
- // if (!wp_verify_nonce($nonce, 'edit-aioseop-nonce')) die ( 'Security Check - If you receive this in error, log out and back in to WordPress');
1075
- if (isset($awmp_edit) && !empty($awmp_edit) && wp_verify_nonce($nonce, 'edit-aioseop-nonce')) {
1076
- $keywords = $_POST["aiosp_keywords"];
1077
- $description = $_POST["aiosp_description"];
1078
- $title = $_POST["aiosp_title"];
1079
- $aiosp_meta = $_POST["aiosp_meta"];
1080
- $aiosp_disable = $_POST["aiosp_disable"];
1081
- $aiosp_titleatr = $_POST["aiosp_titleatr"];
1082
- $aiosp_menulabel = $_POST["aiosp_menulabel"];
1083
-
1084
- delete_post_meta($id, '_aioseop_keywords');
1085
- delete_post_meta($id, '_aioseop_description');
1086
- delete_post_meta($id, '_aioseop_title');
1087
- delete_post_meta($id, '_aioseop_titleatr');
1088
- delete_post_meta($id, '_aioseop_menulabel');
1089
-
1090
-
1091
- if ($this->is_admin()) {
1092
- delete_post_meta($id, '_aioseop_disable');
1093
- }
1094
- //delete_post_meta($id, 'aiosp_meta');
1095
-
1096
- if (isset($keywords) && !empty($keywords)) {
1097
- add_post_meta($id, '_aioseop_keywords', $keywords);
1098
- }
1099
- if (isset($description) && !empty($description)) {
1100
- add_post_meta($id, '_aioseop_description', $description);
1101
- }
1102
- if (isset($title) && !empty($title)) {
1103
- add_post_meta($id, '_aioseop_title', $title);
1104
- }
1105
- if (isset($aiosp_titleatr) && !empty($aiosp_titleatr)) {
1106
- add_post_meta($id, '_aioseop_titleatr', $aiosp_titleatr);
1107
- }
1108
- if (isset($aiosp_menulabel) && !empty($aiosp_menulabel)) {
1109
- add_post_meta($id, '_aioseop_menulabel', $aiosp_menulabel);
1110
- }
1111
- if (isset($aiosp_disable) && !empty($aiosp_disable) && $this->is_admin()) {
1112
- add_post_meta($id, '_aioseop_disable', $aiosp_disable);
1113
- }
1114
- /*
1115
- if (isset($aiosp_meta) && !empty($aiosp_meta)) {
1116
- add_post_meta($id, 'aiosp_meta', $aiosp_meta);
1117
- }
1118
- */
1119
- }
1120
- }
1121
-
1122
- function edit_category($id) {
1123
- global $wpdb;
1124
- $id = $wpdb->escape($id);
1125
- $awmp_edit = $_POST["aiosp_edit"];
1126
- if (isset($awmp_edit) && !empty($awmp_edit)) {
1127
- $keywords = $wpdb->escape($_POST["aiosp_keywords"]);
1128
- $title = $wpdb->escape($_POST["aiosp_title"]);
1129
- $old_category = $wpdb->get_row("select * from $this->table_categories where category_id=$id", OBJECT);
1130
- if ($old_category) {
1131
- $wpdb->query($wpdb->prepare("update $this->table_categories
1132
- set meta_title='$title', meta_keywords='$keywords'
1133
- where category_id=$id"));
1134
- } else {
1135
- $wpdb->query($wpdb->prepare("insert into $this->table_categories(meta_title, meta_keywords, category_id)
1136
- values ('$title', '$keywords', $id"));
1137
- }
1138
- //$wpdb->query($wpdb->prepare("insert into $this->table_categories"))
1139
- /*
1140
- delete_post_meta($id, 'keywords');
1141
- delete_post_meta($id, 'description');
1142
- delete_post_meta($id, 'title');
1143
-
1144
- if (isset($keywords) && !empty($keywords)) {
1145
- add_post_meta($id, 'keywords', $keywords);
1146
- }
1147
- if (isset($description) && !empty($description)) {
1148
- add_post_meta($id, 'description', $description);
1149
- }
1150
- if (isset($title) && !empty($title)) {
1151
- add_post_meta($id, 'title', $title);
1152
- }
1153
- */
1154
- }
1155
- }
1156
-
1157
- /**
1158
- * @deprecated This was for the feature of dedicated meta tags for categories which never went mainstream.
1159
- */
1160
- function edit_category_form() {
1161
- global $post;
1162
- $keywords = stripcslashes(get_post_meta($post->ID, '_aioseop_keywords', true));
1163
- $title = stripcslashes(get_post_meta($post->ID, '_aioseop_title', true));
1164
- $description = stripcslashes(get_post_meta($post->ID, '_aioseop_description', true));
1165
- ?>
1166
- <input value="aiosp_edit" type="hidden" name="aiosp_edit" />
1167
- <table class="editform" width="100%" cellspacing="2" cellpadding="5">
1168
- <tr>
1169
- <th width="33%" scope="row" valign="top">
1170
- <a href="http://wp.uberdose.com/2007/03/24/all-in-one-seo-pack/"><?php _e('All in One SEO Pack', 'all_in_one_seo_pack') ?></a>
1171
- </th>
1172
- </tr>
1173
- <tr>
1174
- <th width="33%" scope="row" valign="top"><label for="aiosp_title"><?php _e('Title:', 'all_in_one_seo_pack') ?></label></th>
1175
- <td><input value="<?php echo $title ?>" type="text" name="aiosp_title" size="70"/></td>
1176
- </tr>
1177
- <tr>
1178
- <th width="33%" scope="row" valign="top"><label for="aiosp_keywords"><?php _e('Keywords (comma separated):', 'all_in_one_seo_pack') ?></label></th>
1179
- <td><input value="<?php echo $keywords ?>" type="text" name="aiosp_keywords" size="70"/></td>
1180
- </tr>
1181
- </table>
1182
- <?php
1183
- }
1184
-
1185
- function add_meta_tags_textinput() {
1186
- global $post;
1187
- $post_id = $post;
1188
- if (is_object($post_id)) {
1189
- $post_id = $post_id->ID;
1190
- }
1191
- $keywords = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_keywords', true)));
1192
- $title = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_title', true)));
1193
- $description = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_description', true)));
1194
- $aiosp_meta = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_meta', true)));
1195
- $aiosp_disable = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_disable', true)));
1196
- $aiosp_titleatr = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_titleatr', true)));
1197
- $aiosp_menulabel = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_menulabel', true)));
1198
-
1199
- ?>
1200
- <SCRIPT LANGUAGE="JavaScript">
1201
- <!-- Begin
1202
- function countChars(field,cntfield) {
1203
- cntfield.value = field.value.length;
1204
- }
1205
- // End -->
1206
- </script>
1207
-
1208
- <?php if (substr($this->wp_version, 0, 3) >= '2.5') { ?>
1209
- <div id="postaiosp" class="postbox closed">
1210
- <h3><?php _e('All in One SEO Pack', 'all_in_one_seo_pack') ?></h3>
1211
- <div class="inside">
1212
- <div id="postaiosp">
1213
- <?php } else { ?>
1214
- <div class="dbx-b-ox-wrapper">
1215
- <fieldset id="seodiv" class="dbx-box">
1216
- <div class="dbx-h-andle-wrapper">
1217
- <h3 class="dbx-handle"><?php _e('All in One SEO Pack', 'all_in_one_seo_pack') ?></h3>
1218
- </div>
1219
- <div class="dbx-c-ontent-wrapper">
1220
- <div class="dbx-content">
1221
- <?php } ?>
1222
-
1223
- <a target="__blank" href="http://semperfiwebdesign.com/portfolio/wordpress/wordpress-plugins/all-in-one-seo-pack/"><?php _e('Click here for Support', 'all_in_one_seo_pack') ?></a>
1224
- <input value="aiosp_edit" type="hidden" name="aiosp_edit" />
1225
- <table style="margin-bottom:40px">
1226
- <tr>
1227
- <th style="text-align:left;" colspan="2">
1228
- </th>
1229
- </tr>
1230
- <tr>
1231
- <th scope="row" style="text-align:right;"><?php _e('Title:', 'all_in_one_seo_pack') ?></th>
1232
- <td><input value="<?php echo $title ?>" type="text" name="aiosp_title" size="62"/></td>
1233
- </tr>
1234
- <tr>
1235
- <th scope="row" style="text-align:right;"><?php _e('Description:', 'all_in_one_seo_pack') ?></th>
1236
- <td><textarea name="aiosp_description" rows="1" cols="60"
1237
- onKeyDown="countChars(document.post.aiosp_description,document.post.length1)"
1238
- onKeyUp="countChars(document.post.aiosp_description,document.post.length1)"><?php echo $description ?></textarea><br />
1239
- <input readonly type="text" name="length1" size="3" maxlength="3" value="<?php echo strlen($description);?>" />
1240
- <?php _e(' characters. Most search engines use a maximum of 160 chars for the description.', 'all_in_one_seo_pack') ?>
1241
- </td>
1242
- </tr>
1243
- <tr>
1244
- <th scope="row" style="text-align:right;"><?php _e('Keywords (comma separated):', 'all_in_one_seo_pack') ?></th>
1245
- <td><input value="<?php echo $keywords ?>" type="text" name="aiosp_keywords" size="62"/></td>
1246
- </tr>
1247
- <input type="hidden" name="nonce-aioseop-edit" value="<?php echo wp_create_nonce('edit-aioseop-nonce'); ?>" />
1248
- <?php if ($this->is_admin()) { ?>
1249
- <tr>
1250
- <th scope="row" style="text-align:right; vertical-align:top;">
1251
- <?php _e('Disable on this page/post:', 'all_in_one_seo_pack')?>
1252
- </th>
1253
- <td>
1254
- <input type="checkbox" name="aiosp_disable" <?php if ($aiosp_disable) echo "checked=\"1\""; ?>/>
1255
- </td>
1256
- </tr>
1257
-
1258
- <tr>
1259
- <th scope="row" style="text-align:right;"><?php _e('Title Attribute:', 'all_in_one_seo_pack') ?></th>
1260
- <td><input value="<?php echo $aiosp_titleatr ?>" type="text" name="aiosp_titleatr" size="62"/></td>
1261
- </tr>
1262
-
1263
- <tr>
1264
- <th scope="row" style="text-align:right;"><?php _e('Menu Label:', 'all_in_one_seo_pack') ?></th>
1265
- <td><input value="<?php echo $aiosp_menulabel ?>" type="text" name="aiosp_menulabel" size="62"/></td>
1266
- </tr>
1267
-
1268
-
1269
-
1270
-
1271
-
1272
-
1273
- <?php } ?>
1274
-
1275
- </table>
1276
-
1277
- <?php if (substr($this->wp_version, 0, 3) >= '2.5') { ?>
1278
- </div></div></div>
1279
- <?php } else { ?>
1280
- </div>
1281
- </fieldset>
1282
- </div>
1283
- <?php } ?>
1284
-
1285
- <?php
1286
- }
1287
-
1288
- function admin_menu() {
1289
- $file = __FILE__;
1290
-
1291
- // hack for 1.5
1292
- if (substr($this->wp_version, 0, 3) == '1.5') {
1293
- $file = 'all-in-one-seo-pack/all_in_one_seo_pack.php';
1294
- }
1295
- //add_management_page(__('All in One SEO Title', 'all_in_one_seo_pack'), __('All in One SEO', 'all_in_one_seo_pack'), 10, $file, array($this, 'management_panel'));
1296
- add_submenu_page('options-general.php', __('All in One SEO', 'all_in_one_seo_pack'), __('All in One SEO', 'all_in_one_seo_pack'), 10, $file, array($this, 'options_panel'));
1297
- }
1298
-
1299
- function management_panel() {
1300
- $message = null;
1301
- $base_url = "edit.php?page=" . __FILE__;
1302
- //echo($base_url);
1303
- $type = $_REQUEST['type'];
1304
- if (!isset($type)) {
1305
- $type = "posts";
1306
- }
1307
- ?>
1308
-
1309
- <ul class="aiosp_menu">
1310
- <li><a href="<?php echo $base_url ?>&type=posts">Posts</a>
1311
- </li>
1312
- <li><a href="<?php echo $base_url ?>&type=pages">Pages</a>
1313
- </li>
1314
- </ul>
1315
-
1316
- <?php
1317
-
1318
- if ($type == "posts") {
1319
- echo("posts");
1320
- } elseif ($type == "pages") {
1321
- echo("pages");
1322
- }
1323
-
1324
- }
1325
-
1326
- function options_panel() {
1327
- $message = null;
1328
- $message_updated = __("All in One SEO Options Updated.", 'all_in_one_seo_pack');
1329
- global $aioseop_options;
1330
-
1331
-
1332
- if(!$aioseop_options['aiosp_cap_cats']){
1333
- $aioseop_options['aiosp_cap_cats'] = '1';
1334
- }
1335
-
1336
- // update options
1337
- if ($_POST['action'] && $_POST['action'] == 'aiosp_update') {
1338
- $nonce = $_POST['nonce-aioseop'];
1339
- if (!wp_verify_nonce($nonce, 'aioseop-nonce')) die ( 'Security Check - If you receive this in error, log out and back in to WordPress');
1340
- $message = $message_updated;
1341
- $aioseop_options['aiosp_can'] = $_POST['aiosp_can'];
1342
- $aioseop_options['aiosp_donate'] = $_POST['aiosp_donate'];
1343
- $aioseop_options['aiosp_home_title'] = $_POST['aiosp_home_title'];
1344
- $aioseop_options['aiosp_home_description'] = $_POST['aiosp_home_description'];
1345
- $aioseop_options['aiosp_home_keywords'] = $_POST['aiosp_home_keywords'];
1346
- $aioseop_options['aiosp_max_words_excerpt'] = $_POST['aiosp_max_words_excerpt'];
1347
- $aioseop_options['aiosp_rewrite_titles'] = $_POST['aiosp_rewrite_titles'];
1348
- $aioseop_options['aiosp_post_title_format'] = $_POST['aiosp_post_title_format'];
1349
- $aioseop_options['aiosp_page_title_format'] = $_POST['aiosp_page_title_format'];
1350
- $aioseop_options['aiosp_category_title_format'] = $_POST['aiosp_category_title_format'];
1351
- $aioseop_options['aiosp_archive_title_format'] = $_POST['aiosp_archive_title_format'];
1352
- $aioseop_options['aiosp_tag_title_format'] = $_POST['aiosp_tag_title_format'];
1353
- $aioseop_options['aiosp_search_title_format'] = $_POST['aiosp_search_title_format'];
1354
- $aioseop_options['aiosp_description_format'] = $_POST['aiosp_description_format'];
1355
- $aioseop_options['aiosp_404_title_format'] = $_POST['aiosp_404_title_format'];
1356
- $aioseop_options['aiosp_paged_format'] = $_POST['aiosp_paged_format'];
1357
- $aioseop_options['aiosp_use_categories'] = $_POST['aiosp_use_categories'];
1358
- $aioseop_options['aiosp_dynamic_postspage_keywords'] = $_POST['aiosp_dynamic_postspage_keywords'];
1359
- $aioseop_options['aiosp_category_noindex'] = $_POST['aiosp_category_noindex'];
1360
- $aioseop_options['aiosp_archive_noindex'] = $_POST['aiosp_archive_noindex'];
1361
- $aioseop_options['aiosp_tags_noindex'] = $_POST['aiosp_tags_noindex'];
1362
- $aioseop_options['aiosp_generate_descriptions'] = $_POST['aiosp_generate_descriptions'];
1363
- $aioseop_options['aiosp_cap_cats'] = $_POST['aiosp_cap_cats'];
1364
- $aioseop_options['aiosp_debug_info'] = $_POST['aiosp_debug_info'];
1365
- $aioseop_options['aiosp_post_meta_tags'] = $_POST['aiosp_post_meta_tags'];
1366
- $aioseop_options['aiosp_page_meta_tags'] = $_POST['aiosp_page_meta_tags'];
1367
- $aioseop_options['aiosp_home_meta_tags'] = $_POST['aiosp_home_meta_tags'];
1368
- $aioseop_options['aiosp_ex_pages'] = $_POST['aiosp_ex_pages'];
1369
- $aioseop_options['aiosp_do_log'] = $_POST['aiosp_do_log'];
1370
- $aioseop_options['aiosp_enabled'] = $_POST['aiosp_enabled'];
1371
-
1372
- update_option('aioseop_options', $aioseop_options);
1373
-
1374
- if (function_exists('wp_cache_flush')) {
1375
- wp_cache_flush();
1376
- }
1377
- } /*elseif ($_POST['aiosp_upgrade']) {
1378
- $message = __("Upgraded to newest version. Please revisit the options page to make sure you see the newest version.", 'all_in_one_seo_pack');
1379
- $success = $this->install_newest_version();
1380
- if (!$success) {
1381
- $message = __("Upgrade failed", 'all_in_one_seo_pack');
1382
- if (isset($this->upgrade_error) && !empty($this->upgrade_error)) {
1383
- $message .= ": " . $this->upgrade_error;
1384
- } else {
1385
- $message .= ".";
1386
- }
1387
- }
1388
- }*/
1389
-
1390
- ?>
1391
- <?php if ($message) : ?>
1392
- <div id="message" class="updated fade"><p><?php echo $message; ?></p></div>
1393
- <?php endif; ?>
1394
- <div id="dropmessage" class="updated" style="display:none;"></div>
1395
- <div class="wrap">
1396
- <h2><?php _e('All in One SEO Plugin Options', 'all_in_one_seo_pack'); ?></h2>
1397
- <p>
1398
- <?php //_e("This is version ", 'all_in_one_seo_pack') ?><?php //_e("$this->version ", 'all_in_one_seo_pack') ?>
1399
- &nbsp;<a target="_blank" title="<?php _e('All in One SEO Plugin Release History', 'all_in_one_seo_pack')?>"
1400
- href="http://semperfiwebdesign.com/documentation/all-in-one-seo-pack/all-in-one-seo-pack-release-history/"><?php _e("Changelog", 'all_in_one_seo_pack')?>
1401
- </a>
1402
- | <a target="_blank" title="<?php _e('FAQ', 'all_in_one_seo_pack') ?>"
1403
- href="http://semperfiwebdesign.com/documentation/all-in-one-seo-pack/all-in-one-seo-faq/"><?php _e('FAQ', 'all_in_one_seo_pack') ?></a>
1404
- | <a target="_blank" title="<?php _e('All in One SEO Plugin Support Forum', 'all_in_one_seo_pack') ?>"
1405
- href="http://semperfiwebdesign.com/portfolio/wordpress/wordpress-plugins/forum/"><?php _e('Support', 'all_in_one_seo_pack') ?></a>
1406
- | <a target="_blank" title="<?php _e('All in One SEO Plugin Translations', 'all_in_one_seo_pack') ?>"
1407
- href="http://semperfiwebdesign.com/documentation/all-in-one-seo-pack/translations-for-all-in-one-seo-pack/"><?php _e('Translations', 'all_in_one_seo_pack') ?></a>
1408
- <br />
1409
- <div style="width:75%;background-color:yellow;">
1410
- <em>Thank you for using <strong>All in One SEO Pack</strong> by <strong>Michael Torbert</strong> of <strong>Semper Fi Web Design</strong>. If you like this plugin and find it useful, feel free to click the <strong>donate</strong> button or send me a gift from my <strong>Amazon wishlist</strong>. Also, don't forget to follow me on <strong>Twitter</strong>.</em>
1411
- </div>
1412
- <br />
1413
- <a target="_blank" title="<?php echo 'Donate' ?>"
1414
- href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=mrtorbert%40gmail%2ecom&item_name=All%20In%20One%20SEO%20Pack&item_number=Support%20Open%20Source&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8"><img src="https://www.paypal.com/en_US/i/btn/btn_donateCC_LG.gif" width="" alt="Donate" /><?php //echo 'Donate' ?></a>
1415
- | <a target="_blank" title="Amazon Wish List" href="https://www.amazon.com/wishlist/1NFQ133FNCOOA/ref=wl_web"><img src="https://images-na.ssl-images-amazon.com/images/G/01/gifts/registries/wishlist/v2/web/wl-btn-74-b._V46774601_.gif" width="74" alt="My Amazon.com Wish List" height="42" border="0" /></a>
1416
- | <a target="_blank" title="<?php _e('Follow us on Twitter', 'all_in_one_seo_pack') ?>"
1417
- href="http://twitter.com/michaeltorbert/"><img src="<?php echo WP_PLUGIN_URL; ?>/all-in-one-seo-pack/images/twitter.png" alt="<?php _e('Follow Us on Twitter', 'all_in_one_seo_pack') ?>" height="47px" /></a>
1418
-
1419
- </p>
1420
-
1421
-
1422
- <!--
1423
- <p>
1424
- <?php
1425
- //$canwrite = $this->is_upgrade_directory_writable();
1426
- //$canwrite = false;
1427
- ?>
1428
- <form class="form-table" name="dofollow" action="" method="post">
1429
- <p class="submit">
1430
- <input type="submit" <?php //if (!$canwrite) echo(' disabled="disabled" ');?> name="aiosp_upgrade" value="<?php //_e('One Click Upgrade', 'all_in_one_seo_pack')?> &raquo;" />
1431
- <strong><?php //_e("(Remember: Backup early, backup often!)", 'all_in_one_seo_pack') ?></strong>
1432
- </form>
1433
- </p>
1434
- <p></p>
1435
-
1436
-
1437
- <?php //if (!$canwrite) {
1438
- //echo("<p><strong>"); echo(sprintf(__("Please make sure that %s is writable.", 'all_in_one_seo_pack'), $this->upgrade_folder)); echo("</p></strong>");
1439
- // } ?>
1440
- </p>
1441
- -->
1442
-
1443
- <script type="text/javascript">
1444
- <!--
1445
- function toggleVisibility(id) {
1446
- var e = document.getElementById(id);
1447
- if(e.style.display == 'block')
1448
- e.style.display = 'none';
1449
- else
1450
- e.style.display = 'block';
1451
- }
1452
- //-->
1453
- </script>
1454
-
1455
- <h3><?php _e('Click on option titles to get help!', 'all_in_one_seo_pack') ?></h3>
1456
-
1457
- <?php
1458
- $uri = "feed://donations.semperfiwebdesign.com/category/highest-donations/feed/";
1459
- include_once(ABSPATH . WPINC . '/rss.php');
1460
- $rss = fetch_rss($uri);
1461
- if($rss){
1462
- echo "Highest Donations";
1463
- $maxitems = 5;
1464
- if(is_array($rss->items)){
1465
- $items = array_slice($rss->items, 0, $maxitems);
1466
- ?>
1467
- <ul>
1468
- <?php if (empty($items)) echo '<li>No items</li>';
1469
- else
1470
- foreach ( $items as $item ) : ?>
1471
- <li><a href='<?php echo $item['description']; ?>'
1472
- title='<?php echo $item['title']; ?>'>
1473
- <?php echo $item['title']; ?>
1474
- </a></li>
1475
- <?php endforeach; ?>
1476
- </ul>
1477
- <?php } }else{
1478
- //do something else for feed here
1479
- }
1480
-
1481
-
1482
- ?>
1483
-
1484
- <?php
1485
- $uri = "feed://donations.semperfiwebdesign.com/category/all-in-one-seo-pack/feed/";
1486
- include_once(ABSPATH . WPINC . '/rss.php');
1487
- $rss = fetch_rss($uri);
1488
- if($rss){
1489
- echo "Latest Donations";
1490
- $maxitems = 5;
1491
- if(is_array($rss->items)){
1492
- $items = array_slice($rss->items, 0, $maxitems);
1493
- ?>
1494
- <ul>
1495
- <?php if (empty($items)) echo '<li>No items</li>';
1496
- else
1497
- foreach ( $items as $item ) : ?>
1498
- <li><a href='<?php echo $item['link']; ?>'
1499
- title='<?php echo $item['title']; ?>'>
1500
- <?php echo $item['title']; ?>
1501
- </a></li>
1502
- <?php endforeach; ?>
1503
- </ul>
1504
- <?php } }else{
1505
- //fall back on something else for feed here
1506
- }?>
1507
-
1508
- <?php
1509
- global $wpdb;
1510
- $somecount = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key = 'keywords'");
1511
- $somecount = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key = 'title'") + $somecount;
1512
- $somecount = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key = 'description'") + $somecount;
1513
- $somecount = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key = 'aiosp_meta'") + $somecount;
1514
- $somecount = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key = 'aiosp_disable'") + $somecount;
1515
- if($somecount > 0){
1516
- echo "<div class='error' style='text-align:center;'><p><strong>Your database meta needs to be updated. " . $somecount . " old fields remaining</strong> <em>(Back up your database before updating.)</em>
1517
- <FORM action='' method='post' name='aioseop-migrate'>
1518
- <input type='hidden' name='nonce-aioseop-migrate' value='" . wp_create_nonce('aioseop-migrate-nonce') . "' />
1519
- <input type='submit' name='aioseop_migrate' class='button-primary' value='Update Database'>
1520
- </FORM>
1521
- </p></div>";
1522
- }
1523
-
1524
- if(!get_option('aioseop_options')){
1525
- echo "<div class='error' style='text-align:center;'><p><strong>Your database options need to be updated.</strong><em>(Back up your database before updating.)</em>
1526
- <FORM action='' method='post' name='aioseop-migrate-options'>
1527
- <input type='hidden' name='nonce-aioseop-migrate-options' value='" . wp_create_nonce('aioseop-migrate-nonce-options') . "' />
1528
- <input type='submit' name='aioseop_migrate_options' class='button-primary' value='Update Database Options'>
1529
- </FORM>
1530
- </p></div>";
1531
-
1532
- }
1533
-
1534
- ?>
1535
-
1536
-
1537
- <form name="dofollow" action="" method="post">
1538
- <table class="form-table">
1539
- <?php $aioseop_options = get_option('aioseop_options'); ?>
1540
- <?php if (!$aioseop_options['aiosp_donate']){?>
1541
- <tr>
1542
- <th scope="row" style="text-align:right; vertical-align:top;">
1543
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_donate_tip');">
1544
- <?php _e('I enjoy this plugin and have made a donation:', 'all_in_one_seo_pack')?>
1545
- </a>
1546
- </td>
1547
- <td>
1548
- <input type="checkbox" name="aiosp_donate" <?php if ($aioseop_options['aiosp_donate']) echo "checked=\"1\""; ?>/>
1549
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_donate_tip">
1550
- <?php
1551
- _e('All donations support continued development of this free software.', 'all_in_one_seo_pack');
1552
- ?>
1553
- </div>
1554
- </td>
1555
- </tr>
1556
- <?php } ?>
1557
-
1558
- <tr>
1559
- <th scope="row" style="text-align:right; vertical-align:top;">
1560
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_enabled_tip');">
1561
- <?php _e('Plugin Status:', 'all_in_one_seo_pack')?>
1562
- </a>
1563
- </td>
1564
- <td>
1565
- <input type="radio" name="aiosp_enabled" value="1" <?php if($aioseop_options['aiosp_enabled']) echo "checked"?> > Enabled<br>
1566
- <input type="radio" name="aiosp_enabled" value="0" <?php if(!$aioseop_options['aiosp_enabled']) echo "checked"?>> Disabled
1567
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_enabled_tip">
1568
- <?php
1569
- _e('All in One SEO Pack must be enabled for use.', 'all_in_one_seo_pack');
1570
- ?>
1571
- </div>
1572
- </td>
1573
- </tr>
1574
-
1575
- <tr>
1576
- <th scope="row" style="text-align:right; vertical-align:top;">
1577
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_home_title_tip');">
1578
- <?php _e('Home Title:', 'all_in_one_seo_pack')?>
1579
- </a>
1580
- </td>
1581
- <td>
1582
- <textarea cols="57" rows="2" name="aiosp_home_title"><?php echo stripcslashes($aioseop_options['aiosp_home_title']); ?></textarea>
1583
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_home_title_tip">
1584
- <?php
1585
- _e('As the name implies, this will be the title of your homepage. This is independent of any other option. If not set, the default blog title will get used.', 'all_in_one_seo_pack');
1586
- ?>
1587
- </div>
1588
- </td>
1589
- </tr>
1590
-
1591
- <tr>
1592
- <th scope="row" style="text-align:right; vertical-align:top;">
1593
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_home_description_tip');">
1594
- <?php _e('Home Description:', 'all_in_one_seo_pack')?>
1595
- </a>
1596
- </td>
1597
- <td>
1598
- <textarea cols="57" rows="2" name="aiosp_home_description"><?php echo stripcslashes($aioseop_options['aiosp_home_description']); ?></textarea>
1599
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_home_description_tip">
1600
- <?php
1601
- _e('The META description for your homepage. Independent of any other options, the default is no META description at all if this is not set.', 'all_in_one_seo_pack');
1602
- ?>
1603
- </div>
1604
- </td>
1605
- </tr>
1606
-
1607
- <tr>
1608
- <th scope="row" style="text-align:right; vertical-align:top;">
1609
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_home_keywords_tip');">
1610
- <?php _e('Home Keywords (comma separated):', 'all_in_one_seo_pack')?>
1611
- </a>
1612
- </td>
1613
- <td>
1614
- <textarea cols="57" rows="2" name="aiosp_home_keywords"><?php echo stripcslashes($aioseop_options['aiosp_home_keywords']); ?></textarea>
1615
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_home_keywords_tip">
1616
- <?php
1617
- _e("A comma separated list of your most important keywords for your site that will be written as META keywords on your homepage. Don't stuff everything in here.", 'all_in_one_seo_pack');
1618
- ?>
1619
- </div>
1620
- </td>
1621
- </tr>
1622
-
1623
- <tr>
1624
- <th scope="row" style="text-align:right; vertical-align:top;">
1625
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_can_tip');">
1626
- <?php _e('Canonical URLs:', 'all_in_one_seo_pack')?>
1627
- </a>
1628
- </td>
1629
- <td>
1630
- <input type="checkbox" name="aiosp_can" <?php if ($aioseop_options['aiosp_can']) echo "checked=\"1\""; ?>/>
1631
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_can_tip">
1632
- <?php
1633
- _e("This option will automatically generate Canonical URLS for your entire WordPress installation. This will help to prevent duplicate content penalties by <a href='http://googlewebmastercentral.blogspot.com/2009/02/specify-your-canonical.html' target='_blank'>Google</a>.", 'all_in_one_seo_pack');
1634
- ?>
1635
- </div>
1636
- </td>
1637
- </tr>
1638
-
1639
- <tr>
1640
- <th scope="row" style="text-align:right; vertical-align:top;">
1641
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_rewrite_titles_tip');">
1642
- <?php _e('Rewrite Titles:', 'all_in_one_seo_pack')?>
1643
- </a>
1644
- </td>
1645
- <td>
1646
- <input type="checkbox" name="aiosp_rewrite_titles" <?php if ($aioseop_options['aiosp_rewrite_titles']) echo "checked=\"1\""; ?>/>
1647
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_rewrite_titles_tip">
1648
- <?php
1649
- _e("Note that this is all about the title tag. This is what you see in your browser's window title bar. This is NOT visible on a page, only in the window title bar and of course in the source. If set, all page, post, category, search and archive page titles get rewritten. You can specify the format for most of them. For example: The default templates puts the title tag of posts like this: “Blog Archive >> Blog Name >> Post Title” (maybe I've overdone slightly). This is far from optimal. With the default post title format, Rewrite Title rewrites this to “Post Title | Blog Name”. If you have manually defined a title (in one of the text fields for All in One SEO Plugin input) this will become the title of your post in the format string.", 'all_in_one_seo_pack');
1650
- ?>
1651
- </div>
1652
- </td>
1653
- </tr>
1654
-
1655
- <tr>
1656
- <th scope="row" style="text-align:right; vertical-align:top;">
1657
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_post_title_format_tip');">
1658
- <?php _e('Post Title Format:', 'all_in_one_seo_pack')?>
1659
- </a>
1660
- </td>
1661
- <td>
1662
- <input size="59" name="aiosp_post_title_format" value="<?php echo stripcslashes($aioseop_options['aiosp_post_title_format']); ?>"/>
1663
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_post_title_format_tip">
1664
- <?php
1665
- _e('The following macros are supported:', 'all_in_one_seo_pack');
1666
- echo('<ul>');
1667
- echo('<li>'); _e('%blog_title% - Your blog title', 'all_in_one_seo_pack'); echo('</li>');
1668
- echo('<li>'); _e('%blog_description% - Your blog description', 'all_in_one_seo_pack'); echo('</li>');
1669
- echo('<li>'); _e('%post_title% - The original title of the post', 'all_in_one_seo_pack'); echo('</li>');
1670
- echo('<li>'); _e('%category_title% - The (main) category of the post', 'all_in_one_seo_pack'); echo('</li>');
1671
- echo('<li>'); _e('%category% - Alias for %category_title%', 'all_in_one_seo_pack'); echo('</li>');
1672
- echo('<li>'); _e("%post_author_login% - This post's author' login", 'all_in_one_seo_pack'); echo('</li>');
1673
- echo('<li>'); _e("%post_author_nicename% - This post's author' nicename", 'all_in_one_seo_pack'); echo('</li>');
1674
- echo('<li>'); _e("%post_author_firstname% - This post's author' first name (capitalized)", 'all_in_one_seo_pack'); echo('</li>');
1675
- echo('<li>'); _e("%post_author_lastname% - This post's author' last name (capitalized)", 'all_in_one_seo_pack'); echo('</li>');
1676
- echo('</ul>');
1677
- ?>
1678
- </div>
1679
- </td>
1680
- </tr>
1681
-
1682
- <tr>
1683
- <th scope="row" style="text-align:right; vertical-align:top;">
1684
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_page_title_format_tip');">
1685
- <?php _e('Page Title Format:', 'all_in_one_seo_pack')?>
1686
- </a>
1687
- </td>
1688
- <td>
1689
- <input size="59" name="aiosp_page_title_format" value="<?php echo stripcslashes($aioseop_options['aiosp_page_title_format']); ?>"/>
1690
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_page_title_format_tip">
1691
- <?php
1692
- _e('The following macros are supported:', 'all_in_one_seo_pack');
1693
- echo('<ul>');
1694
- echo('<li>'); _e('%blog_title% - Your blog title', 'all_in_one_seo_pack'); echo('</li>');
1695
- echo('<li>'); _e('%blog_description% - Your blog description', 'all_in_one_seo_pack'); echo('</li>');
1696
- echo('<li>'); _e('%page_title% - The original title of the page', 'all_in_one_seo_pack'); echo('</li>');
1697
- echo('<li>'); _e("%page_author_login% - This page's author' login", 'all_in_one_seo_pack'); echo('</li>');
1698
- echo('<li>'); _e("%page_author_nicename% - This page's author' nicename", 'all_in_one_seo_pack'); echo('</li>');
1699
- echo('<li>'); _e("%page_author_firstname% - This page's author' first name (capitalized)", 'all_in_one_seo_pack'); echo('</li>');
1700
- echo('<li>'); _e("%page_author_lastname% - This page's author' last name (capitalized)", 'all_in_one_seo_pack'); echo('</li>');
1701
- echo('</ul>');
1702
- ?>
1703
- </div>
1704
- </td>
1705
- </tr>
1706
-
1707
- <tr>
1708
- <th scope="row" style="text-align:right; vertical-align:top;">
1709
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_category_title_format_tip');">
1710
- <?php _e('Category Title Format:', 'all_in_one_seo_pack')?>
1711
- </a>
1712
- </td>
1713
- <td>
1714
- <input size="59" name="aiosp_category_title_format" value="<?php echo stripcslashes($aioseop_options['aiosp_category_title_format']); ?>"/>
1715
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_category_title_format_tip">
1716
- <?php
1717
- _e('The following macros are supported:', 'all_in_one_seo_pack');
1718
- echo('<ul>');
1719
- echo('<li>'); _e('%blog_title% - Your blog title', 'all_in_one_seo_pack'); echo('</li>');
1720
- echo('<li>'); _e('%blog_description% - Your blog description', 'all_in_one_seo_pack'); echo('</li>');
1721
- echo('<li>'); _e('%category_title% - The original title of the category', 'all_in_one_seo_pack'); echo('</li>');
1722
- echo('<li>'); _e('%category_description% - The description of the category', 'all_in_one_seo_pack'); echo('</li>');
1723
- echo('</ul>');
1724
- ?>
1725
- </div>
1726
- </td>
1727
- </tr>
1728
-
1729
- <tr>
1730
- <th scope="row" style="text-align:right; vertical-align:top;">
1731
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_archive_title_format_tip');">
1732
- <?php _e('Archive Title Format:', 'all_in_one_seo_pack')?>
1733
- </a>
1734
- </td>
1735
- <td>
1736
- <input size="59" name="aiosp_archive_title_format" value="<?php echo stripcslashes($aioseop_options['aiosp_archive_title_format']); ?>"/>
1737
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_archive_title_format_tip">
1738
- <?php
1739
- _e('The following macros are supported:', 'all_in_one_seo_pack');
1740
- echo('<ul>');
1741
- echo('<li>'); _e('%blog_title% - Your blog title', 'all_in_one_seo_pack'); echo('</li>');
1742
- echo('<li>'); _e('%blog_description% - Your blog description', 'all_in_one_seo_pack'); echo('</li>');
1743
- echo('<li>'); _e('%date% - The original archive title given by wordpress, e.g. "2007" or "2007 August"', 'all_in_one_seo_pack'); echo('</li>');
1744
- echo('</ul>');
1745
- ?>
1746
- </div>
1747
- </td>
1748
- </tr>
1749
-
1750
- <tr>
1751
- <th scope="row" style="text-align:right; vertical-align:top;">
1752
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_tag_title_format_tip');">
1753
- <?php _e('Tag Title Format:', 'all_in_one_seo_pack')?>
1754
- </a>
1755
- </td>
1756
- <td>
1757
- <input size="59" name="aiosp_tag_title_format" value="<?php echo stripcslashes($aioseop_options['aiosp_tag_title_format']); ?>"/>
1758
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_tag_title_format_tip">
1759
- <?php
1760
- _e('The following macros are supported:', 'all_in_one_seo_pack');
1761
- echo('<ul>');
1762
- echo('<li>'); _e('%blog_title% - Your blog title', 'all_in_one_seo_pack'); echo('</li>');
1763
- echo('<li>'); _e('%blog_description% - Your blog description', 'all_in_one_seo_pack'); echo('</li>');
1764
- echo('<li>'); _e('%tag% - The name of the tag', 'all_in_one_seo_pack'); echo('</li>');
1765
- echo('</ul>');
1766
- ?>
1767
- </div>
1768
- </td>
1769
- </tr>
1770
-
1771
- <tr>
1772
- <th scope="row" style="text-align:right; vertical-align:top;">
1773
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_search_title_format_tip');">
1774
- <?php _e('Search Title Format:', 'all_in_one_seo_pack')?>
1775
- </a>
1776
- </td>
1777
- <td>
1778
- <input size="59" name="aiosp_search_title_format" value="<?php echo stripcslashes($aioseop_options['aiosp_search_title_format']); ?>"/>
1779
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_search_title_format_tip">
1780
- <?php
1781
- _e('The following macros are supported:', 'all_in_one_seo_pack');
1782
- echo('<ul>');
1783
- echo('<li>'); _e('%blog_title% - Your blog title', 'all_in_one_seo_pack'); echo('</li>');
1784
- echo('<li>'); _e('%blog_description% - Your blog description', 'all_in_one_seo_pack'); echo('</li>');
1785
- echo('<li>'); _e('%search% - What was searched for', 'all_in_one_seo_pack'); echo('</li>');
1786
- echo('</ul>');
1787
- ?>
1788
- </div>
1789
- </td>
1790
- </tr>
1791
-
1792
- <tr>
1793
- <th scope="row" style="text-align:right; vertical-align:top;">
1794
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_description_format_tip');">
1795
- <?php _e('Description Format:', 'all_in_one_seo_pack')?>
1796
- </a>
1797
- </td>
1798
- <td>
1799
- <input size="59" name="aiosp_description_format" value="<?php echo stripcslashes($aioseop_options['aiosp_description_format']); ?>"/>
1800
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_description_format_tip">
1801
- <?php
1802
- _e('The following macros are supported:', 'all_in_one_seo_pack');
1803
- echo('<ul>');
1804
- echo('<li>'); _e('%blog_title% - Your blog title', 'all_in_one_seo_pack'); echo('</li>');
1805
- echo('<li>'); _e('%blog_description% - Your blog description', 'all_in_one_seo_pack'); echo('</li>');
1806
- echo('<li>'); _e('%description% - The original description as determined by the plugin, e.g. the excerpt if one is set or an auto-generated one if that option is set', 'all_in_one_seo_pack'); echo('</li>');
1807
- echo('<li>'); _e('%wp_title% - The original wordpress title, e.g. post_title for posts', 'all_in_one_seo_pack'); echo('</li>');
1808
- echo('</ul>');
1809
- ?>
1810
- </div>
1811
- </td>
1812
- </tr>
1813
-
1814
- <tr>
1815
- <th scope="row" style="text-align:right; vertical-align:top;">
1816
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_404_title_format_tip');">
1817
- <?php _e('404 Title Format:', 'all_in_one_seo_pack')?>
1818
- </a>
1819
- </td>
1820
- <td>
1821
- <input size="59" name="aiosp_404_title_format" value="<?php echo stripcslashes($aioseop_options['aiosp_404_title_format']); ?>"/>
1822
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_404_title_format_tip">
1823
- <?php
1824
- _e('The following macros are supported:', 'all_in_one_seo_pack');
1825
- echo('<ul>');
1826
- echo('<li>'); _e('%blog_title% - Your blog title', 'all_in_one_seo_pack'); echo('</li>');
1827
- echo('<li>'); _e('%blog_description% - Your blog description', 'all_in_one_seo_pack'); echo('</li>');
1828
- echo('<li>'); _e('%request_url% - The original URL path, like "/url-that-does-not-exist/"', 'all_in_one_seo_pack'); echo('</li>');
1829
- echo('<li>'); _e('%request_words% - The URL path in human readable form, like "Url That Does Not Exist"', 'all_in_one_seo_pack'); echo('</li>');
1830
- echo('<li>'); _e('%404_title% - Additional 404 title input"', 'all_in_one_seo_pack'); echo('</li>');
1831
- echo('</ul>');
1832
- ?>
1833
- </div>
1834
- </td>
1835
- </tr>
1836
-
1837
- <tr>
1838
- <th scope="row" style="text-align:right; vertical-align:top;">
1839
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_paged_format_tip');">
1840
- <?php _e('Paged Format:', 'all_in_one_seo_pack')?>
1841
- </a>
1842
- </td>
1843
- <td>
1844
- <input size="59" name="aiosp_paged_format" value="<?php echo stripcslashes($aioseop_options['aiosp_paged_format']); ?>"/>
1845
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_paged_format_tip">
1846
- <?php
1847
- _e('This string gets appended/prepended to titles when they are for paged index pages (like home or archive pages).', 'all_in_one_seo_pack');
1848
- _e('The following macros are supported:', 'all_in_one_seo_pack');
1849
- echo('<ul>');
1850
- echo('<li>'); _e('%page% - The page number', 'all_in_one_seo_pack'); echo('</li>');
1851
- echo('</ul>');
1852
- ?>
1853
- </div>
1854
- </td>
1855
- </tr>
1856
-
1857
- <tr>
1858
- <th scope="row" style="text-align:right; vertical-align:top;">
1859
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_use_categories_tip');">
1860
- <?php _e('Use Categories for META keywords:', 'all_in_one_seo_pack')?>
1861
- </td>
1862
- <td>
1863
- <input type="checkbox" name="aiosp_use_categories" <?php if ($aioseop_options['aiosp_use_categories']) echo "checked=\"1\""; ?>/>
1864
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_use_categories_tip">
1865
- <?php
1866
- _e('Check this if you want your categories for a given post used as the META keywords for this post (in addition to any keywords and tags you specify on the post edit page).', 'all_in_one_seo_pack');
1867
- ?>
1868
- </div>
1869
- </td>
1870
- </tr>
1871
-
1872
- <tr>
1873
- <th scope="row" style="text-align:right; vertical-align:top;">
1874
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_dynamic_postspage_keywords_tip');">
1875
- <?php _e('Dynamically Generate Keywords for Posts Page:', 'all_in_one_seo_pack')?>
1876
- </td>
1877
- <td>
1878
- <input type="checkbox" name="aiosp_dynamic_postspage_keywords" <?php if ($aioseop_options['aiosp_dynamic_postspage_keywords']) echo "checked=\"1\""; ?>/>
1879
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_dynamic_postspage_keywords_tip">
1880
- <?php
1881
- _e('Check this if you want your keywords on a custom posts page (set it in options->reading) to be dynamically generated from the keywords of the posts showing on that page. If unchecked, it will use the keywords set in the edit page screen for the posts page.', 'all_in_one_seo_pack');
1882
- ?>
1883
- </div>
1884
- </td>
1885
- </tr>
1886
-
1887
- <tr>
1888
- <th scope="row" style="text-align:right; vertical-align:top;">
1889
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_category_noindex_tip');">
1890
- <?php _e('Use noindex for Categories:', 'all_in_one_seo_pack')?>
1891
- </a>
1892
- </td>
1893
- <td>
1894
- <input type="checkbox" name="aiosp_category_noindex" <?php if ($aioseop_options['aiosp_category_noindex']) echo "checked=\"1\""; ?>/>
1895
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_category_noindex_tip">
1896
- <?php
1897
- _e('Check this for excluding category pages from being crawled. Useful for avoiding duplicate content.', 'all_in_one_seo_pack');
1898
- ?>
1899
- </div>
1900
- </td>
1901
- </tr>
1902
-
1903
- <tr>
1904
- <th scope="row" style="text-align:right; vertical-align:top;">
1905
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_archive_noindex_tip');">
1906
- <?php _e('Use noindex for Archives:', 'all_in_one_seo_pack')?>
1907
- </a>
1908
- </td>
1909
- <td>
1910
- <input type="checkbox" name="aiosp_archive_noindex" <?php if ($aioseop_options['aiosp_archive_noindex']) echo "checked=\"1\""; ?>/>
1911
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_archive_noindex_tip">
1912
- <?php
1913
- _e('Check this for excluding archive pages from being crawled. Useful for avoiding duplicate content.', 'all_in_one_seo_pack');
1914
- ?>
1915
- </div>
1916
- </td>
1917
- </tr>
1918
-
1919
- <tr>
1920
- <th scope="row" style="text-align:right; vertical-align:top;">
1921
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_tags_noindex_tip');">
1922
- <?php _e('Use noindex for Tag Archives:', 'all_in_one_seo_pack')?>
1923
- </a>
1924
- </td>
1925
- <td>
1926
- <input type="checkbox" name="aiosp_tags_noindex" <?php if ($aioseop_options['aiosp_tags_noindex']) echo "checked=\"1\""; ?>/>
1927
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_tags_noindex_tip">
1928
- <?php
1929
- _e('Check this for excluding tag pages from being crawled. Useful for avoiding duplicate content.', 'all_in_one_seo_pack');
1930
- ?>
1931
- </div>
1932
- </td>
1933
- </tr>
1934
-
1935
- <tr>
1936
- <th scope="row" style="text-align:right; vertical-align:top;">
1937
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_generate_descriptions_tip');">
1938
- <?php _e('Autogenerate Descriptions:', 'all_in_one_seo_pack')?>
1939
- </a>
1940
- </td>
1941
- <td>
1942
- <input type="checkbox" name="aiosp_generate_descriptions" <?php if ($aioseop_options['aiosp_generate_descriptions']) echo "checked=\"1\""; ?>/>
1943
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_generate_descriptions_tip">
1944
- <?php
1945
- _e("Check this and your META descriptions will get autogenerated if there's no excerpt.", 'all_in_one_seo_pack');
1946
- ?>
1947
- </div>
1948
- </td>
1949
- </tr>
1950
-
1951
- <tr>
1952
- <th scope="row" style="text-align:right; vertical-align:top;">
1953
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_cap_cats_tip');">
1954
- <?php _e('Capitalize Category Titles:', 'all_in_one_seo_pack')?>
1955
- </a>
1956
- </td>
1957
- <td>
1958
- <input type="checkbox" name="aiosp_cap_cats" <?php if ($aioseop_options['aiosp_cap_cats']) echo "checked=\"1\""; ?>/>
1959
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_cap_cats_tip">
1960
- <?php
1961
- _e("Check this and Category Titles will have the first letter of each word capitalized.", 'all_in_one_seo_pack');
1962
- ?>
1963
- </div>
1964
- </td>
1965
- </tr>
1966
-
1967
- <!-- new crap start -->
1968
- <tr>
1969
- <th scope="row" style="text-align:right; vertical-align:top;">
1970
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_ex_pages_tip');">
1971
- <?php _e('Exclude Pages:', 'all_in_one_seo_pack')?>
1972
- </a>
1973
- </td>
1974
- <td>
1975
- <textarea cols="57" rows="2" name="aiosp_ex_pages"><?php echo stripcslashes($aioseop_options['aiosp_ex_pages']); ?></textarea>
1976
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_ex_pages_tip">
1977
- <?php
1978
- _e("Enter any comma separated pages here to be excluded by All in One SEO Pack. This is helpful when using plugins which generate their own non-WordPress dynamic pages. Ex: <em>/forum/,/contact/</em> For instance, if you want to exclude the virtual pages generated by a forum plugin, all you have to do is give forum or /forum or /forum/ or and any URL with the word \"forum\" in it, such as http://mysite.com/forum or http://mysite.com/forum/someforumpage will be excluded from All in One SEO Pack.", 'all_in_one_seo_pack');
1979
- ?>
1980
- </div>
1981
- </td>
1982
- </tr>
1983
- <!-- new crap end -->
1984
-
1985
- <tr>
1986
- <th scope="row" style="text-align:right; vertical-align:top;">
1987
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_post_meta_tags_tip');">
1988
- <?php _e('Additional Post Headers:', 'all_in_one_seo_pack')?>
1989
- </a>
1990
- </td>
1991
- <td>
1992
- <textarea cols="57" rows="2" name="aiosp_post_meta_tags"><?php echo stripcslashes($aioseop_options['aiosp_post_meta_tags']); ?></textarea>
1993
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_post_meta_tags_tip">
1994
- <?php
1995
- _e('What you enter here will be copied verbatim to your header on post pages. You can enter whatever additional headers you want here, even references to stylesheets.', 'all_in_one_seo_pack');
1996
- ?>
1997
- </div>
1998
- </td>
1999
- </tr>
2000
-
2001
- <tr>
2002
- <th scope="row" style="text-align:right; vertical-align:top;">
2003
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_page_meta_tags_tip');">
2004
- <?php _e('Additional Page Headers:', 'all_in_one_seo_pack')?>
2005
- </a>
2006
- </td>
2007
- <td>
2008
- <textarea cols="57" rows="2" name="aiosp_page_meta_tags"><?php echo stripcslashes($aioseop_options['aiosp_page_meta_tags']); ?></textarea>
2009
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_page_meta_tags_tip">
2010
- <?php
2011
- _e('What you enter here will be copied verbatim to your header on pages. You can enter whatever additional headers you want here, even references to stylesheets.', 'all_in_one_seo_pack');
2012
- ?>
2013
- </div>
2014
- </td>
2015
- </tr>
2016
-
2017
- <tr>
2018
- <th scope="row" style="text-align:right; vertical-align:top;">
2019
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_home_meta_tags_tip');">
2020
- <?php _e('Additional Home Headers:', 'all_in_one_seo_pack')?>
2021
- </a>
2022
- </td>
2023
- <td>
2024
- <textarea cols="57" rows="2" name="aiosp_home_meta_tags"><?php echo stripcslashes($aioseop_options['aiosp_home_meta_tags']); ?></textarea>
2025
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_home_meta_tags_tip">
2026
- <?php
2027
- _e('What you enter here will be copied verbatim to your header on the home page. You can enter whatever additional headers you want here, even references to stylesheets.', 'all_in_one_seo_pack');
2028
- ?>
2029
- </div>
2030
- </td>
2031
- </tr>
2032
-
2033
- <tr>
2034
- <th scope="row" style="text-align:right; vertical-align:top;">
2035
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'auto_social')?>" onclick="toggleVisibility('aiosp_do_log_tip');">
2036
- <?php _e('Log important events:', 'all_in_one_seo_pack')?>
2037
- </a>
2038
- </td>
2039
- <td>
2040
- <input type="checkbox" name="aiosp_do_log" <?php if ($aioseop_options['aiosp_do_log']) echo "checked=\"1\""; ?>/>
2041
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_do_log_tip">
2042
- <?php
2043
- _e('Check this and SEO pack will create a log of important events (all_in_one_seo_pack.log) in its plugin directory which might help debugging it. Make sure this directory is writable.', 'all_in_one_seo_pack');
2044
- ?>
2045
- </div>
2046
- </td>
2047
- </tr>
2048
-
2049
- <?php if ($aioseop_options['aiosp_donate']){?>
2050
- <tr>
2051
- <th scope="row" style="text-align:right; vertical-align:top;">
2052
- <a style="cursor:pointer;" title="<?php _e('Click for Help!', 'all_in_one_seo_pack')?>" onclick="toggleVisibility('aiosp_donate_tip');">
2053
- <?php _e('Thank you for your donation:', 'all_in_one_seo_pack')?>
2054
- </a>
2055
- </td>
2056
- <td>
2057
- <input type="checkbox" name="aiosp_donate" <?php if ($aioseop_options['aiosp_donate']) echo "checked=\"1\""; ?>/>
2058
- <div style="max-width:500px; text-align:left; display:none" id="aiosp_donate_tip">
2059
- <?php
2060
- _e('All donations support continued development of this free software.', 'all_in_one_seo_pack');
2061
- ?>
2062
- </div>
2063
- </td>
2064
- </tr>
2065
- <?php } ?>
2066
-
2067
- </table>
2068
- <p class="submit">
2069
- <?php if($aioseop_options) { ?>
2070
-
2071
- <input type="hidden" name="action" value="aiosp_update" />
2072
- <input type="hidden" name="nonce-aioseop" value="<?php echo wp_create_nonce('aioseop-nonce'); ?>" />
2073
- <input type="hidden" name="page_options" value="aiosp_home_description" />
2074
- <input type="submit" class='button-primary' name="Submit" value="<?php _e('Update Options', 'all_in_one_seo_pack')?> &raquo;" />
2075
- </p>
2076
- <?php } ?>
2077
-
2078
- <p><br />
2079
- <strong>Check out these other great plugins!</strong><br />
2080
- <a href="http://semperfiwebdesign.com/custom-applications/sms-text-message/" title="SMS Text Message WordPress plugin">SMS Text Message</a> - sends SMS updates to your readers<br />
2081
- <a href="http://semperfiwebdesign.com/custom-applications/wp-security-scan/" title="WordPress Security">WordPress Security Scan</a> - provides vital security for your WordPress site
2082
- </p>
2083
- </form>
2084
- </div>
2085
- <?php
2086
-
2087
- } // options_panel
2088
-
2089
- }
2090
-
2091
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/all_in_one_seo_pack-bg_BG.mo DELETED
Binary file
trunk/all_in_one_seo_pack-bg_NO.mo DELETED
Binary file
trunk/all_in_one_seo_pack-da_DK.mo DELETED
Binary file
trunk/all_in_one_seo_pack-de_DE.mo DELETED
Binary file
trunk/all_in_one_seo_pack-es_ES.mo DELETED
Binary file
trunk/all_in_one_seo_pack-fr_FR.mo DELETED
Binary file
trunk/all_in_one_seo_pack-he_IL.mo DELETED
Binary file
trunk/all_in_one_seo_pack-hu_HU.mo DELETED
Binary file
trunk/all_in_one_seo_pack-it_IT.mo DELETED
Binary file
trunk/all_in_one_seo_pack-ja.mo DELETED
Binary file
trunk/all_in_one_seo_pack-nl_NL.mo DELETED
Binary file
trunk/all_in_one_seo_pack-pl_PL.mo DELETED
Binary file
trunk/all_in_one_seo_pack-pt_BR.mo DELETED
Binary file
trunk/all_in_one_seo_pack-ru_RU.mo DELETED
Binary file
trunk/all_in_one_seo_pack-tr_TR.mo DELETED
Binary file
trunk/all_in_one_seo_pack-uk.mo DELETED
Binary file
trunk/all_in_one_seo_pack-zh_CN.mo DELETED
Binary file
trunk/all_in_one_seo_pack-zh_TW.mo DELETED
Binary file
trunk/all_in_one_seo_pack.php DELETED
@@ -1,775 +0,0 @@
1
- <?php
2
-
3
- /*
4
- Plugin Name: All in One SEO Pack
5
- Plugin URI: http://semperfiwebdesign.com
6
- Description: Out-of-the-box SEO for your Wordpress blog. <a href="options-general.php?page=all-in-one-seo-pack/aioseop.class.php">Options configuration panel</a> | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=mrtorbert%40gmail%2ecom&item_name=All%20In%20One%20SEO%20Pack&item_number=Support%20Open%20Source&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8">Donate</a> | <a href="http://semperfiwebdesign.com/forum/" >Support</a> | <a href="https://www.amazon.com/wishlist/1NFQ133FNCOOA/ref=wl_web" target="_blank" title="Amazon Wish List">Amazon Wishlist</a>
7
- Version: 1.6.5
8
- Author: Michael Torbert
9
- Author URI: http://michaeltorbert.com
10
- */
11
-
12
- /*
13
- Copyright (C) 2008-2009 Michael Torbert, semperfiwebdesign.com (michael AT semperfiwebdesign DOT com)
14
- Original code by uberdose of uberdose.com
15
-
16
- This program is free software; you can redistribute it and/or modify
17
- it under the terms of the GNU General Public License as published by
18
- the Free Software Foundation; either version 3 of the License, or
19
- (at your option) any later version.
20
-
21
- This program is distributed in the hope that it will be useful,
22
- but WITHOUT ANY WARRANTY; without even the implied warranty of
23
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
- GNU General Public License for more details.
25
-
26
- You should have received a copy of the GNU General Public License
27
- along with this program. If not, see <http://www.gnu.org/licenses/>.
28
- */
29
-
30
- /*******************************************************************************************************/
31
- register_activation_hook(__FILE__,'aioseop_activate_pl');
32
-
33
- $UTF8_TABLES['strtolower'] = array(
34
- "Z" => "z", "Y" => "y", "X" => "x",
35
- "W" => "w", "V" => "v", "U" => "u",
36
- "T" => "t", "S" => "s", "R" => "r",
37
- "Q" => "q", "P" => "p", "O" => "o",
38
- "N" => "n", "M" => "m", "L" => "l",
39
- "K" => "k", "J" => "j", "I" => "i",
40
- "H" => "h", "G" => "g", "F" => "f",
41
- "E" => "e", "D" => "d", "C" => "c",
42
- "B" => "b", "A" => "a", "Å" => "å",
43
- "K" => "k", "Ω" => "ω", "Ώ" => "ώ",
44
- "Ὼ" => "ὼ", "Ό" => "ό", "Ὸ" => "ὸ",
45
- "Ῥ" => "ῥ", "Ύ" => "ύ", "Ὺ" => "ὺ",
46
- "Ῡ" => "ῡ", "Ῠ" => "� ", "Ί" => "ί",
47
- "Ὶ" => "ὶ", "Ῑ" => "ῑ", "Ῐ" => "ῐ",
48
- "Ή" => "ή", "Ὴ" => "ὴ", "Έ" => "έ",
49
- "Ὲ" => "ὲ", "Ά" => "ά", "Ὰ" => "ὰ",
50
- "Ᾱ" => "ᾱ", "Ᾰ" => "ᾰ", "Ὧ" => "ὧ",
51
- "Ὦ" => "ὦ", "Ὥ" => "ὥ", "Ὤ" => "ὤ",
52
- "Ὣ" => "ὣ", "Ὢ" => "ὢ", "Ὡ" => "ὡ",
53
- "Ὠ" => "� ", "Ὗ" => "ὗ", "Ὕ" => "ὕ",
54
- "Ὓ" => "ὓ", "Ὑ" => "ὑ", "Ὅ" => "ὅ",
55
- "Ὄ" => "ὄ", "Ὃ" => "ὃ", "Ὂ" => "ὂ",
56
- "Ὁ" => "ὁ", "Ὀ" => "ὀ", "Ἷ" => "ἷ",
57
- "Ἶ" => "ἶ", "Ἵ" => "ἵ", "Ἴ" => "ἴ",
58
- "Ἳ" => "ἳ", "Ἲ" => "ἲ", "Ἱ" => "ἱ",
59
- "Ἰ" => "ἰ", "Ἧ" => "ἧ", "Ἦ" => "ἦ",
60
- "Ἥ" => "ἥ", "Ἤ" => "ἤ", "Ἣ" => "ἣ",
61
- "Ἢ" => "ἢ", "Ἡ" => "ἡ", "Ἠ" => "� ",
62
- "Ἕ" => "ἕ", "Ἔ" => "ἔ", "Ἓ" => "ἓ",
63
- "Ἒ" => "ἒ", "Ἑ" => "ἑ", "Ἐ" => "ἐ",
64
- "Ἇ" => "ἇ", "Ἆ" => "ἆ", "Ἅ" => "ἅ",
65
- "Ἄ" => "ἄ", "Ἃ" => "ἃ", "Ἂ" => "ἂ",
66
- "Ἁ" => "ἁ", "Ἀ" => "ἀ", "Ỹ" => "ỹ",
67
- "Ỷ" => "ỷ", "Ỵ" => "ỵ", "Ỳ" => "ỳ",
68
- "Ự" => "ự", "Ữ" => "ữ", "Ử" => "ử",
69
- "Ừ" => "ừ", "Ứ" => "ứ", "Ủ" => "ủ",
70
- "Ụ" => "ụ", "Ợ" => "ợ", "� " => "ỡ",
71
- "Ở" => "ở", "Ờ" => "ờ", "Ớ" => "ớ",
72
- "Ộ" => "ộ", "Ỗ" => "ỗ", "Ổ" => "ổ",
73
- "Ồ" => "ồ", "Ố" => "ố", "Ỏ" => "ỏ",
74
- "Ọ" => "ọ", "Ị" => "ị", "Ỉ" => "ỉ",
75
- "Ệ" => "ệ", "Ễ" => "ễ", "Ể" => "ể",
76
- "Ề" => "ề", "Ế" => "ế", "Ẽ" => "ẽ",
77
- "Ẻ" => "ẻ", "Ẹ" => "ẹ", "Ặ" => "ặ",
78
- "Ẵ" => "ẵ", "Ẳ" => "ẳ", "Ằ" => "ằ",
79
- "Ắ" => "ắ", "Ậ" => "ậ", "Ẫ" => "ẫ",
80
- "Ẩ" => "ẩ", "Ầ" => "ầ", "Ấ" => "ấ",
81
- "Ả" => "ả", "� " => "ạ", "Ẕ" => "ẕ",
82
- "Ẓ" => "ẓ", "Ẑ" => "ẑ", "Ẏ" => "ẏ",
83
- "Ẍ" => "ẍ", "Ẋ" => "ẋ", "Ẉ" => "ẉ",
84
- "Ẇ" => "ẇ", "Ẅ" => "ẅ", "Ẃ" => "ẃ",
85
- "Ẁ" => "ẁ", "Ṿ" => "ṿ", "Ṽ" => "ṽ",
86
- "Ṻ" => "ṻ", "Ṹ" => "ṹ", "Ṷ" => "ṷ",
87
- "Ṵ" => "ṵ", "Ṳ" => "ṳ", "Ṱ" => "ṱ",
88
- "Ṯ" => "ṯ", "Ṭ" => "ṭ", "Ṫ" => "ṫ",
89
- "Ṩ" => "ṩ", "Ṧ" => "ṧ", "Ṥ" => "ṥ",
90
- "Ṣ" => "ṣ", "� " => "ṡ", "Ṟ" => "ṟ",
91
- "Ṝ" => "ṝ", "Ṛ" => "ṛ", "Ṙ" => "ṙ",
92
- "Ṗ" => "ṗ", "Ṕ" => "ṕ", "Ṓ" => "ṓ",
93
- "Ṑ" => "ṑ", "Ṏ" => "ṏ", "Ṍ" => "ṍ",
94
- "Ṋ" => "ṋ", "Ṉ" => "ṉ", "Ṇ" => "ṇ",
95
- "Ṅ" => "ṅ", "Ṃ" => "ṃ", "Ṁ" => "ṁ",
96
- "Ḿ" => "ḿ", "Ḽ" => "ḽ", "Ḻ" => "ḻ",
97
- "Ḹ" => "ḹ", "Ḷ" => "ḷ", "Ḵ" => "ḵ",
98
- "Ḳ" => "ḳ", "Ḱ" => "ḱ", "Ḯ" => "ḯ",
99
- "Ḭ" => "ḭ", "Ḫ" => "ḫ", "Ḩ" => "ḩ",
100
- "Ḧ" => "ḧ", "Ḥ" => "ḥ", "Ḣ" => "ḣ",
101
- "� " => "ḡ", "Ḟ" => "ḟ", "Ḝ" => "ḝ",
102
- "Ḛ" => "ḛ", "Ḙ" => "ḙ", "Ḗ" => "ḗ",
103
- "Ḕ" => "ḕ", "Ḓ" => "ḓ", "Ḑ" => "ḑ",
104
- "Ḏ" => "ḏ", "Ḍ" => "ḍ", "Ḋ" => "ḋ",
105
- "Ḉ" => "ḉ", "Ḇ" => "ḇ", "Ḅ" => "ḅ",
106
- "Ḃ" => "ḃ", "Ḁ" => "ḁ", "Ֆ" => "ֆ",
107
- "Օ" => "օ", "Ք" => "ք", "Փ" => "փ",
108
- "Ւ" => "ւ", "Ց" => "ց", "Ր" => "ր",
109
- "Տ" => "տ", "Վ" => "վ", "Ս" => "ս",
110
- "Ռ" => "ռ", "Ջ" => "ջ", "Պ" => "պ",
111
- "Չ" => "չ", "Ո" => "ո", "Շ" => "շ",
112
- "Ն" => "ն", "Յ" => "յ", "Մ" => "մ",
113
- "Ճ" => "ճ", "Ղ" => "ղ", "Ձ" => "ձ",
114
- "Հ" => "հ", "Կ" => "կ", "Ծ" => "ծ",
115
- "Խ" => "խ", "Լ" => "լ", "Ի" => "ի",
116
- "Ժ" => "ժ", "Թ" => "թ", "Ը" => "ը",
117
- "Է" => "է", "Զ" => "զ", "Ե" => "ե",
118
- "Դ" => "դ", "Գ" => "գ", "Բ" => "բ",
119
- "Ա" => "ա", "Ԏ" => "ԏ", "Ԍ" => "ԍ",
120
- "Ԋ" => "ԋ", "Ԉ" => "ԉ", "Ԇ" => "ԇ",
121
- "Ԅ" => "ԅ", "Ԃ" => "ԃ", "Ԁ" => "ԁ",
122
- "Ӹ" => "ӹ", "Ӵ" => "ӵ", "Ӳ" => "ӳ",
123
- "Ӱ" => "ӱ", "Ӯ" => "ӯ", "Ӭ" => "ӭ",
124
- "Ӫ" => "ӫ", "Ө" => "ө", "Ӧ" => "ӧ",
125
- "Ӥ" => "ӥ", "Ӣ" => "ӣ", "� " => "ӡ",
126
- "Ӟ" => "ӟ", "Ӝ" => "ӝ", "Ӛ" => "ӛ",
127
- "Ә" => "ә", "Ӗ" => "ӗ", "Ӕ" => "ӕ",
128
- "Ӓ" => "ӓ", "Ӑ" => "ӑ", "Ӎ" => "ӎ",
129
- "Ӌ" => "ӌ", "Ӊ" => "ӊ", "Ӈ" => "ӈ",
130
- "Ӆ" => "ӆ", "Ӄ" => "ӄ", "Ӂ" => "ӂ",
131
- "Ҿ" => "ҿ", "Ҽ" => "ҽ", "Һ" => "һ",
132
- "Ҹ" => "ҹ", "Ҷ" => "ҷ", "Ҵ" => "ҵ",
133
- "Ҳ" => "ҳ", "Ұ" => "ұ", "Ү" => "ү",
134
- "Ҭ" => "ҭ", "Ҫ" => "ҫ", "Ҩ" => "ҩ",
135
- "Ҧ" => "ҧ", "Ҥ" => "ҥ", "Ң" => "ң",
136
- "� " => "ҡ", "Ҟ" => "ҟ", "Ҝ" => "ҝ",
137
- "Қ" => "қ", "Ҙ" => "ҙ", "Җ" => "җ",
138
- "Ҕ" => "ҕ", "Ғ" => "ғ", "Ґ" => "ґ",
139
- "Ҏ" => "ҏ", "Ҍ" => "ҍ", "Ҋ" => "ҋ",
140
- "Ҁ" => "ҁ", "Ѿ" => "ѿ", "Ѽ" => "ѽ",
141
- "Ѻ" => "ѻ", "Ѹ" => "ѹ", "Ѷ" => "ѷ",
142
- "Ѵ" => "ѵ", "Ѳ" => "ѳ", "Ѱ" => "ѱ",
143
- "Ѯ" => "ѯ", "Ѭ" => "ѭ", "Ѫ" => "ѫ",
144
- "Ѩ" => "ѩ", "Ѧ" => "ѧ", "Ѥ" => "ѥ",
145
- "Ѣ" => "ѣ", "� " => "ѡ", "Я" => "я",
146
- "Ю" => "ю", "Э" => "э", "Ь" => "ь",
147
- "Ы" => "ы", "Ъ" => "ъ", "Щ" => "щ",
148
- "Ш" => "ш", "Ч" => "ч", "Ц" => "ц",
149
- "Х" => "х", "Ф" => "ф", "У" => "у",
150
- "Т" => "т", "С" => "с", "� " => "р",
151
- "П" => "п", "О" => "о", "Н" => "н",
152
- "М" => "м", "Л" => "л", "К" => "к",
153
- "Й" => "й", "И" => "и", "З" => "з",
154
- "Ж" => "ж", "Е" => "е", "Д" => "д",
155
- "Г" => "г", "В" => "в", "Б" => "б",
156
- "А" => "а", "Џ" => "џ", "Ў" => "ў",
157
- "Ѝ" => "ѝ", "Ќ" => "ќ", "Ћ" => "ћ",
158
- "Њ" => "њ", "Љ" => "љ", "Ј" => "ј",
159
- "Ї" => "ї", "І" => "і", "Ѕ" => "ѕ",
160
- "Є" => "є", "Ѓ" => "ѓ", "Ђ" => "ђ",
161
- "Ё" => "ё", "Ѐ" => "ѐ", "ϴ" => "θ",
162
- "Ϯ" => "ϯ", "Ϭ" => "ϭ", "Ϫ" => "ϫ",
163
- "Ϩ" => "ϩ", "Ϧ" => "ϧ", "Ϥ" => "ϥ",
164
- "Ϣ" => "ϣ", "� " => "ϡ", "Ϟ" => "ϟ",
165
- "Ϝ" => "ϝ", "Ϛ" => "ϛ", "Ϙ" => "ϙ",
166
- "Ϋ" => "ϋ", "Ϊ" => "ϊ", "Ω" => "ω",
167
- "Ψ" => "ψ", "Χ" => "χ", "Φ" => "φ",
168
- "Υ" => "υ", "Τ" => "τ", "Σ" => "σ",
169
- "Ρ" => "ρ", "� " => "π", "Ο" => "ο",
170
- "Ξ" => "ξ", "Ν" => "ν", "Μ" => "μ",
171
- "Λ" => "λ", "Κ" => "κ", "Ι" => "ι",
172
- "Θ" => "θ", "Η" => "η", "Ζ" => "ζ",
173
- "Ε" => "ε", "Δ" => "δ", "Γ" => "γ",
174
- "Β" => "β", "Α" => "α", "Ώ" => "ώ",
175
- "Ύ" => "ύ", "Ό" => "ό", "Ί" => "ί",
176
- "Ή" => "ή", "Έ" => "έ", "Ά" => "ά",
177
- "Ȳ" => "ȳ", "Ȱ" => "ȱ", "Ȯ" => "ȯ",
178
- "Ȭ" => "ȭ", "Ȫ" => "ȫ", "Ȩ" => "ȩ",
179
- "Ȧ" => "ȧ", "Ȥ" => "ȥ", "Ȣ" => "ȣ",
180
- "� " => "ƞ", "Ȟ" => "ȟ", "Ȝ" => "ȝ",
181
- "Ț" => "ț", "Ș" => "ș", "Ȗ" => "ȗ",
182
- "Ȕ" => "ȕ", "Ȓ" => "ȓ", "Ȑ" => "ȑ",
183
- "Ȏ" => "ȏ", "Ȍ" => "ȍ", "Ȋ" => "ȋ",
184
- "Ȉ" => "ȉ", "Ȇ" => "ȇ", "Ȅ" => "ȅ",
185
- "Ȃ" => "ȃ", "Ȁ" => "ȁ", "Ǿ" => "ǿ",
186
- "Ǽ" => "ǽ", "Ǻ" => "ǻ", "Ǹ" => "ǹ",
187
- "Ƿ" => "ƿ", "Ƕ" => "ƕ", "Ǵ" => "ǵ",
188
- "DZ" => "dz", "Ǯ" => "ǯ", "Ǭ" => "ǭ",
189
- "Ǫ" => "ǫ", "Ǩ" => "ǩ", "Ǧ" => "ǧ",
190
- "Ǥ" => "ǥ", "Ǣ" => "ǣ", "� " => "ǡ",
191
- "Ǟ" => "ǟ", "Ǜ" => "ǜ", "Ǚ" => "ǚ",
192
- "Ǘ" => "ǘ", "Ǖ" => "ǖ", "Ǔ" => "ǔ",
193
- "Ǒ" => "ǒ", "Ǐ" => "ǐ", "Ǎ" => "ǎ",
194
- "NJ" => "nj", "LJ" => "lj", "DŽ" => "dž",
195
- "Ƽ" => "ƽ", "Ƹ" => "ƹ", "Ʒ" => "ʒ",
196
- "Ƶ" => "ƶ", "Ƴ" => "ƴ", "Ʋ" => "ʋ",
197
- "Ʊ" => "ʊ", "Ư" => "ư", "Ʈ" => "ʈ",
198
- "Ƭ" => "ƭ", "Ʃ" => "ʃ", "Ƨ" => "ƨ",
199
- "Ʀ" => "ʀ", "Ƥ" => "ƥ", "Ƣ" => "ƣ",
200
- "� " => "ơ", "Ɵ" => "ɵ", "Ɲ" => "ɲ",
201
- "Ɯ" => "ɯ", "Ƙ" => "ƙ", "Ɨ" => "ɨ",
202
- "Ɩ" => "ɩ", "Ɣ" => "ɣ", "Ɠ" => "� ",
203
- "Ƒ" => "ƒ", "Ɛ" => "ɛ", "Ə" => "ə",
204
- "Ǝ" => "ǝ", "Ƌ" => "ƌ", "Ɗ" => "ɗ",
205
- "Ɖ" => "ɖ", "Ƈ" => "ƈ", "Ɔ" => "ɔ",
206
- "Ƅ" => "ƅ", "Ƃ" => "ƃ", "Ɓ" => "ɓ",
207
- "Ž" => "ž", "Ż" => "ż", "Ź" => "ź",
208
- "Ÿ" => "ÿ", "Ŷ" => "ŷ", "Ŵ" => "ŵ",
209
- "Ų" => "ų", "Ű" => "ű", "Ů" => "ů",
210
- "Ŭ" => "ŭ", "Ū" => "ū", "Ũ" => "ũ",
211
- "Ŧ" => "ŧ", "Ť" => "ť", "Ţ" => "ţ",
212
- "� " => "š", "Ş" => "ş", "Ŝ" => "ŝ",
213
- "Ś" => "ś", "Ř" => "ř", "Ŗ" => "ŗ",
214
- "Ŕ" => "ŕ", "Œ" => "œ", "Ő" => "ő",
215
- "Ŏ" => "ŏ", "Ō" => "ō", "Ŋ" => "ŋ",
216
- "Ň" => "ň", "Ņ" => "ņ", "Ń" => "ń",
217
- "Ł" => "ł", "Ŀ" => "ŀ", "Ľ" => "ľ",
218
- "Ļ" => "ļ", "Ĺ" => "ĺ", "Ķ" => "ķ",
219
- "Ĵ" => "ĵ", "IJ" => "ij", "İ" => "i",
220
- "Į" => "į", "Ĭ" => "ĭ", "Ī" => "ī",
221
- "Ĩ" => "ĩ", "Ħ" => "ħ", "Ĥ" => "ĥ",
222
- "Ģ" => "ģ", "� " => "ġ", "Ğ" => "ğ",
223
- "Ĝ" => "ĝ", "Ě" => "ě", "Ę" => "ę",
224
- "Ė" => "ė", "Ĕ" => "ĕ", "Ē" => "ē",
225
- "Đ" => "đ", "Ď" => "ď", "Č" => "č",
226
- "Ċ" => "ċ", "Ĉ" => "ĉ", "Ć" => "ć",
227
- "Ą" => "ą", "Ă" => "ă", "Ā" => "ā",
228
- "Þ" => "þ", "Ý" => "ý", "Ü" => "ü",
229
- "Û" => "û", "Ú" => "ú", "Ù" => "ù",
230
- "Ø" => "ø", "Ö" => "ö", "Õ" => "õ",
231
- "Ô" => "ô", "Ó" => "ó", "Ò" => "ò",
232
- "Ñ" => "ñ", "Ð" => "ð", "Ï" => "ï",
233
- "Î" => "î", "Í" => "í", "Ì" => "ì",
234
- "Ë" => "ë", "Ê" => "ê", "É" => "é",
235
- "È" => "è", "Ç" => "ç", "Æ" => "æ",
236
- "Å" => "å", "Ä" => "ä", "Ã" => "ã",
237
- "Â" => "â", "Á" => "á", "À" => "� ",
238
- "Z" => "z", "Y" => "y", "X" => "x",
239
- "W" => "w", "V" => "v", "U" => "u",
240
- "T" => "t", "S" => "s", "R" => "r",
241
- "Q" => "q", "P" => "p", "O" => "o",
242
- "N" => "n", "M" => "m", "L" => "l",
243
- "K" => "k", "J" => "j", "I" => "i",
244
- "H" => "h", "G" => "g", "F" => "f",
245
- "E" => "e", "D" => "d", "C" => "c",
246
- "B" => "b", "A" => "a",
247
- );
248
-
249
-
250
- $UTF8_TABLES['strtoupper'] = array(
251
- "z" => "Z", "y" => "Y", "x" => "X",
252
- "w" => "W", "v" => "V", "u" => "U",
253
- "t" => "T", "s" => "S", "r" => "R",
254
- "q" => "Q", "p" => "P", "o" => "O",
255
- "n" => "N", "m" => "M", "l" => "L",
256
- "k" => "K", "j" => "J", "i" => "I",
257
- "h" => "H", "g" => "G", "f" => "F",
258
- "e" => "E", "d" => "D", "c" => "C",
259
- "b" => "B", "a" => "A", "ῳ" => "ῼ",
260
- "ῥ" => "Ῥ", "ῡ" => "Ῡ", "� " => "Ῠ",
261
- "ῑ" => "Ῑ", "ῐ" => "Ῐ", "ῃ" => "ῌ",
262
- "ι" => "Ι", "ᾳ" => "ᾼ", "ᾱ" => "Ᾱ",
263
- "ᾰ" => "Ᾰ", "ᾧ" => "ᾯ", "ᾦ" => "ᾮ",
264
- "ᾥ" => "ᾭ", "ᾤ" => "ᾬ", "ᾣ" => "ᾫ",
265
- "ᾢ" => "ᾪ", "ᾡ" => "ᾩ", "� " => "ᾨ",
266
- "ᾗ" => "ᾟ", "ᾖ" => "ᾞ", "ᾕ" => "ᾝ",
267
- "ᾔ" => "ᾜ", "ᾓ" => "ᾛ", "ᾒ" => "ᾚ",
268
- "ᾑ" => "ᾙ", "ᾐ" => "ᾘ", "ᾇ" => "ᾏ",
269
- "ᾆ" => "ᾎ", "ᾅ" => "ᾍ", "ᾄ" => "ᾌ",
270
- "ᾃ" => "ᾋ", "ᾂ" => "ᾊ", "ᾁ" => "ᾉ",
271
- "ᾀ" => "ᾈ", "ώ" => "Ώ", "ὼ" => "Ὼ",
272
- "ύ" => "Ύ", "ὺ" => "Ὺ", "ό" => "Ό",
273
- "ὸ" => "Ὸ", "ί" => "Ί", "ὶ" => "Ὶ",
274
- "ή" => "Ή", "ὴ" => "Ὴ", "έ" => "Έ",
275
- "ὲ" => "Ὲ", "ά" => "Ά", "ὰ" => "Ὰ",
276
- "ὧ" => "Ὧ", "ὦ" => "Ὦ", "ὥ" => "Ὥ",
277
- "ὤ" => "Ὤ", "ὣ" => "Ὣ", "ὢ" => "Ὢ",
278
- "ὡ" => "Ὡ", "� " => "Ὠ", "ὗ" => "Ὗ",
279
- "ὕ" => "Ὕ", "ὓ" => "Ὓ", "ὑ" => "Ὑ",
280
- "ὅ" => "Ὅ", "ὄ" => "Ὄ", "ὃ" => "Ὃ",
281
- "ὂ" => "Ὂ", "ὁ" => "Ὁ", "ὀ" => "Ὀ",
282
- "ἷ" => "Ἷ", "ἶ" => "Ἶ", "ἵ" => "Ἵ",
283
- "ἴ" => "Ἴ", "ἳ" => "Ἳ", "ἲ" => "Ἲ",
284
- "ἱ" => "Ἱ", "ἰ" => "Ἰ", "ἧ" => "Ἧ",
285
- "ἦ" => "Ἦ", "ἥ" => "Ἥ", "ἤ" => "Ἤ",
286
- "ἣ" => "Ἣ", "ἢ" => "Ἢ", "ἡ" => "Ἡ",
287
- "� " => "Ἠ", "ἕ" => "Ἕ", "ἔ" => "Ἔ",
288
- "ἓ" => "Ἓ", "ἒ" => "Ἒ", "ἑ" => "Ἑ",
289
- "ἐ" => "Ἐ", "ἇ" => "Ἇ", "ἆ" => "Ἆ",
290
- "ἅ" => "Ἅ", "ἄ" => "Ἄ", "ἃ" => "Ἃ",
291
- "ἂ" => "Ἂ", "ἁ" => "Ἁ", "ἀ" => "Ἀ",
292
- "ỹ" => "Ỹ", "ỷ" => "Ỷ", "ỵ" => "Ỵ",
293
- "ỳ" => "Ỳ", "ự" => "Ự", "ữ" => "Ữ",
294
- "ử" => "Ử", "ừ" => "Ừ", "ứ" => "Ứ",
295
- "ủ" => "Ủ", "ụ" => "Ụ", "ợ" => "Ợ",
296
- "ỡ" => "� ", "ở" => "Ở", "ờ" => "Ờ",
297
- "ớ" => "Ớ", "ộ" => "Ộ", "ỗ" => "Ỗ",
298
- "ổ" => "Ổ", "ồ" => "Ồ", "ố" => "Ố",
299
- "ỏ" => "Ỏ", "ọ" => "Ọ", "ị" => "Ị",
300
- "ỉ" => "Ỉ", "ệ" => "Ệ", "ễ" => "Ễ",
301
- "ể" => "Ể", "ề" => "Ề", "ế" => "Ế",
302
- "ẽ" => "Ẽ", "ẻ" => "Ẻ", "ẹ" => "Ẹ",
303
- "ặ" => "Ặ", "ẵ" => "Ẵ", "ẳ" => "Ẳ",
304
- "ằ" => "Ằ", "ắ" => "Ắ", "ậ" => "Ậ",
305
- "ẫ" => "Ẫ", "ẩ" => "Ẩ", "ầ" => "Ầ",
306
- "ấ" => "Ấ", "ả" => "Ả", "ạ" => "� ",
307
- "ẛ" => "� ", "ẕ" => "Ẕ", "ẓ" => "Ẓ",
308
- "ẑ" => "Ẑ", "ẏ" => "Ẏ", "ẍ" => "Ẍ",
309
- "ẋ" => "Ẋ", "ẉ" => "Ẉ", "ẇ" => "Ẇ",
310
- "ẅ" => "Ẅ", "ẃ" => "Ẃ", "ẁ" => "Ẁ",
311
- "ṿ" => "Ṿ", "ṽ" => "Ṽ", "ṻ" => "Ṻ",
312
- "ṹ" => "Ṹ", "ṷ" => "Ṷ", "ṵ" => "Ṵ",
313
- "ṳ" => "Ṳ", "ṱ" => "Ṱ", "ṯ" => "Ṯ",
314
- "ṭ" => "Ṭ", "ṫ" => "Ṫ", "ṩ" => "Ṩ",
315
- "ṧ" => "Ṧ", "ṥ" => "Ṥ", "ṣ" => "Ṣ",
316
- "ṡ" => "� ", "ṟ" => "Ṟ", "ṝ" => "Ṝ",
317
- "ṛ" => "Ṛ", "ṙ" => "Ṙ", "ṗ" => "Ṗ",
318
- "ṕ" => "Ṕ", "ṓ" => "Ṓ", "ṑ" => "Ṑ",
319
- "ṏ" => "Ṏ", "ṍ" => "Ṍ", "ṋ" => "Ṋ",
320
- "ṉ" => "Ṉ", "ṇ" => "Ṇ", "ṅ" => "Ṅ",
321
- "ṃ" => "Ṃ", "ṁ" => "Ṁ", "ḿ" => "Ḿ",
322
- "ḽ" => "Ḽ", "ḻ" => "Ḻ", "ḹ" => "Ḹ",
323
- "ḷ" => "Ḷ", "ḵ" => "Ḵ", "ḳ" => "Ḳ",
324
- "ḱ" => "Ḱ", "ḯ" => "Ḯ", "ḭ" => "Ḭ",
325
- "ḫ" => "Ḫ", "ḩ" => "Ḩ", "ḧ" => "Ḧ",
326
- "ḥ" => "Ḥ", "ḣ" => "Ḣ", "ḡ" => "� ",
327
- "ḟ" => "Ḟ", "ḝ" => "Ḝ", "ḛ" => "Ḛ",
328
- "ḙ" => "Ḙ", "ḗ" => "Ḗ", "ḕ" => "Ḕ",
329
- "ḓ" => "Ḓ", "ḑ" => "Ḑ", "ḏ" => "Ḏ",
330
- "ḍ" => "Ḍ", "ḋ" => "Ḋ", "ḉ" => "Ḉ",
331
- "ḇ" => "Ḇ", "ḅ" => "Ḅ", "ḃ" => "Ḃ",
332
- "ḁ" => "Ḁ", "ֆ" => "Ֆ", "օ" => "Օ",
333
- "ք" => "Ք", "փ" => "Փ", "ւ" => "Ւ",
334
- "ց" => "Ց", "ր" => "Ր", "տ" => "Տ",
335
- "վ" => "Վ", "ս" => "Ս", "ռ" => "Ռ",
336
- "ջ" => "Ջ", "պ" => "Պ", "չ" => "Չ",
337
- "ո" => "Ո", "շ" => "Շ", "ն" => "Ն",
338
- "յ" => "Յ", "մ" => "Մ", "ճ" => "Ճ",
339
- "ղ" => "Ղ", "ձ" => "Ձ", "հ" => "Հ",
340
- "կ" => "Կ", "ծ" => "Ծ", "խ" => "Խ",
341
- "լ" => "Լ", "ի" => "Ի", "ժ" => "Ժ",
342
- "թ" => "Թ", "ը" => "Ը", "է" => "Է",
343
- "զ" => "Զ", "ե" => "Ե", "դ" => "Դ",
344
- "գ" => "Գ", "բ" => "Բ", "ա" => "Ա",
345
- "ԏ" => "Ԏ", "ԍ" => "Ԍ", "ԋ" => "Ԋ",
346
- "ԉ" => "Ԉ", "ԇ" => "Ԇ", "ԅ" => "Ԅ",
347
- "ԃ" => "Ԃ", "ԁ" => "Ԁ", "ӹ" => "Ӹ",
348
- "ӵ" => "Ӵ", "ӳ" => "Ӳ", "ӱ" => "Ӱ",
349
- "ӯ" => "Ӯ", "ӭ" => "Ӭ", "ӫ" => "Ӫ",
350
- "ө" => "Ө", "ӧ" => "Ӧ", "ӥ" => "Ӥ",
351
- "ӣ" => "Ӣ", "ӡ" => "� ", "ӟ" => "Ӟ",
352
- "ӝ" => "Ӝ", "ӛ" => "Ӛ", "ә" => "Ә",
353
- "ӗ" => "Ӗ", "ӕ" => "Ӕ", "ӓ" => "Ӓ",
354
- "ӑ" => "Ӑ", "ӎ" => "Ӎ", "ӌ" => "Ӌ",
355
- "ӊ" => "Ӊ", "ӈ" => "Ӈ", "ӆ" => "Ӆ",
356
- "ӄ" => "Ӄ", "ӂ" => "Ӂ", "ҿ" => "Ҿ",
357
- "ҽ" => "Ҽ", "һ" => "Һ", "ҹ" => "Ҹ",
358
- "ҷ" => "Ҷ", "ҵ" => "Ҵ", "ҳ" => "Ҳ",
359
- "ұ" => "Ұ", "ү" => "Ү", "ҭ" => "Ҭ",
360
- "ҫ" => "Ҫ", "ҩ" => "Ҩ", "ҧ" => "Ҧ",
361
- "ҥ" => "Ҥ", "ң" => "Ң", "ҡ" => "� ",
362
- "ҟ" => "Ҟ", "ҝ" => "Ҝ", "қ" => "Қ",
363
- "ҙ" => "Ҙ", "җ" => "Җ", "ҕ" => "Ҕ",
364
- "ғ" => "Ғ", "ґ" => "Ґ", "ҏ" => "Ҏ",
365
- "ҍ" => "Ҍ", "ҋ" => "Ҋ", "ҁ" => "Ҁ",
366
- "ѿ" => "Ѿ", "ѽ" => "Ѽ", "ѻ" => "Ѻ",
367
- "ѹ" => "Ѹ", "ѷ" => "Ѷ", "ѵ" => "Ѵ",
368
- "ѳ" => "Ѳ", "ѱ" => "Ѱ", "ѯ" => "Ѯ",
369
- "ѭ" => "Ѭ", "ѫ" => "Ѫ", "ѩ" => "Ѩ",
370
- "ѧ" => "Ѧ", "ѥ" => "Ѥ", "ѣ" => "Ѣ",
371
- "ѡ" => "� ", "џ" => "Џ", "ў" => "Ў",
372
- "ѝ" => "Ѝ", "ќ" => "Ќ", "ћ" => "Ћ",
373
- "њ" => "Њ", "љ" => "Љ", "ј" => "Ј",
374
- "ї" => "Ї", "і" => "І", "ѕ" => "Ѕ",
375
- "є" => "Є", "ѓ" => "Ѓ", "ђ" => "Ђ",
376
- "ё" => "Ё", "ѐ" => "Ѐ", "я" => "Я",
377
- "ю" => "Ю", "э" => "Э", "ь" => "Ь",
378
- "ы" => "Ы", "ъ" => "Ъ", "щ" => "Щ",
379
- "ш" => "Ш", "ч" => "Ч", "ц" => "Ц",
380
- "х" => "Х", "ф" => "Ф", "у" => "У",
381
- "т" => "Т", "с" => "С", "р" => "� ",
382
- "п" => "П", "о" => "О", "н" => "Н",
383
- "м" => "М", "л" => "Л", "к" => "К",
384
- "й" => "Й", "и" => "И", "з" => "З",
385
- "ж" => "Ж", "е" => "Е", "д" => "Д",
386
- "г" => "Г", "в" => "В", "б" => "Б",
387
- "а" => "А", "ϵ" => "Ε", "ϲ" => "Σ",
388
- "ϱ" => "Ρ", "ϰ" => "Κ", "ϯ" => "Ϯ",
389
- "ϭ" => "Ϭ", "ϫ" => "Ϫ", "ϩ" => "Ϩ",
390
- "ϧ" => "Ϧ", "ϥ" => "Ϥ", "ϣ" => "Ϣ",
391
- "ϡ" => "� ", "ϟ" => "Ϟ", "ϝ" => "Ϝ",
392
- "ϛ" => "Ϛ", "ϙ" => "Ϙ", "ϖ" => "� ",
393
- "ϕ" => "Φ", "ϑ" => "Θ", "ϐ" => "Β",
394
- "ώ" => "Ώ", "ύ" => "Ύ", "ό" => "Ό",
395
- "ϋ" => "Ϋ", "ϊ" => "Ϊ", "ω" => "Ω",
396
- "ψ" => "Ψ", "χ" => "Χ", "φ" => "Φ",
397
- "υ" => "Υ", "τ" => "Τ", "σ" => "Σ",
398
- "ς" => "Σ", "ρ" => "Ρ", "π" => "� ",
399
- "ο" => "Ο", "ξ" => "Ξ", "ν" => "Ν",
400
- "μ" => "Μ", "λ" => "Λ", "κ" => "Κ",
401
- "ι" => "Ι", "θ" => "Θ", "η" => "Η",
402
- "ζ" => "Ζ", "ε" => "Ε", "δ" => "Δ",
403
- "γ" => "Γ", "β" => "Β", "α" => "Α",
404
- "ί" => "Ί", "ή" => "Ή", "έ" => "Έ",
405
- "ά" => "Ά", "ʒ" => "Ʒ", "ʋ" => "Ʋ",
406
- "ʊ" => "Ʊ", "ʈ" => "Ʈ", "ʃ" => "Ʃ",
407
- "ʀ" => "Ʀ", "ɵ" => "Ɵ", "ɲ" => "Ɲ",
408
- "ɯ" => "Ɯ", "ɩ" => "Ɩ", "ɨ" => "Ɨ",
409
- "ɣ" => "Ɣ", "� " => "Ɠ", "ɛ" => "Ɛ",
410
- "ə" => "Ə", "ɗ" => "Ɗ", "ɖ" => "Ɖ",
411
- "ɔ" => "Ɔ", "ɓ" => "Ɓ", "ȳ" => "Ȳ",
412
- "ȱ" => "Ȱ", "ȯ" => "Ȯ", "ȭ" => "Ȭ",
413
- "ȫ" => "Ȫ", "ȩ" => "Ȩ", "ȧ" => "Ȧ",
414
- "ȥ" => "Ȥ", "ȣ" => "Ȣ", "ȟ" => "Ȟ",
415
- "ȝ" => "Ȝ", "ț" => "Ț", "ș" => "Ș",
416
- "ȗ" => "Ȗ", "ȕ" => "Ȕ", "ȓ" => "Ȓ",
417
- "ȑ" => "Ȑ", "ȏ" => "Ȏ", "ȍ" => "Ȍ",
418
- "ȋ" => "Ȋ", "ȉ" => "Ȉ", "ȇ" => "Ȇ",
419
- "ȅ" => "Ȅ", "ȃ" => "Ȃ", "ȁ" => "Ȁ",
420
- "ǿ" => "Ǿ", "ǽ" => "Ǽ", "ǻ" => "Ǻ",
421
- "ǹ" => "Ǹ", "ǵ" => "Ǵ", "dz" => "Dz",
422
- "ǯ" => "Ǯ", "ǭ" => "Ǭ", "ǫ" => "Ǫ",
423
- "ǩ" => "Ǩ", "ǧ" => "Ǧ", "ǥ" => "Ǥ",
424
- "ǣ" => "Ǣ", "ǡ" => "� ", "ǟ" => "Ǟ",
425
- "ǝ" => "Ǝ", "ǜ" => "Ǜ", "ǚ" => "Ǚ",
426
- "ǘ" => "Ǘ", "ǖ" => "Ǖ", "ǔ" => "Ǔ",
427
- "ǒ" => "Ǒ", "ǐ" => "Ǐ", "ǎ" => "Ǎ",
428
- "nj" => "Nj", "lj" => "Lj", "dž" => "Dž",
429
- "ƿ" => "Ƿ", "ƽ" => "Ƽ", "ƹ" => "Ƹ",
430
- "ƶ" => "Ƶ", "ƴ" => "Ƴ", "ư" => "Ư",
431
- "ƭ" => "Ƭ", "ƨ" => "Ƨ", "ƥ" => "Ƥ",
432
- "ƣ" => "Ƣ", "ơ" => "� ", "ƞ" => "� ",
433
- "ƙ" => "Ƙ", "ƕ" => "Ƕ", "ƒ" => "Ƒ",
434
- "ƌ" => "Ƌ", "ƈ" => "Ƈ", "ƅ" => "Ƅ",
435
- "ƃ" => "Ƃ", "ſ" => "S", "ž" => "Ž",
436
- "ż" => "Ż", "ź" => "Ź", "ŷ" => "Ŷ",
437
- "ŵ" => "Ŵ", "ų" => "Ų", "ű" => "Ű",
438
- "ů" => "Ů", "ŭ" => "Ŭ", "ū" => "Ū",
439
- "ũ" => "Ũ", "ŧ" => "Ŧ", "ť" => "Ť",
440
- "ţ" => "Ţ", "š" => "� ", "ş" => "Ş",
441
- "ŝ" => "Ŝ", "ś" => "Ś", "ř" => "Ř",
442
- "ŗ" => "Ŗ", "ŕ" => "Ŕ", "œ" => "Œ",
443
- "ő" => "Ő", "ŏ" => "Ŏ", "ō" => "Ō",
444
- "ŋ" => "Ŋ", "ň" => "Ň", "ņ" => "Ņ",
445
- "ń" => "Ń", "ł" => "Ł", "ŀ" => "Ŀ",
446
- "ľ" => "Ľ", "ļ" => "Ļ", "ĺ" => "Ĺ",
447
- "ķ" => "Ķ", "ĵ" => "Ĵ", "ij" => "IJ",
448
- "ı" => "I", "į" => "Į", "ĭ" => "Ĭ",
449
- "ī" => "Ī", "ĩ" => "Ĩ", "ħ" => "Ħ",
450
- "ĥ" => "Ĥ", "ģ" => "Ģ", "ġ" => "� ",
451
- "ğ" => "Ğ", "ĝ" => "Ĝ", "ě" => "Ě",
452
- "ę" => "Ę", "ė" => "Ė", "ĕ" => "Ĕ",
453
- "ē" => "Ē", "đ" => "Đ", "ď" => "Ď",
454
- "č" => "Č", "ċ" => "Ċ", "ĉ" => "Ĉ",
455
- "ć" => "Ć", "ą" => "Ą", "ă" => "Ă",
456
- "ā" => "Ā", "ÿ" => "Ÿ", "þ" => "Þ",
457
- "ý" => "Ý", "ü" => "Ü", "û" => "Û",
458
- "ú" => "Ú", "ù" => "Ù", "ø" => "Ø",
459
- "ö" => "Ö", "õ" => "Õ", "ô" => "Ô",
460
- "ó" => "Ó", "ò" => "Ò", "ñ" => "Ñ",
461
- "ð" => "Ð", "ï" => "Ï", "î" => "Î",
462
- "í" => "Í", "ì" => "Ì", "ë" => "Ë",
463
- "ê" => "Ê", "é" => "É", "è" => "È",
464
- "ç" => "Ç", "æ" => "Æ", "å" => "Å",
465
- "ä" => "Ä", "ã" => "Ã", "â" => "Â",
466
- "á" => "Á", "� " => "À", "µ" => "Μ",
467
- "z" => "Z", "y" => "Y", "x" => "X",
468
- "w" => "W", "v" => "V", "u" => "U",
469
- "t" => "T", "s" => "S", "r" => "R",
470
- "q" => "Q", "p" => "P", "o" => "O",
471
- "n" => "N", "m" => "M", "l" => "L",
472
- "k" => "K", "j" => "J", "i" => "I",
473
- "h" => "H", "g" => "G", "f" => "F",
474
- "e" => "E", "d" => "D", "c" => "C",
475
- "b" => "B", "a" => "A",
476
- );
477
-
478
- if ( ! defined( 'WP_CONTENT_URL' ) )
479
- define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' );
480
- if ( ! defined( 'WP_CONTENT_DIR' ) )
481
- define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' );
482
- if ( ! defined( 'WP_PLUGIN_URL' ) )
483
- define( 'WP_PLUGIN_URL', WP_CONTENT_URL. '/plugins' );
484
- if ( ! defined( 'WP_PLUGIN_DIR' ) )
485
- define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' );
486
-
487
- require_once('aioseop.class.php');
488
-
489
- global $aioseop_options;
490
- $aioseop_options = get_option('aioseop_options');
491
-
492
-
493
-
494
- /*
495
- add_option("aiosp_home_description", null, 'All in One SEO Plugin Home Description', 'yes');
496
- add_option("aiosp_home_title", null, 'All in One SEO Plugin Home Title', 'yes');
497
- add_option("aiosp_donate", 0, 'All in One SEO Pack Donate', 'no');
498
- add_option("aiosp_can", 1, 'All in One SEO Pack Canonical URLs', 'yes');
499
- add_option("aiosp_rewrite_titles", 1, 'All in One SEO Plugin Rewrite Titles', 'yes');
500
- add_option("aiosp_use_categories", 0, 'All in One SEO Plugin Use Categories', 'yes');
501
- add_option("aiosp_category_noindex", 1, 'All in One SEO Plugin Noindex for Categories', 'yes');
502
- add_option("aiosp_archive_noindex", 1, 'All in One SEO Plugin Noindex for Archives', 'yes');
503
- add_option("aiosp_tags_noindex", 0, 'All in One SEO Plugin Noindex for Tag Archives', 'yes');
504
- add_option("aiosp_generate_descriptions", 1, 'All in One SEO Plugin Autogenerate Descriptions', 'yes');
505
- add_option("aiosp_post_title_format", '%post_title% | %blog_title%', 'All in One SEO Plugin Post Title Format', 'yes');
506
- add_option("aiosp_page_title_format", '%page_title% | %blog_title%', 'All in One SEO Plugin Page Title Format', 'yes');
507
- add_option("aiosp_dynamic_postspage_keywords", 1, 'All in One SEO Plugin Dynamic Posts Page Keywords', 'yes');
508
- add_option("aiosp_category_title_format", '%category_title% | %blog_title%', 'All in One SEO Plugin Category Title Format', 'yes');
509
- add_option("aiosp_archive_title_format", '%date% | %blog_title%', 'All in One SEO Plugin Archive Title Format', 'yes');
510
- add_option("aiosp_tag_title_format", '%tag% | %blog_title%', 'All in One SEO Plugin Tag Title Format', 'yes');
511
- add_option("aiosp_search_title_format", '%search% | %blog_title%', 'All in One SEO Plugin Search Title Format', 'yes');
512
- add_option("aiosp_description_format", '%description%', 'All in One SEO Plugin Description Format', 'yes');
513
- add_option("aiosp_paged_format", ' - Part %page%', 'All in One SEO Plugin Paged Format', 'yes');
514
- add_option("aiosp_404_title_format", 'Nothing found for %request_words%', 'All in One SEO Plugin 404 Title Format', 'yes');
515
- add_option("aiosp_post_meta_tags", '', 'All in One SEO Plugin Additional Post Meta Tags', 'yes');
516
- add_option("aiosp_page_meta_tags", '', 'All in One SEO Plugin Additional Post Meta Tags', 'yes');
517
- add_option("aiosp_home_meta_tags", '', 'All in One SEO Plugin Additional Home Meta Tags', 'yes');
518
- add_option("aiosp_do_log", null, 'All in One SEO Plugin write log file', 'yes');
519
- */
520
-
521
- //$role = get_role('administrator');
522
- //$role->add_cap('Edit AIOSEOP Options');
523
- //$role->add_cap('Edit AIOSEOP on Posts/Pages');
524
-
525
- ////checking to see if things need to be updated
526
-
527
- //if_post('turn-on'){
528
-
529
- /* automattic?
530
- if(!get_option('aioseop_options')){
531
- aioseop_mrt_fix_meta(); //move this to the if also
532
- aioseop_mrt_mkarry();
533
- }
534
- */
535
-
536
- if($_POST['aioseop_migrate']) aioseop_mrt_fix_meta();
537
- if($_POST['aioseop_migrate_options']) aioseop_mrt_mkarry();
538
- if(!get_option('aiosp_post_title_format') && !get_option('aioseop_options')) aioseop_mrt_mkarry();
539
-
540
- //}end _post('turn_on')
541
-
542
-
543
- ////end checking to see if things need to be updated
544
-
545
-
546
- function aioseop_mrt_fix_meta(){
547
- global $wpdb;
548
- $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '_aioseop_keywords' WHERE meta_key = 'keywords'");
549
- $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '_aioseop_title' WHERE meta_key = 'title'");
550
- $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '_aioseop_description' WHERE meta_key = 'description'");
551
- $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '_aioseop_meta' WHERE meta_key = 'aiosp_meta'");
552
- $wpdb->query("UPDATE $wpdb->postmeta SET meta_key = '_aioseop_disable' WHERE meta_key = 'aiosp_disable'");
553
- echo "<div class='updated fade' style='background-color:green;border-color:green;'><p><strong>Updating SEO post meta in database.</strong></p></div";
554
- }
555
-
556
- function aioseop_get_version(){
557
- return '1.6.5';
558
- }
559
-
560
-
561
-
562
-
563
- function aioseop_mrt_mkarry() {
564
- $naioseop_options = array(
565
- "aiosp_can"=>1,
566
- "aiosp_donate"=>0,
567
- "aiosp_home_title"=>null,
568
- "aiosp_home_description"=>'',
569
- "aiosp_home_keywords"=>null,
570
- "aiosp_max_words_excerpt"=>'something',
571
- "aiosp_rewrite_titles"=>1,
572
- "aiosp_post_title_format"=>'%post_title% | %blog_title%',
573
- "aiosp_page_title_format"=>'%page_title% | %blog_title%',
574
- "aiosp_category_title_format"=>'%category_title% | %blog_title%',
575
- "aiosp_archive_title_format"=>'%date% | %blog_title%',
576
- "aiosp_tag_title_format"=>'%tag% | %blog_title%',
577
- "aiosp_search_title_format"=>'%search% | %blog_title%',
578
- "aiosp_description_format"=>'%description%',
579
- "aiosp_404_title_format"=>'Nothing found for %request_words%',
580
- "aiosp_paged_format"=>' - Part %page%',
581
- "aiosp_use_categories"=>0,
582
- "aiosp_dynamic_postspage_keywords"=>1,
583
- "aiosp_category_noindex"=>1,
584
- "aiosp_archive_noindex"=>1,
585
- "aiosp_tags_noindex"=>0,
586
- "aiosp_cap_cats"=>1,
587
- "aiosp_generate_descriptions"=>1,
588
- "aiosp_debug_info"=>null,
589
- "aiosp_post_meta_tags"=>'',
590
- "aiosp_page_meta_tags"=>'',
591
- "aiosp_home_meta_tags"=>'',
592
- "aiosp_enabled" =>0,
593
- "aiosp_do_log"=>null);
594
-
595
- if(get_option('aiosp_post_title_format')){
596
- foreach( $naioseop_options as $aioseop_opt_name => $value ) {
597
- if( $aioseop_oldval = get_option($aioseop_opt_name) ) {
598
- $naioseop_options[$aioseop_opt_name] = $aioseop_oldval;
599
-
600
- }
601
- if( $aioseop_oldval == ''){
602
- $naioseop_options[$aioseop_opt_name] = '';
603
- }
604
-
605
- delete_option($aioseop_opt_name);
606
- }
607
- }
608
- add_option('aioseop_options',$naioseop_options);
609
- echo "<div class='updated fade' style='background-color:green;border-color:green;'><p><strong>Updating SEO configuration options in database</strong></p></div";
610
-
611
- }
612
- //if( function_exists( 'is_site_admin' ) ) {
613
-
614
- function aioseop_activation_notice(){
615
- global $aioseop_options;
616
- echo '<div class="error fade" style="background-color:red;"><p><strong>All in One SEO Pack must be configured. Go to <a href="' . admin_url( 'options-general.php?page=all-in-one-seo-pack/aioseop.class.php' ) . '">the admin page</a> to enable and configure the plugin.</strong></p></div>';
617
-
618
- }
619
-
620
- //add_action('after_plugin_row_all-in-one-seo-pack/all_in_one_seo_pack.php', 'add_plugin_row', 10, 2);
621
-
622
- function add_plugin_row($links, $file) {
623
-
624
- echo '<td colspan="5" style="background-color:yellow;">';
625
- echo wp_remote_fopen('http://aioseop.semperfiwebdesign.com/');
626
- echo '</td>';
627
-
628
- }
629
- function aioseop_activate_pl(){
630
- if(get_option('aioseop_options')){
631
- $aioseop_options = get_option('aioseop_options');
632
- $aioseop_options['aiosp_enabled'] = "0";
633
- $aioseop_options['aiosp_donate'] = "0";
634
- update_option('aioseop_options',$aioseop_options);
635
- }
636
- }
637
-
638
-
639
- if($aioseop_options['aiosp_enabled']){
640
- add_action('wp_list_pages', 'aioseop_list_pages');
641
-
642
- }
643
- $aiosp = new All_in_One_SEO_Pack();
644
- add_action('edit_post', array($aiosp, 'post_meta_tags'));
645
- add_action('publish_post', array($aiosp, 'post_meta_tags'));
646
- add_action('save_post', array($aiosp, 'post_meta_tags'));
647
- add_action('edit_page_form', array($aiosp, 'post_meta_tags'));
648
- add_action('init', array($aiosp, 'init'));
649
- add_action('wp_head', array($aiosp, 'wp_head'));
650
- add_action('template_redirect', array($aiosp, 'template_redirect'));
651
- //add_action('admin_head',array($aiosp, 'seo_mrt_admin_head');
652
- add_action('admin_menu', array($aiosp, 'admin_menu'));
653
- add_action('admin_menu', 'aiosp_meta_box_add');
654
-
655
-
656
-
657
- if( ($_POST['aiosp_enabled'] == null && $aioseop_options['aiosp_enabled']!='1') || $_POST['aiosp_enabled']=='0'){
658
- add_action( 'admin_notices', 'aioseop_activation_notice');
659
- }
660
-
661
-
662
- // The following two functions copied entirely and modified slightly from Sarah G's Page Menu Editor, http://wordpress.org/extend/plugins/page-menu-editor/
663
- function aioseop_list_pages($content){
664
- $url = preg_replace(array('/\//', '/\./', '/\-/'), array('\/', '\.', '\-'), get_option('siteurl'));
665
- $pattern = '/<li class="page_item page-item-(\d+)([^\"]*)"><a href=\"([^\"]+)" title="([^\"]+)">([^<]+)<\/a>/i';
666
- return preg_replace_callback($pattern, "aioseop_filter_callback", $content);
667
- }
668
-
669
- function aioseop_filter_callback($matches) {
670
- global $wpdb;
671
- if ($matches[1] && !empty($matches[1])) $postID = $matches[1];
672
- if (empty($postID)) $postID = get_option("page_on_front");
673
- $title_attrib = stripslashes(get_post_meta($postID, '_aioseop_titleatr', true));
674
- $menulabel = stripslashes(get_post_meta($postID, '_aioseop_menulabel', true));
675
- if (empty($menulabel)) $menulabel = $matches[4];
676
- if (!empty($title_attrib)) :
677
- $filtered = '<li class="page_item page-item-'.$postID.$matches[2].'"><a href="'.$matches[3].'" title="'.$title_attrib.'">'.$menulabel.'</a>';
678
- else :
679
- $filtered = '<li class="page_item page-item-'.$postID.$matches[2].'"><a href="'.$matches[3].'">'.$menulabel.'</a>';
680
- endif;
681
- return $filtered;
682
- }
683
-
684
- if (substr($aiosp->wp_version, 0, 3) < '2.5') {
685
- add_action('dbx_post_advanced', array($aiosp, 'add_meta_tags_textinput'));
686
- add_action('dbx_page_advanced', array($aiosp, 'add_meta_tags_textinput'));
687
- }
688
-
689
-
690
-
691
-
692
- function aiosp_meta_box_add() {
693
- if ( function_exists('add_meta_box') ) {
694
- add_meta_box('aiosp',__('All in One SEO Pack', 'all_in_one_seo_pack'),'aiosp_meta','post');
695
- add_meta_box('aiosp',__('All in One SEO Pack', 'all_in_one_seo_pack'),'aiosp_meta','page');
696
- } else {
697
- add_action('dbx_post_advanced', array($aiosp, 'add_meta_tags_textinput'));
698
- add_action('dbx_page_advanced', array($aiosp, 'add_meta_tags_textinput'));
699
- }
700
- }
701
-
702
- function aiosp_meta() {
703
-
704
- global $post;
705
-
706
- $post_id = $post;
707
- if (is_object($post_id)){
708
- $post_id = $post_id->ID;
709
- }
710
- $keywords = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_keywords', true)));
711
- $title = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_title', true)));
712
- $description = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_description', true)));
713
- $aiosp_meta = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aiosp_meta', true)));
714
- $aiosp_disable = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aiosp_disable', true)));
715
- $aiosp_titleatr = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_titleatr', true)));
716
- $aiosp_menulabel = htmlspecialchars(stripcslashes(get_post_meta($post_id, '_aioseop_menulabel', true)));
717
- ?>
718
- <SCRIPT LANGUAGE="JavaScript">
719
- <!-- Begin
720
- function countChars(field,cntfield) {
721
- cntfield.value = field.value.length;
722
- }
723
- // End -->
724
- </script>
725
- <input value="aiosp_edit" type="hidden" name="aiosp_edit" />
726
-
727
- <a target="__blank" href="http://semperfiwebdesign.com/forum/"><?php _e('Click here for Support', 'all_in_one_seo_pack') ?></a>
728
- <table style="margin-bottom:40px">
729
- <tr>
730
- <th style="text-align:left;" colspan="2">
731
- </th>
732
- </tr>
733
- <tr>
734
- <th scope="row" style="text-align:right;"><?php _e('Title:', 'all_in_one_seo_pack') ?></th>
735
- <td><input value="<?php echo $title ?>" type="text" name="aiosp_title" size="62"/></td>
736
- </tr>
737
- <tr>
738
- <th scope="row" style="text-align:right;"><?php _e('Description:', 'all_in_one_seo_pack') ?></th>
739
- <td><textarea name="aiosp_description" rows="3" cols="60"
740
- onKeyDown="countChars(document.post.aiosp_description,document.post.length1)"
741
- onKeyUp="countChars(document.post.aiosp_description,document.post.length1)"><?php echo $description ?></textarea><br />
742
- <input readonly type="text" name="length1" size="3" maxlength="3" value="<?php echo strlen($description);?>" />
743
- <?php _e(' characters. Most search engines use a maximum of 160 chars for the description.', 'all_in_one_seo_pack') ?>
744
- </td>
745
- </tr>
746
- <tr>
747
- <th scope="row" style="text-align:right;"><?php _e('Keywords (comma separated):', 'all_in_one_seo_pack') ?></th>
748
- <td><input value="<?php echo $keywords ?>" type="text" name="aiosp_keywords" size="62"/></td>
749
- </tr>
750
- <input type="hidden" name="nonce-aioseop-edit" value="<?php echo wp_create_nonce('edit-aioseop-nonce') ?>" />
751
- <?php if($post->post_type=='page'){ ?>
752
- <tr>
753
- <th scope="row" style="text-align:right;"><?php _e('Title Attribute:', 'all_in_one_seo_pack') ?></th>
754
- <td><input value="<?php echo $aiosp_titleatr ?>" type="text" name="aiosp_titleatr" size="62"/></td>
755
- </tr>
756
-
757
- <tr>
758
- <th scope="row" style="text-align:right;"><?php _e('Menu Label:', 'all_in_one_seo_pack') ?></th>
759
- <td><input value="<?php echo $aiosp_menulabel ?>" type="text" name="aiosp_menulabel" size="62"/></td>
760
- </tr>
761
- <?php } ?>
762
- <tr>
763
- <th scope="row" style="text-align:right; vertical-align:top;">
764
- <?php _e('Disable on this page/post:', 'all_in_one_seo_pack')?>
765
- </th>
766
- <td>
767
- <input type="checkbox" name="aiosp_disable" <?php if ($aiosp_disable) echo "checked=\"1\""; ?>/>
768
- </td>
769
- </tr>
770
-
771
-
772
- </table>
773
- <?php
774
- }
775
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/all_in_one_seo_pack.pot DELETED
@@ -1,293 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: \n"
4
- "POT-Creation-Date: \n"
5
- "PO-Revision-Date: 2007-12-11 06:09+0200\n"
6
- "Last-Translator: Baris Unver <baris.unver@beyn.org>\n"
7
- "Language-Team: \n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=iso-8859-1\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
-
12
- msgid "All in One SEO Pack"
13
- msgstr ""
14
-
15
- msgid "Title:"
16
- msgstr ""
17
-
18
- msgid "Keywords (comma separated):"
19
- msgstr ""
20
-
21
- msgid "Description:"
22
- msgstr ""
23
-
24
- msgid " characters. Most search engines use a maximum of 160 chars for the description."
25
- msgstr ""
26
-
27
- msgid "All in One SEO"
28
- msgstr ""
29
-
30
- msgid "All in One SEO Options Updated."
31
- msgstr ""
32
-
33
- msgid "All in One SEO Plugin Options"
34
- msgstr ""
35
-
36
- msgid "This is version "
37
- msgstr ""
38
-
39
- msgid "All in One SEO Plugin Release History"
40
- msgstr ""
41
-
42
- msgid "FAQ"
43
- msgstr ""
44
-
45
- msgid "All in One SEO Plugin Feedback"
46
- msgstr ""
47
-
48
- msgid "Feedback"
49
- msgstr ""
50
-
51
- msgid "All in One SEO Plugin Translations"
52
- msgstr ""
53
-
54
- msgid "Translations"
55
- msgstr ""
56
-
57
- msgid "Click for Help!"
58
- msgstr ""
59
-
60
- msgid "Home Title:"
61
- msgstr ""
62
-
63
- msgid "As the name implies, this will be the title of your homepage. This is independent of any other option. If not set, the default blog title will get used."
64
- msgstr ""
65
-
66
- msgid "Home Description:"
67
- msgstr ""
68
-
69
- msgid "The META description for your homepage. Independent of any other options, the default is no META description at all if this is not set."
70
- msgstr ""
71
-
72
- msgid "Home Keywords (comma separated):"
73
- msgstr ""
74
-
75
- msgid "A comma separated list of your most important keywords for your site that will be written as META keywords on your homepage. Don't stuff everything in here."
76
- msgstr ""
77
-
78
- msgid "Rewrite Titles:"
79
- msgstr ""
80
-
81
- msgid "Note that this is all about the title tag. This is what you see in your browser's window title bar. This is NOT visible on a page, only in the window title bar and of course in the source. If set, all page, post, category, search and archive page titles get rewritten. You can specify the format for most of them. For example: The default templates puts the title tag of posts like this: \"Blog Archive >> Blog Name >> Post Title\" (maybe I've overdone slightly). This is far from optimal. With the default post title format, Rewrite Title rewrites this to \"Post Title | Blog Name\". If you have manually defined a title (in one of the text fields for All in One SEO Plugin input) this will become the title of your post in the format string."
82
- msgstr ""
83
-
84
- msgid "Post Title Format:"
85
- msgstr ""
86
-
87
- msgid "The following macros are supported:"
88
- msgstr ""
89
-
90
- msgid "%blog_title% - Your blog title"
91
- msgstr ""
92
-
93
- msgid "%blog_description% - Your blog description"
94
- msgstr ""
95
-
96
- msgid "%post_title% - The original title of the post"
97
- msgstr ""
98
-
99
- msgid "%category_title% - The (main) category of the post"
100
- msgstr ""
101
-
102
- msgid "%category% - Alias for %category_title%"
103
- msgstr ""
104
-
105
- msgid "Page Title Format:"
106
- msgstr ""
107
-
108
- msgid "%page_title% - The original title of the page"
109
- msgstr ""
110
-
111
- msgid "Category Title Format:"
112
- msgstr ""
113
-
114
- msgid "%category_title% - The original title of the category"
115
- msgstr ""
116
-
117
- msgid "%category_description% - The description of the category"
118
- msgstr ""
119
-
120
- msgid "Archive Title Format:"
121
- msgstr ""
122
-
123
- msgid "%date% - The original archive title given by wordpress, e.g. \"2007\" or \"2007 August\""
124
- msgstr ""
125
-
126
- msgid "Tag Title Format:"
127
- msgstr ""
128
-
129
- msgid "%tag% - The name of the tag"
130
- msgstr ""
131
-
132
- msgid "Search Title Format:"
133
- msgstr ""
134
-
135
- msgid "%search% - What was searched for"
136
- msgstr ""
137
-
138
- msgid "Description Format:"
139
- msgstr ""
140
-
141
- msgid "%description% - The original description as determined by the plugin, e.g. the excerpt if one is set or an auto-generated one if that option is set"
142
- msgstr ""
143
-
144
- msgid "404 Title Format:"
145
- msgstr ""
146
-
147
- msgid "%request_url% - The original URL path, like \"/url-that-does-not-exist/\""
148
- msgstr ""
149
-
150
- msgid "%request_words% - The URL path in human readable form, like \"Url That Does Not Exist\""
151
- msgstr ""
152
-
153
- msgid "Use Categories for META keywords:"
154
- msgstr ""
155
-
156
- msgid "Check this if you want your categories for a given post used as the META keywords for this post (in addition to any keywords and tags you specify on the post edit page)."
157
- msgstr ""
158
-
159
- msgid "Use noindex for Categories:"
160
- msgstr ""
161
-
162
- msgid "Check this for excluding category pages from being crawled. Useful for avoiding duplicate content."
163
- msgstr ""
164
-
165
- msgid "Use noindex for Archives:"
166
- msgstr ""
167
-
168
- msgid "Check this for excluding archive pages from being crawled. Useful for avoiding duplicate content."
169
- msgstr ""
170
-
171
- msgid "Use noindex for Tag Archives:"
172
- msgstr ""
173
-
174
- msgid "Check this for excluding tag pages from being crawled. Useful for avoiding duplicate content."
175
- msgstr ""
176
-
177
- msgid "Autogenerate Descriptions:"
178
- msgstr ""
179
-
180
- msgid "Check this and your META descriptions will get autogenerated if there's no excerpt."
181
- msgstr ""
182
-
183
- msgid "Update Options"
184
- msgstr ""
185
-
186
- msgid "Additional Post Headers:"
187
- msgstr ""
188
-
189
- msgid "Additional Page Headers:"
190
- msgstr ""
191
-
192
- msgid "What you enter here will be copied verbatim to your header on post pages. You can enter whatever additional headers you want here, even references to stylesheets."
193
- msgstr ""
194
-
195
- msgid "What you enter here will be copied verbatim to your header on pages. You can enter whatever additional headers you want here, even references to stylesheets."
196
- msgstr ""
197
-
198
- msgid "%wp_title% - The original wordpress title, e.g. post_title for posts"
199
- msgstr ""
200
-
201
- msgid "Upgraded to newest version. Please revisit the options page to make sure you see the newest version."
202
- msgstr ""
203
-
204
- msgid "Upgrade failed"
205
- msgstr ""
206
-
207
- msgid "(Remember: Backup early, backup often!)"
208
- msgstr ""
209
-
210
- msgid "Please make sure that %s is writable."
211
- msgstr ""
212
-
213
- msgid "One Click Upgrade"
214
- msgstr ""
215
-
216
- msgid "Should I upgrade?"
217
- msgstr ""
218
-
219
- msgid "Additional META:"
220
- msgstr ""
221
-
222
- msgid "Could not download distribution (%s)"
223
- msgstr ""
224
-
225
- msgid "Could not download distribution (%s): %s"
226
- msgstr ""
227
-
228
- msgid "Could not open %s for writing"
229
- msgstr ""
230
-
231
- msgid "Please make sure %s is writable"
232
- msgstr ""
233
-
234
- msgid "Could not write to %s"
235
- msgstr ""
236
-
237
- msgid "Disable on this page/post:"
238
- msgstr ""
239
-
240
- msgid "Paged Format:"
241
- msgstr ""
242
-
243
- msgid "This string gets appended/prepended to titles when they are for paged index pages (like home or archive pages)."
244
- msgstr ""
245
-
246
- msgid "%page% - The page number"
247
- msgstr ""
248
-
249
- msgid "Part %page%"
250
- msgstr ""
251
-
252
- msgid "Log important events:"
253
- msgstr ""
254
-
255
- msgid "Check this and SEO pack will create a log of important events (all_in_one_seo_pack.log) in its plugin directory which might help debugging it. Make sure this directory is writable."
256
- msgstr ""
257
-
258
- msgid "%page_author_login% - This page's author' login"
259
- msgstr ""
260
-
261
- msgid "%page_author_nicename% - This page's author' nicename"
262
- msgstr ""
263
-
264
- msgid "%page_author_firstname% - This page's author' first name (capitalized)"
265
- msgstr ""
266
-
267
- msgid "%page_author_lastname% - This page's author' last name (capitalized)"
268
- msgstr ""
269
-
270
- msgid "%post_author_login% - This post's author' login"
271
- msgstr ""
272
-
273
- msgid "%post_author_nicename% - This post's author' nicename"
274
- msgstr ""
275
-
276
- msgid "%post_author_firstname% - This post's author' first name (capitalized)"
277
- msgstr ""
278
-
279
- msgid "%post_author_lastname% - This post's author' last name (capitalized)"
280
- msgstr ""
281
-
282
- msgid "Additional Home Headers:"
283
- msgstr ""
284
-
285
- msgid "What you enter here will be copied verbatim to your header on the home page. You can enter whatever additional headers you want here, even references to stylesheets."
286
- msgstr ""
287
-
288
- msgid "Click here for Support"
289
- msgstr ""
290
-
291
- msgid "You can click on option titles to get help!"
292
- msgstr ""
293
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/images/twitter.png DELETED
Binary file
trunk/pclzip.lib.php DELETED
@@ -1,5651 +0,0 @@
1
- <?php
2
- // --------------------------------------------------------------------------------
3
- // PhpConcept Library - Zip Module 2.5
4
- // --------------------------------------------------------------------------------
5
- // License GNU/LGPL - Vincent Blavet - March 2006
6
- // http://www.phpconcept.net
7
- // --------------------------------------------------------------------------------
8
- //
9
- // Presentation :
10
- // PclZip is a PHP library that manage ZIP archives.
11
- // So far tests show that archives generated by PclZip are readable by
12
- // WinZip application and other tools.
13
- //
14
- // Description :
15
- // See readme.txt and http://www.phpconcept.net
16
- //
17
- // Warning :
18
- // This library and the associated files are non commercial, non professional
19
- // work.
20
- // It should not have unexpected results. However if any damage is caused by
21
- // this software the author can not be responsible.
22
- // The use of this software is at the risk of the user.
23
- //
24
- // --------------------------------------------------------------------------------
25
- // $Id: pclzip.lib.php,v 1.44 2006/03/08 21:23:59 vblavet Exp $
26
- // --------------------------------------------------------------------------------
27
-
28
- // ----- Constants
29
- define( 'PCLZIP_READ_BLOCK_SIZE', 2048 );
30
-
31
- define( 'PCLZIP_SEPARATOR', ',' );
32
-
33
- define( 'PCLZIP_ERROR_EXTERNAL', 0 );
34
-
35
- define( 'PCLZIP_TEMPORARY_DIR', '' );
36
-
37
- // --------------------------------------------------------------------------------
38
- // ***** UNDER THIS LINE NOTHING NEEDS TO BE MODIFIED *****
39
- // --------------------------------------------------------------------------------
40
-
41
- // ----- Global variables
42
- $g_pclzip_version = "2.5";
43
-
44
- define( 'PCLZIP_ERR_USER_ABORTED', 2 );
45
- define( 'PCLZIP_ERR_NO_ERROR', 0 );
46
- define( 'PCLZIP_ERR_WRITE_OPEN_FAIL', -1 );
47
- define( 'PCLZIP_ERR_READ_OPEN_FAIL', -2 );
48
- define( 'PCLZIP_ERR_INVALID_PARAMETER', -3 );
49
- define( 'PCLZIP_ERR_MISSING_FILE', -4 );
50
- define( 'PCLZIP_ERR_FILENAME_TOO_LONG', -5 );
51
- define( 'PCLZIP_ERR_INVALID_ZIP', -6 );
52
- define( 'PCLZIP_ERR_BAD_EXTRACTED_FILE', -7 );
53
- define( 'PCLZIP_ERR_DIR_CREATE_FAIL', -8 );
54
- define( 'PCLZIP_ERR_BAD_EXTENSION', -9 );
55
- define( 'PCLZIP_ERR_BAD_FORMAT', -10 );
56
- define( 'PCLZIP_ERR_DELETE_FILE_FAIL', -11 );
57
- define( 'PCLZIP_ERR_RENAME_FILE_FAIL', -12 );
58
- define( 'PCLZIP_ERR_BAD_CHECKSUM', -13 );
59
- define( 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP', -14 );
60
- define( 'PCLZIP_ERR_MISSING_OPTION_VALUE', -15 );
61
- define( 'PCLZIP_ERR_INVALID_OPTION_VALUE', -16 );
62
- define( 'PCLZIP_ERR_ALREADY_A_DIRECTORY', -17 );
63
- define( 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION', -18 );
64
- define( 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION', -19 );
65
- define( 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE', -20 );
66
- define( 'PCLZIP_ERR_DIRECTORY_RESTRICTION', -21 );
67
-
68
- // ----- Options values
69
- define( 'PCLZIP_OPT_PATH', 77001 );
70
- define( 'PCLZIP_OPT_ADD_PATH', 77002 );
71
- define( 'PCLZIP_OPT_REMOVE_PATH', 77003 );
72
- define( 'PCLZIP_OPT_REMOVE_ALL_PATH', 77004 );
73
- define( 'PCLZIP_OPT_SET_CHMOD', 77005 );
74
- define( 'PCLZIP_OPT_EXTRACT_AS_STRING', 77006 );
75
- define( 'PCLZIP_OPT_NO_COMPRESSION', 77007 );
76
- define( 'PCLZIP_OPT_BY_NAME', 77008 );
77
- define( 'PCLZIP_OPT_BY_INDEX', 77009 );
78
- define( 'PCLZIP_OPT_BY_EREG', 77010 );
79
- define( 'PCLZIP_OPT_BY_PREG', 77011 );
80
- define( 'PCLZIP_OPT_COMMENT', 77012 );
81
- define( 'PCLZIP_OPT_ADD_COMMENT', 77013 );
82
- define( 'PCLZIP_OPT_PREPEND_COMMENT', 77014 );
83
- define( 'PCLZIP_OPT_EXTRACT_IN_OUTPUT', 77015 );
84
- define( 'PCLZIP_OPT_REPLACE_NEWER', 77016 );
85
- define( 'PCLZIP_OPT_STOP_ON_ERROR', 77017 );
86
- // Having big trouble with crypt. Need to multiply 2 long int
87
- // which is not correctly supported by PHP ...
88
- //define( 'PCLZIP_OPT_CRYPT', 77018 );
89
- define( 'PCLZIP_OPT_EXTRACT_DIR_RESTRICTION', 77019 );
90
-
91
- // ----- File description attributes
92
- define( 'PCLZIP_ATT_FILE_NAME', 79001 );
93
- define( 'PCLZIP_ATT_FILE_NEW_SHORT_NAME', 79002 );
94
- define( 'PCLZIP_ATT_FILE_NEW_FULL_NAME', 79003 );
95
-
96
- // ----- Call backs values
97
- define( 'PCLZIP_CB_PRE_EXTRACT', 78001 );
98
- define( 'PCLZIP_CB_POST_EXTRACT', 78002 );
99
- define( 'PCLZIP_CB_PRE_ADD', 78003 );
100
- define( 'PCLZIP_CB_POST_ADD', 78004 );
101
-
102
- class PclZip
103
- {
104
- // ----- Filename of the zip file
105
- var $zipname = '';
106
-
107
- // ----- File descriptor of the zip file
108
- var $zip_fd = 0;
109
-
110
- // ----- Internal error handling
111
- var $error_code = 1;
112
- var $error_string = '';
113
-
114
- // ----- Current status of the magic_quotes_runtime
115
- // This value store the php configuration for magic_quotes
116
- // The class can then disable the magic_quotes and reset it after
117
- var $magic_quotes_status;
118
-
119
- // --------------------------------------------------------------------------------
120
- // Function : PclZip()
121
- // Description :
122
- // Creates a PclZip object and set the name of the associated Zip archive
123
- // filename.
124
- // Note that no real action is taken, if the archive does not exist it is not
125
- // created. Use create() for that.
126
- // --------------------------------------------------------------------------------
127
- function PclZip($p_zipname)
128
- {
129
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::PclZip', "zipname=$p_zipname");
130
-
131
- // ----- Tests the zlib
132
- if (!function_exists('gzopen'))
133
- {
134
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 1, "zlib extension seems to be missing");
135
- die('Abort '.basename(__FILE__).' : Missing zlib extensions');
136
- }
137
-
138
- // ----- Set the attributes
139
- $this->zipname = $p_zipname;
140
- $this->zip_fd = 0;
141
- $this->magic_quotes_status = -1;
142
-
143
- // ----- Return
144
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 1);
145
- return;
146
- }
147
-
148
- function create($p_filelist)
149
- {
150
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::create', "filelist='$p_filelist', ...");
151
- $v_result=1;
152
-
153
- // ----- Reset the error handler
154
- $this->privErrorReset();
155
-
156
- // ----- Set default values
157
- $v_options = array();
158
- $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
159
-
160
- // ----- Look for variable options arguments
161
- $v_size = func_num_args();
162
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
163
-
164
- // ----- Look for arguments
165
- if ($v_size > 1) {
166
- // ----- Get the arguments
167
- $v_arg_list = func_get_args();
168
-
169
- // ----- Remove from the options list the first argument
170
- array_shift($v_arg_list);
171
- $v_size--;
172
-
173
- // ----- Look for first arg
174
- if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
175
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");
176
-
177
- // ----- Parse the options
178
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
179
- array (PCLZIP_OPT_REMOVE_PATH => 'optional',
180
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
181
- PCLZIP_OPT_ADD_PATH => 'optional',
182
- PCLZIP_CB_PRE_ADD => 'optional',
183
- PCLZIP_CB_POST_ADD => 'optional',
184
- PCLZIP_OPT_NO_COMPRESSION => 'optional',
185
- PCLZIP_OPT_COMMENT => 'optional'
186
- //, PCLZIP_OPT_CRYPT => 'optional'
187
- ));
188
- if ($v_result != 1) {
189
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
190
- return 0;
191
- }
192
- }
193
-
194
- // ----- Look for 2 args
195
- // Here we need to support the first historic synopsis of the
196
- // method.
197
- else {
198
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
199
-
200
- // ----- Get the first argument
201
- $v_options[PCLZIP_OPT_ADD_PATH] = $v_arg_list[0];
202
-
203
- // ----- Look for the optional second argument
204
- if ($v_size == 2) {
205
- $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
206
- }
207
- else if ($v_size > 2) {
208
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
209
- "Invalid number / type of arguments");
210
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
211
- return 0;
212
- }
213
- }
214
- }
215
-
216
- // ----- Init
217
- $v_string_list = array();
218
- $v_att_list = array();
219
- $v_filedescr_list = array();
220
- $p_result_list = array();
221
-
222
- // ----- Look if the $p_filelist is really an array
223
- if (is_array($p_filelist)) {
224
-
225
- // ----- Look if the first element is also an array
226
- // This will mean that this is a file description entry
227
- if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
228
- $v_att_list = $p_filelist;
229
- }
230
-
231
- // ----- The list is a list of string names
232
- else {
233
- $v_string_list = $p_filelist;
234
- }
235
- }
236
-
237
- // ----- Look if the $p_filelist is a string
238
- else if (is_string($p_filelist)) {
239
- // ----- Create a list from the string
240
- $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
241
- }
242
-
243
- // ----- Invalid variable type for $p_filelist
244
- else {
245
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_filelist");
246
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
247
- return 0;
248
- }
249
-
250
- // ----- Reformat the string list
251
- if (sizeof($v_string_list) != 0) {
252
- foreach ($v_string_list as $v_string) {
253
- if ($v_string != '') {
254
- $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
255
- }
256
- else {
257
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Ignore an empty filename");
258
- }
259
- }
260
- }
261
-
262
- // ----- For each file in the list check the attributes
263
- $v_supported_attributes
264
- = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
265
- ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
266
- ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
267
- );
268
- foreach ($v_att_list as $v_entry) {
269
- $v_result = $this->privFileDescrParseAtt($v_entry,
270
- $v_filedescr_list[],
271
- $v_options,
272
- $v_supported_attributes);
273
- if ($v_result != 1) {
274
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
275
- return 0;
276
- }
277
- }
278
-
279
- // ----- Expand the filelist (expand directories)
280
- $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
281
- if ($v_result != 1) {
282
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
283
- return 0;
284
- }
285
-
286
- // ----- Call the create fct
287
- $v_result = $this->privCreate($v_filedescr_list, $p_result_list, $v_options);
288
- if ($v_result != 1) {
289
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
290
- return 0;
291
- }
292
-
293
- // ----- Return
294
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);
295
- return $p_result_list;
296
- }
297
- // --------------------------------------------------------------------------------
298
-
299
- // --------------------------------------------------------------------------------
300
- // Function :
301
- // add($p_filelist, $p_add_dir="", $p_remove_dir="")
302
- // add($p_filelist, $p_option, $p_option_value, ...)
303
- // Description :
304
- // This method supports two synopsis. The first one is historical.
305
- // This methods add the list of files in an existing archive.
306
- // If a file with the same name already exists, it is added at the end of the
307
- // archive, the first one is still present.
308
- // If the archive does not exist, it is created.
309
- // Parameters :
310
- // $p_filelist : An array containing file or directory names, or
311
- // a string containing one filename or one directory name, or
312
- // a string containing a list of filenames and/or directory
313
- // names separated by spaces.
314
- // $p_add_dir : A path to add before the real path of the archived file,
315
- // in order to have it memorized in the archive.
316
- // $p_remove_dir : A path to remove from the real path of the file to archive,
317
- // in order to have a shorter path memorized in the archive.
318
- // When $p_add_dir and $p_remove_dir are set, $p_remove_dir
319
- // is removed first, before $p_add_dir is added.
320
- // Options :
321
- // PCLZIP_OPT_ADD_PATH :
322
- // PCLZIP_OPT_REMOVE_PATH :
323
- // PCLZIP_OPT_REMOVE_ALL_PATH :
324
- // PCLZIP_OPT_COMMENT :
325
- // PCLZIP_OPT_ADD_COMMENT :
326
- // PCLZIP_OPT_PREPEND_COMMENT :
327
- // PCLZIP_CB_PRE_ADD :
328
- // PCLZIP_CB_POST_ADD :
329
- // Return Values :
330
- // 0 on failure,
331
- // The list of the added files, with a status of the add action.
332
- // (see PclZip::listContent() for list entry format)
333
- // --------------------------------------------------------------------------------
334
- function add($p_filelist)
335
- {
336
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::add', "filelist='$p_filelist', ...");
337
- $v_result=1;
338
-
339
- // ----- Reset the error handler
340
- $this->privErrorReset();
341
-
342
- // ----- Set default values
343
- $v_options = array();
344
- $v_options[PCLZIP_OPT_NO_COMPRESSION] = FALSE;
345
-
346
- // ----- Look for variable options arguments
347
- $v_size = func_num_args();
348
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
349
-
350
- // ----- Look for arguments
351
- if ($v_size > 1) {
352
- // ----- Get the arguments
353
- $v_arg_list = func_get_args();
354
-
355
- // ----- Remove form the options list the first argument
356
- array_shift($v_arg_list);
357
- $v_size--;
358
-
359
- // ----- Look for first arg
360
- if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
361
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options detected");
362
-
363
- // ----- Parse the options
364
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
365
- array (PCLZIP_OPT_REMOVE_PATH => 'optional',
366
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
367
- PCLZIP_OPT_ADD_PATH => 'optional',
368
- PCLZIP_CB_PRE_ADD => 'optional',
369
- PCLZIP_CB_POST_ADD => 'optional',
370
- PCLZIP_OPT_NO_COMPRESSION => 'optional',
371
- PCLZIP_OPT_COMMENT => 'optional',
372
- PCLZIP_OPT_ADD_COMMENT => 'optional',
373
- PCLZIP_OPT_PREPEND_COMMENT => 'optional'
374
- //, PCLZIP_OPT_CRYPT => 'optional'
375
- ));
376
- if ($v_result != 1) {
377
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
378
- return 0;
379
- }
380
- }
381
-
382
- // ----- Look for 2 args
383
- // Here we need to support the first historic synopsis of the
384
- // method.
385
- else {
386
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
387
-
388
- // ----- Get the first argument
389
- $v_options[PCLZIP_OPT_ADD_PATH] = $v_add_path = $v_arg_list[0];
390
-
391
- // ----- Look for the optional second argument
392
- if ($v_size == 2) {
393
- $v_options[PCLZIP_OPT_REMOVE_PATH] = $v_arg_list[1];
394
- }
395
- else if ($v_size > 2) {
396
- // ----- Error log
397
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
398
-
399
- // ----- Return
400
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
401
- return 0;
402
- }
403
- }
404
- }
405
-
406
- // ----- Init
407
- $v_string_list = array();
408
- $v_att_list = array();
409
- $v_filedescr_list = array();
410
- $p_result_list = array();
411
-
412
- // ----- Look if the $p_filelist is really an array
413
- if (is_array($p_filelist)) {
414
-
415
- // ----- Look if the first element is also an array
416
- // This will mean that this is a file description entry
417
- if (isset($p_filelist[0]) && is_array($p_filelist[0])) {
418
- $v_att_list = $p_filelist;
419
- }
420
-
421
- // ----- The list is a list of string names
422
- else {
423
- $v_string_list = $p_filelist;
424
- }
425
- }
426
-
427
- // ----- Look if the $p_filelist is a string
428
- else if (is_string($p_filelist)) {
429
- // ----- Create a list from the string
430
- $v_string_list = explode(PCLZIP_SEPARATOR, $p_filelist);
431
- }
432
-
433
- // ----- Invalid variable type for $p_filelist
434
- else {
435
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type '".gettype($p_filelist)."' for p_filelist");
436
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
437
- return 0;
438
- }
439
-
440
- // ----- Reformat the string list
441
- if (sizeof($v_string_list) != 0) {
442
- foreach ($v_string_list as $v_string) {
443
- $v_att_list[][PCLZIP_ATT_FILE_NAME] = $v_string;
444
- }
445
- }
446
-
447
- // ----- For each file in the list check the attributes
448
- $v_supported_attributes
449
- = array ( PCLZIP_ATT_FILE_NAME => 'mandatory'
450
- ,PCLZIP_ATT_FILE_NEW_SHORT_NAME => 'optional'
451
- ,PCLZIP_ATT_FILE_NEW_FULL_NAME => 'optional'
452
- );
453
- foreach ($v_att_list as $v_entry) {
454
- $v_result = $this->privFileDescrParseAtt($v_entry,
455
- $v_filedescr_list[],
456
- $v_options,
457
- $v_supported_attributes);
458
- if ($v_result != 1) {
459
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
460
- return 0;
461
- }
462
- }
463
-
464
- // ----- Expand the filelist (expand directories)
465
- $v_result = $this->privFileDescrExpand($v_filedescr_list, $v_options);
466
- if ($v_result != 1) {
467
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
468
- return 0;
469
- }
470
-
471
- // ----- Call the create fct
472
- $v_result = $this->privAdd($v_filedescr_list, $p_result_list, $v_options);
473
- if ($v_result != 1) {
474
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
475
- return 0;
476
- }
477
-
478
- // ----- Return
479
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_result_list);
480
- return $p_result_list;
481
- }
482
- // --------------------------------------------------------------------------------
483
-
484
- // --------------------------------------------------------------------------------
485
- // Function : listContent()
486
- // Description :
487
- // This public method, gives the list of the files and directories, with their
488
- // properties.
489
- // The properties of each entries in the list are (used also in other functions) :
490
- // filename : Name of the file. For a create or add action it is the filename
491
- // given by the user. For an extract function it is the filename
492
- // of the extracted file.
493
- // stored_filename : Name of the file / directory stored in the archive.
494
- // size : Size of the stored file.
495
- // compressed_size : Size of the file's data compressed in the archive
496
- // (without the headers overhead)
497
- // mtime : Last known modification date of the file (UNIX timestamp)
498
- // comment : Comment associated with the file
499
- // folder : true | false
500
- // index : index of the file in the archive
501
- // status : status of the action (depending of the action) :
502
- // Values are :
503
- // ok : OK !
504
- // filtered : the file / dir is not extracted (filtered by user)
505
- // already_a_directory : the file can not be extracted because a
506
- // directory with the same name already exists
507
- // write_protected : the file can not be extracted because a file
508
- // with the same name already exists and is
509
- // write protected
510
- // newer_exist : the file was not extracted because a newer file exists
511
- // path_creation_fail : the file is not extracted because the folder
512
- // does not exists and can not be created
513
- // write_error : the file was not extracted because there was a
514
- // error while writing the file
515
- // read_error : the file was not extracted because there was a error
516
- // while reading the file
517
- // invalid_header : the file was not extracted because of an archive
518
- // format error (bad file header)
519
- // Note that each time a method can continue operating when there
520
- // is an action error on a file, the error is only logged in the file status.
521
- // Return Values :
522
- // 0 on an unrecoverable failure,
523
- // The list of the files in the archive.
524
- // --------------------------------------------------------------------------------
525
- function listContent()
526
- {
527
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::listContent', "");
528
- $v_result=1;
529
-
530
- // ----- Reset the error handler
531
- $this->privErrorReset();
532
-
533
- // ----- Check archive
534
- if (!$this->privCheckFormat()) {
535
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
536
- return(0);
537
- }
538
-
539
- // ----- Call the extracting fct
540
- $p_list = array();
541
- if (($v_result = $this->privList($p_list)) != 1)
542
- {
543
- unset($p_list);
544
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
545
- return(0);
546
- }
547
-
548
- // ----- Return
549
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
550
- return $p_list;
551
- }
552
- // --------------------------------------------------------------------------------
553
-
554
- // --------------------------------------------------------------------------------
555
- // Function :
556
- // extract($p_path="./", $p_remove_path="")
557
- // extract([$p_option, $p_option_value, ...])
558
- // Description :
559
- // This method supports two synopsis. The first one is historical.
560
- // This method extract all the files / directories from the archive to the
561
- // folder indicated in $p_path.
562
- // If you want to ignore the 'root' part of path of the memorized files
563
- // you can indicate this in the optional $p_remove_path parameter.
564
- // By default, if a newer file with the same name already exists, the
565
- // file is not extracted.
566
- //
567
- // If both PCLZIP_OPT_PATH and PCLZIP_OPT_ADD_PATH aoptions
568
- // are used, the path indicated in PCLZIP_OPT_ADD_PATH is append
569
- // at the end of the path value of PCLZIP_OPT_PATH.
570
- // Parameters :
571
- // $p_path : Path where the files and directories are to be extracted
572
- // $p_remove_path : First part ('root' part) of the memorized path
573
- // (if any similar) to remove while extracting.
574
- // Options :
575
- // PCLZIP_OPT_PATH :
576
- // PCLZIP_OPT_ADD_PATH :
577
- // PCLZIP_OPT_REMOVE_PATH :
578
- // PCLZIP_OPT_REMOVE_ALL_PATH :
579
- // PCLZIP_CB_PRE_EXTRACT :
580
- // PCLZIP_CB_POST_EXTRACT :
581
- // Return Values :
582
- // 0 or a negative value on failure,
583
- // The list of the extracted files, with a status of the action.
584
- // (see PclZip::listContent() for list entry format)
585
- // --------------------------------------------------------------------------------
586
- function extract()
587
- {
588
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extract", "");
589
- $v_result=1;
590
-
591
- // ----- Reset the error handler
592
- $this->privErrorReset();
593
-
594
- // ----- Check archive
595
- if (!$this->privCheckFormat()) {
596
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
597
- return(0);
598
- }
599
-
600
- // ----- Set default values
601
- $v_options = array();
602
- // $v_path = "./";
603
- $v_path = '';
604
- $v_remove_path = "";
605
- $v_remove_all_path = false;
606
-
607
- // ----- Look for variable options arguments
608
- $v_size = func_num_args();
609
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
610
-
611
- // ----- Default values for option
612
- $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
613
-
614
- // ----- Look for arguments
615
- if ($v_size > 0) {
616
- // ----- Get the arguments
617
- $v_arg_list = func_get_args();
618
-
619
- // ----- Look for first arg
620
- if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
621
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");
622
-
623
- // ----- Parse the options
624
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
625
- array (PCLZIP_OPT_PATH => 'optional',
626
- PCLZIP_OPT_REMOVE_PATH => 'optional',
627
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
628
- PCLZIP_OPT_ADD_PATH => 'optional',
629
- PCLZIP_CB_PRE_EXTRACT => 'optional',
630
- PCLZIP_CB_POST_EXTRACT => 'optional',
631
- PCLZIP_OPT_SET_CHMOD => 'optional',
632
- PCLZIP_OPT_BY_NAME => 'optional',
633
- PCLZIP_OPT_BY_EREG => 'optional',
634
- PCLZIP_OPT_BY_PREG => 'optional',
635
- PCLZIP_OPT_BY_INDEX => 'optional',
636
- PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
637
- PCLZIP_OPT_EXTRACT_IN_OUTPUT => 'optional',
638
- PCLZIP_OPT_REPLACE_NEWER => 'optional'
639
- ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
640
- ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional'
641
- ));
642
- if ($v_result != 1) {
643
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
644
- return 0;
645
- }
646
-
647
- // ----- Set the arguments
648
- if (isset($v_options[PCLZIP_OPT_PATH])) {
649
- $v_path = $v_options[PCLZIP_OPT_PATH];
650
- }
651
- if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
652
- $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
653
- }
654
- if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
655
- $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
656
- }
657
- if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
658
- // ----- Check for '/' in last path char
659
- if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
660
- $v_path .= '/';
661
- }
662
- $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
663
- }
664
- }
665
-
666
- // ----- Look for 2 args
667
- // Here we need to support the first historic synopsis of the
668
- // method.
669
- else {
670
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
671
-
672
- // ----- Get the first argument
673
- $v_path = $v_arg_list[0];
674
-
675
- // ----- Look for the optional second argument
676
- if ($v_size == 2) {
677
- $v_remove_path = $v_arg_list[1];
678
- }
679
- else if ($v_size > 2) {
680
- // ----- Error log
681
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
682
-
683
- // ----- Return
684
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
685
- return 0;
686
- }
687
- }
688
- }
689
-
690
- // ----- Trace
691
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");
692
-
693
- // ----- Call the extracting fct
694
- $p_list = array();
695
- $v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path,
696
- $v_remove_all_path, $v_options);
697
- if ($v_result < 1) {
698
- unset($p_list);
699
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
700
- return(0);
701
- }
702
-
703
- // ----- Return
704
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
705
- return $p_list;
706
- }
707
- // --------------------------------------------------------------------------------
708
-
709
-
710
- // --------------------------------------------------------------------------------
711
- // Function :
712
- // extractByIndex($p_index, $p_path="./", $p_remove_path="")
713
- // extractByIndex($p_index, [$p_option, $p_option_value, ...])
714
- // Description :
715
- // This method supports two synopsis. The first one is historical.
716
- // This method is doing a partial extract of the archive.
717
- // The extracted files or folders are identified by their index in the
718
- // archive (from 0 to n).
719
- // Note that if the index identify a folder, only the folder entry is
720
- // extracted, not all the files included in the archive.
721
- // Parameters :
722
- // $p_index : A single index (integer) or a string of indexes of files to
723
- // extract. The form of the string is "0,4-6,8-12" with only numbers
724
- // and '-' for range or ',' to separate ranges. No spaces or ';'
725
- // are allowed.
726
- // $p_path : Path where the files and directories are to be extracted
727
- // $p_remove_path : First part ('root' part) of the memorized path
728
- // (if any similar) to remove while extracting.
729
- // Options :
730
- // PCLZIP_OPT_PATH :
731
- // PCLZIP_OPT_ADD_PATH :
732
- // PCLZIP_OPT_REMOVE_PATH :
733
- // PCLZIP_OPT_REMOVE_ALL_PATH :
734
- // PCLZIP_OPT_EXTRACT_AS_STRING : The files are extracted as strings and
735
- // not as files.
736
- // The resulting content is in a new field 'content' in the file
737
- // structure.
738
- // This option must be used alone (any other options are ignored).
739
- // PCLZIP_CB_PRE_EXTRACT :
740
- // PCLZIP_CB_POST_EXTRACT :
741
- // Return Values :
742
- // 0 on failure,
743
- // The list of the extracted files, with a status of the action.
744
- // (see PclZip::listContent() for list entry format)
745
- // --------------------------------------------------------------------------------
746
- //function extractByIndex($p_index, options...)
747
- function extractByIndex($p_index)
748
- {
749
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::extractByIndex", "index='$p_index', ...");
750
- $v_result=1;
751
-
752
- // ----- Reset the error handler
753
- $this->privErrorReset();
754
-
755
- // ----- Check archive
756
- if (!$this->privCheckFormat()) {
757
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
758
- return(0);
759
- }
760
-
761
- // ----- Set default values
762
- $v_options = array();
763
- // $v_path = "./";
764
- $v_path = '';
765
- $v_remove_path = "";
766
- $v_remove_all_path = false;
767
-
768
- // ----- Look for variable options arguments
769
- $v_size = func_num_args();
770
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
771
-
772
- // ----- Default values for option
773
- $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
774
-
775
- // ----- Look for arguments
776
- if ($v_size > 1) {
777
- // ----- Get the arguments
778
- $v_arg_list = func_get_args();
779
-
780
- // ----- Remove form the options list the first argument
781
- array_shift($v_arg_list);
782
- $v_size--;
783
-
784
- // ----- Look for first arg
785
- if ((is_integer($v_arg_list[0])) && ($v_arg_list[0] > 77000)) {
786
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Variable list of options");
787
-
788
- // ----- Parse the options
789
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
790
- array (PCLZIP_OPT_PATH => 'optional',
791
- PCLZIP_OPT_REMOVE_PATH => 'optional',
792
- PCLZIP_OPT_REMOVE_ALL_PATH => 'optional',
793
- PCLZIP_OPT_EXTRACT_AS_STRING => 'optional',
794
- PCLZIP_OPT_ADD_PATH => 'optional',
795
- PCLZIP_CB_PRE_EXTRACT => 'optional',
796
- PCLZIP_CB_POST_EXTRACT => 'optional',
797
- PCLZIP_OPT_SET_CHMOD => 'optional',
798
- PCLZIP_OPT_REPLACE_NEWER => 'optional'
799
- ,PCLZIP_OPT_STOP_ON_ERROR => 'optional'
800
- ,PCLZIP_OPT_EXTRACT_DIR_RESTRICTION => 'optional'
801
- ));
802
- if ($v_result != 1) {
803
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
804
- return 0;
805
- }
806
-
807
- // ----- Set the arguments
808
- if (isset($v_options[PCLZIP_OPT_PATH])) {
809
- $v_path = $v_options[PCLZIP_OPT_PATH];
810
- }
811
- if (isset($v_options[PCLZIP_OPT_REMOVE_PATH])) {
812
- $v_remove_path = $v_options[PCLZIP_OPT_REMOVE_PATH];
813
- }
814
- if (isset($v_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
815
- $v_remove_all_path = $v_options[PCLZIP_OPT_REMOVE_ALL_PATH];
816
- }
817
- if (isset($v_options[PCLZIP_OPT_ADD_PATH])) {
818
- // ----- Check for '/' in last path char
819
- if ((strlen($v_path) > 0) && (substr($v_path, -1) != '/')) {
820
- $v_path .= '/';
821
- }
822
- $v_path .= $v_options[PCLZIP_OPT_ADD_PATH];
823
- }
824
- if (!isset($v_options[PCLZIP_OPT_EXTRACT_AS_STRING])) {
825
- $v_options[PCLZIP_OPT_EXTRACT_AS_STRING] = FALSE;
826
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING not set.");
827
- }
828
- else {
829
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Option PCLZIP_OPT_EXTRACT_AS_STRING set.");
830
- }
831
- }
832
-
833
- // ----- Look for 2 args
834
- // Here we need to support the first historic synopsis of the
835
- // method.
836
- else {
837
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Static synopsis");
838
-
839
- // ----- Get the first argument
840
- $v_path = $v_arg_list[0];
841
-
842
- // ----- Look for the optional second argument
843
- if ($v_size == 2) {
844
- $v_remove_path = $v_arg_list[1];
845
- }
846
- else if ($v_size > 2) {
847
- // ----- Error log
848
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid number / type of arguments");
849
-
850
- // ----- Return
851
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
852
- return 0;
853
- }
854
- }
855
- }
856
-
857
- // ----- Trace
858
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "index='$p_index', path='$v_path', remove_path='$v_remove_path', remove_all_path='".($v_remove_path?'true':'false')."'");
859
-
860
- // ----- Trick
861
- // Here I want to reuse extractByRule(), so I need to parse the $p_index
862
- // with privParseOptions()
863
- $v_arg_trick = array (PCLZIP_OPT_BY_INDEX, $p_index);
864
- $v_options_trick = array();
865
- $v_result = $this->privParseOptions($v_arg_trick, sizeof($v_arg_trick), $v_options_trick,
866
- array (PCLZIP_OPT_BY_INDEX => 'optional' ));
867
- if ($v_result != 1) {
868
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
869
- return 0;
870
- }
871
- $v_options[PCLZIP_OPT_BY_INDEX] = $v_options_trick[PCLZIP_OPT_BY_INDEX];
872
-
873
- // ----- Call the extracting fct
874
- if (($v_result = $this->privExtractByRule($p_list, $v_path, $v_remove_path, $v_remove_all_path, $v_options)) < 1) {
875
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
876
- return(0);
877
- }
878
-
879
- // ----- Return
880
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
881
- return $p_list;
882
- }
883
- // --------------------------------------------------------------------------------
884
-
885
- // --------------------------------------------------------------------------------
886
- // Function :
887
- // delete([$p_option, $p_option_value, ...])
888
- // Description :
889
- // This method removes files from the archive.
890
- // If no parameters are given, then all the archive is emptied.
891
- // Parameters :
892
- // None or optional arguments.
893
- // Options :
894
- // PCLZIP_OPT_BY_INDEX :
895
- // PCLZIP_OPT_BY_NAME :
896
- // PCLZIP_OPT_BY_EREG :
897
- // PCLZIP_OPT_BY_PREG :
898
- // Return Values :
899
- // 0 on failure,
900
- // The list of the files which are still present in the archive.
901
- // (see PclZip::listContent() for list entry format)
902
- // --------------------------------------------------------------------------------
903
- function delete()
904
- {
905
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::delete", "");
906
- $v_result=1;
907
-
908
- // ----- Reset the error handler
909
- $this->privErrorReset();
910
-
911
- // ----- Check archive
912
- if (!$this->privCheckFormat()) {
913
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
914
- return(0);
915
- }
916
-
917
- // ----- Set default values
918
- $v_options = array();
919
-
920
- // ----- Look for variable options arguments
921
- $v_size = func_num_args();
922
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "$v_size arguments passed to the method");
923
-
924
- // ----- Look for arguments
925
- if ($v_size > 0) {
926
- // ----- Get the arguments
927
- $v_arg_list = func_get_args();
928
-
929
- // ----- Parse the options
930
- $v_result = $this->privParseOptions($v_arg_list, $v_size, $v_options,
931
- array (PCLZIP_OPT_BY_NAME => 'optional',
932
- PCLZIP_OPT_BY_EREG => 'optional',
933
- PCLZIP_OPT_BY_PREG => 'optional',
934
- PCLZIP_OPT_BY_INDEX => 'optional' ));
935
- if ($v_result != 1) {
936
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
937
- return 0;
938
- }
939
- }
940
-
941
- // ----- Magic quotes trick
942
- $this->privDisableMagicQuotes();
943
-
944
- // ----- Call the delete fct
945
- $v_list = array();
946
- if (($v_result = $this->privDeleteByRule($v_list, $v_options)) != 1) {
947
- $this->privSwapBackMagicQuotes();
948
- unset($v_list);
949
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0, PclZip::errorInfo());
950
- return(0);
951
- }
952
-
953
- // ----- Magic quotes trick
954
- $this->privSwapBackMagicQuotes();
955
-
956
- // ----- Return
957
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_list);
958
- return $v_list;
959
- }
960
- // --------------------------------------------------------------------------------
961
-
962
- // --------------------------------------------------------------------------------
963
- // Function : deleteByIndex()
964
- // Description :
965
- // ***** Deprecated *****
966
- // delete(PCLZIP_OPT_BY_INDEX, $p_index) should be prefered.
967
- // --------------------------------------------------------------------------------
968
- function deleteByIndex($p_index)
969
- {
970
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::deleteByIndex", "index='$p_index'");
971
-
972
- $p_list = $this->delete(PCLZIP_OPT_BY_INDEX, $p_index);
973
-
974
- // ----- Return
975
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $p_list);
976
- return $p_list;
977
- }
978
- // --------------------------------------------------------------------------------
979
-
980
- // --------------------------------------------------------------------------------
981
- // Function : properties()
982
- // Description :
983
- // This method gives the properties of the archive.
984
- // The properties are :
985
- // nb : Number of files in the archive
986
- // comment : Comment associated with the archive file
987
- // status : not_exist, ok
988
- // Parameters :
989
- // None
990
- // Return Values :
991
- // 0 on failure,
992
- // An array with the archive properties.
993
- // --------------------------------------------------------------------------------
994
- function properties()
995
- {
996
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::properties", "");
997
-
998
- // ----- Reset the error handler
999
- $this->privErrorReset();
1000
-
1001
- // ----- Magic quotes trick
1002
- $this->privDisableMagicQuotes();
1003
-
1004
- // ----- Check archive
1005
- if (!$this->privCheckFormat()) {
1006
- $this->privSwapBackMagicQuotes();
1007
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
1008
- return(0);
1009
- }
1010
-
1011
- // ----- Default properties
1012
- $v_prop = array();
1013
- $v_prop['comment'] = '';
1014
- $v_prop['nb'] = 0;
1015
- $v_prop['status'] = 'not_exist';
1016
-
1017
- // ----- Look if file exists
1018
- if (@is_file($this->zipname))
1019
- {
1020
- // ----- Open the zip file
1021
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
1022
- if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
1023
- {
1024
- $this->privSwapBackMagicQuotes();
1025
-
1026
- // ----- Error log
1027
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
1028
-
1029
- // ----- Return
1030
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), 0);
1031
- return 0;
1032
- }
1033
-
1034
- // ----- Read the central directory informations
1035
- $v_central_dir = array();
1036
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
1037
- {
1038
- $this->privSwapBackMagicQuotes();
1039
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
1040
- return 0;
1041
- }
1042
-
1043
- // ----- Close the zip file
1044
- $this->privCloseFd();
1045
-
1046
- // ----- Set the user attributes
1047
- $v_prop['comment'] = $v_central_dir['comment'];
1048
- $v_prop['nb'] = $v_central_dir['entries'];
1049
- $v_prop['status'] = 'ok';
1050
- }
1051
-
1052
- // ----- Magic quotes trick
1053
- $this->privSwapBackMagicQuotes();
1054
-
1055
- // ----- Return
1056
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_prop);
1057
- return $v_prop;
1058
- }
1059
- // --------------------------------------------------------------------------------
1060
-
1061
- // --------------------------------------------------------------------------------
1062
- // Function : duplicate()
1063
- // Description :
1064
- // This method creates an archive by copying the content of an other one. If
1065
- // the archive already exist, it is replaced by the new one without any warning.
1066
- // Parameters :
1067
- // $p_archive : The filename of a valid archive, or
1068
- // a valid PclZip object.
1069
- // Return Values :
1070
- // 1 on success.
1071
- // 0 or a negative value on error (error code).
1072
- // --------------------------------------------------------------------------------
1073
- function duplicate($p_archive)
1074
- {
1075
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::duplicate", "");
1076
- $v_result = 1;
1077
-
1078
- // ----- Reset the error handler
1079
- $this->privErrorReset();
1080
-
1081
- // ----- Look if the $p_archive is a PclZip object
1082
- if ((is_object($p_archive)) && (get_class($p_archive) == 'pclzip'))
1083
- {
1084
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is valid PclZip object '".$p_archive->zipname."'");
1085
-
1086
- // ----- Duplicate the archive
1087
- $v_result = $this->privDuplicate($p_archive->zipname);
1088
- }
1089
-
1090
- // ----- Look if the $p_archive is a string (so a filename)
1091
- else if (is_string($p_archive))
1092
- {
1093
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The parameter is a filename '$p_archive'");
1094
-
1095
- // ----- Check that $p_archive is a valid zip file
1096
- // TBC : Should also check the archive format
1097
- if (!is_file($p_archive)) {
1098
- // ----- Error log
1099
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "No file with filename '".$p_archive."'");
1100
- $v_result = PCLZIP_ERR_MISSING_FILE;
1101
- }
1102
- else {
1103
- // ----- Duplicate the archive
1104
- $v_result = $this->privDuplicate($p_archive);
1105
- }
1106
- }
1107
-
1108
- // ----- Invalid variable
1109
- else
1110
- {
1111
- // ----- Error log
1112
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1113
- $v_result = PCLZIP_ERR_INVALID_PARAMETER;
1114
- }
1115
-
1116
- // ----- Return
1117
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
1118
- return $v_result;
1119
- }
1120
- // --------------------------------------------------------------------------------
1121
-
1122
- // --------------------------------------------------------------------------------
1123
- // Function : merge()
1124
- // Description :
1125
- // This method merge the $p_archive_to_add archive at the end of the current
1126
- // one ($this).
1127
- // If the archive ($this) does not exist, the merge becomes a duplicate.
1128
- // If the $p_archive_to_add archive does not exist, the merge is a success.
1129
- // Parameters :
1130
- // $p_archive_to_add : It can be directly the filename of a valid zip archive,
1131
- // or a PclZip object archive.
1132
- // Return Values :
1133
- // 1 on success,
1134
- // 0 or negative values on error (see below).
1135
- // --------------------------------------------------------------------------------
1136
- function merge($p_archive_to_add)
1137
- {
1138
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::merge", "");
1139
- $v_result = 1;
1140
-
1141
- // ----- Reset the error handler
1142
- $this->privErrorReset();
1143
-
1144
- // ----- Check archive
1145
- if (!$this->privCheckFormat()) {
1146
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, 0);
1147
- return(0);
1148
- }
1149
-
1150
- // ----- Look if the $p_archive_to_add is a PclZip object
1151
- if ((is_object($p_archive_to_add)) && (get_class($p_archive_to_add) == 'pclzip'))
1152
- {
1153
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is valid PclZip object");
1154
-
1155
- // ----- Merge the archive
1156
- $v_result = $this->privMerge($p_archive_to_add);
1157
- }
1158
-
1159
- // ----- Look if the $p_archive_to_add is a string (so a filename)
1160
- else if (is_string($p_archive_to_add))
1161
- {
1162
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The parameter is a filename");
1163
-
1164
- // ----- Create a temporary archive
1165
- $v_object_archive = new PclZip($p_archive_to_add);
1166
-
1167
- // ----- Merge the archive
1168
- $v_result = $this->privMerge($v_object_archive);
1169
- }
1170
-
1171
- // ----- Invalid variable
1172
- else
1173
- {
1174
- // ----- Error log
1175
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid variable type p_archive_to_add");
1176
- $v_result = PCLZIP_ERR_INVALID_PARAMETER;
1177
- }
1178
-
1179
- // ----- Return
1180
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
1181
- return $v_result;
1182
- }
1183
- // --------------------------------------------------------------------------------
1184
-
1185
-
1186
-
1187
- // --------------------------------------------------------------------------------
1188
- // Function : errorCode()
1189
- // Description :
1190
- // Parameters :
1191
- // --------------------------------------------------------------------------------
1192
- function errorCode()
1193
- {
1194
- if (PCLZIP_ERROR_EXTERNAL == 1) {
1195
- return(PclErrorCode());
1196
- }
1197
- else {
1198
- return($this->error_code);
1199
- }
1200
- }
1201
- // --------------------------------------------------------------------------------
1202
-
1203
- // --------------------------------------------------------------------------------
1204
- // Function : errorName()
1205
- // Description :
1206
- // Parameters :
1207
- // --------------------------------------------------------------------------------
1208
- function errorName($p_with_code=false)
1209
- {
1210
- $v_name = array ( PCLZIP_ERR_NO_ERROR => 'PCLZIP_ERR_NO_ERROR',
1211
- PCLZIP_ERR_WRITE_OPEN_FAIL => 'PCLZIP_ERR_WRITE_OPEN_FAIL',
1212
- PCLZIP_ERR_READ_OPEN_FAIL => 'PCLZIP_ERR_READ_OPEN_FAIL',
1213
- PCLZIP_ERR_INVALID_PARAMETER => 'PCLZIP_ERR_INVALID_PARAMETER',
1214
- PCLZIP_ERR_MISSING_FILE => 'PCLZIP_ERR_MISSING_FILE',
1215
- PCLZIP_ERR_FILENAME_TOO_LONG => 'PCLZIP_ERR_FILENAME_TOO_LONG',
1216
- PCLZIP_ERR_INVALID_ZIP => 'PCLZIP_ERR_INVALID_ZIP',
1217
- PCLZIP_ERR_BAD_EXTRACTED_FILE => 'PCLZIP_ERR_BAD_EXTRACTED_FILE',
1218
- PCLZIP_ERR_DIR_CREATE_FAIL => 'PCLZIP_ERR_DIR_CREATE_FAIL',
1219
- PCLZIP_ERR_BAD_EXTENSION => 'PCLZIP_ERR_BAD_EXTENSION',
1220
- PCLZIP_ERR_BAD_FORMAT => 'PCLZIP_ERR_BAD_FORMAT',
1221
- PCLZIP_ERR_DELETE_FILE_FAIL => 'PCLZIP_ERR_DELETE_FILE_FAIL',
1222
- PCLZIP_ERR_RENAME_FILE_FAIL => 'PCLZIP_ERR_RENAME_FILE_FAIL',
1223
- PCLZIP_ERR_BAD_CHECKSUM => 'PCLZIP_ERR_BAD_CHECKSUM',
1224
- PCLZIP_ERR_INVALID_ARCHIVE_ZIP => 'PCLZIP_ERR_INVALID_ARCHIVE_ZIP',
1225
- PCLZIP_ERR_MISSING_OPTION_VALUE => 'PCLZIP_ERR_MISSING_OPTION_VALUE',
1226
- PCLZIP_ERR_INVALID_OPTION_VALUE => 'PCLZIP_ERR_INVALID_OPTION_VALUE',
1227
- PCLZIP_ERR_UNSUPPORTED_COMPRESSION => 'PCLZIP_ERR_UNSUPPORTED_COMPRESSION',
1228
- PCLZIP_ERR_UNSUPPORTED_ENCRYPTION => 'PCLZIP_ERR_UNSUPPORTED_ENCRYPTION'
1229
- ,PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE => 'PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE'
1230
- ,PCLZIP_ERR_DIRECTORY_RESTRICTION => 'PCLZIP_ERR_DIRECTORY_RESTRICTION'
1231
- );
1232
-
1233
- if (isset($v_name[$this->error_code])) {
1234
- $v_value = $v_name[$this->error_code];
1235
- }
1236
- else {
1237
- $v_value = 'NoName';
1238
- }
1239
-
1240
- if ($p_with_code) {
1241
- return($v_value.' ('.$this->error_code.')');
1242
- }
1243
- else {
1244
- return($v_value);
1245
- }
1246
- }
1247
- // --------------------------------------------------------------------------------
1248
-
1249
- // --------------------------------------------------------------------------------
1250
- // Function : errorInfo()
1251
- // Description :
1252
- // Parameters :
1253
- // --------------------------------------------------------------------------------
1254
- function errorInfo($p_full=false)
1255
- {
1256
- if (PCLZIP_ERROR_EXTERNAL == 1) {
1257
- return(PclErrorString());
1258
- }
1259
- else {
1260
- if ($p_full) {
1261
- return($this->errorName(true)." : ".$this->error_string);
1262
- }
1263
- else {
1264
- return($this->error_string." [code ".$this->error_code."]");
1265
- }
1266
- }
1267
- }
1268
- // --------------------------------------------------------------------------------
1269
-
1270
-
1271
- // --------------------------------------------------------------------------------
1272
- // ***** UNDER THIS LINE ARE DEFINED PRIVATE INTERNAL FUNCTIONS *****
1273
- // ***** *****
1274
- // ***** THESES FUNCTIONS MUST NOT BE USED DIRECTLY *****
1275
- // --------------------------------------------------------------------------------
1276
-
1277
-
1278
-
1279
- // --------------------------------------------------------------------------------
1280
- // Function : privCheckFormat()
1281
- // Description :
1282
- // This method check that the archive exists and is a valid zip archive.
1283
- // Several level of check exists. (futur)
1284
- // Parameters :
1285
- // $p_level : Level of check. Default 0.
1286
- // 0 : Check the first bytes (magic codes) (default value))
1287
- // 1 : 0 + Check the central directory (futur)
1288
- // 2 : 1 + Check each file header (futur)
1289
- // Return Values :
1290
- // true on success,
1291
- // false on error, the error code is set.
1292
- // --------------------------------------------------------------------------------
1293
- function privCheckFormat($p_level=0)
1294
- {
1295
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFormat", "");
1296
- $v_result = true;
1297
-
1298
- // ----- Reset the file system cache
1299
- clearstatcache();
1300
-
1301
- // ----- Reset the error handler
1302
- $this->privErrorReset();
1303
-
1304
- // ----- Look if the file exits
1305
- if (!is_file($this->zipname)) {
1306
- // ----- Error log
1307
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "Missing archive file '".$this->zipname."'");
1308
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());
1309
- return(false);
1310
- }
1311
-
1312
- // ----- Check that the file is readeable
1313
- if (!is_readable($this->zipname)) {
1314
- // ----- Error log
1315
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to read archive '".$this->zipname."'");
1316
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, false, PclZip::errorInfo());
1317
- return(false);
1318
- }
1319
-
1320
- // ----- Check the magic code
1321
- // TBC
1322
-
1323
- // ----- Check the central header
1324
- // TBC
1325
-
1326
- // ----- Check each file header
1327
- // TBC
1328
-
1329
- // ----- Return
1330
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
1331
- return $v_result;
1332
- }
1333
- // --------------------------------------------------------------------------------
1334
-
1335
- // --------------------------------------------------------------------------------
1336
- // Function : privParseOptions()
1337
- // Description :
1338
- // This internal methods reads the variable list of arguments ($p_options_list,
1339
- // $p_size) and generate an array with the options and values ($v_result_list).
1340
- // $v_requested_options contains the options that can be present and those that
1341
- // must be present.
1342
- // $v_requested_options is an array, with the option value as key, and 'optional',
1343
- // or 'mandatory' as value.
1344
- // Parameters :
1345
- // See above.
1346
- // Return Values :
1347
- // 1 on success.
1348
- // 0 on failure.
1349
- // --------------------------------------------------------------------------------
1350
- function privParseOptions(&$p_options_list, $p_size, &$v_result_list, $v_requested_options=false)
1351
- {
1352
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privParseOptions", "");
1353
- $v_result=1;
1354
-
1355
- // ----- Read the options
1356
- $i=0;
1357
- while ($i<$p_size) {
1358
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Looking for table index $i, option = '".PclZipUtilOptionText($p_options_list[$i])."(".$p_options_list[$i].")'");
1359
-
1360
- // ----- Check if the option is supported
1361
- if (!isset($v_requested_options[$p_options_list[$i]])) {
1362
- // ----- Error log
1363
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid optional parameter '".$p_options_list[$i]."' for this method");
1364
-
1365
- // ----- Return
1366
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1367
- return PclZip::errorCode();
1368
- }
1369
-
1370
- // ----- Look for next option
1371
- switch ($p_options_list[$i]) {
1372
- // ----- Look for options that request a path value
1373
- case PCLZIP_OPT_PATH :
1374
- case PCLZIP_OPT_REMOVE_PATH :
1375
- case PCLZIP_OPT_ADD_PATH :
1376
- // ----- Check the number of parameters
1377
- if (($i+1) >= $p_size) {
1378
- // ----- Error log
1379
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1380
-
1381
- // ----- Return
1382
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1383
- return PclZip::errorCode();
1384
- }
1385
-
1386
- // ----- Get the value
1387
- $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false);
1388
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
1389
- $i++;
1390
- break;
1391
-
1392
- case PCLZIP_OPT_EXTRACT_DIR_RESTRICTION :
1393
- // ----- Check the number of parameters
1394
- if (($i+1) >= $p_size) {
1395
- // ----- Error log
1396
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1397
-
1398
- // ----- Return
1399
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1400
- return PclZip::errorCode();
1401
- }
1402
-
1403
- // ----- Get the value
1404
- if ( is_string($p_options_list[$i+1])
1405
- && ($p_options_list[$i+1] != '')) {
1406
- $v_result_list[$p_options_list[$i]] = PclZipUtilTranslateWinPath($p_options_list[$i+1], false);
1407
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
1408
- $i++;
1409
- }
1410
- else {
1411
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." set with an empty value is ignored.");
1412
- }
1413
- break;
1414
-
1415
- // ----- Look for options that request an array of string for value
1416
- case PCLZIP_OPT_BY_NAME :
1417
- // ----- Check the number of parameters
1418
- if (($i+1) >= $p_size) {
1419
- // ----- Error log
1420
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1421
-
1422
- // ----- Return
1423
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1424
- return PclZip::errorCode();
1425
- }
1426
-
1427
- // ----- Get the value
1428
- if (is_string($p_options_list[$i+1])) {
1429
- $v_result_list[$p_options_list[$i]][0] = $p_options_list[$i+1];
1430
- }
1431
- else if (is_array($p_options_list[$i+1])) {
1432
- $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1433
- }
1434
- else {
1435
- // ----- Error log
1436
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1437
-
1438
- // ----- Return
1439
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1440
- return PclZip::errorCode();
1441
- }
1442
- ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
1443
- $i++;
1444
- break;
1445
-
1446
- // ----- Look for options that request an EREG or PREG expression
1447
- case PCLZIP_OPT_BY_EREG :
1448
- case PCLZIP_OPT_BY_PREG :
1449
- //case PCLZIP_OPT_CRYPT :
1450
- // ----- Check the number of parameters
1451
- if (($i+1) >= $p_size) {
1452
- // ----- Error log
1453
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1454
-
1455
- // ----- Return
1456
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1457
- return PclZip::errorCode();
1458
- }
1459
-
1460
- // ----- Get the value
1461
- if (is_string($p_options_list[$i+1])) {
1462
- $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1463
- }
1464
- else {
1465
- // ----- Error log
1466
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Wrong parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1467
-
1468
- // ----- Return
1469
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1470
- return PclZip::errorCode();
1471
- }
1472
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
1473
- $i++;
1474
- break;
1475
-
1476
- // ----- Look for options that takes a string
1477
- case PCLZIP_OPT_COMMENT :
1478
- case PCLZIP_OPT_ADD_COMMENT :
1479
- case PCLZIP_OPT_PREPEND_COMMENT :
1480
- // ----- Check the number of parameters
1481
- if (($i+1) >= $p_size) {
1482
- // ----- Error log
1483
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE,
1484
- "Missing parameter value for option '"
1485
- .PclZipUtilOptionText($p_options_list[$i])
1486
- ."'");
1487
-
1488
- // ----- Return
1489
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1490
- return PclZip::errorCode();
1491
- }
1492
-
1493
- // ----- Get the value
1494
- if (is_string($p_options_list[$i+1])) {
1495
- $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1496
- }
1497
- else {
1498
- // ----- Error log
1499
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE,
1500
- "Wrong parameter value for option '"
1501
- .PclZipUtilOptionText($p_options_list[$i])
1502
- ."'");
1503
-
1504
- // ----- Return
1505
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1506
- return PclZip::errorCode();
1507
- }
1508
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
1509
- $i++;
1510
- break;
1511
-
1512
- // ----- Look for options that request an array of index
1513
- case PCLZIP_OPT_BY_INDEX :
1514
- // ----- Check the number of parameters
1515
- if (($i+1) >= $p_size) {
1516
- // ----- Error log
1517
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1518
-
1519
- // ----- Return
1520
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1521
- return PclZip::errorCode();
1522
- }
1523
-
1524
- // ----- Get the value
1525
- $v_work_list = array();
1526
- if (is_string($p_options_list[$i+1])) {
1527
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is a string '".$p_options_list[$i+1]."'");
1528
-
1529
- // ----- Remove spaces
1530
- $p_options_list[$i+1] = strtr($p_options_list[$i+1], ' ', '');
1531
-
1532
- // ----- Parse items
1533
- $v_work_list = explode(",", $p_options_list[$i+1]);
1534
- }
1535
- else if (is_integer($p_options_list[$i+1])) {
1536
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an integer '".$p_options_list[$i+1]."'");
1537
- $v_work_list[0] = $p_options_list[$i+1].'-'.$p_options_list[$i+1];
1538
- }
1539
- else if (is_array($p_options_list[$i+1])) {
1540
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Index value is an array");
1541
- $v_work_list = $p_options_list[$i+1];
1542
- }
1543
- else {
1544
- // ----- Error log
1545
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Value must be integer, string or array for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1546
-
1547
- // ----- Return
1548
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1549
- return PclZip::errorCode();
1550
- }
1551
-
1552
- // ----- Reduce the index list
1553
- // each index item in the list must be a couple with a start and
1554
- // an end value : [0,3], [5-5], [8-10], ...
1555
- // ----- Check the format of each item
1556
- $v_sort_flag=false;
1557
- $v_sort_value=0;
1558
- for ($j=0; $j<sizeof($v_work_list); $j++) {
1559
- // ----- Explode the item
1560
- $v_item_list = explode("-", $v_work_list[$j]);
1561
- $v_size_item_list = sizeof($v_item_list);
1562
-
1563
- // ----- TBC : Here we might check that each item is a
1564
- // real integer ...
1565
-
1566
- // ----- Look for single value
1567
- if ($v_size_item_list == 1) {
1568
- // ----- Set the option value
1569
- $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1570
- $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[0];
1571
- }
1572
- elseif ($v_size_item_list == 2) {
1573
- // ----- Set the option value
1574
- $v_result_list[$p_options_list[$i]][$j]['start'] = $v_item_list[0];
1575
- $v_result_list[$p_options_list[$i]][$j]['end'] = $v_item_list[1];
1576
- }
1577
- else {
1578
- // ----- Error log
1579
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Too many values in index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1580
-
1581
- // ----- Return
1582
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1583
- return PclZip::errorCode();
1584
- }
1585
-
1586
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extracted index item = [".$v_result_list[$p_options_list[$i]][$j]['start'].",".$v_result_list[$p_options_list[$i]][$j]['end']."]");
1587
-
1588
- // ----- Look for list sort
1589
- if ($v_result_list[$p_options_list[$i]][$j]['start'] < $v_sort_value) {
1590
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The list should be sorted ...");
1591
- $v_sort_flag=true;
1592
-
1593
- // ----- TBC : An automatic sort should be writen ...
1594
- // ----- Error log
1595
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Invalid order of index range for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1596
-
1597
- // ----- Return
1598
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1599
- return PclZip::errorCode();
1600
- }
1601
- $v_sort_value = $v_result_list[$p_options_list[$i]][$j]['start'];
1602
- }
1603
-
1604
- // ----- Sort the items
1605
- if ($v_sort_flag) {
1606
- // TBC : To Be Completed
1607
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "List sorting is not yet write ...");
1608
- }
1609
-
1610
- // ----- Next option
1611
- $i++;
1612
- break;
1613
-
1614
- // ----- Look for options that request no value
1615
- case PCLZIP_OPT_REMOVE_ALL_PATH :
1616
- case PCLZIP_OPT_EXTRACT_AS_STRING :
1617
- case PCLZIP_OPT_NO_COMPRESSION :
1618
- case PCLZIP_OPT_EXTRACT_IN_OUTPUT :
1619
- case PCLZIP_OPT_REPLACE_NEWER :
1620
- case PCLZIP_OPT_STOP_ON_ERROR :
1621
- $v_result_list[$p_options_list[$i]] = true;
1622
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
1623
- break;
1624
-
1625
- // ----- Look for options that request an octal value
1626
- case PCLZIP_OPT_SET_CHMOD :
1627
- // ----- Check the number of parameters
1628
- if (($i+1) >= $p_size) {
1629
- // ----- Error log
1630
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1631
-
1632
- // ----- Return
1633
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1634
- return PclZip::errorCode();
1635
- }
1636
-
1637
- // ----- Get the value
1638
- $v_result_list[$p_options_list[$i]] = $p_options_list[$i+1];
1639
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($p_options_list[$i])." = '".$v_result_list[$p_options_list[$i]]."'");
1640
- $i++;
1641
- break;
1642
-
1643
- // ----- Look for options that request a call-back
1644
- case PCLZIP_CB_PRE_EXTRACT :
1645
- case PCLZIP_CB_POST_EXTRACT :
1646
- case PCLZIP_CB_PRE_ADD :
1647
- case PCLZIP_CB_POST_ADD :
1648
- /* for futur use
1649
- case PCLZIP_CB_PRE_DELETE :
1650
- case PCLZIP_CB_POST_DELETE :
1651
- case PCLZIP_CB_PRE_LIST :
1652
- case PCLZIP_CB_POST_LIST :
1653
- */
1654
- // ----- Check the number of parameters
1655
- if (($i+1) >= $p_size) {
1656
- // ----- Error log
1657
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_OPTION_VALUE, "Missing parameter value for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1658
-
1659
- // ----- Return
1660
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1661
- return PclZip::errorCode();
1662
- }
1663
-
1664
- // ----- Get the value
1665
- $v_function_name = $p_options_list[$i+1];
1666
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "call-back ".PclZipUtilOptionText($p_options_list[$i])." = '".$v_function_name."'");
1667
-
1668
- // ----- Check that the value is a valid existing function
1669
- if (!function_exists($v_function_name)) {
1670
- // ----- Error log
1671
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_OPTION_VALUE, "Function '".$v_function_name."()' is not an existing function for option '".PclZipUtilOptionText($p_options_list[$i])."'");
1672
-
1673
- // ----- Return
1674
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1675
- return PclZip::errorCode();
1676
- }
1677
-
1678
- // ----- Set the attribute
1679
- $v_result_list[$p_options_list[$i]] = $v_function_name;
1680
- $i++;
1681
- break;
1682
-
1683
- default :
1684
- // ----- Error log
1685
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1686
- "Unknown parameter '"
1687
- .$p_options_list[$i]."'");
1688
-
1689
- // ----- Return
1690
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1691
- return PclZip::errorCode();
1692
- }
1693
-
1694
- // ----- Next options
1695
- $i++;
1696
- }
1697
-
1698
- // ----- Look for mandatory options
1699
- if ($v_requested_options !== false) {
1700
- for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1701
- // ----- Look for mandatory option
1702
- if ($v_requested_options[$key] == 'mandatory') {
1703
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")");
1704
- // ----- Look if present
1705
- if (!isset($v_result_list[$key])) {
1706
- // ----- Error log
1707
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1708
-
1709
- // ----- Return
1710
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1711
- return PclZip::errorCode();
1712
- }
1713
- }
1714
- }
1715
- }
1716
-
1717
- // ----- Return
1718
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
1719
- return $v_result;
1720
- }
1721
- // --------------------------------------------------------------------------------
1722
-
1723
- // --------------------------------------------------------------------------------
1724
- // Function : privFileDescrParseAtt()
1725
- // Description :
1726
- // Parameters :
1727
- // Return Values :
1728
- // 1 on success.
1729
- // 0 on failure.
1730
- // --------------------------------------------------------------------------------
1731
- function privFileDescrParseAtt(&$p_file_list, &$p_filedescr, $v_options, $v_requested_options=false)
1732
- {
1733
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrParseAtt", "");
1734
- $v_result=1;
1735
-
1736
- // ----- For each file in the list check the attributes
1737
- foreach ($p_file_list as $v_key => $v_value) {
1738
-
1739
- // ----- Check if the option is supported
1740
- if (!isset($v_requested_options[$v_key])) {
1741
- // ----- Error log
1742
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file attribute '".$v_key."' for this file");
1743
-
1744
- // ----- Return
1745
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1746
- return PclZip::errorCode();
1747
- }
1748
-
1749
- // ----- Look for attribute
1750
- switch ($v_key) {
1751
- case PCLZIP_ATT_FILE_NAME :
1752
- if (!is_string($v_value)) {
1753
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1754
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1755
- return PclZip::errorCode();
1756
- }
1757
-
1758
- $p_filedescr['filename'] = PclZipUtilPathReduction($v_value);
1759
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");
1760
-
1761
- if ($p_filedescr['filename'] == '') {
1762
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty filename for attribute '".PclZipUtilOptionText($v_key)."'");
1763
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1764
- return PclZip::errorCode();
1765
- }
1766
-
1767
- break;
1768
-
1769
- case PCLZIP_ATT_FILE_NEW_SHORT_NAME :
1770
- if (!is_string($v_value)) {
1771
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1772
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1773
- return PclZip::errorCode();
1774
- }
1775
-
1776
- $p_filedescr['new_short_name'] = PclZipUtilPathReduction($v_value);
1777
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");
1778
-
1779
- if ($p_filedescr['new_short_name'] == '') {
1780
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty short filename for attribute '".PclZipUtilOptionText($v_key)."'");
1781
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1782
- return PclZip::errorCode();
1783
- }
1784
- break;
1785
-
1786
- case PCLZIP_ATT_FILE_NEW_FULL_NAME :
1787
- if (!is_string($v_value)) {
1788
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid type ".gettype($v_value).". String expected for attribute '".PclZipUtilOptionText($v_key)."'");
1789
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1790
- return PclZip::errorCode();
1791
- }
1792
-
1793
- $p_filedescr['new_full_name'] = PclZipUtilPathReduction($v_value);
1794
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "".PclZipUtilOptionText($v_key)." = '".$v_value."'");
1795
-
1796
- if ($p_filedescr['new_full_name'] == '') {
1797
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ATTRIBUTE_VALUE, "Invalid empty full filename for attribute '".PclZipUtilOptionText($v_key)."'");
1798
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1799
- return PclZip::errorCode();
1800
- }
1801
- break;
1802
-
1803
- default :
1804
- // ----- Error log
1805
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER,
1806
- "Unknown parameter '".$v_key."'");
1807
-
1808
- // ----- Return
1809
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1810
- return PclZip::errorCode();
1811
- }
1812
-
1813
- // ----- Look for mandatory options
1814
- if ($v_requested_options !== false) {
1815
- for ($key=reset($v_requested_options); $key=key($v_requested_options); $key=next($v_requested_options)) {
1816
- // ----- Look for mandatory option
1817
- if ($v_requested_options[$key] == 'mandatory') {
1818
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Detect a mandatory option : ".PclZipUtilOptionText($key)."(".$key.")");
1819
- // ----- Look if present
1820
- if (!isset($p_file_list[$key])) {
1821
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Missing mandatory parameter ".PclZipUtilOptionText($key)."(".$key.")");
1822
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1823
- return PclZip::errorCode();
1824
- }
1825
- }
1826
- }
1827
- }
1828
-
1829
- // end foreach
1830
- }
1831
-
1832
- // ----- Return
1833
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
1834
- return $v_result;
1835
- }
1836
- // --------------------------------------------------------------------------------
1837
-
1838
- // --------------------------------------------------------------------------------
1839
- // Function : privFileDescrExpand()
1840
- // Description :
1841
- // Parameters :
1842
- // Return Values :
1843
- // 1 on success.
1844
- // 0 on failure.
1845
- // --------------------------------------------------------------------------------
1846
- function privFileDescrExpand(&$p_filedescr_list, &$p_options)
1847
- {
1848
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privFileDescrExpand", "");
1849
- $v_result=1;
1850
-
1851
- // ----- Create a result list
1852
- $v_result_list = array();
1853
-
1854
- // ----- Look each entry
1855
- for ($i=0; $i<sizeof($p_filedescr_list); $i++) {
1856
- // ----- Get filedescr
1857
- $v_descr = $p_filedescr_list[$i];
1858
-
1859
- // ----- Reduce the filename
1860
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filedescr before reduction :'".$v_descr['filename']."'");
1861
- $v_descr['filename'] = PclZipUtilTranslateWinPath($v_descr['filename']);
1862
- $v_descr['filename'] = PclZipUtilPathReduction($v_descr['filename']);
1863
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filedescr after reduction :'".$v_descr['filename']."'");
1864
-
1865
- // ----- Get type of descr
1866
- if (!file_exists($v_descr['filename'])) {
1867
- // ----- Error log
1868
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_descr['filename']."' does not exists");
1869
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$v_descr['filename']."' does not exists");
1870
-
1871
- // ----- Return
1872
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
1873
- return PclZip::errorCode();
1874
- }
1875
- if (@is_file($v_descr['filename'])) {
1876
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "This is a file");
1877
- $v_descr['type'] = 'file';
1878
- }
1879
- else if (@is_dir($v_descr['filename'])) {
1880
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "This is a folder");
1881
- $v_descr['type'] = 'folder';
1882
- }
1883
- else if (@is_link($v_descr['filename'])) {
1884
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Unsupported file type : link");
1885
- // skip
1886
- continue;
1887
- }
1888
- else {
1889
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Unsupported file type : unknown type");
1890
- // skip
1891
- continue;
1892
- }
1893
-
1894
- // ----- Calculate the stored filename
1895
- $this->privCalculateStoredFilename($v_descr, $p_options);
1896
-
1897
- // ----- Add the descriptor in result list
1898
- $v_result_list[sizeof($v_result_list)] = $v_descr;
1899
-
1900
- // ----- Look for folder
1901
- if ($v_descr['type'] == 'folder') {
1902
- // ----- List of items in folder
1903
- $v_dirlist_descr = array();
1904
- $v_dirlist_nb = 0;
1905
- if ($v_folder_handler = @opendir($v_descr['filename'])) {
1906
- while (($v_item_handler = @readdir($v_folder_handler)) !== false) {
1907
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for '".$v_item_handler."' in the directory");
1908
-
1909
- // ----- Skip '.' and '..'
1910
- if (($v_item_handler == '.') || ($v_item_handler == '..')) {
1911
- continue;
1912
- }
1913
-
1914
- // ----- Compose the full filename
1915
- $v_dirlist_descr[$v_dirlist_nb]['filename'] = $v_descr['filename'].'/'.$v_item_handler;
1916
-
1917
- // ----- Look for different stored filename
1918
- // Because the name of the folder was changed, the name of the
1919
- // files/sub-folders also change
1920
- if ($v_descr['stored_filename'] != $v_descr['filename']) {
1921
- $v_dirlist_descr[$v_dirlist_nb]['new_full_name'] = $v_descr['stored_filename'].'/'.$v_item_handler;
1922
- }
1923
-
1924
- $v_dirlist_nb++;
1925
- }
1926
- }
1927
- else {
1928
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to open dir '".$v_descr['filename']."' in read mode. Skipped.");
1929
- // TBC : unable to open folder in read mode
1930
- }
1931
-
1932
- // ----- Expand each element of the list
1933
- if ($v_dirlist_nb != 0) {
1934
- // ----- Expand
1935
- if (($v_result = $this->privFileDescrExpand($v_dirlist_descr, $p_options)) != 1) {
1936
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
1937
- return $v_result;
1938
- }
1939
-
1940
- // ----- Concat the resulting list
1941
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Merging result list (size '".sizeof($v_result_list)."') with dirlist (size '".sizeof($v_dirlist_descr)."')");
1942
- $v_result_list = array_merge($v_result_list, $v_dirlist_descr);
1943
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "merged result list is size '".sizeof($v_result_list)."'");
1944
- }
1945
- else {
1946
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Nothing in this folder to expand.");
1947
- }
1948
-
1949
- // ----- Free local array
1950
- unset($v_dirlist_descr);
1951
- }
1952
- }
1953
-
1954
- // ----- Get the result list
1955
- $p_filedescr_list = $v_result_list;
1956
-
1957
- // ----- Return
1958
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
1959
- return $v_result;
1960
- }
1961
- // --------------------------------------------------------------------------------
1962
-
1963
- // --------------------------------------------------------------------------------
1964
- // Function : privCreate()
1965
- // Description :
1966
- // Parameters :
1967
- // Return Values :
1968
- // --------------------------------------------------------------------------------
1969
- function privCreate($p_filedescr_list, &$p_result_list, &$p_options)
1970
- {
1971
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCreate", "list");
1972
- $v_result=1;
1973
- $v_list_detail = array();
1974
-
1975
- // ----- Magic quotes trick
1976
- $this->privDisableMagicQuotes();
1977
-
1978
- // ----- Open the file in write mode
1979
- if (($v_result = $this->privOpenFd('wb')) != 1)
1980
- {
1981
- // ----- Return
1982
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
1983
- return $v_result;
1984
- }
1985
-
1986
- // ----- Add the list of files
1987
- $v_result = $this->privAddList($p_filedescr_list, $p_result_list, $p_options);
1988
-
1989
- // ----- Close
1990
- $this->privCloseFd();
1991
-
1992
- // ----- Magic quotes trick
1993
- $this->privSwapBackMagicQuotes();
1994
-
1995
- // ----- Return
1996
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
1997
- return $v_result;
1998
- }
1999
- // --------------------------------------------------------------------------------
2000
-
2001
- // --------------------------------------------------------------------------------
2002
- // Function : privAdd()
2003
- // Description :
2004
- // Parameters :
2005
- // Return Values :
2006
- // --------------------------------------------------------------------------------
2007
- function privAdd($p_filedescr_list, &$p_result_list, &$p_options)
2008
- {
2009
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAdd", "list");
2010
- $v_result=1;
2011
- $v_list_detail = array();
2012
-
2013
- // ----- Look if the archive exists or is empty
2014
- if ((!is_file($this->zipname)) || (filesize($this->zipname) == 0))
2015
- {
2016
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, or is empty, create it.");
2017
-
2018
- // ----- Do a create
2019
- $v_result = $this->privCreate($p_filedescr_list, $p_result_list, $p_options);
2020
-
2021
- // ----- Return
2022
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2023
- return $v_result;
2024
- }
2025
- // ----- Magic quotes trick
2026
- $this->privDisableMagicQuotes();
2027
-
2028
- // ----- Open the zip file
2029
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
2030
- if (($v_result=$this->privOpenFd('rb')) != 1)
2031
- {
2032
- // ----- Magic quotes trick
2033
- $this->privSwapBackMagicQuotes();
2034
-
2035
- // ----- Return
2036
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2037
- return $v_result;
2038
- }
2039
-
2040
- // ----- Read the central directory informations
2041
- $v_central_dir = array();
2042
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
2043
- {
2044
- $this->privCloseFd();
2045
- $this->privSwapBackMagicQuotes();
2046
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2047
- return $v_result;
2048
- }
2049
-
2050
- // ----- Go to beginning of File
2051
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
2052
- @rewind($this->zip_fd);
2053
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
2054
-
2055
- // ----- Creates a temporay file
2056
- $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
2057
-
2058
- // ----- Open the temporary file in write mode
2059
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
2060
- if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
2061
- {
2062
- $this->privCloseFd();
2063
- $this->privSwapBackMagicQuotes();
2064
-
2065
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
2066
-
2067
- // ----- Return
2068
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
2069
- return PclZip::errorCode();
2070
- }
2071
-
2072
- // ----- Copy the files from the archive to the temporary file
2073
- // TBC : Here I should better append the file and go back to erase the central dir
2074
- $v_size = $v_central_dir['offset'];
2075
- while ($v_size != 0)
2076
- {
2077
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2078
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
2079
- $v_buffer = fread($this->zip_fd, $v_read_size);
2080
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
2081
- $v_size -= $v_read_size;
2082
- }
2083
-
2084
- // ----- Swap the file descriptor
2085
- // Here is a trick : I swap the temporary fd with the zip fd, in order to use
2086
- // the following methods on the temporary fil and not the real archive
2087
- $v_swap = $this->zip_fd;
2088
- $this->zip_fd = $v_zip_temp_fd;
2089
- $v_zip_temp_fd = $v_swap;
2090
-
2091
- // ----- Add the files
2092
- $v_header_list = array();
2093
- if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2094
- {
2095
- fclose($v_zip_temp_fd);
2096
- $this->privCloseFd();
2097
- @unlink($v_zip_temp_name);
2098
- $this->privSwapBackMagicQuotes();
2099
-
2100
- // ----- Return
2101
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2102
- return $v_result;
2103
- }
2104
-
2105
- // ----- Store the offset of the central dir
2106
- $v_offset = @ftell($this->zip_fd);
2107
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");
2108
-
2109
- // ----- Copy the block of file headers from the old archive
2110
- $v_size = $v_central_dir['size'];
2111
- while ($v_size != 0)
2112
- {
2113
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
2114
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
2115
- $v_buffer = @fread($v_zip_temp_fd, $v_read_size);
2116
- @fwrite($this->zip_fd, $v_buffer, $v_read_size);
2117
- $v_size -= $v_read_size;
2118
- }
2119
-
2120
- // ----- Create the Central Dir files header
2121
- for ($i=0, $v_count=0; $i<sizeof($v_header_list); $i++)
2122
- {
2123
- // ----- Create the file header
2124
- if ($v_header_list[$i]['status'] == 'ok') {
2125
- if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2126
- fclose($v_zip_temp_fd);
2127
- $this->privCloseFd();
2128
- @unlink($v_zip_temp_name);
2129
- $this->privSwapBackMagicQuotes();
2130
-
2131
- // ----- Return
2132
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2133
- return $v_result;
2134
- }
2135
- $v_count++;
2136
- }
2137
-
2138
- // ----- Transform the header to a 'usable' info
2139
- $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2140
- }
2141
-
2142
- // ----- Zip file comment
2143
- $v_comment = $v_central_dir['comment'];
2144
- if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2145
- $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2146
- }
2147
- if (isset($p_options[PCLZIP_OPT_ADD_COMMENT])) {
2148
- $v_comment = $v_comment.$p_options[PCLZIP_OPT_ADD_COMMENT];
2149
- }
2150
- if (isset($p_options[PCLZIP_OPT_PREPEND_COMMENT])) {
2151
- $v_comment = $p_options[PCLZIP_OPT_PREPEND_COMMENT].$v_comment;
2152
- }
2153
-
2154
- // ----- Calculate the size of the central header
2155
- $v_size = @ftell($this->zip_fd)-$v_offset;
2156
-
2157
- // ----- Create the central dir footer
2158
- if (($v_result = $this->privWriteCentralHeader($v_count+$v_central_dir['entries'], $v_size, $v_offset, $v_comment)) != 1)
2159
- {
2160
- // ----- Reset the file list
2161
- unset($v_header_list);
2162
- $this->privSwapBackMagicQuotes();
2163
-
2164
- // ----- Return
2165
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2166
- return $v_result;
2167
- }
2168
-
2169
- // ----- Swap back the file descriptor
2170
- $v_swap = $this->zip_fd;
2171
- $this->zip_fd = $v_zip_temp_fd;
2172
- $v_zip_temp_fd = $v_swap;
2173
-
2174
- // ----- Close
2175
- $this->privCloseFd();
2176
-
2177
- // ----- Close the temporary file
2178
- @fclose($v_zip_temp_fd);
2179
-
2180
- // ----- Magic quotes trick
2181
- $this->privSwapBackMagicQuotes();
2182
-
2183
- // ----- Delete the zip file
2184
- // TBC : I should test the result ...
2185
- @unlink($this->zipname);
2186
-
2187
- // ----- Rename the temporary file
2188
- // TBC : I should test the result ...
2189
- //@rename($v_zip_temp_name, $this->zipname);
2190
- PclZipUtilRename($v_zip_temp_name, $this->zipname);
2191
-
2192
- // ----- Return
2193
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2194
- return $v_result;
2195
- }
2196
- // --------------------------------------------------------------------------------
2197
-
2198
- // --------------------------------------------------------------------------------
2199
- // Function : privOpenFd()
2200
- // Description :
2201
- // Parameters :
2202
- // --------------------------------------------------------------------------------
2203
- function privOpenFd($p_mode)
2204
- {
2205
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privOpenFd", 'mode='.$p_mode);
2206
- $v_result=1;
2207
-
2208
- // ----- Look if already open
2209
- if ($this->zip_fd != 0)
2210
- {
2211
- // ----- Error log
2212
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Zip file \''.$this->zipname.'\' already open');
2213
-
2214
- // ----- Return
2215
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
2216
- return PclZip::errorCode();
2217
- }
2218
-
2219
- // ----- Open the zip file
2220
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Open file in '.$p_mode.' mode');
2221
- if (($this->zip_fd = @fopen($this->zipname, $p_mode)) == 0)
2222
- {
2223
- // ----- Error log
2224
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in '.$p_mode.' mode');
2225
-
2226
- // ----- Return
2227
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
2228
- return PclZip::errorCode();
2229
- }
2230
-
2231
- // ----- Return
2232
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2233
- return $v_result;
2234
- }
2235
- // --------------------------------------------------------------------------------
2236
-
2237
- // --------------------------------------------------------------------------------
2238
- // Function : privCloseFd()
2239
- // Description :
2240
- // Parameters :
2241
- // --------------------------------------------------------------------------------
2242
- function privCloseFd()
2243
- {
2244
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCloseFd", "");
2245
- $v_result=1;
2246
-
2247
- if ($this->zip_fd != 0)
2248
- @fclose($this->zip_fd);
2249
- $this->zip_fd = 0;
2250
-
2251
- // ----- Return
2252
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2253
- return $v_result;
2254
- }
2255
- // --------------------------------------------------------------------------------
2256
-
2257
- // --------------------------------------------------------------------------------
2258
- // Function : privAddList()
2259
- // Description :
2260
- // $p_add_dir and $p_remove_dir will give the ability to memorize a path which is
2261
- // different from the real path of the file. This is usefull if you want to have PclTar
2262
- // running in any directory, and memorize relative path from an other directory.
2263
- // Parameters :
2264
- // $p_list : An array containing the file or directory names to add in the tar
2265
- // $p_result_list : list of added files with their properties (specially the status field)
2266
- // $p_add_dir : Path to add in the filename path archived
2267
- // $p_remove_dir : Path to remove in the filename path archived
2268
- // Return Values :
2269
- // --------------------------------------------------------------------------------
2270
- // function privAddList($p_list, &$p_result_list, $p_add_dir, $p_remove_dir, $p_remove_all_dir, &$p_options)
2271
- function privAddList($p_filedescr_list, &$p_result_list, &$p_options)
2272
- {
2273
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddList", "list");
2274
- $v_result=1;
2275
-
2276
- // ----- Add the files
2277
- $v_header_list = array();
2278
- if (($v_result = $this->privAddFileList($p_filedescr_list, $v_header_list, $p_options)) != 1)
2279
- {
2280
- // ----- Return
2281
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2282
- return $v_result;
2283
- }
2284
-
2285
- // ----- Store the offset of the central dir
2286
- $v_offset = @ftell($this->zip_fd);
2287
-
2288
- // ----- Create the Central Dir files header
2289
- for ($i=0,$v_count=0; $i<sizeof($v_header_list); $i++)
2290
- {
2291
- // ----- Create the file header
2292
- if ($v_header_list[$i]['status'] == 'ok') {
2293
- if (($v_result = $this->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
2294
- // ----- Return
2295
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2296
- return $v_result;
2297
- }
2298
- $v_count++;
2299
- }
2300
-
2301
- // ----- Transform the header to a 'usable' info
2302
- $this->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
2303
- }
2304
-
2305
- // ----- Zip file comment
2306
- $v_comment = '';
2307
- if (isset($p_options[PCLZIP_OPT_COMMENT])) {
2308
- $v_comment = $p_options[PCLZIP_OPT_COMMENT];
2309
- }
2310
-
2311
- // ----- Calculate the size of the central header
2312
- $v_size = @ftell($this->zip_fd)-$v_offset;
2313
-
2314
- // ----- Create the central dir footer
2315
- if (($v_result = $this->privWriteCentralHeader($v_count, $v_size, $v_offset, $v_comment)) != 1)
2316
- {
2317
- // ----- Reset the file list
2318
- unset($v_header_list);
2319
-
2320
- // ----- Return
2321
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2322
- return $v_result;
2323
- }
2324
-
2325
- // ----- Return
2326
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2327
- return $v_result;
2328
- }
2329
- // --------------------------------------------------------------------------------
2330
-
2331
- // --------------------------------------------------------------------------------
2332
- // Function : privAddFileList()
2333
- // Description :
2334
- // Parameters :
2335
- // $p_filedescr_list : An array containing the file description
2336
- // or directory names to add in the zip
2337
- // $p_result_list : list of added files with their properties (specially the status field)
2338
- // Return Values :
2339
- // --------------------------------------------------------------------------------
2340
- function privAddFileList($p_filedescr_list, &$p_result_list, &$p_options)
2341
- {
2342
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFileList", "filedescr_list");
2343
- $v_result=1;
2344
- $v_header = array();
2345
-
2346
- // ----- Recuperate the current number of elt in list
2347
- $v_nb = sizeof($p_result_list);
2348
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Before add, list have ".$v_nb." elements");
2349
-
2350
- // ----- Loop on the files
2351
- for ($j=0; ($j<sizeof($p_filedescr_list)) && ($v_result==1); $j++) {
2352
- // ----- Format the filename
2353
- $p_filedescr_list[$j]['filename']
2354
- = PclZipUtilTranslateWinPath($p_filedescr_list[$j]['filename'], false);
2355
-
2356
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Looking for file '".$p_filedescr_list[$j]['filename']."'");
2357
-
2358
- // ----- Skip empty file names
2359
- // TBC : Can this be possible ? not checked in DescrParseAtt ?
2360
- if ($p_filedescr_list[$j]['filename'] == "") {
2361
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Skip empty filename");
2362
- continue;
2363
- }
2364
-
2365
- // ----- Check the filename
2366
- if (!file_exists($p_filedescr_list[$j]['filename'])) {
2367
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_filedescr_list[$j]['filename']."' does not exists");
2368
- PclZip::privErrorLog(PCLZIP_ERR_MISSING_FILE, "File '".$p_filedescr_list[$j]['filename']."' does not exists");
2369
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
2370
- return PclZip::errorCode();
2371
- }
2372
-
2373
- // ----- Look if it is a file or a dir with no all path remove option
2374
- if ( (is_file($p_filedescr_list[$j]['filename']))
2375
- || ( is_dir($p_filedescr_list[$j]['filename'])
2376
- && ( !isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])
2377
- || !$p_options[PCLZIP_OPT_REMOVE_ALL_PATH]))) {
2378
-
2379
- // ----- Add the file
2380
- $v_result = $this->privAddFile($p_filedescr_list[$j], $v_header,
2381
- $p_options);
2382
- if ($v_result != 1) {
2383
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2384
- return $v_result;
2385
- }
2386
-
2387
- // ----- Store the file infos
2388
- $p_result_list[$v_nb++] = $v_header;
2389
- }
2390
- }
2391
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "After add, list have ".$v_nb." elements");
2392
-
2393
- // ----- Return
2394
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2395
- return $v_result;
2396
- }
2397
- // --------------------------------------------------------------------------------
2398
-
2399
- // --------------------------------------------------------------------------------
2400
- // Function : privAddFile()
2401
- // Description :
2402
- // Parameters :
2403
- // Return Values :
2404
- // --------------------------------------------------------------------------------
2405
- function privAddFile($p_filedescr, &$p_header, &$p_options)
2406
- {
2407
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privAddFile", "filename='".$p_filedescr['filename']."'");
2408
- $v_result=1;
2409
-
2410
- // ----- Working variable
2411
- $p_filename = $p_filedescr['filename'];
2412
-
2413
- // TBC : Already done in the fileAtt check ... ?
2414
- if ($p_filename == "") {
2415
- // ----- Error log
2416
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_PARAMETER, "Invalid file list parameter (invalid or empty list)");
2417
-
2418
- // ----- Return
2419
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
2420
- return PclZip::errorCode();
2421
- }
2422
-
2423
- // ----- Look for a stored different filename
2424
- if (isset($p_filedescr['stored_filename'])) {
2425
- $v_stored_filename = $p_filedescr['stored_filename'];
2426
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is NOT the same "'.$v_stored_filename.'"');
2427
- }
2428
- else {
2429
- $v_stored_filename = $p_filedescr['stored_filename'];
2430
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'Stored filename is the same');
2431
- }
2432
-
2433
- // ----- Set the file properties
2434
- clearstatcache();
2435
- $p_header['version'] = 20;
2436
- $p_header['version_extracted'] = 10;
2437
- $p_header['flag'] = 0;
2438
- $p_header['compression'] = 0;
2439
- $p_header['mtime'] = filemtime($p_filename);
2440
- $p_header['crc'] = 0;
2441
- $p_header['compressed_size'] = 0;
2442
- $p_header['size'] = filesize($p_filename);
2443
- $p_header['filename_len'] = strlen($p_filename);
2444
- $p_header['extra_len'] = 0;
2445
- $p_header['comment_len'] = 0;
2446
- $p_header['disk'] = 0;
2447
- $p_header['internal'] = 0;
2448
- // $p_header['external'] = (is_file($p_filename)?0xFE49FFE0:0x41FF0010);
2449
- $p_header['external'] = (is_file($p_filename)?0x00000000:0x00000010);
2450
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header external extension '".sprintf("0x%X",$p_header['external'])."'");
2451
- $p_header['offset'] = 0;
2452
- $p_header['filename'] = $p_filename;
2453
- $p_header['stored_filename'] = $v_stored_filename;
2454
- $p_header['extra'] = '';
2455
- $p_header['comment'] = '';
2456
- $p_header['status'] = 'ok';
2457
- $p_header['index'] = -1;
2458
-
2459
- // ----- Look for pre-add callback
2460
- if (isset($p_options[PCLZIP_CB_PRE_ADD])) {
2461
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_ADD]."()') is defined for the extraction");
2462
-
2463
- // ----- Generate a local information
2464
- $v_local_header = array();
2465
- $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2466
-
2467
- // ----- Call the callback
2468
- // Here I do not use call_user_func() because I need to send a reference to the
2469
- // header.
2470
- eval('$v_result = '.$p_options[PCLZIP_CB_PRE_ADD].'(PCLZIP_CB_PRE_ADD, $v_local_header);');
2471
- if ($v_result == 0) {
2472
- // ----- Change the file status
2473
- $p_header['status'] = "skipped";
2474
- $v_result = 1;
2475
- }
2476
-
2477
- // ----- Update the informations
2478
- // Only some fields can be modified
2479
- if ($p_header['stored_filename'] != $v_local_header['stored_filename']) {
2480
- $p_header['stored_filename'] = PclZipUtilPathReduction($v_local_header['stored_filename']);
2481
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New stored filename is '".$p_header['stored_filename']."'");
2482
- }
2483
- }
2484
-
2485
- // ----- Look for empty stored filename
2486
- if ($p_header['stored_filename'] == "") {
2487
- $p_header['status'] = "filtered";
2488
- }
2489
-
2490
- // ----- Check the path length
2491
- if (strlen($p_header['stored_filename']) > 0xFF) {
2492
- $p_header['status'] = 'filename_too_long';
2493
- }
2494
-
2495
- // ----- Look if no error, or file not skipped
2496
- if ($p_header['status'] == 'ok') {
2497
-
2498
- // ----- Look for a file
2499
- if (is_file($p_filename))
2500
- {
2501
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a file");
2502
- // ----- Open the source file
2503
- if (($v_file = @fopen($p_filename, "rb")) == 0) {
2504
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, "Unable to open file '$p_filename' in binary read mode");
2505
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
2506
- return PclZip::errorCode();
2507
- }
2508
-
2509
- if ($p_options[PCLZIP_OPT_NO_COMPRESSION]) {
2510
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be compressed");
2511
- // ----- Read the file content
2512
- $v_content_compressed = @fread($v_file, $p_header['size']);
2513
-
2514
- // ----- Calculate the CRC
2515
- $p_header['crc'] = @crc32($v_content_compressed);
2516
-
2517
- // ----- Set header parameters
2518
- $p_header['compressed_size'] = $p_header['size'];
2519
- $p_header['compression'] = 0;
2520
- }
2521
- else {
2522
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will be compressed");
2523
- // ----- Read the file content
2524
- $v_content = @fread($v_file, $p_header['size']);
2525
-
2526
- // ----- Calculate the CRC
2527
- $p_header['crc'] = @crc32($v_content);
2528
-
2529
- // ----- Compress the file
2530
- $v_content_compressed = @gzdeflate($v_content);
2531
-
2532
- // ----- Set header parameters
2533
- $p_header['compressed_size'] = strlen($v_content_compressed);
2534
- $p_header['compression'] = 8;
2535
- }
2536
-
2537
- // ----- Look for encryption
2538
- /*
2539
- if ((isset($p_options[PCLZIP_OPT_CRYPT]))
2540
- && ($p_options[PCLZIP_OPT_CRYPT] != "")) {
2541
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File need to be crypted ....");
2542
-
2543
- // Should be a random header
2544
- $v_header = 'xxxxxxxxxxxx';
2545
- $v_content_compressed = PclZipUtilZipEncrypt($v_content_compressed,
2546
- $p_header['compressed_size'],
2547
- $v_header,
2548
- $p_header['crc'],
2549
- "test");
2550
-
2551
- $p_header['compressed_size'] += 12;
2552
- $p_header['flag'] = 1;
2553
-
2554
- // ----- Add the header to the data
2555
- $v_content_compressed = $v_header.$v_content_compressed;
2556
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size after header : ".strlen($v_content_compressed)."");
2557
- }
2558
- */
2559
-
2560
- // ----- Call the header generation
2561
- if (($v_result = $this->privWriteFileHeader($p_header)) != 1) {
2562
- @fclose($v_file);
2563
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2564
- return $v_result;
2565
- }
2566
-
2567
- // ----- Write the compressed (or not) content
2568
- @fwrite($this->zip_fd,
2569
- $v_content_compressed, $p_header['compressed_size']);
2570
-
2571
- // ----- Close the file
2572
- @fclose($v_file);
2573
- }
2574
-
2575
- // ----- Look for a directory
2576
- else {
2577
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "'".$p_filename."' is a folder");
2578
- // ----- Look for directory last '/'
2579
- if (@substr($p_header['stored_filename'], -1) != '/') {
2580
- $p_header['stored_filename'] .= '/';
2581
- }
2582
-
2583
- // ----- Set the file properties
2584
- $p_header['size'] = 0;
2585
- //$p_header['external'] = 0x41FF0010; // Value for a folder : to be checked
2586
- $p_header['external'] = 0x00000010; // Value for a folder : to be checked
2587
-
2588
- // ----- Call the header generation
2589
- if (($v_result = $this->privWriteFileHeader($p_header)) != 1)
2590
- {
2591
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2592
- return $v_result;
2593
- }
2594
- }
2595
- }
2596
-
2597
- // ----- Look for post-add callback
2598
- if (isset($p_options[PCLZIP_CB_POST_ADD])) {
2599
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_ADD]."()') is defined for the extraction");
2600
-
2601
- // ----- Generate a local information
2602
- $v_local_header = array();
2603
- $this->privConvertHeader2FileInfo($p_header, $v_local_header);
2604
-
2605
- // ----- Call the callback
2606
- // Here I do not use call_user_func() because I need to send a reference to the
2607
- // header.
2608
- eval('$v_result = '.$p_options[PCLZIP_CB_POST_ADD].'(PCLZIP_CB_POST_ADD, $v_local_header);');
2609
- if ($v_result == 0) {
2610
- // ----- Ignored
2611
- $v_result = 1;
2612
- }
2613
-
2614
- // ----- Update the informations
2615
- // Nothing can be modified
2616
- }
2617
-
2618
- // ----- Return
2619
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2620
- return $v_result;
2621
- }
2622
- // --------------------------------------------------------------------------------
2623
-
2624
- // --------------------------------------------------------------------------------
2625
- // Function : privCalculateStoredFilename()
2626
- // Description :
2627
- // Based on file descriptor properties and global options, this method
2628
- // calculate the filename that will be stored in the archive.
2629
- // Parameters :
2630
- // Return Values :
2631
- // --------------------------------------------------------------------------------
2632
- function privCalculateStoredFilename(&$p_filedescr, &$p_options)
2633
- {
2634
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCalculateStoredFilename", "filename='".$p_filedescr['filename']."'");
2635
- $v_result=1;
2636
-
2637
- // ----- Working variables
2638
- $p_filename = $p_filedescr['filename'];
2639
- if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
2640
- $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
2641
- }
2642
- else {
2643
- $p_add_dir = '';
2644
- }
2645
- if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
2646
- $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
2647
- }
2648
- else {
2649
- $p_remove_dir = '';
2650
- }
2651
- if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
2652
- $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
2653
- }
2654
- else {
2655
- $p_remove_all_dir = 0;
2656
- }
2657
-
2658
- // ----- Look for full name change
2659
- if (isset($p_filedescr['new_full_name'])) {
2660
- $v_stored_filename = $p_filedescr['new_full_name'];
2661
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing full name of '".$p_filename."' for '".$v_stored_filename."'");
2662
- }
2663
-
2664
- // ----- Look for path and/or short name change
2665
- else {
2666
-
2667
- // ----- Look for short name change
2668
- if (isset($p_filedescr['new_short_name'])) {
2669
- $v_path_info = pathinfo($p_filename);
2670
- $v_dir = '';
2671
- if ($v_path_info['dirname'] != '') {
2672
- $v_dir = $v_path_info['dirname'].'/';
2673
- }
2674
- $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
2675
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Changing short name of '".$p_filename."' for '".$v_stored_filename."'");
2676
- }
2677
- else {
2678
- // ----- Calculate the stored filename
2679
- $v_stored_filename = $p_filename;
2680
- }
2681
-
2682
- // ----- Look for all path to remove
2683
- if ($p_remove_all_dir) {
2684
- $v_stored_filename = basename($p_filename);
2685
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove all path selected change '".$p_filename."' for '".$v_stored_filename."'");
2686
- }
2687
- // ----- Look for partial path remove
2688
- else if ($p_remove_dir != "") {
2689
- if (substr($p_remove_dir, -1) != '/')
2690
- $p_remove_dir .= "/";
2691
-
2692
- if ( (substr($p_filename, 0, 2) == "./")
2693
- || (substr($p_remove_dir, 0, 2) == "./")) {
2694
-
2695
- if ( (substr($p_filename, 0, 2) == "./")
2696
- && (substr($p_remove_dir, 0, 2) != "./")) {
2697
- $p_remove_dir = "./".$p_remove_dir;
2698
- }
2699
- if ( (substr($p_filename, 0, 2) != "./")
2700
- && (substr($p_remove_dir, 0, 2) == "./")) {
2701
- $p_remove_dir = substr($p_remove_dir, 2);
2702
- }
2703
- }
2704
-
2705
- $v_compare = PclZipUtilPathInclusion($p_remove_dir,
2706
- $v_stored_filename);
2707
- if ($v_compare > 0) {
2708
- if ($v_compare == 2) {
2709
- $v_stored_filename = "";
2710
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Path to remove is the current folder");
2711
- }
2712
- else {
2713
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Remove path '$p_remove_dir' in file '$v_stored_filename'");
2714
- $v_stored_filename = substr($v_stored_filename,
2715
- strlen($p_remove_dir));
2716
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Result is '$v_stored_filename'");
2717
- }
2718
- }
2719
- }
2720
- // ----- Look for path to add
2721
- if ($p_add_dir != "") {
2722
- if (substr($p_add_dir, -1) == "/")
2723
- $v_stored_filename = $p_add_dir.$v_stored_filename;
2724
- else
2725
- $v_stored_filename = $p_add_dir."/".$v_stored_filename;
2726
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Add path '$p_add_dir' in file '$p_filename' = '$v_stored_filename'");
2727
- }
2728
- }
2729
-
2730
- // ----- Filename (reduce the path of stored name)
2731
- $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
2732
- $p_filedescr['stored_filename'] = $v_stored_filename;
2733
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Stored filename will be '".$p_filedescr['stored_filename']."', strlen ".strlen($p_filedescr['stored_filename']));
2734
-
2735
- // ----- Return
2736
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2737
- return $v_result;
2738
- }
2739
- // --------------------------------------------------------------------------------
2740
-
2741
- // --------------------------------------------------------------------------------
2742
- // Function : privWriteFileHeader()
2743
- // Description :
2744
- // Parameters :
2745
- // Return Values :
2746
- // --------------------------------------------------------------------------------
2747
- function privWriteFileHeader(&$p_header)
2748
- {
2749
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');
2750
- $v_result=1;
2751
-
2752
- // ----- Store the offset position of the file
2753
- $p_header['offset'] = ftell($this->zip_fd);
2754
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, 'File offset of the header :'.$p_header['offset']);
2755
-
2756
- // ----- Transform UNIX mtime to DOS format mdate/mtime
2757
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
2758
- $v_date = getdate($p_header['mtime']);
2759
- $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
2760
- $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
2761
-
2762
- // ----- Packed data
2763
- $v_binary_data = pack("VvvvvvVVVvv", 0x04034b50,
2764
- $p_header['version_extracted'], $p_header['flag'],
2765
- $p_header['compression'], $v_mtime, $v_mdate,
2766
- $p_header['crc'], $p_header['compressed_size'],
2767
- $p_header['size'],
2768
- strlen($p_header['stored_filename']),
2769
- $p_header['extra_len']);
2770
-
2771
- // ----- Write the first 148 bytes of the header in the archive
2772
- fputs($this->zip_fd, $v_binary_data, 30);
2773
-
2774
- // ----- Write the variable fields
2775
- if (strlen($p_header['stored_filename']) != 0)
2776
- {
2777
- fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
2778
- }
2779
- if ($p_header['extra_len'] != 0)
2780
- {
2781
- fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
2782
- }
2783
-
2784
- // ----- Return
2785
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2786
- return $v_result;
2787
- }
2788
- // --------------------------------------------------------------------------------
2789
-
2790
- // --------------------------------------------------------------------------------
2791
- // Function : privWriteCentralFileHeader()
2792
- // Description :
2793
- // Parameters :
2794
- // Return Values :
2795
- // --------------------------------------------------------------------------------
2796
- function privWriteCentralFileHeader(&$p_header)
2797
- {
2798
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralFileHeader", 'file="'.$p_header['filename'].'", stored as "'.$p_header['stored_filename'].'"');
2799
- $v_result=1;
2800
-
2801
- // TBC
2802
- //for(reset($p_header); $key = key($p_header); next($p_header)) {
2803
- // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "header[$key] = ".$p_header[$key]);
2804
- //}
2805
-
2806
- // ----- Transform UNIX mtime to DOS format mdate/mtime
2807
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
2808
- $v_date = getdate($p_header['mtime']);
2809
- $v_mtime = ($v_date['hours']<<11) + ($v_date['minutes']<<5) + $v_date['seconds']/2;
2810
- $v_mdate = (($v_date['year']-1980)<<9) + ($v_date['mon']<<5) + $v_date['mday'];
2811
-
2812
- // ----- Packed data
2813
- $v_binary_data = pack("VvvvvvvVVVvvvvvVV", 0x02014b50,
2814
- $p_header['version'], $p_header['version_extracted'],
2815
- $p_header['flag'], $p_header['compression'],
2816
- $v_mtime, $v_mdate, $p_header['crc'],
2817
- $p_header['compressed_size'], $p_header['size'],
2818
- strlen($p_header['stored_filename']),
2819
- $p_header['extra_len'], $p_header['comment_len'],
2820
- $p_header['disk'], $p_header['internal'],
2821
- $p_header['external'], $p_header['offset']);
2822
-
2823
- // ----- Write the 42 bytes of the header in the zip file
2824
- fputs($this->zip_fd, $v_binary_data, 46);
2825
-
2826
- // ----- Write the variable fields
2827
- if (strlen($p_header['stored_filename']) != 0)
2828
- {
2829
- fputs($this->zip_fd, $p_header['stored_filename'], strlen($p_header['stored_filename']));
2830
- }
2831
- if ($p_header['extra_len'] != 0)
2832
- {
2833
- fputs($this->zip_fd, $p_header['extra'], $p_header['extra_len']);
2834
- }
2835
- if ($p_header['comment_len'] != 0)
2836
- {
2837
- fputs($this->zip_fd, $p_header['comment'], $p_header['comment_len']);
2838
- }
2839
-
2840
- // ----- Return
2841
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2842
- return $v_result;
2843
- }
2844
- // --------------------------------------------------------------------------------
2845
-
2846
- // --------------------------------------------------------------------------------
2847
- // Function : privWriteCentralHeader()
2848
- // Description :
2849
- // Parameters :
2850
- // Return Values :
2851
- // --------------------------------------------------------------------------------
2852
- function privWriteCentralHeader($p_nb_entries, $p_size, $p_offset, $p_comment)
2853
- {
2854
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privWriteCentralHeader", 'nb_entries='.$p_nb_entries.', size='.$p_size.', offset='.$p_offset.', comment="'.$p_comment.'"');
2855
- $v_result=1;
2856
-
2857
- // ----- Packed data
2858
- $v_binary_data = pack("VvvvvVVv", 0x06054b50, 0, 0, $p_nb_entries,
2859
- $p_nb_entries, $p_size,
2860
- $p_offset, strlen($p_comment));
2861
-
2862
- // ----- Write the 22 bytes of the header in the zip file
2863
- fputs($this->zip_fd, $v_binary_data, 22);
2864
-
2865
- // ----- Write the variable fields
2866
- if (strlen($p_comment) != 0)
2867
- {
2868
- fputs($this->zip_fd, $p_comment, strlen($p_comment));
2869
- }
2870
-
2871
- // ----- Return
2872
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2873
- return $v_result;
2874
- }
2875
- // --------------------------------------------------------------------------------
2876
-
2877
- // --------------------------------------------------------------------------------
2878
- // Function : privList()
2879
- // Description :
2880
- // Parameters :
2881
- // Return Values :
2882
- // --------------------------------------------------------------------------------
2883
- function privList(&$p_list)
2884
- {
2885
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privList", "list");
2886
- $v_result=1;
2887
-
2888
- // ----- Magic quotes trick
2889
- $this->privDisableMagicQuotes();
2890
-
2891
- // ----- Open the zip file
2892
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
2893
- if (($this->zip_fd = @fopen($this->zipname, 'rb')) == 0)
2894
- {
2895
- // ----- Magic quotes trick
2896
- $this->privSwapBackMagicQuotes();
2897
-
2898
- // ----- Error log
2899
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive \''.$this->zipname.'\' in binary read mode');
2900
-
2901
- // ----- Return
2902
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
2903
- return PclZip::errorCode();
2904
- }
2905
-
2906
- // ----- Read the central directory informations
2907
- $v_central_dir = array();
2908
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
2909
- {
2910
- $this->privSwapBackMagicQuotes();
2911
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2912
- return $v_result;
2913
- }
2914
-
2915
- // ----- Go to beginning of Central Dir
2916
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Offset : ".$v_central_dir['offset']."'");
2917
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
2918
- @rewind($this->zip_fd);
2919
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
2920
- if (@fseek($this->zip_fd, $v_central_dir['offset']))
2921
- {
2922
- $this->privSwapBackMagicQuotes();
2923
-
2924
- // ----- Error log
2925
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
2926
-
2927
- // ----- Return
2928
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
2929
- return PclZip::errorCode();
2930
- }
2931
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position in file : ".ftell($this->zip_fd)."'");
2932
-
2933
- // ----- Read each entry
2934
- for ($i=0; $i<$v_central_dir['entries']; $i++)
2935
- {
2936
- // ----- Read the file header
2937
- if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
2938
- {
2939
- $this->privSwapBackMagicQuotes();
2940
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2941
- return $v_result;
2942
- }
2943
- $v_header['index'] = $i;
2944
-
2945
- // ----- Get the only interesting attributes
2946
- $this->privConvertHeader2FileInfo($v_header, $p_list[$i]);
2947
- unset($v_header);
2948
- }
2949
-
2950
- // ----- Close the zip file
2951
- $this->privCloseFd();
2952
-
2953
- // ----- Magic quotes trick
2954
- $this->privSwapBackMagicQuotes();
2955
-
2956
- // ----- Return
2957
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2958
- return $v_result;
2959
- }
2960
- // --------------------------------------------------------------------------------
2961
-
2962
- // --------------------------------------------------------------------------------
2963
- // Function : privConvertHeader2FileInfo()
2964
- // Description :
2965
- // This function takes the file informations from the central directory
2966
- // entries and extract the interesting parameters that will be given back.
2967
- // The resulting file infos are set in the array $p_info
2968
- // $p_info['filename'] : Filename with full path. Given by user (add),
2969
- // extracted in the filesystem (extract).
2970
- // $p_info['stored_filename'] : Stored filename in the archive.
2971
- // $p_info['size'] = Size of the file.
2972
- // $p_info['compressed_size'] = Compressed size of the file.
2973
- // $p_info['mtime'] = Last modification date of the file.
2974
- // $p_info['comment'] = Comment associated with the file.
2975
- // $p_info['folder'] = true/false : indicates if the entry is a folder or not.
2976
- // $p_info['status'] = status of the action on the file.
2977
- // Parameters :
2978
- // Return Values :
2979
- // --------------------------------------------------------------------------------
2980
- function privConvertHeader2FileInfo($p_header, &$p_info)
2981
- {
2982
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privConvertHeader2FileInfo", "Filename='".$p_header['filename']."'");
2983
- $v_result=1;
2984
-
2985
- // ----- Get the interesting attributes
2986
- $p_info['filename'] = $p_header['filename'];
2987
- $p_info['stored_filename'] = $p_header['stored_filename'];
2988
- $p_info['size'] = $p_header['size'];
2989
- $p_info['compressed_size'] = $p_header['compressed_size'];
2990
- $p_info['mtime'] = $p_header['mtime'];
2991
- $p_info['comment'] = $p_header['comment'];
2992
- $p_info['folder'] = (($p_header['external']&0x00000010)==0x00000010);
2993
- $p_info['index'] = $p_header['index'];
2994
- $p_info['status'] = $p_header['status'];
2995
-
2996
- // ----- Return
2997
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
2998
- return $v_result;
2999
- }
3000
- // --------------------------------------------------------------------------------
3001
-
3002
- // --------------------------------------------------------------------------------
3003
- // Function : privExtractByRule()
3004
- // Description :
3005
- // Extract a file or directory depending of rules (by index, by name, ...)
3006
- // Parameters :
3007
- // $p_file_list : An array where will be placed the properties of each
3008
- // extracted file
3009
- // $p_path : Path to add while writing the extracted files
3010
- // $p_remove_path : Path to remove (from the file memorized path) while writing the
3011
- // extracted files. If the path does not match the file path,
3012
- // the file is extracted with its memorized path.
3013
- // $p_remove_path does not apply to 'list' mode.
3014
- // $p_path and $p_remove_path are commulative.
3015
- // Return Values :
3016
- // 1 on success,0 or less on error (see error code list)
3017
- // --------------------------------------------------------------------------------
3018
- function privExtractByRule(&$p_file_list, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3019
- {
3020
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privExtractByRule", "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");
3021
- $v_result=1;
3022
-
3023
- // ----- Magic quotes trick
3024
- $this->privDisableMagicQuotes();
3025
-
3026
- // ----- Check the path
3027
- if ( ($p_path == "")
3028
- || ( (substr($p_path, 0, 1) != "/")
3029
- && (substr($p_path, 0, 3) != "../")
3030
- && (substr($p_path,1,2)!=":/")))
3031
- $p_path = "./".$p_path;
3032
-
3033
- // ----- Reduce the path last (and duplicated) '/'
3034
- if (($p_path != "./") && ($p_path != "/"))
3035
- {
3036
- // ----- Look for the path end '/'
3037
- while (substr($p_path, -1) == "/")
3038
- {
3039
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Destination path [$p_path] ends by '/'");
3040
- $p_path = substr($p_path, 0, strlen($p_path)-1);
3041
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Modified to [$p_path]");
3042
- }
3043
- }
3044
-
3045
- // ----- Look for path to remove format (should end by /)
3046
- if (($p_remove_path != "") && (substr($p_remove_path, -1) != '/'))
3047
- {
3048
- $p_remove_path .= '/';
3049
- }
3050
- $p_remove_path_size = strlen($p_remove_path);
3051
-
3052
- // ----- Open the zip file
3053
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
3054
- if (($v_result = $this->privOpenFd('rb')) != 1)
3055
- {
3056
- $this->privSwapBackMagicQuotes();
3057
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3058
- return $v_result;
3059
- }
3060
-
3061
- // ----- Read the central directory informations
3062
- $v_central_dir = array();
3063
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
3064
- {
3065
- // ----- Close the zip file
3066
- $this->privCloseFd();
3067
- $this->privSwapBackMagicQuotes();
3068
-
3069
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3070
- return $v_result;
3071
- }
3072
-
3073
- // ----- Start at beginning of Central Dir
3074
- $v_pos_entry = $v_central_dir['offset'];
3075
-
3076
- // ----- Read each entry
3077
- $j_start = 0;
3078
- for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
3079
- {
3080
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry : '$i'");
3081
-
3082
- // ----- Read next Central dir entry
3083
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position before rewind : ".ftell($this->zip_fd)."'");
3084
- @rewind($this->zip_fd);
3085
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Position after rewind : ".ftell($this->zip_fd)."'");
3086
- if (@fseek($this->zip_fd, $v_pos_entry))
3087
- {
3088
- // ----- Close the zip file
3089
- $this->privCloseFd();
3090
- $this->privSwapBackMagicQuotes();
3091
-
3092
- // ----- Error log
3093
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3094
-
3095
- // ----- Return
3096
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
3097
- return PclZip::errorCode();
3098
- }
3099
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Position after fseek : ".ftell($this->zip_fd)."'");
3100
-
3101
- // ----- Read the file header
3102
- $v_header = array();
3103
- if (($v_result = $this->privReadCentralFileHeader($v_header)) != 1)
3104
- {
3105
- // ----- Close the zip file
3106
- $this->privCloseFd();
3107
- $this->privSwapBackMagicQuotes();
3108
-
3109
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3110
- return $v_result;
3111
- }
3112
-
3113
- // ----- Store the index
3114
- $v_header['index'] = $i;
3115
-
3116
- // ----- Store the file position
3117
- $v_pos_entry = ftell($this->zip_fd);
3118
-
3119
- // ----- Look for the specific extract rules
3120
- $v_extract = false;
3121
-
3122
- // ----- Look for extract by name rule
3123
- if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
3124
- && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
3125
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");
3126
-
3127
- // ----- Look if the filename is in the list
3128
- for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_extract); $j++) {
3129
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");
3130
-
3131
- // ----- Look for a directory
3132
- if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
3133
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");
3134
-
3135
- // ----- Look if the directory is in the filename path
3136
- if ( (strlen($v_header['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
3137
- && (substr($v_header['stored_filename'], 0, strlen($p_options[PCLZIP_OPT_BY_NAME][$j])) == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
3138
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");
3139
- $v_extract = true;
3140
- }
3141
- }
3142
- // ----- Look for a filename
3143
- elseif ($v_header['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
3144
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");
3145
- $v_extract = true;
3146
- }
3147
- }
3148
- }
3149
-
3150
- // ----- Look for extract by ereg rule
3151
- else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
3152
- && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
3153
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
3154
-
3155
- if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header['stored_filename'])) {
3156
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
3157
- $v_extract = true;
3158
- }
3159
- }
3160
-
3161
- // ----- Look for extract by preg rule
3162
- else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
3163
- && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
3164
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");
3165
-
3166
- if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header['stored_filename'])) {
3167
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
3168
- $v_extract = true;
3169
- }
3170
- }
3171
-
3172
- // ----- Look for extract by index rule
3173
- else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
3174
- && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
3175
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");
3176
-
3177
- // ----- Look if the index is in the list
3178
- for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_extract); $j++) {
3179
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]");
3180
-
3181
- if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
3182
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");
3183
- $v_extract = true;
3184
- }
3185
- if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
3186
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop");
3187
- $j_start = $j+1;
3188
- }
3189
-
3190
- if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
3191
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop");
3192
- break;
3193
- }
3194
- }
3195
- }
3196
-
3197
- // ----- Look for no rule, which means extract all the archive
3198
- else {
3199
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with no rule (extract all)");
3200
- $v_extract = true;
3201
- }
3202
-
3203
- // ----- Check compression method
3204
- if ( ($v_extract)
3205
- && ( ($v_header['compression'] != 8)
3206
- && ($v_header['compression'] != 0))) {
3207
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported compression method (".$v_header['compression'].")");
3208
- $v_header['status'] = 'unsupported_compression';
3209
-
3210
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3211
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3212
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3213
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
3214
-
3215
- $this->privSwapBackMagicQuotes();
3216
-
3217
- PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_COMPRESSION,
3218
- "Filename '".$v_header['stored_filename']."' is "
3219
- ."compressed by an unsupported compression "
3220
- ."method (".$v_header['compression'].") ");
3221
-
3222
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
3223
- return PclZip::errorCode();
3224
- }
3225
- }
3226
-
3227
- // ----- Check encrypted files
3228
- if (($v_extract) && (($v_header['flag'] & 1) == 1)) {
3229
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unsupported file encryption");
3230
- $v_header['status'] = 'unsupported_encryption';
3231
-
3232
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3233
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3234
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3235
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
3236
-
3237
- $this->privSwapBackMagicQuotes();
3238
-
3239
- PclZip::privErrorLog(PCLZIP_ERR_UNSUPPORTED_ENCRYPTION,
3240
- "Unsupported encryption for "
3241
- ." filename '".$v_header['stored_filename']
3242
- ."'");
3243
-
3244
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
3245
- return PclZip::errorCode();
3246
- }
3247
- }
3248
-
3249
- // ----- Look for real extraction
3250
- if (($v_extract) && ($v_header['status'] != 'ok')) {
3251
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "No need for extract");
3252
- $v_result = $this->privConvertHeader2FileInfo($v_header,
3253
- $p_file_list[$v_nb_extracted++]);
3254
- if ($v_result != 1) {
3255
- $this->privCloseFd();
3256
- $this->privSwapBackMagicQuotes();
3257
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3258
- return $v_result;
3259
- }
3260
-
3261
- $v_extract = false;
3262
- }
3263
-
3264
- // ----- Look for real extraction
3265
- if ($v_extract)
3266
- {
3267
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file '".$v_header['filename']."', index '$i'");
3268
-
3269
- // ----- Go to the file position
3270
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
3271
- @rewind($this->zip_fd);
3272
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
3273
- if (@fseek($this->zip_fd, $v_header['offset']))
3274
- {
3275
- // ----- Close the zip file
3276
- $this->privCloseFd();
3277
-
3278
- $this->privSwapBackMagicQuotes();
3279
-
3280
- // ----- Error log
3281
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
3282
-
3283
- // ----- Return
3284
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
3285
- return PclZip::errorCode();
3286
- }
3287
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
3288
-
3289
- // ----- Look for extraction as string
3290
- if ($p_options[PCLZIP_OPT_EXTRACT_AS_STRING]) {
3291
-
3292
- // ----- Extracting the file
3293
- $v_result1 = $this->privExtractFileAsString($v_header, $v_string);
3294
- if ($v_result1 < 1) {
3295
- $this->privCloseFd();
3296
- $this->privSwapBackMagicQuotes();
3297
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);
3298
- return $v_result1;
3299
- }
3300
-
3301
- // ----- Get the only interesting attributes
3302
- if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted])) != 1)
3303
- {
3304
- // ----- Close the zip file
3305
- $this->privCloseFd();
3306
- $this->privSwapBackMagicQuotes();
3307
-
3308
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3309
- return $v_result;
3310
- }
3311
-
3312
- // ----- Set the file content
3313
- $p_file_list[$v_nb_extracted]['content'] = $v_string;
3314
-
3315
- // ----- Next extracted file
3316
- $v_nb_extracted++;
3317
-
3318
- // ----- Look for user callback abort
3319
- if ($v_result1 == 2) {
3320
- break;
3321
- }
3322
- }
3323
- // ----- Look for extraction in standard output
3324
- elseif ( (isset($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT]))
3325
- && ($p_options[PCLZIP_OPT_EXTRACT_IN_OUTPUT])) {
3326
- // ----- Extracting the file in standard output
3327
- $v_result1 = $this->privExtractFileInOutput($v_header, $p_options);
3328
- if ($v_result1 < 1) {
3329
- $this->privCloseFd();
3330
- $this->privSwapBackMagicQuotes();
3331
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);
3332
- return $v_result1;
3333
- }
3334
-
3335
- // ----- Get the only interesting attributes
3336
- if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1) {
3337
- $this->privCloseFd();
3338
- $this->privSwapBackMagicQuotes();
3339
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3340
- return $v_result;
3341
- }
3342
-
3343
- // ----- Look for user callback abort
3344
- if ($v_result1 == 2) {
3345
- break;
3346
- }
3347
- }
3348
- // ----- Look for normal extraction
3349
- else {
3350
- // ----- Extracting the file
3351
- $v_result1 = $this->privExtractFile($v_header,
3352
- $p_path, $p_remove_path,
3353
- $p_remove_all_path,
3354
- $p_options);
3355
- if ($v_result1 < 1) {
3356
- $this->privCloseFd();
3357
- $this->privSwapBackMagicQuotes();
3358
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result1);
3359
- return $v_result1;
3360
- }
3361
-
3362
- // ----- Get the only interesting attributes
3363
- if (($v_result = $this->privConvertHeader2FileInfo($v_header, $p_file_list[$v_nb_extracted++])) != 1)
3364
- {
3365
- // ----- Close the zip file
3366
- $this->privCloseFd();
3367
- $this->privSwapBackMagicQuotes();
3368
-
3369
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3370
- return $v_result;
3371
- }
3372
-
3373
- // ----- Look for user callback abort
3374
- if ($v_result1 == 2) {
3375
- break;
3376
- }
3377
- }
3378
- }
3379
- }
3380
-
3381
- // ----- Close the zip file
3382
- $this->privCloseFd();
3383
- $this->privSwapBackMagicQuotes();
3384
-
3385
- // ----- Return
3386
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3387
- return $v_result;
3388
- }
3389
- // --------------------------------------------------------------------------------
3390
-
3391
- // --------------------------------------------------------------------------------
3392
- // Function : privExtractFile()
3393
- // Description :
3394
- // Parameters :
3395
- // Return Values :
3396
- //
3397
- // 1 : ... ?
3398
- // PCLZIP_ERR_USER_ABORTED(2) : User ask for extraction stop in callback
3399
- // --------------------------------------------------------------------------------
3400
- function privExtractFile(&$p_entry, $p_path, $p_remove_path, $p_remove_all_path, &$p_options)
3401
- {
3402
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFile', "path='$p_path', remove_path='$p_remove_path', remove_all_path='".($p_remove_all_path?'true':'false')."'");
3403
- $v_result=1;
3404
-
3405
- // ----- Read the file header
3406
- if (($v_result = $this->privReadFileHeader($v_header)) != 1)
3407
- {
3408
- // ----- Return
3409
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3410
- return $v_result;
3411
- }
3412
-
3413
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");
3414
-
3415
- // ----- Check that the file header is coherent with $p_entry info
3416
- if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
3417
- // TBC
3418
- }
3419
-
3420
- // ----- Look for all path to remove
3421
- if ($p_remove_all_path == true) {
3422
- // ----- Look for folder entry that not need to be extracted
3423
- if (($p_entry['external']&0x00000010)==0x00000010) {
3424
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The entry is a folder : need to be filtered");
3425
-
3426
- $p_entry['status'] = "filtered";
3427
-
3428
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3429
- return $v_result;
3430
- }
3431
-
3432
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "All path is removed");
3433
- // ----- Get the basename of the path
3434
- $p_entry['filename'] = basename($p_entry['filename']);
3435
- }
3436
-
3437
- // ----- Look for path to remove
3438
- else if ($p_remove_path != "")
3439
- {
3440
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look for some path to remove");
3441
- if (PclZipUtilPathInclusion($p_remove_path, $p_entry['filename']) == 2)
3442
- {
3443
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The folder is the same as the removed path '".$p_entry['filename']."'");
3444
-
3445
- // ----- Change the file status
3446
- $p_entry['status'] = "filtered";
3447
-
3448
- // ----- Return
3449
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3450
- return $v_result;
3451
- }
3452
-
3453
- $p_remove_path_size = strlen($p_remove_path);
3454
- if (substr($p_entry['filename'], 0, $p_remove_path_size) == $p_remove_path)
3455
- {
3456
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found path '$p_remove_path' to remove in file '".$p_entry['filename']."'");
3457
-
3458
- // ----- Remove the path
3459
- $p_entry['filename'] = substr($p_entry['filename'], $p_remove_path_size);
3460
-
3461
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Resulting file is '".$p_entry['filename']."'");
3462
- }
3463
- }
3464
-
3465
- // ----- Add the path
3466
- if ($p_path != '') {
3467
- $p_entry['filename'] = $p_path."/".$p_entry['filename'];
3468
- }
3469
-
3470
- // ----- Check a base_dir_restriction
3471
- if (isset($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION])) {
3472
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Check the extract directory restriction");
3473
- $v_inclusion
3474
- = PclZipUtilPathInclusion($p_options[PCLZIP_OPT_EXTRACT_DIR_RESTRICTION],
3475
- $p_entry['filename']);
3476
- if ($v_inclusion == 0) {
3477
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_EXTRACT_DIR_RESTRICTION is selected, file is outside restriction");
3478
-
3479
- PclZip::privErrorLog(PCLZIP_ERR_DIRECTORY_RESTRICTION,
3480
- "Filename '".$p_entry['filename']."' is "
3481
- ."outside PCLZIP_OPT_EXTRACT_DIR_RESTRICTION");
3482
-
3483
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
3484
- return PclZip::errorCode();
3485
- }
3486
- }
3487
-
3488
- // ----- Look for pre-extract callback
3489
- if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
3490
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction");
3491
-
3492
- // ----- Generate a local information
3493
- $v_local_header = array();
3494
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3495
-
3496
- // ----- Call the callback
3497
- // Here I do not use call_user_func() because I need to send a reference to the
3498
- // header.
3499
- eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
3500
- if ($v_result == 0) {
3501
- // ----- Change the file status
3502
- $p_entry['status'] = "skipped";
3503
- $v_result = 1;
3504
- }
3505
-
3506
- // ----- Look for abort result
3507
- if ($v_result == 2) {
3508
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
3509
- // ----- This status is internal and will be changed in 'skipped'
3510
- $p_entry['status'] = "aborted";
3511
- $v_result = PCLZIP_ERR_USER_ABORTED;
3512
- }
3513
-
3514
- // ----- Update the informations
3515
- // Only some fields can be modified
3516
- $p_entry['filename'] = $v_local_header['filename'];
3517
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'");
3518
- }
3519
-
3520
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'");
3521
-
3522
- // ----- Look if extraction should be done
3523
- if ($p_entry['status'] == 'ok') {
3524
-
3525
- // ----- Look for specific actions while the file exist
3526
- if (file_exists($p_entry['filename']))
3527
- {
3528
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$p_entry['filename']."' already exists");
3529
-
3530
- // ----- Look if file is a directory
3531
- if (is_dir($p_entry['filename']))
3532
- {
3533
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is a directory");
3534
-
3535
- // ----- Change the file status
3536
- $p_entry['status'] = "already_a_directory";
3537
-
3538
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3539
- // For historical reason first PclZip implementation does not stop
3540
- // when this kind of error occurs.
3541
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3542
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3543
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
3544
-
3545
- PclZip::privErrorLog(PCLZIP_ERR_ALREADY_A_DIRECTORY,
3546
- "Filename '".$p_entry['filename']."' is "
3547
- ."already used by an existing directory");
3548
-
3549
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
3550
- return PclZip::errorCode();
3551
- }
3552
- }
3553
- // ----- Look if file is write protected
3554
- else if (!is_writeable($p_entry['filename']))
3555
- {
3556
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is write protected");
3557
-
3558
- // ----- Change the file status
3559
- $p_entry['status'] = "write_protected";
3560
-
3561
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3562
- // For historical reason first PclZip implementation does not stop
3563
- // when this kind of error occurs.
3564
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3565
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3566
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
3567
-
3568
- PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3569
- "Filename '".$p_entry['filename']."' exists "
3570
- ."and is write protected");
3571
-
3572
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
3573
- return PclZip::errorCode();
3574
- }
3575
- }
3576
-
3577
- // ----- Look if the extracted file is older
3578
- else if (filemtime($p_entry['filename']) > $p_entry['mtime'])
3579
- {
3580
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is newer (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")");
3581
- // ----- Change the file status
3582
- if ( (isset($p_options[PCLZIP_OPT_REPLACE_NEWER]))
3583
- && ($p_options[PCLZIP_OPT_REPLACE_NEWER]===true)) {
3584
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_REPLACE_NEWER is selected, file will be replaced");
3585
- }
3586
- else {
3587
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File will not be replaced");
3588
- $p_entry['status'] = "newer_exist";
3589
-
3590
- // ----- Look for PCLZIP_OPT_STOP_ON_ERROR
3591
- // For historical reason first PclZip implementation does not stop
3592
- // when this kind of error occurs.
3593
- if ( (isset($p_options[PCLZIP_OPT_STOP_ON_ERROR]))
3594
- && ($p_options[PCLZIP_OPT_STOP_ON_ERROR]===true)) {
3595
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "PCLZIP_OPT_STOP_ON_ERROR is selected, extraction will be stopped");
3596
-
3597
- PclZip::privErrorLog(PCLZIP_ERR_WRITE_OPEN_FAIL,
3598
- "Newer version of '".$p_entry['filename']."' exists "
3599
- ."and option PCLZIP_OPT_REPLACE_NEWER is not selected");
3600
-
3601
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
3602
- return PclZip::errorCode();
3603
- }
3604
- }
3605
- }
3606
- else {
3607
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Existing file '".$p_entry['filename']."' is older than the extrated one - will be replaced by the extracted one (".date("l dS of F Y h:i:s A", filemtime($p_entry['filename'])).") than the extracted file (".date("l dS of F Y h:i:s A", $p_entry['mtime']).")");
3608
- }
3609
- }
3610
-
3611
- // ----- Check the directory availability and create it if necessary
3612
- else {
3613
- if ((($p_entry['external']&0x00000010)==0x00000010) || (substr($p_entry['filename'], -1) == '/'))
3614
- $v_dir_to_check = $p_entry['filename'];
3615
- else if (!strstr($p_entry['filename'], "/"))
3616
- $v_dir_to_check = "";
3617
- else
3618
- $v_dir_to_check = dirname($p_entry['filename']);
3619
-
3620
- if (($v_result = $this->privDirCheck($v_dir_to_check, (($p_entry['external']&0x00000010)==0x00000010))) != 1) {
3621
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to create path for '".$p_entry['filename']."'");
3622
-
3623
- // ----- Change the file status
3624
- $p_entry['status'] = "path_creation_fail";
3625
-
3626
- // ----- Return
3627
- ////--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3628
- //return $v_result;
3629
- $v_result = 1;
3630
- }
3631
- }
3632
- }
3633
-
3634
- // ----- Look if extraction should be done
3635
- if ($p_entry['status'] == 'ok') {
3636
-
3637
- // ----- Do the extraction (if not a folder)
3638
- if (!(($p_entry['external']&0x00000010)==0x00000010))
3639
- {
3640
- // ----- Look for not compressed file
3641
- if ($p_entry['compression'] == 0) {
3642
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");
3643
-
3644
- // ----- Opening destination file
3645
- if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0)
3646
- {
3647
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");
3648
-
3649
- // ----- Change the file status
3650
- $p_entry['status'] = "write_error";
3651
-
3652
- // ----- Return
3653
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3654
- return $v_result;
3655
- }
3656
-
3657
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read '".$p_entry['size']."' bytes");
3658
-
3659
- // ----- Read the file by PCLZIP_READ_BLOCK_SIZE octets blocks
3660
- $v_size = $p_entry['compressed_size'];
3661
- while ($v_size != 0)
3662
- {
3663
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
3664
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Read $v_read_size bytes");
3665
- $v_buffer = @fread($this->zip_fd, $v_read_size);
3666
- /* Try to speed up the code
3667
- $v_binary_data = pack('a'.$v_read_size, $v_buffer);
3668
- @fwrite($v_dest_file, $v_binary_data, $v_read_size);
3669
- */
3670
- @fwrite($v_dest_file, $v_buffer, $v_read_size);
3671
- $v_size -= $v_read_size;
3672
- }
3673
-
3674
- // ----- Closing the destination file
3675
- fclose($v_dest_file);
3676
-
3677
- // ----- Change the file mtime
3678
- touch($p_entry['filename'], $p_entry['mtime']);
3679
-
3680
-
3681
- }
3682
- else {
3683
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (Compression method ".$p_entry['compression'].")");
3684
- // ----- TBC
3685
- // Need to be finished
3686
- if (($p_entry['flag'] & 1) == 1) {
3687
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File is encrypted");
3688
- /*
3689
- // ----- Read the encryption header
3690
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read 12 encryption header bytes");
3691
- $v_encryption_header = @fread($this->zip_fd, 12);
3692
-
3693
- // ----- Read the encrypted & compressed file in a buffer
3694
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".($p_entry['compressed_size']-12)."' compressed & encrypted bytes");
3695
- $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']-12);
3696
-
3697
- // ----- Decrypt the buffer
3698
- $this->privDecrypt($v_encryption_header, $v_buffer,
3699
- $p_entry['compressed_size']-12, $p_entry['crc']);
3700
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Buffer is '".$v_buffer."'");
3701
- */
3702
- }
3703
- else {
3704
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read '".$p_entry['compressed_size']."' compressed bytes");
3705
- // ----- Read the compressed file in a buffer (one shot)
3706
- $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
3707
- }
3708
-
3709
- // ----- Decompress the file
3710
- $v_file_content = @gzinflate($v_buffer);
3711
- unset($v_buffer);
3712
- if ($v_file_content === FALSE) {
3713
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to inflate compressed file");
3714
-
3715
- // ----- Change the file status
3716
- // TBC
3717
- $p_entry['status'] = "error";
3718
-
3719
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3720
- return $v_result;
3721
- }
3722
-
3723
- // ----- Opening destination file
3724
- if (($v_dest_file = @fopen($p_entry['filename'], 'wb')) == 0) {
3725
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Error while opening '".$p_entry['filename']."' in write binary mode");
3726
-
3727
- // ----- Change the file status
3728
- $p_entry['status'] = "write_error";
3729
-
3730
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3731
- return $v_result;
3732
- }
3733
-
3734
- // ----- Write the uncompressed data
3735
- @fwrite($v_dest_file, $v_file_content, $p_entry['size']);
3736
- unset($v_file_content);
3737
-
3738
- // ----- Closing the destination file
3739
- @fclose($v_dest_file);
3740
-
3741
- // ----- Change the file mtime
3742
- @touch($p_entry['filename'], $p_entry['mtime']);
3743
- }
3744
-
3745
- // ----- Look for chmod option
3746
- if (isset($p_options[PCLZIP_OPT_SET_CHMOD])) {
3747
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "chmod option activated '".$p_options[PCLZIP_OPT_SET_CHMOD]."'");
3748
-
3749
- // ----- Change the mode of the file
3750
- @chmod($p_entry['filename'], $p_options[PCLZIP_OPT_SET_CHMOD]);
3751
- }
3752
-
3753
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
3754
- }
3755
- }
3756
-
3757
- // ----- Change abort status
3758
- if ($p_entry['status'] == "aborted") {
3759
- $p_entry['status'] = "skipped";
3760
- }
3761
-
3762
- // ----- Look for post-extract callback
3763
- elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
3764
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction");
3765
-
3766
- // ----- Generate a local information
3767
- $v_local_header = array();
3768
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3769
-
3770
- // ----- Call the callback
3771
- // Here I do not use call_user_func() because I need to send a reference to the
3772
- // header.
3773
- eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
3774
-
3775
- // ----- Look for abort result
3776
- if ($v_result == 2) {
3777
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
3778
- $v_result = PCLZIP_ERR_USER_ABORTED;
3779
- }
3780
- }
3781
-
3782
- // ----- Return
3783
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3784
- return $v_result;
3785
- }
3786
- // --------------------------------------------------------------------------------
3787
-
3788
- // --------------------------------------------------------------------------------
3789
- // Function : privExtractFileInOutput()
3790
- // Description :
3791
- // Parameters :
3792
- // Return Values :
3793
- // --------------------------------------------------------------------------------
3794
- function privExtractFileInOutput(&$p_entry, &$p_options)
3795
- {
3796
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileInOutput', "");
3797
- $v_result=1;
3798
-
3799
- // ----- Read the file header
3800
- if (($v_result = $this->privReadFileHeader($v_header)) != 1) {
3801
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3802
- return $v_result;
3803
- }
3804
-
3805
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");
3806
-
3807
- // ----- Check that the file header is coherent with $p_entry info
3808
- if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
3809
- // TBC
3810
- }
3811
-
3812
- // ----- Look for pre-extract callback
3813
- if (isset($p_options[PCLZIP_CB_PRE_EXTRACT])) {
3814
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A pre-callback '".$p_options[PCLZIP_CB_PRE_EXTRACT]."()') is defined for the extraction");
3815
-
3816
- // ----- Generate a local information
3817
- $v_local_header = array();
3818
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3819
-
3820
- // ----- Call the callback
3821
- // Here I do not use call_user_func() because I need to send a reference to the
3822
- // header.
3823
- eval('$v_result = '.$p_options[PCLZIP_CB_PRE_EXTRACT].'(PCLZIP_CB_PRE_EXTRACT, $v_local_header);');
3824
- if ($v_result == 0) {
3825
- // ----- Change the file status
3826
- $p_entry['status'] = "skipped";
3827
- $v_result = 1;
3828
- }
3829
-
3830
- // ----- Look for abort result
3831
- if ($v_result == 2) {
3832
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
3833
- // ----- This status is internal and will be changed in 'skipped'
3834
- $p_entry['status'] = "aborted";
3835
- $v_result = PCLZIP_ERR_USER_ABORTED;
3836
- }
3837
-
3838
- // ----- Update the informations
3839
- // Only some fields can be modified
3840
- $p_entry['filename'] = $v_local_header['filename'];
3841
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "New filename is '".$p_entry['filename']."'");
3842
- }
3843
-
3844
- // ----- Trace
3845
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file (with path) '".$p_entry['filename']."', size '$v_header[size]'");
3846
-
3847
- // ----- Look if extraction should be done
3848
- if ($p_entry['status'] == 'ok') {
3849
-
3850
- // ----- Do the extraction (if not a folder)
3851
- if (!(($p_entry['external']&0x00000010)==0x00000010)) {
3852
- // ----- Look for not compressed file
3853
- if ($p_entry['compressed_size'] == $p_entry['size']) {
3854
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");
3855
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");
3856
-
3857
- // ----- Read the file in a buffer (one shot)
3858
- $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
3859
-
3860
- // ----- Send the file to the output
3861
- echo $v_buffer;
3862
- unset($v_buffer);
3863
- }
3864
- else {
3865
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file");
3866
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Reading '".$p_entry['size']."' bytes");
3867
-
3868
- // ----- Read the compressed file in a buffer (one shot)
3869
- $v_buffer = @fread($this->zip_fd, $p_entry['compressed_size']);
3870
-
3871
- // ----- Decompress the file
3872
- $v_file_content = gzinflate($v_buffer);
3873
- unset($v_buffer);
3874
-
3875
- // ----- Send the file to the output
3876
- echo $v_file_content;
3877
- unset($v_file_content);
3878
- }
3879
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
3880
- }
3881
- }
3882
-
3883
- // ----- Change abort status
3884
- if ($p_entry['status'] == "aborted") {
3885
- $p_entry['status'] = "skipped";
3886
- }
3887
-
3888
- // ----- Look for post-extract callback
3889
- elseif (isset($p_options[PCLZIP_CB_POST_EXTRACT])) {
3890
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "A post-callback '".$p_options[PCLZIP_CB_POST_EXTRACT]."()') is defined for the extraction");
3891
-
3892
- // ----- Generate a local information
3893
- $v_local_header = array();
3894
- $this->privConvertHeader2FileInfo($p_entry, $v_local_header);
3895
-
3896
- // ----- Call the callback
3897
- // Here I do not use call_user_func() because I need to send a reference to the
3898
- // header.
3899
- eval('$v_result = '.$p_options[PCLZIP_CB_POST_EXTRACT].'(PCLZIP_CB_POST_EXTRACT, $v_local_header);');
3900
-
3901
- // ----- Look for abort result
3902
- if ($v_result == 2) {
3903
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "User callback abort the extraction");
3904
- $v_result = PCLZIP_ERR_USER_ABORTED;
3905
- }
3906
- }
3907
-
3908
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3909
- return $v_result;
3910
- }
3911
- // --------------------------------------------------------------------------------
3912
-
3913
- // --------------------------------------------------------------------------------
3914
- // Function : privExtractFileAsString()
3915
- // Description :
3916
- // Parameters :
3917
- // Return Values :
3918
- // --------------------------------------------------------------------------------
3919
- function privExtractFileAsString(&$p_entry, &$p_string)
3920
- {
3921
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privExtractFileAsString', "p_entry['filename']='".$p_entry['filename']."'");
3922
- $v_result=1;
3923
-
3924
- // ----- Read the file header
3925
- $v_header = array();
3926
- if (($v_result = $this->privReadFileHeader($v_header)) != 1)
3927
- {
3928
- // ----- Return
3929
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3930
- return $v_result;
3931
- }
3932
-
3933
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found file '".$v_header['filename']."', size '".$v_header['size']."'");
3934
-
3935
- // ----- Check that the file header is coherent with $p_entry info
3936
- if ($this->privCheckFileHeaders($v_header, $p_entry) != 1) {
3937
- // TBC
3938
- }
3939
-
3940
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting file in string (with path) '".$p_entry['filename']."', size '$v_header[size]'");
3941
-
3942
- // ----- Do the extraction (if not a folder)
3943
- if (!(($p_entry['external']&0x00000010)==0x00000010))
3944
- {
3945
- // ----- Look for not compressed file
3946
- // if ($p_entry['compressed_size'] == $p_entry['size'])
3947
- if ($p_entry['compression'] == 0) {
3948
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting an un-compressed file");
3949
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Reading '".$p_entry['size']."' bytes");
3950
-
3951
- // ----- Reading the file
3952
- $p_string = @fread($this->zip_fd, $p_entry['compressed_size']);
3953
- }
3954
- else {
3955
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extracting a compressed file (compression method '".$p_entry['compression']."')");
3956
-
3957
- // ----- Reading the file
3958
- $v_data = @fread($this->zip_fd, $p_entry['compressed_size']);
3959
-
3960
- // ----- Decompress the file
3961
- if (($p_string = @gzinflate($v_data)) === FALSE) {
3962
- // TBC
3963
- }
3964
- }
3965
-
3966
- // ----- Trace
3967
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Extraction done");
3968
- }
3969
- else {
3970
- // TBC : error : can not extract a folder in a string
3971
- }
3972
-
3973
- // ----- Return
3974
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
3975
- return $v_result;
3976
- }
3977
- // --------------------------------------------------------------------------------
3978
-
3979
- // --------------------------------------------------------------------------------
3980
- // Function : privReadFileHeader()
3981
- // Description :
3982
- // Parameters :
3983
- // Return Values :
3984
- // --------------------------------------------------------------------------------
3985
- function privReadFileHeader(&$p_header)
3986
- {
3987
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadFileHeader", "");
3988
- $v_result=1;
3989
-
3990
- // ----- Read the 4 bytes signature
3991
- $v_binary_data = @fread($this->zip_fd, 4);
3992
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
3993
- $v_data = unpack('Vid', $v_binary_data);
3994
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
3995
-
3996
- // ----- Check signature
3997
- if ($v_data['id'] != 0x04034b50)
3998
- {
3999
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid File header");
4000
-
4001
- // ----- Error log
4002
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4003
-
4004
- // ----- Return
4005
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
4006
- return PclZip::errorCode();
4007
- }
4008
-
4009
- // ----- Read the first 42 bytes of the header
4010
- $v_binary_data = fread($this->zip_fd, 26);
4011
-
4012
- // ----- Look for invalid block size
4013
- if (strlen($v_binary_data) != 26)
4014
- {
4015
- $p_header['filename'] = "";
4016
- $p_header['status'] = "invalid_header";
4017
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));
4018
-
4019
- // ----- Error log
4020
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4021
-
4022
- // ----- Return
4023
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
4024
- return PclZip::errorCode();
4025
- }
4026
-
4027
- // ----- Extract the values
4028
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header : '".$v_binary_data."'");
4029
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Header (Hex) : '".bin2hex($v_binary_data)."'");
4030
- $v_data = unpack('vversion/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len', $v_binary_data);
4031
-
4032
- // ----- Get filename
4033
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "File name length : ".$v_data['filename_len']);
4034
- $p_header['filename'] = fread($this->zip_fd, $v_data['filename_len']);
4035
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename : \''.$p_header['filename'].'\'');
4036
-
4037
- // ----- Get extra_fields
4038
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extra field length : ".$v_data['extra_len']);
4039
- if ($v_data['extra_len'] != 0) {
4040
- $p_header['extra'] = fread($this->zip_fd, $v_data['extra_len']);
4041
- }
4042
- else {
4043
- $p_header['extra'] = '';
4044
- }
4045
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Extra field : \''.bin2hex($p_header['extra']).'\'');
4046
-
4047
- // ----- Extract properties
4048
- $p_header['version_extracted'] = $v_data['version'];
4049
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : ('.$p_header['version_extracted'].') \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\'');
4050
- $p_header['compression'] = $v_data['compression'];
4051
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compression method : \''.$p_header['compression'].'\'');
4052
- $p_header['size'] = $v_data['size'];
4053
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_header['size'].'\'');
4054
- $p_header['compressed_size'] = $v_data['compressed_size'];
4055
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_header['compressed_size'].'\'');
4056
- $p_header['crc'] = $v_data['crc'];
4057
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\'');
4058
- $p_header['flag'] = $v_data['flag'];
4059
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Flag : \''.$p_header['flag'].'\'');
4060
- $p_header['filename_len'] = $v_data['filename_len'];
4061
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Filename_len : \''.$p_header['filename_len'].'\'');
4062
-
4063
- // ----- Recuperate date in UNIX format
4064
- $p_header['mdate'] = $v_data['mdate'];
4065
- $p_header['mtime'] = $v_data['mtime'];
4066
- if ($p_header['mdate'] && $p_header['mtime'])
4067
- {
4068
- // ----- Extract time
4069
- $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4070
- $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4071
- $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4072
-
4073
- // ----- Extract date
4074
- $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4075
- $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4076
- $v_day = $p_header['mdate'] & 0x001F;
4077
-
4078
- // ----- Get UNIX date format
4079
- $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4080
-
4081
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
4082
- }
4083
- else
4084
- {
4085
- $p_header['mtime'] = time();
4086
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
4087
- }
4088
-
4089
- // TBC
4090
- //for(reset($v_data); $key = key($v_data); next($v_data)) {
4091
- // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Attribut[$key] = ".$v_data[$key]);
4092
- //}
4093
-
4094
- // ----- Set the stored filename
4095
- $p_header['stored_filename'] = $p_header['filename'];
4096
-
4097
- // ----- Set the status field
4098
- $p_header['status'] = "ok";
4099
-
4100
- // ----- Return
4101
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4102
- return $v_result;
4103
- }
4104
- // --------------------------------------------------------------------------------
4105
-
4106
- // --------------------------------------------------------------------------------
4107
- // Function : privReadCentralFileHeader()
4108
- // Description :
4109
- // Parameters :
4110
- // Return Values :
4111
- // --------------------------------------------------------------------------------
4112
- function privReadCentralFileHeader(&$p_header)
4113
- {
4114
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadCentralFileHeader", "");
4115
- $v_result=1;
4116
-
4117
- // ----- Read the 4 bytes signature
4118
- $v_binary_data = @fread($this->zip_fd, 4);
4119
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
4120
- $v_data = unpack('Vid', $v_binary_data);
4121
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
4122
-
4123
- // ----- Check signature
4124
- if ($v_data['id'] != 0x02014b50)
4125
- {
4126
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid Central Dir File signature");
4127
-
4128
- // ----- Error log
4129
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Invalid archive structure');
4130
-
4131
- // ----- Return
4132
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
4133
- return PclZip::errorCode();
4134
- }
4135
-
4136
- // ----- Read the first 42 bytes of the header
4137
- $v_binary_data = fread($this->zip_fd, 42);
4138
-
4139
- // ----- Look for invalid block size
4140
- if (strlen($v_binary_data) != 42)
4141
- {
4142
- $p_header['filename'] = "";
4143
- $p_header['status'] = "invalid_header";
4144
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid block size : ".strlen($v_binary_data));
4145
-
4146
- // ----- Error log
4147
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid block size : ".strlen($v_binary_data));
4148
-
4149
- // ----- Return
4150
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
4151
- return PclZip::errorCode();
4152
- }
4153
-
4154
- // ----- Extract the values
4155
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header : '".$v_binary_data."'");
4156
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Header (Hex) : '".bin2hex($v_binary_data)."'");
4157
- $p_header = unpack('vversion/vversion_extracted/vflag/vcompression/vmtime/vmdate/Vcrc/Vcompressed_size/Vsize/vfilename_len/vextra_len/vcomment_len/vdisk/vinternal/Vexternal/Voffset', $v_binary_data);
4158
-
4159
- // ----- Get filename
4160
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "File name length : ".$p_header['filename_len']);
4161
- if ($p_header['filename_len'] != 0)
4162
- $p_header['filename'] = fread($this->zip_fd, $p_header['filename_len']);
4163
- else
4164
- $p_header['filename'] = '';
4165
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Filename : \''.$p_header['filename'].'\'');
4166
-
4167
- // ----- Get extra
4168
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Extra length : ".$p_header['extra_len']);
4169
- if ($p_header['extra_len'] != 0)
4170
- $p_header['extra'] = fread($this->zip_fd, $p_header['extra_len']);
4171
- else
4172
- $p_header['extra'] = '';
4173
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Extra : \''.$p_header['extra'].'\'');
4174
-
4175
- // ----- Get comment
4176
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Comment length : ".$p_header['comment_len']);
4177
- if ($p_header['comment_len'] != 0)
4178
- $p_header['comment'] = fread($this->zip_fd, $p_header['comment_len']);
4179
- else
4180
- $p_header['comment'] = '';
4181
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Comment : \''.$p_header['comment'].'\'');
4182
-
4183
- // ----- Extract properties
4184
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version : \''.($p_header['version']/10).'.'.($p_header['version']%10).'\'');
4185
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Version need to extract : \''.($p_header['version_extracted']/10).'.'.($p_header['version_extracted']%10).'\'');
4186
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Size : \''.$p_header['size'].'\'');
4187
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Compressed Size : \''.$p_header['compressed_size'].'\'');
4188
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'CRC : \''.sprintf("0x%X", $p_header['crc']).'\'');
4189
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Flag : \''.$p_header['flag'].'\'');
4190
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Offset : \''.$p_header['offset'].'\'');
4191
-
4192
- // ----- Recuperate date in UNIX format
4193
- if ($p_header['mdate'] && $p_header['mtime'])
4194
- {
4195
- // ----- Extract time
4196
- $v_hour = ($p_header['mtime'] & 0xF800) >> 11;
4197
- $v_minute = ($p_header['mtime'] & 0x07E0) >> 5;
4198
- $v_seconde = ($p_header['mtime'] & 0x001F)*2;
4199
-
4200
- // ----- Extract date
4201
- $v_year = (($p_header['mdate'] & 0xFE00) >> 9) + 1980;
4202
- $v_month = ($p_header['mdate'] & 0x01E0) >> 5;
4203
- $v_day = $p_header['mdate'] & 0x001F;
4204
-
4205
- // ----- Get UNIX date format
4206
- $p_header['mtime'] = mktime($v_hour, $v_minute, $v_seconde, $v_month, $v_day, $v_year);
4207
-
4208
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
4209
- }
4210
- else
4211
- {
4212
- $p_header['mtime'] = time();
4213
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Date is actual : \''.date("d/m/y H:i:s", $p_header['mtime']).'\'');
4214
- }
4215
-
4216
- // ----- Set the stored filename
4217
- $p_header['stored_filename'] = $p_header['filename'];
4218
-
4219
- // ----- Set default status to ok
4220
- $p_header['status'] = 'ok';
4221
-
4222
- // ----- Look if it is a directory
4223
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Internal (Hex) : '".sprintf("Ox%04X", $p_header['internal'])."'");
4224
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "External (Hex) : '".sprintf("Ox%04X", $p_header['external'])."' (".(($p_header['external']&0x00000010)==0x00000010?'is a folder':'is a file').')');
4225
- if (substr($p_header['filename'], -1) == '/') {
4226
- //$p_header['external'] = 0x41FF0010;
4227
- $p_header['external'] = 0x00000010;
4228
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Force folder external : \''.sprintf("Ox%04X", $p_header['external']).'\'');
4229
- }
4230
-
4231
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Header of filename : \''.$p_header['filename'].'\'');
4232
-
4233
- // ----- Return
4234
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4235
- return $v_result;
4236
- }
4237
- // --------------------------------------------------------------------------------
4238
-
4239
- // --------------------------------------------------------------------------------
4240
- // Function : privCheckFileHeaders()
4241
- // Description :
4242
- // Parameters :
4243
- // Return Values :
4244
- // 1 on success,
4245
- // 0 on error;
4246
- // --------------------------------------------------------------------------------
4247
- function privCheckFileHeaders(&$p_local_header, &$p_central_header)
4248
- {
4249
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privCheckFileHeaders", "");
4250
- $v_result=1;
4251
-
4252
- // ----- Check the static values
4253
- // TBC
4254
- if ($p_local_header['filename'] != $p_central_header['filename']) {
4255
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename" : TBC To Be Completed');
4256
- }
4257
- if ($p_local_header['version_extracted'] != $p_central_header['version_extracted']) {
4258
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "version_extracted" : TBC To Be Completed');
4259
- }
4260
- if ($p_local_header['flag'] != $p_central_header['flag']) {
4261
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "flag" : TBC To Be Completed');
4262
- }
4263
- if ($p_local_header['compression'] != $p_central_header['compression']) {
4264
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "compression" : TBC To Be Completed');
4265
- }
4266
- if ($p_local_header['mtime'] != $p_central_header['mtime']) {
4267
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "mtime" : TBC To Be Completed');
4268
- }
4269
- if ($p_local_header['filename_len'] != $p_central_header['filename_len']) {
4270
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Bad check "filename_len" : TBC To Be Completed');
4271
- }
4272
-
4273
- // ----- Look for flag bit 3
4274
- if (($p_local_header['flag'] & 8) == 8) {
4275
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Purpose bit flag bit 3 set !');
4276
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'File size, compression size and crc found in central header');
4277
- $p_local_header['size'] = $p_central_header['size'];
4278
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size : \''.$p_local_header['size'].'\'');
4279
- $p_local_header['compressed_size'] = $p_central_header['compressed_size'];
4280
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Compressed Size : \''.$p_local_header['compressed_size'].'\'');
4281
- $p_local_header['crc'] = $p_central_header['crc'];
4282
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'CRC : \''.sprintf("0x%X", $p_local_header['crc']).'\'');
4283
- }
4284
-
4285
- // ----- Return
4286
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4287
- return $v_result;
4288
- }
4289
- // --------------------------------------------------------------------------------
4290
-
4291
- // --------------------------------------------------------------------------------
4292
- // Function : privReadEndCentralDir()
4293
- // Description :
4294
- // Parameters :
4295
- // Return Values :
4296
- // --------------------------------------------------------------------------------
4297
- function privReadEndCentralDir(&$p_central_dir)
4298
- {
4299
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privReadEndCentralDir", "");
4300
- $v_result=1;
4301
-
4302
- // ----- Go to the end of the zip file
4303
- $v_size = filesize($this->zipname);
4304
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Size of the file :$v_size");
4305
- @fseek($this->zip_fd, $v_size);
4306
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position at end of zip file : \''.ftell($this->zip_fd).'\'');
4307
- if (@ftell($this->zip_fd) != $v_size)
4308
- {
4309
- // ----- Error log
4310
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to go to the end of the archive \''.$this->zipname.'\'');
4311
-
4312
- // ----- Return
4313
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
4314
- return PclZip::errorCode();
4315
- }
4316
-
4317
- // ----- First try : look if this is an archive with no commentaries (most of the time)
4318
- // in this case the end of central dir is at 22 bytes of the file end
4319
- $v_found = 0;
4320
- if ($v_size > 26) {
4321
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Look for central dir with no comment');
4322
- @fseek($this->zip_fd, $v_size-22);
4323
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after min central position : \''.ftell($this->zip_fd).'\'');
4324
- if (($v_pos = @ftell($this->zip_fd)) != ($v_size-22))
4325
- {
4326
- // ----- Error log
4327
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4328
-
4329
- // ----- Return
4330
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
4331
- return PclZip::errorCode();
4332
- }
4333
-
4334
- // ----- Read for bytes
4335
- $v_binary_data = @fread($this->zip_fd, 4);
4336
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Binary data is : '".sprintf("%08x", $v_binary_data)."'");
4337
- $v_data = @unpack('Vid', $v_binary_data);
4338
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Binary signature is : '".sprintf("0x%08x", $v_data['id'])."'");
4339
-
4340
- // ----- Check signature
4341
- if ($v_data['id'] == 0x06054b50) {
4342
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Found central dir at the default position.");
4343
- $v_found = 1;
4344
- }
4345
-
4346
- $v_pos = ftell($this->zip_fd);
4347
- }
4348
-
4349
- // ----- Go back to the maximum possible size of the Central Dir End Record
4350
- if (!$v_found) {
4351
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Start extended search of end central dir');
4352
- $v_maximum_size = 65557; // 0xFFFF + 22;
4353
- if ($v_maximum_size > $v_size)
4354
- $v_maximum_size = $v_size;
4355
- @fseek($this->zip_fd, $v_size-$v_maximum_size);
4356
- if (@ftell($this->zip_fd) != ($v_size-$v_maximum_size))
4357
- {
4358
- // ----- Error log
4359
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, 'Unable to seek back to the middle of the archive \''.$this->zipname.'\'');
4360
-
4361
- // ----- Return
4362
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
4363
- return PclZip::errorCode();
4364
- }
4365
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Position after max central position : \''.ftell($this->zip_fd).'\'');
4366
-
4367
- // ----- Read byte per byte in order to find the signature
4368
- $v_pos = ftell($this->zip_fd);
4369
- $v_bytes = 0x00000000;
4370
- while ($v_pos < $v_size)
4371
- {
4372
- // ----- Read a byte
4373
- $v_byte = @fread($this->zip_fd, 1);
4374
-
4375
- // ----- Add the byte
4376
- $v_bytes = ($v_bytes << 8) | Ord($v_byte);
4377
-
4378
- // ----- Compare the bytes
4379
- if ($v_bytes == 0x504b0506)
4380
- {
4381
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, 'Found End Central Dir signature at position : \''.ftell($this->zip_fd).'\'');
4382
- $v_pos++;
4383
- break;
4384
- }
4385
-
4386
- $v_pos++;
4387
- }
4388
-
4389
- // ----- Look if not found end of central dir
4390
- if ($v_pos == $v_size)
4391
- {
4392
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Unable to find End of Central Dir Record signature");
4393
-
4394
- // ----- Error log
4395
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Unable to find End of Central Dir Record signature");
4396
-
4397
- // ----- Return
4398
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
4399
- return PclZip::errorCode();
4400
- }
4401
- }
4402
-
4403
- // ----- Read the first 18 bytes of the header
4404
- $v_binary_data = fread($this->zip_fd, 18);
4405
-
4406
- // ----- Look for invalid block size
4407
- if (strlen($v_binary_data) != 18)
4408
- {
4409
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
4410
-
4411
- // ----- Error log
4412
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT, "Invalid End of Central Dir Record size : ".strlen($v_binary_data));
4413
-
4414
- // ----- Return
4415
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
4416
- return PclZip::errorCode();
4417
- }
4418
-
4419
- // ----- Extract the values
4420
- ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record : '".$v_binary_data."'");
4421
- ////--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Central Dir Record (Hex) : '".bin2hex($v_binary_data)."'");
4422
- $v_data = unpack('vdisk/vdisk_start/vdisk_entries/ventries/Vsize/Voffset/vcomment_size', $v_binary_data);
4423
-
4424
- // ----- Check the global size
4425
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Comment length : ".$v_data['comment_size']);
4426
- if (($v_pos + $v_data['comment_size'] + 18) != $v_size) {
4427
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "The central dir is not at the end of the archive. Some trailing bytes exists after the archive.");
4428
-
4429
- // ----- Removed in release 2.2 see readme file
4430
- // The check of the file size is a little too strict.
4431
- // Some bugs where found when a zip is encrypted/decrypted with 'crypt'.
4432
- // While decrypted, zip has training 0 bytes
4433
- if (0) {
4434
- // ----- Error log
4435
- PclZip::privErrorLog(PCLZIP_ERR_BAD_FORMAT,
4436
- 'The central dir is not at the end of the archive.'
4437
- .' Some trailing bytes exists after the archive.');
4438
-
4439
- // ----- Return
4440
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
4441
- return PclZip::errorCode();
4442
- }
4443
- }
4444
-
4445
- // ----- Get comment
4446
- if ($v_data['comment_size'] != 0)
4447
- $p_central_dir['comment'] = fread($this->zip_fd, $v_data['comment_size']);
4448
- else
4449
- $p_central_dir['comment'] = '';
4450
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Comment : \''.$p_central_dir['comment'].'\'');
4451
-
4452
- $p_central_dir['entries'] = $v_data['entries'];
4453
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries : \''.$p_central_dir['entries'].'\'');
4454
- $p_central_dir['disk_entries'] = $v_data['disk_entries'];
4455
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Nb of entries for this disk : \''.$p_central_dir['disk_entries'].'\'');
4456
- $p_central_dir['offset'] = $v_data['offset'];
4457
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Offset of Central Dir : \''.$p_central_dir['offset'].'\'');
4458
- $p_central_dir['size'] = $v_data['size'];
4459
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Size of Central Dir : \''.$p_central_dir['size'].'\'');
4460
- $p_central_dir['disk'] = $v_data['disk'];
4461
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Disk number : \''.$p_central_dir['disk'].'\'');
4462
- $p_central_dir['disk_start'] = $v_data['disk_start'];
4463
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, 'Start disk number : \''.$p_central_dir['disk_start'].'\'');
4464
-
4465
- // TBC
4466
- //for(reset($p_central_dir); $key = key($p_central_dir); next($p_central_dir)) {
4467
- // //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "central_dir[$key] = ".$p_central_dir[$key]);
4468
- //}
4469
-
4470
- // ----- Return
4471
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4472
- return $v_result;
4473
- }
4474
- // --------------------------------------------------------------------------------
4475
-
4476
- // --------------------------------------------------------------------------------
4477
- // Function : privDeleteByRule()
4478
- // Description :
4479
- // Parameters :
4480
- // Return Values :
4481
- // --------------------------------------------------------------------------------
4482
- function privDeleteByRule(&$p_result_list, &$p_options)
4483
- {
4484
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDeleteByRule", "");
4485
- $v_result=1;
4486
- $v_list_detail = array();
4487
-
4488
- // ----- Open the zip file
4489
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
4490
- if (($v_result=$this->privOpenFd('rb')) != 1)
4491
- {
4492
- // ----- Return
4493
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4494
- return $v_result;
4495
- }
4496
-
4497
- // ----- Read the central directory informations
4498
- $v_central_dir = array();
4499
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
4500
- {
4501
- $this->privCloseFd();
4502
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4503
- return $v_result;
4504
- }
4505
-
4506
- // ----- Go to beginning of File
4507
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
4508
- @rewind($this->zip_fd);
4509
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in file : ".ftell($this->zip_fd)."'");
4510
-
4511
- // ----- Scan all the files
4512
- // ----- Start at beginning of Central Dir
4513
- $v_pos_entry = $v_central_dir['offset'];
4514
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
4515
- @rewind($this->zip_fd);
4516
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
4517
- if (@fseek($this->zip_fd, $v_pos_entry))
4518
- {
4519
- // ----- Close the zip file
4520
- $this->privCloseFd();
4521
-
4522
- // ----- Error log
4523
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4524
-
4525
- // ----- Return
4526
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
4527
- return PclZip::errorCode();
4528
- }
4529
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
4530
-
4531
- // ----- Read each entry
4532
- $v_header_list = array();
4533
- $j_start = 0;
4534
- for ($i=0, $v_nb_extracted=0; $i<$v_central_dir['entries']; $i++)
4535
- {
4536
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Read next file header entry (index '$i')");
4537
-
4538
- // ----- Read the file header
4539
- $v_header_list[$v_nb_extracted] = array();
4540
- if (($v_result = $this->privReadCentralFileHeader($v_header_list[$v_nb_extracted])) != 1)
4541
- {
4542
- // ----- Close the zip file
4543
- $this->privCloseFd();
4544
-
4545
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4546
- return $v_result;
4547
- }
4548
-
4549
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename (index '$i') : '".$v_header_list[$v_nb_extracted]['stored_filename']."'");
4550
-
4551
- // ----- Store the index
4552
- $v_header_list[$v_nb_extracted]['index'] = $i;
4553
-
4554
- // ----- Look for the specific extract rules
4555
- $v_found = false;
4556
-
4557
- // ----- Look for extract by name rule
4558
- if ( (isset($p_options[PCLZIP_OPT_BY_NAME]))
4559
- && ($p_options[PCLZIP_OPT_BY_NAME] != 0)) {
4560
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByName'");
4561
-
4562
- // ----- Look if the filename is in the list
4563
- for ($j=0; ($j<sizeof($p_options[PCLZIP_OPT_BY_NAME])) && (!$v_found); $j++) {
4564
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Compare with file '".$p_options[PCLZIP_OPT_BY_NAME][$j]."'");
4565
-
4566
- // ----- Look for a directory
4567
- if (substr($p_options[PCLZIP_OPT_BY_NAME][$j], -1) == "/") {
4568
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The searched item is a directory");
4569
-
4570
- // ----- Look if the directory is in the filename path
4571
- if ( (strlen($v_header_list[$v_nb_extracted]['stored_filename']) > strlen($p_options[PCLZIP_OPT_BY_NAME][$j]))
4572
- && (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])) {
4573
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The directory is in the file path");
4574
- $v_found = true;
4575
- }
4576
- elseif ( (($v_header_list[$v_nb_extracted]['external']&0x00000010)==0x00000010) /* Indicates a folder */
4577
- && ($v_header_list[$v_nb_extracted]['stored_filename'].'/' == $p_options[PCLZIP_OPT_BY_NAME][$j])) {
4578
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The entry is the searched directory");
4579
- $v_found = true;
4580
- }
4581
- }
4582
- // ----- Look for a filename
4583
- elseif ($v_header_list[$v_nb_extracted]['stored_filename'] == $p_options[PCLZIP_OPT_BY_NAME][$j]) {
4584
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "The file is the right one.");
4585
- $v_found = true;
4586
- }
4587
- }
4588
- }
4589
-
4590
- // ----- Look for extract by ereg rule
4591
- else if ( (isset($p_options[PCLZIP_OPT_BY_EREG]))
4592
- && ($p_options[PCLZIP_OPT_BY_EREG] != "")) {
4593
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract by ereg '".$p_options[PCLZIP_OPT_BY_EREG]."'");
4594
-
4595
- if (ereg($p_options[PCLZIP_OPT_BY_EREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
4596
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
4597
- $v_found = true;
4598
- }
4599
- }
4600
-
4601
- // ----- Look for extract by preg rule
4602
- else if ( (isset($p_options[PCLZIP_OPT_BY_PREG]))
4603
- && ($p_options[PCLZIP_OPT_BY_PREG] != "")) {
4604
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByEreg'");
4605
-
4606
- if (preg_match($p_options[PCLZIP_OPT_BY_PREG], $v_header_list[$v_nb_extracted]['stored_filename'])) {
4607
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Filename match the regular expression");
4608
- $v_found = true;
4609
- }
4610
- }
4611
-
4612
- // ----- Look for extract by index rule
4613
- else if ( (isset($p_options[PCLZIP_OPT_BY_INDEX]))
4614
- && ($p_options[PCLZIP_OPT_BY_INDEX] != 0)) {
4615
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Extract with rule 'ByIndex'");
4616
-
4617
- // ----- Look if the index is in the list
4618
- for ($j=$j_start; ($j<sizeof($p_options[PCLZIP_OPT_BY_INDEX])) && (!$v_found); $j++) {
4619
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Look if index '$i' is in [".$p_options[PCLZIP_OPT_BY_INDEX][$j]['start'].",".$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']."]");
4620
-
4621
- if (($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['start']) && ($i<=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end'])) {
4622
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Found as part of an index range");
4623
- $v_found = true;
4624
- }
4625
- if ($i>=$p_options[PCLZIP_OPT_BY_INDEX][$j]['end']) {
4626
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Do not look this index range for next loop");
4627
- $j_start = $j+1;
4628
- }
4629
-
4630
- if ($p_options[PCLZIP_OPT_BY_INDEX][$j]['start']>$i) {
4631
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Index range is greater than index, stop loop");
4632
- break;
4633
- }
4634
- }
4635
- }
4636
- else {
4637
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "No argument mean remove all file");
4638
- $v_found = true;
4639
- }
4640
-
4641
- // ----- Look for deletion
4642
- if ($v_found)
4643
- {
4644
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' need to be deleted");
4645
- unset($v_header_list[$v_nb_extracted]);
4646
- }
4647
- else
4648
- {
4649
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 2, "File '".$v_header_list[$v_nb_extracted]['stored_filename']."', index '$i' will not be deleted");
4650
- $v_nb_extracted++;
4651
- }
4652
- }
4653
-
4654
- // ----- Look if something need to be deleted
4655
- if ($v_nb_extracted > 0) {
4656
-
4657
- // ----- Creates a temporay file
4658
- $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
4659
-
4660
- // ----- Creates a temporary zip archive
4661
- $v_temp_zip = new PclZip($v_zip_temp_name);
4662
-
4663
- // ----- Open the temporary zip file in write mode
4664
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary write mode");
4665
- if (($v_result = $v_temp_zip->privOpenFd('wb')) != 1) {
4666
- $this->privCloseFd();
4667
-
4668
- // ----- Return
4669
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4670
- return $v_result;
4671
- }
4672
-
4673
- // ----- Look which file need to be kept
4674
- for ($i=0; $i<sizeof($v_header_list); $i++) {
4675
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Keep entry index '$i' : '".$v_header_list[$i]['filename']."'");
4676
-
4677
- // ----- Calculate the position of the header
4678
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset='". $v_header_list[$i]['offset']."'");
4679
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position before rewind : ".ftell($this->zip_fd)."'");
4680
- @rewind($this->zip_fd);
4681
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after rewind : ".ftell($this->zip_fd)."'");
4682
- if (@fseek($this->zip_fd, $v_header_list[$i]['offset'])) {
4683
- // ----- Close the zip file
4684
- $this->privCloseFd();
4685
- $v_temp_zip->privCloseFd();
4686
- @unlink($v_zip_temp_name);
4687
-
4688
- // ----- Error log
4689
- PclZip::privErrorLog(PCLZIP_ERR_INVALID_ARCHIVE_ZIP, 'Invalid archive size');
4690
-
4691
- // ----- Return
4692
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
4693
- return PclZip::errorCode();
4694
- }
4695
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position after fseek : ".ftell($this->zip_fd)."'");
4696
-
4697
- // ----- Read the file header
4698
- $v_local_header = array();
4699
- if (($v_result = $this->privReadFileHeader($v_local_header)) != 1) {
4700
- // ----- Close the zip file
4701
- $this->privCloseFd();
4702
- $v_temp_zip->privCloseFd();
4703
- @unlink($v_zip_temp_name);
4704
-
4705
- // ----- Return
4706
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4707
- return $v_result;
4708
- }
4709
-
4710
- // ----- Check that local file header is same as central file header
4711
- if ($this->privCheckFileHeaders($v_local_header,
4712
- $v_header_list[$i]) != 1) {
4713
- // TBC
4714
- }
4715
- unset($v_local_header);
4716
-
4717
- // ----- Write the file header
4718
- if (($v_result = $v_temp_zip->privWriteFileHeader($v_header_list[$i])) != 1) {
4719
- // ----- Close the zip file
4720
- $this->privCloseFd();
4721
- $v_temp_zip->privCloseFd();
4722
- @unlink($v_zip_temp_name);
4723
-
4724
- // ----- Return
4725
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4726
- return $v_result;
4727
- }
4728
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset for this file is '".$v_header_list[$i]['offset']."'");
4729
-
4730
- // ----- Read/write the data block
4731
- if (($v_result = PclZipUtilCopyBlock($this->zip_fd, $v_temp_zip->zip_fd, $v_header_list[$i]['compressed_size'])) != 1) {
4732
- // ----- Close the zip file
4733
- $this->privCloseFd();
4734
- $v_temp_zip->privCloseFd();
4735
- @unlink($v_zip_temp_name);
4736
-
4737
- // ----- Return
4738
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4739
- return $v_result;
4740
- }
4741
- }
4742
-
4743
- // ----- Store the offset of the central dir
4744
- $v_offset = @ftell($v_temp_zip->zip_fd);
4745
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "New offset of central dir : $v_offset");
4746
-
4747
- // ----- Re-Create the Central Dir files header
4748
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the new central directory");
4749
- for ($i=0; $i<sizeof($v_header_list); $i++) {
4750
- // ----- Create the file header
4751
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Offset of file : ".$v_header_list[$i]['offset']);
4752
- if (($v_result = $v_temp_zip->privWriteCentralFileHeader($v_header_list[$i])) != 1) {
4753
- $v_temp_zip->privCloseFd();
4754
- $this->privCloseFd();
4755
- @unlink($v_zip_temp_name);
4756
-
4757
- // ----- Return
4758
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4759
- return $v_result;
4760
- }
4761
-
4762
- // ----- Transform the header to a 'usable' info
4763
- $v_temp_zip->privConvertHeader2FileInfo($v_header_list[$i], $p_result_list[$i]);
4764
- }
4765
-
4766
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Creates the central directory footer");
4767
-
4768
- // ----- Zip file comment
4769
- $v_comment = '';
4770
- if (isset($p_options[PCLZIP_OPT_COMMENT])) {
4771
- $v_comment = $p_options[PCLZIP_OPT_COMMENT];
4772
- }
4773
-
4774
- // ----- Calculate the size of the central header
4775
- $v_size = @ftell($v_temp_zip->zip_fd)-$v_offset;
4776
-
4777
- // ----- Create the central dir footer
4778
- if (($v_result = $v_temp_zip->privWriteCentralHeader(sizeof($v_header_list), $v_size, $v_offset, $v_comment)) != 1) {
4779
- // ----- Reset the file list
4780
- unset($v_header_list);
4781
- $v_temp_zip->privCloseFd();
4782
- $this->privCloseFd();
4783
- @unlink($v_zip_temp_name);
4784
-
4785
- // ----- Return
4786
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4787
- return $v_result;
4788
- }
4789
-
4790
- // ----- Close
4791
- $v_temp_zip->privCloseFd();
4792
- $this->privCloseFd();
4793
-
4794
- // ----- Delete the zip file
4795
- // TBC : I should test the result ...
4796
- @unlink($this->zipname);
4797
-
4798
- // ----- Rename the temporary file
4799
- // TBC : I should test the result ...
4800
- //@rename($v_zip_temp_name, $this->zipname);
4801
- PclZipUtilRename($v_zip_temp_name, $this->zipname);
4802
-
4803
- // ----- Destroy the temporary archive
4804
- unset($v_temp_zip);
4805
- }
4806
-
4807
- // ----- Remove every files : reset the file
4808
- else if ($v_central_dir['entries'] != 0) {
4809
- $this->privCloseFd();
4810
-
4811
- if (($v_result = $this->privOpenFd('wb')) != 1) {
4812
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4813
- return $v_result;
4814
- }
4815
-
4816
- if (($v_result = $this->privWriteCentralHeader(0, 0, 0, '')) != 1) {
4817
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4818
- return $v_result;
4819
- }
4820
-
4821
- $this->privCloseFd();
4822
- }
4823
-
4824
- // ----- Return
4825
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4826
- return $v_result;
4827
- }
4828
- // --------------------------------------------------------------------------------
4829
-
4830
- // --------------------------------------------------------------------------------
4831
- // Function : privDirCheck()
4832
- // Description :
4833
- // Check if a directory exists, if not it creates it and all the parents directory
4834
- // which may be useful.
4835
- // Parameters :
4836
- // $p_dir : Directory path to check.
4837
- // Return Values :
4838
- // 1 : OK
4839
- // -1 : Unable to create directory
4840
- // --------------------------------------------------------------------------------
4841
- function privDirCheck($p_dir, $p_is_dir=false)
4842
- {
4843
- $v_result = 1;
4844
-
4845
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDirCheck", "entry='$p_dir', is_dir='".($p_is_dir?"true":"false")."'");
4846
-
4847
- // ----- Remove the final '/'
4848
- if (($p_is_dir) && (substr($p_dir, -1)=='/'))
4849
- {
4850
- $p_dir = substr($p_dir, 0, strlen($p_dir)-1);
4851
- }
4852
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Looking for entry '$p_dir'");
4853
-
4854
- // ----- Check the directory availability
4855
- if ((is_dir($p_dir)) || ($p_dir == ""))
4856
- {
4857
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, "'$p_dir' is a directory");
4858
- return 1;
4859
- }
4860
-
4861
- // ----- Extract parent directory
4862
- $p_parent_dir = dirname($p_dir);
4863
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Parent directory is '$p_parent_dir'");
4864
-
4865
- // ----- Just a check
4866
- if ($p_parent_dir != $p_dir)
4867
- {
4868
- // ----- Look for parent directory
4869
- if ($p_parent_dir != "")
4870
- {
4871
- if (($v_result = $this->privDirCheck($p_parent_dir)) != 1)
4872
- {
4873
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4874
- return $v_result;
4875
- }
4876
- }
4877
- }
4878
-
4879
- // ----- Create the directory
4880
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Create directory '$p_dir'");
4881
- if (!@mkdir($p_dir, 0777))
4882
- {
4883
- // ----- Error log
4884
- PclZip::privErrorLog(PCLZIP_ERR_DIR_CREATE_FAIL, "Unable to create directory '$p_dir'");
4885
-
4886
- // ----- Return
4887
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
4888
- return PclZip::errorCode();
4889
- }
4890
-
4891
- // ----- Return
4892
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result, "Directory '$p_dir' created");
4893
- return $v_result;
4894
- }
4895
- // --------------------------------------------------------------------------------
4896
-
4897
- // --------------------------------------------------------------------------------
4898
- // Function : privMerge()
4899
- // Description :
4900
- // If $p_archive_to_add does not exist, the function exit with a success result.
4901
- // Parameters :
4902
- // Return Values :
4903
- // --------------------------------------------------------------------------------
4904
- function privMerge(&$p_archive_to_add)
4905
- {
4906
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privMerge", "archive='".$p_archive_to_add->zipname."'");
4907
- $v_result=1;
4908
-
4909
- // ----- Look if the archive_to_add exists
4910
- if (!is_file($p_archive_to_add->zipname))
4911
- {
4912
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to add does not exist. End of merge.");
4913
-
4914
- // ----- Nothing to merge, so merge is a success
4915
- $v_result = 1;
4916
-
4917
- // ----- Return
4918
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4919
- return $v_result;
4920
- }
4921
-
4922
- // ----- Look if the archive exists
4923
- if (!is_file($this->zipname))
4924
- {
4925
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive does not exist, duplicate the archive_to_add.");
4926
-
4927
- // ----- Do a duplicate
4928
- $v_result = $this->privDuplicate($p_archive_to_add->zipname);
4929
-
4930
- // ----- Return
4931
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4932
- return $v_result;
4933
- }
4934
-
4935
- // ----- Open the zip file
4936
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
4937
- if (($v_result=$this->privOpenFd('rb')) != 1)
4938
- {
4939
- // ----- Return
4940
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4941
- return $v_result;
4942
- }
4943
-
4944
- // ----- Read the central directory informations
4945
- $v_central_dir = array();
4946
- if (($v_result = $this->privReadEndCentralDir($v_central_dir)) != 1)
4947
- {
4948
- $this->privCloseFd();
4949
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4950
- return $v_result;
4951
- }
4952
-
4953
- // ----- Go to beginning of File
4954
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");
4955
- @rewind($this->zip_fd);
4956
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in zip : ".ftell($this->zip_fd)."'");
4957
-
4958
- // ----- Open the archive_to_add file
4959
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open archive_to_add in binary read mode");
4960
- if (($v_result=$p_archive_to_add->privOpenFd('rb')) != 1)
4961
- {
4962
- $this->privCloseFd();
4963
-
4964
- // ----- Return
4965
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4966
- return $v_result;
4967
- }
4968
-
4969
- // ----- Read the central directory informations
4970
- $v_central_dir_to_add = array();
4971
- if (($v_result = $p_archive_to_add->privReadEndCentralDir($v_central_dir_to_add)) != 1)
4972
- {
4973
- $this->privCloseFd();
4974
- $p_archive_to_add->privCloseFd();
4975
-
4976
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
4977
- return $v_result;
4978
- }
4979
-
4980
- // ----- Go to beginning of File
4981
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");
4982
- @rewind($p_archive_to_add->zip_fd);
4983
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Position in archive_to_add : ".ftell($p_archive_to_add->zip_fd)."'");
4984
-
4985
- // ----- Creates a temporay file
4986
- $v_zip_temp_name = PCLZIP_TEMPORARY_DIR.uniqid('pclzip-').'.tmp';
4987
-
4988
- // ----- Open the temporary file in write mode
4989
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
4990
- if (($v_zip_temp_fd = @fopen($v_zip_temp_name, 'wb')) == 0)
4991
- {
4992
- $this->privCloseFd();
4993
- $p_archive_to_add->privCloseFd();
4994
-
4995
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open temporary file \''.$v_zip_temp_name.'\' in binary write mode');
4996
-
4997
- // ----- Return
4998
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
4999
- return PclZip::errorCode();
5000
- }
5001
-
5002
- // ----- Copy the files from the archive to the temporary file
5003
- // TBC : Here I should better append the file and go back to erase the central dir
5004
- $v_size = $v_central_dir['offset'];
5005
- while ($v_size != 0)
5006
- {
5007
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5008
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
5009
- $v_buffer = fread($this->zip_fd, $v_read_size);
5010
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5011
- $v_size -= $v_read_size;
5012
- }
5013
-
5014
- // ----- Copy the files from the archive_to_add into the temporary file
5015
- $v_size = $v_central_dir_to_add['offset'];
5016
- while ($v_size != 0)
5017
- {
5018
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5019
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
5020
- $v_buffer = fread($p_archive_to_add->zip_fd, $v_read_size);
5021
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5022
- $v_size -= $v_read_size;
5023
- }
5024
-
5025
- // ----- Store the offset of the central dir
5026
- $v_offset = @ftell($v_zip_temp_fd);
5027
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "New offset of central dir : $v_offset");
5028
-
5029
- // ----- Copy the block of file headers from the old archive
5030
- $v_size = $v_central_dir['size'];
5031
- while ($v_size != 0)
5032
- {
5033
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5034
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
5035
- $v_buffer = @fread($this->zip_fd, $v_read_size);
5036
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5037
- $v_size -= $v_read_size;
5038
- }
5039
-
5040
- // ----- Copy the block of file headers from the archive_to_add
5041
- $v_size = $v_central_dir_to_add['size'];
5042
- while ($v_size != 0)
5043
- {
5044
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5045
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
5046
- $v_buffer = @fread($p_archive_to_add->zip_fd, $v_read_size);
5047
- @fwrite($v_zip_temp_fd, $v_buffer, $v_read_size);
5048
- $v_size -= $v_read_size;
5049
- }
5050
-
5051
- // ----- Merge the file comments
5052
- $v_comment = $v_central_dir['comment'].' '.$v_central_dir_to_add['comment'];
5053
-
5054
- // ----- Calculate the size of the (new) central header
5055
- $v_size = @ftell($v_zip_temp_fd)-$v_offset;
5056
-
5057
- // ----- Swap the file descriptor
5058
- // Here is a trick : I swap the temporary fd with the zip fd, in order to use
5059
- // the following methods on the temporary fil and not the real archive fd
5060
- $v_swap = $this->zip_fd;
5061
- $this->zip_fd = $v_zip_temp_fd;
5062
- $v_zip_temp_fd = $v_swap;
5063
-
5064
- // ----- Create the central dir footer
5065
- if (($v_result = $this->privWriteCentralHeader($v_central_dir['entries']+$v_central_dir_to_add['entries'], $v_size, $v_offset, $v_comment)) != 1)
5066
- {
5067
- $this->privCloseFd();
5068
- $p_archive_to_add->privCloseFd();
5069
- @fclose($v_zip_temp_fd);
5070
- $this->zip_fd = null;
5071
-
5072
- // ----- Reset the file list
5073
- unset($v_header_list);
5074
-
5075
- // ----- Return
5076
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
5077
- return $v_result;
5078
- }
5079
-
5080
- // ----- Swap back the file descriptor
5081
- $v_swap = $this->zip_fd;
5082
- $this->zip_fd = $v_zip_temp_fd;
5083
- $v_zip_temp_fd = $v_swap;
5084
-
5085
- // ----- Close
5086
- $this->privCloseFd();
5087
- $p_archive_to_add->privCloseFd();
5088
-
5089
- // ----- Close the temporary file
5090
- @fclose($v_zip_temp_fd);
5091
-
5092
- // ----- Delete the zip file
5093
- // TBC : I should test the result ...
5094
- @unlink($this->zipname);
5095
-
5096
- // ----- Rename the temporary file
5097
- // TBC : I should test the result ...
5098
- //@rename($v_zip_temp_name, $this->zipname);
5099
- PclZipUtilRename($v_zip_temp_name, $this->zipname);
5100
-
5101
- // ----- Return
5102
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
5103
- return $v_result;
5104
- }
5105
- // --------------------------------------------------------------------------------
5106
-
5107
- // --------------------------------------------------------------------------------
5108
- // Function : privDuplicate()
5109
- // Description :
5110
- // Parameters :
5111
- // Return Values :
5112
- // --------------------------------------------------------------------------------
5113
- function privDuplicate($p_archive_filename)
5114
- {
5115
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZip::privDuplicate", "archive_filename='$p_archive_filename'");
5116
- $v_result=1;
5117
-
5118
- // ----- Look if the $p_archive_filename exists
5119
- if (!is_file($p_archive_filename))
5120
- {
5121
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Archive to duplicate does not exist. End of duplicate.");
5122
-
5123
- // ----- Nothing to duplicate, so duplicate is a success.
5124
- $v_result = 1;
5125
-
5126
- // ----- Return
5127
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
5128
- return $v_result;
5129
- }
5130
-
5131
- // ----- Open the zip file
5132
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
5133
- if (($v_result=$this->privOpenFd('wb')) != 1)
5134
- {
5135
- // ----- Return
5136
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
5137
- return $v_result;
5138
- }
5139
-
5140
- // ----- Open the temporary file in write mode
5141
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Open file in binary read mode");
5142
- if (($v_zip_temp_fd = @fopen($p_archive_filename, 'rb')) == 0)
5143
- {
5144
- $this->privCloseFd();
5145
-
5146
- PclZip::privErrorLog(PCLZIP_ERR_READ_OPEN_FAIL, 'Unable to open archive file \''.$p_archive_filename.'\' in binary write mode');
5147
-
5148
- // ----- Return
5149
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, PclZip::errorCode(), PclZip::errorInfo());
5150
- return PclZip::errorCode();
5151
- }
5152
-
5153
- // ----- Copy the files from the archive to the temporary file
5154
- // TBC : Here I should better append the file and go back to erase the central dir
5155
- $v_size = filesize($p_archive_filename);
5156
- while ($v_size != 0)
5157
- {
5158
- $v_read_size = ($v_size < PCLZIP_READ_BLOCK_SIZE ? $v_size : PCLZIP_READ_BLOCK_SIZE);
5159
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Read $v_read_size bytes");
5160
- $v_buffer = fread($v_zip_temp_fd, $v_read_size);
5161
- @fwrite($this->zip_fd, $v_buffer, $v_read_size);
5162
- $v_size -= $v_read_size;
5163
- }
5164
-
5165
- // ----- Close
5166
- $this->privCloseFd();
5167
-
5168
- // ----- Close the temporary file
5169
- @fclose($v_zip_temp_fd);
5170
-
5171
- // ----- Return
5172
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
5173
- return $v_result;
5174
- }
5175
- // --------------------------------------------------------------------------------
5176
-
5177
- // --------------------------------------------------------------------------------
5178
- // Function : privErrorLog()
5179
- // Description :
5180
- // Parameters :
5181
- // --------------------------------------------------------------------------------
5182
- function privErrorLog($p_error_code=0, $p_error_string='')
5183
- {
5184
- if (PCLZIP_ERROR_EXTERNAL == 1) {
5185
- PclError($p_error_code, $p_error_string);
5186
- }
5187
- else {
5188
- $this->error_code = $p_error_code;
5189
- $this->error_string = $p_error_string;
5190
- }
5191
- }
5192
- // --------------------------------------------------------------------------------
5193
-
5194
- // --------------------------------------------------------------------------------
5195
- // Function : privErrorReset()
5196
- // Description :
5197
- // Parameters :
5198
- // --------------------------------------------------------------------------------
5199
- function privErrorReset()
5200
- {
5201
- if (PCLZIP_ERROR_EXTERNAL == 1) {
5202
- PclErrorReset();
5203
- }
5204
- else {
5205
- $this->error_code = 0;
5206
- $this->error_string = '';
5207
- }
5208
- }
5209
- // --------------------------------------------------------------------------------
5210
-
5211
- // --------------------------------------------------------------------------------
5212
- // Function : privDecrypt()
5213
- // Description :
5214
- // Parameters :
5215
- // Return Values :
5216
- // --------------------------------------------------------------------------------
5217
- function privDecrypt($p_encryption_header, &$p_buffer, $p_size, $p_crc)
5218
- {
5219
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDecrypt', "size=".$p_size."");
5220
- $v_result=1;
5221
-
5222
- // ----- To Be Modified ;-)
5223
- $v_pwd = "test";
5224
-
5225
- $p_buffer = PclZipUtilZipDecrypt($p_buffer, $p_size, $p_encryption_header,
5226
- $p_crc, $v_pwd);
5227
-
5228
- // ----- Return
5229
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
5230
- return $v_result;
5231
- }
5232
- // --------------------------------------------------------------------------------
5233
-
5234
- // --------------------------------------------------------------------------------
5235
- // Function : privDisableMagicQuotes()
5236
- // Description :
5237
- // Parameters :
5238
- // Return Values :
5239
- // --------------------------------------------------------------------------------
5240
- function privDisableMagicQuotes()
5241
- {
5242
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privDisableMagicQuotes', "");
5243
- $v_result=1;
5244
-
5245
- // ----- Look if function exists
5246
- if ( (!function_exists("get_magic_quotes_runtime"))
5247
- || (!function_exists("set_magic_quotes_runtime"))) {
5248
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported");
5249
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
5250
- return $v_result;
5251
- }
5252
-
5253
- // ----- Look if already done
5254
- if ($this->magic_quotes_status != -1) {
5255
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote already disabled");
5256
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
5257
- return $v_result;
5258
- }
5259
-
5260
- // ----- Get and memorize the magic_quote value
5261
- $this->magic_quotes_status = @get_magic_quotes_runtime();
5262
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Current magic_quotes_runtime status is '".($this->magic_quotes_status==0?'disable':'enable')."'");
5263
-
5264
- // ----- Disable magic_quotes
5265
- if ($this->magic_quotes_status == 1) {
5266
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Disable magic_quotes");
5267
- @set_magic_quotes_runtime(0);
5268
- }
5269
-
5270
- // ----- Return
5271
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
5272
- return $v_result;
5273
- }
5274
- // --------------------------------------------------------------------------------
5275
-
5276
- // --------------------------------------------------------------------------------
5277
- // Function : privSwapBackMagicQuotes()
5278
- // Description :
5279
- // Parameters :
5280
- // Return Values :
5281
- // --------------------------------------------------------------------------------
5282
- function privSwapBackMagicQuotes()
5283
- {
5284
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, 'PclZip::privSwapBackMagicQuotes', "");
5285
- $v_result=1;
5286
-
5287
- // ----- Look if function exists
5288
- if ( (!function_exists("get_magic_quotes_runtime"))
5289
- || (!function_exists("set_magic_quotes_runtime"))) {
5290
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Functions *et_magic_quotes_runtime are not supported");
5291
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
5292
- return $v_result;
5293
- }
5294
-
5295
- // ----- Look if something to do
5296
- if ($this->magic_quotes_status != -1) {
5297
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "magic_quote not modified");
5298
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
5299
- return $v_result;
5300
- }
5301
-
5302
- // ----- Swap back magic_quotes
5303
- if ($this->magic_quotes_status == 1) {
5304
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Enable back magic_quotes");
5305
- @set_magic_quotes_runtime($this->magic_quotes_status);
5306
- }
5307
-
5308
- // ----- Return
5309
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
5310
- return $v_result;
5311
- }
5312
- // --------------------------------------------------------------------------------
5313
-
5314
- }
5315
- // End of class
5316
- // --------------------------------------------------------------------------------
5317
-
5318
- // --------------------------------------------------------------------------------
5319
- // Function : PclZipUtilPathReduction()
5320
- // Description :
5321
- // Parameters :
5322
- // Return Values :
5323
- // --------------------------------------------------------------------------------
5324
- function PclZipUtilPathReduction($p_dir)
5325
- {
5326
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathReduction", "dir='$p_dir'");
5327
- $v_result = "";
5328
-
5329
- // ----- Look for not empty path
5330
- if ($p_dir != "") {
5331
- // ----- Explode path by directory names
5332
- $v_list = explode("/", $p_dir);
5333
-
5334
- // ----- Study directories from last to first
5335
- $v_skip = 0;
5336
- for ($i=sizeof($v_list)-1; $i>=0; $i--) {
5337
- // ----- Look for current path
5338
- if ($v_list[$i] == ".") {
5339
- // ----- Ignore this directory
5340
- // Should be the first $i=0, but no check is done
5341
- }
5342
- else if ($v_list[$i] == "..") {
5343
- $v_skip++;
5344
- }
5345
- else if ($v_list[$i] == "") {
5346
- // ----- First '/' i.e. root slash
5347
- if ($i == 0) {
5348
- $v_result = "/".$v_result;
5349
- if ($v_skip > 0) {
5350
- // ----- It is an invalid path, so the path is not modified
5351
- // TBC
5352
- $v_result = $p_dir;
5353
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 3, "Invalid path is unchanged");
5354
- $v_skip = 0;
5355
- }
5356
- }
5357
- // ----- Last '/' i.e. indicates a directory
5358
- else if ($i == (sizeof($v_list)-1)) {
5359
- $v_result = $v_list[$i];
5360
- }
5361
- // ----- Double '/' inside the path
5362
- else {
5363
- // ----- Ignore only the double '//' in path,
5364
- // but not the first and last '/'
5365
- }
5366
- }
5367
- else {
5368
- // ----- Look for item to skip
5369
- if ($v_skip > 0) {
5370
- $v_skip--;
5371
- }
5372
- else {
5373
- $v_result = $v_list[$i].($i!=(sizeof($v_list)-1)?"/".$v_result:"");
5374
- }
5375
- }
5376
- }
5377
-
5378
- // ----- Look for skip
5379
- if ($v_skip > 0) {
5380
- while ($v_skip > 0) {
5381
- $v_result = '../'.$v_result;
5382
- $v_skip--;
5383
- }
5384
- }
5385
- }
5386
-
5387
- // ----- Return
5388
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
5389
- return $v_result;
5390
- }
5391
- // --------------------------------------------------------------------------------
5392
-
5393
- // --------------------------------------------------------------------------------
5394
- // Function : PclZipUtilPathInclusion()
5395
- // Description :
5396
- // This function indicates if the path $p_path is under the $p_dir tree. Or,
5397
- // said in an other way, if the file or sub-dir $p_path is inside the dir
5398
- // $p_dir.
5399
- // The function indicates also if the path is exactly the same as the dir.
5400
- // This function supports path with duplicated '/' like '//', but does not
5401
- // support '.' or '..' statements.
5402
- // Parameters :
5403
- // Return Values :
5404
- // 0 if $p_path is not inside directory $p_dir
5405
- // 1 if $p_path is inside directory $p_dir
5406
- // 2 if $p_path is exactly the same as $p_dir
5407
- // --------------------------------------------------------------------------------
5408
- function PclZipUtilPathInclusion($p_dir, $p_path)
5409
- {
5410
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilPathInclusion", "dir='$p_dir', path='$p_path'");
5411
- $v_result = 1;
5412
-
5413
- // ----- Look for path beginning by ./
5414
- if ( ($p_dir == '.')
5415
- || ((strlen($p_dir) >=2) && (substr($p_dir, 0, 2) == './'))) {
5416
- $p_dir = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_dir, 1);
5417
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_dir '".$p_dir."'");
5418
- }
5419
- if ( ($p_path == '.')
5420
- || ((strlen($p_path) >=2) && (substr($p_path, 0, 2) == './'))) {
5421
- $p_path = PclZipUtilTranslateWinPath(getcwd(), FALSE).'/'.substr($p_path, 1);
5422
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Replacing ./ by full path in p_path '".$p_path."'");
5423
- }
5424
-
5425
- // ----- Explode dir and path by directory separator
5426
- $v_list_dir = explode("/", $p_dir);
5427
- $v_list_dir_size = sizeof($v_list_dir);
5428
- $v_list_path = explode("/", $p_path);
5429
- $v_list_path_size = sizeof($v_list_path);
5430
-
5431
- // ----- Study directories paths
5432
- $i = 0;
5433
- $j = 0;
5434
- while (($i < $v_list_dir_size) && ($j < $v_list_path_size) && ($v_result)) {
5435
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Working on dir($i)='".$v_list_dir[$i]."' and path($j)='".$v_list_path[$j]."'");
5436
-
5437
- // ----- Look for empty dir (path reduction)
5438
- if ($v_list_dir[$i] == '') {
5439
- $i++;
5440
- continue;
5441
- }
5442
- if ($v_list_path[$j] == '') {
5443
- $j++;
5444
- continue;
5445
- }
5446
-
5447
- // ----- Compare the items
5448
- if (($v_list_dir[$i] != $v_list_path[$j]) && ($v_list_dir[$i] != '') && ( $v_list_path[$j] != '')) {
5449
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Items ($i,$j) are different");
5450
- $v_result = 0;
5451
- }
5452
-
5453
- // ----- Next items
5454
- $i++;
5455
- $j++;
5456
- }
5457
-
5458
- // ----- Look if everything seems to be the same
5459
- if ($v_result) {
5460
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Look for tie break");
5461
- // ----- Skip all the empty items
5462
- while (($j < $v_list_path_size) && ($v_list_path[$j] == '')) $j++;
5463
- while (($i < $v_list_dir_size) && ($v_list_dir[$i] == '')) $i++;
5464
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Looking on dir($i)='".($i < $v_list_dir_size?$v_list_dir[$i]:'')."' and path($j)='".($j < $v_list_path_size?$v_list_path[$j]:'')."'");
5465
-
5466
- if (($i >= $v_list_dir_size) && ($j >= $v_list_path_size)) {
5467
- // ----- There are exactly the same
5468
- $v_result = 2;
5469
- }
5470
- else if ($i < $v_list_dir_size) {
5471
- // ----- The path is shorter than the dir
5472
- $v_result = 0;
5473
- }
5474
- }
5475
-
5476
- // ----- Return
5477
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
5478
- return $v_result;
5479
- }
5480
- // --------------------------------------------------------------------------------
5481
-
5482
- // --------------------------------------------------------------------------------
5483
- // Function : PclZipUtilCopyBlock()
5484
- // Description :
5485
- // Parameters :
5486
- // $p_mode : read/write compression mode
5487
- // 0 : src & dest normal
5488
- // 1 : src gzip, dest normal
5489
- // 2 : src normal, dest gzip
5490
- // 3 : src & dest gzip
5491
- // Return Values :
5492
- // --------------------------------------------------------------------------------
5493
- function PclZipUtilCopyBlock($p_src, $p_dest, $p_size, $p_mode=0)
5494
- {
5495
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilCopyBlock", "size=$p_size, mode=$p_mode");
5496
- $v_result = 1;
5497
-
5498
- if ($p_mode==0)
5499
- {
5500
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset before read :".(@ftell($p_src)));
5501
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset before write :".(@ftell($p_dest)));
5502
- while ($p_size != 0)
5503
- {
5504
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5505
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
5506
- $v_buffer = @fread($p_src, $v_read_size);
5507
- @fwrite($p_dest, $v_buffer, $v_read_size);
5508
- $p_size -= $v_read_size;
5509
- }
5510
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Src offset after read :".(@ftell($p_src)));
5511
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Dest offset after write :".(@ftell($p_dest)));
5512
- }
5513
- else if ($p_mode==1)
5514
- {
5515
- while ($p_size != 0)
5516
- {
5517
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5518
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
5519
- $v_buffer = @gzread($p_src, $v_read_size);
5520
- @fwrite($p_dest, $v_buffer, $v_read_size);
5521
- $p_size -= $v_read_size;
5522
- }
5523
- }
5524
- else if ($p_mode==2)
5525
- {
5526
- while ($p_size != 0)
5527
- {
5528
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5529
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
5530
- $v_buffer = @fread($p_src, $v_read_size);
5531
- @gzwrite($p_dest, $v_buffer, $v_read_size);
5532
- $p_size -= $v_read_size;
5533
- }
5534
- }
5535
- else if ($p_mode==3)
5536
- {
5537
- while ($p_size != 0)
5538
- {
5539
- $v_read_size = ($p_size < PCLZIP_READ_BLOCK_SIZE ? $p_size : PCLZIP_READ_BLOCK_SIZE);
5540
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 4, "Read $v_read_size bytes");
5541
- $v_buffer = @gzread($p_src, $v_read_size);
5542
- @gzwrite($p_dest, $v_buffer, $v_read_size);
5543
- $p_size -= $v_read_size;
5544
- }
5545
- }
5546
-
5547
- // ----- Return
5548
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
5549
- return $v_result;
5550
- }
5551
- // --------------------------------------------------------------------------------
5552
-
5553
- // --------------------------------------------------------------------------------
5554
- // Function : PclZipUtilRename()
5555
- // Description :
5556
- // This function tries to do a simple rename() function. If it fails, it
5557
- // tries to copy the $p_src file in a new $p_dest file and then unlink the
5558
- // first one.
5559
- // Parameters :
5560
- // $p_src : Old filename
5561
- // $p_dest : New filename
5562
- // Return Values :
5563
- // 1 on success, 0 on failure.
5564
- // --------------------------------------------------------------------------------
5565
- function PclZipUtilRename($p_src, $p_dest)
5566
- {
5567
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilRename", "source=$p_src, destination=$p_dest");
5568
- $v_result = 1;
5569
-
5570
- // ----- Try to rename the files
5571
- if (!@rename($p_src, $p_dest)) {
5572
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to rename file, try copy+unlink");
5573
-
5574
- // ----- Try to copy & unlink the src
5575
- if (!@copy($p_src, $p_dest)) {
5576
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to copy file");
5577
- $v_result = 0;
5578
- }
5579
- else if (!@unlink($p_src)) {
5580
- //--(MAGIC-PclTrace)--//PclTraceFctMessage(__FILE__, __LINE__, 5, "Fail to unlink old filename");
5581
- $v_result = 0;
5582
- }
5583
- }
5584
-
5585
- // ----- Return
5586
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
5587
- return $v_result;
5588
- }
5589
- // --------------------------------------------------------------------------------
5590
-
5591
- // --------------------------------------------------------------------------------
5592
- // Function : PclZipUtilOptionText()
5593
- // Description :
5594
- // Translate option value in text. Mainly for debug purpose.
5595
- // Parameters :
5596
- // $p_option : the option value.
5597
- // Return Values :
5598
- // The option text value.
5599
- // --------------------------------------------------------------------------------
5600
- function PclZipUtilOptionText($p_option)
5601
- {
5602
- //--(MAGIC-PclTrace)--//PclTraceFctStart(__FILE__, __LINE__, "PclZipUtilOptionText", "option='".$p_option."'");
5603
-
5604
- $v_list = get_defined_constants();
5605
- for (reset($v_list); $v_key = key($v_list); next($v_list)) {
5606
- $v_prefix = substr($v_key, 0, 10);
5607
- if (( ($v_prefix == 'PCLZIP_OPT')
5608
- || ($v_prefix == 'PCLZIP_CB_')
5609
- || ($v_prefix == 'PCLZIP_ATT'))
5610
- && ($v_list[$v_key] == $p_option)) {
5611
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_key);
5612
- return $v_key;
5613
- }
5614
- }
5615
-
5616
- $v_result = 'Unknown';
5617
-
5618
- //--(MAGIC-PclTrace)--//PclTraceFctEnd(__FILE__, __LINE__, $v_result);
5619
- return $v_result;
5620
- }
5621
- // --------------------------------------------------------------------------------
5622
-
5623
- // --------------------------------------------------------------------------------
5624
- // Function : PclZipUtilTranslateWinPath()
5625
- // Description :
5626
- // Translate windows path by replacing '\' by '/' and optionally removing
5627
- // drive letter.
5628
- // Parameters :
5629
- // $p_path : path to translate.
5630
- // $p_remove_disk_letter : true | false
5631
- // Return Values :
5632
- // The path translated.
5633
- // --------------------------------------------------------------------------------
5634
- function PclZipUtilTranslateWinPath($p_path, $p_remove_disk_letter=true)
5635
- {
5636
- if (stristr(php_uname(), 'windows')) {
5637
- // ----- Look for potential disk letter
5638
- if (($p_remove_disk_letter) && (($v_position = strpos($p_path, ':')) != false)) {
5639
- $p_path = substr($p_path, $v_position+1);
5640
- }
5641
- // ----- Change potential windows directory separator
5642
- if ((strpos($p_path, '\\') > 0) || (substr($p_path, 0,1) == '\\')) {
5643
- $p_path = strtr($p_path, '\\', '/');
5644
- }
5645
- }
5646
- return $p_path;
5647
- }
5648
- // --------------------------------------------------------------------------------
5649
-
5650
-
5651
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/readme.txt DELETED
@@ -1,70 +0,0 @@
1
- === All in One SEO Pack ===
2
- Contributors: hallsofmontezuma
3
- Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=mrtorbert%40gmail%2ecom&item_name=All%20In%20One%20SEO%20Pack&item_number=Support%20Open%20Source&no_shipping=0&no_note=1&tax=0&currency_code=USD&lc=US&bn=PP%2dDonationsBF&charset=UTF%2d8
4
- Tags: post,google,seo,meta,meta keywords,meta description,title,posts,plugin, search engine optimization
5
- Requires at least: 1.5
6
- Tested up to: 2.8.4
7
- Stable tag: trunk
8
-
9
- Automatically optimizes your Wordpress blog for Search Engines (Search Engine Optimization).
10
-
11
- == Description ==
12
-
13
- **Optimizes** your Wordpress blog for Search Engines (**Search Engine Optimization**).
14
-
15
- **[Download now!](http://downloads.wordpress.org/plugin/all-in-one-seo-pack.zip)**
16
-
17
- **If upgrading, please back up your database first!**
18
-
19
- [Support](http://semperfiwebdesign.com/forum/) |
20
- [Change Log](http://semperfiwebdesign.com/documentation/all-in-one-seo-pack/all-in-one-seo-pack-release-history/) |
21
- [FAQ](http://semperfiwebdesign.com/documentation/all-in-one-seo-pack/all-in-one-seo-faq/)|
22
- [Translations](http://semperfiwebdesign.com/documentation/all-in-one-seo-pack/translations-for-all-in-one-seo-pack/)
23
-
24
- Some features:
25
-
26
- * Canonical URLs
27
- * Fine tune Page Navigational Links
28
- * Built-in API so other plugins/themes can access and extend functionality
29
- * Provides SEO Integration for WP e-Commerce sites
30
- * Nonce Security
31
- * Support for CMS-style WordPress installations
32
- * Automatically optimizes your **titles** for search engines
33
- * Generates **META tags automatically**
34
- * Avoids the typical duplicate content found on Wordpress blogs
35
- * For beginners, you don't even have to look at the options, it works out-of-the-box. Just install.
36
- * For advanced users, you can fine-tune everything
37
- * You can override any title and set any META description and any META keywords you want.
38
- * Backward-Compatibility with many other plugins, like Auto Meta, Ultimate Tag Warrior and others.
39
-
40
- Be sure to check out:
41
- [WP Security Scan](http://wordpress.org/extend/plugins/wp-security-scan/)
42
- and
43
- [SMS Text Message](http://wordpress.org/extend/plugins/sms-text-message/)
44
-
45
- Follow me on Twitter to keep up with the latest updates [Michael
46
- Torbert](http://twitter.com/michaeltorbert/)
47
-
48
- == Installation ==
49
-
50
- You can use the built in installer and upgrader, or you can install the plugin
51
- manually.
52
-
53
- 1. You can either use the automatic plugin installer or your FTP program to upload it to your wp-content/plugins directory
54
- the top-level folder. Don't just upload all the php files and put them in `/wp-content/plugins/`.
55
- 1. Activate the plugin through the 'Plugins' menu in WordPress
56
- 1. Visit your SEO options (*Options - All in One SEO*) for Wordpress 2.3.x, (*Settings - All in One SEO*) for Wordpress 2.5.x-2.8.x
57
- 1. Configure any options as desired, and then enable the plugin
58
- 1. That's it!
59
-
60
- If you have to upgrade manually simply repeat the installation steps and re-enable the plugin.
61
-
62
- **If upgrading, please back up your database first!**
63
-
64
- [Upgrade guide for upgrading from 1.5.x and below to
65
- 1.6.x](http://onefinejay.com/2009/07/11/a-guide-to-upgrading-to-aioseop-v1-6-1)
66
-
67
- == Frequently Asked Questions ==
68
-
69
- Please read these **[FAQs](http://semperfiwebdesign.com/documentation/all-in-one-seo-pack/all-in-one-seo-faq/)** before requesting
70
- **[My Plugin Support Forum](http://semperfiwebdesign.com/forum/)**