function channel_authenticate() { if (empty($_POST['unikey']) || empty($_POST['u_ID']) || empty($_POST['c_ID'])) { forbidden_page("Authentication failed, wrong parameters."); } else { $auth = new AuthModel(); $unikey = $_POST['unikey']; $ID = $_POST['u_ID']; $c_ID = $_POST['c_ID']; if (!$auth->channel_authentication($unikey, $ID, $c_ID)) { forbidden_page("Authentication failed"); } else { return true; } } }
public function custom($interval) { //$custom = "1 DAY"; switch ($interval) { case "1": $custom = "24 HOUR"; break; case "2": $custom = "1 WEEK"; break; case "3": $custom = "1 MONTH"; break; case "4": $custom = "99 YEAR"; break; default: $custom = "24 HOUR"; break; } $api = sql("SELECT name FROM forecast GROUP BY name", $this->mysqli); if (sizeof($api) <= 0) { return forbidden_page("No forecast found"); } $result = array(); foreach ($api as $key) { $this->openConnection(); $row = sql("SELECT temp, ID FROM forecast WHERE date > (current_timestamp - INTERVAL {$custom}) AND name = '" . $key['name'] . "' ORDER BY ID ASC", $this->mysqli); $temp = array(); foreach ($row as $r) { $temp[] = $r['temp']; } $result = array_merge($result, array($key['name'] => $temp)); } $this->openConnection(); $row = sql("SELECT date FROM forecast WHERE date > (current_timestamp - INTERVAL {$custom}) GROUP BY date", $this->mysqli); $dates = array(); foreach ($row as $r) { $dates[] = $r['date']; } $result = array_merge($result, array("dates" => $dates)); return $result; }