/** * Constructor of the object. * Generates the table for ANSEL to Unicode mapping. * @param String $conversionFile The name of the mapping file made by Heiner Eichmann. * The file can be downloaded FROM this URL: * http://www.heiner-eichmann.de/gedcom/ans2uni.con.zip */ public function __construct($conversion_file = 'ans2uni.con') { $temp_ini_file = 'mappings.ini'; // Name of temporary ini file if (File_exists($conversion_file)) { // Load file contents, convert into well-formed ini file for later parsing. // This is done because the original mapping file cannot be parsed by the // PHP function parse_ini_file. $file_contents = File_get_contents($conversion_file, 'FILE_BINARY'); // Load contents $file_contents = $this->strip_comments($file_contents, '#'); // Strip comments File_put_contents($temp_ini_file, $file_contents); // Save contents // Get ini contents $map = Parse_ini_file($temp_ini_file); // Parse ini file // Go through map to split up the mappings that contain more characters in the key, // so that mappings with one character goes into $this->mapping[1], those with two // characters goes to $this->mapping[2] etc. foreach ($map as $key => $value) { $characters = explode('+', $key); // Split string where '+' occurrs $num_chars = count($characters); // count number of characters $this->_mapping[$num_chars][Strtolower($key)] = $value; // Put mapping in right place } // Delete temporary ini file efterwards if exists if (File_exists($temp_ini_file)) { Unlink($temp_ini_file); } } else { echo '<p>No mapping file with name ' . $conversion_file . ' exists. Download this file ' . 'from <a href="http://www.heiner-eichmann.de/gedcom/ans2uni.con.zip">here</a>.'; } }
</OAI_EMULATION> '; //echo $data."<br /><br />"; /* // VARIABLES FOR WEBPORTAL $EMU_RESULTS = "/drupal-6.19/CLUSTER/r4g7/emu_results"; $EMU_RESULTS_USER = $EMU_RESULTS.'/'.str_replace($espace, "", $user).'/'.$date; $FOR_R4G1 = "/opt/lampp/htdocs/drupal-6.19/CLUSTER/r4g7/emu_results/".str_replace($espace, "", $user)."/".$date."/LOGS/"; $CHEMIN = "/nfs/emu_results/".str_replace($espace, "", $user)."/".$date."/LOGS/"; $file = '/opt/lampp/htdocs/drupal-6.19/CLUSTER/r4g7/webxml/'.$XML_FILE; */ // VARIABLES FOR PORTABLE VERSION $xmlfile = $WEBXML_PATH . '/' . str_replace($espace, "", $user) . '.' . $date . '.xml'; //echo $xmlfile.'<br />'.$XML_FILENAME.'<br />'; // 1 - WRITTING THE XML FILE File_put_contents($xmlfile, $data); sleep(1); // IN PORTABLE VERSION THERE IS NO FOR R4G1, SINCE WE WORK ON ONLY ONE MACHINE // RESULTS_PATH is defined in /opt/lampp/htdocs/OSD/OpenAirEmu.conf file $RESULTS_PATH_EMULATION = $RESULTS_PATH . "/" . str_replace($espace, "", $user) . "/" . $date . "/"; //echo $RESULTS_PATH_EMULATION.'<br />'; //$RESULTS_PATH_EMULATION_LOGS = $RESULTS_PATH_EMULATION."LOGS/"; //$RESULTS_PATH_EMULATION_XML = $RESULTS_PATH_EMULATION."SCENARIO/XML/"; // PROFILING and PCAP Copy if ($PROFILING == 1) { $PROFILING_PARSE = '2>profiling.log'; $PROFILING_COPY = ' ; cp profiling.log ' . $RESULTS_PATH_EMULATION; } else { $PROFILING_PARSE = ''; $PROFILING_COPY = ''; }
function sql($sql, $bd = null, $opt = null) { if (is_array($opt)) { extract($opt); } $param = 'old'; if (substr($sql, -4) == '#' . $param) { $sql = str_replace('#' . $param, '', $sql); ${$param} = 1; } #usage mysql court #if(substr_count($sql,"'")%2==1){db('injection : '.substr_count($sql,"'").$sql);return;} #str_replace("'",'’',$within the quoted space) static $status, $bdsel, $host, $conn; if ($status == 'dead') { return; } #connexion dropped if ($bd == 1 or $opt == 1) { $close = 1; unset($p, $nt); } if (strpos($sql, '.s3db')) { Preg_match('~[^ ]+\\.s3db\\.~i', $sql, $m); $bd = trim($m[0], '.'); $sql = str_replace($m[0], '', $sql); } if (strpos($bd, '.s3db')) { return sqlite($sql, $bd, $close); } #if(function_exists('div_sql'))av(div_sql($sql,$bd));#addition ksv1:list($sql,$bd,$a)=div_sql($sql,$bd);#fonction divergentes if (function_exists('div_sql')) { list($sql, $bd, $a) = div_sql($sql, $bd); } #addition ksv1:list($sql,$bd,$a)=div_sql($sql,$bd);#fonction divergentes if (!$bd && strpos($sql, ' ciel.')) { $bd = 'ciel'; } elseif (!$bd && strpos($sql, ' p.')) { $bd = 'p'; } elseif (!$bd && strpos($sql, ' ben.')) { $bd = 'ben'; } ReM($bd, array($_ENV['defaultdb'], $_GET['defaultdb'], DB, 'localhost')); #av($sql,$bd); if (!$a) { $a = $_ENV['c']['sql'][$bd]; } #si non fournie par div_sql() if (!$a) { db("5.sqldb not defined : {$bd} {$sql}"); return; } #if(J9){echo'<pre>';print_r([$sql,$sa,$bd,SIP,$a,'dfdeb'=>$_ENV['defaultdb'],'getdef'=>$_GET['defaultdb'],'db'=>DB]);die;}#,ben,aws #$bd=ben,SIP=aws if (preg_match("~(/\\*|--|\\(\\{) '|\\x(00|1a)|;(drop|select|delete|update)|'? union select~i", $sql, $m)) { av('injection match', $m); FPC(ERLOGS, "\nsql injection:{$sql}", 4); return; } #injection tester - never add those $Stamp = substr($sql, 4, 15) . " " . substr($sql, -7); if (GT($Stamp) > 10000 and Preg_Match("~update |insert ~i", $sql)) { FAP(LOGS . "sql.decalees", $sql); return; } #check for these ones with a cron if (!e(',sqlon', 1)) { $bdsel = ''; } #could have been killed ..... if ($bd != $bdsel) { GT("sqlon" . $bd); $bdsel = $bd; #on recrée la connexion $_ENV['dbe'][] = $sql; if ($a[0] == '94.23.226.97') { return; } #server offline - returns null - Db(NU.'->'.$sql,'prio'); Rem($sa, SIP, $_ENV['server']); if (SIP == $a[0]) { $a[0] = '127.0.0.1'; } #si l'on tente de connecter à une ip définie et que c'est le localhost en réalité = #Si seulement, au final, on a changé de host if ($host != $a[0]) { $host = $a[0]; $GLOBALS['mysqlconnection'] = $_ENV['sqlconn'] = $conn = mysqli_connect($a[0], $a[1], $a[2]); if ($n = mysqli_connect_error() || !$conn) { File_put_contents(ini_get('error_log'), "\n" . SU . " > {$bd}/{$sql}; pas de connexion sql : " . $n . "-" . str_replace("\n", '', print_r($a, 1)), FILE_APPEND); Db(SU . " > {$bd}/{$sql}; pas de connexion sql : " . $n . "\n" . print_r($a, 1)); return; } $n = mysqli_error($conn); } if ($n) { Db('sqlerror ' . $sql . ' ' . $n); } #if(j10)fb("connect:$a[0],$a[1],$a[2]"); if (!$conn) { DB("!sqlcon:{$a['0']},{$a['1']},{$a['2']}"); } if (!$conn || $n && !stripos('uplicate', $n)) { av("nc:bd:{$bd}/{$sql}; {$n}"); rcache(); $host = $bdsel = 'dead'; Db(SU . " 503>nc:bd:{$bd}/{$sql}; {$n} "); R503("nc:{$bd}/{$sql}; {$n} " . pre($a)); return; } mysqli_select_db($conn, $bd); e(",sqlon:{$bd}"); } #e(','.$sql);; $_ENV['sql'][] = $sql; #bug:possible bug if semicolon within some field.. if (substr_count($sql, '¤') > 0 && $safe) { $x = mysqli_multi_query($conn, str_replace('¤', ';', $sql)); } elseif (substr_count($sql, '¤') > 0) { db('unsafe injection : ¤'); r404('¤'); } else { $x = mysqli_query($conn, $sql); } $_ENV['sqlquery'] = $x; $_GET['nSQL']++; $n = mysqli_error($conn); #todo:add pdo, mysqli, mysqlnd if ($n) { $_ENV['errors'][] = $n; if (j10) { FB($_ENV['args']); } if (Preg_match("~server has gone away|access denied~i", $n)) { rcache(); $status = 'dead'; R503($n); return; return sql($sql, $bd); } elseif ($n and !strpos($n, "uplicate entry")) { db("{$sql}; {$n} {$_SERVER['SCRIPT_FILENAME']} " . SU); } elseif ($n) { $_ENV['error'] .= "sqlfail:{$_SERVER['SCRIPT_FILENAME']} : {$sql} {$n}"; db($_ENV['error'], null, 'sql'); return; } #une erreur mais ... } if (Preg_match("~(update|delete) ~i", $sql)) { $x = Mysqli_affected_rows($conn); } if (Preg_match("~insert ~i", $sql)) { $x = Mysqli_insert_id($conn); } #ahah on nettoye les congestions $Temps = GT('sql:' . $_GET['nSQL'] . ':' . $sql); //Récupère la valeur du chrono if ($Temps > 4000 and !preg_match("~OPTIMIZE|CSF|ALTER~i", $sql) && 0) { #stopped $x2 = mysql_query("SHOW PROCESSLIST"); while ($t = @mysqli_fetch_assoc($x2)) { $killed[] = $t; if ($t["Time"] > 30) { mysql_query("kill {$t['Id']}"); $Temps .= "+kill {$t['Id']}"; db("kill {$Temps} >{$sql} via {$_SERVER['SCRIPT_FILENAME']}" . SU); } } if ($killed) { Bmail('sql killed', pre($killed)); } } #if(!Preg_match("~select ~i",$sql))av($sql."<li>".$x); return $x; #mysqli_free_result($x);//else echo mysql_error().$SQL; }