/**
  * Validate the client's API key, store reported device information
  * in the database and return a success message.
  *
  * \param $request REST request from client
  *
  * \return Array with response data
  */
 private function reportDeviceInformation($request)
 {
     $result = array();
     $bodyData = $request->getBodyData();
     $arguments = $request->getURLArguments();
     // Validate client credentials
     if (isset($bodyData['AppName']) && isset($bodyData['ApiKey']) && Authentication::validate($bodyData['AppName'], $bodyData['ApiKey'])) {
         // Report device information
         if (isset($bodyData['OSVersion']) && isset($bodyData['APILevel']) && isset($bodyData['DeviceType']) && isset($bodyData['ReportedBy'])) {
             $result = MediaServer::handleReportDeviceInfoRequest($bodyData['OSVersion'], $bodyData['APILevel'], $bodyData['DeviceType'], $bodyData['ReportedBy']);
         } else {
             $result = array('Statuscode' => 'Error', 'Message' => 'Invalid or incomplete request. Check URL arguments and body data.');
         }
     } else {
         $result = array('Statuscode' => 'Error', 'Message' => 'Invalid or no auth data provided. Check your API key.');
     }
     return $result;
 }
示例#2
0
	$password = isset($_POST['pass']) ? $_POST['pass'] : null;
	$identity = isset($_POST['email']) ? $_POST['email'] : null;
	
	$fname = isset($_POST['fname']) ? $_POST['fname'] : null;
	$lname = isset($_POST['lname']) ? $_POST['lname'] : null;
	$identity = isset($_POST['email']) ? $_POST['email'] : null;
	$ident_conf = isset($_POST['email_confirm']) ? $_POST['email_confirm'] : null;
	$password = isset($_POST['pass']) ? $_POST['pass'] : null;
	$pass_conf = isset($_POST['pass_confirm']) ? $_POST['pass_confirm'] : null;
	$role = isset($_POST['register_role']) ? $_POST['register_role'] : 3;
	
	if( $action == 'login' )
	{
		if( $password != null && $identity != null )
		{
			$tmp = Authentication::validate($identity, $password);
			
			if( $tmp )
			{
				setSessionVar('active', true);
				setSessionVar('fname', $tmp->fname);
				setSessionVar('lname', $tmp->lname);
				setSessionVar('roleid', $tmp->authentication->role->roleid);
				setSessionVar('userid', $tmp->userid);
				setSessionVar('isAnon', false);
				
				kick(2, null, 0 );
			}
			else
			{
				kick(0, array('identity' => $identity), 1);
 /**
  * Validate the client's API key, save uploaded sound sample on
  * disk and return a success message.
  *
  * \param $request REST request from client
  *
  * \return Array with response data
  */
 private function uploadSoundSample($request)
 {
     $result = array();
     $bodyData = $request->getBodyData();
     $arguments = $request->getURLArguments();
     // Validate client credentials
     if (isset($bodyData['AppName']) && isset($bodyData['ApiKey']) && Authentication::validate($bodyData['AppName'], $bodyData['ApiKey'])) {
         // Upload sound sample
         if (isset($arguments['latitude']) && isset($arguments['longitude']) && isset($bodyData['Time']) && isset($bodyData['Tag']) && isset($bodyData['PayloadType']) && isset($bodyData['Payload']) && isset($bodyData['ReportedBy'])) {
             // Prevent PHP notice because of undefined index
             if (!isset($bodyData['Title'])) {
                 $bodyData['Title'] = null;
             }
             if (!isset($bodyData['Description'])) {
                 $bodyData['Description'] = null;
             }
             $result = MediaServer::handleUploadRequest($arguments['latitude'], $arguments['longitude'], $bodyData['Title'], $bodyData['Time'], $bodyData['Description'], $bodyData['Tag'], $bodyData['PayloadType'], $bodyData['Payload'], $bodyData['ReportedBy']);
         } else {
             $result = array('Statuscode' => 'Error', 'Message' => 'Invalid or incomplete request. Check URL arguments and body data.');
         }
     } else {
         $result = array('Statuscode' => 'Error', 'Message' => 'Invalid or no auth data provided. Check your API key.');
     }
     return $result;
 }
 /**
  * Validate the client's API key, store reported noise level
  * value in the database and return a success message.
  *
  * \param $request REST request from client
  *
  * \return Array with response data
  */
 private function reportNoiseLevel($request)
 {
     $result = array();
     $bodyData = $request->getBodyData();
     $arguments = $request->getURLArguments();
     // Validate client credentials
     if (isset($bodyData['AppName']) && isset($bodyData['ApiKey']) && Authentication::validate($bodyData['AppName'], $bodyData['ApiKey'])) {
         // Report noise level
         if (isset($arguments['latitude']) && isset($arguments['longitude']) && isset($bodyData['Time']) && isset($bodyData['NoiseLevel']) && isset($bodyData['NoiseLevelOrg']) && isset($bodyData['ReportedBy']) && isset($bodyData['InPocket'])) {
             // Prevent PHP notice because of undefined index
             if (!isset($arguments['zipCode'])) {
                 $arguments['zipCode'] = null;
             }
             $result = MediaServer::handleReportRequest($arguments['latitude'], $arguments['longitude'], $bodyData['Time'], $arguments['zipCode'], $bodyData['NoiseLevel'], $bodyData['NoiseLevelOrg'], $bodyData['ReportedBy'], $bodyData['InPocket']);
         } else {
             $result = array('Statuscode' => 'Error', 'Message' => 'Invalid or incomplete request. Check URL arguments and body data.');
         }
     } else {
         $result = array('Statuscode' => 'Error', 'Message' => 'Invalid or no auth data provided. Check your API key.');
     }
     return $result;
 }
示例#5
0
function test($name, $key)
{
    echo '<br />Is ' . (Authentication::validate($name, $key) === false ? 'NOT' : '') . ' a valid combination: ' . $name . ' / ' . $key;
}