• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP rcube_db类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中rcube_db的典型用法代码示例。如果您正苦于以下问题:PHP rcube_db类的具体用法?PHP rcube_db怎么用?PHP rcube_db使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了rcube_db类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: password_save

/**
 * i-MSCP - internet Multi Server Control Panel
 * Copyright (C) 2010-2011 by i-MSCP team
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * @category	iMSCP
 * @package	 iMSCP Roundcube password changer
 * @copyright   2010-2011 by i-MSCP team
 * @author 		Sascha Bay
 * @link		http://www.i-mscp.net i-MSCP Home Site
 * @license	 http://www.gnu.org/licenses/gpl-2.0.html GPL v2
 */
function password_save($passwd)
{
    $rcmail = rcmail::get_instance();
    $sql = "UPDATE `mail_users` SET `mail_pass` = %p WHERE `mail_addr` = %u LIMIT 1";
    if ($dsn = $rcmail->config->get('password_db_dsn')) {
        // #1486067: enable new_link option
        if (is_array($dsn) && empty($dsn['new_link'])) {
            $dsn['new_link'] = true;
        } else {
            if (!is_array($dsn) && !preg_match('/\\?new_link=true/', $dsn)) {
                $dsn .= '?new_link=true';
            }
        }
        $db = rcube_db::factory($dsn, '', false);
        $db->set_debug((bool) $rcmail->config->get('sql_debug'));
        $db->db_connect('w');
    }
    if ($err = $db->is_error()) {
        return PASSWORD_ERROR;
    }
    $sql = str_replace('%u', $db->quote($_SESSION['username'], 'text'), $sql);
    $sql = str_replace('%p', $db->quote($passwd, 'text'), $sql);
    $res = $db->query($sql);
    if (!$db->is_error()) {
        if ($db->affected_rows($res) == 1) {
            return PASSWORD_SUCCESS;
            // This is the good case: 1 row updated
        }
    }
    return PASSWORD_ERROR;
}
开发者ID:elurofilico,项目名称:i-MSCP-plugins,代码行数:56,代码来源:sql.php


示例2: mail_forward_write

function mail_forward_write(array &$data)
{
    $rcmail = rcmail::get_instance();
    if ($dsn = $rcmail->config->get('forward_sql_dsn')) {
        if (is_array($dsn) && empty($dsn['new_link'])) {
            $dsn['new_link'] = true;
        } else {
            if (!is_array($dsn) && !preg_match('/\\?new_link=true/', $dsn)) {
                $dsn .= '?new_link=true';
            }
        }
        $db = rcube_db::factory($dsn, '', FALSE);
        $db->set_debug((bool) $rcmail->config->get('sql_debug'));
        $db->db_connect('w');
    } else {
        $db = $rcmail->get_dbh();
    }
    if ($err = $db->is_error()) {
        return PLUGIN_ERROR_CONNECT;
    }
    $search = array('%address', '%goto', '%modified');
    $replace = array($db->quote($data['address']), $db->quote($data['goto']), $db->quote($data['modified']));
    $query = str_replace($search, $replace, $rcmail->config->get('forward_sql_write'));
    $sql_result = $db->query($query);
    if ($err = $db->is_error()) {
        return PLUGIN_ERROR_PROCESS;
    }
    return PLUGIN_SUCCESS;
}
开发者ID:freedomson,项目名称:roundcube-forward,代码行数:29,代码来源:sql.php


示例3: get_dbh

 /**
  * Get the current database connection
  *
  * @return rcube_db Database object
  */
 public function get_dbh()
 {
     if (!$this->db) {
         $this->db = rcube_db::factory($this->config->get('db_dsnw'), $this->config->get('db_dsnr'), $this->config->get('db_persistent'));
         $this->db->set_debug((bool) $this->config->get('sql_debug'));
     }
     return $this->db;
 }
开发者ID:neynah,项目名称:roundcubemail,代码行数:13,代码来源:rcube.php


示例4: get_dbh

 /**
  * Get the current database connection
  *
  * @return rcube_db Database object
  */
 public function get_dbh()
 {
     if (!$this->db) {
         $config_all = $this->config->all();
         $this->db = rcube_db::factory($config_all['db_dsnw'], $config_all['db_dsnr'], $config_all['db_persistent']);
         $this->db->set_debug((bool) $config_all['sql_debug']);
     }
     return $this->db;
 }
开发者ID:zamentur,项目名称:roundcube_ynh,代码行数:14,代码来源:rcube.php


