Exemple #1
0
 /**
 dcCore constructor inits everything related to Dotclear. It takes arguments
 to init database connection.
 
 @param	driver	<b>string</b>	Database driver name
 @param	host		<b>string</b>	Database hostname
 @param	db		<b>string</b>	Database name
 @param	user		<b>string</b>	Database username
 @param	password	<b>string</b>	Database password
 @param	prefix	<b>string</b>	DotClear tables prefix
 @param	persist	<b>boolean</b>	Persistent database connection
 */
 public function __construct($driver, $host, $db, $user, $password, $prefix, $persist)
 {
     $this->con = dbLayer::init($driver, $host, $db, $user, $password, $persist);
     # define weak_locks for mysql
     if ($this->con instanceof mysqlConnection) {
         mysqlConnection::$weak_locks = true;
     }
     $this->prefix = $prefix;
     $this->error = new dcError();
     $this->auth = $this->authInstance();
     $this->session = new sessionDB($this->con, $this->prefix . 'session', DC_SESSION_NAME, '', null, DC_ADMIN_SSL);
     $this->url = new urlHandler();
     $this->plugins = new dcModules($this);
     $this->rest = new dcRestServer($this);
     $this->addFormater('xhtml', create_function('$s', 'return $s;'));
     $this->addFormater('wiki', array($this, 'wikiTransform'));
 }
Exemple #2
0
 /**
 dcCore constructor inits everything related to Dotclear. It takes arguments
 to init database connection.
 
 @param	driver	<b>string</b>	Database driver name
 @param	host		<b>string</b>	Database hostname
 @param	db		<b>string</b>	Database name
 @param	user		<b>string</b>	Database username
 @param	password	<b>string</b>	Database password
 @param	prefix	<b>string</b>	DotClear tables prefix
 @param	persist	<b>boolean</b>	Persistent database connection
 */
 public function __construct($driver, $host, $db, $user, $password, $prefix, $persist)
 {
     if (defined('DC_START_TIME')) {
         $this->stime = DC_START_TIME;
     } else {
         $this->stime = microtime(true);
     }
     $this->con = dbLayer::init($driver, $host, $db, $user, $password, $persist);
     # define weak_locks for mysql
     if ($this->con instanceof mysqlConnection) {
         mysqlConnection::$weak_locks = true;
     } elseif ($this->con instanceof mysqliConnection) {
         mysqliConnection::$weak_locks = true;
     }
     # define searchpath for postgresql
     if ($this->con instanceof pgsqlConnection) {
         $searchpath = explode('.', $prefix, 2);
         if (count($searchpath) > 1) {
             $prefix = $searchpath[1];
             $sql = 'SET search_path TO ' . $searchpath[0] . ',public;';
             $this->con->execute($sql);
         }
     }
     $this->prefix = $prefix;
     $ttl = DC_SESSION_TTL;
     if (!is_null($ttl)) {
         if (substr(trim($ttl), 0, 1) != '-') {
             // Clearbricks requires negative session TTL
             $ttl = '-' . trim($ttl);
         }
     }
     $this->error = new dcError();
     $this->auth = $this->authInstance();
     $this->session = new sessionDB($this->con, $this->prefix . 'session', DC_SESSION_NAME, '', null, DC_ADMIN_SSL, $ttl);
     $this->url = new dcUrlHandlers();
     $this->plugins = new dcPlugins($this);
     $this->rest = new dcRestServer($this);
     $this->meta = new dcMeta($this);
     $this->log = new dcLog($this);
 }
<?php

include_once 'db.php';
$myDB = new dbLayer();
$id = $_POST['id'];
$sql = "SELECT * FROM {$myDB->table} where ID = '{$id}'";
$result = $myDB->queryTable($sql);
$row = $result->fetch_array();
$sql2 = "SELECT `Name` FROM Profiles";
$result2 = $myDB->queryTable($sql2);
$sql3 = "SELECT `Name` FROM Departments";
$result3 = $myDB->queryTable($sql3);
?>
 
