Пример #1
0
 public function actionRegister()
 {
     $model = new User('register');
     $provinces = Province::model()->findAll();
     $provinces = CHtml::listData($provinces, 'idProvince', 'name');
     $cities = array();
     $districts = array();
     if (isset($_POST['User'])) {
         $model->attributes = $_POST['User'];
         if ($model->createUser()) {
             //Log in the new user
             $modelLoginForm = new LoginForm();
             $modelLoginForm->username = $model->username;
             $modelLoginForm->password = $model->conf_password;
             //because password has been md5
             if ($modelLoginForm->login()) {
                 $this->redirect(Yii::app()->user->returnUrl);
             }
         }
         if (isset($model->idProvince)) {
             $cities = City::model()->findAllByAttributes(array('idProvince' => $model->idProvince));
             $cities = CHtml::listData($cities, 'idCity', 'name');
         }
         if (isset($model->idCity)) {
             $districts = District::model()->findAllByAttributes(array('idCity' => $model->idCity));
             $districts = CHtml::listData($districts, 'idDistrict', 'name');
         }
     }
     $this->render('register', array('model' => $model, 'provinces' => $provinces, 'cities' => $cities, 'districts' => $districts));
 }
 public function run()
 {
     try {
         foreach ($this->groups as $g) {
             User::createGroup($g);
         }
         // Add super user
         $super = ['email' => '*****@*****.**', 'password' => 'password', 'first_name' => 'Fordyce', 'last_name' => 'Gozali', 'slug' => 'fordyce-gozali', 'activated' => true];
         $group = User::findGroupByName('Super User');
         if ($group) {
             $user = User::createUser($super);
             $user->addGroup($group);
         }
         //Add admins
         $admins = [['email' => '*****@*****.**', 'password' => 'password', 'first_name' => 'Admin', 'last_name' => '', 'slug' => 'admin', 'activated' => true]];
         $group = User::findGroupByName('Admin');
         if ($group) {
             foreach ($admins as $a) {
                 $user = User::createUser($a);
                 $user->addGroup($group);
             }
         }
     } catch (\Exception $e) {
         return $this->command->info($e->getMessage());
     }
 }
Пример #3
0
 public static function acceptRequest($req_id, $admin = false)
 {
     DB::updateRequestAccepted($req_id);
     $req = self::getRequest($req_id);
     $pass = User::createUser(array('email' => $req['email'], 'login' => $req['login'], 'admin' => $admin ? 1 : 0, 'request_id' => $req_id));
     sendMessage($req['email'], "Ваша заявка одобрена. Пароль: {$pass}");
 }
 public function register()
 {
     $this->db->begin();
     $modelUser = new User();
     $res = $modelUser->createUser($this->request->getPost());
     if (false == $res) {
         $this->db->rollback();
         return parent::resWithErrMsg($modelUser->getMessages());
     }
     $this->db->commit();
     return parent::success();
 }
Пример #5
0
 /**
  * Public: Set user
  */
 public function setUser($username)
 {
     $app = App::getInstance();
     try {
         parent::__construct($username);
     } catch (\FelixOnline\Exceptions\ModelNotFoundException $e) {
         User::createUser($username);
         parent::__construct($username);
     }
     $this->setVisits($this->getVisits() + 1);
     $this->setIp($app['env']['REMOTE_ADDR']);
     $this->setTimestamp(time());
     $this->save();
 }
Пример #6
0
 function post_index($f3)
 {
     $user = \User::createUser(\kksd\Sesi::$DB);
     $user->load(array("email=?", $f3->POST['email']));
     if ($user->checkLogin($f3->get('POST.email'), $f3->get('POST.password'))) {
         $user->load(array("email=?", $f3->POST['email']));
         $f3->SESSION['user_type'] = 'admin';
         if (!$f3->POST['remember']) {
             $f3->SESSION['user'] = $user->id;
             $f3->SESSION['user_obj'] = $user;
         } else {
             $f3->set('COOKIE.user', $user->id, time() + 24 * 3600 * 7);
         }
         $f3->reroute('@admin_home');
         return;
     }
     \Flash::instance()->addMessage('Wrong password, you morron!', 'danger');
     $this->index($f3);
     return;
 }
