/** * Indicates if a reset was requested for search values * * @return boolean If a reset was requested */ private static function wasResetRequested() { $tail = substr(fURL::getWithQueryString(), -6); return $tail == '?reset' || $tail == '&reset'; }
<? $page_title = ($action == 'add' ? 'Add a Line' : 'Edit Line'); $tmpl->set('title', $page_title); $breadcrumbs[] = array('name' => 'Dashboard', 'url' => Dashboard::makeURL('list'),'active' => false); //$breadcrumbs[] = array('name' => 'Edit Dashboard', 'url' => Dashboard::makeURL('edit',$graph),'active' => false); $breadcrumbs[] = array('name' => $graph->prepareName(), 'url' => Graph::makeURL('edit',$graph),'active'=> false); $breadcrumbs[] = array('name' => $page_title, 'url' => fURL::getWithQueryString(),'active'=> true); $tmpl->set('breadcrumbs',$breadcrumbs); $tmpl->place('header'); if (isset($line_id)) { $query_string = "&line_id=$line_id"; } elseif (isset($graph_id)) { $query_string = "&graph_id=$graph_id"; } else { $query_string = ''; } ?> <div class="row"> <div class="span6"> <form action="<?php echo fURL::get(); ?> ?action=<? echo $action.$query_string; ?>" method="post"> <div class="main" id="main"> <fieldset> <div class="clearfix"> <label for="line-alias">Alias<em>*</em></label> <div class="input"> <input id="line-alias" class="span3" type="text" size="30" name="alias" value="<?php echo $line->encodeAlias(); ?>
?> </head> <body> <?php if (!$this->get('full_screen')) { ?> <div class="topbar"> <div class="topbar-inner"> <div class="container-fluid"> <a class="brand" href="index.php">Tattle </a> <ul class="nav"> <? $current_url = fURL::getWithQueryString(); echo '<li' . ($current_url == '' ? ' class="active"' : '') . '><a href="index.php">Alerts</a></li>'. "\n"; $check_list = Check::makeURL('list'); echo '<li' . ($current_url == $check_list ? ' class="active"' : '') . '><a href="' . $check_list . '" >Checks</a></li>' . "\n"; $subscription_list = Subscription::makeURL('list'); echo '<li' . ($current_url == $subscription_list ? ' class="active"' : '') .'><a href="' . $subscription_list . '" >Subscriptions</a></li>' . "\n"; $dashboard_list = Dashboard::makeURL('list'); echo '<li' . ($current_url == $dashboard_list ? ' class="active"' : '') . '><a href="' . $dashboard_list . '">Dashboards</a></li>'; $setting_list = Setting::makeURL('list'); echo '<li' . ($current_url == $setting_list ? ' class="active"' : '') . '><a href="' . $setting_list . '" >Settings</a></li>' . "\n"; if (fAuthorization::checkAuthLevel('admin')) { $user_list = User::makeURL('list'); echo '<li><a href="' . User::makeURL('list') . '" >Users</a></li>'; } ?> </ul>
$action = fRequest::getValid('action', array('list', 'add', 'edit', 'delete', 'view')); $dashboard_id = fRequest::get('dashboard_id', 'integer?'); $graph_id = fRequest::get('graph_id', 'integer?'); $manage_url = $_SERVER['SCRIPT_NAME']; // --------------------------------- // if ('edit' == $action) { try { $graph = new Graph($graph_id); $dashboard = new Dashboard($graph->getDashboardId()); $lines = Line::findAll($graph_id); if (fRequest::isPost()) { $graph->populate(); fRequest::validateCSRFToken(fRequest::get('token')); $graph->store(); fMessaging::create('affected', fURL::get(), $graph->getName()); fMessaging::create('success', fURL::getWithQueryString(), 'The Graph ' . $graph->getName() . ' was successfully updated'); fURL::redirect(Dashboard::makeUrl('edit', $dashboard)); } } catch (fNotFoundException $e) { fMessaging::create('error', $manage_url, 'The Graph requested, ' . fHTML::encode($graph_id) . ', could not be found'); fURL::redirect($manage_url); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/add_edit_graph.php'; // --------------------------------- // } elseif ('add' == $action) { $graph = new Graph(); $dashboard = new Dashboard($dashboard_id); if (fRequest::isPost()) { try {
/** * Redirects the user to the login page * * @return void */ private static function redirect() { self::setRequestedURL(fURL::getWithQueryString()); fURL::redirect(self::$login_page); }
/** * For example: /path?param=value /path/ * @return string */ protected function getCurrentUrl() { return fURL::getWithQueryString(); }
fURL::redirect(Graph::makeUrl('edit', $graph)); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/delete.php'; // --------------------------------- // } elseif ('edit' == $action) { try { $line = new Line($line_id); $graph = new Graph($line->getGraphId()); if (fRequest::isPost()) { $line->populate(); fRequest::validateCSRFToken(fRequest::get('token')); $line->store(); fMessaging::create('affected', fURL::get(), $graph->getName()); fMessaging::create('success', fURL::getWithQueryString(), 'The Line ' . $line->getAlias() . ' was successfully updated'); } } catch (fNotFoundException $e) { fMessaging::create('error', Graph::makeUrl('edit', $graph), 'The Line requested, ' . fHTML::encode($line_id) . ', could not be found'); fURL::redirect(Graph::makeUrl('edit', $graph)); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/add_edit_line.php'; // --------------------------------- // } elseif ('add' == $action) { $line = new Line(); $graph = new Graph($graph_id); if (fRequest::isPost()) { try { $line->populate();
$over_under_array = array('0' => 'Over', '1' => 'Under'); $breadcrumbs = array(); $breadcrumbs[] = array('name' => 'Home', 'url' => '#', 'active' => false); error_reporting(E_STRICT | E_ALL); fCore::enableErrorHandling('html'); fCore::enableExceptionHandling('html'); fTimestamp::setDefaultTimezone($GLOBALS['TIMEZONE']); fAuthorization::setLoginPage(User::makeURL('login')); fAuthorization::setAuthLevels(array('admin' => 100, 'user' => 50, 'guest' => 25)); // This prevents cross-site session transfer fSession::setPath($GLOBALS['SESSION_FILES']); if (!fAuthorization::checkLoggedIn()) { if ($GLOBALS['ALLOW_HTTP_AUTH'] && (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW']))) { unset($_SERVER['PHP_AUTH_PW']); //no need for a clear text password hanging around. try { $user = new User(array('username' => $_SERVER['PHP_AUTH_USER'])); // Auto Register User fAuthorization::setUserToken($user->getEmail()); fAuthorization::setUserAuthLevel($user->getRole()); fSession::set('user_id', $user->getUserId()); fSession::set('user_name', $user->getUsername()); } catch (fNotFoundException $e) { if (fURL::getWithQueryString() != TATTLE_WEB_ROOT . User::makeURL('add')) { fMessaging::create('affected', User::makeURL('add'), $_SERVER['PHP_AUTH_USER']); fMessaging::create('success', User::makeURL('add'), 'The user ' . $_SERVER['PHP_AUTH_USER'] . ' was successfully created'); fURL::redirect(User::makeURL('add')); } } } }
/** * Redirects the user to the login page * * @return void */ private static function redirect() { fSession::set('requested_url', fURL::getWithQueryString(), __CLASS__ . '::'); fURL::redirect(self::$login_page); }
<?php $tmpl->set('title', $action == 'add' ? 'Add a User' : 'Edit User'); $tmpl->place('header'); ?> <div class="row"> <div class="span6"> <form action="<?=fURL::getWithQueryString(); ?>" method="post"> <div class="main" id="main"> <fieldset> <div class="clearfix"> <label for="user-username">User Name<em>*</em></label> <div class="input"> <? if ($GLOBALS['ALLOW_HTTP_AUTH']) { echo $_SERVER['PHP_AUTH_USER']; ?> <input id="user-username" class="span3" type="hidden" name="username" value="<?=$_SERVER['PHP_AUTH_USER']; ?>"> <? } else { ?> <input id="user-username" class="span3" type="text" size="30" name="username" value="<?=$user->encodeUsername(); ?>" /> <? } ?> </div> </div><!-- /clearfix --> <div class="clearfix"> <label for="user-email">Email<em>*</em></label> <div class="input"> <input id="user-email" class="span3" type="text" size="30" name="email" value="<?=$user->encodeEmail(); ?>" /> </div> </div><!-- /clearfix --> <? if (!$GLOBALS['ALLOW_HTTP_AUTH'] || ($user->getUserId() == 1)) { ?> <div class="clearfix"> <label for="user-password">Password<em>*</em></label> <div class="input"> <input id="user-password" class="span3" type="password" size="30" name="password" value="" />