Jump to content

gogogadgets

New Members
  • Posts

    2
  • Joined

  • Last visited

gogogadgets's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thank you for suggestions...I managed to solve problem using PHP exec & shell wget command: function exec_wget($url) { exec('/usr/bin/wget -O - -q -t 1 "http://'. $url . '/' . addslashes($url) . '" >/dev/null 2>&1' ); )
  2. Hello, PHP Friends! I wonder if somebody knows how to post or I better say call some URL like http://192.168.0.1/out.cgi?out1=1 from valid IP domain (server sees lan url) in background with Button click using form? For example to turn some device ON or OFF... I have tried with only PHP and also cURL but no luck <? //Check for status of device from xml (1 is Off & 0 is On) if ($xml->out1 == 1) { echo "<tr><td>OUT1</td><td><img src='images/red.png' alt='RED' height='23' width='23'></td><td><form method='post' action='index.php'><input type='hidden' value='out1' name='out1'><input type='submit' value='TURNON' name='TURNON'></form></td></tr>"; } else { echo "<tr><td>OUT1</td><td><img src='images/green.png' alt='GREEN' height='23' width='23'></td><td><form method='post' action='index.php'><input type='hidden' value='out1' name='out1'><input type='submit' value='TURNOFF' name='TURNOFF'></form></td></tr>"; } //cURL function to call URL with parameters function post_to_url($url, $data) { $fields = ''; foreach($data as $key => $value) { $fields .= $key . '=' . $value . '&'; } rtrim($fields, '&'); $post = curl_init(); curl_setopt($post, CURLOPT_URL, $url); curl_setopt($post, CURLOPT_POST, count($data)); curl_setopt($post, CURLOPT_POSTFIELDS, $fields); curl_setopt($post, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($post); curl_close($post); } //device URL $url = 'http://192.168.0.1/out.cgi'; //Turn on device $on = $_POST['name'] . '=0'; //Turn off device $off = $_POST['name'] . '=1'; //Check for Button action on user Click if(isset($_POST['TURNON'])) { post_to_url($url,$on); }elseif(isset($_POST['TURNOFF'])){ post_to_url($url,$off); }else{} ?> If I should use any other method, way, function, shell_exec etc..? Any suggestions, help is very welcome. Thank you.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.