コード例 #1
0
 /**
  * 
  * @param array $data
  * @param string $token
  */
 public function __construct($data, $token)
 {
     // Override for avoid Token's check
     $this->setData($data);
     //check db connection
     PDOFactory::getPDO();
 }
コード例 #2
0
 public function __construct($id = NULL, $temp = false)
 {
     # If we want to retrieve an object from temporary table
     # This is used for example when we have a notification that displays
     # action point that has been changed, we want to display what was the change
     # and therefore we need the old object as well as the new one
     if ($temp) {
         $temp = 'Temp';
     } else {
         $temp = '';
     }
     # Set instance variables
     $this->strTableName = $this->DefineTableName() . $temp;
     $this->arRelationMap = $this->DefineRelationMap();
     # Get DB connection
     $this->objPDO = PDOFactory::get();
     # By default properties are not loaded
     $this->blIsLoaded = false;
     # If we want to load a particular object
     if (isset($id)) {
         $this->ID = $id;
     }
     # By default, there are no modified properties
     $this->arModifiedRelations = array();
 }
コード例 #3
0
ファイル: script-1.php プロジェクト: Tipkin-Commons/tipkin
function lauchScript1()
{
    $managers = new Managers('pdo', PDOFactory::getMysqlConnexion());
    $reservationManager = $managers->getManagerOf('announcementreservations');
    $announcementManager = $managers->getManagerOf('announcements');
    $userManager = $managers->getManagerOf('users');
    //On supprime les réservations non-payée
    $reservationManager->deletePassedWaitingPaiement();
    $listOfReservationPassed = $reservationManager->getListOfPassed();
    $messageMail = new Mail();
    $countRervation = 0;
    foreach ($listOfReservationPassed as $reservation) {
        $reservation->setStateId(PaiementStates::CANCELED);
        $reservation->setUpdatedTime(time());
        $reservation->setKeyCheck(null);
        $reservationManager->save($reservation);
        $announce = $announcementManager->get($reservation->getAnnouncementId());
        $userOwner = $userManager->get($reservation->getUserOwnerId());
        $userSubscriber = $userManager->get($reservation->getUserSubscriberId());
        $messageMail->sendReservationSubscriberCanceled($userOwner, $userSubscriber, $announce);
        $messageMail->sendAdminReservationSubscriberCanceled($userOwner, $userSubscriber, $announce, $reservation);
        $countRervation++;
    }
    if ($countRervation > 0) {
        echo $countRervation . ' mail(s) d\'annulation de réservation envoyé(s) !';
    }
}
コード例 #4
0
 /**
  * 
  * @param string $email
  * @param string $password
  * @return UserMagic $usermagic
  */
 public static function createNewUser($email, $password)
 {
     $pdo = PDOFactory::getPDO();
     $i = $pdo->prepare("INSERT INTO users(email, password) VALUES (:email, :password)");
     $i->execute([":email" => $email, ":password" => $password]);
     return new UserMagic($email, $password);
 }
コード例 #5
0
 public function __construct($api, $app)
 {
     $this->api = $api;
     $this->dao = PDOFactory::getMysqlConnexion($app);
     $this->dal_folder_path = $app->config()->get("DalFolderPath");
     $this->core_dal_folder_path = "\\Library\\DAL\\Modules\\";
 }
コード例 #6
0
 /**
  * A method to get notification objects
  * @param int $projectId the project id these notes are associated with
  * @return array the notification objects
  */
 public static function getNotificationsForProject($projectId)
 {
     # Get db connection
     $objPDO = PDOFactory::get();
     # Get all notifications associated with the $projectId from a database
     $strQuery = "SELECT id, object_type FROM Notification WHERE project_id = :project_id AND is_deleted = 0 ORDER BY datetime_created DESC";
     $objStatement = $objPDO->prepare($strQuery);
     $objStatement->bindValue(':project_id', $projectId, PDO::PARAM_INT);
     $objStatement->execute();
     # Define empty array
     $myArr = array();
     # Add all notifications associated with the $projectId to an array
     if ($result = $objStatement->fetchAll(PDO::FETCH_ASSOC)) {
         foreach ($result as $row) {
             # Decide what kind of object should be created
             switch ($row["object_type"]) {
                 case "Action Point":
                     $myArr[$row["id"]] = new NotificationAP(null, null, $row["id"]);
                     break;
                 case "Meeting":
                     $myArr[$row['id']] = new NotificationMeeting(null, null, $row['id']);
                     break;
                 case "Note":
                     $myArr[$row['id']] = new NotificationNote(null, null, $row['id']);
                     break;
                 default:
                     $myArr[$row["id"]] = new Notification(null, null, $row["id"]);
             }
         }
     }
     # Return the array of notifications
     return $myArr;
 }
コード例 #7
0
 public function __construct(Application $app, $module, $action = '')
 {
     parent::__construct($app);
     $this->managers = new Managers('PDO', PDOFactory::getMysqlConnexion());
     $this->page = new Page($app);
     $this->setModule($module);
     $this->setAction($action);
     $this->setView($action);
 }
コード例 #8
0
 public function __construct(Application $app, $module, $action)
 {
     parent::__construct($app);
     $this->managers = new Managers('PDO', PDOFactory::getMysqlConnexion());
     $this->page = new Page($app);
     $this->cache = new Cache(__DIR__ . '/../../tmp/cache/datas', __DIR__ . '/../../tmp/cache/views');
     $this->setModule($module);
     $this->setAction($action);
     $this->setView($action);
 }
コード例 #9
0
 /**
  * 
  * @param type $token
  * @throws ErrorLoginException
  */
 public function checkToken($token)
 {
     $pdo = PDOFactory::getPDO();
     $ms = $pdo->prepare("SELECT * FROM session WHERE token=:token");
     $ms->execute([":token" => $token]);
     if (($results = $ms->fetchObject()) != null) {
         $username = $pdo->prepare("SELECT * FROM users WHERE id=:iduser");
         $username->execute([":iduser" => $results->idUser]);
         $usernameobj = $username->fetchObject();
         $this->setUser(["id" => $usernameobj->id]);
     } else {
         throw new ErrorLoginException("Wrong Token " . $token);
     }
 }
コード例 #10
0
 public function __construct(Application $app, $module, $action)
 {
     parent::__construct($app);
     $this->managers = new Managers('pdo', PDOFactory::getMysqlConnexion());
     $this->page = new Page($app);
     $this->setModule($module);
     $this->setAction($action);
     $this->setView($action);
     if ($this->app->name() == 'frontend') {
         $this->initUser();
     } else {
         $this->initAdmin();
     }
 }
