Example #1
0
 function put()
 {
     //LoggingLevel - Bit mapped level
     //Level = 0 - All logging off
     //Level = 65535 - All logging on
     //Bit 1 - main process loop only
     //Bit 2 - REST operations
     //Bit 3 - functions logging
     // ...space for more levels
     //Bit 9 - PXMP logging
     $allowed_array = array('4b09d28f-1583-4e64-887c-a6889181daac' => array('URL' => 'http://ec2.energychaser.com/rest/', 'LoggingLevel' => 65535), 'testuser' => array('URL' => 'http://ec2.energychaser.com/rest/', 'LoggingLevel' => 65535), 'lynnes' => array('URL' => 'http://ec2.energychaser.com/rest/', 'LoggingLevel' => 65535));
     $request = check_and_clean_json('collectorGUID');
     error_log('$requestGUID: ');
     if ($request != null) {
         foreach ($allowed_array as $guid => $server) {
             error_log('$server: ' . print_r($server, true));
             if ($request->collectorGUID == $guid) {
                 $response = array('URL' => $server['URL'], 'LoggingLevel' => $server['LoggingLevel']);
                 //Send the response
                 echo json_encode($response);
             }
         }
         //If no matching GUID, echo nothing
     }
 }
Example #2
0
 function put()
 {
     require 'config.php';
     $request = check_and_clean_json('collectorGUID');
     if ($request != null) {
         $collector = update_collector_last_contact($request->collectorGUID);
         //echo print_r($request, true);
         // die;
         if ($collector != null) {
             //Collector exists
             //Create the response
             $response = array('serverResponse' => 'ok', 'serverEpochTimestamp' => time(), 'serverAvailable' => true, 'collector_id' => $collector['collector_id'], 'contact_interval' => $collector['contact_interval'], 'collectorEnabled' => $collector['enabled'], 'gmt_last_config_update' => $collector['gmt_last_config_update'], 'config_mode' => 0, 'upload_log_data' => true);
             if (EC_DEBUG) {
                 error_log(__FILE__ . __LINE__ . ":" . ' - ' . $collector['collector_name'] . ' - GUID:' . $request->collectorGUID . ' - PING');
             }
         } else {
             //collector does not exist
             error_log('Invalid collector GUID:' . $request->collectorGUID . ' from IP ' . $_SERVER['REMOTE_ADDR'] . ' at ' . gethostbyaddr($_SERVER['REMOTE_ADDR']));
             //Create the response - return the current server time
             $response = array('serverResponse' => 'BAD_GUID', 'serverEpochTimestamp' => 0, 'serverAvailable' => false, 'collectorEnabled' => false, 'gmt_last_config_update' => 0);
         }
         //Send the response
         echo json_encode($response);
     }
 }