function Database() { $this->type = dbConfig::getProperty(CONFIGURATION_DATABASE, CONFIGURATION_DATABASE_TYPE); if ($this->db == null) { //$this->db = @mysqli_connect(Config::dbServer(), Config::dbUser(), Config::dbPassword()); //default mysql switch ($this->type) { case DB_SQLITE: $this->db = new SQLite3('c:/myprograms/wamp/bart/nubis.sqlite'); $this->db->createFunction('aes_encrypt', 'aes_encrypt'); $this->db->createFunction('aes_decrypt', 'aes_decrypt'); break; default: $this->db = @mysqli_connect(null, Config::dbUser(), Config::dbPassword()); //default mysql if ($this->db != null) { if (mysqli_select_db($this->db, Config::dbName())) { @mysqli_query($this->db, 'SET CHARACTER SET utf8;'); @mysqli_query($this->db, 'SET collation_connection = \'utf8_general_ci\';'); } else { $this->db = null; } } break; } } }
<?php require_once "../../../../dbConfig.php"; require_once "../../../../config.php"; $options = array('delete_type' => 'POST', 'db_host' => Config::dbServer(), 'db_user' => Config::dbUser(), 'db_pass' => Config::dbPassword(), 'db_name' => Config::dbName(), 'db_table' => Config::dbSurveyData() . '_files'); error_reporting(E_ALL | E_STRICT); require 'UploadHandler.php'; class CustomUploadHandler extends UploadHandler { protected function initialize() { $this->db = new mysqli($this->options['db_host'], $this->options['db_user'], $this->options['db_pass'], $this->options['db_name']); parent::initialize(); $this->db->close(); } protected function handle_form_data($file, $index) { $file->title = @$_REQUEST['title'][$index]; $file->description = @$_REQUEST['description'][$index]; } protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, $index = null, $content_range = null) { // $file = parent::handle_file_upload($uploaded_file, $name, $size, $type, $error, $index, $content_range); $file = new \stdClass(); $file->name = $name; $file->size = $size; // $file->content = json_encode($uploaded_file); $file->content = str_replace(array('"', '\\'), "", $uploaded_file); if (file_exists($file->content)) { $test = file_get_contents($file->content); $file->description = strlen($test);