Beispiel #1
0
function updateVersion()
{
    require_once 'lib/class.settings.php';
    require_once 'lib/class.github.php';
    $github = new GitHub('gugahoi', 'mediafrontpage');
    $commit = $github->getCommits();
    $commitNo = $commit['0']['sha'];
    $config = new ConfigMagik('config.ini', true, true);
    try {
        $config->set('version', $commitNo, 'ADVANCED');
    } catch (Exception $e) {
        echo false;
        exit;
    }
    echo true;
}
    //Si pas d'erreur de validation
    if (!isset($formerrors)) {
        require_once INSTALL_FUNCTIONS . DS . 'database.php';
        //Inclusion des fonctions de paramétrage de la base de données
        $bddcheck = check_connexion($datas['host'], $datas['login'], $datas['password'], $datas['database']);
        //On check la connexion à la bdd
        if ($bddcheck) {
            require_once LIBS . DS . 'config_magik.php';
            //Import de la librairie de gestion des fichiers de configuration
            $cfg = new ConfigMagik(CONFIGS_FILES . DS . 'database.ini', true, true);
            //Création d'une instance, si le fichier database.ini n'existe pas il sera créé
            $datas['prefix'] = "";
            //Par défaut à vide
            //On va parcourir les données postées et mettre à jour le fichier ini
            foreach ($datas as $k => $v) {
                $cfg->set($k, $v, $section);
            }
            $cfg->save();
            //On sauvegarde le fichier de configuration
        }
    }
}
?>
<div id="right">		
	<div id="main">				
		
		<div class="box">			
			<div class="title">
				<h2>CONFIGURATION DE LA BASE DE DONNEES</h2>
			</div>
			<div class="content nopadding">							
     return false;
 }
 //if there is no section parameter, we will not do anything.
 if (!isset($_GET['section'])) {
     echo false;
     return false;
 } else {
     $section_name = $_GET['section'];
     unset($_GET['section']);
     //Unset section so that we can use the GET array to manipulate the other parameters in a foreach loop.
     if (!empty($_GET)) {
         foreach ($_GET as $var => $value) {
             //Here we go through all $_GET variables and add the values one by one.
             $var = urlencode($var);
             try {
                 $config->set($var, $value, $section_name);
                 //Setting variable '. $var.' to '.$value.' on section '.$section_name;
             } catch (Exception $e) {
                 echo 'Could not set variable ' . $var . '<br>';
                 echo $e;
                 return false;
             }
         }
     }
     try {
         $section = $config->get($section_name);
         //Get the entire section so that we can check the variables in it.
         foreach ($section as $title => $value) {
             //Here we go through all variables in the section and delete the ones that are in there but not in the $_GET variables
             //Used mostly for deleting things.
             if (!isset($_GET[$title]) && $config->get($title, $section_name) !== NULL) {
Beispiel #4
0
// NOTE: It's always good practice when dealing with text-files (like ini's are) 
//       that hold sensitive data to protect them from beeing directly accessed.
//       This can be archieved in many ways, but the most simple of them all is 
//       just by naming them something like ´ini.mainConf.php´ and by leaving the 
//       Protected-Mode-Switch below enabled ;)
//       This is enabled by default.
#$Config->PROTECTED_MODE   = false;

// switch Synchronisation between Object and Ini-File on or off
// NOTE: In some cases ( ConfigurationPanel, Admin-Settings, etc.) it can be 
//       very useful to have this class saving the values to the file auto-
//       matically on each change.
//       This is enabled by default.
$Config->SYNCHRONIZE      = false;

// set a key named 'Name' with value 'SomeOne' in section 'second_section'
$Config->set( 'Name', 'SomeOne', 'second_section');

// get value from current config
$name = $Config->get( 'Name', 'second_section');
echo "<p>Name: " . $name . "</p>\n";

// remove a key/value-pair from section
$Config->removeKey( 'Name', 'second_section');

// remove entire section
$Config->removeSection( 'first_section');

// print-out ConfigMagik-Object
print_r( $Config);
?>
 /**
  * Cette fonction va permettre l'affichage et la modification des fichiers ini sans section
  *
  * @param	varchar $file		Fichier ini à charger
  * @param	varchar $redirect	Page de redirection
  * @access 	private
  * @author 	koéZionCMS
  * @version 0.1 - 18/04/2012 by FI
  */
 function _proceed_datas_ini($file, $redirect, $section = null, $websiteUrl = null)
 {
     require_once LIBS . DS . 'config_magik.php';
     //Import de la librairie de gestion des fichiers de configuration
     //Création d'une instance
     if (isset($section)) {
         $cfg = new ConfigMagik($file, true, true);
     } else {
         $cfg = new ConfigMagik($file, true, false);
     }
     //Si des données sont postées
     if ($this->request->data) {
         if (isset($section)) {
             foreach ($this->request->data as $k => $v) {
                 $cfg->set($k, $v, $section);
             }
             $cfg->set('website_url', $websiteUrl, $section);
             //On va rajouter l'url du site dans les configurations pour information
         } else {
             //On va parcourir les données postées et mettre à jour le fichier ini
             foreach ($this->request->data as $k => $v) {
                 $cfg->set($k, $v);
             }
         }
         Session::setFlash("Fichier de configuration modifié");
         //Message de confirmation
         $this->redirect($redirect);
         //Redirection
     }
     //Récupération des configurations
     if (isset($section)) {
         $this->request->data = $cfg->keys_values($section);
     } else {
         $this->request->data = $cfg->keys_values();
     }
 }