daily pastebin goal
83%
SHARE
TWEET

Untitled

a guest Oct 23rd, 2017 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. /**
  4.  * @copyright Galym Kerimbekov
  5.  * @license GNU GPLv2
  6.  */
  7.  
  8. namespace MS\Core;
  9.  
  10. use PDO;
  11.  
  12. class ConfigModel {
  13.  
  14.     private $conndb = null;
  15.  
  16.     public function __construct() {
  17.         $servername = null;
  18.         $dbname = null;
  19.         $username = null;
  20.         $mysqlpassword = null;
  21.  
  22.         $BaseRoot = $_SERVER['DOCUMENT_ROOT'];
  23.         $requestRoot = explode("/", dirname($_SERVER['REQUEST_URI']));
  24.        
  25.         if ($requestRoot['1'] === 'app') {
  26.             $Baseurl = $BaseRoot;
  27.         } else {
  28.             $Baseurl  = $BaseRoot . $requestRoot['1'];
  29.         }
  30.  
  31.         if (file_exists("$Baseurl/app/Core/input.c.php")) {
  32.  
  33.             require "$Baseurl/app/Core/Configuration.php";
  34.  
  35.             try {
  36.                 $opt = array(PDO::ATTR_PERSISTENT => true,
  37.                     PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
  38.                     PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC, PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8");
  39.                 $this->conndb = new PDO("mysql:host=$servername;dbname=$dbname", $username, $mysqlpassword, $opt);
  40.             } catch (PDOException $e) {
  41.                 print "Error!: " . $e->getMessage() . "";
  42.                 header("Location: app/Core/configure.php");
  43.             }
  44.         } else {
  45.             header("Location: /");
  46.         }
  47.     }
  48.  
  49.     public function getConn() {
  50.         return $this->conndb;
  51.     }
  52.  
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top