Changeset 9735 for extensions/autoupdate/trunk/include/functions.inc.php
- Timestamp:
- Mar 16, 2011, 11:45:17 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/autoupdate/trunk/include/functions.inc.php
r9712 r9735 86 86 } 87 87 } 88 }89 }90 91 function move_local_files($dir)92 {93 global $page, $cfgBase, $cfgUser, $cfgPassword, $cfgHote, $prefixeTable;94 95 if ((!is_dir($dir) and !mkdir($dir, 0777))96 or (!is_dir($dir.'/config') and !mkdir($dir.'/config'))97 or (!is_dir($dir.'/css') and !mkdir($dir.'/css'))98 or (!is_dir($dir.'/language') and !mkdir($dir.'/language')))99 {100 autoupdate_deltree($dir);101 array_push($page['errors'], l10n('Unable to write new local directory.'));102 return;103 }104 105 // Add index.php106 autoupdate_add_index($dir);107 108 // mysql.inc.php109 $file = PHPWG_ROOT_PATH.'include/mysql.inc.php';110 if (is_readable($file))111 {112 $file_content = '<?php113 $conf[\'dblayer\'] = \'mysql\';114 $conf[\'db_base\'] = \''.$cfgBase.'\';115 $conf[\'db_user\'] = \''.$cfgUser.'\';116 $conf[\'db_password\'] = \''.$cfgPassword.'\';117 $conf[\'db_host\'] = \''.$cfgHote.'\';118 119 $prefixeTable = \''.$prefixeTable.'\';120 121 define(\'PHPWG_INSTALLED\', true);';122 if (defined('PWG_CHARSET'))123 {124 $file_content.= '125 define(\'PWG_CHARSET\', \'utf-8\');126 define(\'DB_CHARSET\', \'utf8\');127 define(\'DB_COLLATE\', \'\');';128 }129 $file_content.= '130 ?>';131 $new_config_file = $dir.'/config/database.inc.php';132 133 if (!($fp = @fopen($new_config_file, 'w'))134 or !@fwrite($fp, $file_content)135 or !@fclose($fp))136 {137 array_push($page['errors'], l10n('Unable to write new local directory.'));138 return;139 }140 @chmod($new_config_file, 0755);141 }142 143 // config_local.inc.php144 $file = PHPWG_ROOT_PATH.'include/config_local.inc.php';145 if (is_readable($file))146 {147 copy($file, $dir.'/config/config.inc.php');148 @chmod($file, 0755);149 }150 151 // languages152 $language_dir = opendir(PHPWG_ROOT_PATH.'language');153 while ($file = readdir($language_dir))154 {155 $path = PHPWG_ROOT_PATH.'language/'.$file;156 if (!is_link($path) and is_dir($path) and is_readable($path.'/local.lang.php'))157 {158 $content = file_get_contents($path.'/local.lang.php');159 $langdef = explode('.',$file);160 if (count($langdef)>1)161 {162 $content = utf8_encode($content);163 }164 $filename = $dir.'/language/'.$langdef[0].'.lang.php';165 $fp = @fopen($filename, 'w');166 @fwrite($fp, $content);167 @fclose($fp);168 @chmod($filename, 0755);169 }170 }171 closedir($language_dir);172 173 // template-common/local-layout.css174 $file = PHPWG_ROOT_PATH.'template-common/local-layout.css';175 if (is_readable($file))176 {177 copy($file, $dir.'/css/rules.css');178 @chmod($file, 0755);179 }180 181 // template/xxx/local-layout.css182 $known_templates = array(183 'yoga' => 'default',184 'floPure' => 'Pure_default',185 'floOs' => 'OS_default',186 'gally' => 'gally-default',187 'simple' => 'simple',188 );189 190 foreach ($known_templates as $old_tpl => $new_tpl)191 {192 $file = PHPWG_ROOT_PATH.'template/'.$old_tpl.'/local-layout.css';193 if (is_readable($file))194 {195 copy($file, $dir.'/css/'.$new_tpl.'-rules.css');196 @chmod($file, 0755);197 }198 }199 }200 201 function autoupdate_save_template_dir()202 {203 global $page, $conf;204 205 $path = $conf['local_data_dir'].'/autoupdate';206 207 if (@mkgetdir($path)208 and ($zip = tempnam($path, 'zip'))209 and ($archive = new pclZip($zip))210 and ($v_list = $archive->add(PHPWG_ROOT_PATH.'template', PCLZIP_OPT_REMOVE_PATH, PHPWG_ROOT_PATH))211 and is_array($v_list)212 and !empty($v_list))213 {214 $http_headers = array(215 'Content-Length: '.@filesize($zip),216 'Content-Type: application/zip',217 'Content-Disposition: attachment; filename="template.zip";',218 'Content-Transfer-Encoding: binary',219 );220 221 foreach ($http_headers as $header) {222 header($header);223 }224 225 @readfile($zip);226 autoupdate_deltree($conf['local_data_dir'].'/autoupdate');227 exit();228 }229 else230 {231 array_push($page['errors'], l10n('Unable to send template directory.'));232 88 } 233 89 } … … 312 168 $remove_path = version_compare($code, '2.0.8', '>=') ? 'piwigo' : 'piwigo-'.$code; 313 169 $obsolete_list = PHPWG_ROOT_PATH.'install/obsolete.list'; 314 315 if (version_compare(PHPWG_VERSION, '2.1', '<'))316 {317 move_local_files(PHPWG_ROOT_PATH.'local');318 }319 170 } 320 171
Note: See TracChangeset
for help on using the changeset viewer.