/** * @param FlashMessages $flashMessages * @return mixed */ public function transform(FlashMessages $flashMessages) { if (session()->has('errors')) { foreach (session('errors')->all() as $messages) { $flashMessages->add('danger', $messages); } } session()->forget('errors'); }
public function testInfo() { $this->assertEmpty($this->flash->getAllInfo()); $this->assertNull($this->flash->getInfo("foo")); $this->assertEquals("bar", $this->flash->getInfo("foo", "bar")); $this->assertFalse($this->flash->hasAnyInfo()); $this->flash->setInfo("foo", "bar"); $this->flash = new FlashMessages($this->storage, $this->key); $this->assertEquals(["foo" => "bar"], $this->flash->getAllInfo()); $this->assertEquals("bar", $this->flash->getInfo("foo")); $this->assertTrue($this->flash->hasAnyInfo()); $this->flash->setInfo("foo", "bar"); $this->flash->setInfo("foo2", "bar2"); $this->assertArrayHasKey("info", $this->storage[$this->key]); $this->assertEquals("bar", $this->storage[$this->key]["info"]["foo"]); $this->flash->removeInfo("foo"); $this->assertArrayNotHasKey("foo", $this->storage[$this->key]["info"]); $this->assertNotEmpty($this->storage[$this->key]["info"]); $this->flash->removeAllInfo(); $this->assertEmpty($this->storage[$this->key]["info"]); }
<?php require_once 'config.php'; require_once 'db.php'; require_once 'functions.php'; require_once 'queries.php'; session_start(); include_once 'modules/FlashMessages.class.php'; $message = new FlashMessages(); $page = 'home'; function slashes(&$el) { if (is_array($el)) { foreach ($el as $k => $v) { slashes($el[$k]); } } else { $el = stripslashes($el); } } ?> <!DOCTYPE html> <html lang="EN"> <?php include 'modules/stats-header.php'; ?> <div class="container custom-container"> <body> <div class="content"> <?php
$parseDomain = new ParseDomain($_SERVER['SERVER_NAME']); if (!$parseDomain->isCoveredByCookies()) { if ($app['config']->isSingleSiteMode) { header("Location: " . $app['config']->getWebIndexDomainSecure() . $_SERVER['REQUEST_URI']); } else { // Not sure how to improve this; it's hard to work out which domain they were trying to hit. header("Location: " . $app['config']->getWebIndexDomainSecure()); } die("REDIRECT!"); } ///////////////////////// Sessions /** @var WebSession **/ $WEBSESSION = new WebSession(); $app['websession'] = $WEBSESSION; /** @var FlashMessages **/ $FLASHMESSAGES = new FlashMessages($WEBSESSION); $app['flashmessages'] = $FLASHMESSAGES; /** @var UserAgent **/ $USERAGENT = new \UserAgent(); $app['userAgent'] = $USERAGENT; ///////////////////////// TWIG $dirs = array(); foreach ($CONFIG->extensions as $extensionName) { // Carefully ordered so extensions are first in list. // And in config, later extensions listed can overwrite earlier extensions. array_unshift($dirs, APP_ROOT_DIR . '/extension/' . $extensionName . '/theme/default/templates'); if ($CONFIG->isSingleSiteMode) { array_unshift($dirs, APP_ROOT_DIR . '/extension/' . $extensionName . '/theme/default/templatesSingleSite'); } } // default templates are last
<?php /** * webtrees: online genealogy * Copyright (C) 2016 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ namespace Fisharebest\Webtrees; define('WT_SCRIPT_NAME', 'logout.php'); require './includes/session.php'; if (Auth::id()) { Log::addAuthenticationLog('Logout: ' . Auth::user()->getUserName() . '/' . Auth::user()->getRealName()); Auth::logout(); FlashMessages::addMessage(I18N::translate('You are logged out.'), 'info'); } header('Location: ' . WT_BASE_URL);
public function index() { wfProfileIn(__METHOD__); $this->wg->Out->setPageTitle(wfMsg('managewikiahome')); if (!$this->checkAccess()) { wfProfileOut(__METHOD__); $this->forward('ManageWikiaHome', 'onWrongRights'); return false; } $this->setVal('slotsInTotal', WikiaHomePageHelper::SLOTS_IN_TOTAL); $this->infoMsg = FlashMessages::pop(); //wikis with visualization selectbox $visualizationLang = $this->wg->request->getVal(self::WHST_VISUALIZATION_LANG_VAR_NAME, $this->wg->contLang->getCode()); $visualizationLang = substr(strtolower($visualizationLang), 0, 2); $this->visualizationLang = $visualizationLang; $this->visualizationWikisData = $this->helper->getVisualizationWikisData(); $this->currentPage = $this->request->getVal('page', 1); $this->corpWikiId = $this->visualizationWikisData[$this->visualizationLang]['wikiId']; $this->filterOptions = array_merge($this->initFilterOptions(), $this->request->getParams()); $this->exportListAsCSVUri = $this->getExportListAsCSVUri(); //verticals slots' configuration /* @var $this->helper WikiaHomePageHelper */ $videoGamesAmount = $this->request->getVal('video-games-amount', $this->helper->getNumberOfVideoGamesSlots($this->visualizationLang)); $entertainmentAmount = $this->request->getVal('entertainment-amount', $this->helper->getNumberOfEntertainmentSlots($this->visualizationLang)); $lifestyleAmount = $this->request->getVal('lifestyle-amount', $this->helper->getNumberOfLifestyleSlots($this->visualizationLang)); $this->form = new CollectionsForm(); $this->statsForm = new StatsForm(); $this->hubsForm = new HubsSlotsForm(); $savedSlotsValues = $this->helper->getHubSlotsFromWF($this->corpWikiId, $visualizationLang); $homePageSlotsValues = $this->prepareSlots($savedSlotsValues); $collectionsModel = $this->getWikiaCollectionsModel(); $this->collectionsList = $collectionsModel->getList($this->visualizationLang); $collectionValues = $this->prepareArrayFieldsToShow($this->collectionsList); $wikisPerCollection = $this->getWikisPerCollection($this->collectionsList); $statsValues = $this->app->sendRequest('WikiaStatsController', 'getWikiaStatsFromWF')->getData(); if ($this->request->wasPosted()) { if ($this->request->getVal('wikis-in-slots', false)) { //todo: separate post request handling //todo: move validation from saveSlotsConfigInWikiFactory() to helper $total = intval($videoGamesAmount) + intval($entertainmentAmount) + intval($lifestyleAmount); if ($total !== WikiaHomePageHelper::SLOTS_IN_TOTAL) { $this->errorMsg = wfMessage('manage-wikia-home-error-invalid-total-no-of-slots')->params(array($total, WikiaHomePageHelper::SLOTS_IN_TOTAL))->text(); } elseif ($this->isAnySlotNumberNegative($videoGamesAmount, $entertainmentAmount, $lifestyleAmount)) { $this->errorMsg = wfMessage('manage-wikia-home-error-negative-slots-number-not-allowed')->text(); } else { $this->saveSlotsConfigInWikiFactory($this->corpWikiId, $visualizationLang, array(WikiaHomePageHelper::VIDEO_GAMES_SLOTS_VAR_NAME => $videoGamesAmount, WikiaHomePageHelper::ENTERTAINMENT_SLOTS_VAR_NAME => $entertainmentAmount, WikiaHomePageHelper::LIFESTYLE_SLOTS_VAR_NAME => $lifestyleAmount)); } } elseif ($this->request->getVal('collections', false)) { $collectionValues = $this->request->getParams(); $collectionValues = $this->form->filterData($collectionValues); $isValid = $this->form->validate($collectionValues); if ($isValid) { $collectionSavedValues = $this->prepareArrayFieldsForSave($collectionValues); $collectionsModel->saveAll($this->visualizationLang, $collectionSavedValues); FlashMessages::put(wfMessage('manage-wikia-home-collections-success')->text()); $this->response->redirect($_SERVER['REQUEST_URI']); } else { $this->errorMsg = wfMessage('manage-wikia-home-collections-failure')->text(); } } elseif ($this->request->getVal('stats', false)) { $statsValues = $this->request->getParams(); $statsValues = $this->statsForm->filterData($statsValues); $isValid = $this->statsForm->validate($statsValues); if ($isValid) { $isAllowed = true; try { $this->app->sendRequest('WikiaStatsController', 'saveWikiaStatsInWF', array('statsValues' => $statsValues)); } catch (PermissionsException $ex) { $isAllowed = false; } if ($isAllowed) { FlashMessages::put(wfMessage('manage-wikia-home-stats-success')->text()); $this->response->redirect($_SERVER['REQUEST_URI']); } else { $this->errorMsg = wfMessage('manage-wikia-home-stats-permissions-error')->text(); } } else { $this->errorMsg = wfMessage('manage-wikia-home-stats-failure')->text(); } } elseif ($this->request->getVal('hubs-slots', false)) { $homePageSlotsValues = $this->request->getParams(); $homePageSlotsValues = $this->hubsForm->filterData($homePageSlotsValues); $homePageSlotsValues = $this->filterUrls($homePageSlotsValues); $hubSavedSlotsValues = $homePageSlotsValues['hub_slot']; $marketingSlotsValues = $this->getMarketingSlotsValues($homePageSlotsValues); $marketingSavedSlotsValues = $this->prepareArrayFieldsForSave($marketingSlotsValues); $isValid = $this->hubsForm->validate($homePageSlotsValues); $isValid &= $this->validateMarketingSlots($marketingSavedSlotsValues); if ($isValid) { $savedSlotsValues = ['hub_slot' => $hubSavedSlotsValues, 'marketing_slot' => $marketingSavedSlotsValues]; $status = $this->helper->saveHubSlotsToWF($savedSlotsValues, $this->corpWikiId, $this->visualizationLang, 'wgWikiaHomePageHubsSlotsV2'); if ($status) { $this->infoMsg = wfMessage('manage-wikia-home-hubs-slot-success')->text(); } else { $this->errorMsg = wfMessage('manage-wikia-home-hubs-slot-error')->text(); } } } } $this->form->setFieldsValues($collectionValues); $this->statsForm->setFieldsValues($statsValues); $this->verticals = $this->helper->getWikiVerticals(); $this->marketingImages = []; if (array_key_exists('marketing_slots', $savedSlotsValues)) { $this->marketingImages = $this->prepareMarketingSlotImages($savedSlotsValues['marketing_slot']); } $this->prepareHubsForm($homePageSlotsValues); $this->setVal('videoGamesAmount', $videoGamesAmount); $this->setVal('entertainmentAmount', $entertainmentAmount); $this->setVal('lifestyleAmount', $lifestyleAmount); $this->setVal('wikisPerCollection', $wikisPerCollection); $this->response->addAsset('/extensions/wikia/SpecialManageWikiaHome/css/ManageWikiaHome.scss'); $this->response->addAsset('manage_wikia_home_js'); JSMessages::enqueuePackage('ManageWikiaHome', JSMessages::EXTERNAL); $this->wg->Out->addJsConfigVars(['wgWikisPerCollection' => $wikisPerCollection, 'wgSlotsInTotal' => WikiaHomePageHelper::SLOTS_IN_TOTAL]); wfProfileOut(__METHOD__); }
<?php session_start(); require "flashMessages.php"; unset($_SESSION["onidid"]); unset($_SESSION["ticket"]); $msg = new FlashMessages(); //$msg->success("Successfully logged out!", "index.php"); $msg->success("Successfully logged out!", "https://login.oregonstate.edu/cas/logout"); //header('Location: https://login.oregonstate.edu/cas/logout');
* You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ namespace Fisharebest\Webtrees; /** * Defined in session.php * * @global Tree $WT_TREE */ global $WT_TREE; define('WT_SCRIPT_NAME', 'admin_trees_export.php'); require './includes/session.php'; if (Auth::isManager($WT_TREE) && Filter::checkCsrf()) { $filename = WT_DATA_DIR . $WT_TREE->getName(); // Force a ".ged" suffix if (strtolower(substr($filename, -4)) != '.ged') { $filename .= '.ged'; } try { // To avoid partial trees on timeout/diskspace/etc, write to a temporary file first $stream = fopen($filename . '.tmp', 'w'); $WT_TREE->exportGedcom($stream); fclose($stream); rename($filename . '.tmp', $filename); FlashMessages::addMessage(I18N::translate('The family tree has been exported to %s.', Html::filename($filename)), 'success'); } catch (\ErrorException $ex) { FlashMessages::addMessage(I18N::translate('The file %s could not be created.', Html::filename($filename)) . '<hr><samp dir="ltr">' . $ex->getMessage() . '</samp>', 'danger'); } } header('Location: ' . WT_BASE_URL . 'admin_trees_manage.php');
/** * Main action for editing hub modules */ public function editHubAction() { global $wgCityId; if (!$this->checkAccess()) { return false; } $this->retriveDataFromUrl(); $this->wg->Out->addJsConfigVars(['wgEditHubModuleIdSelected' => $this->selectedModuleId, 'wgEditHubModuleIdPopularVideos' => WikiaHubsModulePopularvideosService::MODULE_ID, 'wgEditHubModuleIdFeaturedVideo' => WikiaHubsModuleFeaturedvideoService::MODULE_ID]); $this->checkDate($this->date); $this->flashMessage = FlashMessages::pop(); $modulesData = $this->editHubModel->getModulesData($wgCityId, $this->date, $this->selectedModuleId); $this->prepareLayoutData($this->selectedModuleId, $modulesData); $this->response->addAsset('resources/jquery/jquery.validate.js'); $this->response->addAsset('/extensions/wikia/SpecialEditHub/js/EditHub.js'); $this->response->addAsset('/extensions/wikia/SpecialEditHub/js/EditHubNavigation.js'); $this->response->addAsset('/extensions/wikia/SpecialEditHub/js/jquery.MetaData.js'); $selectedModuleValues = $modulesData['moduleList'][$this->selectedModuleId]['data']; $module = WikiaHubsModuleService::getModuleByName($this->editHubModel->getNotTranslatedModuleName($this->selectedModuleId), $wgCityId); $form = new FormBuilderService(EditHubModel::FORM_FIELD_PREFIX); $form->setFields($module->getFormFields()); if ($this->request->wasPosted()) { $selectedModuleValues = $this->request->getParams(); $selectedModuleValues = $module->filterData($selectedModuleValues); $isValid = $form->validate($selectedModuleValues); if ($isValid) { $this->editHubModel->saveModule(['cityId' => $wgCityId, 'langCode' => $this->wg->ContLang->getCode(), 'verticalId' => WikiFactoryHub::getInstance()->getCategoryId($wgCityId)], $this->date, $this->selectedModuleId, $selectedModuleValues, $this->wg->user->getId()); $this->purgeCache($module); FlashMessages::put(wfMessage('edit-hub-module-save-ok', $modulesData['activeModuleName'])->escaped()); $nextUrl = $this->getNextModuleUrl(); $this->response->redirect($nextUrl); } else { $this->errorMessage = wfMessage('edit-hub-module-save-error')->escaped(); } } $form->setFieldsValues($selectedModuleValues); $this->moduleName = $modulesData['activeModuleName']; $this->moduleContent = $module->renderEditor(['form' => $form]); $this->overrideTemplate('editHub'); }
<?php if (isset($_SESSION["onidid"])) { ?> <ul class="nav navbar-nav navbar-right"> <li><a href="logout.php"><span class="glyphicon glyphicon-log-out"></span> Logout</a></li> <?php } else { if (false) { ?> <ul class="nav navbar-nav navbar-right"> <li><a href="https://secure.onid.oregonstate.edu/cgi-bin/newacct?type=want_auth"><span class="glyphicon glyphicon-user"></span> Sign Up</a></li> <li><a href="https://login.oregonstate.edu/cas/login"><span class="glyphicon glyphicon-log-in"></span> Login</a></li> <?php } } ?> </ul> </div> </nav> <main> <div class="container"> <?php $msg = new FlashMessages(); $msg->display(); ?> </div>
<?php /** * webtrees: online genealogy * Copyright (C) 2016 webtrees development team * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ namespace Fisharebest\Webtrees; define('WT_SCRIPT_NAME', 'logout.php'); require './includes/session.php'; // The current tree (if any). $gedcom = Session::get('GEDCOM', ''); if (Auth::id()) { Log::addAuthenticationLog('Logout: ' . Auth::user()->getUserName() . '/' . Auth::user()->getRealName()); Auth::logout(); FlashMessages::addMessage(I18N::translate('You have signed out.'), 'info'); } header('Location: ' . WT_BASE_URL . 'index.php?ged=' . rawurlencode($gedcom));