[ Index ]

PHP Cross Reference of phpwcms V1.5.0 _r431 (28.01.12)

title

Body

[close]

/setup/inc/ -> setup.func.inc.php (source)

   1  <?php
   2  /*************************************************************************************
   3     Copyright notice
   4     
   5     (c) 2002-2012 Oliver Georgi <oliver@phpwcms.de> // All rights reserved.
   6   
   7     This script is part of PHPWCMS. The PHPWCMS web content management system is
   8     free software; you can redistribute it and/or modify it under the terms of
   9     the GNU General Public License as published by the Free Software Foundation;
  10     either version 2 of the License, or (at your option) any later version.
  11    
  12     The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
  13     A copy is found in the textfile GPL.txt and important notices to the license 
  14     from the author is found in LICENSE.txt distributed with these scripts.
  15    
  16     This script is distributed in the hope that it will be useful, but WITHOUT ANY 
  17     WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
  18     PARTICULAR PURPOSE.  See the GNU General Public License for more details.
  19   
  20     This copyright notice MUST APPEAR in all copies of the script!
  21  *************************************************************************************/
  22  
  23  //setup functions
  24  
  25  $DOCROOT = rtrim(str_replace('\\', '/', dirname(dirname(dirname(__FILE__)))), '/');
  26  include ($DOCROOT.'/include/inc_lib/revision/revision.php');
  27  
  28  if(empty($_SERVER['DOCUMENT_ROOT'])) {
  29      $_SERVER['DOCUMENT_ROOT'] = $DOCROOT;
  30  }
  31  
  32  $phpwcms_version        = PHPWCMS_VERSION;
  33  $phpwcms_release_date    = PHPWCMS_RELEASE_DATE;
  34  $phpwcms_revision        = PHPWCMS_REVISION;
  35  
  36  function read_textfile($filename) {
  37      if(is_file($filename)) {
  38          $fd = @fopen($filename, "rb");
  39          $text = fread($fd, filesize($filename));
  40          fclose($fd);
  41          return $text;                
  42      } else {
  43          return false;
  44      }
  45  }
  46  
  47  function write_textfile($filename, $text) {
  48      if($fp = @fopen($filename, "w+b")) {;
  49          fwrite($fp, $text);
  50          fclose($fp);
  51          return true;    
  52      } else {
  53          return false;
  54      }
  55  }
  56  
  57  function set_chmod($path, $rights, $status, $file_folder=0) {
  58  
  59      $Cpath = $_SERVER['DOCUMENT_ROOT'].$path;
  60      if(@file_exists($Cpath)) {
  61          if(@chmod($Cpath, $rights)) {
  62              $status = $file_folder ? check_path_status($path) : check_file_status($path);
  63          }
  64      }
  65      return $status;
  66  }
  67  
  68  function check_path_status($path) {
  69      $path = $_SERVER['DOCUMENT_ROOT'].$path;
  70      $status = 0;
  71      $status += (is_dir($path)) ? 1 : 0;
  72      if($status) {
  73          $status += (is_writable($path)) ? 1 : 0;
  74      }
  75      return $status;
  76  }
  77  
  78  function check_file_status($path) {
  79      $path = $_SERVER['DOCUMENT_ROOT'].$path;
  80      $status = 0;
  81      $status += (is_file($path)) ? 1 : 0;
  82      if($status) {
  83          $status += (is_writable($path)) ? 1 : 0;
  84      }
  85      return $status;
  86  }
  87  
  88  function gib_bg_color($status) {
  89      $color = ' bgcolor="#FF3300"';
  90      switch($status) {
  91          case 2: $color = ' bgcolor="#99CC00"';
  92                  break;
  93          case 1: $color = ' bgcolor="#99CC00"';
  94                  break;
  95      }
  96      return $color;
  97      
  98  }
  99  
 100  function gib_status_text($status) {
 101      $msg = "&nbsp;<b>FALSE</b> (not existing)";
 102      switch($status) {
 103          case 2: $msg = "&nbsp;<b>OK</b> (exists + writable)";
 104                  break;
 105          case 1: $msg = "&nbsp;<b>FALSE</b> (exists + not writable)";
 106                  break;
 107          case 3: $msg = "&nbsp;<b>OK</b> (exists + not writable)";
 108                  break;
 109      }
 110      return $msg;
 111  }
 112  
 113  function slweg($string_wo_slashes_weg, $string_laenge=0) {
 114      // Falls die Serverfunktion magic_quotes_gpc aktiviert ist, so
 115      // sollen die Slashes herausgenommen werden, anderenfalls nicht
 116      $string_wo_slashes_weg = trim($string_wo_slashes_weg);
 117      if( get_magic_quotes_gpc() ) $string_wo_slashes_weg = stripslashes ($string_wo_slashes_weg);
 118      if($string_laenge) $string_wo_slashes_weg = substr($string_wo_slashes_weg, 0, $string_laenge);
 119      return $string_wo_slashes_weg;
 120  }
 121  
 122  function clean_slweg($string_wo_slashes_weg, $string_laenge=0) {
 123      // Falls die Serverfunktion magic_quotes_gpc aktiviert ist, so
 124      // sollen die Slashes herausgenommen werden, anderenfalls nicht
 125      $string_wo_slashes_weg = trim($string_wo_slashes_weg);
 126      if( get_magic_quotes_gpc() ) $string_wo_slashes_weg = stripslashes ($string_wo_slashes_weg);
 127      $string_wo_slashes_weg = strip_tags($string_wo_slashes_weg);
 128      if($string_laenge) $string_wo_slashes_weg = substr($string_wo_slashes_weg, 0, $string_laenge);
 129      return $string_wo_slashes_weg;
 130  }
 131  
 132  function write_conf_file($val) {
 133  
 134      $conf_file  = '<?'."php\n\n";
 135      $conf_file .= "// database values\n";
 136      $conf_file .= "\$phpwcms['db_host']           = '".$val["db_host"]."';\n";
 137      $conf_file .= "\$phpwcms['db_user']           = '".$val["db_user"]."';\n";
 138      $conf_file .= "\$phpwcms['db_pass']           = '".$val["db_pass"]."';\n";
 139      $conf_file .= "\$phpwcms['db_table']          = '".$val["db_table"]."';\n";
 140      $conf_file .= "\$phpwcms['db_prepend']        = '".$val["db_prepend"]."';\n";
 141      $conf_file .= "\$phpwcms['db_pers']           = ".intval($val["db_pers"]).";\n";
 142      $conf_file .= "\$phpwcms['db_charset']        = '".$val["db_charset"]."';\n";
 143      $conf_file .= "\$phpwcms['db_collation']      = '".$val["db_collation"]."';\n";
 144      $conf_file .= "\$phpwcms['db_version']        = ".intval($val["db_version"]).";\n";
 145      $conf_file .= "\$phpwcms['db_timezone']       = '".trim($val["db_timezone"])."';\n // set MySQL session time zone http://dev.mysql.com/doc/refman/5.5/en/time-zone-support.html";
 146      
 147      $conf_file .= "\n// site values\n";
 148      $conf_file .= "\$phpwcms['site']              = '".$val["site"]."';\n";
 149      $conf_file .= "\$phpwcms['admin_name']        = '".$val["admin_name"]."'; //default: Webmaster\n";
 150      $conf_file .= "\$phpwcms['admin_user']        = '".$val["admin_user"]."'; //default: admin\n";
 151      $conf_file .= "\$phpwcms['admin_pass']        = '".$val["admin_pass"]."'; //MD5(phpwcms)\n";
 152      $conf_file .= "\$phpwcms['admin_email']       = '".$val["admin_email"]."'; //default: noreplay@host\n";
 153  
 154      $conf_file .= "\n// paths\n";
 155      if(!$val['DOC_ROOT'] || $val['DOC_ROOT'] == $_SERVER['DOCUMENT_ROOT']) {
 156          $conf_file .= "\$phpwcms['DOC_ROOT']          = \$_SERVER"."['DOCUMENT_ROOT'];";
 157      } else {
 158          $conf_file .= "\$phpwcms['DOC_ROOT']          = '".$val["DOC_ROOT"]."';         //default: \$_SERVER['DOCUMENT_ROOT']";
 159      }
 160      $real_doc_root = dirname(__FILE__);
 161      $real_doc_root = str_replace("\\", '/', $real_doc_root);
 162      $real_doc_root = str_replace('/setup', '', $real_doc_root);
 163      $real_doc_root = str_replace($val["root"], '', $real_doc_root);
 164      $real_doc_root = preg_replace('/\/$/i', '', $real_doc_root);
 165      $conf_file .= "// real DOC_ROOT seems to be: '".$real_doc_root."' \n";
 166      $conf_file .= "\$phpwcms['root']                 = '".$val["root"]."';         //default: ''\n";
 167      $conf_file .= "\$phpwcms['file_path']         = '".$val["file_path"]."';    //default: 'filearchive'\n";
 168      $conf_file .= "\$phpwcms['templates']         = '".$val["templates"]."';    //default: 'template'\n";
 169      $conf_file .= "\$phpwcms['content_path']      = '".$val["content_path"]."'; //default: 'content'\n";
 170      $conf_file .= "\$phpwcms['cimage_path']       = 'images';  //default: 'images'\n";
 171      $conf_file .= "\$phpwcms['ftp_path']          = '".$val["ftp_path"]."';     //default: 'upload'\n";
 172  
 173      $conf_file .= "\n// content values\n";
 174      $conf_file .= "\$phpwcms['file_maxsize']      = ".intval($val["file_maxsize"])."; //Bytes (50 x 1024 x 1024)\n";
 175      $conf_file .= "\$phpwcms['content_width']     = ".intval($val["content_width"])."; //max width of the article content column - important for rendering multi column images\n";
 176      $conf_file .= "\$phpwcms['img_list_width']    = ".intval($val["img_list_width"])."; //max with of the list thumbnail image\n";
 177      $conf_file .= "\$phpwcms['img_list_height']   = ".intval($val["img_list_height"])."; //max height of the list thumbnail image\n";
 178      $conf_file .= "\$phpwcms['img_prev_width']    = ".intval($val["img_prev_width"])."; //max width of the large preview image\n";
 179      $conf_file .= "\$phpwcms['img_prev_height']   = ".intval($val["img_prev_height"])."; //max height of the large preview image\n";
 180      $conf_file .= "\$phpwcms['max_time']          = ".intval($val["max_time"])."; //logout after max_time/60 seconds\n";
 181  
 182      $conf_file .= "\n// other stuff\n";
 183      $conf_file .= "\$phpwcms['image_library']     = 'GD2';    //GD, GD2, ImageMagick, NetPBM\n";
 184      $conf_file .= "\$phpwcms['library_path']      = '';       //Path to ImageMagick or NetPBM\n";
 185      $conf_file .= "\$phpwcms['rewrite_url']       = 0;  //whether URL should be rewritable\n";
 186      $conf_file .= "\$phpwcms['wysiwyg_editor']    = 1;  //0 = no wysiwyg editor, 1 = CKEditor, 2 = FCKeditor\n";
 187      $conf_file .= "\$phpwcms['phpmyadmin']        = 0;  //enable/disable phpMyAdmin in Backend\n";
 188      $conf_file .= "\$phpwcms['allowed_lang']      = array('en','de','fr','es');     //array of allowed languages: array('en', 'de', 'fr', 'es')\n";
 189      $conf_file .= "\$phpwcms['be_lang_parse']     = false; // to disable backend language parsing use false, otherwise 'BBCode' or 'BraceCode'\n";
 190      $conf_file .= "\$phpwcms['DOCTYPE_LANG']      = '';          //by default same as \$phpwcms['default_lang'], but can be injected by whatever you like\n";
 191      $conf_file .= "\$phpwcms['default_lang']      = '".$val["default_lang"]."';  //default language\n";
 192      $conf_file .= "\$phpwcms['charset']           = '".$val["charset"]."';  //default charset 'utf-8'\n";
 193      $conf_file .= "\$phpwcms['allow_remote_URL']  = 1;  //0 = no remote URL in {PHP:...} replacement tag allowed, 1 = allowed\n";
 194      $conf_file .= "\$phpwcms['jpg_quality']       = 85; //JPG Quality Range 25-100\n";
 195      $conf_file .= "\$phpwcms['sharpen_level']     = 1;  //Sharpen Level - only ImageMagick: 0, 1, 2, 3, 4, 5 -- 0 = no, 5 = extra sharp\n";
 196      $conf_file .= "\$phpwcms['allow_ext_init']    = 1;  //allow including of custom external scripts at frontend initialization\n";
 197      $conf_file .= "\$phpwcms['allow_ext_render']  = 1;  //allow including of custom external scripts at frontend rendering\n";
 198      $conf_file .= "\$phpwcms['cache_enabled']     = 0;        //cache On/Off - 1 = caching On / 0 = caching Off (default)\n";
 199      $conf_file .= "\$phpwcms['cache_timeout']     = 0;  //default cache timeout setting in seconds - 0 = caching Off\n";
 200      $conf_file .= "\$phpwcms['imgext_disabled']   = '';  //comma seperated list of imagetypes which should not be handled 'pdf,ps'\n";
 201      $conf_file .= "\$phpwcms['multimedia_ext']    = 'aif,aiff,mov,movie,mp3,mpeg,mpeg4,mpeg2,wav,swf,swc,ram,ra,wma,wmv,avi,au,midi,moov,rm,rpm,mid,midi'; //comma seperated list of file extensiosn allowed for multimedia\n";
 202      $conf_file .= "\$phpwcms['inline_download']   = 1;  //1 = try to display download documents in new window; 0 = show safe under dialog\n";
 203      $conf_file .= "\$phpwcms['form_tracking']     = 1; //make a db entry for each form\n";
 204      $conf_file .= "\$phpwcms['formmailer_set']    = array('allow_send_copy' => 0, 'global_recipient_email' => 'mail@example.com'); //for better security handling\n";
 205      $conf_file .= "\$phpwcms['allow_cntPHP_rt']   = 0; //allow PHP replacement tags and includes in content parts\n";
 206      $conf_file .= "\$phpwcms['GETparameterName']  = 'id'; //must have a minimum of 2 chars \n";
 207      $conf_file .= "\$phpwcms['BOTS']              = array('googlebot', 'msnbot', 'bingbot', 'ia_archiver', 'altavista', 'slurp', 'yahoo', 'jeeves', 'teoma', 'lycos', 'crawler'); //don't start session \n";
 208      $conf_file .= "\$phpwcms['mode_XHTML']        = 1; // Doctype: 1 = XHTML 1.0 Transitional, 0 = HTML 4.01 Transitional, 2 = XHTML 1.0 Strict, 3 = HTML5 \n";
 209      $conf_file .= "\$phpwcms['header_XML']        = 0; // Content Type: 1 = application/xhtml+xml, 0 = text/html \n";
 210      $conf_file .= "\$phpwcms['IE7-js']              = 0; // load IE7-js - fix for HTML/CSS/PNG bugs in IE\n";
 211      $conf_file .= "\$phpwcms['php_timezone']        = ''; // overwrite PHP default time zone http://php.net/manual/en/timezones.php\n";
 212      $conf_file .= "\$phpwcms['wysiwyg_template']  = array( 'FCKeditor' => 'phpwcms_basic,phpwcms_default,Default,Basic', 'CKEditor' => 'phpwcms_basic,phpwcms_default,Default,Basic' );\n";
 213      $conf_file .= "\$phpwcms['GET_pageinfo']      = 0; // will add \"&pageinfo=/cat1/cat2/page-title.htm\" based on the breadcrumb information for each site link \n";
 214      $conf_file .= "\$phpwcms['version_check']     = 1; // checks for current release of phpwcms online \n";
 215      $conf_file .= "\$phpwcms['SESSION_FEinit']    = 0; // set 1 to enable sessions in frontend, 0 to disable sessions in frontend \n";
 216      $conf_file .= "\$phpwcms['Login_IPcheck']     = 0; \n";
 217      $conf_file .= "\$phpwcms['frontend_edit']      = 0; // enable content specific direct links - linking direct into the backend \n";
 218      $conf_file .= "\$phpwcms['gd_memcheck_off']   = 0; // disable GD php memory check before resize an image \n";
 219      $conf_file .= "\$phpwcms['enable_chat']          = 0; // enable or disable chat function, by default it is disabled - not recommend anymore to use it \n";
 220      $conf_file .= "\$phpwcms['enable_messages']      = 0; // enable or disable internal messags, by default it is disabled - not recommend anymore to use it \n";
 221      $conf_file .= "\$phpwcms['enable_seolog']      = 1; // enable or disable logging of search engine referrer data \n";
 222      $conf_file .= "\$phpwcms['i18n_parse']            = 1; // enable|disable browser based language parser - all @@Text@@ will be parsed and checked for translation/var based replacement\n";
 223      $conf_file .= "\$phpwcms['i18n_complex']      = 0; // enable|disable the way browser language setting should be used, false = the easier way (always 2 chars 'en'), true - 'en-gb'...\n";
 224      $conf_file .= "\$phpwcms['FCK_FileBrowser']   = 1; // enable|disable phpwcms Filebrowser in FCKeditor instead of built-in FCK file bowser support\n";
 225      $conf_file .= "\$phpwcms['JW_FLV_License']    = ''; // insert your JW FLV Media Player License Code here - License warning will no longer displayed\n";
 226      $conf_file .= "\$phpwcms['feuser_regkey']      = 'FEUSER';\n";
 227      $conf_file .= "\$phpwcms['login.php']            = 'login.php';\n";
 228      $conf_file .= "\$phpwcms['rewrite_ext']            = '.html'; // The file extension used while URL is rewritten\n";
 229      $conf_file .= "\$phpwcms['js_lib']              = array('mootools-1.4'=>'MooTools 1.4','mootools-1.4-compat'=>'MooTools 1.4 Compat','mootools-1.3'=>'MooTools 1.3','mootools-1.3-compat'=>'MooTools 1.3 Compat','mootools-1.2'=>'MooTools 1.2','mootools-1.1'=>'MooTools 1.1','jquery-1.7'=>'jQuery 1.7','jquery-1.6'=>'jQuery 1.6','jquery-1.5'=>'jQuery 1.5','jquery-1.4'=>'jQuery 1.4','jquery'=>'jQuery 1.3');\n";
 230      $conf_file .= "\$phpwcms['video-js']          = 'http://vjs.zencdn.net/c/'; // can be stored locally too 'template/lib/video-js/ (http://videojs.com/)\n";
 231      $conf_file .= "\$phpwcms['render_device']     = 0; // allow user agent specific rendering templates <!--if:mobile-->DoMobile<!--/if--><!--!if:mobile-->DoNotMobile<!--/!if--><!--!if:default-->Default<!--/!if-->\n";
 232  
 233      $conf_file .= "\n// dynamic ssl encryption engine\n";
 234      $conf_file .= "\$phpwcms['site_ssl_mode']     = '0'; // tuns the SSL Support of WCMS on(1) or off (0) DEFAULT '0'\n";
 235      $conf_file .= "\$phpwcms['site_ssl_url']      = '';  //URL assigned to the SSL Certificate. DON'T add a slash at the End! Exp. 'https://www.yourdomainhere.tld'\n";
 236      $conf_file .= "\$phpwcms['site_ssl_port']     = '443'; //The Port on which you SSL Service serve the secure Sites. Servers DEFAULT is '443'\n";
 237      
 238      $conf_file .= "\n// smtp values\n";
 239      $conf_file .= "\$phpwcms['SMTP_FROM_EMAIL']   = '".$val["SMTP_FROM_EMAIL"]."'; // reply/from email address\n";
 240      $conf_file .= "\$phpwcms['SMTP_FROM_NAME']    = '".$val["SMTP_FROM_NAME"]."'; // reply/from name\n";
 241      $conf_file .= "\$phpwcms['SMTP_HOST']         = '".$val["SMTP_HOST"]."'; // SMTP server (host/IP)\n";
 242      $conf_file .= "\$phpwcms['SMTP_PORT']         = ".intval($val["SMTP_PORT"])."; // SMTP-Server port (default 25)\n";
 243      $conf_file .= "\$phpwcms['SMTP_MAILER']       = '".$val["SMTP_MAILER"]."'; // default phpMailer: smtp, mail (default), sendmail\n";
 244      $conf_file .= "\$phpwcms['SMTP_AUTH']         = ".intval($val["SMTP_AUTH"])."; // sets SMTP_AUTH to ON/OFF\n";
 245      $conf_file .= "\$phpwcms['SMTP_USER']         = '".$val["SMTP_USER"]."'; // default SMTP login (user) name\n";
 246      $conf_file .= "\$phpwcms['SMTP_PASS']         = '".$val["SMTP_PASS"]."'; // default SMTP password\n";
 247      
 248      $conf_file .= "\ndefine('PHPWCMS_INCLUDE_CHECK', true);\n";
 249      
 250      $conf_file .= "\n?>";
 251      
 252      write_textfile("setup.conf.inc.php", $conf_file);    
 253  }
 254  
 255  function aporeplace($string_to_convert="") {
 256      //Ändert die einfachen Apostrophe für SQL-Funktionen in doppelte
 257      $string_to_convert = str_replace("\\", "\\\\", $string_to_convert);
 258      $string_to_convert = str_replace("'", "''", $string_to_convert );
 259      return $string_to_convert;
 260  }
 261  
 262  function html_specialchars($h="") {
 263      //used to replace the htmlspecialchars original php function
 264      //not compatible with many internation chars like turkish, polish
 265      $h = preg_replace("/&(?!#[0-9]+;)/s", '&amp;', $h );
 266      $h = str_replace( "<", "&lt;"  , $h );
 267      $h = str_replace( ">", "&gt;"  , $h );
 268      $h = str_replace( '"', "&quot;", $h );
 269      $h = str_replace( "'", "&#039;", $h );
 270      $h = str_replace( "\\", "&#92;", $h );
 271      return $h;
 272  }
 273  
 274  
 275  // taken from http://de.php.net/manual/de/function.phpinfo.php#59573
 276  function parsePHPModules() {
 277   ob_start();
 278   phpinfo(INFO_MODULES);
 279   $s = ob_get_clean(); 
 280   $s = strip_tags($s,'<h2><th><td>');
 281   $s = preg_replace('/<th[^>]*>([^<]+)<\/th>/',"<info>\\1</info>",$s);
 282   $s = preg_replace('/<td[^>]*>([^<]+)<\/td>/',"<info>\\1</info>",$s);
 283   $vTmp = preg_split('/(<h2>[^<]+<\/h2>)/',$s,-1,PREG_SPLIT_DELIM_CAPTURE);
 284   $vModules = array();
 285   for ($i=1;$i<count($vTmp);$i++) {
 286    if (preg_match('/<h2>([^<]+)<\/h2>/',$vTmp[$i],$vMat)) {
 287     $vName = trim($vMat[1]);
 288     $vTmp2 = explode("\n",$vTmp[$i+1]);
 289     foreach ($vTmp2 AS $vOne) {
 290     $vPat = '<info>([^<]+)<\/info>';
 291     $vPat3 = "/$vPat\s*$vPat\s*$vPat/";
 292     $vPat2 = "/$vPat\s*$vPat/";
 293     if (preg_match($vPat3,$vOne,$vMat)) { // 3cols
 294       $vModules[$vName][trim($vMat[1])] = array(trim($vMat[2]),trim($vMat[3]));
 295     } elseif (preg_match($vPat2,$vOne,$vMat)) { // 2cols
 296       $vModules[$vName][trim($vMat[1])] = trim($vMat[2]);
 297     }
 298     }
 299    }
 300   }
 301   return $vModules;
 302  }
 303  
 304  
 305  function errorWarning($warning='') {
 306      $t  = '<p class="error"><img src="../img/famfamfam/icon_alert.gif" alt="Alert" border="0" class="icon1" /><b>';
 307      $t .= $warning;
 308      $t .= '</b></p>';
 309      return $t;
 310  }
 311  
 312  // based on definitions of phpMyAdmin
 313  
 314  $mysql_charset_map = array(
 315      'big5'         => 'big5',
 316      'cp-866'       => 'cp866',
 317      'euc-jp'       => 'ujis',
 318      'euc-kr'       => 'euckr',
 319      'gb2312'       => 'gb2312',
 320      'gbk'          => 'gbk',
 321      'iso-8859-1'   => 'latin1',
 322      'iso-8859-2'   => 'latin2',
 323      'iso-8859-7'   => 'greek',
 324      'iso-8859-8'   => 'hebrew',
 325      'iso-8859-8-i' => 'hebrew',
 326      'iso-8859-9'   => 'latin5',
 327      'iso-8859-13'  => 'latin7',
 328      'iso-8859-15'  => 'latin1',
 329      'koi8-r'       => 'koi8r',
 330      'shift_jis'    => 'sjis',
 331      'tis-620'      => 'tis620',
 332      'utf-8'        => 'utf8',
 333      'windows-1250' => 'cp1250',
 334      'windows-1251' => 'cp1251',
 335      'windows-1252' => 'latin1',
 336      'windows-1256' => 'cp1256',
 337      'windows-1257' => 'cp1257',
 338  );
 339  
 340  $available_languages = array(
 341      'af-iso-8859-1'     => array('af|afrikaans', 'afrikaans-iso-8859-1', 'af', ''),
 342      'af-utf-8'          => array('af|afrikaans', 'afrikaans-utf-8', 'af', ''),
 343      'ar-win1256'        => array('ar|arabic', 'arabic-windows-1256', 'ar', '&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577;'),
 344      'ar-utf-8'          => array('ar|arabic', 'arabic-utf-8', 'ar', '&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577;'),
 345      'az-iso-8859-9'     => array('az|azerbaijani', 'azerbaijani-iso-8859-9', 'az', 'Az&#601;rbaycanca'),
 346      'az-utf-8'          => array('az|azerbaijani', 'azerbaijani-utf-8', 'az', 'Az&#601;rbaycanca'),
 347  
 348      'becyr-win1251'     => array('be|belarusian', 'belarusian_cyrillic-windows-1251', 'be', '&#1041;&#1077;&#1083;&#1072;&#1088;&#1091;&#1089;&#1082;&#1072;&#1103;'),
 349      'becyr-utf-8'       => array('be|belarusian', 'belarusian_cyrillic-utf-8', 'be', '&#1041;&#1077;&#1083;&#1072;&#1088;&#1091;&#1089;&#1082;&#1072;&#1103;'),
 350      'belat-utf-8'       => array('be[-_]lat|belarusian latin', 'belarusian_latin-utf-8', 'be-lat', 'Byelorussian'),
 351      'bg-win1251'        => array('bg|bulgarian', 'bulgarian-windows-1251', 'bg', '&#1041;&#1098;&#1083;&#1075;&#1072;&#1088;&#1089;&#1082;&#1080;'),
 352      'bg-koi8-r'         => array('bg|bulgarian', 'bulgarian-koi8-r', 'bg', '&#1041;&#1098;&#1083;&#1075;&#1072;&#1088;&#1089;&#1082;&#1080;'),
 353      'bg-utf-8'          => array('bg|bulgarian', 'bulgarian-utf-8', 'bg', '&#1041;&#1098;&#1083;&#1075;&#1072;&#1088;&#1089;&#1082;&#1080;'),
 354      'bs-win1250'        => array('bs|bosnian', 'bosnian-windows-1250', 'bs', 'Bosanski'),
 355      'bs-utf-8'          => array('bs|bosnian', 'bosnian-utf-8', 'bs', 'Bosanski'),
 356      'ca-iso-8859-1'     => array('ca|catalan', 'catalan-iso-8859-1', 'ca', 'Catal&agrave;'),
 357      'ca-utf-8'          => array('ca|catalan', 'catalan-utf-8', 'ca', 'Catal&agrave;'),
 358      'cs-iso-8859-2'     => array('cs|czech', 'czech-iso-8859-2', 'cs', '&#268;esky'),
 359      'cs-win1250'        => array('cs|czech', 'czech-windows-1250', 'cs', '&#268;esky'),
 360      'cs-utf-8'          => array('cs|czech', 'czech-utf-8', 'cs', '&#268;esky'),
 361      'da-iso-8859-1'     => array('da|danish', 'danish-iso-8859-1', 'da', 'Dansk'),
 362      'da-utf-8'          => array('da|danish', 'danish-utf-8', 'da', 'Dansk'),
 363      'de-iso-8859-1'     => array('de|german', 'german-iso-8859-1', 'de', 'Deutsch'),
 364      'de-iso-8859-15'    => array('de|german', 'german-iso-8859-15', 'de', 'Deutsch'),
 365      'de-utf-8'          => array('de|german', 'german-utf-8', 'de', 'Deutsch'),
 366      'el-iso-8859-7'     => array('el|greek',  'greek-iso-8859-7', 'el', '&Epsilon;&lambda;&lambda;&eta;&nu;&iota;&kappa;&#940;'),
 367      'el-utf-8'          => array('el|greek',  'greek-utf-8', 'el', '&Epsilon;&lambda;&lambda;&eta;&nu;&iota;&kappa;&#940;'),
 368      'en-iso-8859-1'     => array('en|english',  'english-iso-8859-1', 'en', ''),
 369      'en-iso-8859-15'    => array('en|english',  'english-iso-8859-15', 'en', ''),
 370      'en-utf-8'          => array('en|english',  'english-utf-8', 'en', ''),
 371      'es-iso-8859-1'     => array('es|spanish', 'spanish-iso-8859-1', 'es', 'Espa&ntilde;ol'),
 372      'es-iso-8859-15'    => array('es|spanish', 'spanish-iso-8859-15', 'es', 'Espa&ntilde;ol'),
 373      'es-utf-8'          => array('es|spanish', 'spanish-utf-8', 'es', 'Espa&ntilde;ol'),
 374      'et-iso-8859-1'     => array('et|estonian', 'estonian-iso-8859-1', 'et', 'Eesti'),
 375      'et-utf-8'          => array('et|estonian', 'estonian-utf-8', 'et', 'Eesti'),
 376      'eu-iso-8859-1'     => array('eu|basque', 'basque-iso-8859-1', 'eu', 'Euskara'),
 377      'eu-utf-8'          => array('eu|basque', 'basque-utf-8', 'eu', 'Euskara'),
 378      'fa-win1256'        => array('fa|persian', 'persian-windows-1256', 'fa', '&#1601;&#1575;&#1585;&#1587;&#1740;'),
 379      'fa-utf-8'          => array('fa|persian', 'persian-utf-8', 'fa', '&#1601;&#1575;&#1585;&#1587;&#1740;'),
 380      'fi-iso-8859-1'     => array('fi|finnish', 'finnish-iso-8859-1', 'fi', 'Suomi'),
 381      'fi-iso-8859-15'    => array('fi|finnish', 'finnish-iso-8859-15', 'fi', 'Suomi'),
 382      'fi-utf-8'          => array('fi|finnish', 'finnish-utf-8', 'fi', 'Suomi'),
 383      'fr-iso-8859-1'     => array('fr|french', 'french-iso-8859-1', 'fr', 'Fran&ccedil;ais'),
 384      'fr-iso-8859-15'    => array('fr|french', 'french-iso-8859-15', 'fr', 'Fran&ccedil;ais'),
 385      'fr-utf-8'          => array('fr|french', 'french-utf-8', 'fr', 'Fran&ccedil;ais'),
 386      'gl-iso-8859-1'     => array('gl|galician', 'galician-iso-8859-1', 'gl', 'Galego'),
 387      'gl-utf-8'          => array('gl|galician', 'galician-utf-8', 'gl', 'Galego'),
 388      'he-iso-8859-8-i'   => array('he|hebrew', 'hebrew-iso-8859-8-i', 'he', '&#1506;&#1489;&#1512;&#1497;&#1514;'),
 389      'he-utf-8'          => array('he|hebrew', 'hebrew-utf-8', 'he', '&#1506;&#1489;&#1512;&#1497;&#1514;'),
 390      'hi-utf-8'          => array('hi|hindi', 'hindi-utf-8', 'hi', '&#2361;&#2367;&#2344;&#2381;&#2342;&#2368;'),
 391      'hr-win1250'        => array('hr|croatian', 'croatian-windows-1250', 'hr', 'Hrvatski'),
 392      'hr-iso-8859-2'     => array('hr|croatian', 'croatian-iso-8859-2', 'hr', 'Hrvatski'),
 393      'hr-utf-8'          => array('hr|croatian', 'croatian-utf-8', 'hr', 'Hrvatski'),
 394      'hu-iso-8859-2'     => array('hu|hungarian', 'hungarian-iso-8859-2', 'hu', 'Magyar'),
 395      'hu-utf-8'          => array('hu|hungarian', 'hungarian-utf-8', 'hu', 'Magyar'),
 396      'id-iso-8859-1'     => array('id|indonesian', 'indonesian-iso-8859-1', 'id', 'Bahasa Indonesia'),
 397      'id-utf-8'          => array('id|indonesian', 'indonesian-utf-8', 'id', 'Bahasa Indonesia'),
 398      'it-iso-8859-1'     => array('it|italian', 'italian-iso-8859-1', 'it', 'Italiano'),
 399      'it-iso-8859-15'    => array('it|italian', 'italian-iso-8859-15', 'it', 'Italiano'),
 400      'it-utf-8'          => array('it|italian', 'italian-utf-8', 'it', 'Italiano'),
 401      'ja-euc'            => array('ja|japanese', 'japanese-euc', 'ja', '&#26085;&#26412;&#35486;'),
 402      'ja-sjis'           => array('ja|japanese', 'japanese-sjis', 'ja', '&#26085;&#26412;&#35486;'),
 403      'ja-utf-8'          => array('ja|japanese', 'japanese-utf-8', 'ja', '&#26085;&#26412;&#35486;'),
 404      'ko-euc-kr'         => array('ko|korean', 'korean-euc-kr', 'ko', '&#54620;&#44397;&#50612;'),
 405      'ko-utf-8'          => array('ko|korean', 'korean-utf-8', 'ko', '&#54620;&#44397;&#50612;'),
 406      'ka-utf-8'          => array('ka|georgian', 'georgian-utf-8', 'ka', '&#4325;&#4304;&#4320;&#4311;&#4323;&#4314;&#4312;'),
 407      'lt-win1257'        => array('lt|lithuanian', 'lithuanian-windows-1257', 'lt', 'Lietuvi&#371;'),
 408      'lt-utf-8'          => array('lt|lithuanian', 'lithuanian-utf-8', 'lt', 'Lietuvi&#371;'),
 409      'lv-win1257'        => array('lv|latvian', 'latvian-windows-1257', 'lv', 'Latvie&scaron;u'),
 410      'lv-utf-8'          => array('lv|latvian', 'latvian-utf-8', 'lv', 'Latvie&scaron;u'),
 411      'mn-utf-8'          => array('mn|mongolian', 'mongolian-utf-8', 'mn', '&#1052;&#1086;&#1085;&#1075;&#1086;&#1083;'),
 412      'ms-iso-8859-1'     => array('ms|malay', 'malay-iso-8859-1', 'ms', 'Bahasa Melayu'),
 413      'ms-utf-8'          => array('ms|malay', 'malay-utf-8', 'ms', 'Bahasa Melayu'),
 414      'nl-iso-8859-1'     => array('nl|dutch', 'dutch-iso-8859-1', 'nl', 'Nederlands'),
 415      'nl-iso-8859-15'    => array('nl|dutch', 'dutch-iso-8859-15', 'nl', 'Nederlands'),
 416      'nl-utf-8'          => array('nl|dutch', 'dutch-utf-8', 'nl', 'Nederlands'),
 417      'no-iso-8859-1'     => array('no|norwegian', 'norwegian-iso-8859-1', 'no', 'Norsk'),
 418      'no-utf-8'          => array('no|norwegian', 'norwegian-utf-8', 'no', 'Norsk'),
 419      'pl-iso-8859-2'     => array('pl|polish', 'polish-iso-8859-2', 'pl', 'Polski'),
 420      'pl-win1250'        => array('pl|polish', 'polish-windows-1250', 'pl', 'Polski'),
 421      'pl-utf-8'          => array('pl|polish', 'polish-utf-8', 'pl', 'Polski'),
 422      'ptbr-iso-8859-1'   => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese-iso-8859-1', 'pt-BR', 'Portugu&ecirc;s'),
 423      'ptbr-utf-8'        => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese-utf-8', 'pt-BR', 'Portugu&ecirc;s'),
 424      'pt-iso-8859-1'     => array('pt|portuguese', 'portuguese-iso-8859-1', 'pt', 'Portugu&ecirc;s'),
 425      'pt-iso-8859-15'    => array('pt|portuguese', 'portuguese-iso-8859-15', 'pt', 'Portugu&ecirc;s'),
 426      'pt-utf-8'          => array('pt|portuguese', 'portuguese-utf-8', 'pt', 'Portugu&ecirc;s'),
 427      'ro-iso-8859-1'     => array('ro|romanian', 'romanian-iso-8859-1', 'ro', 'Rom&acirc;n&#259;'),
 428      'ro-utf-8'          => array('ro|romanian', 'romanian-utf-8', 'ro', 'Rom&acirc;n&#259;'),
 429      'ru-win1251'        => array('ru|russian', 'russian-windows-1251', 'ru', '&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;'),
 430      'ru-cp-866'         => array('ru|russian', 'russian-cp-866', 'ru', '&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;'),
 431      'ru-koi8-r'         => array('ru|russian', 'russian-koi8-r', 'ru', '&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;'),
 432      'ru-utf-8'          => array('ru|russian', 'russian-utf-8', 'ru', '&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;'),
 433      'sk-iso-8859-2'     => array('sk|slovak', 'slovak-iso-8859-2', 'sk', 'Sloven&#269;ina'),
 434      'sk-win1250'        => array('sk|slovak', 'slovak-windows-1250', 'sk', 'Sloven&#269;ina'),
 435      'sk-utf-8'          => array('sk|slovak', 'slovak-utf-8', 'sk', 'Sloven&#269;ina'),
 436      'sl-iso-8859-2'     => array('sl|slovenian', 'slovenian-iso-8859-2', 'sl', 'Sloven&scaron;&#269;ina'),
 437      'sl-win1250'        => array('sl|slovenian', 'slovenian-windows-1250', 'sl', 'Sloven&scaron;&#269;ina'),
 438      'sl-utf-8'          => array('sl|slovenian', 'slovenian-utf-8', 'sl', 'Sloven&scaron;&#269;ina'),
 439      'sq-iso-8859-1'     => array('sq|albanian', 'albanian-iso-8859-1', 'sq', 'Shqip'),
 440      'sq-utf-8'          => array('sq|albanian', 'albanian-utf-8', 'sq', 'Shqip'),
 441      'srlat-win1250'     => array('sr[-_]lat|serbian latin', 'serbian_latin-windows-1250', 'sr-lat', 'Srpski'),
 442      'srlat-utf-8'       => array('sr[-_]lat|serbian latin', 'serbian_latin-utf-8', 'sr-lat', 'Srpski'),
 443      'srcyr-win1251'     => array('sr|serbian', 'serbian_cyrillic-windows-1251', 'sr', '&#1057;&#1088;&#1087;&#1089;&#1082;&#1080;'),
 444      'srcyr-utf-8'       => array('sr|serbian', 'serbian_cyrillic-utf-8', 'sr', '&#1057;&#1088;&#1087;&#1089;&#1082;&#1080;'),
 445      'sv-iso-8859-1'     => array('sv|swedish', 'swedish-iso-8859-1', 'sv', 'Svenska'),
 446      'sv-utf-8'          => array('sv|swedish', 'swedish-utf-8', 'sv', 'Svenska'),
 447      'th-tis-620'        => array('th|thai', 'thai-tis-620', 'th', '&#3616;&#3634;&#3625;&#3634;&#3652;&#3607;&#3618;'),
 448      'th-utf-8'          => array('th|thai', 'thai-utf-8', 'th', '&#3616;&#3634;&#3625;&#3634;&#3652;&#3607;&#3618;'),
 449      'tr-iso-8859-9'     => array('tr|turkish', 'turkish-iso-8859-9', 'tr', 'T&uuml;rk&ccedil;e'),
 450      'tr-utf-8'          => array('tr|turkish', 'turkish-utf-8', 'tr', 'T&uuml;rk&ccedil;e'),
 451      'tt-iso-8859-9'     => array('tt|tatarish', 'tatarish-iso-8859-9', 'tt', 'Tatar&ccedil;a'),
 452      'tt-utf-8'          => array('tt|tatarish', 'tatarish-utf-8', 'tt', 'Tatar&ccedil;a'),
 453      'uk-win1251'        => array('uk|ukrainian', 'ukrainian-windows-1251', 'uk', '&#1059;&#1082;&#1088;&#1072;&#1111;&#1085;&#1089;&#1100;&#1082;&#1072;'),
 454      'uk-utf-8'          => array('uk|ukrainian', 'ukrainian-utf-8', 'uk', '&#1059;&#1082;&#1088;&#1072;&#1111;&#1085;&#1089;&#1100;&#1082;&#1072;'),
 455      'zhtw-big5'         => array('zhtw|chinese traditional', 'chinese_traditional-big5', 'zh-TW', '&#20013;&#25991;'),
 456      'zhtw-utf-8'        => array('zhtw|chinese traditional', 'chinese_traditional-utf-8', 'zh-TW', '&#20013;&#25991;'),
 457      'zh-gb2312'         => array('zh|chinese simplified', 'chinese_simplified-gb2312', 'zh', '&#20013;&#25991;'),
 458      'zh-utf-8'          => array('zh|chinese simplified', 'chinese_simplified-utf-8', 'zh', '&#20013;&#25991;'),
 459  );
 460  
 461  function _dbQuery($query='', $_queryMode='ASSOC') {
 462  
 463      if(empty($query)) return false;
 464      
 465      global $db;
 466      $queryResult    = array();
 467      $queryCount        = 0;
 468      
 469      if($result = @mysql_query($query, $db)) {
 470      
 471          switch($_queryMode) {
 472  
 473              // INSERT, UPDATE, DELETE
 474              case 'INSERT':    $queryResult['INSERT_ID']        = mysql_insert_id($db);
 475              case 'DELETE':    
 476              case 'UPDATE':    
 477                              $queryResult['AFFECTED_ROWS']    = mysql_affected_rows($db);
 478                              return $queryResult;
 479                              break;
 480  
 481              // SELECT Queries    
 482              case 'ROW':        $_queryMode = 'mysql_fetch_row';    break;
 483              case 'ARRAY':    $_queryMode = 'mysql_fetch_array';    break;
 484              default:         $_queryMode = 'mysql_fetch_assoc';
 485      
 486          }
 487      
 488          while($row = $_queryMode($result)) {
 489              
 490              $queryResult[$queryCount] = $row;
 491              $queryCount++;
 492  
 493          }
 494          mysql_free_result($result);
 495      
 496          return $queryResult;
 497      
 498      } else {
 499          return false;
 500      }
 501  }
 502  
 503  if(!function_exists('decode_entities')) {
 504  	function decode_entities($string) {
 505          // replace numeric entities
 506          $string = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $string);
 507          $string = preg_replace('~&#([0-9]+);~e', 'chr(\\1)', $string);
 508          // replace literal entities
 509          $trans_tbl = get_html_translation_table(HTML_ENTITIES);
 510          $trans_tbl = array_flip($trans_tbl);
 511          return strtr($string, $trans_tbl);
 512      }
 513  }
 514  
 515  ?>


Generated: Sun Jan 29 16:31:14 2012 Cross-referenced by PHPXref 0.7.1