public function editProcess($actionurl = false) { global $callbackId; if (PPostHandler::isHandling()) { $vars =& PPostHandler::getVars(); if ($vars) { // Populate the _REQUEST array with the Post-Vars, so the wiki can use them :-/ foreach ($vars as $key => $value) { $_REQUEST[$key] = $value; } } $url = $this->parseRequest(); $this->no_output = true; ob_start(); $this->getWiki($url); ob_end_clean(); PPostHandler::clearVars(); $url = str_replace('edit/', '', $url); if ($actionurl) { header('Location: ' . PVars::getObj('env')->baseuri . $actionurl); PPHP::PExit(); } header('Location: ' . PVars::getObj('env')->baseuri . 'wiki/' . $url); PPHP::PExit(); //return PVars::getObj('env')->baseuri.'wiki'; } else { $callbackId = PFunctions::hex2base64(sha1(__METHOD__)); PPostHandler::setCallback($callbackId, __CLASS__, __FUNCTION__); return $callbackId; } }
private function _redirect($rel_url) { /* echo PVars::getObj('env')->baseuri.'<br>'; echo PVars::getObj('env')->baseuri.implode('/', PRequest::get()->request).'<br>'; echo PVars::getObj('env')->baseuri.$rel_url; */ header('Location: ' . PVars::getObj('env')->baseuri . $rel_url); PPHP::PExit(); }
public function index($args = false) { $page = new ExtensionsPage(); $request = $args->request; if (!isset($request[1])) { // nothing happens } else { if (empty($request[1])) { // nothing happens } else { if (!is_dir(SCRIPT_BASE . 'extensions/' . $request[1])) { echo $request[1]; // nothing happens } else { if (!isset($_SESSION['extension_folders'])) { $_SESSION['extension_folders'] = ''; } $active_ext_folders = preg_split("/[,\n\r\t ]+/", $_SESSION['extension_folders']); $extfolder = $request[1]; switch (isset($request[2]) ? $request[2] : '') { case 'off': case 'disable': if (is_numeric($key = array_search($extfolder, $active_ext_folders))) { unset($active_ext_folders[$key]); } break; case 'on': default: if (!in_array($extfolder, $active_ext_folders)) { $active_ext_folders[] = $extfolder; } } $_SESSION['extension_folders'] = implode(' ', $active_ext_folders); if (isset($request[3])) { $this->redirect(implode('/', array_slice($request, 3))); PPHP::PExit(); } else { $this->redirect('extensions'); PPHP::PExit(); } } } } return $page; }
public function __construct($dir) { $datadir = DATA_DIR . $dir; if (PPHP::os() == 'WIN') { $datadir = str_replace('/', '\\', $datadir); } if (!file_exists($datadir)) { @mkdir($datadir, 0700, true); } if (!file_exists($datadir)) { throw new PException('Data subdir "' . $datadir . '" does not exist!'); } if (!is_dir($datadir)) { throw new PException('Data subdir "' . $datadir . '" is not a directory!'); } if (!is_writable($datadir)) { throw new PException('Data subdir "' . $datadir . '" is not writable!'); } $this->dir = $datadir; }
public function avatar($userId) { if (!$this->_model->hasAvatar($userId)) { header('Content-type: image/png'); @copy(HTDOCS_BASE . 'images/misc/empty_avatar' . (isset($_GET['xs']) ? '_xs' : '') . '.png', 'php://output'); PPHP::PExit(); } $file = (int) $userId; if (isset($_GET['xs'])) { $file .= '_xs'; } $img = new MOD_images_Image($this->_model->avatarDir->dirName() . '/' . $file); if (!$img->isImage()) { header('Content-type: image/png'); @copy(HTDOCS_BASE . 'images/misc/empty_avatar' . (isset($_GET['xs']) ? '_xs' : '') . '.png', 'php://output'); PPHP::PExit(); } $size = $img->getImageSize(); header('Content-type: ' . image_type_to_mime_type($size[2])); $this->_model->avatarDir->readFile($file); PPHP::PExit(); }
function MustLogIn() { // TODO: This is not a good place to include something! It has been here before, so whatever. require_once 'FunctionsLogin.php'; if (IsLoggedIn()) { // all is fine, move on in program } else { // not logged in, redirect to a login page // TODO: Why do we have to log out here? // I would assume the user IS already logged out! // APP_User::get()->logout(); $request = PRequest::get()->request; if (isset($_SERVER['PHP_SELF']) and strpos($_SERVER['PHP_SELF'], '/admin/') !== 0) { $redirect_url = PVars::getObj('env')->baseuri . 'login' . $_SERVER['PHP_SELF']; } else { $redirect_url = PVars::getObj('env')->baseuri . 'login/bw/' . implode('/', $request); } $redirect_url .= empty($_SERVER['QUERY_STRING']) ? '' : '?' . $_SERVER['QUERY_STRING']; header("Location: " . $redirect_url); PPHP::PExit(); } }
public function thumbImg($id) { if (!($d = $this->_model->imageData($id))) { PPHP::PExit(); } $tmpDir = new PDataDir('gallery/user' . $d->user_id_foreign); if (isset($_GET['t'])) { $thumbFile = 'thumb' . (int) $_GET['t'] . $d->file; } else { $thumbFile = 'thumb' . $d->file; } if (!$tmpDir->fileExists($thumbFile)) { $thumbFile = $d->file; } if (!$tmpDir->fileExists($thumbFile) || $tmpDir->file_Size($thumbFile) == 0) { $tmpDir = new PDataDir('gallery'); $thumbFile = 'nopic.gif'; $d->mimetype = 'image/gif'; } header('Content-type: ' . $d->mimetype); $tmpDir->readFile($thumbFile); PPHP::PExit(); }
/** * Index function * * Currently the index consists of following possible requests: * register - registration form to page content * confirm - confirmation redirect to signup * * @param void */ public function index($args = false) { // In case Signup is closed if (isset($_SESSION['Param']->FeatureSignupClose) && $_SESSION['Param']->FeatureSignupClose == "Yes") { return new SignupClosedPage(); } /* * Enable to check against DNS Blocklists if (MOD_dnsblock::get()->checkRemoteIp()) { return new SignupDNSBlockPage(); } */ $request = $args->request; $model = new SignupModel(); if (isset($_SESSION['IdMember']) && !MOD_right::get()->hasRight('words')) { if (!isset($_SESSION['Username'])) { unset($_SESSION['IdMember']); $page = new SignupProblemPage(); } else { $this->redirect('members/' . $_SESSION['Username']); } } else { switch (isset($request[1]) ? $request[1] : '') { // copied from TB: // checks e-mail address for validity and availability case 'checkemail': // ignore current request, so we can use the last request PRequest::ignoreCurrentRequest(); if (!isset($_GET['email'])) { echo '0'; PPHP::PExit(); } if (!PFunctions::isEmailAddress($_GET['email'])) { echo '0'; PPHP::PExit(); } $users = $model->takeCareForNonUniqueEmailAddress($_GET['email']); if ($users == '') { echo "1"; } else { echo "0"; } PPHP::PExit(); break; // copied from TB: rewiewed by JeanYves // checks Username for validity and availability // copied from TB: rewiewed by JeanYves // checks Username for validity and availability case 'checkhandle': // ignore current request, so we can use the last request PRequest::ignoreCurrentRequest(); if (!isset($request[2])) { echo '0'; PPHP::PExit(); } if (!preg_match(User::HANDLE_PREGEXP, $request[2])) { echo '0'; PPHP::PExit(); } if (strpos($request[2], 'xn--') !== false) { // Don't allow IDN-Prefixes echo '0'; PPHP::PExit(); } echo (bool) (!$model->UsernameInUse($request[2])); PPHP::PExit(); break; case 'getRegions': // ignore current request, so we can use the last request PRequest::ignoreCurrentRequest(); if (!isset($request[2])) { PPHP::PExit(); } case 'terms': MOD_log::get()->write("Viewing terms", "Signup"); // the termsandconditions popup $page = new SignupTermsPopup(); break; case 'privacy': MOD_log::get()->write("Viewing privacy", "Signup"); $page = new SignupPrivacyPopup(); break; case 'confirm': // or give it a different name? // this happens when you click the link in the confirmation email if (!isset($request[2]) || !isset($request[3]) || !preg_match(User::HANDLE_PREGEXP, $request[2]) || !$model->UsernameInUse($request[2]) || !preg_match('/^[a-f0-9]{16}$/', $request[3])) { $error = 'InvalidLink'; } else { $error = $model->confirmSignup($request[2], $request[3]); } $page = new SignupMailConfirmPage(); $page->error = $error; break; case 'resendmail': // shown when clicking on the link in the MailToConfirm error message $error = ''; if (!isset($request[2])) { $error = 'InvalidLink'; } else { $resent = $model->resendConfirmationMail($request[2]); if ($resent !== true) { $error = $resent; } } $page = new SignupResentMailPage(); $page->error = $error; break; case 'finish': $page = new SignupFinishPage(); break; default: $page = new SignupPage(); $page->step = isset($request[1]) && $request[1] ? $request[1] : '1'; $StrLog = "Entering Signup step: #" . $page->step; MOD_log::get()->write($StrLog, "Signup"); $page->model = $model; } } return $page; }
public function index($args = false) { if (PPostHandler::isHandling()) { return; } $request = $args->request; if (isset($request[0]) && 'rox' == $request[0]) { // bw.org/rox/in/lang or bw.org/rox/start // should be the same as just // bw.org/in/lang, or bw.org/start array_shift($request); } switch (isset($request[0]) ? $request[0] : false) { case 'in': // language switching if (!isset($request[1])) { $this->redirectHome(); } else { $this->_switchLang($request[1]); $this->redirect(array_slice($request, 2), $args->get); } PPHP::PExit(); case 'trmode': // an alias.. // an alias.. case 'tr_mode': // translation mode switching if (!isset($request[1])) { $this->redirectHome(); } else { $this->_switchTrMode($request[1]); $this->redirect(array_slice($request, 2), $args->get); } PPHP::PExit(); case 'start': $page = new PublicStartpage(); break; case 'trac': case 'mediawiki': case 'mailman': $this->redirectAbsolute('http://www.bevolunteer.org/' . $request[0]); PPHP::PExit(); case 'www.bewelcome.org': // some emails sent by mailbot contain a link to // http://www.bewelcome.org/www.bewelcome.org/something // we need to redirect them to // https://www.bewelcome.org/something $this->redirect(array_slice($request, 1), $args->get); PPHP::PExit(); case 'main': case 'home': case 'index': case '': default: if (APP_User::isBWLoggedIn("NeedMore,Pending")) { $page = new PersonalStartpage(); // This is the Main Start page for logged in members } else { $page = new PublicStartpage(); // This is the Default Start page for not logged in members } } $page->setModel($this->_model); $page->model = $this->_model; // some want it like this return $page; }
/** * again, PT needs it. * */ protected function loadDefaults($xpath, $settings) { // copied from defaults.inc.php // we don't need PPckup() and translate($request) anymore, // we have chooseControllerClassname() instead. // suspended $susp = $xpath->query('/basedata/suspended'); if ($susp->length > 0) { if (isset($settings['env']['suspend_url'])) { header('Location: ' . $settings['env']['suspend_url']); } else { header('HTTP/1.1 403 Forbidden'); } PPHP::PExit(); } // debug? $debug = $xpath->query('/basedata/debug'); if ($debug->length > 0) { PVars::register('debug', true); $build = str_replace(SCRIPT_BASE, '', BUILD_DIR); PVars::register('build', substr($build, 0, strlen($build) - 1)); } }
private function ajaxPost() { PRequest::ignoreCurrentRequest(); if (!($member = $this->_model->getLoggedInMember())) { return false; } // Modifying a blog post using an ajax-request if (isset($_GET['item'])) { $id = $_GET['item']; if ($this->_model->isUserPost($member->id, $id)) { if (isset($_GET['title'])) { $str = htmlentities($_GET['title'], ENT_QUOTES, "UTF-8"); if (!empty($str)) { $this->_model->ajaxEditPost($id, $str, ''); $str2 = utf8_decode(addslashes(preg_replace("/\r|\n/s", "", nl2br($str)))); echo $str2; } else { echo 'Can`t be empty! Click to edit!'; } } if (isset($_GET['text'])) { $str = htmlentities($_GET['text'], ENT_QUOTES, "UTF-8"); $this->_model->ajaxEditPost($id, '', $str); $str = utf8_decode(addslashes(preg_replace("/\r|\n/s", "", nl2br($str)))); echo $str; } if (isset($_GET['geoid'])) { $str = (int) $_GET['geoid']; $result = $this->_model->ajaxEditPost($id, '', '', $str); echo $result ? 'OK' : 'NO'; } PPHP::PExit(); } } echo 'Error!'; PPHP::PExit(); }
private function _redirect($rel_url) { header('Location: ' . PVars::getObj('env')->baseuri . $rel_url); PPHP::PExit(); }
/** */ public function index() { $vw = new ViewWrap($this->_view); $P = PVars::getObj('page'); // First check if the feature is closed if ($_SESSION["Param"]->FeatureSearchPageIsClosed != 'No') { $P->content = $this->_view->showFeatureIsClosed(); return; } // end of test "if feature is closed" if (PPostHandler::isHandling()) { return; } $request = PRequest::get()->request; if (!isset($request[1])) { $request[1] = ''; } // Route quicksearch if ($request[0] == 'quicksearch') { $error = false; // static pages switch ($request[1]) { case '': $searchtext = isset($_GET["vars"]) ? $_GET['vars'] : ''; // Because of old way to use the QuickSearch with a get break; default: $searchtext = $request[1]; break; } $TReturn = $this->_model->quicksearch($searchtext); if (count($TReturn->TMembers) == 1 and count($TReturn->TPlaces) == 0 and count($TReturn->TForumTags) == 0) { $loc = "members/" . $TReturn->TMembers[0]->Username; header('Location: ' . $loc); PPHP::PExit(); } else { if (count($TReturn->TMembers) == 0 and count($TReturn->TPlaces) == 1 and count($TReturn->TForumTags) == 0) { $loc = $TReturn->TPlaces[0]->link; header('Location: ' . $loc); PPHP::PExit(); } else { if (count($TReturn->TMembers) == 0 and count($TReturn->TPlaces) == 0 and count($TReturn->TForumTags) == 1) { $loc = "forums/t" . $TReturn->TForumTags[0]->IdTag; header('Location: ' . $loc); PPHP::PExit(); } } } $P->content .= $vw->quicksearch_results($TReturn); return $P; } if ($request[0] != 'searchmembers') { header('Location: searchmembers'); PPHP::PExit(); } // fix a problem with Opera javascript, which sends a 'searchmembers/searchmembers/ajax' request if ($request[1] === 'searchmembers') { $request = array_slice($request, 1); } // default mapstyle: $mapstyle = 'mapon'; $queries = ''; $varsOnLoad = ''; $varsGet = ''; if (isset($request[1])) { switch ($request[1]) { case 'mapoff': $mapstyle = "mapoff"; $_SESSION['SearchMembersTList'] = array(); break; case 'mapon': $mapstyle = "mapon"; $_SESSION['SearchMembersTList'] = array(); break; case 'queries': if (PVars::get()->debug) { $R = MOD_right::get(); if ($R->HasRight("Debug", "DB_QUERY")) { $queries = true; $mapstyle = "mapoff"; } } break; default: if (isset($_SESSION['SearchMapStyle']) and $_SESSION['SearchMapStyle']) { $mapstyle = $_SESSION['SearchMapStyle']; } break; } } // Store the MapStyle in session $_SESSION['SearchMapStyle'] = $mapstyle; // Check wether there are latest search results and variables from the session if (!$queries && isset($_SESSION['SearchMembersTList'])) { if ($_SESSION['SearchMembersTList'] && $_SESSION['SearchMembersVars']) { $varsOnLoad = $_SESSION['SearchMembersVars']; } } switch ($request[1]) { case 'ajax': if (isset($request[2]) and $request[2] == "varsonload") { $vars['varsOnLoad'] = true; // Read the latest search results and variables from the session if (!empty($_SESSION['SearchMembersTList'])) { $TList = $_SESSION['SearchMembersTList']; } if (!empty($_SESSION['SearchMembersVars'])) { $vars = $_SESSION['SearchMembersVars']; } if (isset($request[3])) { $vars['OrderBy'] = $request[3]; $TList = $this->_model->search($vars); } } else { $vars = isset($_GET) ? $_GET : array(); if (isset($request[2]) && $request[2] == "queries") { $vars['queries'] = true; } if (!isset($TList)) { $TList = $this->_model->search($vars); } } $this->_view->searchmembers_ajax($TList, $vars, $mapstyle); // Store latest search results and variables in session $_SESSION['SearchMembersTList'] = $TList; $_SESSION['SearchMembersVars'] = $vars; PPHP::PExit(); break; /* quicksearch shouldn't go through this route case 'quicksearch': $mapstyle = "mapoff"; // First check if the QuickSearch feature is closed if ($_SESSION["Param"]->FeatureQuickSearchIsClosed!='No') { $this->_view->showFeatureIsClosed(); PPHP::PExit(); break ; } // end of test "if QuickSearch feature is closed" if (isset($request[2])) { // The parameter to search for can be for the form searchmember/quicksearch/ value $searchtext=$request[2] ; } if (isset($_GET['searchtext'])) { // The parameter can come from the main menu $searchtext = $_GET['searchtext']; } if (isset($_POST['searchtext'])) { // The parameter can come from the quicksearch form $searchtext = $_POST['searchtext']; } // die('here searchtext={'.$searchtext.'}') ; if (!empty($searchtext)) { $TReturn=$this->_model->quicksearch($searchtext) ; if ((count($TReturn->TMembers)==1) and (count($TReturn->TPlaces)==0) and (count($TReturn->TForumTags)==0)) { $loc="members/".$TReturn->TMembers[0]->Username ; header('Location: '.$loc); PPHP::PExit(); } else if ((count($TReturn->TMembers)==0) and (count($TReturn->TPlaces)==1) and (count($TReturn->TForumTags)==0)) { $loc=$TReturn->TPlaces[0]->link ; header('Location: '.$loc); PPHP::PExit(); } else if ((count($TReturn->TMembers)==0) and (count($TReturn->TPlaces)==0) and (count($TReturn->TForumTags)==1)) { $loc="forums/t".$TReturn->TForumTags[0]->IdTag ; header('Location: '.$loc); PPHP::PExit(); } $P->content .= $vw->quicksearch_results($TReturn); } else { $vars = PPostHandler::getVars('quicksearch_callbackId'); PPostHandler::clearVars('quicksearch_callbackId'); // first include the col2-stylesheet $P->addStyles .= $this->_view->customStyles($mapstyle,$quicksearch=1); // now the teaser content $P->teaserBar .= $vw->teaserquicksearch($mapstyle); $P->content .= $vw->quicksearch_form(); } break; // Backwards compatibility case 'index': $loc = PVars::getObj('env')->baseuri; $loc .= 'searchmembers'; if(isset($request[2])) {$loc .= '/'.$request[2];} elseif(isset($request[3])) {$loc .= '/'.$request[3];} header('Location: '.$loc); PPHP::PExit(); break; */ /* quicksearch shouldn't go through this route case 'quicksearch': $mapstyle = "mapoff"; // First check if the QuickSearch feature is closed if ($_SESSION["Param"]->FeatureQuickSearchIsClosed!='No') { $this->_view->showFeatureIsClosed(); PPHP::PExit(); break ; } // end of test "if QuickSearch feature is closed" if (isset($request[2])) { // The parameter to search for can be for the form searchmember/quicksearch/ value $searchtext=$request[2] ; } if (isset($_GET['searchtext'])) { // The parameter can come from the main menu $searchtext = $_GET['searchtext']; } if (isset($_POST['searchtext'])) { // The parameter can come from the quicksearch form $searchtext = $_POST['searchtext']; } // die('here searchtext={'.$searchtext.'}') ; if (!empty($searchtext)) { $TReturn=$this->_model->quicksearch($searchtext) ; if ((count($TReturn->TMembers)==1) and (count($TReturn->TPlaces)==0) and (count($TReturn->TForumTags)==0)) { $loc="members/".$TReturn->TMembers[0]->Username ; header('Location: '.$loc); PPHP::PExit(); } else if ((count($TReturn->TMembers)==0) and (count($TReturn->TPlaces)==1) and (count($TReturn->TForumTags)==0)) { $loc=$TReturn->TPlaces[0]->link ; header('Location: '.$loc); PPHP::PExit(); } else if ((count($TReturn->TMembers)==0) and (count($TReturn->TPlaces)==0) and (count($TReturn->TForumTags)==1)) { $loc="forums/t".$TReturn->TForumTags[0]->IdTag ; header('Location: '.$loc); PPHP::PExit(); } $P->content .= $vw->quicksearch_results($TReturn); } else { $vars = PPostHandler::getVars('quicksearch_callbackId'); PPostHandler::clearVars('quicksearch_callbackId'); // first include the col2-stylesheet $P->addStyles .= $this->_view->customStyles($mapstyle,$quicksearch=1); // now the teaser content $P->teaserBar .= $vw->teaserquicksearch($mapstyle); $P->content .= $vw->quicksearch_form(); } break; // Backwards compatibility case 'index': $loc = PVars::getObj('env')->baseuri; $loc .= 'searchmembers'; if(isset($request[2])) {$loc .= '/'.$request[2];} elseif(isset($request[3])) {$loc .= '/'.$request[3];} header('Location: '.$loc); PPHP::PExit(); break; */ default: $words = new MOD_words(); $P->addStyles = $this->_view->customStyles($mapstyle); $google_conf = PVars::getObj('config_google'); $P->title = $words->getBuffered('searchmembersTitle') . " - BeWelcome"; $P->currentTab = 'searchmembers'; $P->currentSubTab = 'searchmembers'; $subTab = 'index'; // prepare sort order for both the filters and the userbar $sortorder = $this->_model->get_sort_order(); $P->teaserBar = $vw->teaser($mapstyle, $sortorder, $varsOnLoad); $P->teaserBar .= $vw->searchmembersFilters($this->_model->sql_get_groups(), $this->_model->sql_get_set("members", "Accomodation"), $this->_model->sql_get_set("members", "TypicOffer"), $sortorder); $P->content = $vw->search_column_col3($sortorder, $queries, $mapstyle, $varsOnLoad, $varsGet, $this->_model->sql_get_set("members", "Accomodation")); /*$P->content = $vw->memberlist($mapstyle,$sortorder); $P->content .= $vw->searchmembers( $queries, $mapstyle, $varsOnLoad, $varsGet, $this->_model->sql_get_set("members", "Accomodation") ); */ $P->show_volunteerbar = false; break; } }
private function _redirectNotLoggedIn() { $request = PVars::getObj('env')->baseuri . 'login/' . implode('/', $this->request) . '#login-widget'; header('Location: ' . $request); PPHP::PExit(); }
/** * Index function * * Currently the index consists of following possible requests: * checkemail - prints either "0" or "1" depending on e-mail validity * checkhandle - like "checkemail" with user handle * register - registration form to page content * * @param void */ public function index() { // index is called when http request = ./user $request = PRequest::get()->request; if (!isset($request[1])) { $request[1] = ''; } switch ($request[1]) { case 'avatar': PRequest::ignoreCurrentRequest(); if (!isset($request[2]) || !preg_match(User::HANDLE_PREGEXP, $request[2]) || !($userId = $this->_model->handleInUse($request[2]))) { PPHP::PExit(); } $this->_view->avatar($userId); break; // checks e-mail address for validity and availability // checks e-mail address for validity and availability case 'checkemail': // ignore current request, so we can use the last request PRequest::ignoreCurrentRequest(); if (!isset($_GET['e'])) { echo '0'; PPHP::PExit(); } if (!PFunctions::isEmailAddress($_GET['e'])) { echo '0'; PPHP::PExit(); } echo (bool) (!$this->_model->emailInUse($_GET['e'])); PPHP::PExit(); break; // checks handle for validity and availability // checks handle for validity and availability case 'checkhandle': // ignore current request, so we can use the last request PRequest::ignoreCurrentRequest(); if (!isset($request[2])) { echo '0'; PPHP::PExit(); } if (!preg_match(User::HANDLE_PREGEXP, $request[2])) { echo '0'; PPHP::PExit(); } if (strpos($request[2], 'xn--') !== false) { // Don't allow IDN-Prefixes echo '0'; PPHP::PExit(); } echo (bool) (!$this->_model->handleInUse($request[2])); PPHP::PExit(); break; // confirms a registration // confirms a registration case 'confirm': if (!isset($request[2]) || !isset($request[3]) || !preg_match(User::HANDLE_PREGEXP, $request[2]) || !$this->_model->handleInUse($request[2]) || !preg_match('/^[a-f0-9]{16}$/', $request[3])) { $error = true; } else { if ($this->_model->confirmRegister($request[2], $request[3])) { $error = false; } else { $error = true; } } ob_start(); $this->_view->registerConfirm($error); $str = ob_get_contents(); ob_end_clean(); $P = PVars::getObj('page'); $P->content .= $str; break; case 'find': $res = $this->_model->find($_GET['q']); ob_start(); $this->_view->searchResult($res); $str = ob_get_contents(); ob_end_clean(); $P = PVars::getObj('page'); $P->content .= $str; break; case 'friends': if (!($User = APP_User::login())) { return false; } $friends = $this->_model->getFriends($User->getId()); ob_start(); $this->_view->friends($friends); $str = ob_get_contents(); ob_end_clean(); $P = PVars::getObj('page'); $P->content .= $str; break; case 'logout': $this->_model->logout(); header("Location: " . PVars::getObj('env')->baseuri); break; // waiting approval message // waiting approval message case 'waitingapproval': // now the teaser content ob_start(); $this->_view->ShowInfoMessage('', ''); $str = ob_get_contents(); $Page = PVars::getObj('page'); $Page->teaserBar .= $str; ob_end_clean(); // now the message content ob_start(); $this->_view->ShowInfoMessage('WaitingForApprovalText', 'WaitingForApprovalTitle'); $str = ob_get_contents(); ob_end_clean(); $P = PVars::getObj('page'); $P->content .= $str; break; case 'settings': ob_start(); $this->_view->settingsForm(); $str = ob_get_contents(); ob_end_clean(); $P = PVars::getObj('page'); $P->content .= $str; break; case 'password': ob_start(); $this->_view->customStyles(); $str = ob_get_contents(); $Page = PVars::getObj('page'); $Page->addStyles .= $str; ob_end_clean(); // now the teaser content ob_start(); $this->_view->teaser(); $str = ob_get_contents(); $Page = PVars::getObj('page'); $Page->teaserBar .= $str; ob_end_clean(); // now the content on the right ob_start(); $this->_view->rightContent(); $str = ob_get_contents(); $Page = PVars::getObj('page'); $Page->rContent .= $str; ob_end_clean(); // main content ob_start(); $this->_view->passwordForm(); $str = ob_get_contents(); $P = PVars::getObj('page'); $P->content .= $str; ob_end_clean(); break; default: if (preg_match(User::HANDLE_PREGEXP, $request[1])) { if (!isset($request[2])) { $request[2] = ''; } switch ($request[2]) { case 'pic': if (!($User = APP_User::login())) { return false; } ob_start(); $picture = $this->_model->getPicture($request[1]); $this->_view->picture($picture); $str = ob_get_contents(); ob_end_clean(); $P = PVars::getObj('page'); $P->content .= $str; break; default: // redirects to the old bw-based profile header("Location: " . PVars::getObj('env')->baseuri . "bw/member.php?cid=" . $request[1]); // disabled TB-based userpage for now /* ob_start(); $this->_view->userPage($request[1]); $str = ob_get_contents(); ob_end_clean(); $P = PVars::getObj('page'); $P->content .= $str; */ break; } } } }
public static function home() { $base = PVars::getObj('env')->baseuri; header('Location: ' . $base); PPHP::PExit(); }
public function delProcess() { if (!($User = APP_User::login())) { return false; } if ($this->BW_Right->HasRight("ForumModerator", "Delete")) { $this->dao->query("START TRANSACTION"); $query = sprintf("\r\nSELECT\r\n `forums_posts`.`threadid`,\r\n `HasVotes`,\r\n `IdLocalEvent`,\r\n `forums_threads`.`first_postid`,\r\n `forums_threads`.`last_postid`,\r\n `forums_threads`.`expiredate`,\r\n `forums_threads`.`stickyvalue`\r\nFROM `forums_posts`\r\nLEFT JOIN `forums_threads` ON (`forums_posts`.`threadid` = `forums_threads`.`threadid`)\r\nWHERE `forums_posts`.`postid` = '%d'\r\n ", $this->messageId); $s = $this->dao->query($query); if (!$s) { throw new PException('Could not retrieve Threadinfo!'); } $topicinfo = $s->fetch(PDB::FETCH_OBJ); if ($topicinfo->first_postid == $this->messageId) { // Delete the complete topic $this->subtractTagCounter($topicinfo->threadid); $query = "\r\nUPDATE `forums_threads`\r\nSET `first_postid` = NULL, `last_postid` = NULL\r\nWHERE `threadid` = '{$topicinfo->threadid}'\r\n "; $this->dao->query($query); $query = "\r\nDELETE FROM `forums_posts`\r\nWHERE `threadid` = '{$topicinfo->threadid}'\r\n "; $this->dao->query($query); MOD_log::get()->write("deleting posts where Thread=#" . $topicinfo->threadid, "Forum"); // Prepare a notification (before the delete !) $this->prepare_notification($this->messageId, "deletethread"); $query = "\r\nDELETE FROM `forums_threads`\r\nWHERE `threadid` = '{$topicinfo->threadid}'\r\n "; $this->dao->query($query); $redir = 'forums'; } else { // Delete a single post /* * Check if we are deleting the very last post of a topic * if so, we have to update the `last_postid` field of the `forums_threads` table */ if ($topicinfo->last_postid == $this->messageId) { $query = "\r\nUPDATE `forums_threads`\r\nSET `last_postid` = NULL\r\nWHERE `threadid` = '{$topicinfo->threadid}'\r\n "; $this->dao->query($query); } MOD_log::get()->write("deleting single post where Post=#" . $this->messageId, "Forum"); $this->prepare_notification($this->messageId, "deletepost"); // Prepare a notification (before the delete !) $query = "\r\nDELETE FROM `forums_posts`\r\nWHERE `postid` = '{$this->messageId}'\r\n "; $this->dao->query($query); if ($topicinfo->last_postid == $this->messageId) { $query = "\r\nSELECT `postid`\r\nFROM `forums_posts`\r\nWHERE `threadid` = '{$topicinfo->threadid}'\r\nORDER BY `create_time` DESC LIMIT 1\r\n "; $s = $this->dao->query($query); if (!$s) { throw new PException('Could not retrieve Postinfo!'); } $lastpost = $s->fetch(PDB::FETCH_OBJ); $lastpostupdate = sprintf(", `last_postid` = '%d'", $lastpost->postid); } else { $lastpostupdate = ''; } $query = "\r\nUPDATE `forums_threads`\r\nSET `replies` = (`replies` - 1) {$lastpostupdate}\r\nWHERE `threadid` = '{$topicinfo->threadid}'\r\n "; $this->dao->query($query); $redir = $this->forums_uri . 's' . $topicinfo->threadid; } $this->dao->query("COMMIT"); } header('Location: ' . PVars::getObj('env')->baseuri . $redir); PPHP::PExit(); }
/** * sends headers, reads out an image and then exits * * @param int $id - id of group to get thumbnail for * @access public */ public function realImg($id) { if (!($group = $this->createEntity('Group')->findById($id)) || !$group->Picture) { PPHP::PExit(); } $dir = new PDataDir('groups'); if (!$dir->fileExists($group->Picture) || $dir->file_Size($group->Picture) == 0) { PPHP::PExit(); } $img = new MOD_images_Image($dir->dirName() . '/' . $group->Picture); header('Content-type: ' . $img->getMimetype()); $dir->readFile($group->Picture); PPHP::PExit(); }
/** * redirects to a login screen, returning the user to where it was afterwards * * @param string $url_part - relative url * @access protected */ protected function redirectToLogin($url_part) { $this->redirectAbsolute($this->router->url('login_helper', array('url' => $url_part))); PPHP::PExit(); }
/** * @param void * @access private */ private function __construct() { if (!PPHP::assertExtension('mysqli')) { throw new PException('MySQLi backend error!'); } }
public function getOldPicture($memberid) { $s = $this->dao->query(' SELECT `membersphotos`.`FilePath` as FilePath FROM `members` LEFT JOIN `membersphotos` on `membersphotos`.`IdMember`=`members`.`id` WHERE `members`.`id`=\'' . $memberid . '\' AND `members`.`Status`=\'Active\' ORDER BY membersphotos.SortOrder '); // look if any of the pics exists while ($row = $s->fetch(PDB::FETCH_OBJ)) { $path = str_replace("/bw", "", $row->FilePath); $full_path = getcwd() . '/bw' . $path; if (PPHP::os() == 'WIN') { $full_path = str_replace("/", "\\", $full_path); } if (is_file($full_path)) { return $full_path; } } return false; }
/** * Processing login * * This is a POST callback function * * @param void */ public function loginProcess() { $callbackId = PFunctions::hex2base64(sha1(__METHOD__)); if (PPostHandler::isHandling()) { $vars =& PPostHandler::getVars(); $User = APP_User::login($vars['u'], $vars['p']); if (!$User || !$User->IsBWLoggedIn("Pending,NeedMore")) { $vars['errors'][] = 'not_logged_in'; } $redirect_url = $vars['redirect']; header('Location: ' . $redirect_url); PPHP::PExit(); return false; } else { PPostHandler::setCallback($callbackId, __CLASS__, __METHOD__); return $callbackId; } }
public function importConfigPHP($default_settings) { if (is_file(SCRIPT_BASE . 'rox_local.ini')) { // rox_local.ini exists, don't need to create. // normally this should not happen when this function is called. echo ' <pre> ' . __METHOD__ . '() was called, but "' . SCRIPT_BASE . 'rox_local.ini" already exists! </pre> '; PPHP::PExit(); } else { if (!is_file(SCRIPT_BASE . 'inc/config.inc.php')) { // rox_local.ini exists, don't need to create. // normally this should not happen when this function is called. echo ' <pre> ' . __METHOD__ . '() was called, but "' . SCRIPT_BASE . 'inc/config.inc.php" is missing </pre> '; PPHP::PExit(); } else { // the rox_local.ini is missing, and has to be created. // load settings from config.inc.php require_once SCRIPT_BASE . 'inc/config.inc.php'; // where is PVars different from the ini settings? $differences = array(); foreach (array('db' => 'config_rdbms', 'db' => 'db', 'smtp' => 'config_smtp', 'mailAddresses' => 'config_mailAddresses', 'request' => 'config_request', 'google' => 'config_google', 'env' => 'env') as $sectionname => $objectname) { $differences[$sectionname] = array(); if (!($object = PVars::getObj($objectname))) { // ehm.. no idea } else { if (!isset($default_settings[$sectionname])) { // ehm.. no idea. } else { foreach ($default_settings[$sectionname] as $key => $value) { if (!$object->{$key}) { // do nothing } else { if ($default_settings[$sectionname][$key] != $object->{$key}) { $differences[$sectionname][$key] = $object->{$key}; } } echo '.'; } } } echo ';'; } // where is $_SYSHCVOL different from $default_settings['syshcvol'] ? if (!isset($default_settings['syshcvol'])) { if (!empty($_SYSHCVOL)) { echo '<br>creating a full syshcvolbullshit<br>'; $differences['syshcvol'] = $_SYSHCVOL; } else { echo '<br>syshcvol empity<br>'; } } else { echo '<br>syshcvol differences extraction<br>'; $default_settings_syshcvol = $default_settings['syshcvol']; $differences['syshcvol'] = array(); foreach ($_SYSHCVOL as $key => $value) { if (!isset($default_settings_syshcvol[$key]) || $default_settings_syshcvol[$key] != $_SYSHCVOL[$key]) { // setting needs to go into $differences $differences['syshcvol'][$key] = $value; } echo '+'; } } // some things are forced to be implicit (not imported) unset($differences['syshcvol']['MYSQLUsername']); unset($differences['syshcvol']['MYSQLPassword']); unset($differences['syshcvol']['MYSQLDB']); unset($differences['syshcvol']['SiteName']); unset($differences['syshcvol']['MainDir']); unset($differences['syshcvol']['WWWIMAGEDIR']); // some things are forced to be explicit (imported even if the same as default). if (!isset($differences['db'])) { $differences['db'] = array(); } if (!isset($differences['env'])) { $differences['env'] = array(); } $differences['db']['dsn'] = PVars::getObj('config_rdbms')->dsn; $differences['db']['user'] = PVars::getObj('config_rdbms')->user; $differences['db']['password'] = PVars::getObj('config_rdbms')->password; $differences['env']['baseuri'] = PVars::getObj('env')->baseuri; // create the string to write into the ini file $res = ""; foreach ($differences as $sectionname => $sectioncontents) { if (empty($sectioncontents)) { // nothing to do. } else { $res .= "\n[{$sectionname}]\n"; if (isset($default_settings[$sectionname])) { $default_settings_section = $default_settings[$sectionname]; } else { $default_settings_section = array(); } foreach ($sectioncontents as $key => $value) { if (!is_array($value)) { $res .= "{$key} = \"{$value}\"\n"; } else { // ini notation does only work with numeric keys, unfortunately.. $res .= "\n"; for ($i = 0; $i < count($value); ++$i) { if (isset($value[$i])) { $res .= $key . "[] = \"" . $value[$i] . "\"\n"; } else { $res .= $key . "[] = \"\"\n"; } } $res .= "\n"; } } } } $filename = SCRIPT_BASE . 'rox_local.ini'; $this->writeSettingsToFile($filename, $res); } } }
private function save() { if ($this->_callback && is_array($this->_callback)) { foreach ($this->_callback as $key => $callback) { if (!array_key_exists($key, $_POST)) { continue; } foreach ($_POST as $k => $v) { if (is_string($v)) { $v = trim($v); $v = stripslashes($v); } $this->_vars[$key][$k] = $v; } $this->_activeKey = $key; $callback = $this->_callback[$key]; unset($this->_callback[$key]); break; } $ret = false; $db = PVars::getObj('config_rdbms'); $dao = PDB::get($db->dsn, $db->user, $db->password); $c = new $callback[0]($dao); $cbRet = call_user_func(array(&$c, $callback[1])); if ($cbRet) { $ret = $cbRet; } $_SESSION['PostHandler'] = serialize($this); if ($ret) { $ret = parse_url($ret); $query = array(); if (isset($ret['query'])) { parse_str($ret['query'], $query); } if (is_array($query) && array_key_exists(session_name(), $query)) { continue; } $query[session_name()] = session_id(); $queries = array(); foreach ($query as $k => $q) { $queries[] = $k . '=' . $q; } $ret['query'] = implode('&', $queries); $ret = PFunctions::glueParsedUrl($ret); session_write_close(); header('Location: ' . $ret); PPHP::PExit(); } return TRUE; } }
private function _getPageByKeyword($keyword, $keyword_2) { switch ($keyword) { case 'thepeople': return new AboutThepeoplePage(); case 'getactive': return new AboutGetactivePage(); case 'newsletters': case 'missions': case 'bod': case 'help': case 'terms': case 'commentguidelines': case 'impressum': case 'affiliations': case 'privacy': $page = new AboutGenericPage($keyword); $page->setModel(new AboutModel()); return $page; case 'stats': case 'statistics': if (!empty($keyword_2)) { // return the given image header('Content-type: image/png'); $statsDir = new PDataDir('statimages'); $statsDir->readFile($keyword_2); PPHP::PExit(); } $statsModel = new StatsModel(); // Generate new statsImages if needed $statsModel->generateStatsImages(); $page = new AboutStatisticsPage(); $page->setModel($statsModel); return $page; case 'feedback': case 'contact': case 'contactus': case 'support': if (isset($keyword_2) && $keyword_2 == "submit") { return new FeedbackSentPage(); } $page = new FeedbackPage(); $page->model = new FeedbackModel(); return $page; case 'faq': case 'faqs': $model = new AboutModel(); $faq_categories = $model->getFaqsCategorized(); if ($faq_section = $model->getFaqSection($keyword_2)) { $page = new AboutFaqsectionPage(); $page->faq_section = $faq_section; $page->key = $keyword_2; } else { $page = new AboutFaqPage(); } $page->faq_categories = $faq_categories; return $page; case 'idea': case 'theidea': default: return new AboutTheideaPage(); } }
/** * The index function is called by /htdocs/index.php, * if your URL looks like this: http://[fqdn]/geo/... * ... and by this is the entry point to your application. * * @param void */ public function index() { $request = PRequest::get()->request; if (!isset($request[1])) { $request[1] = ''; } $matches = array(); switch ($request[1]) { case 'countries': // if your URL looks like this: http://[fqdn]/geo/countries ob_start(); $this->_view->displayCountries(); // delegates output to viewer class $Page = PVars::getObj('page'); $Page->content .= ob_get_contents(); ob_end_clean(); break; case 'selector': // for use as an alternative to the javascript geo-selection (popup) $page = new GeoPopupPage($request[1]); return $page; break; case 'displaylocation': // The purpose of this request is to display the content of a specific geoplace ob_start(); $this->_view->GeoDisplayLocation($request[2]); // delegates output to viewer class $Page = PVars::getObj('page'); $Page->content .= ob_get_contents(); ob_end_clean(); break; case 'suggestLocation': // ignore current request, so we can use the last request PRequest::ignoreCurrentRequest(); if (isset($_GET['s'])) { $request[2] = $_GET['s']; } if (!isset($request[3])) { PPHP::PExit(); } $type = false; //set the features that should be suggested (only cities or mountains and stuff as well) -- to be improved switch ($request[3]) { case 'blog': $fcode = $this->fcode_blog; break; case 'city': $fcode = $this->fcode_city; break; default: $fcode = $this->fcode_default; } $activities = false; if (isset($request[4]) && $request[4] == 'activities') { $activities = true; } // get locations from geonames. suggestLocation returns empty array // if nothing is found. if ($activities) { $locations = $this->_model->suggestLocation($request[2], 45, $fcode); } else { $locations = $this->_model->suggestLocation($request[2], 40, $fcode); } echo $this->_view->generateLocationOverview($locations, $activities); PPHP::PExit(); break; case 'refreshgeo': if ($_SERVER['REMOTE_ADDR'] !== '127.0.0.1') { header("Location: http://www.bewelcome.org"); exit(0); } ob_start(); if (MOD_geonames::get()->getUpdate() && MOD_geonames::get()->getAltnamesUpdate()) { ob_end_clean(); echo "success"; } else { ob_end_clean(); echo "failure"; } exit(0); case 'admin': $R = MOD_right::get(); if ($R->hasRight('Debug')) { $usageUpdate = $this->_model->updateGeoCounters(); $page = new GeoAdminPage($request[1]); return $page; } break; } }
function setBWMemberAsLoggedIn($m) { // Process the login of the member according to his status $member_id = (int) $m->id; unset($_SESSION['MemberStatus']); // For the case where it is set to empty unset($_SESSION['Status']); // For the case where it is set to empty if (!$m->Status) { die("Alarm : in setBWMemberAsLoggedIn with empty \$m->Status"); } else { $_SESSION['MemberStatus'] = $_SESSION['Status'] = $m->Status; } switch ($m->Status) { case "OutOfRemind": // in case an inactive member comes back $this->singleLookup("\r\nUPDATE members\r\nSET Status = 'Active'\r\nWHERE members.id = {$member_id} and Status='OutOfRemind'\r\n "); // the following is needed for MOD_log::get, // because otherwise it would not link the log with the right member $_SESSION['IdMember'] = $m->id; $_SESSION['MemberStatus'] = $_SESSION['Status'] = $m->Status = 'Active'; MOD_log::get()->write("Successful login, becoming active again (was OutOfRemind), with <b>" . $_SERVER['HTTP_USER_AGENT'] . "</b>", "Login"); break; case "Active": case "ActiveHidden": case "ChoiceInactive": // the following is needed for MOD_log::get, // because otherwise it would not link the log with the right member $_SESSION['IdMember'] = $m->id; MOD_log::get()->write("Successful login with <b>" . $_SERVER['HTTP_USER_AGENT'] . "</b> (" . $m->Username . ")", "Login"); break; case "ToComplete": // TODO: This case seems to be nonsense.. ? // TODO: Redirects are not the model's task! MOD_log::get()->write("Login with (tocomplete)<b>" . $_SERVER['HTTP_USER_AGENT'] . "</b>", "Login"); // FIXME: completeprofile.php does not exist - why used here? (steinwinde 2007-12-05) header("Location: " . PVars::getObj('env')->baseuri . "bw/completeprofile.php"); PPHP::PExit(); case "MailToConfirm": // I just add this here in case someone try to log with mail to confirm MOD_log::get()->write("Login with (MailToConfirm)<b>" . $_SERVER['HTTP_USER_AGENT'] . "</b>", "Login"); return false; break; case "NeedMore": $_SESSION['IdMember'] = $m->id; MOD_log::get()->write("Login with (needmore)<b>" . $_SERVER['HTTP_USER_AGENT'] . "</b>", "Login"); $this->_immediateRedirect = PVars::getObj('env')->baseuri . "bw/updatemandatory.php"; break; case "Banned": case "TakenOut": case "CompletedPending": case "SuspendedBeta": MOD_log::get()->write("Logging Refused because of status<b>" . $m->Status . "</b> <b>" . $_SERVER['HTTP_USER_AGENT'] . "</b>", "Login"); return false; break; case "Pending": $_SESSION['IdMember'] = $m->id; MOD_log::get()->write("Successful login (Pending State)with <b>" . $_SERVER['HTTP_USER_AGENT'] . "</b> (" . $m->Username . ")", "Login"); break; default: MOD_log::get()->write("Logging Refused because of unknown status<b>" . $m->Status . "</b> <b>" . $_SERVER['HTTP_USER_AGENT'] . "</b>", "Login"); return false; } return true; }
protected function index_loggedIn($args, $member_self) { $request = $args->request; $myself = true; $adminMember = false; $rights_self = $member_self->getOldRights(); if (in_array("SafetyTeam", array_keys($rights_self)) || in_array("Admin", array_keys($rights_self)) || in_array("Profile", array_keys($rights_self))) { $adminMember = true; } switch (isset($request[0]) ? $request[0] : false) { case 'setlocation': $page = new SetLocationPage(); break; case 'mypreferences': $page = new MyPreferencesPage(); break; case 'deleteprofile': $page = new DeleteProfilePage(); break; case 'editmyprofile': $page = new EditMyProfilePage(); // $member->edit_mode = true; if (isset($request[1])) { $this->model->set_profile_language($request[1]); } if (isset($request[2]) && $request[2] == 'delete') { $page = new DeleteTranslationPage(); } if (in_array('finish', $request)) { $page->status = "finish"; } break; case 'myvisitors': $member = $this->model->getLoggedInMember(); $showVisits = $member->getPreference('PreferenceShowProfileVisits', 'Yes'); if ($showVisits == 'Yes') { $page = new MyVisitorsPage(); } else { $this->redirect("members/" . $member->Username); } break; case 'self': case 'myself': $page = new ProfilePage(); break; case 'my': switch (isset($request[1]) ? $request[1] : false) { case 'preferences': $page = new MyPreferencesPage(); break; case 'visitors': $page = new MyVisitorsPage(); return; case 'messages': $this->redirect("messages/received"); return; case 'profile': default: $page = new ProfilePage(); } break; case 'flagcomment': if (isset($request[1]) && isset($request[2])) { $username = $request[1]; $commentId = $request[2]; if (isset($request[3])) { $commentPage = $request[3]; } else { $commentPage = $username; } $reportResult = $this->model->reportBadComment($username, $commentId); if ($reportResult) { $member = $this->model->getLoggedInMember(); $this->logWrite("{$member->Username} has reported" . " comment ID: {$commentId} on user {$username}" . " as problematic", 'comments'); $this->redirect('members/' . $commentPage . '/comments'); $notice = $this->getWords()->CommentReported; $this->setFlashNotice($notice); } else { $this->redirect(''); } } else { $this->redirect(''); } break; case 'people': case 'members': default: if (!isset($request[1])) { // no member specified $this->redirect("places"); } elseif ($request[1] == 'reportcomment') { if (isset($request[2]) && isset($request[3]) && $this->model->getLoggedInMember()) { $username = $request[2]; $commentId = $request[3]; $redirect = 'flagcomment/' . $username . '/' . $commentId; // Use profile the comment was left on if available // (needed to redirect user back to correct page) if (isset($request[4])) { $redirect .= '/' . $request[4]; } // Prepare feedback data $baseUri = PVars::getObj('env')->baseuri; $data = array(); $data['Admin comment'] = $baseUri . 'bw/admin/admincomments.php?IdComment=' . $commentId . '&action=All'; $data['Member comment page'] = $baseUri . 'members/' . $username . '/comments'; $dataEncoded = urlencode(serialize($data)); // Redirect $url = 'feedback?IdCategory=2&redirect=' . urlencode($redirect) . '&data=' . $dataEncoded; $this->redirect($url); } else { $this->redirect(''); } } else { if ($request[1] == 'avatar') { if (!isset($request[2]) || !($member = $this->getMember($request[2]))) { PPHP::PExit(); } PRequest::ignoreCurrentRequest(); $this->model->showAvatar($member->id); break; } else { if (!($member = $this->getMember($request[1]))) { // did not find such a member $page = new MembersMembernotfoundPage(); } else { //check if member can browse that profile if (!$member->isBrowsable() && !$adminMember) { $page = new MembersMembernotfoundPage(); break; } // found a member with given id or username $myself = false; if ($member->id == $member_self->id) { // user is watching her own profile $myself = true; } else { if ($logged_member = $this->model->getLoggedInMember() and $logged_member->isNotActiveHidden()) { $member->recordVisit($logged_member); } } switch (isset($request[2]) ? $request[2] : false) { case 'relations': if (isset($request[3])) { if ($request[3] == 'add') { if (!$myself) { $page = new AddRelationPage(); if (isset($request[4]) && $request[4] == 'finish') { $page->relation_wait = true; } } } elseif ($request[3] == 'delete') { // Make sure user is deleting their own relation and that ID is set if ($myself && isset($request[4])) { $id = intval($request[4]); if ($id > 0) { $deleteResult = $this->model->deleteRelation($id); if ($deleteResult) { $this->setFlashNotice($this->getWords()->Relation_deleted); } else { $this->setFlashError($this->getWords()->Relation_delete_error); } } else { $this->setFlashError($this->getWords()->Relation_delete_error); } } // Define redirect target // TODO: if there is a nicer way than using $_GET, please change this if ($_GET['redirect']) { $redirect = $_GET['redirect']; } else { // Redirect to relations page or homepage if (isset($_SESSION['Username'])) { $redirect = 'members/' . $_SESSION['Username'] . '/relations/'; } else { $redirect = ''; } } $this->redirect($redirect); return; } } // Default relations page if (!isset($page)) { $page = new RelationsPage(); } break; case 'comments': if (!$myself && isset($request[3]) && $request[3] == 'adminedit') { $page = new AddCommentPage(); $page->adminedit; } elseif (!$myself && isset($request[3]) && ($request[3] == 'add' || $request[3] == 'edit')) { $page = new AddCommentPage(); $page->commentGuidelinesRead = $this->model->getCommentGuidelinesRead(); } else { $page = new CommentsPage(); } break; case 'groups': $my_groups = $member->getGroups(); $params = new stdClass(); $params->strategy = new HalfPagePager('left'); $params->items = $my_groups; $params->items_per_page = 10; $pager = new PagerWidget($params); $page = new MemberGroupsPage(); $page->my_groups = $my_groups; $page->pager = $pager; break; case 'redesign': $page = new ProfileRedesignPage(); break; case 'adminedit': $rights = new MOD_right(); if ($rights->hasRight('Admin') || $rights->hasRight('SafetyTeam')) { $page = new EditMyProfilePage(); $page->adminedit = true; $page->statuses = $this->model->getStatuses(); // $member->edit_mode = true; if (isset($request[3]) && $request[3] == 'delete') { $page = new DeleteTranslationPage(); } if (in_array('finish', $request)) { $page->status = "finish"; } } else { $page = new MembersMembernotfoundPage(); } break; case 'profile': case '': case false: $hideProfile = !$myself && $member->Status == 'ChoiceInactive' && !$adminMember; if ($hideProfile) { $page = new InactiveProfilePage(); } else { $page = new ProfilePage(); $page->statuses = $this->model->getStatuses(); } break; default: $hideProfile = !$myself && $member->Status == 'ChoiceInactive' && !$adminMember; if ($hideProfile) { $page = new InactiveProfilePage(); } else { $page = new ProfilePage(); $this->model->set_profile_language($request[2]); $page->statuses = $this->model->getStatuses(); } break; } } } } } if (!isset($member)) { $page->member = $member_self; } else { if (is_object($member)) { $page->member = $member; } } if (!empty($myself)) { $page->myself = true; } $page->loggedInMember = $this->model->getLoggedInMember(); $page->model = $this->model; if ($page->member && $page->member->Status == 'PassedAway') { $page->passedAway = true; } else { $page->passedAway = false; } return $page; }
function redirect($url) { $redirect_url = PVars::getObj('env')->baseuri . $url; header("Location: " . $redirect_url); PPHP::PExit(); }
<?php /** * Check environment * * @package core * @author The myTravelbook Team <http://www.sourceforge.net/projects/mytravelbook> * @copyright Copyright (c) 2005-2006, myTravelbook Team * @license http://www.gnu.org/licenses/gpl.html GNU General Public License (GPL) * @version $Id: env_check.inc.php 122 2006-07-13 16:48:45Z kang $ */ // BW Rox needs the GD plugin if (!PPHP::assertExtension('gd')) { die('GD lib required!'); } // example call of requiring extension "xsl" //if (!PPHP::assertExtension('xsl')) // die('XSL required!');