Exemplo n.º 1
0
 function iconv($in_charset, $out_charset, $str)
 {
     // Get a converter object.
     global $PHORUM;
     $cache_key = strtolower($in_charset . '->' . $out_charset);
     if (isset($PHORUM['ConvertCharsetCache'][$cache_key])) {
         $converter = $PHORUM['ConvertCharsetCache'][$cache_key];
     } else {
         $converter = new ConvertCharset($in_charset, $out_charset);
         $PHORUM['ConvertCharsetCache'][$cache_key] = $converter;
     }
     // Convert and return the string.
     return $converter->Convert($str);
 }
Exemplo n.º 2
0
 function prepStr($str)
 {
     global $CONF_use_utf, $langEncodings, $nativeLanguage;
     if (!$CONF_use_utf) {
         require_once dirname(__FILE__) . '/../ConvertCharset/ConvertCharset.class.php';
         $NewEncoding = new ConvertCharset();
         $str = $NewEncoding->Convert($str, $langEncodings[$nativeLanguage], "utf-8", $Entities);
     }
     $newStr = json::encode($str);
     if ($newStr[0] == '"') {
         return substr($newStr, 1, -1);
     } else {
         return $newStr;
     }
     // return str_replace('"','\"',$str);
 }
Exemplo n.º 3
0
 function ConvertCharset($FromCharset, $ToCharset, $TurnOnEntities = false)
 {
     $this->FromCharset = strtolower($FromCharset);
     $this->ToCharset = strtolower($ToCharset);
     $this->Entities = $TurnOnEntities;
     $this->CharsetTable = array('windows-1251' => ConvertCharset::w1251());
     $this->Flip = array_flip(ConvertCharset::w1251());
 }
Exemplo n.º 4
0
function toLatin1($str, $enc = "")
{
    if (!preg_match("/[^\\w\\.\\-\\@\\!\\#\$\\%\\^\\&\\*\\?\\[\\]\\{\\}\\.\\+\\/]/", $str)) {
        return $str;
    }
    //echo "non latin char in name<BR>";
    $orgNum = substr_count($str, "?");
    // check utf
    require_once dirname(__FILE__) . "/lib/utf8_to_ascii/utf8_to_ascii.php";
    $newString = utf8_to_ascii($str);
    $newNum = substr_count($newString, "?");
    if ($newNum <= $orgNum) {
        // no extra ? were added, this was a valid utf string
        return $newString;
    }
    global $langEncodings, $nativeLanguage;
    if ($enc == "") {
        $enc = $langEncodings[$nativeLanguage];
    }
    require_once dirname(__FILE__) . "/lib/ConvertCharset/ConvertCharset.class.php";
    $NewEncoding = new ConvertCharset();
    $str_utf8 = $NewEncoding->Convert($str, $enc, "utf-8", $Entities);
    return utf8_to_ascii($str_utf8);
}
Exemplo n.º 5
0
 function iconv($input_encoding, $output_encoding, $string)
 {
     $converter = new ConvertCharset();
     return $converter->Convert($string, $input_encoding, $output_encoding);
 }