コード例 #11
0
ファイル: script-2.php プロジェクト: Tipkin-Commons/tipkin
function lauchScript2()
{
    $managers = new Managers('pdo', PDOFactory::getMysqlConnexion());
    $reservationManager = $managers->getManagerOf('announcementreservations');
    $feedbacksManager = $managers->getManagerOf('feedbacks');
    $feedbackRequestsManager = $managers->getManagerOf('feedbackrequests');
    $contactsManager = $managers->getManagerOf('contacts');
    $contactRequestsManager = $managers->getManagerOf('contactrequests');
    $usersManager = $managers->getManagerOf('users');
    $listOfPassedReservation = $reservationManager->getListOfPassedValidated();
    $messageMail = new Mail();
    foreach ($listOfPassedReservation as $reservation) {
        $listOfFeddbackRequest = $feedbackRequestsManager->getByReservationId($reservation->id());
        $listOfFeddback = $feedbacksManager->getByReservationId($reservation->id());
        if (count($listOfFeddback) + count($listOfFeddbackRequest) == 0) {
            $feedbackRequest = new FeedbackRequest();
            $feedbackRequest->setAnnounceId($reservation->getAnnouncementId());
            $feedbackRequest->setReservationId($reservation->id());
            $feedbackRequest->setUserOwnerId($reservation->getUserOwnerId());
            $feedbackRequest->setUserSubscriberId($reservation->getUserSubscriberId());
            //ENVOI POUR LE PRETEUR
            $feedbackRequest->setId(null);
            $feedbackRequest->setUserAuthorId($feedbackRequest->getUserOwnerId());
            $feedbackRequestsManager->save($feedbackRequest);
            //Envoyer un mail pour le preteur ICI
            $messageMail->sendFeedbackRequest($usersManager->get($feedbackRequest->getUserOwnerId()), $usersManager->get($feedbackRequest->getUserSubscriberId()));
            //ENVOI POUR L'EMPRUNTEUR
            $feedbackRequest->setId(null);
            $feedbackRequest->setUserAuthorId($feedbackRequest->getUserSubscriberId());
            $feedbackRequestsManager->save($feedbackRequest);
            //Envoyer un mail pour l'emprunteur ICI
            $messageMail->sendFeedbackRequest($usersManager->get($feedbackRequest->getUserSubscriberId()), $usersManager->get($feedbackRequest->getUserOwnerId()));
            //On effectue la création d'un ajout de contact s'ils ne le sont pas déjà ou qu'aucune demande n'est en attente
            $contactRequest = new ContactRequest();
            $contactRequest->setContactGroupId(ContactGroups::TIPPEURS);
            $contactRequest->setUserIdFrom($reservation->getUserSubscriberId());
            $contactRequest->setUserIdTo($reservation->getUserOwnerId());
            if (!$contactRequestsManager->isContactRequestExist($contactRequest) && !$contactsManager->isContactExistById($contactRequest->getUserIdFrom(), $contactRequest->getUserIdTo())) {
                $contactRequestsManager->save($contactRequest);
                $userFrom = $usersManager->get($contactRequest->getUserIdFrom());
                $userTo = $usersManager->get($contactRequest->getUserIdTo());
                $messageMail->sendContactRequest($userFrom, $userTo);
            }
        }
    }
}
コード例 #12
0
ファイル: BackendTest.php プロジェクト: bmdevel/bav
 /**
  * @return DataBackend[]
  */
 public function provideInstallationBackends()
 {
     $backends = array();
     $backends[] = new PDODataBackend(PDOFactory::makePDO(), "bavtest_");
     $fileUtil = new FileUtil();
     $backends[] = new FileDataBackend(tempnam($fileUtil->getTempDirectory(), "bavtest"));
     $conn = array("driver" => "pdo_sqlite", "path" => ":memory:");
     $doctrineContainer = DoctrineBackendContainer::buildByConnection($conn, true);
     $backends[] = new DoctrineDataBackend($doctrineContainer->getEntityManager());
     foreach ($backends as &$backend) {
         if ($backend->isInstalled()) {
             $backend->uninstall();
         }
         self::$freeableDatabackends[] = $backend;
         $backend = array($backend);
     }
     return $backends;
 }
