Esempio n. 1
1
 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'database', 'file');
     $this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
     $this->fmtDateTime = isset($config['formatDateTime']) ? $config['formatDateTime'] : 'U';
     if (isset($config['resource']) && $config['resource'] instanceof SQLite3) {
         $this->connection = $config['resource'];
     } else {
         try {
             $this->connection = new SQLite3($config['database']);
         } catch (Exception $e) {
             throw new DibiDriverException($e->getMessage(), $e->getCode());
         }
     }
     $this->dbcharset = empty($config['dbcharset']) ? 'UTF-8' : $config['dbcharset'];
     $this->charset = empty($config['charset']) ? 'UTF-8' : $config['charset'];
     if (strcasecmp($this->dbcharset, $this->charset) === 0) {
         $this->dbcharset = $this->charset = NULL;
     }
     // enable foreign keys support (defaultly disabled; if disabled then foreign key constraints are not enforced)
     $version = SQLite3::version();
     if ($version['versionNumber'] >= '3006019') {
         $this->query("PRAGMA foreign_keys = ON");
     }
 }
Esempio n. 2
1
 /**
  * Database version number
  *
  * @return	string
  */
 public function version()
 {
     if (isset($this->data_cache['version'])) {
         return $this->data_cache['version'];
     }
     $version = SQLite3::version();
     return $this->data_cache['version'] = $version['versionString'];
 }
Esempio n. 3
1
 public function testBatchInsert()
 {
     if (version_compare(\SQLite3::version()['versionString'], '3.7.11', '>=')) {
         $this->markTestSkipped('This test is only relevant for SQLite < 3.7.11');
     }
     $sql = $this->getQueryBuilder()->batchInsert('{{customer}} t', ['t.id', 't.name'], [[1, 'a'], [2, 'b']]);
     $this->assertEquals("INSERT INTO {{customer}} t (`t`.`id`, `t`.`name`) SELECT 1, 'a' UNION SELECT 2, 'b'", $sql);
 }
Esempio n. 4
1
 /**
  * returns an array with infos about the current database
  * The array returned should have tho following structure:
  * ["dbserver"]
  * ["dbclient"]
  * ["dbconnection"]
  *
  * @return mixed
  */
 public function getDbInfo()
 {
     $arrDB = $this->linkDB->version();
     $arrReturn = array();
     $arrReturn["dbdriver"] = "sqlite3-extension";
     $arrReturn["dbserver"] = "SQLite3 " . $arrDB["versionString"] . " " . $arrDB["versionNumber"];
     $arrReturn["dbclient"] = "";
     $arrReturn["dbconnection"] = "";
     return $arrReturn;
 }
Esempio n. 5
1
function _init()
{
    global $CRUD;
    $CRUD['TITLE'] = "CRUD APP";
    $CRUD['SELF'] = $_SERVER["SCRIPT_NAME"];
    // loose "index.php" if nec (regexes are fugly in php. Feh.)
    $CRUD["SELF"] = preg_replace('/([\\/\\\\])index\\.php$/i', '$1', $CRUD["SELF"]);
    foreach (array('DBVERSION', 'BUTTONS', 'HIDDENS', 'MESSAGES', 'ERRORS', 'CONTENT', 'PRECONTENT', 'POSTCONTENT', 'Atitle', 'Aartist', 'Alabel', 'Areleased_day', 'Areleased_month', 'Areleased_year', 'Ttrack_number', 'Ttitle', 'Tduration') as $v) {
        $CRUD[$v] = '';
    }
    switch (DBENGINE) {
        case 'sqlite3':
            try {
                $dbh = new PDO('sqlite:' . DBFILE, 'unused', 'unused');
                $dbh->sqliteCreateFunction('SEC_TO_TIME', 'sec_to_time', 1);
                // custom functions ...
                $dbh->sqliteCreateFunction('TIME_TO_SEC', 'time_to_sec', 1);
                $dbh->sqliteCreateAggregate('SUM_SEC_TO_TIME', 'sum_sec_to_time_step', 'sum_sec_to_time_finalize', 1);
                $CRUD['DBVERSION'] = SQLite3::version();
                $CRUD['DBVERSION'] = 'SQLite version ' . $CRUD['DBVERSION']['versionString'];
            } catch (PDOException $e) {
                error($e->getMessage());
            }
            break;
        case 'mysql':
            // connect to the database (persistent)
            try {
                $dbh = new PDO('mysql:host=localhost;dbname=' . MYSQLDB, MYSQLUSER, MYSQLPASS, array(PDO::ATTR_PERSISTENT => true));
                $sth = $dbh->query("SHOW VARIABLES WHERE variable_name = 'version'");
                $CRUD['DBVERSION'] = 'MySQL server version ' . $sth->fetchColumn(1);
                if ($dbh) {
                    set_mysql_album_len_function($dbh);
                }
            } catch (PDOException $e) {
                error($e->getMessage());
            }
            break;
        case 'pgsql':
            // connect to the database (persistent)
            try {
                $dbh = new PDO('pgsql:host=localhost;port=5432;dbname=' . PGSQLDB, PGSQLUSER, PGSQLPASS, array(PDO::ATTR_PERSISTENT => true));
                $dbh->exec("set client_encoding to 'latin1'");
                $sth = $dbh->query('SELECT VERSION()');
                $CRUD['DBVERSION'] = explode(' ', $sth->fetchColumn());
                $CRUD['DBVERSION'] = 'PostgreSQL server version ' . $CRUD['DBVERSION'][1];
            } catch (PDOException $e) {
                error($e->getMessage());
            }
            break;
        default:
            error('unsupported DBENGINE specified: ' . DBENGINE);
    }
    $CRUD['dbh'] = $dbh;
}
Esempio n. 6
1
 /**
  * {@inheritDoc}
  */
 public function sql_server_info($raw = false, $use_cache = true)
 {
     global $cache;
     if (!$use_cache || empty($cache) || ($this->sql_server_version = $cache->get('sqlite_version')) === false) {
         $version = \SQLite3::version();
         $this->sql_server_version = $version['versionString'];
         if (!empty($cache) && $use_cache) {
             $cache->put('sqlite_version', $this->sql_server_version);
         }
     }
     return $raw ? $this->sql_server_version : 'SQLite ' . $this->sql_server_version;
 }
    public function testNonDefaultPKOrder()
    {
        $version = \SQLite3::version();
        if (version_compare($version['versionString'], '3.7.16', '<')) {
            $this->markTestSkipped('This version of sqlite doesn\'t return the order of the Primary Key.');
        }
        $this->_conn->executeQuery(<<<EOS
CREATE TABLE non_default_pk_order (
    id INTEGER,
    other_id INTEGER,
    PRIMARY KEY(other_id, id)
)
EOS
);
        $tableIndexes = $this->_sm->listTableIndexes('non_default_pk_order');
        $this->assertEquals(1, count($tableIndexes));
        $this->assertArrayHasKey('primary', $tableIndexes, 'listTableIndexes() has to return a "primary" array key.');
        $this->assertEquals(array('other_id', 'id'), array_map('strtolower', $tableIndexes['primary']->getColumns()));
    }
