/**
  * Store a newly created resource in storage.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['numbers' => 'required|max:255', 'letters' => 'required|max:255', 'housenr' => 'required|max:255']);
     $zipcode = Zipcode::where('pnum', $request->input('numbers'))->where('pchar', $request->input('letters'))->firstOrFail();
     switch ($zipcode->numbertype) {
         case 'even':
             if ($request->input('housenr') % 2 == 0) {
                 if ($this->between($request->input('housenr'), $zipcode->minnumber, $zipcode->maxnumber)) {
                     return response()->json($zipcode);
                 } else {
                     return redirect::back()->with('error', 'uw huisnr bestaat niet i.c.m. deze postcode');
                 }
             }
             break;
         case 'odd':
             if ($request->input('housenr') % 2 == 1) {
                 if ($this->between($request->input('housenr'), $zipcode->minnumber, $zipcode->maxnumber)) {
                     return response()->json($zipcode);
                 } else {
                     return redirect::back()->with('error', 'uw huisnr bestaat niet i.c.m. deze postcode');
                 }
             }
             break;
         case 'mixed':
             if ($this->between($request->input('housenr'), $zipcode->minnumber, $zipcode->maxnumber)) {
                 return response()->json($zipcode);
             } else {
                 return redirect::back()->with('error', 'uw huisnr bestaat niet i.c.m. deze postcode');
             }
             break;
         default:
             return redirect::back()->with('error', 'uw huisnr bestaat niet i.c.m. deze postcode');
     }
 }
 function checkLogin()
 {
     $data = Input::all();
     $partner = Partner::check_login($data['PARTNER_USERNAME'], md5($data['PARTNER_PASSWORD']))->where('PARTNER_TYPE_ID', '=', $data['PARTNER_TYPE_ID'])->first();
     print_r($partner);
     if (sizeof($partner) > 0) {
         if ($partner['PARTNER_TYPE_ID'] == 1) {
             Session(['id' => $partner['PARTNER_ID'], 'hak' => 'partner_travel']);
             return redirect::to('travelpartner');
         } else {
             if ($partner['PARTNER_TYPE_ID'] == 2) {
                 Session(['id' => $partner['PARTNER_ID'], 'hak' => 'partner_rent']);
                 return redirect::to('rentpartner');
             } else {
                 Session(['id' => $partner['PARTNER_ID'], 'hak' => 'partner_ticket']);
                 return redirect::to('ticketpartner');
             }
         }
     } else {
         $member = ['MEMBER_USERNAME' => $data['PARTNER_USERNAME'], 'MEMBER_PASSWORD' => md5($data['PARTNER_PASSWORD'])];
         $member = Member::check_login($member)->get();
         if (sizeof($member) > 0) {
             echo "member";
         } else {
             Session::flash('message', 'Password yang anda masukkan salah');
             return redirect::back();
         }
     }
 }
 function transaksiSubmit()
 {
     $data = Input::all();
     $flag = $data['flag'];
     print_r($data);
     $schedule = Travelschedule::findschedule($data['TRAVEL_SCHEDULE_ID'])->first();
     unset($data['_token']);
     $schedule_id = $data['TRAVEL_SCHEDULE_ID'];
     unset($data['_token'], $data['flag']);
     $costumer = $data;
     unset($data['COSTUMER_EMAIL'], $data['COSTUMER_NAME'], $data['COSTUMER_TELP']);
     if (!is_null(Session::get('id')) and Session::get('hak') == 'COSTUMER') {
         $data['MEMBER_ID'] = Session::get('id');
     } else {
         unset($costumer['TRAVEL_SCHEDULE_ID'], $costumer['TRAVEL_TRANSACTION_PASSENGER'], $costumer['TRAVEL_TRANSACTION_PRICE']);
         Costumer::insert($costumer);
         $id = DB::getPdo()->lastInsertId();
         $data['COSTUMER_ID'] = $id;
     }
     $data['TRAVEL_TRANSACTION_STATUS_ID'] = 1;
     Traveltransaction::insert($data);
     $idtransaksi = DB::getPdo()->lastInsertId();
     $code = DB::select('select travel_code() as code');
     $code = $code[0]->code;
     $code_transaksi = ['TRAVEL_TRANSACTION_CODE' => $code];
     $transaksi = Traveltransaction::where('TRAVEL_TRANSACTION_ID', '=', $idtransaksi);
     $transaksi->update($code_transaksi);
     if ($flag == 1) {
         return redirect::back();
     } else {
         return redirect::to('/');
     }
 }
예제 #4
0
 function destroy()
 {
     $id = Input::get('TRAVEL_SCHEDULE_ID');
     $travel = travelschedule::findSchedule($id);
     $travel->delete();
     return redirect::back()->with('tanggal');
 }
예제 #5
0
 public function getAdd($id)
 {
     $record = Customer::find($id);
     if (count($record) < 0) {
         return redirect::back();
     }
     return view(vw('theme.work.add'), compact('record'))->withTitle('İş Ekle');
 }
예제 #6
0
파일: list.php 프로젝트: 453111208/bbc
 public function index()
 {
     $objLibFilter = kernel::single('topc_item_filter');
     $params = $objLibFilter->decode(input::get());
     $params['use_platform'] = '0,1';
     //判断自营  自营是1,非自营是0
     if ($params['is_selfshop'] == '1') {
         $pagedata['isself'] = '0';
     } else {
         $pagedata['isself'] = '1';
     }
     //如果不是从分类进入,并且没有关键字搜索则不能进入列表页
     $params['search_keywords'] = trim($params['search_keywords']);
     if (empty($params['cat_id']) && empty($params['search_keywords'])) {
         return redirect::back();
     }
     //默认图片
     $pagedata['image_default_id'] = app::get('image')->getConf('image.set');
     //搜索或者筛选获取商品
     $searchParams = $this->__preFilter($params);
     $searchParams['fields'] = 'item_id,title,image_default_id,price,promotion.ids';
     $itemsList = app::get('topc')->rpcCall('item.search', $searchParams);
     //检测是否有参加团购活动
     if ($itemsList['list']) {
         $itemsList['list'] = array_bind_key($itemsList['list'], 'item_id');
         $itemIds = array_keys($itemsList['list']);
         $activityParams['item_id'] = implode(',', $itemIds);
         $activityParams['status'] = 'agree';
         $activityParams['end_time'] = 'bthan';
         $activityParams['start_time'] = 'sthan';
         $activityParams['fields'] = 'activity_id,item_id,activity_tag,price,activity_price';
         $activityItemList = app::get('topc')->rpcCall('promotion.activity.item.list', $activityParams);
         if ($activityItemList['list']) {
             foreach ($activityItemList['list'] as $key => $value) {
                 $itemsList['list'][$value['item_id']]['activity'] = $value;
                 $itemsList['list'][$value['item_id']]['price'] = $value['activity_price'];
             }
         }
     }
     //根据条件搜索出最多商品的分类,进行显示渐进式筛选项
     $filterItems = app::get('topc')->rpcCall('item.search.filterItems', $params);
     //渐进式筛选的数据
     $pagedata['screen'] = $filterItems;
     $pagedata['items'] = $itemsList['list'];
     //根据条件搜索出的商品
     $pagedata['count'] = $itemsList['total_found'];
     //根据条件搜索到的总数
     //已有的搜索条件
     $tmpFilter = $params;
     unset($tmpFilter['pages']);
     $pagedata['filter'] = $objLibFilter->encode($tmpFilter);
     //分页
     $pagedata['pagers'] = $this->__pages($params['pages'], $pagedata['count'], $pagedata['filter']);
     //已选择的搜索条件
     $pagedata['activeFilter'] = $params;
     return $this->page('topc/list/index.html', $pagedata);
 }
 public function add($id)
 {
     $bag = new Bag();
     $bag->productId = $id;
     $bag->inBag = 0;
     $bag->save();
     $bag->users()->attach(Auth::user()->id);
     $bag->products()->attach($id);
     return redirect::back();
 }
예제 #8
0
 public static function eliminarDelCarrito($id)
 {
     $ldv = \App\LineaDeVenta::find(Carrito::find($id)->idLineaDeVenta);
     $carrito = Carrito::find($id);
     //Eliminar la relación en el carrito
     $carrito->delete($id);
     //Eliminar la linea de venta
     $ldv->delete($ldv);
     return redirect::back();
 }
 public function index()
 {
     if (Auth::check()) {
         if (Auth::user()->tipoDeUsuario == 2) {
             $cntPedidos = Pedido::pedidosPendientes();
             return view('empleado.principal', compact('cntPedidos'));
         } else {
             return redirect::back();
         }
     } else {
         return redirect::to('/');
     }
 }
예제 #10
0
파일: list.php 프로젝트: 453111208/bbc
 public function index()
 {
     $postdata = input::get();
     $pagedata = $this->__getItems($postdata);
     if (!$pagedata) {
         return redirect::back();
     }
     if ($pagedata['screen']['shopInfo']) {
         $pagedata['shopDsrData'] = $this->__getShopDsr($pagedata['screen']['shopInfo']['shop_id']);
     }
     $pagedata['title'] = "搜索结果";
     return $this->page('topm/list/index.html', $pagedata);
 }
예제 #11
0
 function store()
 {
     $data = Input::all();
     unset($data['_token']);
     $data['VEHICLE_PHOTO'] = md5(time()) . '.jpg';
     $data['VEHICLE_STATUS_ID'] = '1';
     $destPath = public_path() . '/Assets/vehiclePhoto';
     Input::file('VEHICLE_PHOTO')->move($destPath, $data['VEHICLE_PHOTO']);
     $data['VEHICLE_CREATEBY'] = session::get('id');
     print_r($data);
     Vehicle::insert($data);
     return redirect::back();
 }
예제 #12
0
파일: search.php 프로젝트: 453111208/bbc
 public function index()
 {
     $keyword = input::get('keyword');
     $searchType = input::get('searchtype');
     if (!empty($keyword)) {
         if ($searchType == 'shop') {
             return redirect::action('topc_ctl_shopcenter@search', array('n' => $keyword));
         } else {
             return redirect::action('topc_ctl_list@index', array('n' => $keyword));
         }
     } else {
         return redirect::back();
     }
 }
예제 #13
0
 public function login()
 {
     $data = Input::all();
     $data['password'] = md5($data['password']);
     $user = User::checklogin($data)->get();
     if (sizeof($user) > 0) {
         $rule = User::getHakAkses($user[0]['USERS_ID'])->get();
         session(['hak' => 'admin', 'name' => $user[0]['USERS_NAME'], 'id' => $user[0]['USERS_ID']]);
         return redirect::to('usermanagement');
     } else {
         Session::flash('error', "Password dan Username yang anda masukkan salah");
         return redirect::back();
     }
 }
예제 #14
0
 public function store()
 {
     $data = Input::all();
     unset($data['_token']);
     $data['RENT_SCHEDULE_CREATEBY'] = session::get('id');
     $data['RENT_SCHEDULE_DATE'] = date('Y-m-d', strtotime($data['RENT_SCHEDULE_DATE']));
     print_r($data);
     $flag = Rentschedule::whereDate('RENT_SCHEDULE_DATE', '=', date('Y-m-d', strtotime($data['RENT_SCHEDULE_DATE'])))->where('VEHICLE_ID', '=', $data['VEHICLE_ID'])->count();
     if ($flag == 0) {
         Rentschedule::insert($data);
     } else {
         Session::flash("error", "Ada jadwal yang bentrok, mohon periksa kembali");
     }
     return redirect::back();
 }
예제 #15
0
 public function add($id)
 {
     $bag = Auth::user()->bags->where('productId', $id)->where('inBag', 1);
     if (count($bag) > 0) {
         return redirect()->action('BagController@index');
     }
     $bag = new Bag();
     $bag->productId = $id;
     $bag->inBag = 1;
     $bag->save();
     $bag->users()->attach(Auth::user()->id);
     $bag->products()->attach($id);
     if (count(Auth::user()->bags->where('productId', $id)->where('inBag', 0)) != 0 && Auth::user()->bags->where('productId', $id)->where('inBag', 0)->first()->exists()) {
         return redirect('heartbag/remove/' . $id);
     }
     return redirect::back();
 }
예제 #16
0
 /**
  * Render an exception into an HTTP response.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Exception  $e
  * @return \Illuminate\Http\Response
  */
 public function render($request, Exception $e)
 {
     if ($e instanceof ModelNotFoundException) {
         $e = new NotFoundHttpException($e->getMessage(), $e);
     } else {
         if ($e instanceof QueryException) {
             preg_match_all('/ORA-20001: constraint (.*?) violated/', $e, $matchTriggerViolations);
             preg_match_all('/ORA-02290: check constraint (.*?) violated/', $e, $matchConstraintViolations);
             if (count($matchTriggerViolations[1])) {
                 switch ($matchTriggerViolations[1][0]) {
                     case '(not a driver)':
                         return redirect::back()->with('errors', 'Sorry, you are not a driver.');
                     case '(invalid ride capacity)':
                         return redirect::back()->with('errors', 'Your car does not have enough capacity for your stated ride.');
                     case '(ride timing not after 1 hour of current time)':
                         return redirect::back()->with('errors', 'Your departure timing must be at least 1 hour after the current time.');
                     case '(ride to insert too close to others)':
                         return redirect::back()->with('errors', 'You have other rides that are too close to this ride (i.e. within +/- 1 hour of your other rides).');
                     case '(not enough credit)':
                         return redirect::back()->with('errors', 'You do not have enough credit in your account balance for this ride.');
                     case '(ride to sign up too close to others)':
                         return redirect::back()->with('errors', 'You have signed up for rides that are too close to the selected ride (i.e. within +/- 1 hour of your other rides).');
                 }
             }
             if (count($matchConstraintViolations[1])) {
                 switch ($matchConstraintViolations[1][0]) {
                     case '(A0097663.VALIDBALANCE)':
                         return redirect::back()->with('errors', 'Your account balance cannot be negative.');
                     case '(A0097663.VALIDEMAIL)':
                         return redirect::back()->with('errors', 'Your email is invalid.');
                     case '(A0097663.VALIDNUMSEATS)':
                         return redirect::back()->with('errors', 'Your car must have at least 1 seating capacity.');
                     case '(A0097663.VALIDCANCEL)':
                         return redirect::back()->with('errors', 'You cannot cancel the ride after it has started.');
                     case '(A0097663.VALIDPRICE)':
                         return redirect::back()->with('errors', 'Your ride price-per-seat cannot be negative.');
                     case '(A0097663.VALIDDESTANDDEPARTLOC)':
                         return redirect::back()->with('errors', 'Your destination cannot be the same as your departure location!');
                     case '(A0097663.NOOWNRIDESIGNUP)':
                         return redirect::back()->with('errors', 'You cannot sign up for your own ride.');
                 }
             }
         }
     }
     return parent::render($request, $e);
 }
