needsLoggedIn(); $path = formatPath($path); died(is_file($path) ? 'true' : 'false'); } function _exists($path) { needsLoggedIn(); $path = formatPath($path); died(file_exists($path) ? 'true' : 'false'); } if (isset($_SESSION['nearos']) && isset($_SESSION['nearos']['aes']) && !empty($_SESSION['nearos']['aes']) && $request !== 'login') { $request = '_' . AES_Decrypt($request, $_SESSION['nearos']['aes']); } else { $request = '_' . $request; } if (function_exists($request)) { $args = get_func_argNames($request); $callArgs = array(); if ($request === '_login' && !isset($_POST['aeskey'])) { $_POST['aeskey'] = ''; } foreach ($args as $i => $name) { if (!isset($_POST[$name])) { died('Missing argument "' . $name . '" for request "' . substr($request, 1) . '"'); } $callArgs[] = isset($_SESSION['nearos']) && isset($_SESSION['nearos']['aes']) && !empty($_SESSION['nearos']['aes']) && $request !== '_login' ? AES_Decrypt($_POST[$name], $_SESSION['nearos']['aes']) : $_POST[$name]; } died(call_user_func_array($request, $callArgs)); } else { died('Bad request'); }
public function getDataOfVariables() { //function to get the argument names within this method function get_func_argNames($funcName) { $parameters = ""; //get the file $file = file_get_contents(basename($_SERVER['PHP_SELF'])); //echo "file is ".$file; //search for the specific function $pos = strpos($file, $funcName); if ($pos != false) { $i = 0; //find the first occurance of the open brace after the function $open = strpos($file, '(', $pos); //loop until we get to the end of the brace $i = $open + 1; //move over from the open brace and start getting parameter names while ($file[$i] != ')') { $parameters .= $file[$i]; $i++; } return $parameters; } else { echo '<br/>ERROR: ' . $funcName . ' is not a function <br/>'; } } //end og get_function_argument name //execute $generatedParam = split(",", get_func_argNames('getDataOfVariables')); //get each parameters and split them based on the ',' $args = func_get_args(); //get the real value of every arguments //echo 'Number of arguments :'. $numargs; //loop and display the data echo '<br/>Displaying values for getDataOfVariables(' . get_func_argNames('getDataOfVariables') . ')'; echo '<br/>===================================================================================='; for ($i = 0; $i < count($generatedParam); $i++) { echo "<br/> Data for {$generatedParam[$i]} is : {$args[$i]}"; } }