コード例 #1
0
ファイル: edit_injury.php プロジェクト: studywithyou/webreg
<?php

// script that displays an injury that is to be edited
include 'DB.php';
include 'db_config.php';
// Grab our models
include './models/franchises.php';
include './models/games.php';
include './models/injuries.php';
$db = DB::connect(DSN);
$franchiseModel = new Franchise($db);
$gameModel = new Game($db);
$injuryModel = new Injury($db);
$injuryId = htmlspecialchars($_GET['id']);
$maxWeek = $gameModel->getMaxWeek();
$injury = $injuryModel->find($injuryId);
$franchises = $franchiseModel->getAll();
$token = sha1('ibl2012' . $injury['id']);
include './templates/edit_injury.php';
コード例 #2
0
<?php

// Controller for main page
include 'vendor/autoload.php';
include 'db_config.php';
// Grab all our models
include './models/injuries.php';
include './models/franchises.php';
include './models/games.php';
// Collect data
$franchiseModel = new Franchise($db);
$injuryModel = new Injury($db);
$gameModel = new Game($db);
$maxWeek = $gameModel->getMaxWeek();
$injuries = $injuryModel->getAll($maxWeek);
$franchises = $franchiseModel->getAll();
// Display template
include './templates/injury_management.php';
コード例 #3
0
<?php

// Script that processes an injury to be added to the system
include 'DB.php';
include 'db_config.php';
include './models/games.php';
include './models/injuries.php';
$db = DB::connect(DSN);
$injuryModel = new Injury($db);
// Grab whatever came in via $_POST and make sure it's okay
$weekStarting = filter_var($_POST['week_starting'], FILTER_VALIDATE_INT);
$weekEnding = filter_var($_POST['week_ending'], FILTER_VALIDATE_INT);
$franchiseId = filter_var($_POST['franchise_id'], FILTER_VALIDATE_INT);
$description = htmlspecialchars($_POST['description']);
$data = array('week_starting' => $weekStarting, 'week_ending' => $weekEnding, 'franchise_id' => $franchiseId, 'description' => $description);
/**
 * Let's look and see if we got a token passed in. If we did, then let's make
 * sure the token is correct and then add the ID for the record to the data
 * that is passed in to be saved
 */
if (isset($_POST['token'])) {
    $expectedToken = sha1('ibl2012' . $_POST['id']);
    if ($expectedToken != $_POST['token']) {
        die('bad token, m**********r');
        header('Location: injury_management.php');
        exit;
    }
    $data['id'] = $_POST['id'];
}
$injuryModel->save($data);
header('Location: injury_management.php');