예제 #17
0
 public function postRegAlumno(Request $request)
 {
     //echo "hola :D";
     $regForm = Input::All();
     //print_r($regForm);
     //reglas de validación
     $validadorFormulario = array("rut" => "required|min:11|max:11", "nombre" => "required|min:2|max:12", "apellido" => "required|min:2|max:20", "correo" => "required|min:6|max:20", "clave" => "required|min:5|max:60");
     //mensajes de validación erronea
     $mensajeForm = array("rut.required" => "El campo rut es obligatorio", "rut.min" => "El campo rut no puede tener menos de 11 caracteres", "rut.max" => "El campo rut no puede tener mas de 11 caracteres", "nombre.required" => "El campo nombre es obligatorio", "nombre.min" => "El campo nombre no puede tener menos de 11 caracteres", "nombre.max" => "El campo nombreno puede tener mas de 11 caracteres", "apellido.required" => "El campo apellido es obligatorio", "apellido.min" => "El campo rut no puede tener menos de 20 caracteres", "apellido.max" => "El campo rut no puede tener mas de 50 caracteres", "correo.required" => "El campo correo es obligatorio", "correo.min" => "El campo rut no puede tener menos de 6 caracteres", "correo.max" => "El campo rut no puede tener mas de 20 caracteres", "clave.required" => "El campo clave es obligatorio", "clave.min" => "El campo rut no puede tener menos de 5 caracteres", "clave.max" => "El campo rut no puede tener mas de 20 caracteres");
     $validar = Validator::make($regForm, $validadorFormulario, $mensajeForm);
     if ($validar->fails()) {
         return redirect::back()->withErrors($validar);
     } else {
         $alumno = new Usuario();
         $alumno->usu_rut = $regForm["rut"];
         $alumno->usu_nombre = $regForm["nombre"];
         $alumno->usu_apellido = $regForm["apellido"];
         $alumno->usu_correo = $regForm["correo"];
         $alumno->usu_clave = $regForm["clave"];
         $alumno->tipo = $regForm["tipo"];
         $alumno->save();
         Session::flash('mensaje', 'Registro Exitoso');
         return $this->layout = view('masterLogin');
     }
     /*
             $usuario = new Usuario();
             $usuario = \Input::get('rut');
             $usuario = \Input::get('nombre');
             $usuario = \Input::get('apellido');
             $usuario = \Input::get('correo');
             $usuario = \Input::get('clave');
             $usuario = \Input::get('Tipo_usuario');
     
             $usuario = save();
     
             return redirect()->to('');
     
             if($usuario->save()){
                 return 'exito';
             }
             else{
                 return 'no';
             }*/
 }
