Exemplo n.º 1
0
<?php

/*
$HeadURL$
$LastChangedRevision$
*/
if (!defined('TXP_INSTALL')) {
    exit;
}
@ignore_user_abort(1);
@set_time_limit(0);
include_once txpath . '/lib/mdb.php';
global $DB;
$DB =& mdb_factory($dhost, $ddb, $duser, $dpass, $dbcharset);
if ($DB->table_exists(PFX . 'textpattern')) {
    die("Textpattern database table already exist. Can't run setup.");
}
// FIXME: this stuff all belongs in mdb, if it's not there already
if (MDB_TYPE == 'pg') {
    #	if (isset($dbcharset))
    #		$DB->query('SET NAMES '.$dbcharset);
    $zerodate = '1970-01-01';
    $zerodatetime = $zerodate . ' 00:00:00';
    $datetime = 'timestamp without time zone';
    $autoinc = 'SERIAL NOT NULL';
    $mediumtext = 'text';
    $tinytext = 'text';
    $tabletype = '';
    $incval = 'DEFAULT';
} elseif (MDB_TYPE == 'my') {
    $version = mysql_get_server_info();
Exemplo n.º 2
0
		$this->link = @db_connect($this->host, $this->user, $this->pass, $this->db);
		// PDO returns an object. Do strict comparison
		if ($this->link === false) die(db_down());

		if (!$this->link) {
			$GLOBALS['connected'] = false;
		} else $GLOBALS['connected'] = true;
		@db_selectdb($this->db) or die(db_down());

		if ($txpcfg['dbtype']!='pdo_sqlite') @db_query("SET NAMES ". $txpcfg['dbcharset']);
    }
}
*/
global $txpcfg;
if (empty($GLOBALS['DB'])) {
    $GLOBALS['DB'] =& mdb_factory($txpcfg['host'], $txpcfg['db'], $txpcfg['user'], $txpcfg['pass'], @$txpcfg['dbcharset'], 'trace_add');
}
//-------------------------------------------------------------
function safe_pfx($table)
{
    $name = PFX . $table;
    if (preg_match('@[^\\w._$]@', $name)) {
        return '`' . $name . '`';
    }
    return $name;
}
//-------------------------------------------------------------
function safe_pfx_j($table)
{
    $ts = array();
    foreach (explode(',', $table) as $t) {
Exemplo n.º 3
0
    function printConfig()
    {
        # Is anybody using the ftp values for something?
        $this->vars = psa(array('ddb', 'duser', 'dpass', 'dhost', 'dprefix', 'dbtype', 'txprefix', 'txpath', 'siteurl', 'ftphost', 'ftplogin', 'ftpass', 'ftpath', 'lang'));
        $GLOBALS['textarray'] = $this->_load_lang();
        @(include txpath . '/config.php');
        if (!empty($txpcfg['db'])) {
            $this->setup_error(gTxt('already_installed', array('{txpath}' => txpath)));
        }
        $this->vars['txpath'] = preg_replace("/^(.*)\\/\$/", "\$1", $this->vars['txpath']);
        $this->vars['ftpath'] = preg_replace("/^(.*)\\/\$/", "\$1", $this->vars['ftpath']);
        extract($this->vars);
        // FIXME, remove when all languages are updated with this string
        if (!isset($GLOBALS['textarray']['prefix_bad_characters'])) {
            $GLOBALS['textarray']['prefix_bad_characters'] = 'The Table prefix {dbprefix} contains characters that are not allowed.<br />' . 'The first character must match one of <b>a-zA-Z_</b> and all following
				 characters must match one of <b>a-zA-Z0-9_</b>';
        }
        $this->_step_view = graf(gTxt("checking_database"));
        $GLOBALS['txpcfg']['dbtype'] = $dbtype;
        # include here in order to load only the required driver
        include_once txpath . '/lib/mdb.php';
        if ($dbtype == 'pdo_sqlite') {
            $ddb = $txpath . DS . $ddb;
            $carry['ddb'] = $ddb;
        }
        if (empty($GLOBALS['DB'])) {
            $GLOBALS['DB'] =& mdb_factory($dhost, $ddb, $duser, $dpass);
        }
        $DB = $GLOBALS['DB'];
        if (!$DB->connect($dhost, $duser, $dpass, $ddb)) {
            $this->setup_error(graf(gTxt('db_cant_connect')));
        }
        $this->_step_view .= graf(gTxt('db_connected'));
        if (!($dprefix == '' || preg_match('#^[a-zA-Z_][a-zA-Z0-9_]*$#', $dprefix))) {
            $this->setup_error(graf(gTxt('prefix_bad_characters', array('{dbprefix}' => strong($dprefix)))));
        }
        if (!$DB->selectdb($ddb)) {
            $this->setup_error(graf(gTxt('db_doesnt_exist', array('{dbname}' => strong($ddb)))));
        }
        # On 4.1 or greater use utf8-tables
        if ($dbtype != 'pdo_sqlite' && $DB->query("SET NAMES 'utf8'")) {
            $this->vars['dbcharset'] = "utf8";
            $this->vars['dbcollate'] = "utf8_general_ci";
        } elseif ($dbtype == 'pdo_sqlite' && db_query('PRAGMA encoding="UTF-8"')) {
            $this->vars['dbcharset'] = "utf8";
        } else {
            $this->vars['dbcharset'] = "latin1";
            $this->vars['dbcollate'] = '';
        }
        $this->_step_view .= graf(gTxt('using_db', array('{dbname}' => strong($ddb))) . ' (' . $this->vars['dbcharset'] . ')') . graf(strong(gTxt('before_you_proceed')) . ', ' . gTxt('create_config', array('{txpath}' => txpath))) . '<textarea name="config" cols="40" rows="5" style="width: 400px; height: 200px;">' . $this->makeConfig($this->vars) . '</textarea>' . '<form action="' . $this->rel_siteurl . '/textpattern/setup/install.php" method="post">' . fInput('submit', 'submit', gTxt('did_it'), 'smallbox') . sInput('getTxpLogin') . hInput('carry', $this->postEncode($this->vars)) . '</form>';
    }
Exemplo n.º 4
0
function createTxp()
{
    $email = ps('email');
    if (!is_valid_email($email)) {
        exit(graf(gTxt('email_required')));
    }
    $carry = ps('carry');
    extract(postDecode($carry));
    require txpath . '/config.php';
    $dbb = $txpcfg['db'];
    $duser = $txpcfg['user'];
    $dpass = $txpcfg['pass'];
    $dhost = $txpcfg['host'];
    $dprefix = $txpcfg['table_prefix'];
    $GLOBALS['txpcfg']['dbtype'] = $txpcfg['dbtype'];
    $dbcharset = $txpcfg['dbcharset'];
    include_once txpath . '/lib/mdb.php';
    $GLOBALS['textarray'] = setup_load_lang($lang);
    $siteurl = str_replace("http://", '', $siteurl);
    $siteurl = rtrim($siteurl, "/");
    define("PFX", trim($dprefix));
    define('TXP_INSTALL', 1);
    $name = addslashes(gps('name'));
    include_once txpath . '/lib/txplib_update.php';
    include txpath . '/setup/txpsql.php';
    extract(gpsa(array('name', 'pass', 'RealName', 'email')));
    $nonce = md5(uniqid(rand(), true));
    global $DB;
    $DB =& mdb_factory($dhost, $ddb, $duser, $dpass, $dbcharset);
    $DB->query("INSERT INTO " . PFX . "txp_users VALUES\n\t\t\t(1,'" . $DB->escape($name) . "',password(lower('" . $DB->escape($pass) . "')),'" . $DB->escape($RealName) . "','" . $DB->escape($email) . "',1,now(),'" . $DB->escape($nonce) . "')");
    $DB->query("update " . PFX . "txp_prefs set val = '" . $DB->escape($siteurl) . "' where name='siteurl'");
    $DB->query("update " . PFX . "txp_prefs set val = '" . $DB->escape($lang) . "' where name='language'");
    $DB->query("update " . PFX . "txp_prefs set val = '" . $DB->escape(getlocale($lang)) . "' where name='locale'");
    echo fbCreate();
}