PHP User::Insert Examples

PHP User::Insert - 14 examples found. These are the top rated real world PHP examples of User::Insert extracted from open source projects. You can rate examples to help us improve the quality of examples.
Example #1
0
 public function Insert()
 {
     global $obj, $model;
     include_once 'Model/user.php';
     $model = new User();
     if (isset($_POST['btnSubmit'])) {
         foreach ($_POST as $key => $value) {
             try {
                 $model->{$key} = $value;
             } catch (Exception $ex) {
             }
         }
         $model->Image = $_FILES['Image']['name'];
         if ($model->Insert()) {
             if ($_FILES['Image']['name'] != "") {
                 $sp = $_FILES['Image']['tmp_name'];
                 $dp = "images/user_images/" . $model->Id . $_FILES['Image']['name'];
                 move_uploaded_file($sp, $dp);
             }
             print '<span class="success">User Created</span>';
             $model = new User();
         } else {
             print '<span class="error">' . $model->Error . '</span>';
         }
     }
     include_once 'View/User/insert.php';
 }
Example #2
0
 protected function _RequireAuthentication()
 {
     $user = new User();
     $user->email = 'bugdar@bluestatic.org';
     $user->Insert();
     Bugdar::$auth = new AuthenticationTest($user);
 }
Example #3
0
 public function Fire()
 {
     if ($this->input->do == 'submit') {
         if (!filter_var($this->input->email, FILTER_VALIDATE_EMAIL)) {
             EventPump::Pump()->RaiseEvent(new StandardErrorEvent(l10n::S('INVALID_EMAIL')));
             return;
         }
         if (strlen($this->input->password) <= 4) {
             EventPump::Pump()->RaiseEvent(new StandardErrorEvent(l10n::S('PASSWORD_TOO_SHORT')));
             return;
         }
         $stmt = Bugdar::$db->Prepare("SELECT COUNT(*) AS count FROM users WHERE email = ?");
         $stmt->Execute(array($this->input->email));
         if ($stmt->FetchObject()->count > 0) {
             EventPump::Pump()->RaiseEvent(new StandardErrorEvent(l10n::S('EMAIL_IN_USE')));
             return;
         }
         $alias = preg_replace('/[^a-zA-Z0-9\\-_,\\. ]/', '', $this->input->alias);
         $salt = phalanx\base\Random(10);
         $user = new User();
         $user->email = $this->input->email;
         $user->alias = preg_replace('/[^a-zA-Z0-9\\-_,\\. ]/', '', $this->input->alias);
         $user->password = sha1($this->input->password);
         $user->usergroup_id = Usergroup::ROLE_REGISTERED;
         $user->Insert();
         $this->user_id = $user->user_id;
         EventPump::Pump()->PostEvent(new StandardSuccessEvent('login', l10n::S('USER_REGISTER_SUCCESS')));
     }
 }
Example #4
0
 public function testUserLogin()
 {
     Bugdar::$auth = new AuthenticationTest(NULL);
     // Create the user.
     $user = new User();
     $user->email = self::EMAIL;
     $user->alias = 'Robert';
     $user->password = sha1('moo');
     $user->Insert();
     $data = new phalanx\base\PropertyBag(array('do' => 'fire', 'email' => self::EMAIL, 'password' => 'moo'));
     $event = $this->getMock('UserLoginEvent', array('_SetCookie'), array($data));
     $event->expects($this->exactly(2))->method('_SetCookie');
     EventPump::Pump()->PostEvent($event);
     $this->assertTrue($event->was_successful());
 }
Example #5
0
 public function testValidateUser()
 {
     $user = new User();
     $user->alias = 'fluffy@bluestatic.org';
     $user->email = 'fluffy@bluestatic.org';
     $user->password = 'abc123';
     $user->Insert();
     $attr = new Attribute();
     $attr->type = Attribute::TYPE_USER;
     $v = $attr->Validate('fluffy@bluestatic.org');
     $this->assertTrue($v[0]);
     $this->assertEquals($user->user_id, $v[1]);
 }