コード例 #13
0
 private function __construct()
 {
     # Set database connection
     $this->objPDO = PDOFactory::get();
     # Set up the handler for default session methods
     session_set_save_handler(array(&$this, '_session_open_method'), array(&$this, '_session_close_method'), array(&$this, '_session_read_method'), array(&$this, '_session_write_method'), array(&$this, '_session_destroy_method'), array(&$this, '_session_gc_method'));
     # Get the user agent string
     $strUserAgent = $_SERVER["HTTP_USER_AGENT"];
     # Check if session cookie has passed
     if (isset($_COOKIE["PHPSESSID"])) {
         # Save the cookie
         $this->php_session_id = $_COOKIE["PHPSESSID"];
         # This statement gets the session from database under following conditions:
         # 1. If there's a session ID equal to $this->php_session_id
         # 2. If session_lifespan hasn't run out of time
         # 3. If a user is still in the same user_agent (browser)
         # 4. If session_timeout hasn't run out of time
         # Prepare statement for database
         $strQuery = "SELECT id FROM http_session WHERE ascii_session_id = '" . $this->php_session_id . "' AND (TIME_TO_SEC(TIMEDIFF(now(),created)) < " . $this->session_lifespan . ") AND user_agent='{$strUserAgent}" . "' AND (TIME_TO_SEC(TIMEDIFF(now(),last_impression)) <= " . $this->session_timeout . " OR last_impression IS NULL)";
         # Execute statement
         $objStatement = $this->objPDO->query($strQuery);
         # Fetch it from the database
         $row = $objStatement->fetch(PDO::FETCH_ASSOC);
         # If such row doesn't exist
         if (!$row) {
             # Delete from database - we do garbage cleanup at the same time
             $maxlifetime = $this->session_lifespan;
             $strQuery = "DELETE FROM http_session WHERE (ascii_session_id = '" . $this->php_session_id . "') OR (now() - created > '{$maxlifetime} seconds')";
             unset($objStatement);
             $objStatement = $this->objPDO->query($strQuery);
             # Clean up stray session variables
             $strQuery = "DELETE FROM session_variable WHERE session_id NOT IN (SELECT id FROM http_session)";
             unset($objStatement);
             $objStatement = $this->objPDO->query($strQuery);
             # Get rid of old PHPSESSID, this will force PHP to give us another
             unset($_COOKIE["PHPSESSID"]);
         }
     }
     # Set the life time for the cookie
     session_set_cookie_params($this->session_lifespan);
     # Call the session_start method to get things started
     session_start();
 }
コード例 #14
0
 /**
  * A method to return action points' counts for RAG algorithm purposes
  * @param int $factor what kind of count should be returned
  * @return int the count
  */
 public static function getActionPointsCount($factor)
 {
     # Get database connection
     $objPDO = PDOFactory::get();
     # Get project ID from session
     $projectId = HTTPSession::getInstance()->PROJECT_ID;
     # Beginning of the select statement
     $select = "COUNT(id) AS ap_count";
     # Decide what count to get from DB
     switch ($factor) {
         case RedAmberGreen::TO_BE_DONE:
             $factor = " AND is_done = 0";
             break;
         case RedAmberGreen::RUNNING_OVER_DEADLINE:
             $factor = " AND is_done = 0 AND deadline < NOW()";
             break;
         case RedAmberGreen::FINISHED:
             $factor = " AND is_done = 1";
             break;
         case RedAmberGreen::FINISHED_AFTER_DEADLINE:
             $factor = " AND is_done = 1 AND deadline < datetime_done";
             break;
         case RedAmberGreen::AVG_GRADE:
             $factor = " AND is_done = 1 AND grade <> 0";
             $select = "TRUNCATE(AVG(grade),1) AS ap_count";
             break;
         default:
             $factor = "";
     }
     # Get a certain number of action points
     $strQuery = "SELECT " . $select . " FROM ActionPoint WHERE project_id = :project_id AND is_approved = 1" . $factor . " AND is_deleted = 0";
     $objStatement = $objPDO->prepare($strQuery);
     $objStatement->bindValue(':project_id', $projectId, PDO::PARAM_INT);
     $objStatement->execute();
     # Return the value
     $result = $objStatement->fetch()['ap_count'];
     # Return the count
     if ($result) {
         return $result;
     } else {
         return 0;
     }
 }
