public function postUpdate($email)
 {
     $data = Input::only('firstname', 'lastname', 'email');
     $userObj = new User();
     $update = $userObj->updateUser($data['firstname'], $data['lastname'], $data['email']);
     if ($update) {
         return Response::json(array('status' => '1', $data));
     } else {
         return Response::json(array('status' => '0', $data));
     }
 }
Example #2
0
 function testUpdateUser()
 {
     $name = "John Doe";
     $password = "******";
     $email = "*****@*****.**";
     $signed_in = 0;
     $test_user = new User($name, $password, $email, $signed_in);
     $test_user->save();
     $name2 = "Jane Boe";
     $password2 = "wordpass";
     $email2 = "*****@*****.**";
     $test_user->updateUser($name2, $password2, $email2);
     $result = User::getAll();
     $this->assertEquals($test_user, $result[0]);
 }
Example #3
0
 public function fbLogin($fbEmail, $fbID, $fbName)
 {
     $fbEmail = $this->db->real_escape_string($fbEmail);
     $fbID = $this->db->real_escape_string($fbID);
     $fbName = $this->db->real_escape_string($fbName);
     $query = "select * from user_registration where fbID=\"{$fbID}\"";
     $result = $this->db->query($query);
     if (!is_array($result) || count($result) < 1) {
         throw new Exception("unregistered user", -1);
     }
     $userID = $result[0]['userID'];
     if ($fbEmail != $result[0]['fbEmail'] || $fbName != $result[0]['fbName']) {
         $attr = array("fbEmail" => $fbEmail, "fbName" => $fbName);
         $user = new User($userID);
         $user->updateUser($attr);
     }
     $this->setupSession($userID);
     return $this;
 }
Example #4
0
 /**
  * Enter description here ...
  */
 public function saveAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $post = $this->getRequest()->getPost();
     $data = array('username' => $post['username'], 'email' => $post['email'], 'role' => 'admin');
     if ($post['password'] != '') {
         $data['password'] = md5($post['password']);
     }
     $user = new User();
     if ($post['id'] == "") {
         $user->insertUser($data);
     } else {
         $user->updateUser($data, $post['id']);
     }
     if ($post['savenew'] == 0) {
         $this->_redirect('admin/user/show');
     } else {
         $this->_redirect('admin/user/new');
     }
 }
