Example #1
0
 /**
  * Main action. Will use the action mapper to get a controller that can
  * handle the given Action, and then the viewresolver to get a View that
  * can render the returned ModelAndView from the controller.
  *
  * @param Action  $action Action to dispatch.
  *
  * @throws MvcException
  * @return void
  */
 public function dispatch(DispatchInfo $dispatchInfo)
 {
     $controller = $dispatchInfo->handler;
     $actionHandler = $dispatchInfo->method;
     $action = $dispatchInfo->action;
     if (!method_exists($controller, $actionHandler)) {
         throw new MvcException('No valid action handler found: ' . $actionHandler);
     }
     $interceptors = $dispatchInfo->interceptors;
     $filtersPassed = true;
     $result = false;
     foreach ($interceptors as $interceptor) {
         $this->_logger->debug("Running pre filter: " . get_class($interceptor));
         $result = $interceptor->preHandle($action, $controller);
         if ($result === false) {
             $filtersPassed = false;
             $this->_logger->debug("Filter returned false, stopping dispatch");
             break;
         } else {
             if ($result instanceof ModelAndView) {
                 return $result;
             }
         }
     }
     if ($filtersPassed) {
         $result = $this->invokeAction($controller, $actionHandler, $action->getArguments());
         foreach ($interceptors as $interceptor) {
             $this->_logger->debug("Running post filter: " . get_class($interceptor));
             $interceptor->postHandle($action, $controller);
         }
     }
     return $result;
 }
Example #2
0
 /**
  * Request the page from IMDb
  * @param $url
  * @return string Page html. Empty string on failure
  * @throws Exception\Http
  */
 protected function requestPage($url)
 {
     $this->logger->info("[Page] Requesting [{$url}]");
     $req = $this->buildRequest($url);
     if (!$req->sendRequest()) {
         $this->logger->error("[Page] Failed to connect to server when requesting url [{$url}]");
         if ($this->config->throwHttpExceptions) {
             throw new Exception\Http("Failed to connect to server when requesting url [{$url}]");
         } else {
             return '';
         }
     }
     if (200 == $req->getStatus()) {
         return $req->getResponseBody();
     } elseif ($redirectUrl = $req->getRedirect()) {
         $this->logger->debug("[Page] Following redirect from [{$url}] to [{$redirectUrl}]");
         return $this->requestPage($redirectUrl);
     } else {
         $this->logger->error("[Page] Failed to retrieve url [{url}]. Response headers:{headers}", array('url' => $url, 'headers' => $req->getLastResponseHeaders()));
         if ($this->config->throwHttpExceptions) {
             throw new Exception\Http("Failed to retrieve url [{$url}]. Status code [{$req->getStatus()}]");
         } else {
             return '';
         }
     }
 }
Example #3
0
 /**
  * @param string|\Exception $msg
  * @param array $context
  * @throws \RuntimeException
  */
 public static function debug($msg, array $context = array())
 {
     if (empty(static::$instance)) {
         throw new \RuntimeException('Logger instance not added to proxy yet');
     }
     static::$instance->debug($msg, $context);
 }