コード例 #15
0
 /**
  * A method to return note objects from database
  * @param null $meeting filter by a specific meeting
  * @param bool $agenda if it should be agenda notes returned
  * @return array the note objects
  */
 public static function getNotes($meeting = null, $agenda = false)
 {
     # Get database connection
     $objPDO = PDOFactory::get();
     # Get project ID from session
     $projectId = HTTPSession::getInstance()->PROJECT_ID;
     # Get user ID from session
     $userID = HTTPSession::getInstance()->getUserId();
     # If notes for specific meeting are requested
     if ($meeting) {
         $meeting = " AND meeting_id = " . $meeting;
     } else {
         $meeting = "";
     }
     # If notes for agenda are requested
     if ($agenda) {
         $agenda = " AND is_agenda = 1";
     } else {
         $agenda = " AND is_agenda = 0";
     }
     # Get all notes associated with a given project with the following condition:
     # – Apart from notes that are private AND associated with a different user than logged in
     $strQuery = "SELECT id FROM Note WHERE project_id = :project_id AND NOT (user_id != :user_id AND is_private = 1) AND is_deleted = 0 " . $meeting . $agenda . " ORDER BY datetime_created DESC";
     $objStatement = $objPDO->prepare($strQuery);
     $objStatement->bindValue(':project_id', $projectId, PDO::PARAM_INT);
     $objStatement->bindValue(':user_id', $userID, PDO::PARAM_INT);
     $objStatement->execute();
     # Define empty array
     $myArr = array();
     # Add all notes to an array
     if ($result = $objStatement->fetchAll(PDO::FETCH_ASSOC)) {
         foreach ($result as $row) {
             $myArr[$row["id"]] = new Note($row["id"]);
         }
     }
     # Return the note objects
     return $myArr;
 }
コード例 #16
0
 public function redirect404()
 {
     $this->page = new Page($this->app);
     $this->page->smarty()->force_compile = true;
     $this->addHeader('HTTP/1.0 404 Not Found');
     $this->page->addTemplateDir(dirname(__FILE__) . '/../apps/' . $this->app->name() . '/templates/');
     $this->page->addTemplateDir(dirname(__FILE__) . '/../errors/');
     if ($this->app->name() == 'backend') {
         $this->page->smarty()->assign('isAdminAuthenticate', 'false');
         if ($this->app()->user()->isAdminAuthenticated()) {
             $this->page->smarty()->assign('isAdminAuthenticate', 'true');
         }
     } else {
         $this->page->smarty()->assign('isAuthenticate', 'false');
         if ($this->app()->user()->isAuthenticated()) {
             $userManager = new UsersManager_PDO(PDOFactory::getMysqlConnexion());
             $user = $userManager->get($this->app->user()->getAttribute('id'));
             $this->page->smarty()->assign('isAuthenticate', 'true');
             $this->page->smarty()->assign('currentUser', $user);
         }
     }
     $this->page->smarty()->assign('title', 'Erreur 404');
     $this->page->smarty()->display('404.tpl');
 }
コード例 #17
0
ファイル: DataConstraintTest.php プロジェクト: bmdevel/bav
 public static function setUpBeforeClass()
 {
     self::$pdo = PDOFactory::makePDO();
     self::$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
     self::$pdo->exec("DROP TABLE IF EXISTS bank");
     self::$pdo->exec("CREATE TEMPORARY TABLE bank (\n                id int primary key,\n                blz char(8),\n                isMain tinyint(1),\n                name varchar(58),\n                plz varchar(5),\n                city varchar(35),\n                shortterm varchar(27),\n                pan char(5),\n                bic varchar(11),\n                validator char(2),\n                index(blz),\n                index(name),\n                index(shortterm),\n                index(pan),\n                index(bic)\n            ) engine=MEMORY");
     $fp = fopen(__DIR__ . '/../../data/banklist.txt', 'r');
     if (!is_resource($fp)) {
         throw new RuntimeException('I/O-Error');
     }
     $insert = self::$pdo->prepare("INSERT INTO bank\n                   ( id,  blz,  isMain,  name,  plz,  city,  shortterm,  pan,  bic,  validator)\n            VALUES (:id, :blz, :isMain, :name, :plz, :city, :shortTerm, :pan, :bic, :validator)");
     $insert->bindParam(':id', $id);
     $insert->bindParam(':blz', $blz);
     $insert->bindParam(':isMain', $isMain);
     $insert->bindParam(':name', $name);
     $insert->bindParam(':plz', $plz);
     $insert->bindParam(':city', $city);
     $insert->bindParam(':shortTerm', $shortTerm);
     $insert->bindParam(':pan', $pan);
     $insert->bindParam(':bic', $bic);
     $insert->bindParam(':validator', $validator);
     while ($line = fgets($fp)) {
         $blz = substr($line, 0, 8);
         $isMain = $line[8] === '1' ? 1 : 0;
         $name = trim(substr($line, 9, 58));
         $plz = trim(substr($line, 67, 5));
         $city = trim(substr($line, 72, 35));
         $shortTerm = trim(substr($line, 107, 27));
         $pan = trim(substr($line, 134, 5));
         $bic = trim(substr($line, 139, 11));
         $validator = substr($line, 150, 2);
         $id = substr($line, 152, 6);
         $insert->execute();
     }
     fclose($fp);
 }
