public function create() { try { $profileId = UserHelper::getProfileId(); $msg = new Msg(); $msg->setSender($profileId); $msg->setContent(trim(fRequest::get('msg-content'))); $re = trim(fRequest::get('dest', 'integer')); $x = new Profile($re); $msg->setReceiver($re); if (strlen($msg->getContent()) < 1) { throw new fValidationException('信息长度不能少于1个字符'); } if (strlen($msg->getContent()) > 140) { throw new fValidationException('信息长度不能超过140个字符'); } $msg->store(); //Activity::fireNewTweet(); fMessaging::create('success', 'create msg', '留言成功!'); } catch (fNotFoundException $e) { fMessaging::create('failure', 'create msg', '该用户名不存在!'); } catch (fException $e) { fMessaging::create('failure', 'create msg', $e->getMessage()); } fURL::redirect(SITE_BASE . '/profile/' . $re . '/msgs'); }
function email_plugin_notify($check,$check_result,$subscription,$alt_email=false) { global $status_array; $user = new User($subscription->getUserId()); $email = new fEmail(); // This sets up fSMTP to connect to the gmail SMTP server // with a 5 second timeout. Gmail requires a secure connection. $smtp = new fSMTP(sys_var('smtp_server'), sys_var('smtp_port'), TRUE, 5); $smtp->authenticate(sys_var('smtp_user'), sys_var('smtp_pass')); if ($alt_email) { $email_address = usr_var('alt_email',$user->getUserId()); } else { $email_address = $user->getEmail(); } $email->addRecipient($email_address, $user->getUsername()); // Set who the email is from $email->setFromEmail(sys_var('email_from'), sys_var('email_from_display')); // Set the subject include UTF-8 curly quotes $email->setSubject(str_replace('{check_name}', $check->prepareName(), sys_var('email_subject'))); // Set the body to include a string containing UTF-8 $state = $status_array[$check_result->getStatus()]; $email->setHTMLBody("<p>$state Alert for {$check->prepareName()} </p><p>The check returned {$check_result->prepareValue()}</p><p>Warning Threshold is : ". $check->getWarn() . "</p><p>Error Threshold is : ". $check->getError() . '</p><p>View Alert Details : <a href="' . fURL::getDomain() . '/' . CheckResult::makeURL('list',$check_result) . '">'.$check->prepareName()."</a></p>"); $email->setBody(" $state Alert for {$check->prepareName()} The check returned {$check_result->prepareValue()} Warning Threshold is : ". $check->getWarn() . " Error Threshold is : ". $check->getError() . " "); try { $message_id = $email->send($smtp); } catch ( fConnectivityException $e) { fCore::debug("email send failed",FALSE); } }
function ensureLogin() { global $user; if (!isset($user)) { fURL::redirect("/login.php?forward={$_SERVER['REQUEST_URI']}"); } }
/** * Upload an image file for avatar */ public function upload() { try { if (self::isImage($_FILES['avatar-file']) && move_uploaded_file($_FILES['avatar-file']['tmp_name'], $this->uploadfile)) { fURL::redirect(SITE_BASE . '/avatar/edit'); } else { throw new fValidationException('上传图片失败'); } } catch (Exception $e) { fMessaging::create('failure', 'upload avatar', $e->getMessage()); fURL::redirect(SITE_BASE . '/profile/' . UserHelper::getProfileId()); } }
public function upload() { $uploadfile = UPLOAD_DIR . basename($_FILES['userfile']['name']); try { if (self::validFile($uploadfile) && move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) { fURL::redirect(SITE_BASE . '/manage'); } else { throw new fValidationException('上传失败'); } } catch (Exception $e) { fMessaging::create('failure', 'upload file', $e->getMessage()); fURL::redirect(SITE_BASE . '/manage'); } }
public function show($id) { $this->cache_control('private', 2); try { $this->record = new Record($id); if (!$this->record->isReadable()) { throw new fAuthorizationException('You are not allowed to read this record.'); } $this->nav_class = 'status'; $this->render('record/show'); } catch (fExpectedException $e) { fMessaging::create('warning', $e->getMessage()); fURL::redirect(Util::getReferer()); } catch (fUnexpectedException $e) { fMessaging::create('error', $e->getMessage()); fURL::redirect(Util::getReferer()); } }
public function reply($id) { try { $tweet = new Tweet($id); $comment = new TweetComment(); $comment->setTweetId($tweet->getId()); $comment->setProfileId(UserHelper::getProfileId()); $comment->setContent(trim(fRequest::get('tweet-comment'))); if (strlen($comment->getContent()) < 1) { throw new fValidationException('回复长度不能少于1个字符'); } if (strlen($comment->getContent()) > 140) { throw new fValidationException('回复长度不能超过140个字符'); } $comment->store(); } catch (fException $e) { // TODO } fURL::redirect(SITE_BASE . '/profile/' . $tweet->getProfileId() . '#tweet/' . $tweet->getId()); }
public function create() { try { $profileId = UserHelper::getProfileId(); $mail = new Mail(); $mail->setSender($profileId); $mail->setContent(trim(fRequest::get('mail-content'))); $re = trim(fRequest::get('dest')); if (empty($re)) { $re = trim(fRequest::get('destre', 'integer')); $pa = trim(fRequest::get('parent', 'integer', -1)); $x = new Profile($re); $mail->setReceiver($re); $mail->setParent($pa); } else { //$receiver=fRecordSet::build('Profile',array('login_name=' => $re ),array())->getRecord(0); $receiver = fRecordSet::build('Profile', array('login_name=' => $re), array()); if ($receiver->count()) { $receiver = $receiver->getRecord(0); } else { throw new fNotFoundException('user doesn\'t exist'); } $mail->setReceiver($receiver->getId()); } if (strlen($mail->getContent()) < 1) { throw new fValidationException('信息长度不能少于1个字符'); } if (strlen($mail->getContent()) > 140) { throw new fValidationException('信息长度不能超过140个字符'); } $mail->store(); //Activity::fireNewTweet(); fMessaging::create('success', 'create mail', '信息发送成功!'); } catch (fNotFoundException $e) { fMessaging::create('failure', 'create mail', '该用户名不存在,或该用户没有创建个人资料!'); } catch (fException $e) { fMessaging::create('failure', 'create mail', $e->getMessage()); } fURL::redirect(SITE_BASE . '/inbox'); }
public function show($id) { if (fAuthorization::checkLoggedIn()) { $this->cache_control('private', 30); } else { $this->cache_control('private', 60); } try { $this->problem = new Problem($id); if ($this->problem->isSecretNow()) { if (!User::can('view-any-problem')) { throw new fAuthorizationException('Problem is secret now.'); } } $this->nav_class = 'problems'; $this->render('problem/show'); } catch (fExpectedException $e) { fMessaging::create('warning', $e->getMessage()); fURL::redirect(Util::getReferer()); } catch (fUnexpectedException $e) { fMessaging::create('error', $e->getMessage()); fURL::redirect(Util::getReferer()); } }
<?php $title = 'Project Storage'; require './header.php'; $cards = fRecordSet::build('Card', array('uid=' => $_GET['cardid'])); if ($cards->count() == 0) { fURL::redirect("/kiosk/addcard.php?cardid=" . $_GET['cardid']); } $card = $cards->getRecord(0); $user = new User($card->getUserId()); $user->load(); if (isset($_POST['print'])) { $project = new Project($_POST['print']); $project->load(); if ($project->getUserId() != $user->getId()) { print "Incorrect project ID"; exit; } $data = array('storage_id' => $project->getId(), 'name' => $project->getName(), 'ownername' => $user->getFullName(), 'more_info' => $project->getDescription(), 'completion_date' => $project->getToDate()->format('Y/m/d'), 'max_extention' => "14"); $data_string = json_encode($data); $ch = curl_init('http://kiosk.london.hackspace.org.uk:12345/print/dnh'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($data_string))); $result = curl_exec($ch); curl_close($ch); echo "<p>Your sticker is being printed now.</p>"; } $projects = fRecordSet::build('Project', array('state_id!=' => array('6', '7'), 'user_id=' => $user->getId())); ?>
if ($newStatus != $project->getState() && $project->canTransitionStates($project->getState(), $newStatus)) { $project->setState($newStatus); $project->store(); if ($reason != '') { $reason = ' with the reason \'' . $reason . "'"; } // log the update $project->submitLog('Status changed to ' . $project->getState() . $reason, $user->getId()); if ($project->getState() != 'Archived') { // send to mailing list $project->submitMailingList('Status changed to ' . $project->getState() . $reason . " by " . htmlspecialchars($user->getFullName())); // inform the owner $project->submitEmailToOwner("Dear {$projectUser->getFullName()},<br/><br/>" . "This is an automatic email to let you know your project {$project->getName()} has been updated with status {$project->getState()}{$reason}.<br/><br/>" . "If you have any questions or concerns regarding this change you can discuss this with members on the <a href=\"{$project->getMailingListURL()}\">Mailing List</a>.<br/><br/>" . "Best,<br/>Monkeys in the machine"); } } fURL::redirect("/storage/list.php"); } catch (fValidationException $e) { echo $e->printMessage(); } catch (fSQLException $e) { echo '<div class="alert alert-danger">An unexpected error occurred, please try again later</div>'; } } ?> <?php if ($user->getId() == $project->getUserId() && ($project->getState() == 'Pending Approval' || $project->getState() == 'Unapproved')) { ?> <small class="edit_bttn"> <a href="/storage/edit/<?php echo $project->getId(); ?>
<meta property="og:title" content="Safecast" /> <meta property="og:type" content="website" /> <meta property="og:url" content="http://www.safecast.org" /> <meta property="og:image" content="http://www.safecast.org/images/logo.png" /> <meta property="og:site_name" content="Safecast" /> <meta property="fb:admins" content="595809984" /> <meta name="description" content="Safecast is a website that aggregates radioactivity data from throughout the world in order to provide real-time hyper-local information about the status of the Japanese nuclear crisis."> <meta name="keywords" content="japan,fukushima,radiation,nuclear,reactor,geiger,counter,RDTN,Safecast"> <title><?php echo $this->prepare('title'); echo strpos($this->get('title'), 'Safecast') === FALSE ? ' - Safecast' : ''; ?> </title> <base href="<?php echo fURL::getDomain() . URL_ROOT; ?> " /> <link rel="stylesheet" type="text/css" href="style/reset.css" media="screen" /> <!--<link rel="stylesheet" type="text/css" href="style/base.css" media="screen" />--> <?php echo $this->place('css'); ?> <script type="text/javascript" src="script/jquery-1.5.1.min.js"></script> <?php echo $this->place('js', 'js'); ?> <!--[if lte IE 8]><script language="javascript" type="text/javascript" src="excanvas.min.js"></script><![endif]--> <script type="text/javascript">
foreach ($subscriptions as $sub) { $user_id = $sub['user_id']; if (!in_array($user_id, $alt_ids) && $user_id != $id_user_session) { $user = new User($sub['user_id']); $recipients[] = array("mail" => $user->getEmail(), "name" => $user->getUsername()); } } if (!empty($recipients)) { // Send the mail to everybody notify_multiple_users($user_session, $recipients, $subject_mail, $content_mail); fMessaging::create('success', fURL::get(), 'The mail "' . $subject_mail . '" was successfully sent to all the users who subscribe to "' . $check->getName() . '"'); } else { fMessaging::create('error', fURL::get(), "Nobody subscribe to this check"); } } } } catch (fNotFoundException $e) { fMessaging::create('error', $manage_url, 'The check requested, ' . fHTML::encode($check_id) . ', could not be found'); fURL::redirect($manage_url); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } $page_num = fRequest::get('page', 'int', 1); $url_redirect = CheckResult::makeURL('list', $check) . "&page=" . $page_num; fURL::redirect($url_redirect); } else { $page_num = fRequest::get('page', 'int', 1); $check_results = CheckResult::findAll($check_id, false, $GLOBALS['PAGE_SIZE'], $page_num); include VIEW_PATH . '/list_check_results.php'; } }
<?php $tmpl->set('title', 'Log In'); $tmpl->set('no-nav', true); $tmpl->place('header'); ?> <form action="<?php echo fURL::get() . '?action=log_in'; ?> " method="post"> <div class="main" id="main"> <fieldset> <div class="clearfix"> <label for="username">Username</label> <div class="input"> <input id="username" type="text" name="username" value="<?php echo fRequest::get('username'); ?> " /> </div> </div><!-- /clearfix --> <div class="clearfix"> <label for="password">Password</label> <div class="input"> <input id="password" type="password" name="password" value="" /> </div> </div><!-- /clearfix --> <div class="actions"> <input class="btn" type="submit" value="Log In" /> <a class="btn" href="<?php echo User::makeUrl('add');
/** * Validates a request token generated by ::generateCSRFToken() * * This method takes a request token and ensures it is valid, otherwise * it will throw an fValidationException. * * @throws fValidationException When the CSRF token specified is invalid * * @param string $token The request token to validate * @param string $url The URL to validate the token for, default to the current page * @return void */ public static function validateCSRFToken($token, $url = NULL) { if ($url === NULL) { $url = fURL::get(); } $key = __CLASS__ . '::' . $url . '::csrf_tokens'; $tokens = fSession::get($key, array()); if (!in_array($token, $tokens)) { throw new fValidationException('The form submitted could not be validated as authentic, please try submitting it again'); } $tokens = array_diff($tokens, array($token)); fSession::set($key, $tokens); }
$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(); ?> " /> </div> </div><!-- /clearfix --> <div class="clearfix"> <label for="line-target">Target<em>*</em></label>
/** * Prints the links for a set of records * * @param string $template The template to use * @param array $data The extra data to make available to the template * @param integer $page The page of records being displayed * @param integer $per_page The number of records being displayed on each page * @param integer $total_records The total number of records * @return void */ private static function showTemplatedLinks($template, $data, $page, $per_page, $total_records) { if ($total_records <= $per_page) { return FALSE; } $total_pages = ceil($total_records / $per_page); self::printPiece($template, 'start', array_merge(array('page' => $page, 'total_pages' => $total_pages, 'first_record' => ($page - 1) * $per_page + 1, 'last_record' => min($page * $per_page, $total_records), 'total_records' => $total_records), $data)); if ($page > 1) { self::printPiece($template, 'prev', array_merge(array('page' => $page - 1, 'url' => fURL::replaceInQueryString('page', $page - 1)), $data)); } else { self::printPiece($template, 'prev_disabled', $data); } $size = self::$templates[$template]['size']; if (self::$templates[$template]['type'] == 'without_first_last') { $start_page = max(1, $page - $size); $end_page = min($total_pages, $page + $size); } else { $start_separator = TRUE; $start_page = $page - ($size - 2); if ($start_page <= 2) { $start_separator = FALSE; $start_page = 1; } $extra_end_pages = 0; if ($page <= $size) { $extra_end_pages = $size - $page + 1; } $end_separator = TRUE; $end_page = $page + ($size - 2); if ($end_page >= $total_pages - 1) { $end_separator = FALSE; $end_page = $total_pages; } $extra_start_pages = 0; if ($page > $total_pages - $size) { $extra_start_pages = $size - ($total_pages - $page); } $start_page -= $extra_start_pages; if ($start_page <= 3) { $start_separator = FALSE; $start_page = 1; } $end_page += $extra_end_pages; if ($end_page >= $total_pages - 2) { $end_separator = FALSE; $end_page = $total_pages; } } if (self::$templates[$template]['type'] == 'with_first_last' && $start_separator) { self::printPiece($template, 'page', array_merge(array('page' => 1, 'url' => fURL::replaceInQueryString('page', 1), 'first' => 'first', 'last' => '', 'current' => ''), $data)); self::printPiece($template, 'separator', $data); } for ($loop_page = $start_page; $loop_page <= $end_page; $loop_page++) { self::printPiece($template, 'page', array_merge(array('page' => $loop_page, 'url' => fURL::replaceInQueryString('page', $loop_page), 'first' => $loop_page == 1 ? 'first' : '', 'last' => $loop_page == $total_pages ? 'last' : '', 'current' => $loop_page == $page ? 'current' : ''), $data)); } if (self::$templates[$template]['type'] == 'with_first_last' && $end_separator) { self::printPiece($template, 'separator', $data); self::printPiece($template, 'page', array_merge(array('page' => $total_pages, 'url' => fURL::replaceInQueryString('page', $total_pages), 'first' => '', 'last' => 'last', 'current' => ''), $data)); } if ($page < $total_pages) { self::printPiece($template, 'next', array_merge(array('page' => $page + 1, 'url' => fURL::replaceInQueryString('page', $page + 1)), $data)); } else { self::printPiece($template, 'next_disabled', $data); } self::printPiece($template, 'end', array_merge(array('page' => $page, 'total_pages' => $total_pages, 'first_record' => ($page - 1) * $per_page + 1, 'last_record' => min($page * $per_page, $total_records), 'total_records' => $total_records), $data)); return TRUE; }
/** * Can be used to convert strings such as textual labels into simpler strings suitable for use as an HTML statement's id. **/ public static function _simplify($name) { //$o = wire()->sanitizer->pageName($name, true); $o = fURL::makeFriendly($name); return strtr($o, array('[]' => '', '-' => '_')); }
</div> </div> <?php } ?> <div class="container-fluid"> <?php $breadcrumbs = $this->get('breadcrumbs'); if (is_array($breadcrumbs)) { echo '<ul class="breadcrumb">'; $crumb_count = count($breadcrumbs); $crumb_counter = 1; foreach ($breadcrumbs as $crumb) { echo '<li' . (isset($crumb['class']) ? ' class="' . $crumb['class'] . '"' : ' class="active"') . '><a href="' . $crumb['url'] . '">' . $crumb['name'] . '</a>'; if ($crumb_counter < $crumb_count) { echo '<span class="divider">/</span></li>'; } $crumb_counter++; } echo '</ul>'; } if (fMessaging::check('error', fURL::get())) { echo '<div class="alert-message error">'; fMessaging::show('error', fURL::get()); echo '</div>'; } if (fMessaging::check('success', fURL::get())) { echo '<div class="alert-message success">'; fMessaging::show('success', fURL::get()); echo '</div>'; }
$page = 'cards'; $title = 'Add card'; $desc = ''; require '../header.php'; if (!isset($user)) { fURL::redirect('/login.php?forward=/members/cards.php'); } if (isset($_POST['submit'])) { try { fRequest::validateCSRFToken($_POST['token']); $card = new Card(); $card->setUserId($user->getId()); $card->setAddedDate(time()); $card->setUid($_POST['uid']); $card->store(); fURL::redirect('/members/cards.php'); exit; } catch (fValidationException $e) { echo "<p>" . $e->printMessage() . "</p>"; } catch (fSQLException $e) { echo "<p>An unexpected error occurred, please try again later</p>"; trigger_error($e); } } ?> <h2>Add card</h2> <form method="POST"> <input type="hidden" name="token" value="<?php echo fRequest::generateCSRFToken(); ?>
// Get list of models $models = Model::getSimple($db); // Get types if (feature('consumable_types')) { $types = Tag::get_by_type('consumable_type'); } include 'views/consumables/addedit.php'; } /** * Delete a consumable */ if ($action == 'delete') { // Get ID $id = fRequest::get('id', 'integer'); try { $c = new Consumable($id); if (fRequest::isPost()) { $c->delete(); fMessaging::create('success', fURL::get(), 'The consumable ' . $c->getName() . ' was successfully deleted.'); fURL::redirect(fURL::get()); } } catch (fNotFoundException $e) { fMessaging::create('error', fURL::get(), 'The consumable requested, ID ' . $id . ', could not be found.'); fURL::redirect($manage_url); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } catch (fSQLException $e) { fMessaging::create('error', fURL::get(), 'Database error: ' . $e->getMessage()); } include 'views/consumables/delete.php'; }
$tmpl->set('title', 'Self Service Alerts based on Graphite metrics'); $active_tab_alerts = " class=active"; $tmpl->set('breadcrumbs', $breadcrumbs); $tmpl->place('header'); ?> <script type="text/javascript"> $(function(){ $('#list_of_filters').change(function(){ $(location).attr('href',$('#list_of_filters').val()); }); }); </script> <?php try { $checks->tossIfEmpty(); $affected = fMessaging::retrieve('affected', fURL::get()); ?> <script type="text/javascript"> function filterChecks() { var filter_text = $("#filter_text").val(); var type = '<?php echo $check_type; ?> '; var filter_group_id = <?php echo $filter_group_id; ?> ; $.get( 'inc/views/list_filtered_checks.php',
<?php $page = 'members'; require '../header.php'; if (!$user) { fURL::redirect('/login.php?forward=/members'); } ?> <h2>Members Area</h2> <?php if ($user->getAddress() == '') { ?> <h4>More Details Required</h4> <p>UK Law requires that we store our members' real name and address. Since you haven't provided these details you will be unable to gain membership privileges until you do.</p> <p>Please <a href="/members/edit.php">provide your details</a> to continue.</p> <?php } else { if ($user->isMember()) { ?> <p>You're currently a member of London Hackspace, thanks for your support!</p> <h3>Your Recent Payments</h3> <table> <tr> <th>Date</th> <th>Amount</th> </tr>
$validator->addEmailFields('email'); $validator->validate(); if ($_POST['newpassword'] != '') { if ($_POST['newpassword'] != $_POST['newpasswordconfirm']) { throw new fValidationException('Passwords do not match'); } $user->setPassword(fCryptography::hashPassword($_POST['newpassword'])); } $user->setEmail(strtolower(trim($_POST['email']))); $user->setFullName(trim($_POST['fullname'])); $user->setAddress(trim($_POST['address'])); $user->setSubscriptionPeriod($_POST['length']); $user->setEmergencyName(trim($_POST['emergency_name'])); $user->setEmergencyPhone(trim($_POST['emergency_phone'])); $user->store(); fURL::redirect('?saved'); exit; } catch (fValidationException $e) { echo "<p>" . $e->printMessage() . "</p>"; } catch (fSQLException $e) { echo "<p>An unexpected error occurred, please try again later</p>"; trigger_error($e); } } if (isset($_GET['saved'])) { echo "<div class=\"alert alert-success\"><p>Details saved.</p></div>"; } ?> <p><a href="http://www.legislation.gov.uk/ukpga/2006/46/part/8/chapter/2/crossheading/general">UK law</a> requires us to store the full name and address of all our members. If you don't provide these details, you won't receive membership privileges.</p>
/** * 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'; }
public function testMakeFriendlyOmitMaxLength() { $this->assertEquals('tests-of-dashes-and-under_scores', fURL::makeFriendly('tests of dashes - and under_scores', '-')); }
try { if (method_exists($results, 'tossIfNoRows')) { $results->tossIfNoRows(); } else { throw new fNoRowsException(); } ?> <?php //check to see if paging is needed $total_pages = ceil($alert_count / $GLOBALS['PAGE_SIZE']); if ($total_pages > 1) { $prev_class = 'previous'; $prev_link = fURL::replaceInQueryString('page', $page_num - 1); $next_class = 'next'; $next_link = fURL::replaceInQueryString('page', $page_num + 1); if ($page_num == 1) { $prev_class .= ' disabled'; $prev_link = '#'; } elseif ($page_num == $total_pages) { $next_class .= ' disabled'; $next_link = '#'; } ?> </tbody></table> <div class="pagination"> <ul class="pager"> <li class="<?php echo $prev_class; ?> ">
try { $user->populate(); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e - getMessage()); } } include VIEW_PATH . '/add_edit_user_settings.php'; } elseif ('delete' == $action) { try { $user = new User($user_id); if (fRequest::isPost()) { fRequest::validateCSRFToken(fRequest::get('token')); $user->delete(); fMessaging::create('success', User::makeUrl('edit', $user), 'The user ' . $user->getName() . ' was successfully deleted'); fURL::redirect(User::makeUrl('edit', $user)); } } catch (fNotFoundException $e) { fMessaging::create('error', User::makeUrl('edit', $user), 'The line requested could not be found'); fURL::redirect(User::makeUrl('edit', $user)); } catch (fExpectedException $e) { fMessaging::create('error', fURL::get(), $e->getMessage()); } include VIEW_PATH . '/delete.php'; } else { if (!fAuthorization::checkAuthLevel('admin')) { fURL::redirect(User::makeURL('edit', fSession::get('user_id'))); } else { $users = User::findAll(); include VIEW_PATH . '/list_users.php'; } }
<?php include './resources/init.php'; fURL::redirect("authentication.php");
if ($users->count() == 0) { throw new fValidationException('Invalid username or password.'); } $rec = $users->getRecords(); $user = $rec[0]; if (!fCryptography::checkPasswordHash($_POST['password'], $user->getPassword())) { throw new fValidationException('Invalid username or password.'); } fSession::set('user', $user->getId()); if (fRequest::get('persistent_login', 'boolean')) { fSession::enablePersistence(); } if (isset($_POST['forward'])) { fURL::redirect('http://' . $_SERVER['SERVER_NAME'] . $_POST['forward']); } else { fURL::redirect('/members'); } exit; } catch (fValidationException $e) { echo "<p>" . $e->printMessage() . "</p>"; } catch (fSQLException $e) { echo "<p>An unexpected error occurred, please try again later</p>"; trigger_error($e); } } ?> <h2>Log In</h2> <form method="post"> <input type="hidden" name="token" value="<?php echo fRequest::generateCSRFToken(); ?>