public function run()
 {
     DB::table('readings')->delete();
     Reading::create(array('device' => 1, 'temp' => 19.5, 'heaton' => 1, 'created_at' => \Carbon\Carbon::now()->subDays(2)->toDateTimeString(), 'updated_at' => \Carbon\Carbon::now()->subDays(2)->toDateTimeString()));
     Reading::create(array('device' => 1, 'temp' => 19.7, 'heaton' => 1, 'created_at' => \Carbon\Carbon::now()->subDays(1)->toDateTimeString(), 'updated_at' => \Carbon\Carbon::now()->subDays(1)->toDateTimeString()));
     Reading::create(array('device' => 1, 'temp' => 20.1, 'heaton' => 0, 'created_at' => \Carbon\Carbon::now()->toDateTimeString(), 'updated_at' => \Carbon\Carbon::now()->toDateTimeString()));
 }
 public static function fromArray(&$p)
 {
     $readings = array();
     if (isset($p['readings'])) {
         foreach ($p['readings'] as $reading) {
             $readings[] = Reading::fromArray($reading);
         }
     }
     return new ObservationDetail($p['id'], $p['observatory_id'], $p['begin'], $p['end'], $p['reviewer_user_id'], $p['observer_user_id'], $p['mark_id'], $p['electronics_id'], $p['theodolite_id'], $p['pier_temperature'], $p['elect_temperature'], $p['flux_temperature'], $p['proton_temperature'], $p['outside_temperature'], $p['reviewed'], $p['annotation'], $readings);
 }
Example #3
0
<?
include ('con_db.php');
include ('models/users_model.php');
include ('models/reading_model.php');
$users = new Users($con);
$reading = new Reading($con);
function base_url(){
  	return 'http://'.$_SERVER['HTTP_HOST'].parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
}
?>
<html>
  <head>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
    <title>My FB2Reader Example</title>
    <meta charset="utf-8">
    <link rel="stylesheet" href="style.css">
    <script src="jquery.js"></script>
    <script src="spin.min.js"></script>
    <script src="jquery.color.js"></script>
  </head>
  <body>
<?
if(isset($_GET['action'])){
  if($_GET['action']=='author_act'){
    $valid=$users->checkPass(strip_tags($_POST['login']),strip_tags($_POST['pass']));
      if($valid){
        setcookie('id',$valid,time()+60*60*24*365);
        header('Location: '.base_url());
      }else{
        header('Location: '.base_url().'?error=Не вірно введений логін чи пароль');
      }
Example #4
0
<?php

header('Access-Control-Allow-Origin: *');
include '../classes/reading.php';
//headers
$headers = getallheaders();
/*if (isset($headers['user']) & isset($headers['token']))
  {
      if ($headers['token'] == generatetoken($headers['user']))
      {*/
$averages = Reading::getWeekAverages();
if ($averages != null) {
    $json = '{ 
                            "status" : 0,
                            "averages" : ';
    $first = true;
    $json .= '{ 
                            "station1" : ' . round($averages['station1'], 2) . ',
                            "station2" : ' . round($averages['station2'], 2) . ',
                            "station3" : ' . round($averages['station3'], 2) . '
                        }';
    $json .= "}";
} else {
    $json = '{ "status" : 2, "message" : "There is no data for this Week!" }';
}
/*}
      else $json = '{ "status" : 2, "message" : "Invalid token" }'; 
  }
  else $json = '{ "status" : 1, "message" : "Invalid parameters" }';*/
echo $json;
 function getTemperatureByLocationDateToArray($location, $date)
 {
     //Convert date into the required format
     $formatted_date = date("Y-m-d", strtotime($date));
     //Daabase query
     $query = "SELECT * FROM `reading` AS R, `location` AS L, `sensor` AS S, `sensor_board` AS B, `sensor_type` AS T WHERE R.sensor_idsensor = S.idsensor AND S.sensor_board_id = B.idsensor_board AND B.location_id = L.idlocation AND S.sensor_type = T.idsensor_type AND L.idlocation='" . $location . "' AND T.type_name='Temperature' AND R.date='" . $formatted_date . "' ORDER BY R.idreading DESC LIMIT 50";
     //Open Connection
     $this->con->openConnection();
     //Variable Declaration
     $readings = array();
     $str = '';
     $count = 0;
     //Calculation part
     if ($result = $this->con->executeRawQuery($query)) {
         while ($row = $result->fetch_array()) {
             $read = new Reading($row['idreading'], $row['sensor_idsensor'], $row['date'], $row['time'], $row['value']);
             $readings[] = $read;
             $str .= $read->getValue() . ':';
             $count += 1;
         }
     }
     //Close connection
     $this->con->closeConnection();
     //Return result
     if ($count != 0) {
         return $str;
     } else {
         return 'Not detected';
     }
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Reading::destroy($id);
     return Response::json(array('success' => true));
 }
Example #7
0
            $user = new User(array('email' => $email));
        } else {
            $success = false;
        }
    } catch (fExpectedException $e) {
        $success = false;
    }
    try {
        //$user = new User();
        $email = fRequest::get('email', "string?");
        if (!$success) {
            $user = new User();
            $user->populate();
            $user->store();
        }
        $reading = new Reading();
        $reading->populate();
        $reading->setUserId($user->getUserId());
        //	     if (in_array(strtolower($email), $whitelist)) {
        $reading->setIsVerified(1);
        //		}
        $reading->store();
        echo "Thank you for submitting your radiation reading.";
    } catch (fExpectedException $e) {
        echo $e->printMessage();
    }
    echo '</div>
		</div>
	</div>
</div>';
    $tmpl->place('footer');