<style>
#editData {
    border: 0px;
    width: 100%;
}
td {
    padding: 8px;
}
#saveEdit {
	border-radius: 5px;
	width: 120px;
}
input {
	padding: 4px;
}
select {
	padding: 4px;
<?php

include_once 'db.php';
$myDB = new dbLayer();
$sql = "SELECT * FROM " . $myDB->table . " where ID = '" . $_POST['id'] . "'";
$result = $myDB->queryTable($sql);
$row = $result->fetch_array();
$sql2 = "SELECT * FROM Users";
$result2 = $myDB->queryTable($sql2);
?>
 
<style>
#editData {
    border: 0px;
    width: 100%;
}
td {
    padding: 8px;
}
#saveEdit {
	border-radius: 5px;
	width: 120px;
}
input {
	padding: 4px;
	width: 220px;
}
select {
	padding: 4px;
	width: 220px;
}
 protected function db()
 {
     $db = dbLayer::init('mysql', $this->vars['db_host'], $this->vars['db_name'], $this->vars['db_user'], $this->vars['db_pwd']);
     $rs = $db->select("SHOW TABLES LIKE '" . $this->vars['db_prefix'] . "%'");
     if ($rs->isEmpty()) {
         throw new Exception(__('Dotclear tables not found'));
     }
     while ($rs->fetch()) {
         $this->has_table[$rs->f(0)] = true;
     }
     # Set this to read data as they were written in Dotclear 1
     try {
         $db->execute('SET NAMES DEFAULT');
     } catch (Exception $e) {
     }
     $db->execute('SET CHARACTER SET DEFAULT');
     $db->execute("SET COLLATION_CONNECTION = DEFAULT");
     $db->execute("SET COLLATION_SERVER = DEFAULT");
     $db->execute("SET CHARACTER_SET_SERVER = DEFAULT");
     $db->execute("SET CHARACTER_SET_DATABASE = DEFAULT");
     $this->post_count = $db->select('SELECT COUNT(post_id) FROM ' . $this->vars['db_prefix'] . 'post ')->f(0);
     return $db;
 }
<?php

include_once 'db.php';
$myDB = new dbLayer();
// construct the query to insert the values the user entered on the form
$sql = "update " . $myDB->table . " set Name = '" . $_POST['name'] . "' where ID = '" . $_POST['id'] . "'";
$myDB->updateTable($sql);
Exemple #7
0
if (!empty($_POST)) {
    try {
        if ($DBDRIVER == 'sqlite') {
            if (strpos($DBNAME, '/') === false) {
                $sqlite_db_directory = dirname(DC_RC_PATH) . '/../db/';
                files::makeDir($sqlite_db_directory, true);
                # Can we write sqlite_db_directory ?
                if (!is_writable($sqlite_db_directory)) {
                    throw new Exception(sprintf(__('Cannot write "%s" directory.'), path::real($sqlite_db_directory, false)));
                }
                $DBNAME = $sqlite_db_directory . $DBNAME;
            }
        }
        # Tries to connect to database
        try {
            $con = dbLayer::init($DBDRIVER, $DBHOST, $DBNAME, $DBUSER, $DBPASSWORD);
        } catch (Exception $e) {
            throw new Exception('<p>' . __($e->getMessage()) . '</p>');
        }
        # Checks system capabilites
        require dirname(__FILE__) . '/check.php';
        if (!dcSystemCheck($con, $_e)) {
            $can_install = false;
            throw new Exception('<p>' . __('Dotclear cannot be installed.') . '</p><ul><li>' . implode('</li><li>', $_e) . '</li></ul>');
        }
        # Check if dotclear is already installed
        $schema = dbSchema::init($con);
        if (in_array($DBPREFIX . 'version', $schema->getTables())) {
            throw new Exception(__('Dotclear is already installed.'));
        }
        # Does config.php.in exist?
}
if (!defined('CLEARBRICKS_PATH') || !is_dir(CLEARBRICKS_PATH)) {
    exit('No clearbricks path defined');
}
require CLEARBRICKS_PATH . '/_common.php';
$DBDRIVER = !empty($_POST['DBDRIVER']) ? $_POST['DBDRIVER'] : 'mysql';
$DBHOST = !empty($_POST['DBHOST']) ? $_POST['DBHOST'] : '';
$DBNAME = !empty($_POST['DBNAME']) ? $_POST['DBNAME'] : '';
$DBUSER = !empty($_POST['DBUSER']) ? $_POST['DBUSER'] : '';
$DBPASSWORD = !empty($_POST['DBPASSWORD']) ? base64_encode(stripslashes($_POST['DBPASSWORD'])) : '';
$DBPREFIX = !empty($_POST['DBPREFIX']) ? $_POST['DBPREFIX'] : 'bp_';
if (!empty($_POST)) {
    try {
        # Tries to connect to database
        try {
            $con = dbLayer::init($DBDRIVER, $DBHOST, $DBNAME, $DBUSER, base64_decode($DBPASSWORD));
        } catch (Exception $e) {
            throw new Exception('<p>' . T_($e->getMessage()) . '</p>');
        }
        # Checks system capabilites
        require dirname(__FILE__) . '/check.php';
        if (!dcSystemCheck($con, $_e)) {
            $can_install = false;
            throw new Exception('<p>' . T_('The Bilboplanet could not be installed.') . '</p><ul><li>' . implode('</li><li>', $_e) . '</li></ul>');
        }
        # Does config.php.default exist?
        $config_in = dirname(__FILE__) . '/../../inc/config.php.default';
        if (!is_file($config_in)) {
            throw new Exception(sprintf(T_('File %s does not exist.'), $config_in));
        }
        # Can we write config.php
Exemple #9
0
 /**
  *  Create a database connexion if none exists
  */
 private static function getConnection($parameters)
 {
     if (!self::$conf_loaded) {
         // @TODO : find a better way to include conf without define DC_RC_PATH
         define('DC_RC_PATH', $parameters['config_file']);
         include $parameters['config_file'];
         self::$conf_loaded = true;
         self::$prefix = DC_DBPREFIX;
         self::$session_name = DC_SESSION_NAME;
         self::$con = \dbLayer::init(DC_DBDRIVER, DC_DBHOST, DC_DBNAME, DC_DBUSER, DC_DBPASSWORD, DC_DBPERSIST);
     }
 }
<?php

include_once 'db.php';
$myDB = new dbLayer();
$sql = "SELECT * FROM " . $myDB->table . " where ID = '" . $_POST['id'] . "'";
$result = $myDB->queryTable($sql);
$row = $result->fetch_array();
?>
 
<style>
#editData {
    border: 0px;
    width: 100%;
}
td {
    padding: 8px;
}
#saveEdit {
	border-radius: 5px;
	width: 120px;
}
input {
	padding: 4px;
}
#delete {
	border-radius 5px;
}
</style>
<table id="editData">
<tr>
<td>ID</td>
<?php