Пример #7
0
 static function testUser()
 {
     $user = new User();
     $logout = User::logout();
     $_POST["user"] = self::generateRandomString();
     $_POST["pass"] = self::generateRandomString();
     $_POST["email"] = self::generateRandomString();
     if ($register = User::createUser()) {
         echo 'CREATE USER: <font color="green">Stworzono uzytkownika o id: ' . $register . ' Dane: ' . $_POST["user"] . ' Haslo: ' . $_POST["pass"] . '</font></br>';
     } else {
         echo 'CREATE USER: <font color="red">ERROR!</font>';
     }
     $login = User::login();
     $id = User::getUID();
     if ($login == true) {
         echo 'LOGIN: <font color="green">Zalogowano, twoje UID: ' . $id . '</font></br>';
     } else {
         echo '<font color="red">LOGIN: ERROR!</font></br>';
         return false;
     }
     if (User::checkLogin()) {
         echo 'CHECK LOGIN: <font color="green">Zalogowany</font></br>';
     } else {
         echo 'CHECK LOGIN: <font color="red">Niezalogowany</font></br>';
         return false;
     }
     if ($delete = User::deleteUser() == true) {
         echo 'DELETE USER: <font color="green">Usunieto uzytkownika</font></br>';
     } else {
         echo 'DELETE USER: <font color="red">ERROR</font></br>';
         return false;
     }
     User::logout();
     if (!isset($_SESSION["uid"])) {
         echo 'LOGOUT: <font color="green">Wylogowano!</font></br>';
     } else {
         echo 'LOGOUT: <font color="red">ERROR!</font></br>';
         return false;
     }
     return true;
 }
Пример #8
0
 public function registerAction()
 {
     //	$formRegister= new Form_User();
     $formUser = new Form_User();
     $formUser->removeElement('avatar');
     $formUser->removeElement('status');
     $formUser->removeElement('role');
     $formUser->removeElement('profile');
     if ($this->getRequest()->isPost()) {
         if (!$formUser->isValid($_POST)) {
             $userData = $formUser->getValues();
             $modelUser = new User();
             $newUser = $modelUser->createUser($userData);
             if ($newUser) {
                 $this->_redirect('/user/account/id/' . $newUser);
             }
         }
     }
     $this->view->formUser = $formUser;
     //$this -> view -> formUser = $formRegister;
 }
Пример #9
0
 public function pgpSignUp()
 {
     if (self::sessionGet('signin_text')) {
         return Redirect::to('success');
     }
     if (Request::isMethod('get')) {
         return View::make('auth.signup');
     } else {
         $input = Input::only('key', 'info');
         User::validate($input);
         self::botLimit();
         $info = $this->checkKey($input['key']);
         if (User::where('user_fp', '=', $info['fingerprint'])->first() != NULL) {
             return Redirect::to('retrieve');
         }
         $result = User::createUser($info['fingerprint'], $input);
         $this->gpg->addencryptkey($info['fingerprint']);
         $text = self::formatSignupText($result['user']->id, $result['priv_hash']);
         self::sessionSet('signin_text', $this->gpg->encrypt($text));
         return Redirect::to('success');
     }
 }
Пример #10
0
                    $notifications[] = MakeNotification("error", Language::Get('main', 'differentPasswords', $langTemplate));
                }
            } else {
                $notifications[] = MakeNotification("error", Language::Get('main', 'incorrectOldPassword', $langTemplate));
            }
        } else {
            $notifications = $notifications + $f->notifications;
        }
    } else {
        if ($_POST['action'] == "SetAccountInfo") {
            $f = new FormEvaluator($_POST);
            $f->checkStringForKey('language', FormEvaluator::OPTIONAL, 'warning', '???.');
            if ($f->evaluate(true)) {
                $foundValues = $f->foundValues;
                $language = $foundValues['language'];
                $newUserSettings = User::encodeUser(User::createUser($uid, null, null, null, null, null, null, null, null, null, null, null, null, null, $language));
                $URI = $databaseURI . "/user/" . $uid;
                http_put_data($URI, $newUserSettings, true, $message);
                if ($message == "201") {
                    $notifications[] = MakeNotification("success", Language::Get('main', 'languageChanged', $langTemplate));
                }
            } else {
                $notifications = $notifications + $f->notifications;
            }
        }
    }
}
// load user data from the database
$databaseURI = $getSiteURI . "/accountsettings/user/{$uid}";
$accountSettings_data = http_get($databaseURI, true);
$accountSettings_data = json_decode($accountSettings_data, true);
Пример #11
0
<?php

/**
 * Created by PhpStorm.
 * User: Dushyant
 * Date: 2015-10-30
 * Time: 12:00 PM
 */
//user class required
require_once "../../Local/Classes/class.User.inc";
extract($_POST);
if (isset($btnSubmit)) {
    $user = new User();
    $result = $user->createUser($txtFirstName, $txtLastName, $txtEmail, $txtPassword, $drpUserRole, $txtBirthDate, $rdbGender, $txtCredentials, $txtWorkPhone, $txtCellPhone, $txtFax, $txtAddress, $txtCity, $drpStdProvince, $txtPostalCode, $txtRegistrationNumber, $txtLicenseNumber);
    if ($result === true) {
        $notifications['addUserSuccess'] = "New user is success fully added";
    } else {
        $notifications['addUserError'] = $result;
    }
}
//include header and sidebar
include "header.php";
include "sidebar.php";
?>
    <form role="form" id="frm" method="post" action="<?php 
