Esempio n. 1
0
function check_login()
{
    global $db, $mem;
    if (defined('MEM') && MEM == True) {
        $mem = new Memcached('moyoj');
        $mem->setOption(Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
        if (!count($mem->getServerList())) {
            $mem->addServer(MEM_HOST, MEM_PORT);
        }
    }
    $db = new DB();
    $db->init(DB_HOST, DB_USER, DB_PASS, DB_NAME);
    $db->connect();
    $admin_info = mo_read_cache('mo-admin-' . $_SESSION['aid']);
    if (!$admin_info) {
        $sql = 'SELECT `id`, `username`, `password`, `nickname`, `role` FROM `mo_admin` WHERE `id` = ? AND `role` > 0';
        $db->prepare($sql);
        $db->bind('i', $_SESSION['aid']);
        $result = $db->execute();
        if (!$result || $result[0]['password'] != $_SESSION['admin_password']) {
            unset($_SESSION['aid']);
            header("Location: login.php");
            exit(0);
        }
        mo_write_cache('mo-admin-' . $_SESSION['aid'], $result[0]);
    }
    $mo_settings = array();
    mo_load_settings();
    if (!isset($active)) {
        $active = '';
    }
}
Esempio n. 2
0
 public function __construct($REQUEST, $model, $view)
 {
     $UI = \CORE\UI::init();
     switch ($REQUEST->get('act')) {
         case 'add':
             $model->create();
             break;
         case 'get':
             $model->get();
             break;
         case 'update':
             $model->update();
             break;
         case 'del':
             $model->delete();
             break;
         default:
             $UI->pos['main'] .= $view->main($model);
             break;
     }
     if (\CORE::init()->is_ajax()) {
         \DB::init()->close();
         exit;
     }
 }
Esempio n. 3
0
File: mt_m.php Progetto: sniyozov/mt
 public function get_mt($type = 0)
 {
     $lang = \CORE::lng();
     $mt = array();
     $DB = \DB::init();
     $type = $this->selected_type;
     if ($DB->connect()) {
         if ($type > 0) {
             $sql = "SELECT * FROM `mt` WHERE `mt-type`=:type ORDER BY `mt-name-" . $lang . "`;";
             $sth = $DB->dbh->prepare($sql);
             $sth->execute(array('type' => $type));
         } else {
             $sql = "SELECT * FROM `mt` ORDER BY `mt-type`,`mt-name-" . $lang . "`;";
             $sth = $DB->dbh->prepare($sql);
             $sth->execute();
         }
         $DB->query_count();
         if ($sth->rowCount() > 0) {
             while ($r = $sth->fetch()) {
                 $mt[$r['mt-id']] = $r;
             }
         }
     }
     return $mt;
 }
Esempio n. 4
0
 function __construct()
 {
     $this->db = DB::init();
     // todo: move this prepared statement to a singleton instance so it is only loaded on first fetch
     $this->stmt_getSolarSystemID = $this->db->prepare('SELECT solarSystemID FROM staStations WHERE stationID=?');
     $this->stmt_getSolarSystemID->bind_param('i', $this->stationID);
 }
Esempio n. 5
0
 /**
  * Comprueba si el usuario existe en la base de datos comparando el sh1 de los campos dados con los valores
  * 
  * @param		$fields			array asociativo campo => valor
  * @return	bool				true		=> Hay un usuario con esos datos
  * 							false	=> No hay un usuario con esos datos
  */
 public function check_user_exists($fields)
 {
     //Comprobamos si es el superadministrador
     if ($fields['user'] == K_USER && $fields['pass'] == K_PASS) {
         return array('user' => $fields['user'], 'name' => 'THE SUPER ADMIN', 'access' => 0);
         //Comprobamos si esta en la base de datos
     } else {
         $db = DB::init();
         $sqlFields = array();
         $hash = '';
         foreach ($fields as $key => $value) {
             $sqlFields[] = $key;
             $hash .= $value;
         }
         //fin foreach
         $rows = array();
         $field = array('*');
         $where = 'SHA1(CONCAT(' . implode(',', $sqlFields) . ')) = "' . sha1($hash) . '"';
         $db->select();
         $db->fields($field);
         $db->tables($this->_ut);
         $db->where($where, '', '', false);
         $rows = $db->execute(true);
         return sizeof($rows) == 1 ? $rows[0] : false;
     }
     //fin else
 }
Esempio n. 6
0
 function __construct()
 {
     $this->email = Config::$email;
     $this->domain = Config::$domain;
     $this->oSmarty = new Smarty();
     $this->oSmarty->assign("domain", Config::$domain);
     DB::init();
 }
Esempio n. 7
0
 public function __construct()
 {
     try {
         DB::init();
     } catch (Exception $e) {
         LogHandling::logDBError($e);
         exit;
     }
 }
Esempio n. 8
0
 private function init_db()
 {
     if ($this->is_init) {
         return;
     }
     $db = new mysql($this->_config);
     $db->connect();
     DB::init($db, $this->_config['db']['tablepre']);
     $this->is_init = true;
 }
Esempio n. 9
0
 public function __construct($params)
 {
     $this->_params = $params;
     try {
         DB::init();
     } catch (Exception $e) {
         $data['success'] = false;
         $data['errormsg'] = 'DB connection fault: ' . $e->getMessage();
     }
 }
Esempio n. 10
0
 static final function getDb($name = "")
 {
     if (isset(self::$db[$name])) {
         return self::$db[$name];
     } else {
         $DB = new DB();
         C('db:db_type', $name);
         $DB->init(C('db'));
         self::$db[$name] = $DB;
         return $DB;
     }
 }
 /**
  * Initialize the component
  *
  * @param array $gp
  * @param array $settings
  */
 public function init($gp, $settings)
 {
     if (!is_array($settings['fields.'])) {
         $settings['fields.'] = [];
     }
     $this->settings = $settings;
     parent::init($gp, $settings);
     if ($this->settings['newFieldsSqlAttribs']) {
         $this->newFieldsSqlAttribs = $this->utilityFuncs->getSingle($this->settings, 'newFieldsSqlAttribs');
     }
     $this->db = $GLOBALS['TYPO3_DB'];
 }
Esempio n. 12
0
 public function __construct($withoutInclude)
 {
     $this->withoutInclude =& $withoutInclude;
     if (!$withoutInclude) {
         require INCLUDE_PATH . '/class/roh/mailer.php';
         require INCLUDE_PATH . '/class/funclib.php';
         require INCLUDE_PATH . '/class/email.php';
         require INCLUDE_PATH . '/class/querybuild.php';
         require INCLUDE_PATH . '/class/database.php';
         require INCLUDE_PATH . '/class/charhandling.php';
         require INCLUDE_PATH . '/class/url.php';
         DB::init(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE);
         URL::init(HTTP_HOST, HTTPS_HOST);
     }
 }
Esempio n. 13
0
 public function __construct($REQUEST, $model, $view)
 {
     $UI = \CORE\UI::init();
     switch ($REQUEST->get('act')) {
         case 'km1':
             $UI->pos['main'] .= $view->km1($model);
             break;
         default:
             $UI->pos['main'] .= $view->main($model);
             break;
     }
     if (\CORE::init()->is_ajax()) {
         \DB::init()->close();
         exit;
     }
 }
Esempio n. 14
0
 public function __construct($REQUEST, $model, $view)
 {
     switch ($REQUEST->get('act')) {
         case 'login':
             $model->login();
             break;
         case 'logout':
             $model->logout();
             break;
         case 'profile':
             $view->profile($model);
             break;
         case 'change_password':
             $UI = \CORE\BC\UI::init();
             $UI->pos['main'] .= $view->change_pwd();
             break;
         case 'passwd':
             $model->passwd();
             break;
         case 'manage':
             if (isset($_GET['do'])) {
                 switch ($_GET['do']) {
                     case 'add':
                         $model->add();
                         break;
                     case 'edit':
                         $model->edit();
                         break;
                     case 'update':
                         $model->update();
                         break;
                     case 'del':
                         $model->del();
                         break;
                 }
             } else {
                 $UI = \CORE\BC\UI::init();
                 $UI->pos['main'] .= $view->manage($model);
             }
             break;
     }
     if (\CORE::init()->is_ajax()) {
         \DB::init()->close();
         exit;
     }
 }
Esempio n. 15
0
 public static function run()
 {
     require_once 'Database.php';
     require_once 'Route.php';
     require_once 'Load.php';
     require_once 'Engine.php';
     DB::init('localhost', 'icourse', 'root', '');
     Route::init();
     Load::$path = OBJ_ROOT . Route::$class . '.php';
     Load::init();
     foreach ($_REQUEST as $key => $val) {
         Engine::$oil[$key] = $val;
     }
     Engine::$class = Route::$class;
     Engine::$function = Route::$function;
     Engine::init();
 }
Esempio n. 16
0
 public function get_acl_db($all = false)
 {
     $acl = array();
     $DB = \DB::init();
     if ($DB->connect()) {
         //$where=" WHERE `acl-c`=:c";
         $sql = "SELECT * FROM `n-acl`;";
         $sth = $DB->dbh->prepare($sql);
         $sth->execute();
         $DB->query_count();
         if ($sth->rowCount() > 0) {
             while ($r = $sth->fetch()) {
                 $acl[$r['acl-type']] = array('c' => $r['acl-c'], 'act' => $r['acl-act'], 'xid' => $r['acl-xid'], 'val' => $r['acl-val']);
             }
         }
     }
     return $acl;
 }
Esempio n. 17
0
 static function install()
 {
     $DB = new DB();
     $DB->init();
     $DB->install();
 }
Esempio n. 18
0
 private static function init_db()
 {
     DB::init('mysql', self::$config['dbconfig']);
 }
Esempio n. 19
0
<?php

require 'class.DB.php';
define('HOST', 'localhost');
define('USER', 'db_class');
define('PASS', 'DQ82tAYWrPteWjyQ');
define('_DB_', 'proofs');
$db = DB::init();
$fields = array('date_insert' => date('Y-m-d H:i'), 'title' => 'Lorem Ipsum 2', 'body' => 'Nullam rutrum, orci vel euismod 
				 			viverra, orci odio rhoncus metus, ut 
				 			ullamcorper dui erat id massa. Vivamus 
				 			convallis, neque eu viverra sollicitudin, 
				 			libero neque fermentum turpis, ut rutrum 
				 			turpis arcu.', 'id_user' => 1);
$db->insert();
$db->tables('articles');
$db->fields($fields);
echo $db->execute(true) ? 'success!' : 'error!';
Esempio n. 20
0
error_reporting(E_ALL ^ E_NOTICE);
require "classes/DB.class.php";
require "classes/Chat.class.php";
require "classes/ChatBase.class.php";
require "classes/ChatLine.class.php";
require "classes/ChatUser.class.php";
session_name('webchat');
session_start();
if (get_magic_quotes_gpc()) {
    // If magic quotes is enabled, strip the extra slashes
    array_walk_recursive($_GET, create_function('&$v,$k', '$v = stripslashes($v);'));
    array_walk_recursive($_POST, create_function('&$v,$k', '$v = stripslashes($v);'));
}
try {
    // Connecting to the database
    DB::init($dbOptions);
    $response = array();
    // Handling the supported actions:
    switch ($_GET['action']) {
        case 'login':
            $response = Chat::login($_POST['name'], $_POST['email']);
            break;
        case 'checkLogged':
            $response = Chat::checkLogged();
            break;
        case 'logout':
            $response = Chat::logout();
            break;
        case 'submitChat':
            $response = Chat::submitChat($_POST['chatText']);
            break;
Esempio n. 21
0
 private function _init_db()
 {
     if ($this->init_db) {
         $driver = function_exists('mysql_connect') ? 'db_driver_mysql' : 'db_driver_mysqli';
         if (getglobal('config/db/slave')) {
             $driver = function_exists('mysql_connect') ? 'db_driver_mysql_slave' : 'db_driver_mysqli_slave';
         }
         DB::init($driver, $this->config['db']);
     }
 }
Esempio n. 22
0
/* Set the language */
Lang::set_language(Config::Get('SITE_LANGUAGE'));
error_reporting(Config::Get('ERROR_LEVEL'));
Debug::$debug_enabled = Config::Get('DEBUG_MODE');
if (Debug::$debug_enabled == true) {
    ini_set('log_errors', 'On');
    ini_set('display_errors', 'Off');
    ini_set('error_log', LOGS_PATH . '/errors.txt');
}
/* Init caching engine */
CodonCache::init($cache_settings);
if (DBASE_NAME != '' && DBASE_SERVER != '' && DBASE_NAME != 'DBASE_NAME') {
    require CLASS_PATH . DS . 'ezdb/ezdb.class.php';
    DB::$show_errors = Config::Get('DEBUG_MODE');
    DB::$throw_exceptions = false;
    DB::init(DBASE_TYPE);
    DB::set_log_errors(Config::Get('DEBUG_MODE'));
    DB::set_error_handler(array('Debug', 'db_error'));
    DB::set_caching(false);
    DB::$table_prefix = TABLE_PREFIX;
    DB::set_cache_dir(CACHE_PATH);
    DB::$DB->debug_all = false;
    if (Config::Get('DEBUG_MODE') == true) {
        DB::show_errors();
    } else {
        DB::hide_errors();
    }
    if (!DB::connect(DBASE_USER, DBASE_PASS, DBASE_NAME, DBASE_SERVER)) {
        Debug::showCritical(Lang::gs('database.connection.failed') . ' (' . DB::$errno . ': ' . DB::$error . ')');
        die;
    }
Esempio n. 23
0
 private function _init_db()
 {
     if ($this->init_db) {
         DB::init('db_driver_mysqli' . ($this->config['db']['slave'] ? '_slave' : ''), $this->config['db']);
         // $driver = function_exists('mysql_connect') ? 'db_driver_mysql' : 'db_driver_mysqli';
         // if(getglobal('config/db/slave')) {
         // $driver = function_exists('mysql_connect') ? 'db_driver_mysql_slave' : 'db_driver_mysqli_slave';
         // }
         // DB::init($driver, $this->config['db']);
     }
 }
Esempio n. 24
0
 public function delete($alias = '')
 {
     if (isset($_POST['alias'])) {
         $alias = trim($_POST['alias']);
     }
     if ($alias != '') {
         $DB = \DB::init();
         if ($DB->connect()) {
             $sql = "DELETE FROM `mt-translation` WHERE `t-alias`=:alias AND `t-module`=:module;";
             $sth = $DB->dbh->prepare($sql);
             $sth->execute(array('alias' => $alias, 'module' => $this->sel_module));
             $DB->query_count();
             \CORE::msg('info', 'deleted');
         }
     }
 }
Esempio n. 25
0
<?php

define(TPL_DIR, "application/views");
class DBConfig
{
    const HOST = "localhost";
    const PASS = "******";
    const USER = "******";
    const DBNAME = "board";
}
try {
    DB::init();
} catch (Exception $e) {
    error($e->getMessage());
}
Esempio n. 26
0
                    $init_table = false;
                    $setup = file_get_contents(ROOT . 'setup/db.sql');
                    if (self::$mysqli->query($setup)) {
                        continue;
                    } else {
                        if (self::$mysqli->errno == 1050) {
                            // Race condition: two threads tried to create the table at the same times
                            // -> Ignore error, table should be ready now.
                            continue;
                        }
                        error_log("Create table failed: (" . self::$mysqli->errno . ") " . self::$mysqli->error);
                        return false;
                    }
                }
                error_log("Prepare failed: (" . self::$mysqli->errno . ") " . self::$mysqli->error);
                return false;
            }
        }
        if (!$stmt->bind_param("sssssssssssss", $host, $path, $query, $uri, $referrer, $blocked_uri, $violated, $violated_directive, $original_policy, $source, $sample, $line, $browser)) {
            error_log("Binding parameters failed: (" . $stmt->errno . ") " . $stmt->error);
            return false;
        }
        if (!$stmt->execute()) {
            error_log("Execute failed: (" . $stmt->errno . ") " . $stmt->error);
            return false;
        }
        return true;
    }
}
DB::init(DB_HOST, DB_USER, DB_PW, DB_DB, DB_TABLE);
Esempio n. 27
0
 /**
  * 装载数据库
  * param	$link 数据库链接
  * param	$way 返回方式 为true时返回数据库链接对象
  * @E-mail	rushui@qq.com
  * @author	Rushui
  */
 public function database($link = 'default', $way = false)
 {
     $db = $this->_inc_config('database', true);
     $obj = DB::init($db[$link]['dbdriver'], $db[$link]);
     $obj->connect($db[$link]);
     //链接数据库
     if ($way === true) {
         return $obj;
     } else {
         $this->set_obj('db', $obj);
     }
 }