Example #4
0
 public function stream(Git_HTTP_Command $command)
 {
     $cwd = '/tmp';
     $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"));
     if (ForgeConfig::get('sys_logger_level') == Logger::DEBUG) {
         $descriptorspec[2] = array('file', ForgeConfig::get('codendi_log') . '/git_http_error_log', 'a');
     }
     $pipes = array();
     $this->logger->debug('Command: ' . $command->getCommand());
     $this->logger->debug('Environment: ' . print_r($command->getEnvironment(), true));
     $process = proc_open($command->getCommand(), $descriptorspec, $pipes, $cwd, $command->getEnvironment());
     if (is_resource($process)) {
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             fwrite($pipes[0], file_get_contents('php://input'));
         }
         fclose($pipes[0]);
         $first = true;
         while ($result = stream_get_contents($pipes[1], self::CHUNK_LENGTH)) {
             if ($first) {
                 list($headers, $body) = http_split_header_body($result);
                 foreach (explode("\r\n", $headers) as $header) {
                     header($header);
                 }
                 file_put_contents('php://output', $body);
             } else {
                 file_put_contents('php://output', $result);
             }
             $first = false;
         }
         fclose($pipes[1]);
         $return_value = proc_close($process);
     }
 }
 public function getProcessForQueue($request_queue)
 {
     $owner = SystemEvent::OWNER_APP;
     $custom_queues = array();
     $this->event_manager->processEvent(Event::SYSTEM_EVENT_GET_CUSTOM_QUEUES, array('queues' => &$custom_queues));
     if (isset($custom_queues[$request_queue])) {
         $this->logger = $custom_queues[$request_queue]->getLogger();
         $this->logger->debug('Processing ' . $request_queue . ' queue.');
         $process = new SystemEventProcessCustomQueue($request_queue);
         $owner = $custom_queues[$request_queue]->getOwner();
     } else {
         switch ($request_queue) {
             case SystemEvent::OWNER_APP:
                 $this->logger->debug('Processing default queue as app user.');
                 $process = new SystemEventProcessApplicationOwnerDefaultQueue();
                 break;
             case SystemEvent::DEFAULT_QUEUE:
                 $this->logger->debug('Processing default queue as root user.');
                 $owner = SystemEvent::OWNER_ROOT;
                 $process = new SystemEventProcessRootDefaultQueue();
                 break;
             default:
                 $this->logger->debug('Ignoring ' . $request_queue . ' queue.');
                 exit(0);
         }
     }
     if ($owner === SystemEvent::OWNER_APP) {
         return new SystemEventProcessor_ApplicationOwner($process, $this->system_event_manager, new SystemEventDao(), $this->logger);
     }
     return new SystemEventProcessor_Root($process, $this->system_event_manager, new SystemEventDao(), $this->logger, Backend::instance('Aliases'), Backend::instance('CVS'), Backend::instance('SVN'), Backend::instance('System'), new SiteCache($this->logger));
 }
 /**
  * Framework entry point
  *
  * @return void.
  */
 public function dispatch()
 {
     include_once 'action/controller/http/HTTPResponse.php';
     include_once 'action/controller/http/HTTPRequest.php';
     $request = new HTTPRequest();
     $response = new HTTPResponse();
     try {
         $configurator = $this->manager->getConfigurator();
         Registry::put($configurator, '__configurator');
         Registry::put($logger = new Logger($configurator), '__logger');
         $ap = $configurator->getApplicationPath();
         // application path
         $an = $configurator->getApplicationName();
         // application name
         $logger->debug('[Medick] >> version: ' . Medick::getVersion() . ' ready for ' . $an);
         $logger->debug('[Medick] >> Application path ' . $ap);
         $routes_path = $ap . DIRECTORY_SEPARATOR . 'conf' . DIRECTORY_SEPARATOR . $an . '.routes.php';
         include_once $routes_path;
         // load routes
         $logger->debug('[Medick] >> Config File: ' . str_replace($ap, '${' . $an . '}', $configurator->getConfigFile()));
         $logger->debug('[Medick] >> Routes loaded from: ' . str_replace($ap, '${' . $an . '}', $routes_path));
         ActionControllerRouting::recognize($request)->process($request, $response)->dump();
     } catch (Exception $ex) {
         ActionController::process_with_exception($request, $response, $ex)->dump();
         $logger->warn($ex->getMessage());
     }
 }
Example #7
0
 /**
  * Mark the last started query as stopped. This can be used for timing of queries.
  *
  * @return void
  */
 public function stopQuery()
 {
     $result = microtime() - $this->startTime;
     if ($this->logger->isDebugEnabled()) {
         $this->logger->debug("query done for {$result}");
     }
 }
