Open Sencillo  2015.003
Long live the simplicity of PHP
 All Data Structures Namespaces Functions
core_functions.php
1 <?php
12 {
13  public $name;
14 
15  private $rfp;
16  private $wfp;
17  private $contents;
18 
23  public function __construct($name)
24  {
25  $this->name = $name;
26  }
31  final public function write($data)
32  {
33  $this->wfp = fopen($this->name,"wb");
34  fwrite($this->wfp,$data);
35  fclose($this->wfp);
36  }
41  final public function read()
42  {
43  $this->rfp = fopen($this->name,"rb");
44  $this->contents = '';
45  while (!feof($this->rfp))
46  {
47  $this->contents .= fread($this->rfp, 8192);
48  }
49  fclose($this->rfp);
50  return $this->contents;
51  }
52 }
62 class file extends fileSystem
63 {
68  public function __construct($name)
69  {
70  chmod("../fw_core/", 0777);
71  chmod("../fw_cache/", 0777);
72  chmod("../fw_headers/", 0777);
73  chmod("../fw_modules/", 0777);
74  chmod("../fw_libraries/", 0777);
75  chmod("../fw_script/", 0777);
76  chmod("../", 0777);
77  }
82  public function __destruct()
83  {
84  chmod("../fw_core/", 0700);
85  chmod("../fw_cache/", 0700);
86  chmod("../fw_headers/", 0700);
87  chmod("../fw_modules/", 0700);
88  chmod("../fw_libraries/", 0700);
89  chmod("../fw_script/", 0700);
90  chmod("../", 0700);
91  }
92 }
103 {
104  public $seo;
105  public $info;
106 
107  private $header;
108  private $body;
109  private $lang;
110 
114  public function __construct()
115  {
116  $this->header['doctype-def']='<!DOCTYPE html>';
117  $this->header['html-def']='<html><head>';
118  $this->body='</head>';
119  }
120 
125  public function keywords($kw)
126  {
127  $this->header['keywords-def'] = '<meta name="keywords" content="'.$kw.'" />';
128  }
129 
134  public function encode($ec='UTF-8')
135  {
136  $this->header['charset-def'] = '<meta charset="'.$ec.'" />';
137  }
138 
142  public function responsive()
143  {
144  $this->header['responsive-def'] = '<meta name="viewport" content="width=device-width, initial-scale=1">';
145  }
146 
151  public function title($t)
152  {
153  if(strlen($t)>69)
154  {
155  $t = substr($t,0,66).'...';
156  }
157  $this->header['title-def'] = '<title>'.$t.'</title>';
158  }
159 
164  public function description($data)
165  {
166  if(strlen($data)>159)
167  {
168  $data = substr($data,0,155).'...';
169  }
170  $this->header['description-def'] = '<meta name="description" content="'.$data.'">';
171  }
172 
176  public function robots()
177  {
178  $this->header['robots-def'] = '<meta name="ROBOTS" content="NOODP"><meta name="Slurp" content="NOYDIR">';
179  }
180 
185  public function owner($author)
186  {
187  $this->header['owner-def'] = '<meta name="author" content="'.$author.'">';
188  }
189 
193  public function generator()
194  {
195  $this->header['generator-def'] = '<meta name="generator" content="OpenSencillo Framework (www.opensencillo.com)">';
196  }
197 
202  public function custom($code)
203  {
204  $this->header['custom'][] = $code;
205  }
206 
212  public function script($code)
213  {
214  $this->custom('<script type="text/javascript" src="'.$code.'"></script>');
215  }
216 
221  public function save()
222  {
223  $this->seo = $this->header['doctype-def'];
224  $this->seo .= $this->header['html-def'];
225  $this->seo .= $this->header['charset-def'];
226  $this->seo .= $this->header['responsive-def'];
227  $this->seo .= $this->header['title-def'];
228  $this->seo .= $this->header['description-def'];
229  $this->generator();
230 
231  unset($this->header['html-def']);
232  unset($this->header['doctype-def']);
233  unset($this->header['charset-def']);
234  unset($this->header['responsive-def']);
235  unset($this->header['title-def']);
236  unset($this->header['description-def']);
237 
238  foreach($this->header as $key => $val)
239  {
240  if(!is_array($val))
241  {
242  $this->seo .= $val;
243  $this->info['head'][] = $key;
244  }
245  }
246  foreach($this->header['custom'] as $key => $val)
247  {
248  $this->seo .= $val;
249  $this->info['head'][] = $key;
250  }
251 
252  $this->seo .= $this->body;
253  return $this->seo;
254  }
255 
261  public function lang($lang)
262  {
263  unset($this->header['html-def']);
264  $this->header['html-def']='<html lang="'.$lang.'"><head>';
265  }
266 
270  public function googleLoad()
271  {
272  $this->header['jquery-js']='<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>';
273  $this->header['jqueryui-js']='<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>';
274  }
275 
279  public function bootstrapDefs()
280  {
281  $this->header['bootstrap-css']='<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">';
282  $this->header['jquery-js']='<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>';
283  $this->header['bootstrap-js']='<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>';
284  }
285 }
286 
297 {
298  public $info;
299  public $request;
300  public $original_request;
301  public $post;
302  public $get;
303 
304  private $authorized;
305  private $pid;
306 
310  public function __construct()
311  {
312  $version = '2015';
313  $layout = '0';
314  $build = '03';
315  $this->info=array( 'CMS'=>'OpenSencillo',
316  'NME'=>'OpenSencillo',
317  'VSN'=>$version.'.'.$layout.$build,
318  'FWK'=>'OpenSencillo '.$version.'.'.$layout.$build,
319  'ARN'=>'Bc.Peter Horváth, Mastery s.r.o. CEO and FOUNDER',
320  'CPY'=>'&copy; COPYRIGHT 2011-'.date('Y').' Bc.Peter Horváth',
321  'HPE'=>'http://www.opensencillo.com',
322  'DTC'=>'01.'.$build.'.'.$version.':00.00:00.'.$layout.$build,
323  'PID'=>'PLEASE CONTACT info@opensencillo.com');
324 
325  $this->io_validator();
326  }
327 
328  public function version_info()
329  {
330  return $this->info;
331  }
332 
338  public function authorized($domains)
339  {
340  if(is_array($domains))
341  {
342  $this->authorized=$domains;
343  foreach($this->authorized as $value)
344  {
345  if($_SERVER['SERVER_NAME']==$value)
346  {
347  $this->pid[$value]=true;
348  }
349  else
350  {
351  $this->pid[$value]=false;
352  }
353  }
354  }
355  }
356 
360  public function product()
361  {
362  $read = new fileSystem('http://auth.mastery.sk/OpenSencillo2015.004.pid');
363  $exist= fopen($read->name,"rb");
364  if(!$exist)
365  {
366  die($this->info['PID']);
367  }
368  else
369  {
370  return $read->read();
371  }
372  }
373 
377  public function payLock()
378  {
379  $json=json_decode(self::product(),true);
380  $this->authorized($json['domains']);
381  if($this->pid[$_SERVER['SERVER_NAME']]!==true)
382  {
383  die($this->info['PID']);
384  }
385  $this->info['product']=$json;
386  }
387 
393  private function io_rw($input)
394  {
395  $arr=array();
396 
397  foreach($input as $key=>$val)
398  {
399  if(is_string($val))
400  {
401  $arr[$key]=htmlspecialchars($val,ENT_COMPAT | ENT_HTML5);
402  $arr['admin_original'][$key]=$val;
403  }
404  }
405 
406  return $arr;
407  }
408 
414  private function io_validator()
415  {
416  $arr = array(
417  'request'=>$this->io_rw($_REQUEST),
418  'get'=>$this->io_rw($_GET),
419  'post'=>$this->io_rw($_POST)
420  );
421 
422  $arr['get'] = $this->info;
423  $arr['request'] = $this->info;
424  $arr['post'] = $this->info;
425  $arr['request']['status'] = 200;
426  $arr['get']['status'] = 200;
427  $arr['post']['status'] = 200;
428 
429  $_GET = $arr['get'];
430  $_POST = $arr['post'];
431  $_REQUEST = $arr['request'];
432 
433  $this->get = $arr['get'];
434  $this->post = $arr['post'];
435  $this->request = $arr['request'];
436 
437  if(($_GET['status']==200)&&($_POST['status']==200)&&($_REQUEST['status']==200))
438  {
439  return true;
440  }
441  else
442  {
443  return false;
444  }
445  }
446 
447  public function __destruct()
448  {
449  }
450 }
451 $i=0;
452 $afterBootUp=array();
453 $afterBootUp[$i++]=new coreSencillo;
454 ?>
encode($ec='UTF-8')
__construct($name)
owner($author)
description($data)
__destruct()
__construct($name)