예제 #18
0
파일: search.php 프로젝트: 453111208/bbc
 public function index()
 {
     $keyword = input::get('keyword');
     $searchType = input::get('searchtype');
     if (!empty($keyword)) {
         try {
             if ($searchType == "shop") {
                 return redirect::action('topc_ctl_gallery@index', array('searchContent' => $keyword));
             } else {
                 return redirect::action('topc_ctl_list@index', array('n' => $keyword));
             }
         } catch (Exception $e) {
             $msg = $e->getMessage();
             return $this->splash('error', null, $msg);
         }
     } else {
         return redirect::back();
     }
 }
 function updatepassword()
 {
     $data = Input::all();
     $partnerObject = Partner::where('PARTNER_ID', '=', $data['PARTNER_ID']);
     $partner = $partnerObject->first();
     if ($partner['PARTNER_PASSWORD'] == md5($data['old_password'])) {
         if ($data['new_password'] == $data['confirm_password']) {
             $password = [];
             $new_password = md5($data['confirm_password']);
             $password = ['PARTNER_PASSWORD' => $new_password];
             $partnerObject->update($password);
             Session::flash('message', "Perubahan Password Berhasil");
             return back();
         } else {
             Session::flash('message', "Password Yang Anda Masukkan Tidak sama, mohon ulang kembali");
             return redirect::back();
         }
     } else {
         Session::flash('message', "Password Yang Anda Masukkan Salah");
         return redirect::back();
     }
 }
예제 #20
0
 public function postLogin(Request $request)
 {
     $loginValidation = validator::make($request->all(), ['loginemail' => 'required|email|exists:users,email', 'loginpassword' => 'required|min:8']);
     if ($loginValidation->fails()) {
         return redirect::back()->withErrors($loginValidation->errors())->withInput(Input::except('password'));
     } else {
         /*
          *getting the email and password that user has typed in form
          */
         $loginData = array('email' => Input::get('loginemail'), 'password' => Input::get('loginpassword'), 'confirmed' => 1, 'type' => 'user');
         if (Auth::validate($loginData)) {
             if (Auth::attempt($loginData)) {
                 return Redirect::intended('home');
             }
         } else {
             // if any error send back with message.
             Session::flash('error', 'Invalid Email/Password Combination');
             return Redirect::to('startjourney');
         }
     }
 }
예제 #21
0
 public function postindex(Request $request)
 {
     $input = $request->only('link', 'http_auth', 'http_username', 'http_password', 'comment', 'hold', 'id', 'type', 'torrent_file_name', 't_submit_name', 'fetch_filter');
     if ($request->ajax() && $input['type'] == 'fetch') {
         $v = Validator::make($input, ['link' => 'required|url']);
         if ($v->fails()) {
             return response()->json(['result' => 'error', 'message' => 'Link is invalid.']);
         }
         //echo $html = file_get_contents($input['link']);
         //get_headers($input['link'], 1)
         $main = new main();
         $link = $main->get_info($input['link']);
         // echo $link['content_type'];
         // print_r($link['full_headers']['content-type']);
         if (isset($link['full_headers']['content-type'])) {
             if (is_array($link['full_headers']['content-type'])) {
                 $contet_type = $link['full_headers']['content-type'][count($link['full_headers']['content-type']) - 1];
             } else {
                 $contet_type = $link['full_headers']['content-type'];
             }
             if (strpos($contet_type, 'text/') === false) {
                 return response()->json(['result' => 'error', 'message' => 'Not a valid HTML link.']);
             }
         } else {
             return response()->json(['result' => 'error', 'message' => 'Not a valid HTML link.']);
         }
         $html = file_get_contents($input['link']);
         $pattern = '`.*?((http|https)://[\\w#$&+,\\/:;=?@.-]+)[^\\w#$&+,\\/:;=?@.-]*?`i';
         $links = [];
         if (preg_match_all($pattern, $html, $matches)) {
             foreach ($matches[1] as $url) {
                 if ($input['fetch_filter'] == '' || strpos($url, $input['fetch_filter']) !== false) {
                     $links[] = $url;
                 }
             }
             if (count($links)) {
                 return response()->json(['result' => 'ok', 'links' => $links]);
             } else {
                 return response()->json(['result' => 'error', 'message' => 'No links found with the provided filter :(']);
             }
         } else {
             return response()->json(['result' => 'error', 'message' => 'Could not find any link.']);
         }
     } elseif (!empty($input['torrent_file_name']) && !empty($input['t_submit_name'])) {
         // Final Submit for torrents
         $path = public_path() . '/' . Config::get('leech.save_to') . '/torrent/' . Auth::user()->username . '_' . $input['torrent_file_name'];
         if (!file_exists($path)) {
             return redirect::back()->withErrors('Couldn\'t get your request');
         }
         $torrent = new Torrent($path);
         if (!$torrent->is_torrent($path)) {
             return redirect::back()->withErrors('Your Torrent file is not valid!');
         }
         $torrent_size = $torrent->size();
         if ($torrent_size < 1) {
             return redirect::back()->withErrors('Invalid Torrent size.');
         }
         if ($torrent_size > Auth::user()->credit) {
             return Redirect::to('/buy');
         }
         $q_credit = DB::table('download_list')->where('user_id', '=', Auth::user()->id)->where('deleted', '=', '0')->where(function ($query) {
             $query->whereNull('state');
             $query->orWhere('state', '<>', '0');
         })->sum('length') + $torrent_size;
         if ($q_credit > Auth::user()->credit) {
             return redirect::back()->withErrors('You have too many files in your queue. Please wait until they finish up.');
         }
         $main = new main();
         $zip_name = $main->sanitize_filename($input['t_submit_name'] . '.zip');
         $hold = $input['hold'] ? -2 : null;
         DB::table('download_list')->insertGetId(['user_id' => Auth::user()->id, 'link' => $path, 'length' => $torrent_size, 'file_name' => $zip_name, 'state' => $hold, 'http_user' => null, 'http_password' => null, 'comment' => $input['comment'], 'torrent' => 1, 'date_added' => date('Y-m-d H:i:s', time())]);
         return Redirect::to('downloads');
     } elseif ($request->ajax() && $input['type'] == 'torrent') {
         if (isset($_FILES[0])) {
             $maxsize = 5 * 1024 * 1024;
             //5 MB
             $acceptable = ['application/x-bittorrent'];
             if ($_FILES[0]['size'] >= $maxsize || $_FILES[0]['size'] == 0) {
                 return response()->json(['result' => 'error', 'message' => 'File too large. File must be less than 5 megabytes.']);
             }
             if (!in_array($_FILES[0]['type'], $acceptable) && !empty($_FILES[0]['type'])) {
                 return response()->json(['result' => 'error', 'message' => 'Invalid file type. Only Torrent files are accepted.']);
             }
             $path = public_path() . '/' . Config::get('leech.save_to') . '/torrent/';
             if (!file_exists($path)) {
                 mkdir($path, 0777, true);
             }
             $path .= Auth::user()->username . '_' . $_FILES[0]['name'];
             move_uploaded_file($_FILES[0]['tmp_name'], $path);
             $torrent = new Torrent($path);
             $torrent->name();
             $main = new main();
             $new_content = [];
             foreach ($torrent->content() as $key => $value) {
                 $key = str_replace('\\', '/', $key);
                 $new_content[] = $key . ' (' . $main->formatBytes($value, 2) . ')';
             }
             $paths = $new_content;
             sort($paths);
             $array = [];
             foreach ($paths as $path) {
                 $path = trim($path, '/');
                 $list = explode('/', $path);
                 $n = count($list);
                 $arrayRef =& $array;
                 // start from the root
                 for ($i = 0; $i < $n; $i++) {
                     $key = $list[$i];
                     $arrayRef =& $arrayRef[$key];
                     // index into the next level
                 }
             }
             $GLOBALS['rec'] = '{ "core" : { "data" : [';
             function rec($array)
             {
                 $c = count($array);
                 foreach ($array as $key => $value) {
                     if (is_array($value)) {
                         $GLOBALS['rec'] .= '{"text": "' . $key . '"';
                         $GLOBALS['rec'] .= ', "children": [';
                         rec($value);
                         $GLOBALS['rec'] .= ']}';
                     } else {
                         $GLOBALS['rec'] .= '"' . $key . '"';
                         $c--;
                         if ($c) {
                             $GLOBALS['rec'] .= ",";
                         }
                     }
                 }
             }
             rec($array);
             $GLOBALS['rec'] .= ']}}';
             $JSTreeContent = $GLOBALS['rec'];
             unset($GLOBALS['rec']);
             return response()->json(['result' => 'ok', 'size' => $main->formatBytes($torrent->size(), 1), 'name' => $torrent->name(), 'file_name' => $_FILES[0]['name'], 'hash' => $torrent->hash_info(), 'comment' => $torrent->comment(), 'piece_length' => $main->formatBytes($torrent->piece_length(), 3), 'content' => $JSTreeContent]);
         } else {
             return response()->json(['result' => 'error', 'message' => 'Nothing uploaded to the server.']);
         }
     } elseif ($request->ajax() && $input['type'] == 'check') {
         $v = Validator::make($input, ['link' => 'required|url']);
         if ($v->fails()) {
             $message = $v->messages();
             if ($request->ajax()) {
                 return response()->json(['type' => 'error', 'message' => 'Input Error.']);
             } else {
                 return redirect::back()->withErrors($message);
             }
         }
         if (strpos($input['link'], '.torrent') !== false && Auth::user()->role != 2) {
             //I'll delete this 'if' very soon.
             if ($request->ajax()) {
                 return response()->json(['type' => 'error', 'message' => 'What?! Torrent?! Go away!']);
             } else {
                 return redirect::back()->withErrors('What?! Torrent?! Go away!');
             }
         }
         $main = new main();
         $blocked = $main->isBlocked($input['link']);
         if ($blocked) {
             if ($request->ajax()) {
                 return response()->json(['type' => 'error', 'message' => $blocked]);
             } else {
                 return redirect::back()->withErrors($blocked);
             }
         }
         $url_inf = $main->get_info($input['link']);
         if ($request->ajax()) {
             return response()->json(['type' => 'success', 'status' => $url_inf['status'], 'filename' => $url_inf['filename'], 'file_extension' => $url_inf['file_extension'], 'filesize' => $main->formatBytes($url_inf['filesize'], 1), 'location' => $url_inf['location']]);
         } else {
             return redirect::back()->withErrors('sth is wrong.');
         }
     } else {
         $v = Validator::make($input, ['link' => 'required|url', 'comment' => 'max:140']);
         if ($v->fails()) {
             $message = $v->messages();
             if ($request->ajax()) {
                 return response()->json(['type' => 'error', 'id' => $input['id'], 'message' => 'Input Error.']);
             } else {
                 return redirect::back()->withErrors($message);
             }
         }
         if ($input['http_auth']) {
             $v = Validator::make($input, ['http_username' => 'required|max:64', 'http_password' => 'required|max:64']);
             if ($v->fails()) {
                 $message = $v->messages();
                 if ($request->ajax()) {
                     return response()->json(['type' => 'error', 'id' => $input['id'], 'message' => 'Input Error. HTTP Auth']);
                 } else {
                     return redirect::back()->withErrors($message);
                 }
             }
         }
         if (strpos($input['link'], '.torrent') !== false && Auth::user()->role != 2) {
             //I'll delete this 'if' very soon.
             if ($request->ajax()) {
                 return response()->json(['type' => 'error', 'id' => $input['id'], 'message' => 'What?! Torrent?! Go away!']);
             } else {
                 return redirect::back()->withErrors('What?! Torrent?! Go away!');
             }
         }
         $main = new main();
         $blocked = $main->isBlocked($input['link']);
         if ($blocked) {
             if ($request->ajax()) {
                 return response()->json(['type' => 'error', 'id' => $input['id'], 'message' => $blocked]);
             } else {
                 return redirect::back()->withErrors($blocked);
             }
         }
         $url_inf = $main->get_info($input['link']);
         $fileSize = $url_inf['filesize'];
         $filename = $url_inf['filename'];
         if ($url_inf['status'] != 200) {
             if (empty($url_inf['status'])) {
                 $url_inf['status'] = "N/A";
             }
             if ($request->ajax()) {
                 return response()->json(['type' => 'error', 'id' => $input['id'], 'message' => 'File not found or it has been moved! Response code was not 200' . " (" . $url_inf['status'] . ')']);
             } else {
                 return redirect::back()->withErrors('File not found or it has been moved! Response code was not 200' . " (" . $url_inf['status'] . ')');
             }
         }
         $blocked_ext = Config::get('leech.blocked_ext');
         if (array_key_exists($url_inf['file_extension'], $blocked_ext)) {
             if ($blocked_ext[$url_inf['file_extension']] === false) {
                 if ($request->ajax()) {
                     return response()->json(['type' => 'error', 'id' => $input['id'], 'message' => '.' . $url_inf['file_extension'] . ' files are blocked by system administrator. Sorry.']);
                 } else {
                     return redirect::back()->withErrors('.' . $url_inf['file_extension'] . ' files are blocked by system administrator. Sorry.');
                 }
             } else {
                 $filename = pathinfo($url_inf['filename'], PATHINFO_FILENAME) . '.' . $blocked_ext[$url_inf['file_extension']];
             }
         }
         if ($fileSize < 1) {
             if ($request->ajax()) {
                 return response()->json(['type' => 'error', 'id' => $input['id'], 'message' => 'Invalid File Size!' . " (" . $url_inf['status'] . ')']);
             } else {
                 return redirect::back()->withErrors('Invalid File Size!' . " (" . $url_inf['status'] . ')');
             }
         }
         if ($fileSize > Auth::user()->credit) {
             if ($request->ajax()) {
                 return response()->json(['type' => 'error', 'id' => $input['id'], 'message' => 'Not enough Credits!']);
             } else {
                 return Redirect::to('/buy');
                 //return redirect::back()->withErrors('Not enough Credits!');
             }
         }
         $q_credit = DB::table('download_list')->where('user_id', '=', Auth::user()->id)->where('deleted', '=', '0')->where(function ($query) {
             $query->whereNull('state');
             $query->orWhere('state', '<>', '0');
         })->sum('length') + $fileSize;
         if ($q_credit > Auth::user()->credit) {
             if ($request->ajax()) {
                 return response()->json(['type' => 'error', 'id' => $input['id'], 'message' => 'You have too many files in your queue. Please wait until they finish up.']);
             } else {
                 return redirect::back()->withErrors('You have too many files in your queue. Please wait until they finish up.');
             }
         }
         if (empty($filename)) {
             if ($request->ajax()) {
                 return response()->json(['type' => 'error', 'id' => $input['id'], 'message' => 'Invalid Filename!']);
             } else {
                 return redirect::back()->withErrors('Invalid Filename!');
             }
         }
         //        DB::table('users')
         //            ->where('id', Auth::user()->id)
         //            ->update([
         //                'queue_credit' => $q_credit
         //            ]);
         $hold = $input['hold'] ? -2 : null;
         if ($input['http_auth']) {
             $http_user = $input['http_username'];
             $http_pass = $input['http_password'];
         } else {
             $http_user = $http_pass = null;
         }
         DB::table('download_list')->insertGetId(['user_id' => Auth::user()->id, 'link' => $url_inf['location'], 'length' => $fileSize, 'file_name' => $filename, 'state' => $hold, 'http_user' => $http_user, 'http_password' => $http_pass, 'comment' => $input['comment'], 'torrent' => 0, 'date_added' => date('Y-m-d H:i:s', time())]);
         if ($request->ajax()) {
             return response()->json(['type' => 'success', 'id' => $input['id'], 'message' => 'Link Added!']);
         } else {
             return Redirect::to('downloads');
         }
     }
 }