function _updateUser()
{
    isUserLoggedIn();
    $user = new User(getdbh());
    $grupa = new Grupa(getdbh());
    if ($_POST['currentGroup'] > 0 && $_POST['currentGroup'] != $_POST['grupa']) {
        $remove = $grupa->removeGroupMember($_POST['currentGroup'], $_POST['idUser']);
    }
    $check = $grupa->checkRegister($_POST['grupa'], $_POST['idUser']);
    if ($check == false) {
        $addGrupa = $grupa->addGrupaMember($_POST['grupa'], $_POST['idUser']);
    }
    $result = $user->updateUser($_POST['idUser'], $_POST['email'], $_POST['nume'], $_POST['prenume'], $_POST['type'], $_POST['status']);
    if ($result) {
        $data['msg'][] = 'Userul a fost modificat cu success';
        $data['redirect'][] = 'administrare/show_users';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    } else {
        $data['msg'][] = "Eroare la modificarea userului";
        $data['redirect'][] = 'administrare/show_users';
        View::do_dump(VIEW_PATH . 'layout.php', $data);
    }
}
 public function go()
 {
     if (isset($_GET['id'])) {
         $id = $_GET['id'];
     }
     if (isset($_POST['submit'])) {
         if ($_POST['username'] == '') {
             $this->addErrorMessage("Name of the user should not be empty");
         } elseif ($_POST['email'] == '') {
             $this->addErrorMessage("Email should not be empty");
         } elseif ($_POST['full_name'] == '') {
             $this->addErrorMessage("Please enter your full name");
         } elseif ($_POST['is_activated'] == '') {
             $this->addErrorMessage("Is the user activated or not");
         } elseif ($_POST['type'] == '') {
             $this->addErrorMessage("Please select the type of the user");
         } else {
             $this->username = $_POST['username'];
             $this->email = $_POST['email'];
             $this->password = $_POST['password'];
             $this->full_name = $_POST['full_name'];
             $this->is_activated = $_POST['is_activated'];
             $this->type = $_POST['type'];
             User::updateUser($id, $this->username, $this->full_name, $this->email, $this->password, $this->is_activated, $this->type);
             $this->addSuccessMessage("User details have been updated succesfully");
         }
     }
     $users = User::getUser($id);
     $this->setViewTemplate('edituser.tpl');
     $this->addToView('user', $users[0]);
     $this->generateView();
     if (isset($_POST['deletesubmit'])) {
         User::deleteUser($id);
         $this->addSuccessMessage("User has been deleted succesfully");
         header('Location:' . SOURCE_ROOT_PATH . "admin/pages/usermanager.php?source=del");
     }
 }
        } else {
            if ($console === "4") {
                $console = "X1";
            } else {
                $console = "ERR";
            }
        }
    }
}
$about = $_POST["accountAbout"];
$password = $_POST["accountCurrPass"];
$newPassword = $_POST["accountNewPass1"];
if ($_POST["accountNewPass1"] !== $_POST["accountNewPass2"]) {
    $_SESSION["account_updateFail"];
    $_SESSION["account_updateConsole"] = $_POST["accountConsole"];
    $_SESSION["account_updateAbout"] = $_POST["accountAbout"];
    header("Location: account.php");
}
$user = new User($username, $password);
if ($user->verify()) {
    // verify complete, update user
    $user->updateUser($newPassword, $console, $about);
    header("Location: account.php");
} else {
    // verify fail, wrong password
    $_SESSION["login_console"] = $console;
    $_SESSION["login_about"] = $about;
    $_SESSION["login_newPassword"] = $newPassword;
    header("Location: account.php");
}
//exit();
Example #8
0
}
if (Common::isPost()) {
    if ($real_name == "" || $mobile == "" || $email == "" || $user_id != 1 && $user_group <= 0) {
        OSAdmin::alert("error", ErrorMessage::NEED_PARAM);
    } else {
        $update_data = array('real_name' => $real_name, 'mobile' => $mobile, 'email' => $email, 'user_desc' => $user_desc);
        if ($user_id > 1) {
            $update_data["user_group"] = $user_group;
        }
        if (!empty($password)) {
            if (!preg_match("/^(([a-z]+[0-9]+)|([0-9]+[a-z]+))[a-z0-9]*\$/i", $password)) {
                Common::exitWithError('密码必须由数字和字母的组合而成', '');
            }
            $update_data = array_merge($update_data, array('password' => md5($password)));
        }
        $result = User::updateUser($user_id, $update_data);
        if ($result >= 0) {
            $current_user = UserSession::getSessionInfo();
            $ip = Common::getIp();
            $update_data['ip'] = $ip;
            SysLog::addLog(UserSession::getUserName(), 'MODIFY', 'User', $user_id, json_encode($update_data));
            Common::exitWithSuccess('更新完成', 'complaint/user.php');
        } else {
            OSAdmin::alert("error");
        }
    }
}
$group_options = UserGroup::getGroupForOptions();
unset($group_options[1]);
Template::assign('user', $user);
Template::assign('group_options', $group_options);
Example #9
0
<?php

