diff options
author | cookie <cookie@29ba0400-6e00-0410-a75a-ca02368028f8> | 2006-11-08 21:00:04 +0000 |
---|---|---|
committer | cookie <cookie@29ba0400-6e00-0410-a75a-ca02368028f8> | 2006-11-08 21:00:04 +0000 |
commit | 07776d01ef06dcd25df25303c92a9fa8c650ca45 (patch) | |
tree | 4d0bebaa1b4803a9641e3cd50a1efef2be61349f /services | |
parent | 54eddebc929ca92009234cbc030522125a9a2019 (diff) |
grundgeruest fur srevice (jabberbot)
git-svn-id: svn://svn.cccv.de/engel-system@150 29ba0400-6e00-0410-a75a-ca02368028f8
Diffstat (limited to 'services')
-rwxr-xr-x | services/dect_clear.php | 25 | ||||
-rwxr-xr-x | services/dect_cron.php | 69 | ||||
-rwxr-xr-x | services/dect_cron_asterisk.php | 120 | ||||
l--------- | services/inc | 1 | ||||
-rwxr-xr-x | services/jabberserver.php | 113 |
5 files changed, 328 insertions, 0 deletions
diff --git a/services/dect_clear.php b/services/dect_clear.php new file mode 100755 index 00000000..a01241be --- /dev/null +++ b/services/dect_clear.php @@ -0,0 +1,25 @@ +<?PHP +// löscht alle eintrag in der telefonanlage, indem jede nummer einzähln gelöscht wir (#10<NUMBER>) + +include ("./inc/db.php"); +include ("./inc/config.php"); +include ("./inc/funktion_modem.php"); + + +$SQL = "SELECT DECT FROM `User`;"; + +$Erg = mysql_query($SQL, $con); + +echo mysql_error($con); + +for( $i=0; $i<mysql_num_rows($Erg); $i++) +{ + $Number = "#10". mysql_result($Erg, $i, "DECT"); + if( strlen($Number)==7) + DialNumber( $Number); +} + +return 0; + +?> + diff --git a/services/dect_cron.php b/services/dect_cron.php new file mode 100755 index 00000000..00119567 --- /dev/null +++ b/services/dect_cron.php @@ -0,0 +1,69 @@ +<?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 new file mode 100755 index 00000000..06ff2d50 --- /dev/null +++ b/services/dect_cron_asterisk.php @@ -0,0 +1,120 @@ +<?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/services/inc b/services/inc new file mode 120000 index 00000000..54c38819 --- /dev/null +++ b/services/inc @@ -0,0 +1 @@ +../www-ssl/inc
\ No newline at end of file diff --git a/services/jabberserver.php b/services/jabberserver.php new file mode 100755 index 00000000..9bdd209a --- /dev/null +++ b/services/jabberserver.php @@ -0,0 +1,113 @@ +<?php
+
+/****************************************************************************************************/
+// INCLUDE
+/****************************************************************************************************/
+require_once('./inc/jabber.php');
+require_once("./inc/funktion_jabber.php");
+include("./inc/config_MessegeServer.php");
+
+// Set time limit to indefinite execution
+set_time_limit( 0 );
+
+/****************************************************************************************************/
+// show MODE
+/****************************************************************************************************/
+if( DEBUG)
+ echo "DEBUG mode is enable\n\tjabber is disable\n\n";
+
+/****************************************************************************************************/
+// INIT jabber
+/****************************************************************************************************/
+if( !DEBUG)
+{
+ echo "INIT jabber\n";
+ $jabber = new Jabber($server, $port, $username, $password, $resource);
+ if ( !($jabber->Connect() && $jabber->SendAuth()))
+ die("Couldn't connect to Jabber Server.");
+}
+
+
+/****************************************************************************************************/
+// INIT socked
+/****************************************************************************************************/
+echo "INIT socked\n";
+ //http://de3.php.net/manual/de/function.socket-listen.php
+// Create a UDP socket
+$sock = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP) or die('Could not create socked ('.socket_strerror(socket_last_error()). ')');
+// Bind the socket to an address/port
+socket_bind($sock, SERVER_ADDRESS, SERVER_PORT) or die('Could not bind to address ('.socket_strerror(socket_last_error()). ')');
+// Setzt Nonbock Mode
+socket_set_nonblock($sock);
+
+
+/****************************************************************************************************/
+// Loop continuos
+/****************************************************************************************************/
+$RUNNING = TRUE;
+while( $RUNNING )
+{
+ if( @socket_recvfrom($sock, $data, 65535, 0, $ip, $port))
+ {
+ //daten empfangen
+ $data = substr($data,0, strlen($data)-1); //ENTER entfernen
+ echo "\n". gmdate("Y-m-d H:i:s", time()). "\tresive from $ip:$port ". strlen($data). " byte data ($data)\n";
+ PackedAnalyser( $data);
+ }
+
+ usleep(100000); // 100ms delay keeps the doctor away
+} // end while
+
+//disconnect jabber
+if( !DEBUG)
+ $jabber->Disconnect();
+
+// Close the master sockets
+socket_close($sock);
+
+/****************************************************************************************************/
+/****************************************** MAIN END ************************************************/
+/****************************************************************************************************/
+
+
+/****************************************************************************************************/
+//***** function PackedAnalyser
+/****************************************************************************************************/
+function PackedAnalyser( $data )
+{
+ GLOBAL $jabber, $RUNNING;
+ // init array
+ $matches = array();
+
+ //#message
+ if( preg_match( "/^#(message) ([^ ]+) (.+)/i", $data, $matches ) )
+ {
+ if( $matches[2]=="" || $matches[3]=="")
+ {
+ // Wrong syntax
+ echo "\t\t\t\t#messaage parameter fail\n";
+ }
+ else
+ {
+ // Whisper
+ if( !DEBUG)
+ $jabber->SendMessage($value, "normal", NULL, array("body" => $message, "subject" => "Error in Pentabarf"), NULL);
+ else
+ echo "\t\t\t\tmessage to:\"". $matches[2]. "\" Text: \"". $matches[3]. "\"\n";
+ }
+ }
+ elseif( preg_match( "/^#quit/i", $data, $matches ) )
+ {
+ if( DEBUG)
+ {
+ echo "\t\t\t\tSystem Shutdown\n\n";
+ $RUNNING = FALSE;
+ }
+ }
+ else
+ {
+ echo "\t\t\t\tcommand not found\n\n";
+ }
+}
+
+?>
|