PHP User::Exist Examples

PHP User::Exist - 10 examples found. These are the top rated real world PHP examples of User::Exist extracted from open source projects. You can rate examples to help us improve the quality of examples.
?>

<link rel="stylesheet" type="text/css" href="style/pages/comunity.css">

<div><h1 align="center" >Evelynpa comunity</h1></div>

<?php 
include_once 'API/UserHandler.php';
if (isset($_GET['sub'])) {
    $pagePath = 'view/pages/sub/' . $_GET['sub'] . '.php';
    include_once $pagePath;
} else {
    if (isset($_SESSION['login'])) {
        $login = $_SESSION['login'];
        if (is_numeric($login)) {
            $user = User::Exist($login);
            echo '<div class="welcome-message">Welcome ' . $user->getData('name') . ' !</div>';
            echo '<a class="welcome-message" href="?page=comunity&comm=logoff">Log off</a>';
            if ($user->getData('name') == 'admin') {
                echo '<a class="welcome-message" href="?page=import">Import</a>';
            }
        } else {
            echo '<div class="welcome-message">' . $login . '</div>';
            include_once 'view/pages/sub/login.php';
        }
    } else {
        include_once 'view/pages/sub/login.php';
    }
}
?>
Example #2
0
        $original_message = new Message($message_id);
        View::$vars->to = $original_message->username;
        View::$vars->subject = "Re: {$original_message->subject}";
        View::$vars->msg = "\n\n\n> " . View::$vars->to . " wrote: \n\n {$original_message->message}";
        Plugin::Trigger('message_send.load_original_message');
    }
}
/***********************
Handle form if submitted
***********************/
if (isset($_POST['submitted'])) {
    // Validate 'to' field
    if (!empty($_POST['to']) && !ctype_space($_POST['to'])) {
        $username = trim($_POST['to']);
        $data = array('username' => $username);
        $id = User::Exist($data);
        if ($id) {
            $recipient = new User($id);
            if ($recipient->user_id != View::$vars->user->user_id) {
                View::$vars->to = $recipient->username;
                $message['recipient'] = $recipient->user_id;
            } else {
                View::$vars->errors['recipient'] = Language::GetText('error_recipient_self');
            }
        } else {
            View::$vars->errors['recipient'] = Language::GetText('error_recipient_exist');
        }
    } else {
        View::$vars->errors['recipient'] = Language::GetText('error_recipient');
    }
    // Validate subject field
Example #3
0
 }
 switch ($_POST['type']) {
     case 'video':
         $id = Video::Exist(array('video_id' => $_POST['id'], 'status' => 'approved'));
         if (!$id) {
             App::Throw404();
         }
         $video = new Video($_POST['id']);
         $member_id = $video->user_id;
         $url = $video->url;
         $name = "Title: {$video->title}";
         $type = 'Video';
         Plugin::Trigger('flag.ajax.flag_video');
         break;
     case 'member':
         $id = User::Exist(array('user_id' => $_POST['id'], 'status' => 'active'));
         if (!$id) {
             App::Throw404();
         }
         $member = new User($id);
         $member_id = $id;
         $url = HOST . "/members/{$member->username}/";
         $name = "Username: {$user->username}";
         $type = 'Member';
         Plugin::Trigger('flag.ajax.flag_user');
         break;
     case 'comment':
         $id = Comment::Exist(array('comment_id' => $_POST['id'], 'status' => 'approved'));
         if (!$id) {
             App::Throw404();
         }
Example #4
0
Plugin::Trigger('subscribe.ajax.start');
// Establish page variables, objects, arrays, etc
$logged_in = User::LoginCheck();
if ($logged_in) {
    $user = new User($logged_in);
}
Plugin::Trigger('subscribe.ajax.login_check');
// Verify passed values
if (empty($_POST['type']) || !in_array($_POST['type'], array('subscribe', 'unsubscribe'))) {
    App::Throw404();
}
if (empty($_POST['user']) || !is_numeric($_POST['user'])) {
    App::Throw404();
}
// Validate user
if (!User::Exist(array('user_id' => $_POST['user'], 'status' => 'active'))) {
    App::Throw404();
}
$member = new User($_POST['user']);
### Handle subscribe/unsubscribe
switch ($_POST['type']) {
    ### Handle subscribe user to a member
    case 'subscribe':
        // Verify user is logged in
        if (!$logged_in) {
            echo json_encode(array('result' => 0, 'msg' => (string) Language::GetText('error_subscribe_login')));
            exit;
        }
        // Check if user is subscribing to himself
        if ($user->user_id == $member->user_id) {
            echo json_encode(array('result' => 0, 'msg' => (string) Language::GetText('error_subscribe_own')));
Example #5
0
App::LoadClass('Post');
// Establish page variables, objects, arrays, etc
View::InitView('profile');
Plugin::Trigger('profile.start');
View::$vars->logged_in = User::LoginCheck();
if (View::$vars->logged_in) {
    View::$vars->user = new User(View::$vars->logged_in);
}
$success = NULL;
$errors = NULL;
$sub_id = NULL;
$post_count = 5;
// Verify Member was supplied
if (isset($_GET['username'])) {
    $data = array('username' => $_GET['username'], 'status' => 'Active');
    $user_id = User::Exist($data);
} else {
    App::Throw404();
}
// Verify Member exists
if ($user_id) {
    View::$vars->member = new User($user_id);
    View::$vars->meta->title = Functions::Replace(View::$vars->meta->title, array('member' => View::$vars->member->username));
    Plugin::Trigger('profile.load_member');
} else {
    App::Throw404();
}
### Check if user is subscribed
if (View::$vars->logged_in) {
    $data = array('user_id' => View::$vars->user->user_id, 'member' => View::$vars->member->user_id);
    View::$vars->subscribe_text = Subscription::Exist($data) ? 'unsubscribe' : 'subscribe';
Example #6
0
 } else {
     View::$vars->errors['password'] = Language::GetText('error_password');
 }
 // Validate password confirm
 if (!empty($_POST['password_confirm']) && !ctype_space($_POST['password'])) {
     if (isset($password_first) && $password_first == $_POST['password_confirm']) {
         View::$vars->data['password'] = trim($_POST['password']);
     } else {
         View::$vars->errors['match'] = Language::GetText('error_password_match');
     }
 } else {
     View::$vars->errors['password_confirm'] = Language::GetText('error_password_confirm');
 }
 // Validate email
 if (!empty($_POST['email']) && preg_match('/^[a-z0-9][a-z0-9\\._-]+@[a-z0-9][a-z0-9\\.-]+\\.[a-z0-9]{2,4}$/i', $_POST['email'])) {
     if (!User::Exist(array('email' => $_POST['email']))) {
         View::$vars->data['email'] = htmlspecialchars(trim($_POST['email']));
     } else {
         View::$vars->errors['email'] = Language::GetText('error_email_unavailable');
     }
 } else {
     View::$vars->errors['email'] = Language::GetText('error_email');
 }
 ### Create user if no errors were found
 if (empty(View::$vars->errors)) {
     View::$vars->data['confirm_code'] = User::CreateToken();
     View::$vars->data['status'] = 'new';
     View::$vars->data['password'] = md5(View::$vars->data['password']);
     Plugin::Trigger('register.before_create');
     User::Create(View::$vars->data);
     View::$vars->message = Language::GetText('success_registered');
Example #7
0
<?php

// Include required files
include_once dirname(dirname(__FILE__)) . '/config/bootstrap.php';
App::LoadClass('User');
Plugin::Trigger('username.ajax.start');
### Check if username is in use
if (!empty($_POST['username']) && strlen($_POST['username']) >= 4) {
    if (User::Exist(array('username' => $_POST['username']))) {
        echo json_encode(array('result' => 0, 'msg' => (string) Language::GetText('error_username_unavailable')));
    } else {
        echo json_encode(array('result' => 1, 'msg' => (string) Language::GetText('username_available')));
    }
} else {
    echo json_encode(array('result' => 0, 'msg' => (string) Language::GetText('username_minimum')));
}
Example #8
0
 // Validate status
 if (!empty($_POST['status']) && !ctype_space($_POST['status'])) {
     $data['status'] = htmlspecialchars(trim($_POST['status']));
 } else {
     $errors['status'] = 'Invalid status';
 }
 // Validate role
 if (!empty($_POST['role']) && !ctype_space($_POST['role'])) {
     $data['role'] = htmlspecialchars(trim($_POST['role']));
 } else {
     $errors['role'] = 'Invalid role';
 }
 // Validate Email
 if (!empty($_POST['email']) && !ctype_space($_POST['email']) && preg_match('/^[a-z0-9][a-z0-9_\\.\\-]+@[a-z0-9][a-z0-9\\.\\-]+\\.[a-z0-9]{2,4}$/i', $_POST['email'])) {
     $email = array('email' => $_POST['email']);
     $id = User::Exist($email);
     if (!$id || $id == $user->user_id) {
         $data['email'] = $_POST['email'];
     } else {
         $errors['email'] = 'Email is unavailable';
     }
 } else {
     $errors['email'] = 'Invalid email address';
 }
 // Validate password
 if (!empty($_POST['password']) && !ctype_space($_POST['password'])) {
     $data['password'] = trim($_POST['password']);
 }
 // Validate First Name
 if (!empty($user->first_name) && $_POST['first_name'] == '') {
     $data['first_name'] = '';
Example #9
0
App::LoadClass('User');
App::LoadClass('Flag');
App::LoadClass('Pagination');
// Establish page variables, objects, arrays, etc
Functions::RedirectIf($logged_in = User::LoginCheck(), HOST . '/login/');
$admin = new User($logged_in);
Functions::RedirectIf(User::CheckPermissions('admin_panel', $admin), HOST . '/myaccount/');
$records_per_page = 9;
$url = ADMIN . '/members.php';
$query_string = array();
$message = null;
$sub_header = null;
### Handle "Delete" member
if (!empty($_GET['delete']) && is_numeric($_GET['delete'])) {
    // Validate id
    if (User::Exist(array('user_id' => $_GET['delete']))) {
        User::Delete($_GET['delete']);
        $message = 'Member has been deleted';
        $message_type = 'success';
    }
} else {
    if (!empty($_GET['activate']) && is_numeric($_GET['activate'])) {
        // Validate id
        $user = new User($_GET['activate']);
        if ($user->found) {
            $user->UpdateContentStatus('active');
            $user->Approve('approve');
            $message = 'Member has been activated';
            $message_type = 'success';
        }
    } else {
Example #10
0
<?php

// Include required files
include_once dirname(dirname(__FILE__)) . '/config/bootstrap.php';
App::LoadClass('User');
// Establish page variables, objects, arrays, etc
View::InitView('activate');
Plugin::Trigger('activate.start');
View::$vars->logged_in = User::LoginCheck();
Functions::RedirectIf(!View::$vars->logged_in, HOST . '/myaccount/');
View::$vars->message = null;
### Verify token was provided
if (isset($_GET['token'])) {
    $token = $_GET['token'];
    $id = User::Exist(array('confirm_code' => $token, 'status' => 'new'));
    if ($id) {
        $user = new User($id);
        $user->Approve('activate');
        if (Settings::Get('auto_approve_users') == 1) {
            View::$vars->message = Language::GetText('activate_success', array('host' => HOST));
            $_SESSION['user_id'] = $user->user_id;
        } else {
            View::$vars->message = Language::GetText('activate_approve');
        }
        View::$vars->message_type = 'success';
        Plugin::Trigger('activate.activate');
    } else {
        View::$vars->message = Language::GetText('activate_error', array('host' => HOST));
        View::$vars->message_type = 'error';
    }
} else {