source: trunk/admin/site_update.php @ 13018

Last change on this file since 13018 was 12922, checked in by mistic100, 12 years ago

update Piwigo headers to 2012, last change before the expected (or not) apocalypse

  • Property svn:eol-style set to LF
File size: 24.1 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | Piwigo - a PHP based photo gallery                                    |
4// +-----------------------------------------------------------------------+
5// | Copyright(C) 2008-2012 Piwigo Team                  http://piwigo.org |
6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
23
24if (!defined('PHPWG_ROOT_PATH'))
25{
26  die('Hacking attempt!');
27}
28
29include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
30
31// +-----------------------------------------------------------------------+
32// | Check Access and exit when user status is not ok                      |
33// +-----------------------------------------------------------------------+
34check_status(ACCESS_ADMINISTRATOR);
35
36if (!is_numeric($_GET['site']))
37{
38  die ('site param missing or invalid');
39}
40$site_id = $_GET['site'];
41
42$query='
43SELECT galleries_url
44  FROM '.SITES_TABLE.'
45  WHERE id = '.$site_id;
46list($site_url) = pwg_db_fetch_row(pwg_query($query));
47if (!isset($site_url))
48{
49  die('site '.$site_id.' does not exist');
50}
51$site_is_remote = url_is_remote($site_url);
52
53list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
54define('CURRENT_DATE', $dbnow);
55
56$error_labels = array(
57  'PWG-UPDATE-1' => array(
58    l10n('wrong filename'),
59    l10n('The name of directories and files must be composed of letters, numbers, "-", "_" or "."')
60    ),
61  'PWG-UPDATE-2' => array(
62    l10n('missing thumbnail'),
63    l10n('a picture filetype requires a thumbnail. The thumbnail must be present in the sub-directory "thumbnail" of the album directory. The thumbnail filename must start with the configured thumbnail prefix and the extension must be among the following list :').implode(',', $conf['picture_ext'])
64    ),
65  'PWG-ERROR-NO-FS' => array(
66    l10n('File/directory read error'),
67    l10n('The file or directory cannot be accessed (either it does not exist or the access is denied)')
68    ),
69  'PWG-ERROR-VERSION' => array(
70    l10n('Piwigo version differs on the remote site'),
71    l10n('Version of create_listing_file.php on the remote site and Piwigo must be the same')
72    ),
73  'PWG-ERROR-NOLISTING' => array(
74    l10n('listing.xml file was not found'),
75    l10n('listing.xml file was not found on the remote site. This file is generated by choosing the "generate listing" command in the Site manager')
76    )
77  );
78$errors = array();
79$infos = array();
80
81if ($site_is_remote)
82{
83  fatal_error('remote sites not supported');
84  include_once(PHPWG_ROOT_PATH.'admin/site_reader_remote.php');
85  $local_listing = null;
86  if ( isset($_GET['local_listing'])
87      and $_GET['local_listing'] )
88  {
89    $local_listing = PHPWG_ROOT_PATH.'listing.xml';
90  }
91  $site_reader = new RemoteSiteReader($site_url, $local_listing);
92}
93else
94{
95  include_once( PHPWG_ROOT_PATH.'admin/site_reader_local.php');
96  $site_reader = new LocalSiteReader($site_url);
97}
98
99$general_failure = true;
100if (isset($_POST['submit']))
101{
102  if ($site_reader->open())
103  {
104    $general_failure = false;
105  }
106
107  // shall we simulate only
108  if (isset($_POST['simulate']) and $_POST['simulate'] == 1)
109  {
110    $simulate = true;
111  }
112  else
113  {
114    $simulate = false;
115  }
116}
117
118// +-----------------------------------------------------------------------+
119// |                      directories / categories                         |
120// +-----------------------------------------------------------------------+
121if (isset($_POST['submit'])
122    and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files'))
123{
124  $counts['new_categories'] = 0;
125  $counts['del_categories'] = 0;
126  $counts['del_elements'] = 0;
127  $counts['new_elements'] = 0;
128  $counts['upd_elements'] = 0;
129}
130
131
132if (isset($_POST['submit'])
133    and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files')
134    and !$general_failure)
135{
136  $start = get_moment();
137  // which categories to update ?
138  $query = '
139SELECT id, uppercats, global_rank, status, visible
140  FROM '.CATEGORIES_TABLE.'
141  WHERE dir IS NOT NULL
142    AND site_id = '.$site_id;
143  if (isset($_POST['cat']) and is_numeric($_POST['cat']))
144  {
145    if (isset($_POST['subcats-included']) and $_POST['subcats-included'] == 1)
146    {
147      $query.= '
148    AND uppercats '.DB_REGEX_OPERATOR.' \'(^|,)'.$_POST['cat'].'(,|$)\'
149';
150    }
151    else
152    {
153      $query.= '
154    AND id = '.$_POST['cat'].'
155';
156    }
157  }
158  $db_categories = hash_from_query($query, 'id');
159
160  // get categort full directories in an array for comparison with file
161  // system directory tree
162  $db_fulldirs = get_fulldirs(array_keys($db_categories));
163
164  // what is the base directory to search file system sub-directories ?
165  if (isset($_POST['cat']) and is_numeric($_POST['cat']))
166  {
167    $basedir = $db_fulldirs[$_POST['cat']];
168  }
169  else
170  {
171    $basedir = preg_replace('#/*$#', '', $site_url);
172  }
173
174  // we need to have fulldirs as keys to make efficient comparison
175  $db_fulldirs = array_flip($db_fulldirs);
176
177  // finding next rank for each id_uppercat. By default, each category id
178  // has 1 for next rank on its sub-categories to create
179  $next_rank['NULL'] = 1;
180
181  $query = '
182SELECT id
183  FROM '.CATEGORIES_TABLE;
184  $result = pwg_query($query);
185  while ($row = pwg_db_fetch_assoc($result))
186  {
187    $next_rank[$row['id']] = 1;
188  }
189
190  // let's see if some categories already have some sub-categories...
191  $query = '
192SELECT id_uppercat, MAX(rank)+1 AS next_rank
193  FROM '.CATEGORIES_TABLE.'
194  GROUP BY id_uppercat';
195  $result = pwg_query($query);
196  while ($row = pwg_db_fetch_assoc($result))
197  {
198    // for the id_uppercat NULL, we write 'NULL' and not the empty string
199    if (!isset($row['id_uppercat']) or $row['id_uppercat'] == '')
200    {
201      $row['id_uppercat'] = 'NULL';
202    }
203    $next_rank[$row['id_uppercat']] = $row['next_rank'];
204  }
205
206  // next category id available
207  $next_id = pwg_db_nextval('id', CATEGORIES_TABLE);
208
209  // retrieve sub-directories fulldirs from the site reader
210  $fs_fulldirs = $site_reader->get_full_directories($basedir);
211
212  // get_full_directories doesn't include the base directory, so if it's a
213  // category directory, we need to include it in our array
214  if (isset($_POST['cat']))
215  {
216    array_push($fs_fulldirs, $basedir);
217  }
218  // If $_POST['subcats-included'] != 1 ("Search in sub-albums" is unchecked)
219  // $db_fulldirs doesn't include any subdirectories and $fs_fulldirs does
220  // So $fs_fulldirs will be limited to the selected basedir
221  // (if that one is in $fs_fulldirs)
222  if (!isset($_POST['subcats-included']) or $_POST['subcats-included'] != 1)
223  {
224    $fs_fulldirs = array_intersect($fs_fulldirs, array_keys($db_fulldirs));
225  }
226  $inserts = array();
227  // new categories are the directories not present yet in the database
228  foreach (array_diff($fs_fulldirs, array_keys($db_fulldirs)) as $fulldir)
229  {
230    $dir = basename($fulldir);
231    if (preg_match('/^[a-zA-Z0-9-_.]+$/', $dir))
232    {
233      $insert = array(
234        'id'          => $next_id++,
235        'dir'         => $dir,
236        'name'        => str_replace('_', ' ', $dir),
237        'site_id'     => $site_id,
238        'commentable' =>
239          boolean_to_string($conf['newcat_default_commentable']),
240        'status'      => $conf['newcat_default_status'],
241        'visible'     => boolean_to_string($conf['newcat_default_visible']),
242        );
243
244      if (isset($db_fulldirs[dirname($fulldir)]))
245      {
246        $parent = $db_fulldirs[dirname($fulldir)];
247
248        $insert['id_uppercat'] = $parent;
249        $insert['uppercats'] =
250          $db_categories[$parent]['uppercats'].','.$insert['id'];
251        $insert['rank'] = $next_rank[$parent]++;
252        $insert['global_rank'] =
253          $db_categories[$parent]['global_rank'].'.'.$insert['rank'];
254        if ('private' == $db_categories[$parent]['status'])
255        {
256          $insert['status'] = 'private';
257        }
258        if ('false' == $db_categories[$parent]['visible'])
259        {
260          $insert['visible'] = 'false';
261        }
262      }
263      else
264      {
265        $insert['uppercats'] = $insert['id'];
266        $insert{'rank'} = $next_rank['NULL']++;
267        $insert['global_rank'] = $insert['rank'];
268      }
269
270      array_push($inserts, $insert);
271      array_push(
272        $infos,
273        array(
274          'path' => $fulldir,
275          'info' => l10n('added')
276          )
277        );
278
279      // add the new category to $db_categories and $db_fulldirs array
280      $db_categories[$insert{'id'}] =
281        array(
282          'id' => $insert['id'],
283          'status' => $insert['status'],
284          'visible' => $insert['visible'],
285          'uppercats' => $insert['uppercats'],
286          'global_rank' => $insert['global_rank']
287          );
288      $db_fulldirs[$fulldir] = $insert['id'];
289      $next_rank[$insert{'id'}] = 1;
290    }
291    else
292    {
293      array_push(
294        $errors,
295        array(
296          'path' => $fulldir,
297          'type' => 'PWG-UPDATE-1'
298          )
299        );
300    }
301  }
302
303  if (count($inserts) > 0)
304  {
305    if (!$simulate)
306    {
307      $dbfields = array(
308        'id','dir','name','site_id','id_uppercat','uppercats','commentable',
309        'visible','status','rank','global_rank'
310        );
311      mass_inserts(CATEGORIES_TABLE, $dbfields, $inserts);
312
313      // add default permissions to categories
314      $category_ids = array();
315      foreach ($inserts as $category)
316      {
317        $category_ids[] = $category['id'];
318      }
319      add_permission_on_category($category_ids, get_admins());
320    }
321
322    $counts['new_categories'] = count($inserts);
323  }
324
325  // to delete categories
326  $to_delete = array();
327  foreach (array_diff(array_keys($db_fulldirs), $fs_fulldirs) as $fulldir)
328  {
329    array_push($to_delete, $db_fulldirs[$fulldir]);
330    unset($db_fulldirs[$fulldir]);
331    array_push($infos, array('path' => $fulldir,
332                             'info' => l10n('deleted')));
333  }
334  if (count($to_delete) > 0)
335  {
336    if (!$simulate)
337    {
338      delete_categories($to_delete);
339    }
340    $counts['del_categories'] = count($to_delete);
341  }
342
343  $template->append('footer_elements', '<!-- scanning dirs : '
344    . get_elapsed_time($start, get_moment())
345    . ' -->' );
346}
347// +-----------------------------------------------------------------------+
348// |                           files / elements                            |
349// +-----------------------------------------------------------------------+
350if (isset($_POST['submit']) and $_POST['sync'] == 'files'
351      and !$general_failure)
352{
353  $start_files = get_moment();
354  $start= $start_files;
355
356  $fs = $site_reader->get_elements($basedir);
357  $template->append('footer_elements', '<!-- get_elements: '
358    . get_elapsed_time($start, get_moment())
359    . ' -->' );
360
361  $cat_ids = array_diff(array_keys($db_categories), $to_delete);
362
363  $db_elements = array();
364
365  if (count($cat_ids) > 0)
366  {
367    $query = '
368SELECT id, path
369  FROM '.IMAGES_TABLE.'
370  WHERE storage_category_id IN ('
371      .wordwrap(
372        implode(', ', $cat_ids),
373        160,
374        "\n"
375        ).')';
376    $db_elements = simple_hash_from_query($query, 'id', 'path');
377  }
378
379  // next element id available
380  $next_element_id = pwg_db_nextval('id', IMAGES_TABLE);
381
382  $start = get_moment();
383
384  $inserts = array();
385  $insert_links = array();
386
387  foreach (array_diff(array_keys($fs), $db_elements) as $path)
388  {
389    $insert = array();
390    // storage category must exist
391    $dirname = dirname($path);
392    if (!isset($db_fulldirs[$dirname]))
393    {
394      continue;
395    }
396    $filename = basename($path);
397    if (!preg_match('/^[a-zA-Z0-9-_.]+$/', $filename))
398    {
399      array_push(
400        $errors,
401        array(
402          'path' => $path,
403          'type' => 'PWG-UPDATE-1'
404          )
405        );
406
407      continue;
408    }
409
410    $insert = array(
411      'id'             => $next_element_id++,
412      'file'           => $filename,
413      'date_available' => CURRENT_DATE,
414      'path'           => $path,
415      'representative_ext'  => $fs[$path]['representative_ext'],
416      'storage_category_id' => $db_fulldirs[$dirname],
417      'added_by'       => $user['id'],
418      );
419
420    if ( $_POST['privacy_level']!=0 )
421    {
422      $insert['level'] = $_POST['privacy_level'];
423    }
424
425    array_push(
426      $inserts,
427      $insert
428      );
429
430    array_push(
431      $insert_links,
432      array(
433        'image_id'    => $insert['id'],
434        'category_id' => $insert['storage_category_id'],
435        )
436      );
437
438    array_push(
439      $infos,
440      array(
441        'path' => $insert['path'],
442        'info' => l10n('added')
443        )
444      );
445
446    $caddiables[] = $insert['id'];
447  }
448
449  if (count($inserts) > 0)
450  {
451    if (!$simulate)
452    {
453      // inserts all new elements
454      mass_inserts(
455        IMAGES_TABLE,
456        array_keys($inserts[0]),
457        $inserts
458        );
459
460      // inserts all links between new elements and their storage category
461      mass_inserts(
462        IMAGE_CATEGORY_TABLE,
463        array_keys($insert_links[0]),
464        $insert_links
465        );
466
467      // add new photos to caddie
468      if (isset($_POST['add_to_caddie']) and $_POST['add_to_caddie'] == 1)
469      {
470        fill_caddie($caddiables);
471      }
472    }
473    $counts['new_elements'] = count($inserts);
474  }
475
476  // delete elements that are in database but not in the filesystem
477  $to_delete_elements = array();
478  foreach (array_diff($db_elements, array_keys($fs)) as $path)
479  {
480    array_push($to_delete_elements, array_search($path, $db_elements));
481    array_push($infos, array('path' => $path,
482                             'info' => l10n('deleted')));
483  }
484  if (count($to_delete_elements) > 0)
485  {
486    if (!$simulate)
487    {
488      delete_elements($to_delete_elements);
489    }
490    $counts['del_elements'] = count($to_delete_elements);
491  }
492
493  $template->append('footer_elements', '<!-- scanning files : '
494    . get_elapsed_time($start_files, get_moment())
495    . ' -->' );
496}
497
498// +-----------------------------------------------------------------------+
499// |                          synchronize files                            |
500// +-----------------------------------------------------------------------+
501if (isset($_POST['submit'])
502    and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files')
503    and !$general_failure )
504{
505  if (!$simulate)
506  {
507    $start = get_moment();
508    update_category('all');
509    $template->append('footer_elements', '<!-- update_category(all) : '
510      . get_elapsed_time($start,get_moment())
511      . ' -->' );
512    $start = get_moment();
513    update_global_rank();
514    $template->append('footer_elements', '<!-- ordering categories : '
515      . get_elapsed_time($start, get_moment())
516      . ' -->');
517  }
518
519  if ($_POST['sync'] == 'files')
520  {
521    $start = get_moment();
522    $opts['category_id'] = '';
523    $opts['recursive'] = true;
524    if (isset($_POST['cat']))
525    {
526      $opts['category_id'] = $_POST['cat'];
527      if (!isset($_POST['subcats-included']) or $_POST['subcats-included'] != 1)
528      {
529        $opts['recursive'] = false;
530      }
531    }
532    $files = get_filelist($opts['category_id'], $site_id,
533                          $opts['recursive'],
534                          false);
535    $template->append('footer_elements', '<!-- get_filelist : '
536      . get_elapsed_time($start, get_moment())
537      . ' -->');
538    $start = get_moment();
539
540    $datas = array();
541    foreach ( $files as $id=>$file )
542    {
543      $file = $file['path'];
544      $data = $site_reader->get_element_update_attributes($file);
545      if ( !is_array($data) )
546      {
547        continue;
548      }
549
550      $data['id']=$id;
551      array_push($datas, $data);
552    } // end foreach file
553
554    $counts['upd_elements'] = count($datas);
555    if (!$simulate and count($datas)>0 )
556    {
557      mass_updates(
558        IMAGES_TABLE,
559        // fields
560        array(
561          'primary' => array('id'),
562          'update'  => $site_reader->get_update_attributes(),
563          ),
564        $datas
565        );
566    }
567    $template->append('footer_elements', '<!-- update files : '
568      . get_elapsed_time($start,get_moment())
569      . ' -->');
570  }// end if sync files
571}
572
573// +-----------------------------------------------------------------------+
574// |                          synchronize files                            |
575// +-----------------------------------------------------------------------+
576if (isset($_POST['submit'])
577    and ($_POST['sync'] == 'dirs' or $_POST['sync'] == 'files'))
578{
579  $template->assign(
580    'update_result',
581    array(
582      'NB_NEW_CATEGORIES'=>$counts['new_categories'],
583      'NB_DEL_CATEGORIES'=>$counts['del_categories'],
584      'NB_NEW_ELEMENTS'=>$counts['new_elements'],
585      'NB_DEL_ELEMENTS'=>$counts['del_elements'],
586      'NB_UPD_ELEMENTS'=>$counts['upd_elements'],
587      'NB_ERRORS'=>count($errors),
588      ));
589}
590
591// +-----------------------------------------------------------------------+
592// |                          synchronize metadata                         |
593// +-----------------------------------------------------------------------+
594if (isset($_POST['submit']) and isset($_POST['sync_meta'])
595         and !$general_failure)
596{
597  // sync only never synchronized files ?
598  $opts['only_new'] = isset($_POST['meta_all']) ? false : true;
599  $opts['category_id'] = '';
600  $opts['recursive'] = true;
601
602  if (isset($_POST['cat']))
603  {
604    $opts['category_id'] = $_POST['cat'];
605    // recursive ?
606    if (!isset($_POST['subcats-included']) or $_POST['subcats-included'] != 1)
607    {
608      $opts['recursive'] = false;
609    }
610  }
611  $start = get_moment();
612  $files = get_filelist($opts['category_id'], $site_id,
613                        $opts['recursive'],
614                        $opts['only_new']);
615
616  $template->append('footer_elements', '<!-- get_filelist : '
617    . get_elapsed_time($start, get_moment())
618    . ' -->');
619
620  $start = get_moment();
621  $datas = array();
622  $tags_of = array();
623
624  foreach ( $files as $id => $element_infos )
625  {
626    $data = $site_reader->get_element_metadata($element_infos);
627
628    if ( is_array($data) )
629    {
630      $data['date_metadata_update'] = CURRENT_DATE;
631      $data['id']=$id;
632      array_push($datas, $data);
633
634      foreach (array('keywords', 'tags') as $key)
635      {
636        if (isset($data[$key]))
637        {
638          if (!isset($tags_of[$id]))
639          {
640            $tags_of[$id] = array();
641          }
642
643          foreach (explode(',', $data[$key]) as $tag_name)
644          {
645            array_push(
646              $tags_of[$id],
647              tag_id_from_tag_name($tag_name)
648              );
649          }
650        }
651      }
652    }
653    else
654    {
655      array_push($errors, array('path' => $element_infos['path'], 'type' => 'PWG-ERROR-NO-FS'));
656    }
657  }
658
659  if (!$simulate)
660  {
661    if (count($datas) > 0)
662    {
663      mass_updates(
664        IMAGES_TABLE,
665        // fields
666        array(
667          'primary' => array('id'),
668          'update'  => array_unique(
669            array_merge(
670              array_diff(
671                $site_reader->get_metadata_attributes(),
672                // keywords and tags fields are managed separately
673                array('keywords', 'tags')
674                ),
675              array('date_metadata_update'))
676            )
677          ),
678        $datas,
679        isset($_POST['meta_empty_overrides']) ? 0 : MASS_UPDATES_SKIP_EMPTY
680        );
681    }
682    set_tags_of($tags_of);
683  }
684
685  $template->append('footer_elements', '<!-- metadata update : '
686    . get_elapsed_time($start, get_moment())
687    . ' -->');
688
689  $template->assign(
690    'metadata_result',
691    array(
692      'NB_ELEMENTS_DONE' => count($datas),
693      'NB_ELEMENTS_CANDIDATES' => count($files),
694      'NB_ERRORS' => count($errors),
695      ));
696}
697
698// +-----------------------------------------------------------------------+
699// |                        template initialization                        |
700// +-----------------------------------------------------------------------+
701$template->set_filenames(array('update'=>'site_update.tpl'));
702$result_title = '';
703if (isset($simulate) and $simulate)
704{
705  $result_title.= '['.l10n('Simulation').'] ';
706}
707
708// used_metadata string is displayed to inform admin which metadata will be
709// used from files for synchronization
710$used_metadata = implode( ', ', $site_reader->get_metadata_attributes());
711if ($site_is_remote and !isset($_POST['submit']) )
712{
713  $used_metadata.= ' + ...';
714}
715
716$template->assign(
717  array(
718    'SITE_URL'=>$site_url,
719    'U_SITE_MANAGER'=> get_root_url().'admin.php?page=site_manager',
720    'L_RESULT_UPDATE'=>$result_title.l10n('Search for new images in the directories'),
721    'L_RESULT_METADATA'=>$result_title.l10n('Metadata synchronization results'),
722    'METADATA_LIST' => $used_metadata,
723    'U_HELP' => get_root_url().'admin/popuphelp.php?page=synchronize',
724    ));
725
726// +-----------------------------------------------------------------------+
727// |                        introduction : choices                         |
728// +-----------------------------------------------------------------------+
729if (isset($_POST['submit']))
730{
731  $tpl_introduction = array(
732      'sync'  => $_POST['sync'],
733      'sync_meta'  => isset($_POST['sync_meta']) ? true : false,
734      'display_info' => isset($_POST['display_info']) and $_POST['display_info']==1,
735      'add_to_caddie' => isset($_POST['add_to_caddie']) and $_POST['add_to_caddie']==1,
736      'subcats_included' => isset($_POST['subcats-included']) and $_POST['subcats-included']==1,
737      'privacy_level_selected' => (int)@$_POST['privacy_level'],
738      'meta_all'  => isset($_POST['meta_all']) ? true : false,
739      'meta_empty_overrides'  => isset($_POST['meta_empty_overrides']) ? true : false,
740    );
741
742  if (isset($_POST['cat']) and is_numeric($_POST['cat']))
743  {
744    $cat_selected = array($_POST['cat']);
745  }
746  else
747  {
748    $cat_selected = array();
749  }
750}
751else
752{
753  $tpl_introduction = array(
754      'sync'  => 'dirs',
755      'sync_meta'  => true,
756      'display_info' => false,
757      'add_to_caddie' => false,
758      'subcats_included' => true,
759      'privacy_level_selected' => 0,
760      'meta_all'  => false,
761      'meta_empty_overrides'  => false,
762    );
763
764  $cat_selected = array();
765
766  if (isset($_GET['cat_id']))
767  {
768    check_input_parameter('cat_id', $_GET, false, PATTERN_ID);
769
770    $cat_selected = array($_GET['cat_id']);
771    $tpl_introduction['sync'] = 'files';
772  }
773}
774
775$tpl_introduction['privacy_level_options'] = get_privacy_level_options();
776
777$template->assign('introduction', $tpl_introduction);
778
779$query = '
780SELECT id,name,uppercats,global_rank
781  FROM '.CATEGORIES_TABLE.'
782  WHERE site_id = '.$site_id;
783display_select_cat_wrapper($query,
784                           $cat_selected,
785                           'category_options',
786                           false);
787
788
789if (count($errors) > 0)
790{
791  foreach ($errors as $error)
792  {
793    $template->append(
794      'sync_errors',
795      array(
796        'ELEMENT' => $error['path'],
797        'LABEL' => $error['type'].' ('.$error_labels[$error['type']][0].')'
798        ));
799  }
800
801  foreach ($error_labels as $error_type=>$error_description)
802  {
803    $template->append(
804      'sync_error_captions',
805      array(
806        'TYPE' => $error_type,
807        'LABEL' => $error_description[1]
808        ));
809  }
810}
811
812if (count($infos) > 0
813    and isset($_POST['display_info'])
814    and $_POST['display_info'] == 1)
815{
816  foreach ($infos as $info)
817  {
818    $template->append(
819      'sync_infos',
820      array(
821        'ELEMENT' => $info['path'],
822        'LABEL' => $info['info']
823        ));
824  }
825}
826
827// +-----------------------------------------------------------------------+
828// |                          sending html code                            |
829// +-----------------------------------------------------------------------+
830$template->assign_var_from_handle('ADMIN_CONTENT', 'update');
831?>
Note: See TracBrowser for help on using the repository browser.