Example #8
0
  /**
   * Delete a contact
   *
   * @param Integer $c_id contact_id
   * @return Boolean
   */
  function DeleteContact($c_id)  {
    global $cdg_sql, $c_use_connectors;
    
    $sql_id = sql_parse_id($c_id, true);
    $this->logger->debug("Delete contact $c_id");
    
    $obm_q = new DB_OBM;
    
    $query = "SELECT contact_company_id, contact_birthday_id, contact_usercreate, contact_addressbook_id FROM Contact
      WHERE contact_id $sql_id";
    $this->logger->core($query);
    $obm_q->query($query);
    $obm_q->next_record();
    $comp_id = $obm_q->f('contact_company_id');
    $birthday_id = $obm_q->f('contact_birthday_id');
    $uid = $obm_q->f('contact_usercreate');
    $ad = $obm_q->f('contact_addressbook_id');
    
    // Hook : Pre
    if (function_exists('hook_pre_run_query_contact_delete')) {
      if (! hook_pre_run_query_contact_delete($c_id)) {
        return false;
      }
    }
    
    run_query_global_delete_document_links($c_id, 'contact');    
    $ret = of_userdata_query_delete('contact', $c_id);
    
    
    // BEGIN birthday support
    
    $query = "DELETE FROM Event WHERE event_id = '$birthday_id'";
    $this->logger->core($query);
    $obm_q->query($query);
    
    // END birthday support
    
    
    of_entity_delete('contact', $c_id); 
    $query = "DELETE FROM Contact WHERE contact_id $sql_id";
    $this->logger->core($query);
    $obm_q->query($query);
    
    // If connectors in use
    
    if ($c_use_connectors) {
      $query = "INSERT INTO
        DeletedContact (deletedcontact_contact_id, deletedcontact_addressbook_id, deletedcontact_timestamp, deletedcontact_origin)
        VALUES ($c_id, $ad, NOW(), '$GLOBALS[c_origin_cron]')";
      $this->logger->core($query);
      $obm_q->query($query);
    }
    
    // After contact deletion to get correct number
    run_query_global_company_contact_number_update($comp_id);

    // Delete index
    OBM_IndexingService::delete('contact', $c_id);  
  }
Example #9
0
 function execute($date)
 {
     $this->logger->debug('Updating groups built from delegations');
     $domains = $this->getDomains();
     foreach ($domains as $domain_id) {
         $this->processDomain($domain_id);
     }
 }
 public function myAction($app_id, $vid, $sig)
 {
     $this->logger->debug("index/my with arguments {$app_id}, {$vid}, {$sig}");
     $this->socialManager->authenticate($_GET, SocialNetwork::$MY);
     $this->logger->debug("authenticate {$vid}");
     $this->securityManager->authenticate($vid, SocialNetwork::$MY);
     return new ModelAndView("Index/index", array('user' => $this->securityManager->getUser()));
 }
Example #11
0
 /**
  * This will resolve the given ModelAndView to a view in the filesystem
  * (an absolute path to a file).
  *
  * @param ModelAndView $modelAndView What to render.
  *
  * @see Ding\Mvc.IViewResolver::resolve()
  * @return HttpView
  */
 public function resolve(ModelAndView $modelAndView)
 {
     $name = $modelAndView->getName();
     $path = $this->_path . DIRECTORY_SEPARATOR . $this->_prefix . $name . $this->_suffix;
     if ($this->_logger->isDebugEnabled()) {
         $this->_logger->debug('Using viewpath: ' . $path);
     }
     return new HttpView($modelAndView, $path);
 }
 protected function _sendWebhook($url, $body)
 {
     $this->_logger->debug("Sending webhook for event " . $this->_getWebhookEvent() . " to " . $url);
     $bodyJson = $this->_jsonHelper->jsonEncode($body);
     $headers = ["Content-Type: application/json"];
     $this->_curlAdapter->write('POST', $url, '1.1', $headers, $bodyJson);
     $this->_curlAdapter->read();
     $this->_curlAdapter->close();
 }
