Beispiel #1
0
<?php

ini_set('display_errors', 1);
ini_set('display_startup_errors', 0);
error_reporting(E_ERROR | E_PARSE);
require "db.php";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
</head>

<body>
<pre>
<?php 
$testTrail = new trail();
$testTrail->setID(1);
print_r($testTrail->getInfo("Array"));
?>
</pre>
</body>
</html>
Beispiel #2
0
$page_type = "admin";
$error = false;
if (!isset($_GET['id']) || empty($_GET['id'])) {
    $error = true;
    $error_type = "missing_id";
    $error_details = "The trail ID was not provided in the request.<br><br>";
}
if (!is_numeric($_GET['id']) && $error === false) {
    $error = true;
    $error_type = "invalid_id";
    $error_details = "The trail ID should be an integer. '" . htmlspecialchars($_GET['id']) . "' is an invalid id value.";
}
if (!$error) {
    $trailObj = new trail();
    $trailObj->setID(intval($_GET['id']));
    $trail = $trailObj->getInfo("Array");
    if ($trail == "Etrail") {
        //ERROR - Trail does not exist
        $error = true;
        $error_type = "unknown_id";
        $error_details = "The trail ID '" . htmlspecialchars($_GET['id']) . "' was not found in our database. It may have been deleted from our system. Please contact us if you have any questions or concerns.";
    } else {
        $update = false;
        if (in_array($lang, $trail['translations'])) {
            $update = true;
            $translation = $trailObj->getTranslation($lang, "Array");
        }
    }
}
if (!$error) {
    ini_set('display_errors', 1);
Beispiel #3
0
<?php

if (empty($_POST['id'])) {
    die("bad request");
}
require "../admin/db.php";
if ($userActive) {
    $id = intval($_POST['id']);
    $trail = new trail();
    $trail->setID($id);
    $info = $trail->getInfo("array");
    $rating = $info['rating'];
    $ratings = $info['ratings'];
    $userRating = intval($_POST['value']);
    $newRatings = $ratings + 1;
    $weighted = $rating * $ratings;
    $add = $weighted + $userRating;
    $newRating = $add / $newRatings;
    $rate = $_SESSION['data']['rate'];
    if (is_array($rate)) {
        $rate[] = $id;
    } else {
        $rate = array(0, $id);
    }
    $_SESSION['data']['rate'] = $rate;
    $update = array("rate" => $rate);
    $authObj = new Auth();
    $result = $authObj->setAttr($_SESSION['user_id'], $update);
    $update = array("rating" => $newRating, "ratings" => $newRatings);
    $response = $trail->setAttr($update);
    if ($response == "done") {
Beispiel #4
0
                    <p>These data are licensed under the <a class="green-text text-darken-3" rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.</p>

                    <h3>Trail Object</h3>                    
                    <p>Trail data can be retrieve by sending a <code>GET</code> request to <code><?php 
echo $baseurl;
?>
api/trail/</code> with the trail's id as a variable. For example, <code>GET <?php 
echo $baseurl;
?>
api/trail/?id=2</code> returns the following information in JSON:</p>
                    <pre>

	<?php 
$GetTrail = new trail();
$GetTrail->setID(2);
echo json_encode($GetTrail->getInfo("Array"), JSON_PRETTY_PRINT);
?>

                    </pre>

                    <h3>Filter</h3>                    
                    <p>Our database can be searched by sending a <code>GET</code> request to <code><?php 
echo $baseurl;
?>
api/filter/</code> with filter commands as variables. Each request will return the number of trails returned as <code>countReturned</code> and the total number of trails matched by the query as <code>totalMatched</code>. Note, you must set <code>offset</code> and <code>count</code>. For example, <code>GET <?php 
echo $baseurl;
?>
api/filter/?by=city&city=Albuquerque&offset=0&count=6 </code> returns the following information in JSON:</p>
                    <pre>

	<?php 
Beispiel #5
0
<?php

require "../../admin/db.php";
if ($_GET['maintainAdmin'] == "yes") {
    $adminPage = true;
    require "../../src/secure.php";
}
header('Content-Type: application/json');
if (!isset($_GET['id']) || empty($_GET['id'])) {
    $response = array("status" => "error", "type" => "MISSING_ID", "message" => "The trail ID was not provided in the request. See " . $baseurl . "api/");
    echo json_encode($response);
    exit;
}
if (!is_numeric($_GET['id']) && $error === false) {
    $response = array("status" => "error", "type" => "INVALID_ID", "message" => "The trail ID should be an integer. '" . htmlspecialchars($_GET['id']) . "' is an invalid id value. See " . $baseurl . "api/");
    echo json_encode($response);
    exit;
}
$trailObj = new trail();
$trailObj->setID(intval($_GET['id']));
$trail = $trailObj->getInfo("JSON");
if ($trail == "Etrail") {
    $response = array("status" => "error", "type" => "UNKNOWN_ID", "message" => "The trail ID '" . htmlspecialchars($_GET['id']) . "' was not found in our database. It may have been deleted from our system. Please contact us if you have any questions or concerns. See " . $baseurl . "api/");
    echo json_encode($response);
    exit;
} else {
    echo $trail;
}