improved documentation, better api documentation
This commit is contained in:
		
							
								
								
									
										38
									
								
								html/get.php
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								html/get.php
									
									
									
									
									
								
							@@ -2,18 +2,15 @@
 | 
			
		||||
/*! @file
 | 
			
		||||
 | 
			
		||||
    @id $Id$
 | 
			
		||||
*/
 | 
			
		||||
//       1         2         3         4         5         6         7         8
 | 
			
		||||
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
 | 
			
		||||
 | 
			
		||||
    @see @ref apiget
 | 
			
		||||
 | 
			
		||||
    @page api
 | 
			
		||||
/// Get new messages
 | 
			
		||||
/** Get all messages that are newer than @c $start.
 | 
			
		||||
 | 
			
		||||
    @section apiget Get Messages
 | 
			
		||||
 | 
			
		||||
    API-call get.php
 | 
			
		||||
 | 
			
		||||
    Get all messages that are newer than start.
 | 
			
		||||
 | 
			
		||||
    @param start Number of message to start with.
 | 
			
		||||
    @param $start Number of message to start with.
 | 
			
		||||
    @return json encoded array of messages:
 | 
			
		||||
       @code
 | 
			
		||||
           [
 | 
			
		||||
@@ -25,16 +22,19 @@
 | 
			
		||||
             }, ...
 | 
			
		||||
           ]
 | 
			
		||||
       @endcode
 | 
			
		||||
 | 
			
		||||
    @api Get New Messages
 | 
			
		||||
*/
 | 
			
		||||
//       1         2         3         4         5         6         7         8
 | 
			
		||||
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
 | 
			
		||||
try {
 | 
			
		||||
  require_once("opendb.php");
 | 
			
		||||
  $start = $db->real_escape_string($_REQUEST['start']);
 | 
			
		||||
  $q = $db->query("select id, UNIX_TIMESTAMP(time) as time, user, msg from message where id>$start;");
 | 
			
		||||
  if ($q) echo json_encode($q->fetch_all(MYSQLI_ASSOC));
 | 
			
		||||
  else echo json_encode(null);
 | 
			
		||||
} catch (Exception $e) {
 | 
			
		||||
  echo json_encode(null);
 | 
			
		||||
function get($start) {
 | 
			
		||||
  try {
 | 
			
		||||
    require_once("opendb.php");
 | 
			
		||||
    $start = $db->real_escape_string($start);
 | 
			
		||||
    $q = $db->query("select id, UNIX_TIMESTAMP(time) as time, user, msg from message where id>$start;");
 | 
			
		||||
    if ($q) echo json_encode($q->fetch_all(MYSQLI_ASSOC));
 | 
			
		||||
    else echo json_encode(null);
 | 
			
		||||
  } catch (Exception $e) {
 | 
			
		||||
    echo json_encode(null);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
get($_REQUEST['start']);
 | 
			
		||||
?>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user