Example #1
0
function controller_render($name, $action)
{
    if (!$name) {
        $name = 'default';
    }
    $name = strtolower($name);
    $ret = preg_match('/(^[a-z][a-z]*?[a-z]$)/', $name);
    if ($ret <= 0) {
        return '控制器名称非法' . $ret . $name;
    }
    $path = _ROOT . 'controller/' . $name . '.php';
    if (!file_exists($path)) {
        return '控制器不存在';
    }
    include_once $path;
    $classname = $name . 'Controller';
    if (!class_exists($classname)) {
        return '控制器声明不完全';
    }
    $o = new $classname();
    if (!method_exists($o, 'render')) {
        return '控制器未继承BaseController::Render';
    }
    define('BASE_CONTROLLER', $name);
    return call_user_method('render', $o, $action);
}
Example #2
0
 public function import()
 {
     $job = $this->getEngine()->getJob();
     $config = $this->getEngine()->getConfig();
     $resourcesCfg = new NagiosResource();
     $segment = $this->getSegment();
     $values = $segment->getValues();
     $fileName = $segment->getFilename();
     foreach ($values as $key => $entries) {
         foreach ($entries as $entry) {
             $value = $entry['value'];
             $lineNum = $entry['line'];
             if (key_exists($key, $this->fieldMethods) && $this->fieldMethods[$key] != '') {
                 // Okay, let's check that the method DOES exist
                 if (!method_exists($resourcesCfg, $this->fieldMethods[$key])) {
                     $job->addError("Method " . $this->fieldMethods[$key] . " does not exist for variable: " . $key . " on line " . $lineNum . " in file " . $fileName);
                     if (!$config->getVar('continue_error')) {
                         return false;
                     }
                 } else {
                     call_user_method($this->fieldMethods[$key], $resourcesCfg, $value);
                 }
             }
         }
     }
     // If we got here, it's safe to delete the existing main config and save the new one
     $oldConfig = NagiosResourcePeer::doSelectOne(new Criteria());
     if ($oldConfig) {
         $oldConfig->delete();
     }
     $resourcesCfg->save();
     $job->addNotice("NagiosResourceImporter finished importing resources configuration.");
     return true;
 }
Example #3
0
 public function get($type)
 {
     $method = "_get_{$type}";
     if (method_exists($this, $method)) {
         return call_user_method($method, $this);
     }
 }
 /**
  * @param $methodOne
  * @param $methodTwo
  *
  * @dataProvider providerTestApiBuildUrlBasic
  *
  */
 public function testApiBuildUrlBasicWithTwoMethods($methodOne, $methodTwo, $expected)
 {
     $api = new Api();
     call_user_method($methodOne, $api);
     call_user_method($methodTwo, $api);
     $this->assertEquals($expected, $api->get());
 }
