mirror of
https://github.com/myvesta/vesta
synced 2025-07-05 20:41:53 -07:00
php-func fix
This commit is contained in:
parent
dd1efc58a1
commit
beccead388
4 changed files with 34 additions and 14 deletions
|
@ -9,3 +9,4 @@
|
|||
#----------------------------------------------------------#
|
||||
|
||||
php /usr/local/vesta/func/bash-to-php-interpreter.php "$@"
|
||||
exit $?
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
if (!isset($argv)) exit;
|
||||
if (!isset($argv)) exit 5;
|
||||
|
||||
include ("/usr/local/vesta/func/main.php");
|
||||
include ("/usr/local/vesta/func/string.php");
|
||||
|
@ -8,8 +8,11 @@ include ("/usr/local/vesta/func/string.php");
|
|||
$counter=count($argv);
|
||||
if ($counter<2) myvesta_throw_error(2, 'Function is missing');
|
||||
|
||||
$func="myvesta_".$argv[1];
|
||||
if (!function_exists($func)) myvesta_throw_error(2, 'Function does not exists');
|
||||
$func=$argv[1];
|
||||
if (!function_exists($func)) {
|
||||
$func="myvesta_".$argv[1];
|
||||
if (!function_exists($func)) myvesta_throw_error(2, 'Function does not exists');
|
||||
}
|
||||
|
||||
$params=array();
|
||||
|
||||
|
@ -17,5 +20,15 @@ for ($i=2; $i<$counter; $i++) {
|
|||
$argv[$i]=myvesta_fix_backslashes($argv[$i]);
|
||||
$params[]=$argv[$i];
|
||||
}
|
||||
// echo $func."\n"; print_r($params);
|
||||
|
||||
$r=call_user_func_array($func, $params);
|
||||
if (is_bool($r)) {
|
||||
if ($r) {
|
||||
exit(0);
|
||||
} else {
|
||||
exit(MYVESTA_ERROR_GENERAL);
|
||||
}
|
||||
} else {
|
||||
echo $r;
|
||||
exit(0);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ define('MYVESTA_ERROR_PERMISSION_DENIED', 1);
|
|||
define('MYVESTA_ERROR_MISSING_ARGUMENTS', 2);
|
||||
define('MYVESTA_ERROR_FILE_DOES_NOT_EXISTS', 3);
|
||||
define('MYVESTA_ERROR_STRING_NOT_FOUND', 4);
|
||||
define('MYVESTA_ERROR_GENERAL', 5);
|
||||
|
||||
function myvesta_throw_error($code, $message) {
|
||||
global $myvesta_exit_on_error;
|
||||
|
|
|
@ -11,7 +11,8 @@ function myvesta_replace_in_file($file, $find, $replace) {
|
|||
|
||||
$buf=str_replace($find, $replace, $buf);
|
||||
$r=file_put_contents($file, $buf);
|
||||
return $r;
|
||||
if ($r===false) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function myvesta_get_between_in_file($file, $left_substring, $right_substring, $start=0, $return_left_substring=0, $return_right_substring=0, $left_substring_necessary=1, $right_substring_necessary=1) {
|
||||
|
@ -25,7 +26,8 @@ function myvesta_replace_in_file_once_between_including_borders($file, $left, $r
|
|||
$text=file_get_contents($file);
|
||||
$buf=myvesta_str_replace_once_between_including_borders($text, $left, $right, $replace_with);
|
||||
$r=file_put_contents($file, $buf);
|
||||
return $r;
|
||||
if ($r===false) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function myvesta_strip_once_in_file_between_including_borders($file, $left, $right) {
|
||||
|
@ -33,7 +35,8 @@ function myvesta_strip_once_in_file_between_including_borders($file, $left, $rig
|
|||
$text=file_get_contents($file);
|
||||
$buf=myvesta_str_strip_once_between_including_borders($text, $left, $right);
|
||||
$r=file_put_contents($file, $buf);
|
||||
return $r;
|
||||
if ($r===false) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function myvesta_replace_in_file_between_including_borders($file, $left, $right, $replace_with) {
|
||||
|
@ -41,7 +44,8 @@ function myvesta_replace_in_file_between_including_borders($file, $left, $right,
|
|||
$text=file_get_contents($file);
|
||||
$buf=myvesta_str_replace_between_including_borders($text, $left, $right, $replace_with);
|
||||
$r=file_put_contents($file, $buf);
|
||||
return $r;
|
||||
if ($r===false) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function myvesta_strip_in_file_between_including_borders($file, $left, $right) {
|
||||
|
@ -49,7 +53,8 @@ function myvesta_strip_in_file_between_including_borders($file, $left, $right) {
|
|||
$text=file_get_contents($file);
|
||||
$buf=myvesta_str_strip_between_including_borders($text, $left, $right);
|
||||
$r=file_put_contents($file, $buf);
|
||||
return $r;
|
||||
if ($r===false) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// --- string functions ---
|
||||
|
@ -71,7 +76,7 @@ function myvesta_str_get_between (&$text, $left_substring, $right_substring, $st
|
|||
{
|
||||
if ($from_null==0) $pos1=$pos1+strlen($left_substring);
|
||||
}
|
||||
$pos2=strpos($text, $right_substring, $pos1+1);
|
||||
$pos2=strpos($text, $right_substring, $pos1+strlen($left_substring));
|
||||
if ($pos2===FALSE)
|
||||
{
|
||||
if ($right_substring_necessary==1) return "";
|
||||
|
@ -92,7 +97,7 @@ function myvesta_str_get_between (&$text, $left_substring, $right_substring, $st
|
|||
function myvesta_str_replace_once_between_including_borders(&$text, $left, $right, $replace_with) {
|
||||
$pos1=strpos($text, $left);
|
||||
if ($pos1===false) return $text;
|
||||
$pos2=strpos($text, $right, $left+strlen($left));
|
||||
$pos2=strpos($text, $right, $pos1+strlen($left));
|
||||
if ($pos2===false) return $text;
|
||||
return substr($text, 0, $pos1).$replace_with.substr($text, $pos2+strlen($right));
|
||||
}
|
||||
|
@ -100,7 +105,7 @@ function myvesta_str_replace_once_between_including_borders(&$text, $left, $righ
|
|||
function myvesta_str_strip_once_between_including_borders(&$text, $left, $right) {
|
||||
$pos1=strpos($text, $left);
|
||||
if ($pos1===false) return $text;
|
||||
$pos2=strpos($text, $right, $left+strlen($left));
|
||||
$pos2=strpos($text, $right, $pos1+strlen($left));
|
||||
if ($pos2===false) return $text;
|
||||
return substr($text, 0, $pos1).substr($text, $pos2+strlen($right));
|
||||
}
|
||||
|
@ -112,7 +117,7 @@ function myvesta_str_replace_between_including_borders($text, $left, $right, $re
|
|||
while (true) {
|
||||
$pos1=strpos($text, $left);
|
||||
if ($pos1===false) break;
|
||||
$pos2=strpos($text, $right, $left+$left_len);
|
||||
$pos2=strpos($text, $right, $pos1+$left_len);
|
||||
if ($pos2===false) break;
|
||||
$text=substr($text, 0, $pos1).$replace_with.substr($text, $pos2+$right_len);
|
||||
}
|
||||
|
@ -125,7 +130,7 @@ function myvesta_str_strip_between_including_borders($text, $left, $right) {
|
|||
while (true) {
|
||||
$pos1=strpos($text, $left);
|
||||
if ($pos1===false) break;
|
||||
$pos2=strpos($text, $right, $left+$left_len);
|
||||
$pos2=strpos($text, $right, $pos1+$left_len);
|
||||
if ($pos2===false) break;
|
||||
$text=substr($text, 0, $pos1).substr($text, $pos2+$right_len);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue