public function __construct(&$view) { // Loading configuration file parameters try { if (!FileConfig::open(CONFIG_FILE)) { throw new Exception("The configuration file is missing"); } else { $this->catalog_nb = FileConfig::count_Catalogs(); } } catch (Exception $e) { CErrorHandler::displayError($e); } // Template engine initalization $this->view = $view; // Checking template cache permissions if (!is_writable(VIEW_CACHE_DIR)) { throw new Exception("The template cache folder <b>" . VIEW_CACHE_DIR . "</b> must be writable by Apache user"); } // Initialize smarty gettext function $language = FileConfig::get_Value('language'); if (!$language) { throw new Exception("Language translation problem"); } $this->translate = new CTranslation($language); $this->translate->set_Language($this->view); // Get catalog_id from http $_GET request if (!is_null(CHttpRequest::get_Value('catalog_id'))) { if (FileConfig::catalogExist(CHttpRequest::get_Value('catalog_id'))) { $this->catalog_current_id = CHttpRequest::get_Value('catalog_id'); $_SESSION['catalog_id'] = $this->catalog_current_id; } else { $_SESSION['catalog_id'] = 0; $this->catalog_current_id = 0; throw new Exception('The catalog_id value provided does not correspond to a valid catalog, please verify the config.php file'); } } else { if (isset($_SESSION['catalog_id'])) { // Stick with previously selected catalog_id $this->catalog_current_id = $_SESSION['catalog_id']; } } // Define catalog id and catalog label $this->view->assign('catalog_current_id', $this->catalog_current_id); $this->view->assign('catalog_label', FileConfig::get_Value('label', $this->catalog_current_id)); // Getting database connection paremeter from configuration file $dsn = FileConfig::get_DataSourceName($this->catalog_current_id); $driver = FileConfig::get_Value('db_type', $this->catalog_current_id); $user = ''; $pwd = ''; if ($driver != 'sqlite') { $user = FileConfig::get_Value('login', $this->catalog_current_id); $pwd = FileConfig::get_Value('password', $this->catalog_current_id); } switch ($driver) { case 'mysql': case 'pgsql': $this->db_link = CDB::connect($dsn, $user, $pwd); break; case 'sqlite': $this->db_link = CDB::connect($dsn); break; } // Getting driver name from PDO connection $this->db_driver = CDB::getDriverName(); // Set PDO connection options $this->db_link->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); $this->db_link->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->db_link->setAttribute(PDO::ATTR_STATEMENT_CLASS, array('CDBResult', array($this))); // MySQL connection specific parameter if ($driver == 'mysql') { $this->db_link->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, true); } // Bacula catalog selection if ($this->catalog_nb > 1) { // Catalogs list $this->view->assign('catalogs', FileConfig::get_Catalogs()); // Catalogs count $this->view->assign('catalog_nb', $this->catalog_nb); } }
} /* $dbconfig = array( 'host'=>'sql208.0fees.net', 'db_name'=>'fees0_3157581_filmohren', 'user'=>'fees0_3157581', 'password'=>'3mk8a9'); */ $dbconfig = array('host' => 'localhost', 'db_name' => 'db_filmohren', 'user' => 'root', 'password' => ''); $cmd = new CCommander(); $dbg = new CMyDebug($cmd, true); $db = new CDB($dbconfig, $dbg); $proc = NULL; $auth = true; //$resp_arr = array('data'=>'','target'=>'','mode'=>'0'); if ($db->connect()) { $usr = new CUser($dbg); $state = new CState(); $data = array('p' => ''); $state->scan_states(); if (isset($_POST['ball']) && $_POST['ball'] != "") { $dbg->add_line("POST: " . $_POST['ball']); $_POST['ball'] = str_replace("\\", "", $_POST['ball']); $data['p'] = json_decode($_POST['ball'], true); if (isset($data['p']) && is_array($data['p']) && isset($data['p']['data']) && is_array($data['p']['data'])) { $dbg->add_line("decoding successfull..."); $dbg->add_line("sender: " . $data['p']['name']); foreach ($data['p']['data'] as $k => $v) { $dbg->add_line($k . ", " . $v); } }