2017-12-31 16:15:38 +00:00
|
|
|
<?php
|
2017-12-31 18:31:02 +00:00
|
|
|
// view render
|
|
|
|
if(!function_exists('renderView')) {
|
|
|
|
function renderView($name, $data=array()) {
|
|
|
|
if(count($data) > 0) {
|
|
|
|
extract($data);
|
|
|
|
}
|
|
|
|
|
2018-02-13 07:11:13 +00:00
|
|
|
// load view file
|
2017-12-31 18:31:02 +00:00
|
|
|
$viewfile = './view/' . $name . '.php';
|
|
|
|
if(file_exists($viewfile)) {
|
|
|
|
include($viewfile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-26 10:58:54 +00:00
|
|
|
// load system module
|
|
|
|
if(!function_exists('loadModule')) {
|
|
|
|
function loadModule($name) {
|
|
|
|
// load system file
|
2018-03-10 16:47:25 +00:00
|
|
|
$modules = explode(';', $name);
|
|
|
|
foreach($modules as $name2) {
|
|
|
|
$systemfile = './system/' . $name2 . '.php';
|
|
|
|
if(file_exists($systemfile)) {
|
|
|
|
include($systemfile);
|
|
|
|
}
|
2018-02-26 10:58:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-31 18:31:02 +00:00
|
|
|
// load helper
|
|
|
|
if(!function_exists('loadHelper')) {
|
|
|
|
function loadHelper($name) {
|
2018-02-13 07:11:13 +00:00
|
|
|
// load helper file
|
2018-03-10 16:47:25 +00:00
|
|
|
$helpers = explode(';', $name);
|
|
|
|
foreach($helpers as $name2) {
|
|
|
|
$helperfile = './helper/' . $name2 . '.php';
|
|
|
|
if(file_exists($helperfile)) {
|
|
|
|
include($helperfile);
|
|
|
|
}
|
2017-12-31 18:31:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-08 10:01:12 +00:00
|
|
|
// re-route
|
|
|
|
if(!function_exists('reRoute')) {
|
|
|
|
function reRoute($name, $data=array()) {
|
|
|
|
if(count($data) > 0) {
|
|
|
|
extract($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
// load route file
|
|
|
|
$routefile = './route/' . $name . '.php';
|
|
|
|
|
|
|
|
if(file_exists($routefile)) {
|
|
|
|
include($routefile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-31 18:31:02 +00:00
|
|
|
if(!function_exists('array_key_empty')) {
|
2017-12-31 16:15:38 +00:00
|
|
|
function array_key_empty($key, $array) {
|
|
|
|
$empty = true;
|
|
|
|
|
|
|
|
if(is_array($array)) {
|
|
|
|
if(array_key_exists($key, $array)) {
|
|
|
|
if(!empty($array[$key])) {
|
|
|
|
$empty = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return $empty;
|
|
|
|
}
|
|
|
|
}
|
2017-12-31 17:00:50 +00:00
|
|
|
|
2018-02-14 04:45:33 +00:00
|
|
|
if(!function_exists('array_multikey_empty')) {
|
|
|
|
function array_multikey_empty($keys, $array) {
|
|
|
|
$empty = true;
|
|
|
|
foreach($keys as $key) {
|
|
|
|
$empty = ($empty && array_key_empty($key, $array));
|
|
|
|
}
|
|
|
|
return $empty;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-23 09:24:05 +00:00
|
|
|
if(!function_exists("get_value_in_array")) {
|
|
|
|
function get_value_in_array($name, $arr=array(), $default=0) {
|
|
|
|
$output = 0;
|
|
|
|
|
|
|
|
if(is_array($arr)) {
|
|
|
|
$output = array_key_empty($name, $arr) ? $default : $arr[$name];
|
|
|
|
} else {
|
|
|
|
$output = $default;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-31 17:00:50 +00:00
|
|
|
if(!function_exists("cut_str")) {
|
|
|
|
function cut_str($str, $start, $len=0) {
|
|
|
|
$cutted_str = "";
|
|
|
|
if(function_exists("iconv_substr")) {
|
|
|
|
$cutted_str = iconv_substr($str, $start, $len, "utf-8");
|
|
|
|
} elseif(function_exists("mb_substr")) {
|
|
|
|
$cutted_str = mb_substr($str, $start, $len);
|
|
|
|
} else {
|
|
|
|
$cutted_str = substr($start, $len);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $cutted_str;
|
|
|
|
}
|
|
|
|
}
|
2017-12-31 17:55:03 +00:00
|
|
|
|
2018-01-17 13:49:04 +00:00
|
|
|
if(!function_exists("read_file_by_line")) {
|
2017-12-31 17:55:03 +00:00
|
|
|
function read_file_by_line($filename) {
|
|
|
|
$lines = array();
|
|
|
|
$handle = fopen($filename, "r");
|
|
|
|
if ($handle) {
|
|
|
|
while (($line = fgets($handle)) !== false) {
|
|
|
|
$lines[] .= $line;
|
|
|
|
}
|
|
|
|
|
|
|
|
fclose($handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $lines;
|
|
|
|
}
|
|
|
|
}
|
2018-01-17 13:49:04 +00:00
|
|
|
|
|
|
|
if(!function_exists("nl2p")) {
|
|
|
|
function nl2p($string) {
|
|
|
|
$paragraphs = '';
|
|
|
|
foreach (explode("\n", $string) as $line) {
|
|
|
|
if (trim($line)) {
|
|
|
|
$paragraphs .= '<p>' . $line . '</p>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $paragraphs;
|
|
|
|
}
|
|
|
|
}
|