예제 #22
0
 public function postAbout(Request $request)
 {
     $about = $request->input('static_content');
     $page = Static_page::find($request->id);
     $page->content = $about;
     $page->save();
     return redirect::back()->with('page', $page);
 }
예제 #23
0
 /**
  * Process POST method for CSV register
  *
  */
 public function postregister_csv(Request $request)
 {
     ignore_user_abort(true);
     ini_set('max_execution_time', 0);
     if (ini_get('max_execution_time') != 0) {
         return redirect::back()->withErrors('Could not change max_execution_time variable. Please review php.ini file.');
     }
     if ($request->hasFile('csv_file') && $request->file('csv_file')->isValid()) {
         if (mb_strtolower($request->file('csv_file')->getClientOriginalExtension()) != 'csv') {
             return redirect::back()->withErrors('The uploaded file is not a valid CSV file.');
         }
         if ($request->file('csv_file')->getClientSize() > 1024 * 1024) {
             return redirect::back()->withErrors('The uploaded file is bigger than 1MB.');
         }
         $path = $request->file('csv_file')->move(storage_path() . '/csv_files/', date('d-m-Y-H-i', time()) . '-' . Auth::user()->username . '-' . rand(100, 999) . '.csv');
         $row = 1;
         if (($handle = fopen("{$path}", "r")) !== FALSE) {
             $fails = 0;
             $success = 0;
             $conflicts = [];
             while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                 $num = count($data);
                 if ($num != 4) {
                     return redirect::back()->withErrors('CSV file should have 4 rows. First name, Last name, Password and Username');
                 }
                 $row++;
                 $input['username'] = $data[3];
                 $rules = array('username' => 'unique:users,username');
                 $validator = Validator::make($input, $rules);
                 if ($validator->fails()) {
                     $fails++;
                     $conflicts[] = "Couldn't add user " . $data[3];
                 } else {
                     $success++;
                     $user = new User();
                     $user->first_name = trim($data[0]);
                     $user->last_name = trim($data[1]);
                     $user->username = trim($data[3]);
                     $password = trim($data[2]);
                     if (empty($password)) {
                         $password = $data[3];
                     }
                     $role = $request['role_radio'] == 2 ? 2 : 1;
                     $user->role = $role;
                     $active = $request['active'] == 'active' ? 1 : 0;
                     $user->active = $active;
                     $torrent = $request['torrent'] == 'torrent' ? 1 : 0;
                     $user->torrent = $torrent;
                     $public = $request['public'] == 'public' ? 1 : 0;
                     $user->public = $public;
                     $user->password = Hash::make($password);
                     $user->credit = $request['credit'] * 1024 * 1024 * 1024;
                     $user->save();
                     DB::table('credit_log')->insert(array('user_id' => $user->id, 'credit_change' => $request['credit'] * 1024 * 1024 * 1024, 'agent' => 0));
                 }
             }
             fclose($handle);
         } else {
             return redirect::back()->withErrors('CSV is not valid.');
         }
         if ($success) {
             return redirect()->back()->with('message', $success . ' users added successfully and ' . $fails . ' failed.')->withErrors($conflicts);
         } else {
             return redirect()->back()->withErrors($conflicts);
         }
     } else {
         return redirect::back()->withErrors('CSV file did not upload to server. Try again.');
     }
 }
 public function autouploadsaved()
 {
     //Image Upload
     $purchasecheck = Purchase::orderby('id', 'DESC')->count();
     if ($purchasecheck != 0) {
         $purchase = Purchase::orderby('id', 'DESC')->find(Input::get('id'));
         $docs = Document::orderby('id', 'DESC')->where('pr_id', $purchase->id)->first();
         $pr_id = $purchase->id;
         $doc_id = $docs->id;
     } else {
         $pr_id = 1;
         $doc_id = 1;
     }
     foreach (Input::file('file') as $file) {
         $rules = array('file' => 'required|mimes:png,gif,jpeg,jpg|max:900000000000000000000');
         $validator = \Validator::make(array('file' => $file), $rules);
         $destine = public_path() . "/uploads";
         if ($validator->passes()) {
             $ext = $file->guessClientExtension();
             // (Based on mime type)
             $ext = $file->getClientOriginalExtension();
             // (Based on filename)
             $filename = $file->getClientOriginalName();
             $archivo = value(function () use($file) {
                 $filename = str_random(10) . '.' . $file->getClientOriginalExtension();
                 return strtolower($filename);
             });
             $archivo = value(function () use($file) {
                 $date = date('m-d-Y-h-i-s', time());
                 $filename = $date . "-" . $file->getClientOriginalName();
                 return strtolower($filename);
             });
             $attach = new Attachments();
             $attach->doc_id = $doc_id;
             $attach->data = $archivo;
             $attach->saved = 1;
             $attach->save();
             $filename = $doc_id . "_" . $attach->id;
             $file->move($destine, $archivo);
             $target_folder = $destine;
             $upload_image = $target_folder . "/" . $archivo;
             $thumbnail = $target_folder . "/resize" . $archivo;
             $actual = $target_folder . "/" . $archivo;
             // THUMBNAIL SIZE
             list($width, $height) = getimagesize($upload_image);
             $newwidth = $width;
             $newheight = $height;
             while ($newheight > 525) {
                 $newheight = $newheight * 0.8;
                 $newwidth = $newwidth * 0.8;
             }
             $source = $upload_image;
             $ext = strtolower($ext);
             $thumb = imagecreatetruecolor($newwidth, $newheight);
             if ($ext == "jpg" || $ext == "jpeg") {
                 $source = imagecreatefromjpeg($upload_image);
             } elseif ($ext == "png") {
                 $source = imagecreatefrompng($upload_image);
             } elseif ($ext == "gif") {
                 $source = imagecreatefromgif($upload_image);
             } else {
                 continue;
             }
             // RESIZE
             imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
             // MAKE NEW FILES
             if ($ext == "jpg" || $ext == "jpeg") {
                 imagejpeg($thumb, $thumbnail, 100);
             } elseif ($ext == "png") {
                 imagepng($thumb, $thumbnail, 9);
             } elseif ($ext == "gif") {
                 imagegif($thumb, $thumbnail, 100);
             } else {
                 echo "An invalid image";
             }
             unlink($actual);
             // FILE RENAMES
             rename($thumbnail, $actual);
         } else {
             Session::put('imgerror', 'Invalid file.');
         }
     }
     //End Image Upload
     return redirect::back()->withInput();
 }
