コード例 #1
1
ファイル: session.php プロジェクト: r0the/paedawan
function userName()
{
    if (isLoggedIn()) {
        return $_SESSION['username'];
    } else {
        return '';
    }
}
コード例 #2
0
ファイル: Index.php プロジェクト: chiiiro/SSP-TwitterApp
 /**
  * Function renders main page and implements user login behaviour.
  * If user is already logged in, he will be redirected to his twitter wall.
  * If user doesn't exist or entered data is wrong, warning message will show.
  */
 public function action()
 {
     if (isLoggedIn()) {
         redirect(\route\Route::get("twitterWall")->generate(array("id" => UserRepository::getIdByUsername($_SESSION['username']))));
     }
     $main = new Main();
     $main->setPageTitle("Twitter App");
     $body = new \templates\Index();
     $main->setBody($body);
     echo $main;
     if (UserRepository::isLoggedIn()) {
         redirect(\route\Route::get("twitterWall")->generate());
     }
     if (post('login')) {
         $username = htmlentities(trim(post('username')));
         $password = htmlentities(trim(post('password')));
         $hashedPassword = hash_password($password);
         if (UserRepository::login($username, $hashedPassword)) {
             redirect(\route\Route::get("twitterWall")->generate(array("id" => UserRepository::getIdByUsername($_SESSION['username']))));
             exit;
         } else {
             ?>
             <script src="assets/js/loginError.js"></script>
             <?php 
         }
     }
 }
コード例 #3
0
function redirect($page)
{
    $currentPage = basename($_SERVER['PHP_SELF']);
    // prevent redirecting away from graphs.php when $.post is accessing
    if ($currentPage == 'graphs.php' || $currentPage == 'verify.php') {
        if ($_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest') {
            header('Location: /fp2.0/');
            exit;
        }
    } else {
        if ($currentPage != $page) {
            if ($page == 'index.php') {
                $page = '';
            }
            // make sure index.php is not included so that the url is shorter
            if (!isLoggedIn()) {
                header("Location: login.php");
                exit;
            } else {
                if ($currentPage != 'monthlyReport.php' && $currentPage != 'settings.php') {
                    header("Location: /fp2.0/" . $page);
                    exit;
                }
            }
        }
    }
}
コード例 #4
0
ファイル: user_cookie.php プロジェクト: redroot/URIKA
 function handleCookies()
 {
     // if no session lets check for cookies
     if (!isLoggedIn()) {
         if (isset($_COOKIE["urika_userlogin"]) == true && isset($_COOKIE["urika_login_tried"]) == false) {
             $CI =& get_instance();
             $CI->load->model("user_model");
             $query = $CI->user_model->getUser($_COOKIE["urika_userlogin"], "u_username");
             if ($query) {
                 // now verify secret before creating session
                 $row = $query->row();
                 if (isset($_COOKIE["urika_usersecret"]) && md5($row->u_username . $row->u_password) == $_COOKIE["urika_usersecret"]) {
                     // win lets make a session
                     $data = array('username' => $row->u_username, 'user_id' => $row->user_id, 'is_logged_in' => true, 'image_url' => getUserProfileURL($row->u_profile_id, $row->u_email));
                     $CI->session->set_userdata($data);
                 } else {
                     // no luck
                     setcookie("urika_login_tried", $_COOKIE["urika_userlogin"]);
                 }
             } else {
                 // no match, so et a cookie so we don't try over and over again
                 setcookie("urika_login_tried", $_COOKIE["urika_userlogin"]);
             }
         }
     }
 }
