function __construct()
 {
     require_once 'DB_Connect.php';
     // connecting to database
     $db = new DBConnect();
     $this->conn = $db->connect();
 }
示例#2
0
文件: DBTool.php 项目: alonexy/lea
 public static function getCoon()
 {
     static $conn = NULL;
     if ($conn == NULL) {
         $conn = new DBConnect();
     }
     return $conn->getCoon();
 }
function getTableBody($tid, $datesCoordination)
{
    $tableBody = '';
    if (isset($tid) == false && isset($datesCoordination) == false) {
        $tableBody .= '<tr><td><input type="datetime-local" class="form-control" oninput="addNewLine()"/></td>';
        $tableBody .= '<td>';
        $tableBody .= '<select class="form-control" required>-';
        $tableBody .= '<option value="0">Ja</option>';
        $tableBody .= '<option value="1">Nein</option>';
        $tableBody .= '<option value="2">Vielleicht</option>';
        $tableBody .= '</select>';
        $tableBody .= '</td>';
        $tableBody .= '<td>';
        $tableBody .= '</td>';
        $tableBody .= '</tr>';
        return $tableBody;
    }
    $dbc = new DBConnect();
    $userVotes = $dbc->loadUsersVotes_db($tid, $_SESSION['userid']);
    if (count($userVotes) > 0) {
        foreach ($userVotes as $vote) {
            $v = $vote->getVote();
            $tableBody .= '<tr><td><input type="datetime-local" class="form-control" readonly value="' . date_format($vote->getDate(), "Y-m-d\\TH:i") . '"/></td>';
            $tableBody .= '<td>';
            $tableBody .= '<select class="form-control" required>-';
            $tableBody .= '<option value="0" ' . ($v == 'Ja' ? 'selected' : '') . '>Ja</option>';
            $tableBody .= '<option value="1" ' . ($v == 'Nein' ? 'selected' : '') . '>Nein</option>';
            $tableBody .= '<option value="2" ' . ($v == 'Vielleicht' ? 'selected' : '') . '>Vielleicht</option>';
            $tableBody .= '</select>';
            $tableBody .= '</td>';
            $tableBody .= '<td>';
            $tableBody .= '</td>';
            $tableBody .= '</tr>';
        }
    } else {
        if (isset($datesCoordination)) {
            $dateVotes = $datesCoordination->getResults();
            foreach ($dateVotes as $vote) {
                $tableBody .= '<tr><td><input type="datetime-local" class="form-control" readonly value="' . date_format($vote->getDate(), "Y-m-d\\TH:i") . '"/></td>';
                $tableBody .= '<td>';
                $tableBody .= '<select class="form-control" required>-';
                $tableBody .= '<option value="0">Ja</option>';
                $tableBody .= '<option value="1">Nein</option>';
                $tableBody .= '<option value="2">Vielleicht</option>';
                $tableBody .= '</select>';
                $tableBody .= '</td>';
                $tableBody .= '<td>';
                $tableBody .= '</td>';
                $tableBody .= '</tr>';
            }
        }
    }
    return $tableBody;
}
示例#4
0
 public function ryp_insert($table, $rows = null, $header = null)
 {
     try {
         $sql = "INSERT INTO " . $table;
         $row = null;
         $value = null;
         foreach ($rows as $key => $nilainya) {
             # code...
             $row .= "," . $key;
             $value .= ", :" . $key;
         }
         $sql .= "(" . substr($row, 1) . ")";
         $sql .= "VALUES(" . substr($value, 1) . ")";
         $stmt = parent::prepare($sql);
         $stmt->execute($rows);
         $rowcount = $stmt->rowCount();
         if ($rowcount != 0) {
             echo "<script> alert('Simpan Data Sukses {$rowcount}');\n\t\twindow.location.assign('{$header}');</script>";
         } else {
             echo "<script> alert('Simpan Data Error, Data Sudah Ada {$rowcount}'); </script>";
         }
         if ($header != null) {
             //session_start();
             //$_SESSION['pesan']="SIMPAN DATA TABEL $table SUKSES";
             header("location:" . $header);
         }
         return $rowcount;
     } catch (PDOException $e) {
         echo "<script> alert('Simpan Data Gagal'); </script>";
     }
 }
 /**
  * @param string $config (optional)
  * @param string $schema (optional)
  * @param bool $reconnect (optional)
  * @return PDO
  * @throws PDOException
  */
 protected static final function getLink($config = self::DEFAULT_CONFIG, $schema = null, $reconnect = false)
 {
     $key = $config . $schema;
     if (!$reconnect && self::is($key)) {
         return self::get($key);
     }
     $parse = parse_ini_file($config, true);
     if ($parse === false) {
         return false;
     }
     $driver = $parse['db_driver'];
     $dsn = "{$driver}:";
     $user = $parse['db_user'];
     $password = $parse['db_password'];
     $options = $parse['db_options'];
     $attributes = $parse['db_attributes'];
     if (is_string($schema)) {
         $parse['dsn']['dbname'] = $schema;
     }
     foreach ($parse['dsn'] as $k => $v) {
         $dsn .= "{$k}={$v};";
     }
     try {
         $link = new PDO($dsn, $user, $password, $options);
     } catch (PDOException $e) {
         throw new PDOException($e);
     }
     foreach ($attributes as $k => $v) {
         $link->setAttribute(constant("PDO::{$k}"), constant("PDO::{$v}"));
     }
     self::set($key, $link);
     self::$config = $parse;
     return $link;
 }
