public function __construct($id) { $myDB = new DBFactory(); $this->sql = $myDB->getMysqlConnexionWithPDO(); $this->classes = $this->getClasses(); $this->id = $id; }
function getRole($role) { $myDB = new DBFactory(); $sql = $myDB->getMysqlConnexionWithPDO(); $query = $sql->prepare("SELECT id, login, role FROM users WHERE role = :role AND login != :me"); $query->execute(array('role' => $role, 'me' => $_SESSION['user'])); return $query->fetchAll(); }
function getCharacters() { $myDB = new DBFactory(); $sql = $myDB->getMysqlConnexionWithPDO(); $query = $sql->prepare("SELECT chars.*, class.name AS className, spec1.role_name AS role1, spec2.role_name AS role2 FROM chars, specs AS spec1, specs AS spec2, class WHERE chars.spec1 = spec1.id AND chars.spec2 = spec2.id AND spec1.class_id = class.id"); $query->execute(); return $query->fetchAll(); }
<?php session_start(); define('DB_NAME', 'dream'); define('DB_USER', 'da'); define('DB_PASSWORD', 'dream-admin2015'); include_once '../include/functions.php'; include_once '../include/DBF.php'; $user = "******"; if (notNull($_SESSION) && notNull($_SESSION['user'])) { $user = $_SESSION['user']; } $url = explode("/", currentPage()); $page = $url[sizeof($url) - 1]; $myDB = new DBFactory(); $sql = $myDB->getMysqlConnexionWithPDO(); $sql->beginTransaction(); try { $statement = "INSERT INTO deadlinks (link) VALUES(:link)"; $query = $sql->prepare($statement); $query->execute(array('link' => currentPage())); $sql->commit(); } catch (Exception $e) { $sql->rollBack(); } logWarning($user, 2, $user . " requested a dead link : " . currentPage()); ?> <h1>404</h1> <p>La page que vous avez demandé n'existe pas ou plus</p> <a href="/">Retourner à l'accueil</a>
public function __construct() { $myDB = new DBFactory(); $this->sql = $myDB->getMysqlConnexionWithPDO(); }
function getFeeds($search = "") { $queryStr = "SELECT * FROM feeds"; $args = array(); $searches = array(); if ($search != "") { if (strpos($search, "::")) { $queryStr .= " WHERE"; if (strpos($search, ";")) { $searches = explode(";", $search); } else { $searches[0] = $search; } $i = 0; foreach ($searches as $option) { $option = explode("::", $option); if ($i == 0) { $queryStr .= " feeds." . $option[0] . " = :s_" . $option[0]; } else { $queryStr .= " AND feeds." . $option[0] . " = :s_" . $option[0]; } $i++; $args["s_" . $option[0]] = $option[1]; } } else { echo "FATAL"; logError($_SESSION['user'], 3, $_SESSION['user'] . " tried to find unreachable feed with search criteria : " . $search); } } $myDB = new DBFactory(); $sql = $myDB->getMysqlConnexionWithPDO(); $queryStr .= " ORDER BY feeds.post_date DESC;"; $query = $sql->prepare($queryStr); $query->execute($args); $result = $query->fetchAll(); return $result; }
<?php require 'lib/autoload.php'; $db = DBFactory::getMysqlConnexionWithPDO(); $manager = new NewsManagerPDO($db); ?> <!DOCTYPE html> <html> <head> <title>Accueil du site</title> <meta charset="utf-8" /> </head> <body> <p><a href="admin.php">Accéder à l'espace d'administration</a></p> <?php if (isset($_GET['id'])) { $news = $manager->getUnique((int) $_GET['id']); echo '<p>Par <em>', $news->auteur(), '</em>, le ', $news->dateAjout()->format('d/m/Y à H\\hi'), '</p>', "\n", '<h2>', $news->titre(), '</h2>', "\n", '<p>', nl2br($news->contenu()), '</p>', "\n"; if ($news->dateAjout() != $news->dateModif()) { echo '<p style="text-align: right;"><small><em>Modifiée le ', $news->dateModif()->format('d/m/Y à H\\hi'), '</em></small></p>'; } } else { echo '<h2 style="text-align:center">Liste des 5 dernières news</h2>'; foreach ($manager->getList(0, 5) as $news) { if (strlen($news->contenu()) <= 200) { $contenu = $news->contenu(); } else { $debut = substr($news->contenu(), 0, 200); $debut = substr($debut, 0, strrpos($debut, ' ')) . '...'; $contenu = $debut;
} else { if (is_file('manager/' . $class_name . '.php')) { require_once 'manager/' . $class_name . '.php'; } } } spl_autoload_register("my_autoload"); require_once 'lib/Facebook/autoload.php'; //Session call session_start(); //Make inludes and add html headers, modules... function createPage($pageName) { //Include Header & navbar include "views/modules/module.header.php"; include "views/modules/module.navbar.php"; include 'views/view.' . $pageName . '.php'; //include footer include "views/modules/module.footer.php"; } function isLogged() { if (isset($_SESSION['user']) && !empty($_SESSION['user']) && $_SESSION['user'] instanceof User) { return true; } else { return false; } } $dbFactory = new DBFactory(); $db = $dbFactory->getMysqlConnexionWithPDO(); $mailer = new UnisalesMailer();
function initDB() { $myDB = new DBFactory(); $sql = $myDB->getMysqlConnexionWithPDO(); return $sql; }