diff --git a/app/fax_queue/resources/service/fax_queue.php b/app/fax_queue/resources/service/fax_queue.php new file mode 100644 index 0000000000..f4f2cca6dc --- /dev/null +++ b/app/fax_queue/resources/service/fax_queue.php @@ -0,0 +1,214 @@ + :interval) "; + $sql .= ") "; + $sql .= "or ( "; + $sql .= " fax_status = 'sent' "; + $sql .= " and fax_notify_date is null "; + $sql .= ") "; + $sql .= "and hostname = :hostname "; + $sql .= "order by domain_uuid asc "; + $sql .= "limit :limit "; + if (isset($hostname)) { + $parameters['hostname'] = $hostname; + } + else { + $parameters['hostname'] = gethostname(); + } + $parameters['limit'] = $fax_queue_limit; + $parameters['interval'] = $fax_queue_interval; + $database = new database; + $fax_queue = $database->select($sql, $parameters, 'all'); + unset($parameters); + + //process the messages + if (is_array($fax_queue) && @sizeof($fax_queue) != 0) { + foreach($fax_queue as $row) { + $command = "cd /var/www/fusionpbx && /usr/bin/php /var/www/fusionpbx/app/fax_queue/resources/job/fax_send.php "; + $command .= "'action=send&fax_queue_uuid=".$row["fax_queue_uuid"]."&hostname=".$hostname."&debug=true'"; + if (isset($debug)) { + //run process inline to see debug info + echo $command."\n"; + $result = system($command); + echo $result."\n"; + } + else { + //starts process rapidly doesn't wait for previous process to finish (used for production) + echo $command."\n"; + $handle = popen($command." > /dev/null &", 'r'); + echo "'$handle'; " . gettype($handle) . "\n"; + $read = fread($handle, 2096); + echo $read; + pclose($handle); + } + } + } + + //pause to prevent excessive database queries + sleep($interval); + } + +//remove the old pid file + if (file_exists($file)) { + unlink($pid_file); + } + +//save output to + //$fp = fopen(sys_get_temp_dir()."/mailer-app.log", "a"); + +//prepare the output buffers + //ob_end_clean(); + //ob_start(); + +//message divider for log file + //echo "\n\n=============================================================================================================================================\n\n"; + +//get and save the output from the buffer + //$content = ob_get_contents(); //get the output from the buffer + //$content = str_replace("
", "", $content); + + //ob_end_clean(); //clean the buffer + + //fwrite($fp, $content); + //fclose($fp); + +//notes + //echo __line__."\n"; + // if not keeping the email then need to delete it after the voicemail is emailed + +//how to use this feature + // cd /var/www/fusionpbx; /usr/bin/php /var/www/fusionpbx/app/fax_queue/resources/send.php + +?>