Exemplo n.º 6
0
$lyric_text = "";
if (strcmp($par_request, 'upload_kar') == 0) {
    $file = isset($_FILES['file_kar']) && $_FILES['file_kar']['tmp_name'] != '' ? $_FILES['file_kar']['tmp_name'] : '';
    if ($file != '') {
        $par_dir = getCode();
        // skopiowanie pliku
        $path = "../wap/get/" . $par_dir;
        // TODO: sprawdzi, czy taki kod już jest w filesystemie
        if (mkdir($path) == FALSE) {
            $reason = M1K0_REASON_NO_DIR;
            $par_request = NULL;
        } else {
            copy($file, $path . "/song.midi");
            require '../scripts/midi.class.php';
            require '../scripts/ConvertCharset.class.php';
            $NewEncoding = new ConvertCharset();
            $midi = new Midi();
            $midi->importMid($file, 0);
            $track = $midi->getTrack(0);
            // list of meta events that we are interested in (adjust!)
            $texttypes = array('Text', 'Copyright', 'TrkName', 'InstrName', 'Lyric', 'Marker', 'Cue');
            $lyric = array();
            // poustawianie czasów trwania
            foreach ($track as $msgStr) {
                //print_r($msgStr);
                $msg = explode(' ', $msgStr);
                if ($msg[1] == 'Meta' && in_array($msg[2], $texttypes)) {
                    $milis = (int) ($msg[0] * $midi->getTempo() / $midi->getTimebase() / 1000);
                    $text = $NewEncoding->Convert(substr($msgStr, strpos($msgStr, '"')), "windows-1250", "utf-8");
                    $text = str_replace("_", " ", $text);
                    $text = str_replace("\n", "/", $text);
Exemplo n.º 7
0
function convertToUTF8($file, $charSet, $char_Set, $converter_dir)
{
    global $home_charset;
    $conv_file = $file;
    //  pure code
    if (stristr($charSet, "WINDOWS-31J")) {
        //
        $charSet = 'cp936';
        //  use cp936, which is equal to WINDOWS-31J
    }
    $iconv_file = @iconv($charSet, "UTF-8//IGNORE", $conv_file);
    //      if installed, first try to use PHP function iconv()
    //      IGNORE => ignore unknown characters
    //      TRANSLIT=> replace unknown characters  with something similar
    //      Attention: TRANSLIT breaks converting, if no 'close to' chararacter will be found
    //echo "\r\n\r\n<br /> iconv_file: $iconv_file<br />";
    if (trim($iconv_file) == "") {
        // iconv is not installed or input charSet not available. We need to use class ConvertCharset
        $char_Set = str_ireplace('iso-', '', $charSet);
        //$charSet = str_ireplace ('iso','',$charSet);
        $converter = "" . $converter_dir . "/charsets/" . $char_Set . ".txt";
        if (!is_file($converter)) {
            //      if this charset table is not avaulable
            $char_Set = str_ireplace('iso-', '', $home_charset);
            //      try alternatively the home charset
            printConverterError($charSet, $cl);
            printTryHome($home_charset, $cl);
        }
        if (is_file($converter) || $home_charset != 'UTF-8') {
            //  UTF-8 -> UTF-8 would not work
            $NewEncoding = new ConvertCharset($char_Set, "utf-8");
            $NewFileOutput = $NewEncoding->Convert($conv_file);
            //$NewEncoding    = new ConvertCharset;
            //$NewFileOutput  = $NewEncoding->Convert($conv_file, $chrSet, "utf-8",false);
            $file = $NewFileOutput;
        }
    } else {
        $file = $iconv_file;
    }
    unset($conv_file, $iconv_file, $NewEncoding, $NewFileOutput);
    return $file;
}
Exemplo n.º 8
0
function fillPilotInfo($pilotID, $userServerID, $userID)
{
    global $pilotNames, $CONF_use_utf;
    if (!$pilotNames[$pilotID]) {
        $pilotInfo = getPilotInfo($userID, $userServerID);
        if (!$CONF_use_utf) {
            $NewEncoding = new ConvertCharset();
            $lName = $NewEncoding->Convert($pilotInfo[0], $langEncodings[$nativeLanguage], "utf-8", $Entities);
            $fName = $NewEncoding->Convert($pilotInfo[1], $langEncodings[$nativeLanguage], "utf-8", $Entities);
        } else {
            $lName = $pilotInfo[0];
            $fName = $pilotInfo[1];
        }
        $pilotNames[$pilotID]['lname'] = $lName;
        $pilotNames[$pilotID]['fname'] = $fName;
        $pilotNames[$pilotID]['country'] = $pilotInfo[2];
        $pilotNames[$pilotID]['sex'] = $pilotInfo[3];
        $pilotNames[$pilotID]['birthdate'] = $pilotInfo[4];
        $pilotNames[$pilotID]['CIVL_ID'] = $pilotInfo[5];
        if ($pilotInfo[5] == -1) {
            $pilotNames[$pilotID]['lname'] = "ERROR:NOT IN THE DB !!!";
        }
    }
}
Exemplo n.º 9
0
function kontoudtog($id)
{
    global $db_id;
    global $printserver;
    global $db_encode;
    $r = db_fetch_array(db_select("select * from ordrer where id = '{$id}'", __FILE__ . " linje " . __LINE__));
    $k_konto_id = $r['konto_id'];
    $k_kontonr = $r['kontonr'];
    $k_firmanavn = $r['firmanavn'];
    $k_addr1 = $r['addr1'];
    $k_addr2 = $r['addr2'];
    $k_postnr = $r['postnr'];
    $k_k_bynavn = $r['bynavn'];
    $k_tlf = $r['tlf'];
    $k_cvrnr = $r['cvrnr'];
    $r = db_fetch_array(db_select("select * from grupper where art = 'POS' and kodenr = '2'", __FILE__ . " linje " . __LINE__));
    $printer_ip = explode(chr(9), $r['box3']);
    $tmp = $kasse - 1;
    $printserver = $printer_ip[$tmp];
    if (!$printserver) {
        $printserver = 'localhost';
    }
    $x = 0;
    $q = db_select("select faktnr,amount,uxtid from openpost where konto_id='{$k_konto_id}' order by uxtid", __FILE__ . " linje " . __LINE__);
    while ($r = db_fetch_array($q)) {
        $faktnr[$x] = $r['faktnr'];
        $amount[$x] = $r['amount'];
        $uxtid[$x] = $r['uxtid'];
        $sum += $amount[$x];
        if ($sum) {
            $x++;
        } else {
            $x = 0;
        }
    }
    $antal = $x;
    include "../includes/ConvertCharset.class.php";
    if ($db_encode == "UTF8") {
        $FromCharset = "UTF-8";
    } else {
        $FromCharset = "iso-8859-15";
    }
    $ToCharset = "cp865";
    $convert = new ConvertCharset();
    $pfnavn = "../temp/" . $db . "/" . $bruger_id . ".txt";
    $fp = fopen("{$pfnavn}", "w");
    $r = db_fetch_array(db_select("select * from adresser where art = 'S'", __FILE__ . " linje " . __LINE__));
    $firmanavn = $r['firmanavn'];
    $addr1 = $r['addr1'];
    $addr2 = $r['addr2'];
    $postnr = $r['postnr'];
    $bynavn = $r['bynavn'];
    $tlf = $r['tlf'];
    $cvrnr = $r['cvrnr'];
    $belob = "beløb";
    if ($firmanavn) {
        $firmanavn = $convert->Convert($firmanavn, $FromCharset, $ToCharset);
    }
    if ($addr1) {
        $addr1 = $convert->Convert($addr1, $FromCharset, $ToCharset);
    }
    if ($addr2) {
        $addr2 = $convert->Convert($addr2, $FromCharset, $ToCharset);
    }
    if ($bynavn) {
        $bynavn = $convert->Convert($bynavn, $FromCharset, $ToCharset);
    }
    if ($tlf) {
        $tlf = $convert->Convert($tlf, $FromCharset, $ToCharset);
    }
    if ($cvrnr) {
        $cvrnr = $convert->Convert($cvrnr, $FromCharset, $ToCharset);
    }
    if ($belob) {
        $belob = $convert->Convert($belob, $FromCharset, $ToCharset);
    }
    if ($k_firmanavn) {
        $k_firmanavn = $convert->Convert($k_firmanavn, $FromCharset, $ToCharset);
    }
    if ($k_addr1) {
        $k_addr1 = $convert->Convert($k_addr1, $FromCharset, $ToCharset);
    }
    if ($k_addr2) {
        $k_addr2 = $convert->Convert($k_addr2, $FromCharset, $ToCharset);
    }
    if ($k_bynavn) {
        $k_bynavn = $convert->Convert($k_bynavn, $FromCharset, $ToCharset);
    }
    if ($k_tlf) {
        $k_tlf = $convert->Convert($k_tlf, $FromCharset, $ToCharset);
    }
    if ($k_cvrnr) {
        $k_cvrnr = $convert->Convert($k_cvrnr, $FromCharset, $ToCharset);
    }
    if (file_exists("../debitor/pos_print/kontoprint_{$db_id}.php")) {
        include "../debitor/pos_print/kontoprint_{$db_id}.php";
    } else {
        if ($k_kontonr) {
            $bon = "{$k_kontonr}\n";
        }
        if ($k_firmanavn) {
            $bon .= "{$k_firmanavn}\n";
        }
        if ($k_addr1) {
            $bon .= "{$k_addr1}\n";
        }
        if ($k_postnr) {
            $bon .= "{$k_postnr} {$k_bynavn}\n";
        }
        if ($k_tlf) {
            $bon .= "Tlf.: {$k_tlf}\n";
        }
        if ($k_cvrnr) {
            $bon .= "CVR.: {$k_cvrnr}\n";
        }
        $bon .= "\n\n";
        $bon .= "Dato  Kl.      Bon             {$belob}       Saldo\n";
        $bon .= "------------------------------------------------\n";
        $saldo = 0;
        for ($x = 0; $x < $antal; $x++) {
            $dkdato = date("d-m-y H:i", $uxtid[$x]);
            $saldo += $amount[$x];
            $dkamount = dkdecimal($amount[$x], 2);
            $dksaldo = dkdecimal($saldo, 2);
            while (strlen($faktnr[$x]) < 10) {
                $faktnr[$x] .= " ";
            }
            while (strlen($dkamount) < 10) {
                $dkamount = " " . $dkamount;
            }
            while (strlen($dksaldo) < 10) {
                $dksaldo = " " . $dksaldo;
            }
            $bon .= "{$dkdato} {$faktnr[$x]} {$dkamount} {$dksaldo}\n";
        }
        $bon .= "------------------------------------------------\n";
        $bon .= "------------------------------------------------\n";
        $bon .= "{$firmanavn}\n\n";
        $bon .= "{$addr1}\n";
        $bon .= "{$postnr} {$bynavn}\n";
        $bon .= "Tlf.: {$tlf}\n";
        $bon .= "CVR.: {$cvrnr}\n";
        $bon .= "\n\n";
        $bon = urlencode($bon);
        if (!$printserver || $printserver == 'box') {
            $filnavn = "http://saldi.dk/kasse/" . $_SERVER['REMOTE_ADDR'] . ".ip";
            if ($fp = fopen($filnavn, 'r')) {
                $printserver = trim(fgets($fp));
                fclose($fp);
            }
        }
        $fakturanr ? $skuffe = 1 : ($skuffe = 0);
        $url = "://" . ($_SERVER['SERVER_NAME'] .= $_SERVER['PHP_SELF']);
        $url = str_replace("/debitor/pos_ordre.php", "", $url);
        if ($_SERVER['HTTPS']) {
            $url = "s" . $url;
        }
        $url = "http" . $url;
        $returside = $url . "/debitor/pos_ordre.php";
        print "<meta http-equiv=\"refresh\" content=\"0;URL=http://{$printserver}/saldiprint.php?printfil={$tmp}&url={$url}&bruger_id={$bruger_id}&bon={$bon}&bonantal={$bonantal}&id={$id}&skuffe={$skuffe}&returside={$returside}\">\n";
        exit;
    }
}
Exemplo n.º 10
0
					}				
					
					// continue;				
				} else {
					$latinAvailable=1;
				}
				
				if ( $newfilename != $row['filename']){

						
						if ( ! is_file( $fdir.$row["filename"] )  ) {
							$year=substr($row['DATE'],0,4);
							$fdir=$flightsAbsPath."/".$row['userID']."/flights/".$year."/";
		
							require_once dirname(__FILE__)."/lib/ConvertCharset/ConvertCharset.class.php";
							$NewEncoding = new ConvertCharset;
		
		
							$filenameUTF= $NewEncoding->Convert($row['filename'], 'iso-8859-1', "utf-8", $Entities);
							$filenameISO= $NewEncoding->Convert($row['filename'], "utf-8",'iso-8859-1' , $Entities);
							$filenameGR= $NewEncoding->Convert($filenameUTF, "utf-8", "iso-8859-7", $Entities);

						$oldFilename='';
						if (is_file($fdir.$filenameUTF) ) { 
							echo "[UTF]";
							$oldFilename=$filenameUTF;
						} else if (is_file($fdir.$filenameISO) ) { 
							echo "[ISO]";
							$oldFilename=$filenameISO;
						} else if (is_file($fdir.$row['filename']) ) { 
							echo "[ORG]";
Exemplo n.º 11
0
 function createKMLfile($lineColor = "ff0000", $exaggeration = 1, $lineWidth = 2, $extendedInfo = 0)
 {
     global $takeoffRadious, $landingRadious;
     global $moduleRelPath, $baseInstallationPath;
     global $langEncodings, $currentlang, $CONF_use_utf;
     $exaggeration = 1;
     //if (file_exists($this->getKMLFilename())) return;
     $getFlightKML = $this->getFlightKML() . "&c={$lineColor}&w={$lineWidth}&an={$extendedInfo}";
     //UTF-8 or
     //".$langEncodings[$currentlang]."
     $kml_file_contents = "<?xml version='1.0' encoding='UTF-8'?>\n" . "<kml xmlns=\"http://earth.google.com/kml/2.1\">\n<Document>\n<name>" . $this->filename . "</name>" . $this->kmlGetDescription($extendedInfo, $getFlightKML) . "\n<open>1</open>";
     /*<LookAt>
     			<longitude>-3.10135108046447</longitude>
     			<latitude>52.9733850011146</latitude>
     			<range>3000</range>
     			<tilt>65</tilt>
     			<heading>227.735584972338</heading>
     		</LookAt>*/
     $kml_file_contents .= $this->kmlGetTrack($lineColor, $exaggeration, $lineWidth, $extendedInfo);
     // create the start and finish points
     $kml_file_contents .= makeWaypointPlacemark($this->takeoffID);
     if ($this->takeoffID != $this->landingID) {
         $kml_file_contents .= makeWaypointPlacemark($this->landingID);
     }
     // create the XC task
     $kml_file_contents .= $this->kmlGetTask();
     $kml_file_contents .= "</Document>\n</kml>";
     if (!$CONF_use_utf) {
         require_once dirname(__FILE__) . "/lib/ConvertCharset/ConvertCharset.class.php";
         $NewEncoding = new ConvertCharset();
         $FromCharset = $langEncodings[$currentlang];
         $kml_file_contents = $NewEncoding->Convert($kml_file_contents, $FromCharset, "utf-8", $Entities);
     }
     return $kml_file_contents;
 }
Exemplo n.º 12
0
 function win2utf($s, $force = false)
 {
     global $_COMMON_SITE_CONF;
     static $Encoding;
     if ($_COMMON_SITE_CONF['site_encoding'] == 'utf-8' && !$force) {
         return $s;
     }
     if (!$force) {
         $force = $_COMMON_SITE_CONF['site_encoding'];
     }
     if (!is_object($Encoding)) {
         $Encoding = new ConvertCharset($force, "utf-8", $Entities);
     }
     if (is_array($s)) {
         XARRAY::array_walk_recursive2($s, 'winutf_recursive', $force);
         return $s;
     }
     if (!($m = $Encoding->Convert($s))) {
         $m = $str;
     }
     return $m;
 }
Exemplo n.º 13
0
 // write first the original iso encoding with any missing defines added
 writeFile(LANG_ABS_PATH . "/iso/lang-{$lang}.php", $NewFileOutput);
 if (!$convert_to_utf_manually) {
     // replace in first list the encoding
     $encFrom = $langEncodings[$lang];
     if ($lang == 'hebrew') {
         $encFrom = 'iso-8859-8';
     }
     $encTo = "utf-8";
     $NewFileOutput = str_replace("charset={$encFrom}", "charset=utf-8", $NewFileOutput);
     // now convert to utf-8 and write also
     if ($lang == 'chinese') {
         require_once dirname(__FILE__) . "/lib/ConvertCharset/chinese/charset.class.php";
         $NewFileOutput = Charset::convert($NewFileOutput, 'gb2312', 'utf-8');
     } else {
         $NewEncoding = new ConvertCharset();
         $Entities = 0;
         $NewFileOutput = $NewEncoding->Convert($NewFileOutput, $encFrom, $encTo, $Entities);
     }
     writeFile(LANG_ABS_PATH . "/utf8/lang-{$lang}.php", $NewFileOutput);
 }
 // ----------------------------------
 // Now do the countries files
 // ----------------------------------
 $FileName = LANG_ABS_PATH . "/source/countries-{$lang}.php";
 $File = file($FileName);
 $FileText = implode("", $File);
 writeFile(LANG_ABS_PATH . "/iso/countries-{$lang}.php", $FileText);
 if (!$convert_to_utf_mannually) {
     $FileText = str_replace("charset={$encFrom}", "charset=utf-8", $FileText);
     if ($lang == 'chinese') {
Exemplo n.º 14
0
function makeKMLwaypoint($waypointID)
{
    global $langEncodings, $currentlang, $CONF_use_utf;
    $placemarkString = makeWaypointPlacemark($waypointID);
    //	$xml_text='<?xml version="1.0" encoding="'.$langEncodings[$currentlang].'"? >'.
    $xml_text = '<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"
 xmlns:gx="http://www.google.com/kml/ext/2.2">
' . $placemarkString . '
</kml>
';
    if (!$CONF_use_utf) {
        require_once dirname(__FILE__) . "/lib/ConvertCharset/ConvertCharset.class.php";
        $NewEncoding = new ConvertCharset();
        $FromCharset = $langEncodings[$currentlang];
        $xml_text = $NewEncoding->Convert($xml_text, $FromCharset, "utf-8", $Entities);
    }
    return $xml_text;
}
Exemplo n.º 15
0
function transliterate($str, $enc)
{
    // see this for hebraic-chinisee
    // http://www.derickrethans.nl/translit.php
    global $CONF_use_utf;
    if ($enc == 'gb2312') {
        // echo "#### $str $enc ##";
        if (!$CONF_use_utf) {
            require_once dirname(__FILE__) . "/lib/ConvertCharset/convert_gb2312.php";
            return gb2312_to_latin($str);
        } else {
            if (substr(phpversion(), 0, 1) >= 5) {
                require_once dirname(__FILE__) . "/lib/ConvertCharset/chinese/charset.class.php";
                $gb2312_str = Charset::convert($str, 'utf-8', 'gb2312');
                $str2 = Charset::PinYin($gb2312_str, 'gb2312');
                // echo "^gb2312_str : $gb2312_str ^ ";
                // echo "^str2: $str2 ^ ";
                return $str2;
            } else {
                return $str;
            }
        }
    }
    require_once dirname(__FILE__) . "/lib/ConvertCharset/ConvertCharset.class.php";
    require_once dirname(__FILE__) . "/lib/utf8_to_ascii/utf8_to_ascii.php";
    // if $CONF_use_utf it means the $str is already in utf
    // so  translitarate it directly
    if ($CONF_use_utf) {
        return utf8_to_ascii($str);
    }
    $NewEncoding = new ConvertCharset();
    $str_utf8 = $NewEncoding->Convert($str, $enc, "utf-8", $Entities);
    return utf8_to_ascii($str_utf8);
}
Exemplo n.º 16
0
function putOutput($reply)
{
    global $query_id;
    global $chatBill;
    global $query_in;
    global $free, $circle;
    global $time_start;
    global $no_result_string;
    global $debug;
    global $charge_per_query;
    global $service_name;
    global $toLog;
    global $product_name_tag;
    global $to_logserver;
    global $cri_bill;
    global $wiki_output;
    global $operator;
    global $spcl_bill;
    global $api_response;
    global $isReturn, $isCampaing, $isAppSet, $isAppQuery, $isgmobi;
    global $add_below;
    global $arCacheData, $outPutType;
    global $current_folder;
    global $number, $chargeMT, $appStore, $prefixQuery;
    global $shortcode, $listAll;
    global $isEvernote;
    global $akosha;
    global $blockINDSpec;
    if (!$free && $to_logserver['isresult'] == 0) {
        $free = true;
    }
    $listAll["expiry"] = date("Y-m-d H:i:s", strtotime("+1 day"));
    $arCacheData["ls"] = $listAll;
    $reply = preg_replace("~\\b(55444)\\b~i", $shortcode, $reply);
    if ($operator == "dialog") {
        $reply = str_replace(" @Rs 2.449/query", "", $reply);
    }
    var_dump($arCacheData);
    if ($isEvernote) {
        $arCacheData["en"]["c"] = $reply;
        $arCacheData["en"]["expiry"] = date("Y-m-d H:i:s", strtotime("+1 day"));
    }
    if (insertToCache("ls" . $number, json_encode($arCacheData), "86400")) {
        echo "<br>Insertded To Cache\n";
    }
    $billable = 0;
    $time_output = microtime(true);
    $time = $time_output - $time_start;
    echo "<br>Output is" . $reply;
    $reply = normalize(clean(trim(clean(html_entity_decode($reply)))));
    echo "<br>Output is" . $reply;
    if (!preg_match("~[\\w\\d]+~", $reply)) {
        $reply = $no_result_string . $add_below;
    }
    if ($akosha && !$blockINDSpec) {
        $reply = $add_below;
    }
    $r_in = $reply;
    $numbs = $_GET["mobile"];
    $myid = "AUU";
    //Log
    $response_length = strlen($reply);
    $to_log = array("Qid" => $query_id, "T" => $time, "L" => $response_length, "R" => addslashes($reply), "TS" => time());
    $log = serialize($to_log);
    file_put_contents(LOG_DIR . "response.log", $log . "\n", FILE_APPEND);
    //Billing
    if ($r_in != $no_result_string && $free == false) {
        $billable = $charge_per_query;
        echo "<br>ADDING TO BILL_Q<bR>";
        var_dump($no_result_string);
        var_dump($free);
        var_dump($r_in);
        $ttime = microtime(true);
        //        $query = 'INSERT INTO bill_queue (msisdn, query) VALUES ("' . $numbs . '","' . mysql_real_escape_string($query_in) . '")';
        //        mysql_query($query) or trigger_error("Error in $query: " . mysql_error(), E_USER_ERROR);
        $ttime = microtime(true) - $ttime;
    } else {
        echo "<br>Not charged - {$free}<br>";
    }
    if ($operator != 'api' && $operator != 'wap' && $outPutType != "xml") {
        include_once 'ConvertCharset.class.php';
        echo '<br>Befor Conver: ' . $reply;
        $encoding_in = mb_detect_encoding($reply);
        if ($encoding_in != 'ASCII') {
            echo "<br> Not ASCII";
            $utf2gsm = new ConvertCharset($encoding_in, 'gsm0338');
            $reply = $utf2gsm->Convert($reply);
        }
    }
    if ($isAppQuery) {
        echo "<h3>APPQuery {$isAppSet}</h3>";
        $chargeMT = 0;
        $txnid = uniqid();
        if (!$isAppSet) {
            echo "<h3>PrefixSet in functions</h3>";
            $reply = $prefixQuery . " " . trim($reply);
            $reply = trim($reply);
        }
    }
    echo '<br>After Conver: ' . $reply;
    $tagtolog = '';
    foreach ($toLog as $key => $logdata) {
        $tagtolog .= "<{$key}>{$logdata}</{$key}>";
    }
    echo "<br><br>--------------------<br>";
    //    if(strlen($reply) <= 465){
    //        $reply .= "\n--\nHappy Xmas.";
    //    }
    //----------TO LOG-------------------------------
    $time_output = microtime(true);
    $time = $time_output - $time_start;
    $to_logserver['rtime'] = $time;
    $log_json = urlencode(json_encode($to_logserver));
    //    if (basename(dirname(__FILE__)) == 'test') {
    $ttime = microtime();
    $data = file_get_contents($log_url);
    $ttime = microtime() - $ttime;
    if (basename(dirname(__FILE__)) == 'test') {
        echo "<br>LOG TIME: {$ttime}";
    }
    if (!is_numeric($data)) {
        $query = "insert into log_buffer(log_data) values('" . mysql_real_escape_string(urldecode($log_json)) . "')";
        mysql_query($query) or trigger_error(mysql_error(), E_USER_ERROR);
        $data = mysql_insert_id();
    }
    if (($to_logserver['source'] == 'keyword' || $appStore) && $to_logserver['isresult'] == 1 && !$free) {
        $hashbill = $data;
    } else {
        $hashbill = '';
    }
    if ($debug) {
        ob_end_flush();
    } else {
        ob_end_clean();
    }
    $time_output = microtime(true);
    $time = $time_output - $time_start;
    $time_in = date("Y-m-d H:i:s", $time_start);
    echo "<pre><bill>{$billable}</bill><ubill>{$spcl_bill}</ubill><tolog>{$tagtolog}</tolog><time_in>{$time_in}</time_in><query_id>{$query_id}</query_id><response_time>{$time}</response_time><product_name>{$product_name_tag}</product_name><service>{$service_name}</service><must_bill>{$hashbill}</must_bill><cri_bill>{$cri_bill}</cri_bill><send>{$isReturn}</send><chargeMT>{$chargeMT}</chargeMT><chat_bill>{$chatBill}</chat_bill><innoz_response>{$reply}</innoz_response></pre>";
    if ($isAppQuery) {
        insertToAppLog($number, $query_in, $circle, $reply, $time, $query_id, $operator);
    }
    ob_start();
}
Exemplo n.º 17
0
 function iconvert($fromcharset, $tocharset, $source, $useiconv = FALSE)
 {
     if (strtolower($fromcharset) == strtolower($tocharset)) {
         return $source;
     }
     if ($useiconv) {
         if (function_exists('iconv')) {
             return iconv($fromcharset, $tocharset, $source);
         } else {
             return FALSE;
         }
     }
     $NewEncoding = new ConvertCharset();
     return $NewEncoding->Convert($source, $fromcharset, $tocharset, false);
 }
Exemplo n.º 18
0
 $tilfravalg = $_POST['tilfravalg'];
 $notes = $_POST['notes'];
 $koekkenprinter = $_POST['koekkenprinter'];
 $koekkennr = $_POST['koekkennr'];
 $kategori = $_POST['kategori'];
 $besked = $_POST['besked'];
 if ($_POST['send_bestilling']) {
     $bestil = $_POST['bestil'];
     include "../includes/ConvertCharset.class.php";
     if ($db_encode == "UTF8") {
         $FromCharset = "UTF-8";
     } else {
         $FromCharset = "iso-8859-15";
     }
     $ToCharset = "cp865";
     $convert = new ConvertCharset();
     $skriv = 0;
     for ($x = 0; $x < count($linje_id); $x++) {
         $tmp = "bestil_" . $x;
         $tmp = $_POST[$tmp];
         if ($tmp || $tmp == '0') {
             $bestil[$x] = $tmp;
         }
         if ($bestil[$x]) {
             $skriv = 1;
             $bestil[$x] = $convert->Convert("{$bestil[$x]}", $FromCharset, $ToCharset);
             $beskrivelse[$x] = $convert->Convert("{$beskrivelse[$x]}", $FromCharset, $ToCharset);
             if (strlen($bestil[$x]) > 5) {
                 $bestil[$x] = substr($bestil[$x], -5);
             }
             while (strlen($bestil[$x]) < 5) {
Exemplo n.º 19
0
         }
     }
     $item_num++;
 }
 // end while
 if ($format == 'XML') {
     $RSS_str .= "</log>\n";
 } else {
     if ($format == 'JSON') {
         $RSS_str .= ' ] } ';
     }
 }
 //$RSS_str=htmlspecialchars($RSS_str);
 if (!$CONF_use_utf) {
     require_once dirname(__FILE__) . '/lib/ConvertCharset/ConvertCharset.class.php';
     $NewEncoding = new ConvertCharset();
     $RSS_str = $NewEncoding->Convert($RSS_str, $langEncodings[$nativeLanguage], "utf-8", $Entities);
 }
 if ($zip) {
     $filesToServe = array();
     require_once dirname(__FILE__) . "/lib/pclzip/pclzip.lib.php";
     if ($getIGCfiles && count($flightsToServe)) {
         $sql = "select ID, DATE, userID, filename from {$flightsTable} WHERE ID IN ( ";
         for ($i = 0; $i < count($flightsToServe); $i++) {
             if ($i > 0) {
                 $sql .= ' , ';
             }
             $sql .= $flightsToServe[$i];
         }
         $sql .= " ) ";
         $res = $db->sql_query($sql);
Exemplo n.º 20
0
 /**
  * Enter description here...
  *
  * @param unknown_type $domain
  * @param unknown_type $langdir
  */
 function convert_charset($domain, $textdomain, $lang, $from_charset, $to_charset)
 {
     $path = "{$textdomain}/{$lang}";
     if ($this->has_gettext) {
         $cmd = $this->escCommand("msgconv") . " --to-code={$to_charset} -o " . $this->escPath("{$path}/{$domain}.po") . " " . $this->escPath("{$path}/{$domain}.po");
         $ret = $this->execute($cmd);
         return $ret;
     }
     if (!class_exists('ConvertCharset')) {
         return false;
     }
     $catalog = new PHPGettext_catalog($domain, $textdomain);
     $catalog->setproperty('mode', _MODE_PO_);
     $catalog->setproperty('lang', $lang);
     $catalog->load();
     $catalog->headers['Content-Type'] = "text/plain; charset={$to_charset}\n";
     $NewEncoding = new ConvertCharset();
     foreach ($catalog->strings as $index => $message) {
         if (empty($message->msgid_plural)) {
             $catalog->strings[$index]->msgstr = $NewEncoding->Convert($message->msgstr, $from_charset, $to_charset, false);
         }
     }
     $catalog->save();
     return true;
 }
Exemplo n.º 21
0
 /**
  * Instaniate an XML parser under PHP4
  *
  * Unfortunately PHP4's support for character encodings
  * and especially XML and character encodings sucks.  As
  * long as the documents you parse only contain characters
  * from the ISO-8859-1 character set (a superset of ASCII,
  * and a subset of UTF-8) you're fine.  However once you
  * step out of that comfy little world things get mad, bad,
  * and dangerous to know.
  *
  * The following code is based on SJM's work with FoF
  * @see http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss
  *
  */
 function php4_create_parser($source, $in_enc, $detect)
 {
     if (!$detect) {
         return array(xml_parser_create($in_enc), $source);
     }
     if (!$in_enc) {
         if (preg_match('/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m', $source, $m)) {
             $in_enc = strtoupper($m[1]);
             $this->source_encoding = $in_enc;
         } else {
             $in_enc = 'UTF-8';
         }
     }
     if ($this->known_encoding($in_enc)) {
         return array(xml_parser_create($in_enc), $source);
     }
     // the dectected encoding is not one of the simple encodings PHP knows
     // attempt to use class ConvertCharset
     if (class_exists('ConvertCharset')) {
         $NewEncoding = new ConvertCharset();
         $encoded_source = $NewEncoding->Convert($source, $in_enc, 'UTF-8', false);
         if ($encoded_source) {
             return array(xml_parser_create('UTF-8'), $encoded_source);
         }
     }
     // ConvertCharset didn't work, try mb_convert_encoding
     // @see http://php.net/mbstring
     if (function_exists('mb_convert_encoding')) {
         $encoded_source = mb_convert_encoding($source, 'UTF-8', $in_enc);
         if ($encoded_source) {
             return array(xml_parser_create('UTF-8'), $encoded_source);
         }
     }
     // else
     $this->error("Feed is in an unsupported character encoding. ({$in_enc}) " . "You may see strange artifacts, and mangled characters.", E_USER_NOTICE);
     return array(xml_parser_create(), $source);
 }
Exemplo n.º 22
0
echo "{$Tox_mac_cyrillic}";
?>
>x-mac-cyrillic</option>
	<option value="utf-8" <?php 
echo "{$Toutf_8}";
?>
>utf-8</option>
</select><br />
<input type="checkbox" name="Entities" <?php 
if ($Entities == 1) {
    echo "CHECKED";
}
?>
> Check the box if you want numeric entities insted of regular chars.
<input type="submit" name="encode" value=" Encode string from file " />
</form>

<?php 
$FileName = "cyrillic" . "." . $FromCharset;
$File = file($FileName);
$FileText = implode("", $File);
$NewEncoding = new ConvertCharset();
$NewFileOutput = $NewEncoding->Convert($FileText, $FromCharset, $ToCharset, $Entities);
echo "This is your filename \"" . $FileName . "\" encoded to " . $ToCharset . ": <BR>\r\n<table border=\"0\"><tr><td>" . $NewFileOutput . "</td></tr></table><br />";
?>
<br />
I hope you do understand what is this class for? :) If you don't well..., that means<br />
I should never write any class again :)<br />
<h4>If you don't understand what you are doing on this site do a <A href="demo.php">step back</a></h4>
</body>
</html>
Exemplo n.º 23
0
                                if (!is_array($takeoffs[$countryCode])) {
                                    $takeoffs[$countryCode] = array();
                                }
                                array_push($takeoffs[$countryCode], $xml_str);
                            }
                            foreach ($takeoffs as $countryCode => $countrySites) {
                                $xml .= "<Folder>\n<name>" . $countries[$countryCode] . "</name>\n";
                                foreach ($countrySites as $siteXml) {
                                    $xml .= $siteXml;
                                }
                                $xml .= "</Folder>";
                            }
                            $xml .= "</Folder>\n</kml>\n";
                            if (!$CONF_use_utf) {
                                require_once dirname(__FILE__) . "/lib/ConvertCharset/ConvertCharset.class.php";
                                $NewEncoding = new ConvertCharset();
                                $FromCharset = $langEncodings[$currentlang];
                                $xml = $NewEncoding->Convert($xml, $FromCharset, "utf-8", $Entities);
                            }
                            $file_name = "Leonardo site guide.kml";
                        } else {
                            if ($type == "explore_ge") {
                                $baseUrl = "http://" . str_replace('//', '/', $_SERVER['SERVER_NAME'] . "/{$baseInstallationPath}/{$moduleRelPath}");
                                $fltr = $_GET['fltr'];
                                if ($fltr) {
                                    $fltr = "&fltr={$fltr}";
                                }
                                $exploreKML = "{$baseUrl}/download.php?type=explore{$fltr}";
                                $logoUrl = "{$baseUrl}/templates/basic/tpl/leonardo_logo.gif";
                                $xml = '<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
Exemplo n.º 24
0
     exit;
 }
 $output2screen = false;
 $outStr .= "<table>";
 $outStr .= "<tr><td>Flight</td><td>serverID</td><td>orgID</td><td>PilotID</td><td>Pilot</td></tr>\n";
 $suggestedMappings = array();
 $pilots = array();
 $k = 0;
 while ($row = $db->sql_fetchrow($res)) {
     $pilotID = $row['userServerID'] . '_' . $row['userID'];
     $pilots[$pilotID]['serverID'] = $row['userServerID'];
     $pilots[$pilotID]['userID'] = $row['userID'];
     if (!$pilotNames[$pilotID]) {
         $pilotInfo = getPilotInfo($row['userID'], $row['userServerID']);
         if (!$CONF_use_utf) {
             $NewEncoding = new ConvertCharset();
             $lName = $NewEncoding->Convert($pilotInfo[0], $langEncodings[$nativeLanguage], "utf-8", $Entities);
             $fName = $NewEncoding->Convert($pilotInfo[1], $langEncodings[$nativeLanguage], "utf-8", $Entities);
         } else {
             $lName = $pilotInfo[0];
             $fName = $pilotInfo[1];
         }
         $pilotNames[$pilotID]['lname'] = $lName;
         $pilotNames[$pilotID]['fname'] = $fName;
         $pilotNames[$pilotID]['country'] = $pilotInfo[2];
         $pilotNames[$pilotID]['sex'] = $pilotInfo[3];
         $pilotNames[$pilotID]['birthdate'] = $pilotInfo[4];
         $pilotNames[$pilotID]['CIVL_ID'] = $pilotInfo[5];
     }
     $outStr .= "<tr><td>ID: <a href='" . CONF_MODULE_ARG . "&op=show_flight&flightID=" . $row['ID'] . "'>" . $row['ID'] . "</a></td>\n<td>" . $row['serverID'] . "</td>\n<td>" . $row['original_ID'] . "</td>\t\t\n<td>{$pilotID}</td>\n\t\t\t<td><a href='" . CONF_MODULE_ARG . "&op=list_flights&year=0&month=0&pilotID={$pilotID}'>" . $pilotNames[$pilotID]['lname'] . " " . $pilotNames[$pilotID]['fname'] . " [ " . $pilotNames[$pilotID]['country'] . " ] CIVLID: " . $pilotNames[$pilotID]['CIVL_ID'] . "</td>\n</tr>\n\t\t\n";
     $k++;
Exemplo n.º 25
0
    Click go to get going!
    </head>
    <body>
    Do you really wanna upgrade to UTF-8? Have you backed up?

    <form method="get">
       <input type="submit" name="go" value="go" />
    </form>
    </body>
    </html>
    <?php 
    exit;
}
set_time_limit(86400);
require_once 'ConvertCharset.class.php';
$conv = new ConvertCharset();
if (isset($_GET['table'])) {
    $tables = array($_GET['table']);
} else {
    $tables = $dbcon->MetaTables('TABLES');
}
foreach ($tables as $table) {
    print "Updating {$table} ... ";
    if (array_search($table, $skip_tables)) {
        print "skipping.<br/>";
        continue;
    }
    $columns = $dbcon->MetaColumns($table, false);
    $indexes = $dbcon->MetaIndexes($table);
    $pre_sql = array();
    $post_sql = array();
Exemplo n.º 26
0
function kassebeholdning($kasse, $optalt, $godkendt, $cookievalue)
{
    global $bruger_id;
    global $brugernavn;
    global $db;
    global $db_encode;
    #	global $printserver;
    global $regnaar;
    $dd = date("Y-m-d");
    $tid = date("H:m");
    if (!$cookievalue) {
        $cookievalue = $_COOKIE['saldi_kasseoptael'];
    }
    list($ore_50, $kr_1, $kr_2, $kr_5, $kr_10, $kr_20, $kr_50, $kr_100, $kr_200, $kr_500, $kr_1000, $kr_andet) = explode(chr(9), $cookievalue);
    $r = db_fetch_array(db_select("select * from grupper where art = 'POS' and kodenr = '2'", __FILE__ . " linje " . __LINE__));
    $byttepenge = $r['box1'];
    $optalassist = $r['box2'];
    $printer_ip = explode(chr(9), $r['box3']);
    $printserver = $printer_ip[$kasse - 1];
    if (!$printserver) {
        $printserver = 'localhost';
    }
    if (!$godkendt && $optalassist) {
        kasseoptalling($kasse, $optalt, $ore_50, $kr_1, $kr_2, $kr_5, $kr_10, $kr_20, $kr_50, $kr_100, $kr_200, $kr_500, $kr_1000, $kr_andet);
    }
    $r = db_fetch_array(db_select("select * from grupper where art = 'RA' and kodenr = '{$regnaar}'", __FILE__ . " linje " . __LINE__));
    $startmd = $r['box1'];
    $startaar = $r['box2'];
    #cho "startmd $startmd startaar $startaar<br>\n";
    $regnstart = $startaar . "-" . $startmd . "-01";
    $r = db_fetch_array(db_select("select box9 from grupper where art = 'POS' and kodenr = '1'", __FILE__ . " linje " . __LINE__));
    if (!$r['box9']) {
        posbogfor($kasse, $regnstart);
    }
    include "../includes/ConvertCharset.class.php";
    if ($db_encode == "UTF8") {
        $FromCharset = "UTF-8";
    } else {
        $FromCharset = "iso-8859-15";
    }
    $ToCharset = "cp865";
    $convert = new ConvertCharset();
    $pfnavn = "../temp/" . $db . "/" . $bruger_id . ".txt";
    $fp = fopen("{$pfnavn}", "w");
    $kassopgorelse = "KASSEOPGØRELSE";
    $tmp = $convert->Convert($kassopgorelse, $FromCharset, $ToCharset);
    fwrite($fp, "\n\n{$tmp}\n\n");
    fwrite($fp, "Den {$dd} kl. {$tid}\n");
    fwrite($fp, "Kasse nr: {$kasse}\n");
    $tmp = $convert->Convert($brugernavn, $FromCharset, $ToCharset);
    fwrite($fp, "Optalt af: {$tmp}\n");
    if ($optalassist) {
        $byttepenge = if_isset($_POST['byttepenge']);
        $tilgang = if_isset($_POST['tilgang']);
        $optalt = if_isset($_POST['optalt']);
        $omsatning = if_isset($_POST['omsatning']);
        $udtages = if_isset($_POST['udtages']);
        $kontkonto = if_isset($_POST['kontkonto']);
        $kortnavn = if_isset($_POST['kortnavn']);
        $kortsum = if_isset($_POST['kortsum']);
        #		fwrite($fp,"Optalt kassebeholdning: ".dkdecimal($optalt)."\n\n");
        #		fwrite($fp,"Differece $prefix".dkdecimal($diff)."\n\n");
        #		fwrite($fp,"Optalt tilgang i kasse: ".dkdecimal($optalt-$byttepenge)."\n\n");
        $tmp = $convert->Convert('50 øre', $FromCharset, $ToCharset);
        fwrite($fp, "  {$tmp}:  {$ore_50}\n");
        fwrite($fp, "    1 kr:  {$kr_1}\n");
        fwrite($fp, "    2 kr:  {$kr_2}\n");
        fwrite($fp, "    5 kr:  {$kr_5}\n");
        fwrite($fp, "   10 kr:  {$kr_10}\n");
        fwrite($fp, "   20 kr:  {$kr_20}\n");
        fwrite($fp, "   50 kr:  {$kr_50}\n");
        fwrite($fp, "  100 kr:  {$kr_100}\n");
        fwrite($fp, "  200 kr:  {$kr_200}\n");
        fwrite($fp, "  500 kr:  {$kr_500}\n");
        fwrite($fp, " 1000 kr:  {$kr_1000}\n");
        fwrite($fp, "Andet kr:  " . dkdecimal($kr_andet) . "\n\n");
        $txt1 = "Morgenbeholdning:";
        $txt2 = dkdecimal($byttepenge);
        while (strlen($txt1) + strlen($txt2) < 40) {
            $txt2 = " " . $txt2;
        }
        fwrite($fp, "{$txt1}{$txt2}\n");
        $txt1 = "Dagens tilgang:";
        $txt2 = dkdecimal($tilgang);
        while (strlen($txt1) + strlen($txt2) < 40) {
            $txt2 = " " . $txt2;
        }
        fwrite($fp, "{$txt1}{$txt2}\n");
        $txt1 = "Forventet beholdning:";
        $txt2 = dkdecimal($byttepenge + $tilgang);
        while (strlen($txt1) + strlen($txt2) < 40) {
            $txt2 = " " . $txt2;
        }
        fwrite($fp, "{$txt1}{$txt2}\n");
        $txt1 = "Optalt beholdning:";
        $txt2 = dkdecimal($optalt);
        while (strlen($txt1) + strlen($txt2) < 40) {
            $txt2 = " " . $txt2;
        }
        fwrite($fp, "{$txt1}{$txt2}\n");
        $txt1 = "Difference:";
        $txt2 = dkdecimal($optalt - ($byttepenge + $tilgang));
        while (strlen($txt1) + strlen($txt2) < 40) {
            $txt2 = " " . $txt2;
        }
        fwrite($fp, "{$txt1}{$txt2}\n");
        $txt1 = "Udtaget fra kasse {$kasse}:";
        $txt2 = dkdecimal($udtages);
        while (strlen($txt1) + strlen($txt2) < 40) {
            $txt2 = " " . $txt2;
        }
        fwrite($fp, "{$txt1}{$txt2}\n\n\n\n");
        fwrite($fp, "Underskrift:______________________\n\n");
    } else {
        $svar = find_kassesalg($kasse, $optalt);
        $byttepenge = $svar[0];
        $tilgang = $svar[1];
        $diff = $svar[2];
        $kortantal = $svar[3];
        $kontkonto = explode(chr(9), $svar[4]);
        $kortnavn = explode(chr(9), $svar[5]);
        $kortsum = explode(chr(9), $svar[6]);
        fwrite($fp, "Beholdning primo: " . dkdecimal($byttepenge) . "\n\n");
        fwrite($fp, "Dagens indbetalinger: " . dkdecimal($tilgang) . "\n\n");
        fwrite($fp, "Beholdning ultimo: " . dkdecimal($byttepenge + $tilgang) . "\n\n");
    }
    for ($x = 0; $x < count($kortnavn); $x++) {
        $txt1 = "{$kortnavn[$x]}";
        $txt2 = dkdecimal($kortsum[$x]);
        while (strlen($txt1) + strlen($txt2) < 40) {
            $txt2 = " " . $txt2;
        }
        #			fwrite($fp,"\nSalg paa kort:\n");
        fwrite($fp, "{$txt1}{$txt2}\n");
    }
    fwrite($fp, "\n\n\n");
    fclose($fp);
    $tmp = "/temp/" . $db . "/" . $bruger_id . ".txt";
    $url = "://" . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
    $url = str_replace("/debitor/pos_ordre.php", "", $url);
    if ($_SERVER[HTTPS]) {
        $url = "s" . $url;
    }
    $url = "http" . $url;
    print "<BODY onLoad=\"JavaScript:window.open('http://{$printserver}/saldiprint.php?printfil={$tmp}&url={$url}&bruger_id={$bruger_id}&bonantal=1' , '' , '{$jsvars}');\">\n";
}
Exemplo n.º 27
-6
function index_url($url, $level, $site_id, $md5sum, $domain, $indexdate, $sessid, $can_leave_domain, $reindex)
{
    global $tmp_urls, $delay_time, $domain_arr, $charSet, $url_status, $whitelist, $blacklist, $supdomain, $smp, $realnum, $dup_url, $entities, $command_line;
    if (DEBUG == '0') {
        error_reporting(0);
    } else {
        error_reporting(E_ERROR);
        //  otherwise  a non existing siemap.xml  would always cause a warning message
    }
    $needsReindex = 1;
    $deletable = 0;
    $url_status = url_status($url);
    $thislevel = $level - 1;
    if ($smp != 1 && Configure::read('follow_sitemap') == 1) {
        //  enter here if we don't already know a valid sitemap and if admin settings allowed us to do so
        $tmp_urls = get_temp_urls($sessid);
        //  reload previous temp
        $url2 = remove_sessid(convert_url($url));
        // get folder where sitemap should be and if exists, cut existing filename, suffix and subfolder
        //                Configure::read('local') = "http://localhost/publizieren/";   //  your base adress for your local server
        $sitemap_name = "sitemap.xml";
        //  could be individualized
        $host = parse_url($url2);
        $hostname = $host[host];
        if ($hostname == 'localhost') {
            $host1 = str_replace(Configure::read('local'), '', $url2);
        }
        $pos = strpos($host1, "/");
        //      on local server delete all behind the /
        if ($pos) {
            $host1 = substr($host1, 0, $pos);
        }
        //      build full adress again, now only until host
        if ($hostname == 'localhost') {
            $url2 = Configure::read('local') . $host1;
        } else {
            $url2 = "{$host['scheme']}://{$hostname}";
        }
        $input_file = "{$url2}/{$sitemap_name}";
        // create path to sitemap
        if ($handle = fopen($input_file, "r")) {
            // happy times, we found a new sitemap
            $links = get_sitemap($input_file, TABLE_PREFIX);
            // now extract links from sitemap.xml
            if ($links != '') {
                //  if links were extracted from sitemap.xml
                reset($links);
                while ($thislink = each($links)) {
                    //  check if we already know this link as a site url
                    $result = mysql_query("select url from " . TABLE_PREFIX . "sites where url like '{$thislink['1']}%'");
                    if (DEBUG > '0') {
                        echo mysql_error();
                    }
                    $rows = mysql_num_rows($result);
                    if ($rows == '0') {
                        // for all new links: save in temp table
                        mysql_query("insert into " . TABLE_PREFIX . "temp (link, level, id) values ('{$thislink['1']}', '{$level}', '{$sessid}')");
                        if (DEBUG > '0') {
                            echo mysql_error();
                        }
                    }
                }
                clean_resource($result);
                $smp = '1';
                //     there was a valid sitemap and we stored the new links
            }
            unset($links, $input_file);
            fclose($handle);
        }
    }
    if (strstr($url_status['state'], "Relocation")) {
        $url = eregi_replace(" ", "", url_purify($url_status['path'], $url, $can_leave_domain));
        if ($url != '') {
            $result = mysql_query("select link from " . TABLE_PREFIX . "temp where link='{$url}' && id = '{$sessid}'");
            if (DEBUG > '0') {
                echo mysql_error();
            }
            $rows = mysql_num_rows($result);
            if ($rows == 0) {
                mysql_query("insert into " . TABLE_PREFIX . "temp (link, level, id) values ('{$url}', '{$level}', '{$sessid}')");
                if (DEBUG > '0') {
                    echo mysql_error();
                }
            }
            clean_resource($result);
        }
        $url_status['state'] == "redirected";
    }
    ini_set("user_agent", Configure::read('user_agent'));
    if ($url_status['state'] == 'ok') {
        $OKtoIndex = 1;
        $file_read_error = 0;
        if (time() - $delay_time < Configure::read('min_delay')) {
            sleep(Configure::read('min_delay') - (time() - $delay_time));
        }
        $delay_time = time();
        if (!fst_lt_snd(phpversion(), "4.3.0")) {
            $file = file_get_contents($url);
            if ($file === FALSE) {
                $file_read_error = 1;
            }
        } else {
            $fl = @fopen($url, "r");
            if ($fl) {
                while ($buffer = @fgets($fl, 4096)) {
                    $file .= $buffer;
                }
                unset($buffer);
            } else {
                $file_read_error = 1;
            }
            fclose($fl);
        }
        if ($file_read_error || Configure::read('utf8') == 1) {
            unset($file);
            $contents = getFileContents($url);
            // parse_url to get charset
            $file = $contents['file'];
        }
        $pageSize = number_format(strlen($file) / 1024, 2, ".", "");
        printPageSizeReport($pageSize);
        if ($url_status['content'] != 'text') {
            $file = extract_text($file, $url_status['content']);
            //for DOCs, PDFs etc we need special converter
            if ($file == 'ERROR') {
                //      if error, suppress further indexing
                $OKtoIndex = 0;
                $file_read_error = 1;
            }
        }
        if (Configure::read('utf8') == 1) {
            //   enter here if file should be translated into utf-8
            $charSet = $contents['charset'];
            if ($charSet == '') {
                // if we did not find any charset, we will use our own
                $charSet = Configure::read('home_charset');
            }
            $charSet = strtoupper(trim($charSet));
            if (strpos($charSet, '8859')) {
                $conv_file = html_entity_decode($file);
            } else {
                $conv_file = $file;
                //  pure code
            }
            if ($charSet != "UTF-8") {
                //  enter here only, if site / file is not jet UTF-8 coded
                $iconv_file = iconv($charSet, "UTF-8", $conv_file);
                //      if installed, first try to use PHP function iconv
                if (trim($iconv_file) == "") {
                    // iconv is not installed or input charSet not available. We need to use class ConvertCharset
                    $charSet = str_ireplace('iso-', '', $charSet);
                    $charSet = str_ireplace('iso', '', $charSet);
                    $NewEncoding = new ConvertCharset($charSet, "utf-8");
                    $NewFileOutput = $NewEncoding->Convert($conv_file);
                    $file = $NewFileOutput;
                } else {
                    $file = $iconv_file;
                }
                unset($conv_file, $iconv_file, $NewEncoding, $NewFileOutput);
            }
        }
        $data = clean_file($file, $url, $url_status['content']);
        $newmd5sum = md5($data['content']);
        if ($md5sum == $newmd5sum) {
            printStandardReport('md5notChanged', $command_line);
            $OKtoIndex = 0;
            $realnum--;
        } else {
            if (Configure::read('use_white') == '1') {
                $found = '0';
                //  check if content of page matches any word in whitelist
                foreach ($whitelist as $key => $value) {
                    $met = stripos($file, $value);
                    if ($met) {
                        $found = '1';
                    }
                }
                if ($found == '0') {
                    printStandardReport('noWhitelist', $command_line);
                    $OKtoIndex = 0;
                    $realnum--;
                }
            }
            if (Configure::read('use_black') == '1') {
                $found = '0';
                //  check if content of page matches any word in blacklist
                foreach ($blacklist as $key => $value) {
                    $met = stripos($file, $value);
                    if ($met) {
                        $found = '1';
                    }
                }
                if ($found == '1') {
                    printStandardReport('matchBlacklist', $command_line);
                    $OKtoIndex = 0;
                    $realnum--;
                }
            }
            //     check for duplicate page content
            $result = mysql_query("select link_id from " . TABLE_PREFIX . "links where md5sum='{$newmd5sum}'");
            if (DEBUG > '0') {
                echo mysql_error();
            }
            if (mysql_num_rows($result) > 0) {
                //  display warning message and urls with duplicate content
                printStandardReport('duplicate', $command_line);
                $num_rows = mysql_num_rows($result);
                for ($i = 0; $i < $num_rows; $i++) {
                    $link_id = mysql_result($result, $i, "link_id");
                    $num = $i + 1;
                    $res = mysql_query("select url from " . TABLE_PREFIX . "links where link_id like '{$link_id}'");
                    if (DEBUG > '0') {
                        echo mysql_error();
                    }
                    $row = mysql_fetch_row($res);
                    $dup_url = $row[0];
                    clean_resource($res);
                    printDupReport($dup_url, $command_line);
                }
                if (Configure::read('dup_content') == '0') {
                    //  enter here, if pages with duplicate content should not be indexed/re-indexed
                    $OKtoIndex = 0;
                    $realnum--;
                } else {
                    $OKtoIndex = 1;
                }
            }
        }
        if (($md5sum != $newmd5sum || $reindex == 1) && $OKtoIndex == 1) {
            $urlparts = parse_url($url);
            $newdomain = $urlparts['host'];
            $type = 0;
            if ($data['noindex'] == 1) {
                $OKtoIndex = 0;
                $deletable = 1;
                printStandardReport('metaNoindex', $command_line);
            }
            if (Configure::read('use_white') == '1') {
                $found = '0';
                //  check if content of page matches any word in whitelist
                foreach ($whitelist as $key => $value) {
                    $met = stripos($data[fulltext], $value);
                    if ($met) {
                        $found = '1';
                    }
                }
                if ($found == '0') {
                    printStandardReport('noWhitelist', $command_line);
                    $OKtoIndex = 0;
                    $realnum--;
                }
            }
            if (Configure::read('use_black') == '1') {
                $found = '0';
                //  check if content of page matches any word in blacklist
                foreach ($blacklist as $key => $value) {
                    $met = stripos($data[fulltext], $value);
                    if ($met) {
                        $found = '1';
                    }
                }
                if ($found == '1') {
                    printStandardReport('matchBlacklist', $command_line);
                    $OKtoIndex = 0;
                    $realnum--;
                }
            }
            $wordarray = unique_array(explode(" ", $data['content']));
            if ($smp != 1) {
                if ($data['nofollow'] != 1) {
                    $links = get_links($file, $url, $can_leave_domain, $data['base']);
                    $links = distinct_array($links);
                    $all_links = count($links);
                    if ($all_links > Configure::read('max_links')) {
                        $all_links = Configure::read('max_links');
                    }
                    $links = array_slice($links, 0, Configure::read('max_links'));
                    if ($realnum < Configure::read('max_links')) {
                        $numoflinks = 0;
                        //if there are any, add to the temp table, but only if there isnt such url already
                        if (is_array($links)) {
                            reset($links);
                            if (DEBUG == '2') {
                                //  if debug mode, show details
                                printStandardReport('newLinks', $command_line);
                            }
                            while ($thislink = each($links)) {
                                if ($tmp_urls[$thislink[1]] != 1) {
                                    $tmp_urls[$thislink[1]] = 1;
                                    $numoflinks++;
                                    if (DEBUG == '2') {
                                        $act_link = $thislink[1];
                                        printNewLinks($act_link);
                                    }
                                    if ($numoflinks <= Configure::read('max_links')) {
                                        mysql_query("insert into " . TABLE_PREFIX . "temp (link, level, id) values ('{$thislink['1']}', '{$level}', '{$sessid}')");
                                    }
                                    if (DEBUG > '0') {
                                        echo mysql_error();
                                    }
                                }
                            }
                        }
                    }
                } else {
                    printStandardReport('noFollow', $command_line);
                }
                unset($file);
            }
            if ($OKtoIndex == 1) {
                if (Configure::read('link_check') == 0) {
                    $title = $data['title'];
                    $host = $data['host'];
                    $path = $data['path'];
                    $fulltxt = $data['fulltext'];
                    $desc = substr($data['description'], 0, 254);
                    $url_parts = parse_url($url);
                    $domain_for_db = $url_parts['host'];
                    if (isset($domain_arr[$domain_for_db])) {
                        $dom_id = $domain_arr[$domain_for_db];
                    } else {
                        mysql_query("insert into " . TABLE_PREFIX . "domains (domain) values ('{$domain_for_db}')");
                        $dom_id = mysql_insert_id();
                        $domain_arr[$domain_for_db] = $dom_id;
                    }
                    $wordarray = calc_weights($wordarray, $title, $host, $path, $data['keywords'], $url_parts);
                    //if there are words to index, add the link to the database, get its id, and add the word + their relation
                    if (is_array($wordarray) && count($wordarray) > Configure::read('min_words_per_page')) {
                        if ($md5sum == '') {
                            mysql_query("insert into " . TABLE_PREFIX . "links (site_id, url, title, description, fulltxt, indexdate, size, md5sum, level) values ('{$site_id}', '{$url}', '{$title}', '{$desc}', '{$fulltxt}', curdate(), '{$pageSize}', '{$newmd5sum}', {$thislevel})");
                            if (DEBUG > '0') {
                                echo mysql_error();
                            }
                            $result = mysql_query("select link_id from " . TABLE_PREFIX . "links where url='{$url}'");
                            if (DEBUG > '0') {
                                echo mysql_error();
                            }
                            $row = mysql_fetch_row($result);
                            $link_id = $row[0];
                            clean_resource($result);
                            if (DEBUG == '2') {
                                //  if debug mode, show details
                                printStandardReport('newKeywords', $command_line);
                            }
                            save_keywords($wordarray, $link_id, $dom_id);
                            if (DEBUG == '2') {
                                printStandardReport('indexed1', $command_line);
                            } else {
                                printStandardReport('indexed', $command_line);
                            }
                        } else {
                            if ($md5sum != '' && $md5sum != $newmd5sum) {
                                //if page has changed, start updating
                                $result = mysql_query("select link_id from " . TABLE_PREFIX . "links where url='{$url}'");
                                if (DEBUG > '0') {
                                    echo mysql_error();
                                }
                                $row = mysql_fetch_row($result);
                                $link_id = $row[0];
                                for ($i = 0; $i <= 15; $i++) {
                                    $char = dechex($i);
                                    mysql_query("delete from " . TABLE_PREFIX . "link_keyword{$char} where link_id={$link_id}");
                                    if (DEBUG > '0') {
                                        echo mysql_error();
                                    }
                                }
                                clean_resource($result);
                                if (DEBUG == '2') {
                                    //  if debug mode, show details
                                    printStandardReport('newKeywords', $command_line);
                                }
                                save_keywords($wordarray, $link_id, $dom_id);
                                $query = "update " . TABLE_PREFIX . "links set title='{$title}', description ='{$desc}', fulltxt = '{$fulltxt}', indexdate=now(), size = '{$pageSize}', md5sum='{$newmd5sum}', level={$thislevel} where link_id={$link_id}";
                                mysql_query($query);
                                if (DEBUG > '0') {
                                    echo mysql_error();
                                }
                                if (DEBUG == '2') {
                                    printStandardReport('re-indexed1', $command_line);
                                } else {
                                    printStandardReport('re-indexed', $command_line);
                                }
                            }
                        }
                    } else {
                        printStandardReport('minWords', $command_line);
                        $realnum--;
                    }
                } else {
                    printStandardReport('link_okay', $command_line);
                }
                unset($wordarray, $title, $fulltxt, $desc);
            }
        }
    } else {
        $deletable = 1;
        printUrlStatus($url_status['state'], $command_line);
    }
    if ($reindex == 1 && $deletable == 1) {
        check_for_removal($url);
    } else {
        if ($reindex == 1) {
        }
    }
    if (!isset($all_links)) {
        $all_links = 0;
    }
    if (!isset($numoflinks)) {
        $numoflinks = 0;
    }
    if ($smp != 1) {
        //      if valid sitemap found, no LinkReport
        printLinksReport($numoflinks, $all_links, $command_line);
    }
}