/** * Return the HTML code for an unordered list showing opinions that can be voted (no AJAX) * If the user has already voted, then a message appears * * @param BaseObject $object Propel object instance to vote * @param string $message a message string to be displayed in the voting-message block * @param array $options Array of HTML options to apply on the HTML list * @return string **/ function depp_prioritiser($object, $message = '', $options = array()) { if (is_null($object)) { sfLogger::getInstance()->debug('A NULL object cannot be prioritised'); return ''; } $user_id = sfContext::getInstance()->getUser()->getId(); try { $options = _parse_attributes($options); if (!isset($options['id'])) { $options = array_merge($options, array('id' => 'prioritising-items')); } $object_id = $object->getPrioritisableReferenceKey(); $list_content = ''; $object_priority = is_null($object->getPriorityValue()) ? 1 : $object->getPriorityValue(); for ($i = $object->allowsNullPriority() ? 0 : 1; $i <= $object->getMaxPriority(); $i++) { if ($object_priority == $i) { if ($object->getPriorityLastUser() != 0) { $label = sprintf('Priorità impostata da user_id:%d il %s alle %s', $object->getPriorityLastUser(), $object->getPriorityLastUpdate('d/m/Y'), $object->getPriorityLastUpdate('h:i')); } else { $label = 'Priorità di default'; } $list_content .= content_tag('li', content_tag('span', $i, array('title' => $label)), array('class' => 'current')); } else { $label = sprintf(__('Set priority to %d'), $i); $list_content .= content_tag('li', link_to($i, sprintf('deppPrioritising/prioritise?object_id=%d&object_model=%s&priority=%d', $object->getId(), get_class($object), $i), array('title' => $label, 'post' => true))); } } return content_tag('ul', $list_content, $options) . content_tag('div', $message, array('id' => 'priority-message')); } catch (Exception $e) { sfLogger::getInstance()->err('Exception catched from deppPrioritising helper: ' . $e->getMessage()); } }
public static function highlight($raw_body) { $body = sfMarkdown::doConvert($raw_body); $matches = array(); $langs = array(); preg_match_all("/<pre><code>\\[(\\w*)\\](\\r?\\n)+(.+)(\\r?\\n)+<\\/code><\\/pre>/isU", $body, $matches, PREG_SET_ORDER); if (sizeof($matches) > 0) { $service = new SnippetServiceClient(); $cnt = 1; foreach ($matches as $match) { sfLogger::getInstance()->info("From myUtils: " . $match[3]); $languageLower = $match[1]; $languageUpper = strtoupper($match[1]); sfLogger::getInstance()->info("myUtils languages: {$languageLower} {$languageUpper}" . sizeof(self::$languages)); if (in_array($languageUpper, self::$languages)) { $highlighted = $service->highlight($languageUpper, htmlspecialchars_decode($match[3])); $highlighted['snippet'] = "<div class=\"code-wrapper\">{$highlighted['snippet']}</div>"; $body = str_replace($match[0], $highlighted['snippet'], $body, $cnt); $langs[$languageLower] = $langs[$languageLower] ? $langs[$languageLower] + 1 : 1; } else { sfLogger::getInstance()->info("myUtils : {$languageLower} is not supported."); $langs[$languageLower] = $langs[$languageLower] ? $langs[$languageLower] + 1 : 1; $body = str_replace($match[0], "<div class=\"code-wrapper\"><pre><code>{$match[3]}</code></pre></div>", $body, $cnt); } } } return array('body' => $body, 'langs' => $langs); }
/** * Return the HTML code for an unordered list showing opinions that can be voted (no AJAX) * If the user has already voted, then a message appears * * @param BaseObject $object Propel object instance to vote * @param string $message a message string to be displayed in the voting-message block * @param array $options Array of HTML options to apply on the HTML list * @return string **/ function depp_omnibus_selector($object, $message = '', $options = array()) { if (is_null($object)) { sfLogger::getInstance()->debug('A NULL object cannot be flagged as Omnibus'); return ''; } $user_id = sfContext::getInstance()->getUser()->getId(); try { $options = _parse_attributes($options); if (!isset($options['id'])) { $options = array_merge($options, array('id' => 'omnibus-flag')); } $object_is_omnibus = $object->getIsOmnibus(); $object_will_be_omnibus = !$object_is_omnibus; $selector = ''; if ($object_is_omnibus) { $status = "Questo atto è Omnibus"; $label = "Marcalo come non-Omnibus"; } else { $status = "Questo atto non è Omnibus"; $label = "Marcalo come Omnibus"; } $selector .= link_to($label, sprintf('atto/setOmnibusStatus?id=%d&status=%d', $object->getId(), $object_will_be_omnibus), array('post' => true)); return content_tag('div', $status) . content_tag('div', $selector, $options); } catch (Exception $e) { sfLogger::getInstance()->err('Exception catched from deppOmnibus helper: ' . $e->getMessage()); } }
public function execute($filterChain) { $filterChain->execute(); $response = $this->getContext()->getResponse(); $request = $this->getContext()->getRequest(); $controller = $this->getContext()->getController(); // don't highlight: // * for XHR requests // * if 304 // * if not rendering to the client // * if HTTP headers only if ($request->isXmlHttpRequest() || strpos($response->getContentType(), 'html') === false || $response->getStatusCode() == 304 || $controller->getRenderMode() != sfView::RENDER_CLIENT || $response->isHeaderOnly()) { return; } $timer = sfTimerManager::getTimer('Highlight Filter'); try { if (!$this->highlight()) { $this->removeNotice(); } } catch (sfSolrHighlighterException $e) { sfLogger::getInstance()->err('{sfSolrHighlightFilter} silently ignoring exception: ' . $e->getMessage()); if ($this->testMode) { $timer->addTime(); throw $e; } } catch (Exception $e) { $timer->addTime(); throw $e; } $timer->addTime(); }
/** * <p>Vote a propel object, un-ajax style</p> * * @see deppPropelActAsVotableBehavior API */ public function executePrioritise() { try { if ($this->getRequest()->getMethod() !== sfRequest::POST) { $this->setError($this->messages['post_only']); } // Retrieve parameters from request $object_id = $this->getRequestParameter('object_id'); $object_model = $this->getRequestParameter('object_model'); $priority = $this->getRequestParameter('priority'); // Retrieve ratable propel object if (is_null($priority) || is_null($object_id) || is_null($object_model)) { $this->setError($this->messages['missing_params']); } $object = deppPropelActAsPrioritisableBehaviorToolkit::retrievePrioritisableObject($object_model, $object_id); if (is_null($object)) { $this->setError($this->message['prioritisable_error']); } // User retrieval $user_id = sfContext::getInstance()->getUser()->getId(); if (!$object->allowsNullPriority() && $priority == 0) { $msg = $this->messages['null_not_allowed']; sfLogger::getInstance()->warning($msg); $this->setError($msg); } else { $object->setPriorityValue((int) $priority, $user_id); $message = $this->messages['thank_you']; } $this->setFlash('depp_prioritising_message', $message); $this->redirect($this->getRequest()->getReferer()); } catch (Exception $e) { $this->setError($e->getMessage()); } }
/** * uses information in the $xml_user SimpleXML object to give attributes and permissions to the user * also sets remember or sso cookie, depending on the value of the $remember parameter * * @param $xml_user - SimpleXMLObject * @param $cookie - boolean * @return void * @author Guglielmo Celata **/ public function signIn($xml_user, $cookie = 'none') { // legge i permission dall'xml user $permissions = array(); foreach ($xml_user->permissions->permission as $perm) { $permissions[] = $perm; } $this->setAttribute('subscriber_id', (string) $xml_user->subscriber_id, 'subscriber'); $this->setAuthenticated(true); $expiration_age = sfConfig::get('app_cookies_remember_key_expiration_age', 15 * 24 * 3600); $cookie_remember_name = sfConfig::get('app_cookies_remember_name', 'sfRemember'); $cookie_sso_name = sfConfig::get('app_cookies_sso_name', 'sfSSO'); $cookie_path = sfConfig::get('app_cookies_path', '/'); $cookie_domain = sfConfig::get('app_cookies_domain', 'sfDomain.it'); // if cookie argument was set to 'remember' or 'session' a cookie is set // this MUST only happen with signin invoked from validator (form) sfContext::getInstance()->getLogger()->info('xxx - signIn - cookie: ' . $cookie); if ($cookie == 'remember') { //save the key to the remember cookie sfContext::getInstance()->getLogger()->info('xxx - setting remember cookie: ' . (string) $xml_user->remember_key); sfContext::getInstance()->getResponse()->setCookie($cookie_remember_name, (string) $xml_user->remember_key, time() + $expiration_age, $cookie_path, $cookie_domain); } elseif ($cookie == 'session') { // save the hash to the sso cookie sfContext::getInstance()->getLogger()->info('xxx - setting sso cookie: ' . (string) $xml_user->remember_key); sfContext::getInstance()->getResponse()->setCookie($cookie_sso_name, (string) $xml_user->remember_key, 0, $cookie_path, $cookie_domain); } $this->addCredential('subscriber'); if (in_array('moderatore', $permissions)) { $this->addCredential('moderator'); } if (in_array('amministratore', $permissions)) { $this->addCredential('moderator'); $this->addCredential('administrator'); } // add all credentials from groups and direct permissions foreach ($permissions as $perm) { $this->addCredential((string) $perm); } $this->setAttribute('name', (string) $xml_user->name, 'subscriber'); $this->setAttribute('firstname', (string) $xml_user->firstname, 'subscriber'); $this->setAttribute('hash', (string) $xml_user->hash, 'subscriber'); // read the last_login ts from the xml (it comes from the DB) $this->setAttribute('last_login', (string) $xml_user->last_login, 'subscriber'); // store the new last_login ts (now) in the DB $remote_guard_host = sfConfig::get('sf_remote_guard_host', 'op_accesso.openpolis.it'); $script = str_replace('fe', 'be', sfContext::getInstance()->getRequest()->getScriptName()); if ($script == '/be.php') { $script = '/index.php'; } $apikey = sfConfig::get('sf_internal_api_key', 'xxx'); $last_login_url = sprintf("http://%s%s/setLastLogin/%s/%s/%s", $remote_guard_host, $script, $apikey, (string) $xml_user->hash, urlencode(date('Y-m-d H:i:s'))); sfLogger::getInstance()->info('xxx: last_login_call: ' . $last_login_url); $xml = simplexml_load_file($last_login_url); if (!$xml->ok instanceof SimpleXMLElement) { sfLogger::getInstance()->info('xxx: error while setting last login: %s' . (string) $xml->error); } }
public function getPreference($preference) { if ($item = $this->getAttribute("app_preference_{$preference}")) { return $item; } $item = sfConfig::get("app_preference_{$preference}"); sfLogger::getInstance()->info("Sending default preference for app_preference_{$preference}={$item}"); return $item; }
/** * Class constructor. * * @param string The error message * @param int The error code */ public function __construct($message = null, $code = 0) { if ($this->getName() === null) { $this->setName('sfException'); } parent::__construct($message, $code); if (sfConfig::get('sf_logging_enabled') && $this->getName() != 'sfStopException') { sfLogger::getInstance()->err('{' . $this->getName() . '} ' . $message); } }
private static function getLogger() { if (!self::$logger) { if (class_exists('sfLogger')) { self::$logger = sfLogger::getInstance(); } else { self::$logger = KalturaLog::getInstance(); } } return self::$logger; }
/** * Initializes the cache. * * @param array An array of options * Available options: * - database: database name * - automaticCleaningFactor: disable / tune automatic cleaning process (int) * */ public function initialize($options = array()) { if (isset($options['database'])) { $this->setDatabase($options['database']); unset($options['database']); } $availableOptions = array('automaticCleaningFactor'); foreach ($options as $key => $value) { if (!in_array($key, $availableOptions) && sfConfig::get('sf_logging_enabled')) { sfLogger::getInstance()->err(sprintf('sfSQLiteCache cannot take "%s" as an option', $key)); } $this->{$key} = $value; } }
/** * Return the HTML code for an unordered list showing opinions that can be voted * If the user has already voted, then a message appears * * @param BaseObject $object Propel object instance to vote * @param string $domid unique css identifier for the block (div) containing the voter tool * @param string $message a message string to be displayed in the voting-message block * @param array $options Array of HTML options to apply on the HTML list * @return string **/ function depp_voter($object, $domid = 'depp-voter-block', $message = '', $options = array()) { if (is_null($object)) { sfLogger::getInstance()->debug('A NULL object cannot be voted'); return ''; } $user_id = deppPropelActAsVotableBehaviorToolkit::getUserId(); // anonymous votes if ((is_null($user_id) || $user_id == '') && !$object->allowsAnonymousVoting()) { return __('Anonymous voting is not allowed') . ", " . __('please') . " " . link_to('login', '/login'); } try { $voting_range = $object->getVotingRange(); $options = _parse_attributes($options); if (!isset($options['id'])) { $options = array_merge($options, array('id' => 'voting-items')); } if ($object instanceof sfOutputEscaperObjectDecorator) { $object_class = get_class($object->getRawValue()); } else { $object_class = get_class($object); } $object_id = $object->getReferenceKey(); $token = deppPropelActAsVotableBehaviorToolkit::addTokenToSession($object_class, $object_id); // already voted if ($object->hasBeenVotedByUser($user_id)) { $message .= " " . link_to_remote(__('Take your vote back'), array('url' => sprintf('deppVoting/unvote?domid=%s&token=%s', $domid, $token), 'update' => $domid, 'script' => true, 'complete' => visual_effect('appear', $domid) . visual_effect('highlight', $domid))); } $list_content = ''; for ($i = -1 * $voting_range; $i <= $voting_range; $i++) { if ($i == 0 && !$object->allowsNeutralPosition()) { continue; } $text = sprintf("[%d]", $i); $label = sprintf(__('Vote %d!'), $i); if ($object->hasBeenVotedByUser($user_id) && $object->getUserVoting($user_id) == $i) { $list_content .= content_tag('li', $text); } else { $list_content .= ' <li>' . link_to_remote($text, array('url' => sprintf('deppVoting/vote?domid=%s&token=%s&voting=%d', $domid, $token, $i), 'update' => $domid, 'script' => true, 'complete' => visual_effect('appear', $domid) . visual_effect('highlight', $domid)), array('title' => $label)) . '</li>'; } } $results = get_component('deppVoting', 'votingDetails', array('object' => $object)); return content_tag('ul', $list_content, $options) . content_tag('div', $message, array('id' => 'voting-message')) . content_tag('div', $results, array('id' => 'voting-results')); } catch (Exception $e) { sfLogger::getInstance()->err('Exception catched from sf_rater helper: ' . $e->getMessage()); } }
protected function initialize() { $this->logger = sfLogger::getInstance(); if (sfConfig::get('sf_logging_enabled')) { $this->logger->info('{sfContext} initialization'); } if (sfConfig::get('sf_use_database')) { // setup our database connections $this->databaseManager = new sfDatabaseManager(); $this->databaseManager->initialize(); } // create a new action stack $this->actionStack = new sfActionStack(); // include the factories configuration require sfConfigCache::getInstance()->checkConfig(sfConfig::get('sf_app_config_dir_name') . '/factories.yml'); // register our shutdown function register_shutdown_function(array($this, 'shutdown')); }
/** * Return the HTML code for a unordered list showing rating stars * * @param BaseObject $object Propel object instance * @param array $options Array of HTML options to apply on the HTML list * @throws sfPropelActAsRatableException * @return string **/ function sf_rater($object, $options = array()) { if (is_null($object)) { sfLogger::getInstance()->debug('A NULL object cannot be rated'); } if (!isset($options['star-width'])) { $star_width = sfConfig::get('app_rating_star_width', 25); } else { $star_width = $options['star-width']; unset($options['star-width']); } try { $max_rating = $object->getMaxRating(); $actual_rating = $object->getRating(); $bar_width = $actual_rating * $star_width; $options = _parse_attributes($options); if (!isset($options['class'])) { $options = array_merge($options, array('class' => 'star-rating')); } if (!isset($options['style']) or !preg_match('/width:/i', $options['style'])) { $full_bar_width = $max_rating * $star_width; $options = array_merge($options, array('style' => 'width:' . $full_bar_width . 'px')); } if ($object instanceof sfOutputEscaperObjectDecorator) { $object_class = get_class($object->getRawValue()); } else { $object_class = get_class($object); } $object_id = $object->getReferenceKey(); $token = sfPropelActAsRatableBehaviorToolkit::addTokenToSession($object_class, $object_id); $msg_domid = sprintf('rating_message_%s', $token); $bar_domid = sprintf('current_rating_%s', $token); $list_content = ' <li class="current-rating" id="' . $bar_domid . '" style="width:' . $bar_width . 'px;">'; $list_content .= sprintf(__('Currently rated %d star(s) on %d'), $object->getRating(), $max_rating); $list_content .= ' </li>'; for ($i = 1; $i <= $max_rating; $i++) { $label = sprintf(__('Rate it %d stars'), $i); $list_content .= ' <li>' . link_to_remote($label, array('url' => sprintf('sfRating/rate?token=%s&rating=%d&star_width=%d', $token, $i, $star_width), 'update' => $msg_domid, 'script' => true, 'complete' => visual_effect('appear', $msg_domid) . visual_effect('highlight', $msg_domid)), array('class' => 'r' . $i . 'stars', 'title' => $label)) . '</li>'; } return content_tag('ul', $list_content, $options) . content_tag('div', null, array('id' => $msg_domid)); } catch (Exception $e) { sfLogger::getInstance()->err('Exception catched from sf_rater helper: ' . $e->getMessage()); } }
/** * Returns response as XML * * If reponse is not a valid XML it is being created from * a DOM document which is being created from a text response * (this is the case for not valid HTML documents). * * @return SimpleXMLElement */ public function getResponseXML() { try { $this->responseXml = parent::getResponseXML(); } catch (Exception $exception) { $doc = new DOMDocument(); $resp_str = $this->getResponseText(); // suppress error output libxml_use_internal_errors(true); $doc->loadHTML($resp_str); $this->responseXml = simplexml_import_dom($doc); // send errors to logger $errors = libxml_get_errors(); foreach ($errors as $error) { sfLogger::getInstance()->warning('{zWebBrowser::getResponseXML} ' . $this->displayXMLError($error)); } libxml_clear_errors(); } return $this->responseXml; }
/** * propagate all tags assigned to an OppEmendamento object * to the related OppAtto objects * * @param string $object * @param string $con * @param string $affected_rows * @return void * @author Guglielmo Celata */ public function propagateTagsToRelatedAttos($object, $con, $affected_rows) { $taggable_model = $object->getTaggableModel(); if ($taggable_model != 'OppEmendamento') { return; } $taggable_id = $object->getTaggableId(); $tagged_obj = call_user_func_array(array($taggable_model . 'Peer', 'retrieveByPK'), array($taggable_id)); $relatedAttos = $tagged_obj->getOppAttoHasEmendamentosJoinOppAtto(); foreach ($relatedAttos as $cnt => $atto_em) { $atto = $atto_em->getOppAtto(); $tags_objs = $tagged_obj->getTagsAsObjects(); $names = array(); foreach ($tags_objs as $cnt => $tag_obj) { $names[] = $tag_obj->getName(); } $atto->addTag($names); $atto->save(); sfLogger::getInstance()->info('{OppTaggingExtension::propagateTagsToRelatedAttos}' . sprintf('atto with id %d received the following tags: %s', $atto->getId(), implode(",", $names))); } }
public function executeVotingBlockSmall() { // embed javascripts for ajax interaction $response = sfContext::getInstance()->getResponse(); $response->addStylesheet('/deppPropelActAsVotableBehaviorPlugin/css/depp_voting.css'); $this->must_login = false; if (is_null($this->object)) { sfLogger::getInstance()->debug('A NULL object cannot be voted'); return ''; } $this->user_id = deppPropelActAsVotableBehaviorToolkit::getUserId(); // anonymous votes if ((is_null($this->user_id) || $this->user_id == '') && !$this->object->allowsAnonymousVoting()) { $this->must_login = true; } if (!isset($this->can_unvote)) { $this->can_unvote = true; } $object_class = get_class($this->object); $object_id = $this->object->getReferenceKey(); $this->token = deppPropelActAsVotableBehaviorToolkit::addTokenToSession($object_class, $object_id); }
/** * Parses a URL to find a matching route. * * Returns null if no route match the URL. * * @param string URL to be parsed * * @return array An array of parameters */ public function parse($url) { // an URL should start with a '/', mod_rewrite doesn't respect that, but no-mod_rewrite version does. if ($url && '/' != $url[0]) { $url = '/' . $url; } // we remove the query string if ($pos = strpos($url, '?')) { $url = substr($url, 0, $pos); } // we remove multiple / $url = preg_replace('#/+#', '/', $url); foreach ($this->routes as $route_name => $route) { $out = array(); $r = null; list($route, $regexp, $names, $names_hash, $defaults, $requirements, $suffix) = $route; $break = false; if (preg_match($regexp, $url, $r)) { $break = true; // remove the first element, which is the url array_shift($r); // hack, pre-fill the default route names foreach ($names as $name) { $out[$name] = null; } // defaults foreach ($defaults as $name => $value) { if (preg_match('#[a-z_\\-]#i', $name)) { $out[$name] = urldecode($value); } else { $out[$value] = true; } } $pos = 0; foreach ($r as $found) { // if $found is a named url element (i.e. ':action') if (isset($names[$pos])) { $out[$names[$pos]] = urldecode($found); } else { $pass = explode('/', $found); $found = ''; for ($i = 0, $max = count($pass); $i < $max; $i += 2) { if (!isset($pass[$i + 1])) { continue; } $found .= $pass[$i] . '=' . $pass[$i + 1] . '&'; } parse_str($found, $pass); if (get_magic_quotes_gpc()) { $pass = sfToolkit::stripslashesDeep((array) $pass); } foreach ($pass as $key => $value) { // we add this parameters if not in conflict with named url element (i.e. ':action') if (!isset($names_hash[$key])) { $out[$key] = $value; } } } $pos++; } // we must have found all :var stuffs in url? except if default values exists foreach ($names as $name) { if ($out[$name] == null) { $break = false; } } if ($break) { // we store route name $this->setCurrentRouteName($route_name); if (sfConfig::get('sf_logging_enabled')) { sfLogger::getInstance()->info('{sfRouting} match route [' . $route_name . '] "' . $route . '"'); } break; } } } // no route found if (!$break) { if (sfConfig::get('sf_logging_enabled')) { sfLogger::getInstance()->info('{sfRouting} no matching route found'); } return null; } return $out; }
protected function initialize() { $this->logger = sfLogger::getInstance(); if (sfConfig::get('sf_logging_enabled')) { $this->logger->info('{sfContext} initialization'); } if (sfConfig::get('sf_use_database')) { $this->databaseManager = new sfDatabaseManager(); $this->databaseManager->initialize(); } $this->actionStack = new sfActionStack(); // 'config/factories.yml' config file // auto-generated by sfFactoryConfigHandler // date: 2015/09/01 13:56:04 $this->controller = sfController::newInstance(sfConfig::get('sf_factory_controller', 'sfFrontWebController')); $this->request = sfRequest::newInstance(sfConfig::get('sf_factory_request', 'sfWebRequest')); $this->response = sfResponse::newInstance(sfConfig::get('sf_factory_response', 'sfWebResponse')); $this->storage = sfStorage::newInstance(sfConfig::get('sf_factory_storage', 'sfSessionStorage')); $this->user = sfUser::newInstance(sfConfig::get('sf_factory_user', 'myUser')); $this->controller->initialize($this); $this->request->initialize($this, sfConfig::get('sf_factory_request_parameters', NULL), sfConfig::get('sf_factory_request_attributes', array())); $this->response->initialize($this, sfConfig::get('sf_factory_response_parameters', NULL)); $this->storage->initialize($this, sfConfig::get('sf_factory_storage_parameters', array('session_name' => 'symfony'))); $this->user->initialize($this, sfConfig::get('sf_factory_user_parameters', NULL)); if (sfConfig::get('sf_cache')) { $this->viewCacheManager = new sfViewCacheManager(); $this->viewCacheManager->initialize($this, sfConfig::get('sf_factory_view_cache', 'sfFileCache'), sfConfig::get('sf_factory_view_cache_parameters', array('automaticCleaningFactor' => 0, 'cacheDir' => '/Applications/MAMP/trademark/cache/backend/prod/template'))); } register_shutdown_function(array($this, 'shutdown')); }
/** * will remove all unwanted characters fro mthe request - * it will be hard coded for now !!! * TODO - the complex security will use configuration */ private function basicSecureRequest() { $start = microtime(true); $stop_at_first = false; $this->m_invalid_params = array(); $all_valid = true; $logger = sfLogger::getInstance(); // fix all the request containers. // fixing only _REQUEST does not modify the rest! $this->fixRequestContainer($_REQUEST); $this->fixRequestContainer($_POST); $this->fixRequestContainer($_GET); $this->fixRequestContainer($_COOKIE); $this->m_basic_security_time = microtime(true) - $start; if (count($this->m_invalid_params) > 0) { $logger->warning("basicSecureRequest: errors\n" . print_r($this->m_invalid_params, true)); } $logger->warning("basicSecureRequest: took [" . $this->m_basic_security_time . "] seconds"); return $all_valid; }
/** * Retrieve the numberof objects monitored by the user. * An object_model can be specified to filter on the objects type. * A Criteria can also be specified. * * The number of objects is taken from the cache, if possible * and read from the DB if specifically asked, * through the override_cache parameter or if the cache does not exist * * @return int * @param BaseObject $user * @param String $object_model - define the type of objects * @param Criteria $criteria - an additional criteria * @param boolean $override_cache - wether to override cache or not **/ public function countMonitoredObjects(BaseObject $user, $object_model = null, $criteria = null, $override_cache = false) { if ($override_cache == false) { try { $res = self::getCachedCountMonitoredObjects($user, $object_model); } catch (deppPropelActAsMonitorerException $e) { sfLogger::getInstance()->warning($e); $override_cache = true; } } if ($override_cache == true) { if (!is_null($criteria)) { $c = clone $criteria; } else { $c = new Criteria(); } if (!is_null($object_model)) { $c->add(MonitoringPeer::MONITORABLE_MODEL, $object_model); } $c->add(MonitoringPeer::USER_ID, $this->getReferenceKey($user)); $res = MonitoringPeer::doCount($c); try { self::setCachedCountMonitoredObjects($user, $object_model, $res); } catch (deppPropelActAsMonitorerException $e) { sfLogger::getInstance()->warning($e); } } return $res; }
protected function initialize() { $this->logger = sfLogger::getInstance(); if (sfConfig::get('sf_logging_enabled')) { $this->logger->info('{sfContext} initialization'); } if (sfConfig::get('sf_use_database')) { $this->databaseManager = new sfDatabaseManager(); $this->databaseManager->initialize(); } $this->actionStack = new sfActionStack(); $this->controller = sfController::newInstance(sfConfig::get('sf_factory_controller', 'sfFrontWebController')); $this->request = sfRequest::newInstance(sfConfig::get('sf_factory_request', 'sfWebRequest')); $this->response = sfResponse::newInstance(sfConfig::get('sf_factory_response', 'sfWebResponse')); $this->storage = sfStorage::newInstance(sfConfig::get('sf_factory_storage', 'sfSessionStorage')); $this->user = sfUser::newInstance(sfConfig::get('sf_factory_user', 'myUser')); $this->controller->initialize($this); $this->request->initialize($this, sfConfig::get('sf_factory_request_parameters', NULL), sfConfig::get('sf_factory_request_attributes', array())); $this->response->initialize($this, sfConfig::get('sf_factory_response_parameters', NULL)); $this->storage->initialize($this, sfConfig::get('sf_factory_storage_parameters', array('session_name' => 'symfony'))); $this->user->initialize($this, sfConfig::get('sf_factory_user_parameters', NULL)); if (sfConfig::get('sf_cache')) { $this->viewCacheManager = new sfViewCacheManager(); $this->viewCacheManager->initialize($this, sfConfig::get('sf_factory_view_cache', 'sfFileCache'), sfConfig::get('sf_factory_view_cache_parameters', array('automaticCleaningFactor' => 0, 'cacheDir' => 'C:\\xampp\\htdocs\\bm400\\cache\\pmbonline\\dev\\template'))); } register_shutdown_function(array($this, 'shutdown')); }
/** * Initializes the cache. * * @param array An array of options * Available options: * - cacheDir: cache root directory * - fileLocking: enable / disable file locking (boolean) * - writeControl: enable / disable write control (boolean) * - readControl: enable / disable read control (boolean) * - fileNameProtection: enable / disable automatic file name protection (boolean) * - automaticCleaningFactor: disable / tune automatic cleaning process (int) * - hashedDirectoryLevel: level of the hashed directory system (int) * - lifeTime: default life time * */ public function initialize($options = array()) { if (isset($options['cacheDir'])) { $this->setCacheDir($options['cacheDir']); unset($options['cacheDir']); } $availableOptions = array('fileLocking', 'writeControl', 'readControl', 'fileNameProtection', 'automaticCleaningFactor', 'hashedDirectoryLevel', 'lifeTime'); foreach ($options as $key => $value) { if (!in_array($key, $availableOptions) && sfConfig::get('sf_logging_enabled')) { sfLogger::getInstance()->err(sprintf('sfFileCache cannot take "%s" as an option', $key)); } $this->{$key} = $value; } }
<?php /* * This file is part of the symfony package. * (c) 2004-2006 Fabien Potencier <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ /** * @package symfony * @subpackage addon * @author Fabien Potencier <*****@*****.**> * @version SVN: $Id: sfPropelAutoload.php 210 2007-03-01 23:59:16Z jphipps $ */ require_once 'propel/Propel.php'; if (sfConfig::get('sf_debug') && sfConfig::get('sf_logging_enabled')) { // register debug driver require_once 'creole/Creole.php'; Creole::registerDriver('*', 'symfony.addon.creole.drivers.sfDebugConnection'); // register our logger require_once sfConfig::get('sf_symfony_lib_dir') . '/addon/creole/drivers/sfDebugConnection.php'; sfDebugConnection::setLogger(sfLogger::getInstance()); } // propel initialization Propel::setConfiguration(sfPropelDatabase::getConfiguration()); Propel::initialize();
function emailContactImporterDiagnose() { include_once "email_import_diagnose.php"; } $ok = image_tag('/sf/sf_default/images/icons/ok48.png'); $notok = image_tag('/sf/sf_default/images/icons/cancel48.png'); ?> <a href="/index.php/system/login?exit=true">logout</a><br> <h1>System Test Results</h1> <TABLE align="center"> <?php echo '<TR><TD>'; echo "logger class: " . get_class(sfLogger::getInstance()); echo '</TD></TR>'; echo '<TR><TD>'; echo "Host: " . requestUtils::getHost(); echo '</TD></TR>'; echo '<TR><TD>'; echo " webRoot: " . requestUtils::getWebRootUrl(); echo '</TD></TR>'; echo "<TR><TD>Is the server running the 'curl_init' extension? " . (function_exists("curl_init") ? $ok : $notok) . "</TD></TR>"; /* echo '<TR><TD>The name of the user running httpd: '. exec('whoami')."</TD></TR>"; echo '<TR><TD>Path: '. exec('echo $PATH')."</TD></TR>"; echo '<TR><TD>Is FFMPEG in the path: '. (exec('ffmpeg') != null ? $ok : $notok)."</TD></TR>"; */
require_once dirname(__FILE__) . '/../../bootstrap/unit.php'; $t = new lime_test(136, new lime_output_color()); class myLogger { public $log = ''; public function log($message, $priority) { $this->log .= $message; } } $myLogger = new myLogger(); // ->getInstance() $t->diag('->getInstance()'); $t->isa_ok(sfLogger::getInstance(), 'sfLogger', '::getInstance() returns a sfLogger instance'); $t->is(sfLogger::getInstance(), sfLogger::getInstance(), '::getInstance() is a singleton'); $logger = sfLogger::getInstance(); // ->getLoggers() $t->diag('->getLoggers()'); $t->is($logger->getLoggers(), array(), '->getLoggers() returns an array of registered loggers'); // ->registerLogger() $t->diag('->registerLogger()'); $logger->registerLogger($myLogger); $t->is($logger->getLoggers(), array($myLogger), '->registerLogger() registers a new logger instance'); // ->initialize() $t->diag('->initialize()'); $logger->initialize(); $t->is($logger->getLoggers(), array(), '->initialize() initializes the logger and clears all current registered loggers'); // ->setLogLevel() ->getLogLevel() $t->diag('->setLogLevel() ->getLogLevel()'); $t->is($logger->getLogLevel(), SF_LOG_EMERG, '->getLogLevel() gets the current log level'); $logger->setLogLevel(SF_LOG_WARNING);
<?php // auto-generated by sfPhpConfigHandler // date: 2015/12/07 17:49:30 ini_set('magic_quotes_runtime', ''); ini_set('log_errors', '1'); ini_set('arg_separator.output', '&'); if (ini_get('magic_quotes_gpc') != false) { sfLogger::getInstance()->warning('{sfPhpConfigHandler} php.ini "magic_quotes_gpc" key is better set to "false" (current value is "\'1\'" - php.ini location: "C:\\xampp\\apache\\bin\\php.ini")'); } if (ini_get('register_globals') != false) { sfLogger::getInstance()->warning('{sfPhpConfigHandler} php.ini "register_globals" key is better set to "false" (current value is "\'\'" - php.ini location: "C:\\xampp\\apache\\bin\\php.ini")'); } if (ini_get('session.auto_start') != false) { sfLogger::getInstance()->warning('{sfPhpConfigHandler} php.ini "session.auto_start" key is better set to "false" (current value is "\'0\'" - php.ini location: "C:\\xampp\\apache\\bin\\php.ini")'); }
public function executeSottoscrizionePremium() { if ($this->getUser()->hasCredential('premium')) { $this->redirect('@homepage'); } // processes the form if posted if ($this->getRequest()->getMethod() == sfRequest::POST) { // TODO: DB Storage for form data // richiesta di upgrade della sottoscrizione utente $token = $this->getUser()->getPassword(); $opaccesso_key = sfConfig::get('api_opaccesso_key', '--XXX(-:-)XXX--'); $remote_guard_host = sfConfig::get('sf_remote_guard_host', 'op_accesso.openpolis.it'); // finezza: se sono in dev, rimane in dev if (sfConfig::get('sf_environment') == 'dev') { $controller = 'be_dev.php'; } else { $controller = 'index.php'; } $xml = simplexml_load_file("http://{$remote_guard_host}/{$controller}/promoteUser/{$token}/{$opaccesso_key}"); // go home if something really wrong happens (could not write last_login to db) if (!$xml->ok instanceof SimpleXMLElement) { sfLogger::getInstance()->info('xxx: user promotion failed: ' . (string) $xml->error); } // clean session variable and redirect $redirect_to = $this->getUser()->getAttribute('page_before_buy', '@homepage'); $this->getUser()->getAttributeHolder()->remove('page_before_buy'); $this->redirect($redirect_to); } }
<?php define('KALTURA_ROOT_PATH', realpath(__DIR__ . '/../')); define('SF_APP', 'kaltura'); define('SF_ROOT_DIR', KALTURA_ROOT_PATH . '/alpha'); define('MODULES', SF_ROOT_DIR . '/apps/kaltura/modules/'); $sf_symfony_lib_dir = KALTURA_ROOT_PATH . '/vendor/symfony'; $sf_symfony_data_dir = KALTURA_ROOT_PATH . '/vendor/symfony-data'; // symfony bootstraping require_once "{$sf_symfony_lib_dir}/util/sfCore.class.php"; sfCore::bootstrap($sf_symfony_lib_dir, $sf_symfony_data_dir); // Logger kLoggerCache::InitLogger(KALTURA_LOG, 'PS2'); sfLogger::getInstance()->registerLogger(KalturaLog::getInstance()); sfLogger::getInstance()->setLogLevel(7); sfConfig::set('sf_logging_enabled', true); DbManager::setConfig(kConf::getDB()); DbManager::initialize(); ActKeyUtils::checkCurrent(); sfContext::getInstance()->getController()->dispatch();
/** * Return the HTML code for an unordered list showing opinions that can be voted (no AJAX) * If the user has already voted, then a message appears * * @param BaseObject $object Propel object instance to vote * @param string $message a message string to be displayed in the voting-message block * @param array $options Array of HTML options to apply on the HTML list * @return string **/ function depp_voter_no_ajax($object, $message = '', $options = array()) { if (is_null($object)) { sfLogger::getInstance()->debug('A NULL object cannot be voted'); return ''; } $results = get_component('deppVoting', 'votingDetails', array('object' => $object)); $user_id = deppPropelActAsVotableBehaviorToolkit::getUserId(); // anonymous votes if ((is_null($user_id) || $user_id == '') && !$object->allowsAnonymousVoting()) { $msg = "<ul id='voting-items'>" . link_to('<li>' . image_tag('/images/btn-voted-yes.png', array('alt' => 'effettua il login per votare')) . '</li><li>' . image_tag('/images/btn-voted-no.png', array('alt' => 'effettua il login per votare')) . '</li></ul><br />effettua il login per votare', '/login'); return content_tag('div', $msg, array('id' => 'voting-message')) . content_tag('div', $results, array('id' => 'voting-results')); } try { $options = _parse_attributes($options); if (!isset($options['id'])) { $options = array_merge($options, array('id' => 'voting-items')); } if ($object instanceof sfOutputEscaperObjectDecorator) { $object_class = get_class($object->getRawValue()); } else { $object_class = get_class($object); } $object_id = $object->getReferenceKey(); $token = deppPropelActAsVotableBehaviorToolkit::addTokenToSession($object_class, $object_id); // already voted if ($object->hasBeenVotedByUser($user_id)) { $message .= " " . link_to(__('Take your vote back'), sprintf('deppVoting/unvoteNoAjax?token=%s', $token), array('post' => true)); } $list_content = ''; for ($i = 1; $i >= -1; $i -= 2) { $text = $i == 1 ? 'yes' : 'no'; $label = sprintf(__('Vote %s!'), $text); if ($object->hasBeenVotedByUser($user_id)) { $image_name = $object->getUserVoting($user_id) == $i ? "btn-has-voted-{$text}.png" : "btn-non-voted-{$text}.png"; $list_content .= content_tag('li', image_tag($image_name, $label)); } else { $list_content .= content_tag('li', link_to(image_tag("btn-vote-{$text}.png", $label), sprintf('deppVoting/voteNoAjax?token=%s&voting=%d', $token, $i), array('post' => true))); } } return content_tag('ul', $list_content, $options) . content_tag('div', $message, array('id' => 'voting-message')) . content_tag('div', $results, array('id' => 'voting-results')); } catch (Exception $e) { sfLogger::getInstance()->err('Exception catched from sf_rater helper: ' . $e->getMessage()); } }
/** * This methods will returns a basic user error message while logging a * complete one if provided in the debug log file * * @param string $log_info Log information message */ protected function renderFatalError($log_info = null) { if (!is_null($log_info)) { sfLogger::getInstance()->warning('Rating error: ' . $log_info); } return $this->renderText($this->messages['user_error']); }