include_once 'db.php';
$myDB = new dbLayer();
$sql = "SELECT * FROM " . $myDB->table . " where ID = '" . $_POST['id'] . "'";
$result = $myDB->queryTable($sql);
$row = $result->fetch_array();
$sql2 = "SELECT * FROM Profiles";
$result2 = $myDB->queryTable($sql2);
$sql3 = "SELECT * FROM Areas";
$result3 = $myDB->queryTable($sql3);
?>
 
<style>
#editData {
    border: 0px;
    width: 100%;
}
td {
    padding: 8px;
}
#saveEdit {
	border-radius: 5px;
	width: 120px;
}
input {
	padding: 4px;
	width: 256px;
}
select {
	padding: 4px;
 /**
 dcCore constructor inits everything related to Dotclear. It takes arguments
 to init database connection.
 
 @param	driver	<b>string</b>	Database driver name
 @param	host		<b>string</b>	Database hostname
 @param	db		<b>string</b>	Database name
 @param	user		<b>string</b>	Database username
 @param	password	<b>string</b>	Database password
 @param	prefix	<b>string</b>	DotClear tables prefix
 @param	persist	<b>boolean</b>	Persistent database connection
 */
 public function __construct($driver, $host, $db, $user, $password, $prefix, $persist)
 {
     $this->con = dbLayer::init($driver, $host, $db, $user, $password, $persist);
     # define weak_locks for mysql
     if ($this->con instanceof mysqlConnection) {
         mysqlConnection::$weak_locks = true;
     }
     $this->prefix = $prefix;
     $this->error = new dcError();
     $this->auth = $this->authInstance();
     $this->session = new sessionDB($this->con, $this->prefix . 'session', BP_SESSION_NAME, '', null, false);
     $this->url = new urlHandler();
     $this->rest = new dcRestServer($this);
     # Create the Hyla_Tpl object
     $this->tpl = new Hyla_Tpl();
     $this->tpl->setL10nCallback('T_');
 }