当前位置: 首页>>代码示例>>PHP>>正文


PHP rcube_db类代码示例

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


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

示例13: 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

示例14: build_message

 /**
  * Converts cache row into message object.
  *
  * @param array $sql_arr Message row data
  *
  * @return rcube_message_header Message object
  */
 private function build_message($sql_arr)
 {
     $message = $this->db->decode($sql_arr['data'], true);
     if ($message) {
         $message->flags = array();
         foreach ($this->flags as $idx => $flag) {
             if (($sql_arr['flags'] & $idx) == $idx) {
                 $message->flags[$flag] = true;
             }
         }
     }
     return $message;
 }
开发者ID:JotapePinheiro,项目名称:roundcubemail,代码行数:20,代码来源:rcube_imap_cache.php

示例15: unique_groupname

 /**
  * Check for existing groups with the same name
  *
  * @param string Name to check
  * @return string A group name which is unique for the current use
  */
 private function unique_groupname($name)
 {
     $checkname = $name;
     $num = 2;
     $hit = false;
     do {
         $sql_result = $this->db->query("SELECT 1 FROM " . $this->db->table_name($this->db_groups) . " WHERE del<>1" . " AND user_id=?" . " AND name=?", $this->user_id, $checkname);
         // append number to make name unique
         if ($hit = $this->db->fetch_array($sql_result)) {
             $checkname = $name . ' ' . $num++;
         }
     } while ($hit);
     return $checkname;
 }
开发者ID:netcon-source,项目名称:roundcubemail,代码行数:20,代码来源:rcube_contacts.php


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