Ejemplo n.º 1
0
 function WikiDB_backend_ADODB($dbparams)
 {
     $parsed = parseDSN($dbparams['dsn']);
     $this->_dbparams = $dbparams;
     $this->_parsedDSN =& $parsed;
     $this->_dbh =& ADONewConnection($parsed['phptype']);
     if (DEBUG & _DEBUG_SQL) {
         $this->_dbh->debug = true;
         $GLOBALS['ADODB_OUTP'] = '_sql_debuglog';
     }
     $this->_dsn = $parsed;
     // persistent is defined as DSN option, or with a config value.
     //   phptype://username:password@hostspec/database?persistent=false
     if (!empty($parsed['persistent']) or DATABASE_PERSISTENT) {
         $conn = $this->_dbh->PConnect($parsed['hostspec'], $parsed['username'], $parsed['password'], $parsed['database']);
     } else {
         $conn = $this->_dbh->Connect($parsed['hostspec'], $parsed['username'], $parsed['password'], $parsed['database']);
     }
     // Since 1.3.10 we use the faster ADODB_FETCH_NUM,
     // with some ASSOC based recordsets.
     $GLOBALS['ADODB_FETCH_MODE'] = ADODB_FETCH_NUM;
     $this->_dbh->SetFetchMode(ADODB_FETCH_NUM);
     $GLOBALS['ADODB_COUNTRECS'] = false;
     $prefix = isset($dbparams['prefix']) ? $dbparams['prefix'] : '';
     $this->_table_names = array('page_tbl' => $prefix . 'page', 'version_tbl' => $prefix . 'version', 'link_tbl' => $prefix . 'link', 'recent_tbl' => $prefix . 'recent', 'nonempty_tbl' => $prefix . 'nonempty');
     $page_tbl = $this->_table_names['page_tbl'];
     $version_tbl = $this->_table_names['version_tbl'];
     $this->page_tbl_fields = "{$page_tbl}.id AS id, {$page_tbl}.pagename AS pagename, " . "{$page_tbl}.hits AS hits";
     $this->links_field_list = array('id', 'pagename');
     $this->page_tbl_field_list = array('id', 'pagename', 'hits');
     $this->version_tbl_fields = "{$version_tbl}.version AS version, " . "{$version_tbl}.mtime AS mtime, " . "{$version_tbl}.minor_edit AS minor_edit, {$version_tbl}.content AS content, " . "{$version_tbl}.versiondata AS versiondata";
     $this->version_tbl_field_list = array('version', 'mtime', 'minor_edit', 'content', 'versiondata');
     $this->_expressions = array('maxmajor' => "MAX(CASE WHEN minor_edit=0 THEN version END)", 'maxminor' => "MAX(CASE WHEN minor_edit<>0 THEN version END)", 'maxversion' => "MAX(version)", 'notempty' => "<>''", 'iscontent' => "{$version_tbl}.content<>''");
     $this->_lock_count = 0;
 }
Ejemplo n.º 2
0
 /**
  * Constructor.
  */
 function WikiDB_backend_ADODB_sqlite($dbparams)
 {
     $parsed = parseDSN($dbparams['dsn']);
     if (!file_exists($parsed['database'])) {
         // creating the empty database
         $db = $parsed['database'];
         $schema = FindFile("schemas/sqlite.sql");
         `sqlite {$db} < {$schema}`;
     }
     $this->WikiDB_backend_ADODB($dbparams);
 }
Ejemplo n.º 3
0
 function &_connect()
 {
     global $request;
     static $parsed = false;
     $dbh =& $this->_dbh;
     if (!$dbh or !is_resource($dbh->_connectionID)) {
         if (!$parsed) {
             $parsed = parseDSN($request->_dbi->getParam('dsn'));
         }
         $this->_dbh =& ADONewConnection($parsed['phptype']);
         // Probably only MySql works just now
         $this->_dbh->Connect($parsed['hostspec'], $parsed['username'], $parsed['password'], $parsed['database']);
         $dbh =& $this->_dbh;
     }
     return $dbh;
 }
