Beispiel #1
0
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Beispiel #2
0
 public static function get_instance()
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 public function userData($matricule)
 {
     $this->database = database::instance();
     $this->auth = authentification::instance();
     $this->matricule = $matricule;
     $this->getUserData();
 }
 static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 public static function getInstance()
 {
     if (!isset(self::$instance)) {
         $object = __CLASS__;
         self::$instance = new $object();
     }
     return self::$instance;
 }
Beispiel #6
0
 public static function get_instance($dsn = null, $user = null, $pass = null)
 {
     if (null == self::$instance || $dsn != null) {
         self::$instance = new database($dsn, $user, $pass);
     }
     //var_dump(self::$instance->dbh);
     return self::$instance->dbh;
 }
 private static function getSpecifiedCount($field, $value)
 {
     $database = database::instance();
     $whereClause = !isset($value) ? "" : "WHERE {$field} = '{$value}'";
     $result = $database->requete("SELECT count(" . demande::MATRICULE_DB_FIELD . ") as nb FROM st_demande {$whereClause}");
     $result = mysql_fetch_array($result);
     return $result['nb'];
 }
 /**
  * Short description of method instance
  *
  * @access public
  * @return void
  */
 public static function instance()
 {
     if (!database::$instance) {
         database::$instance = new database();
         database::$instance->init();
         database::$instance->connect();
     }
     return database::$instance;
 }
<?php

error_reporting(E_ALL);
require_once 'class.authentification.php';
require_once 'class.database.php';
require_once 'class.util.php';
$statusId = util::getParam($_POST, 'statusId');
$db = database::instance();
$result = $db->requete("SELECT description FROM st_status WHERE st_status.statusId={$statusId}");
$resultArray = mysql_fetch_array($result);
print util::cleanUTF8($resultArray['description']);
error_reporting(E_ALL);
require_once "header.php";
require_once "class.util.php";
require_once "class.userData.php";
require_once "class.validation.php";
require_once "class.database.php";
$message = "";
if (isset($_GET['sendmail']) && $_GET['sendmail'] == 1) {
    $matricule = $_POST['matricule'];
    if (isset($matricule) && validation::matricule($matricule)) {
        $user = new userData($_POST['matricule']);
        if ($user->getExist()) {
            $password = util::generatePassword();
            $pregArray = array(array('key' => "/@@FIRSTNAME@@/", 'value' => $user->getFirstName()), array('key' => "/@@LASTNAME@@/", 'value' => $user->getLastName()), array('key' => "/@@PASSWORD@@/", 'value' => $password));
            $database = database::instance();
            $database->requete("UPDATE st_authentication SET password='******' WHERE matricule='" . $matricule . "'");
            util::sendEmail($user->getEmail(), 'accessrecovery.txt', $pregArray, "Stationnement AEP - Demande de nouveau mot de passe");
            $message = util::UTF8toISO8859("Un courriel avec votre nouveau mot de passe vous a été envoyé");
        } else {
            $message = 'Utilisateur non existant';
        }
    } else {
        $message = 'Matricule invalide';
    }
}
?>
<div>
	<?php 
if ($message != "") {
    echo $message . '</br></br>';
Beispiel #11
0
 /**
  * This is the task code that adds photos and albums.  It first examines all the target files
  * and creates a set of Server_Add_File_Models, then runs through the list of models and adds
  * them one at a time.
  */
 static function add($task)
 {
     $mode = $task->get("mode", "init");
     $start = microtime(true);
     switch ($mode) {
         case "init":
             $task->set("mode", "build-file-list");
             $task->percent_complete = 0;
             $task->status = t("Starting up");
             batch::start();
             break;
         case "build-file-list":
             // 0% to 10%
             // We can't fit an arbitrary number of paths in a task, so store them in a separate table.
             // Don't use an iterator here because we can't get enough control over it when we're dealing
             // with a deep hierarchy and we don't want to go over our time quota.  The queue is in the
             // form [path, parent_id] where the parent_id refers to another Server_Add_File_Model.  We
             // have this extra level of abstraction because we don't know its Item_Model id yet.
             $queue = $task->get("queue");
             while ($queue && microtime(true) - $start < 0.5) {
                 list($file, $parent_entry_id) = array_shift($queue);
                 $entry = ORM::factory("server_add_file");
                 $entry->task_id = $task->id;
                 $entry->file = $file;
                 $entry->parent_id = $parent_entry_id;
                 $entry->save();
                 foreach (glob("{$file}/*") as $child) {
                     if (is_dir($child)) {
                         $queue[] = array($child, $entry->id);
                     } else {
                         $ext = strtolower(pathinfo($child, PATHINFO_EXTENSION));
                         if (in_array($ext, array("gif", "jpeg", "jpg", "png", "flv", "mp4"))) {
                             $child_entry = ORM::factory("server_add_file");
                             $child_entry->task_id = $task->id;
                             $child_entry->file = $child;
                             $child_entry->parent_id = $entry->id;
                             $child_entry->save();
                         }
                     }
                 }
             }
             // We have no idea how long this can take because we have no idea how deep the tree
             // hierarchy rabbit hole goes.  Leave ourselves room here for 100 iterations and don't go
             // over 10% in percent_complete.
             $task->set("queue", $queue);
             $task->percent_complete = min($task->percent_complete + 0.1, 10);
             $task->status = t2("Found one file", "Found %count files", Database::instance()->where("task_id", $task->id)->count_records("server_add_files"));
             if (!$queue) {
                 $task->set("mode", "add-files");
                 $task->set("total_files", database::instance()->count_records("server_add_files", array("task_id" => $task->id)));
                 $task->percent_complete = 10;
             }
             break;
         case "add-files":
             // 10% to 100%
             $completed_files = $task->get("completed_files", 0);
             $total_files = $task->get("total_files");
             // Ordering by id ensures that we add them in the order that we created the entries, which
             // will create albums first.  Ignore entries which already have an Item_Model attached,
             // they're done.
             $entries = ORM::factory("server_add_file")->where("task_id", $task->id)->where("item_id", null)->orderby("id", "ASC")->limit(10)->find_all();
             if ($entries->count() == 0) {
                 // Out of entries, we're done.
                 $task->set("mode", "done");
             }
             $owner_id = user::active()->id;
             foreach ($entries as $entry) {
                 if (microtime(true) - $start > 0.5) {
                     break;
                 }
                 // Look up the parent item for this entry.  By now it should exist, but if none was
                 // specified, then this belongs as a child of the current item.
                 $parent_entry = ORM::factory("server_add_file", $entry->parent_id);
                 if (!$parent_entry->loaded) {
                     $parent = ORM::factory("item", $task->get("item_id"));
                 } else {
                     $parent = ORM::factory("item", $parent_entry->item_id);
                 }
                 $name = basename($entry->file);
                 $title = item::convert_filename_to_title($name);
                 if (is_dir($entry->file)) {
                     $album = album::create($parent, $name, $title, null, $owner_id);
                     $entry->item_id = $album->id;
                 } else {
                     $extension = strtolower(pathinfo($name, PATHINFO_EXTENSION));
                     if (in_array($extension, array("gif", "png", "jpg", "jpeg"))) {
                         $photo = photo::create($parent, $entry->file, $name, $title, null, $owner_id);
                         $entry->item_id = $photo->id;
                     } else {
                         if (in_array($extension, array("flv", "mp4"))) {
                             $movie = movie::create($parent, $entry->file, $name, $title, null, $owner_id);
                             $entry->item_id = $movie->id;
                         } else {
                             // This should never happen, because we don't add stuff to the list that we can't
                             // process.  But just in, case.. set this to a non-null value so that we skip this
                             // entry.
                             $entry->item_id = 0;
                             $task->log("Skipping unknown file type: {$entry->file}");
                         }
                     }
                 }
                 $completed_files++;
                 $entry->save();
             }
             $task->set("completed_files", $completed_files);
             $task->status = t("Adding photos and albums (%completed of %total)", array("completed" => $completed_files, "total" => $total_files));
             $task->percent_complete = 10 + 100 * ($completed_files / $total_files);
             break;
         case "done":
             batch::stop();
             $task->done = true;
             $task->state = "success";
             $task->percent_complete = 100;
             ORM::factory("server_add_file")->where("task_id", $task->id)->delete_all();
             message::info(t2("Successfully added one photo", "Successfully added %count photos and albums", $task->get("completed_files")));
     }
 }
 /**
  * Short description of method instance
  *
  * @access private
  * @return void
  */
 private function init()
 {
     $this->objDatabase = database::instance();
     $this->objLog = log::instance();
     session_save_path(config::PhpSessionPath);
     session_set_cookie_params(0);
     session_start();
     $this->estIdentifie();
 }
Beispiel #13
0
 public function loadFromServer($matricule, $fileDbFieldName)
 {
     $database = database::instance();
     $results = $database->requete("SELECT * from st_demande WHERE matricule = '{$matricule}'");
     $resultsArray = mysql_fetch_array($results);
     $url = $resultsArray[$fileDbFieldName];
     $this->loadFromUrl($url);
 }
 public static function getDemandStatusNameFromId($statusId)
 {
     $database = database::instance();
     $results = $database->requete("\tSELECT " . demandStatus::STATUS_NAME_DB_FIELD . " \n\t\t\t\t\t\t\t\t\t\tFROM st_status \n\t\t\t\t\t\t\t\t\t\tWHERE  " . demandStatus::STATUS_ID_DB_FIELD . " = '{$statusId}' ");
     $results = mysql_fetch_array($results);
     return $results[demandStatus::STATUS_NAME_DB_FIELD];
 }
Beispiel #15
0
 /**
  * Creates and verifies a database configuration.
  * @param  String $hostname 
  * @param  String $database 
  * @param  String $username 
  * @param  String $password 
  * @return Array           Error message.  None if successful.
  * @throws Exception If Bad data.
  */
 private function _create_database_config($hostname, $database, $username, $password)
 {
     $config = array('type' => 'mysql', 'connection' => array('hostname' => $hostname, 'database' => $database, 'username' => $username, 'password' => $password, 'persistent' => FALSE), 'table_prefix' => '', 'charset' => 'utf8', 'caching' => FALSE, 'profiling' => TRUE);
     try {
         $db = database::instance('test', $config);
         $db->connect();
         // Make sure this is empty.
         $tables = $db->query(Database::SELECT, 'SHOW TABLES;', TRUE);
         if (count($tables)) {
             throw new Exception("That database already has tables loaded.  Please select a different database or empty this database.<br>\n\t\t\t\t\tIf you absolutely must use this database then please follow the manual configuration instructions in README.md.");
         }
     } catch (Exception $e) {
         throw new Exception($e->getMessage());
     }
     return $config;
 }
 public function __construct()
 {
     parent::__construct();
     $this->objDatabase = database::instance();
     $this->objLog = log::instance();
 }
Beispiel #17
0
 /**
  * Crée et retourne l'objet SPDO
  *
  * @access public
  * @static
  * @param void
  * @return SPDO $instance
  */
 public static function getInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new database();
     }
     return self::$instance;
 }
 public function saveToDatabase($tripId)
 {
     $database = database::instance();
     $this->tripId = $tripId;
     if (isset($this->tripId)) {
         $database->requete("UPDATE st_trip \n\t\t\t\t\tSET \n\t\t\t\t\t" . tripInfo::DISTANCE_DB_FIELD . " = '" . $this->tripInfoData->getDistance() . "',\n\t\t\t\t\t" . tripInfo::DURATION_DB_FIELD . " = '" . $this->tripInfoData->getDuration() . "',\n\t\t\t\t\t" . tripInfo::SCORE_DB_FIELD . " = '" . $this->tripInfoData->getScore() . "',\n\t\t\t\t\t" . tripInfo::LATITUDE_DB_FIELD . " = '" . $this->tripInfoData->getLatitude() . "',\n\t\t\t\t\t" . tripInfo::LONGITUDE_DB_FIELD . " = '" . $this->tripInfoData->getLongitude() . "',\n\t\t\t\t\t" . tripInfo::INFO_VALID_DB_FIELD . " = '" . $this->tripInfoData->isValid() . "' \n\t\t\t\t\tWHERE " . tripInfo::ID_DB_FIELD . " = '" . $this->tripId . "' ");
     } else {
         $database->requete("INSERT INTO st_trip \n\t\t\t\t\t\t\t\t(" . tripInfo::ID_DB_FIELD . ",\n\t\t\t\t\t\t\t\t " . tripInfo::DISTANCE_DB_FIELD . ",\n\t\t\t\t\t\t\t\t " . tripInfo::DURATION_DB_FIELD . ",\n\t\t\t\t\t\t\t\t " . tripInfo::SCORE_DB_FIELD . ",\t \n\t\t\t\t\t\t\t\t " . tripInfo::LATITUDE_DB_FIELD . ",\n\t\t\t\t\t\t\t\t " . tripInfo::LONGITUDE_DB_FIELD . ",\n\t\t\t\t\t\t\t\t " . tripInfo::INFO_VALID_DB_FIELD . ")\n\t\t\t\t\t\t\t\tVALUES \n\t\t\t\t\t\t\t\t(NULL, \n\t\t\t\t\t\t\t\t'" . $this->tripInfoData->getDistance() . "',\n\t\t\t\t\t\t\t\t'" . $this->tripInfoData->getDuration() . "',\n\t\t\t\t\t\t\t\t'" . $this->tripInfoData->getScore() . "',\n\t\t\t\t\t\t\t\t'" . $this->tripInfoData->getLatitude() . "',\n\t\t\t\t\t\t\t\t'" . $this->tripInfoData->getLongitude() . "',\n\t\t\t\t\t\t\t\t'" . $this->tripInfoData->isValid() . "')", true, true);
         $this->tripId = $database->dernierInsertId;
     }
 }