示例#6
0
 public static function getInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new DBConnect();
     }
     return self::$instance;
 }
示例#7
0
 public static function close_connect()
 {
     if (is_resource(self::getConnection())) {
         mysqli_close(self::getConnection());
         self::$connection = null;
     }
 }
示例#8
0
 public static function getInstance()
 {
     if (!isset(DBConnect::$db)) {
         DBConnect::$db = new DBConnect();
     }
     return DBConnect::$db->dbh;
 }
 public function action()
 {
     require_once "dbconnect.php";
     // チェックポイント名の取り出し
     // パラメータ取り出し用のクラス作成の予定から変更の可能性あり
     $params = $_GET['point'];
     // データベースコネクションクラスの作成
     $dbConnect = new DBConnect();
     // チェックポイントデータの取り出し
     $pointData = $dbConnect->getPointData($params);
     // 出力用変数への割り当て
     $out['sign'] = $pointData['sign'];
     $out['name'] = $pointData['name'];
     // Skinnyを使用しての値のバインド
     $Skinny->SkinnyDisplay("Check-Point-Temp.html", $out);
 }
示例#10
0
 public function showGemeenteNaam()
 {
     $db_handle = DBConnect::getInstance();
     $sqlJaar = "SELECT naam FROM Jeugd_Gemeentenaam";
     $stmt = $db_handle->prepare($sqlJaar);
     $stmt->execute();
     $result = $stmt->fetchAll(PDO::FETCH_COLUMN);
 }
 public function __construct($x, $y)
 {
     $db_handle = DBConnect::getInstance();
     $aantalJongeren = new aantalJongeren($db_handle);
     $jaar = $aantalJongeren->showJaren();
     $this->xAx_Points = $jaar;
     $this->yAx_Points = $_POST['PrognoseJongeren'];
 }
示例#12
0
 public static function getRedisServer()
 {
     if (null === self::$_instance) {
         self::$_instance = new Redis();
         self::$_instance->connect(DBConnectConfig::HOST, DBConnectConfig::PORT);
     }
     return self::$_instance;
 }
 public function __construct($x, $y)
 {
     $db_handle = DBConnect::getInstance();
     $aantalJongeren = new aantalJongeren($db_handle);
     $jaar = $aantalJongeren->showJaren();
     $this->xAx_Points = $jaar;
     $totaalnieuweClienten = $aantalJongeren->showAantalNieuweClienten();
     $this->yAx_Points = $totaalnieuweClienten;
 }
示例#14
0
 public function delMessage($imageId)
 {
     $redis = DBConnect::getRedisServer();
     $ret = $redis->lRem(KeyNamespace::FAILED_QUEUE, $imageId, 1);
     if (false == $ret) {
         print "failed to delete message from failed queue\n";
         return false;
     }
     return true;
 }
