Exemple #1
0
 function checkDriver()
 {
     $drivers = pdo_drivers();
     if (array_search('mysql', $drivers) === FALSE) {
         return false;
     }
     return TRUE;
 }
Exemple #2
0
 public function getDsn()
 {
     if (!isset($this->driver)) {
         throw new \RuntimeException("Cannot get database DSN (no driver set).");
     }
     if (!in_array($this->driver, pdo_drivers(), true)) {
         throw new \InvalidArgumentException("Invalid PDO driver: '{$driver}'.");
     }
     return pdo_dsn($this->get('driver'), $this->get('host'), $this->get('name'), $this->get('port'));
 }
 /**
  * Prepares the environment before running a test.
  *
  * We are using '_' as the param prefix.
  */
 protected function setUp()
 {
     parent::setUp();
     if (!\function_exists('\\pdo_drivers')) {
         $this->markTestSkipped('PDO is not available');
     } else {
         $driverlist = \pdo_drivers();
         if (!\array_search('sqlite', $driverlist)) {
             $this->markTestSkipped('PDO SQLite driver is not available');
         }
     }
     $this->subject = new SqliteConnection(array('path' => ':memory:'), 'test', '_');
 }
Exemple #4
0
 function sys_info()
 {
     $env_items = array('meiupic_version' => array('c' => 'MPIC_VERSION'), 'operate_system' => array('c' => 'PHP_OS'), 'server_software' => array('s' => 'SERVER_SOFTWARE'), 'php_runmode' => 'php_runmode', 'php_version' => array('c' => 'PHP_VERSION'), 'memory_limit' => array('i' => 'memory_limit'), 'post_max_size' => array('i' => 'post_max_size'), 'upload_max_filesize' => array('i' => 'upload_max_filesize'), 'mysql_support' => array('f' => 'mysql_connect'), 'mysqli_support' => array('f' => 'mysqli_connect'), 'sqlite_support' => array('f' => 'sqlite_open'), 'database_version' => 'database_version', 'gd_info' => 'gd_info', 'imagick_support' => array('cla' => 'imagick'), 'exif_support' => array('f' => 'exif_read_data'), 'zlib_support' => array('f' => 'gzopen'));
     $info = array();
     foreach ($env_items as $k => $v) {
         if ($k == 'php_runmode') {
             $info[] = array('title' => lang($k), 'value' => php_sapi_name());
         } elseif ($k == 'database_version') {
             $adapater = $this->db->adapter == 'mysql' || $this->db->adapter == 'mysqli' ? 'Mysql' : $this->db->adapter;
             $info[] = array('title' => lang($k), 'value' => $adapater . ' ' . $this->db->version());
         } elseif ($k == 'gd_info') {
             $tmp = function_exists('gd_info') ? gd_info() : false;
             $gd_ver = empty($tmp['GD Version']) ? lang('notsupport') : $tmp['GD Version'];
             $gd_rst = array();
             if (isset($tmp['FreeType Support']) && $tmp['FreeType Support']) {
                 $gd_rst[] = 'freetype';
             }
             if (isset($tmp['GIF Read Support']) && $tmp['GIF Read Support']) {
                 $gd_rst[] = 'gif';
             }
             if (isset($tmp['JPEG Support']) && $tmp['JPEG Support'] || isset($tmp['JPG Support']) && $tmp['JPG Support']) {
                 $gd_rst[] = 'jpg';
             }
             if (isset($tmp['PNG Support']) && $tmp['PNG Support']) {
                 $gd_rst[] = 'png';
             }
             $info[] = array('title' => lang($k), 'value' => $gd_ver . ' ' . implode(',', $gd_rst));
         } elseif ($k == 'sqlite_support') {
             if (function_exists('sqlite_open') || class_exists("SQLite3") || function_exists('pdo_drivers') && in_array('sqlite', pdo_drivers())) {
                 $support = true;
             } else {
                 $support = false;
             }
             $info[] = array('title' => lang($k), 'value' => $support ? lang('support') : lang('notsupport'));
         } elseif (isset($v['f'])) {
             $info[] = array('title' => lang($k), 'value' => function_exists($v['f']) ? lang('support') : lang('notsupport'));
         } elseif (isset($v['c'])) {
             $info[] = array('title' => lang($k), 'value' => constant($v['c']));
         } elseif (isset($v['s'])) {
             $info[] = array('title' => lang($k), 'value' => $_SERVER[$v['s']]);
         } elseif (isset($v['cla'])) {
             $info[] = array('title' => lang($k), 'value' => class_exists($v['cla']) ? lang('support') : lang('notsupport'));
         }
     }
     return $info;
 }