コード例 #5
0
ファイル: userFunctions.php プロジェクト: Tourepedia/v1.1
function logout()
{
    if (isLoggedIn()) {
        unset($_SESSION['user']);
    }
    return true;
}
コード例 #6
0
ファイル: treasure.php プロジェクト: robertmain/Treasure-Hunt
 public function find()
 {
     if (!$this->uri->segment(3)) {
         show_404(current_url(), FALSE);
     } else {
         if ($this->data['Treasure'] = $this->treasure_model->get_by('md5', $this->uri->segment(3))) {
             if (isFound($this->data['Treasure']->id, $this->session->userdata('id'))) {
                 $found = TRUE;
             } else {
                 $found = FALSE;
                 if (isLoggedIn()) {
                     if (!isBanned($this->session->userdata('id'))) {
                         if (!isAdmin()) {
                             $this->mytreasure_model->insert(array('pirate' => $this->session->userdata('id'), 'treasure' => $this->data['Treasure']->id, 'time' => time()));
                         }
                     }
                 }
             }
             $this->data['found'] = $found;
             $this->template->write_view('content', 'views/treasure/find', $this->data);
             $this->template->render();
         } else {
             show_404(current_url(), FALSE);
         }
     }
 }
コード例 #7
0
ファイル: helpers.php プロジェクト: AshniSukhoo/blog
 /**
  * Returns the current logged in user
  *
  * @return array|null
  */
 function loggedin_user()
 {
     //User is not lgged in
     if (!isLoggedIn()) {
         //we return null
         return null;
     }
     //Check if we have user id
     if (!isset($_SESSION['user_id']) || $_SESSION['user_id'] == '' || $_SESSION['user_id'] == null) {
         //Return null
         return null;
     }
     //Create new user object
     $user = new App\Models\User();
     //Get user id
     $user_id = $_SESSION['user_id'];
     //Get the user
     $results = $user->query("SELECT * FROM users WHERE id = '" . $user_id . "'");
     //We got the results
     if ($results != false) {
         //Return the current user row
         return $results[0];
     } else {
         //No user found
         //return null
         return null;
     }
 }
コード例 #8
0
ファイル: functions.php プロジェクト: chiiiro/SSP-TwitterApp
/**
 * Vraca korisnicko ime ako je korisnik ulogiran.
 */
function getUsername()
{
    if (isLoggedIn()) {
        return $_SESSION["username"];
    }
    return null;
}
コード例 #9
0
 function index($info = "")
 {
     $menuList[] = array('id' => 1, 'name' => $this->spTextPanel['Website Manager'], 'url_section' => 'websites');
     if (isAdmin()) {
         $menuList[] = array('id' => 2, 'name' => $this->spTextPanel['User Manager'], 'url_section' => 'users');
     }
     if (isLoggedIn()) {
         $menuList[] = array('id' => 3, 'name' => $this->spTextPanel['Reports Manager'], 'url_section' => 'report-manager');
     }
     if (isAdmin()) {
         $menuList[] = array('id' => 4, 'name' => $this->spTextPanel['Seo Tools Manager'], 'url_section' => 'seo-tools-manager');
         $menuList[] = array('id' => 5, 'name' => $this->spTextPanel['Seo Plugins Manager'], 'url_section' => 'seo-plugin-manager');
         $menuList[] = array('id' => 6, 'name' => $this->spTextPanel['Directory Manager'], 'url_section' => 'directory-manager');
         $menuList[] = array('id' => 11, 'name' => $this->spTextPanel['Search Engine Manager'], 'url_section' => 'se-manager');
         $menuList[] = array('id' => 9, 'name' => $this->spTextPanel['Proxy Manager'], 'url_section' => 'proxy-manager');
         $menuList[] = array('id' => 7, 'name' => $this->spTextPanel['System Settings'], 'url_section' => 'settings');
     }
     $menuList[] = array('id' => 8, 'name' => $this->spTextPanel['My Profile'], 'url_section' => 'my-profile');
     $menuList[] = array('id' => 10, 'name' => $this->spTextPanel['About Us'], 'url_section' => 'about-us');
     $menuSelected = empty($info['menu_selected']) ? 'websites' : urldecode($info['menu_selected']);
     $this->set('menuList', $menuList);
     $this->set('menuSelected', $menuSelected);
     $startScript = empty($info['start_script']) ? "websites.php" : urldecode($info['start_script']);
     if (!stristr($startScript, '.php')) {
         $startScript .= ".php";
     }
     $arguments = "";
     foreach ($info as $key => $value) {
         if (!in_array($key, array('menu_selected', 'start_script'))) {
             $arguments .= "&{$key}=" . urldecode($value);
         }
     }
     $this->set('startFunction', "scriptDoLoad('{$startScript}', 'content', '{$arguments}')");
     $this->render('adminpanel/adminpanel');
 }
