OpenSencillo  2016.106
Long live the simplicity of PHP
 All Data Structures Namespaces Files Functions Pages
core_functions.php
1 <?php
11 class coreSencillo implements coreInterface
12 {
13  public $info;
14  public $request;
15  public $original_request;
16  public $post;
17  public $get;
18 
19  private $authorized;
20  private $pid;
21 
25  public function __construct($sum=null)
26  {
27  $version = '2016';
28  $layout = '1';
29  $build = '06';
30  $this->info=array( 'CMS'=>'OpenSencillo',
31  'NME'=>'OpenSencillo',
32  'VSN'=>$version.'.'.$layout.$build,
33  'FWK'=>'OpenSencillo '.$version.'.'.$layout.$build,
34  'ARN'=>'Bc.Peter Horváth, Mastery s.r.o. CEO and FOUNDER',
35  'CPY'=>'&copy; COPYRIGHT 2011-'.date('Y').' Bc.Peter Horváth',
36  'HPE'=>'http://www.opensencillo.com',
37  'DTC'=>'01.'.$build.'.'.$version.':00.00:00.'.$layout.$build,
38  'PID'=>'PLEASE CONTACT info@opensencillo.com',
39  'SUM'=>$sum);
40  if($_GET['install']!='true')
41  {
42  $this->io_validator();
43  }
44  }
45 
46  public function version_info()
47  {
48  return $this->info;
49  }
50 
56  public function authorized($domains)
57  {
58  if(is_array($domains))
59  {
60  $this->authorized=$domains;
61  foreach($this->authorized as $value)
62  {
63  if($_SERVER['SERVER_NAME']==$value)
64  {
65  $this->pid[$value]=true;
66  }
67  else
68  {
69  $this->pid[$value]=false;
70  }
71  }
72  }
73  }
74 
78  public function product($path=false)
79  {
80  if($path==false)
81  {
82  $read = new fileSystem('http://auth.mastery.sk/action.php');
83  }
84  else
85  {
86  $read = new fileSystem('key.pid');
87  }
88  $exist= fopen($read->name,"rb");
89  if(!$exist)
90  {
91  die($this->info['PID']);
92  }
93  else
94  {
95  return $read->read();
96  }
97  }
98 
102  public function payLock()
103  {
104  if(!file_exists("key.pid"))
105  {
106  $json=json_decode(self::product(false),true);
107  $this->authorized($json['domains']);
108  if($this->pid[$_SERVER['SERVER_NAME']]!==true)
109  {
110  die($this->info['PID']);
111  }
112  $this->info['product']=$json;
113  if(($json['sum']!='none')&&(!empty($this->info['SUM']))&&($json['sum']==$this->info['SUM']))
114  {
115  $write = new fileSystem('key.pid');
116  $json['expired']=md5(date('Ym'));
117  $write->write(json_encode($json));
118  }
119  }
120  else
121  {
122  $json=json_decode(self::product(true),true);
123  $this->authorized($json['domains']);
124  if(($this->pid[$_SERVER['SERVER_NAME']]!==true)&&($json['sum']===$this->info['SUM']))
125  {
126  die($this->info['PID']);
127  }
128  $this->info['product']=$json;
129  if($this->info['product']['expired']!=md5(date('Ym')))
130  {
131  unlink('key.pid');
132  }
133  }
134  }
135 
141  private function io_rw($input)
142  {
143  $arr=array();
144 
145  foreach($input as $key=>$val)
146  {
147  if(is_string($val))
148  {
149  $arr[$key]=htmlspecialchars($val,ENT_COMPAT | ENT_HTML5);
150  $arr['admin_original'][$key]=$val;
151  }
152  }
153 
154  return $arr;
155  }
156 
162  private function io_validator()
163  {
164  $arr = array(
165  'request'=>$this->io_rw($_REQUEST),
166  'get'=>$this->io_rw($_GET),
167  'post'=>$this->io_rw($_POST)
168  );
169 
170  $arr['get']['core_info'] = $this->info;
171  $arr['request']['core_info']= $this->info;
172  $arr['post']['core_info'] = $this->info;
173  $arr['request']['status'] = 200;
174  $arr['get']['status'] = 200;
175  $arr['post']['status'] = 200;
176 
177  $this->get = $arr['get'];
178  $this->post = $arr['post'];
179  $this->request = $arr['request'];
180 
181  if(($_GET['status']==200)&&($_POST['status']==200)&&($_REQUEST['status']==200))
182  {
183  return true;
184  }
185  else
186  {
187  return false;
188  }
189  }
190 
196  public function upgrade($source=null)
197  {
198  $fileList=scandir('./fw_core');
199 
200  foreach($fileList as $key=>$val)
201  {
202  if($key>1)
203  {
204  $md5 = md5_file('./fw_core/'.$val);
205  $remote_md5 = md5_file($source.$val.'.suf');
206  if($md5!=$remote_md5)
207  {
208  $read = new fileSystem($source.$val.'.suf');
209  $write= new fileSystem('./fw_core/'.$val);
210  $write->write($read->read());
211  }
212  }
213  }
214  }
215 
216  public function __destruct()
217  {
218  }
219 }
220 
232 class bootUp
233 {
234  public $coreSencillo;
235  public $headerSeo;
236  public $fileSystem;
237 
238  public function __construct($sum=false)
239  {
240  $this->headerSeo = new headerSeo;
241  $this->fileSystem = new fileSystem('firststart.json');
242 
243  if($sum)
244  {
245  $this->coreSencillo = new coreSencillo(json_decode($this->fileSystem->read(),true));
246  $this->fileSystem->payLock();
247  }
248  else
249  {
250  $this->coreSencillo = new coreSencillo;
251  }
252  }
253 }
254 ?>