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


PHP DBConnection::getDBSlaveConf方法代码示例

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


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

示例1: showFormDBSlave

 /**
  * Print the config form for slave DB
  *
  * @return Nothing (display)
  **/
 function showFormDBSlave()
 {
     global $DB, $CFG_GLPI, $DBslave;
     if (!Config::canUpdate()) {
         return false;
     }
     echo "<form name='form' action=\"" . Toolbox::getItemTypeFormURL(__CLASS__) . "\" method='post'>";
     echo "<div class='center' id='tabsbody'>";
     echo "<input type='hidden' name='_dbslave_status' value='1'>";
     echo "<table class='tab_cadre_fixe'>";
     $active = DBConnection::isDBSlaveActive();
     echo "<tr class='tab_bg_2'><th colspan='4'>" . _n('Mysql replica', 'Mysql replicas', Session::getPluralNumber()) . "</th></tr>";
     $DBslave = DBConnection::getDBSlaveConf();
     if (is_array($DBslave->dbhost)) {
         $host = implode(' ', $DBslave->dbhost);
     } else {
         $host = $DBslave->dbhost;
     }
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Mysql server') . "</td>";
     echo "<td><input type='text' name='_dbreplicate_dbhost' size='40' value='{$host}'></td>";
     echo "<td>" . __('Database') . "</td>";
     echo "<td><input type='text' name='_dbreplicate_dbdefault' value='" . $DBslave->dbdefault . "'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Mysql user') . "</td>";
     echo "<td><input type='text' name='_dbreplicate_dbuser' value='" . $DBslave->dbuser . "'></td>";
     echo "<td>" . __('Mysql password') . "</td>";
     echo "<td><input type='password' name='_dbreplicate_dbpassword' value='" . rawurldecode($DBslave->dbpassword) . "'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Use the slave for the search engine') . "</td><td>";
     $values = array(0 => __('Never'), 1 => __('If synced (all changes)'), 2 => __('If synced (current user changes)'), 3 => __('If synced or read-only account'), 4 => __('Always'));
     Dropdown::showFromArray('use_slave_for_search', $values, array('value' => $CFG_GLPI["use_slave_for_search"]));
     echo "<td colspan='2'>&nbsp;</td>";
     echo "</tr>";
     if ($DBslave->connected && !$DB->isSlave()) {
         echo "<tr class='tab_bg_2'><td colspan='4' class='center'>";
         DBConnection::showAllReplicateDelay();
         echo "</td></tr>";
     }
     echo "<tr class='tab_bg_2'><td colspan='4' class='center'>";
     echo "<input type='submit' name='update' class='submit' value=\"" . _sx('button', 'Save') . "\">";
     echo "</td></tr>";
     echo "</table></div>";
     Html::closeForm();
 }
开发者ID:UnidadInformaticaSERVIUVI,项目名称:Administrador-de-Inventario,代码行数:52,代码来源:config.class.php

示例2: define

* @brief
*/
define('DO_NOT_CHECK_HTTP_REFERER', 1);
include './inc/includes.php';
// Force in normal mode
$_SESSION['glpi_use_mode'] = Session::NORMAL_MODE;
// Need to be used using :
// check_http -H servername -u /glpi/status.php -s GLPI_OK
// Plain text content
header('Content-type: text/plain');
$ok_master = true;
$ok_slave = true;
$ok = true;
// Check slave server connection
if (DBConnection::isDBSlaveActive()) {
    $DBslave = DBConnection::getDBSlaveConf();
    if (is_array($DBslave->dbhost)) {
        $hosts = $DBslave->dbhost;
    } else {
        $hosts = array($DBslave->dbhost);
    }
    foreach ($hosts as $num => $name) {
        $diff = DBConnection::getReplicateDelay($num);
        if (abs($diff) > 1000000000) {
            echo "GLPI_DBSLAVE_{$num}_OFFLINE\n";
            $ok_slave = false;
        } else {
            if (abs($diff) > HOUR_TIMESTAMP) {
                echo "GLPI_DBSLAVE_{$num}_PROBLEM\n";
                $ok_slave = false;
            } else {
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:31,代码来源:status.php

示例3: showFormDBSlave

 /**
  * Print the config form for slave DB
  *
  * @return Nothing (display)
  **/
 function showFormDBSlave()
 {
     global $DB, $LANG, $CFG_GLPI, $DBSlave;
     if (!haveRight("config", "w")) {
         return false;
     }
     echo "<form name='form' action=\"" . getItemTypeFormURL(__CLASS__) . "\" method='post'>";
     echo "<div class='center' id='tabsbody'>";
     echo "<input type='hidden' name='id' value='" . $CFG_GLPI["id"] . "'>";
     echo "<input type='hidden' name='_dbslave_status' value='1'>";
     echo "<table class='tab_cadre_fixe'>";
     $active = DBConnection::isDBSlaveActive();
     echo "<tr class='tab_bg_2'><th colspan='4'>" . $LANG['setup'][800] . "</th></tr>";
     $DBSlave = DBConnection::getDBSlaveConf();
     if (is_array($DBSlave->dbhost)) {
         $host = implode(' ', $DBSlave->dbhost);
     } else {
         $host = $DBSlave->dbhost;
     }
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . $LANG['install'][30] . "&nbsp;:</td>";
     echo "<td><input type='text' name='_dbreplicate_dbhost' size='40' value='{$host}'></td>";
     echo "<td>" . $LANG['setup'][802] . "&nbsp;:</td>";
     echo "<td><input type='text' name='_dbreplicate_dbdefault' value='" . $DBSlave->dbdefault . "'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . $LANG['install'][31] . "&nbsp;:</td>";
     echo "<td><input type='text' name='_dbreplicate_dbuser' value='" . $DBSlave->dbuser . "'></td>";
     echo "<td>" . $LANG['install'][32] . "&nbsp;:</td>";
     echo "<td><input type='password' name='_dbreplicate_dbpassword' value='" . $DBSlave->dbpassword . "'>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . $LANG['setup'][804] . "&nbsp;:</td><td>";
     Dropdown::showYesNo("use_slave_for_search", $CFG_GLPI["use_slave_for_search"]);
     echo "<td colspan='2'>&nbsp;</td>";
     echo "</tr>";
     if ($DBSlave->connected && !$DB->isSlave()) {
         echo "<tr class='tab_bg_2'><td colspan='4' class='center'>";
         DBConnection::showAllReplicateDelay();
         echo "</td></tr>";
     }
     echo "<tr class='tab_bg_2'><td colspan='4' class='center'>";
     echo "<input type='submit' name='update' class='submit' value=\"" . $LANG['buttons'][2] . "\">";
     echo "</td></tr>";
     echo "</table></div>";
     echo "</form>";
 }
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:52,代码来源:config.class.php

示例4: methodStatus

 /**
  * This method return GLPI status (same as status.php)
  *
  * @param $params    array of option : ignored
  * @param $protocol        the communication protocol used
  *
  * @return an response ready to be encode
  **/
 static function methodStatus($params, $protocol)
 {
     global $DB;
     if (isset($params['help'])) {
         return array('help' => 'bool,optional');
     }
     $resp = array();
     $ok_master = true;
     $ok_slave = true;
     $ok = true;
     // Check slave server connection
     if (DBConnection::isDBSlaveActive()) {
         $DBslave = DBConnection::getDBSlaveConf();
         if (is_array($DBslave->dbhost)) {
             $hosts = $DBslave->dbhost;
         } else {
             $hosts = array($DBslave->dbhost);
         }
         foreach ($hosts as $num => $name) {
             $diff = DBConnection::getReplicateDelay($num);
             if ($diff > 1000000000) {
                 $resp['slavedb_' . $num] = "offline";
                 $ok_slave = false;
             } else {
                 if ($diff) {
                     $resp['slavedb_' . $num] = $diff;
                     if ($diff > HOUR_TIMESTAMP) {
                         $ok_slave = false;
                     }
                 } else {
                     $resp['slavedb_' . $num] = "ok";
                 }
             }
         }
     } else {
         $resp['slavedb'] = "not configured";
     }
     // Check main server connection
     if (DBConnection::establishDBConnection(false, true, false)) {
         $resp['maindb'] = "ok";
     } else {
         $resp['slavedb'] = "offline";
         $ok_master = false;
     }
     // Slave and master ok;
     $ok = $ok_slave && $ok_master;
     // Check session dir (usefull when NFS mounted))
     if (is_dir(GLPI_SESSION_DIR) && is_writable(GLPI_SESSION_DIR)) {
         $resp['sessiondir'] = "ok";
     } else {
         $resp['sessiondir'] = "not writable";
         $ok = false;
     }
     // Reestablished DB connection
     if (($ok_master || $ok_slave) && DBConnection::establishDBConnection(false, false, false)) {
         // Check Auth connections
         $auth = new Auth();
         $auth->getAuthMethods();
         $ldap_methods = $auth->authtypes["ldap"];
         if (count($ldap_methods)) {
             foreach ($ldap_methods as $method) {
                 if ($method['is_active']) {
                     if (AuthLdap::tryToConnectToServer($method, $method["rootdn"], Toolbox::decrypt($method["rootdn_passwd"], GLPIKEY))) {
                         $resp['LDAP_' . $method['name']] = "ok";
                     } else {
                         $resp['LDAP_' . $method['name']] = "offline";
                         $ok = false;
                     }
                 }
             }
         }
     }
     if ($ok) {
         $resp['glpi'] = "ok";
     } else {
         $resp['glpi'] = "error";
     }
     return $resp;
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:87,代码来源:methodcommon.class.php

示例5: plugin_item_add_update_timezones_dbconnection

function plugin_item_add_update_timezones_dbconnection(Config $parm)
{
    $slaveDB = DBConnection::getDBSlaveConf();
    if ($slaveDB) {
        $host = $slaveDB->dbhost;
        $user = $slaveDB->dbuser;
        $password = $slaveDB->dbpassword;
        $DBname = $slaveDB->dbdefault;
        unset($slaveDB);
        timezones_createSlaveConnectionFile($host, $user, $password, $DBname) or Toolbox::logInFile('php-errors', "timezones: Can't create config_db_slave.php\n");
    }
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:12,代码来源:hook.php


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