Example #1
0
 public function newUser($username, $password, $email)
 {
     $insertResult = DB::insert('users', ['username' => $username, 'password' => password_hash($password, PASSWORD_DEFAULT), 'email' => $email], self::USER_TYPES);
     $queryResult['success'] = is_bool($insertResult) ? true : false;
     $queryResult['error'] = is_string($insertResult) ? $insertResult : '';
     return $queryResult;
 }
Example #2
0
 public function getMoviesID()
 {
     //connect to database :
     include '../autoloader.php';
     $db2 = DB::getDB();
     //Execute the Query
     $queryAllMoviesId = 'SELECT film_id FROM moviefeature';
     $getId = $db2->prepare($queryAllMoviesId);
     $getId->execute();
     $getIds = $getId->fetchAll();
     $getId->closeCursor();
     return $getIds;
 }
Example #3
0
 public function saveMenu(array $menus)
 {
     // truncate, very bad
     DB::getDB()->exec('TRUNCATE menus');
     $stmt = DB::getDB()->prepare('INSERT INTO menus VALUES (:name, :menu)
   ON DUPLICATE KEY UPDATE name = :name, menu = :menu');
     foreach ($menus as $menu) {
         $stmt->bindParam(':name', $menu['name'], \PDO::PARAM_STR);
         $stmt->bindParam(':menu', json_encode($menu['menu']), \PDO::PARAM_STR);
         if (!$stmt->execute()) {
             return false;
         }
     }
     return true;
 }
Example #4
0
 private function updateCookie($userId)
 {
     $id = hash('sha256', mt_rand());
     $token = password_hash(mt_rand(), PASSWORD_DEFAULT);
     $rememberStmt = $this->db->prepare('
   INSERT INTO tokens (id, token, user_id)
   VALUES(:id, :token, :user_id)
   ON DUPLICATE KEY UPDATE token = :token;
 ');
     $rememberStmt = DB::bindValues($rememberStmt, ['id' => $id, 'user_id' => $userId, 'token' => $token], self::TOKEN_TYPES);
     if ($rememberStmt->execute()) {
         $cookie = "{$id};{$token}";
         return setcookie('rememberme', $cookie, time() + 604800, '/', '', false, true);
     } else {
         return false;
     }
 }
Example #5
0
<?php

use Project\Classes\DB\DB;
include '../../autoloader.php';
require_once '../Model/Filmadmin.php';
//require_once '../../FilmAdmin_CMS/Model/Filmadmin.php';
require_once 'manage_movie.php';
$db = DB::getDB();
//validate date
$date_regex = '/^(19|20)\\d\\d[\\-\\/.](0[1-9]|1[012])[\\-\\/.](0[1-9]|[12][0-9]|3[01])$/';
// Validate inputs
if (empty($title) || empty($releaseDate) || empty($cast) || empty($director) || empty($thumbnail)) {
    echo "<span style='color:red;font-size:24px;'>";
    $error = "Invalid Movie data. Check all fields and try again.";
    echo $error;
    echo "</span>";
} else {
    if (!preg_match($date_regex, $releaseDate)) {
        $error = "Your date entry does not match the YYYY-MM-DD required format.";
        echo "<span style='color:red;font-size:24px;'>";
        echo $error;
        echo "</span>";
    } else {
        // If valid, update the movie to the database
        $thumbnail = "/Assets/image/HomePage/" . "thumb_" . $file_get;
        $updatingMovie = new Filmadmin();
        $updatingMovie->updateMovie($title, $releaseDate, $director, $cast, $thumbnail, $film_id);
        // Display the Movie List page
        // header('location: ../View/IndexMovies_AdminView.php');
        header('location: /admin/movie');
    }
Example #6
0
 public function __construct()
 {
     $this->db = DB::getDB();
     Helper::startSession();
 }
Example #7
0
<?php

use Project\Classes\DB\DB;
require_once './Model/Ratings.php';
require_once '../autoloader.php';
require_once 'database.php';
require_once '../FilmAdmin_CMS/Model/Filmadmin.php';
$db = Database::getDB();
$db2 = DB::getDB();
$getMovieID = new Filmadmin();
$getMoviesId = $getMovieID->getMoviesID();
//define  quantity of movies in array and it's display rating system for that
$ids = array();
foreach ($getMoviesId as $film) {
    // $ids = $film['film_id'];
    array_push($ids, $film['film_id']);
    $filename_arr = $ids;
    $Movieid = implode(',', $filename_arr);
}
?>

<html>
<head>
    <meta charset="UTF-8">
    <title>Rate Movie</title>
    <script src="jquery.js" type="text/javascript"></script>
    <link rel="stylesheet" href="rating.css" />
    <script type="text/javascript" src="rating.js"></script>
</head>
<body>
Example #8
0
 public function delete($id)
 {
     $stmt = DB::getDB()->prepare('DELETE FROM pages WHERE id = :id');
     self::bindValues($stmt, [':id' => $id]);
     return $stmt->execute() == 1 ? true : false;
 }
Example #9
0
 public function contactProcess()
 {
     //connect to database :
     include '../../../autoloader.php';
     $db = DB::getDB();
     $first_name = htmlspecialchars($_POST['first_name']);
     $last_name = htmlspecialchars($_POST['last_name']);
     $Email = htmlspecialchars($_POST['Email']);
     $Message = htmlspecialchars($_POST['Message']);
     // Now inserting form values to the database table
     $query = "INSERT INTO contactus(first_name,last_name,Email,Message) VALUES ('{$first_name}','{$last_name}','{$Email}','{$Message}')";
     $contactQuery = $db->prepare($query);
     $contactQuery->execute();
     $contactQuery->closeCursor();
 }