summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcookie <cookie@29ba0400-6e00-0410-a75a-ca02368028f8>2006-11-29 17:09:25 +0000
committercookie <cookie@29ba0400-6e00-0410-a75a-ca02368028f8>2006-11-29 17:09:25 +0000
commit30876a0a85897125854226112d8de7f19a707dad (patch)
tree0e9dc32d8e596096b817242746e66a0f48f0d909
parentf8fbc9c0cf182963e92a176dd84c569b00ab42f5 (diff)
cron joby aufgereumt
git-svn-id: svn://svn.cccv.de/engel-system@181 29ba0400-6e00-0410-a75a-ca02368028f8
-rwxr-xr-xdefault-conf/www-ssl/inc/config.php3
-rw-r--r--default-conf/www-ssl/inc/config_IAX.php9
-rw-r--r--default-conf/www-ssl/inc/config_modem.php11
-rwxr-xr-xservices/cron_dect_asterisk.php52
-rwxr-xr-xservices/dect_cron.php69
-rwxr-xr-xservices/dect_cron_asterisk.php120
-rw-r--r--www-ssl/inc/config_modem.php11
-rwxr-xr-xwww-ssl/inc/funktion_cron.php100
-rwxr-xr-xwww-ssl/inc/funktion_modem.php16
9 files changed, 187 insertions, 204 deletions
diff --git a/default-conf/www-ssl/inc/config.php b/default-conf/www-ssl/inc/config.php
index ccf359c4..3e2c3b51 100755
--- a/default-conf/www-ssl/inc/config.php
+++ b/default-conf/www-ssl/inc/config.php
@@ -31,9 +31,6 @@ $show_SSLCERT = "MD5:<br>FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF:FF<br>\n".
//globale const. fuer schischtplan
$GlobalZeileProStunde = 4;
-//ist ein modem angeschlossen
-$ModemEnable = false;
-
//Tempdir
$Tempdir="/tmp";
diff --git a/default-conf/www-ssl/inc/config_IAX.php b/default-conf/www-ssl/inc/config_IAX.php
new file mode 100644
index 00000000..f5bdeaeb
--- /dev/null
+++ b/default-conf/www-ssl/inc/config_IAX.php
@@ -0,0 +1,9 @@
+<?PHP
+
+$IAXenable = TRUE;
+
+//Setting Asterisk
+$IAXcontent="Engelsystem";
+$IAXserver="Engelsystem:engelengel@10.1.1.1";
+
+?>
diff --git a/default-conf/www-ssl/inc/config_modem.php b/default-conf/www-ssl/inc/config_modem.php
new file mode 100644
index 00000000..0625936d
--- /dev/null
+++ b/default-conf/www-ssl/inc/config_modem.php
@@ -0,0 +1,11 @@
+<?PHP
+
+//ist ein modem angeschlossen
+$ModemEnable = false;
+
+// COM port
+$ModemDev="/dev/ttyS0";
+
+// vorwahl, bei tnovis telefonanlage für das programmieren von weckrufen
+$WackupNumber="**3";
+?>
diff --git a/services/cron_dect_asterisk.php b/services/cron_dect_asterisk.php
new file mode 100755
index 00000000..73e1f199
--- /dev/null
+++ b/services/cron_dect_asterisk.php
@@ -0,0 +1,52 @@
+<?PHP
+
+include ("./inc/config.php");
+include ("./inc/config_IAX.php");
+include ("./inc/config_db.php");
+include ("./inc/error_handler.php");
+include ("./inc/funktion_modem.php");
+include ("./inc/funktion_cron.php");
+
+//ausfuerungs Ruetmuss (in s)
+$StartTimeBeforEvent = (60/4)*60;
+$AnrufDelay = -5;
+$DebugDECT=FALSE;
+
+//Timeout erhöhen;
+set_time_limit(50000);
+
+//SQL zusammensetzen
+$SQL = "SELECT Shifts.DateS, Shifts.RID, ShiftEntry.UID, ShiftEntry.TID ".
+ "FROM `Shifts` INNER JOIN `ShiftEntry` ON `Shifts`.`SID` = `ShiftEntry`.`SID` ";
+if( $DebugDECT)
+ $SQL .= "WHERE (Shifts.DateS>'2004-12-27 10:45:00' AND ".
+ "Shifts.DateS<='2004-12-27 11:00:00');";
+else
+ $SQL .= "WHERE ((`Shifts`.`DateS`>'". gmdate("Y-m-d H:i:s", time()+3600+120). "') AND ".
+ "(`Shifts`.`DateS`<='". gmdate("Y-m-d H:i:s", time()+3600+120+$StartTimeBeforEvent). "') );";
+
+$Erg = mysql_query($SQL, $con);
+echo mysql_error($con);
+
+for( $i=0; $i<mysql_num_rows($Erg); $i++)
+{
+ if( mysql_result($Erg, $i, "UID")>0)
+ {
+ $DECTnumber = UID2DECT(mysql_result($Erg, $i, "UID"));
+ if( $DECTnumber!="")
+ {
+ DialNumberIAX( $DECTnumber,
+ mysql_result($Erg, $i, "DateS"),
+ mysql_result($Erg, $i, "RID"),
+ mysql_result($Erg, $i, "TID"));
+ DialNumberModem( $DECTnumber,
+ mysql_result($Erg, $i, "DateS"));
+ }
+ }
+}
+
+return 0;
+
+
+?>
+
diff --git a/services/dect_cron.php b/services/dect_cron.php
deleted file mode 100755
index 00119567..00000000
--- a/services/dect_cron.php
+++ /dev/null
@@ -1,69 +0,0 @@
-<?PHP
-
-
-include ("./inc/db.php");
-include ("./inc/config.php");
-include ("./inc/funktion_modem.php");
-
-//ausfuerungs Ruetmuss (in s)
-$StartTimeBeforEvent = (60/4)*60;
-
-
-
-
-function UID2DECT($UID)
-{
- include ("./inc/db.php");
-
- $SQL = "SELECT DECT FROM `User` WHERE UID='$UID'";
- $Erg = mysql_query($SQL, $con);
-
- return mysql_result($Erg, 0);
-}
-
-
-$SQL = "SELECT Shifts.DateS, ShiftEntry.UID ".
- "FROM `Shifts` INNER JOIN `ShiftEntry` ON `Shifts`.`SID` = `ShiftEntry`.`SID` ".
- "WHERE ((`Shifts`.`DateS`>'". gmdate("Y-m-d H:i:s", time()+3600+120). "') AND ".
- "(`Shifts`.`DateS`<='". gmdate("Y-m-d H:i:s", time()+3600+120+$StartTimeBeforEvent). "') );";
-// "WHERE (Shifts.DateS>'2004-12-27 10:45:00' AND ".
-// "Shifts.DateS<='2004-12-27 11:00:00');";
-
-$Erg = mysql_query($SQL, $con);
-
-echo mysql_error($con);
-
-for( $i=0; $i<mysql_num_rows($Erg); $i++)
-{
-// echo mysql_result($Erg, $i, "UID");
- if( mysql_result($Erg, $i, "UID")>0)
- {
- $SQL2 = "SELECT DECT FROM `User` WHERE ( `UID`='". mysql_result($Erg, $i, "UID"). "');";
- $Erg2 = mysql_query($SQL2, $con);
-
- $Number = mysql_result($Erg2, 0, "DECT");
- if( $Number!="")
- {
- $TimeH = substr( mysql_result($Erg, $i, "DateS"), 11, 2);
- $TimeM = substr( mysql_result($Erg, $i, "DateS"), 14, 2);
- $TimeM = substr( mysql_result($Erg, $i, "DateS"), 14, 2) - 5;
- if( $TimeM < 0 )
- {
- $TimeM += 60;
- $TimeH -= 1;
- }
- if( $TimeH < 0 )
- $TimeH += 24;
-
- if( strlen( $TimeH) == 1)
- $TimeH = "0".$TimeH;
-
- SetWackeup( $Number, $TimeH, $TimeM);
- }
- }
-}
-
-return 0;
-
-?>
-
diff --git a/services/dect_cron_asterisk.php b/services/dect_cron_asterisk.php
deleted file mode 100755
index 06ff2d50..00000000
--- a/services/dect_cron_asterisk.php
+++ /dev/null
@@ -1,120 +0,0 @@
-<?PHP
-
-include ("./inc/db.php");
-include ("./inc/config.php");
-
-//ausfuerungs Ruetmuss (in s)
-$StartTimeBeforEvent = (60/4)*60;
-$DebugDECT=FALSE;
-
-//Setting Asterisk
-$Content="Engelsystem";
-$IAXserver="Engelsystem:engelengel@10.1.1.1";
-
-function DialNumber( $DECTnumber, $TimeH, $TimeM, $Room, $Engeltype)
-{
- global $Content, $IAXserver, $ModemEnable;
-
- $CallFile = "/tmp/call_". date("Ymd_His"). "_$DECTnumber";
- if( $ModemEnable)
- {
- $file = fopen( $CallFile, 'w' );
- if( $file != FALSE)
- {
- fputs( $file, "Channel: IAX2/$IAXserver/Engelserver@$Content\n");
- fputs( $file, "Callerid: $Content\n");
- fputs( $file, "Context: $Content\n");
- fputs( $file, "Extension: s\n");
- fputs( $file, "MaxRetries: 3\n");
- fputs( $file, "RetryTime: 10\n");
- fputs( $file, "SetVar: TimeH=$TimeH\n");
- fputs( $file, "SetVar: TimeM=$TimeM\n");
- fputs( $file, "SetVar: DECTnumber=$DECTnumber\n");
- fputs( $file, "SetVar: Room=$Room\n");
- fputs( $file, "SetVar: Engeltype=$Engeltype\n");
- fclose($file);
-
- system( "cat $CallFile");
- system( "chmod 777 $CallFile");
- system( "mv $CallFile /var/spool/asterisk/outgoing");
- }
- }
- else
- echo "Modem is Disable, number:'$DECTnumber' with the Parameter, Time:'$TimeH:$TimeM', Room:'$Room', Type:'$Engeltype' was called<br>\n";
-}
-
-function UID2DECT($UID)
-{
- global $con;
- $SQL = "SELECT DECT FROM `User` WHERE UID='$UID'";
- $Erg = mysql_query($SQL, $con);
- return mysql_result($Erg, 0);
-}
-function RID2Room($RID)
-{
- global $con;
- $SQL = "SELECT Name FROM `Room` WHERE RID='$RID'";
- $Erg = mysql_query($SQL, $con);
- return mysql_result($Erg, 0);
-}
-
-function TID2Engeltype($TID)
-{
- global $con;
- $SQL = "SELECT Name FROM `EngelType` WHERE TID='$TID'";
- $Erg = mysql_query($SQL, $con);
- return mysql_result($Erg, 0);
-}
-
-
-
-$SQL = "SELECT Shifts.DateS, Shifts.RID, ShiftEntry.UID, ShiftEntry.TID ".
- "FROM `Shifts` INNER JOIN `ShiftEntry` ON `Shifts`.`SID` = `ShiftEntry`.`SID` ";
-if( $DebugDECT)
- $SQL .= "WHERE (Shifts.DateS>'2004-12-27 10:45:00' AND ".
- "Shifts.DateS<='2004-12-27 11:00:00');";
-else
- $SQL .= "WHERE ((`Shifts`.`DateS`>'". gmdate("Y-m-d H:i:s", time()+3600+120). "') AND ".
- "(`Shifts`.`DateS`<='". gmdate("Y-m-d H:i:s", time()+3600+120+$StartTimeBeforEvent). "') );";
-
-$Erg = mysql_query($SQL, $con);
-
-echo mysql_error($con);
-
-for( $i=0; $i<mysql_num_rows($Erg); $i++)
-{
-// echo mysql_result($Erg, $i, "UID");
- if( mysql_result($Erg, $i, "UID")>0)
- {
- $SQL2 = "SELECT DECT FROM `User` WHERE ( `UID`='". mysql_result($Erg, $i, "UID"). "');";
- $Erg2 = mysql_query($SQL2, $con);
-
- $Number = mysql_result($Erg2, 0, "DECT");
- if( $Number!="")
- {
- $TimeH = substr( mysql_result($Erg, $i, "DateS"), 11, 2);
- $TimeM = substr( mysql_result($Erg, $i, "DateS"), 14, 2);
- $TimeM = substr( mysql_result($Erg, $i, "DateS"), 14, 2) - 5;
- if( $TimeM < 0 )
- {
- $TimeM += 60;
- $TimeH -= 1;
- }
- if( $TimeH < 0 )
- $TimeH += 24;
-
- if( strlen( $TimeH) == 1)
- $TimeH = "0".$TimeH;
-
- $Room = RID2Room( mysql_result($Erg, $i, "RID"));
- $EngelType = TID2Engeltype( mysql_result($Erg, $i, "TID"));
- DialNumber( $Number, $TimeH, $TimeM, $Room, $EngelType);
- }
- }
-}
-
-return 0;
-
-
-?>
-
diff --git a/www-ssl/inc/config_modem.php b/www-ssl/inc/config_modem.php
new file mode 100644
index 00000000..0625936d
--- /dev/null
+++ b/www-ssl/inc/config_modem.php
@@ -0,0 +1,11 @@
+<?PHP
+
+//ist ein modem angeschlossen
+$ModemEnable = false;
+
+// COM port
+$ModemDev="/dev/ttyS0";
+
+// vorwahl, bei tnovis telefonanlage für das programmieren von weckrufen
+$WackupNumber="**3";
+?>
diff --git a/www-ssl/inc/funktion_cron.php b/www-ssl/inc/funktion_cron.php
new file mode 100755
index 00000000..d2afa70b
--- /dev/null
+++ b/www-ssl/inc/funktion_cron.php
@@ -0,0 +1,100 @@
+<?PHP
+
+function UID2DECT($UID)
+{
+ global $con;
+ $SQL = "SELECT DECT FROM `User` WHERE UID='$UID'";
+ $Erg = mysql_query($SQL, $con);
+ return mysql_result($Erg, 0);
+}
+function RID2Room($RID)
+{
+ global $con;
+ $SQL = "SELECT Name FROM `Room` WHERE RID='$RID'";
+ $Erg = mysql_query($SQL, $con);
+ return mysql_result($Erg, 0);
+}
+
+function TID2Engeltype($TID)
+{
+ global $con;
+ $SQL = "SELECT Name FROM `EngelType` WHERE TID='$TID'";
+ $Erg = mysql_query($SQL, $con);
+ return mysql_result($Erg, 0);
+}
+
+
+function DialNumberIAX( $DECTnumber, $Time, $RID, $TID)
+{
+ global $IAXenable, $IAXcontent, $IAXserver, $AnrufDelay;
+
+ //Parameter verarbeiten
+ $TimeH = substr( $Time, 11, 2);
+ $TimeM = substr( $Time, 14, 2);
+ $TimeM = substr( $Time, 14, 2) + $AnrufDelay;
+ if( $TimeM < 0 )
+ {
+ $TimeM += 60;
+ $TimeH -= 1;
+ }
+ if( $TimeH < 0 )
+ $TimeH += 24;
+
+ if( strlen( $TimeH) == 1)
+ $TimeH = "0".$TimeH;
+
+ // IAX file Schareiebn
+ $CallFile = "/tmp/call_". date("Ymd_His"). "_$DECTnumber";
+
+ if( $IAXenable)
+ {
+ $file = fopen( $CallFile, 'w' );
+ if( $file != FALSE)
+ {
+ fputs( $file, "Channel: IAX2/$IAXserver/Engelserver@$IAXcontent\n");
+ fputs( $file, "Callerid: $IAXcontent\n");
+ fputs( $file, "Context: $IAXcontent\n");
+ fputs( $file, "Extension: s\n");
+ fputs( $file, "MaxRetries: 3\n");
+ fputs( $file, "RetryTime: 10\n");
+ fputs( $file, "SetVar: TimeH=$TimeH\n");
+ fputs( $file, "SetVar: TimeM=$TimeM\n");
+ fputs( $file, "SetVar: DECTnumber=$DECTnumber\n");
+ fputs( $file, "SetVar: Room=". RID2Room( $RID). "\n");
+ fputs( $file, "SetVar: Engeltype=". TID2Engeltype( $TID). "\n");
+ fclose($file);
+ system( "cat $CallFile");
+ system( "chmod 777 $CallFile");
+ system( "mv $CallFile /var/spool/asterisk/outgoing");
+ }
+ }
+ else
+ echo "IAX is disable\n";
+}
+
+function DialNumberModem( $DECTnumber, $Time)
+{
+ global $AnrufDelay;
+
+ //Parameter verarbeiten
+ $TimeH = substr( $Time, 11, 2);
+ $TimeM = substr( $Time, 14, 2);
+ $TimeM = substr( $Time, 14, 2) + $AnrufDelay;
+ if( $TimeM < 0 )
+ {
+ $TimeM += 60;
+ $TimeH -= 1;
+ }
+ if( $TimeH < 0 )
+ $TimeH += 24;
+
+ if( strlen( $TimeH) == 1)
+ $TimeH = "0".$TimeH;
+
+ SetWackeup( $DECTnumber, $TimeH, $TimeM);
+}
+
+return 0;
+
+?>
+
diff --git a/www-ssl/inc/funktion_modem.php b/www-ssl/inc/funktion_modem.php
index a8ae010d..6cbbb49b 100755
--- a/www-ssl/inc/funktion_modem.php
+++ b/www-ssl/inc/funktion_modem.php
@@ -1,20 +1,14 @@
<?PHP
-
-$Dev="/dev/ttyS0"; // COM port
-$WackupNumber="**3";
-
-//ob_end_flush(); //ausgabe obwohl skript nich in arbeit
-set_time_limit(50000); //Timeout erhöhen;
+include "./inc/config_modem.php";
function DialNumber( $Number )
{
global $Dev, $ModemEnable;
-echo $Number;
-
if( $ModemEnable)
{
- $fp = fopen( $Dev, "w");
+ echo "Dial number: '<u>$Number</u>' was called<br>\n";
+ $fp = fopen( $ModemDev, "w");
sleep(1);
fwrite( $fp, "+++");
sleep(1);
@@ -28,9 +22,7 @@ echo $Number;
sleep(1);
}
else
- {
- echo "Modem is Disable, number: '<u>$Number</u>' was called<br>\n";
- }
+ echo "Modem is Disable, number: '<u>$Number</u>' was not called<br>\n";
}