echo $_SERVER['PHP_SELF'];
?>
">
        <div class="form-group">
            <div id="page-wrapper">
                <!--Notifications-->
Пример #12
0
 public function actionRegister()
 {
     if (!param('useUserRegistration', 0)) {
         throw404();
     }
     $this->showSearchForm = false;
     $this->layout = '//layouts/inner';
     if (Yii::app()->user->isGuest) {
         if (param('user_registrationMode') == 'without_confirm') {
             $model = new User('register_without_confirm');
         } else {
             $model = new User('register');
         }
         if (isset($_POST['User']) && BlockIp::checkAllowIp(Yii::app()->controller->currentUserIpLong)) {
             $model->attributes = $_POST['User'];
             if ($model->validate()) {
                 $model->activatekey = User::generateActivateKey();
                 $user = User::createUser($model->attributes);
                 if ($user) {
                     $model->id = $user['id'];
                     $model->password = $user['password'];
                     $model->email = $user['email'];
                     $model->username = $user['username'];
                     $model->activatekey = $user['activatekey'];
                     $model->activateLink = $user['activateLink'];
                     $notifier = new Notifier();
                     $notifier->raiseEvent('onNewUser', $model, array('user' => $user['userModel']));
                     if (param('user_registrationMode') == 'without_confirm') {
                         $login = new LoginForm();
                         $login->setAttributes(array('username' => $user['username'], 'password' => $user['password']));
                         if ($login->validate() && $login->login()) {
                             User::updateUserSession();
                             User::updateLatestInfo(Yii::app()->user->id, Yii::app()->controller->currentUserIp);
                             $this->redirect(array('/usercpanel/main/index'));
                         } else {
                             /*echo 'getErrors=<pre>';
                             		print_r($login->getErrors());
                             		echo '</pre>';
                             		exit;*/
                             showMessage(Yii::t('common', 'Registration'), Yii::t('common', 'You were successfully registered.'));
                         }
                     } else {
                         showMessage(Yii::t('common', 'Registration'), Yii::t('common', 'You were successfully registered. The letter for account activation has been sent on {useremail}', array('{useremail}' => $user['email'])));
                     }
                 } else {
                     showMessage(Yii::t('common', 'Registration'), Yii::t('common', 'Error. Repeat attempt later'));
                 }
             } else {
                 $model->unsetAttributes(array('verifyCode'));
             }
         }
         $this->render('register', array('model' => $model));
     } else {
         $this->redirect('index');
     }
 }
Пример #13
0
 */
$app = new \Slim\Slim();
/**
 * Step 3: Define the Slim application routes
 *
 * Here we define several Slim application routes that respond
 * to appropriate HTTP request methods. In this example, the second
 * argument for `Slim::get`, `Slim::post`, `Slim::put`, `Slim::patch`, and `Slim::delete`
 * is an anonymous function.
 */
