예제 #1
0
 /** Saves the rights database.
  * This function saves the rights database into a file for later use.
  * 
  * \param $filename The file in which the database will be saved.
  * 
  * \return The size of the written file, or FALSE if an error occured.
  */
 public function saveRights($filename)
 {
     return file_put_contents($filename, Leelabot::generateINIStringRecursive($this->rights));
 }
예제 #2
0
 /** Generates INI config string for recursive data.
  * This function takes configuration array passed in parameter and generates an INI configuration string with recursive sections.
  * 
  * \param $data The data to be transformed.
  * \param $root The root section. Normally, this parameter is used by the function to recursively parse data by calling itself.
  * 
  * \return The INI config data.
  */
 public static function generateINIStringRecursive($data, $root = "")
 {
     $out = "";
     if ($root) {
         $out = '[' . $root . ']' . "\n";
     }
     $arrays = array();
     //Process data, saving sub-arrays, putting direct values in config.
     foreach ($data as $name => $value) {
         if (is_array($value) || is_object($value)) {
             $arrays[$name] = $value;
         } elseif (is_bool($value)) {
             $out .= $name . '=' . ($value ? 'yes' : 'no') . "\n";
         } else {
             $out .= $name . '=' . $value . "\n";
         }
     }
     if ($out) {
         $out .= "\n";
     }
     //Processing sub-sections
     foreach ($arrays as $name => $value) {
         $out .= Leelabot::generateINIStringRecursive($value, $root . ($root ? '.' : '') . $name) . "\n\n";
     }
     return trim($out);
 }
예제 #3
0
파일: bans.php 프로젝트: Geolim4/Leelabot
 /** Saves the banlist.
  * This function takes the banlist in memory and put it into the banlist file specified in the configuration, after having it transformed
  * into recursive INI mode.
  * 
  * \return TRUE if the banlist saved correctly, FALSE otherwise.
  */
 public function saveBanlist()
 {
     $dump = Leelabot::generateINIStringRecursive($this->_banlist);
     return file_put_contents($this->_banlistLocation, $dump);
 }