|
0) { $i=0; foreach($a_dialplan_includes as $row) { if ($row["dialplanincludeid"] == $faxid) { $order = $row['order']; unset($a_dialplan_includes[$i]); } $i++; } } //delete the dialplan include details. aka. child data if (count($a_dialplan_includes_details) > 0) { $i=0; foreach($a_dialplan_includes_details as $row) { if ($row["dialplanincludeid"] == $faxid) { unset($a_dialplan_includes_details[$i]); } $i++; } } if (file_exists($v_conf_dir."/dialplan/default/".$order."_".$faxname.".xml")){ unlink($v_conf_dir."/dialplan/default/".$order."_".$faxname.".xml"); } //remove fax entries unset($a_fax[$_GET['id']]); write_config(); header("Location: v_fax.php"); exit; } } } if (($_POST['type'] == "fax_send") && is_uploaded_file($_FILES['fax_file']['tmp_name'])) { $fax_number = $_POST['fax_number']; $fax_name = $_FILES['fax_file']['name']; $fax_name = str_replace(".tif", "", $fax_name); $fax_name = str_replace(".tiff", "", $fax_name); $fax_name = str_replace(".pdf", "", $fax_name); $fax_gateway = $_POST['fax_gateway']; $password = $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_password']; $port = $config['installedpackages']['freeswitchsettings']['config'][0]['event_socket_port']; $host = $config['interfaces']['lan']['ipaddr']; //upload the file move_uploaded_file($_FILES['fax_file']['tmp_name'], $dir_fax_temp.$_FILES['fax_file']['name']); $fax_file_extension = substr($dir_fax_temp.$_FILES['fax_file']['name'], -4); if ($fax_file_extension == ".pdf") { exec("cd ".$dir_fax_temp.";gs -q -sDEVICE=tiffg3 -r204x98 -dNOPAUSE -sOutputFile=".$fax_name.".tif -- ".$fax_name.".pdf -c quit"); //exec("rm ".$dir_fax_temp.$fax_name.".pdf"); } if ($fax_file_extension == ".tiff") { exec("cp ".$dir_fax_temp.$fax_name.".tiff ".$dir_fax_temp.$fax_name.".tif"); exec("rm ".$dir_fax_temp.$fax_name.".tiff"); } //send the fax $fp = event_socket_create($host, $port, $password); $cmd = "api originate [absolute_codec_string=PCMU]sofia/gateway/".$fax_gateway."/".$fax_number." &txfax(".$dir_fax_temp.$fax_name.".tif)"; $response = event_socket_request($fp, $cmd); $response = str_replace("\n", "", $response); $uuid = str_replace("+OK ", "", $response); fclose($fp); //if ($response >= 1) { // $fp = event_socket_create($host, $port, $password); // $cmd = "api uuid_getvar ".$uuid." fax_result_text"; // echo $cmd."\n"; // $response = event_socket_request($fp, $cmd); // $response = trim($response); // fclose($fp); //} sleep(5); //copy the .tif to the sent directory exec("cp ".$dir_fax_temp.$fax_name.".tif ".$dir_fax_sent.$fax_name.".tif"); //delete the .tif from the temp directory //exec("rm ".$dir_fax_temp.$fax_name.".tif"); //convert the tif to pdf and png exec("cd $dir_fax_sent; ".bin_dir."/tiff2png ".$dir_fax_sent.$fax_name.".tif"); exec("cd $dir_fax_sent; ".bin_dir."/tiff2pdf -f -o ".$fax_name.".pdf ".$dir_fax_sent.$fax_name.".tif"); header("Location: v_fax_edit.php?id=".$id."&msg=".$response); exit; } if ($_GET['a'] == "download") { session_cache_limiter('public'); if ($_GET['type'] == "fax_inbox") { if (file_exists($dir_fax_inbox.$_GET['filename'])) { $fd = fopen($dir_fax_inbox.$_GET['filename'], "rb"); if ($_GET['t'] == "bin") { header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Description: File Transfer"); header('Content-Disposition: attachment; filename="'.$_GET['filename'].'"'); } else { $file_ext = substr($_GET['filename'], -3); if ($file_ext == "png") { header("Content-Type: image/png"); } } header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Content-Length: " . filesize($dir_fax_inbox.$_GET['filename'])); fpassthru($fd); } else { echo "not found"; } exit; } } else { //echo $dir_fax_inbox.$_GET['filename']; } if ($_GET['a'] == "download") { session_cache_limiter('public'); if ($_GET['type'] == "fax_sent") { if (file_exists($dir_fax_sent.$_GET['filename'])) { $fd = fopen($dir_fax_sent.$_GET['filename'], "rb"); if ($_GET['t'] == "bin") { header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Description: File Transfer"); header('Content-Disposition: attachment; filename="'.$_GET['filename'].'"'); } else { $file_ext = substr($_GET['filename'], -3); if ($file_ext == "png") { header("Content-Type: image/png"); } } header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past header("Content-Length: " . filesize($dir_fax_sent.$_GET['filename'])); fpassthru($fd); } } exit; } else { //echo $dir_fax_inbox.$_GET['filename']; } if ($_GET['act'] == "del") { if ($_GET['type'] == 'fax_inbox') { //if ($a_fax[$_GET['id']]) { $tmp_file_array = split("\.",$_GET['filename']); $file_name = $tmp_file_array[0]; $file_ext = $tmp_file_array[1]; unlink_if_exists($dir_fax_inbox.$file_name.".pdf"); unlink_if_exists($dir_fax_inbox.$file_name.".png"); unlink_if_exists($dir_fax_inbox.$file_name.".tif"); //unset($a_fax[$_GET['id']]); write_config(); header("Location: v_fax.php"); exit; //} } } if ($_GET['act'] == "del") { if ($_GET['type'] == 'fax_sent') { //if ($a_fax[$_GET['id']]) { $tmp_file_array = split("\.",$_GET['filename']); $file_name = $tmp_file_array[0]; $file_ext = $tmp_file_array[1]; unlink_if_exists($dir_fax_sent.$file_name.".pdf"); unlink_if_exists($dir_fax_sent.$file_name.".png"); unlink_if_exists($dir_fax_sent.$file_name.".tif"); //unset($a_fax[$_GET['id']]); write_config(); header("Location: v_fax.php"); exit; //} } } if ($_POST) { unset($input_errors); $pconfig = $_POST; if (!$input_errors) { $ent = array(); if (strlen($_POST['faxid']) > 0) { $ent['faxid'] = $_POST['faxid']; } else { $ent['faxid'] = guid(); } $ent['faxextension'] = $_POST['faxextension']; $ent['faxname'] = $_POST['faxname']; $ent['faxemail'] = $_POST['faxemail']; $ent['faxdomain'] = $_POST['faxdomain']; $ent['faxdescription'] = $_POST['faxdescription']; if (isset($id) && $a_fax[$id]) { //update $a_fax[$id] = $ent; } else { //add $a_fax[] = $ent; } if (!is_dir($v_storage_dir)) { exec("mkdir ".$v_storage_dir); } if (!is_dir($v_storage_dir.'/fax/')) { exec("mkdir ".$v_storage_dir."/fax/"); } $faxfolder = $v_storage_dir.'/fax/'.$_POST['faxextension']; if (!is_dir($faxfolder)) { exec('mkdir '.$faxfolder); } if (!is_dir($faxfolder.'/inbox/')) { exec('mkdir '.$faxfolder.'/inbox/'); } if (!is_dir($faxfolder.'/sent/')) { exec('mkdir '.$faxfolder.'/sent/'); } if (!is_dir($faxfolder.'/temp/')) { exec('mkdir '.$faxfolder.'/temp/'); } write_config(); sync_package_v_fax(); header("Location: v_fax.php"); exit; } } include("head.inc"); ?>
$v_label: FAX: Edit\n"; } if ($input_errors) print_input_errors($input_errors); ?>
|