Example #13
0
 /**
  * Sends message
  * @param  integer $type
  * @param  string  $msg
  * @return void
  */
 public function send($type, $msg)
 {
     $err = 0;
     if (!msg_send($this->queue, $type, $msg, true, false, $err)) {
         $this->logger->critical("Message of type {$type} not sent: {$err}", (array) $msg);
     } else {
         $this->logger->debug("Message of type {$type} sent", (array) $msg);
     }
 }
Example #14
0
 /**
  * @param string $commandFormat Command string to run. Use printf like placeholders for argument
  * WARNING Only STRINGS supported. This is due to escapeshellcommand converting everything to a string.
  * @param string $args, ... [Optional] All arguments
  * @warning Do NOT single-quote any arg placeholders in $commandFormat. This will be done by
  * the class itself and placing single-quotes in the command string will negate this work.
  */
 public function __construct($commandFormat)
 {
     $this->logger = Log4PHP::getLogger(__CLASS__);
     $safeCommandFormat = escapeshellcmd($commandFormat);
     $args = func_get_args();
     array_shift($args);
     // bump off the format string from the front
     $this->safeCommandStr = self::makeSafeString($safeCommandFormat, $args);
     $this->logger->debug('Set safe command string ' . $this->safeCommandStr);
 }
 private function _createCustomers()
 {
     $records = $this->_readDataCustomers($this->_fileNameCustomers);
     $count = sizeof($records);
     if ($count) {
         $this->_log->debug("Total {$count} lines are read from file {$this->_fileNameCustomers}");
         foreach ($records as $one) {
             $this->_createCustomerEntry($one);
         }
     }
 }
 public function dumpPartialProjectRepoConf(Project $project, array $repositories)
 {
     $this->logger->debug("Dumping partial project repo conf for: " . $project->getUnixName());
     $project_config = '';
     foreach ($repositories as $repository) {
         $this->logger->debug("Fetching Repo Configuration: " . $repository->getName() . "...");
         $project_config .= $this->fetchReposConfig($project, $repository);
         $this->logger->debug("Fetching Repo Configuration: " . $repository->getName() . ": done");
     }
     return $project_config;
 }
 public function process()
 {
     foreach ($this->getProjectIdsFromParameters() as $project_id) {
         $project = $this->project_manager->getProject($project_id);
         if ($project && !$project->isError()) {
             $this->logger->debug('Update configuration for project ' . $project->getID());
             $this->gitolite_driver->dumpProjectRepoConf($project);
         }
     }
     $this->system_event_manager->queueGrokMirrorGitoliteAdminUpdate();
     $this->done();
 }
Example #18
0
 public function process($raw_mail)
 {
     $incoming_message = $this->parser->parse($raw_mail);
     $user = $incoming_message->getRecipient()->getUser();
     $artifact = $incoming_message->getRecipient()->getArtifact();
     $this->logger->debug("Receiving new follow-up comment from " . $user->getUserName());
     if (!$artifact->userCanUpdate($user)) {
         $this->logger->info("User " . $user->getUnixName() . " has no right to update the artifact #" . $artifact->getId());
         return;
     }
     $body = $this->citation_stripper->stripText($incoming_message->getBody());
     $artifact->createNewChangeset(array(), $body, $user, true, Tracker_Artifact_Changeset_Comment::TEXT_COMMENT);
 }
 /**
  * Populate the MediaWiki with the given pages.
  * Returns true in case of success, false otherwise.
  * @var Project
  * @var SimpleXMLElement
  * @var String
  * @return boolean
  */
 public function import(Project $project, PFUser $creator, SimpleXMLElement $xml_input, $extraction_path)
 {
     $xml_mediawiki = $xml_input->mediawiki;
     if (!$xml_mediawiki) {
         $this->logger->debug('No mediawiki node found into xml.');
         return true;
     }
     if ($xml_mediawiki['language']) {
         $this->importLanguage($project, (string) $xml_mediawiki['language']);
     }
     $pages_backup_path = $extraction_path . '/' . $xml_mediawiki['pages-backup'];
     return $this->importPages($project, $pages_backup_path);
 }
