Exemplo n.º 1
0
 *   (at your option) any later version.
 *
**/
# Details for the grepper to pick up on
#name SQLite Database Module
#author Rob Lemley
#description Use a SQLite database (file-based, requires no additional database server)
#type database
#extension sqlite
# Must be here so 2.1 knows it can create and drop.
# Although preg_grep just looks for the create_bhdb stuff.
$dbmoduleversion = 2;
# Define what configuration you want. Key = what the dbconfig key will be. Value = array, with Data type (string / password) and description.
$dbconfigneeded = array("filename" => array("type" => "string", "name" => "SQLite Database Filename", "description" => "The filename of the SQLite database file.<br>You may leave it as the default unless you want more than one program sharing the same database.<br>If you use a relative filepath, it will be taken relative to the main ByteHoard directory.", "default" => "bytehoard.sqlite"), "prefix" => array("type" => "string", "name" => "Table Prefix", "description" => "The prefix ByteHoard should use on its tables. <br>Leave it as the default unless you're doing multiple installations using the same database.", "default" => "bh2_"));
# Dynamically load extension in case (this will do addition of .dll or .so and only load if needed)
bh_dl("sqlite");
function bhdb_sqlite_correct_filename($filename)
{
    if (substr($filename, 0, 1) == "/" || substr($filename, 1, 1) == ":") {
        return $filename;
    } else {
        return str_replace("//", "/", realpath(dirname(__FILE__) . "/../../") . "/" . $filename);
    }
}
function insert_bhdb($table, $values)
{
    global $dbconfig;
    # Login to MySQL database
    $dblink = sqlite_open(bhdb_sqlite_correct_filename($dbconfig['filename']));
    # Parse given variables into SQL statement.
    $sql = "INSERT INTO '" . $dbconfig['prefix'] . $table . "' ";
Exemplo n.º 2
0
if (IN_BH != 1) {
    header("Location: ../index.php");
    die;
}
# Details for the grepper to pick up on
#name MySQL Database Module (Native)
#author Andrew Godwin
#description Old, native version of the MySQL library. Use if you have problems with the new one.
#type database
#extension mysql
# Must be here so 2.1 knows it can create and drop.
# Although preg_grep just looks for the create_bhdb stuff.
$dbmoduleversion = 2;
# Define what configuration you want. Key = what the dbconfig key will be. Value = array, with Data type (string / password) and description.
$dbconfigneeded = array("host" => array("type" => "string", "name" => "MySQL Hostname", "description" => "The hostname of your MySQL server. If it's running on the same machine, this will be 'localhost'.", "default" => "localhost"), "username" => array("type" => "string", "name" => "MySQL Username", "description" => "The username you use to connect to this server."), "password" => array("type" => "password", "name" => "MySQL Password", "description" => "The password you use to connect to this server."), "db" => array("type" => "string", "name" => "MySQL Database", "description" => "The database you want ByteHoard to use."), "prefix" => array("type" => "string", "name" => "Table Prefix", "description" => "The prefix ByteHoard should use on its tables. <br>Leave it as the default unless you're doing multiple installations using the same database.", "default" => "bh2_"));
bh_dl("mysql");
function insert_bhdb($table, $values)
{
    global $dbconfig;
    # Login to MySQL database
    $dblink = mysql_connect($dbconfig['host'], $dbconfig['username'], $dbconfig['password']);
    # Select the database
    mysql_select_db($dbconfig['db']);
    # Parse given variables into SQL statement.
    $sql = "INSERT INTO `" . $dbconfig['prefix'] . $table . "` ";
    $csql = "( ";
    $vsql = " VALUES ( ";
    $n = 0;
    foreach ($values as $column => $data) {
        if ($n == 0) {
            $csql .= "`" . $column . "`";
Exemplo n.º 3
0
if (IN_BH != 1) {
    header("Location: ../index.php");
    die;
}
# Details for the grepper to pick up on
#name PostgreSQL Database Module (Alpha)
#author Andrew Godwin
#description Uses a PostgreSQL (local or remote) database to store configuration. <br>(Note: This module is alpha quality. Use at your own risk)
#type database
#extension pgsql
# Must be here so 2.1 knows it can create and drop.
# Although preg_grep just looks for the create_bhdb stuff.
$dbmoduleversion = 2;
# Define what configuration you want. Key = what the dbconfig key will be. Value = array, with Data type (string / password) and description.
$dbconfigneeded = array("host" => array("type" => "string", "name" => "PostgreSQL Hostname", "description" => "The hostname of your PostgreSQL server. If it's running on the same machine, this will be 'localhost'.", "default" => "localhost"), "username" => array("type" => "string", "name" => "PostgreSQL Username", "description" => "The username you use to connect to this server."), "password" => array("type" => "password", "name" => "PostgreSQL Password", "description" => "The password you use to connect to this server."), "db" => array("type" => "string", "name" => "PostgreSQL Database", "description" => "The database you want ByteHoard to use."), "prefix" => array("type" => "string", "name" => "Table Prefix", "description" => "The prefix ByteHoard should use on its tables. <br>Leave it as the default unless you're doing multiple installations using the same database.", "default" => "bh2_"));
bh_dl("pgsql");
# Load ADOdb
require_once realpath(dirname(__FILE__) . "/../adodb/adodb.inc.php");
function insert_bhdb($table, $values)
{
    global $dbconfig;
    # Create DSN
    $dsn = "postgres://" . $dbconfig['username'] . ":" . $dbconfig['password'] . "@" . $dbconfig['host'] . "/" . $dbconfig['db'];
    $db = NewADOConnection($dsn);
    # Parse given variables into SQL statement.
    $sql = "INSERT INTO " . $dbconfig['prefix'] . $table . " ";
    $csql = "( ";
    $vsql = " VALUES ( ";
    $n = 0;
    foreach ($values as $column => $data) {
        if ($n == 0) {