/** * constructor. * @param array $config optional key/value pairs in an associative array. Used to override default configuration values. */ public function __construct(array $config = null) { $filterManager = FilterManager::getInstance(); $filterManager->addFilter(ServiceRouter::FILTER_SERVICE_OBJECT, $this, "filterServiceObject"); $filterManager->addFilter(AmfHandler::FILTER_AMF_REQUEST_HEADER_HANDLER, $this, "filterAmfRequestHeaderHandler"); $this->headerUserId = null; $this->headerPassword = null; }
/** * Invokes the appropriate controller action. * * @since 1.0.0 */ public function load() { $controller = $this->getController($this->registry->request->getController()); // check if the action is callable $action = $this->registry->request->getAction(); if (is_callable(array($controller, $action)) === false) { $action = 'index'; } else { $action = $action; } // Add filters $controller = FilterManager::addFilters($controller, $this->registry); // run the action try { $controller->{$action}(); } catch (NotAuthenticatedException $e) { $this->registry->lastException = $e; $controller = $this->getController(AppConstants::CONTROLLER_UNAUTHENTICATED); $controller->index(); } catch (NotAuthorizedException $e) { $this->registry->lastException = $e; $controller = $this->getController(AppConstants::CONTROLLER_UNAUTHORIZED); $controller->index($e); } catch (Exception $e) { $this->registry->lastException = $e; $controller = $this->getController(AppConstants::CONTROLLER_ERROR); $controller->index($e); } }
/** * constructor. * @param array $config optional key/value pairs in an associative array. Used to override default configuration values. */ public function __construct(array $config = null) { $filterManager = FilterManager::getInstance(); $filterManager->addFilter(Gateway::FILTER_SERIALIZED_REQUEST, $this, "filterSerializedRequest"); $filterManager->addFilter(Gateway::FILTER_DESERIALIZED_REQUEST, $this, "filterDeserializedRequest"); $filterManager->addFilter(Gateway::FILTER_DESERIALIZED_RESPONSE, $this, "filterDeserializedResponse"); $filterManager->addFilter(Gateway::FILTER_SERIALIZED_RESPONSE, $this, "filterSerializedResponse"); }
/** * constructor. Add filters on the HookManager. * @param array $config optional key/value pairs in an associative array. Used to override default configuration values. */ public function __construct(array $config = null) { $filterManager = FilterManager::getInstance(); $filterManager->addFilter(Gateway::FILTER_DESERIALIZER, $this, "filterHandler"); $filterManager->addFilter(Gateway::FILTER_DESERIALIZED_REQUEST_HANDLER, $this, "filterHandler"); $filterManager->addFilter(Gateway::FILTER_EXCEPTION_HANDLER, $this, "filterHandler"); $filterManager->addFilter(Gateway::FILTER_SERIALIZER, $this, "filterHandler"); $filterManager->addFilter(Gateway::FILTER_HEADERS, $this, "filterHeaders"); }
/** * constructor. * @param array $config optional key/value pairs in an associative array. Used to override default configuration values. */ public function __construct(array $config = null) { //default $this->customClassFolderPaths = array(AMFPHP_ROOTPATH . "/Services/Vo/"); if($config){ if(isset($config["customClassFolderPaths"])){ $this->customClassFolderPaths = $config["customClassFolderPaths"]; } } $filterManager = FilterManager::getInstance(); $filterManager->addFilter(Gateway::FILTER_DESERIALIZED_REQUEST, $this, "filterDeserializedRequest"); $filterManager->addFilter(Gateway::FILTER_DESERIALIZED_RESPONSE, $this, "filterDeserializedResponse"); }
/** * Writes an asset collection to a cache file, optionally applies filters. * * @param AssetCollection $assets * @param string $file * @param array $filters * @return string|false */ protected function doCache(AssetCollection $assets, $file, $filters = []) { $filters = $this->filters->get($filters); if (count($assets)) { $salt = array_merge([$_SERVER['SCRIPT_NAME']], array_keys($filters)); $file = preg_replace('/(.*?)(\\.[^\\.]+)?$/i', '$1-' . $assets->hash(implode(',', $salt)) . '$2', $file, 1); if (!file_exists($file)) { file_put_contents($file, $assets->dump($filters)); } return $file; } return false; }
/** * constructor. * @param array $config optional key/value pairs in an associative array. Used to override default configuration values. */ public function __construct(array $config = null) { FilterManager::getInstance()->addFilter(AmfHandler::FILTER_AMF_REQUEST_MESSAGE_HANDLER, $this, "filterAmfRequestMessageHandler"); FilterManager::getInstance()->addFilter(AmfHandler::FILTER_AMF_EXCEPTION_HANDLER, $this, "filterAmfExceptionHandler"); $this->clientUsesFlexMessaging = false; }
/** * * * @param IssueSelection $inputIssueSel * @param array $params */ public function execute(IssueSelection $inputIssueSel, array $params = NULL) { $this->checkParams($inputIssueSel, $params); $this->inputIssueSel = $inputIssueSel; // do the work ... $filterMgr = new FilterManager($inputIssueSel, $this->filterList); $resultList = $filterMgr->execute(); $this->execData = $filterMgr->explodeResults($resultList); }
/** * Initialize complex static variables * @static */ public static function staticInit() { self::$logger = Logger::getLogger(__CLASS__); }
/** * get the response headers. Creates an associative array of headers, then filters them, then returns an array of strings * * @return array */ public function getResponseHeaders(){ $filterManager = FilterManager::getInstance(); $headers = array("Content-Type" => $this->contentType); $headers = $filterManager->callFilters(self::FILTER_HEADERS, $headers, $this->contentType); $ret = array(); foreach($headers as $key => $value){ $ret[] = $key . ": " . $value; } return $ret; }
protected function display() { if (Tools::isConnectedUser()) { $user = UserCache::getInstance()->getUser($_SESSION['userid']); $teamList = $user->getTeamList(); if (0 != count($teamList)) { // ---- select project // define the list of tasks the user can display // All projects from teams where I'm a Developper or Manager AND Observers $dTeamList = $user->getDevTeamList(); $devProjList = 0 == count($dTeamList) ? array() : $user->getProjectList($dTeamList); $managedTeamList = $user->getManagedTeamList(); $managedProjList = 0 == count($managedTeamList) ? array() : $user->getProjectList($managedTeamList); $oTeamList = $user->getObservedTeamList(); $observedProjList = 0 == count($oTeamList) ? array() : $user->getProjectList($oTeamList); $projList = $devProjList + $managedProjList + $observedProjList; if (isset($_GET['projectid'])) { $projectid = Tools::getSecureGETIntValue('projectid'); $_SESSION['projectid'] = $projectid; } else { if (isset($_SESSION['projectid'])) { $projectid = $_SESSION['projectid']; } else { $projectsid = array_keys($projList); $projectid = $projectsid[0]; } } // get selected filters if (isset($_GET['selectedFilters']) && NULL != $_GET['selectedFilters']) { $selectedFilters = Tools::getSecureGETStringValue('selectedFilters'); #echo "last = ".$selectedFilters[strlen($selectedFilters)-1]; if (',' == $selectedFilters[strlen($selectedFilters) - 1]) { $selectedFilters = substr($selectedFilters, 0, -1); // last char is a ',' } $filterList = explode(',', $selectedFilters); } else { $selectedFilters = ""; $filterList = array(); } $this->smartyHelper->assign('projects', SmartyTools::getSmartyArray($projList, $projectid)); $project = ProjectCache::getInstance()->getProject($projectid); // ---- $availFilterList = array("ProjectVersionFilter" => "Project Version", "ProjectCategoryFilter" => "Project Category", "IssueExtIdFilter" => "Issue External ID", "IssuePublicPrivateFilter" => "Issue Public / Private", "IssueTagFilter" => "Issue Tags"); $selectedFilterList = array(); foreach ($filterList as $id) { $selectedFilterList[$id] = $availFilterList[$id]; unset($availFilterList[$id]); } // do the work ... $projectIssueSel = $project->getIssueSelection(); $filterMgr = new FilterManager($projectIssueSel, $filterList); $resultList = $filterMgr->execute(); $issueSelList = $filterMgr->explodeResults($resultList); $smatyObj = $this->getDetailedMgr($issueSelList, $filterList); $totalLine = array_shift($smatyObj); // first line is rootElem (TOTAL) $titleLine = array_pop($smatyObj); // last line is the table titles $this->smartyHelper->assign('availFilterList', $availFilterList); $this->smartyHelper->assign('selectedFilterList', $selectedFilterList); $this->smartyHelper->assign('selectedFilters', $selectedFilters); $this->smartyHelper->assign('nbFilters', count($filterList)); $this->smartyHelper->assign('filterResultsTitles', $titleLine); $this->smartyHelper->assign('filterResults', $smatyObj); $this->smartyHelper->assign('filterResultsTotal', $totalLine); } } }
/** * Loads and instanciates a service class matching $serviceName, then calls the function defined by $methodName using $parameters as parameters * throws an exception if service not found. * if the service exists but not the function, an exception is thrown by call_user_func_array. It is pretty explicit, so no furher code was added * * @param string $serviceName * @param string $methodName * @param array $parameters * * @return mixed the result of the function call * */ public function executeServiceCall($serviceName, $methodName, array $parameters){ $serviceObject = $this->getServiceObject($serviceName); $serviceObject = FilterManager::getInstance()->callFilters(self::FILTER_SERVICE_OBJECT, $serviceObject, $serviceName, $methodName); if(!method_exists($serviceObject, $methodName)){ throw new RemotingException("method $methodName not found on $serviceName object "); } return call_user_func_array(array($serviceObject, $methodName), $parameters); }
/** * constructor. * @param array $config optional key/value pairs in an associative array. Used to override default configuration values. */ public function __construct(array $config = null) { //defaults $this->clientCharset = "utf-8"; $this->phpCharset = "utf-8"; $this->method = self::METHOD_NONE; if($config){ if(isset ($config["clientCharset"])){ $this->clientCharset = $config["clientCharset"]; } if(isset ($config["phpCharset"])){ $this->phpCharset = $config["phpCharset"]; } if(isset ($config["method"])){ $this->method = $config["method"]; } } //only add filters if conversion is necessary if($this->method == self::METHOD_NONE){ return; } if($this->clientCharset == $this->phpCharset){ return; } $filterManager = FilterManager::getInstance(); $filterManager->addFilter(Gateway::FILTER_DESERIALIZED_REQUEST, $this, "filterDeserializedRequest"); $filterManager->addFilter(Gateway::FILTER_DESERIALIZED_RESPONSE, $this, "filterDeserializedResponse"); }
} } $space = User::getUserSpace(); $userInfo = User::getUserInfo(); $all = LIMIT + (int) $userInfo['capacity']; $space['percent'] = $space['space'] / ($all * 1024 * 1024) * 100; $space['all'] = round($all / 1024, 2); define('SPACE', json_encode($space)); } define('UID_DIR', $uidDir); define('UP_DIR', ROOT_PATH . 'files' . DS . $uidDir); define('DATA_DIR', ROOT_PATH . DIR . DS . $uidDir); $actionFile = ACTION_PATH . $m . '.class.php'; if (!file_exists($actionFile)) { echo Response::json(FAIL, array('no file')); exit; } require_once $actionFile; if (!class_exists($m)) { echo Response::json(FAIL, array('no class')); exit; } $act = new $m(); if (!method_exists($act, $a)) { echo Response::json(FAIL, array('no method')); exit; } FilterManager::execute($m, $a); $act->{$a}(); Log::getInstance('apistat')->write(array('api' => 'm=' . $m . '&a=' . $a, 'runTime' => round(microtime(true) - $stime, 5)), 'file'); session_write_close();
/** * @see IExceptionHandler */ public function handleException(Exception $exception){ $errorPacket = new AmfPacket(); $filterManager = FilterManager::getInstance(); $fromFilters = $filterManager->callFilters(self::FILTER_AMF_EXCEPTION_HANDLER, null); if($fromFilters){ $handler = $fromFilters; return $handler->generateErrorResponse($exception); } //no special handling by plugins. generate a simple error response with information about the exception $errorResponseMessage = null; $errorResponseMessage = new AmfMessage(); $errorResponseMessage->targetUri = $this->lastRequestMessageResponseUri . AmfConstants::CLIENT_FAILURE_METHOD; //not specified $errorResponseMessage->responseUri = "null"; $errorResponseMessage->data = new stdClass(); $errorResponseMessage->data->faultCode = $exception->getCode(); $errorResponseMessage->data->faultString = $exception->getMessage(); $details = $exception->getTraceAsString(); // localizes the paths of the stack-trace. if(defined(WEB_ROOT)){ $details = str_replace(WEB_ROOT, "", $details); } $errorResponseMessage->data->faultDetail = $details; $errorPacket->messages[] = $errorResponseMessage; return $errorPacket; }
/** * * @return FilterManager */ public static function getInstance() { if (self::$instance == NULL) { self::$instance = new FilterManager(); } return self::$instance; }