Example #5
0
	function display($tpl = null) {
		$tpl = null;
		$this->set('_layout', 'default');
		$user = JFactory::getUser();
		$app = JFactory::getApplication('SITE');
		if ($user->guest) {
			$session = JFactory::getSession();
			$session->set('oseReturnUrl', base64_encode('index.php?option=com_osemsc&view=member'));
			$app->redirect('index.php?option=com_osemsc&view=login');
		} else {
			$member = oseRegistry::call('member');
			$view = $member->getInstance('PanelView');
			$member->instance($user->id);
			$hasMember = $member->hasOwnMsc();
			if ($hasMember > 0) {
				$result = $member->getMemberPanelView('Member');
				if ($result['tpl'] != 'master') {
					$tpl = $result['tpl'];
				}
			} else {
				$app->redirect('index.php?option=com_osemsc&view=member', JText::_('You do not have access'));
			}
		}
		$task = JRequest::getCmd('memberTask', null);
		if (empty($task)) {
			oseExit();
		}
		if (!method_exists($this, $task)) {
			oseExit();
		}
		call_user_method($task, $this);
	}
 /**
  * Builds a project.
  * Takes filesystem data and builds a product XML file
  * Also copies associated files to upload directory
  *
  * @param   VDE_Project
  */
 public function build(VDE_Project $project)
 {
     if (!is_dir($project->buildPath)) {
         if (!mkdir($project->buildPath, 0644)) {
             throw new VDE_Builder_Exception('Could not create project directory');
         }
     }
     $this->_output .= "Building project {$project->id}\n";
     $this->_project = $project;
     $this->_xml = new vB_XML_Builder($this->_registry);
     $this->_phrases = array();
     $this->_files = array();
     $this->_xml->add_group('product', array('productid' => $project->id, 'active' => $project->active));
     $this->_xml->add_tag('title', $project->meta['title']);
     $this->_xml->add_tag('description', $project->meta['description']);
     $this->_xml->add_tag('version', $project->meta['version']);
     $this->_xml->add_tag('url', $project->meta['url']);
     $this->_xml->add_tag('versioncheckurl', $project->meta['versionurl']);
     foreach ($this->_types as $type) {
         $suffix = ucfirst($type);
         $method = method_exists($project, $extended = "getExtended{$suffix}") ? $extended : "get{$suffix}";
         call_user_method("_process{$suffix}", $this, call_user_method($method, $project));
     }
     $this->_xml->close_group();
     file_put_contents($xmlPath = sprintf('%s/product-%s.xml', $project->buildPath, $project->id), $xml = "<?xml version=\"1.0\" encoding=\"{$project->encoding}\"?>\r\n\r\n" . $this->_xml->output());
     $this->_output .= "Created Product XML Successfully at {$xmlPath}\n";
     if ($uploadFiles = array_merge($project->files, $this->_files)) {
         $this->_copyFiles($uploadFiles, $project->buildPath . '/upload');
     }
     $this->_output .= "Project {$project->meta[title]} Built Succesfully!\n\n";
     return $this->_output;
 }
Example #7
0
 public function callback($type, $method = 'callback')
 {
     $at = AuthenticationType::getByHandle($type);
     $this->view();
     if (!method_exists($at->controller, $method)) {
         throw new exception('Invalid method.');
     }
     if ($method != 'callback') {
         if (!is_array($at->controller->apiMethods) || !in_array($method, $at->controller->apiMethods)) {
             throw new Exception("Invalid method.");
         }
     }
     try {
         $message = call_user_method($method, $at->controller);
         if (trim($message)) {
             $this->set('message', $message);
         }
     } catch (exception $e) {
         if ($e instanceof AuthenticationTypeFailureException) {
             // Throw again if this is a big`n
             throw $e;
         }
         $this->error->add($e->getMessage());
     }
 }
Example #8
0
 public function loadModule($module)
 {
     if (!isset($_GET['module'])) {
         if (isset($_GET["r"])) {
             $d = explode("/", $_GET["r"]);
             if (count($d) != 2) {
                 echo "Invalid R parameters";
                 exit;
             } else {
                 if ($d[0] != "" && $d[1] != "") {
                     $this->default_controller = $d[0];
                     $this->default_view = $d[1];
                 }
             }
         }
         $this->default_controller = $this->default_controller . "Controller";
         $this->default_controller[0] = strtoupper($this->default_controller[0]);
         require_once "app/controllers/" . $this->default_controller . ".php";
         $controller = new $this->default_controller();
         $method = $this->default_view . "Action";
         if (method_exists($controller, $method)) {
             $data = call_user_method($method, $controller);
         } else {
             echo "<b>" . $method . "</b> not found in " . $this->default_controller;
         }
     } else {
     }
 }
 public function import()
 {
     $job = $this->getEngine()->getJob();
     $config = $this->getEngine()->getConfig();
     $segment = $this->getSegment();
     $values = $segment->getValues();
     $fileName = $segment->getFilename();
     $contactgroup = new NagiosContactGroup();
     foreach ($values as $key => $entries) {
         foreach ($entries as $entry) {
             // Skips
             $value = $entry['value'];
             $lineNum = $entry['line'];
             // Okay, let's check that the method DOES exist
             if (!method_exists($contactgroup, $this->fieldMethods[$key])) {
                 $job->addError("Method " . $this->fieldMethods[$key] . " does not exist for variable: " . $key . " on line " . $lineNum . " in file " . $fileName);
                 if (!$config->getVar('continue_error')) {
                     return false;
                 }
             } else {
                 call_user_method($this->fieldMethods[$key], $contactgroup, $value);
             }
         }
     }
     $contactgroup->save();
     $contactgroup->clearAllReferences(true);
     $job->addNotice("NagiosContactGroupImporter finished importing contact group: " . $contactgroup->getName());
     return true;
 }
 public function index()
 {
     if (isset($_GET['acao'])) {
         return @call_user_method($_GET['acao'], $this);
     }
     return $this->listar();
 }
