public function validateSave($obj) { $userTemp = new User(); if (empty($obj->id)) { $users = $userTemp->Find("email = ?", array($obj->email)); if (count($users) > 0) { return new IceResponse(IceResponse::ERROR, "A user with same authentication email already exist"); } } else { $users = $userTemp->Find("email = ? and id <> ?", array($obj->email, $obj->id)); if (count($users) > 0) { return new IceResponse(IceResponse::ERROR, "A user with same authentication email already exist"); } } return new IceResponse(IceResponse::SUCCESS, ""); }
/** * Store a newly created resource in storage. * POST /coach * * @return Response */ public function store($id) { $user = Auth::user(); $club = $user->Clubs()->FirstOrFail(); $team = Team::Find($id); $coachUser = User::Find(Input::get('user')); $input = Input::all(); $messages = array('user.required' => 'Please select a user', 'user.unique' => 'User selected is already a coach for this team'); $validator = Validator::make(Input::all(), Coach::$rules, $messages); if ($validator->passes()) { $coach = new Coach(); $coach->user_id = $coachUser->id; $coach->team_id = $team->id; $status = $coach->save(); if ($status) { $newCoach = Coach::find($coach->id); return Redirect::action('TeamController@show', $team->id)->with('notice', 'Player added successfully'); } else { $error = $status->errors()->all(':message'); return Redirect::back()->withInput()->withErrors($error); } } $error = $validator->errors()->all(':message'); return Redirect::back()->withInput()->withErrors($error); }
public function sendEmail($subject, $toEmail, $template, $params, $ccList = array(), $bccList = array()){ $body = $template; foreach($params as $k=>$v){ $body = str_replace("#_".$k."_#", $v, $body); } $fromEmail = APP_NAME." <".$this->settings->getSetting("Email: Email From").">"; //Convert to an html email $emailBody = file_get_contents(APP_BASE_PATH.'/templates/email/emailBody.html'); $emailBody = str_replace("#_emailBody_#", $body, $emailBody); $emailBody = str_replace("#_logourl_#", BASE_URL."images/logo.png" , $emailBody); $user = new User(); $user->load("username = ?",array('admin')); if(empty($user->id)){ $users = $user->Find("user_level = ?",array('Admin')); $user = $users[0]; } $emailBody = str_replace("#_adminEmail_#", $user->email, $emailBody); $emailBody = str_replace("#_url_#", CLIENT_BASE_URL, $emailBody); $this->sendMail($subject, $emailBody, $toEmail, $fromEmail, $user->email, $ccList, $bccList); }
protected function deleteAllUsers() { $user = new User(); $users = $user->Find("username <> ?", array('admin')); foreach ($users as $user) { $user->Delete(); } }
<?php include_once "../includes/header.inc.php"; include_once "../includes/needLogIn.inc.php"; require_once "../Classes/User.class.php"; $user = new User(); if (isset($PARAMS['password'])) { $u = $_SESSION['username']; $p = $PARAMS['password']; $user->username = $u; $user->Find(); if ($user->variables && $user->delete_date == "" && md5(base64_encode($p)) == $user->password) { $user->delete_date = date("Ymd"); $user->Save(); $datos = array("status" => "OK"); print_r(json_encode($datos)); } else { if ($user->variables && $user->delete_date == "" && md5(base64_encode($p)) != $user->password) { $datos = array("status" => "WrongPassword"); print_r(json_encode($datos)); } else { if (!$user->variables || $user->delete_date != "") { $datos = array("status" => "NoResults"); print_r(json_encode($datos)); } } } } else { $datos = array("status" => "WrongData"); print_r(json_encode($datos)); }
public function getAllAdmins() { $user = new User(); $admins = $user->Find('user_level = ?', array('Admin')); return $admins; }
<td colspan="2" align="center"><?php if (isset($_POST['login'])) { $email = $_POST['email']; $password = $_POST['password']; $err = ""; if ($email == "" || $password == "") { $err .= "<strong class='error'>Please enter correct email and password</strong>"; } echo $err; if ($err == "") { $user_status = User::FindAll("email ='" . $email . "' and password ='******'", "*", array(), "A", 0, 0, array(_ACTIVE)); if (count($user_status) == 1) { foreach ($user_status as $user_obj) { echo $_SESSION['loged_user'] = $user_obj->getUserId(); $date = User::dateTime(); $user_o = User::Find($user_obj->getUserId()); $user_o->setLastlog($date); $user_o->Update(); echo "<strong class='success'>Login success</strong>"; echo '<SCRIPT langueage="JavaScript"> window.location="index.php?page=home"; </SCRIPT>'; } } else { $user_status2 = User::FindAll("email ='" . $email . "' and password ='******'", "*", array(), "A", 0, 0, array(_INACTIVE)); if (count($user_status2) == 1) { echo "<strong class='error'>Confirm your email first</strong>"; } else { echo "<strong class='error'>Login Failed</strong>"; } }
$msg = ""; $firstname = null; $lastname = null; $company = null; $email = null; $dateTime = date("F j, Y, g:i a"); if (isset($_GET['email']) && $_GET['email']) { $request_email = $_GET['email']; if (isset($_GET['key']) && strlen($_GET['key']) == 32) { $key = $_GET['key']; $email_obj = User::FindAll("email ='" . $request_email . "' and act_code ='" . $key . "'", "*", array(), "A", 0, 0, array(_INACTIVE)); if (count($email_obj) == 1) { foreach ($email_obj as $email_objs) { // $email_objs->setStatus(_ACTIVE); // $return_id= $email_objs->Update(); $user_o = User::Find($email_objs->getUserId()); } $user_o->setStatus(_ACTIVE); $return_id = $user_o->Update(); if ($return_id) { echo "Registation complete"; } } else { echo "There is an error maybe some one took your email"; } } } if (isset($_POST['register'])) { $firstname = $_POST['f_name']; $lastname = $_POST['l_name']; $company = $_POST['c_name'];
public function sendEmailWithoutWrap($subject, $toEmail, $template, $params, $ccList = array(), $bccList = array()) { $body = $template; foreach ($params as $k => $v) { $body = str_replace("#_" . $k . "_#", $v, $body); } $fromEmail = APP_NAME . " <" . $this->settings->getSetting("Email: Email From") . ">"; //Convert to an html email $emailBody = $body; $emailBody = str_replace("#_logourl_#", UIManager::getInstance()->getCompanyLogoUrl(), $emailBody); $user = new User(); $user->load("username = ?", array('admin')); if (empty($user->id)) { $users = $user->Find("user_level = ?", array('Admin')); $user = $users[0]; } $emailBody = str_replace("#_adminEmail_#", $user->email, $emailBody); $emailBody = str_replace("#_url_#", CLIENT_BASE_URL, $emailBody); foreach ($params as $k => $v) { $emailBody = str_replace("#_" . $k . "_#", $v, $emailBody); } $this->sendMail($subject, $emailBody, $toEmail, $fromEmail, $user->email, $ccList, $bccList); }
/** * @property read_by * @complex * @return \Models\User */ public function getReadBy() { $userid = $this->read_by; $user = User::Find($userid, 'user'); return $user; }
public static function isUser($username) { $user = new User(); $userArray = $user->Find("username='******'"); return count($userArray) > 0 ? true : false; }
if ($user->haspermission("admin")) { if ($user->Find(Input::Get("userId"))) { $userData = array("id" => $user->data()->id, "username" => escape($user->data()->username), "email" => escape($user->data()->email), "roles" => $user->data()->roles); echo json_encode($userData, JSON_PRETTY_PRINT); } } else { echo json_encode(array("You do not have enough permission to request user info"), JSON_PRETTY_PRINT); } } // save changes if (Input::Get("userId") && Input::Get("action") == "edit") { $errors = array(); $user = new User(); if ($user->haspermission("admin")) { $validate = new Validate(); $user->Find(Input::Get("userId")); $_POST['roles'] = Input::Get("roles"); $validation = $validate->check($_POST, array('roles' => array('disp_text' => lang('ROLE'), 'required' => true, 'inArray' => array(1, 2)))); if (Input::Get("email") != $user->data()->email) { $_POST['email'] = Input::Get("email"); $validation = $validate->check($_POST, array('email' => array('disp_text' => lang('EMAIL'), 'required' => true, 'unique' => 'users', 'valid_email' => true))); } if (Input::Get("password")) { $_POST['password'] = Input::Get("password"); $_POST['repassword'] = Input::Get("repassword"); $validation = $validate->check($_POST, array('password' => array('disp_text' => lang('PASSWORD'), 'min' => '4', 'max' => '32'), 'repassword' => array('disp_text' => lang('RE_ENTER_PASSWORD'), 'required' => true, 'matches' => 'password'))); } if (isset($validation)) { if ($validation->passed()) { foreach ($validation->errors() as $error) { $errors[] = $error;
/** * * @param string $username * @return User */ public static function FindUsername($username) { $db = \DB::Instance(); $rows = $db->select('user', ['id'], ['username' => strtolower($username)]); if (sizeof($rows) == 0) { return false; } $rows = $rows[0]; return User::Find($rows['id'], 'user'); }
Route::filter('before', function () { // Do stuff before every request to your application... }); Route::filter('after', function ($response) { // Do stuff after every request to your application... }); Route::filter('csrf', function () { if (Request::forged()) { return Response::error('500'); } }); Route::filter('auth', function () { if (Auth::guest()) { Session::flash('error', 'You do not have access level to be there.'); return Redirect::to('user'); } }); Route::filter('admin', function () { if (Auth::user()->administrator == 0) { Session::flash('error', 'You do not have access level to be there.'); return Redirect::to('user'); } }); Route::filter('valid_client', function () { $client_id = URI::Segment(4); $user = User::Find($client_id); if (!is_numeric($user->id)) { Session::flash('error', 'Unknown user.'); return Redirect::to('user/clients/'); } });