Example #1
0
		$note["subject"] = $subject;
		$note["content"] = $body;
		$ret = array();
		$ret["error"] = false;
        $ret["warn"] = false;
        $ret["info"] = "test warn msg";
		$ret["threads"] = array($note);
		echo json_encode($ret);
	}else if(isset($_REQUEST["load"])){
		// request to load all notes, limit 10 each time
        //$startId = $_REQUEST["startId"];
		$ret = array();
		$ret["error"] = false;
		$ret["dt"] = gmdate("Y-m-d H:i:s");
		$ret["threads"] = array();
		$result = query(sql_getAllNotes($startId));
		while($row = mysql_fetch_array($result)){
			$ret["threads"][] = $row;
		}
		error_log("load threads:".count($ret["threads"]));
		echo json_encode($ret);
	}else if(isset($_REQUEST["search"])){
        //TODO: limit return number, to save user potential computing time
		// request to add search notes
		$dt = gmdate("Y-m-d H:i:s");
		$keywords = $_REQUEST["keywords"];
		$ret = array();
		$startId = $_REQUEST["startId"];
        $queryTerm = sql_searchNoteByKeywords(json_decode($keywords), $startId);
		$result = query($queryTerm);
		while($row = mysql_fetch_array($result)){
Example #2
0
		$note["note_id"] = mysql_insert_id($mysql);
		$note["dt_added"] = $dt;
		$note["dt_modified"] = $dt;
		$note["subject"] = $subject;
		$note["body"] = $body;
		$ret = array();
		$ret["error"] = false;
		$ret["notes"] = array($note);
		echo json_encode($ret);
	}else if(isset($_REQUEST["load"])){
		// request to load all notes
		$ret = array();
		$ret["error"] = false;
		$ret["dt"] = gmdate("Y-m-d H:i:s");
		$ret["notes"] = array();
		$result = query(sql_getAllNotes());
		while($row = mysql_fetch_array($result)){
			$ret["notes"][] = $row;
		}
		echo json_encode($ret);
	}else{
		// the client asked for something we don't support
		throw new Exception("not supported operation");
	}

}catch(Exception $e){
	// something bad happened
	$ret = array();
	$ret["error"] = true;
	$ret["message"] = $e->getMessage();
	echo json_encode($ret);