Exemplo n.º 1
0
 public function loginUser(Request $request)
 {
     $data = $request->all();
     $validator = Validator::make($data, ['mac' => 'required|min:17|max:17', 'uamport' => 'required', 'uamip' => 'required', 'userurl' => 'required', 'res' => 'required']);
     //var_dump($data);
     if ($validator->fails()) {
         $error = (array) json_decode($validator->errors());
         dd($error);
     }
     $url = $data['userurl'];
     if ($data['res'] == "success") {
         header("Location: " . $url);
         exit;
     }
     $dateHostPots = Hostpots::whereName($data['uamport'])->get();
     if (!empty($dateHostPots->toArray())) {
         $uamip = explode(':', $data['uamip']);
         $obj = Hostpots::find($dateHostPots[0]->id);
         $obj->update(array('owner' => $uamip[0]));
         $ip = $uamip[0];
         $table = HotspotsCampania::whereHotspotsId($dateHostPots[0]->id)->whereDayId(date("N"))->get();
         if ($table->toArray()) {
             $idCampania = $table->toArray()[0]['campania_id'];
         } else {
             $datos = GroupsCampania::whereGroupsId($dateHostPots[0]->geocode)->whereDayId(date("N"))->get();
             $idCampania = $datos[0]->campania_id;
         }
         $datosCampania = \App\Models\Campania::whereId($idCampania)->get();
         $imagen = $datosCampania[0]->imagen;
         $extension = explode('.', $imagen);
         $value = $extension[1] == 'jpg' || $extension[1] == 'png' || $extension[1] == 'jpeg' || $extension[1] == 'gif' ? 'img' : 'video';
     } else {
         $msg = array('msg' => 'no existe equipo asociado');
         dd($msg);
     }
     $User = $this->getUser($data['mac']);
     // Usergroup
     $this->getUsergroup($data['mac'], $data['uamport']);
     //$href = 'http://' . $ip . '?login?user='******'username'] . '&password='******'value'] . '&dst=' . $datosCampania[0]->url;
     $href = 'http://' . $ip . '/login?user='******'username'] . '&password='******'value'] . '&dst=' . $datosCampania[0]->url;
     return viewc('home.login-user.login', compact('ip', 'href', 'imagen', 'value'));
 }
Exemplo n.º 2
0
 public function postConfiguracion2(Request $request)
 {
     $data = $request->all();
     GroupsCampania::whereGroupsId($data['groups_id'])->forceDelete();
     GroupsCampania::create($data);
     $dataEquipos = Hostpots::whereGeocode($data['groups_id'])->get();
     $datosCampania = Campania::whereId($data['campania_id'])->get();
     $datosCampaniaFinal = $datosCampania->toArray();
     $datosGrupo = Groups::find($data['groups_id'])->lists('name');
     Radgroupreply::whereGroupname($datosGrupo[0])->forceDelete();
     foreach ($dataEquipos->toArray() as $v) {
         $valor1 = array('groupname' => $datosGrupo[0], 'MikroTik-Advertise-URL', 'op' => '==', 'value' => $datosCampaniaFinal[0]['url']);
         Radgroupreply::create($valor1);
         $valor2 = array('groupname' => $datosGrupo[0], 'MikroTik-Advertise-Interval', 'op' => '==', 'value' => $datosCampaniaFinal[0]['expiracion']);
         Radgroupreply::create($valor2);
         $valor3 = array('groupname' => $datosGrupo[0], 'MikroTik-Rate-Limit', 'op' => '==', 'value' => $datosCampaniaFinal[0]['megas']);
         Radgroupreply::create($valor3);
     }
     echo nl2br("\r\n\r\n\r\n\r\nCONFIGURACION GUARDADA CORRECTAMENTE", false);
     exit;
 }