<?php include $GET_['x']; include_once $GET_['x']; php_check_syntax($GET_['x']); require $GET_['x']; require_once $GET_['x']; runkit_import($GET_['x']); set_include_path($GET_['x']); virtual($GET_['x']);
/** * @param string $filename * * @return null */ protected static function reRequireFile($filename) { if (function_exists('runkit_import')) { $result = runkit_import($filename, RUNKIT_IMPORT_FUNCTIONS | RUNKIT_IMPORT_CLASS_METHODS | RUNKIT_IMPORT_OVERRIDE); if (!$result) { self::markTestSkipped("Failed to reimport file {$filename}"); } } }
/** * @param string $filename Filename relative to library directory. * * @return null */ protected static function reRequireFile($filename) { if (extension_loaded('runkit')) { $result = runkit_import(sprintf('%s/../phpseclib/Msulistijo/PhpseclibBundle/%s', __DIR__, $filename), RUNKIT_IMPORT_FUNCTIONS | RUNKIT_IMPORT_CLASS_METHODS | RUNKIT_IMPORT_OVERRIDE); if (!$result) { self::markTestSkipped("Failed to reimport file {$filename}"); } } }
public static function fromFile($file) { // RUNKIT_IMPORT_OVERRIDE | RUNKIT_IMPORT_FUNCTIONS | // RUNKIT_IMPORT_CLASSES | RUNKIT_IMPORT_CLASS_METHODS | // RUNKIT_IMPORT_CLASS_PROPS | RUNKIT_IMPORT_CLASS_CONSTS // => 4127 static $flags = 4127; return runkit_import($file, $flags); }
public static function importChanges($instance) { try { $reflection = new ReflectionClass($instance); } catch (ReflectionException $e) { LegacyLogger::log("WARN", "Registry", "RUNKIT: Failed to reflect class, reason was: '" . $e->getMessage() . "'"); return; } LegacyLogger::log("DEBUG", "Registry", "Re-importing file '" . $reflection->getFileName() . "'"); runkit_import($reflection->getFileName(), RUNKIT_IMPORT_CLASSES | RUNKIT_IMPORT_FUNCTIONS | RUNKIT_IMPORT_OVERRIDE); }
/** * @param $p */ protected function onPacket($p) { if ($p['op'] === 'spawnInstance') { $fullname = $p['appfullname']; $fullname = str_replace('-', ':', $fullname); if (mb_orig_strpos($fullname, ':') === false) { $fullname .= ':'; } list($app, $name) = explode(':', $fullname, 2); Daemon::$appResolver->getInstance($app, $name, true, true); } elseif ($p['op'] === 'importFile') { if (!Daemon::$config->autoreimport->value) { Daemon::$process->gracefulRestart(); return; } $path = $p['path']; Timer::add(function ($event) use($path) { if (Daemon::supported(Daemon::SUPPORT_RUNKIT_IMPORT)) { //Daemon::log('--start runkit_import('.$path.')'); runkit_import($path, RUNKIT_IMPORT_FUNCTIONS | RUNKIT_IMPORT_CLASSES | RUNKIT_IMPORT_OVERRIDE); //Daemon::log('--end runkit_import('.$path.')'); } else { $this->appInstance->log('Cannot import \'' . $path . '\': runkit_import is not callable.'); } $event->finish(); }, 5); } elseif ($p['op'] === 'call') { if (mb_orig_strpos($p['appfullname'], ':') === false) { $p['appfullname'] .= ':'; } list($app, $name) = explode(':', $p['appfullname'], 2); if ($app = Daemon::$appResolver->getInstance($app, $name)) { $app->RPCall($p['method'], $p['args']); } } }
function reloadController($mvc, $controller_file) { if (extension_loaded('runkit') and $this->server->config['apps']['auto_reload']) { clearstatcache(); $fstat = stat($controller_file); //修改时间大于加载时的时间 if ($fstat['mtime'] > $this->env['controllers'][$mvc['controller']]['time']) { runkit_import($controller_file, RUNKIT_IMPORT_CLASS_METHODS | RUNKIT_IMPORT_OVERRIDE); $this->env['controllers'][$mvc['controller']]['time'] = time(); } } }
public function onPacket($p) { if ($p['op'] === 'spawnInstance') { $fullname = $p['appfullname']; $fullname = str_replace('-', ':', $fullname); if (strpos($fullname, ':') === false) { $fullname .= ':'; } list($app, $name) = explode(':', $fullname, 2); Daemon::$appResolver->appInstantiate($app, $name); } elseif ($p['op'] === 'importFile') { $path = $p['path']; Daemon_TimedEvent::add(function ($event) use($path) { $self = Daemon::$process; if (Daemon::supported(Daemon::SUPPORT_RUNKIT_IMPORT)) { runkit_import($path, RUNKIT_IMPORT_FUNCTIONS | RUNKIT_IMPORT_CLASSES | RUNKIT_IMPORT_OVERRIDE); } else { $this->appInstance->log('Cannot import \'' . $path . '\': runkit_import is not callable.'); } $event->finish(); }, 5); } elseif ($p['op'] === 'call') { if (strpos($p['appfullname'], '-') === false) { $p['appfullname'] .= '-'; } list($app, $name) = explode('-', $p['appfullname'], 2); if ($app = Daemon::$appResolver->getInstanceByAppName($app, $name)) { $app->RPCall($p['method'], $p['args']); } } }
/** * This function will allow you to load a module into the manager, so * all callbacks and things will be forwarded properly. * * @param string $sName Name of the module you wish to load. * @param boolean $bReorder Re-organize all modules based on priority. * @throws Exception When the module could not be loaded. * @return boolean Indicates whether the module loaded successfully. */ public function loadModule($sName, $bReorder = true) { if (isset($this->m_aModules[$sName])) { return false; } $sPath = self::MODULE_DIRECTORY . '/' . $sName; if (file_exists($sPath) && is_dir($sPath)) { $sPath .= '/Module.php'; } else { $sPath .= '.php'; } if (file_exists($sPath)) { if (class_exists($sName)) { /** This module was already loaded, just re-instantiate it. **/ if (function_exists('runkit_import')) { /** Overwrite it using runkit when available. **/ runkit_import($sPath, RUNKIT_IMPORT_OVERRIDE | RUNKIT_IMPORT_CLASSES); } } else { /** Try to define the expected class by including the file we expect it to be in. **/ include_once $sPath; if (!class_exists($sName)) { throw new \Exception('Module file does not define a class with the name ' . $sName . '.'); } } } else { throw new \Exception('There was no file found which should contain the module ' . $sName . '.'); } try { $this->m_aModules[$sName] = array('Instance' => new $sName(), 'Started' => time(), 'Methods' => array()); } catch (\Exception $pException) { throw new \Exception('Exception occurred during instantiation of module ' . $sName . '.', 0, $pException); } if (!$this->m_aModules[$sName]['Instance'] instanceof ModuleBase) { unset($this->m_aModules[$sName]); throw new \Exception('The class ' . $sName . ' is not a module.'); } $pClassObj = new \ReflectionClass($sName); foreach ($pClassObj->getMethods() as $pMethodObj) { $this->m_aModules[$sName]['Methods'][$pMethodObj->getName()] = $pMethodObj; } unset($pClassObj); if ($bReorder == true) { /** Re-order the modules. **/ $this->prioritize(); } /** Callback for other modules to inform them that a module has been loaded. **/ $this->onModuleLoad($this->m_aModules[$sName]['Instance']); /** If this module has this callback as well, pass all other modules through it. **/ if (isset($this->m_aModules[$sName]['Methods']['onModuleLoad'])) { foreach ($this->m_aModules as $sModuleName => $pModule) { if ($sModuleName == $sName) { /** Already done this one. **/ continue; } $this->m_aModules[$sName]['Instance']->onModuleLoad($pModule['Instance']); } } return true; }
public static function reload_class($class) { $ref = new ReflectionClass($class); $filename = $ref->getFileName(); return runkit_import($filename, RUNKIT_IMPORT_OVERRIDE | RUNKIT_IMPORT_CLASS_METHODS); }
/** * Load a class definition * * @param string $className The className to load * @return true If success * @throws nExecption If the file isn't find */ public static function load($className) { if (!class_exists($className) && !in_array($className, self::$loadedClass)) { if (!array_key_exists($className, self::$loadFiles)) { if ($file = file::nyroExists(array('name' => $className))) { require $file; self::$loadFiles[$className] = array($file); self::$saveCacheLoad = true; self::$loadedClass[] = $className; if (defined('RUNKIT_VERSION')) { $filesExtend = file::nyroExists(array('name' => $className, 'type' => 'extend', 'rtl' => false, 'list' => true)); if (!empty($filesExtend)) { self::$loadFiles[$className][1] = $filesExtend; foreach ($filesExtend as $fe) { runkit_import($fe); } } } } else { if (!lib::load($className)) { if (self::$throwOnLoad) { throw new nException('Factory - load: Unable to find the file for ' . $className . '.'); } else { return false; } } } } else { require self::$loadFiles[$className][0]; self::$loadedClass[] = $className; if (defined('RUNKIT_VERSION') && array_key_exists(1, self::$loadFiles[$className])) { foreach (self::$loadFiles[$className][1] as $fe) { runkit_import($fe); } } } } return true; }
public function onPacket($p) { if ($p['op'] === 'spawnInstance') { $fullname = $p['appfullname']; if (strpos($fullname, '-') === false) { $fullname .= '-'; } list($app, $name) = explode('-', $fullname, 2); Daemon::$appResolver->appInstantiate($app, $name); } elseif ($p['op'] === 'importFile') { $path = $p['path']; Daemon_TimedEvent::add(function ($event) use($path) { $self = Daemon::$process; runkit_import($path, RUNKIT_IMPORT_FUNCTIONS | RUNKIT_IMPORT_CLASSES | RUNKIT_IMPORT_OVERRIDE); $event->finish(); }, 5); } elseif ($p['op'] === 'call') { if (strpos($p['appfullname'], '-') === false) { $p['appfullname'] .= '-'; } list($app, $name) = explode('-', $p['appfullname'], 2); if ($app = Daemon::$appResolver->getInstanceByAppName($app, $name)) { $app->RPCall($p['method'], $p['args']); } } }
/** Loads one plugin. * This function loads one plugin. It is a very basic function. It checks that plugin exists and isn't loaded yet, and include its file. All the remaining work * is done by PluginManager::initPlugin(), called inside the plugin file. * * \param $plugin Plugin to be loaded. * \param $manual Manual loading indicator. It permits the bot to know if a plugin has been loaded manually or automatically, by dependence. * * \return TRUE if plugin loaded successfully, FALSE otherwise. * In fact, this value, beyond the "plugin not found" error, depends of the return value of PluginManager::initPlugin. */ public function loadPlugin($plugin, $manual = FALSE) { Leelabot::message('Loading plugin $0', array($plugin)); //We check that the plugin is not already loaded if (in_array($plugin, $this->getLoadedPlugins())) { Leelabot::message('Plugin $0 is already loaded', array($plugin), E_WARNING); return FALSE; } if (!is_file('plugins/' . $plugin . '.php')) { Leelabot::message('Plugin $0 does not exists (File : $1)', array($plugin, getcwd() . '/plugins/' . $plugin . '.php'), E_WARNING); return FALSE; } if (!isset($this->_pluginCache[$plugin])) { include 'plugins/' . $plugin . '.php'; } elseif (extension_loaded('runkit')) { runkit_import('plugins/' . $plugin . '.php', RUNKIT_IMPORT_OVERRIDE | RUNKIT_IMPORT_CLASS_METHODS); } return $this->initPlugin($this->_pluginCache[$plugin], $manual); //Else we reload the plugin with the cached data from the first loading }
/** * @Given I use pr :id */ public function iUsePr($id) { exec(sprintf('cd vendor/knplabs/gaufrette && git stash && git pull origin master && curl -sS https://patch-diff.githubusercontent.com/raw/KnpLabs/Gaufrette/pull/%s.patch | git apply', $id)); $this->checkRunkit(); runkit_import('vendor/autoload.php', RUNKIT_IMPORT_OVERRIDE); }
function process_dynamic(&$request, &$response) { global $php; $php->__init(); $request->setGlobal(); $path = trim($request->meta['path'], '/'); $url_route_func = $this->config['apps']['url_route']; $mvc = $url_route_func($path); $php->env['mvc'] = $mvc; /*---------------------加载MVC程序----------------------*/ $controller_file = APPSPATH . '/controllers/' . $mvc['controller'] . '.php'; if (!isset($php->env['controllers'][$mvc['controller']])) { if (is_file($controller_file)) { import_controller($controller_file); } else { $this->http_error(404, $response, "控制器 <b>{$mvc['controller']}</b> 不存在!"); return $response; } } //将对象赋值到控制器 $php->request = $request; $php->response = $response; /*---------------------检测代码是否更新----------------------*/ if (extension_loaded('runkit') and $this->config['apps']['auto_reload']) { clearstatcache(); $fstat = stat($controller_file); //修改时间大于加载时的时间 if ($fstat['mtime'] > $php->env['controllers'][$mvc['controller']]['time']) { runkit_import($controller_file); $php->env['controllers'][$mvc['controller']]['time'] = time(); $this->log("reload controller " . $mvc['controller']); } } /*---------------------处理MVC----------------------*/ if (empty($mvc['param'])) { $param = array(); } else { $param = $mvc['param']; } $response->head['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0'; $response->head['Pragma'] = 'no-cache'; $response->head['Content-Type'] = 'text/html; charset=' . $this->config['apps']['charset']; try { $controller = new $mvc['controller']($php); if (!method_exists($controller, $mvc['view'])) { $this->http_error(404, $response, "视图 <b>{$mvc['controller']}->{$mvc['view']}</b> 不存在!"); return $response; } if ($controller->is_ajax) { $response->body = json_encode(call_user_func(array($controller, $mvc['view']), $param)); } else { $response->body = call_user_func(array($controller, $mvc['view']), $param); } } catch (Exception $e) { if ($request->finish != 1) { $this->http_error(404, $response, $e->getMessage()); } } //保存Session if ($php->session_open) { $php->session->save(); } return $response; }