pythonscript($path,escapeshellarg($param)); } public function pythonscript($path,$param) { $path_info = pathinfo($path); $config = Grav::instance()['config']->get('plugins.python-script'); $command = "python " . $path; //$command = "test"; if (in_array($path_info['extension'], $config['allowed_extensions'])) { if (Utils::startsWith($path, '/')) { if ($config['allow_in_grav'] && file_exists(GRAV_ROOT . $path)) { $command = "python " .GRAV_ROOT. $path; } elseif ($config['allow_in_filesystem'] && file_exists($path)) { $command = "python " . $path; } } else { $page_path = Grav::instance()['page']->path() . '/' . $path; //$param=Grav::instance()['page']->path() . '/' . $param; if ($config['allow_in_page'] && file_exists($page_path)) { $command = "python " . $page_path; } } } $command .= " ". $param; $output = shell_exec($command); //return $command ."
" . $output; return $output; } }