180 lines
No EOL
8.5 KiB
PHP
180 lines
No EOL
8.5 KiB
PHP
<?php
|
|
header("Content-Type: text/html; charset=utf-8");
|
|
error_reporting(E_ALL); ini_set('display_errors',1);
|
|
require('lib/config.php');
|
|
session_name(CONFIG_SESSION); session_start();
|
|
require('lib/mysql.class.php');
|
|
include('lib/class.mysms.php');
|
|
$GLOBALS['mysql'] = new mysql(CONFIG_MYSQL_HOST,CONFIG_MYSQL_USER,CONFIG_MYSQL_PW,CONFIG_MYSQL_DB);
|
|
date_default_timezone_set('Europe/London');
|
|
//----------------------------------------------------------------------------------------------------------------
|
|
//------------------------------------------------- Eingehende SMS -----------------------------------------------
|
|
//----------------------------------------------------------------------------------------------------------------
|
|
$api_key = 'OvHiwonvVKneoYttEOE64g'; // Jörg
|
|
$mysms = new mysms($api_key);
|
|
$login_data = array('msisdn' => '491783481356', 'password' => 'laden');
|
|
$login = $mysms->ApiCall('json', '/user/login', $login_data);
|
|
$user_info = json_decode($login);
|
|
$_SESSION['AuthToken'] = $user_info->authToken;
|
|
$mysms->setAuthToken($user_info->authToken);
|
|
$msisdn = "+491783481356"; //jörg
|
|
$req_data = array('apiKey' => $api_key,'authToken' => $_SESSION['AuthToken'],'address' => $msisdn,'offset' => 0,'limit' => 10); //providing
|
|
$ergebnis = $mysms->ApiCall('json', '/user/message/get/by/conversation', $req_data); //calling method ->ApiCall
|
|
|
|
$tmp1=$jsonrow->messages[0]->messageId;
|
|
$tmp2=$jsonrow->messages[0]->status;
|
|
$tmp3=$jsonrow->messages[0]->dateStatus; $tmp3=substr($tmp3, 0, -3);
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------------------
|
|
//------------------------------------------------- abfragen neu versendet --------------------------------------
|
|
//----------------------------------------------------------------------------------------------------------------
|
|
$smstime = time();
|
|
$tmptime=$smstime-259200;
|
|
//$abfrage = $GLOBALS['mysql']->query_single("SELECT * FROM log_sms WHERE test=0 and messageId>0 and status!=2,0 and senddate>'".$tmptime."' ORDER BY smsID DESC");
|
|
$abfrage = $GLOBALS['mysql']->query_single("SELECT * FROM log_sms WHERE test=0 and messageId>0 and status!=2 and incoming!=1 and senddate>'".$tmptime."'");
|
|
if($abfrage['num_rows'] != 0) {
|
|
// echo $abfrage['smsID'];
|
|
// echo "<pre>"; print_r($abfrage); echo "</pre>";
|
|
$row_sender = $GLOBALS['mysql']->query_single("SELECT * FROM benutzer WHERE id='".$abfrage['sender_id']."'");
|
|
if($row_sender['num_rows']!=0) {
|
|
//-------------------------------------------------------------
|
|
$GLOBALS['mysql']->insert("UPDATE log_sms SET test=1 WHERE smsID='".$abfrage['smsID']."'");
|
|
//-------------------------------------------------------------
|
|
$mysms = new mysms($row_sender['api-key']);
|
|
$login_data = array('msisdn' => $row_sender['nummer'], 'password' => $row_sender['passwd']);
|
|
$login = $mysms->ApiCall('json', '/user/login', $login_data);
|
|
//echo "<pre>"; print_r(json_decode($login)); echo "</pre>"; // login prüfren
|
|
$user_info = json_decode($login); $_SESSION['AuthToken'] = $user_info->authToken;
|
|
$req_data = array('authToken' => $_SESSION['AuthToken'], 'address'=> $abfrage['nummer'], 'query'=> utf8_decode($abfrage['text']));
|
|
$ergbniss = $mysms->ApiCall('json', '/user/message/search', $req_data);
|
|
echo "<pre>"; print_r(json_decode($ergbniss)); echo "</pre>";
|
|
$jsonrow=json_decode($ergbniss);
|
|
//-----------------------------------------------------------
|
|
// echo count($jsonrow->messages);
|
|
// echo $abfrage['smsID'];
|
|
$test=1;
|
|
if(isset($jsonrow->messages[0])) { /////
|
|
//$tmp1=$jsonrow->messages[0]->messageId; $tmp2=$jsonrow->messages[0]->status; $tmp3=$jsonrow->messages[0]->dateStatus; $tmp3=substr($tmp3,0,-3);
|
|
// $GLOBALS['mysql']->insert("UPDATE log_sms SET status='".$tmp2."' WHERE smsID='".$abfrage['smsID']."'");
|
|
// $GLOBALS['mysql']->insert("UPDATE log_sms SET statusdate='".$tmp3."' WHERE smsID='".$abfrage['smsID']."'");
|
|
// $GLOBALS['mysql']->insert("UPDATE tourenliste SET smsstatus='".$tmp2."' WHERE id='".$abfrage['tId']."'");
|
|
// $GLOBALS['mysql']->insert("UPDATE tourenliste SET smsstatusdate='".$tmp3."' WHERE id='".$abfrage['tId']."'");
|
|
|
|
$anzahl=count($jsonrow->messages);
|
|
for($i=0; $i < $anzahl; $i++) {
|
|
if(isset($jsonrow->messages[$i])) {
|
|
$tmp1=$jsonrow->messages[$i]->messageId; $tmp2=$jsonrow->messages[$i]->status; $tmp3=$jsonrow->messages[$i]->dateStatus; $tmp3=substr($tmp3, 0, -3);
|
|
if($tmp1==$abfrage['messageId']) {
|
|
$GLOBALS['mysql']->insert("UPDATE log_sms SET status='".$tmp2."' WHERE smsID='".$abfrage['smsID']."'");
|
|
$GLOBALS['mysql']->insert("UPDATE log_sms SET statusdate='".$tmp3."' WHERE smsID='".$abfrage['smsID']."'");
|
|
|
|
if($abfrage['tId']>0) {
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET smsstatus='".$tmp2."' WHERE id='".$abfrage['tId']."'");
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET smsstatusdate='".$tmp3."' WHERE id='".$abfrage['tId']."'");
|
|
}
|
|
$test=0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if($test>0) {
|
|
$GLOBALS['mysql']->insert("UPDATE log_sms SET status=8 WHERE smsID='".$abfrage['smsID']."'");
|
|
$GLOBALS['mysql']->insert("UPDATE log_sms SET statusdate=99 WHERE smsID='".$abfrage['smsID']."'");
|
|
if($abfrage['tId']>0) {
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET smsstatus=8 WHERE id='".$abfrage['tId']."'");
|
|
$GLOBALS['mysql']->insert("UPDATE tourenliste SET smsstatusdate=99 WHERE id='".$abfrage['tId']."'");
|
|
}
|
|
}
|
|
}
|
|
//sleep (5);
|
|
} else {
|
|
$GLOBALS['mysql']->insert("UPDATE log_sms SET test=0 WHERE logtime>'".$tmptime."'");
|
|
echo "keine SMS zu prüfen...";
|
|
}
|
|
//---------------------------------------------------------------------------------------------------------------------------
|
|
/*
|
|
stdClass Object
|
|
(
|
|
[place_id] => 92100685
|
|
[licence] => Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright
|
|
[osm_type] => way
|
|
[osm_id] => 25815620
|
|
[lat] => 51.64401147390837
|
|
[lon] => 12.25841893049767
|
|
[display_name] => B 183, Sandersdorf, Bitterfeld-Wolfen, Anhalt-Bitterfeld, Sachsen-Anhalt, 06803, Deutschland
|
|
[address] => stdClass Object
|
|
(
|
|
[road] => B 183
|
|
[city_district] => Sandersdorf
|
|
[town] => Bitterfeld-Wolfen
|
|
[county] => Anhalt-Bitterfeld
|
|
[state] => Sachsen-Anhalt
|
|
[postcode] => 06803
|
|
[country] => Deutschland
|
|
[country_code] => de
|
|
)
|
|
|
|
[boundingbox] => Array
|
|
(
|
|
[0] => 51.6374534
|
|
[1] => 51.6444531
|
|
[2] => 12.2521345
|
|
[3] => 12.27533
|
|
)
|
|
|
|
)
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------------
|
|
$tmp = $GLOBALS['mysql']->query_single("SELECT * FROM verkehr WHERE status=1");
|
|
if($tmp['num_rows'] != 0) {
|
|
$lat= $tmp['lat'];
|
|
$lng= $tmp['lng'];
|
|
$page1='http://nominatim.openstreetmap.org/reverse?format=json&lat='.$lat.'&lon='.$lng.'&email=frank@first-mp.de';
|
|
$html2 = file_get_contents($page1);
|
|
$jsonrow2=json_decode($html2);
|
|
if(isset($jsonrow2->address->town)) {
|
|
$datastreet=($jsonrow2->address->town);
|
|
} else {
|
|
if(isset($jsonrow2->address->city)) {
|
|
$datastreet=($jsonrow2->address->city);
|
|
} else {
|
|
if(isset($jsonrow2->address->city_district)) {
|
|
$datastreet=($jsonrow2->address->city_district);
|
|
} else {
|
|
$datastreet=($jsonrow2->address->village);
|
|
}
|
|
}
|
|
}
|
|
$datastreet=utf8_decode($datastreet);
|
|
if(strlen($tmp['street'])<5) {
|
|
$street=$tmp['street'].', '.$datastreet;
|
|
} else {
|
|
$street=$datastreet.', '.$tmp['street'];
|
|
}
|
|
|
|
$GLOBALS['mysql']->insert("UPDATE verkehr SET street='".$street."' WHERE id='".$tmp['id']."'");
|
|
$GLOBALS['mysql']->insert("UPDATE verkehr SET status=2 WHERE id='".$tmp['id']."'");
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------------------------------------------
|
|
} else {
|
|
echo "keine geocoordinaten zu prüfen...";
|
|
|
|
}
|
|
//---------------------------------------------------------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------------------------------------------------------
|
|
//---------------------------------------------------------------------------------------------------------------------------
|
|
|
|
?>
|