Esempio n. 28
0
/*
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/**
* @author Ronny Bansemer
*/
session_start();
if (!empty($_SESSION['unternehmenid'])) {
    require '../include/constants.php';
    require INCLUDE_PATH . '/class/roh/mailer.php';
    require INCLUDE_PATH . '/class/funclib.php';
    require INCLUDE_PATH . '/class/email.php';
    require INCLUDE_PATH . '/class/querybuild.php';
    require INCLUDE_PATH . '/class/database.php';
    require INCLUDE_PATH . '/class/charhandling.php';
    DB::init(MYSQL_HOST, MYSQL_USER, MYSQL_PASSWORD, MYSQL_DATABASE);
    $url = Funclib::trimValues($_GET);
    if (!empty($url['id'])) {
        $filename = 'all-statusmessages-from-sensor';
        $typ = 1;
        DB::query('SELECT
                        `sensorid`
                    FROM
                        `sensoren`
                    WHERE
                        `unternehmenid` = ?
                    AND
                        `sensorid` = ?', 2);
        DB::setParam($_SESSION['unternehmenid'], 'int');
        DB::setParam($url['id'], 'str');
        DB::exec();
Esempio n. 29
0
 /**
  * Write all of the SQL tables to the database
  * 
  * @return
  */
 public static function AddTables()
 {
     if (!DB::init($_POST['DBASE_TYPE'])) {
         self::$error = DB::$error;
         return false;
     }
     DB::set_caching(false);
     $ret = DB::connect($_POST['DBASE_USER'], $_POST['DBASE_PASS'], $_POST['DBASE_NAME'], $_POST['DBASE_SERVER']);
     if ($ret == false) {
         self::$error = DB::$error;
         return false;
     }
     if (!DB::select($_POST['DBASE_NAME'])) {
         self::$error = DB::$error;
         return false;
     }
     DB::$throw_exceptions = false;
     echo '<h2>Writing Tables...</h2>';
     $sqlLines = self::readSQLFile(SITE_ROOT . '/install/sql/install.sql', $_POST['TABLE_PREFIX']);
     foreach ($sqlLines as $sql) {
         DB::query($sql['sql']);
         if (DB::errno() != 0) {
             #echo 'failed - manually run this query: <br /><br />"'.$sql.'"';
             echo '<div id="error" style="text-align: left;">Writing "' . $sql['table'] . '" table... ';
             echo "<br /><br />" . DB::error();
             echo '</div>';
         }
     }
     echo "Wrote {$totalTables} tables<br />";
     echo '<h2>Populating Initial Data...</h2>';
     $sqlLines = self::readSQLFile(SITE_ROOT . '/install/fixtures/install.sql', $_POST['TABLE_PREFIX']);
     foreach ($sqlLines as $sql) {
         DB::query($sql['sql']);
         if (DB::errno() != 0) {
             echo '<div id="error" style="text-align: left;">Writing to "' . $sql['table'] . '" table... ';
             echo "<br /><br />" . DB::error();
             echo '</div>';
         }
     }
     return true;
 }
 private function _init_db()
 {
     if ($this->init_db) {
         $driver = 'db_driver_mysql';
         if (getglobal('config/db/slave')) {
             $driver = 'db_driver_mysql_slave';
         }
         DB::init($driver, $this->config['db']);
     }
 }