17 protected $store=array();
27 final public function __construct($path=
'',$file=
'log.txt',$maxLine=100,$useFile=
true,$mysql=null)
29 $this->
file = $path.$file;
32 $this->maxLine = $maxLine;
33 $this->useFile = $useFile;
34 $this->store[
'mysql'] = $mysql;
46 $this->current = fopen($this->
file,
"w");
47 fprintf($this->current,
"%s\t%s\t%s\t%s\t%s\t%s\n",date(
'Y-m-d'),date(
'H:i:s'),$data[0],$data[1],$data[2],$data[3]);
48 foreach ($this->store as $val)
50 fprintf($this->current,
"%s\t%s\t%s\t%s\t%s\t%s\n",$val[0],$val[1],$val[2],$val[3],$val[4],$val[5]);
53 fclose($this->current);
55 if($this->maxLine<
sizeof($this->store))
57 rename($_SERVER[
'DOCUMENT_ROOT'] . $this->
file,$_SERVER[
'DOCUMENT_ROOT'] . $this->path .
"old_" . $this->name);
62 $name=explode(
'.',$this->name);
63 $this->store[
'mysql']->newColumn(
'date',
'VARCHAR(10)');
64 $this->store[
'mysql']->newColumn(
'time',
'VARCHAR(8)');
65 $this->store[
'mysql']->newColumn(
'data0',
'TEXT');
66 $this->store[
'mysql']->newColumn(
'data1',
'TEXT');
67 $this->store[
'mysql']->newColumn(
'data2',
'TEXT');
68 $this->store[
'mysql']->newColumn(
'data3',
'TEXT');
69 $this->store[
'mysql']->createTable($name[0].
'_log');
70 $this->store[
'mysql']->openTable($name[0].
'_log');
71 $this->store[
'mysql']->insert(
'\''.date(
'Y-m-d').
'\',\
''.date(
'H:i:s').
'\',\
''.$data[0].
'\',\
''.$data[1].
'\',\
''.$data[2].
'\',\
''.$data[3].
'\'');
78 private function getContent()
82 $this->current = fopen($this->
file,
"r");
84 while(($buffer = fgets($this->current, 4096)) !==
false)
86 $this->store[$i++] = sscanf($buffer,
"%s\t%s\t%s\t%s\t%s\t%s\n");
88 fclose($this->current);
92 return $this->output(
"`id`>0",
"`id` DESC",$this->maxLine);
109 public function vd($var)
113 $result = ob_get_clean();
114 $result = highlight_string($result,
true);
115 $result = str_replace(
'=><br /> ',
'<b>=></b>',$result);
116 $result = str_replace(
') "',
') "<font color="blue">',$result);
117 $result = str_replace(
'"<br />',
'</font>"<br />',$result);
134 protected $env=
'public';
145 $this->env = ($public===
true?
'public':
'developer');
148 print
"<script type='text/javascript'>console.log('<<< Sencillo Testing Tool >>>');</script>";
149 error_reporting(E_ALL);
150 print
"<script type='text/javascript'>console.log('<<< DEVEL MODE ON >>>');</script>";
164 public function print_test($function=null,$validator=null,$die=
false)
166 return $this->
print_ut($this->init($function,$validator),$die);
198 public function init($function=null,$validator=null)
200 if((is_array($validator))&&($this->env===
'developer'))
202 foreach($validator as $key=>$val)
208 if(!(is_string($function)))
210 return array(
"status"=>
"no$key",
211 "value"=>var_export($function,
true)
218 if(!(is_integer($function)))
220 return array(
"status"=>
"no$key",
221 "value"=>var_export($function,
true)
227 if(!(is_float($function)))
229 return array(
"status"=>
"no$key",
230 "value"=>var_export($function,
true)
237 if(!(is_bool($function)))
239 return array(
"status"=>
"no$key",
240 "value"=>var_export($function,
true)
245 if(!(filter_var($function, FILTER_VALIDATE_EMAIL)))
247 return array(
"status"=>
"no$key",
248 "value"=>var_export($function,
true)
253 if(!(filter_var($function, FILTER_VALIDATE_IP)))
255 return array(
"status"=>
"no$key",
256 "value"=>var_export($function,
true)
261 if(!(filter_var($function, FILTER_VALIDATE_URL)))
263 return array(
"status"=>
"no$key",
264 "value"=>var_export($function,
true)
269 if(!(filter_var($function, FILTER_VALIDATE_REGEXP)))
271 return array(
"status"=>
"no$key",
272 "value"=>var_export($function,
true)
278 if(!(is_array($function)))
280 return array(
"status"=>
"no$key",
281 "value"=>var_export($function,
true)
287 if(!(is_object($function)))
289 return array(
"status"=>
"no$key",
290 "value"=>var_export($function,
true)
298 return array(
"status"=>
"no$key",
299 "value"=>var_export($function,
true)
305 if(!($val!=$function))
307 return array(
"status"=>
"no$key",
308 "value"=>var_export($function,
true)
313 if(!($val>$function))
315 return array(
"status"=>
"no$key",
316 "value"=>var_export($function,
true)
321 if(!($val<$function))
323 return array(
"status"=>
"no$key",
324 "value"=>var_export($function,
true)
329 if(!($val>=$function))
331 return array(
"status"=>
"no$key",
332 "value"=>var_export($function,
true)
337 if(!($val<=$function))
339 return array(
"status"=>
"no$key",
340 "value"=>var_export($function,
true)
346 return array(
"status"=>
"ok",
348 "value"=>var_export($function,
true)
360 if($this->env===
'developer')
362 if($export[
'status']==
"ok")
370 print
"<script type='text/javascript'>console.$console('status: ".$export[
'status'].
"');</script>";
371 print
"<script type='text/javascript'>console.$console('value: ".$export[
'value'].
"');</script>";
372 if($die){die(
'STOP:500:by Unit Test');}
__construct($path='', $file='log.txt', $maxLine=100, $useFile=true, $mysql=null)
print_ut($export, $die=true)
setEnvironment($public=true)