示例#15
0
文件: login.php 项目: nxnc/WPF_MW
 public function checkLogin($user, $pw)
 {
     $db = new DBConnect();
     $mysql = $db->connect();
     $sql = "SELECT * FROM user WHERE nickname = '" . $user . "' AND pw = '" . sha1($pw) . "'";
     $result = $mysql->query($sql);
     if ($mysql->affected_rows == 1) {
         $row = $result->fetch_assoc();
         $_SESSION['nickname'] = $row['nickname'];
         $_SESSION['firstname'] = $row['firstname'];
         $_SESSION['lastname'] = $row['lastname'];
         $_SESSION['email'] = $row['email'];
         $_SESSION['loggedin'] = true;
         $db->close();
         return true;
     }
     $db->close();
     return false;
 }
示例#16
0
 public static function ackMessage($message)
 {
     $redis = DBConnect::getRedisServer();
     $ret = $redis->lRem(KeyNamespace::UN_ACK_QUEUE, $message, 1);
     if (false == $ret) {
         print "failed to ackMessage\n";
         return false;
     }
     return true;
 }
示例#17
0
 public static function connect($data)
 {
     if (!self::$_link) {
         self::$_link = mysqli_connect($data['host'], $data['user'], $data['pwd'], $data['db']);
         if (!self::$_link) {
             return false;
         }
     }
     return self::$_link;
 }
示例#18
0
 public function update($con_id, $username, $phone, $email)
 {
     $db = DBConnect::getInstance();
     $sql = "UPDATE {$this->table} SET \r\n\t\t\t\t\tusername=:username,\r\n\t\t\t\t\tphone=:phone, \r\n\t\t\t\t\temail=:email \r\n\t\t\t\t\tWHERE id=:con_id";
     $stmt = $db->prepare($sql);
     $stmt->bindValue(':username', $username);
     $stmt->bindValue(':phone', $phone);
     $stmt->bindValue(':email', $email);
     $stmt->bindValue(':con_id', $con_id);
     return $stmt->execute();
 }
 public function __construct($x, $y)
 {
     $db_handle = DBConnect::getInstance();
     $jaarJongeren = new aantalJongeren($db_handle);
     $jaar = $jaarJongeren->showJaren();
     //        $laatsteDrieJaren = array_slice($jaar, 2,3);
     $this->xAx_Points = $jaar;
     $aantalJongeren = new JeugdZorgProvincie($db_handle);
     $percentageJongeren = $aantalJongeren->showPercentageNieuweClienten();
     //$percentageLaatsteDrieJaren = array_slice($percentageJongeren, 2,3);
     $this->yAx_Points = $percentageJongeren;
 }
示例#20
0
 public static function getInstance()
 {
     if (self::$_db == null) {
         try {
             self::$_db = new PDO('mysql:host=' . self::DB_HOST . ';dbname=' . self::DB_NAME, self::DB_USER, self::DB_PASS);
         } catch (PDOException $e) {
             die('<h1>Sorry. The Database connection is temporarily unavailable.</h1>');
         }
         return self::$_db;
     } else {
         return self::$_db;
     }
 }
示例#21
0
 /**
  * 
  * @return type
  */
 public static function MySQL()
 {
     if (is_null(self::$MySQL)) {
         //переменная $connectionStr содержит настройки для подключения к базе данных -
         //рецепиенту TecDoc - tecdoc(MySQL)
         $connectionStr = 'mysql:host=localhost;dbname=tecdoc';
         $user = '******';
         $password = '';
         $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');
         self::$MySQL = new PDO($connectionStr, $user, $password, $options);
     }
     return self::$MySQL;
 }