Beispiel #19
0
<?php

session_start();
include 'class/database.php';
$DB = database::instance();
include 'class/upr.php';
include 'ctrl/functions.php';
include 'class/klient.php';
include 'class/koszyk.php';
include 'class/transakcja.php';
sprawdz_uprawnienia();
if (!isset($_GET['site'])) {
    $_GET['site'] = '';
}
include 'ctrl/drzewo-kategorii.php';
ob_start();
switch ($_GET['site']) {
    case 'logout':
        session_destroy();
        header("Location: {$dir}glowna.html");
        break;
    case 'index':
    case '':
        header("Location: {$dir}glowna.html");
        break;
    case 'glowna':
        //$htitle = '';
        include 'view/glowna.php';
        break;
    case 'produkt':
        include 'ctrl/produkt.php';
 public function init()
 {
     $this->objLog = log::instance();
     $this->database = database::instance();
     $this->car1 = new car(1);
     $this->car2 = new car(2);
     $this->userData = new userData($this->matricule);
     $this->userData->getUserData($_SESSION['usager']);
 }
Beispiel #21
0
 /**
  * 连接系统默认的数据库
  *
  * @param $config array  数据库参数
  * @return object 数据库连接
  */
 public static function db($settings = array())
 {
     $config = array('driver' => zotop::config('zotop.db.driver'), 'username' => zotop::config('zotop.db.username'), 'password' => zotop::config('zotop.db.password'), 'hostname' => zotop::config('zotop.db.hostname'), 'hostport' => zotop::config('zotop.db.hostport'), 'database' => zotop::config('zotop.db.database'), 'prefix' => zotop::config('zotop.db.prefix'), 'charset' => zotop::config('zotop.db.charset'));
     $config = array_merge($config, $settings);
     return database::instance($config);
 }
Beispiel #22
0
 public function saveToDatabase($id, $doesCarExistInDatabase)
 {
     $database = database::instance();
     if ($doesCarExistInDatabase) {
         $this->id = $id;
         // TODO: POTENTIALLY PUT THIS IN FILE SUBCLASS METHOD SAVETOSERVER
         $results = $database->requete("SELECT * FROM st_car WHERE " . car::CAR_ID_DB_FIELD . " = '" . $this->id . "'");
         $resultsArray = mysql_fetch_array($results);
         // Server and database URLs may differ at this point, in which case we update the DB
         $insuranceHasChangedOnServer = $this->insurance->saveToServer($resultsArray[car::INSURANCE_DB_FIELD]);
         $insuranceColumnString = $insuranceHasChangedOnServer ? car::INSURANCE_DB_FIELD . " = " : "";
         $insuranceValuesString = $insuranceHasChangedOnServer ? "'" . util::cleanup($this->insurance->getOutputLocation()) . "', " : "";
         $database->requete("UPDATE st_car\n\t\t\t\t\t\t\t  SET  \t\t\t  \n\t\t        \t\t\t  " . car::MODEL_DB_FIELD . " = '" . util::cleanup($this->model) . "',\n\t\t        \t\t\t  " . car::COLOR_DB_FIELD . " = '" . util::cleanup($this->color) . "',\n\t\t        \t\t\t  " . car::YEAR_DB_FIELD . " = '" . util::cleanup($this->year) . "',\n\t\t        \t\t\t   " . $insuranceColumnString . $insuranceValuesString . "\n                               " . car::LICENSE_DB_FIELD . " = '" . util::cleanup($this->license) . "',\n                             " . car::ELECTRIC_DB_FIELD . " = '" . util::cleanup($this->isElectric) . "' \n\t\t        \t\t\t  WHERE \n\t\t        \t\t\t  " . car::CAR_ID_DB_FIELD . " = '" . $this->id . "'");
     } else {
         $this->insurance->saveToServer(car::INSURANCE_DB_FIELD);
         $database->requete("INSERT INTO st_car \n\t\t\t\t\t\t\t\t(" . car::CAR_ID_DB_FIELD . ",\n\t\t\t\t\t\t\t\t" . car::MODEL_DB_FIELD . ",\n\t\t\t\t\t\t\t\t" . car::COLOR_DB_FIELD . ",\n\t\t\t\t\t\t\t\t" . car::YEAR_DB_FIELD . ",\n\t\t\t\t\t\t\t\t" . car::INSURANCE_DB_FIELD . ",\n                                " . car::LICENSE_DB_FIELD . ",\n                                " . car::ELECTRIC_DB_FIELD . ") \n\t\t\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t\t\t(NULL, \n\t\t\t\t\t\t\t\t '" . $this->model . "',\n\t\t\t\t\t\t\t\t '" . $this->color . "', \n\t\t\t\t\t\t\t\t '" . $this->year . "',\n\t\t\t\t\t\t\t\t '" . $this->insurance->getOutputLocation() . "',\n                                 '" . $this->license . "',\n                                 '" . $this->isElectric . "')", true, true);
         $this->id = $database->dernierInsertId;
     }
     return $this->id;
 }
Beispiel #23
0
 /**
  * Short description of method instance
  *
  * @access private
  * @return void
  */
 private function init()
 {
     $this->objDatabase = database::instance();
     $this->objAuthentification = authentification::instance();
 }
Beispiel #24
0
 /**
  * 连接系统默认的数据库
  *
  * @param $config array  数据库参数
  * @return object 数据库连接
  */
 public static function db($config = array())
 {
     if (empty($config)) {
         $config = zotop::config('zotop.database');
     }
     $db = database::instance($config);
     return $db;
 }
Beispiel #25
0
 public static function openWebsite()
 {
     $db = database::instance();
     $result = $db->requete("UPDATE st_opening SET isOpen='1' WHERE st_opening.isOpen='0'");
 }
Beispiel #26
0
 /**
  * 连接系统默认的数据库
  *
  * @param $config array  数据库参数
  * @return object 数据库连接
  */
 public static function db($settings = array())
 {
     $config = zotop::config('zotop.database');
     $config = array_merge($config, $settings);
     return database::instance($config);
 }
Beispiel #27
0
function updateTripInfo($address, $city, $zipCode, $matricule)
{
    $database = database::instance();
    $results = $database->requete("SELECT " . tripInfo::ID_DB_FIELD . " \n\t\t\t\t\t\t\t\t  FROM st_trip INNER JOIN st_demande \n\t\t\t\t\t\t\t\t  WHERE st_demande." . demande::MATRICULE_DB_FIELD . " = '" . $matricule . "' \n\t\t\t\t\t\t\t\t  AND st_trip." . tripInfo::ID_DB_FIELD . " = st_demande." . demande::TRIP_DB_FIELD . "");
    if (mysql_num_rows($results) == 1) {
        $resultsArray = mysql_fetch_array($results);
        $tripId = $resultsArray[tripInfo::ID_DB_FIELD];
        $tripInfo = new tripInfo($address, $city, $zipCode);
        $tripInfo->computeValues();
        $tripInfo->saveToDatabase($tripId);
    }
}