Example #11
0
 /**
  *
  */
 public function process()
 {
     global $a;
     if ($this->action == false) {
         return;
     }
     return call_user_method($this->action, $this);
 }
 function admin_notices()
 {
     $this->check_uploaddir();
     if (!empty($_GET[$this->pre . 'message'])) {
         $msg_type = !empty($_GET[$this->pre . 'updated']) ? 'msg' : 'err';
         call_user_method('render_' . $msg_type, $this, $_GET[$this->pre . 'message']);
     }
 }
Example #13
0
 /**
  * This function will call all methods
  * which begins with the auto call flag
  */
 public final function autoCall()
 {
     foreach ((new \ReflectionClass($this))->getMethods() as $method) {
         if (preg_match('/^' . self::AUTO_CALL_FLAG . '(.*)$/', $method->name) && !array_key_exists($method->name, self::$called)) {
             call_user_method($method->name, $this);
             self::$called[$method->name] = true;
         }
     }
 }
 /**
  * Default initialization method
  * To be overriden by child classes
  */
 function init()
 {
     $func = 'register_hooks';
     if (isset($this)) {
         if (method_exists($this, $func)) {
             call_user_method($func, $this);
         }
     }
 }
 function query($method, $params)
 {
     $this->result();
     $method = str_replace(".", "_", $method);
     if (!method_exists($this, $method)) {
         return $this->result(array('message' => '方法未定义'));
     }
     return call_user_method($method, $this, $params);
 }
Example #16
0
 public function import()
 {
     $job = $this->getEngine()->getJob();
     $config = $this->getEngine()->getConfig();
     $cgiCfg = new NagiosCgiConfiguration();
     $segment = $this->getSegment();
     $values = $segment->getValues();
     $fileName = $segment->getFilename();
     foreach ($values as $key => $entries) {
         if (preg_match("/^authorized_for/i", $key)) {
             // We need to pass the entire value over.
             // Collect the entries
             $value = array();
             foreach ($entries as $entry) {
                 $value[] = $entry['value'];
             }
             $value = implode(",", $value);
             if (!method_exists($cgiCfg, $this->fieldMethods[$key])) {
                 $job->addError("Method " . $this->fieldMethods[$key] . " does not exist for variable: " . $key . " on line " . $entries[0]['line'] . " in file " . $fileName);
                 if (!$config->getVar('continue_error')) {
                     return false;
                 }
             } else {
                 call_user_method($this->fieldMethods[$key], $cgiCfg, $value);
             }
             continue;
         }
         foreach ($entries as $entry) {
             $value = $entry['value'];
             $lineNum = $entry['line'];
             if (key_exists($key, $this->fieldMethods) && $this->fieldMethods[$key] != '') {
                 // Okay, let's check that the method DOES exist
                 if (!method_exists($cgiCfg, $this->fieldMethods[$key])) {
                     $job->addError("Method " . $this->fieldMethods[$key] . " does not exist for variable: " . $key . " on line " . $lineNum . " in file " . $fileName);
                     if (!$config->getVar('continue_error')) {
                         return false;
                     }
                 } else {
                     call_user_method($this->fieldMethods[$key], $cgiCfg, $value);
                 }
             }
         }
     }
     // If we got here, it's safe to delete the existing main config and save the new one
     $oldConfig = NagiosCgiConfigurationPeer::doSelectOne(new Criteria());
     if ($oldConfig) {
         $oldConfig->clearAllReferences(true);
         $oldConfig->delete();
     }
     $cgiCfg->save();
     $cgiCfg->clearAllReferences(true);
     $job->addNotice("NagiosCgiImporter finished importing cgi configuration.");
     return true;
 }