Example #20
0
 /**
  * Parse <a href="http://onesocialweb.org/spec/1.0/osw-vcard4.html">VCard4 over XMPP</a>.
  * @param String $xml
  */
 public function parseVCard($xml)
 {
     // TODO ACL
     $this->logger->debug("parseVCard: '{$xml}'");
     $doc = \phpQuery::newDocument($xml);
     \phpQuery::selectDocument($doc);
     $this->fn = pq('vcard fn text')->text();
     $this->note = pq('vcard note text')->text();
     $this->photo = pq('vcard photo uri')->text();
     $this->logger->debug("fn: '{$this->fn}'");
     $this->logger->debug("note: '{$this->note}'");
     $this->logger->debug("photo: '{$this->photo}'");
 }
 /**
  * generate model files
  */
 public function run()
 {
     foreach ($this->soapClient->__getTypes() as $t) {
         $typeContent = $this->getTypeContent($t);
         if (is_array($typeContent) && isset($typeContent['content'])) {
             $file = SOAP_OUTPUT_BASE_DIR . '/' . SOAP_MODEL_DIR . '/' . $typeContent['class'] . '.class.php';
             if (file_put_contents($file, $typeContent['content']) === false) {
                 $this->logger->err('can not write file ' . $file . ' check if permissions are correct.');
             } else {
                 $this->logger->debug('write new model file: ' . $file);
             }
         }
     }
 }
 private function deleteRepo(GitRepository $repository)
 {
     $path = $repository->getPath();
     try {
         $this->logger->debug("Deleting repository " . $path);
         $this->system_event_manager->queueGrokMirrorManifestRepoDelete($path);
         $repository->delete();
     } catch (Exception $e) {
         $this->error($e->getMessage());
         return false;
     }
     $this->done();
     return true;
 }
Example #23
0
 public function dumpProjectRepoConf(Project $project)
 {
     $git_modifications = new Git_Gitolite_GitModifications();
     $hostname = $this->gitoliterc_reader->getHostname();
     if ($hostname) {
         $this->dumpProjectRepoConfForMirrors($project, $git_modifications);
     }
     $this->logger->debug("Get Project Permission Conf File: " . $project->getUnixName() . "...");
     $config_file = $this->getProjectPermissionConfFile($project);
     $this->logger->debug("Get Project Permission Conf File: " . $project->getUnixName() . ": done");
     $this->logger->debug("Write Git config: " . $project->getUnixName() . "...");
     $this->writeGitConfig($config_file, $this->project_serializer->dumpProjectRepoConf($project), $git_modifications);
     $this->logger->debug("Write Git config: " . $project->getUnixName() . ": done");
     return $git_modifications;
 }
 /**
  * Each day, load sessions info from elapsed day.
  * We need to do that because sessions are deleted from DB when user logout
  * or when session expire.
  *
  * This not perfect because with very short session (few hours for instance)
  * do data will survive in this session table.
  */
 private function archiveSessions()
 {
     $this->logger->debug(__METHOD__);
     $max = 0;
     $sql = 'SELECT MAX(time) as max FROM plugin_statistics_user_session';
     $res = db_query($sql);
     if ($res && db_numrows($res) == 1) {
         $row = db_fetch_array($res);
         if ($row['max'] != null) {
             $max = $row['max'];
         }
     }
     $sql = 'INSERT INTO plugin_statistics_user_session (user_id, time)' . ' SELECT user_id, time FROM session WHERE time > ' . $max;
     db_query($sql);
 }
Example #25
0
 /**
  * Closes the connection to ami.
  *
  * @return void
  */
 public function close()
 {
     if ($this->_logger->isDebugEnabled()) {
         $this->_logger->debug('Closing connection to asterisk.');
     }
     @stream_socket_shutdown($this->_socket, STREAM_SHUT_RDWR);
 }
