summaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorMoritz helios Rudert <helios@planetcyborg.de>2011-06-01 12:13:39 +0200
committerMoritz helios Rudert <helios@planetcyborg.de>2011-06-01 12:13:39 +0200
commit75448045cfe70054c8f4bae1bcfaf9bb0f70d330 (patch)
tree6a4d3d35019cdf933c1816e8522dc5d2557f5238 /services
parent12e0b0d809c29d435a247798d7318cc9835980ea (diff)
fixes
Diffstat (limited to 'services')
-rwxr-xr-xservices/cron_dect.php106
-rwxr-xr-xservices/dect_clear.php32
-rwxr-xr-xservices/jabberserver.php188
3 files changed, 136 insertions, 190 deletions
diff --git a/services/cron_dect.php b/services/cron_dect.php
index b5e338c6..57d12e0f 100755
--- a/services/cron_dect.php
+++ b/services/cron_dect.php
@@ -1,61 +1,51 @@
-<?PHP
-
-include ("../includes/config.php");
-include ("../includes/config_IAX.php");
-include ("../includes/config_db.php");
-include ("../includes/error_handler.php");
-include ("../includes/funktion_modem.php");
-include ("../includes/funktion_cron.php");
-
-
-//ausfuerungs Ruetmuss (in s)
-$StartTimeBeforEvent = (60/4)*60;
-$AnrufDelay = -5;
-$DebugDECT = FALSE;
-#$DebugDECT = TRUE;
-
-//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>'2007-07-09 09:45:00' AND ".
- "Shifts.DateS<='2007-07-09 11:00:00');";
-else
- $SQL .= "WHERE ((`Shifts`.`DateS`>'". gmdate("Y-m-d H:i:s", time()+120+$gmdateOffset). "') AND ".
- "(`Shifts`.`DateS`<='". gmdate("Y-m-d H:i:s", time()+120+$gmdateOffset+$StartTimeBeforEvent). "') );";
-
-$Erg = mysql_query($SQL, $con);
-echo mysql_error($con);
-
-$Z=0;
-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!="")
- {
- echo "dial $DECTnumber\n";
- DialNumberIAX( $DECTnumber,
- mysql_result($Erg, $i, "DateS"),
- mysql_result($Erg, $i, "RID"),
- mysql_result($Erg, $i, "TID"));
- DialNumberModem( $DECTnumber,
- mysql_result($Erg, $i, "DateS"));
- if( $Z++>10)
- {
- $Z=0;
- sleep(30);
- }
- }
+<?php
+ include "../includes/config.php";
+ include "../includes/config_IAX.php";
+ include "../includes/config_db.php";
+ include "../includes/error_handler.php";
+ include "../includes/funktion_modem.php";
+ include "../includes/funktion_cron.php";
+
+ // ausfuerungs Ruetmuss (in s)
+ $StartTimeBeforEvent = (60 / 4) * 60;
+ $AnrufDelay = -5;
+ $DebugDECT = false;
+
+ // Timeout erhoehen
+ 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>'2007-07-09 09:45:00' AND ".
+ "Shifts.DateS<='2007-07-09 11:00:00');";
+ else
+ $SQL .= "WHERE ((`Shifts`.`DateS`>'". gmdate("Y-m-d H:i:s", time()+120+$gmdateOffset). "') AND ".
+ "(`Shifts`.`DateS`<='". gmdate("Y-m-d H:i:s", time()+120+$gmdateOffset+$StartTimeBeforEvent). "') );";
+
+ $Erg = mysql_query($SQL, $con);
+ echo mysql_error($con);
+
+ $Z = 0;
+
+ 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 != "") {
+ echo "dial $DECTnumber\n";
+ DialNumberIAX( $DECTnumber, mysql_result($Erg, $i, "DateS"), mysql_result($Erg, $i, "RID"), mysql_result($Erg, $i, "TID"));
+ DialNumberModem( $DECTnumber, mysql_result($Erg, $i, "DateS"));
+
+ if($Z++ > 10) {
+ $Z = 0;
+ sleep(30);
+ }
+ }
+ }
}
-}
-
-return 0;
-
+ return 0;
?>
-
diff --git a/services/dect_clear.php b/services/dect_clear.php
index 713cce36..b49b1e40 100755
--- a/services/dect_clear.php
+++ b/services/dect_clear.php
@@ -1,25 +1,19 @@
-<?PHP
-// löscht alle eintrag in der telefonanlage, indem jede nummer einzähln gelöscht wir (#10<NUMBER>)
+<?php
+ include "../includes/db.php";
+ include "../includes/config.php";
+ include "../includes/funktion_modem.php";
-include ("../includes/db.php");
-include ("../includes/config.php");
-include ("../includes/funktion_modem.php");
+ $SQL = "SELECT DECT FROM `User`;";
+ $Erg = mysql_query($SQL, $con);
+ echo mysql_error($con);
-$SQL = "SELECT DECT FROM `User`;";
+ for($i=0; $i < mysql_num_rows($Erg); $i++) {
+ $Number = "#10" . mysql_result($Erg, $i, "DECT");
-$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;
+ if(strlen($Number) == 7)
+ DialNumber($Number);
+ }
+ return 0;
?>
-
diff --git a/services/jabberserver.php b/services/jabberserver.php
index 8a80b35c..94ef3a8b 100755
--- a/services/jabberserver.php
+++ b/services/jabberserver.php
@@ -1,113 +1,75 @@
-<?php
-
-/****************************************************************************************************/
-// INCLUDE
-/****************************************************************************************************/
-require_once('../includes/config_jabber.php');
-require_once("../includes/funktion_jabber.php");
-include("../includes/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";
- }
-}
-
-?>
+<?php
+ require_once "../includes/config_jabber.php";
+ require_once "../includes/funktion_jabber.php";
+ include "../includes/config_MessegeServer.php";
+
+ // Set time limit to indefinite execution
+ set_time_limit(0);
+
+ if(DEBUG)
+ echo "DEBUG mode is enable\n\tjabber is disable\n\n";
+
+ 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.");
+ }
+
+ echo "INIT socked\n";
+
+ // 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);
+
+ $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);
+
+ function PackedAnalyser($data) {
+ global $jabber, $RUNNING;
+ // init array
+ $matches = array();
+
+ //#message
+ if(preg_match("/^#(message) ([^ ]+) (.+)/i", $data, $matches)) {
+ if($matches[2]=="" || $matches[3]=="")
+ 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";
+ }
+?>