示例5: _db_connect

 private function _db_connect($mode)
 {
     $this->db = rcube_db::factory($this->config['db_dsn'], '', false);
     $this->db->db_connect($mode);
     // check DB connections and exit on failure
     if ($err_str = $this->db->is_error()) {
         raise_error(array('code' => 603, 'type' => 'db', 'message' => $err_str), FALSE, TRUE);
     }
 }
开发者ID:soujak,项目名称:VeximAccountAdmin,代码行数:9,代码来源:veximaccountadmin.php


示例6: _do_list

 private function _do_list($uids, $spam)
 {
     $rcmail = rcube::get_instance();
     $this->sa_user = $rcmail->config->get('sauserprefs_userid', "%u");
     $this->sa_table = $rcmail->config->get('sauserprefs_sql_table_name');
     $this->sa_username_field = $rcmail->config->get('sauserprefs_sql_username_field');
     $this->sa_preference_field = $rcmail->config->get('sauserprefs_sql_preference_field');
     $this->sa_value_field = $rcmail->config->get('sauserprefs_sql_value_field');
     $identity_arr = $rcmail->user->get_identity();
     $identity = $identity_arr['email'];
     $this->sa_user = str_replace('%u', $_SESSION['username'], $this->sa_user);
     $this->sa_user = str_replace('%l', $rcmail->user->get_username('local'), $this->sa_user);
     $this->sa_user = str_replace('%d', $rcmail->user->get_username('domain'), $this->sa_user);
     $this->sa_user = str_replace('%i', $identity, $this->sa_user);
     if (is_file($rcmail->config->get('markasjunk2_sauserprefs_config')) && !$rcmail->config->load_from_file($rcmail->config->get('markasjunk2_sauserprefs_config'))) {
         rcube::raise_error(array('code' => 527, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Failed to load config from " . $rcmail->config->get('markasjunk2_sauserprefs_config')), true, false);
         return false;
     }
     $db = rcube_db::factory($rcmail->config->get('sauserprefs_db_dsnw'), $rcmail->config->get('sauserprefs_db_dsnr'), $rcmail->config->get('sauserprefs_db_persistent'));
     $db->set_debug((bool) $rcmail->config->get('sql_debug'));
     $db->db_connect('w');
     // check DB connections and exit on failure
     if ($err_str = $db->is_error()) {
         rcube::raise_error(array('code' => 603, 'type' => 'db', 'message' => $err_str), FALSE, TRUE);
     }
     foreach ($uids as $uid) {
         $message = new rcube_message($uid);
         $email = $message->sender['mailto'];
         if ($spam) {
             // delete any whitelisting for this address
             $db->query("DELETE FROM `{$this->sa_table}` WHERE `{$this->sa_username_field}` = ? AND `{$this->sa_preference_field}` = ? AND `{$this->sa_value_field}` = ?;", $this->sa_user, 'whitelist_from', $email);
             // check address is not already blacklisted
             $sql_result = $db->query("SELECT `value` FROM `{$this->sa_table}` WHERE `{$this->sa_username_field}` = ? AND `{$this->sa_preference_field}` = ? AND `{$this->sa_value_field}` = ?;", $this->sa_user, 'blacklist_from', $email);
             if (!$db->fetch_array($sql_result)) {
                 $db->query("INSERT INTO `{$this->sa_table}` (`{$this->sa_username_field}`, `{$this->sa_preference_field}`, `{$this->sa_value_field}`) VALUES (?, ?, ?);", $this->sa_user, 'blacklist_from', $email);
                 if ($rcmail->config->get('markasjunk2_debug')) {
                     rcube::write_log('markasjunk2', $this->sa_user . ' blacklist ' . $email);
                 }
             }
         } else {
             // delete any blacklisting for this address
             $db->query("DELETE FROM `{$this->sa_table}` WHERE `{$this->sa_username_field}` = ? AND `{$this->sa_preference_field}` = ? AND `{$this->sa_value_field}` = ?;", $this->sa_user, 'blacklist_from', $email);
             // check address is not already whitelisted
             $sql_result = $db->query("SELECT `value` FROM `{$this->sa_table}` WHERE `{$this->sa_username_field}` = ? AND `{$this->sa_preference_field}` = ? AND `{$this->sa_value_field}` = ?;", $this->sa_user, 'whitelist_from', $email);
             if (!$db->fetch_array($sql_result)) {
                 $db->query("INSERT INTO `{$this->sa_table}` (`{$this->sa_username_field}`, `{$this->sa_preference_field}`, `{$this->sa_value_field}`) VALUES (?, ?, ?);", $this->sa_user, 'whitelist_from', $email);
                 if ($rcmail->config->get('markasjunk2_debug')) {
                     rcube::write_log('markasjunk2', $this->sa_user . ' whitelist ' . $email);
                 }
             }
         }
     }
 }
开发者ID:nciftci,项目名称:plugins,代码行数:53,代码来源:sa_blacklist.php


示例7: db

 /**
  * Initialize database object and connect
  *
  * @return rcube_db Database instance
  */
 public static function db()
 {
     if (self::$db === null) {
         $rc = rcube::get_instance();
         $db = rcube_db::factory($rc->config->get('db_dsnw'));
         $db->set_debug((bool) $rc->config->get('sql_debug'));
         // Connect to database
         $db->db_connect('w');
         if (!$db->is_connected()) {
             rcube::raise_error("Error connecting to database: " . $db->is_error(), false, true);
         }
         self::$db = $db;
     }
     return self::$db;
 }
开发者ID:JotapePinheiro,项目名称:roundcubemail,代码行数:20,代码来源:rcmail_utils.php


示例8: init_db

 private function init_db()
 {
     if (!$this->db_conn) {
         if (!class_exists('rcube_db')) {
             // Version: < 0.9
             $this->db_conn = new rcube_mdb2($this->db_config, '', true);
         } else {
             // Version: > 0.9
             $this->db_conn = rcube_db::factory($this->db_config, '', true);
         }
     }
     $this->db_conn->db_connect('w');
     // Error check
     if ($error = $this->db_conn->is_error()) {
         $this->rc->amacube->errors[] = 'db_connect_error';
         write_log('errors', 'AMACUBE: Database connect error: ' . $error);
         return false;
     }
     return true;
 }
开发者ID:Takika,项目名称:amacube,代码行数:20,代码来源:database_driver.php


示例9: _do_list

 private function _do_list($uids, $spam)
 {
     $rcmail = rcube::get_instance();
     if (is_file($rcmail->config->get('markasjunk2_sauserprefs_config')) && !$rcmail->config->load_from_file($rcmail->config->get('markasjunk2_sauserprefs_config'))) {
         rcube::raise_error(array('code' => 527, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Failed to load config from " . $rcmail->config->get('markasjunk2_sauserprefs_config')), true, false);
         return false;
     }
     $db = rcube_db::factory($rcmail->config->get('sauserprefs_db_dsnw'), $rcmail->config->get('sauserprefs_db_dsnr'), $rcmail->config->get('sauserprefs_db_persistent'));
     $db->db_connect('w');
     // check DB connections and exit on failure
     if ($err_str = $db->is_error()) {
         rcube::raise_error(array('code' => 603, 'type' => 'db', 'message' => $err_str), FALSE, TRUE);
     }
     foreach (explode(",", $uids) as $uid) {
         $message = new rcube_message($uid);
         $email = $message->sender['mailto'];
         if ($spam) {
             // delete any whitelisting for this address
             $db->query("DELETE FROM " . $rcmail->config->get('sauserprefs_sql_table_name') . " WHERE " . $rcmail->config->get('sauserprefs_sql_username_field') . " = ? AND " . $rcmail->config->get('sauserprefs_sql_preference_field') . " = ? AND " . $rcmail->config->get('sauserprefs_sql_value_field') . " = ?;", $_SESSION['username'], 'whitelist_from', $email);
             // check address is not already blacklisted
             $sql_result = $db->query("SELECT value FROM " . $rcmail->config->get('sauserprefs_sql_table_name') . " WHERE " . $rcmail->config->get('sauserprefs_sql_username_field') . " = ? AND " . $rcmail->config->get('sauserprefs_sql_preference_field') . " = ? AND " . $rcmail->config->get('sauserprefs_sql_value_field') . " = ?;", $_SESSION['username'], 'blacklist_from', $email);
             if (!$db->fetch_array($sql_result)) {
                 $db->query("INSERT INTO " . $rcmail->config->get('sauserprefs_sql_table_name') . " (" . $rcmail->config->get('sauserprefs_sql_username_field') . ", " . $rcmail->config->get('sauserprefs_sql_preference_field') . ", " . $rcmail->config->get('sauserprefs_sql_value_field') . ") VALUES (?, ?, ?);", $_SESSION['username'], 'blacklist_from', $email);
                 if ($rcmail->config->get('markasjunk2_debug')) {
                     rcube::write_log('markasjunk2', $_SESSION['username'] . ' blacklist ' . $email);
                 }
             }
         } else {
             // delete any blacklisting for this address
             $db->query("DELETE FROM " . $rcmail->config->get('sauserprefs_sql_table_name') . " WHERE " . $rcmail->config->get('sauserprefs_sql_username_field') . " = ? AND " . $rcmail->config->get('sauserprefs_sql_preference_field') . " = ? AND " . $rcmail->config->get('sauserprefs_sql_value_field') . " = ?;", $_SESSION['username'], 'blacklist_from', $email);
             // check address is not already whitelisted
             $sql_result = $db->query("SELECT value FROM " . $rcmail->config->get('sauserprefs_sql_table_name') . " WHERE " . $rcmail->config->get('sauserprefs_sql_username_field') . " = ? AND " . $rcmail->config->get('sauserprefs_sql_preference_field') . " = ? AND " . $rcmail->config->get('sauserprefs_sql_value_field') . " = ?;", $_SESSION['username'], 'whitelist_from', $email);
             if (!$db->fetch_array($sql_result)) {
                 $db->query("INSERT INTO " . $rcmail->config->get('sauserprefs_sql_table_name') . " (" . $rcmail->config->get('sauserprefs_sql_username_field') . ", " . $rcmail->config->get('sauserprefs_sql_preference_field') . ", " . $rcmail->config->get('sauserprefs_sql_value_field') . ") VALUES (?, ?, ?);", $_SESSION['username'], 'whitelist_from', $email);
                 if ($rcmail->config->get('markasjunk2_debug')) {
                     rcube::write_log('markasjunk2', $_SESSION['username'] . ' whitelist ' . $email);
                 }
             }
         }
     }
 }
开发者ID:elurofilico,项目名称:i-MSCP-plugins,代码行数:41,代码来源:sa_blacklist.php


示例10: init_db

 /**
  * Wipe and re-initialize (mysql) database
  */
 public static function init_db()
 {
     $rcmail = rcmail::get_instance();
     $dsn = rcube_db::parse_dsn($rcmail->config->get('db_dsnw'));
     if ($dsn['phptype'] == 'mysql' || $dsn['phptype'] == 'mysqli') {
         // drop all existing tables first
         $db = $rcmail->get_dbh();
         $db->query("SET FOREIGN_KEY_CHECKS=0");
         $sql_res = $db->query("SHOW TABLES");
         while ($sql_arr = $db->fetch_array($sql_res)) {
             $table = reset($sql_arr);
             $db->query("DROP TABLE {$table}");
         }
         // init database with schema
         system(sprintf('cat %s %s | mysql -h %s -u %s --password=%s %s', realpath(INSTALL_PATH . '/SQL/mysql.initial.sql'), realpath(TESTS_DIR . 'Selenium/data/mysql.sql'), escapeshellarg($dsn['hostspec']), escapeshellarg($dsn['username']), escapeshellarg($dsn['password']), escapeshellarg($dsn['database'])));
     } else {
         if ($dsn['phptype'] == 'sqlite') {
             // delete database file -- will be re-initialized on first access
             system(sprintf('rm -f %s', escapeshellarg($dsn['database'])));
         }
     }
 }
开发者ID:noikiy,项目名称:roundcubemail,代码行数:25,代码来源:bootstrap.php


示例11: hmail_db_connect

function hmail_db_connect()
{
    $rcmail = rcube::get_instance();
    if ($dsn = $rcmail->config->get('companyaddressbook_db_dsnw')) {
        $db = new rcube_db($dsn, '', FALSE);
        $db->set_debug((bool) $rcmail->config->get('sql_debug'));
        $db->db_connect('w');
        $sql = 'SELECT * FROM hm_dbversion LIMIT 1';
        $result = $db->query($sql);
        if ($db->error) {
            return false;
        }
        $v = $db->fetch_assoc($result);
        if ($v['value'] >= HMAIL_DB_VERSION_MIN && $v['value'] <= HMAIL_DB_VERSION_MAX) {
            return $db;
        } else {
            return false;
        }
    } else {
        return false;
    }
}
开发者ID:MetallianFR68,项目名称:myroundcube,代码行数:22,代码来源:driver.php


示例12: getHmsDb

 function getHmsDb()
 {
     $dbConf = $this->rc->config->get('hmailserver_server_for_hmsrc');
     $dsn = $dbConf['Protocol'] . "://" . $dbConf['Username'] . ":" . $dbConf['Password'] . "@" . $dbConf['Server'] . "/" . $dbConf["Database"];
     $db = rcube_db::factory($dsn, "", false);
     $db->db_connect('w');
     return $db;
 }
开发者ID:hazarkarabay,项目名称:hmsfromrc,代码行数:8,代码来源:hmsfromrc.php


示例13: _db_connect

 private function _db_connect($mode)
 {
     if (!$this->db) {
         $this->db = rcube_db::factory($this->db_dsnw, $this->db_dsnr, $this->db_persistent);
     }
     $this->db->db_connect($mode);
     // check DB connections and exit on failure
     if ($err_str = $this->db->is_error()) {
         raise_error(array('code' => 603, 'type' => 'db', 'message' => $err_str), false, true);
     }
 }
开发者ID:elurofilico,项目名称:i-MSCP-plugins,代码行数:11,代码来源:rcube_sauserprefs_storage.php


示例14: _do_list

 private function _do_list($uids, $spam)
 {
     $rcmail = rcmail::get_instance();
     $this->user_email = $rcmail->user->data['username'];
     if (is_file($rcmail->config->get('markasjunk2_amacube_config')) && !$rcmail->config->load_from_file($rcmail->config->get('markasjunk2_amacube_config'))) {
         rcube::raise_error(array('code' => 527, 'type' => 'php', 'file' => __FILE__, 'line' => __LINE__, 'message' => "Failed to load config from " . $rcmail->config->get('markasjunk2_amacube_config')), true, false);
         return false;
     }
     $db = rcube_db::factory($rcmail->config->get('amacube_db_dsn'), '', TRUE);
     $db->set_debug((bool) $rcmail->config->get('sql_debug'));
     $db->db_connect('w');
     // check DB connections and exit on failure
     if ($err_str = $db->is_error()) {
         rcube::raise_error(array('code' => 603, 'type' => 'db', 'message' => $err_str), FALSE, TRUE);
     }
     $sql_result = $db->query("SELECT `id` FROM `users` WHERE `email` = ?", $this->user_email);
     if ($sql_result && ($res_array = $db->fetch_assoc($sql_result))) {
         $rid = $res_array['id'];
     } else {
         if ($rcmail->config->get('markasjunk2_debug')) {
             rcube::write_log('markasjunk2', $this->user_email . ' not found in users table');
         }
         return false;
     }
     foreach ($uids as $uid) {
         $message = new rcube_message($uid);
         $email = $message->sender['mailto'];
         $sql_result = $db->query("SELECT `id` FROM `mailaddr` WHERE `email` = ? ORDER BY `priority` DESC", $email);
         if ($sql_result && ($res_array = $db->fetch_assoc($sql_result))) {
             $sid = $res_array['id'];
         } else {
             if ($rcmail->config->get('markasjunk2_debug')) {
                 rcube::write_log('markasjunk2', $email . ' not found in mailaddr table - add it');
             }
             $sql_result = $db->query("INSERT INTO `mailaddr` ( `priority`, `email` ) VALUES ( 20, ? )", $email);
             if ($sql_result) {
                 $sid = $db->insert_id();
             } else {
                 if ($rcmail->config->get('markasjunk2_debug')) {
                     rcube::write_log('markasjunk2', 'Cannot add ' . $email . ' to mailaddr table: ' . $db->is_error($sql_result));
                 }
                 return false;
             }
         }
         $wb = '';
         $sql_result = $db->query("SELECT `wb` FROM `wblist` WHERE `sid` = ? AND `rid` =?", $sid, $rid);
         if ($sql_result && ($res_array = $db->fetch_assoc($sql_result))) {
             $wb = $res_array['wb'];
         }
         if (!$wb || !$spam && preg_match('/^([BbNnFf])[ ]*\\z/', $wb) || $spam && preg_match('/^([WwYyTt])[ ]*\\z/', $wb)) {
             $newwb = 'w';
             if ($spam) {
                 $newwb = 'b';
             }
             if ($wb) {
                 $sql_result = $db->query('UPDATE `wblist` SET `wb` = ? WHERE `sid` = ? AND `rid` = ?', $newwb, $sid, $rid);
             } else {
                 $sql_result = $db->query('INSERT INTO `wblist` (`sid`, `rid`, `wb`) VALUES (?,?,?)', $sid, $rid, $newwb);
             }
             if (!$sql_result) {
                 if ($rcmail->config->get('markasjunk2_debug')) {
                     rcube::write_log('markasjunk2', 'Cannot update wblist for user ' . $this->user_email . ' with ' . $email);
                 }
                 return false;
             }
         }
     }
 }
开发者ID:aalmenar,项目名称:Roundcube-Plugin-Mark-as-Junk-2,代码行数:68,代码来源:amavis_blacklist.php


示例15: html_select

<dl class="configblock" id="cgfblockdb">
<dt class="propname">db_dsnw</dt>
<dd>
<p>Database settings for read/write operations:</p>
<?php 
$select_dbtype = new html_select(array('name' => '_dbtype', 'id' => "cfgdbtype"));
foreach ($RCI->supported_dbs as $database => $ext) {
    if (extension_loaded($ext)) {
        $select_dbtype->add($database, substr($ext, 4));
    }
}
$input_dbhost = new html_inputfield(array('name' => '_dbhost', 'size' => 20, 'id' => "cfgdbhost"));
$input_dbname = new html_inputfield(array('name' => '_dbname', 'size' => 20, 'id' => "cfgdbname"));
$input_dbuser = new html_inputfield(array('name' => '_dbuser', 'size' => 20, 'id' => "cfgdbuser"));
$input_dbpass = new html_passwordfield(array('name' => '_dbpass', 'size' => 20, 'id' => "cfgdbpass"));
$dsnw = rcube_db::parse_dsn($RCI->getprop('db_dsnw'));
echo $select_dbtype->show($RCI->is_post ? $_POST['_dbtype'] : $dsnw['phptype']);
echo '<label for="cfgdbtype">Database type</label><br />';
echo $input_dbhost->show($RCI->is_post ? $_POST['_dbhost'] : $dsnw['hostspec']);
echo '<label for="cfgdbhost">Database server (omit for sqlite)</label><br />';
echo $input_dbname->show($RCI->is_post ? $_POST['_dbname'] : $dsnw['database']);
echo '<label for="cfgdbname">Database name (use absolute path and filename for sqlite)</label><br />';
echo $input_dbuser->show($RCI->is_post ? $_POST['_dbuser'] : $dsnw['username']);
echo '<label for="cfgdbuser">Database user name (needs write permissions)(omit for sqlite)</label><br />';
echo $input_dbpass->show($RCI->is_post ? $_POST['_dbpass'] : $dsnw['password']);
echo '<label for="cfgdbpass">Database password (omit for sqlite)</label><br />';
?>
</dd>

<dt class="propname">db_prefix</dt>
<dd>
开发者ID:StudsPro,项目名称:islandpeeps.com,代码行数:31,代码来源:config.php


示例16: get_dbh

 /**
  * Initialize database handler
  */
 function get_dbh()
 {
     if (!$this->db) {
         if ($dsn = $this->app->config->get('virtuser_query_dsn')) {
             // connect to the virtuser database
             $this->db = rcube_db::factory($dsn);
             $this->db->set_debug((bool) $this->app->config->get('sql_debug'));
             $this->db->db_connect('r');
             // connect in read mode
         } else {
             $this->db = $this->app->get_dbh();
         }
     }
     return $this->db;
 }
开发者ID:jimjag,项目名称:roundcubemail,代码行数:18,代码来源:virtuser_query.php


示例17: save

 function save($curpass, $passwd)
 {
     $rcmail = rcmail::get_instance();
     if (!($sql = $rcmail->config->get('password_query'))) {
         $sql = 'SELECT update_passwd(%c, %u)';
     }
     if ($dsn = $rcmail->config->get('password_db_dsn')) {
         // #1486067: enable new_link option
         if (is_array($dsn) && empty($dsn['new_link'])) {
             $dsn['new_link'] = true;
         } else {
             if (!is_array($dsn) && !preg_match('/\\?new_link=true/', $dsn)) {
                 $dsn .= '?new_link=true';
             }
         }
         $db = rcube_db::factory($dsn, '', false);
         $db->set_debug((bool) $rcmail->config->get('sql_debug'));
         $db->db_connect('w');
     } else {
         $db = $rcmail->get_dbh();
     }
     if ($db->is_error()) {
         return PASSWORD_ERROR;
     }
     // crypted password
     if (strpos($sql, '%c') !== FALSE) {
         $salt = '';
         if (!($crypt_hash = $rcmail->config->get('password_crypt_hash'))) {
             if (CRYPT_MD5) {
                 $crypt_hash = 'md5';
             } else {
                 if (CRYPT_STD_DES) {
                     $crypt_hash = 'des';
                 }
             }
         }
         switch ($crypt_hash) {
             case 'md5':
                 $len = 8;
                 $salt_hashindicator = '$1$';
                 break;
             case 'des':
                 $len = 2;
                 break;
             case 'blowfish':
                 $cost = (int) $rcmail->config->get('password_blowfish_cost');
                 $cost = $cost < 4 || $cost > 31 ? 12 : $cost;
                 $len = 22;
                 $salt_hashindicator = sprintf('$2a$%02d$', $cost);
                 break;
             case 'sha256':
                 $len = 16;
                 $salt_hashindicator = '$5$';
                 break;
             case 'sha512':
                 $len = 16;
                 $salt_hashindicator = '$6$';
                 break;
             default:
                 return PASSWORD_CRYPT_ERROR;
         }
         //Restrict the character set used as salt (#1488136)
         $seedchars = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
         for ($i = 0; $i < $len; $i++) {
             $salt .= $seedchars[rand(0, 63)];
         }
         $sql = str_replace('%c', $db->quote(crypt($passwd, $salt_hashindicator ? $salt_hashindicator . $salt . '$' : $salt)), $sql);
     }
     // dovecotpw
     if (strpos($sql, '%D') !== FALSE) {
         if (!($dovecotpw = $rcmail->config->get('password_dovecotpw'))) {
             $dovecotpw = 'dovecotpw';
         }
         if (!($method = $rcmail->config->get('password_dovecotpw_method'))) {
             $method = 'CRAM-MD5';
         }
         // use common temp dir
         $tmp_dir = $rcmail->config->get('temp_dir');
         $tmpfile = tempnam($tmp_dir, 'roundcube-');
         $pipe = popen("{$dovecotpw} -s '{$method}' > '{$tmpfile}'", "w");
         if (!$pipe) {
             unlink($tmpfile);
             return PASSWORD_CRYPT_ERROR;
         } else {
             fwrite($pipe, $passwd . "\n", 1 + strlen($passwd));
             usleep(1000);
             fwrite($pipe, $passwd . "\n", 1 + strlen($passwd));
             pclose($pipe);
             $newpass = trim(file_get_contents($tmpfile), "\n");
             if (!preg_match('/^\\{' . $method . '\\}/', $newpass)) {
                 return PASSWORD_CRYPT_ERROR;
             }
             if (!$rcmail->config->get('password_dovecotpw_with_method')) {
                 $newpass = trim(str_replace('{' . $method . '}', '', $newpass));
             }
             unlink($tmpfile);
         }
         $sql = str_replace('%D', $db->quote($newpass), $sql);
     }
     // hashed passwords
//.........这里部分代码省略.........
开发者ID:bbspike,项目名称:sentora-core,代码行数:101,代码来源:sql.php


示例18: read_squirrel_prefs

 private function read_squirrel_prefs($uname)
 {
     $rcmail = rcmail::get_instance();
     /**** File based backend ****/
     if ($rcmail->config->get('squirrelmail_driver') == 'file' && ($srcdir = $rcmail->config->get('squirrelmail_data_dir'))) {
         if (($hash_level = $rcmail->config->get('squirrelmail_data_dir_hash_level')) > 0) {
             $srcdir = slashify($srcdir) . chunk_split(substr(base_convert(crc32($uname), 10, 16), 0, $hash_level), 1, '/');
         }
         $prefsfile = slashify($srcdir) . $uname . '.pref';
         $abookfile = slashify($srcdir) . $uname . '.abook';
         $sigfile = slashify($srcdir) . $uname . '.sig';
         $sigbase = slashify($srcdir) . $uname . '.si';
         if (is_readable($prefsfile)) {
             $this->prefs = array();
             foreach (file($prefsfile) as $line) {
                 list($key, $value) = explode('=', $line);
                 $this->prefs[$key] = utf8_encode(rtrim($value));
             }
             // also read signature file if exists
             if (is_readable($sigfile)) {
                 $this->prefs['___signature___'] = utf8_encode(file_get_contents($sigfile));
             }
             if (isset($this->prefs['identities']) && $this->prefs['identities'] > 1) {
                 for ($i = 1; $i < $this->prefs['identities']; $i++) {
                     // read signature file if exists
                     if (is_readable($sigbase . $i)) {
                         $this->prefs['___sig' . $i . '___'] = utf8_encode(file_get_contents($sigbase . $i));
                     }
                 }
             }
             // parse addres book file
             if (filesize($abookfile)) {
                 foreach (file($abookfile) as $line) {
                     list($rec['name'], $rec['firstname'], $rec['surname'], $rec['email']) = explode('|', utf8_encode(rtrim($line)));
                     if ($rec['name'] && $rec['email']) {
                         $this->abook[] = $rec;
                     }
                 }
             }
         }
     } else {
         if ($rcmail->config->get('squirrelmail_driver') == 'sql') {
             $this->prefs = array();
             /* connect to squirrelmail database */
             $db = rcube_db::factory($rcmail->config->get('squirrelmail_dsn'));
             $db->set_debug($rcmail->config->get('sql_debug'));
             $db->db_connect('r');
             // connect in read mode
             /* retrieve prefs */
             $userprefs_table = $rcmail->config->get('squirrelmail_userprefs_table');
             $address_table = $rcmail->config->get('squirrelmail_address_table');
             $db_charset = $rcmail->config->get('squirrelmail_db_charset');
             if ($db_charset) {
                 $db->query('SET NAMES ' . $db_charset);
             }
             $sql_result = $db->query('SELECT * FROM ' . $userprefs_table . ' WHERE user=?', $uname);
             // ? is replaced with emailaddress
             while ($sql_array = $db->fetch_assoc($sql_result)) {
                 // fetch one row from result
                 $this->prefs[$sql_array['prefkey']] = rcube_charset::convert(rtrim($sql_array['prefval']), $db_charset);
             }
             /* retrieve address table data */
             $sql_result = $db->query('SELECT * FROM ' . $address_table . ' WHERE owner=?', $uname);
             // ? is replaced with emailaddress
             // parse addres book
             while ($sql_array = $db->fetch_assoc($sql_result)) {
                 // fetch one row from result
                 $rec['name'] = rcube_charset::convert(rtrim($sql_array['nickname']), $db_charset);
                 $rec['firstname'] = rcube_charset::convert(rtrim($sql_array['firstname']), $db_charset);
                 $rec['surname'] = rcube_charset::convert(rtrim($sql_array['lastname']), $db_charset);
                 $rec['email'] = rcube_charset::convert(rtrim($sql_array['email']), $db_charset);
                 $rec['notes'] = rcube_charset::convert(rtrim($sql_array['label']), $db_charset);
                 if ($rec['name'] && $rec['email']) {
                     $this->abook[] = $rec;
                 }
             }
         }
     }
     // end if 'sql'-driver
 }
开发者ID:bbspike,项目名称:sentora-core,代码行数:80,代码来源:squirrelmail_usercopy.php


示例19: max_packet_size

 /**
  * Determine the maximum size for cache data to be written
  */
 private function max_packet_size()
 {
     if ($this->max_packet < 0) {
         $this->max_packet = 2097152;
         // default/max is 2 MB
         if ($this->type == 'db') {
             if ($value = $this->db->get_variable('max_allowed_packet', $this->max_packet)) {
                 $this->max_packet = $value;
             }
             $this->max_packet -= 2000;
         } else {
             if ($this->type == 'memcache') {
                 $stats = $this->db->getStats();
                 $remaining = $stats['limit_maxbytes'] - $stats['bytes'];
                 $this->max_packet = min($remaining / 5, $this->max_packet);
             } else {
                 if ($this->type == 'apc' && function_exists('apc_sma_info')) {
                     $stats = apc_sma_info();
                     $this->max_packet = min($stats['avail_mem'] / 5, $this->max_packet);
                 }
             }
         }
     }
     return $this->max_packet;
 }
开发者ID:StudsPro,项目名称:islandpeeps.com,代码行数:28,代码来源:rcube_cache_shared.php


示例20: unserialize

 /**
  * Unserializes serialized data
  */
 private function unserialize($data)
 {
     if ($this->type == 'db') {
         return $this->db->decode($data, $this->packed);
     }
     return $this->packed ? @unserialize($data) : $data;
 }
开发者ID:bbspike,项目名称:sentora-core,代码行数:10,代码来源:rcube_cache.php



注:本文中的rcube_db类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP rcube_mime类代码示例发布时间:2022-05-23
下一篇:
PHP rcube_charset类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap