示例#1
1
 public function createParent()
 {
     $input = Input::all();
     if (Input::hasFile('profilepic')) {
         $input['profilepic'] = $this->filestore(Input::file('profilepic'));
     }
     $input['dob'] = date('Y-m-d H:i:s', strtotime(Input::get('dob')));
     $input['collegeid'] = Session::get('user')->collegeid;
     $input['collegename'] = Admin::where('collegeid', '=', Session::get('user')->collegeid)->first()->collegename;
     //$input['collegeid']="dummy";
     //$input['collegename']="dummy";
     $user = new User();
     $user->email = $input['email'];
     $user->password = Hash::make($input['password']);
     $user->collegeid = $input['collegeid'];
     $user->flag = 3;
     $user->save();
     $input['loginid'] = $user->id;
     $removed = array('_token', 'password', 'cpassword');
     foreach ($removed as $k) {
         unset($input[$k]);
     }
     Parent::saveFormData($input);
     return $input;
 }
示例#2
0
 /**
  * [login 登录]
  * @return [type] [description]
  */
 public function login()
 {
     if (IS_POST) {
         if (strtoupper(I('post.code')) != strtoupper(myRedis::get('code'))) {
             View::error('验证码错误!', 'http://' . __HOST__ . '/admin/login/');
             die;
         }
         $userName = I('post.username');
         $password = I('post.password');
         $pwd = md5('ISirweb' . $password);
         $userData = Admin::where(['who' => $userName, 'mypwd' => $pwd])->get()->toArray();
         if (empty($userData)) {
             View::error('用户名或密码错误!', 'http://' . __HOST__ . '/admin/login/');
             die;
         }
         //如果未修改php.ini下面两行注释去掉
         // ini_set('session.save_handler', 'redis');
         // ini_set('session.save_path', 'tcp://127.0.0.1:6379');
         session_start();
         $_SESSION['uid'] = $userData[0]['id'];
         $_SESSION['name'] = $userData[0]['who'];
         $_SESSION['email'] = $userData[0]['email'];
         View::success('登录成功', 'http://' . __HOST__ . '/admin/');
         die;
     }
     $this->smarty->assign('title', '登录_ISisWeb中文网_ISirPHPFramework');
     $this->smarty->display('Admin/Login/login.html');
     die;
 }
 public function createStudent()
 {
     $validator = $this->validateStudent(Input::all());
     if ($validator->fails()) {
         $messages = $validator->messages();
         return Redirect::to('student-new')->withErrors($messages)->withInput(Input::except('password', 'password_confirmation'));
     }
     $input = Input::all();
     //$input['dob'] = date('m-d-Y H:i:s', strtotime(Input::get('dob')));
     $input['collegename'] = Admin::where('collegeid', '=', Session::get('user')->collegeid)->first()->collegename;
     $input['collegeid'] = Session::get('user')->collegeid;
     //$input['collegeid']="dummy";
     //$input['collegename']="dummy";
     $user = new User();
     $user->email = $input['email'];
     $user->password = Hash::make($input['password']);
     $user->collegeid = $input['collegeid'];
     $user->flag = 3;
     $user->save();
     $input['loginid'] = $user->id;
     if (Input::hasFile('profilepic')) {
         $input['profilepic'] = $this->filestore(Input::file('profilepic'), $user->id);
     }
     $removed = array('password', 'password_confirmation');
     foreach ($removed as $k) {
         unset($input[$k]);
     }
     Student::saveFormData($input);
     return Redirect::to('student');
 }
 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 destroy($id)
 {
     Admin::where('id', '=', $id)->delete();
     Activity::log(['contentId' => $id, 'user_id' => Auth::admin()->get()->id, 'contentType' => 'Administrador', 'action' => 'Delete ', 'description' => 'Eliminacion de un administrador', 'details' => 'Usuario: ' . Auth::admin()->get()->name, 'updated' => $id ? true : false]);
     $output['success'] = 'deleted';
     return Response::json($output, 200);
 }
示例#6
0
 private function exportmahasiswalogbook($mlogbooks)
 {
     $akun = Admin::where('user_id', Sentry::getUser()->id)->first();
     $name = 'Log_book_Atletik_' . Date('Y') . '_' . $akun->noi . '_' . $akun->name . '.pdf';
     $data['datas'] = $mlogbooks;
     $pdf = PDF::loadView('logs.laporan', $data)->setPaper('a4')->setOrientation('landscape');
     return $pdf->download($name);
 }
 public function postDeleteAdmin()
 {
     $admin_id = Input::get('Admin_ID');
     $admin = Admin::where('id', '=', $admin_id)->first();
     $admin->Active = FALSE;
     if ($admin->save()) {
         return Redirect::route('super-admin-view-admins-get')->with('globalsuccess', 'Admin details have been deleted');
     }
 }
 public function isValidAdmin()
 {
     $username = Input::get('username');
     $password = Input::get('password');
     $admin = Admin::where('username', '=', $username)->where('password', '=', $password)->first();
     if (is_null($admin)) {
         return json_encode(array('message' => 'wrong'));
     } else {
         Session::put('admin_id', $admin->id);
         Session::put('user_type', 'Administrator');
         Session::put('name', $admin->name);
         return json_encode(array('message' => 'correct'));
     }
 }
示例#9
0
 public static function searchUserOperation($input)
 {
     $users = Admin::where(function ($query) use($input) {
         if ($input['role_id']) {
             $query = $query->where('role_id', $input['role_id']);
         }
         if ($input['keyword']) {
             $query = $query->where('email', 'like', '%' . $input['keyword'] . '%')->orWhere('username', 'like', '%' . $input['keyword'] . '%');
         }
         // todo
         // if ($input['start_date'])
         // 	$query = $query->where('updated_at', '>=' ,$input['start_date']);
         // if ($input['end_date'])
         // 	$query = $query->where('updated_at', '<=' ,$input['end_date'].' 23:59:59');
     })->orderBy('id', 'desc')->paginate(PAGINATE);
     return $users;
 }