예제 #25
0
파일: helpers.php 프로젝트: 453111208/bbc
 /**
  * Create a new redirect response to the previous location.
  *
  * @param  int    $status
  * @param  array  $headers
  * @return \Illuminate\Http\RedirectResponse
  */
 function back($status = 302, $headers = array())
 {
     return redirect::back($status, $headers);
 }
예제 #26
0
 /**
  * Redirect to a specific page.
  *
  * @param   string  $target   Page to redirect to.
  * @param   array   $data     Optional data to save in a users session.
  */
 protected function redirect($target, $data = null)
 {
     // Write optional session data
     if ($data instanceof Messages) {
         Session::flash('errors', $data->toArray());
     } else {
         if (is_array($data)) {
             Session::flash($data);
         } else {
             if (!is_null($data)) {
                 Session::flash('data', $data);
             }
         }
     }
     // Allow to specify the redirect uri as parameter
     $url = r::get('redirect_to');
     if (!empty($url)) {
         redirect::to($url);
     }
     // Perform redirect
     switch ($target) {
         case 'home':
             redirect::home();
             break;
         case 'back':
             redirect::back();
             break;
         case '404':
             $page = site()->errorPage();
             redirect::to($page->uri());
             break;
         case 'referer':
             $referer = server::get('HTTP_REFERER');
             redirect::to($referer);
             break;
         default:
             redirect::to($target);
             break;
     }
 }