Exemple #5
0
 /**
 * 单实例数据库连接
 * @author 景云山
 * @version 2008-8-15
 * @param array $connectionInfo 服务器连接信息 
 	参数格式 array(
 						host => "localhost",   //数据库服务器IP或域名
 						user => "test",      //用户帐号
 						pass => "123",      //用户帐号密码
 						dbname => "test"       //数据库名
 					)
 * @param int $port 数据库服务器端口号
 * @param string $driver 数据库驱动名称 值为 'mysql' 或 'oci'
 * @param string $charset mysql数据库链接层字符集
 * @param array $driverOptions 数据库驱动特定的连接选项数组
 * @return void 无返回值
 */
 private function newConnection($connectionInfo, $port = 3306, $driver = 'mysql', $charset = 'utf8', $driverOptions = null)
 {
     $message = '扩展没有加载,请检查PHP配置。';
     if (!extension_loaded('pdo')) {
         throw new Exception('php_pdo ' . $message, 504);
     }
     if (!in_array($driver, pdo_drivers())) {
         throw new Exception('php_pdo_' . $driver . ' ' . $message, 505);
     }
     if (!is_array($connectionInfo)) {
         throw new Exception('$connectionInfo 参数应为一维数组,请检查传入值。', 506);
     }
     switch ($driver) {
         case 'mysql':
             $dsn = 'mysql:host=' . $connectionInfo['host'] . ';dbname=' . $connectionInfo['dbname'] . ';port=' . $port;
             if ($charset) {
                 $charsetSql = "set names {$charset}";
             }
             break;
         case 'oci':
             $dsn = "oci:dbname={$connectionInfo['dbname']};charset={$charset}";
             break;
         default:
             throw new Exception("数据库类不支持 {$driver} 数据库连接。", 507);
     }
     try {
         parent::__construct($dsn, $connectionInfo['user'], $connectionInfo['pass'], $driverOptions);
         $this->_driver = $driver;
         if ($charsetSql) {
             //设置mysql结果集字符编码
             $this->exec($charsetSql);
         }
     } catch (PDOException $e) {
         throw new Exception('Failed: ' . $e->getMessage(), 503);
     }
 }
    /**
     * Connects to the database server and selects a database
     *
     * PHP5 style constructor for compatibility with PHP5. Does
     * the actual setting up of the class properties and connection
     * to the database.
     *
     * @link http://core.trac.wordpress.org/ticket/3354
     * @since 2.0.8
     *
     * @param string $dbuser MySQL database user
     * @param string $dbpassword MySQL database password
     * @param string $dbname MySQL database name
     * @param string $dbhost MySQL database host
     */
    function __construct($dbuser, $dbpassword, $dbname, $dbhost, $pdo_type)
    {
        $this->pdo_type = $pdo_type;
        if (!extension_loaded('pdo')) {
            $this->bail('
<h1>Extension Not Loaded</h1>
<p>The pdo PHP extension is not loaded properly or available for PHP to use.</p>
<ul>
<li>Check your phpinfo</li>
<li>Make sure it is loaded in your php ini file</li>
<li>Turn on display_errors and display_startup_errors so you can detect issues with loading the module.</li>
</ul>');
            return;
        }
        if (!in_array($this->pdo_type, pdo_drivers())) {
            $this->bail('
<h1>PDO Driver Not Loaded</h1>
<p>The pdo PHP driver extension ' . $this->pdo_type . ' is not loaded properly or available for PHP to use.</p>
<ul>
<li>Check your phpinfo</li>
<li>Make sure it is loaded in your php ini file</li>
<li>Turn on display_errors and display_startup_errors so you can detect issues with loading the module.</li>
</ul>');
            return;
        }
        parent::__construct($dbuser, $dbpassword, $dbname, $dbhost);
    }
Exemple #7
0
function env_check(&$env_items)
{
    foreach ($env_items as $key => $item) {
        if ($key == 'php') {
            $env_items[$key]['current'] = PHP_VERSION;
        } elseif ($key == 'attachmentupload') {
            $env_items[$key]['current'] = @ini_get('file_uploads') ? ini_get('upload_max_filesize') : 'unknow';
        } elseif ($key == 'gdversion') {
            $tmp = function_exists('gd_info') ? gd_info() : array();
            $env_items[$key]['current'] = empty($tmp['GD Version']) ? 'noext' : $tmp['GD Version'];
            unset($tmp);
        } elseif ($key == 'diskspace') {
            if (function_exists('disk_free_space')) {
                $env_items[$key]['current'] = floor(disk_free_space(ROOTDIR) / (1024 * 1024)) . 'M';
            } else {
                $env_items[$key]['current'] = 'unknow';
            }
        } elseif ($key == 'database') {
            $database_support = 0;
            if (function_exists('mysql_connect') || function_exists('mysqli_connect')) {
                $database_support += 1;
            }
            if (function_exists('sqlite_open') || class_exists("SQLite3") || function_exists('pdo_drivers') && in_array('sqlite', pdo_drivers())) {
                $database_support += 2;
            }
            $env_items[$key]['current'] = $database_support . 'db';
        } elseif (isset($item['c'])) {
            $env_items[$key]['current'] = constant($item['c']);
        }
        $env_items[$key]['status'] = 1;
    }
}
Exemple #8
0
 /**
  * 数据库连接
  *
  * @param Array $dbinfo
  * @return boolean
  */
 function connect($dbinfo = false)
 {
     $dbinfo = $dbinfo ? $dbinfo : $this->dbinfo;
     $this->conn = false;
     if (!file_exists($dbinfo['dbpath'])) {
         if (file_exists(ROOTDIR . $dbinfo['dbpath'])) {
             $dbinfo['dbpath'] = ROOTDIR . $dbinfo['dbpath'];
         } else {
             exit(lang('sqlite_not_exists'));
         }
     }
     $ver = $this->version();
     switch (true) {
         case class_exists("SQLite3") && ($ver == -1 || $ver == 3):
             $this->conn = new SQLite3($dbinfo['dbpath']);
             if ($this->conn != NULL) {
                 $this->type = "SQLite3";
                 break;
             }
         case function_exists("pdo_drivers") && in_array('sqlite', pdo_drivers()) && ($ver == -1 || $ver == 3):
             $this->conn = new PDO("sqlite:" . $dbinfo['dbpath']);
             if ($this->conn != NULL) {
                 $this->type = "PDO";
                 $this->conn->query('PRAGMA read_uncommitted=1');
                 break;
             }
         case function_exists("sqlite_open") && ($ver == -1 || $ver == 2):
             $this->conn = sqlite_open($dbinfo['dbpath']);
             if ($this->conn != NULL) {
                 $this->type = "SQLite2";
                 break;
             }
         default:
             exit('Sqlite not support!');
     }
     if ($this->conn) {
         return $this->conn;
     }
 }
function build_installer($step)
{
    switch ($step) {
        case 0:
            return <<<HTML
<div class="message">
                <h2>Welcome to Tower21 WebComiX Manager</h2>
                <p>The following pages are designed to assist you in setting up your server to run this application. The application will assist you and your users in managing WebComiX and related projects.</p>
                <div align=center><button onclick="window.location='http://www.tower21studios.com'">Cancel</button> <button onclick="window.location='./app.php?action=install&step=1'">Get Started</button></div>
</div>
HTML;
            break;
        case 1:
            $types = pdo_drivers();
            @($host = getenv("IP"));
            @($uname = getenv("C9_USER"));
            $drivers = null;
            foreach ($types as $driver) {
                $drivers .= "<option>{$driver}</option>\n";
            }
            return <<<HTML
<form action="./app.php?action=install&step=2" method="post"><div class="form">
<h2>Set-up DataConnect</h2>
<p>This page is designed to help you set-up DataConnect to connect to the database software on your server. Please fill out the form below. Fields marked with and astrix '<span class="required">*</span>' are required.</p>
<table width="100%" border=0 cellspacing=1 cellpadding=1>
<tr>
<th colspan=2>Server</th>
</tr>
<tr>
<td align=right>Server Type<span class="required">*</span>:</td><td align=left><select required="required" name="database[driver]">{$drivers}</select></td>
</tr>
<tr>
<td align=right>Hostname/Address<span class="required">*</span>:</td><td align=left><input type="text" required="required" name="database[host]" value="{$host}"/></td>
</tr>
<tr>
<td align="right">Port:</td><td align="left"><input type="number" name="database[port]"></td>
</tr>
<tr>
<th colspan="2">Schema</th>
</tr>
<tr>
<td align="right">Database Name<span class="required">*</span>:</td><td align="left"><input type="text" required="required" name="schema[name]"/></td>
</tr>
<tr>
<td align="right">User<span class="required">*</span>:</td><td align="left"><input type="text" required=required name="schema[username]" value="{$uname}"/></td>
</tr>
<tr>
<td align="right">Password:</td><td align="left"><input type="password" name="schema[password]"/></td>
</tr>
<tr>
<td align="right">Table Prefix:</td><td align="left"><input type="text" name="schema[tableprefix]"/></td>
</tr>
<tr>
<td align="right"><button onclick="history.back()">Previous</button></td><td align="left"><button type="submit">Continue</button></td>
</tr>
</div></form>
HTML;
            break;
        case 2:
            if (!empty($_POST['database'])) {
                if (is_writable(dirname(__FILE__) . "/dataconnect/")) {
                    if (write_ini_file($_POST, dirname(__FILE__) . "/dataconnect/connect.ini")) {
                        header("Location:./app.php?action=install&step=2");
                    }
                }
            } else {
                return <<<HTML
<div class="message">
<h2>Create Database Tables</h2>
<p>With DataConnect set up you are now ready to create the tables that the WebComiX Manager requires in order to function. This may take a few moments.</p>
<div align=center><button onclick="history.back()">Previous</button> <button onclick="window.location='./app.php?action=install&step=3'">Continue</button></div>
</div>
HTML;
            }
            break;
        case 3:
            if (set_tables()) {
                $wcmroot = dirname($_SERVER['SCRIPT_FILENAME']);
                $wcmuri = $_SERVER['SERVER_NAME'] . dirname($_SERVER['REQUEST_URI']);
                return <<<HTML
<form action="./app.php?action=install&step=4" method="post"><div class="form">
<h2>Populate Tables</h2>
<p>Now that the database tables have been created we are ready to populate them with their default data, however, we need to know what some of that data should be. Fill out the form below to help us.</p>
<table width=100% border=0 cellspacing=1 cellpadding=1>
 <tr>
  <th colspan=2>Application Settings</th>
 </tr>
 <tr>
  <td align="right">Base URI:</td><td align="left"><input type="text" name="settings[base_uri]" title="The root location this application is run from including domain/ip address and root application folder" value="{$wcmuri}"></td>
 </tr>
 <tr>
  <td align="right">Server Root:</td><td align="left"><input type="text" name="settings[base_dir]" title="The actual folder the application is stored in on the server. Setting this prevents the application from guessing where it is, but could pose a security risk." value="{$wcmroot}"/></td>
 </tr>
 <tr>
  <td align="right">Projects Folder:</td><td align="left"><input type="text" name="settings[project_dir]" title="Root folder where files (PDF, Graphics, etc.) are stored for user projects relative to the server root." value="{$wcmroot}/projects"/></td>
 </tr>
 <tr>
  <td align="right">Allow Guest Views:</td><td align="left"><span title="Can users view ad-supported content without registering?"><input type="radio" name="settings[guest_views]" value="y" id="guest_y"><label for="guest_y">Yes</label><input type="radio" name="settings[guest_views]" value="n" id="guest_n"><label for="guest_n">No</label></span></td>
 </tr>
 <tr>
  <td align="right">Open Registration:</td><td align="left"><span title="Can users register themselves, or can they only be registered by admins i.e. by invitation?"><input type="radio" name="settings[open_registration]" value="y" id="or_y"><label for="or_y">Yes</label><input type="radio" name="settings[open_registration]" value="n" id="or_n"><label for="or_n">No</label></span></td>
 </tr>
 <tr>
  <th colspan=2>Default User Settings</th>
 </tr>
 <tr>
  <td align="right">Name:</td><td align="left"><input type="hidden" name="guest[name]" value="guest"><input type="text" name="null[name]" disabled=disabled value="[user specified]"></td>
 </tr>
 <tr>
  <td align="right">Level:</td><td align="lect"><input type="hidden" name="guest[level]" value=5><input type="text" name="null[level]" disabled=disabled value="Free User"></td>
 </tr>
 <tr>
  <td align="right">Date Format:</td><td align="left"><input type="text" name="guest[date_format]" value="m/d/Y"></td>
 </tr>
 <tr>
  <td align="right"># of Rows on an index page:</td><td align="left"><input type="number" name="guest[rows_per_page]" size=3 maxlength=2 value="6"></td>
 </tr>
 <tr>
  <td align="right"># Total items on an index page:</td><td align="left"><input type="number" name="guest[items_per_page]" size=4 maxlength=3 value="24"></td>
 </tr>
 <tr>
  <th colspan=2>Register Your User</th>
 </tr>
 <tr>
  <td align="right">User Name:</td><td align="left"><input type="text" name="admin[name]"></td>
 </tr>
 <tr>
  <td align="right">Password:</td><td align="left"><input type="password" name="admin[pass1]"></td>
 </tr>
 <tr>
  <td align="right">Confirm Password:</td><td align="left"><input type="password" name="admin[pass2]"></td>
 </tr>
 <tr>
  <td align="right">E-Mail:</td><td align="left"><input type="email" name="admin[email]"></td>
 </tr>
 <tr>
  <td colspan=2 align="center"><button type="submint">Save Settings</button></td>
 </tr>
 </table>
</div></form>
HTML;
            } else {
                echo "Failed!";
            }
            break;
        case 4:
            if (put_defaults($_POST['admin'], $_POST['guest'], $_POST['settings'])) {
                return <<<HTML
<div class="message">
<h2>Set-up Complete!</h2>
<p>Your server environment is now set up an ready to run this application!</p>
<div align="center"><button onclick="window.location='./?section=app&action=login'">Login</button> <button onclick="window.location='./'">Go to Main Index</button></div>
</div>
HTML;
            }
    }
}
Exemple #10
0
 *
 * @author		Arthur(ArthurXF@gmail.com)
 * @copyright	(c) 2006 by bizeway.com
 * @version		$Id$
 * @package		ArthurXF
 * @subpackage	admin
 */
require_once 'config/config.inc.php';
require_once 'checklogin.php';
$objWebInit = new ArthurXF();
//smarty参数
$objWebInit->arrGSmarty = $arrGSmarty;
$arrInfo = array();
$arrInfo['serverinfo'] = PHP_OS . ' / PHP v' . PHP_VERSION;
$arrInfo['serverinfo'] .= @ini_get('safe_mode') ? ' / 安全模式' : NULL;
$arrDrivers = pdo_drivers();
$conn = new PDO($arrGPdoDB['dsn'], $arrGPdoDB['db_user'], $arrGPdoDB['db_password']);
foreach ($arrDrivers as $k => $v) {
    if ($v == "mysql") {
        $arrInfo['databaseinfo'] = strtoupper($arrDrivers[$k]) . ' ' . $conn->getAttribute(PDO::ATTR_SERVER_VERSION);
    }
}
if (@ini_get("file_uploads")) {
    $arrInfo['fileupload'] = "允许 - 文件 " . ini_get("upload_max_filesize") . " - 表单:" . ini_get("post_max_size");
} else {
    $arrInfo['fileupload'] = "<font color=\"red\">禁止</font>";
}
if (get_cfg_var('register_globals')) {
    $arrInfo['onoff'] = "打开";
} else {
    $arrInfo['onoff'] = "关闭";
 /**
  * Setup connection, populate tables array
  * Also responsible for selecting the type of connection to use.
  *
  * @return void
  */
 public function db_setup()
 {
     $mysqli_available = class_exists('mysqli');
     $pdo_available = class_exists('PDO');
     $connection_type = '';
     // Default to mysqli type.
     // Only advance to PDO if all conditions are met.
     if ($mysqli_available) {
         $connection_type = 'mysqli';
     }
     if ($pdo_available) {
         // PDO is the interface, but it may not have the 'mysql' module.
         $mysql_driver_present = in_array('mysql', pdo_drivers());
         if ($mysql_driver_present) {
             $connection_type = 'pdo';
         }
     }
     // Abort if mysqli and PDO are both broken.
     if ('' === $connection_type) {
         $this->add_error('Could not find any MySQL database drivers. (MySQLi or PDO required.)', 'db');
         return false;
     }
     // connect
     $this->set('db', $this->connect($connection_type));
 }
Exemple #12
0
 /**
 		Class constructor
 			@param $dsn string
 			@param $user string
 			@param $pw string
 			@param $opt array
 			@param $force boolean
 			@public
 	**/
 function __construct($dsn, $user = NULL, $pw = NULL, $opt = NULL, $force = FALSE)
 {
     if (!isset(self::$vars['MYSQL'])) {
         // Default MySQL character set
         self::$vars['MYSQL'] = 'utf8';
     }
     if (!$opt) {
         $opt = array();
     }
     // Append other default options
     $opt += array(PDO::ATTR_EMULATE_PREPARES => FALSE);
     if (in_array('mysql', pdo_drivers()) && preg_match('/^mysql:/', $dsn)) {
         $opt += array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES ' . self::$vars['MYSQL']);
     }
     list($this->dsn, $this->user, $this->pw, $this->opt) = array($this->resolve($dsn), $user, $pw, $opt);
     $this->backend = strstr($this->dsn, ':', TRUE);
     preg_match('/dbname=([^;$]+)/', $this->dsn, $match);
     if ($match) {
         $this->dbname = $match[1];
     }
     if (!isset(self::$vars['DB'])) {
         self::$vars['DB'] = $this;
     }
     if ($force) {
         $this->pdo = new PDO($this->dsn, $this->user, $this->pw, $this->opt);
     }
 }
Exemple #13
0
    $db = new SQLite3($tmp_sqllite);
    $db->exec("CREATE TABLE foo (bar STRING)");
    $db->exec("INSERT INTO foo VALUES ('ABC')");
    $db->exec("INSERT INTO foo VALUES ('DEF')");
    VS($db->lasterrorcode(), 0);
}
function cleanupSqliteTestTable($tmp_sqllite)
{
    unlink($tmp_sqllite);
}
///////////////////////////////////////////////////////////////////////////////
class MyStatement extends PDOStatement
{
}
///////////////////////////////////////////////////////////////////////////////
VERIFY(count(pdo_drivers()) > 0);
createSqliteTestTable($tmp_sqllite);
$source = "sqlite:{$tmp_sqllite}";
try {
    $dbh = new PDO($source);
    $dbh->query("CREATE TABLE IF NOT EXISTS foobar (id INT)");
    $dbh->query("INSERT INTO foobar (id) VALUES (1)");
    $stmt = $dbh->query("SELECT id FROM foobar LIMIT 1");
    $ret = $stmt->fetch();
    VS($ret['id'], "1");
} catch (Exception $e) {
    VS($e, null);
}
try {
    $dbh = new PDO($source);
    VERIFY($dbh != null);
Exemple #14
0
?>
<div class="site_container">
<h1>欢迎使用zcncms</h1>
<UL class=Form_Advance id=FormRegStep1>
    <LI class=Title>安装环境检测_程序安装</LI>
    <li class="installhr">
      <hr>
    </li>
    <li>您的PHP版本:<?php 
echo PHP_VERSION;
?>
</li>
    <li>sqlite:
      <?php 
if (function_exists("pdo_drivers")) {
    $pdo_drivers = pdo_drivers();
    if (in_array('sqlite', $pdo_drivers)) {
        //通过建立新的数据库来全面测试下看
        $sql = "";
        $pdo = new PDO("sqlite:test.db");
        if ($pdo) {
            //没有错误 开始安装
            //安装表
            $pdo->exec("create table test(a int)");
            if ($pdo->errorCode() == '00000') {
                //测试插入数据
                $pdo->exec("insert into test values(1)");
                if ($pdo->errorCode() == '00000') {
                    echo "<span style='color:green'>支持</span>";
                } else {
                    echo "<span style='color:red'>不支持</span>";
Exemple #15
0
    if (!function_exists('curl_init')) {
        throw new Exception("cURL extension is disabled or not installed\n" . (PHP_OS !== 'WINNT' ? "Run <strong>sudo apt-get install php7.0-curl</strong>" : "Uncomment/add the line <strong>extension=php_curl.dll</strong> {$inipath}") . ' to fix');
    }
    if (!function_exists('imagecreatefrompng')) {
        throw new Exception("GD extension is disabled or not installed" . (PHP_OS !== 'WINNT' ? "\nRun <strong>sudo apt-get install php7.0-gd</strong> to fix" : ""));
    }
    if (!class_exists('DOMDocument', false)) {
        throw new Exception("XML extension is disabled or not installed" . (PHP_OS !== 'WINNT' ? "\nRun <strong>sudo apt-get install php7.0-xml</strong> to fix" : ''));
    }
    if (!function_exists('mb_substr') || !function_exists('mb_strlen')) {
        throw new Exception("mbstring extension is disabled or not installed" . (PHP_OS !== 'WINNT' ? "\nRun <strong>sudo apt-get install php7.0-mbstring</strong> to fix" : ''));
    }
    if (!function_exists('pdo_drivers')) {
        throw new Exception("PDO extension is disabled or not installed\nThe site requires PHP 7.0+ to function, please upgrade your server.");
    }
    if (!in_array('pgsql', pdo_drivers())) {
        throw new Exception("PostgreSQL PDO extension is disabled or not installed\n" . (PHP_OS !== 'WINNT' ? "Run <strong>sudo apt-get install php7.0-pgsql</strong>" : "Uncomment/add the line <strong>extension=php_pdo_pgsql.dll</strong> {$inipath}") . ' to fix');
    }
} catch (Exception $e) {
    $errcause = 'libmiss';
    die(require INCPATH . "views/fatalerr.php");
}
$Database = new PostgresDbWrapper('mlpvc-rr');
try {
    $Database->pdo();
} catch (Exception $e) {
    unset($Database);
    $errcause = 'db';
    die(require INCPATH . "views/fatalerr.php");
}
$CGDb = new PostgresDbWrapper('mlpvc-colorguide');
Exemple #16
0
 static function init()
 {
     if (self::$mode == self::PRODUCTION) {
         self::$useTurboSpeed = true;
     }
     $_ENV['dir.recess'] = self::$recessDir;
     $_ENV['dir.apps'] = self::$appsDir;
     $_ENV['dir.plugins'] = self::$pluginsDir;
     $_ENV['dir.temp'] = self::$dataDir . 'temp/';
     $_ENV['dir.test'] = self::$recessDir . 'test/';
     if (!isset($_ENV['url.assetbase'])) {
         $_ENV['url.assetbase'] = $_ENV['url.base'];
     }
     date_default_timezone_set(self::$defaultTimeZone);
     require_once $_ENV['dir.recess'] . 'recess/lang/Library.class.php';
     Library::addClassPath(self::$recessDir);
     Library::addClassPath(self::$pluginsDir);
     Library::addClassPath(self::$appsDir);
     if (self::$useTurboSpeed) {
         Library::$useNamedRuns = true;
         $cacheProvidersReversed = array_reverse(self::$cacheProviders);
         foreach ($cacheProvidersReversed as $provider) {
             $provider = $provider . 'CacheProvider';
             Cache::reportsTo(new $provider());
         }
     }
     Library::init();
     Library::beginNamedRun('recess');
     Library::import('recess.database.Databases');
     Library::import('recess.database.orm.ModelDataSource');
     if (empty(RecessConf::$defaultDatabase)) {
         $message = 'Congratulations, Recess is almost setup!<br />';
         $message .= '<strong>Next Step(s):</strong>';
         $message .= '<ul>';
         $pdoMessages = array();
         if (!extension_loaded('PDO')) {
             $pdoMessages[] = 'Install PHP\'s PDO Extension';
             $pdoMessages[] = 'Install Sqlite or MySQL PDO Driver';
         } else {
             $drivers = pdo_drivers();
             $hasMySql = in_array('mysql', $drivers);
             $hasSqlite = in_array('sqlite', $drivers);
             if (!$hasMySql && !$hasSqlite) {
                 $pdoMessages[] = 'Install Sqlite and/or MySQL PDO Driver';
             } else {
                 $databases = '';
                 if ($hasSqlite) {
                     $databases = 'Sqlite';
                 }
                 if ($hasMySql) {
                     if ($databases != '') {
                         $databases .= ', ';
                     }
                     $databases .= 'MySql';
                 }
                 $pdoMessages[] = 'You have drivers for the following databases: ' . $databases;
             }
         }
         $pdoMessages[] = 'Setup <strong>recess-conf.php</strong> to point to your database.';
         $pdoMessages[] = 'Checkout the <strong>README.textile</strong> file for instructions.';
         $pdoMessages = '<li>' . implode('</li><li>', $pdoMessages) . '</li>';
         $message .= $pdoMessages . '</ul>';
         die($message);
     }
     try {
         Databases::setDefaultSource(new ModelDataSource(RecessConf::$defaultDatabase));
     } catch (DataSourceCouldNotConnectException $e) {
         $databaseType = parse_url(RecessConf::$defaultDatabase[0], PHP_URL_SCHEME);
         if (!in_array($databaseType, pdo_drivers())) {
             $message = 'It looks like PHP could not load the driver needed to connect to <strong>' . RecessConf::$defaultDatabase[0] . '</strong><br />';
             $message .= 'Please install the <strong>' . ucfirst($databaseType) . '</strong> PDO driver and enable it in php.ini';
         } else {
             $message = 'Error connecting to data source: ' . $e->getMessage();
         }
         die($message);
     }
     if (!empty(RecessConf::$namedDatabases)) {
         foreach (RecessConf::$namedDatabases as $name => $sourceInfo) {
             Databases::addSource($name, new ModelDataSource($sourceInfo));
         }
     }
     Library::import('recess.framework.Application');
     foreach (self::$applications as $key => $app) {
         if (!Library::classExists($app)) {
             die('Application "' . $app . '" does not exist. Remove it from recess-conf.php, RecessConf::$applications array.');
         } else {
             $app = Library::getClassName($app);
             self::$applications[$key] = new $app();
         }
     }
     Library::import('recess.framework.DefaultPolicy');
     self::$policy = new DefaultPolicy();
 }
function label_driver_check($driver)
{
    // TODO: Make this a link to a troubleshooting page
    if (!in_array($driver, pdo_drivers())) {
        echo " <span class=\"missing_driver\">(Driver not loaded!)</span>";
    }
}
 function checkPdo(&$replace)
 {
     if (class_exists('PDO')) {
         $replace['DRIVERS'] = implode(', ', pdo_drivers());
         return 'SUCCESS';
     }
     return 'WARNING';
 }