mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-31 07:18:21 -04:00
Refactor PHP.
This commit is contained in:
parent
122546eae1
commit
8fd393d34a
2 changed files with 11 additions and 28 deletions
|
@ -1,6 +1,13 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
function normalize_path($path, $trailing_slash = false) {
|
||||||
|
|
||||||
|
$path = preg_replace("#\\\\+|/+#", "/", $path);
|
||||||
|
return preg_match("#^(\w:)?/$#", $path) ? $path : (rtrim($path, "/") . ($trailing_slash ? "/" : ""));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function json_exit($obj = array()) {
|
function json_exit($obj = array()) {
|
||||||
|
|
||||||
$obj["code"] = 0;
|
$obj["code"] = 0;
|
||||||
|
@ -86,28 +93,10 @@ function exec_cmdv($cmdv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function delete_path($path, $recursive = false) {
|
|
||||||
|
|
||||||
if (is_file($path)) {
|
/*********************************************************************
|
||||||
return @unlink($path);
|
Debug Tools
|
||||||
}
|
*********************************************************************/
|
||||||
|
|
||||||
if (is_dir($path)) {
|
|
||||||
if ($recursive === true && $dir = opendir($path)) {
|
|
||||||
while (($name = readdir($dir)) !== false) {
|
|
||||||
delete_path($path . "/" . $name);
|
|
||||||
}
|
|
||||||
closedir($dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
return @rmdir($path);
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// debug tools
|
|
||||||
|
|
||||||
function err_log($message, $obj = null) {
|
function err_log($message, $obj = null) {
|
||||||
|
|
||||||
|
|
|
@ -11,15 +11,9 @@ define("PASSHASH", "da39a3ee5e6b4b0d3255bfef95601890afd80709");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function normalize_path($path, $trailing_slash = false) {
|
|
||||||
|
|
||||||
$path = preg_replace("#\\\\+|/+#", "/", $path);
|
|
||||||
return preg_match("#^(\w:)?/$#", $path) ? $path : (rtrim($path, "/") . ($trailing_slash ? "/" : ""));
|
|
||||||
}
|
|
||||||
|
|
||||||
function normalized_require_once($lib) {
|
function normalized_require_once($lib) {
|
||||||
|
|
||||||
require_once(normalize_path(dirname(__FILE__) . "/inc/${lib}.php", false));
|
require_once(preg_replace("#\\\\+|/+#", "/", dirname(__FILE__) . "/inc/${lib}.php"));
|
||||||
}
|
}
|
||||||
|
|
||||||
normalized_require_once("util");
|
normalized_require_once("util");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue