Beispiel #1
0
 public function get_iplogrefresh()
 {
     $logs = IPLog::where('user_id', '=', Auth::user()->id)->get();
     if (empty($logs)) {
         return View::make('msg.errorn')->with('error', 'You have not logged any IP addresses yet.');
     }
     $str = '<table class="table table-condensed">
             <thead>
                 <th>IP address</th>
                 <th>First log at</th>
                 <th>Last seen at</th>
             </thead>
             <tbody>
             ';
     foreach ($logs as $log) {
         $str .= '
             <tr>
                 <td>' . htmlspecialchars($log->ip) . '</td>
                 <td>' . date('Y-m-d H:i', strtotime($log->created_at)) . '</td>
                 <td>' . date('Y-m-d H:i', strtotime($log->updated_at)) . '</td>
             </tr>
         ';
     }
     $str .= '</tbody></table>';
     return $str;
 }
Beispiel #2
0
 public function get_show($id = NULL)
 {
     $user = User::find($id);
     if (empty($user)) {
         return Redirect::to('http://9gag.com/gag/' . rand(300, 6000000));
     }
     if (IPLog::where('ip', '=', $_SERVER['REMOTE_ADDR'])->where('user_id', '=', $user->id)->count() >= 1) {
         $i = IPLog::where('ip', '=', $_SERVER['REMOTE_ADDR'])->where('user_id', '=', $user->id)->first();
         $i->touch();
     } else {
         IPLog::create(array('user_id' => $id, 'ip' => $_SERVER['REMOTE_ADDR']));
     }
     if (empty($user->iplog_link)) {
         return Redirect::to('http://9gag.com/gag/' . rand(300, 6000000));
     }
     return Redirect::to($user->iplog_link);
 }
Beispiel #3
0
 public function transfer()
 {
     if (Session::has('username') && (Session::get('user_type') == "Root" || Session::get('user_type') == "Admin")) {
         $input = Input::all();
         $ip = IP::find($input["id"]);
         if (!$ip) {
             return Redirect::to("assets/IP");
         }
         $validator = Validator::make(array("employee number" => trim($input["employee_number"])), array("employee number" => "required|numeric|exists:tbl_employees,employee_number"));
         if ($validator->fails()) {
             return Redirect::to("assets/IP/transferasset/" . Input::get("id"))->withInput()->with("message", $validator->messages()->first());
         } else {
             if ($input["employee_number"] != null && !empty($ip->employee->last_name) && $ip->employee_number == $input["employee_number"]) {
                 return Redirect::to("assets/office/transferasset/" . Input::get("id"))->withInput()->with("message", "Cannot transfer an asset to the same employee.");
             } else {
                 if (!empty($ip->employee->last_name)) {
                     //Get the employee
                     $employee = Employee::where("employee_number", "=", $input["employee_number"])->first();
                     $desc = "IP Asset <strong>" . $ip->ip . "</strong> transferred from <strong>" . $ip->employee->first_name . " " . $ip->employee->last_name . "</strong> and assigned to employee <strong>" . $employee->first_name . " " . $employee->last_name;
                     //Reassign the asset to the employee
                     $ip->requestor = $employee->employee_number;
                     $ip->save();
                 } else {
                     //Get the employee
                     $employee = Employee::where("employee_number", "=", $input["employee_number"])->first();
                     $desc = "IP Asset <strong>" . $ip->ip . "</strong> transferred to <strong>" . $employee->first_name . " " . $employee->last_name;
                     //Reassign the asset to the employee
                     $ip->requestor = $employee->employee_number;
                     $ip->save();
                 }
                 $newLog = new UserLog();
                 $newLog->description = $desc;
                 $newLog->user_id = Session::get('user_id');
                 $newLog->type = "System";
                 $newLog->save();
                 //Log to software logs
                 $ipLog = new IPLog();
                 $ipLog->user_id = Session::get("user_id");
                 $ipLog->ip_id = $ip->id;
                 $ipLog->employee_id = !empty($ip->employee->id) ? $ip->employee->id : null;
                 $ipLog->description = $desc;
                 $ipLog->transaction = "History";
                 $ipLog->save();
                 return Redirect::to("assets/IP/transferasset/" . Input::get("id"))->with("success", "You have successfully transferred the asset.");
             }
         }
     } else {
         return Redirect::to("/");
     }
 }