function home_route() { if (is_authenticated()) { return profile_route(); } return base_url(); }
function ensure_authenticated() { if (!is_authenticated()) { $CI =& get_instance(); $CI->session->set_flashdata('status', 'You are not allowed to view the page. Please login.'); // returns immediatly redirect(login_route()); } }
/** * skin_getName() -- Return the name of the currently-selected skin * (defaults to DEFAULT_SKIN) */ function skin_getName() { global $cache_skin; global $auth_user; /* Step 1: check cache */ if ('' != $cache_skin) { return $cache_skin; } /* Step 2: Get requested value from config sources */ $skin_name = config_getValue("skin"); /* Step 3: If not in config sources, check authenticated user prefs */ if (is_authenticated() && $skin_name == 'default') { $skin_name = $auth_user->skin; } /* Step 4: Validate */ if (FALSE == file_exists("skins/" . $skin_name . "/default.css") || $skin_name == 'default') { $skin_name = DEFAULT_SKIN; } $cache_skin = $skin_name; return $skin_name; }
<?php defined('CSEPHPBLOG') or die('You cannot execute this script.'); $template->set('title', 'Logout - CSE 294 PHP Blog Demo'); if (is_authenticated()) { session_destroy(); redirect('logout'); }
<?php } require_once './include/display_listrequest.php'; //AB print_requestid_form(); } else { display_errorbox("Unable to send blast e-mail."); print_verify_form(VERIFY_TYPE_APPROVE, $fm_sessionid, $fm_requestid, $fm_notes, $fm_initials); } // send e-mail to requesters } } } } else { if ($fm_stage == "reject") { if (!is_authenticated()) { display_errorbox("You are not authenticated; please log in."); print_review_login_form(); } else { if (empty($fm_notes)) { display_errorbox("One or more reasons for rejecting the message must be provided."); print_verify_form(VERIFY_TYPE_REJECT, $fm_sessionid, $fm_requestid); } else { $dbh = open_db(); //db_update_request_status($dbh, $fm_requestid, "REJECTED", $fm_notes); db_update_request_status_user($dbh, $fm_requestid, "REJECTED", $fm_notes, $_SESSION['username']); $reqinfo = db_load_request($dbh, $fm_requestid); $requserinfo = db_get_user($dbh, $reqinfo['requester']); $revuserinfo = db_get_user($dbh, $reqinfo['reviewer']); if (send_rejection_to_requester($reqinfo, $revuserinfo, $requserinfo) == true) { //echo "<p>Sent notice of rejection to requester.</p>";
/** * Check for admin permissions. Currently this is only the user * <em>admin</em>, ID 1. * @return boolean true if admin user, else false */ function is_admin() { global $app; if (is_authenticated()) { $user = $app->auth->getUserData(); return $user['role'] === '1'; } else { return false; } }
/** * Logs a user into the system * * @param string $username * @param string $password * @return bool */ function login($username, $password) { if (is_authenticated()) { return TRUE; } if ($username == AUTH_USERNAME and sha1($password) == AUTH_PASSWORD) { return $_SESSION['logged_in'] = TRUE; } return FALSE; }
<?php require_once 'inc/config.php'; require_once INC_PATH . 'functions.php'; if ($_POST && $_POST[LOGIN_FORM_USER] && $_POST[LOGIN_FORM_PASS]) { $user = $_POST[LOGIN_FORM_USER]; $pass = $_POST[LOGIN_FORM_PASS]; //authenticate if (is_authenticated($user, $pass)) { //save in session save_auth($user); //redirect header(LOGGED_IN_HOME_URL); die; } else { $form_errors = "Invalid username or password"; } } //invalidate session destroy_session(); //show login form include VIEWS_PATH . 'header.php'; include VIEWS_PATH . 'login-form.php'; include VIEWS_PATH . 'footer.php';
function emit() { /* If there's a link, wrap it */ if (null != $this->url) { print '<a '; print ' class="story-link" '; print ' href="' . $this->url . '" '; if (null != $this->alt) { print ' title="' . $this->alt . '" '; } print '>'; } /* Switch on type */ switch ($this->type) { case STORY_CHUNK_HEADLINE: print '<h1 '; print ' class="story-headline" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print '>' . $this->value . '</h1>'; break; case STORY_CHUNK_SECTION: print '<div class="closure_div"></div>'; print '<h2 '; print ' class="story-headline" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print '>' . $this->value . '</h2>'; break; case STORY_CHUNK_GROUP: print '<div class="closure_div"></div>'; print '<h3 '; print ' class="story-headline" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print '>' . $this->value . '</h3>'; break; case STORY_CHUNK_SUBGROUP: print '<h4 '; print ' class="story-headline" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print '>' . $this->value . '</h4>'; break; case STORY_CHUNK_LEDE: print '<img '; print ' class="story-lede" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } if (null != $this->alt) { print ' alt="' . $this->alt . '" '; } print ' src="' . $this->value . '" '; print '/>'; break; case STORY_CHUNK_BANNER: print '<img '; print ' class="story-banner" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } if (null != $this->alt) { print ' alt="' . $this->alt . '" '; } print ' src="' . $this->value . '" '; print '/>'; break; case STORY_CHUNK_TEXT: print '<span '; print ' class="story-span" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print ">\n"; print $this->value; print "\n</span>"; break; case STORY_CHUNK_ERROR: print '<span '; print ' class="story-error" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print ">\n"; print $this->value; print "\n</span>"; break; case STORY_CHUNK_WARNING: print '<span '; print ' class="story-warning" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print ">\n"; print $this->value; print "\n</span>"; break; case STORY_CHUNK_META: print '<span '; print ' class="story-meta" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print ">\n"; print $this->value; print "\n</span>"; break; case STORY_CHUNK_FILE: /* If the user is logged in, add an editor button */ if (is_authenticated() && is_editor()) { print '<a '; print ' href="/edit-story-file.php?file=' . $this->value . '" '; print ' class="story-trail" '; print ' title="Edit this text" '; print '>'; skin_img("edit_icon.png", "Edit this text", "story-trail"); print '</a>'; } print '<span '; print ' class="story-span" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print ">\n"; /* Verify that we can read it */ if (!is_readable($this->value)) { print "[[I can't import text from \"" . $this->value . "\", because I can't find it (or can't read it). Sorry 'bout that.]]"; } else { @(include $this->value); } print "\n</span>"; break; case STORY_CHUNK_OBJECT: print '<div '; print ' class="story-object" '; if (null != $this->id) { print ' id="' . $this->id . '" '; } print '>'; $this->object->emit(); print '</div>'; } /* Finish the link (if any) */ if (null != $this->url) { print "</a>"; } /* Add the newline */ print "\n"; }