- Timestamp:
- Oct 9, 2007, 3:43:29 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions.php
r2095 r2127 1990 1990 trigger_action('invalidate_user_cache'); 1991 1991 } 1992 1993 /** 1994 * adds the caracter set to a create table sql query. 1995 * all CREATE TABLE queries must call this function 1996 * @param string query - the sql query 1997 */ 1998 function create_table_add_character_set($query) 1999 { 2000 defined('DB_CHARSET') or die('create_table_add_character_set DB_CHARSET undefined'); 2001 if ('DB_CHARSET'!='') 2002 { 2003 if ( version_compare(mysql_get_server_info(), '4.1.0', '<') ) 2004 { 2005 return $query; 2006 } 2007 $charset_collate = " DEFAULT CHARACTER SET ".DB_CHARSET; 2008 if ('DB_COLLATE'!='') 2009 { 2010 $charset_collate .= " COLLATE ".DB_COLLATE; 2011 } 2012 $query=trim($query); 2013 $query=trim($query, ';'); 2014 if (preg_match('/^CREATE\s+TABLE/i',$query)) 2015 { 2016 $query.=$charset_collate; 2017 } 2018 $query .= ';'; 2019 } 2020 return $query; 2021 } 1992 2022 ?> -
trunk/include/common.inc.php
r2126 r2127 145 145 or die ( "Could not connect to database" ); 146 146 147 defined('PWG_CHARSET') and defined('DB_CHARSET') 148 or die('PWG_CHARSET and/or DB_CHARSET is not defined'); 149 if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) 150 { 151 if (DB_CHARSET!='') 152 { 153 pwg_query('SET NAMES "'.DB_CHARSET.'"'); 154 } 155 } 156 else 157 { 158 if ( strtolower(PWG_CHARSET)!='iso-8859-1' ) 159 { 160 die('PWG supports only iso-8859-1 charset on MySql version '.mysql_get_server_info()); 161 } 162 } 163 147 164 // 148 165 // Setup gallery wide options, if this fails then we output a CRITICAL_ERROR -
trunk/include/constants.php
r2104 r2127 29 29 define('PHPWG_DOMAIN', 'phpwebgallery.net'); 30 30 define('PHPWG_URL', 'http://www.'.PHPWG_DOMAIN); 31 define('PHPWG_DEFAULT_LANGUAGE', 'en_UK .iso-8859-1');31 define('PHPWG_DEFAULT_LANGUAGE', 'en_UK'); 32 32 define('PHPWG_DEFAULT_TEMPLATE', 'yoga/clear'); 33 33 -
trunk/include/functions.inc.php
r2126 r2127 477 477 * @returns array 478 478 */ 479 function get_languages() 480 { 479 function get_languages($target_charset = null) 480 { 481 if ( empty($target_charset) ) 482 { 483 $target_charset = get_pwg_charset(); 484 } 485 $target_charset = strtolower($target_charset); 486 481 487 $dir = opendir(PHPWG_ROOT_PATH.'language'); 482 488 $languages = array(); … … 488 494 { 489 495 list($language_name) = @file($path.'/iso.txt'); 490 $languages[$file] = $language_name; 496 497 $langdef = explode('.',$file); 498 if (count($langdef)>1) // (langCode,encoding) 499 { 500 $langdef[1] = strtolower($langdef[1]); 501 502 if ( 503 $target_charset==$langdef[1] 504 or 505 ($target_charset=='utf-8' and $langdef[1]=='iso-8859-1') 506 or 507 ($target_charset=='iso-8859-1' and 508 in_array( substr($langdef[0],2), array('en','fr','de','es','it','nl'))) 509 ) 510 { 511 $language_name = convert_charset($language_name, 512 $langdef[1], $target_charset); 513 $languages[ $langdef[0] ] = $language_name; 514 } 515 else 516 continue; // the language encoding is not compatible with our charset 517 } 518 else 519 { // probably english that is the same in all ISO-xxx and UTF-8 520 $languages[$file] = $language_name; 521 } 491 522 } 492 523 } … … 1430 1461 function get_pwg_charset() 1431 1462 { 1432 //TEMP CODE1433 global $lang_info;return $lang_info['charset'];1463 defined('PWG_CHARSET') or die('load_language PWG_CHARSET undefined'); 1464 return PWG_CHARSET; 1434 1465 } 1435 1466 … … 1450 1481 */ 1451 1482 function load_language($filename, $dirname = '', $language = '', 1452 $return_content=false) 1453 { 1454 //TEMP CODE 1455 if (!$return_content) $filename.='.php'; 1456 $f = get_language_filepath($filename, $dirname, $language); 1457 if ($f === false) 1458 return false; 1459 if ($return_content) 1460 return @file_get_contents($f); 1461 global $lang, $lang_info; 1462 @include($f); 1463 return true; 1464 } 1465 1483 $return_content=false, $target_charset=null) 1484 { 1485 global $user; 1486 1487 if (!$return_content) 1488 { 1489 $filename .= '.php'; //MAYBE to do .. load .po and .mo localization files 1490 } 1491 if (empty($dirname)) 1492 { 1493 $dirname = PHPWG_ROOT_PATH; 1494 } 1495 $dirname .= 'language/'; 1496 1497 $languages = array(); 1498 if ( !empty($language) ) 1499 { 1500 $languages[] = $language; 1501 } 1502 1503 if ( !empty($user['language']) ) 1504 { 1505 $languages[] = $user['language']; 1506 } 1507 $languages[] = PHPWG_DEFAULT_LANGUAGE; 1508 $languages = array_unique($languages); 1509 1510 if ( empty($target_charset) ) 1511 { 1512 $target_charset = get_pwg_charset(); 1513 } 1514 $target_charset = strtolower($target_charset); 1515 $source_charset = ''; 1516 $source_file = ''; 1517 foreach ($languages as $language) 1518 { 1519 $dir = $dirname.$language; 1520 1521 // exact charset match - no conversion required 1522 $f = $dir.'.'.$target_charset.'/'.$filename; 1523 if (file_exists($f)) 1524 { 1525 $source_file = $f; 1526 break; 1527 } 1528 1529 // universal language (like Eng) no conversion required 1530 $f = $dir.'/'.$filename; 1531 if (file_exists($f)) 1532 { 1533 $source_file = $f; 1534 break; 1535 } 1536 1537 if ($target_charset=='utf-8') 1538 { // we accept conversion from ISO-8859-1 to UTF-8 1539 $f = $dir.'.iso-8859-1/'.$filename; 1540 if (file_exists($f)) 1541 { 1542 $source_charset = 'iso-8859-1'; 1543 $source_file = $f; 1544 break; 1545 } 1546 } 1547 1548 if ($target_charset=='iso-8859-1' and 1549 in_array( substr($language,2), array('en','fr','de','es','it','nl') ) 1550 ) 1551 { // we accept conversion from UTF-8 to ISO-8859-1 for backward compatibility ONLY 1552 $f = $dir.'.utf-8/'.$filename; 1553 if (file_exists($f)) 1554 { 1555 $source_charset = 'utf-8'; 1556 $source_file = $f; 1557 break; 1558 } 1559 } 1560 } 1561 1562 if ( !empty($source_file) ) 1563 { 1564 if (!$return_content) 1565 { 1566 @include($source_file); 1567 $load_lang = @$lang; 1568 $load_lang_info = @$lang_info; 1569 1570 global $lang, $lang_info; 1571 if ( !isset($lang) ) $lang=array(); 1572 if ( !isset($lang_info) ) $lang_info=array(); 1573 1574 if ( !empty($source_charset) and $source_charset!=$target_charset) 1575 { 1576 if ( is_array($load_lang) ) 1577 { 1578 foreach ($load_lang as $k => $v) 1579 { 1580 if ( is_array($v) ) 1581 { 1582 $func = create_function('$v', 'return convert_charset($v, "'.$source_charset.'","'.$target_charset.'");' ); 1583 $lang[$k] = array_map($func, $v); 1584 } 1585 else 1586 $lang[$k] = convert_charset($v, $source_charset, $target_charset); 1587 } 1588 } 1589 if ( is_array($load_lang_info) ) 1590 { 1591 foreach ($load_lang_info as $k => $v) 1592 { 1593 $lang_info[$k] = convert_charset($v, $source_charset, $target_charset); 1594 } 1595 } 1596 } 1597 else 1598 { 1599 $lang = array_merge( $lang, $load_lang ); 1600 $lang_info = array_merge( $lang_info, $load_lang_info ); 1601 } 1602 return true; 1603 } 1604 else 1605 { 1606 $content = @file_get_contents($source_file); 1607 if ( !empty($source_charset) and $source_charset!=$target_charset) 1608 { 1609 $content = convert_charset($content, $source_charset, $target_charset); 1610 } 1611 return $content; 1612 } 1613 } 1614 return false; 1615 } 1616 1617 /** 1618 * converts a string from a character set to another character set 1619 * @param string str the string to be converted 1620 * @param string source_charset the character set in which the string is encoded 1621 * @param string dest_charset the destination character set 1622 */ 1623 function convert_charset($str, $source_charset, $dest_charset) 1624 { 1625 if ($source_charset==$dest_charset) 1626 return $str; 1627 if ($source_charset=='iso-8859-1' and $dest_charset=='utf-8') 1628 { 1629 return utf8_encode($str); 1630 } 1631 if ($source_charset=='utf-8' and $dest_charset=='iso-8859-1') 1632 { 1633 return utf8_decode($str); 1634 } 1635 if (function_exists('iconv')) 1636 { 1637 return iconv($source_charset, $dest_charset, $str); 1638 } 1639 if (function_exists('mb_convert_encoding')) 1640 { 1641 return mb_convert_encoding( $str, $dest_charset, $source_charset ); 1642 } 1643 return $str; //??? 1644 } 1466 1645 ?> -
trunk/include/functions_user.inc.php
r2124 r2127 33 33 // o check if address is not used by a other user 34 34 // If the mail address doesn't correspond, an error message is returned. 35 // 35 // 36 36 function validate_mail_address($user_id, $mail_address) 37 37 { … … 39 39 40 40 if (empty($mail_address) and 41 !($conf['obligatory_user_mail_address'] and 41 !($conf['obligatory_user_mail_address'] and 42 42 in_array(script_basename(), array('register', 'profile')))) 43 43 { … … 50 50 return l10n('reg_err_mail_address'); 51 51 } 52 52 53 53 if (defined("PHPWG_INSTALLED") and !empty($mail_address)) 54 54 { … … 157 157 158 158 return $errors; 159 }160 161 function setup_style($style)162 {163 return new Template(PHPWG_ROOT_PATH.'template/'.$style);164 159 } 165 160 -
trunk/install.php
r2124 r2127 28 28 define('PHPWG_ROOT_PATH','./'); 29 29 30 // Guess an initial language ...31 function guess_lang()32 {33 return 'en_UK.iso-8859-1';34 }35 36 30 // 37 31 // Pick a language, any language ... … … 39 33 function language_select($default, $select_name = "language") 40 34 { 41 $available_lang = get_languages( );35 $available_lang = get_languages('utf-8'); 42 36 43 37 $lang_select = '<select name="' . $select_name . '" onchange="document.location = \''.PHPWG_ROOT_PATH.'install.php?language=\'+this.options[this.selectedIndex].value;">'; … … 85 79 if (!preg_match('/^DROP TABLE/i', $query)) 86 80 { 81 global $install_charset_collate; 82 if ( !empty($install_charset_collate) ) 83 { 84 if ( preg_match('/^(CREATE TABLE .*)[\s]*;[\s]*/im', $query, $matches) ) 85 { 86 $query = $matches[1].' '.$install_charset_collate.';'; 87 } 88 } 87 89 mysql_query($query); 88 90 } … … 211 213 create_empty_local_files(); 212 214 213 if ( isset( $_POST['language'] )) 214 { 215 $language = strip_tags($_POST['language']); 216 } 217 elseif ( isset( $_GET['language'] )) 218 { 219 $language = strip_tags($_GET['language']); 220 } 221 else 222 { 223 $language = guess_lang(); 224 } 225 226 if (!file_exists(PHPWG_ROOT_PATH.'language/'.$language.'/install.lang.php')) 227 { 228 $language = 'en_UK.iso-8859-1'; 229 } 230 231 include( './language/'.$language.'/common.lang.php' ); 232 // Never: @include( './language/'.$language.'/local.lang.php' ); 233 include( './language/'.$language.'/admin.lang.php' ); 234 include( './language/'.$language.'/install.lang.php' ); 215 if ( isset( $_REQUEST['language'] )) 216 { 217 $language = strip_tags($_REQUEST['language']); 218 } 219 else 220 { 221 $language = 'en_UK'; 222 } 223 224 load_language( 'common.lang', '', $language, false, 'utf-8' ); 225 load_language( 'admin.lang', '', $language, false, 'utf-8' ); 226 load_language( 'install.lang', '', $language, false, 'utf-8' ); 227 235 228 //----------------------------------------------------- template initialization 236 $template= setup_style('yoga');229 $template=new Template(PHPWG_ROOT_PATH.'template/yoga'); 237 230 $template->set_filenames( array('install'=>'install.tpl') ); 238 231 $step = 1; … … 252 245 array_push( $errors, $lang['step1_err_db'] ); 253 246 } 247 if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) 248 { 249 $pwg_charset='utf-8'; 250 $pwg_db_charset='utf8'; 251 $install_charset_collate = "DEFAULT CHARACTER SET $pwg_db_charset"; 252 } 253 else 254 { 255 $pwg_charset='iso-8859-1'; 256 $pwg_db_charset='latin1'; 257 $install_charset_collate = ''; 258 if ( !array_key_exists($language, get_languages($pwg_charset) ) ) 259 { 260 $language='en_UK'; 261 } 262 } 254 263 } 255 264 else … … 257 266 array_push( $errors, $lang['step1_err_server'] ); 258 267 } 259 268 260 269 $webmaster = trim(preg_replace( '/\s{2,}/', ' ', $admin_name )); 261 270 if ( empty($webmaster)) … … 267 276 if ( empty($admin_mail)) 268 277 array_push( $errors, $lang['reg_err_mail_address'] ); 269 else 278 else 270 279 { 271 280 $error_mail_address = validate_mail_address(null, $admin_mail); … … 273 282 array_push( $errors, $error_mail_address ); 274 283 } 275 284 276 285 if ( count( $errors ) == 0 ) 277 286 { … … 286 295 287 296 define(\'PHPWG_INSTALLED\', true); 297 define(\'PWG_CHARSET\', \''.$pwg_charset.'\'); 298 define(\'DB_CHARSET\', \''.$pwg_db_charset.'\'); 299 define(\'DB_COLLATE\', \'\'); 300 288 301 ?'.'>'; 289 302 290 303 @umask(0111); 291 304 // writing the configuration file … … 303 316 @fputs($fp, $file_content, strlen($file_content)); 304 317 @fclose($fp); 305 318 306 319 // tables creation, based on phpwebgallery_structure.sql 307 320 execute_sqlfile( … … 325 338 ); 326 339 mass_inserts(SITES_TABLE, array_keys($insert), array($insert)); 327 340 328 341 // webmaster admin user 329 342 $inserts = array( … … 371 384 array( 372 385 'RELEASE'=>PHPWG_VERSION, 373 386 374 387 'L_BASE_TITLE'=>$lang['Initial_config'], 375 388 'L_LANG_TITLE'=>$lang['Default_lang'], … … 399 412 'L_END_TITLE'=>$lang['install_end_title'], 400 413 'L_END_MESSAGE'=>$lang['install_end_message'], 401 414 402 415 'F_ACTION'=>'install.php', 403 416 'F_DB_HOST'=>$dbhost, … … 412 425 'F_ADMIN_EMAIL'=>$admin_mail, 413 426 'F_LANG_SELECT'=>language_select($language), 414 415 'T_CONTENT_ENCODING' => $lang_info['charset']427 428 'T_CONTENT_ENCODING' => 'utf-8' 416 429 )); 417 430 -
trunk/install/phpwebgallery_structure.sql
r2084 r2127 383 383 `status` enum('webmaster','admin','normal','generic','guest') NOT NULL default 'guest', 384 384 `adviser` enum('true','false') NOT NULL default 'false', 385 `language` varchar(50) NOT NULL default 'en_UK .iso-8859-1',385 `language` varchar(50) NOT NULL default 'en_UK', 386 386 `maxwidth` smallint(6) default NULL, 387 387 `maxheight` smallint(6) default NULL, -
trunk/language/en_UK.iso-8859-1/common.lang.php
r2122 r2127 28 28 $lang_info['language_name'] = 'English'; 29 29 $lang_info['country'] = 'Great Britain'; 30 $lang_info['charset'] = 'iso-8859-1';31 30 $lang_info['direction'] = 'ltr'; 32 31 $lang_info['code'] = 'en'; -
trunk/language/fr_FR.iso-8859-1/common.lang.php
r2122 r2127 28 28 $lang_info['language_name'] = 'Français'; 29 29 $lang_info['country'] = 'France'; 30 $lang_info['charset'] = 'iso-8859-1';31 30 $lang_info['direction'] = 'ltr'; 32 31 $lang_info['code'] = 'fr'; -
trunk/plugins/admin_multi_view/controller.php
r2073 r2127 121 121 <html> 122 122 <head> 123 <meta http-equiv="Content-Type" content="text/html; charset=<?php echo get_pwg_charset() ?>"> 123 124 <title>Controller</title> 124 <?php 125 <?php 125 126 // Controller will be displayed with the **real admin template** (without Any if it has been removed) 126 127 if ( $my_template !== '') {
Note: See TracChangeset
for help on using the changeset viewer.