Exemple #1
0
 /**
  * Extends default connection method. It will be useful in order to
  * allow accents and other DB-centric global commands.
  *
  * @param string $connect_string a PDO connection string
  * @param string $db_user the database user name
  * @param string $db_pass the database user password
  * @return boolean TRUE on success, FALSE on error
  */
 public function connect($connect_string, $db_user, $db_pass)
 {
     // If something went wrong, we don't need to exec the specific commands.
     if (!parent::connect($connect_string, $db_user, $db_pass)) {
         return false;
     }
     return true;
 }
Exemple #2
0
 protected static final function openConnection($driver)
 {
     $adapter = 'Adapter' . $driver;
     include_once dirname(__FILE__) . '/adapter/' . $adapter . '.php';
     $connection = new DatabaseConnection(new $adapter());
     $cfg = self::getConnectionConf();
     $connection->connect($cfg['engine'], $cfg['hostname'], $cfg['database'], $cfg['username'], $cfg['password']);
     return $connection;
     // end function
 }
Exemple #3
0
 /**
  * Extends default connection method. It will be useful in order to
  * allow accents and other DB-centric global commands.
  *
  * @param string $connect_string a PDO connection string
  * @param string $db_user the database user name
  * @param string $db_pass the database user password
  * @return boolean TRUE on success, FALSE on error
  */
 public function connect($connect_string, $db_user, $db_pass)
 {
     // If something went wrong, we don't need to exec the specific commands.
     if (!parent::connect($connect_string, $db_user, $db_pass)) {
         return false;
     }
     $this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
     // Everything is OK. Let's update the charset!
     if (!defined('MYSQL_CHAR_SET')) {
         define('MYSQL_CHAR_SET', 'UTF8');
     }
     $this->exec('SET NAMES ' . MYSQL_CHAR_SET);
     return true;
 }
Exemple #4
0
 /**
  * Connect to SQLite
  * Overrides the DatabaseConnection to return false if the SQLite file doesn't exist.
  *
  * @param connection_string string a PDO connection string
  * @param db_user string the database user name
  * @param db_pass string the database user password
  * @return boolean True if connection succeeded, false if not.
  */
 public function connect($connect_string, $db_user, $db_pass)
 {
     list($type, $file) = explode(':', $connect_string, 2);
     if ($file == basename($file)) {
         if (file_exists(HABARI_PATH . '/' . $file)) {
             $file = HABARI_PATH . '/' . $file;
         } else {
             $file = HABARI_PATH . '/' . Site::get_path('user', TRUE) . $file;
         }
         $connect_string = implode(':', array($type, $file));
     }
     $conn = parent::connect($connect_string, $db_user, $db_pass);
     $this->exec('PRAGMA synchronous = OFF');
     return $conn;
 }
Exemple #5
0
 /**
  * Extends default connection method. It will be useful in order to
  * allow accents and other DB-centric global commands.
  *
  * @param string $connect_string a PDO connection string
  * @param string $db_user the database user name
  * @param string $db_pass the database user password
  * @return boolean true on success, false on error
  */
 public function connect($connect_string, $db_user, $db_pass)
 {
     // If something went wrong, we don't need to exec the specific commands.
     if (!parent::connect($connect_string, $db_user, $db_pass)) {
         return false;
     }
     $this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
     // Everything is OK. Let's update the charset!
     if (!defined('MYSQL_CHAR_SET')) {
         define('MYSQL_CHAR_SET', 'UTF8');
     }
     // SET NAMES defines character_set_client, character_set_results, and character_set_connection (which implicitly sets collation_connection) and therefore covers everything SET CHARACTER SET does, but uses the character set we tell it to, ignoring what the database is configured to use
     // 	http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html
     $this->exec('SET NAMES ' . MYSQL_CHAR_SET);
     return true;
 }
Exemple #6
0
 /**
  * Extends default connection method. It will be useful in order to
  * allow accents and other DB-centric global commands.
  *
  * @param string $connect_string a PDO connection string
  * @param string $db_user the database user name
  * @param string $db_pass the database user password
  * @return boolean true on success, false on error
  */
 public function connect($connect_string, $db_user, $db_pass)
 {
     // If something went wrong, we don't need to exec the specific commands.
     if (!parent::connect($connect_string, $db_user, $db_pass)) {
         return false;
     }
     $this->pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
     // Everything is OK. Let's update the charset!
     if (!defined('MYSQL_CHAR_SET')) {
         define('MYSQL_CHAR_SET', 'UTF8');
     }
     // SET CHARACTER SET might get the character_set_connection wrong, thus we also need SET NAMES. See http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html
     $this->exec('SET CHARACTER SET ' . MYSQL_CHAR_SET);
     $this->exec('SET NAMES ' . MYSQL_CHAR_SET);
     return true;
 }