Example #26
0
 /**
  * @param AbstractPlugin $plugin
  * @param null $stackIndex
  * @return $this
  * @throws \Exception
  */
 public function registerPlugin(AbstractPlugin $plugin, $stackIndex = null)
 {
     if (false !== array_search($plugin, $this->_plugins, true)) {
         throw new \Exception('Plugin already registered');
     }
     //installed?
     if (!$plugin::isInstalled()) {
         if (is_object($plugin)) {
             $className = get_class($plugin);
             \Logger::debug("Not registering plugin [ " . $className . " ] because it is not installed");
         } else {
             \Logger::debug("Not registering plugin, it is not an object");
         }
         return $this;
     }
     $stackIndex = (int) $stackIndex;
     if ($stackIndex) {
         if (isset($this->_plugins[$stackIndex])) {
             throw new \Exception('Plugin with stackIndex "' . $stackIndex . '" already registered');
         }
         $this->_plugins[$stackIndex] = $plugin;
     } else {
         $stackIndex = count($this->_plugins);
         while (isset($this->_plugins[$stackIndex])) {
             ++$stackIndex;
         }
         $this->_plugins[$stackIndex] = $plugin;
     }
     ksort($this->_plugins);
     $plugin->init();
     return $this;
 }
Example #27
0
 public function isOK($user_)
 {
     $minimun_attribute = array('login', 'displayname');
     if (is_object($user_)) {
         foreach ($minimun_attribute as $attribute) {
             if ($user_->hasAttribute($attribute) == false) {
                 Logger::debug('main', 'UserDB::isOK attribute \'' . $attribute . '\' missing');
                 return false;
             } else {
                 $a = $user_->getAttribute($attribute);
                 if (is_null($a)) {
                     Logger::debug('main', 'UserDB::isOK attribute \'' . $attribute . '\' null');
                     return false;
                 }
                 if ($a == "") {
                     Logger::debug('main', 'UserDB::isOK attribute \'' . $attribute . '\' empty');
                     return false;
                 }
             }
         }
         return true;
     } else {
         Logger::debug('main', 'UserDB::isOK user not an object (' . gettype($user_) . ')');
         return false;
     }
 }
 private function initializeMapping(Tracker $tracker)
 {
     if (!$this->mappingExists($tracker)) {
         $this->logger->debug('[Tracker] Elasticsearch set mapping for tracker #' . $tracker->getId());
         $this->client->setMapping((string) $tracker->getId(), $this->tracker_data_factory->getTrackerMapping($tracker));
     }
 }
Example #29
0
 /**
  *
  * 执行登录检查,如果错误,将返回状态代码403
  *
  * @access public
  * @param 无
  * @return void
  */
 public function execute($request)
 {
     Logger::debug('----- ' . __CLASS__ . ' is started -----');
     // 验证 SessionKey
     $user_id = $request->getRequestParameter(Constants::PARAM_SESSION_KEY);
     $clientSendKey = $request->getRequestParameter(Constants::PARAM_USER_ID);
     $userCache = UserCache::getCacheInstance();
     $serverSaveKey = $userCache->getByKey($user_id, Constants::CURRENT_SESSION_KEY);
     if ($serverSaveKey !== $clientSendKey) {
         Logger::debug('Stopping ' . __CLASS__ . '. caused by: Invalid session key.');
         Logger::debug('server save session key: ', $serverSaveKey);
         Logger::debug('client send session key: ', $clientSendKey);
         $view = new JsonView();
         $view->setValue('result', Constants::RESP_RESULT_ERROR);
         $view->setValue('message', "session key not match");
         $view->display();
         throw new ForbiddenException("Session Key not match.");
     }
     // 登录检查
     /*if( !$authorizer->loginCheck($auth_param) )
       {
           Logger::debug( 'Stopping ' . __CLASS__ . '. caused by: The request not authenticated.' );
           throw new ForbiddenException();
       }*/
     Logger::debug(__CLASS__ . ' is success.');
     Logger::debug('----- ' . __CLASS__ . ' is finished -----');
 }
 public function load() {
     Logger::debug('Loading Template-Engine');
     $loader = $this->get_loader();     
     $config = $this->get_config();
     $this->twig = new \Twig_Environment($loader, $config);
     $this->twig = \ViewPreloader::pre_load($this->twig);
 }