Ejemplo n.º 4
0
 function imdb()
 {
     global $DBParams;
     $ini = parse_ini_file(FindFile("config/SqlResult.ini"));
     $dsn = $ini['imdb'];
     if ($DBParams['dbtype'] == 'SQL') {
         $this->_dbh = DB::connect($dsn);
         $this->_dbtype = "PearDB";
     } else {
         if ($DBParams['dbtype'] != 'ADODB') {
             // require_once('lib/WikiDB/adodb/adodb-errorhandler.inc.php');
             require_once 'lib/WikiDB/adodb/adodb-pear.inc.php';
         }
         $parsed = parseDSN($dsn);
         $this->_dbh =& ADONewConnection($parsed['phptype']);
         $conn = $this->_dbh->Connect($parsed['hostspec'], $parsed['username'], $parsed['password'], $parsed['database']);
         $this->_dbtype = "ADODB";
     }
     $this->_title_1_1 = array("business", "moviebudgets", "colorinfo", "mpaaratingsreasons");
     $this->_title_1_n = array("akatitles", "alternateversions", "miscellaneouscompanies", "moviecountries", "certificates", "completecast", "completecrew", "crazycredits", "genres", "goofs", "keywords", "movielinks", "plot", "quotes", "ratings", "soundtracks", "specialeffectscompanies", "taglines", "trivia", "distributors", "language", "laserdisc", "literature", "locations", "miscellaneouscompanies", "productioncompanies", "releasedates", "runningtimes", "soundmix", "technical");
 }