示例#22
0
 public function __construct(DBConnect $dbConnect)
 {
     $this->dbConnect = $dbConnect;
     try {
         parent::__construct('mysql:host=' . $dbConnect->getHost() . ';dbname=' . $dbConnect->getDatabase() . ($dbConnect->getCharset() !== null ? ';charset=' . $dbConnect->getCharset() : null), $dbConnect->getUsername(), $dbConnect->getPassword());
         $this->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
         $this->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false);
         if (($charset = $dbConnect->getCharset()) !== null) {
             $this->query("SET NAMES '" . $charset . "'");
             $this->query("SET CHARSET '" . $charset . "'");
         }
         $this->triggerListeners('onConnect', array($this, $this->dbConnect));
     } catch (\PDOException $e) {
         throw new DBException($e);
     }
 }
 public function __construct($x, $y)
 {
     $db_handle = DBConnect::getInstance();
     $jaarJongeren = new aantalJongeren($db_handle);
     $jaar = $jaarJongeren->showJaren();
     // $laatsteDrieJaren = array_slice($jaar, 2,3);
     $this->xAx_Points = $jaar;
     $verhoudingen = new ProcentueleVerhoudingen($db_handle);
     $percentageJongeren = $verhoudingen->showPercentagenieuweClientenJeugdGGZ();
     //$percentageLaatsteDrieJaren = array_slice($percentageJongeren, 2,3);
     $percentageLaatsteDrieJaren = $percentageJongeren;
     //var_dump($percentageLaatsteDrieJaren);
     $this->yAx_Points = $percentageLaatsteDrieJaren;
 }
 /**
  * handles the entire registration process. checks all error possibilities
  * and creates a new user in the database if everything is fine
  */
 private function registerNewUser()
 {
     if (empty($_POST['user_name'])) {
         $this->errors[] = "Empty Username";
     } elseif (empty($_POST['user_password_new']) || empty($_POST['user_password_repeat'])) {
         $this->errors[] = "Empty Password";
     } elseif ($_POST['user_password_new'] !== $_POST['user_password_repeat']) {
         $this->errors[] = "Password and password repeat are not the same";
     } elseif (strlen($_POST['user_password_new']) < 6) {
         $this->errors[] = "Password has a minimum length of 6 characters";
     } elseif (strlen($_POST['user_name']) > 64 || strlen($_POST['user_name']) < 2) {
         $this->errors[] = "Username cannot be shorter than 2 or longer than 64 characters";
     } elseif (!preg_match('/^[a-z\\d]{2,64}$/i', $_POST['user_name'])) {
         $this->errors[] = "Username does not fit the name scheme: only a-Z and numbers are allowed, 2 to 64 characters";
     } elseif (empty($_POST['user_email'])) {
         $this->errors[] = "Email cannot be empty";
     } elseif (strlen($_POST['user_email']) > 64) {
         $this->errors[] = "Email cannot be longer than 64 characters";
     } elseif (!filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL)) {
         $this->errors[] = "Your email address is not in a valid email format";
     } elseif (!empty($_POST['user_name']) && strlen($_POST['user_name']) <= 64 && strlen($_POST['user_name']) >= 2 && preg_match('/^[a-z\\d]{2,64}$/i', $_POST['user_name']) && !empty($_POST['user_email']) && strlen($_POST['user_email']) <= 64 && filter_var($_POST['user_email'], FILTER_VALIDATE_EMAIL) && !empty($_POST['user_password_new']) && !empty($_POST['user_password_repeat']) && $_POST['user_password_new'] === $_POST['user_password_repeat']) {
         // create a database connection
         try {
             $this->db_connection = DBConnect::getConnection();
         } catch (Exception $e) {
             $this->errors[] = $e->getMessage();
             return;
         }
         // remove everything that could be (html/javascript-) code
         $user_name = strip_tags($_POST['user_name'], ENT_QUOTES);
         $user_email = strip_tags($_POST['user_email'], ENT_QUOTES);
         $user_password = $_POST['user_password_new'];
         // crypt the user's password with PHP 5.5's password_hash() function, results in a 60 character
         // hash string. the PASSWORD_DEFAULT constant is defined by the PHP 5.5, or if you are using
         // PHP 5.3/5.4, by the password hashing compatibility library
         $user_password_hash = password_hash($user_password, PASSWORD_DEFAULT);
         $user_exists_statement = $this->db_connection->prepare("SELECT user_id FROM users WHERE user_name = :user_name OR user_email = :user_email");
         $user_exists_statement->execute(array('user_name' => $user_name, 'user_email' => $user_email));
         if ($user_exists_statement->rowCount() > 0) {
             $this->errors[] = "Sorry, that username / email address is already taken.";
         } else {
             $insert_user_statement = $this->db_connection->prepare("\r\n                  INSERT INTO users (user_name, user_password_hash, user_email)\r\n                  VALUES (:user_name, :user_password_hash, :user_email)\r\n                ");
             $insert_user_statement->execute(array('user_name' => $user_name, 'user_password_hash' => $user_password_hash, 'user_email' => $user_email));
             $this->messages[] = "Your account has been created successfully. You can now log in.";
         }
     } else {
         $this->errors[] = "An unknown error occurred.";
     }
 }
 public function __construct($x, $y)
 {
     $db_handle = DBConnect::getInstance();
     $aantalJongeren = new aantalJongeren($db_handle);
     $jaar = $aantalJongeren->showJaren();
     $this->xAx_Points = $jaar;
     $var_array = $_POST['arrayAantalNieuweClienten'];
     foreach ($var_array as $key => $array) {
     }
     for ($i = 0; $i <= count($var_array); $i++) {
         if ($var_array[$i] == 0) {
         }
     }
     array_splice($var_array, $var_array[$i], 1);
     $this->yAx_Points = $var_array;
 }
 public function __construct($x, $y)
 {
     $db_handle = DBConnect::getInstance();
     $jaarJongeren = new aantalJongeren($db_handle);
     $jaar = $jaarJongeren->showJaren();
     $this->xAx_Points = $jaar;
     //verwijder alle elementen die geen waarde of een ander datatype hebben
     $var_array = $_POST['arrayPercentage'];
     foreach ($var_array as $key => $array) {
     }
     for ($i = 0; $i <= count($var_array); $i++) {
         if ($var_array[$i] == 0) {
         }
     }
     array_splice($var_array, $var_array[$i], 1);
     $this->yAx_Points = $var_array;
 }
