Ignore:
Timestamp:
May 15, 2010, 2:03:52 PM (14 years ago)
Author:
patdenice
Message:

Update language keys.
Code cleaning.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/autoupdate/trunk/autoupdate.php

    r6168 r6181  
    11<?php
    22
    3 load_language('plugin.lang', dirname(__FILE__).'/');
    43include(AUTOUPDATE_PATH.'include/functions.inc.php');
    54include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php');
     
    1312*/
    1413$step = isset($_GET['step']) ? $_GET['step'] : 0;
     14$upgrade_to = isset($_GET['to']) ? $_GET['to'] : '';
    1515
    1616// +-----------------------------------------------------------------------+
     
    1919if ($step == 0)
    2020{
    21   if (preg_match('/(\d+\.\d+)\.(\d+)/', PHPWG_VERSION, $matches)
    22     and @fetchRemote(PHPWG_URL.'/download/all_versions.php', $result)
    23     and $all_versions = @explode("\n", $result)
    24     and is_array($all_versions))
     21  $template->assign(array(
     22    'CHECK_VERSION' => false,
     23    'DEV_VERSION' => false,
     24    )
     25  );
     26
     27  if (preg_match('/(\d+\.\d+)\.(\d+)/', PHPWG_VERSION, $matches))
    2528  {
    26     $template->assign('CHECK_VERSION', true);
     29    if (@fetchRemote(PHPWG_URL.'/download/all_versions.php', $result)
     30      and $all_versions = @explode("\n", $result)
     31      and is_array($all_versions))
     32    {
     33      $template->assign('CHECK_VERSION', true);
    2734
    28     $last_version = trim($all_versions[0]);
     35      $last_version = trim($all_versions[0]);
     36      $upgrade_to = $last_version;
    2937
    30     if (version_compare(PHPWG_VERSION, $last_version, '<'))
    31     {
    32       $new_branch = preg_replace('/(\d+\.\d+)\.\d+/', '$1', $last_version);
    33       $actual_branch = $matches[1];
     38      if (version_compare(PHPWG_VERSION, $last_version, '<'))
     39      {
     40        $new_branch = preg_replace('/(\d+\.\d+)\.\d+/', '$1', $last_version);
     41        $actual_branch = $matches[1];
    3442
    35       if ($new_branch == $actual_branch)
    36       {
    37         $step = 2;
    38       }
    39       else
    40       {
    41         $step = 3;
     43        if ($new_branch == $actual_branch)
     44        {
     45          $step = 2;
     46        }
     47        else
     48        {
     49          $step = 3;
    4250
    43         // Check if new version exists in same branch
    44         foreach ($all_versions as $version)
    45         {
    46           $new_branch = preg_replace('/(\d+\.\d+)\.\d+/', '$1', $version);
     51          // Check if new version exists in same branch
     52          foreach ($all_versions as $version)
     53          {
     54            $new_branch = preg_replace('/(\d+\.\d+)\.\d+/', '$1', $version);
    4755
    48           if ($new_branch == $actual_branch)
    49           {
    50             if (version_compare(PHPWG_VERSION, $version, '<'))
     56            if ($new_branch == $actual_branch)
    5157            {
    52               $step = 1;
     58              if (version_compare(PHPWG_VERSION, $version, '<'))
     59              {
     60                $step = 1;
     61              }
     62              break;
    5363            }
    54             break;
    5564          }
    5665        }
     
    6069  else
    6170  {
    62     $template->assign('CHECK_VERSION', false);
     71    $template->assign('DEV_VERSION', true);
    6372  }
    6473}
     
    6978if ($step == 1)
    7079{
    71   $new_versions = array($last_version, $version);
    72   $template->assign('new_versions', $new_versions);
     80  $template->assign(array(
     81    'MINOR_VERSION' => $version,
     82    'MAJOR_VERSION' => $last_version,
     83    )
     84  );
    7385}
    7486
     
    8092  if (isset($_POST['submit']) and isset($_POST['upgrade_to']))
    8193  {
    82     upgrade_to($_POST['upgrade_to'], $step);
     94    autoupdate_upgrade_to($_POST['upgrade_to'], $step);
    8395  }
    84 
    85   $template->assign('UPGRADE_TO', isset($_GET['to']) ? $_GET['to'] : $last_version);
    8696}
    8797
     
    93103  if (isset($_POST['saveTemplate']))
    94104  {
    95     $path = $conf['local_data_dir'].'/autoupdate';
    96 
    97     if (@mkgetdir($path)
    98       and ($zip = tempnam($path, 'zip'))
    99       and ($archive = new pclZip($zip))
    100       and ($v_list = $archive->add(PHPWG_ROOT_PATH.'template', PCLZIP_OPT_REMOVE_PATH, PHPWG_ROOT_PATH))
    101       and is_array($v_list)
    102       and !empty($v_list))
    103     {
    104       $http_headers = array(
    105         'Content-Length: '.@filesize($zip),
    106         'Content-Type: application/zip',
    107         'Content-Disposition: attachment; filename="template.zip";',
    108         'Content-Transfer-Encoding: binary',
    109         );
    110 
    111       foreach ($http_headers as $header) {
    112         header($header);
    113       }
    114 
    115       @readfile($zip);
    116       autoupdate_deltree($conf['local_data_dir'].'/autoupdate');
    117       exit();
    118     }
    119 
    120     array_push($page['errors'], l10n('Unable to send template directory.'));
     105    autoupdate_save_template_dir();
    121106  }
    122107
    123108  if (isset($_POST['dumpDatabase']))
    124109  {
    125     if (version_compare(PHPWG_VERSION, '2.1', '<'))
    126     {
    127       global $cfgBase;
    128       $conf['db_base'] = $cfgBase;
    129     }
    130 
    131     include(AUTOUPDATE_PATH.'include/mysqldump.php');
    132 
    133     $path = $conf['local_data_dir'].'/autoupdate';
    134 
    135     if (@mkgetdir($path)
    136       and ($backupFile = tempnam($path, 'sql'))
    137       and ($dumper = new MySQLDump($conf['db_base'],$backupFile,false,false)))
    138     {
    139       $tablesStructure = array(
    140         CATEGORIES_TABLE,
    141         COMMENTS_TABLE,
    142         CONFIG_TABLE,
    143         FAVORITES_TABLE,
    144         GROUP_ACCESS_TABLE,
    145         GROUPS_TABLE,
    146         HISTORY_TABLE,
    147         HISTORY_SUMMARY_TABLE,
    148         IMAGE_CATEGORY_TABLE,
    149         IMAGES_TABLE,
    150         SESSIONS_TABLE,
    151         SITES_TABLE,
    152         USER_ACCESS_TABLE,
    153         USER_GROUP_TABLE,
    154         USERS_TABLE,
    155         USER_INFOS_TABLE,
    156         USER_FEED_TABLE,
    157         WAITING_TABLE,
    158         RATE_TABLE,
    159         USER_CACHE_TABLE,
    160         USER_CACHE_CATEGORIES_TABLE,
    161         CADDIE_TABLE,
    162         UPGRADE_TABLE,
    163         SEARCH_TABLE,
    164         USER_MAIL_NOTIFICATION_TABLE,
    165         TAGS_TABLE,
    166         IMAGE_TAG_TABLE,
    167         PLUGINS_TABLE,
    168         OLD_PERMALINKS_TABLE,
    169         );
    170 
    171       $tablesData = $tablesStructure;
    172 
    173       if (!isset($_POST['includeHistory']))
    174       {
    175         unset($tablesData[6]);
    176       }
    177 
    178       foreach ($tablesStructure as $table)
    179       {
    180         $dumper->getTableStructure($table);
    181       }
    182       foreach ($tablesData as $table)
    183       {
    184         $dumper->getTableData($table);
    185       }
    186     }
    187 
    188     if (@filesize($backupFile))
    189     {
    190       $http_headers = array(
    191         'Content-Length: '.@filesize($backupFile),
    192         'Content-Type: text/x-sql',
    193         'Content-Disposition: attachment; filename="database.sql";',
    194         'Content-Transfer-Encoding: binary',
    195         );
    196 
    197       foreach ($http_headers as $header) {
    198         header($header);
    199       }
    200 
    201       @readfile($backupFile);
    202       autoupdate_deltree($conf['local_data_dir'].'/autoupdate');
    203       exit();
    204     }
    205 
    206     array_push($page['errors'], l10n('Unable to dump database.'));
     110    autoupdate_dump_database();
    207111  }
    208112
    209113  if (isset($_POST['submit']) and isset($_POST['upgrade_to']))
    210114  {
    211     upgrade_to($_POST['upgrade_to'], $step);
     115    autoupdate_upgrade_to($_POST['upgrade_to'], $step);
    212116  }
    213 
    214   $template->assign('UPGRADE_TO', isset($_GET['to']) ? $_GET['to'] : $last_version);
    215117}
    216118
     
    220122
    221123$template->assign(array(
    222   'STEP' => $step,
    223   'AU_URL' => get_admin_plugin_menu_link(AUTOUPDATE_PATH . '/autoupdate.php'),
     124  'STEP'        => $step,
     125  'AU_URL'      => get_admin_plugin_menu_link(AUTOUPDATE_PATH . '/autoupdate.php'),
     126  'UPGRADE_TO'  => $upgrade_to,
     127  'RELEASE_URL' => PHPWG_URL.'/releases/'.$upgrade_to,
    224128  )
    225129);
Note: See TracChangeset for help on using the changeset viewer.