$xml_cdr_dir = $_SESSION['switch']['log']['dir'] . '/xml_cdr'; $dir_handle = opendir($xml_cdr_dir); $x = 0; while ($file = readdir($dir_handle)) { if ($file != '.' && $file != '..') { if (!is_dir($xml_cdr_dir . '/' . $file)) { //get the leg of the call if (substr($file, 0, 2) == "a_") { $leg = "a"; } else { $leg = "b"; } //get the xml cdr string $xml_string = file_get_contents($xml_cdr_dir . '/' . $file); //parse the xml and insert the data into the db process_xml_cdr($db, $leg, $xml_string); //delete the file after it has been imported unlink($xml_cdr_dir . '/' . $file); $x++; } } } closedir($dir_handle); //debug true if ($debug) { $content = ob_get_contents(); //get the output from the buffer ob_end_clean(); //clean the buffer $time = "\n\n{$insert_count} inserts in: " . number_format($insert_time, 5) . " seconds.\n"; $time .= "Other processing time: " . number_format(microtime(true) - $time5 - $insert_time, 5) . " seconds.\n";
//parse the xml and insert the data into the db process_xml_cdr($db, $v_log_dir, $xml_string); } //check the filesystem for xml cdr records that were missed $xml_cdr_dir = $v_log_dir . '/xml_cdr'; $dir_handle = opendir($xml_cdr_dir); $x = 0; while ($file = readdir($dir_handle)) { if ($file != '.' && $file != '..') { if (!is_dir($xml_cdr_dir . '/' . $file)) { //echo $x.": ".$xml_cdr_dir.'/'.$file."<br />\n"; $xml_string = file_get_contents($xml_cdr_dir . '/' . $file); //echo strlen($xml_string)." length<br />\n"; //echo $xml_string."<br />\n"; //parse the xml and insert the data into the db process_xml_cdr($db, $v_log_dir, $xml_string); //delete the file after it has been imported unlink($xml_cdr_dir . '/' . $file); $x++; } } } closedir($dir_handle); //testing //ob_end_clean(); //clean the buffer //ob_start(); //phpinfo(); //$content = ob_get_contents(); //get the output from the buffer //ob_end_clean(); //clean the buffer //$fp = fopen('/tmp/test.htm', 'w'); //fwrite($fp, $content);