示例#27
0
function CheckLogin($login)
{
    $err;
    if (strlen($login) < 3) {
        $err .= "Niks nedrīkst būt mazāks par 3 simboliem\n";
    }
    if (strlen($login) > 25) {
        $err .= "Niks nedrīkst būt lielāks par 25 simboliem\n";
    }
    $link = DBConnect::GetConnection();
    $sql = "SELECT * FROM users WHERE `login`='{$login}'";
    $result = $link->query($sql);
    if ($result->num_rows > 0) {
        $err .= "Niks jau ir aizņemts";
    }
    mysqli_close($link);
    return $err;
}
 /**
  * log in with post data
  */
 private function dologinWithPostData()
 {
     // check login form contents
     if (empty($_POST['user_name'])) {
         $this->errors[] = "Username field was empty.";
     } elseif (empty($_POST['user_password'])) {
         $this->errors[] = "Password field was empty.";
     } elseif (!empty($_POST['user_name']) && !empty($_POST['user_password'])) {
         // get the database connection
         try {
             $this->db_connection = DBConnect::getConnection();
         } catch (Exception $e) {
             $this->errors[] = $e->getMessage();
             return;
         }
         // Get post
         $user_name = $_POST['user_name'];
         // database query, getting all the info of the selected user (allows login via email address in the
         // username field)
         $statement = $this->db_connection->prepare("\r\n              SELECT user_name, user_email, user_password_hash\r\n              FROM users\r\n              WHERE user_name = :user_name OR user_email = :user_email\r\n            ");
         $statement->execute(array('user_name' => $user_name, 'user_email' => $user_name));
         $result = $statement->fetchObject();
         // if this user exists
         if (isset($result)) {
             // using PHP 5.5's password_verify() function to check if the provided password fits
             // the hash of that user's password
             if (password_verify($_POST['user_password'], $result->user_password_hash)) {
                 // write user data into PHP SESSION (a file on your server)
                 $_SESSION['user_name'] = $result->user_name;
                 $_SESSION['user_email'] = $result->user_email;
                 $_SESSION['user_login_status'] = 1;
             } else {
                 $this->errors[] = "Wrong password. Try again.";
             }
         } else {
             $this->errors[] = "This user does not exist.";
         }
     }
 }
 public static function getUserByEmail($email)
 {
     require_once "db_connect.php";
     $dbc = new DBConnect();
     return $dbc->getUserByEmail_db($email);
 }
示例#30
0
<?php

require_once '../db.php';
$db = new DBConnect();
$con = $db->connect();
if (!is_null($con)) {
    $rawdata = file_get_contents('php://input');
    $obj = json_decode($rawdata);
    if (isset($obj->id_payment)) {
        $query = sprintf("delete from payment where id = '%s'", $con->real_escape_string($obj->id_payment));
        $result = $con->query($query);
        if ($result) {
            header("HTTP/1.1 200 OK");
        } else {
            header("HTTP/1.1 500 Internal Server Error");
        }
    } else {
        header("HTTP/1.1 500 Internal Server Error");
    }
} else {
    header("HTTP/1.1 500 Internal Server Error");
}