// GET route
$app->get('/', function () {
    //instance of User class
    $u = new User();
    $conn = $u->connect();
    $u->createUser($conn, 'milos', 'babic', '1988-04-15', 'Serbia', 'baki', '123', 'a@a.a');
});
// GET rerister/ registration form
$app->get('/register', function () {
    echo "\n        <form action='' method='post'>\n            <label>first name</label><br />\n            <input type='text' name='txt_name' /><br />\n            <label>last name</label><br />\n            <input type='text' name='txt_surname' /><br />\n            <label>date of birth (DD/MM/YYYY)</label><br />\n            <input type='text' name='txt_day' /><input type='text' name='txt_mounth' /><input type='text' name='txt_year' /><br />\n            <label>coutry</label><br />\n            <input type='text' name='txt_country' /><br />\n            <label>username</label><br />\n            <input type='text' name='txt_username' /><br />\n            <label>pasword</label><br />\n            <input type='password' name='txt_pass' /><br />\n            <label>email</label><br />\n            <input type='text' name='txt_email' /><br />\n            <input type='submit' name='btn_register' value='register' />\n        </form>\n        ";
});
// POST route
$app->post('/register', function () {
    //db for later check of existing username
    $u = new User();
    $conn = $u->connect();
    //cehck if some post aprams are missing
    if (empty($_POST['first_name']) || empty($_POST['last_name']) || empty($_POST['date_of_birth']) || empty($_POST['country']) || empty($_POST['username']) || empty($_POST['password']) || empty($_POST['email'])) {
        returnError('Missing or empty post parameters.');
    }
    //assigning post paramms to variables
                        	<label> Nama Depan : <input type="text" name="fname"  required autofocus></label>
                        </p>
                        <p>
                        <label> Nama Belakang : <input type="text" name="lname"  required autofocus></label>
                        </p>
                        <p>
                        <label> Username : <input type="text" name="username"  required autofocus></label>
                        </p>
                        <p>
                        <label> Password :  <input type="password" name="pass" required></label>
                        </p>
                        <p>
                        <label> Profile Picture :  <input type="file" name="photo" id="photo" ></label>
                        </p>
                        <button type="submit" name="regist">Register</button>

                    </fieldset>
                </form>
            </div>
        </div>
    
    </body>


</html>
<?php 
include 'Loginclass.php';
$user = new User();
if (isset($_POST['regist'])) {
    $user->createUser();
}
Пример #15
0
        if (empty($_POST["comment"])) {
            $comment = " ";
        } else {
            $comment = test_input($_POST["comment"]);
        }
        if ($name = "" && ($lastname = "" && $create_email_error == "" && $create_password_error == "" && ($gender = ""))) {
            echo "Saab kasutajat luua! Kasutajanimi on " . $create_email . " ja parool on " . $create_password;
            $password_hash = hash("sha512", $create_password);
            echo "<br>";
            echo $password_hash;
            //createUser($name, $lastname, $create_email, $password_hash, $age, $gender);
            /*  $stmt = $mysqli->prepare("INSERT INTO users (name, lastname, email, password, age, gender) VALUES (?, ?, ?, ?, ?, ?)");
            				$stmt->bind_param("ssssis", $name, $lastname, $create_email, $create_password, $age, $gender);
            				$stmt->execute();
            				$stmt->close(); */
            $create_response = $User->createUser($name, $lastname, $create_email, $password_hash, $gender);
        }
    }
    // create if end
}
// funktsioon, mis eemaldab koikvoimaliku uleliigse tekstist
function test_input($data)
{
    $data = trim($data);
    $data = stripslashes($data);
    $data = htmlspecialchars($data);
    return $data;
}
// siin kirjutame uut php koogdi
/*
//(kehtestame) m22rame email'i vigu
Пример #16
0
 /**
  * Creates an Invitation object, for database post(insert) and put(update).
  * Not needed attributes can be set to null.
  *
  * @param string $leaderId The id of the leader.
  * @param string $memberId The id of a member.
  * @param string $sheetId The id of the exercise sheet.
  *
  * @return an invitation object
  */
 public static function createInvitation($leaderId, $memberId, $sheetId)
 {
     return new Invitation(array('sheet' => $sheetId, 'leader' => User::createUser($leaderId, null, null, null, null, null, null, null, null, null), 'member' => User::createUser($memberId, null, null, null, null, null, null, null, null, null)));
 }
Пример #17
0
<?php

session_start();
$whitelist = array('message', 'submit', 'name', 'game_id');
require 'controller/dbsettings.php';
if ($submit == "Join") {
    //$name=substr($name,0,20);
    $_SESSION["game_id"] = $game_id;
    // User::createUser($game_id,$name);
    if (Game::findGame() == null) {
        header('Location: joinQuiz.php?error=Bad Game');
    }
    if (!User::createUser($game_id, $name)) {
        header('Location: joinQuiz.php?error=Bad Username');
    }
    $game = Game::findGame();
    $questionNumber = $game->round;
    if ($questionNumber != -1) {
        if ($game->type == "geo") {
            header('Location: userScreen.php?question=' . $questionNumber);
        } else {
            $type = ucwords($game->type);
            header('Location: userScreen' . $type . '.php?question=' . $questionNumber);
        }
    }
}
?>
 <html>
 <head>
    <link rel="stylesheet" href="style/global.css">
    <link rel="stylesheet" href="style/joinQuiz.css">
