PHP User::addUser Examples

PHP User::addUser - 30 examples found. These are the top rated real world PHP examples of User::addUser extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
 public function _index()
 {
     $post = Input::post();
     if (!empty($post)) {
         $validate = Validate::register($post);
         $token = Token::check($post['token']);
         if ($validate === TRUE && $token === TRUE) {
             User::addUser($post);
             echo 'Registered';
         } else {
             if (!$token) {
                 echo 'Security Token is missing';
             }
             echo '<pre>';
             print_r($validate);
             echo '</pre>';
         }
     } else {
         if (Session::exists('user_id')) {
             header('Location: /');
             exit;
         }
         self::init('RegisterModel', 'register', $arg);
     }
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function adduser()
 {
     $currentPage = "ADD_USERS";
     $mainMenu = "USERS_MAIN";
     $Users = User::getUsersByFranchisee();
     $inputs = Input::all();
     if (isset($inputs['userType'])) {
         $inputs['franchiseeId'] = Session::get('franchiseId');
         $randomPassword = str_random(6);
         $encryptedPassword = Hash::make($randomPassword);
         $inputs['password'] = $encryptedPassword;
         $addUserResult = User::addUser($inputs);
         $userFullName = $inputs['firstName'] . ' ' . $inputs['lastName'];
         $UserDetails = array('password' => $randomPassword, 'userName' => $userFullName, 'email' => $inputs['email']);
         if ($UserDetails) {
             Mail::send('emails.account.usercreation', $UserDetails, function ($msg) use($UserDetails) {
                 $msg->from(Config::get('constants.EMAIL_ID'), Config::get('constants.EMAIL_NAME'));
                 $msg->to($UserDetails['email'], $UserDetails['userName'])->subject('The Little Gym - User account created');
             });
         }
         if ($addUserResult) {
             Session::flash('msg', "User account created successfully.");
         } else {
             Session::flash('error', "User account could not be created at the moment.");
         }
         return Redirect::to('admin/users/view/' . $addUserResult->id);
     }
     //$data = array('Users','currentPage', 'mainMenu');
     return View::make('pages.users.useradd', compact('Users', 'currentPage', 'mainMenu'));
 }
function _newUser()
{
    $user = new User(getdbh());
    $email = $user->checkEmail($_POST['email']);
    if (isset($email['ID'])) {
        $data['msg'][] = " Acest email nu este disponibil! Va rugam alegeti altul!";
        $data['redirect'][] = 'main/new';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    } else {
        $result = $user->addUser($_POST['email'], $_POST['password1'], $_POST['nume'], $_POST['prenume']);
        if ($result > 0) {
            $setToken = $user->newUserToken($result);
            if ($setToken != false) {
                $body = 'Pentru a activa contul apasa   <a href="' . WEB_DOMAIN . WEB_FOLDER . 'ops/newUserToken/' . $setToken . '"> AICI </a>';
                if (sendEmail('Email confirmare cont', $body, 'ulbsPlatform@ebs.ro', $_POST['email'])) {
                    $data['msg'][] = "Emailul cu linkul de confirmare cont a fost trimis";
                    $data['redirect'][] = 'main/index';
                    View::do_dump(VIEW_PATH . 'layout.php', $data);
                } else {
                    $data['msg'][] = "Emailul cu linkul de confirmare nu a fost trimis";
                    $data['redirect'][] = 'main/index';
                    View::do_dump(VIEW_PATH . 'layout.php', $data);
                }
            } else {
                $data['msg'][] = "Eroare la generarea tokenului";
                $data['redirect'][] = 'main/index';
                View::do_dump(VIEW_PATH . 'layout.php', $data);
            }
        } else {
            $data['msg'][] = "Eroare la crearea contului!";
            $data['redirect'][] = 'main/index';
            View::do_dump(VIEW_PATH . 'layout.php', $data);
        }
    }
}
 public function action_add()
 {
     $success = false;
     if (isset($_POST["add"])) {
         $user = new User($_POST);
         $success = $user->addUser();
         $success = $user->success($success);
     }
     $this->view->generate('add.php', ["success" => $success]);
 }
Example #5
0
 public function actionRegUser()
 {
     $login = $_POST['loginReg'];
     $password = $_POST['passwordReg'];
     if (User::CheckLogin($login)) {
         echo "<h3> Используйте другой логин, этот уже существует!</h3>";
     } else {
         if (User::addUser($login, $password)) {
             echo "<h3>Вы успешно зарегистрировались!</h3>";
         }
     }
     require_once ROOT . '/views/Avtorisation.php';
     return true;
 }
 public function registration()
 {
     if (!empty($_POST)) {
         $user = new User();
         if ($user->unique($_POST) == 0) {
             $user->addUser($_POST);
             return $this->renderView('user/registration', array('result' => $user->result));
         } else {
             header('Refresh: 5');
             return $this->renderView('user/registration', array('result' => "Данный E-mail занят! Через 5 сек Вы будете перенаправлены на страницу " . "регистрации. <a href='index.php?r=user&a=registration'>Не ждать!</a>"));
         }
     }
     $this->renderView('user/registration');
 }
 public function go()
 {
     $this->setViewTemplate('adduser.tpl');
     if (isset($_POST['submit'])) {
         if ($_POST['username'] == '') {
             $this->addErrorMessage("Username should not be empty");
         } elseif ($_POST['full_name'] == '') {
             $this->addErrorMessage("Full name should not be empty");
         } elseif ($_POST['password'] == '') {
             $this->addErrorMessage("Password should not be empty");
         } elseif ($_POST['confirmpassword'] == '') {
             $this->addErrorMessage("Please confirm password");
         } elseif (!isset($_POST['is_activated'])) {
             $this->addErrorMessage("Is the user activated?");
         } elseif (!isset($_POST['type'])) {
             $this->addErrorMessage("Select the type of user");
         } elseif ($_POST['email'] == '') {
             $this->addErrorMessage("please enter ur email id");
         } else {
             $username = $_POST['username'];
             $password = $_POST['password'];
             $confirmpassword = $_POST['confirmpassword'];
             $full_name = $_POST['full_name'];
             $email = $_POST['email'];
             $is_activated = $_POST['is_activated'];
             $type = $_POST['type'];
             if (User::doesUserExist($username)) {
                 $this->addErrorMessage("Username already exists");
             } elseif (!($password == $confirmpassword)) {
                 $this->addErrorMessage("The two passwords dont match!");
             } elseif (!Utils::validateEmail($email)) {
                 $this->addErrorMessage("Please enter a valid email id");
             } else {
                 $subject = "Hackademic new account";
                 $message = "Hackademic account created succesfully";
                 //Mailer::mail($email,$subject,$message);
                 $joined = date("Y-m-d H-i-s");
                 $result = User::addUser($username, $full_name, $email, $password, $joined, $is_activated, $type);
                 $this->addSuccessMessage("User has been added succesfully");
                 header('Location:' . SOURCE_ROOT_PATH . "admin/pages/usermanager.php?source=add");
             }
         }
     }
     return $this->generateView();
 }
Example #8
0
 public static function createWeiboUser()
 {
     if (!self::$_config) {
         self::$_config = (require_once WEIBO_PATH . 'config/config.php');
     }
     //获取用户的资料
     if (!$_SESSION['token']['uid']) {
         return false;
     }
     $uid = $_SESSION['token']['uid'];
     //获取用户的信息
     $c = new SaeTClientV2(self::$_config['WB_AKEY'], self::$_config['WB_SKEY'], self::$_config['WB_ACCESS_TOKEN']);
     $info = $c->request_with_uid('https://api.weibo.com/2/users/show.json', $uid);
     if ($info) {
         //检查是否已经建立过用户了
         $db = self::_db();
         $check = $db->where(array('uid' => $_SESSION['token']['uid']))->limit(1)->select();
         if ($check && $check[0]['uid']) {
             //已经建立过用户了
             LuS::set('uid', $check[0]['user_id']);
             LuS::set('username', $check[0]['screen_name']);
             return true;
         }
         //建立用户
         $email = $info['screen_name'] . '@sina.com';
         $username = $info['screen_name'];
         $password = md5(rand(100, 9999) . time());
         $user_id = User::addUser($username, $password, $email);
         if (!$user_id) {
             echo '登录失败';
             throw new Exception('exit');
         }
         //存储用户信息
         $rs = self::addWeiboUserInfo($user_id);
         if ($rs) {
             LuS::set('uid', $user_id);
             LuS::set('username', $username);
             return true;
         } else {
             return false;
         }
     } else {
         return false;
     }
 }
Example #9
0
                 redirect($options['site_url'] . '/admin.php?area=' . $area);
             }
             if (isset($_POST['delete'])) {
                 Role::deleteRole($id);
                 redirect($options['site_url'] . '/admin.php?area=' . $area);
             }
         } else {
             $template->page_title = 'Manage Roles';
         }
     }
     break;
 case 'users':
     if ($action == 'add') {
         $template->page_title = 'Add New User';
         if (isset($_POST['submit'])) {
             User::addUser($_POST);
             redirect($options['site_url'] . '/admin.php?area=' . $area);
         }
     } else {
         if ($action == 'view') {
             $template->page_title = 'View User';
             if (isset($_POST['submit'])) {
                 User::saveUser($id, $_POST);
                 redirect($options['site_url'] . '/admin.php?area=' . $area);
             }
             if (isset($_POST['delete'])) {
                 User::deleteUser($id);
                 redirect($options['site_url'] . '/admin.php?area=' . $area);
             }
         } else {
             $template->page_title = 'Manage Users';
Example #10
0
<?php

/**
 * Created by PhpStorm.
 * User: Hoan
 * Date: 11/4/2015
 * Time: 7:44 PM
 */
//Khởi động session
session_start();
//Kiểm tra nếu chưa đăng nhập thì quay về trang đăng nhập
if (!isset($_SESSION['user'])) {
    header('location:login.php');
}
//Require các file cần thiết
require '../../config/Config.php';
require '../../models/User.php';
//Nếu có POST dữ liệu lên thì xử lý
if ($_POST) {
    //Nhận dữ liệu từ form và gán vào một mãng (Có thể sử dụng UserObj để lưu dữ liệu)
    $data = array('username' => $_POST['username'], 'password' => md5($_POST['password']), 'fullname' => $_POST['fullname'], 'email' => $_POST['email'], 'status' => isset($_POST['status']) ? 1 : 0, 'created' => date('Y-m-d H:i:s'), 'modified' => date('Y-m-d H:i:s'));
    $userModel = new User();
    if ($userModel->addUser($data)) {
        $_SESSION['success'] = true;
        header('location:list.php');
    }
    //Ngừng thực thi
    exit;
}
require '../../views/user/v_add.php';
Example #11
0
<?php

if (!isset($_SESSION)) {
    session_start();
}
define('__ROOT__', dirname(dirname(__FILE__)));
define('__BASENAME__', basename(__ROOT__));
require_once __ROOT__ . '/modules/User.class.php';
$email = !isset($_POST['email']) ? "" : $_POST['email'];
$password = !isset($_POST['password']) ? "" : $_POST['password'];
$firstName = !isset($_POST['firstName']) ? "" : $_POST['firstName'];
$lastName = !isset($_POST['lastName']) ? "" : $_POST['lastName'];
$companyId = !isset($_POST['companyId']) ? "" : $_POST['companyId'];
$userType = !isset($_POST['userType']) ? "" : $_POST['userType'];
$isUserActive = !isset($_POST['isActive']) ? 0 : $_POST['isActive'];
$phone = !isset($_POST['phone']) ? '' : $_POST['phone'];
$baseUrl = !isset($_POST['baseUrl']) ? '' : $_POST['baseUrl'];
$userObj = new User();
$userObj->addUser($email, $password, $firstName, $lastName, $companyId, $userType, $isUserActive, $phone, $baseUrl);
<?php

include_once "../class/User.php";
$regUser = new User();
$usname = $_GET["regUname"];
$paword = $_GET["regPass"];
$firstName = $_GET["regFname"];
$lastName = $_GET["regLname"];
$position = $_GET["regPosition"];
$stat = $_GET["regStatus"];
if ($stat == "ผู้ดูแลระบบ") {
    $stat = "Administrator";
    $regUser->setValues($usname, $paword, $firstName, $lastName, $position, $stat);
    $regUser->addUser();
} else {
    if ($stat == "เจ้าหน้าที่พัสดุ") {
        $stat = "Officer";
        $regUser->setValues($usname, $paword, $firstName, $lastName, $position, $stat);
        $regUser->addUser();
    } else {
    }
}
Example #13
0
        }
    }
    return $response->withStatus(401);
};
$app->get('/', function ($request, $response, $args) {
    $response->write("Welcome to Slim!");
    return $response;
});
$app->get('/register', function ($request, $response, $args) {
    render('views/registration.php');
    return $response;
});
$app->post('/registration', function ($request, $response, $args) {
    $data = $request->getParsedBody();
    $user = new User(db::getInstance());
    $result = $user->addUser($data['username'], $data['password'], $data['email']);
    if ($result) {
        $response->write("Registration successful");
    } else {
        $response->write("Error: wrong data format");
    }
    return $response;
});
$app->post('/login', function ($request, $response, $args) {
    $data = $request->getParsedBody();
    $user = new User(db::getInstance());
    $result = $user->checkUser($data['username'], $data['password']);
    if ($result === false) {
        $response->write(json_encode(array('error' => array('message' => 'Wrong login information.'))));
    } else {
        $response->write(json_encode(array('token' => $result)));
     }
     $data = $userModel->getUserInfo($registry->session->user->id);
     $userView->details('update', $data);
     break;
 case 'register':
     // display signup form and allow user to register
     $data = array();
     $error = array();
     if ($_SERVER['REQUEST_METHOD'] === "POST") {
         // POST values that will be validated
         $values = array('details' => array('firstName' => isset($_POST['firstName']) ? $_POST['firstName'] : '', 'lastName' => isset($_POST['lastName']) ? $_POST['lastName'] : ''), 'username' => array('username' => isset($_POST['username']) ? $_POST['username'] : ''), 'email' => array('email' => isset($_POST['email']) ? $_POST['email'] : ''), 'password' => array('password' => isset($_POST['password']) ? $_POST['password'] : '', 'password2' => isset($_POST['password2']) ? $_POST['password2'] : ''), 'captcha' => array('recaptcha_challenge_field' => isset($_POST['recaptcha_challenge_field']) ? $_POST['recaptcha_challenge_field'] : '', 'recaptcha_response_field' => isset($_POST['recaptcha_response_field']) ? $_POST['recaptcha_response_field'] : ''));
         $dotValidateUser = new Dot_Validate_User(array('who' => 'user', 'action' => 'add', 'values' => $values));
         if ($dotValidateUser->isValid()) {
             // no error - then add user
             $data = $dotValidateUser->getData();
             $userModel->addUser($data);
             $session->message['txt'] = $option->infoMessage->add;
             $session->message['type'] = 'info';
             //login user
             $userModel->authorizeLogin($data);
         } else {
             if (array_key_exists('password', $data)) {
                 // do not display password in the add form
                 $data = $dotValidateUser->getData();
                 unset($data['password']);
             }
         }
         // add action and validation are made with ajax, so return json string
         header('Content-type: application/json');
         echo Zend_Json::encode(array('data' => $dotValidateUser->getData(), 'error' => $dotValidateUser->getError()));
         // return $data and $error as json
Example #15
0
session_start();
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
include_once '../resources/User.php';
$error = NULL;
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $tag = $_POST['user'];
    $email = $_POST['email'];
    $pass = $_POST['password'];
    $confirm = $_POST['confirm-password'];
    if ($pass != $confirm) {
        $error = "Passwords did not match.";
    } else {
        $user = new User($tag, $pass, $email);
        $error = $user->addUser();
        if ($error == NULL) {
            header("Location: index.php");
            exit;
        }
    }
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" media="all"
	href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" media="all"
	href="css/main.css">
Example #16
0
    $email = $user->getUserEmail($id);
    echo $email[0]['user_email'];
});
//REGISTER PROCESS - check if email exists
$app->post('/checkemail', function () {
    global $user, $app;
    //echo ($app->request->getBody());
    $result = $user->checkEmailExists($app->request->getBody());
    echo $result[0]['COUNT(*)'];
    //var_dump ($us0r->getAllUsers());
});
// Register User
$app->post('/user/', function () {
    global $user, $app;
    $jsonUser = json_decode($app->request->getBody());
    $add = $user->addUser($jsonUser->{'email'}, $jsonUser->{'password'});
    //$bool =  var_export($add);
    $boolString = $add ? 'true' : 'false';
    $id = $user->getID($jsonUser->{'email'}, $jsonUser->{'password'});
    //echo ($id['0']['user_id']);
    $results = array("boolean" => $boolString, "id" => $id['0']['user_id']);
    print_r(json_encode($results));
});
//Adding user info
$app->post('/user/:id', function ($id) {
    global $user, $app;
    $details = json_decode($app->request->getBody(), true);
    //var_dump (json_decode( $app->request->getBody() ) );
    $add = $user->addUserInfo($details);
    $boolString = $add ? 'true' : 'false';
    echo $boolString;
Example #17
0
                 }
                 break;
         }
     }
 }
 if (strlen($_POST['user']) < 3 || !validUsername($_POST['user'])) {
     $error .= '- El usuario debe tener al menos cuatro caracteres y el primer caracter no puede ser un número<br />';
 }
 if (strlen($_POST['mail']) < 3 || !emailValido($_POST['mail'])) {
     $error .= '- El E-Mail no es válido<br />';
 }
 if ($error == '') {
     $_POST['country'] = $_SESSION['valid_register'];
     $_POST['rol'] = 3;
     $error = false;
     $result = User::addUser($_POST);
     if ($result == OK) {
         $msj = 'Se le envió un correo electrónico, debe revisarlo para completar el registro.';
         email($_POST['mail'], 'Confirmación de Registro', 'Sr(a). ' . $_POST['name'] . ',<br /><br />Para completar el registro haga click en el siguiente link: ' . ACTUAL_URL . '?op=validate&user=' . $_POST['user'] . '&token=' . md5($_POST['user'] . SEMILLA_NEW_USER) . '</b>');
         unset($_POST);
         $_POST = array();
         unset($_SESSION['valid_register']);
     } else {
         if ($result == E_MAIL_EXIST) {
             $error = 'El E-Mail ya está siendo utilizado por otro usuario';
         } else {
             if ($result == E_USER_EXIST) {
                 $error = 'El Nombre de Usuario ya está siendo utilizado por otro usuario';
             } else {
                 $error = 'Ocurrió un error interno registrando su cuenta, intente más tarde.';
             }
Example #18
0
    }
    echo json_encode($_SESSION);
});
//REGISTER PROCESS - check if email exists
$app->post('/checkemail', function () {
    global $user, $app;
    //echo ($app->request->getBody());
    $result = $user->checkEmailExists($app->request->getBody());
    echo $result;
    //var_dump ($us0r->getAllUsers());
});
// Register User
$app->post('/user/', function () {
    global $user, $app;
    $jsonUser = json_decode($app->request->getBody(), true);
    $add = $user->addUser($jsonUser);
    echo $add;
});
//Update User
$app->put('/user', function () {
    global $user, $app, $login;
    $jsonUser = json_decode($app->request->getBody(), true);
    echo $user->updateUser($_SESSION['user_id'], $jsonUser);
    $login->setSession($_SESSION['user_id']);
});
//publish post
//includes server-side check that content isn't empty
$app->post('/post', function () {
    global $post, $app;
    $jsonDetails = json_decode($app->request->getBody(), true);
    if ($jsonDetails['post_content']) {
Example #19
0
                 $st = $obj->addUser($userName, $password, 21);
                 if ($st) {
                     echo "Data Entry Operator Added :) \n";
                     echo "Updated Data Base\n";
                     $obj->DisplayUsers();
                 }
                 break;
             default:
                 echo "Wrong choice :(\n";
                 break;
         }
     }
     break;
 case 21:
     echo "\nWellcome to Data Entry Panel :) \n ";
     echo " please enter your name & password to continue \n ";
     while ($attempts != 0 && $status == false) {
         do {
             echo "UserName :\n ";
             $userName = readline();
         } while ($userName == " ");
         do {
             echo "Password :\n ";
             $password = readline();
         } while ($password == " ");
         $status = $obj->SignIn($userName, $password);
         if ($status) {
             $attempts = 0;
             break;
         }
         $attempts--;
     }
     if ($status == true) {
         #validation of rollnumber
         $temp = new Result();
         echo "\nenter student rollno: ";
         $temp->rollNum = readline();
         echo "\nenter student name: ";
         $temp->Name = readline();
         echo "\nenter student Fathername: ";
         $temp->fatherName = readline();
         echo "\n Now Enter Suject Marks \n";
         echo "\nenter  Science marks : ";
         $temp->marks[0] = readline();
         echo "\nenter  Mathamatics: ";
         $temp->marks[1] = readline();
         echo "\nenter English marks: ";
         $temp->marks[2] = readline();
         echo "\nenter Islamyat marks: ";
         $temp->marks[3] = readline();
         echo "\nenter Pak study marks: ";
         $temp->marks[4] = readline();
         echo "\nenter student Total marks: ";
         $temp->TotalMarks = readline();
         $stt = $std->AddResult($temp);
         if ($stt) {
             echo " \nStudent Result Added :) \n";
             $std->DisplayResult($temp->rollNum);
         }
     }
     break;
 case 31:
     echo "\nWellcome to DB Admin Panel :)  \n";
     echo " please enter your name & password to continue \n ";
     while ($attempts != 0 && $status == false) {
         echo "UserName :\n ";
         $userName = readline();
         echo "Password :\n ";
         $password = readline();
         $status = $obj->SignIn($userName, $password);
         if ($status) {
             $attempts = 0;
             break;
         }
         $attempts--;
     }
     if ($status == true) {
         echo "press 1 to Add user(Internee or Data Entry Operator) \n";
         echo "press 2 to Edit Database\n";
         echo "press 3 to show Db Records \n";
         $input = readline();
         switch ($input) {
             case 1:
                 do {
                     echo "Set UserName :\n ";
                     $userName = readline();
                     #check username availability
                 } while ($userName == null);
                 do {
                     echo "Set Password :\n ";
                     $password = readline();
                 } while ($password == null);
                 do {
                     echo "Set userType 11 or 21 :\n ";
                     $userType = readline();
                 } while ($userType == null && ($userType == 11 || $userType == 21));
                 $st = $obj->addUser($userName, $password, $userType);
Example #20
0
<?php

require '../include/init.inc.php';
$user_name = $real_name = $mobile = $password = $email = $user_desc = $user_group = '';
extract($_POST, EXTR_IF_EXISTS);
if (Common::isPost()) {
    $exist = User::getUserByName($user_name);
    if ($exist) {
        OSAdmin::alert("error", ErrorMessage::NAME_CONFLICT);
    } else {
        if ($password == "" || $real_name == "" || $mobile == "" || $email == "" || $user_group <= 0) {
            OSAdmin::alert("error", ErrorMessage::NEED_PARAM);
        } else {
            $input_data = array('user_name' => $user_name, 'password' => md5($password), 'real_name' => $real_name, 'mobile' => $mobile, 'email' => $email, 'user_desc' => $user_desc, 'user_group' => $user_group);
            $user_id = User::addUser($input_data);
            if ($user_id) {
                $input_data['password'] = "";
                SysLog::addLog(UserSession::getUserName(), 'ADD', 'User', $user_id, json_encode($input_data));
                Common::exitWithSuccess('账号添加成功', 'complaint/user.php');
            } else {
                OSAdmin::alert("error");
            }
        }
    }
}
$group_options = UserGroup::getGroupForOptions();
unset($group_options[1]);
Template::assign("_POST", $_POST);
Template::assign('group_options', $group_options);
Template::display('complaint/user_add.tpl');
Example #21
0
 $PhoneNum = $employee[4];
 $flagForRemoval = $employee[5];
 /** @var User $User */
 $User = User::getUserByEmpInfo($EID, $CID);
 if ($User && $flagForRemoval == 1) {
     //Remove
     User::flagUser($User->getUID());
 } elseif (!$User) {
     //Add
     $newUser = new User();
     $newUser->setEID($EID);
     $newUser->setCID($CID);
     $newUser->setEmail($Email);
     //Assume that the added employees are normal staff, and can have privileges promoted later if needed
     $newUser->setRoleID(4);
     User::addUser($newUser);
     $User = User::getUserByEmpInfo($EID, $CID);
     $newEmployee = new BossFlexEmployee();
     $newEmployee->setBFID($EID);
     $newEmployee->setFname($Fname);
     $newEmployee->setLname($Lname);
     $newEmployee->setPhoneNum($PhoneNum);
     BossFlexEmployee::addEmployee($newEmployee);
 } else {
     //Update
     $User->setEmail($Email);
     $User->saveToDB();
     $employee = BossFlexEmployee::getEmployeeByBFID($User->getEID());
     $employee->setFname($Fname);
     $employee->setLname($Lname);
     $employee->setPhoneNum($PhoneNum);
Example #22
0
function addUser()
{
    User::checkLoggedIn();
    global $error;
    $arr_submit = array(array('firstname', 'string', false, ''), array('infix', 'string', false, ''), array('lastname', 'string', true, ''), array('username', 'string', false, ''), array('email', 'email', true, ''), array('copy_to_admin', 'bool', false, false));
    $frm_submitted = validate_var($arr_submit);
    if (!$error) {
        $mixed_success = User::addUser($frm_submitted);
        if (is_string($mixed_success)) {
            echo json_encode(array('success' => false, 'error' => $mixed_success));
            exit;
        } else {
            if ($mixed_success['insert'] === false) {
                echo json_encode(array('success' => false, 'error' => 'Failure while inserting the user'));
                exit;
            } else {
                $password = '';
                if (defined('SHOW_CREATED_PASSWORD_WHEN_ADMIN_ADDS_USER') && SHOW_CREATED_PASSWORD_WHEN_ADMIN_ADDS_USER) {
                    if (isset($mixed_success['password'])) {
                        $password = $mixed_success['password'];
                    }
                }
                if ($mixed_success['mail'] == 'notsend') {
                    echo json_encode(array('success' => false, 'password' => $password, 'error' => 'User inserted succesfully, failure while sending email'));
                    exit;
                } else {
                    echo json_encode(array('success' => true, 'password' => $password, 'error' => 'User inserted succesfully and email send successfully'));
                    exit;
                }
            }
            echo json_encode(array('success' => $mixed_success));
            exit;
        }
    }
    echo json_encode(array('success' => false, 'error' => $error));
    exit;
}
Example #23
0
 public function createSiteAdmin($params)
 {
     try {
         include_once ROOT . '/sites/' . $params->siteId . '/conf.php';
         include_once ROOT . '/dataProvider/User.php';
         $u = new User();
         $admin = new stdClass();
         $admin->title = 'Mr.';
         $admin->fname = 'Administrator';
         $admin->mname = '';
         $admin->lname = 'Administrator';
         $admin->username = $params->adminUsername;
         $admin->password = $params->adminPassword;
         $admin->authorized = 1;
         $admin->active = 1;
         $admin->role_id = 8;
         $admin->facility_id = 1;
         $u->addUser($admin);
         session_unset();
         session_destroy();
         return ['success' => true];
     } catch (Exception $Error) {
         return ['success' => false, 'error' => $Error->getMessage()];
     }
 }
Example #24
0
$app->post('/signup', function () use($app) {
    $req = $app->request();
    $err = array('db_err' => 0, 'name' => 0, 'username' => 0, 'email' => 0, 'password' => 0, 'conf_password' => 0, 'mismatch' => 0, 'invalid_email' => 0, 'duplicate' => 0);
    $action = 0;
    if ($req->post('signup')) {
        require_once 'core/user.inc.php';
        $user = new User();
        $name = $req->post('name');
        $username = $req->post('username');
        $password = $req->post('passwd');
        $conf_password = $req->post('con_passwd');
        $email = $req->post('email');
        if (!empty($name) && !empty($username) && !empty($email) && !empty($password) && !empty($conf_password)) {
            if ($user->validEmail($email) && $password == $conf_password) {
                $user_details = array('name' => $name, 'username' => $username, 'password' => $password, 'email' => $email);
                $result = $user->addUser($user_details);
                if ($result == 1) {
                    //Succesful Signup, redirect to login to confirm registration
                    $app->redirect('/Blog-It/login');
                } elseif (explode(' ', $result)[0] == 'Duplicate') {
                    $err['duplicate'] = 1;
                    $app->render('signup.php', array('err' => $err, 'action' => $action));
                } else {
                    $err['db_err'] = 1;
                    $app->render('signup.php', array('err' => $err, 'action' => $action));
                }
            } else {
                if (!$user->validEmail($email)) {
                    $action = 1;
                    $err['invalid_email'] = 1;
                    $app->render('signup.php', array('err' => $err, 'action' => $action));
Example #25
0
<?php

include './classes/user.php';
$oUser = new User();
$post = $_POST['post'];
if ($post == 'login') {
    $sUsername = $_POST['username'];
    $sPassword = $_POST['password'];
    $oUser->login($sUsername, $sPassword);
} elseif ($post == 'regsiter') {
    $sUsername = $_POST['username'];
    $sPassword = $_POST['password'];
    $oUser->addUser($sUsername, $sPassword);
}
Example #26
0
     $userName = $_POST['userName'];
     $userPwd = $_POST['userPwd'];
     $userAction = new User();
     if ($userAction->checkUserLogin($userName, $userPwd)) {
         $_SESSION["username"] = $userName;
         echo "1";
     } else {
         echo "0";
     }
     break;
 case "addadminuser":
     $userName = $_POST['userName'];
     $userPwd = $_POST['userPwd'];
     $id = $_POST['id'];
     $userAction = new User();
     if ($userAction->addUser($userName, $userPwd, $id)) {
         echo "1";
     } else {
         echo "0";
     }
     break;
 case "deladminuser":
     $items = $_POST['items'];
     $id = explode(",", $items);
     $userAction = new User();
     foreach ($id as $ide) {
         $userAction->delUser($ide);
     }
     echo "1";
     break;
 case "getuserinfo":
Example #27
0
    $pass_1 = $objForm->getPost('password');
    $pass_2 = $objForm->getPost('confirm_password');
    if (!empty($pass_1) && !empty($pass_2) && $pass_1 != $pass_2) {
        $objValid->add2Errors('password_mismatch');
    }
    $email = $objForm->getPost('email');
    $user = $objUser->getByEmail($email);
    if (!empty($user)) {
        $objValid->add2Errors('email_duplicate');
    }
    if ($objValid->isValid()) {
        // add hash for activating account
        $objValid->_post['hash'] = mt_rand() . date('YmdHis') . mt_rand();
        // add registration date
        $objValid->_post['date'] = Helper::setDate();
        if ($objUser->addUser($objValid->_post, $objForm->getPost('password'))) {
            $_SESSION['link'] = $_POST['link'];
            Helper::redirect('/start/?page=registered');
        } else {
            Helper::redirect('/start/?page=registered-failed');
        }
    }
}
require_once '_header.php';
?>

<h1>Login</h1>

<form action="" method="post">
<table cellspacing="0" cellpadding="0" class="tbl_insert" border="0">
	<tr>
Example #28
0
 public function createSiteAdmin($params)
 {
     include_once 'sites/' . $params->siteId . '/conf.php';
     include_once 'dataProvider/User.php';
     $u = new User();
     $userParams = new stdClass();
     $userParams->title = 'Mr.';
     $userParams->fname = 'Administrator';
     $userParams->lname = 'Administrator';
     $userParams->username = $params->adminUsername;
     $userParams->password = $params->adminPassword;
     $userParams->authorized = 1;
     $userParams->active = 1;
     $userParams->role_id = 1;
     $u->addUser($userParams);
     return array('success' => true);
 }
 public function addUser()
 {
     if (isset($_POST['submit'])) {
         if ($_POST['nip'] == "" || $_POST['nama'] == "" || $_POST['pass'] == "" || $_POST['cpass'] == "" || $_POST['akses'] == "" || $_FILES['upload'] == "") {
             echo 'ada field yang masih kosong';
         } else {
             if ($_POST['pass'] !== $_POST['cpass']) {
                 echo 'password tidak sama dengan confirm password';
             } else {
                 //FILES
                 $allowedExts = array("jpg", "jpeg", "png");
                 $ext = explode('.', $_FILES['upload']['name']);
                 $extension = $ext[count($ext) - 1];
                 if (in_array($extension, $allowedExts)) {
                     $img_small = new ResizeImage($_FILES["upload"]["tmp_name"]);
                     $img_small->resizeTo(64, $resizeOption = 'maxwidth');
                     $img_small->saveImage("files/foto/" . $_POST['nip'] . "_small." . $extension);
                     move_uploaded_file($_FILES["upload"]["tmp_name"], "files/foto/" . $_POST['nip'] . "." . $extension);
                 } else {
                 }
                 $user = new User($registry);
                 $user->set_nip($_POST['nip']);
                 $user->set_nmUser($_POST['nama']);
                 $user->set_pass($_POST['pass']);
                 $user->set_akses($_POST['akses']);
                 $user->set_foto($_POST['nip'] . "." . $extension);
                 $user->addUser($user);
             }
         }
     }
     header('location:' . URL . 'admin/listUser');
 }
Example #30
0
/**
* Insert a user into the database with the info stored in $_POST.
*/
function addUser()
{
    $id = User::addUser($_POST['fName'], $_POST['lName'], $_POST['creditProvider'], $_POST['creditCardNum'], $_POST['email'], $_POST['password']);
    echo json_encode($id);
}