Esempio n. 8
1
 /**
  * Generates a batch INSERT SQL statement.
  * For example,
  *
  * ~~~
  * $connection->createCommand()->batchInsert('user', ['name', 'age'], [
  *     ['Tom', 30],
  *     ['Jane', 20],
  *     ['Linda', 25],
  * ])->execute();
  * ~~~
  *
  * Note that the values in each row must match the corresponding column names.
  *
  * @param string $table the table that new rows will be inserted into.
  * @param array $columns the column names
  * @param array $rows the rows to be batch inserted into the table
  * @return string the batch INSERT SQL statement
  */
 public function batchInsert($table, $columns, $rows)
 {
     // SQLite supports batch insert natively since 3.7.11
     // http://www.sqlite.org/releaselog/3_7_11.html
     if (version_compare(\SQLite3::version()['versionString'], '3.7.11', '>=')) {
         return parent::batchInsert($table, $columns, $rows);
     }
     $schema = $this->db->getSchema();
     if (($tableSchema = $schema->getTableSchema($table)) !== null) {
         $columnSchemas = $tableSchema->columns;
     } else {
         $columnSchemas = [];
     }
     $values = [];
     foreach ($rows as $row) {
         $vs = [];
         foreach ($row as $i => $value) {
             if (!is_array($value) && isset($columnSchemas[$columns[$i]])) {
                 $value = $columnSchemas[$columns[$i]]->dbTypecast($value);
             }
             if (is_string($value)) {
                 $value = $schema->quoteValue($value);
             } elseif ($value === false) {
                 $value = 0;
             } elseif ($value === null) {
                 $value = 'NULL';
             }
             $vs[] = $value;
         }
         $values[] = implode(', ', $vs);
     }
     foreach ($columns as $i => $name) {
         $columns[$i] = $schema->quoteColumnName($name);
     }
     return 'INSERT INTO ' . $schema->quoteTableName($table) . ' (' . implode(', ', $columns) . ') SELECT ' . implode(' UNION SELECT ', $values);
 }
Esempio n. 9
1
 public function GetDBVer($dbname)
 {
     if (empty($dbname)) {
         return '错误';
     }
     switch ($dbname) {
         case 'mysql':
             if (function_exists("mysql_get_server_info")) {
                 $s = @mysql_get_server_info();
                 $s = $s ? '&nbsp; mysql_server 版本:' . $s : '';
                 $c = @mysql_get_client_info();
                 $c = $c ? '&nbsp; mysql_client 版本:' . $c : '';
                 return $s . $c;
             }
             return '';
             break;
         case 'sqlite':
             if (extension_loaded('sqlite3')) {
                 $sqliteVer = SQLite3::version();
                 $str = '<font color=green>√</font>';
                 $str .= 'SQLite3 Ver' . $sqliteVer['versionString'];
             } else {
                 $str = $this->isfun('sqlite_close');
                 if (strpos($str, '√') !== false) {
                     $str .= '&nbsp; 版本:' . sqlite_libversion();
                 }
             }
             return $str;
             break;
         default:
             return '';
             break;
     }
 }
