Esempio n. 1
0
 public function __construct($BikeId = null, $BranchId = null, $Number = null)
 {
     $this->bikes_id = $BikeId;
     $this->branch_identifier = $BranchId;
     $this->number_of_bikes = $Number;
     $this->db = database::getInstance();
 }
 private function __construct()
 {
     require_once './database.class.php';
     require_once './movie.class.php';
     $this->db = database::getInstance();
     $this->db->connect();
 }
Esempio n. 3
0
 public function init()
 {
     if (database::getInstance()->isDown() || !property::getInstance()->get('collect_statistic')) {
         return;
     }
     $realip = system::getInstance()->getRealIp();
     $visittime = time();
     $browser = self::user_browser($_SERVER['HTTP_USER_AGENT']);
     $os = self::user_os($_SERVER['HTTP_USER_AGENT']);
     $cookie = $_COOKIE['source'] ?: '';
     $userid = user::getInstance()->get('id');
     if ($userid == null) {
         $userid = 0;
     }
     if ($cookie == null) {
         $settime = $visittime + 365 * 24 * 60 * 60;
         setcookie('source', system::getInstance()->md5random(), $settime, '/');
         $cookie = '';
     }
     $referer = $_SERVER['HTTP_REFERER'] ?: '';
     $path = $_SERVER['REQUEST_URI'] ?: '';
     $query = "INSERT INTO " . property::getInstance()->get('db_prefix') . "_statistic (ip, cookie, browser, os, time, referer, path, reg_id) VALUES(?, ?, ?, ?, ?, ?, ?, ?)";
     $stmt = database::getInstance()->con()->prepare($query);
     $stmt->bindParam(1, $realip, \PDO::PARAM_STR);
     $stmt->bindParam(2, $cookie, \PDO::PARAM_STR, 32);
     $stmt->bindParam(3, $browser, \PDO::PARAM_STR);
     $stmt->bindParam(4, $os, \PDO::PARAM_STR);
     $stmt->bindParam(5, $visittime, \PDO::PARAM_INT);
     $stmt->bindParam(6, $referer, \PDO::PARAM_STR);
     $stmt->bindParam(7, $path, \PDO::PARAM_STR);
     $stmt->bindParam(8, $userid, \PDO::PARAM_INT);
     $stmt->execute();
 }
Esempio n. 4
0
 /**
  * Check if user is permament banned in database and display ban.tpl theme
  */
 public function init()
 {
     $ip = system::getInstance()->getRealIp();
     $time = time();
     $userid = user::getInstance()->get('id');
     if ($userid > 0) {
         $stmt = database::getInstance()->con()->prepare("SELECT COUNT(*) FROM " . property::getInstance()->get('db_prefix') . "_user_block WHERE (user_id = ? or ip = ?) AND (express > ? OR express = 0)");
         $stmt->bindParam(1, $userid, \PDO::PARAM_INT);
         $stmt->bindParam(2, $ip, \PDO::PARAM_STR);
         $stmt->bindParam(3, $time, \PDO::PARAM_INT);
         $stmt->execute();
     } else {
         $stmt = database::getInstance()->con()->prepare("SELECT COUNT(*) FROM " . property::getInstance()->get('db_prefix') . "_user_block WHERE ip = ? AND (express > ? OR express = 0)");
         $stmt->bindParam(1, $ip, \PDO::PARAM_STR);
         $stmt->bindParam(2, $time, \PDO::PARAM_INT);
         $stmt->execute();
     }
     $rowFetch = $stmt->fetch();
     $count = $rowFetch[0];
     if ($count > 0) {
         // block founded in db
         $content = template::getInstance()->twigRender('ban.tpl', array('local' => array('admin_email' => property::getInstance()->get('mail_from'))));
         template::getInstance()->justPrint($content);
     }
 }
Esempio n. 5
0
 function __construct($un = null, $pwd = null, $branch_n = null, $branch_location = null)
 {
     $this->username = $un;
     $this->password = $pwd;
     $this->branch_name = $branch_n;
     $this->branch_location = $branch_location;
     $this->db = database::getInstance();
 }
Esempio n. 6
0
 public function __construct($number = null, $brand_id = null, $branch_identifier = null, $limit_set = null)
 {
     $this->db = database::getInstance();
     $this->bike_id = $brand_id;
     $this->number_of_items = $number;
     $this->branch_id = $branch_identifier;
     $this->limit = $limit_set;
 }
Esempio n. 7
0
 public function __construct($id = 0)
 {
     $this->pdo = database::getInstance();
     if ($id != 0) {
         $this->id = $id;
         $this->getFromDatabase();
     }
 }
Esempio n. 8
0
function get_title()
{
    $db_once = database::getInstance();
    $sql = "SELECT * FROM common_entry where ID = 1";
    $row = $db_once->getDataSingle($sql);
    $Name = $row['Name'];
    echo $Name;
    //$db_once->closeConn();
}
 public function __construct($id = 0)
 {
     $this->pdo = database::getInstance();
     $this->tf = new textFinder();
     $this->products = array();
     if ($id != 0) {
         $this->id = $id;
         $this->getFromDatabase();
     }
 }
Esempio n. 10
0
 public function __construct($id = 0)
 {
     $this->pdo = database::getInstance();
     $this->tf = new textFinder();
     $this->id_address = -1;
     if ($id != 0) {
         $this->id = $id;
         $this->getFromDatabase();
     }
 }
Esempio n. 11
0
 private function __construct()
 {
     require_once './database.class.php';
     require_once './event.class.php';
     /* echo 'Creating database instance. <br/>'; */
     $this->db = database::getInstance();
     /* echo 'Database instance created. <br/>';
       	echo 'Creating connection. <br/>'; */
     $this->db->connect();
     /* echo 'Database connected. <br/>'; */
 }
Esempio n. 12
0
 public static function getUserByEmail($email)
 {
     $db = database::getInstance();
     $stmt = $db->prepare("SELECT uid FROM users WHERE email=? LIMIT 1");
     $stmt->bind_param("s", $email);
     $db->select($stmt);
     $stmt->bind_result($id);
     if ($stmt->fetch()) {
         $stmt->close();
         return new User($id);
     }
     return NULL;
 }
Esempio n. 13
0
 public function __construct($id = 0)
 {
     $this->pdo = database::getInstance();
     $this->tf = new textFinder();
     $this->id = $id;
     $this->name = '';
     $this->description = '';
     $this->cost = 0;
     $this->price = 0;
     $this->unit = '';
     $this->id_group = 0;
     if ($id != 0) {
         $this->getFromDatabase();
     }
 }
Esempio n. 14
0
 public static function getUser($username, $input)
 {
     $db = database::getInstance();
     $stmt = $db->prepare("SELECT uid,password FROM users WHERE username=? LIMIT 1");
     $stmt->bind_param("s", $username);
     $db->select($stmt);
     $stmt->bind_result($id, $password);
     if ($stmt->fetch()) {
         if (self::ValidatePassword($input, $password)) {
             $stmt->close();
             return new User($id);
         }
     }
     return NULL;
 }
Esempio n. 15
0
 public function __construct($id = 0)
 {
     $this->pdo = database::getInstance();
     $this->id_contact = "";
     $this->id_billing_address = "";
     $this->id_receiving_address = "";
     $this->normal_billing_period = "";
     $this->receiving_address = new address();
     $this->billing_address = new address();
     $this->tf = new textFinder();
     $this->orders = array();
     $this->ordersMonth = array();
     $this->alreadyPaid = 0;
     $this->ca = 0;
     if ($id != 0) {
         $this->id = $id;
         $this->getFromDatabase();
     }
 }
Esempio n. 16
0
 public function __construct($UserID = null)
 {
     $this->_database = database::getInstance();
     $this->_sessionName = config::get('session/session_name');
     $this->_cookieName = config::get('remember/cookie_name');
     if (!$UserID) {
         if (session::exists($this->_sessionName)) {
             $UserID = session::get($this->_sessionName);
             if ($this->find($UserID)) {
                 $this->_isLoggedIn = true;
             } else {
                 // proceed to logout
                 $this->logout();
             }
         }
     } else {
         $this->find($UserID);
     }
 }
Esempio n. 17
0
 public function __construct($id = 0)
 {
     $this->pdo = database::getInstance();
     $this->tf = new textFinder();
     $this->id_company = -1;
     $this->id_address = -1;
     if ($id != 0) {
         $this->id = $id;
         $this->getFromDatabase();
         $this->address = new address($this->id_address);
         $stmt = $this->pdo->PDOInstance->prepare("SELECT name FROM company WHERE id = :id");
         $stmt->bindParam(':id', $this->id_company);
         try {
             $stmt->execute();
         } catch (Exception $e) {
             echo "Problem at " . $e->getLine() . " from model customer :" . $e->getMessage();
         }
         $stmt = $stmt->fetch(PDO::FETCH_ASSOC);
         $this->company_name = $stmt["name"];
     }
 }
Esempio n. 18
0
 public function __construct($id = 0)
 {
     $this->pdo = database::getInstance();
     if ($id != 0) {
         $this->id = $id;
         $this->getFromDatabase();
         $this->company = new company($this->id_company);
         $this->employee = new employee($this->id_employee);
         $this->delivery_address = new address($this->id_delivery_address);
         $this->line_product = array();
         $this->price = 0;
         $this->getLineProduct();
         //
         $tva = 0;
         if ($this->company->getUst_id() != "" && $this->company->getNationality() != "GER") {
             //
         } else {
             $tva = round(19 * $this->getPrice() / 100, 2);
         }
         $this->final_price = $this->price + $tva;
     }
 }
Esempio n. 19
0
 public function &database()
 {
     static $db;
     if ($db == null) {
         $db =& database::getInstance();
     }
     return $db;
 }
Esempio n. 20
0
 public static function siteOnline()
 {
     $live = self::readCache('site_live');
     if (!empty($live)) {
         return $live;
     } else {
         $live = database::getInstance()->select('fetch', 'settings', 'value', array('name' => 'site_live'));
         $auction = self::writeCache('site_live', $live['value']);
         return $live['value'];
     }
 }
Esempio n. 21
0
 public function __construct()
 {
     $this->_database = database::getInstance();
 }
