public static function registerUser()
 {
     $newUser = new User();
     $username = $_POST['username'];
     $password = $_POST['password'];
     $password2 = $_POST['password2'];
     $boo = FALSE;
     $errors = User::validateUsername($username);
     if (count($errors) > 0) {
         View::make('/user/register.html', array('message' => $errors[0]));
     }
     $errors = User::validatePassword($password);
     if (count($errors) > 0) {
         View::make('/user/register.html', array('username' => $username, 'message' => $errors[0]));
     }
     $newUser->setUsername($username);
     $newUser->setPassword($password);
     $newUser->setAdmin($boo);
     if ($password == $password2) {
         $newUser->saveUser();
         $_SESSION['user'] = $newUser->user_id;
     } else {
         Redirect::to('/register', array('username' => $username, 'message' => 'Passwords do not match.'));
     }
     Redirect::to('/', array('message' => 'User has been registered.'));
 }
Example #2
0
 /**
  * Saves a user to the database
  *
  * @url POST /users
  * @url PUT /users/$id
  */
 public function saveUser($id = null, $data)
 {
     // ... validate $data properties such as $data->username, $data->firstName, etc.
     $data->id = $id;
     $user = User::saveUser($data);
     // saving the user to the database
     return $user;
     // returning the updated or newly created user object
 }
 /**
  * Saves the user from form whatever type
  */
 public function saveUser($new)
 {
     $this->setState('SAVE_USER');
     //Create Strings
     $username = "";
     $fullname = $this->getInputString("name", null, "P");
     $email = $this->getInputString("email", null, "P");
     $password1 = $this->getInputString("password1", null, "P");
     $password2 = $this->getInputString("password2", null, "P");
     $accesslvl = $this->getInputString("access", null, "P");
     //If loading from post data
     if ($new) {
         //Get from post
         $username = $this->getInputString("username", null, "P");
     } else {
         //Get from URL
         $username = $this->getActiveRequest();
     }
     //If username empty return false
     if (empty($username)) {
         //User not filled in correctly
         return false;
     }
     //If no new passwords
     if (empty($password1)) {
         $password1 = "";
         $password2 = "";
     } else {
         //If passwords were filled in
         if ($password1 != $password2) {
             //Password 1 not equal to password 2
             return false;
         }
     }
     //Include the User Library
     include_once "core/lib/User.php";
     //Setup user class
     $u = new User();
     //USER LIB API
     $u->saveUser($username, $fullname, $email, $password1, $accesslvl);
     //Was Success
     return true;
 }
