home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
General Forums
OffTopic
php/SQL-Help for Geofence-Project?
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="The_Stig" data-source="post: 1139439" data-attributes="member: 12276"><p>Sooooo...tried a bit around. Did get a bit further, but not working.</p><p></p><p>What I have working so far is a simple php activating and deactivating it. Had to change the script I posted here, because this did not work (don't know why). This one works (and yes, I know, the if else isn't nice, but I don't know how to remove it ;-)</p><p></p><p>[CODE]</p><p><?php</p><p>//Authentication</p><p>$json = file_get_contents('http://IP:PORT/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=3&account=user&passwd=PASSWORD&session=SurveillanceStation&format=sid');</p><p>$obj = json_decode($json, true);</p><p>$sid = $obj["data"]["sid"];</p><p></p><p>//GetList</p><p>$json = file_get_contents('http://IP:PORT/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&method=List&version=3&_sid='.$sid);</p><p>$obj = json_decode($json, true);</p><p>$cam_activated = $obj["data"]["cameras"][0]["enabled"];</p><p></p><p>if($cam_activated == false){</p><p> //Deactivate cam</p><p> $json = file_get_contents('http://IP:PORT/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&method=Enable&version=3&cameraIds=2&_sid='.$sid);</p><p> echo "<div class=\"centered\"><img src=\"http://192.168.178.99:5000/on_icon.png\" style=\"width:auto;height:auto;\" /></div>";</p><p>}</p><p>else</p><p>{</p><p> //Deactivate cam</p><p> $json = file_get_contents('http://IP:PORT/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&method=Enable&version=3&cameraIds=2&_sid='.$sid);</p><p> echo "<div class=\"centered\"><img src=\"https://externeAdresse:Port/off_icon.png\" /></div>";</p><p>}</p><p>?></p><p>[/CODE]</p><p></p><p>What I've done in php is this:</p><p>[ATTACH=full]165543[/ATTACH]</p><p></p><p>I guess some of the types are wrong?</p><p></p><p>And I have this now as php script:</p><p>[CODE]</p><p><?php</p><p>$httpformat="http"; //hier angeben ob http oder https</p><p>$port="5000"; //port</p><p>$loginname="administrator"; //Loginname an der Surveillance Station</p><p>$passwd="Password"; //passwort an der Surveillance Station</p><p>$ip="IP"; //ip adresse der Surveillance station im LAN</p><p>$cam_id="2"; // Kamera ID mit script "hole Kamera ID" abfragen, später automatisieren</p><p>// db</p><p>$db_name = "root";</p><p>$db_pw = "Password";</p><p>$db_database = "Surveillance";</p><p>$db_table = "user";</p><p>$db_ip = "127.0.0.1";</p><p></p><p>// activate Surveillance</p><p>$surveillance = true;</p><p>// connect to db</p><p>$connection = mysql_connect(db_ip, $db_user,$db_pw) or die ("No connection. User or password is wrong");</p><p>// select table</p><p>mysql_select_db($db_database) or die ("The Database ". $db_database ." doesn't exist");</p><p></p><p>// update table</p><p>$query = "UPDATE ".$db_table." Set available = ".mysql_real_escape_string($_GET['available']).", time = NOW() WHERE id = ".mysql_real_escape_string($_GET['id'])." AND pw='".mysql_real_escape_string($_GET['pw'])."'";</p><p>$update = mysql_query($query);</p><p></p><p>if (!$update) {</p><p> die('Error: ' . mysql_error());</p><p>}</p><p></p><p>// select info</p><p></p><p>$query = "SELECT available FROM ".$db_table;</p><p>$result = mysql_query($query);</p><p>while($row = mysql_fetch_object($result)) {</p><p> if ($row->available == true)</p><p> $surveillance = false;</p><p>}</p><p>//Login an der Surveillance Station:</p><p>$json = file_get_contents($httpformat."://".$ip.":".$port."/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=3& account=".$loginname."&passwd=".$passwd."&session= SurveillanceStation&format=sid'");</p><p>$obj = json_decode($json, true);</p><p>$sid = $obj["data"]["sid"];</p><p>if ($surveillance) {</p><p>//Kamera aktivieren:</p><p>$json = file_get_contents($httpformat."://".$ip.":".$port."/webapi/_______________________________________________________entry.cgi?api=SYNO.SurveillanceStation.Camera&method=Enable&version=3&cameraIds=".$cam_id."&_sid=".$sid);</p><p>}else {</p><p>//Kamera deaktivieren:</p><p>}</p><p></p><p>//Logout Surveillance Station:</p><p>$out = file_get_contents($httpformat."://".$ip.":".$port."/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=Logout &session=SurveillanceStation");</p><p></p><p>?></p><p>[/CODE]</p><p></p><p>Getting from this php: "Warning: mysql_connect(): php_network_getaddresses: gethostbyname failed. errno=0 in /volume1/web/alarm.php on line 18 Warning: mysql_connect(): php_network_getaddresses: gethostbyname failed. errno=0 in /volume1/web/alarm.php on line 18 No connection. User or password is wrong"</p><p></p><p>But root has access to this db. Checked this. Can you lead me further?</p></blockquote><p></p>
[QUOTE="The_Stig, post: 1139439, member: 12276"] Sooooo...tried a bit around. Did get a bit further, but not working. What I have working so far is a simple php activating and deactivating it. Had to change the script I posted here, because this did not work (don't know why). This one works (and yes, I know, the if else isn't nice, but I don't know how to remove it ;-) [CODE] <?php //Authentication $json = file_get_contents('http://IP:PORT/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=3&account=user&passwd=PASSWORD&session=SurveillanceStation&format=sid'); $obj = json_decode($json, true); $sid = $obj["data"]["sid"]; //GetList $json = file_get_contents('http://IP:PORT/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&method=List&version=3&_sid='.$sid); $obj = json_decode($json, true); $cam_activated = $obj["data"]["cameras"][0]["enabled"]; if($cam_activated == false){ //Deactivate cam $json = file_get_contents('http://IP:PORT/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&method=Enable&version=3&cameraIds=2&_sid='.$sid); echo "<div class=\"centered\"><img src=\"http://192.168.178.99:5000/on_icon.png\" style=\"width:auto;height:auto;\" /></div>"; } else { //Deactivate cam $json = file_get_contents('http://IP:PORT/webapi/entry.cgi?api=SYNO.SurveillanceStation.Camera&method=Enable&version=3&cameraIds=2&_sid='.$sid); echo "<div class=\"centered\"><img src=\"https://externeAdresse:Port/off_icon.png\" /></div>"; } ?> [/CODE] What I've done in php is this: [ATTACH=full]165543[/ATTACH] I guess some of the types are wrong? And I have this now as php script: [CODE] <?php $httpformat="http"; //hier angeben ob http oder https $port="5000"; //port $loginname="administrator"; //Loginname an der Surveillance Station $passwd="Password"; //passwort an der Surveillance Station $ip="IP"; //ip adresse der Surveillance station im LAN $cam_id="2"; // Kamera ID mit script "hole Kamera ID" abfragen, später automatisieren // db $db_name = "root"; $db_pw = "Password"; $db_database = "Surveillance"; $db_table = "user"; $db_ip = "127.0.0.1"; // activate Surveillance $surveillance = true; // connect to db $connection = mysql_connect(db_ip, $db_user,$db_pw) or die ("No connection. User or password is wrong"); // select table mysql_select_db($db_database) or die ("The Database ". $db_database ." doesn't exist"); // update table $query = "UPDATE ".$db_table." Set available = ".mysql_real_escape_string($_GET['available']).", time = NOW() WHERE id = ".mysql_real_escape_string($_GET['id'])." AND pw='".mysql_real_escape_string($_GET['pw'])."'"; $update = mysql_query($query); if (!$update) { die('Error: ' . mysql_error()); } // select info $query = "SELECT available FROM ".$db_table; $result = mysql_query($query); while($row = mysql_fetch_object($result)) { if ($row->available == true) $surveillance = false; } //Login an der Surveillance Station: $json = file_get_contents($httpformat."://".$ip.":".$port."/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=3& account=".$loginname."&passwd=".$passwd."&session= SurveillanceStation&format=sid'"); $obj = json_decode($json, true); $sid = $obj["data"]["sid"]; if ($surveillance) { //Kamera aktivieren: $json = file_get_contents($httpformat."://".$ip.":".$port."/webapi/_______________________________________________________entry.cgi?api=SYNO.SurveillanceStation.Camera&method=Enable&version=3&cameraIds=".$cam_id."&_sid=".$sid); }else { //Kamera deaktivieren: } //Logout Surveillance Station: $out = file_get_contents($httpformat."://".$ip.":".$port."/webapi/auth.cgi?api=SYNO.API.Auth&version=3&method=Logout &session=SurveillanceStation"); ?> [/CODE] Getting from this php: "Warning: mysql_connect(): php_network_getaddresses: gethostbyname failed. errno=0 in /volume1/web/alarm.php on line 18 Warning: mysql_connect(): php_network_getaddresses: gethostbyname failed. errno=0 in /volume1/web/alarm.php on line 18 No connection. User or password is wrong" But root has access to this db. Checked this. Can you lead me further? [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
General Forums
OffTopic
php/SQL-Help for Geofence-Project?
Contact us
RSS
Top
Bottom