Ejemplo n.º 5
0
 function WikiDB_backend_PDO($dbparams)
 {
     $this->_dbparams = $dbparams;
     if (strstr($dbparams['dsn'], "://")) {
         // pear DB syntax
         $parsed = parseDSN($dbparams['dsn']);
         $this->_parsedDSN = $parsed;
         /* Need to convert the DSN
          *    dbtype(dbsyntax)://username:password@protocol+hostspec/database?option=value&option2=value2
          * to dbtype:option1=value1;option2=value2
          * PDO passes the DSN verbatim to the driver. But we need to extract the username + password
          * and cannot rely that the parseDSN keys have the same name as needed by the driver.
          * e.g: odbc:DSN=SAMPLE;UID=db2inst1;PWD=ibmdb2, mysql:host=127.0.0.1;dbname=testdb
          */
         $driver = $parsed['phptype'];
         unset($parsed['phptype']);
         unset($parsed['dbsyntax']);
         $dbparams['dsn'] = $driver . ":";
         $this->_dbh->database = $parsed['database'];
         // mysql needs to map database=>dbname, hostspec=>host. TODO for the others.
         $dsnmap = array('mysql' => array('database' => 'dbname', 'hostspec' => 'host'));
         foreach (array('protocol', 'hostspec', 'port', 'socket', 'database') as $option) {
             if (!empty($parsed[$option])) {
                 $optionname = (isset($dsnmap[$driver][$option]) and !isset($parsed[$optionname])) ? $dsnmap[$driver][$option] : $option;
                 $dbparams['dsn'] .= $optionname . "=" . $parsed[$option] . ";";
                 unset($parsed[$optionname]);
             }
             unset($parsed[$option]);
         }
         unset($parsed['username']);
         unset($parsed['password']);
         // pass the rest verbatim to the driver.
         foreach ($parsed as $option => $value) {
             $dbparams['dsn'] .= $option . "=" . $value . ";";
         }
     } else {
         list($driver, $dsn) = explode(":", $dbparams['dsn'], 2);
         foreach (explode(";", trim($dsn)) as $pair) {
             if ($pair) {
                 list($option, $value) = explode("=", $pair, 2);
                 $this->_parsedDSN[$option] = $value;
             }
         }
         $this->_dbh->database = isset($this->_parsedDSN['database']) ? $this->_parsedDSN['database'] : $this->_parsedDSN['dbname'];
     }
     if (empty($this->_parsedDSN['password'])) {
         $this->_parsedDSN['password'] = '';
     }
     try {
         // try to load it dynamically (unix only)
         if (!loadPhpExtension("pdo_{$driver}")) {
             echo $GLOBALS['php_errormsg'], "<br>\n";
             trigger_error(sprintf("dl() problem: Required extension '%s' could not be loaded!", "pdo_{$driver}"), E_USER_WARNING);
         }
         // persistent is defined as DSN option, or with a config value.
         //   phptype://username:password@hostspec/database?persistent=false
         $this->_dbh = new PDO($dbparams['dsn'], $this->_parsedDSN['username'], $this->_parsedDSN['password'], array(PDO_ATTR_AUTOCOMMIT => true, PDO_ATTR_TIMEOUT => DATABASE_TIMEOUT, PDO_ATTR_PERSISTENT => !empty($parsed['persistent']) or DATABASE_PERSISTENT));
     } catch (PDOException $e) {
         echo "<br>\nDB Connection failed: " . $e->getMessage();
         if (DEBUG & _DEBUG_VERBOSE or DEBUG & _DEBUG_SQL) {
             echo "<br>\nDSN: '", $dbparams['dsn'], "'";
             echo "<br>\n_parsedDSN: '", print_r($this->_parsedDSN), "'";
             echo "<br>\nparsed: '", print_r($parsed), "'";
         }
         exit;
     }
     if (DEBUG & _DEBUG_SQL) {
         // not yet implemented
         $this->_dbh->debug = true;
     }
     $this->_dsn = $dbparams['dsn'];
     $this->_dbh->databaseType = $driver;
     $this->_dbh->setAttribute(PDO_ATTR_CASE, PDO_CASE_NATURAL);
     // Use the faster FETCH_NUM, with some special ASSOC based exceptions.
     $this->_hasTransactions = true;
     try {
         $this->_dbh->beginTransaction();
     } catch (PDOException $e) {
         $this->_hasTransactions = false;
     }
     $sth = $this->_dbh->prepare("SELECT version()");
     $sth->execute();
     $this->_serverinfo['version'] = $sth->fetchSingle();
     $this->commit();
     // required to match the try catch block above!
     $prefix = isset($dbparams['prefix']) ? $dbparams['prefix'] : '';
     $this->_table_names = array('page_tbl' => $prefix . 'page', 'version_tbl' => $prefix . 'version', 'link_tbl' => $prefix . 'link', 'recent_tbl' => $prefix . 'recent', 'nonempty_tbl' => $prefix . 'nonempty');
     $page_tbl = $this->_table_names['page_tbl'];
     $version_tbl = $this->_table_names['version_tbl'];
     $this->page_tbl_fields = "{$page_tbl}.id AS id, {$page_tbl}.pagename AS pagename, " . "{$page_tbl}.hits hits";
     $this->page_tbl_field_list = array('id', 'pagename', 'hits');
     $this->version_tbl_fields = "{$version_tbl}.version AS version, " . "{$version_tbl}.mtime AS mtime, " . "{$version_tbl}.minor_edit AS minor_edit, {$version_tbl}.content AS content, " . "{$version_tbl}.versiondata AS versiondata";
     $this->version_tbl_field_list = array('version', 'mtime', 'minor_edit', 'content', 'versiondata');
     $this->_expressions = array('maxmajor' => "MAX(CASE WHEN minor_edit=0 THEN version END)", 'maxminor' => "MAX(CASE WHEN minor_edit<>0 THEN version END)", 'maxversion' => "MAX(version)", 'notempty' => "<>''", 'iscontent' => "{$version_tbl}.content<>''");
     $this->_lock_count = 0;
 }
 /**
  * Constructor.
  * Create a new message source using SQLite.
  * @see MessageSource::factory();
  * @param string SQLite datasource, in PEAR's DB DSN format.
  */
 function __construct($source)
 {
     $dsn = parseDSN((string) $source);
     $this->source = $dsn['database'];
 }
Ejemplo n.º 7
0
 /**
  * Constructor.
  * Create a new message source using MySQL.
  * @param string MySQL datasource, in PEAR's DB DSN format.
  * @see MessageSource::factory();
  */
 function __construct($source)
 {
     $this->source = (string) $source;
     $this->dns = parseDSN($this->source);
     $this->db = $this->connect();
 }