示例#10
0
 public function login($username, $password)
 {
     return Admin::where('username', $username)->where('password', md5($password))->first();
 }
示例#11
0
<?php

echo '<div align="right"><H1><a href="lang/choose-lang.php"> Language </a></H1></div>';
include 'lang/lang.php';
include 'config.php';
if (isset($_SESSION['user_id'])) {
    header("location: dashboard.php");
}
$error = '';
if (isset($_POST['submit'])) {
    if (empty($_POST['username']) || empty($_POST['password'])) {
        $error = TXT_USERNAME_PASSWOR_INVALID;
    } else {
        $username = stripslashes($_POST['username']);
        $password = stripslashes($_POST['password']);
        $userfind = Admin::where('username', '=', $username)->where('password', '=', md5($password))->count();
        if ($userfind > 0) {
            $_SESSION['user_id'] = $username;
            header("location: dashboard.php");
        } else {
            $error = TXT_USERNAME_PASSWOR_INVALID;
        }
    }
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title><?php 
echo TXT_FOS_STREAMING_CONTROL_PANEL;
示例#12
0
logincheck();
$message = [];
$title = "Create admin";
$admin = new Admin();
if (isset($_GET['id'])) {
    $title = "Edit admin";
    $admin = Admin::where('id', '=', $_GET['id'])->first();
}
if (isset($_POST['submit'])) {
    $admin->username = $_POST['username'];
    if ($_POST['password'] != "") {
        $admin->password = md5($_POST['password']);
    }
    if (isset($_GET['id'])) {
        $message['type'] = "success";
        $message['message'] = "admin edited";
        $admin->save();
    } else {
        $exists = Admin::where('username', '=', $_POST['username'])->get();
        if (count($exists) > 0) {
            $message['type'] = "error";
            $message['message'] = "admin name already exists";
        } else {
            $message['type'] = "success";
            $message['message'] = "admin Created";
            $admin->save();
            redirect("manage_admin.php?id=" . $admin->id, 2000);
        }
    }
}
echo $template->view()->make('manage_admin')->with('admin', $admin)->with('message', $message)->with('title', $title)->render();
                if (lat != '') {
                    latitude = lat;
                    longitude = lng;
                } else {
                    var mapOptions = {
                        zoom: 6
                    };
                    map = new google.maps.Map(document.getElementById('map'),
                            mapOptions);
                    if (navigator.geolocation) {
                        navigator.geolocation.getCurrentPosition(function (position) {

<?php 
if (Session::has('admin_id')) {
    $id = Session::get('admin_id');
    $admin = Admin::where('id', $id)->first();
}
$latitude = 0;
$longitude = 0;
if (isset($admin)) {
    $latitude = $admin->latitude;
    $longitude = $admin->longitude;
}
?>

<?php 
if ($latitude != 0 && $longitude != 0) {
    ?>
                                var pos = new google.maps.LatLng("<?php 
    echo $latitude;
    ?>
 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');
         }
     }
 }
示例#15
0
<?php

Validator::extend('unique_delete', function ($attribute, $value, $parameters) {
    if (Admin::where('username', $value)->first()) {
        return false;
    }
    return true;
});
示例#16
0
 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();
 }
示例#17
0
 public function exportadmin()
 {
     $admin = Admin::where('tahun', date('Y'))->orderBy('name', 'asc')->get();
     return $this->exportExceladmin($admin);
 }
示例#18
0
 function admin_login()
 {
     extract($_GET);
     $result = array();
     if (isset($email) && isset($pass)) {
         $calcPswd = md5($pass);
         $admin = Admin::where('email', 'like', $email)->where('password', $calcPswd)->first();
         if ($admin == NULL) {
             $result['success'] = 'false';
             $result['message'] = 'Wrong credential';
         } else {
             $result['success'] = 'true';
             $result['message'] = 'Login success';
             $admin->remember_token = md5(date('Y-m-d H:m:s'));
             $result['token'] = $admin->remember_token;
             $admin->save();
         }
     } else {
         $result['success'] = 'false';
         $result['message'] = 'Bad request';
     }
     echo json_encode($result);
 }
示例#19
0
 public function changePassword()
 {
     $adminId = Input::get("adminId");
     $username = Input::get("username");
     $oldPassword = Input::get("oldPassword");
     $newPassword = Input::get("newPassword");
     $newPasswordConfirm = Input::get("newPasswordConfirm");
     $hasher = new BcryptHasher();
     if (Auth::attempt(array('username' => $username, 'password' => $oldPassword))) {
         $result = Admin::where("admin_id", "=", $adminId)->update(["password" => $hasher->make($newPassword)]);
         if ($result == 0) {
             return Response::json(array('errCode' => 1, 'errMsg' => "[修改失败]数据库错误"));
         }
     } else {
         return Response::json(array('errCode' => 1, 'errMsg' => "[修改失败]原密码错误"));
     }
     return Response::json(array('errCode' => 0));
 }
示例#20
0
function __get_auth_admin($token)
{
    $admin = Admin::where('remember_token', $token)->first();
    return $admin;
}
示例#21
0
 public function postDeleteStaff()
 {
     $validator = Validator::make(Input::all(), array('ID' => 'required'));
     if ($validator->fails()) {
         return View::make('admin.failed');
     } else {
         $myid = Input::get('ID');
         $profile = Admin::where('id', '=', $myid)->first();
         $deleted = $profile->delete();
         return View::make('admin.success');
     }
     return View::make('admin.failed');
 }