Esempio n. 22
0
             $result['Histories'] = $bid_histories_result;
         }
     }
     $result['Auction'] = $auction;
     // writing data to the application cache
     if (!empty($_GET['histories'])) {
         $auction = tools::writeCache('auction_view_' . $value, $result);
     } else {
         $auction = tools::writeCache('auction_' . $value, $result);
     }
 }
 $result['User_id'] = $user_id;
 if (!empty($user_id)) {
     $balance = tools::readCache('bids_balance_' . $user_id);
     if (empty($balance)) {
         $balance = database::getInstance()->getRow("SELECT SUM(credit) - SUM(debit) AS balance FROM " . DB_PREFIX . "bids WHERE user_id = {$user_id}");
         tools::writeCache('bids_balance_' . $user_id, $balance);
     }
     $result['Balance'] = $balance['balance'];
 }
 $result['Auction']['price'] = $result['Auction']['price'];
 $result['Auction']['serverTimestamp'] = time();
 $result['Auction']['serverTimeString'] = date('d-m-Y, H:i:s');
 $result['Auction']['time_left'] = strtotime($result['Auction']['end_time']) - time();
 if ($result['Auction']['time_left'] <= 0 && $result['Auction']['closed'] == 0) {
     $result['Auction']['time_left'] = 1;
 }
 if ($site_online == 'no') {
     $result['Auction']['isPeakNow'] = 0;
     $result['Auction']['peak_only'] = 1;
 } else {
Esempio n. 23
0
 /**
  * Erstellt die Grundlegenden Tabellen in der Datenbank
  */
 public function createDatabase()
 {
     $oDb = database::getInstance()->getConnection();
     $oDb->query('
         CREATE  TABLE IF NOT EXISTS
           `reportUsers`
         (
         `reportUserIdFk` INT NOT NULL UNIQUE AUTO_INCREMENT,
         `reportUsers` VARCHAR(255) NULL ,
         PRIMARY KEY (`reportUsers`)
         )
         ENGINE = InnoDB;
         ');
     if ($oDb->errno != 0) {
         return false;
     }
     $oDb->query('
        CREATE  TABLE IF NOT EXISTS
         `reportMacs`
         (
         `reportMacIdFk` INT NOT NULL UNIQUE AUTO_INCREMENT,
         `reportMac` VARCHAR(255) NULL ,
         PRIMARY KEY (`reportMac`)
         )
         ENGINE = InnoDB;
         ');
     if ($oDb->errno != 0) {
         return false;
     }
     $oDb->query('
        CREATE  TABLE IF NOT EXISTS
         `reportAppNames`
         (
         `reportAppNameIdFk` INT NOT NULL UNIQUE AUTO_INCREMENT,
         `reportAppName` VARCHAR(255) NULL ,
         PRIMARY KEY (`reportAppName`)
         )
         ENGINE = InnoDB;
         ');
     if ($oDb->errno != 0) {
         return false;
     }
     $oDb->query('
        CREATE  TABLE IF NOT EXISTS
         `reports`
        (
         `reportId` INT NOT NULL AUTO_INCREMENT ,
         `reportAppPath` VARCHAR(255) NULL ,
         `reportType` VARCHAR(255) NULL ,
         `reportAppNameId` INT NULL ,
         `reportMacId` INT NULL ,
         `reportUserId` INT NULL ,
         `reportDate` VARCHAR(255) NULL ,
         PRIMARY KEY (`reportId`) ,
         INDEX `FkReportUser_idx` (`reportUserId` ASC) ,
         INDEX `FKMacs_idx` (`reportMacId` ASC) ,
         INDEX `FKReportAppNames_idx` (`reportAppNameId` ASC) ,
         FOREIGN KEY (`reportUserId`) REFERENCES `reportUsers`(`reportUserIdFk`),
         FOREIGN KEY (`reportMacId`) REFERENCES `reportMacs`(`reportMacIdFk`),
         FOREIGN KEY (`reportAppNameId`) REFERENCES `reportAppNames`(`reportAppNameIdFk`)
       )
       ENGINE = InnoDB;
       ');
     if ($oDb->errno != 0) {
         return false;
     }
     $oDb->query('
        CREATE  TABLE IF NOT EXISTS
         `config`
        (
         `name` VARCHAR(255) NULL ,
         `value` VARCHAR(255) NULL ,
         PRIMARY KEY (`name`)
       )
       ENGINE = InnoDB;
       ');
     if ($oDb->errno != 0) {
         return false;
     }
     return true;
 }
    public function cancelTransaction()
    {
        try {
            return $this->db->rollBack();
        } catch (Exception $e) {
            exit('<strong>ROLLBACK TRANSACTION ERROR:</strong> ' . $e->getMessage());
        }
    }
    public function error()
    {
        echo '<pre>';
        var_dump($this->stmt->debugDumpParams());
        echo '</pre>';
    }
    // Helper function(s)
    public function truncate(array $tables = null)
    {
        if (!count($tables)) {
            return false;
        }
        $this->startTrans();
        foreach ($tables as $table) {
            $this->query('TRUNCATE TABLE ?');
            $this->execute([$table]);
        }
        $this->endTrans();
    }
}
$db = database::getInstance();
$_SERVER['PHP_SELF'] = str_replace('/mtg-engine', '', $_SERVER['PHP_SELF']);
// Temporary, for dev purposes
Esempio n. 25
0
    /**
     * Gibt alle User der Wer Reports zurück
     *
     * @return array|bool
     */
    public static function getUser()
    {
        $rows = [];
        $oDb = database::getInstance()->getConnection();
        $aResult = $oDb->query('
			SELECT DISTINCT
				`ru`.`reportUsers`
			FROM
				`reports` `r`
			JOIN
				`reportusers` `ru`
			ON (
				`ru`.`reportUserIdFk` = `r`.`reportUserId`
			)

			');
        if ($oDb->errno != 0) {
            return false;
        }
        while ($row = $aResult->fetch_assoc()) {
            $rows[] = $row;
        }
        return $rows;
    }
Esempio n. 26
0
 function signup()
 {
     if (isset($_SESSION['user_id'])) {
         tools::redirect('/account');
     }
     if (!empty($_POST)) {
         $data = tools::filter($_POST);
         $toCheck = array('username' => $data['username'], 'password' => $data['password'], 'email' => $data['email'], 'req' => $data['terms'], 'account' => $_SERVER['REMOTE_ADDR']);
         // check captcha if activated
         if ($this->settings['app']['captcha']) {
             $toCheck['captcha'] = $data['captcha'];
         }
         // validate the sent data
         $errors = tools::validate($toCheck);
         if (empty($errors)) {
             $key = mt_rand();
             $toInsert = array('username' => $data['username'], 'ppasswd' => tools::generateHash($data['password']), 'email' => $data['email'], 'validation_key' => $key, 'ip' => $_SERVER['REMOTE_ADDR'], 'created' => date("Y-m-d H:i:s"));
             if ($this->user->add($toInsert)) {
                 // get user id
                 $userID = database::getInstance()->lastInsertId();
                 // add referrer if isset
                 if (isset($_SESSION['referrer'])) {
                     $this->user->addReferral(array('user_id' => $userID, 'referrer_id' => $_SESSION['referrer']));
                     unset($_SESSION['referrer']);
                 }
                 // add free signup credits
                 $this->bid->add(array('user_id' => $userID, 'description' => 'free#signup', 'credit' => $this->settings['app']['free_signup_credits']));
                 // send signing email to user
                 tools::sendMail($data['email'], 'registration', array('username' => $data['username'], 'key' => $key));
                 tools::setFlash($this->l('Thanks for signing up! Please check your email and click Activate Account in the message we just sent to you'), 'success');
                 tools::redirect('/');
             } else {
                 tools::setFlash($this->l('An error has occurred'), 'error');
                 tools::redirect('/user/signup');
             }
         } else {
             $message = '';
             foreach ($errors as $error) {
                 $message .= $this->l($error) . '<br>';
             }
             tools::setFlash($message, 'error');
             $this->smarty->assign('data', $data);
         }
     }
     $this->smarty->assign('active', 7);
     $this->smarty->display('user/signup.tpl');
 }
Esempio n. 27
0
 private function viewUpdate()
 {
     $params = array();
     if (!file_exists(root . "/install/.update-" . version)) {
         $params['notify']['unlock_update'] = true;
     }
     $install_log = @file_get_contents(root . "/install/.update-" . version);
     if ($install_log == "locked") {
         $params['notify']['locked_update'] = true;
     }
     if (!$this->isInstalled()) {
         $params['notify']['not_installed'] = true;
     } else {
         $stmt = database::getInstance()->con()->query("SELECT `version` FROM `" . property::getInstance()->get('db_prefix') . "_version` LIMIT 1");
         $res = $stmt->fetch(\PDO::FETCH_ASSOC);
         $usedVersion = $res['version'];
         if ($usedVersion == version) {
             $params['notify']['actual_version'] = true;
         }
         $updateQuery = null;
         if (sizeof($params['notify']) == 0) {
             if (system::getInstance()->post('startupdate')) {
                 $update_sql_array_files = $this->foundVersionUpdates($usedVersion, version);
                 if (is_array($update_sql_array_files)) {
                     foreach ($update_sql_array_files as $update_file) {
                         $updateQuery .= @file_get_contents(root . '/install/sql/' . $update_file) . '\\n';
                     }
                 }
                 if ($updateQuery != null) {
                     $updateQuery = str_replace('{$db_prefix}', property::getInstance()->get('db_prefix'), $updateQuery);
                     database::getInstance()->con()->exec($updateQuery);
                     @file_put_contents(root . "/install/.update-" . version, 'locked');
                     // only 1 run
                     $params['notify']['success'] = true;
                 } else {
                     $params['notify']['nosql_data'] = true;
                 }
             }
         }
     }
     return template::getInstance()->twigRender('update.tpl', $params);
 }
Esempio n. 28
0
<?php

require_once '../model/link_company_delivery_address.php';
require_once '../model/address.php';
require_once '../model/database.php';
$id_DA = $_GET["idDA"];
$id_c = $_GET["idC"];
$pdo = database::getInstance();
$pdo = $pdo->PDOInstance;
$stmt = $pdo->prepare('SELECT id FROM link_company_delivery_address WHERE id_company = :idc and id_address = :ida');
$stmt->bindParam(':idc', $id_c);
$stmt->bindParam(':ida', $id_DA);
$stmt->execute();
$result = $stmt->fetch();
$idLDA = $result['id'];
$lda = new link_company_delivery_address($idLDA);
$address = new address($lda->getId_address());
?>

<h2>Set this Address to Database</h2>
<form method="get" action="../controller/setLinkDA.php">
	<input type="hidden" name="idA" value="<?php 
echo $address->getId();
?>
">
	<input type="hidden" name="idC" value="<?php 
echo $id_c;
?>
">
	<div class="form-group">
		<label for="line">Line</label>
Esempio n. 29
0
 /**
  * Injects the database to the container
  * 
  * @return database the database
  */
 public function setDatabase()
 {
     $array = 'mysql' == $this['Config']['database']['type'] ? array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8") : array();
     return database::getInstance($this['Config']['database']['host'], $this['Config']['database']['database'], $this['Config']['database']['user'], $this['Config']['database']['password'], $this['Config']['database']['type'], $array);
 }
Esempio n. 30
0
 private function loadAllData()
 {
     if (sizeof($this->full_access_data) < 1) {
         $query = database::getInstance()->con()->query("SELECT * FROM " . property::getInstance()->get('db_prefix') . "_user_access_level");
         $this->full_access_data = $query->fetchAll(\PDO::FETCH_ASSOC);
     }
 }