From f73f9b706f5ce4baea9f0e18f5af003eb688c052 Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Thu, 21 Apr 2022 22:15:45 -0600 Subject: [PATCH] Move Session code to a better location in the file. --- app/fax_queue/resources/service/fax_queue.php | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/app/fax_queue/resources/service/fax_queue.php b/app/fax_queue/resources/service/fax_queue.php index d7f15c2196..d5ae723476 100644 --- a/app/fax_queue/resources/service/fax_queue.php +++ b/app/fax_queue/resources/service/fax_queue.php @@ -72,12 +72,44 @@ return $exists; } +//check to see if the process exists + $pid_exists = process_exists($pid_file); + +//prevent the process running more than once + if ($pid_exists) { + echo "Cannot lock pid file {$pid_file}\n"; + exit; + } + //fax queue enabled if ($_SESSION['fax_queue']['enabled']['boolean'] != 'true') { echo "FAX Queue is disabled in Default Settings\n"; exit; } +//make sure the /var/run/fusionpbx directory exists + if (!file_exists('/var/run/fusionpbx')) { + $result = mkdir('/var/run/fusionpbx', 0777, true); + if (!$result) { + die('Failed to create /var/run/fusionpbx'); + } + } + +//create the process id file if the process doesn't exist + if (!$pid_exists) { + //remove the old pid file + if (file_exists($file)) { + unlink($pid_file); + } + + //show the details to the user + //echo "The process id is ".getmypid()."\n"; + //echo "pid_file: ".$pid_file."\n"; + + //save the pid file + file_put_contents($pid_file, getmypid()); + } + //get the call center settings $interval = $_SESSION['fax_queue']['interval']['numeric']; @@ -103,38 +135,6 @@ $debug = $_SESSION['fax_queue']['debug']['boolean']; } -//check to see if the process exists - $pid_exists = process_exists($pid_file); - -//prevent the process running more than once - if ($pid_exists) { - echo "Cannot lock pid file {$pid_file}\n"; - exit; - } - -//make sure the /var/run/fusionpbx directory exists - if (!file_exists('/var/run/fusionpbx')) { - $result = mkdir('/var/run/fusionpbx', 0777, true); - if (!$result) { - die('Failed to create /var/run/fusionpbx'); - } - } - -//create the process id file if the process doesn't exist - if (!$pid_exists) { - //remove the old pid file - if (file_exists($file)) { - unlink($pid_file); - } - - //show the details to the user - //echo "The process id is ".getmypid()."\n"; - //echo "pid_file: ".$pid_file."\n"; - - //save the pid file - file_put_contents($pid_file, getmypid()); - } - //get the messages waiting in the email queue while (true) {