Ejemplo n.º 8
0
 /**
  * Initialise la connexion à la base de données à partir d'une chaîne DSN
  * 
  * @param string $dsn
  */
 function WaDatabase($dsn)
 {
     if (!($tmp = parseDSN($dsn))) {
         trigger_error("Invalid DSN argument", E_USER_ERROR);
         return false;
     }
     list($infos, $options) = $tmp;
     $dbclass = 'Wadb_' . $infos['driver'];
     if (!class_exists($dbclass)) {
         require WA_ROOTDIR . "/includes/sql/{$infos['driver']}.php";
     }
     $infos['username'] = isset($infos['user']) ? $infos['user'] : null;
     $infos['passwd'] = isset($infos['pass']) ? $infos['pass'] : null;
     $db = new $dbclass($infos['dbname']);
     $db->connect($infos, $options);
     $encoding = $db->encoding();
     if (strncmp($infos['driver'], 'sqlite', 6) != 0 && preg_match('#^UTF-?(8|16)|UCS-?2|UNICODE$#i', $encoding)) {
         /*
          * WorkAround : Wanewsletter ne gère pas les codages de caractères multi-octets.
          * Si le jeu de caractères de la connexion est multi-octet, on le change
          * arbitrairement pour le latin1 et on affiche une alerte à l'utilisateur.
          */
         $newEncoding = 'latin1';
         $db->encoding($newEncoding);
         wanlog("<p>Wanewsletter a détecté que le <strong>jeu de caractères de connexion</strong>\nà votre base de données est réglé sur <q>{$encoding}</q>. Wanewsletter ne gère\npas les codages de caractères multi-octets et a donc changé cette valeur pour\n<q>{$newEncoding}</q>.</p>\n<p>Vous devriez éditer le fichier <samp>includes/config.inc.php</samp> et fixer\nce réglage en ajoutant la chaîne <code>?charset=latin1</code> après le nom de votre\nbase de données dans la variable <code>\$dsn</code> (<q>latin1</q> est utilisé\ndans l'exemple mais vous pouvez spécifier n'importe quel jeu de caractère 8 bit\nconvenant le mieux à votre langue. Référez-vous à la documentation de votre base\nde données pour connaître les jeux de caractères utilisables).</p>");
     }
     return $db;
 }
