/** * 管理员录入 * */ public function actionCreate() { parent::_acl(); $model = new Admin('create'); //所有的用户组 $group = XXcache::get('_adminGroup'); // ppr($group,1); if (XUtils::method() == 'POST' && !empty($_POST['Admin'])) { $post = reqPost('Admin'); $password = $post['password']; if (empty($post['username']) || empty($post['password']) || empty($post['password2']) || $post['password'] != $post['password2']) { XUtils::message('error', '账号密码不能为空,或者两次输入密码不同'); } $model->attributes = $post; $model->setAttribute('password', md5($password)); $id = $model->save(); if (!empty($id)) { parent::_backendLogger(array('catalog' => 'create', 'intro' => '录入管理员:' . $model->username)); $this->redirect(array('index')); } } $this->group_list = parent::_groupList('admin'); $model->create_time = date('Y-m-d'); $model->last_login_time = date('Y-m-d'); $this->render('create', array('model' => $model, 'group' => $group)); }
public function actionAdd() { $model = new Admin; if(isset($_POST['Admin'])){ $model->attributes = $_POST['Admin']; $model->password = md5($_POST['Admin']['password']); // if(!empty($_POST['purview'])){ // $model->purview=implode(';',$_POST['purview']); // }else{ // $model->purview=''; // } // $admin->rid=1; $model->loginip = $_SERVER['REMOTE_ADDR']; $model->createtime = time(); $model->updatetime = time(); if($model->save()){ $this->redirect(array('list')); } } $this->render('add',array('model'=>$model)); }
public function verify() { $username = Input::get('username'); $password = Input::get('password'); if (Admin::count() == 0) { $admin = new Admin(); $admin->username = $username; $admin->name = $username; $admin->designation = 'Admin'; $admin->image_url = ''; $admin->password = Hash::make($password); $admin->remember_token = ''; $admin->save(); return Redirect::to('admin/login'); } $admin = Admin::where('username', $username)->first(); if ($admin && Hash::check($password, $admin->password)) { Session::put('admin_id', $admin->id); Session::put('admin_username', $admin->username); Session::put('admin_name', $admin->name); Session::put('admin_image_url', $admin->image_url); Session::put('admin_designation', $admin->designation); return Redirect::to('admin/dashboard'); } else { $message = "Invalid Username and Password"; $type = "failed"; return Redirect::to('/admin/login')->with('type', $type)->with('message', $message); } }
public function actionCreate() { IsAuth::Admin(); $model = new Admin(); if (isset($_POST['Admin'])) { $model->attributes = $_POST['Admin']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->admin_id)); } } $this->render('create', array('model' => $model)); }
public function run() { DB::table('admins')->truncate(); $admin = new Admin(); $admin->username = "******"; $admin->password = "******"; $admin->save(); $admin = new Admin(); $admin->username = "******"; $admin->password = "******"; $admin->save(); }
function newuser($data) { if ($data['nickname'] && $data['email']) { $newuser = new Admin(); $newuser->nickname = $_POST['nickname']; $newuser->email = $_POST['email']; $newuser->fullname = $_POST['fullname']; $newuser->save(); return true; } else { return false; } }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Admin(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Admin'])) { $model->attributes = $_POST['Admin']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->idad)); } } $this->render('create', array('model' => $model)); }
public function actionAdd() { $model = new Admin; if(isset($_POST['Admin'])){ $_POST['Admin']['password'] = md5($_POST['Admin']['password']); $model->attributes = $_POST['Admin']; $model->loginip = $_SERVER['REMOTE_ADDR']; $model->createtime = time(); $model->updatetime = time(); $model->save(); } $this->render('add',array('model'=>$model)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Admin(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Admin'])) { $model->attributes = $_POST['Admin']; if ($model->save()) { //$this->redirect(array('view','id'=>$model->id)); Yii::app()->user->setFlash('success', '信息提交成功!'); } else { Yii::app()->user->setFlash('success', '信息提交失败!'); } } $this->render('create', array('model' => $model)); }
/** * 管理员录入 * */ public function actionCreate() { parent::_acl('admin_create'); $model = new Admin('create'); if (isset($_POST['Admin'])) { $model->attributes = $_POST['Admin']; $id = $model->save(); if ($id) { AdminLogger::_create(array('catalog' => 'create', 'intro' => '录入管理员:' . $model->username)); $this->redirect(array('index')); } } $this->group_list = parent::_groupList('user'); $model->create_time = date('Y-m-d'); $model->last_login_time = date('Y-m-d'); $this->render('admin_create', array('model' => $model)); }
public function actionAdd() { $model = new Admin(); $model->status = 1; $model->attributes = Yii::app()->request->getParam('Admin'); if (Yii::app()->request->getParam('Admin') && $model->validate()) { $get = Yii::app()->request->getParam('Admin'); $model->password = md5($get['password']); if ($model->save()) { Yii::app()->user->setFlash('success', '添加成功'); $this->redirect(array('user/index')); } else { Yii::app()->user->setFlash('error', '修改失败'); } } $this->render('add', array('model' => $model)); }
$formValid = false; } if (isset($_POST["admin_pass"]) && ($_POST["admin_pass"] == "" || strlen($_POST["admin_pass"]) < 8)) { $errorMessage .= "Password is required and must be 8 alphanumeric characters. </br>"; $formValid = false; } else { if (isset($_POST["admin_pass"]) && $_POST["admin_pass"] != "" && $_POST["admin_pass"] != $_POST["admin_pass_confirm"]) { $errorMessage .= "Password do not match."; $formValid = false; } elseif (isset($_POST["admin_pass"])) { $_POST["admin_pass"] = md5($_POST["admin_pass"]); } } if (isset($_POST["registration"]) && $_POST["admin_pass"] != "" && $formValid) { $client = new Admin($_POST); if ($client->save()) { $_SESSION["formInput"] = array(); $_POST = array(); $successMessage = "Registration Successful! Click <a href='login.php'>Login</a> to proceed."; header('Location: ' . $_SERVER['PHP_SELF'] . '?message=' . $successMessage); die; } else { $errorMessage = "Please check fields."; } } // $test = new Admin(array("admin_id"=>"","admin_fname"=>"test","admin_lname"=>"testing","admin_contact"=>"12345678","admin_eadd"=>"*****@*****.**","admin_pass"=>"password","admin_add"=>"test address")); ?> <!DOCTYPE html> <html> <head>
public function updateAdmin() { if (Request::ajax() && Input::has('pk')) { $arrPost = Input::all(); if ($arrPost['name'] == 'active') { $arrPost['value'] = (int) $arrPost['value']; } Admin::where('id', $arrPost['pk'])->update([$arrPost['name'] => $arrPost['value']]); return Response::json(['status' => 'ok']); } $prevURL = Request::header('referer'); if (!Request::isMethod('post')) { return App::abort(404); } if (Input::has('id')) { $create = false; try { $admin = Admin::findorFail((int) Input::get('id')); } catch (Illuminate\Database\Eloquent\ModelNotFoundException $e) { return App::abort(404); } $message = 'has been updated successful'; unset($admin->password); if (Input::has('password')) { if (Input::has('password') && Input::has('password_confirmation')) { $password = Input::get('password'); $admin->password = Input::get('password'); $admin->password_confirmation = Input::get('password_confirmation'); } } } else { $create = true; $admin = new Admin(); $message = 'has been created successful'; $password = Input::get('password'); $admin->password = $password; $admin->password_confirmation = Input::get('password_confirmation'); } $admin->email = Input::get('email'); $admin->first_name = Input::get('first_name'); $admin->last_name = Input::get('last_name'); $admin->active = Input::has('active') ? 1 : 0; $oldRole = 0; if (isset($admin->role_id) && $admin->role_id) { $oldRole = $admin->role_id; } $admin->role_id = Input::has('role_id') ? Input::get('role_id') : 0; if (Input::hasFile('image')) { $oldPath = $admin->image; $path = VIImage::upload(Input::file('image'), public_path('assets' . DS . 'images' . DS . 'admins'), 110, false); $path = str_replace(public_path() . DS, '', $path); $admin->image = str_replace(DS, '/', $path); if ($oldPath == $admin->image) { unset($oldPath); } } $pass = $admin->valid(); if ($pass->passes()) { if (isset($admin->password_confirmation)) { unset($admin->password_confirmation); } if (isset($password)) { $admin->password = Hash::make($password); } $admin->save(); if ($oldRole != $admin->role_id) { if ($oldRole) { $admin->roles()->detach($oldRole); } if ($admin->role_id) { $admin->roles()->attach($admin->role_id); } } if (isset($oldPath) && File::exists(public_path($oldPath))) { File::delete(public_path($oldPath)); } if (Input::has('continue')) { if ($create) { $prevURL = URL . '/admin/admins/edit-admin/' . $admin->id; } return Redirect::to($prevURL)->with('flash_success', "<b>{$admin->first_name} {$admin->last_name}</b> {$message}."); } return Redirect::to(URL . '/admin/admins')->with('flash_success', "<b>{$admin->first_name} {$admin->last_name}</b> {$message}."); } return Redirect::to($prevURL)->with('flash_error', $pass->messages()->all())->withInput(); }
public function verify() { $username = Input::get('username'); $password = Input::get('password'); if (!Admin::count()) { $user = new Admin(); $user->username = Input::get('username'); $user->password = $user->password = Hash::make(Input::get('password')); $user->save(); return Redirect::to('/admin/login'); } else { if (Auth::attempt(array('username' => $username, 'password' => $password))) { if (Session::has('pre_admin_login_url')) { $url = Session::get('pre_admin_login_url'); Session::forget('pre_admin_login_url'); return Redirect::to($url); } else { $admin = Admin::where('username', 'like', '%' . $username . '%')->first(); Session::put('admin_id', $admin->id); return Redirect::to('/admin/report')->with('notify', 'installation Notification'); } } else { return Redirect::to('/admin/login?error=1'); } } }
$db::schema()->dropIfExists('activity'); $db::schema()->dropIfExists('blocked_ips'); $db::schema()->dropIfExists('blocked_user_agents'); $arraynamesexist = []; } if (!in_array('admins', $arraynamesexist)) { $db->schema()->create('admins', function ($table) { $table->increments('id'); $table->string('username')->unique(); $table->string('password'); $table->timestamps(); }); $admin = new Admin(); $admin->username = '******'; $admin->password = md5('admin'); $admin->save(); echo "created admin table <br>" . PHP_EOL; echo "admin created: username: admin and password: admin <br>" . PHP_EOL; } if (!in_array('categories', $arraynamesexist)) { $db->schema()->create('categories', function ($table) { $table->increments('id'); $table->string('name'); $table->timestamps(); }); echo "created categories table <br>" . PHP_EOL; } if (!in_array('category_user', $arraynamesexist)) { $db->schema()->create('category_user', function ($table) { $table->increments('id'); $table->integer('user_id');
/** * Grant user access to search and manage Department. */ public static function add($username, $departmentId) { if (empty($username)) { return NQ::simple('intern', INTERN_WARNING, 'No username entered.'); } if ($departmentId == -1) { return NQ::simple('intern', INTERN_WARNING, 'No department selected.'); } // First check that the username passed in is a registered user. $db = new PHPWS_DB('users'); $db->addWhere('username', $username); $db->addColumn('id', $count = true); if (sizeof($db->select()) == 0) { // No user exists with that name. return NQ::simple('intern', INTERN_ERROR, "No user exists with the name <i>{$username}</i>. Please choose a valid username."); } // Deity users automatically see every department. No need to add them to table. $db->reset(); $db->addWhere('username', $username); $db->addWhere('deity', true); $db->addColumn('id', $count = true); if (sizeof($db->select()) >= 1) { // Is a deity. return NQ::simple('intern', INTERN_WARNING, "<i>{$username}</i> can view all internships in all departments."); } PHPWS_Core::initModClass('intern', 'Department.php'); $d = new Department($departmentId); // Check if user already has permission. if (self::allowed($username, $departmentId)) { // User permission has already been added. return NQ::simple('intern', INTERN_WARNING, "<i>{$username}</i> can already view internships in <i>{$d->name}</i>."); } $ia = new Admin(); $ia->username = $username; $ia->department_id = $departmentId; $ia->save(); NQ::simple('intern', INTERN_SUCCESS, "<i>{$username}</i> can now view internships for <i>{$d->name}</i>."); }
<?php require_once "../../module/Connexion.php"; require_once "../../module/model/admin.php"; if (isset($_POST["email"])) { $admin = new Admin(); # preparation des donnees $data = array('name' => $_POST["name"], 'lname' => $_POST["lname"], 'bd' => $_POST["bd"], 'email' => $_POST["email"], 'password' => $_POST["password"], 'autorite' => $_POST["autorite"]); # enregistrement $result = $admin->save($data); # tester le rendu if ($result) { header("location:../../admin/sous_admin/index?c=success"); } else { header("location:../../admin/sous_admin/index?c=failed"); } # le cas d'un email repeter if ($result == "existe") { header("location:../../admin/sous_admin/index?c=failedmail"); } } else { include_once "../../layout/intrusion/url.inc"; }
Application::run('config'); for ($i = 0; $i < 10; $i++) { if (!isset($argv[$i])) { $argv[$i] = null; } } Console::writeln('Script module loaded.'); switch ($argv[1]) { case 'adduser': $Admin = new Admin(); if ($argv[2]) { echo "Adding user " . $argv[2]; $Admin->Login = $argv[2]; $Admin->Password = Admin::pwd($argv[3]); $Admin->IsSuper = 1; if ($Admin->save()) { echo " - OK\n"; } else { echo " - FAILED\n"; } } else { echo "Login is not set\n"; } break; case 'images': $Product = new Product(); foreach ($Product->findList() as $Product) { $f1 = File::path($Product, 1); $f2 = File::path($Product, 2); File::restore($f2); copy($f1, $f2);
break; case 'add': case 'edit': if ($config->isPOST()) { $adm->email = $_POST['email']; if (!empty($_POST['password']) && $_POST['password'] == $_POST['password2']) { $adm->password = md5($_POST['password']); } else { Messages::addError('Password not changed'); } $adm->access = isset($_POST['access']) ? array_sum($_POST['access']) : 0; if (empty($adm->id) && empty($adm->password)) { Messages::addError('Password can\'t be empty'); jump('?page=administrators&action=add'); } else { $adm->save(); if ($adm->id == Admin::getLogged()->id) { Admin::setLoggedUser($adm); } Messages::addNotice('Saved'); jump('?page=administrators&action=edit&id=' . $adm->id); } } $smarty->assign('accessData', Admin::getAccessData()); $smarty->assign('adm', $adm); $smarty->assign('CONTENT', 'administrators/add_edit.tpl'); break; case 'remove': $adm->delete(); Messages::addNotice('Deleted'); jump('?page=administrators');
public function register() { $username = Input::get("username"); $password = Input::get("password"); $hasher = new BcryptHasher(); $admin = new Admin(); //实例化User对象 $admin->username = $username; $admin->password = $hasher->make($password); $admin->save(); return Response::json(array("errCode" => 0)); }
/** * Adds a new admin or superadmin to the system. Optionally it can send a welcome email. */ public function addAction() { $form = new ViMbAdmin_Form_Admin_Edit(); $form->removeElement('salt'); if ($this->getRequest()->isPost() && $form->isValid($_POST)) { $adminModel = new Admin(); $adminModel->fromArray($form->getValues()); $adminModel->setPassword($form->getValue('password'), $this->_options['securitysalt'], false); $adminModel->save(); LogTable::log('ADMIN_ADD', "Added new " . ($adminModel['super'] ? 'super ' : '') . "admin {$adminModel['username']}", $this->getAdmin()); if ($form->getValue('welcome_email')) { try { $mailer = new Zend_Mail(); $mailer->setSubject(_('ViMbAdmin :: Your New Administrator Account')); $mailer->addTo($adminModel->username); $mailer->setFrom($this->_options['server']['email']['address'], $this->_options['server']['email']['name']); $this->view->username = $adminModel->username; $this->view->password = $form->getValue('password'); $mailer->setBodyText($this->view->render('admin/email/new_admin.phtml')); $mailer->send(); } catch (Exception $e) { $this->getLogger()->debug($e->getTraceAsString()); $this->addMessage(_('Could not send welcome email'), ViMbAdmin_Message::ALERT); } } $this->addMessage(_('You have successfully added a new administrator to the system.'), ViMbAdmin_Message::SUCCESS); $this->_helper->viewRenderer->setNoRender(true); return print $this->view->render('close_colorbox_reload_parent.phtml'); } $this->view->form = $form; }
public function setupAction() { $form = new ViMbAdmin_Form_Admin_Edit(); $form->removeElement('active'); $form->removeElement('super'); $form->removeElement('welcome_email'); if ($this->getAuth()->getIdentity()) { $this->addMessage(_('You are already logged in.'), ViMbAdmin_Message::INFO); $this->_redirect('domain/list'); } if ($this->_options['securitysalt'] == '') { $charSet = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $randomSalt = substr(str_shuffle("{$charSet}{$charSet}"), 0, 31); // please note this is not UTF-8 compatible $this->view->saltSet = false; $this->view->randomSalt = $randomSalt; $form->getElement('salt')->setValue($randomSalt); } elseif (!AdminTable::isEmpty()) { $this->addMessage(_("Admins already exist in the system."), ViMbAdmin_Message::INFO); $this->_redirect('auth/login'); } else { $this->view->saltSet = true; if ($this->getRequest()->isPost() && $form->isValid($_POST)) { if ($form->getElement('salt')->getValue() != $this->_options['securitysalt']) { $this->addMessage(_("Incorrect security salt provided. Please copy and paste it from the <code>application.ini</code> file."), ViMbAdmin_Message::INFO); } else { $admin = new Admin(); $admin['username'] = $form->getValue('username'); $admin->setPassword($form->getValue('password'), $this->_options['securitysalt'], false); $admin->super = true; $admin->active = true; $admin->save(); try { $mailer = new Zend_Mail(); $mailer->setSubject(_('ViMbAdmin :: Your New Administrator Account')); $mailer->addTo($admin['username']); $mailer->setFrom($this->_options['server']['email']['address'], $this->_options['server']['email']['name']); $this->view->username = $admin['username']; $this->view->password = $form->getValue('password'); $mailer->setBodyText($this->view->render('admin/email/new_admin.phtml')); $mailer->send(); } catch (Exception $e) { } $this->addMessage(_('Your administrator account has been added. Please log in below.'), ViMbAdmin_Message::SUCCESS); } // Try and track new installs to see if it is worthwhile continueing development include_once APPLICATION_PATH . '/../public/PiwikTracker.php'; if (class_exists('PiwikTracker')) { if ($_SERVER['HTTPS'] == 'on') { PiwikTracker::$URL = 'https://stats.opensolutions.ie/'; } else { PiwikTracker::$URL = 'http://stats.opensolutions.ie/'; } $piwikTracker = new PiwikTracker($idSite = 5); $piwikTracker->doTrackPageView('Nes Install Completed'); $piwikTracker->doTrackGoal($idGoal = 1, $revenue = 0); } $this->_helper->viewRenderer->setNoRender(true); $this->_redirect('auth/login'); } } $this->view->form = $form; }
private function addAdmin() { $user_model = new User(); $admin_model = new Admin(); $image_model = Image::model(); if (isset($_POST["User"]) && isset($_POST["Admin"])) { $user_model->attributes = $_POST["User"]; $admin_model->attributes = $_POST["Admin"]; //设定用户种别为:管理员 $user_model->usr_kind = 0; //设定用户密码为:xyz123456 $user_model->usr_password = md5("xyz123456"); $user_model->user_chg_pwd_old = "oldpassword"; $user_model->user_chg_pwd_new = "newpassword"; $user_model->user_chg_pwd_new_cfm = "newpassword"; //设置用户头像的默认值 if ($user_model->usr_pic_id == '') { $user_model->usr_pic_id = '100000'; } if ($user_model->save()) { $admin_model->pk_adm_id = $user_model->pk_usr_id; if ($admin_model->save()) { $this->redirect("./index.php?r=user/show"); } else { $user_model->delete(); } } else { //var_dump($user_model->getErrors()); //var_dump($customer_info->getErrors()); echo "<script>alert('用户添加失败!');</script>"; } } $this->renderPartial('add_step2', array("user_info" => $user_model, "admin_info" => $admin_model, "image_model" => $image_model, "user_kind" => 0)); }
public function updateRememberToken(Admin $admin, $token) { $admin->setAttribute($admin->getRememberTokenName(), $token); $admin->save(); }