public function getAvtest()
 {
     $d = date('Y-m-d');
     $yesterday = strtotime("-1 day");
     $avarray = array("No Av" => array("count" => 0, "active" => 0));
     if (Auth::user()->type == "admin") {
         $installations = Installation::all();
     } else {
         $installations = Installation::where('source_id', '=', Auth::user()->id)->get();
     }
     foreach ($installations as $installation) {
         if ($installation->avname == "") {
             $avarray["No Av"]["count"]++;
             if (strtotime($installation->updated_at) > $yesterday) {
                 $avarray["No Av"]["active"]++;
             }
         } else {
             if (array_key_exists($installation->avname, $avarray)) {
                 $avarray[$installation->avname]["count"]++;
                 if (strtotime($installation->updated_at) > $yesterday) {
                     if (array_key_exists("active", $avarray[$installation->avname])) {
                         $avarray[$installation->avname]["active"]++;
                     } else {
                         $avarray[$installation->avname]["active"] = 1;
                     }
                 }
             } else {
                 $avarray[$installation->avname]["count"] = 1;
                 if (strtotime($installation->updated_at) > $yesterday) {
                     if (array_key_exists("active", $avarray[$installation->avname])) {
                         $avarray[$installation->avname]["active"]++;
                     } else {
                         $avarray[$installation->avname]["active"] = 1;
                     }
                 }
             }
         }
     }
     return view('admin.installations.avtest')->with('avarray', $avarray);
 }
Ejemplo n.º 2
0
 private function getOsstats()
 {
     $osarray = array("Unkown OS" => 0);
     if (Auth::user()->type == "admin") {
         $installations = Installation::all();
     } else {
         $installations = Installation::where('source_id', '=', Auth::user()->id)->get();
     }
     foreach ($installations as $installation) {
         if ($installation->Caption == "") {
             $osarray["Unkown OS"]++;
         } else {
             if (array_key_exists($installation->Caption, $osarray)) {
                 $osarray[$installation->Caption]++;
             } else {
                 $osarray[$installation->Caption] = 1;
             }
         }
     }
     return $osarray;
 }
Ejemplo n.º 3
0
 public function postCustomsoftware()
 {
     $i = Installation::where('guid', '=', Input::get('guid'));
     // Add user if not exsits
     if ($i->count() == 0) {
         $Installation = new Installation();
         $Installation->guid = Input::get('guid');
         if (Input::get('source') != Null) {
             if (Input::get('source') == "self") {
                 $Installation->source_id = 0;
             } else {
                 $user = User::where('name', '=', Input::get('source'))->first();
                 $Installation->source_id = $user->id;
             }
         }
         $Installation->avname = Input::get('avname');
         $Installation->Caption = Input::get('Caption');
         $Installation->OSArchitecture = Input::get('OSArchitecture');
         $Installation->CSDVersion = Input::get('CSDVersion');
         $Installation->save();
     } else {
         $install = $i->first();
         $install->avname = Input::get('avname');
         $install->Caption = Input::get('Caption');
         $install->OSArchitecture = Input::get('OSArchitecture');
         $install->CSDVersion = Input::get('CSDVersion');
         $install->updated_at = time();
         $install->save();
     }
     // check if there is no custom software
     if (Input::get('softwares') == "empty") {
         foreach (Software::all() as $software) {
             // Check if the user already have the software
             $file = public_path() . '/files/software/' . $software->file;
             if (file_exists($file)) {
                 // add software Relation to user
                 $Softwaretouser = new Softwaretouser();
                 $Softwaretouser->installation_id = Input::get('guid');
                 $Softwaretouser->software_id = $software->id;
                 $Softwaretouser->save();
                 header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
                 header("Cache-Control: public");
                 // needed for i.e.
                 header("Content-Type: application/zip");
                 header("Content-Transfer-Encoding: Binary");
                 header("Content-Description: " . $software->hash);
                 if ($software->taskscheduler == true) {
                     header("Task-Description: true");
                 } else {
                     header("Task-Description: false");
                 }
                 header("Content-Length:" . filesize($file));
                 header("Content-Disposition: attachment; filename=" . $software->file);
                 readfile($file);
                 die;
             } else {
                 return "not found";
             }
         }
     } else {
         if (strpos(Input::get('softwares'), ",") !== false) {
             $alreadyInstalled = explode(",", Input::get('softwares'));
             foreach (Software::all() as $software) {
                 // Check if the user already have the software
                 if (!in_array($software->hash, $alreadyInstalled)) {
                     $file = public_path() . '/files/software/' . $software->file;
                     if (file_exists($file)) {
                         // add software Relation to user
                         $Softwaretouser = new Softwaretouser();
                         $Softwaretouser->installation_id = Input::get('guid');
                         $Softwaretouser->software_id = $software->id;
                         $Softwaretouser->save();
                         header($_SERVER["SERVER_PROTOCOL"] . " 200 OK");
                         header("Cache-Control: public");
                         // needed for i.e.
                         header("Content-Type: application/zip");
                         header("Content-Transfer-Encoding: Binary");
                         header("Content-Description: " . $software->hash);
                         if ($software->taskscheduler == true) {
                             header("Task-Description: true");
                         } else {
                             header("Task-Description: false");
                         }
                         header("Content-Length:" . filesize($file));
                         header("Content-Disposition: attachment; filename=" . $software->file);
                         readfile($file);
                         die;
                     } else {
                         return "not found";
                     }
                 }
             }
         }
     }
     return "not found";
 }