コード例 #18
0
 /**
  * 
  * @param string $dbCharset
  */
 static function setDbCharset($dbCharset)
 {
     self::$dbCharset = $dbCharset;
 }
コード例 #19
0
ファイル: modifier.php プロジェクト: sdmg15/cmpj
<?php

include_once "C:\\wamp\\www\\CMPJ\\Vendors\\Entity\\adherent.php";
include_once "C:\\wamp\\www\\CMPJ\\Controleurs\\HTTPRequest.php";
include_once "C:\\wamp\\www\\CMPJ\\Controleurs\\HTTPResponse.php";
include_once "C:\\wamp\\www\\CMPJ\\Model\\AdherentManagerPDO.php";
include_once "C:\\wamp\\www\\CMPJ\\Model\\PDOFactory.php";
$request = new HTTPRequest();
$manager = new AdherentManagerPDO(PDOFactory::getPdoInstance());
if (isset($_GET['modifier'])) {
    if (!$manager->Exists((int) $_GET['modifier'])) {
        $message = 'NOT FOUND.';
    } else {
        $adherent = $manager->getUnique((int) $_GET['modifier']);
    }
}
if ($request->postExists('nom')) {
    //on hydrate les  données
    $adherent = new Adherent(['nom' => $request->postData('nom'), 'prenom' => $request->postData('prenom'), 'dateNaissance' => $request->postData('date'), 'lieu' => $request->postData('lieuNaissance'), 'sexe' => $request->postData('sexe'), 'region' => $request->postData('region'), 'departement' => $request->postData('departement'), 'ethnie' => $request->postData('ethnie'), 'nationalite' => $request->postData('nationalite'), 'profession_mere_parrain' => $request->postData('profession'), 'situationMatrimoniale' => $request->postData('situation'), 'lieuResidence' => $request->postData('lieuResidence'), 'adresse' => $request->postData('addr'), 'telPerso' => $request->postData('telPerso'), 'sosTel' => $request->postData('sosTel'), 'sosName' => $request->postData('sosName'), 'diplomeEleve' => $request->postData('diplome'), 'dateObtentionPlace' => $request->postData('dateObtention'), 'speakLanguage' => $request->postData('speakLanguage'), 'filiere' => $request->postData('option')]);
    $adherent->setId((int) $_GET['modifier']);
    if ($adherent->isvalid()) {
        $manager->update($adherent);
        $message = 'Informations bien modifiées ';
    } else {
        $erreurs = $adherent->getErreurs();
    }
}
?>
<!DOCTYPE html>
<html>
	<head>
コード例 #20
0
ファイル: AgencyQueryTest.php プロジェクト: bmdevel/bav
 /**
  * @return SQLDataBackend[][]
  */
 public function provideBackends()
 {
     $conn = array("pdo" => PDOFactory::makePDO());
     $doctrineContainer = DoctrineBackendContainer::buildByConnection($conn, true);
     return array(array(new PDODataBackend(PDOFactory::makePDO())), array($doctrineContainer->getDataBackend()));
 }