예제 #27
0
 public function questionUpdate(QuestionRequest $request, $id)
 {
     $question = Question::findOrFail($id);
     $question->update($request->all());
     if ($request->correct1 == 0) {
         $question->correct1 = 0;
     }
     if ($request->correct2 == 0) {
         $question->correct2 = 0;
     }
     if ($request->correct3 == 0) {
         $question->correct3 = 0;
     }
     if ($request->correct4 == 0) {
         $question->correct4 = 0;
     }
     if ($request->correct5 == 0) {
         $question->correct5 = 0;
     }
     $question->save();
     return redirect::back();
 }
예제 #28
0
 public function post_aria2console(Request $request)
 {
     $input = $request->only('function', 'param');
     if (!$request->ajax()) {
         $this->validate($request, ['function' => 'required']);
     }
     $functions = ['addUri', 'addTorrent', 'addMetalink', 'remove', 'forceRemove', 'pause', 'pauseAll', 'forcePause', 'forcePauseAll', 'unpause', 'unpauseAll', 'tellStatus', 'getUris', 'getFiles', 'getPeers', 'getServers', 'tellActive', 'tellWaiting', 'tellStopped', 'changePosition', 'changeUri', 'getOption', 'changeOption', 'getGlobalOption', 'changeGlobalOption', 'getGlobalStat', 'purgeDownloadResult', 'removeDownloadResult', 'getVersion', 'getSessionInfo', 'shutdown', 'forceShutdown', 'saveSession', 'multicall'];
     if (!in_array($input['function'], $functions)) {
         if ($request->ajax()) {
             return response()->json(['Error' => 'The function does not exist in Aria2 functions.']);
         } else {
             return redirect::back()->withErrors('The function does not exist in Aria2 functions.');
         }
     }
     $main = new main();
     if (!$main->aria2_online()) {
         if ($request->ajax()) {
             return response()->json(['ERROR 10002' => 'Aria2c is not running!']);
         } else {
             return view('errors.general', ['error_title' => 'ERROR 10002', 'error_message' => 'Aria2c is not running!']);
         }
     }
     $input['param'] = trim($input['param']);
     $params = $input['param'];
     $params = '[' . $params . ']';
     $aria2 = new aria2();
     $res = call_user_func_array([$aria2, 'JSON_INPUT' . $input['function']], [$params]);
     if ($request->ajax()) {
         return response()->json($res);
     }
     return redirect()->back()->withInput()->with('result', $res);
 }