colly_wyx
2018-06-13 e4d5467f055ece8cc9dfdc02dd836bcc187034a5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
 
class ApplicationVar
{
    var $save_file;
    var $application  = null;
     var $app_data    = '';
     var $__writed    = false;
 
    function __construct()
     {
    $this->save_file = __DIR__.'/httpdns.conf' ;
         $this->application = array();
     }
 
     public function setValue($var_name,$var_value)
  {
           if (!is_string($var_name) || empty($var_name))
            return false;
   
           $this->application[$var_name] = $var_value;
  }
 
  public function write(){
      $this->app_data = @serialize($this->application);    
      $this->__writeToFile();
  }
 
     public function getValue()
     {
         if (!is_file($this->save_file))
             $this->__writeToFile();
         return @unserialize(@file_get_contents($this->save_file));
     }
 
     function __writeToFile()
     {
          $fp = @fopen($this->save_file,"w");
      if(flock($fp , LOCK_EX | LOCK_NB)){
          @fwrite($fp,$this->app_data);
          flock($fp , LOCK_UN);
      }
      @fclose($fp);
     }
}
 
?>