"AZ-WEB.CZ","ownerLogo" => "azweb","ownerLink" => "http://www.az-web.cz","adminskin"=>"edacms","CMSname"=>"EDACMS"); //$_EDACMS['Licence'] = array ("ownerName" => "Machin.cz","ownerLogo" => "machin","ownerLink" => "http://www.machin.cz","adminskin"=>"edacms","CMSname"=>"EDACMS"); $_EDACMS['Licence'] = array ("ownerName" => "E.D.A. webdesign","ownerLogo" => "eda","ownerLink" => "http://www.e-d-a.info","adminskin"=>"edacms","CMSname"=>"EDACMS"); //$_EDACMS['Licence'] = array ("ownerName" => "ImperialMedia s.r.o.","ownerLogo" => "netpresence","ownerLink" => "http://www.imperialmedia.cz","adminskin"=>"netpresence","CMSname"=>"NET.presence"); //$_EDACMS['Licence'] = array ("ownerName" => "ImperialMedia s.r.o.","ownerLogo" => "netmarket","ownerLink" => "http://www.imperialmedia.cz","adminskin"=>"netmarket","CMSname"=>"NET.market"); //mysql_settings $_EDACMS['mysql_server'] = "localhost"; $_EDACMS['mysql_dbname'] = "rssemily_sixpastels"; $_EDACMS['mysql_login'] = "sixpastels"; $_EDACMS['mysql_password'] = "etydyvuha"; //ftp settings $_EDACMS['ftp_root_server'] = "sixpastels.cz"; $_EDACMS['ftp_root_dir'] = ""; //example $_EDACMS['ftp_root_dir'] = "/html/" - slashes must be at start and at end as well !!; $_EDACMS['ftp_user_login'] = "sixpastels"; $_EDACMS['ftp_user_pwd'] = "cedecko"; /* others */ $_EDACMS['web_selected_skin']="sixpastels"; /******************/ /* modules loader */ /******************/ $ObjLib[]="cachepage"; // zakladni moduly ------------------------------------------------------------- $ObjLib[]="_fragments2";//KNIHOVNA $ObjLib[]="web"; //STRÁNKY $ObjLib[]="forms"; //FORMULÁŘE $ObjLib[]="news"; //AKTUALITY $ObjLib[]="fgal"; //FOTOGALERIE //eshop system ----------------------------------------------------------------- //$ObjLib[]="eshop"; //ESHOP //$ObjLib[]="eshopxml"; //ESHOP generovani XMS pro //extra modules ---------------------------------------------------------------- //$ObjLib[]="dateutils"; //$ObjLib[]="actionscalendar"; //$ObjLib[]="actioncalendar2"; //$ObjLib[]="urednideska"; //$ObjLib[]="phorum"; //$ObjLib[]="phorum2"; //$ObjLib[]="_intercom"; //$ObjLib[]="_internalmails"; //$ObjLib[]="randombg"; //$ObjLib[]="poll"; //$ObjLib[]="rssagregator"; //$ObjLib[]="odkazy"; //$ObjLib[]="seolista"; $ObjLib[]="seolistaclient"; //$ObjLib[]="seokeywords"; //$ObjLib[]="_googlesitemap"; //$ObjLib[]="flir"; //$ObjLib[]="emailnews"; //individual modules ----------------------------------------------------------- //$ObjLib[]="adresar"; //$ObjLib[]="soupiska"; //$ObjLib[]="fotbal_ptable"; //$ObjLib[]="sportmatches"; //$ObjLib[]="dbviewer"; //$ObjLib[]="dbviewer/ngcatalogue"; //$ObjLib[]="dbviewer/vernostniprog"; //$ObjLib[]="dbviewer\byty"; //$ObjLib[]="dbviewer\carpmania"; //$ObjLib[]="dbviewer\granitrade"; //$ObjLib[]="inzerce"; //$ObjLib[]="inzerce2"; //$ObjLib[]="extramods/imperialmedia"; //deprecated or experimental modules ------------------------------------------- //$ObjLib[]="mininews"; //$ObjLib[]="catalogue"; //$ObjLib[]="banery"; //$ObjLib[]="jquerymenu"; //$ObjLib[]="jquerydroppy"; //$ObjLib[]="autokeywords"; //$ObjLib[]="niceforms"; //$ObjLib[]="contentcss";$_EDACMS['ccss_style'] = 'default'; //default modules ------------------------------------------------------------- //$ObjLib[]="jquery/shadow"; //$ObjLib[]="jquery/dropdownmenu"; //$ObjLib[]="_ru_logtopage"; $ObjLib[]="_help"; $ObjLib[]="useradmin"; $ObjLib[]="_settings"; $ObjLib[]="_printcontent"; $ObjLib[]="_recomendsite"; $ObjLib[]="jupload"; $ObjLib[]="search2"; //$ObjLib[]="shadowbox"; //$ObjLib[]="shadowbox3b"; //$ObjLib[]="_editonthefly"; //$ObjLib[]="webmap"; //$ObjLib[]="_externalcode"; $ObjLib[]="_contentprotector"; //$ObjLib[]="_contentrelations"; //new! 9.4. //$ObjLib[]="programming/geshi"; //$ObjLib[]="_registeredusers"; //$ObjLib[]="tagcloud"; $ObjLib[]="jquery/jmp3"; //------------------------------------------------------------------------------ /* other settings */ $_EDACMS['web_index_file']=""; $_EDACMS['webhosting_not_mysql_is_old']=false; $_EDACMS['web_pagebrowser']=false; $_EDACMS['client_browser_lang_detect']=true; /* menu params */ $_EDACMS['web_generate_submenu_recursive']=false; //recursive generation submenu $_EDACMS['web_generate_menu_recursive']=false; //recursive generation submenu $_EDACMS['web_pages_show_childs_as_links']=true; //show or hide chid links of subsubmenu $_EDACMS['web_expand_submenu_level'] = 0; //how much levels will be direct opened if menu is recursive $_EDACMS['web_expand_mainmenu_level'] = 0; //how much levels will be direct opened if menu is recursive $_EDACMS['web_max_submenu_opened_menu_level_to_display'] = 3;//how much levels can be opened if menu is recursive $_EDACMS['web_show_annotation_at_custom_possition_in_template']=false; //TRUE = show annotation in custom position in template / or FALSE = direct in content $_EDACMS['web_new_template_tags_in_use'] = true; //tags {ActivePageHtml} - page content, {ActivePageAnnotation} - annotation, {ActivePageTitle} - title $_EDACMS['edacms_html_editors'] = array( "tinymce" => array("path"=>"mod/tinymce/","class"=>'tinymce.class.php'), //"tinymce2" => array("path"=>"mod/htmlEditors/tinymce2/","class"=>'tinymce2.class.php'), //"fckeditor" => array("path"=>"mod/htmlEditors/fckeditor/","class"=>'fckeditor.class.php') //"texyla" => array("path"=>"mod/htmlEditors/texyla/","class"=>'texyla.class.php') ); /* image display interfaces (can be set in settings module) possible values */ //$_EDACMS['fr_images_display_mode_interface'] = 'mod/_fragments2/plugins/cycler/cycler.php'; //$_EDACMS['fr_images_display_mode_interface'] = 'mod/_fragments2/plugins/slider/slider.php'; //$_EDACMS['fr_images_display_mode_interface'] = 'mod/_fragments2/plugins/cross-slide/cross-slide.php'; ?> array("path"=>"mod/tinymce/","class"=>'tinymce.class.php'), //"tinymce2" => array("path"=>"mod/htmlEditors/tinymce2/","class"=>'tinymce2.class.php'), //"fckeditor" => array("path"=>"mod/htmlEditors/fckeditor/","class"=>'fckeditor.class.php') //"texyla" => array("path"=>"mod/htmlEditors/texyla/","class"=>'texyla.class.php') ); } $_EDACMS['admin_startup_log_enabled'] = false; $_EDACMS['plugin_startup_log_enabled'] = false; $_EDACMS['save_system_benchmark']=false; $_EDACMS['system_benchmark_log']=false; $_EDACMS['render_submenu_in_skin']=true; //True = system will render submenu in SKIN template, False = system will render submenu in WEB module template $_EDACMS['web_show_images_of_pageChilds'] = true; /* standard settings */ $_EDACMS['edacms_root_dir']=""; //leave "" if system is not installed in subdir (example "edacms/") $_EDACMS['template_extension']=".htm"; //default template extension $_EDACMS['mod_path'] = "mod/"; //module directory $_EDACMS['sys_path'] = ""; //root path - empty : relative $_EDACMS['main_file'] = "admin.php"; //system admin file $_EDACMS['adminlang'] = "cs"; //administration engile language /* system language */ $_EDACMS['lang'] = "cz"; //default language $_EDACMS['lang_default'] = "cz"; //system will use this if other lang files not found $_EDACMS['web_lang']="cs"; /* initialize admin system */ $_EDACMS['content'] = ""; //initialise content $_EDACMS['main_menu'] = ""; //initialise main menu $_EDACMS['sub_menu'] = ""; //initialise sub menu $_EDACMS['logs_dir'] = "mod/_logs/"; /* skin library property */ /* $_EDACMS['skin_library']=array ( 0=>array('skindir'=>'ubytovaniznojmo','skinname'=>'Kontrastn schma'), 1=>array('skindir'=>'ubytovaniznojmo2','skinname'=>'Monochromat schma') ); */ $_EDACMS['web_skindir']="skins/".$_EDACMS['web_selected_skin']."/"; /* users initialize */ $_EDACMS['users_table']="T_Users"; $_EDACMS['users_in_groups_table']="T_UsersInGroups"; $_EDACMS['user_permissions_table']="T_UserPermissions"; $_EDACMS['user_groups_table']="T_UserGroups"; $_EDACMS['tbl_settings']="T_GlobalSettings"; $_EDACMS['edacms_block_adminsection'] = false; $_EDACMS['edacms_use_cache'] = false; $_EDACMS['edacms_use_cache_option'] = array ( 'automaticSerialization' => 1, 'automaticCleaningFactor' => 1, 'lifeTime' => 60*5, //5 minutes 'cacheDir' => 'modfiles/cachedpages/', 'fileLocking' => true, 'fileNameProtection' => false ); //--------------------------------------- COMPLETE LIST OF MODULES /for information/ //--$ObjLib[]="_fragments2"; //--$ObjLib[]="_internalmails"; //--$ObjLib[]="web"; //--$ObjLib[]="forms"; //--$ObjLib[]="eshop"; //--$ObjLib[]="catalogue"; //--$ObjLib[]="emailnews"; //--$ObjLib[]="unishop"; (deprecated) //--$ObjLib[]="news"; //--$ObjLib[]="fgal"; //--$ObjLib[]="gbook"; (deprecated) //--$ObjLib[]="shop"; (deprecated) //--$ObjLib[]="wowraidassist"; //--$ObjLib[]="webmap"; //--$ObjLib[]="adresar"; //--$ObjLib[]="dvdpujcovna"; //--$ObjLib[]="mininews"; //--$ObjLib[]="banner"; //--$ObjLib[]="banery"; //--$ObjLib[]="seokeywords"; //--$ObjLib[]="search"; (deprecated) //--$ObjLib[]="spamcounter"; //--$ObjLib[]="ajax"; //--$ObjLib[]="dateutils"; //--$ObjLib[]="actionscalendar"; //--$ObjLib[]="actioncalendar2"; //--$ObjLib[]="thickbox"; //--$ObjLib[]="swfir"; /\ * * * * * image replacement * * * * * /\ //--$ObjLib[]="soupiska"; //--$ObjLib[]="fotbal_ptable"; //--$ObjLib[]="workagency"; //--$ObjLib[]="workagency2"; //--$ObjLib[]="_printcontent"; //--$ObjLib[]="_pdfcontent"; //--$ObjLib[]="_recomendsite"; //--$ObjLib[]="_externalcode"; //--$ObjLib[]="autokeywords"; (deprecated) //--$ObjLib[]="urednideska"; //--$ObjLib[]="phorum"; //--$ObjLib[]="_registeredusers"; //--$ObjLib[]="randombg"; //--$ObjLib[]="search2"; //--$ObjLib[]="poll"; //--$ObjLib[]="_intercom"; //--$ObjLib[]="_editonthefly"; //--$ObjLib[]="coolbuttons"; (deprecated) //--$ObjLib[]="seofrazes"; //--$ObjLib[]="jquerymenu"; //--$ObjLib[]="useradmin"; //--$ObjLib[]="_googlesitemap"; //--$ObjLib[]="_contentprotector"; //--$ObjLib[]="jupload"; //--$ObjLib[]="rssagregator"; //--$ObjLib[]="sportmatches"; //--$ObjLib[]="_settings"; ?>"; /* block end delimiter */ var $block_start_word="BEGIN:"; /* block start word */ var $block_end_word="END:"; /* block end word */ /* this makes the delimiters look like: if you use my syntax. */ var $NULL_STRING=array(""=>""); /* null string for unassigned vars */ var $NULL_BLOCK=array(""=>""); /* null string for unassigned blocks */ var $mainblock=""; var $ERROR=""; var $AUTORESET=1; /* auto-reset sub blocks */ var $startTime=0; var $parsedFile = ''; /***[ constructor ]*********************************************************/ // eda changed - 11.7.2005 - removed needed file parameter (for possibility to parse html from DB) function XTemplate ($file="",$mainblock="main") { //$this -> startTime = GetMicrotime(); //$this -> parsedFile = $file; $this->mainblock=$mainblock; $this->filecontents=$this->r_getfile($file); $this->blocks=$this->maketree($this->filecontents,$mainblock); /* preprocess some stuff */ } /***************************************************************************/ /***[ public stuff ]********************************************************/ /***************************************************************************/ function getMultypleTagParams($tag,$tpl = '',$level = 0) { if ($tpl=='') {$tpl = $this->filecontents;} if($sp = strpos($tpl,"{".$tag)) { $ep = strpos($tpl,"}",$sp); $tagName = substr($tpl,$sp+1,$ep-$sp-1); $tagParams = substr($tagName,strlen($tag)+1,strlen($tagName)-strlen($tag)+1); $tagParams = explode("_",$tagParams); $result_arr = $this -> getMultypleTagParams($tag,substr($tpl,$sp+1,strlen($tpl)-1-($sp+1)),$level+1); $result_arr[] = array( 'tagName' => $tagName, 'tagParams' => $tagParams ); return $result_arr; } return false; } function getTagParams($t) { if($sp = strpos($this->filecontents,"{".$t)) { $ep = strpos($this->filecontents,"}",$sp); //$tagName = substr($this->filecontents,$sp,$ep-$sp+1); $tagName = substr($this->filecontents,$sp+1,$ep-$sp-1); $tagParams = substr($tagName,strlen($t)+1,strlen($tagName)-strlen($t)+1); $tagParams = explode("_",$tagParams); $result_arr = array( 'tagName' => $tagName, 'tagParams' => $tagParams ); return $result_arr; } else { return false; } } function translateBy($trans_arr,$prefix='tit_') { if (count($trans_arr)>0) { foreach($trans_arr as $fld => $val) { $this->VARS[$prefix.$fld]=$val; } } } function isSetTag($t) { if(strpos($this->filecontents,"{".$t."}")) { return true; } else { return false; } } /***[ assign ]**************************************************************/ /* assign a variable */ function assign ($name,$val="") { if (gettype($name)=="array") while (list($k,$v)=each($name)) $this->VARS[$k]=$v; else $this->VARS[$name]=$val; } /***[ parse ]***************************************************************/ /* parse a block */ function parse ($bname) { $copy=$this->blocks[$bname]; if (!isset($this->blocks[$bname])) $this->set_error ("parse: blockname [$bname] does not exist"); preg_match_all("/\{([A-Za-z0-9\._]+?)}/",$this->blocks[$bname],$var_array); $var_array=$var_array[1]; while (list($k,$v)=each($var_array)) { $sub=explode(".",$v); if ($sub[0]=="_BLOCK_") { unset($sub[0]); $bname2=implode(".",$sub); $var=$this->parsed_blocks[$bname2]; $nul=(!isset($this->NULL_BLOCK[$bname2])) ? $this->NULL_BLOCK[""] : $this->NULL_BLOCK[$bname2]; $var=(empty($var))?$nul:trim($var); $copy=preg_replace("/\{".$v."\}/","$var",$copy); } else { $var=$this->VARS; while(list($k1,$v1)=each($sub)) $var=$var[$v1]; $nul=(!isset($this->NULL_STRING[$v])) ? ($this->NULL_STRING[""]) : ($this->NULL_STRING[$v]); $var=(!isset($var))?$nul:$var; $copy=preg_replace("/\{$v\}/","$var",$copy); } } $this->parsed_blocks[$bname].=$copy; // reset sub-blocks if ($this->AUTORESET && (!empty($this->sub_blocks[$bname]))) { reset($this->sub_blocks[$bname]); while (list($k,$v)=each($this->sub_blocks[$bname])) $this->reset($v); } } /***[ rparse ]**************************************************************/ /* returns the parsed text for a block, including all sub-blocks. */ function rparse($bname) { if (!empty($this->sub_blocks[$bname])) { reset($this->sub_blocks[$bname]); while (list($k,$v)=each($this->sub_blocks[$bname])) if (!empty($v)) $this->rparse($v,$indent."\t"); } $this->parse($bname); } /***[ insert_loop ]*********************************************************/ /* inserts a loop ( call assign & parse ) */ function insert_loop($bname,$var,$value="") { $this->assign($var,$value); $this->parse($bname); } /***[ text ]****************************************************************/ /* returns the parsed text for a block */ function text($bname) { //echo "
|".$this -> parsedFile."#".number_format((GetMicrotime() - ($this -> startTime)),2,',',' ') ."s|"; return $this->parsed_blocks[isset($bname) ? $bname :$this->mainblock]; } /***[ out ]*****************************************************************/ /* prints the parsed text */ function out ($bname) { echo $this->text($bname); } /***[ reset ]***************************************************************/ /* resets the parsed text */ function reset ($bname) { $this->parsed_blocks[$bname]=""; } /***[ parsed ]**************************************************************/ /* returns true if block was parsed, false if not */ function parsed ($bname) { return (!empty($this->parsed_blocks[$bname])); } /***[ SetNullString ]*******************************************************/ /* sets the string to replace in case the var was not assigned */ function SetNullString($str,$varname="") { $this->NULL_STRING[$varname]=$str; } /***[ SetNullBlock ]********************************************************/ /* sets the string to replace in case the block was not parsed */ function SetNullBlock($str,$bname="") { $this->NULL_BLOCK[$bname]=$str; } /***[ set_autoreset ]*******************************************************/ /* sets AUTORESET to 1. (default is 1) if set to 1, parse() automatically resets the parsed blocks' sub blocks (for multiple level blocks) */ function set_autoreset() { $this->AUTORESET=1; } /***[ clear_autoreset ]*****************************************************/ /* sets AUTORESET to 0. (default is 1) if set to 1, parse() automatically resets the parsed blocks' sub blocks (for multiple level blocks) */ function clear_autoreset() { $this->AUTORESET=0; } /***[ scan_globals ]********************************************************/ /* scans global variables */ function scan_globals() { reset($GLOBALS); while (list($k,$v)=each($GLOBALS)) $GLOB[$k]=$v; $this->assign("PHP",$GLOB); /* access global variables as {PHP.HTTP_HOST} in your template! */ } /****** WARNING PUBLIC FUNCTIONS BELOW THIS LINE DIDN'T GET TESTED ******/ /***************************************************************************/ /***[ private stuff ]*******************************************************/ /***************************************************************************/ /***[ maketree ]************************************************************/ /* generates the array containing to-be-parsed stuff: $blocks["main"],$blocks["main.table"],$blocks["main.table.row"], etc. also builds the reverse parse order. */ function maketree($con,$block) { $con2=explode($this->block_start_delim,$con); $level=0; $block_names=array(); $blocks=array(); reset($con2); while(list($k,$v)=each($con2)) { $patt="($this->block_start_word|$this->block_end_word)\s*(\w+)\s*$this->block_end_delim(.*)"; if (preg_match_all("/$patt/ims",$v,$res, PREG_SET_ORDER)) { // $res[0][1] = BEGIN or END // $res[0][2] = block name // $res[0][3] = kinda content if ($res[0][1]==$this->block_start_word) { $parent_name=implode(".",$block_names); $block_names[++$level]=$res[0][2]; /* add one level - array("main","table","row")*/ $cur_block_name=implode(".",$block_names); /* make block name (main.table.row) */ $this->block_parse_order[]=$cur_block_name; /* build block parsing order (reverse) */ $blocks[$cur_block_name].=$res[0][3]; /* add contents */ $blocks[$parent_name].="{_BLOCK_.$cur_block_name}"; /* add {_BLOCK_.blockname} string to parent block */ $this->sub_blocks[$parent_name][]=$cur_block_name; /* store sub block names for autoresetting and recursive parsing */ $this->sub_blocks[$cur_block_name][]=""; /* store sub block names for autoresetting */ } else if ($res[0][1]==$this->block_end_word) { unset($block_names[$level--]); $parent_name=implode(".",$block_names); $blocks[$parent_name].=$res[0][3]; /* add rest of block to parent block */ } } else { /* no block delimiters found */ $blocks[implode(".",$block_names)].=$this->block_start_delim.$v; } } return $blocks; } /***[ error stuff ]*********************************************************/ /* sets and gets error */ function get_error() { return ($this->ERROR=="")?0:$this->ERROR; } function set_error($str) { $this->ERROR=$str; } /***[ getfile ]*************************************************************/ /* returns the contents of a file */ function getfile($file) { if (!isset($file)) { $this->set_error("!isset file name!"); return ""; } if (is_file($file)) { if (!($fh=fopen($file,"r"))) { $this->set_error("Cannot open file: $file"); return ""; } $file_text=fread($fh,filesize($file)); fclose($fh); } else { $this->set_error("[$file] does not exist"); $file_text="__XTemplate fatal error: file [$file] does not exist__"; } return $file_text; } /***[ r_getfile ]***********************************************************/ /* recursively gets the content of a file with {FILE "filename.tpl"} directives */ function r_getfile($file) { $text=$this->getfile($file); while (preg_match($this->file_delim,$text,$res)) { $text2=$this->getfile($res[1]); $text=preg_replace("'".preg_quote($res[0])."'",$text2,$text); } return $text; } } /* end of XTemplate class. */ ?>loadCharset(CP1252); Then call $res = $utfConverter->strToUtf8($str); or $res = $utfConverter->utf8ToStr($utf); to get the needed encoding. --------------------------------------------------------------------------------- Note: Rewrite or Override the onError method if needed. It's the error handler used from everywhere and takes 2 parameters: err_code and err_text. By default it just prints out a message about the error. */ //Charset maps define("MAP_DIR","mod/_systemclasses/utf8/"); define("CP1250",MAP_DIR . "CP1250.MAP"); define("CP1251",MAP_DIR . "CP1251.MAP"); define("CP1252",MAP_DIR . "CP1252.MAP"); define("CP1253",MAP_DIR . "CP1253.MAP"); define("CP1254",MAP_DIR . "CP1254.MAP"); define("CP1255",MAP_DIR . "CP1255.MAP"); define("CP1256",MAP_DIR . "CP1256.MAP"); define("CP1257",MAP_DIR . "CP1257.MAP"); define("CP1258",MAP_DIR . "CP1258.MAP"); define("CP874", MAP_DIR . "CP874.MAP"); define("CP932", MAP_DIR . "CP932.MAP"); define("CP936", MAP_DIR . "CP936.MAP"); define("CP949", MAP_DIR . "CP949.MAP"); define("CP950", MAP_DIR . "CP950.MAP"); //Error constants define("ERR_OPEN_MAP_FILE","ERR_OPEN_MAP_FILE"); //Class definition Class utf8{ var $html=""; var $charset = CP1250; var $ascMap = array(); var $utfMap = array(); var $work_dir = ''; //Constructor function utf8($charset=CP1250,$workdir=''){ $this -> work_dir = $workdir; $this -> loadCharset($charset); } //Load charset function loadCharset($charset){ //$lines = file_get_contents($this -> work_dir.MAP_DIR.$charset.'.MAP'); $lines = file_get_contents($this -> work_dir.$charset) or exit($this->onError(ERR_OPEN_MAP_FILE,"Error openning file: WD:[".$this -> work_dir."] MAPDIR[".MAP_DIR."] CHARSET[".$charset."] PATH[".$this -> work_dir.$charset."]")); $this->charset = $charset; $lines = preg_replace("/#.*$/m","",$lines); $lines = preg_replace("/\n\n/","",$lines); $lines = explode("\n",$lines); foreach($lines as $line){ $parts = explode('0x',$line); if(count($parts)==3){ $asc=hexdec(substr($parts[1],0,2)); $utf=hexdec(substr($parts[2],0,4)); $this->ascMap[$charset][$asc]=$utf; } } $this->utfMap = array_flip($this->ascMap[$charset]); } //Error handler function onError($err_code,$err_text){ print($err_code . " : " . $err_text . "
\n"); } //Translate string ($str) to UTF-8 from given charset function strToUtf8($str){ $chars = unpack('C*', $str); $cnt = count($chars); for($i=1;$i<=$cnt;$i++) $this->_charToUtf8($chars[$i]); return implode("",$chars); } //Translate UTF-8 string to single byte string in the given charset function utf8ToStr($utf){ $chars = unpack('C*', $utf); $cnt = count($chars); $res = ""; //No simple way to do it in place... concatenate char by char for ($i=1;$i<=$cnt;$i++){ $res .= $this->_utf8ToChar($chars, $i); } return $res; } //Char to UTF-8 sequence function _charToUtf8(&$char){ $c = (int)$this->ascMap[$this->charset][$char]; if ($c < 0x80){ $char = chr($c); } else if($c<0x800) // 2 bytes $char = (chr(0xC0 | $c>>6) . chr(0x80 | $c & 0x3F)); else if($c<0x10000) // 3 bytes $char = (chr(0xE0 | $c>>12) . chr(0x80 | $c>>6 & 0x3F) . chr(0x80 | $c & 0x3F)); else if($c<0x200000) // 4 bytes $char = (chr(0xF0 | $c>>18) . chr(0x80 | $c>>12 & 0x3F) . chr(0x80 | $c>>6 & 0x3F) . chr(0x80 | $c & 0x3F)); } //UTF-8 sequence to single byte character function _utf8ToChar(&$chars, &$idx){ if(($chars[$idx] >= 240) && ($chars[$idx] <= 255)){ // 4 bytes $utf = (intval($chars[$idx]-240) << 18) + (intval($chars[++$idx]-128) << 12) + (intval($chars[++$idx]-128) << 6) + (intval($chars[++$idx]-128) << 0); } else if (($chars[$idx] >= 224) && ($chars[$idx] <= 239)){ // 3 bytes $utf = (intval($chars[$idx]-224) << 12) + (intval($chars[++$idx]-128) << 6) + (intval($chars[++$idx]-128) << 0); } else if (($chars[$idx] >= 192) && ($chars[$idx] <= 223)){ // 2 bytes $utf = (intval($chars[$idx]-192) << 6) + (intval($chars[++$idx]-128) << 0); } else{ // 1 byte $utf = $chars[$idx]; } if(array_key_exists($utf,$this->utfMap)) return chr($this->utfMap[$utf]); else return "?"; } } ?>