CURL Aviosys IP9258 HTTP Command PHP works with include turned off!

<?
if(isset($_POST['ON']))
{
// make sure curl is installed
if (function_exists('curl_init')) {
// initialize a new curl resource
$ch = curl_init();
// set the url to fetch
curl_setopt($ch, CURLOPT_URL, 'http://login:password@99.999.11.118/Set.cmd?CMD=SetPower+P60=1');
// set the port
//curl_setopt($ch, CURLOPT_PORT, "219");
// don't give me the headers just the content
curl_setopt($ch, CURLOPT_HEADER, 0);
// return the value instead of printing the response to browser
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// use a user agent to mimic a browser
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0');
$content = curl_exec($ch);
// remember to always close the session and free all resources
curl_close($ch);
} else {
echo "error";
}
}
if(isset($_POST['OFF']))
{
// make sure curl is installed
if (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://login:password@99.999.11.118/Set.cmd?CMD=SetPower+P60=0');
//curl_setopt($ch, CURLOPT_PORT, '219');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0');
$content = curl_exec($ch);
curl_close($ch);
} else {
echo "error";
}
}
?>
<html>
<head>
<!--<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>-->
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Power Tree</title>
</head>
<body>
<form method="post" name="post_on">
<!--
<input type="hidden" name="ON" value="ON" />
<a onclick="javascript: document.post_on.submit();">Power Tree All - On</a>
-->
<input type="submit" name="ON" value="Power Tree - All - On" />
</form>
<br />
<form method="post" name="post_off">
<input type="submit" name="OFF" value="Power Tree - All - Off" />
</form>
<br />
<div id="content"><? if($content){ echo $content; } ?></div>

Posted on 11 Dec 2009, 14:18 - Category: Php
Edit - Delete


No comments posted yet.
Loading