Example #4
0
$o = new User();
$s = new XoopsSecurity();
$action = $_REQUEST['action'];
$isadmin = $xoopsUser->isAdmin();
$uid = $xoopsUser->getVar('uid');
switch ($action) {
    case "search":
        //return xml table to grid
        $wherestring = " WHERE uid>0";
        $o->showUser($wherestring);
        exit;
        //after return xml shall not run more code.
        break;
    case "save":
        //process submited xml data from grid
        $o->saveUser();
    case "searchsetting":
        //return xml table to grid
        $wherestring = " WHERE usersetting_id>0";
        $o->showSetting($wherestring);
        exit;
        //after return xml shall not run more code.
        break;
    case "savesetting":
        //process submited xml data from grid
        $o->saveSetting();
    case "lookup":
        //return xml table to grid
        include_once "../simantz/class/EBAGetHandler.php";
        $defaultorganization_id = $_SESSION['defaultorganization_id'];
        $lookupdelay = 1000;
Example #5
0
File: reg.php Project: Klym/flame
	if (isset($_POST['pol'])) {$pol = User::checkUserData($_POST['pol']);}
	if (isset($_POST['year'])) {$year = User::checkUserData($_POST['year']);}
	if (isset($_POST['month'])) {$month = User::checkUserData($_POST['month']);}
	if (isset($_POST['day'])) {$day = User::checkUserData($_POST['day']);}
	
	if (empty($email) || empty($login) || empty($password) || empty($repeat_pass) || empty ($name) || empty($fam) || empty($pol) || empty($year) || empty($month) || empty($day)) {
		exit("Вы не ввели всю информацию, вернитесь и заполните все поля.");
	}
	else {
		if ($password != $repeat_pass) {
			exit("Пароли не совпадают.");
		}
		$birthDate = $year."-".$month."-".$day;
		$avatar = "net-avatara.jpg";
		$user = new User($email,$login,$password,$name,$fam,$pol,null,$birthDate,$avatar,2,$db);
		$user->saveUser();
		$user->sendMessage();
	}
}
else {
	$monthes = array(1 => "Января", 2 => "Февраля", 3 => "Марта", 4 => "Апреля", 5 => "Мая", 6 => "Июня", 7 => "Июля", 8 => "Августа", 9 => "Сентября", 10 => "Октября", 11 => "Ноября", 12 => "Декабря");
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="description" content="<? echo $page->meta_d; ?>">
<meta name="keywords" content="<? echo $page->meta_k; ?>">
<link rel="shortcut icon" href="img/favicon.ico">
<link rel="stylesheet" type="text/css" href="css/reset.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
Example #6
0
                     $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';
                 }
             }
             break;
     }
     load_template('admin-' . $template->subnav['area'][$area]['template']);
 } else {
     $template->page_title = 'Admin Dashboard';
Example #7
0
// Check if user is webmaster
if (!$user->hasEditPermission()) {
    $login->printLoginForm();
    exit;
}
// Delete user
$deleteUser = getValue("deleteUser");
if (!empty($deleteUser)) {
    // Delete user
    $user->deleteUser();
    // Redirect to user index
    redirect(scriptUrl . "/" . folderUsers);
} else {
    if (!empty($_GET["save"])) {
        // Save user data
        $errors = $user->saveUser();
        // Redirect to user index
        if (!$errors->hasErrors()) {
            redirect(scriptUrl . "/" . folderUsers);
        }
    }
}
// Add navigation links
$site->addNavigationLink(scriptUrl . "/" . folderAdmin, $lAdminIndex["Header"]);
$site->addNavigationLink(scriptUrl . "/" . folderUsers, $lUserIndex["Header"]);
$site->addNavigationLink(scriptUrl . "/" . folderUsers, !empty($user->id) ? $lEditUser["EditUser"] : $lEditUser["NewUser"]);
// Print common header
$site->printHeader();
// Print page description
if (empty($user->id)) {
    echo "<p>" . $lEditUser["NewUserText"] . "</p>";
         }
         //Creates a long random string as salt.
         $salt = generateRandStr(30);
         //Saves site title
         $io->saveFile("data/config/site_title.dat", $title);
         $io->saveFile("data/config/salt.dat", $salt);
         //Save the site Locale
         $io->saveFile("data/config/locale.dat", $locale);
         //Include user libraries
         include "core/lib/User.php";
         //Create new user
         $u = new User();
         //Removing administrator user.
         @unlink("data/users/admin.dat");
         //Creates the new user
         $u->saveUser($username, $fullname, $email, $password, "administrator");
         //Install essentially complete
         @unlink("cache/index.html");
         $out = str_replace("%MESSAGE%", "<p><strong>Complete!</strong><br />The CMS will now try to delete the installation file due to security reasons.</p><form action='install.php?step=4' method='post'><input style='height: 40px;width: 150px;float: right;' type='submit' value='Delete Install Files' /></form>", $out);
     } else {
         redirect(2, true, 1);
     }
     //Put Step number in
     $out = str_replace("%STEP%", "3", $out);
     if (isset($_GET['error'])) {
         //Save error message
         $out = str_replace("%ERROR_MESSAGE%", "Delete failed. Please remove it via FTP.", $out);
     } else {
         $out = str_replace("%ERROR_MESSAGE%", "", $out);
     }
 } else {
Example #9
0
<?php

if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
    header("Access-Control-Allow-Origin: *");
    header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
    exit;
}
require_once 'lib/load.php';
$user = new User();
$data = file_get_contents("php://input");
$result = array();
if (!empty($data)) {
    $result = @json_decode($data, true);
}
if (!empty($result)) {
    $user->saveUser($result);
    $result['success'] = true;
} else {
    $result['success'] = false;
}
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept");
header("Content-type: application/json");
echo json_encode($result);
Example #10
0
<?php

include "header.html";
include "objects.php";
echo "<h1>Hello World!</h1>";
// these are just tests lines
/*$user = new User("Dillon");
	echo $user->get_firstname();
	$user->set_firstname("Heath");
	echo $user->get_firstname(); */
User::saveUser();
include "footer.html";