Example #17
0
 public function send()
 {
     $types = array('reg', 'birth', 'activity', 'wishlist');
     foreach ($types as $type) {
         if (Mage::getStoreConfig('ambirth/' . $type . '/enabled')) {
             $this->debug("Called " . '_send' . ucfirst($type) . 'Coupon');
             call_user_method('_send' . ucfirst($type) . 'Coupon', $this);
         }
     }
     $this->_removeOldCoupons();
     return $this;
 }
Example #18
0
 /**
  * start app
  * @throws \Exception
  */
 public function start()
 {
     // load class
     if (!$this->load($this->app_path . $this->controllers_dir . DIRECTORY_SEPARATOR . ($controller_name = $this->request->get_controller()))) {
         throw new \Exception('File not found!', 404);
     }
     $c = new $controller_name();
     if (!method_exists($c, $this->request->get_action())) {
         throw new \Exception('Page not found!', 404);
     }
     call_user_method($this->request->get_action(), $c);
 }
/**
 * Like get_template_part() put lets you pass args to the template file
 * Args are available in the template as $template_args array
 *
 * @link https://github.com/humanmade/hm-core/blob/1204806c83497d04379d287753cbe3b6c7c66a9b/hm-core.functions.php#L1255
 *
 * @throws \Exception When an undefined template is included.
 *
 * @param string $file          The file to include.
 * @param array  $template_args style argument list.
 * @param array  $cache_args    The arguments to cache.
 *
 * @return false|string
 */
function get_template_part($file, $template_args = array(), $cache_args = array())
{
    $template_args = wp_parse_args($template_args);
    $cache_args = wp_parse_args($cache_args);
    if ($cache_args) {
        foreach ($template_args as $key => $value) {
            if (is_scalar($value) || is_array($value)) {
                $cache_args[$key] = $value;
            } else {
                if (is_object($value) && method_exists($value, 'get_id')) {
                    $cache_args[$key] = call_user_method('get_id', $value);
                }
            }
        }
        if (($cache = wp_cache_get($file, serialize($cache_args))) !== false) {
            if (!empty($template_args['return'])) {
                return $cache;
            }
            echo $cache;
            return false;
        }
    }
    $file_handle = $file;
    do_action('start_operation', 'hm_template_part::' . $file_handle);
    if (file_exists(get_stylesheet_directory() . '/' . $file . '.php')) {
        $file = get_stylesheet_directory() . '/' . $file . '.php';
    } elseif (file_exists(get_template_directory() . '/' . $file . '.php')) {
        $file = get_template_directory() . '/' . $file . '.php';
    } else {
        $backtrace = debug_backtrace();
        $backtrace = $backtrace[0];
        throw new \Exception(sprintf('Undefined template "%s" called from %s:%s', $file, $backtrace['file'], $backtrace['line']));
    }
    ob_start();
    if (WP_DEBUG) {
        printf('<!-- Including template "%s" -->', $file);
    }
    $return = (require $file);
    $data = ob_get_clean();
    do_action('end_operation', 'hm_template_part::' . $file_handle);
    if ($cache_args) {
        wp_cache_set($file, $data, serialize($cache_args), 3600);
    }
    if (!empty($template_args['return'])) {
        if ($return === false) {
            return false;
        } else {
            return $data;
        }
    }
    echo $data;
    return false;
}
Example #20
0
 function init()
 {
     parent::init();
     $this->add('View')->setHTML('<h1>xEpan CMS :: Installer</h1>')->addClass('text-center 	xepan-installer-heading xepan-installer-step1');
     $this->api->template->trySet('page_title', 'Epan :: Installer');
     if (file_exists('config-default.php') and $this->api->getConfig('installed')) {
         $this->step4();
         return;
     }
     $this->api->stickyGET('step');
     $step = isset($_GET['step']) ? $_GET['step'] : 1;
     call_user_method("step{$step}", $this);
 }