コード例 #10
0
 function listSeoTools()
 {
     $userId = isLoggedIn();
     $seoToolList = $this->__getAllSeoTools();
     $this->set('list', $seoToolList);
     $this->render('seotools/listseotools');
 }
コード例 #11
0
ファイル: videos.php プロジェクト: tgassner/Blechophon
?>

<?php 
function addVideo()
{
    if (isLoggedIn()) {
        if (hasCurrentUserRight("video")) {
コード例 #12
0
ファイル: ForumPost.php プロジェクト: Codex-NG/cornexaac
 /**
  * Determinate if user is admin
  *
  * @return boolean
  */
 public function isAdmin()
 {
     if (!isLoggedIn()) {
         return false;
     }
     return (bool) $this->user()->site_access;
 }
コード例 #13
0
ファイル: ModuleFactory.php プロジェクト: uzerpllp/uzerp
 public static function Factory($default_page = null, $requireLogin = true)
 {
     $prefs = UserPreferences::Instance(EGS_USERNAME);
     $default_page = $prefs->getPreferenceValue('default_page', 'shared');
     if ($default_page == null) {
         $ao = AccessObject::Instance();
         $default_page = 'module,' . $ao->getDefaultModule();
     }
     if (get_config('SETUP')) {
         if (defined('MODULE')) {
             $default_page = MODULE;
         }
     }
     $router = RouteParser::Instance();
     $modules = array();
     if (!$requireLogin || isLoggedIn()) {
         foreach ($router->getDispatch() as $key => $dispatch) {
             if (($key == 'group' || $key == 'module' || strstr($key, 'submodule')) && !empty($dispatch)) {
                 $modules[$key] = $dispatch;
             }
         }
         if (empty($modules)) {
             // Default page contains permission type and permission name
             // i.e. type is group or module
             $array = explode(',', $default_page);
             $modules[$array[0]] = $array[1];
         }
     } else {
         $modules['module'] = 'login';
     }
     $al =& AutoLoader::Instance();
     return $modules;
 }
コード例 #14
0
ファイル: AB_Controller.php プロジェクト: angelamuliawan/rd
 public function __construct()
 {
     parent::__construct();
     ini_set('memory_limit', '-1');
     $this->domain = 'http://localhost/cookindo';
     $this->webroot = $_SERVER['DOCUMENT_ROOT'] . '/cookindo/';
     // $this->domain = 'http://'.$_SERVER['SERVER_NAME'];
     // $this->webroot = $_SERVER['DOCUMENT_ROOT'];
     if (isLoggedIn()) {
         if ($this->session->userdata('userpassword') == 'def' && strtolower($this->router->method) != 'completion' && strtolower($this->router->method) != 'logout') {
             $this->load->helper('url');
             redirect($this->domain . '/users/completion');
         }
         $resNotification = $this->db->query('CALL GetNotifications(?)', array($this->session->userdata('userid')));
         $notifications = $resNotification->result_array();
         $resNotification->next_result();
         $this->load->vars(array('notifications' => $notifications));
     }
     if ($this->session->userdata('redirect_now') == true) {
         $this->session->set_userdata('redirect_now', false);
         if (!empty($this->session->userdata('redirect_after'))) {
             $redirect_after = $this->session->userdata('redirect_after');
             $this->session->set_userdata('redirect_after', false);
             $this->load->helper('url');
             redirect($this->domain . '/' . $redirect_after);
         }
     }
     $this->site_lang = get_cookie('site_lang') ? get_cookie('site_lang') : 'indonesian';
     $this->lang->load($this->site_lang, $this->site_lang);
     $this->load->vars(array('domain' => $this->domain, 'webroot' => $this->webroot, 'site_lang' => $this->site_lang));
 }
コード例 #15
0
ファイル: user.php プロジェクト: prymribb/starter
function requireUser($b = true)
{
    if ($b && !isLoggedIn()) {
        warning('You need to login to view this page.');
        redirect($GLOBALS['sLoginPage'] . '?ref=' . str_replace('?logout=true', '', $_SERVER['REQUEST_URI']));
    }
}
コード例 #16
0
/**
 * Logs in and downloads the book
 *
 * @param $book
 */
function downloadBook($book)
{
    $params = array("email" => ACCOUNT_EMAIL, "password" => ACCOUNT_PASSWORD, "op" => "Login", "form_build_id" => $book['form_build_id'], "form_id" => "packt_user_login_form");
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://www.packtpub.com/packt/offers/free-learning');
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/32.0.1700.107 Chrome/32.0.1700.107 Safari/537.36');
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_COOKIESESSION, true);
    curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie-name');
    //could be empty, but cause problems on some hosts
    curl_setopt($ch, CURLOPT_COOKIEFILE, '/tmp');
    //could be empty, but cause problems on some hosts
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    $response = curl_exec($ch);
    if (curl_error($ch)) {
        echo curl_error($ch);
    }
    $loggedIn = isLoggedIn($response);
    $response = false;
    if ($loggedIn) {
        curl_setopt($ch, CURLOPT_URL, 'https://www.packtpub.com' . $book['book_claim_url']);
        curl_setopt($ch, CURLOPT_POST, false);
        curl_setopt($ch, CURLOPT_POSTFIELDS, "");
        $response = curl_exec($ch);
    }
    curl_close($ch);
    if ($response === false) {
        die(1);
    }
}
コード例 #17
0
ファイル: validation.php プロジェクト: arewold/calcuttagutta
function isValidAdmin()
{
    if (isset($_SESSION['valid_admin']) && isLoggedIn()) {
        return true;
    } else {
        return false;
    }
}
コード例 #18
0
ファイル: functions.php プロジェクト: Wayfur/OpenSMO
function me()
{
    if (isLoggedIn()) {
        return new User(intval($_SESSION['UID']));
    } else {
        return false;
    }
}
コード例 #19
0
ファイル: user.model.php プロジェクト: rquiring/klipsmobile
 public static function validateSession()
 {
     $status = array("session" => "invalid");
     if (isLoggedIn()) {
         $status["session"] = "valid";
     }
     return $status;
 }
コード例 #20
0
ファイル: auth.php プロジェクト: Raconeisteron/posit-mobile
function checkAuthz($action)
{
    $noAuth = array('login', 'login.do', 'logout', 'main', '', 'register', 'register.do');
    if (in_array($action, $noAuth)) {
        return true;
    }
    return isLoggedIn();
}
コード例 #21
0
ファイル: home.php プロジェクト: robertmain/Treasure-Hunt
 public function __construct()
 {
     parent::__construct();
     if (isLoggedIn()) {
         redirect('treasure');
     }
     $this->load->model(array('mytreasure_model', 'treasure_model'));
 }
コード例 #22
0
ファイル: helpers.php プロジェクト: Luisfmarkes/socialturn
function userstatus()
{
    global $helper;
    $loggedin = isLoggedIn();
    $user = getUserDetails();
    $helper->set('user', $user);
    return $helper->render();
}
コード例 #23
0
 public function index()
 {
     if (isLoggedIn()) {
         redirect('admin/home');
     }
     $this->template->write_view('content', 'views/admin/auth/index');
     $this->template->render();
 }
コード例 #24
0
ファイル: secure.php プロジェクト: benoastler/Clubband
 function __construct()
 {
     parent::__construct();
     if (!isLoggedIn()) {
         redirect(my_site_url() . 'welcome/view_login');
     }
     $this->load->model('SecureModel', 'secure');
     $this->load->helper('date');
 }
コード例 #25
0
ファイル: lib.misc.php プロジェクト: Kjir/amsn
function canModerateNews()
{
    if (isLoggedIn() == true) {
        if ($_SESSION['level'] == 1 || $_SESSION['level'] == 1) {
            return true;
        }
    }
    return false;
}
コード例 #26
0
ファイル: util.functions.php プロジェクト: Replica94/SysProjE
/**
 * Enforces that the user is logged in. If the user isn't logged in,
 * redirect them to the given address and exit. MUST be called before any
 * output has been sent to the client, otherwise the function doesn't send headers.
 *
 * @param string $redirect The address to redirect to (default login.php), or null for no redirect.
 */
function requireLoggedIn($redirect = 'login.php')
{
    if (!isLoggedIn()) {
        if (isset($redirect) && !headers_sent()) {
            header("Location: {$redirect}");
        }
        exit;
    }
}
コード例 #27
0
 public function __construct()
 {
     parent::__construct();
     if (!isLoggedIn()) {
         redirect('admin/login');
     }
     $this->load->model(array('mytreasure_model', 'pirate_model'));
     $this->load->helper(array('analytics'));
 }
コード例 #28
0
function requireLogin()
{
    $userId = isLoggedIn();
    if (!$userId) {
        header('HTTP/1.1 403 Forbidden: Not logged in');
        exit;
    }
    return $userId;
}
コード例 #29
0
ファイル: auth_helper.php プロジェクト: CMIP5/HUC8Climate
function getSessionUser()
{
    fetch_session();
    if (isLoggedIn()) {
        return $_SESSION['username'];
    } else {
        return false;
    }
}
コード例 #30
0
ファイル: rate.php プロジェクト: sophiacaspar/Banana-webshop
/** VIEW RATES **/
function rate($result, $i)
{
    include 'db_connect.php';
    $avgRate = avgRating(mysql_result($result, $i, 'productId'));
    $roundRate = round($avgRate, 0, PHP_ROUND_HALF_DOWN);
    $maxRate = 5;
    $numRate = numRate(mysql_result($result, $i, 'productId'));
    ?>
 <table align="center"> <tr> <?php 
    /** View rates via monkeys **/
    for ($j = 0; $j < $roundRate; $j++) {
        if (isLoggedIn()) {
            ?>
			<form action="?p=rate" method="post">
			<td><input type="hidden" id="rate" name="rate" value="<?php 
            echo $j + 1;
            ?>
"></td>
			<td><input type="hidden" id="prodId" name="prodId" value="<?php 
            echo mysql_result($result, $i, 'productId');
            ?>
"></td>
			<td><input class="rateFill" type="image" src="commentsRatings/monkey.png" alt="Submit"> </td>
</form>
		<?php 
        } else {
            ?>
		<td><img class="rateFill" src="commentsRatings/monkey.png" alt="monkey"></td>
	<?php 
        }
    }
    /** View rest of monkeys with lower opacity **/
    for ($k = 0; $k < $maxRate - $roundRate; $k++) {
        if (isLoggedIn()) {
            ?>
			<form action="?p=rate" method="post">
			<td><input type="hidden" id="rate" name="rate" value="<?php 
            echo $roundRate + $k + 1;
            ?>
"></td>
			<td><input type="hidden" id="prodId" name="prodId" value="<?php 
            echo mysql_result($result, $i, 'productId');
            ?>
"></td>
			<td><input class="rateTotal" type="image" src="commentsRatings/monkey.png" alt="Submit"></td>
</form>
		<?php 
        } else {
            ?>
		<td><img class="rateTotal" src="commentsRatings/monkey.png" alt="monkey"></td>
	<?php 
        }
    }
    echo "</tr></table>";
    echo "<small> [" . $avgRate . "/" . $maxRate . "] " . $numRate . " votes</small>";
}