Esempio n. 10
0
 function ServerInfo()
 {
     $version = SQLite3::version();
     $arr['version'] = $version['versionString'];
     $arr['description'] = 'SQLite 3';
     return $arr;
 }
 /**
  * Initializes db specific domain mapping.
  */
 protected function initialize()
 {
     parent::initialize();
     $version = \SQLite3::version();
     $version = $version['versionString'];
     $this->foreignKeySupport = version_compare($version, '3.6.19') >= 0;
     $this->setSchemaDomainMapping(new Domain(PropelTypes::NUMERIC, 'DECIMAL'));
     $this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARCHAR, 'MEDIUMTEXT'));
     $this->setSchemaDomainMapping(new Domain(PropelTypes::DATE, 'DATETIME'));
     $this->setSchemaDomainMapping(new Domain(PropelTypes::BINARY, 'BLOB'));
     $this->setSchemaDomainMapping(new Domain(PropelTypes::VARBINARY, 'MEDIUMBLOB'));
     $this->setSchemaDomainMapping(new Domain(PropelTypes::LONGVARBINARY, 'LONGBLOB'));
     $this->setSchemaDomainMapping(new Domain(PropelTypes::BLOB, 'LONGBLOB'));
     $this->setSchemaDomainMapping(new Domain(PropelTypes::CLOB, 'LONGTEXT'));
     $this->setSchemaDomainMapping(new Domain(PropelTypes::OBJECT, 'MEDIUMTEXT'));
     $this->setSchemaDomainMapping(new Domain(PropelTypes::PHP_ARRAY, 'MEDIUMTEXT'));
     $this->setSchemaDomainMapping(new Domain(PropelTypes::ENUM, 'TINYINT'));
 }
Esempio n. 12
0
 public function getAttribute($id)
 {
     switch ($id) {
         case self::ATTR_CLIENT_VERSION:
         case self::ATTR_SERVER_VERSION:
             $v = SQLite3::version();
             return $v['versionString'];
     }
     return "";
 }
 public function getDatabaseVersion($databaseConfig)
 {
     $version = 0;
     if (class_exists('SQLite3')) {
         $info = SQLite3::version();
         if ($info && isset($info['versionString'])) {
             $version = trim($info['versionString']);
         }
     } else {
         // Fallback to using sqlite_version() query
         $file = $databaseConfig['path'] . '/' . $databaseConfig['database'];
         $file = preg_replace('/\\/$/', '', $file);
         $conn = @new PDO("sqlite:{$file}");
         if ($conn) {
             $result = @$conn->query('SELECT sqlite_version()');
             $version = $result->fetchColumn();
         }
     }
     return $version;
 }
    <td>dBASE 数据库:</td>
    <td><?php 
echo isfun("dbase_close");
?>
</td>
    <td>mSQL 数据库:</td>
    <td><?php 
echo isfun("msql_close");
?>
</td>
  </tr>
  <tr>
    <td>SQLite 数据库:</td>
    <td><?php 
if (extension_loaded('sqlite3')) {
    $sqliteVer = SQLite3::version();
    echo '<font color=green>√</font> ';
    echo "SQLite3 Ver ";
    echo $sqliteVer[versionString];
} else {
    echo isfun("sqlite_close");
    if (isfun("sqlite_close") == '<font color="green">√</font>') {
        echo "&nbsp; 版本: " . @sqlite_libversion();
    }
}
?>
</td>
    <td>Hyperwave 数据库:</td>
    <td><?php 
echo isfun("hw_close");
?>
Esempio n. 15
0
 function get_version()
 {
     $info = SQLite3::version();
     return array('name' => 'SQLite3', 'version' => $info['versionString']);
 }
