Changeset 6181 for extensions/autoupdate/trunk/autoupdate.php
- Timestamp:
- May 15, 2010, 2:03:52 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/autoupdate/trunk/autoupdate.php
r6168 r6181 1 1 <?php 2 2 3 load_language('plugin.lang', dirname(__FILE__).'/');4 3 include(AUTOUPDATE_PATH.'include/functions.inc.php'); 5 4 include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php'); … … 13 12 */ 14 13 $step = isset($_GET['step']) ? $_GET['step'] : 0; 14 $upgrade_to = isset($_GET['to']) ? $_GET['to'] : ''; 15 15 16 16 // +-----------------------------------------------------------------------+ … … 19 19 if ($step == 0) 20 20 { 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)) 25 28 { 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); 27 34 28 $last_version = trim($all_versions[0]); 35 $last_version = trim($all_versions[0]); 36 $upgrade_to = $last_version; 29 37 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]; 34 42 35 if ($new_branch == $actual_branch)36 {37 $step = 2;38 }39 else40 {41 $step = 3;43 if ($new_branch == $actual_branch) 44 { 45 $step = 2; 46 } 47 else 48 { 49 $step = 3; 42 50 43 // Check if new version exists in same branch44 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); 47 55 48 if ($new_branch == $actual_branch) 49 { 50 if (version_compare(PHPWG_VERSION, $version, '<')) 56 if ($new_branch == $actual_branch) 51 57 { 52 $step = 1; 58 if (version_compare(PHPWG_VERSION, $version, '<')) 59 { 60 $step = 1; 61 } 62 break; 53 63 } 54 break;55 64 } 56 65 } … … 60 69 else 61 70 { 62 $template->assign(' CHECK_VERSION', false);71 $template->assign('DEV_VERSION', true); 63 72 } 64 73 } … … 69 78 if ($step == 1) 70 79 { 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 ); 73 85 } 74 86 … … 80 92 if (isset($_POST['submit']) and isset($_POST['upgrade_to'])) 81 93 { 82 upgrade_to($_POST['upgrade_to'], $step);94 autoupdate_upgrade_to($_POST['upgrade_to'], $step); 83 95 } 84 85 $template->assign('UPGRADE_TO', isset($_GET['to']) ? $_GET['to'] : $last_version);86 96 } 87 97 … … 93 103 if (isset($_POST['saveTemplate'])) 94 104 { 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(); 121 106 } 122 107 123 108 if (isset($_POST['dumpDatabase'])) 124 109 { 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(); 207 111 } 208 112 209 113 if (isset($_POST['submit']) and isset($_POST['upgrade_to'])) 210 114 { 211 upgrade_to($_POST['upgrade_to'], $step);115 autoupdate_upgrade_to($_POST['upgrade_to'], $step); 212 116 } 213 214 $template->assign('UPGRADE_TO', isset($_GET['to']) ? $_GET['to'] : $last_version);215 117 } 216 118 … … 220 122 221 123 $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, 224 128 ) 225 129 );
Note: See TracChangeset
for help on using the changeset viewer.