Ejemplo n.º 9
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     global $DBParams;
     //$request->setArg('nocache','1');
     extract($this->getArgs($argstr, $request));
     if (!$alias) {
         return $this->error(_("No DSN alias for SqlResult.ini specified"));
     }
     $sql = $this->_sql;
     // apply custom filters
     if ($where and strstr($sql, "%%where%%")) {
         $sql = str_replace("%%where%%", $where, $sql);
     }
     // TODO: use a SQL construction library?
     if ($limit) {
         $pagelist = new PageList();
         $limit = $pagelist->limit($limit);
         if (strstr($sql, "%%limit%%")) {
             $sql = str_replace("%%limit%%", $limit, $sql);
         } else {
             if (strstr($sql, "LIMIT")) {
                 $sql = preg_replace("/LIMIT\\s+[\\d,]+\\s+/m", "LIMIT " . $limit . " ", $sql);
             }
         }
     }
     if (strstr($sql, "%%sortby%%")) {
         if (!$sortby) {
             $sql = preg_replace("/ORDER BY .*%%sortby%%\\s/m", "", $sql);
         } else {
             $sql = str_replace("%%sortby%%", $sortby, $sql);
         }
     } elseif (PageList::sortby($sortby, 'db')) {
         // add sorting: support paging sortby links
         if (preg_match("/\\sORDER\\s/", $sql)) {
             $sql = preg_replace("/ORDER BY\\s\\S+\\s/m", "ORDER BY " . PageList::sortby($sortby, 'db'), $sql);
         } else {
             $sql .= " ORDER BY " . PageList::sortby($sortby, 'db');
         }
     }
     $inidsn = $this->getDsn($alias);
     if (!$inidsn) {
         return $this->error(sprintf(_("No DSN for alias %s in SqlResult.ini found"), $alias));
     }
     // adodb or pear? adodb as default, since we distribute per default it.
     // for pear there may be overrides.
     // TODO: native PDO support (for now we use ADODB)
     if ($DBParams['dbtype'] == 'SQL') {
         $dbh = DB::connect($inidsn);
         $all = $dbh->getAll($sql);
         if (DB::isError($all)) {
             return $this->error($all->getMessage() . ' ' . $all->userinfo);
         }
     } else {
         // unless PearDB use the included ADODB, regardless if dba, file or PDO, ...
         if ($DBParams['dbtype'] != 'ADODB') {
             // require_once('lib/WikiDB/adodb/adodb-errorhandler.inc.php');
             require_once 'lib/WikiDB/adodb/adodb.inc.php';
         }
         $parsed = parseDSN($inidsn);
         $dbh =& ADONewConnection($parsed['phptype']);
         $conn = $dbh->Connect($parsed['hostspec'], $parsed['username'], $parsed['password'], $parsed['database']);
         if (!$conn) {
             return $this->error($dbh->errorMsg());
         }
         $GLOBALS['ADODB_FETCH_MODE'] = ADODB_FETCH_ASSOC;
         $dbh->SetFetchMode(ADODB_FETCH_ASSOC);
         $all = $dbh->getAll($sql);
         $GLOBALS['ADODB_FETCH_MODE'] = ADODB_FETCH_NUM;
         $dbh->SetFetchMode(ADODB_FETCH_NUM);
         if (!$all) {
             return $this->error($dbh->errorMsg());
         }
     }
     $args = array();
     if ($limit) {
         // fill paging vars (see PageList)
         $args = $pagelist->pagingTokens(count($all), count($all[0]), $limit);
         if (!$args) {
             $args = array();
         }
     }
     if ($template) {
         $args = array_merge(array('SqlResult' => $all, 'ordered' => $ordered, 'where' => $where, 'sortby' => $sortby, 'limit' => $limit), $args);
         // paging params override given params
         return Template($template, $args);
     } else {
         if ($ordered) {
             $html = HTML::ol(array('class' => 'sqlresult'));
             if ($all) {
                 foreach ($all as $row) {
                     $html->pushContent(HTML::li(array('class' => $i++ % 2 ? 'evenrow' : 'oddrow'), $row[0]));
                 }
             }
         } else {
             $html = HTML::table(array('class' => 'sqlresult'));
             $i = 0;
             if ($all) {
                 foreach ($all as $row) {
                     $tr = HTML::tr(array('class' => $i++ % 2 ? 'evenrow' : 'oddrow'));
                     if ($row) {
                         foreach ($row as $col) {
                             $tr->pushContent(HTML::td($col));
                         }
                     }
                     $html->pushContent($tr);
                 }
             }
         }
     }
     // do paging via pagelink template
     if (!empty($args['NUMPAGES'])) {
         $paging = Template("pagelink", $args);
         $html = $table->pushContent(HTML::thead($paging), HTML::tbody($html), HTML::tfoot($paging));
     }
     if (0 and DEBUG) {
         // test deferred error/warning/notice collapsing
         trigger_error("test notice", E_USER_NOTICE);
         trigger_error("test warning", E_USER_WARNING);
     }
     return $html;
 }
