mrnutter

Untitled

Sep 8th, 2012
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. <?php
  2.     $req_uri = $_SERVER['REQUEST_URI'];
  3.     $ex = explode("/",$req_uri);
  4.     $action = $ex[count($ex)-1];
  5.  
  6.     switch ($action) {
  7.         case "time":
  8.             echo date("r");
  9.             break;
  10.         case "news":
  11.             echo json_encode(array("last_update"=>time(),"message"=>"news from server"));
  12.             break;
  13.         case "push_test":
  14.             $checksum = md5($_POST['timestamp'].$_POST['frequency'].$_POST['amplitude'].$_POST['error']);
  15.             if($_POST['checksum']==$checksum) $ret="ok";
  16.             else $ret="fail";
  17.             echo json_encode(array("timestamp"=>$_POST['timestamp'],"frequency"=>$_POST['frequency'],"amplitude"=>$_POST['amplitude'],"error"=>$_POST['error'],"checksum"=>$_POST['checksum'],"status"=>$ret));
  18.             break;
  19.         case "push":
  20.             $checksum = md5($_POST['timestamp'].$_POST['frequency'].$_POST['amplitude'].$_POST['error']);
  21.             if($_POST['checksum']==$checksum) $ret="ok";
  22.             else $ret="fail";
  23.             echo json_encode(array("status"=>$ret));   
  24.             break;
  25.         default:
  26.             echo "error";
  27.     }
  28. ?>
Advertisement
Add Comment
Please, Sign In to add comment