Changeset 5982
- Timestamp:
- Apr 28, 2010, 4:28:05 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions_install.inc.php
r5781 r5982 34 34 * @return void 35 35 */ 36 function execute_sqlfile($filepath, $replaced, $replacing )36 function execute_sqlfile($filepath, $replaced, $replacing, $dblayer) 37 37 { 38 38 $sql_lines = file($filepath); … … 55 55 if (!preg_match('/^DROP TABLE/i', $query)) 56 56 { 57 global $install_charset_collate; 58 if ( !empty($install_charset_collate) ) 57 if ('mysql' == $dblayer) 59 58 { 60 59 if ( preg_match('/^(CREATE TABLE .*)[\s]*;[\s]*/im', $query, $matches) ) 61 60 { 62 $query = $matches[1].' '.$install_charset_collate.';';61 $query = $matches[1].' DEFAULT CHARACTER SET utf8'.';'; 63 62 } 64 63 } … … 126 125 127 126 /** 128 * Automatically activate all themes in the "themes" directory.127 * Automatically activate all core themes in the "themes" directory. 129 128 * 130 129 * @return void 131 130 */ 132 function activate_ all_themes()131 function activate_core_themes() 133 132 { 134 133 include_once(PHPWG_ROOT_PATH.'admin/include/themes.class.php'); … … 136 135 foreach ($themes->fs_themes as $theme_id => $fs_theme) 137 136 { 138 $themes->perform_action('activate', $theme_id); 137 if (in_array($theme_id, array('Sylvia', 'clear', 'dark'))) 138 { 139 $themes->perform_action('activate', $theme_id); 140 } 139 141 } 140 142 } … … 144 146 try 145 147 { 146 $pwg_db_link = pwg_db_connect($_POST['dbhost'], $_POST['dbuser'], 147 $_POST['dbpasswd'], $_POST['dbname']); 148 149 return $pwg_db_link; 148 $pwg_db_link = pwg_db_connect($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpasswd'], $_POST['dbname']); 149 if ($pwg_db_link) 150 { 151 pwg_db_check_version(); 152 } 150 153 } 151 154 catch (Exception $e) … … 153 156 array_push( $errors, l10n($e->getMessage())); 154 157 } 155 return false;156 158 } 157 159 ?> -
trunk/admin/include/functions_upgrade.php
r5387 r5982 77 77 78 78 $standard_plugins = array( 79 'add_index',80 'admin_advices',81 79 'admin_multi_view', 82 80 'c13y_upgrade', … … 222 220 try 223 221 { 224 $pwg_db_link = pwg_db_connect($conf['db_host'], $conf['db_user'], 225 $conf['db_password'], $conf['db_base']); 222 $pwg_db_link = pwg_db_connect($conf['db_host'], $conf['db_user'], $conf['db_password'], $conf['db_base']); 223 if ($pwg_db_link) 224 { 225 pwg_db_check_version(); 226 } 226 227 } 227 228 catch (Exception $e) … … 231 232 } 232 233 234 /** 235 * Get languages defined in the language directory 236 */ 237 function get_fs_languages($target_charset = null) 238 { 239 if ( empty($target_charset) ) 240 { 241 $target_charset = get_pwg_charset(); 242 } 243 $target_charset = strtolower($target_charset); 244 245 $dir = opendir(PHPWG_ROOT_PATH.'language'); 246 247 while ($file = readdir($dir)) 248 { 249 $path = PHPWG_ROOT_PATH.'language/'.$file; 250 if (!is_link($path) and is_dir($path) and file_exists($path.'/iso.txt')) 251 { 252 list($language_name) = @file($path.'/iso.txt'); 253 254 $languages[$file] = convert_charset($language_name, $target_charset); 255 } 256 } 257 closedir($dir); 258 @asort($languages); 259 260 return $languages; 261 } 262 233 263 ?> -
trunk/include/dblayer/functions_mysql.inc.php
r5782 r5982 53 53 function pwg_db_check_charset() 54 54 { 55 defined('PWG_CHARSET') and defined('DB_CHARSET') 56 or fatal_error('PWG_CHARSET and/or DB_CHARSET is not defined'); 57 if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) 58 { 59 if (DB_CHARSET!='') 60 { 61 pwg_query('SET NAMES "'.DB_CHARSET.'"'); 62 } 63 } 64 elseif ( strtolower(PWG_CHARSET)!='iso-8859-1' ) 65 { 66 fatal_error('PWG supports only iso-8859-1 charset on MySql version '.mysql_get_server_info()); 55 $db_charset = 'utf8'; 56 if (defined('DB_CHARSET') and DB_CHARSET != '') 57 { 58 $db_charset = DB_CHARSET; 59 } 60 pwg_query('SET NAMES "'.$db_charset.'"'); 61 } 62 63 function pwg_db_check_version() 64 { 65 $current_mysql = pwg_get_db_version(); 66 if (version_compare($current_mysql, REQUIRED_MYSQL_VERSION, '<')) 67 { 68 fatal_error( 69 sprintf( 70 'your MySQL version is too old, you have "%s" and you need at least "%s"', 71 $current_mysql, 72 REQUIRED_MYSQL_VERSION 73 ) 74 ); 67 75 } 68 76 } -
trunk/include/functions.inc.php
r5781 r5982 695 695 while ($row = pwg_db_fetch_assoc($result)) 696 696 { 697 if ( file_exists($conf['themes_dir'].'/'.$row['id'].'/'.'themeconf.inc.php'))697 if (check_theme_installed($row['id'])) 698 698 { 699 699 $themes[ $row['id'] ] = $row['name']; … … 705 705 706 706 return $themes; 707 } 708 709 function check_theme_installed($theme_id) 710 { 711 global $conf; 712 713 return file_exists($conf['themes_dir'].'/'.$theme_id.'/'.'themeconf.inc.php'); 707 714 } 708 715 … … 1149 1156 function get_pwg_charset() 1150 1157 { 1151 defined('PWG_CHARSET') or fatal_error('PWG_CHARSET undefined'); 1152 return PWG_CHARSET; 1158 $pwg_charset = 'utf-8'; 1159 if (defined('PWG_CHARSET')) 1160 { 1161 $pwg_charset = PWG_CHARSET; 1162 } 1163 return $pwg_charset; 1153 1164 } 1154 1165 -
trunk/include/functions_user.inc.php
r5272 r5982 849 849 function get_default_theme() 850 850 { 851 return get_default_user_value('theme', PHPWG_DEFAULT_TEMPLATE); 851 $theme = get_default_user_value('theme', PHPWG_DEFAULT_TEMPLATE); 852 if (check_theme_installed($theme)) 853 { 854 return $theme; 855 } 856 857 // let's find the first available theme 858 $active_themes = get_pwg_themes(); 859 foreach (array_keys(get_pwg_themes()) as $theme_id) 860 { 861 if (check_theme_installed($theme_id)) 862 { 863 return $theme_id; 864 } 865 } 852 866 } 853 867 -
trunk/install.php
r5781 r5982 263 263 if ( isset( $_POST['install'] )) 264 264 { 265 if ($pwg_db_link = install_db_connect($infos, $errors)) 266 { 267 $required_version = constant('REQUIRED_'.strtoupper($dblayer).'_VERSION'); 268 if ( version_compare(pwg_get_db_version(), $required_version, '>=') ) 269 { 270 $pwg_charset = 'utf-8'; 271 $pwg_db_charset = 'utf8'; 272 if ($dblayer=='mysql') 273 { 274 $install_charset_collate = "DEFAULT CHARACTER SET $pwg_db_charset"; 275 pwg_query('SET NAMES "'.$pwg_db_charset.'"'); 276 } 277 else 278 { 279 $install_charset_collate = ''; 280 } 281 } 282 else 283 { 284 $pwg_charset = 'iso-8859-1'; 285 $pwg_db_charset = 'latin1'; 286 $install_charset_collate = ''; 287 if ( !array_key_exists($language, $languages->get_fs_languages($pwg_charset) ) ) 288 { 289 $language='en_UK'; 290 } 291 } 292 } 265 install_db_connect($infos, $errors); 266 pwg_db_check_charset(); 293 267 294 268 $webmaster = trim(preg_replace( '/\s{2,}/', ' ', $admin_name )); … … 321 295 322 296 define(\'PHPWG_INSTALLED\', true); 323 define(\'PWG_CHARSET\', \' '.$pwg_charset.'\');324 define(\'DB_CHARSET\', \' '.$pwg_db_charset.'\');297 define(\'PWG_CHARSET\', \'utf-8\'); 298 define(\'DB_CHARSET\', \'utf8\'); 325 299 define(\'DB_COLLATE\', \'\'); 326 300 … … 351 325 PHPWG_ROOT_PATH.'install/piwigo_structure-'.$dblayer.'.sql', 352 326 DEFAULT_PREFIX_TABLE, 353 $prefixeTable 327 $prefixeTable, 328 $dblayer 354 329 ); 355 330 // We fill the tables with basic informations … … 357 332 PHPWG_ROOT_PATH.'install/config.sql', 358 333 DEFAULT_PREFIX_TABLE, 359 $prefixeTable 334 $prefixeTable, 335 $dblayer 360 336 ); 361 337 … … 367 343 368 344 // fill languages table 369 foreach ($languages->get_fs_languages( $pwg_charset) as $language_code => $language_name)345 foreach ($languages->get_fs_languages() as $language_code => $language_name) 370 346 { 371 347 $languages->perform_action('activate', $language_code); … … 379 355 if (!defined('PWG_CHARSET')) 380 356 { 381 define('PWG_CHARSET', $pwg_charset);382 } 383 activate_ all_themes();357 define('PWG_CHARSET', 'utf-8'); 358 } 359 activate_core_themes(); 384 360 385 361 $insert = array( -
trunk/install/db/65-database.php
r5215 r5982 166 166 $query = 'SHOW TABLES LIKE "'.$prefixeTable.'%"'; 167 167 $result = pwg_query($query); 168 while ( $row=pwg_db_fetch_ assoc($result) )168 while ( $row=pwg_db_fetch_row($result) ) 169 169 { 170 170 array_push($all_tables, $row[0]); -
trunk/install/db/86-database.php
r5452 r5982 27 27 } 28 28 29 $upgrade_description = 'Automatically activate core themes and used themes.';29 $upgrade_description = 'Automatically activate core themes.'; 30 30 31 $themes_core = array('Sylvia', 'dark', 'clear'); 32 33 $query = ' 34 SELECT 35 DISTINCT(theme) 36 FROM '.PREFIX_TABLE.'user_infos 37 ;'; 38 $themes_used = array_from_query($query, 'theme'); 39 40 $query = ' 41 SELECT 42 id 43 FROM '.PREFIX_TABLE.'themes 44 ;'; 45 $themes_active = array_from_query($query, 'id'); 46 47 48 $themes_to_activate = array_diff( 49 array_unique(array_merge($themes_used, $themes_core)), 50 $themes_active 51 ); 52 53 // echo '<pre>'; print_r($themes_to_activate); echo '</pre>'; exit(); 54 55 foreach ($themes_to_activate as $theme) 56 { 57 $query = ' 58 INSERT INTO '.PREFIX_TABLE.'themes 59 (id) VALUES(\''.$theme.'\' 60 ;'; 61 pwg_query($query); 62 } 31 include_once(PHPWG_ROOT_PATH . 'admin/include/functions_install.inc.php'); 32 activate_core_themes(); 63 33 64 34 echo -
trunk/install/upgrade_1.7.0.php
r5196 r5982 33 33 } 34 34 } 35 36 define('UPGRADES_PATH', PHPWG_ROOT_PATH.'install/db');37 38 list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));39 define('CURRENT_DATE', $dbnow);40 35 41 36 // +-----------------------------------------------------------------------+ … … 89 84 echo '<pre>'; 90 85 91 for ($upgrade_id = 61; ; $upgrade_id++)86 for ($upgrade_id = 61; $upgrade_id <= 79; $upgrade_id++) 92 87 { 93 88 if (!file_exists(UPGRADES_PATH.'/'.$upgrade_id.'-database.php')) … … 120 115 121 116 // now we upgrade from 2.0.0 122 //include_once(PHPWG_ROOT_PATH.'install/upgrade_2.0.0.php');117 include_once(PHPWG_ROOT_PATH.'install/upgrade_2.0.0.php'); 123 118 ?> -
trunk/upgrade.php
r5573 r5982 48 48 include_once(PHPWG_ROOT_PATH.'include/constants.php'); 49 49 define('PREFIX_TABLE', $prefixeTable); 50 define('UPGRADES_PATH', PHPWG_ROOT_PATH.'install/db'); 50 51 51 52 // +-----------------------------------------------------------------------+ … … 202 203 203 204 upgrade_db_connect(); 204 205 205 pwg_db_check_charset(); 206 207 list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();')); 208 define('CURRENT_DATE', $dbnow); 206 209 207 210 // +-----------------------------------------------------------------------+ … … 261 264 $current_release = '1.7.0'; 262 265 } 266 else if (!in_array(PREFIX_TABLE.'themes', $tables)) 267 { 268 $current_release = '2.0.0'; 269 } 263 270 else 264 271 { … … 297 304 if (!@file_put_contents($config_file, $config_file_contents)) 298 305 { 299 array_push($page['infos'], 300 l10n_args('In <i>%s</i>, before <b>?></b>, insert:', 301 'local/config/database.inc.php') . 302 '<p><textarea rows="4" cols="40">' . 303 implode("\r\n" , $mysql_changes).'</textarea></p>' 304 ); 306 array_push( 307 $page['infos'], 308 sprintf( 309 l10n('In <i>%s</i>, before <b>?></b>, insert:'), 310 'local/config/database.inc.php' 311 ) 312 .'<p><textarea rows="4" cols="40">' 313 .implode("\r\n" , $mysql_changes).'</textarea></p>' 314 ); 305 315 } 306 316 } … … 368 378 else 369 379 { 370 foreach (get_languages('utf-8') as $language_code => $language_name) 380 if (!defined('PWG_CHARSET')) 381 { 382 define('PWG_CHARSET', 'utf-8'); 383 } 384 385 include_once(PHPWG_ROOT_PATH.'admin/include/languages.class.php'); 386 $languages = new languages(); 387 388 foreach ($languages->fs_languages as $language_code => $language_name) 371 389 { 372 390 if ($language == $language_code)
Note: See TracChangeset
for help on using the changeset viewer.