Example #6
0
    if ($_POST['email'] != "") {
        if (isset($valemail) && ($valemail = $email)) {
            $my_user->setEmail($email);
        } else {
            $err .= "Email already exits";
        }
    }
    $pass = $my_user->setPassword($password);
    if ($password != "") {
        if (isset($pass) && $pass == FALSE) {
            $err .= "Password needs to be more than 6 characters";
        }
    }
    echo $err;
    if ($err == "") {
        $userid = $my_user->Insert();
        if ($userid) {
            $emailstat = $my_user->sendEmail($email, $act_code);
            if ($emailstat) {
                $msg .= "Registration Succesfully Completed";
            }
        } else {
            $msg .= "Registration Fail";
        }
        echo $msg;
    }
}
?>
</td>
  </tr>
<form name="register_frm" method="post" action="">
Example #7
0
<?php

if (isset($_POST['submit'])) {
    require 'include/config.php';
    require 'include/class.user.php';
    $user = new User($db);
    $user->Insert($_POST);
    Misc::Redirect('user_list.php');
}
include 'include/top.php';
?>

<form method="post">
	<p>
		<label><span>Name</span></label>
		<input type="text" name="name" id="name" placeholder="Enter user's name" />
	</p>
	<p>
		<label><span>E-mail</span></label>
		<input type="text" name="email" id="email" placeholder="Enter user's email address" />
	</p>
	<p>
		<label><span>Source</span></label>
		<input type="text" name="source" id="source" placeholder="Source" />
	</p>
	<p>
		<label><span>Country</span></label>
		<input type="text" name="country" id="country" placeholder="Country" />
	</p>
	<p>
		<label><span>City</span></label>
     $message_position = 4;
     $message = "O e-mail do usuário não pode ser nulo.";
 } else {
     if ($usif_first_name == "") {
         $message_position = 1;
         $message = "O primeiro nome do usuário não pode ser nulo.";
     } else {
         if ($usif_nick == "") {
             $usif_nick = $usif_first_name;
         }
         $user = new User();
         $user->SetDatabase($database);
         $user->SetUsername($user_username);
         $user->SetPassword($user_password1);
         $user->SetActive(0);
         $user->Insert();
         $user->SelectByName();
         $user_info = new UserInfo();
         $user_info->SetDatabase($database);
         $user_info->SetFirstName($usif_first_name);
         $user_info->SetLastName($usif_last_name);
         $user_info->SetNick($usif_nick);
         $user_info->SetEmail($usif_email);
         $user_info->SetUser($user->GetId());
         if ($user_info->Insert()) {
             $message_position = 8;
             $message = $screen_module_name . " incluídas com sucesso. Aguarde a ativação do usuário pelo administrador.";
             $usif_id = "";
             $usif_first_name = "";
             $usif_last_name = "";
             $usif_nick = "";
Example #9
0
$showSearch = false;
include 'function/Mysql.php';
include 'function/User.php';
$Users = new User(new Mysql());
if ($_GET['Action'] == "Logout") {
    session_destroy();
} elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
    //新增帳號
    if (isset($_POST['newAccount'])) {
        $isRightForm = false;
        $acc = $_POST['newAccount'];
        //check account is in right form
        $pattern = '[A-Z][12][0-9]{8}';
        if (eregi($pattern, $acc) && strlen($acc) == 10) {
            $pw = substr($acc, -4);
            $Users->Insert($acc, $pw);
            echo "<script type='text/javascript'>alert('success');</script>";
        } else {
            echo "<script type='text/javascript'>alert('The format of account is wrong!');</script>";
        }
    } else {
        //if(isset($_POST['searchWord']))
        $showSearch = true;
    }
} else {
    if ($_SERVER['REQUEST_METHOD'] == 'GET' && isset($_GET['action']) && isset($_GET['account'])) {
        $act = $_GET['action'];
        $acc = $_GET['account'];
        //edit
        if ($act == 1) {
            $Users->UpdateAccount($acc);
Example #10
0
<?php

include 'include/top.php';
if (isset($_POST['submit'])) {
    require 'include/config.php';
    $r = Misc::csvParse($_FILES['file']['tmp_name']);
    if (count($r) > 0) {
        require 'include/class.user.php';
        $u = new User($db);
        $total = 0;
        $inserted = 0;
        foreach ($r as $user) {
            $user['name'] = '';
            $total++;
            if ($u->Insert($user)) {
                $inserted++;
            }
        }
        ?>

			<h1>Upload complete. Inserted <em><?php 
        echo $inserted;
        ?>
</em> out of <em><?php 
        echo $total;
        ?>
</em> users in file.</h1>
			<?php 
    }
} else {
    ?>
Example #11
0
require 'include/config.php';
if (!isset($_GET['email']) || !isset($_GET['product'])) {
    die('Both email and product id are required!');
}
require 'include/class.product.php';
$p = new Product($db);
$product = $p->getProduct($_GET['product']);
if (!isset($product['id'])) {
    die('Product does not exist!');
}
include "go_template.html";
require 'include/class.user.php';
$u = new User($db);
$user = $u->getUserByEmail($_GET['email']);
if (!isset($user['id'])) {
    $u->Insert(array('name' => 'Unknown user', 'email' => $_GET['email'], 'source' => isset($_GET['source']) ? $_GET['source'] : ''));
    $user = $u->getUserByEmail($_GET['email']);
}
require 'include/class.tracking.php';
$t = new Tracking($db);
$hash = $t->newSession(array('user_id' => $user['id'], 'product_id' => $product['id'], 'source' => 'forwarder', 'cid' => $_GET['cid']));
$link = $product['networkLink'];
if (strlen($product['parameter']) > 0) {
    if (strpos($link, '?') !== false) {
        $link .= "&" . $product['parameter'];
    } else {
        $link .= "?" . $product['parameter'];
    }
}
$link = str_replace(array("{product}", "{transaction_id}", "{email}"), array($product['replacement'], $hash, $_GET['email']), $link);
if ($product['auto_subscribe_enabled'] != '1' || $product['auto_subscribe_lists'] == '0' || $product['auto_subscribe_lists'] == '') {
Example #12
0
<?php

include 'configs/configs.php';
if (isset($_POST['sub'])) {
    $ten = $_POST['ten'];
    echo $matkhau = $_POST['matKhau'];
    $diaChiMail = $_POST['diaChiMail'];
    $newUser = new User();
    $newUser->userName = $ten;
    $newUser->passWord = $matkhau;
    $newUser->eMail = $diaChiMail;
    $newUser->Insert();
    header('location: login.php');
} else {
    $smarty->display('register.tpl');
}
Example #13
0
         $user_password1 = "";
         $user_password2 = "";
         $user_active = "";
     }
 }
 if ($action == 2) {
     $user = new User();
     $user->SetDatabase($database);
     $user->SetUsername($user_username);
     $user->SetPassword($user_password1);
     $user->SetActive($user_active);
     $user->Encrypt();
     if ($user_password1 != $user_password2) {
         $message = "Senhas não conferem.";
     } else {
         if ($user->Insert()) {
             $message = $screen_module_name . " incluído com sucesso.";
             $user_id = "";
             $user_username = "";
             $user_password1 = "";
             $user_password2 = "";
             $user_active = "";
         } else {
             $message = "Problemas na operação.";
         }
     }
 }
 if ($action == 3) {
     $user = new User();
     $user->SetDatabase($database);
     $user->SetId($user_id);
Example #14
0
                        session_regenerate_id(TRUE);
                        header('location:user.php');
                        exit;
                    }
                } else {
                    if (User::Update($User, $CurrentUser)) {
                        if ($User->getID() == $CurrentUser->getID()) {
                            $_SESSION['CurrentUser'] = serialize($User);
                        }
                        session_regenerate_id(TRUE);
                        header('location:user.php');
                        exit;
                    }
                }
            } else {
                if (User::Insert($User, $CurrentUser)) {
                    session_regenerate_id(TRUE);
                    header('location:user.php');
                    exit;
                }
            }
        } else {
            $e = new SyntaxError(SYNTAX_ERR_EMAILADDRESS);
            Error::AddError($e);
        }
    } else {
        $e = new LoginError(LOGIN_ERR_PASSWORDSNOTIDENTICAL);
        Error::AddError($e);
    }
}
foreach (i18n::$SupportedLanguages as $l) {