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: 1139529" data-attributes="member: 12276"><p>Currently I think its not a DB-Problem, but an API-Problem. Even when I use only the snipplet to activate / deactivate the cam, it doesn't work. </p><p></p><p>This is my current full php where activating/deactivating is not working:</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="192.168.178.99"; //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_name,$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 password='".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>?>[/CODE]</p><p></p><p>And this is a script, where activating/deactivating is working:</p><p></p><p>[CODE]</p><p><?php</p><p>//Authentication</p><p>$json = file_get_contents('http://192.168.178.99:5000/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=3&account=administrator&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://192.168.178.99:5000/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> //Activate cam</p><p> $json = file_get_contents('http://192.168.178.99:5000/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> //Activate cam</p><p> $json = file_get_contents('http://192.168.178.99:5000/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/off_icon.png\" /></div>";</p><p>}</p><p>?></p><p>[/CODE]</p><p></p><p></p><p>Don't know how to do this. Do you see a possibility to combine the first db-script with the second working activating script?</p></blockquote><p></p>
[QUOTE="The_Stig, post: 1139529, member: 12276"] Currently I think its not a DB-Problem, but an API-Problem. Even when I use only the snipplet to activate / deactivate the cam, it doesn't work. This is my current full php where activating/deactivating is not working: [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="192.168.178.99"; //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_name,$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 password='".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] And this is a script, where activating/deactivating is working: [CODE] <?php //Authentication $json = file_get_contents('http://192.168.178.99:5000/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=3&account=administrator&passwd=Password&session=SurveillanceStation&format=sid'); $obj = json_decode($json, true); $sid = $obj["data"]["sid"]; //GetList $json = file_get_contents('http://192.168.178.99:5000/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){ //Activate cam $json = file_get_contents('http://192.168.178.99:5000/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 { //Activate cam $json = file_get_contents('http://192.168.178.99:5000/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/off_icon.png\" /></div>"; } ?> [/CODE] Don't know how to do this. Do you see a possibility to combine the first db-script with the second working activating script? [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
General Forums
OffTopic
php/SQL-Help for Geofence-Project?
Contact us
RSS
Top
Bottom