Example #21
0
function setup_call_function($function, $parameter, $object = '')
{
    if (!$function) {
        return;
    }
    if ($object == '') {
        return call_user_func($function, $parameter);
    } elseif (PHP_VERSION < 4) {
        return call_user_method($function, $object, $parameter);
    } else {
        return call_user_func(array($object, $function), $parameter);
    }
}
 function _handleDataType($typeName, &$value)
 {
     if ($this->_hasCallbacks) {
         $callback = $this->_callbacks[strtolower($typeName)];
         if ($callback) {
             if (is_object($callback['object'])) {
                 return call_user_method($callback['method'], $callback['object'], $typeName, $value);
             } else {
                 return call_user_func($callback['method'], $typeName, $value);
             }
         }
     }
     return false;
 }
Example #23
0
 function __construct()
 {
     #$this->rel_siteurl = preg_replace('#^(.*)/textpattern[/setuphindx.]*?$#i','\\1',$_SERVER['PHP_SELF']);
     $this->rel_siteurl = preg_replace('#^(.*)/textpattern[/setuphindxlra.]*?$#i', '\\1', $_SERVER['PHP_SELF']);
     $this->_step = ps('step');
     if (empty($this->_step)) {
         $this->_step = $this->_default_step;
     }
     $this->langs =& $GLOBALS['langs'];
     # delegate control into step method
     if (method_exists($this, $this->_step) && is_callable(array(&$this, $this->_step))) {
         call_user_method($this->_step, $this);
     }
 }
Example #24
0
 function __call($method, $args)
 {
     switch ($method) {
         case 'update':
             if (isset($args[1]) || is_array($args[1])) {
                 parent::update($args[0], $args[1]);
             } else {
                 call_user_method($method, $this, $args);
             }
             break;
         default:
             call_user_func($method, $args);
             break;
     }
 }
Example #25
0
 function update_status()
 {
     if (is_array($this->modules)) {
         if (is_object($GLOBALS[$this->selected_module])) {
             if (function_exists('method_exists')) {
                 if (method_exists($GLOBALS[$this->selected_module], 'update_status')) {
                     $GLOBALS[$this->selected_module]->update_status();
                 }
             } else {
                 // PHP3 compatibility
                 @call_user_method('update_status', $GLOBALS[$this->selected_module]);
             }
         }
     }
 }
