[ PHPXref.com ] [ Generated: Sun Jul 20 18:31:52 2008 ] [ Mailing List 1.03 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/lib/ -> config.php (source)

   1  <?php
   2  class CConfig extends CXMLParser {
   3      var $depth = 0;
   4      var $tags = array();
   5      var $vars = array();
   6  	function CConfig($file_name = "") {
   7          parent::CXMLParser();
   8          if ($file_name != "")
   9              $this->Load($file_name);
  10      }
  11  	function HNDTagOpen($parser,$tag,$attr) {
  12          parent::HNDTagOpen($parser,$tag,$attr);
  13          $this->tags[$this->depth] = $tag;
  14          $this->depth++;
  15          foreach ($this->tags as $key => $val)
  16              $code[] = "\"" . strtolower($val) . "\"";
  17          $node = implode("][",$code);
  18          $code = "foreach (\$attr as \$key => \$val) if (\$key != \"NAME\") \$this->vars[$node][strtolower(\$key)] = \"\$val\"; else \$this->vars[\$attr[\"NAME\"]][strtolower(\"\$key\")] = \"\$val\";";
  19          eval($code);
  20      }
  21  	function HNDTagClose($parser,$tag) {
  22          unset($this->tags[$this->depth]);
  23          $this->depth--;
  24      }
  25  	function HNDCData($parser,$cdata) {
  26          $cdata = str_replace("[amp]","&",$cdata);
  27          if ($this->attr["NAME"] != "")
  28              $this->tags[count($this->tags) - 1] = $this->attr["NAME"];
  29          $cdata = trim($cdata);
  30          if ($cdata != "") {
  31              foreach ($this->tags as $key => $val)
  32                  $code[] = "\"" . strtolower($val) . "\"";
  33              $code = "\$this->vars[" . implode("][",$code) . "] = \"" . $cdata . "\";";
  34              eval($code);
  35          }
  36      }
  37  	function Load($file_name) {
  38          parent::Parse($this->data = str_replace("&","[amp]",GetFileContents($file_name)));
  39          $this->vars = ArrayReplace("[amp]" , "&" , $this->vars );
  40      }
  41  }
  42  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]