Пример #18
0
 public function register()
 {
     $request = $this->getHeaderBody();
     $userModel = new User();
     //验证手机 模拟通过
     if (!$request->key) {
         sendMsg('KEY NOT FIND', 1);
     }
     $phone = $this->mCache->get($request->key);
     if (!$phone) {
         sendMsg('KEY ERROR', 1);
     }
     if ($userModel->issetPhone($phone['phone'])) {
         sendMsg('PHONE USED', 1);
     }
     //清理key
     $this->mCache->delete($request->key);
     $userModel = new User();
     $createData = ['phone' => $phone['phone'], 'registerTime' => new MongoDate(), 'registerIP' => $this->request->getClientAddress()];
     foreach ($request as $key => $val) {
         if (in_array($key, ['phone', 'password', 'userName', 'sex'])) {
             $createData[$key] = $val;
         }
         if ($key == 'password') {
             $createData[$key] = mkPwd($val);
         }
         //头像
         if ($key == 'headerimg' && file_exists(TEMP_PATH . '/' . $val)) {
             if (copy(TEMP_PATH . '/' . $val, HEADERIMG_PATH . '/' . $val)) {
                 $createData['headImg'] = $val;
             }
         }
     }
     $res = $userModel->createUser($createData);
     if ($res) {
         //注册EM账户密码
         EM::onConstruct($this->config->em_conf);
         $imUser = EM::createUser();
         if ($imUser) {
             $imUser['userId'] = $res;
             $userModel->create_imuser($imUser);
         }
         sendMsg("OK");
     } else {
         sendMsg('NOT CREATE', 1);
     }
 }
Пример #19
0
    }
}
$emails = preg_replace('/,$/', '', $emails);
if (!empty($login)) {
    if (empty($password)) {
        $password = $User->randomPass();
    }
    $prenom = "";
    if (isset($_POST['prenom'])) {
        $prenom = $_POST['prenom'];
    }
    $user_data = array("id_user" => $_POST['id_user'], "login" => $login, "first_name" => $prenom, "last_name" => $_POST['nom'], "password" => $_POST['password'], "email" => $emails, "role" => array("client"), "disabled" => "off", "admin" => "off");
    if ($User->exists($id_user)) {
        $User->saveData($user_data);
    } else {
        $id_user = $User->createUser($user_data);
    }
}
$q = sprintf("UPDATE webfinance_clients SET " . "nom='%s',\n              addr1='%s',\n              addr2='%s',\n              addr3='%s',\n              cp='%s',\n\t      ville='%s',\n              rcs='%s',\n              vat='%s',\n              capital='%s',\n              pays='%s',\n              tel='%s',\n              fax='%s',\n              web='%s',\n\t      email='%s',\n\t      vat_number='%s',\n              siren='%s',\n              id_company_type='%d',\n              id_user=%d,\n              password='******',\n              rib_titulaire='%s',\n              id_mantis='%d',\n              id_toggl='%d',\n              supportHoursIncludedInContract='%s',\n              language='%s',\n              id_business_entity=%d,\n              contract_signer = '%s',\n              id_contract_signer_role = %d,\n              invoice_delivery = '%s'\n            WHERE id_client=%d", mysql_real_escape_string($nom), mysql_real_escape_string($addr1), mysql_real_escape_string($addr2), mysql_real_escape_string($addr3), mysql_real_escape_string($cp), mysql_real_escape_string($ville), mysql_real_escape_string($rcs), mysql_real_escape_string($vat), mysql_real_escape_string($capital), mysql_real_escape_string($pays), mysql_real_escape_string(removeSpace($tel)), mysql_real_escape_string(removeSpace($fax)), mysql_real_escape_string($web), mysql_real_escape_string($emails), mysql_real_escape_string($vat_number), mysql_real_escape_string($siren), mysql_real_escape_string($id_company_type), mysql_real_escape_string($_POST['id_user']), mysql_real_escape_string($password), mysql_real_escape_string($rib_titulaire), mysql_real_escape_string($id_mantis), mysql_real_escape_string($id_toggl), mysql_real_escape_string($supportHoursIncludedInContract), mysql_real_escape_string($clt_language), mysql_real_escape_string($id_business_entity), mysql_real_escape_string($contract_signer), mysql_real_escape_string($id_contract_signer_role), mysql_real_escape_string($invoice_delivery), mysql_real_escape_string($id_client));
mysql_query($q) or die(mysql_error());
// Check if we have to rename clients
if ($_POST['nom'] != $Client->nom) {
    // Rename Mantis project
    $mantis_project = array('name' => $nom, 'view_state' => array('id' => 50));
    $mantis = new WebfinanceMantis();
    $mantis->updateProject($id_mantis, $mantis_project);
    // Rename Toggl client
    $toggl = new WebfinanceToggl();
    $toggl->renameClient($id_client, $nom);
}
if (isset($_SESSION['message'])) {
Пример #20
0
        // check if user in db => login
        if (mysql_num_rows($ObjUser->check_facebook_user($facebook_id)) > 0) {
            $user = mysql_fetch_array($ObjUser->check_facebook_user($facebook_id));
            //Random Image
            $memory = mysql_fetch_array($ObjMemory->getRandMemory($user['id']));
            $base_url = "http://the-memories.com/memoryphoto/";
            $message = $memory ? $base_url . $memory['MemoryPhoto'] : null;
            $success = true;
            if ($user['status'] == "0") {
                //User is blocked
                $message = "Your account has been blocked. Please contact site administrator";
                $success = false;
            }
            $response = array('success' => $success, 'message' => $message, 'first_name' => $user['firstname'], 'last_name' => $user['lastname'], 'gender' => $user['gender'], 'birth' => $user['dob'], 'who_views' => $user['ProfileView'], 'email' => $user['email'], 'id' => $user['id']);
        } else {
            //user not in db
            $response = $ObjUser->createUser($first_name, $last_name, $username, $birthday, $email, $facebook_id, $gender);
            if ($response && $response['id']) {
                $ObjUserRegister->SentFacebookPasswordEmail($email, $response['temp_pass'], $first_name, $last_name);
                $response = array('success' => true, 'message' => 'A new user had been created', 'first_name' => $first_name, 'last_name' => $last_name, 'gender' => $gender, 'birth' => $birthday, 'email' => $email, 'who_views' => 1, 'id' => $response['id']);
            } else {
                $response = array('success' => false, 'message' => "Not called properly with user_id parameter! DB->Error");
            }
        }
    } else {
        $response = array('success' => false, 'message' => "Not called properly with facebook_id parameter!");
    }
} else {
    $response = array('success' => false, 'message' => "Not called properly with facebook_id parameter!");
}
echo json_encode($response);
Пример #21
0
<?php

/**
 * this file will create a new user from the input given
 */
require "../includes.php";
$return = array();
$email = $_POST['email'];
$password = $_POST['password'];
$name = $_POST['name'];
$user = User::createUser($email, $password, $name, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
if ($user === false) {
    $return['errors'] = "A user with that email already exist";
} else {
    $return['errors'] = "";
    $_SESSION['user'] = $user;
}
echo json_encode($return);
?>

Пример #22
0
 /**
  *  @brief Create new user
  *
  *  PUT https://server/pathname/version/username
  *
  *  Requests that an account be created for username.
  *
  *  The body is a JSON mapping and should include:
  *    password: the password to be associated with the account.
  *    e-mail: Email address associated with the account.
  *    captcha-challenge: The challenge string from the captcha.
  *    captcha-response: The response to the captcha.
  *
  *  An X-Weave-Secret can be provided containing a secret string known by the server.
  *  When provided, it will override the captcha. This is useful for testing and automation.
  *
  *  The server will return the lowercase username on success.
  *
  *  Possible errors:
  *    503: there was an error creating the reset code
  *    400: 4 (user already exists)
  *    400: 6 (Json parse failure)
  *    400: 12 (No email address on file)
  *    400: 7 (Missing password field)
  *    400: 9 (Requested password not strong enough)
  *    400: 2 (Incorrect or missing captcha)
  *
  *  @param string $userName
  */
 private function createUser($syncUserHash)
 {
     $inputData = $this->getInputData();
     // JSON parse failure
     if (!$inputData->isValid()) {
         Utils::sendError(400, 6);
         return true;
     }
     // No password
     if (!$inputData->hasValue('password')) {
         Utils::sendError(400, 7);
         return true;
     }
     // No email
     if (!$inputData->hasValue('email')) {
         Utils::sendError(400, 12);
         return true;
     }
     // User already exists
     if (User::syncUserExists($syncUserHash)) {
         Utils::sendError(400, 4);
         return true;
     }
     // Create user
     if (User::createUser($syncUserHash, $inputData->getValue('password'), $inputData->getValue('email'))) {
         OutputData::write(strtolower($syncUserHash));
     } else {
         Utils::sendError(400, 12);
     }
     return true;
 }
Пример #23
0
<?php

$f3 = (require "lib/base.php");
$f3->set("AUTOLOAD", "../lib");
$test = new Test();
$user = User::createUser(new DB\SQL("sqlite:/tmp/test.sqlite"));
$user->password = "******";
$test->expect($user->password != "abc", "Password is gonna be encrypted");
$user->name = "Hanspolo";
$user->email = "*****@*****.**";
$user->save();
$test->expect($user->_id > 0, "User was saved");
$user->load(array("id = ?", $user->_id));
$test->expect($user->checkLogin("*****@*****.**", "abc"), "Password can be verified");
$test->expect(!$user->checkLogin("*****@*****.**", "jklö"), "Wrong Password detected");
$test->expect(!$user->checkLogin("*****@*****.**", "abc"), "Wrong Email detected");
$test->expect($user->erase(), "User was deleted");
foreach ($test->results() as $result) {
    echo $result['text'] . "\t";
    if ($result['status']) {
        echo 'Pass';
    } else {
        echo 'Fail (' . $result['source'] . ')';
    }
    echo "\n";
}
Пример #24
0
<?php

include dirname(__DIR__) . "/users/User.php";
$name = $_POST["name_lastname"];
$user = $_POST["username"];
$pass = $_POST["password"];
$profile_id = $_POST["profile_id"];
$user_object = new User();
$user_create = $user_object->createUser($user, $pass, $name, $profile_id);
$status = $user_create["success"];
$messagge = $user_create["messagge"];
header("Location: ./create_view.php?status={$status}&messagge={$messagge}");
?>

Пример #25
0
 if (!$selectedNetwork->getAuthenticator()->isRegistrationPermitted()) {
     throw new Exception(_("Sorry, this network does not accept new user registration !"));
 }
 // Validate entered values
 validate_username($username);
 validate_email($email);
 validate_passwords($password, $password_again);
 // Check if user exists
 if (User::getUserByUsernameAndOrigin($username, $selectedNetwork)) {
     throw new Exception(_("Sorry, a user account is already associated to this username. Pick another one."));
 }
 if (User::getUserByEmailAndOrigin($email, $selectedNetwork)) {
     throw new Exception(_("Sorry, a user account is already associated to this email address."));
 }
 // Create user and send him the validation email
 $created_user = User::createUser(get_guid(), $username, $selectedNetwork, $email, $password);
 $created_user->sendValidationEmail();
 // Authenticate this new user automatically
 $errmsg = "";
 $authenticated_user = $selectedNetwork->getAuthenticator()->login($username, $password, $errmsg);
 if (empty($authenticated_user)) {
     throw new Exception(_("Unable to authenticate newly created user.  Please report this bug.  Error was: {$errmsg}"));
 }
 // While in validation period, alert user that he should validate his account ASAP
 $validationMsgHtml = "<div id='warning_message_area'>\n";
 $validationMsgHtml .= _("An email with confirmation instructions was sent to your email address.");
 $validationMsgHtml .= sprintf(_("Your account has been granted %s minutes of access to retrieve your email and validate your account."), $selectedNetwork->getValidationGraceTime() / 60);
 $validationMsgHtml .= _('You may now open a browser window or start your email client and go to any remote Internet address to obtain the validation email.');
 $validationMsgHtml .= "</div>\n";
 // If the user is at a REAL hotspot, login the user and give him his sign-up minutes right away
 $session = Session::getObject();
Пример #26
0
 empty($_REQUEST['username']) ? $username = '******' : ($username = $_REQUEST['username']);
 empty($_REQUEST['password']) ? $password = '' : ($password = $_REQUEST['password']);
 empty($_REQUEST['password2']) ? $password2 = '' : ($password2 = $_REQUEST['password2']);
 empty($_REQUEST['email']) ? $email = $_SERVER['SERVER_ADMIN'] : ($email = $_REQUEST['email']);
 $conn_string = "host={$CONF_DATABASE_HOST} port={$CONF_DATABASE_PORT} dbname={$CONF_DATABASE_NAME} user={$CONF_DATABASE_USER} password={$CONF_DATABASE_PASSWORD}";
 $connection = pg_connect($conn_string) or die;
 $sql = "SELECT * FROM users NATURAL JOIN server_stakeholders";
 $result = pg_query($connection, $sql);
 $result_array = pg_fetch_all($result);
 $username_db = $result_array[0]['username'];
 if (empty($username_db) && $action == 'create') {
     //Only allow creating an adminstrator if we don't already have one.  Otherwise we have a HUGE security hole.
     //      require_once(dirname(__FILE__) . '/config.php');
     require_once dirname(__FILE__) . '/include/common.php';
     require_once dirname(__FILE__) . '/classes/User.php';
     $created_user = User::createUser(get_guid(), $username, Network::getDefaultNetwork(), $email, $password);
     $user_id = $created_user->getId();
     # Add user to admin table, hide his username and set his account status to 1 (allowed)
     $sql = "INSERT INTO server_stakeholders (user_id, role_id, object_id) VALUES ('{$user_id}', 'SERVER_OWNER', 'SERVER_ID');\n";
     $sql .= "INSERT INTO network_stakeholders (user_id, role_id, object_id) VALUES ('{$user_id}', 'NETWORK_OWNER', 'default-network');\n";
     $sql .= "UPDATE users SET account_status='1' WHERE user_id='{$user_id}'";
     $result = pg_query($connection, $sql);
 }
 $sql = "SELECT * FROM users NATURAL JOIN server_stakeholders";
 $result = pg_query($connection, $sql);
 $result_array = pg_fetch_all($result);
 $username_db = $result_array[0]['username'];
 if (!empty($username_db)) {
     #if a username exists
     print "<table>\n";
     print "<tr><th colspan=2>Your current administrator accounts are:</th></tr>\n";
Пример #27
0
 /**
  * Get's the splash-only user.
  *
  * This is the user that people logged-in at a splash-only hotspot will
  * show up as.  This user always has multiple-login capabilities.
  *
  * @param string $username The username of the user
  * @param string $account_origin The account origin
  *
  * @return object A User object
  *
  * @access public
  */
 public function getSplashOnlyUser()
 {
     $username = '******';
     if (!empty($this->splashOnlyUser)) {
         $user = $this->splashOnlyUser;
     } else {
         $user = User::getUserByUsernameAndOrigin($username, $this);
         if (!$user) {
             $user = User::createUser(get_guid(), $username, $this, '', '');
             $user->setAccountStatus(ACCOUNT_STATUS_ALLOWED);
         }
         $this->splashOnlyUser = $user;
     }
     return $user;
 }
Пример #28
0
$app->get('/', 'welcome');
$app->get('/hello/', 'helloWhore');
// **
//Users
// **
$app->get('/users', function () use($app) {
    $user = new User();
    $user->getAllUsers($app);
});
$app->get('/users/:id', function ($id) use($app) {
    $user = new User();
    $user->getUser($app, $id);
});
$app->post('/users', function () use($app) {
    $user = new User();
    $user->createUser($app);
});
$app->put('/users/:id', function ($id) use($app) {
    $user = new User();
    $user->modifyUser($app, $id);
});
$app->delete('/users/:id', function ($id) use($app) {
    $user = new User();
    $user->deleteUser($app, $id);
});
// **
//Connexion
// **
$app->post('/connexion', function () use($app) {
    $co = new theConnexion();
    $co->connexion($app);
Пример #29
0
 /**
  *  @brief Create a new Mozilla Sync user.
  *
  *  PUT https://server/pathname/version/username
  *
  *  Requests that an account be created for username.
  *
  *  The body is a JSON mapping and should include:
  *    password: the password to be associated with the account.
  *    e-mail: Email address associated with the account.
  *    captcha-challenge: The challenge string from the captcha.
  *    captcha-response: The response to the captcha.
  *
  *  An X-Weave-Secret can be provided containing a secret string known by the server.
  *  When provided, it will override the captcha. This is useful for testing and automation.
  *
  *  The server will return the lowercase username on success.
  *
  *  Possible errors:
  *    503: there was an error creating the reset code
  *    400: 4 (user already exists)
  *    400: 6 (Json parse failure)
  *    400: 12 (No email address on file)
  *    400: 7 (Missing password field)
  *    400: 9 (Requested password not strong enough)
  *    400: 2 (Incorrect or missing captcha)
  *
  *  @param string $userHash Mozilla Sync user hash for the user to be
  *	created.
  */
 private function createUser($syncHash)
 {
     if (User::isAutoCreateUser()) {
         //auto create accounts only
         Utils::sendError(400, 4);
         Utils::writeLog("Failed to create user " . $syncHash . ". Registration disabled.");
     }
     $inputData = $this->getInputData();
     // JSON parse failure
     if (!$inputData->isValid()) {
         Utils::sendError(400, 6);
         Utils::writeLog("Failed to parse JSON for user " . $syncHash . ".");
     }
     // No password sent
     if (!$inputData->hasValue('password')) {
         Utils::sendError(400, 7);
         Utils::writeLog("Request for user " . $syncHash . " did not include a password.");
     }
     // No email sent
     if (!$inputData->hasValue('email')) {
         Utils::sendError(400, 12);
         Utils::writeLog("Request for user " . $syncHash . " did not include an email.");
     }
     // User already exists
     if (User::syncUserExists($syncHash)) {
         Utils::sendError(400, 4);
         Utils::writeLog("Failed to create user " . $syncHash . ". User already exists.");
     }
     // Create a new user
     if (User::createUser($syncHash, $inputData->getValue('password'), $inputData->getValue('email'))) {
         OutputData::write(strtolower($syncHash));
     } else {
         Utils::sendError(400, 12);
         Utils::writeLog("Failed to create user " . $syncHash . ".");
     }
 }
Пример #30
0
<?php

include '../conf.php';
if (!isset($_POST['username']) || !isset($_POST['password']) || !filter_var($_POST['username'], FILTER_VALIDATE_EMAIL)) {
    print_r(json_encode(array('success' => false, 'error' => 'INCORRECT_PARAMETERS')));
    exit;
}
$success = User::createUser($_POST['username'], $_POST['password']);
if (!$success) {
    print_r(json_encode(array("success" => false, "error" => "WRITE_ERROR", "session" => $_SESSION)));
    exit;
}
print_r(json_encode(array("success" => true, "session" => $_SESSION)));