private static function loadConfig() { if (!self::$config_loaded) { include sfConfig::get('app_forum_config_path'); self::$cookie_name = $cookie_name; self::$cookie_path = $cookie_path; self::$cookie_domain = $cookie_domain; self::$cookie_secure = $cookie_secure; self::$cookie_seed = $cookie_seed; self::$config_loaded = true; } }
public static function check_password($password, $hash) { // check whether the stored hash is using password_hash() or Punbb::hash() $password_needs_rehash = password_needs_rehash($hash, PASSWORD_DEFAULT); return !$password_needs_rehash && password_verify($password, $hash) || $password_needs_rehash && Punbb::punHash($password) === $hash; }
/** * Gets document comments. */ public function executeComment() { $timer = new sfTimer('executeComment'); $id = $this->getRequestParameter('id'); $lang = $this->getRequestParameter('lang'); // one cannot comment a document which does not exist. if (!($document = DocumentI18n::findName($id, $lang, $this->model_class))) { c2cActions::statsdTiming('document.executeComment.redirect', $timer->getElapsedTime('executeComment')); $this->setNotFoundAndRedirect(); } // redirect to true document module if $model_class == Document if ($this->model_class == 'Document') { $document = Document::find('Document', $id, array('module')); c2cActions::statsdTiming('document.executeComment.redirect', $timer->getElapsedTime('executeComment')); $this->redirect('@document_comment?module=' . $document->get('module') . "&id={$id}&lang={$lang}", 301); } $this->document_name = $document->get('name'); $this->search_name = $document->get('search_name'); $this->comments = PunbbComm::retrieveComments($id . '_' . $lang); // mark topic as read if user connected if ($this->getUser()->isConnected()) { $row = $this->comments->getLast(); $topic_id = $row->get('topic_id'); $last_post_time = $row->get('posted'); Punbb::MarkTopicAsRead($topic_id, $last_post_time); } $this->exists_in_lang = 1; $this->setTemplate('../../documents/templates/comment'); $this->setPageTitle($this->document_name . ' :: ' . $this->__('Comments')); $this->getResponse()->addMeta('robots', 'index, follow'); c2cActions::statsdTiming('document.executeComment', $timer->getElapsedTime('executeComment')); }
/** * Executes Edit action for user private data. */ public function executeEditPrivateData() { $user_id = $this->getUser()->getId(); // logged user id if (!($user_private_data = UserPrivateData::find($user_id))) { $this->setNotFoundAndRedirect(); } if ($this->getRequest()->getMethod() == sfRequest::POST) { // user private data update $email = trim($this->getRequestParameter('email')); $password = trim($this->getRequestParameter('password')); $nickname = trim($this->getRequestParameter('edit_nickname')); $nickname = preg_replace('#\\s+#', ' ', $nickname); $toponame = trim($this->getRequestParameter('edit_topo_name')); $toponame = preg_replace('#\\s+#', ' ', $toponame); $is_profile_public = $this->getRequestParameter('is_profile_public'); $conn = sfDoctrine::Connection(); try { if (!empty($password)) { $user_private_data->setPassword($password); // since the password has been changed, we remove all the remember me keys // attached to this user. RememberKey::deleteUserKeys($user_id); } if (!is_null($email)) { $old_email = $user_private_data->getEmail(); if ($old_email != $email) { Sympa::updateEmail($old_email, $email); $user_private_data->setEmail($email); } } if ($nickname != $user_private_data->getUsername()) { $user_private_data->setUsername($nickname); } if ($toponame != $user_private_data->getTopoName()) { $user_private_data->setTopoName($toponame); } $user_private_data->setIsProfilePublic(!empty($is_profile_public)); $user_private_data->save(); $conn->commit(); $this->statsdIncrement('success'); // update cache $this->clearCache('users', $user_id, false, 'view'); } catch (Exception $e) { $conn->rollback(); $this->statsdIncrement('failure'); } // update user session $this->getUser()->setAttribute('username', $user_private_data->get('topo_name')); // little js update if ($this->isAjaxCall()) { sfLoader::loadHelpers(array('Javascript', 'Tag')); // update the name to use (after the welcome) // and be sure to reset password value $js = javascript_tag("\$('#name_to_use').html('" . $user_private_data->get('topo_name') . "');\n \$('#current_password').val('')"); } else { $js = ""; } if (!empty($password)) { // user updated is password. We need to update the login to punbb Punbb::signIn($user_private_data->getId(), $user_private_data->password); } $lang = $this->getUser()->getCulture(); return $this->setNoticeAndRedirect('Your private information have been successfully updated', "@document_by_id_lang?module=users&id={$user_id}&lang={$lang}", null, $js); } else { // display form //$this->user = $user; $this->user_private_data = $user_private_data; $this->setPageTitle($this->__('User account update')); } }