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


PHP ConfigManager::setConfig方法代码示例

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


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

示例1: setup

 function setup($dbHost, $dbUsername, $dbPassword, $dbName, $controlThreads, $controlInterval)
 {
     if ($dbHost == "" || $dbUsername == "" || $dbPassword == "" || $dbName == "") {
         throw new Exception("La configuration de Base de données est incomplète");
     }
     /*if ($controlThreads == "" || $controlInterval == "" || !is_numeric($controlThreads) || !is_numeric($controlInterval))
       throw new Exception("La configuration de Contrôle est incomplète");*/
     if ($controlThreads == "" || !is_numeric($controlThreads)) {
         throw new Exception("Le champ Threads de contrôle est vide");
     }
     if ($controlInterval == "" || !is_numeric($controlInterval)) {
         throw new Exception("Le champ Intervalle de contrôle est vide");
     }
     $cm = new ConfigManager(ADMIN_CONFIG_PATH);
     $cm->loadINIFile();
     $cm->setConfig('database', 'db_host', $dbHost);
     $cm->setConfig('database', 'db_auth_username', $dbUsername);
     $cm->setConfig('database', 'db_auth_password', $dbPassword);
     $cm->setConfig('database', 'db_auth_dbname', $dbName);
     $cm->setConfig('control', 'ac_control_threads', $controlThreads);
     $cm->setConfig('control', 'ac_control_frequency', $controlInterval);
     $cm->saveINIFile();
     $_SESSION["message"] = array("type" => "success", "title" => "Configuration terminée", "descr" => "La configuration a été modifiée avec succès.");
     header('Location: ' . '/monitoring/?v=admin&tab=config');
     exir(0);
 }
开发者ID:yashodhank,项目名称:Monitoring,代码行数:26,代码来源:admin.php

示例2: editprofile

 function editprofile($username, $email, $email_active, $phone, $phone_active, $cur_password, $password, $new_password)
 {
     if (!isset($email_active)) {
         $email_active = 0;
     }
     if (!isset($phone_active)) {
         $phone_active = 0;
     }
     // Get the old version
     $sth = $this->pdo->prepare("SELECT * FROM users WHERE users.id = ?");
     $sth->execute(array($_SESSION["user_id"]));
     $res = $sth->fetch(PDO::FETCH_ASSOC);
     $user = $res;
     $id = $_SESSION["user_id"];
     if (isset($this->pdo)) {
         if ($cur_password != "") {
             if ($password == "" || $new_password == "") {
                 throw new Exception("Vous devez indiquer un nouveau mot de passe.");
             }
             if ($password != $new_password) {
                 throw new Exception("La vérification du mot de passe a échoué. Le mot de passe de confirmation doit être le même" . "que le mot de passe dans le champ \"Nouveau mot de passe\".");
             }
             // Update password and all others information.
             $sth = $this->pdo->prepare("UPDATE users SET username = ?, email = ?, email_active = ?, phone = ?, phone_active = ? WHERE id = ?");
             $res = $sth->execute(array($username, $email, $email_active, $phone, $phone_active, $id));
             if ($res == 0) {
                 throw new Exception("Impossible de modifier votre profil.");
             }
             if ($_SESSION["user_id"] == -1) {
                 // It's the root user, so let's edit the .ini file
                 $cm = new ConfigManager(ADMIN_CONFIG_PATH);
                 $cm->loadINIFile();
                 $cm->setConfig("superadmin", "ac_superadmin_username", $username);
                 $cm->setConfig("superadmin", "ac_superadmin_password", sha1($new_password));
                 $cm->setConfig("superadmin", "ac_superadmin_email", $email);
                 $cm->setConfig("superadmin", "ac_superadmin_email_active", $email_active);
                 $cm->setConfig("superadmin", "ac_superadmin_phone", $phone);
                 $cm->setConfig("superadmin", "ac_superadmin_phone_active", $phone_active);
                 $cm->saveINIFile();
             }
             $_SESSION["message"] = array("type" => "success", "title" => "Modification de votre profil terminé", "descr" => "Vos informations de profil a été modifié. Votre mot de passe a été modifié.");
             header('Location: ' . '/monitoring/?v=profile');
         } else {
             // No need to change password, so let's go !
             $sth = $this->pdo->prepare("UPDATE users SET username = ?, email = ?, email_active = ?, phone = ?, phone_active = ? WHERE id = ?");
             $res = $sth->execute(array($username, $email, $email_active, $phone, $phone_active, $id));
             if ($res == 0) {
                 throw new Exception("Impossible de modifier votre profil.");
             }
             if ($_SESSION["user_id"] == -1) {
                 // It's the root user, so let's edit the .ini file
                 $cm = new ConfigManager(ADMIN_CONFIG_PATH);
                 $cm->loadINIFile();
                 $cm->setConfig("superadmin", "ac_superadmin_username", $username);
                 $cm->setConfig("superadmin", "ac_superadmin_password", sha1($new_password));
                 $cm->setConfig("superadmin", "ac_superadmin_email", $email);
                 $cm->setConfig("superadmin", "ac_superadmin_email_active", $email_active);
                 $cm->setConfig("superadmin", "ac_superadmin_phone", $phone);
                 $cm->setConfig("superadmin", "ac_superadmin_phone_active", $phone_active);
                 $cm->saveINIFile();
             }
             $_SESSION["message"] = array("type" => "success", "title" => "Modification de votre profil terminé", "descr" => "Vos informations de profil a été modifié. Votre mot de passe n'a PAS été modifié.");
             header('Location: ' . '/monitoring/?v=profile');
         }
     } else {
         // Database not connected. Only for SuperAdmin.
         if ($_SESSION["user_id"] != -1) {
             throw new Exception("Database not connected");
         }
         // It's the root user, so let's edit the .ini file
         $cm = new ConfigManager();
         $cm->loadINIFile();
         $cm->setConfig("superadmin", "ac_superadmin_username", $username);
         $cm->setConfig("superadmin", "ac_superadmin_password", sha1password($new_password));
         $cm->setConfig("superadmin", "ac_superadmin_email", $email);
         $cm->setConfig("superadmin", "ac_superadmin_email_active", $email_active);
         $cm->setConfig("superadmin", "ac_superadmin_phone", $phone);
         $cm->setConfig("superadmin", "ac_superadmin_phone_active", $phone_active);
         $cm->saveINIFile();
         $_SESSION["message"] = array("type" => "success", "title" => "Modification d'utilisateur terminé", "descr" => "L'utilisateur a été modifié. Le mot de passe n'a PAS été modifié.");
         header('Location: ' . '/monitoring/?v=profile');
     }
 }
开发者ID:yashodhank,项目名称:Monitoring,代码行数:83,代码来源:user.php


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