示例#1
0
<?php

//configuration
require "../includes/config.php";
//render template
render2("../templates/proposed_template.php");
示例#2
0
<?php

//configuration
require "../includes/config.php";
//if user reached the page via GET
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    $spot_info = query("SELECT * FROM spots WHERE id = ?", $_GET["id"]);
    //store tricks rows of the spot in $tricks
    $tricks = query("SELECT * FROM tricks WHERE id = ?", $_GET["id"]);
    $counter = 0;
    //sort tricks by skater
    $sortedBySkater = array_sort($tricks, "skater", SORT_ASC);
    //set default tricks to be sorted by skater
    $tricks = $sortedBySkater;
    //display tricks
    render2("../templates/display_template.php", ["spot_info" => $spot_info, "tricks" => $tricks, "counter" => $counter, "title" => "Tricks history"]);
} else {
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        $spot_info = query("SELECT * FROM spots WHERE id = ?", $_GET["id"]);
        //store tricks rows of the spot in $tricks
        $tricks = query("SELECT skater, trick, source, link FROM tricks WHERE id = ?", $_GET["id"]);
        $counter = 0;
        //sort tricks by the way selected by the user
        //$selected_sorting = $_POST["sortingMethod"];
        $sorted_tricks = array_sort($tricks, $_POST["sortingMethod"], SORT_ASC);
        //change original array(the one which will be passed to the template)
        $tricks = $sorted_tricks;
        //display tricks
        render2("../templates/display_template.php", ["spot_info" => $spot_info, "tricks" => $tricks, "counter" => $counter, "title" => "Tricks history"]);
    }
}
示例#3
0
<?php

// configuration
require "../includes/config.php";
// if user reached page via GET (as by clicking a link or via redirect)
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    // else render form
    render2("login_form.php", ["title" => "Log In"]);
} else {
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        // validate submission
        if (empty($_POST["username"])) {
            apologize("You must provide your username.");
        } else {
            if (empty($_POST["password"])) {
                apologize("You must provide your password.");
            }
        }
        // query database for user
        $rows = query("SELECT * FROM users WHERE username = ?", $_POST["username"]);
        // if we found user, check password
        if (count($rows) == 1) {
            // first (and only) row
            $row = $rows[0];
            // compare hash of user's input against hash that's in database
            if (crypt($_POST["password"], $row["hash"]) == $row["hash"]) {
                // remember that user's now logged in by storing user's ID in session
                $_SESSION["id"] = $row["id"];
                // redirect to portfolio
                redirect("/");
            }
示例#4
0
<?php

//config
require "../includes/config.php";
$user = query("SELECT * FROM users WHERE id = ?", $_SESSION["id"]);
//render template
render2("../templates/profile_template.php", ["title" => "Profile", "user" => $user]);
示例#5
0
<?php

require "../includes/config.php";
render2("contacts_template.php", ["title" => "contacts"]);
?>

<script>
    document.getElementById("very_bottom").style.display = "none";
</script>

示例#6
0
<?php

require "../includes/config.php";
render2("../templates/prova_template.php");
示例#7
0
<?php

//config
require "../includes/config.php";
$trick_info = query("SELECT * FROM tricks WHERE num = ?", $_GET["num"]);
//render template
render2("../templates/trick_page_template.php", ["title" => "Trick Info", "trick_info" => $trick_info]);
<?php

//configuration
require "../includes/config.php";
//if page is reaches via GET
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    //store proposals rows in $proposals
    $proposals = query("SELECT * FROM proposals");
    //display proposals
    render2("../templates/assess_proposals_template.php", ["proposals" => $proposals]);
} else {
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        //insert proposal in the tricks table
        query("INSERT INTO tricks (id, skater, trick, source, link) SELECT id, skater, trick, source, link FROM proposals WHERE num = ?", $_POST["num"]);
        //remove the rows off the proposal table
        query("DELETE FROM proposals WHERE num = ?", $_POST["num"]);
        //redirect to proposals page
        redirect("assess_proposals.php");
    }
}
示例#9
0
<?php

// configuration
require "../includes/config.php";
// if user reached page via GET (as by clicking a link or via redirect)
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    // render form
    render2("signin_form.php", ["title" => "Sign In", "loginpage" => true]);
} else {
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        // validate submission
        if (empty($_POST["username"])) {
            apologize("You must provide your username.");
        } else {
            if (empty($_POST["password"])) {
                apologize("You must provide your password.");
            }
        }
        // query database for user
        $rows = query("SELECT * FROM users WHERE username = ?", $_POST["username"]);
        // if we found user, check password
        if (count($rows) == 1) {
            // first (and only) row
            $row = $rows[0];
            // compare hash of user's input against hash that's in database
            if (crypt($_POST["password"], $row["hash"]) == $row["hash"]) {
                // remember that user's now logged in by storing user's ID in session
                $_SESSION["id"] = $row["id"];
                // redirect to home
                redirect("/");
            }
示例#10
0
<?php

// configuration
require "../includes/config.php";
// if user reached page via GET (as by clicking a link or via redirect)
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    // render form
    render2("login_form.php", ["title" => "Log In", "loginpage" => true]);
} else {
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        // validate submission
        if (empty($_POST["username"])) {
            apologize("You must provide your username.");
        } else {
            if (empty($_POST["password"])) {
                apologize("You must provide your password.");
            }
        }
        // query database for user
        $rows = query("SELECT * FROM users WHERE username = ?", $_POST["username"]);
        // if we found user, check password
        if (count($rows) == 1) {
            // first (and only) row
            $row = $rows[0];
            // compare hash of user's input against hash that's in database
            if (crypt($_POST["password"], $row["hash"]) == $row["hash"]) {
                // remember that user's now logged in by storing user's ID in session
                $_SESSION["id"] = $row["id"];
                // redirect to home
                redirect("/");
            }
示例#11
0
<?php

//configuration
include "../includes/config.php";
$user = query("SELECT * FROM users WHERE id = ?", $_SESSION["id"]);
render2("../templates/profile_template.php", ["user" => $user]);
示例#12
0
<?php

//configuration
require "../includes/config.php";
//why invalid template?
render2("about_template.php", ["title" => "About"]);
示例#13
0
<?php

//configuration
require "../includes/config.php";
//render home
render2("home_template.php", ["title" => "Home"]);
示例#14
0
<?php

//configuration
require "../includes/config.php";
//if user reached page via GET (as by clicking a link or via redirect)
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    //else render form
    render2("register_form.php", ["title" => "Register"]);
} else {
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        //TODO
        //user and password cannot be empty
        if ($_POST["username"] == "" || $_POST["password"] == "" || $_POST["confirmation"] == "") {
            apologize("You didn't type all the information we need");
        }
        //password and confirmation have to match
        if ($_POST["password"] !== $_POST["confirmation"]) {
            apologize("Passwords do not match!");
        }
        $result = query("INSERT INTO users (username, hash, cash) VALUES(?, ?, 10000.00)", $_POST["username"], crypt($_POST["password"]));
        //check if query gives false(meaning that the username already exists)
        if ($result === false) {
            apologize("Error! Probably usarname already exists...");
        } else {
            //log the user in:
            //find the id
            $rows = query("SELECT LAST_INSERT_ID() AS id");
            $id = $rows[0]["id"];
            //store id in session
            $_SESSION["id"] = $id;
            //redirect to index.php
示例#15
0
<?php

//configuration
require "../includes/config.php";
render2("../templates/about_template.php", ["title" => "About"]);
示例#16
0
<?php

//conf
require "../includes/config.php";
//render
render2("../templates/registered_template.php", ["title" => "Successful registration"]);
示例#17
0
<?php

//configuration
require "../includes/config.php";
//store tricks rows of the spot in $tricks
$tricks = query("SELECT skater, trick, source, link FROM tricks WHERE id = ?", $_GET["id"]);
//display tricks
render2("../templates/display_template.php", ["tricks" => $tricks, "title" => "Tricks history"]);
示例#18
0
/**
 * Apologizes to user with message.
 */
function apologize($message)
{
    render2("apology.php", ["message" => $message]);
    exit;
}
示例#19
0
<?php

//configuration
require "../includes/config.php";
//if user reached the page via GET
if ($_SERVER["REQUEST_METHOD"] == "GET") {
    //store tricks rows of the spot in $tricks
    $tricks = query("SELECT skater, trick, source, link FROM tricks WHERE id = ?", $_GET["id"]);
    $counter = 0;
    //sort tricks by skater
    $sortedBySkater = array_sort($tricks, "skater", SORT_ASC);
    //set default tricks to be sorted by skater
    $tricks = $sortedBySkater;
    //display tricks
    render2("../templates/display_template_with_colors.php", ["tricks" => $tricks, "counter" => $counter, "title" => "Tricks history"]);
} else {
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        //store tricks rows of the spot in $tricks
        $tricks = query("SELECT skater, trick, source, link FROM tricks WHERE id = ?", $_GET["id"]);
        $counter = 0;
        //sort tricks by the way selected by the user
        //$selected_sorting = $_POST["sortingMethod"];
        $sorted_tricks = array_sort($tricks, $_POST["sortingMethod"], SORT_ASC);
        //change original array(the one which will be passed to the template)
        $tricks = $sorted_tricks;
        //display tricks
        render2("../templates/display_template_with_colors.php", ["tricks" => $tricks, "counter" => $counter, "title" => "Tricks history"]);
    }
}