Exemple #7
0
 /**
  * Connect to SQLite
  * Overrides the DatabaseConnection to return false if the SQLite file doesn't exist.
  *
  * @param connection_string string a PDO connection string
  * @param db_user string the database user name
  * @param db_pass string the database user password
  * @return boolean True if connection succeeded, false if not.
  */
 public function connect($connect_string, $db_user, $db_pass)
 {
     list($type, $file) = explode(':', $connect_string, 2);
     if ($file == basename($file)) {
         if (file_exists(HABARI_PATH . '/' . $file)) {
             $file = HABARI_PATH . '/' . $file;
         } else {
             $file = HABARI_PATH . '/' . Site::get_path('user', true) . $file;
         }
         $connect_string = implode(':', array($type, $file));
     }
     if (file_exists($file) && !is_writable($file)) {
         die(_t('Database file "%s" must be writable.', array($file)));
     }
     $conn = parent::connect($connect_string, $db_user, $db_pass);
     $this->exec('PRAGMA synchronous = OFF');
     return $conn;
 }
Exemple #8
0
 /**
  * @param $email
  * @return bool
  */
 public function isAlreadyRegistered($email)
 {
     //require_once "classes/DatabaseConnection.php";
     /**
      * Get user by email and password
      */
     try {
         $databaseHandle = new DatabaseConnection();
         $connection = $databaseHandle->connect();
         //establish connection to the database
         $statement = $connection->prepare("SELECT * FROM " . TABLE_NAME . " WHERE _email=?");
         $statement->bindParam(1, $email);
         $statement->execute();
         //check if the operation was successful
         if ($statement->rowCount() > 0) {
             return $statement;
         }
     } catch (PDOException $exception) {
         echo $exception->getMessage();
     }
     return false;
 }
 /**
  * Attempt to connect to the Movable Type database
  *
  * @access private
  * @param string $db_host The hostname of the MT database
  * @param string $db_name The name of the MT database
  * @param string $db_user The user of the MT database
  * @param string $db_pass The user's password for the MT database
  * @param string $db_prefix The table prefix for the MT instance in the database
  * @return mixed false on failure, DatabseConnection on success
  */
 private function mt_connect($db_host, $db_name, $db_user, $db_pass, $db_prefix)
 {
     // Connect to the database or return false
     try {
         $mtdb = new DatabaseConnection();
         $mtdb->connect("mysql:host={$db_host};dbname={$db_name}", $db_user, $db_pass, $db_prefix);
         return $mtdb;
     } catch (Exception $e) {
         return false;
     }
 }
Exemple #10
0
<?php

include $_SERVER['DOCUMENT_ROOT'] . '/cabinet/backend/class/reptilicus.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/cabinet/backend/web/domain_manager.php';
$dm = new DomainManager();
if ($dm->isCustomDomain()) {
    include $_SERVER['DOCUMENT_ROOT'] . '/cabinet/backend/tpl/index.php';
    return;
}
$db = new DatabaseConnection();
$dbconn = $db->connect();
$reptilucText = new reptilucText();
$text = $reptilucText->getTextEn($dbconn, 1);
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Login page</title>
  <meta name="viewport" content="width=device-width, maximum-scale=1.0, minimum-scale=1.0 initial-scale=1.0">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" 
  integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/alertify.js/0.3.11/alertify.core.min.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/alertify.js/0.3.11/alertify.default.min.css">
  <link rel="stylesheet" href="node_modules/font-awesome/css/font-awesome.min.css">

  <link rel="stylesheet" href="css/login.css">
</head>
<body ng-app="login" ng-controller="mainCtrl as main">
  <div class="login_container">
    <div id="reptilicus-login-form">
 /**
  * Tests whether a connection can be established.
  *
  * @param string $host
  * @param int    $port
  * @param string $dbname
  * @param string $user
  * @param string $password
  * @return mixed `true` or {@link \PDOException}
  */
 public static function test($host, $port, $dbname, $user, $password)
 {
     try {
         $conn = new DatabaseConnection($host, $port);
         $conn->init($dbname);
         $conn->connect($user, $password);
         return true;
     } catch (\PDOException $e) {
         return $e;
     }
 }
 /**
  * Attempt to connect to the Serendipity database
  *
  * @param string $db_host The hostname of the WP database
  * @param string $db_name The name of the WP database
  * @param string $db_user The user of the WP database
  * @param string $db_pass The user's password for the WP database
  * @param string $db_prefix The table prefix for the WP instance in the database
  * @param string $db_port The port number of the WP database
  * @return mixed false on failure, DatabseConnection on success
  */
 private function s9y_connect($db_host, $db_name, $db_user, $db_pass, $db_prefix, $db_port = null)
 {
     // Connect to the database or return false
     try {
         $s9ydb = new DatabaseConnection();
         $connect_str = "mysql:host={$db_host};dbname={$db_name}";
         if (!is_null($db_port)) {
             $connect_str .= ";port={$db_port}";
         }
         $s9ydb->connect($connect_str, $db_user, $db_pass, $db_prefix);
         return $s9ydb;
     } catch (PDOException $e) {
         return FALSE;
     }
 }