Login::restrictFront();
$objUser = new User();
$user = $objUser->getUser(Session::getSession(Login::$_login_front));
if (!empty($user)) {
    $objForm = new Form();
    $objValid = new Validation($objForm);
    if ($objForm->isPost('first_name')) {
        $objValid->_expected = array('first_name', 'last_name', 'address_1', 'address_2', 'town', 'county', 'post_code', 'country', 'email');
        $objValid->_required = array('first_name', 'last_name', 'address_1', 'town', 'county', 'post_code', 'country', 'email');
        $objValid->_special = array('email' => 'email');
        if ($objValid->isValid()) {
            if ($objUser->updateUser($objValid->_post, $user['id'])) {
                Helper::redirect('/?page=summary');
            } else {
                $mess = "<p class=\"red\">There was a problem updating your details.<br />";
                $mess .= "Please contact administrator.</p>";
            }
        }
    }
    require_once '_header.php';
    ?>
	
	<h1>Checkout</h1>
	
	<p>Please check your details and click <strong>Next</strong>.</p>
	
	<?php 
    echo !empty($mess) ? $mess : null;
    ?>
         }
         if ($rank[0] == 'D') {
             $sort = 3;
         }
         if ($rank[0] == 'M') {
             $sort = 2;
         }
         if ($rank[0] == 'C') {
             $sort = 1;
         }
         $login_user->rank = $sort . $rank;
     } else {
         $login_user->rank = "8";
     }
 }
 $login_user->updateUser($dbh, $login_user);
 //If they are banned, get their current ip and append it to the htaccess
 if ($login_user->admin == 3) {
     //
     if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
         $ip = $_SERVER['HTTP_CLIENT_IP'];
     } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
         $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
     } else {
         $ip = $_SERVER['REMOTE_ADDR'];
     }
     $current = "echo '#" . $login_user->first_name . " " . $login_user->last_name . " " . $login_user->email . "' >> .htaccess";
     $output = shell_exec($current);
     $current = "echo 'deny from " . $ip . "#' >> .htaccess";
     $output = shell_exec($current);
 }
Example #11
0
<?php

include "../conf/topo_basic.php";
header('Content-Type: application/json');
$login = new User();
// Submit login
if (isset($_POST['submit_login'])) {
    echo json_encode($login->login($_POST['user'], $_POST['password']));
}
// Submit login
if (isset($_POST['logout'])) {
    echo json_encode($login->logout());
}
// Submit login
if (isset($_POST['getMenu'])) {
    echo json_encode($login->getMenu());
}
// Get perfil
if (isset($_POST['getPerfil'])) {
    echo json_encode($login->getPerfil());
}
if (isset($_POST['updateUser'])) {
    echo json_encode($login->updateUser($_POST));
}
// else {
//   echo json_encode("wwwwwww");
// }
?>

Example #12
0
    }
} elseif (isset($_POST["pseudoUpdateUser"])) {
    $_SESSION['email'] = $emailUpdateUser = $_POST['emailUpdateUser'];
    $verifEmail = User::verifiEmail($emailUpdateUser);
    if ($verifEmail == False) {
        $_SESSION["verifEmailUpdateUser"] = false;
    } else {
        $_SESSION['verifEmailUpdateUser'] = true;
        $verifEmail = User::existEmail($emailUpdateUser);
        if ($verifEmail == false) {
            $_SESSION["existEmailUpdateUser"] = false;
            $user = new User();
            $_SESSION['pseudo'] = $pseudoUpdateUser = $_POST['pseudoUpdateUser'];
            $user->setLogin($pseudoUpdateUser);
            $user->setEmail($emailUpdateUser);
            $_SESSION['group'] = $groupUpdateUser = $_POST['groupUpdateUser'];
            $user->setGroup($groupUpdateUser);
            $id = $_SESSION["id"];
            $user->updateUser($id);
        } else {
            $_SESSION["existEmailUpdateUser"] = true;
        }
    }
}
$dpList = Dp::getAllDp();
if ($dpList == null) {
    $_SESSION["msgToAllDp"] = "Aucun Design Patterns !";
} else {
    $_SESSION['dpList'] = $dpList;
    $_SESSION['msgToAllDp'] = "";
}
 case 'EDIT':
     $reviewExists = $user->reviewExistsLoginUserForEdit($_POST['USER_NAME'], $_POST['PK_ID_USER']);
     if (count($reviewExists) > 0) {
         Forms::setMessage('ERROR', 'Transaccion erronea!!', 'Lo sentimos el nombre de usuario ya existe, escoja otro nombre de usuario!');
     } else {
         $_POST['ROL'] = array();
         for ($i = 0; $i < 20; $i++) {
             if (isset($_POST['ROL_' . $i])) {
                 $_POST['ROL'][] = $i;
             }
         }
         /*
                $user, $pass, $fk_id_person, $pk_id_user, $fk_id_role
                  * */
         // print_r($_POST);
         $pk_id_user = $user->updateUser($_POST['USER_NAME'], $_POST['PASSWORD'], $_POST['PK_ID_PERSON'], $_POST['PK_ID_USER'], $_POST['ROL']);
         if ($pk_id_user) {
             Forms::setMessage('SUCCESS', 'Transaccion Exitosa!!', 'Los datos de usario se actualizaron correctamente!');
         } else {
             Forms::setMessage('ERROR', 'Transaccion erronea!!', 'Los datos de usario No se actualizaron correctamente!');
         }
     }
     break;
 case 'DELETE':
     $data1 = array($_GET['PK_ID_USER']);
     $pk_id_person = $user->deleteUser($data1);
     if ($pk_id_person > 0) {
         Forms::setMessage('SUCCESS', 'Transaccion Exitosa!!', 'Los datos de usario se eliminaron correctamente!');
     } else {
         Forms::setMessage('ERROR', 'Transaccion erronea!!', 'Los datos de usario No se eliminaron correctamente!');
     }
