$cal = new CalDAVClient($account["uri"], $account["user"], $account["pass"], "", $account["server"], $account["port"]);
 $events = $cal->GetEvents($sta, $end);
 foreach ($events as $k => $event) {
     $ce = explode("VEVENT", $event['data']);
     $su = explode("SUMMARY:", $ce[1]);
     $su1 = explode("\n", $su[1]);
     preg_match("/DTSTART;(.*):(.*)/", $ce[1], $treffer);
     $sta = strtotime($treffer[2]);
     $end = strtotime($treffer[2]) + 60 * 1;
     $now = time();
     if ($now >= $sta && $now <= $end) {
         $su2 = explode("_", trim($su1[0]));
         $lampID = trim($su2[0]);
         $action = trim($su2[1]);
         $stat = checkLightStatus($lampID);
         $co = getCodeById($lampID);
         $code = $co["code"];
         if ($co['letter'] == "A") {
             $letter = "1";
         } elseif ($co['letter'] == "B") {
             $letter = "2";
         } elseif ($co['letter'] == "C") {
             $letter = "3";
         } elseif ($co['letter'] == "D") {
             $letter = "4";
         } elseif ($co['letter'] == "E") {
             $letter = "5";
         }
         if ($action == "on" and $stat == "0") {
             shell_exec('sudo /home/div/rcswitch-pi/send ' . $code . ' ' . $letter . ' 1 ');
             setLightStatus($lampID, $action);
 *
*/

include("configs/dbconfig.inc.php");
include("configs/functions.inc.php");

$value = $_GET["s"];

if($_GET["s"]){

	$cutvalue=explode("_", $value);
	$lid  = $cutvalue[0];
	$stat = $cutvalue[1];

	setLightStatus($lid,$stat);
	$code = getCodeById($lid);

	if($code['letter']=="A"){
		$letter = "1";
	}elseif($code['letter']=="B"){
		$letter = "2";
	}elseif($code['letter']=="C"){
		$letter = "3";
	}elseif($code['letter']=="D"){
		$letter = "4";
	}

	if($stat=="on"){
                $status = "1";
        }elseif($stat=="off"){
                $status = "0";