View Single Post
Old 19.02.2006, 17:11   #48
Sdw
Архивный участник
 
Join Date: Sep 2005
Posts: 150
Default

Code:
<?php
/*======================================================================*\
|| #################################################################### ||
|| # SSQ System  - V1.0                                               # ||
|| # ---------------------------------------------------------------- # ||
|| # L2 Coding : Hami                                                 # ||
|| # PHP/WEB Coding : Pole                                            # ||
|| # Original Ideas/L2autoreboot : Drake                              # ||
|| #################################################################### ||
\*======================================================================*/
  class IniFile
  {
      /**
  * @desc table containing whole information.
  * @type array
  **/
      protected $Content=array();
   
      /**
  * @desc true to show script evolution.
  * @type boolean
  **/
      protected $Debug=false;
   
      /**
  * @return -
  * @desc Show "Object created." if Debug=true.
  **/
      public function __construct()
      {
          $this->Debug("Object created.");
      }
   
      /**
  * @return -
  * @desc Show error if we call a non-existent method if Debug=true.
  **/
      public function __call($name,$arguments)
      {
          $this->Debug("The method '".$name."' doesn't exist.");
      }
   
      /**
  * @return -
  * @param string $name variable name.
  * @desc Show error if we call a non-existent variable if Debug=true.
  **/
      public function _get($name)
      {
          $this->Debug("The variable '".$name."' doesn't exist.");
      }
   
      /**
  * @return -
  * @param string $name variable name.
  * @param variant $value value to assign to the variable.
  * @desc Show error if we assign a value to a non-existent variable if Debug=true.
  **/
      public function _set($name,$value)
      {
          $this->Debug("The variable '".$name."' doesn't exist.");
      }
   
      /**
  * @return -
  * @param string $string message to show.
  * @desc show script evolution if Debug=true.
  **/
      protected function Debug($string)
      {
          if(true==$this->Debug)
              echo "***".$string."
\n";
      }
   
      /**
  * @return -
  * @param string $filname file name which we export informations.
  * @desc Export informations in a file.
  **/
      public function ExportToFile($filename)
      {
          ksort($this->Content);
          if(false!=($file_handle=@fopen($filename,"w")))
          {
              $this->Debug("File '".$filename."' open.");
              foreach($this->Content as $key=>$value)
              {
                  fputs($file_handle,"[".$key."]\n");
                  ksort($this->Content[$key]);
                  foreach($this->Content[$key] as $key2=>$value)
                      fputs($file_handle,$key2."=".$value."\n");
                  fputs($file_handle,"\n");
              }
                  $this->Debug("Informations loaded in '".$filename."'.");
                  $this->Debug("File '".$filename."' closed.");
                  fclose($file_handle);
          }
          else
              $this->Debug("Can't open file'".$filename."'.");
      }
   
      /**
  * @return array
  * @desc Return all information in a table.
  **/
      public function GetAllContent()
      {
          return $this->Content;
      }
   
      /**
  * @return string
  * @param string $category category in which the information is.
  * @param string $key The information name.
  * @desc Return requested information.
  **/
      public function GetContent($category,$key)
      {
          return isset($this->Content[$category][$key])?$this->Content[$category][$key]:false;
      }
   
      /**
  * @return -
  * @param string $filname File name to import.
  * @desc Import informations contained in a file.
  **/
      public function LoadFromFile($filename)
      {
          if(false!=($file_handle=@fopen($filename,"r")))
          {
              $this->Debug("File '".$filename."' open.");
              while(false!=($line=fgets($file_handle)))
              {
                  if(";"==substr($line,0,1))
                      continue;
                  if(true==ereg("\[(.+)\]",$line,$temp))
                      $category=$temp[1];
                  elseif(true==ereg("(.*)=([^;]*)",$line,$temp))
                      $this->Content[$category][trim($temp[1])]=trim($temp[2]);
              }
              $this->Debug("Informations loaded from '".$filename."'.");
              $this->Debug("Fichier '".$filename."' fermé.");
              fclose($file_handle);
          }
          else
              $this->Debug("Can't open file '".$filename."'.");
      }
   
      /**
  * @return -
  * @desc Clear all informations.
  **/
      public function Reset()
      {
          $this->Content=array();
          $this->Debug("Information have been cleared.");
      }
   
      /**
  * @return -
  * @param string $category category in which the information is.
  * @param string $key The information name.
  * @param string $value Value of the information
  * @desc Save an information.
  **/
      public function SetContent($category,$key,$value)
      {
          $this->Content[$category][$key]=$value;
      }
   
      /**
  * @return -
  * @desc Show "Object deleted" if Debug=true.
  **/
      public function __destruct()
      {
          $this->Debug("Object deleted.");
      }
  }
?>
I hope this is correctly translated.
Heee, thanks Hami. Just when I'm back to school (Partiel en plus -_-) so I don't know if I'll have time to help but if someone have more info about things to do (like which debuff debuffer cast or what exactly festival of darkness is) just post it cause I don't really know how it works, and I can't help. Perhaps I won't be able to help even if I know ahah, but this will be usefull to those who don't know how it works.
Sdw is offline