Example #14
0
 /**
  * update
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $user = new User();
     $user->u_id = $id;
     $user->u_token = Input::get('token', null);
     $user->u_password = Input::get('pass', null);
     $user->u_age = Input::get('age', null);
     $user->u_name = Input::get('name', null);
     $user->u_sex = Input::get('sex', null);
     $user->u_school_id = Input::get('school_id', null);
     $user->u_prof = Input::get('profession', null);
     $user->u_degree = Input::get('degree', null);
     $user->u_entry_year = Input::get('in_year', null);
     $imgToken = Input::get('img_token', '');
     try {
         $user->updateUser($imgToken);
         $re = Tools::reTrue('更新成功');
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '更新失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
Example #15
0
    if (!$user->level) {
        throw new LoginException("You must be logged in to use this feature.");
    }
    if ($user->level < 2) {
        throw new LoginException("You do not have permission to use this feature.  Please log into the Administrator account.");
    }
    list($id, $edituser->firstname, $edituser->lastname, $edituser->phone, $edituser->email, $edituser->address, $edituser->city, $edituser->state, $edituser->zip, $newpassword) = $input->getInputValues('id', 'firstname', 'lastname', 'phone', 'email', 'address', 'city', 'state', 'zip', 'newpassword');
    $input->digits($id, 'User ID');
    if (!$currentuser->load($id)) {
        throw new DBException("User not found or could not load user {$id}.");
    }
    if ($edituser->firstname) {
        $input->password($newpassword, 'New User Password');
        $edituser->id = $id;
        $edituser->validate();
        if ($edituser->updateUser($newpassword)) {
            flash("User Updated.");
        }
        $edituser->username = $currentuser->username;
        $edituser->level = $currentuser->level;
        $currentuser = $edituser;
    }
    include "../views/edituser.php";
} catch (LoginException $e) {
    $redirect = "edituser.php";
    include "../views/login.php";
    throw $e;
} catch (InputException $e) {
    include "../views/edituser.php";
    throw $e;
} catch (DBException $e) {
Example #16
0
 public static function loginDoSomething($user_id)
 {
     $user_info = User::getUserById($user_id);
     if ($user_info['status'] != 1) {
         Common::jumpUrl("login.php");
         return;
     }
     //读取该用户所属用户组将该组的权限保存在$_SESSION中
     $user_group = UserGroup::getGroupById($user_info['user_group']);
     $user_info['group_id'] = $user_group['group_id'];
     $user_info['user_role'] = $user_group['group_role'];
     $user_info['shortcuts_arr'] = explode(',', $user_info['shortcuts']);
     $menu = MenuUrl::getMenuByUrl('/admin/setting.php');
     if (strpos($user_group['group_role'], $menu['menu_id'])) {
         $user_info['setting'] = 1;
     }
     $login_time = time();
     $login_ip = Common::getIp();
     $update_data = array('login_ip' => $login_ip, 'login_time' => $login_time);
     User::updateUser($user_info['user_id'], $update_data);
     $user_info['login_ip'] = $login_ip;
     $user_info['login_time'] = Common::getDateTime($login_time);
     UserSession::setSessionInfo($user_info);
 }
Example #17
0
$promo = new Promo();
$promo_list = $promo->getAll();
$droit = new Droit();
$droit_list = $droit->getAll();
if ($id_droit == 1 || $id_droit == 2) {
    echo $twig->render("modif_user.html.twig", array("user" => $infUser = $user->getInfoAdminProfModif(), "promo" => $promo_list, "droit" => $droit_list));
} else {
    echo $twig->render("modif_user.html.twig", array("user" => $infUser = $user->getInfoEleveModif(), "promo" => $promo_list, "droit" => $droit_list));
}
if (isset($_REQUEST['submit'])) {
    if (isset($_REQUEST['nom']) && isset($_REQUEST['prenom']) && isset($_REQUEST['email']) && isset($_REQUEST['droit'])) {
        $db = Database::getInstance();
        $prenom = $_REQUEST['prenom'];
        $nom = $_REQUEST['nom'];
        $email = $_REQUEST['email'];
        $droit = $_REQUEST['droit'];
        $idpromo = $_REQUEST['promo'];
        $password = "";
        if (password_verify($_REQUEST['currentPass'], $user->getPass())) {
            if (!empty($_REQUEST['newPass']) && !empty($_REQUEST['reNewPass'])) {
                if ($_REQUEST['newPass'] == $_REQUEST['reNewPass']) {
                    $password = password_hash($_REQUEST['newPass'], PASSWORD_DEFAULT);
                } else {
                    $password = password_hash($user->password(), PASSWORD_DEFAULT);
                }
            }
        }
        $user->updateUser($nom, $prenom, $password, $email, $droit, $idpromo);
        //header('Location: user_list.php');
    }
}
             // log in
             header('Location: ' . $registry->configuration->website->params->url . '/' . $registry->requestController . '/login');
             exit;
         }
         // POST values that will be validated
         $values = array('details' => array('firstName' => isset($_POST['firstName']) ? $_POST['firstName'] : '', 'lastName' => isset($_POST['lastName']) ? $_POST['lastName'] : ''), 'email' => array('email' => isset($_POST['email']) ? $_POST['email'] : ''));
         // Only if a new password is provided we will update the password field
         if ($_POST['password'] != '' || $_POST['password2'] != '') {
             $values['password'] = array('password' => $_POST['password'], 'password2' => $_POST['password2']);
         }
         $dotValidateUser = new Dot_Validate_User(array('who' => 'user', 'action' => 'update', 'values' => $values, 'userId' => $registry->session->user->id));
         if ($dotValidateUser->isValid()) {
             // no error - then update user
             $data = $dotValidateUser->getData();
             $data['id'] = $registry->session->user->id;
             $userModel->updateUser($data);
             $session->message['txt'] = $option->infoMessage->update;
             $session->message['type'] = 'info';
         } else {
             $data = $dotValidateUser->getData();
             $session->message['txt'] = $dotValidateUser->getError();
             $session->message['type'] = 'error';
         }
     }
     $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();
Example #19
0
require_once "../../Local/Classes/class.User.inc";
extract($_GET);
$user = new User();
if (isset($UserID)) {
    $_SESSION['editUserID'] = $UserID;
    //get query result
    $result = $user->readUserById($_SESSION['editUserID']);
    //fetch result data to fill in form
    $userInfo = mysqli_fetch_assoc($result);
} else {
    header("location: userManager.php");
}
//on submit edit record
if (isset($btnSubmit)) {
    //call function updateUserById and save results in $result;
    $result = $user->updateUser($_SESSION['editUserID'], $txtFirstName, $txtLastName, $txtEmail, $drpUserRole, $txtBirthDate, $rdbGender, $txtCredentials, $txtWorkPhone, $txtCellPhone, $txtFax, $txtAddress, $txtCity, $drpStdProvince, $txtPostalCode, $txtRegistrationNumber, $txtLicenseNumber);
    if ($result === true) {
        //redirect to userManager.
        header("location: userManager.php?userEdit=true");
        unset($_SESSION['editUserID']);
    } else {
        header("location: userManager.php?userEdit={$result}");
    }
}
//Header and sidebar master files
include "header.php";
include "sidebar.php";
?>
    <form role="form" id="frm" method="get" action="<?php 
echo $_SERVER['PHP_SELF'];
?>
Example #20
0
        $us->name = $_POST['name'];
        $us->user = $_POST['user'];
        $us->mail = $_POST['mail'];
        $us->pass = $_POST['pass'];
        $us->rol = $_POST['tipo'];
        $result = User::addUser($us);
        if (isError($result)) {
            echo dError($result);
        }
        exit;
    }
    if ($_GET['t'] == 'update') {
        if ($_POST['pass'] == "") {
            $result = User::updateUser($_POST['idus'], $_POST['name'], $_POST['tipo'], $_POST['mail']);
        } else {
            $result = User::updateUser($_POST['idus'], $_POST['name'], $_POST['tipo'], $_POST['mail'], $_POST['pass']);
        }
        if (isError($result)) {
            echo dError($result);
        }
        exit;
    }
}
if ($_GET['id']) {
    $us = User::getUserByID($_GET['id']);
}
?>
            
<form action = "<?php 
if ($_GET['t'] != 'update') {
    echo 'javascript:fn_agregar();';
Example #21
0
$id = $id ? $id : 0;
$method = $method ? $method : '';
$email = $email ? $email : '';
$captcha = $captcha ? $captcha : '';
if ($method == 'active') {
    $db = new MySQL($log);
    if ($mysqli = $db->openDB()) {
        $user = new User($mysqli, $log);
        $invitation = new Invitation($mysqli, $log);
        if ($user->getUserByID($id)) {
            if ($user->status == 2) {
                $s_email = $user->email;
                $v_res = $invitation->validateEmailCode($code, $id);
                if ($v_res['result']) {
                    $user->status = 1;
                    if ($user->updateUser($id)) {
                        $res['result'] = true;
                        $res['message'] = '恭喜您,用户已激活成功';
                        $res['action'] = 'login';
                    }
                } else {
                    $res['message'] = $v_res['reason'];
                    $res['action'] = 'resend';
                }
            } else {
                $res['message'] = '用户已被激活或已禁用!';
                $res['action'] = 'resend';
            }
        } else {
            $res['message'] = '用户不存在!';
            $res['action'] = 'resend';
Example #22
0
            } else {
                $user_data['password'] = md5($new);
                User::updateUser($current_user_id, $user_data);
                SysLog::addLog(UserSession::getUserName(), 'MODIFY', 'User', $current_user_id);
                Common::exitWithSuccess(ErrorMessage::PWD_UPDATE_SUCCESS, '/index.php');
            }
        } else {
            OSAdmin::alert("error", ErrorMessage::OLD_PWD_WRONG);
        }
    } else {
        $user_data['real_name'] = $real_name;
        $user_data['mobile'] = $mobile;
        $user_data['email'] = $email;
        $user_data['user_desc'] = $user_desc;
        $user_data['show_quicknote'] = $show_quicknote;
        User::updateUser($current_user_id, $user_data);
        UserSession::reload();
        SysLog::addLog(UserSession::getUserName(), 'MODIFY', 'User', $current_user_id, json_encode($user_data));
        Common::exitWithSuccess('资料修改成功', '/index.php');
    }
}
$quicknoteOptions = array("1" => "显示", "0" => "不显示");
//更新Session里的用户信息
Template::assign("change_password", $change_password);
Template::assign("user_info", UserSession::getSessionInfo());
Template::assign("quicknoteOptions", $quicknoteOptions);
Template::display('panel/profile.tpl');
?>


Example #23
0
                     }
                 }
             }
         }
     }
 } else {
     if ($_GET['op'] == 'update_user') {
         if (strlen($_POST['pass']) < 5) {
             $error = 'La clave debe tener al menos cinco caracteres<br />';
         } else {
             if ($_POST['pass'] != $_POST['pass2']) {
                 $error = 'Su contraseña no coincide en ambos campos<br />';
             }
         }
         if (!$error) {
             if (User::updateUser($user->id, $user->rol, $user->mail, $_POST['pass'])) {
                 $msj = 'Se actualizó su contraseña con éxito.';
             } else {
                 $error = 'Ocurrió un error interno registrando su cuenta, intente más tarde.';
             }
         }
     } else {
         if ($_GET['op'] == 'update_data') {
             $error = '';
             $countries = getCountries();
             if (strlen($_POST['name']) < 3 || !validName($_POST['name'])) {
                 $error .= '- Su Nombre es requerido, solo puede usar caracteres alfanuméricos<br />';
             }
             if (strlen($_POST['address']) < 3 || !validAddress($_POST['address'])) {
                 $error .= '- Su Dirección es requerida, solo puede usar caracteres alfanuméricos<br />';
             }
Example #24
0
    $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']) {
        echo $post->publishPost($jsonDetails);
    }
});
//show posts
$app->get('/post/:offset', function ($offset) {
    global $post, $app;
    $posts = $post->showPosts($offset, $_SESSION['user_id']);
Example #25
0
<?php

require_once dirname(__FILE__) . "/../conf/config.php";
require_once dirname(__FILE__) . "/../conf/functions.php";
$user = new User();
if ($_SERVER['REQUEST_METHOD'] != "POST") {
    $target = $user->getUser($_GET['id']);
    if (!$target) {
        header('Location: index.php');
        exit;
    }
} else {
    $target = ['id' => $_POST['id'], 'password' => $_POST['password'], 'name' => $_POST['name'], 'email' => $_POST['email']];
    $error = userValidate($target);
    if (is_null($error)) {
        $user->updateUser($target);
        header("Location: view.php?id=" . $target['id']);
        exit;
    }
}
$title = "ユーザ編集";
require_once dirname(__FILE__) . "/../view/users/temp_update.php";
Example #26
0
    echo json_encode($user->getAllUsers());
});
$app->get('/user/:id/', function ($id) use($user) {
    echo json_encode($user->getUserById($id));
});
$app->post('/user/', function () use($user, $app) {
    $new_user = json_decode($app->request->getBody(), true);
    $success = $user->createNewUser($new_user);
    echo $success;
});
$app->delete('/user/:id/', function ($id) use($user) {
    echo $user->deleteUser($id);
});
$app->put('/user/:id/', function ($id) use($user, $app) {
    $details = json_decode($app->request->getBody());
    echo $user->updateUser($id, $details);
});
$app->post('/login/', function () use($app) {
    $login = new Login();
    $email = $app->request->post('email');
    $password = $app->request->post('password');
    if ($login->match($email, $password)) {
        echo json_encode(array("success" => "true"));
    } else {
        echo json_encode(array("success" => "false"));
    }
});
$app->get('/login/', function () use($app) {
    if ($_SESSION['login']) {
        echo 1;
    } else {
Example #27
0
    include_once 'definition.php';
    $User = new User();
    if (isset($_POST['userUpdate'])) {
        // username,oldpassword,newpassword,email,ui_color,code_theme
        $userData = array(null, null, null, null, null, null);
        if (isset($_POST['username'])) {
            $userData[0] = $_POST['username'];
        }
        if (isset($_POST['oldpassword'])) {
            $userData[1] = $_POST['oldpassword'];
            $userData[2] = $_POST['newpassword'];
        }
        if (isset($_POST['email'])) {
            $userData[3] = $_POST['email'];
        }
        if (isset($_POST['ui_color'])) {
            $userData[4] = $_POST['ui_color'];
        }
        if (isset($_POST['code_theme'])) {
            $userData[5] = $_POST['code_theme'];
        }
        // echo implode(",",$userData);
        // Update color
        $va = $User->updateUser($_SESSION["us"], $userData);
        echo $va;
    }
    //echo 'ok';
    exit;
} else {
    echo 'logout';
}
Example #28
0
<?php

include dirname(__DIR__) . "/users/User.php";
$name = $_POST["name_lastname"];
$user = $_POST["username"];
$pass = $_POST["password"];
$profile_id = $_POST["profile_id"];
$user_id = $_POST["user_id"];
$user_object = new User();
$user_data = $user_object->getUserById($user_id);
if ($pass == "no_change") {
    $pass = $user_data->password;
}
$user_update = $user_object->updateUser($user_id, $user, $pass, $name, $profile_id);
$status = $user_update["success"];
$messagge = $user_update["messagge"];
header("Location: list_view.php?status={$status}&messagge={$messagge}");
?>

 public function updateUser()
 {
     if (isset($_POST['submit'])) {
         //            var_dump($_POST['pass']) ;
         if ($_POST['nip'] == "" || $_POST['nama'] == "") {
             echo 'ada field yang masih belum diisi';
         } else {
             if ($_POST['pass'] !== $_POST['cpass']) {
                 echo 'data tidak bisa disimpan karena password berbeda dengan confirm passwordnya';
             }
             if ($_POST['pass'] == "no_change" || $_POST['cpass'] == "no_change") {
                 if ($_FILES['upload']['name'] == "") {
                     $user = new User($registry);
                     $user->set_id($_POST['id']);
                     $user->set_nip($_POST['nip']);
                     $user->set_nmUser($_POST['nama']);
                     $user->set_akses($_POST['akses']);
                     $user->updateUser_withoutpass($user);
                 } else {
                     $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_id($_POST['id']);
                     $user->set_nip($_POST['nip']);
                     $user->set_nmUser($_POST['nama']);
                     $user->set_akses($_POST['akses']);
                     $user->set_foto($_POST['nip'] . "." . $extension);
                     $user->updateUser_withoutpass($user);
                 }
             }
             if ($_POST['pass'] !== "no_change" && $_POST['pass'] == $_POST['cpass']) {
                 if ($_FILES['upload']['name'] == "") {
                     $user = new User($registry);
                     $user->set_id($_POST['id']);
                     $user->set_nip($_POST['nip']);
                     $user->set_nmUser($_POST['nama']);
                     $user->set_pass($_POST['pass']);
                     $user->set_akses($_POST['akses']);
                     $user->updateUser($user);
                 } else {
                     $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_id($_POST['id']);
                     $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->updateUser($user);
                 }
             }
         }
     }
     header('location:' . URL . 'admin/listUser');
 }
}
// get database object
$db = new Database();
$us = new User();
$usr = $db->select($us->getUserById($id))->fetch_assoc();
// if submit button is pressed
if (isset($_POST['submit'])) {
    // simple validation
    if ($name == '' && !isset($_POST['name']) || $setadmin == '' && !isset($_POST['isAdmin'])) {
        // set error
        $error = 'Please fill out all required fields.';
    } else {
        //assign variables
        $name = mysqli_real_escape_string($db->link, $_POST['name']);
        $isadmin = mysqli_real_escape_string($db->link, $_POST['isAdmin']);
        $update_row = $db->update($us->updateUser($name, $isadmin, $id));
    }
}
if (isset($_POST['delete'])) {
    $delete_row = $db->delete($us->deleteUser($id));
}
// password change section
if (isset($_POST['submit2'])) {
    if (isset($_POST['password']) && isset($_POST['newPassword']) && isset($_POST['confirmPassword']) && $_POST['password'] != '' && $_POST['newPassword'] != '' && $_POST['confirmPassword'] != '') {
        $newPassword = $_POST['newPassword'];
        $confirm = $_POST['confirmPassword'];
        if ($newPassword == $confirm) {
            $newPassword = password_hash($newPassword, PASSWORD_DEFAULT);
            $password = $_POST['password'];
            $password = password_hash($password, PASSWORD_DEFAULT);
            // get password