<?php
ini_set('error_reporting', E_ALL);
ini_set('display_errors', '0');
// Server and Phone URI
$scripturl = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
$phoneip = $_SERVER['REMOTE_ADDR']; // Your phone IP
$maxnum = 4; // Number of wallpaper choices
$username= 'abc'; // Phone web username
$password= '123'; // Phone web password
$id = 0;
if (isset($_GET["id"])) { $id += $_GET["id"]; }
if (($id>0) && ($id<=$maxnum)) {
// Change the Wallpaper and exit to Home screen
setWallpaper("wall0$id.jpg", $phoneip, $username, $password);
echo '<YealinkIPPhoneExecute Beep="no"><ExecuteItem URI="Key:CANCEL"/></YealinkIPPhoneExecute>';
} else {
// List wallpapers
echo '<myTextMenu defaultIndex="1" style="none" Beep="no" Timeout="30" LockIn="no" WrapList="no"><Title wrap = "no">Wallpapers</Title>';
for ($i=1;$i<=$maxnum;$i++) {
echo "<MenuItem><Prompt>Wallpaper $i</Prompt><Selection>$i</Selection><URI>$scripturl?id=$i</URI>";
echo "</MenuItem>\n";
}
echo "</myTextMenu>";
}
function setWallpaper($rname, $host, $username, $password) {
$ch = curl_init();
// Login to the web interface
curl_setopt($ch, CURLOPT_USERPWD, $username . ":" . $password);
curl_setopt($ch, CURLOPT_URL, 'http://'.$host);
curl_setopt($ch, CURLOPT_COOKIEFILE, '/dev/null');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$store = curl_exec($ch);
// Post Wallpaper Choice
curl_setopt($ch, CURLOPT_URL, 'http://'.$host.'/cgi-bin/cgiServer.exx');
$postCommands='profileOpen("/phone/config/user.ini")profileSetString("PhoneSetting","BackGrounds","Config:'.$rname.'")profileSave()msgBroadcastPostMessage("0x10007","43","0"))';
$fields = array('postCommands' => $postCommands);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields);
$content = curl_exec($ch);
return $content;
}
?>