Esempio n. 16
0
$stmt = $db->prepare("SELECT * FROM foo WHERE bar = :id");
VS($stmt->paramcount(), 1);
$id = "DEF";
VERIFY($stmt->bindvalue(":id", $id, SQLITE3_TEXT));
$id = "ABC";
$res = $stmt->execute();
VS($res->fetcharray(SQLITE3_NUM), array("DEF"));
VERIFY($stmt->clear());
VERIFY($stmt->reset());
$id = "DEF";
VERIFY($stmt->bindparam(":id", $id, SQLITE3_TEXT));
$id = "ABC";
$res = $stmt->execute();
VS($res->fetcharray(SQLITE3_NUM), array("ABC"));
VERIFY($db->createfunction("tolower", "lower", 1));
$res = $db->query("SELECT tolower(bar) FROM foo");
VS($res->fetcharray(SQLITE3_NUM), array("abc"));
VERIFY($db->createaggregate("sumlen", "sumlen_step", "sumlen_fini", 1));
$res = $db->query("SELECT sumlen(bar) FROM foo");
VS($res->fetcharray(SQLITE3_NUM), array(6));
// Since minor version can change frequently, just test the major version
VS($db->version()['versionString'][0], "3");
VERIFY((int) $db->version()['versionNumber'] > (int) 3000000);
$db->close();
unlink(":memory:test");
// Check that a PHP Exception is thrown for nonexistant databases
try {
    new SQLite3('/' . uniqid('random', true) . '/db');
} catch (Exception $e) {
    var_dump(true);
}
Esempio n. 17
0
function _init()
{
    global $SID;
    global $db_list;
    $default_db = $db_list[0];
    // initialize display vars
    foreach (array('MESSAGES', 'ERRORS', 'CONTENT', 'SQLfield') as $v) {
        $SID[$v] = '';
    }
    // connect to the database (persistent)
    $database = isset($_REQUEST['select_database']) ? $_REQUEST['select_database'] : $default_db;
    if ($database == '--NONE--') {
        $database = $default_db;
    }
    $SID['utf8'] = FALSE;
    try {
        switch (DBENGINE) {
            case 'sqlite3':
                // don't add the DBDIR to :memory: you'll create a file
                if ($database == ':memory:') {
                    $dbh = new PDO('sqlite::memory:', 'unused', 'unused');
                } else {
                    $dbh = new PDO('sqlite:' . implode('/', array(DBDIR, $database)), 'unused', 'unused');
                }
                $dbh->sqliteCreateFunction('SEC_TO_TIME', 'sec_to_time', 1);
                // custom functions ...
                $dbh->sqliteCreateFunction('TIME_TO_SEC', 'time_to_sec', 1);
                $dbh->sqliteCreateAggregate('SUM_SEC_TO_TIME', 'sum_sec_to_time_step', 'sum_sec_to_time_finalize', 1);
                $dbh->sqliteCreateFunction('REPLACE_REGEX', 'replace_regex', 3);
                $dbh->sqliteCreateAggregate('AVG_LENGTH', 'avg_length_step', 'avg_length_finalize', 1);
                $SID['DBVERSION'] = SQLite3::version();
                $SID['DBVERSION'] = 'SQLite version ' . $SID['DBVERSION']['versionString'];
                $SID['utf8'] = TRUE;
                break;
            case 'pgsql':
                if ($database == '--NONE--') {
                    $database = 'test';
                }
                $dbh = new PDO('pgsql:host=localhost;port=5432;dbname=' . $database, PGSQLUSER, PGSQLPASS, array(PDO::ATTR_PERSISTENT => true));
                $dbh->exec("set client_encoding to 'latin1'");
                $sth = $dbh->query('SELECT VERSION()');
                $SID['DBVERSION'] = explode(' ', $sth->fetchColumn());
                $SID['DBVERSION'] = 'PostgreSQL server version ' . $SID['DBVERSION'][1];
                break;
            case 'mysql':
                if ($database == '--NONE--') {
                    $database = '';
                }
                $dbh = new PDO('mysql:host=localhost;dbname=' . $database, MYSQLUSER, MYSQLPASS, array(PDO::ATTR_PERSISTENT => true));
                $dbh->exec('set character_set_client = utf8');
                $dbh->exec('set character_set_connection = utf8');
                $dbh->exec('set character_set_database = utf8');
                $dbh->exec('set character_set_results = utf8');
                $dbh->exec('set character_set_server = utf8');
                $sth = $dbh->query("SHOW VARIABLES WHERE Variable_name = 'version'");
                $SID['DBVERSION'] = 'MySQL server version ' . $sth->fetchColumn(1);
                $SID['utf8'] = TRUE;
                break;
            default:
                error('unsupported DBENGINE: ' . DBENGINE);
        }
    } catch (PDOException $e) {
        error("Error while constructing PDO object: " . $e->getMessage());
    }
    if ($dbh) {
        // set exception mode for errors (why is this not the default?)
        // this is far more portable for different DB engines than trying to
        // parse error codes
        $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $SID['dbh'] = $dbh;
    } else {
        exit;
    }
    // try to set the timezone to UTC for mysql
    // ignore error -- TZ support not installed in default win xampp
    if ($dbh && DBENGINE == 'mysql') {
        try {
            $dbh->exec('set time_zone = UTC');
        } catch (PDOException $e) {
            // ignore
        }
    }
    $SID['TITLE'] = "SQL Demo";
    $SID['SELF'] = $_SERVER["SCRIPT_NAME"];
    $SID['DATABASE_SELECT_LIST'] = database_select_list($database);
    // fixup missing common characters from the PHP entity translation table
    // (this is only used for latin1 conversions)
    $SID['xlat'] = get_html_translation_table(HTML_ENTITIES, ENT_NOQUOTES);
    $SID['xlat'][chr(130)] = '&sbquo;';
    // Single Low-9 Quotation Mark
    $SID['xlat'][chr(131)] = '&fnof;';
    // Latin Small Letter F With Hook
    $SID['xlat'][chr(132)] = '&bdquo;';
    // Double Low-9 Quotation Mark
    $SID['xlat'][chr(133)] = '&hellip;';
    // Horizontal Ellipsis
    $SID['xlat'][chr(136)] = '&circ;';
    // Modifier Letter Circumflex Accent
    $SID['xlat'][chr(138)] = '&Scaron;';
    // Latin Capital Letter S With Caron
    $SID['xlat'][chr(139)] = '&lsaquo;';
    // Single Left-Pointing Angle Quotation Mark
    $SID['xlat'][chr(140)] = '&OElig;';
    // Latin Capital Ligature OE
    $SID['xlat'][chr(145)] = '&lsquo;';
    // Left Single Quotation Mark
    $SID['xlat'][chr(146)] = '&rsquo;';
    // Right Single Quotation Mark
    $SID['xlat'][chr(147)] = '&ldquo;';
    // Left Double Quotation Mark
    $SID['xlat'][chr(148)] = '&rdquo;';
    // Right Double Quotation Mark
    $SID['xlat'][chr(149)] = '&bull;';
    // Bullet
    $SID['xlat'][chr(150)] = '&ndash;';
    // En Dash
    $SID['xlat'][chr(151)] = '&mdash;';
    // Em Dash
    $SID['xlat'][chr(152)] = '&tilde;';
    // Small Tilde
    $SID['xlat'][chr(154)] = '&scaron;';
    // Latin Small Letter S With Caron
    $SID['xlat'][chr(155)] = '&rsaquo;';
    // Single Right-Pointing Angle Quotation Mark
    $SID['xlat'][chr(156)] = '&oelig;';
    // Latin Small Ligature OE
    $SID['xlat'][chr(159)] = '&Yuml;';
    // Latin Capital Letter Y With Diaeresis
    // loose "index.php" if nec (regexes are fugly in php. Feh.)
    $SID["SELF"] = preg_replace('/([\\/\\\\])index\\.php$/i', '$1', $SID["SELF"]);
}
Esempio n. 18
0
function checkSQLite3()
{
    // Check SQLite3 Class
    if (class_exists('SQLite3')) {
        // Version
        $_GET['sqlite3_version'] = SQLite3::version();
        echo <<<HTML
<tr>
<td class="content_key yes c">SQLite3</td>
<td class="content_value yes c">{$_GET['sqlite3_version']['versionString']}</td>
<td class="content_desc yes r">Your server supports SQLite3.</td>
<td class="content_icon yes"><img src="help.php?load=img_check" class="icon" alt="Supported" /></td>
</tr>

HTML;
    } else {
        echo <<<HTML
<tr>
<td class="content_key no c">SQLite3</td>
<td class="content_value no c">N/A</td>
<td class="content_desc no r">Your server does not support SQLite3.</td>
<td class="content_icon no"><img src="help.php?load=img_cross" class="icon" alt="Not Supported"></td>
</tr>

HTML;
    }
}
Esempio n. 19
0
 /**
  * return version info of connection driver
  * @return string
  */
 public function driver_version()
 {
     $v = \SQLite3::version();
     return $v['versionString'];
 }