Ejemplo n.º 10
0
     if ($row = $result->fetch()) {
         do {
             $reallow_ext_box .= sprintf("<option value=\"%d\">%s</option>\n\t", $row['fe_id'], $row['fe_ext']);
         } while ($row = $result->fetch());
     } else {
         $reallow_ext_box .= '<option value="0">' . $lang['No_forbidden_ext'] . '</option>';
     }
     $reallow_ext_box .= '</select>';
     $output->addHiddenField('sessid', $session->session_id);
     $output->set_filenames(array('tool_body' => 'forbidden_ext_body.tpl'));
     $output->assign_vars(array('L_TITLE_EXT' => $lang['Title']['attach'], 'L_EXPLAIN_TO_FORBID' => nl2br($lang['Explain']['forbid_ext']), 'L_EXPLAIN_TO_REALLOW' => nl2br($lang['Explain']['reallow_ext']), 'L_FORBID_EXT' => $lang['Forbid_ext'], 'L_REALLOW_EXT' => $lang['Reallow_ext'], 'L_VALID_BUTTON' => $lang['Button']['valid'], 'L_RESET_BUTTON' => $lang['Button']['reset'], 'REALLOW_EXT_BOX' => $reallow_ext_box, 'S_HIDDEN_FIELDS' => $output->getHiddenFields()));
     $output->assign_var_from_handle('TOOL_BODY', 'tool_body');
     break;
 case 'backup':
     $tables_wa = array(ABO_LISTE_TABLE, ABONNES_TABLE, ADMIN_TABLE, AUTH_ADMIN_TABLE, BANLIST_TABLE, CONFIG_TABLE, JOINED_FILES_TABLE, FORBIDDEN_EXT_TABLE, LISTE_TABLE, LOG_TABLE, LOG_FILES_TABLE, SESSIONS_TABLE);
     list($infos) = parseDSN($dsn);
     $tables = array();
     $tables_plus = !empty($_POST['tables_plus']) ? array_map('trim', $_POST['tables_plus']) : array();
     $backup_type = isset($_POST['backup_type']) ? intval($_POST['backup_type']) : 0;
     $drop_option = !empty($_POST['drop_option']) ? true : false;
     $backup = new $backupclass($infos);
     // Voir ligne 160 pour $infos et $backupclass
     $backup->eol = WA_EOL;
     $tables_ary = $backup->get_tables();
     foreach ($tables_ary as $tablename => $tabletype) {
         if (!isset($_POST['submit'])) {
             if (!in_array($tablename, $tables_wa)) {
                 $tables_plus[] = $tablename;
             }
         } else {
             if (in_array($tablename, $tables_wa) || in_array($tablename, $tables_plus)) {
Ejemplo n.º 11
0
function getListMailbox()
{
    try {
        $userAccounts = array();
        $regexpUsuario = '/^[a-z0-9]+([\\._\\-]?[a-z0-9]+[_\\-]?)*@[a-z0-9]+([\\._\\-]?[a-z0-9]+)*(\\.[a-z0-9]{2,6})+$/';
        $arrDBConn = parseDSN(generarDSNSistema("asteriskuser", "elxpbx"));
        $conn = new PDO($arrDBConn["dsn"], $arrDBConn["user"], $arrDBConn["passwd"]);
        $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        $sqlEmailInfo = <<<EMAIL_INFO
SELECT username FROM acl_user  
EMAIL_INFO;
        foreach ($conn->query($sqlEmailInfo) as $row) {
            if (preg_match($regexpUsuario, $row['username'])) {
                $userAccounts[] = $row['username'];
            }
        }
        return $userAccounts;
    } catch (PDOException $e) {
        wlog("ERR: failed to read account information - " . $e->getMessage() . "\n");
        return false;
    }
}
Ejemplo n.º 12
0
function _upgrade_db_init(&$dbh)
{
    global $request, $DBParams, $DBAuthParams;
    if (!in_array($DBParams['dbtype'], array('SQL', 'ADODB', 'PDO'))) {
        return;
    }
    if (DBADMIN_USER) {
        // if need to connect as the root user, for CREATE and ALTER privileges
        $AdminParams = $DBParams;
        if ($DBParams['dbtype'] == 'SQL') {
            $dsn = DB::parseDSN($AdminParams['dsn']);
        } else {
            // ADODB or PDO
            $dsn = parseDSN($AdminParams['dsn']);
        }
        $AdminParams['dsn'] = sprintf("%s://%s:%s@%s/%s", $dsn['phptype'], DBADMIN_USER, DBADMIN_PASSWD, $dsn['hostspec'], $dsn['database']);
        if (DEBUG & _DEBUG_SQL and $DBParams['dbtype'] == 'PDO') {
            echo "<br>\nDBParams['dsn']: '", $DBParams['dsn'], "'";
            echo "<br>\ndsn: '", print_r($dsn), "'";
            echo "<br>\nAdminParams['dsn']: '", $AdminParams['dsn'], "'";
        }
        $dbh = WikiDB::open($AdminParams);
    } elseif ($dbadmin = $request->getArg('dbadmin')) {
        if (empty($dbadmin['user']) or isset($dbadmin['cancel'])) {
            $dbh =& $request->_dbi;
        } else {
            $AdminParams = $DBParams;
            if ($DBParams['dbtype'] == 'SQL') {
                $dsn = DB::parseDSN($AdminParams['dsn']);
            } else {
                $dsn = parseDSN($AdminParams['dsn']);
            }
            $AdminParams['dsn'] = sprintf("%s://%s:%s@%s/%s", $dsn['phptype'], $dbadmin['user'], $dbadmin['passwd'], $dsn['hostspec'], $dsn['database']);
            $dbh = WikiDB::open($AdminParams);
        }
    } else {
        // Check if the privileges are enough. Need CREATE and ALTER perms.
        // And on windows: SELECT FROM mysql, possibly: UPDATE mysql.
        $form = HTML::form(array("method" => "post", "action" => $request->getPostURL(), "accept-charset" => $GLOBALS['charset']), HTML::p(_("Upgrade requires database privileges to CREATE and ALTER the phpwiki database."), HTML::br(), _("And on windows at least the privilege to SELECT FROM mysql, and possibly UPDATE mysql")), HiddenInputs(array('action' => 'upgrade')), HTML::table(array("cellspacing" => 4), HTML::tr(HTML::td(array('align' => 'right'), _("DB admin user:"******"dbadmin[user]", 'size' => 12, 'maxlength' => 256, 'value' => 'root')))), HTML::tr(HTML::td(array('align' => 'right'), _("DB admin password:"******"dbadmin[passwd]", 'type' => 'password', 'size' => 12, 'maxlength' => 256)))), HTML::tr(HTML::td(array('align' => 'center', 'colspan' => 2), Button("submit:", _("Submit"), 'wikiaction'), HTML::raw('&nbsp;'), Button("submit:dbadmin[cancel]", _("Cancel"), 'button')))));
        $form->printXml();
        echo "</div><!-- content -->\n";
        echo asXML(Template("bottom"));
        echo "</body></html>\n";
        $request->finish();
        exit;
    }
}
Ejemplo n.º 13
0
 function _try_dbadmin_user($user, $passwd)
 {
     global $DBParams, $DBAuthParams;
     $AdminParams = $DBParams;
     if (DATABASE_TYPE == 'SQL') {
         $dsn = DB::parseDSN($AdminParams['dsn']);
     } else {
         $dsn = parseDSN($AdminParams['dsn']);
     }
     $AdminParams['dsn'] = sprintf("%s://%s:%s@%s/%s", $dsn['phptype'], $user, $passwd, $dsn['hostspec'], $dsn['database']);
     $AdminParams['_tryroot_from_upgrade'] = 1;
     // add error handler to warn about missing permissions for DBADMIN_USER
     global $ErrorManager;
     $ErrorManager->pushErrorHandler(new WikiMethodCb($this, '_dbpermission_filter'));
     $this->error_caught = 0;
     $this->dbi = WikiDB::open($AdminParams);
     if (!$this->error_caught) {
         return true;
     }
     // FAILED: redo our connection with the wikiuser
     $this->dbi = WikiDB::open($DBParams);
     $ErrorManager->flushPostponedErrors();
     $ErrorManager->popErrorHandler();
     return false;
 }
Ejemplo n.º 14
0
    if (!is_array($dsn) || count($dsn) % 2 != 1) {
        throw new PException('DSN parse error!');
    }
    $args = array();
    for ($i = 1; $i < count($dsn); $i++) {
        if ($i % 2 == 0) {
            continue;
        }
        $args[$dsn[$i]] = $dsn[$i + 1];
    }
    return array("provider" => $dsn[0], "dsn" => $args);
}
$config = array();
$inifile = parse_ini_file('rox_local.ini', true);
if (!empty($inifile)) {
    $parsedDSN = parseDSN($inifile['db']['dsn']);
    $provider = $parsedDSN['provider'];
    $dsn = $parsedDSN['dsn'];
    $host = $dsn['host'];
    $dbname = $dsn['dbname'];
    $user = $inifile['db']['user'];
    $password = $inifile['db']['password'];
    $production = false;
    if (isset($inifile['syshcvol']['SiteName'])) {
        $site = $inifile['syshcvol']['SiteName'];
        if ($site == 'www.bewelcome.org' | $site == 'beta.bewelcome.org') {
            $production = true;
        }
    }
    $config = array("paths" => array("migrations" => "%%PHINX_CONFIG_DIR%%/migrations"), "environments" => array("default_migration_table" => "phinxlog", "default_database" => "testing"));
    if ($production) {