function getFunctions($dir){ global $functions_array; if ($dirHandle = opendir($dir)) { while ($file = readdir($dirHandle)) { if ($file != '.' and $file != '..') { if(is_dir($file)){ getFunctions($dir . '/' . $file); } else { $extension=explode(".",$file); if($extension[(count($extension)-1)] == 'php'){ $file_contents = file_get_contents($dir . '/' . $file); $file_contents_array = explode("\n", $file_contents); for ($index = 0; $index < sizeof($file_contents_array); $index++) { if(preg_match('~\s([^\s]*)(\s)?\(|\(~u', $file_contents_array[$index], $matches)){ foreach($matches as $match){ $class_function=explode("->",$match); $match = $class_function[(count($class_function)-1)]; if(!in_array($match, $functions_array) and !strstr($match, '(')){ $functions_array[] = $match; //pr($match); } } } } } } } } } }
function generateSingleReports(&$smarty) { global $db; $lastTimestamp = 0; $profile_ids = array(); $profileDates = array(); $profiles = array(); $qry = $db->query('SELECT UNIX_TIMESTAMP(timestamp) timestamp, MIN(id) id FROM jquery GROUP BY (timestamp) ORDER BY timestamp'); foreach ($qry as $profile) { // länger als eine Sekunde zum letzten Timestamp? $timestamp = intval($profile['timestamp']); if ($timestamp - $lastTimestamp > 1) { // neuer Profile $profile_ids[] = $profile['id']; $profileDates[$profile['id']] = date('Y-m-d H:i:s', $timestamp); } $lastTimestamp = $timestamp; } foreach ($profile_ids as $pindex => $id) { $nextId = $pindex == count($profile_ids) - 1 ? sprintf("%u", -1) : $profile_ids[$pindex + 1]; $whereIdRange = "({$id} <= id) AND (id < {$nextId})"; $aggregatedRuntime = aggregatedRuntime($whereIdRange); $labels = array(); $data = array(); array_push($profiles, array('id' => $id, 'title' => "Profiling " . $profileDates[$id], 'aggregated_runtime' => $aggregatedRuntime, 'functions' => getFunctions($whereIdRange, $aggregatedRuntime, $labels, $data), 'queries' => getQueries($whereIdRange, $aggregatedRuntime), 'chart' => array('labels' => implode("|", $labels), 'data' => implode(",", $data)))); $smarty->assign('profiles', $profiles); } }
if (!empty($returnPath)) { $paths[] = $returnPath; } } } return $paths; } function getFunctions($extensions) { $output = array(); if (!empty($extensions)) { foreach ($extensions as $extension) { $name = explode('/', $extension, 2); $namespace = ucwords(preg_replace('/[^0-9a-z]+/', '_', strtolower(array_shift($name)))); $extensionPath = realpath(__DIR__ . '/../' . $namespace . '/' . $namespace . '.php'); if (file_exists($extensionPath)) { require_once $extensionPath; $namespace = $namespace . '::'; $function = 'getFunctions'; $output = array_merge($output, call_user_func($namespace . $function, $namespace)); } } } return $output; } $path = realpath(__DIR__) . '/../..'; $library = $path . '/SassParser.php'; require_once $library; $options = array('style' => 'expanded', 'cache' => false, 'syntax' => 'scss', 'debug' => false, 'debug_info' => false, 'load_path_functions' => array('loadCallback'), 'load_paths' => array(dirname($file)), 'functions' => getFunctions(array('Compass', 'Own')), 'extensions' => array('Compass', 'Own')); $parser = new SassParser($options); return $parser->toCss($file);
/** * This method process nested function calls that may be in the arguments * passed into a higher level function. * * @param String|\Tbm\Peval\Types\String $arguments * * @throws \Tbm\Peval\EvaluationException * @return \Tbm\Peval\Types\String The arguments with any nested function calls evaluated. * */ public function processNestedFunctions(string $arguments) { $evaluatedArguments = new String(); // Process nested function calls. if ($arguments->length() > 0) { $argumentsEvaluator = new Evaluator($this->quoteCharacter, $this->loadMathVariables, $this->loadMathFunctions, $this->loadStringFunctions, $this->processNestedFunctions); $this->argumentsEvaluator->setFunctions(getFunctions()); $this->argumentsEvaluator->setVariables(getVariables()); $this->argumentsEvaluator->setVariableResolver(getVariableResolver()); $tokenizer = new ArgumentTokenizer($arguments, EvaluationConstants::FUNCTION_ARGUMENT_SEPARATOR); $evaluatedArgumentList = new ArrayList(); while ($tokenizer . hasMoreTokens()) { $argument = $tokenizer->nextToken()->trim(); try { $argument = $argumentsEvaluator->evaluate1($argument); } catch (Exception $e) { throw new EvaluationException($e->getMessage(), $e); } $evaluatedArgumentList->add($argument); } $evaluatedArgumentIterator = $evaluatedArgumentList->iterator(); while ($evaluatedArgumentIterator->valid()) { if ($evaluatedArguments->length() > 0) { $evaluatedArguments->append(EvaluationConstants::FUNCTION_ARGUMENT_SEPARATOR); } $evaluatedArgumentIterator->next(); $evaluatedArgument = (string) $evaluatedArgumentIterator->current(); $evaluatedArguments . append($evaluatedArgument); } } return $evaluatedArguments; }