Esempio n. 20
0
NotSupportedException("PHP extension 'sqlite3' is not loaded.");}}function
connect(array&$config){DibiConnection::alias($config,'database','file');$this->fmtDate=isset($config['formatDate'])?$config['formatDate']:'U';$this->fmtDateTime=isset($config['formatDateTime'])?$config['formatDateTime']:'U';if(isset($config['resource'])&&$config['resource']instanceof
SQLite3){$this->connection=$config['resource'];}else
try{$this->connection=new
SQLite3($config['database']);}catch(Exception$e){throw
new
DibiDriverException($e->getMessage(),$e->getCode());}$this->dbcharset=empty($config['dbcharset'])?'UTF-8':$config['dbcharset'];$this->charset=empty($config['charset'])?'UTF-8':$config['charset'];if(strcasecmp($this->dbcharset,$this->charset)===0){$this->dbcharset=$this->charset=NULL;}$version=SQLite3::version();if($version['versionNumber']>='3006019'){$this->query("PRAGMA foreign_keys = ON");}}function
Esempio n. 21
0
function CheckServer()
{
    global $zbp;
    global $CheckResult;
    $CheckResult = array('server' => array(GetVars('SERVER_SOFTWARE', 'SERVER'), bingo), 'phpver' => array(PHP_VERSION, ''), 'zbppath' => array($zbp->path, bingo), 'gd2' => array('', ''), 'mysql' => array('', ''), 'mysqli' => array('', ''), 'pdo_mysql' => array('', ''), 'sqlite' => array('', ''), 'sqlite3' => array('', ''), 'pdo_sqlite' => array('', ''), 'pgsql' => array('', ''), 'pdo_pgsql' => array('', ''), 'zb_users' => array('', ''), 'cache' => array('', ''), 'data' => array('', ''), 'include' => array('', ''), 'theme' => array('', ''), 'plugin' => array('', ''), 'upload' => array('', ''), 'c_option.php' => array('', ''), 'curl' => array($zbp->lang['zb_install']['connect_appcenter'], ''), 'allow_url_fopen' => array($zbp->lang['zb_install']['connect_appcenter'], ''), 'gethostbyname' => array($zbp->lang['zb_install']['whois_dns'], ''));
    if (version_compare(PHP_VERSION, '5.2.0') >= 0) {
        $CheckResult['phpver'][1] = bingo;
    } else {
        $CheckResult['phpver'][1] = error;
    }
    if (function_exists("gd_info")) {
        $info = gd_info();
        $CheckResult['gd2'][0] = $info['GD Version'];
        $CheckResult['gd2'][1] = $CheckResult['gd2'][0] ? bingo : error;
    }
    if (function_exists("mysql_get_client_info")) {
        $CheckResult['mysql'][0] = strtok(mysql_get_client_info(), '$');
        $CheckResult['mysql'][1] = $CheckResult['mysql'][0] ? bingo : error;
    }
    if (function_exists("mysqli_get_client_info")) {
        $CheckResult['mysqli'][0] = strtok(mysqli_get_client_info(), '$');
        $CheckResult['mysqli'][1] = $CheckResult['mysqli'][0] ? bingo : error;
    }
    if (class_exists("PDO", false)) {
        if (extension_loaded('pdo_mysql')) {
            //$pdo = new PDO( 'mysql:');
            $v = ' ';
            //strtok($pdo->getAttribute(PDO::ATTR_CLIENT_VERSION),'$');
            $pdo = null;
            $CheckResult['pdo_mysql'][0] = $v;
            $CheckResult['pdo_mysql'][1] = $CheckResult['pdo_mysql'][0] ? bingo : error;
        }
        if (extension_loaded('pdo_sqlite')) {
            //$pdo = new PDO('sqlite::memory:');
            $v = ' ';
            //$pdo->getAttribute(PDO::ATTR_CLIENT_VERSION);
            $pdo = null;
            $CheckResult['pdo_sqlite'][0] = $v;
            $CheckResult['pdo_sqlite'][1] = $CheckResult['pdo_sqlite'][0] ? bingo : error;
        }
        if (extension_loaded('pdo_pgsql')) {
            $v = ' ';
            $pdo = null;
            $CheckResult['pdo_pgsql'][0] = $v;
            $CheckResult['pdo_pgsql'][1] = $CheckResult['pdo_pgsql'][0] ? bingo : error;
        }
    }
    if (defined("PGSQL_STATUS_STRING")) {
        $CheckResult['pgsql'][0] = PGSQL_STATUS_STRING;
        $CheckResult['pgsql'][1] = $CheckResult['pgsql'][0] ? bingo : error;
    }
    if (function_exists("sqlite_libversion")) {
        $CheckResult['sqlite'][0] = sqlite_libversion();
        $CheckResult['sqlite'][1] = $CheckResult['sqlite'][0] ? bingo : error;
    }
    if (class_exists('SQLite3', false)) {
        $info = SQLite3::version();
        $CheckResult['sqlite3'][0] = $info['versionString'];
        $CheckResult['sqlite3'][1] = $CheckResult['sqlite3'][0] ? bingo : error;
    }
    getRightsAndExport('', 'zb_users');
    getRightsAndExport('zb_users/', 'cache');
    getRightsAndExport('zb_users/', 'data');
    getRightsAndExport('zb_users/', 'theme');
    getRightsAndExport('zb_users/', 'plugin');
    getRightsAndExport('zb_users/', 'upload');
    //getRightsAndExport('zb_users/','c_option.php');
    $CheckResult['curl'][1] = function_exists('curl_init') ? bingo : error;
    $CheckResult['allow_url_fopen'][1] = (bool) ini_get('allow_url_fopen') ? bingo : error;
    $CheckResult['gethostbyname'][1] = function_exists('gethostbyname') ? bingo : error;
    $CheckResult['simplexml_import_dom'][1] = function_exists('simplexml_import_dom') ? bingo : error;
}
Esempio n. 22
0
     echo "class='tab'";
 }
 echo ">Vacuum</a>";
 echo "<div style='clear:both;'></div>";
 echo "<div id='main'>";
 if ($view == "structure") {
     echo "<b>Database name</b>: " . $db->getName() . "<br/>";
     echo "<b>Path to database</b>: " . $db->getPath() . "<br/>";
     echo "<b>Size of database</b>: " . $db->getSize() . "<br/>";
     echo "<b>Database last modified</b>: " . $db->getDate() . "<br/>";
     if ($db->getType() == "SQLiteDatabase") {
         echo "<b>SQLite version</b>: " . sqlite_libversion() . "<br/>";
         echo "<b>SQLite encoding</b>: " . sqlite_libencoding() . "<br/>";
     }
     if ($db->getType() == "SQLite3") {
         echo "<b>SQLite version</b>: " . SQLite3::version() . "<br/>";
     } else {
         echo "<b>SQLite version</b>: " . $db->getVersion() . "<br/>";
     }
     echo "<b>SQLite extension</b>: " . $db->getType() . "<br/>";
     echo "<b>PHP version</b>: " . phpversion() . "<br/><br/>";
     $query = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name";
     $result = $db->selectArray($query);
     $j = 0;
     for ($i = 0; $i < sizeof($result); $i++) {
         if (substr($result[$i]['name'], 0, 7) != "sqlite_" && $result[$i]['name'] != "") {
             $j++;
         }
     }
     if ($j == 0) {
         echo "No tables in database.<br/><br/>";
 public function getVersion()
 {
     $version = SQLite3::version();
     return trim($version['versionString']);
 }
Esempio n. 24
0
        print "<td style=\" color: #00ff00; \">OK";
    }
} else {
    print "<td style=\" color: #00ff00; \">OK";
}
umask($oldumask);
print "</td></tr>\n<tr><td>Checking SQLite 2 ...</td>";
if (function_exists('sqlite_escape_string')) {
    print "<td style=\" color: #00ff00; \">Installed, version " . sqlite_libversion();
} else {
    print "<td style=\" color: #ff0000; \">No SQLite 2 installed!";
    //	$ok=false;
}
print "</td></tr>\n<tr><td>Checking SQLite 3 ...</td>";
if (defined('SQLITE3_ASSOC')) {
    $res = SQLite3::version();
    print "<td style=\" color: #00ff00; \">Installed, version " . $res['versionString'];
} else {
    print "<td style=\" color: #ff0000; \">No SQLite 3 installed!";
    //	$ok=false;
}
print "</td></tr>\n<tr><td>Creating data/index.html...</td>";
if ($fp = @fopen("../data/index.html", "w")) {
    fwrite($fp, "<html><head><meta http-equiv=\"refresh\" content=\"0;URL=../index.php\" /></head><body></body></html>");
    fclose($fp);
    print "<td style=\" color: #00ff00; \">data/index.html created";
} else {
    print "<td style=\" color: #ff0000; \">Could not create data/index.html!";
    $ok = false;
}
print "</td></tr>\n<tr><td>Creating galeries/index.html...</td>";
Esempio n. 25
0
 public function version($v = 'versionString')
 {
     if (!empty($this->connect)) {
         $version = SQLite3::version();
         return $version[$v];
     } else {
         return false;
     }
 }
/**
* Used to test whether we are able to connect to the database the user has specified
* and identify any problems (eg there are already tables with the names we want to use
* @param	array	$dbms should be of the format of an element of the array returned by {@link get_available_dbms get_available_dbms()}
*					necessary extensions should be loaded already
*/
function connect_check_db($error_connect, &$error, $dbms_details, $table_prefix, $dbhost, $dbuser, $dbpasswd, $dbname, $dbport, $prefix_may_exist = false, $load_dbal = true, $unicode_check = true)
{
    global $phpbb_root_path, $phpEx, $config, $lang;
    $dbms = $dbms_details['DRIVER'];
    // Instantiate it and set return on error true
    $db = new $dbms();
    $db->sql_return_on_error(true);
    // Check that we actually have a database name before going any further.....
    if ($dbms_details['DRIVER'] != 'phpbb\\db\\driver\\sqlite' && $dbms_details['DRIVER'] != 'phpbb\\db\\driver\\sqlite3' && $dbms_details['DRIVER'] != 'phpbb\\db\\driver\\oracle' && $dbname === '') {
        $error[] = $lang['INST_ERR_DB_NO_NAME'];
        return false;
    }
    // Make sure we don't have a daft user who thinks having the SQLite database in the forum directory is a good idea
    if (($dbms_details['DRIVER'] == 'phpbb\\db\\driver\\sqlite' || $dbms_details['DRIVER'] == 'phpbb\\db\\driver\\sqlite3') && stripos(phpbb_realpath($dbhost), phpbb_realpath('../')) === 0) {
        $error[] = $lang['INST_ERR_DB_FORUM_PATH'];
        return false;
    }
    // Check the prefix length to ensure that index names are not too long and does not contain invalid characters
    switch ($dbms_details['DRIVER']) {
        case 'phpbb\\db\\driver\\mysql':
        case 'phpbb\\db\\driver\\mysqli':
            if (strspn($table_prefix, '-./\\') !== 0) {
                $error[] = $lang['INST_ERR_PREFIX_INVALID'];
                return false;
            }
            // no break;
        // no break;
        case 'phpbb\\db\\driver\\postgres':
            $prefix_length = 36;
            break;
        case 'phpbb\\db\\driver\\mssql':
        case 'phpbb\\db\\driver\\mssql_odbc':
        case 'phpbb\\db\\driver\\mssqlnative':
            $prefix_length = 90;
            break;
        case 'phpbb\\db\\driver\\sqlite':
        case 'phpbb\\db\\driver\\sqlite3':
            $prefix_length = 200;
            break;
        case 'phpbb\\db\\driver\\oracle':
            $prefix_length = 6;
            break;
    }
    if (strlen($table_prefix) > $prefix_length) {
        $error[] = sprintf($lang['INST_ERR_PREFIX_TOO_LONG'], $prefix_length);
        return false;
    }
    // Try and connect ...
    if (is_array($db->sql_connect($dbhost, $dbuser, $dbpasswd, $dbname, $dbport, false, true))) {
        $db_error = $db->sql_error();
        $error[] = $lang['INST_ERR_DB_CONNECT'] . '<br />' . ($db_error['message'] ? utf8_convert_message($db_error['message']) : $lang['INST_ERR_DB_NO_ERROR']);
    } else {
        // Likely matches for an existing phpBB installation
        if (!$prefix_may_exist) {
            $temp_prefix = strtolower($table_prefix);
            $table_ary = array($temp_prefix . 'attachments', $temp_prefix . 'config', $temp_prefix . 'sessions', $temp_prefix . 'topics', $temp_prefix . 'users');
            $tables = get_tables($db);
            $tables = array_map('strtolower', $tables);
            $table_intersect = array_intersect($tables, $table_ary);
            if (sizeof($table_intersect)) {
                $error[] = $lang['INST_ERR_PREFIX'];
            }
        }
        // Make sure that the user has selected a sensible DBAL for the DBMS actually installed
        switch ($dbms_details['DRIVER']) {
            case 'phpbb\\db\\driver\\mysqli':
                if (version_compare(mysqli_get_server_info($db->get_db_connect_id()), '4.1.3', '<')) {
                    $error[] = $lang['INST_ERR_DB_NO_MYSQLI'];
                }
                break;
            case 'phpbb\\db\\driver\\sqlite':
                if (version_compare(sqlite_libversion(), '2.8.2', '<')) {
                    $error[] = $lang['INST_ERR_DB_NO_SQLITE'];
                }
                break;
            case 'phpbb\\db\\driver\\sqlite3':
                $version = \SQLite3::version();
                if (version_compare($version['versionString'], '3.6.15', '<')) {
                    $error[] = $lang['INST_ERR_DB_NO_SQLITE3'];
                }
                break;
            case 'phpbb\\db\\driver\\oracle':
                if ($unicode_check) {
                    $sql = "SELECT *\n\t\t\t\t\t\tFROM NLS_DATABASE_PARAMETERS\n\t\t\t\t\t\tWHERE PARAMETER = 'NLS_RDBMS_VERSION'\n\t\t\t\t\t\t\tOR PARAMETER = 'NLS_CHARACTERSET'";
                    $result = $db->sql_query($sql);
                    while ($row = $db->sql_fetchrow($result)) {
                        $stats[$row['parameter']] = $row['value'];
                    }
                    $db->sql_freeresult($result);
                    if (version_compare($stats['NLS_RDBMS_VERSION'], '9.2', '<') && $stats['NLS_CHARACTERSET'] !== 'UTF8') {
                        $error[] = $lang['INST_ERR_DB_NO_ORACLE'];
                    }
                }
                break;
            case 'phpbb\\db\\driver\\postgres':
                if ($unicode_check) {
                    $sql = "SHOW server_encoding;";
                    $result = $db->sql_query($sql);
                    $row = $db->sql_fetchrow($result);
                    $db->sql_freeresult($result);
                    if ($row['server_encoding'] !== 'UNICODE' && $row['server_encoding'] !== 'UTF8') {
                        $error[] = $lang['INST_ERR_DB_NO_POSTGRES'];
                    }
                }
                break;
        }
    }
    if ($error_connect && (!isset($error) || !sizeof($error))) {
        return true;
    }
    return false;
}
Esempio n. 27
0
        try {
            $config->set('nom_asso', Utils::post('nom_asso'));
            $config->set('email_asso', Utils::post('email_asso'));
            $config->set('adresse_asso', Utils::post('adresse_asso'));
            $config->set('site_asso', Utils::post('site_asso'));
            $config->set('email_envoi_automatique', Utils::post('email_envoi_automatique'));
            $config->set('accueil_wiki', Utils::post('accueil_wiki'));
            $config->set('accueil_connexion', Utils::post('accueil_connexion'));
            $config->set('categorie_membres', Utils::post('categorie_membres'));
            $config->set('champ_identite', Utils::post('champ_identite'));
            $config->set('champ_identifiant', Utils::post('champ_identifiant'));
            $config->set('pays', Utils::post('pays'));
            $config->set('monnaie', Utils::post('monnaie'));
            $config->save();
            Utils::redirect('/admin/config/?ok');
        } catch (UserException $e) {
            $error = $e->getMessage();
        }
    }
}
$tpl->assign('error', $error);
$tpl->assign('garradin_version', garradin_version() . ' [' . (garradin_manifest() ?: 'release') . ']');
$tpl->assign('php_version', phpversion());
$v = \SQLite3::version();
$tpl->assign('sqlite_version', $v['versionString']);
$tpl->assign('pays', Utils::getCountryList());
$cats = new Membres\Categories();
$tpl->assign('membres_cats', $cats->listSimple());
$champs_liste = array_merge(['id' => ['title' => 'Numéro unique', 'type' => 'number']], $config->get('champs_membres')->getList());
$tpl->assign('champs', $champs_liste);
$tpl->display('admin/config/index.tpl');
Esempio n. 28
0
<?php

var_dump(SQLite3::version('dummy'));
Esempio n. 29
0
<?php

print_r(SQLite3::version());
echo "Done\n";
Esempio n. 30
0
 public function getVersion()
 {
     $res = SQLite3::version();
     return $res['versionString'];
 }