Example #26
0
 private function getComponent($name)
 {
     if (!isset($this->_hinstance[$name])) {
         require_once dirname(__FILE__) . $this->_core[$this->_coreObj[$name]];
         $class = $this->_coreObj[$name];
         $obj = null;
         if (method_exists($class, 'getInstance')) {
             //fix for php-5.2
             $obj = call_user_method('getInstance', $class);
         } else {
             $obj = new $class();
         }
         $this->_hinstance[$name] = $obj;
     }
     return $this->_hinstance[$name];
 }
 /**
  * Treating constants inside a SQL query using the getConstantXyz() functions
  * @return true
  */
 private function treatConstants()
 {
     $parameters = $this->queryparameters;
     for ($i = 0; $i < count(parameters); $i++) {
         if (method_exists($this, "getConstant" . $parameters[$i]["name"])) {
             // Affecting the value returned by the corresponding method
             // For example, the ^TABLENUM(ca_objects) queryparameter in the SQL will have the value given by getConstantTABLENUM("ca_objects")
             $constantValue = call_user_method("getConstant" . $parameters[$i]["name"], $this, $parameters[$i]["arguments"]);
             // Replacement by the constant value in the SQL query
             $this->sql = str_ireplace($parameters[$i]["string"], $constantValue . " ", $this->sql);
             // As the constant queryparamter is no more required, destroying it
             unset($this->queryparameters[$i]);
         }
     }
     return true;
 }
 public function upgradeComponent()
 {
     // just make sure we're not being asked to do something
     // that is impossible
     if ($this->componentVersion >= self::LATEST_VERSION) {
         throw new \Exception('Folder ' . $this->folder . ' is on version ' . $this->componentVersion . ' which is newer than known latest version ' . self::LATEST_VERSION);
     }
     // ok, let's do the upgrades
     $thisVersion = $this->componentVersion;
     while ($thisVersion < self::LATEST_VERSION) {
         $method = 'upgradeFrom' . $thisVersion . 'To' . ($thisVersion + 1);
         \call_user_method($method, $this);
         $thisVersion++;
         $this->editBuildPropertiesVersionNumber($thisVersion);
     }
     // all done
 }
Example #29
0
 /**
  * display
  */
 public function display()
 {
     if (!is_admin()) {
         return false;
     }
     if (!current_user_can('manage_options')) {
         wp_die('You do not have sufficient permissions to access this page.');
     }
     $view = isset($_REQUEST['view']) ? $_REQUEST['view'] : 'default';
     $view = str_replace(' ', '', ucwords(str_replace('-', ' ', $view)));
     $methodName = '_' . $view . 'View';
     if (method_exists($this, $methodName)) {
         return call_user_method($methodName, $this);
     } else {
         return $this->_defaultView();
     }
 }
Example #30
0
/**
 * See: https://github.com/humanmade/hm-core/blob/1204806c83497d04379d287753cbe3b6c7c66a9b/hm-core.functions.php#L1236
 * Like get_template_part() put lets you pass args to the template file
 * Args are available in the tempalte as $template_args array
 * @since 1.0
 */
function wf_get_template_part($file, $template_args = array(), $cache_args = array())
{
    $template_args = wp_parse_args($template_args);
    $cache_args = wp_parse_args($cache_args);
    if ($cache_args) {
        foreach ($template_args as $key => $value) {
            if (is_scalar($value) || is_array($value)) {
                $cache_args[$key] = $value;
            } else {
                if (is_object($value) && method_exists($value, 'get_id')) {
                    $cache_args[$key] = call_user_method('get_id', $value);
                }
            }
        }
        if (($cache = wp_cache_get($file, serialize($cache_args))) !== false) {
            if (!empty($template_args['return'])) {
                return $cache;
            }
            echo $cache;
            return;
        }
    }
    $file_handle = $file;
    do_action('start_operation', 'wf_template_part::' . $file_handle);
    if (file_exists(get_stylesheet_directory() . '/' . $file . '.php')) {
        $file = get_stylesheet_directory() . '/' . $file . '.php';
    } elseif (file_exists(get_template_directory() . '/' . $file . '.php')) {
        $file = get_template_directory() . '/' . $file . '.php';
    }
    ob_start();
    $return = (require $file);
    $data = ob_get_clean();
    do_action('end_operation', 'wf_template_part::' . $file_handle);
    if ($cache_args) {
        wp_cache_set($file, $data, serialize($cache_args), 3600);
    }
    if (!empty($template_args['return'])) {
        if ($return === false) {
            return false;
        }
    } else {
        return $data;
    }
    echo $data;
}