コード例 #21
0
 /**
  * A method to return all users associated with a project
  * @param int  $projectI the project idd
  * @return array the user objects
  */
 public static function getAllUsersForProject($projectId)
 {
     # Get PDO
     $objPDO = PDOFactory::get();
     # Get alluserss associated with the $projectId from a database
     $strQuery = "SELECT user_id FROM UserProject WHERE project_id = :project_id";
     $objStatement = $objPDO->prepare($strQuery);
     $objStatement->bindValue(':project_id', $projectId, PDO::PARAM_INT);
     $objStatement->execute();
     # Define empty array
     $myArr = array();
     # Add all users associated with the $projectId to an array
     if ($result = $objStatement->fetchAll(PDO::FETCH_ASSOC)) {
         foreach ($result as $row) {
             $myArr[$row["user_id"]] = new User($row["user_id"]);
         }
     }
     # Return the user objects
     return $myArr;
 }
コード例 #22
0
 /**
  * 
  * @param string $email
  * @return boolean
  */
 public function deleteRegistersByEmail($email)
 {
     $pdo = PDOFactory::getPDO();
     $delete = $pdo->prepare("DELETE FROM registro WHERE email=:email");
     $delete->execute([":email" => $email]);
     return true;
 }
コード例 #23
0
ファイル: test-install.php プロジェクト: bmdevel/bav
#!/bin/env php
<?php 
/**
 * Installs the test environment
 *
 * @author Markus Malkusch <*****@*****.**>
 * @license WTFPL
 */
namespace malkusch\bav;

require_once __DIR__ . "/../bootstrap.php";
try {
    ConfigurationRegistry::getConfiguration()->setAutomaticInstallation(false);
    $databack = ConfigurationRegistry::getConfiguration()->getDatabackendContainer()->getDataBackend();
    // install file
    $databack->install();
    echo "Bundesbank file downloaded.\n";
    // install PDO
    $pdoContainer = new PDODataBackendContainer(PDOFactory::makePDO());
    $pdoContainer->getDataBackend()->install();
    echo "PDO installed.\n";
} catch (DataBackendException $error) {
    die("Installation failed: {$error->getMessage()}\n");
}
コード例 #24
0
 public function setUp()
 {
     $this->statementContainer = new StatementContainer(PDOFactory::makePDO());
 }
コード例 #25
0
    protected $db;
    public function __construct(PDO $db)
    {
        $this->db = $db;
    }
    public function update(SplSubject $obj)
    {
        $q = $this->db->prepare('INSERT INTO erreurs SET erreur = :erreur');
        $q->bindValue(':erreur', $obj->getFormatedError());
        $q->execute();
    }
}
// Tester le code
$o = new ErrorHandler();
// Nous créons un nouveau gestionnaire d'erreur.
$db = PDOFactory::getMysqlConnexion();
$o->attach(new MailSender('*****@*****.**'))->attach(new BDDWriter($db));
set_error_handler([$o, 'error']);
// Ce sera par la méthode error() de la classe ErrorHandler que les erreurs doivent être traitées.
5 / 0;
// Générons une erreur
?>
                </p>
                
                
                <!-- Pattern Strategy
                ================================================== -->
                <h2>Le pattern Strategy</h2>
                <p>Séparer les algorithmes</p>
                <p class="col-sm-12">
                    <?php 
コード例 #26
0
 /**
  * A method to return meetings' counts for RAG algorithm purposes
  * @param int $factor what kind of count should be returned
  * @return int the count
  */
 public static function getMeetingsCount($factor)
 {
     # Get database connection
     $objPDO = PDOFactory::get();
     # Get project ID from session
     $projectId = HTTPSession::getInstance()->PROJECT_ID;
     $select = "COUNT(id) AS m_count";
     # Decide what count to get from DB
     switch ($factor) {
         case RedAmberGreen::TAKEN_PLACE:
             $factor = " AND taken_place = 1";
             break;
         case RedAmberGreen::STUDENT_ARRIVED_ON_TIME:
             $factor = " AND taken_place = 1 AND arrived_on_time = 1";
             break;
         case RedAmberGreen::CANCELLED:
             $factor = " AND is_cancelled = 1";
             break;
         case RedAmberGreen::NO_SHOW:
             $factor = " AND datetime < NOW() AND taken_place = 0 AND is_cancelled = 0";
             break;
             # Cancelled can be in the future and we want to include it in the total
         # Cancelled can be in the future and we want to include it in the total
         case RedAmberGreen::M_TOTAL:
             $factor = " AND (datetime < NOW() OR is_cancelled = 1)";
             break;
         default:
             $factor = "";
     }
     # Get a certain number of meetings
     $strQuery = "SELECT " . $select . " FROM Meeting WHERE project_id = :project_id AND is_approved = 1" . $factor . " AND is_deleted = 0";
     $objStatement = $objPDO->prepare($strQuery);
     $objStatement->bindValue(':project_id', $projectId, PDO::PARAM_INT);
     $objStatement->execute();
     # Return the value
     return $objStatement->fetch()['m_count'];
 }
コード例 #27
0
 /**
  * Deletes a session
  * @param string $token
  */
 protected function logout($token)
 {
     $pdo = PDOFactory::getPDO();
     $st = $pdo->prepare("DELETE FROM SESSION WHERE token=:token");
     $st->execute([":token" => $token]);
 }
コード例 #28
0
 public static function create()
 {
     $db = PDOFactory::create();
     return new ProdutoModel($db);
 }
コード例 #29
0
ファイル: CrossProjectTest.php プロジェクト: bmdevel/bav
 /**
  * @return Bank[][]
  */
 public function provideBanks()
 {
     $nodeNumber = getenv(self::ENV_NODE_NUMBER);
     if ($nodeNumber) {
         self::$nodeNumber = (int) $nodeNumber;
     }
     $nodeCount = getenv(self::ENV_NODE_COUNT);
     if ($nodeCount) {
         self::$nodeCount = (int) $nodeCount;
     }
     self::assertGreaterThan(self::$nodeNumber, self::$nodeCount);
     $banks = array();
     $backend = new PDODataBackend(PDOFactory::makePDO());
     $i = 0;
     foreach ($backend->getAllBanks() as $bank) {
         // only pick banks for this node.
         if ($i % self::$nodeCount == self::$nodeNumber) {
             $banks[] = array($bank);
         }
         $i++;
     }
     return $banks;
 }
コード例 #30
0
// ini_set('display_errors', 1);
header("Content-type: application/json");
require_once 'Exceptions/ErrorLoginException.php';
require_once 'Module.php';
require_once 'PDOFactory.php';
require_once 'phpmailer/PHPMailerAutoload.php';
require_once 'JSONAPI.php';
require_once 'MagicObject.php';
JSONAPI::loadExceptions();
JSONAPI::loadMagicObjects();
JSONAPI::loadModules();
// PHPMailer Configuration
PHPMailerAutoload("phpmailer");
PHPMailerAutoload("smtp");
$mailFact = new PHPMailerSMTPMagic();
$mail = PHPMailerSMTPMagic::getPhpmailobj();
$mail->SMTPAuth = true;
$mail->SMTPSecure = "tls";
$mail->Host = "";
$mail->port = 0;
$mail->Username = "";
$mail->Password = "";
PHPMailerSMTPMagic::setPhpmailobj($mail);
// DB Configuration
PDOFactory::setDbCharset("utf-8");
PDOFactory::setDbHost("localhost");
PDOFactory::setDbName("DBNAME");
PDOFactory::setDbUser("root");
PDOFactory::setDbPassword("");
//RUN!
echo JSONAPI::main(['GET' => $_GET, 'POST' => isset($_POST) ? $_POST : '']);