Пример #1
0
 /**
  * 对明文进行加密
  * @param string $text 需要加密的明文
  * @return string 加密后的密文
  */
 public function encrypt($text, $appid)
 {
     try {
         //获得16位随机字符串,填充到明文之前
         $random = \Str::random('alnum', 16);
         $text = $random . pack("N", strlen($text)) . $text . $appid;
         // 网络字节序
         $size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
         $module = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
         $iv = substr($this->key, 0, 16);
         //使用自定义的填充方式对明文进行补位填充
         $pkc_encoder = new PKCS7Encoder();
         $text = $pkc_encoder->encode($text);
         mcrypt_generic_init($module, $this->key, $iv);
         //加密
         $encrypted = mcrypt_generic($module, $text);
         mcrypt_generic_deinit($module);
         mcrypt_module_close($module);
         //print(base64_encode($encrypted));
         //使用BASE64对加密后的字符串进行编码
         return array(ErrorCode::$OK, base64_encode($encrypted));
     } catch (Exception $e) {
         //print $e;
         return array(ErrorCode::$EncryptAESError, null);
     }
 }
Пример #2
0
 public function post_upload()
 {
     $input = Input::get();
     $file = Input::file('fileInput');
     $separator = $input['claimdetailid'] != NULL ? $input['claimid'] . '/' . $input['claimdetailid'] : $input['claimid'];
     $extension = File::extension($file['name']);
     $directory = 'upload/claims/' . sha1(Auth::user()->userid) . '/' . str_replace("-", "", date('Y-m-d')) . '/' . $separator;
     $filename = Str::random(16, 'alpha') . time() . ".{$extension}";
     if (!is_dir(path('public') . $directory)) {
         mkdir(path('public') . $directory, 0777, true);
     }
     $maxSize = ini_get('upload_max_filesize') * 1024 * 1024 * 1024;
     if ($file['size'] != null && $file['size'] < $maxSize) {
         try {
             $upload_success = Input::upload('fileInput', path('public') . $directory, $filename);
             if ($upload_success) {
                 $input['recpath'] = $directory . '/' . $filename;
                 $receipt = new Claims_Receipt();
                 $receipt->fill($input);
                 $receipt->save();
                 Log::write('Claims Receipt', 'File Uploaded : ' . $filename . ' by ' . Auth::user()->username);
                 return $directory . '/' . $filename;
             }
         } catch (Exception $e) {
             Log::write('Claims Receipt', 'Upload error: ' . $e->getMessage());
         }
     } else {
         Log::write('Claims Receipt', 'Upload error: Exceed max size ' . ini_get('upload_max_filesize'));
     }
 }
Пример #3
0
 /**
  * Create Agent
  * @return \Illuminate\Http\JsonResponse
  */
 public function create()
 {
     $success = false;
     if ($this->validator->validate(\Input::all()) && $this->userValidator->validate(['email' => \Input::get('email'), 'password' => \Str::random(8)])) {
         $user = User::create(['email' => \Input::get('email'), 'username' => \Input::get('name'), 'password' => \Str::random(8)]);
         $agentData = \Input::all();
         $agentData['user_id'] = $user->id;
         // TODO: save uploaded image :|
         // Destination path for uplaoded files which is at /public/uploads
         $destinationPath = public_path() . '/uploads/img/';
         // Handle profile Picture
         if (Input::hasFile('profile_pic_filename')) {
             $file = Input::file('profile_pic_filename');
             $propic_filename = str_random(6) . '_' . str_replace(' ', '_', $file->getClientOriginalName());
             $uploadSuccess = $file->move($destinationPath, $propic_filename);
             if ($uploadSuccess) {
                 $agentData['profile_pic_filename'] = $propic_filename;
             }
         }
         $agent = Agent::create($agentData);
         // Send Invitation Email
         $invitation_code = bin2hex(openssl_random_pseudo_bytes(16));
         $invite = Invite::create(['code' => $invitation_code, 'email' => Input::get('email'), 'user_id' => $user->id, 'user_type' => 'Agent']);
         Mail::send('emails.invitation.invite', ['confirmation' => $invitation_code, 'client_base_url' => 'http://d.motibu-head.com/'], function ($message) {
             $message->to(Input::get('email'))->subject('You have been invited to motibu.com');
         });
         $user->roles()->attach(Role::findByName('Agent')->id);
         $success = $user && $agent;
     }
     return \Response::json(['success' => $success, 'data' => $agent->getTransformed(new AgentTransformer())]);
 }
Пример #4
0
 /**
  * Show the form for creating a new user.
  *
  * @return Response
  */
 public function create()
 {
     $groups = $this->group->all();
     $permissions = $this->permissions->allWithChecked();
     $password = \Str::random(16);
     $this->view('users.create', compact('groups', 'permissions', 'password'));
 }
Пример #5
0
 public function postRegistro()
 {
     $input = Input::all();
     $reglas = array('nombre' => 'required', 'apellido' => 'required', 'celular' => 'required|numeric|unique:users', 'cedula' => 'required|numeric|unique:users', 'email' => 'required|email|unique:users', 'pin' => 'required|numeric|digits_between:0,4', 'password' => 'required|numbers|case_diff|letters|min:6|confirmed', 'password_confirmation' => 'required|min:6');
     $validation = Validator::make($input, $reglas);
     if ($validation->fails()) {
         return Response::json(['success' => false, 'errors' => $validation->errors()->toArray()]);
     }
     try {
         // se guarda los datos del usuario
         $user = Sentry::register(array('first_name' => Input::get('nombre'), 'last_name' => Input::get('apellido'), 'email' => Input::get('email'), 'habilitar_pin' => 1, 'celular' => Input::get('celular'), 'cedula' => Input::get('cedula'), 'password' => Input::get('password'), 'pin' => Input::get('pin'), 'porcentaje' => 0.05, 'activated' => true));
         $userId = $user->getId();
         $token = new Token();
         $token->user_id = $userId;
         $token->api_token = hash('sha256', Str::random(10), false);
         $token->client = BrowserDetect::toString();
         $token->expires_on = Carbon::now()->addMonth()->toDateTimeString();
         $token->save();
         // Se autentica de una
         $user_login = Sentry::findUserById($userId);
         Sentry::login($user_login, false);
         return Response::json(['success' => true, 'user' => $user_login, 'token' => $token->api_token]);
     } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
         $error = array('usuario' => 'Email es requerido');
     } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
         $error = array('usuario' => 'Password es requerido');
     } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
         $error = array('usuario' => 'El Email ya está registrado');
     }
     return Response::json(['success' => false, 'errors' => $error]);
 }
Пример #6
0
 public function getPaymentCart()
 {
     $values = Session::get('payment');
     foreach ($values as $key => $value) {
         $product[$key]['name'] = $value['name'];
         $price = round((int) $value['price'] / 21270);
         $product[$key]['price'] = $price;
         $product[$key]['quantity'] = 1;
         $product[$key]['product_id'] = $value['id'];
     }
     $tmpTransaction = new TmpTransaction();
     $st = Str::random(16);
     $baseUrl = URL::to('/product/payment/return?order_id=' . $st);
     // $value[1]['name'] = "sản phẩm 1";
     // $value[1]['price'] = "20000";
     // $value[1]['quantity'] = "1";
     // $value[1]['product_id'] = "3";
     // $value[2]['name'] = "sản phẩm 2";
     // $value[2]['price'] = "20000";
     // $value[2]['quantity'] = "1";
     // $value[2]['product_id'] = "3";
     $payment = $this->makePaymentUsingPayPalCart($product, 'USD', "{$baseUrl}&success=true", "{$baseUrl}&success=false");
     $tmpTransaction->order_id = $st;
     $tmpTransaction->payment_id = $payment->getId();
     $tmpTransaction->save();
     header("Location: " . $this->getLink($payment->getLinks(), "approval_url"));
     exit;
     return "index";
 }
Пример #7
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Eloquent::unguard();
     DB::table('tags')->truncate();
     //DB::table('pastes')->truncate();
     $faker = Faker\Factory::create();
     $paste_count = 10;
     $tags = array('php', 'javascript', 'ruby', 'js', 'cpp', 'c++', 'c#', 'go', 'html', 'css');
     for ($i = 0; $i < $paste_count; $i++) {
         $tags_per_paste = rand(1, 3);
         // Generate the paste
         $examplePaste = new Paste();
         $examplePaste->paste = $faker->paragraph;
         $examplePaste->title = $faker->realText(46);
         $examplePaste->expire = $faker->dateTime($max = 'now');
         $examplePaste->token = Str::random(40);
         $examplePaste->private = rand(0, 1);
         $examplePaste->delete_token = Str::random(40);
         $examplePaste->save();
         // Attach some tags to the new paste
         for ($i = 0; $i < $tags_per_paste; ++$i) {
             $exampleTag = new Tag();
             $exampleTag->tag = $tags[rand(0, sizeof($tags) - 1)];
             $exampleTag->paste_id = $examplePaste->id;
             $examplePaste->tags()->save($exampleTag);
         }
         print "Seeded paste with ID of " . $examplePaste->id . "\n";
     }
 }
Пример #8
0
 /**
  * Salts and saves the password
  *
  * @param string $password
  */
 public function setPasswordAttribute($password)
 {
     $salt = md5(Str::random(64) . time());
     $hashed = Hash::make($salt . $password);
     $this->attributes['password'] = $hashed;
     $this->attributes['salt'] = $salt;
 }
Пример #9
0
 public function view()
 {
     // Group's inputs.
     $name_group_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('name', $this->requested_aircraft->name, ['class' => 'form-control', 'type' => 'text']), 'label' => 'A/C Name'], false)];
     $general_group_1_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('basic_empty_weight', $this->requested_aircraft->basic_empty_weight, ['class' => 'form-control', 'type' => 'number']) . "kg", 'label' => 'Basic Empty Weight'], false), View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('cg_position', $this->requested_aircraft->cg_position, ['class' => 'form-control', 'type' => 'number']) . "aft of datum", 'label' => 'C of G Position'], false)];
     $description_group_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-12', 'input_coltype' => 'col-xs-12', 'input' => Form::textarea('description', $this->requested_aircraft->description, ['class' => 'form-control']), 'label' => 'Description', 'label_left' => true], false)];
     $weight_limits_group_1_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('max_ramp_weight', $this->requested_aircraft->max_ramp_weight, ['class' => 'form-control', 'type' => 'text']), 'label' => 'Max Ramp Weight'], false), View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('mctow', $this->requested_aircraft->mctow, ['class' => 'form-control', 'type' => 'text']), 'label' => 'MCTOW'], false)];
     $weight_limits_group_2_inputs = [View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('mlw', $this->requested_aircraft->mlw, ['class' => 'form-control', 'type' => 'text']), 'label' => 'MLW'], false), View::forge('form/group/input', ['label_coltype' => 'col-xs-2', 'input_coltype' => 'col-xs-4', 'input' => Form::input('mzfw', $this->requested_aircraft->mzfw, ['class' => 'form-control', 'type' => 'text']), 'label' => 'MZFW'], false)];
     $arms_table_template = View::forge('widgets/tablewithactions/template', ['duplicate_action' => false, 'cells' => [View::forge('widgets/tablewithactions/row/cell', ['cell_content' => Form::input('_name', '', ['class' => 'form-control'])], false), View::forge('widgets/tablewithactions/row/cell', ['cell_content' => Form::input('_position', '', ['class' => 'form-control'])], false), View::forge('widgets/tablewithactions/row/cell', ['cell_content' => Form::input('_value', '', ['class' => 'form-control']) . Form::hidden('_type', 'arm')], false)]]);
     $arms_table = View::forge('widgets/tablewithactions', ['template_row' => $arms_table_template, 'name' => '_arms', 'coltype' => 'col-xs-12 col-md-6', 'headings' => ['<th>Label</th>', '<th>Arm (aft of datum)</th>', '<th>Max Weight</th>'], 'rows' => $this->arms_table_rows], false);
     $cglimits_table_template = View::forge('widgets/tablewithactions/template', ['duplicate_action' => false, 'cells' => [View::forge('widgets/tablewithactions/row/cell', ['cell_content' => Form::input('_position', '', ['class' => 'form-control'])], false), View::forge('widgets/tablewithactions/row/cell', ['cell_content' => Form::input('_value', '', ['class' => 'form-control']) . Form::hidden('_type', 'maxweight') . Form::hidden('_name', 'limit')], false)]]);
     $cglimits_table = View::forge('widgets/tablewithactions', ['template_row' => $cglimits_table_template, 'name' => '_arms', 'coltype' => 'col-xs-6', 'headings' => ['<th>Arm (aft of datum)</th>', '<th>Weight Limit</th>'], 'rows' => $this->cglimits_table_rows], false);
     $button_group_1_inputs = [Asset::js('tablewithactions.js', false), View::forge('form/button', ['coltype' => 'col-xs-offset-5 col-xs-2', 'link' => 'submit/aircraft/' . $this->id, 'response_target' => './aircraft_form', 'class' => 'form-control btn-success', 'label' => 'Save Changes'], false)];
     // Headings
     $general_heading = View::forge('form/heading', ['text' => 'General', 'size' => 4], false);
     $weight_limits_heading = View::forge('form/heading', ['text' => 'Weight Limits', 'size' => 4], false);
     $arms_heading = View::forge('form/heading', ['text' => 'Arms', 'size' => 4], false);
     $cg_limits_heading = View::forge('form/heading', ['text' => 'C of G Limits', 'size' => 4], false);
     // Groups
     $name_group = View::forge('form/group', ['inputs' => $name_group_inputs], false);
     $general_group_1 = View::forge('form/group', ['inputs' => $general_group_1_inputs], false);
     $description_group = View::forge('form/group', ['inputs' => $description_group_inputs], false);
     $weight_limits_group_1 = View::forge('form/group', ['inputs' => $weight_limits_group_1_inputs]);
     $weight_limits_group_2 = View::forge('form/group', ['inputs' => $weight_limits_group_2_inputs]);
     $buttons_group = View::forge('form/group', ['inputs' => $button_group_1_inputs], false);
     $cg_limits_group = View::forge('form/group', ['inputs' => ['<div class="col-xs-6">' . $cglimits_table . '</div>' . '<div class="col-xs-6">' . 'Graph here' . '</div>']], false);
     $weightandbalance_section_data = ['heading' => 'Weight and Balance Data', 'unique_id' => Str::random('uuid'), 'groups' => [$general_heading, $name_group, $general_group_1, $description_group, $weight_limits_heading, $weight_limits_group_1, $weight_limits_group_2, $arms_heading, $arms_table, $cg_limits_heading, $cg_limits_group, $buttons_group]];
     $weightandbalance_section = View::forge('form/section', $weightandbalance_section_data, false);
     $this->aircraft_form = $weightandbalance_section;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $id = Auth::user()->ID;
     $files = Input::file('files');
     $assetPath = '/uploads/' . $id;
     $uploadPath = public_path($assetPath);
     $results = array();
     foreach ($files as $file) {
         if ($file->getSize() > $_ENV['max_file_size']) {
             $results[] = array("name" => $file->getClientOriginalName(), "size" => $file->getSize(), "error" => "Please upload file less than " . $_ENV['max_file_size'] / 1000000 . "mb");
         } else {
             //rename filename so that it won't overlap with existing file
             $extension = $file->getClientOriginalExtension();
             $filename = time() . Str::random(20) . "." . $extension;
             // store our uploaded file in our uploads folder
             $name = $assetPath . '/' . $filename;
             $photo_attributes = array('name' => $filename, 'size' => $file->getSize(), 'url' => asset($name), 'user_id' => $id);
             $photo = new Photo($photo_attributes);
             if ($photo->save()) {
                 if (!is_dir($uploadPath)) {
                     mkdir($uploadPath, 0777);
                 }
                 //resize image into different sizes
                 foreach (Photo::getThumbnailSizes() as $key => $thumb) {
                     Image::make($file->getRealPath())->resize($thumb['width'], $thumb['height'])->save($uploadPath . "/" . $key . "-" . $filename);
                 }
                 //save original file
                 $file->move($uploadPath, $filename);
                 $results[] = Photo::find($photo->id)->find_in_json();
             }
         }
     }
     // return our results in a files object
     return json_encode(array('files' => $results));
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $this->info('Iniciando a requisição para o webservice');
     $this->info('Carregando a lista de estados');
     $estados = $this->makeRequest('estados');
     $this->info('Foram encontrados ' . count($estados) . ' estados');
     $this->info('Carregando a lista de cargos');
     $cargos = CandidateType::all()->lists('id', 'type');
     $this->info('Foram encontrados ' . count($cargos) . ' cargos');
     $this->info('Carregando a lista de partidos');
     $partidos = Party::all()->lists('id', 'abbreviation');
     $this->info('Foram encontrados ' . count($partidos) . ' partidos');
     foreach ($estados as $estado_id => $estado) {
         $this->info("Carregando os candidatos de {$estado->sigla} ({$estado_id}/" . count($estado) . ")");
         foreach ($cargos as $cargo_nome => $cargo_id) {
             $this->info('- Procurando por ' . $cargo_nome);
             $candidatos = $this->makeRequest('candidatos', ['estado' => $estado->sigla, 'cargo' => $cargo_id]);
             foreach ($candidatos as $candidato) {
                 $candidate = Candidate::where('full_name', $candidato->nome)->first();
                 if (!$candidate) {
                     $this->info('-- Processando ' . $candidato->nome . '/' . $candidato->apelido);
                     $picture_hash = Str::random(90) . ".jpg";
                     file_put_contents(app_path() . '/../www/uploads/' . $picture_hash, file_get_contents($candidato->foto));
                     Candidate::create(['party_id' => $partidos[$candidato->partido], 'candidate_type_id' => $cargos[ucfirst(strtolower(str_replace('º', '', (string) $candidato->cargo)))], 'nickname' => $candidato->apelido, 'full_name' => $candidato->nome, 'picture' => $picture_hash]);
                 }
             }
             //$this->info('Foram encontrados ' . count($candidatos) . ' candidatos');
         }
     }
 }
 public function submitFile($id)
 {
     $files = Input::file('files');
     foreach ($files as $file) {
         $rules = array('file' => FileTypes::getAllFileTypes());
         $validator = Validator::make(array('file' => $file), $rules);
         if ($validator->passes()) {
             $randomId = Str::random(14);
             $destinationPath = 'uploads/group/activity/' . Auth::user()->StudentID . '/';
             $filename = $file->getClientOriginalName();
             $mime_type = $file->getMimeType();
             $extension = $file->getClientOriginalExtension();
             $upload_success = $file->move('public/' . $destinationPath, $randomId . $filename);
             if ($upload_success) {
                 $check = GroupPageActivityFiles::hasSubmitted($id);
                 if (!count($check)) {
                     GroupPageActivityFiles::create(['path' => $destinationPath . $randomId . $filename, 'filename' => $filename, 'grouppageactivityID' => $id, 'OwnerID' => Auth::user()->StudentID]);
                 } else {
                     $check->update(array('path' => $destinationPath . $randomId . $filename, 'filename' => $filename));
                 }
                 return Redirect::to('/')->with('message', 'Successfully submitted your activity')->with('url', '');
             }
         }
     }
     return Redirect::to('/')->with('message', 'Error submitted your activity')->with('url', '');
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function solicpremium()
 {
     $authuser = Auth::user();
     $clasificado = Clasificado::find(Input::get('clasfid'));
     $clasificado->solicitar_premium = 1;
     $clasificado->save();
     //Generar row en cobros y cobros_pendientes
     $cobrotipoSerProveedor = CobroTipo::where('tipo', 'clasificado_premium')->first();
     $cobro = new Cobro();
     $cobro->tipo_id = $cobrotipoSerProveedor->id;
     $cobro->usuario_id = $authuser->id;
     $cobro->estado = 'pendiente';
     $cobro->datosAdicionales = $clasificado->id;
     //Al entrar a este metodo estoy seguro que el usuario tiene un registro de proveedor asociado
     $cobro->save();
     $id = Str::random(4);
     $date_now = new DateTime();
     $cobrop = new CobroPendiente();
     $cobrop->cobro_id = $cobro->id;
     $cobrop->fecha = $date_now;
     $cobrop->cobro_concepto = 'TODCONS' . $cobro->id . 'CLASF' . $clasificado->id . $date_now->format('YmdHi') . $id;
     // Concepto = clave_empresa+ clave_cobro+ clave_tipo_cobro + clave_objeto_de_cobro + fecha+4_digitos_random (Por favor mejorar!!)
     $cobrop->save();
     return Redirect::to('vistausuario/clasificados')->with(array('usuarioimg' => $authuser->imagen, 'usuarionombre' => $authuser->nombre, 'usuarioid' => $authuser->id));
 }
Пример #14
0
 /**
  * Salts and saves the password
  *
  * @param string $password
  */
 public function set_password($password)
 {
     $salt = md5(\Str::random(64) . time());
     $hashed = \Hash::make($salt . $password);
     $this->set_attribute('password', $hashed);
     $this->set_attribute('salt', $salt);
 }
Пример #15
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $file = $this->argument('file');
     if (!file_exists($file) || !is_file($file)) {
         $this->error('Please provide a valid file.');
     }
     if ($handle = fopen($file, 'r')) {
         while (($data = fgetcsv($handle, 0, ';')) !== false) {
             // If the "level" column is present, use it instead of the
             // "level" option.
             $level = $this->option('level');
             if (count($data) === 7) {
                 $level = $data[6];
             } elseif ($this->option('level') === null) {
                 $this->error('The file does not include the level of the newcomer, please provide it via the "level" flag.');
                 return;
             }
             // See the class description for file format.
             $attributes = ['first_name' => $data[2], 'last_name' => $data[1], 'password' => Str::random(6), 'sex' => strpos($data[0], 'M') !== false ? 'M' : 'F', 'email' => $data[5], 'phone' => $data[4], 'level' => $level, 'birth' => new DateTime($data[3])];
             $newcomer = Newcomer::create($attributes);
             if ($newcomer->save() === false) {
                 $this->error('Error while adding ' . $newcomer->first_name . ' ' . $newcomer->last_name);
             }
         }
     }
 }
Пример #16
0
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $familia = Familia::findOrFail($id);
     $validator = Familia::validator(Input::all());
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $datos = Input::all();
     if (Input::file('foto')) {
         $file = Input::file('foto');
         $destinationPath = 'uploads/images/';
         $filename = Str::random(20) . '.' . $file->getClientOriginalExtension();
         $mimeType = $file->getMimeType();
         $extension = $file->getClientOriginalExtension();
         $upload_success = $file->move($destinationPath, $filename);
         if ($familia->foto != 'fam.jpg') {
             File::delete($destinationPath . $familia->foto);
         }
         $datos['foto'] = $filename;
     } else {
         unset($datos['foto']);
     }
     $familia->update($datos);
     Session::flash('message', 'Actualizado Correctamente');
     Session::flash('class', 'success');
     return Redirect::to('/dashboard/familia');
 }
Пример #17
0
 /**
  * Show the form for creating a new resource.
  * GET /ob/create
  *
  * @return Response
  */
 public function create()
 {
     $validate = LeaveOB::validate(Input::all());
     if ($validate->passes()) {
         if (Input::get('totalleaves') <= 0.0 or Input::get('totalleaves') === 'NaN') {
             $message = 'Please select correct date!';
             return Redirect::to('applyob')->with('error_message', $message);
         } else {
             $lastrow = LeaveOB::orderBy('created_at', 'desc')->first();
         }
         $data = new LeaveOB();
         $data->employee_id = Auth::user()->employee_id;
         if ($lastrow == null) {
             $data->leave_id = Str::random(8);
         } else {
             $data->leave_id = Str::random(8) . $lastrow->id;
         }
         $data->days_of_leave = Input::get('totalleaves');
         $data->wdays_of_leave = Input::get('totalleave');
         $data->date_from = Input::get('date_from');
         $data->time_from = Input::get('time_from');
         $data->date_to = Input::get('date_to');
         $data->time_to = Input::get('time_to');
         $data->company = Input::get('company');
         $data->address = Input::get('address');
         $data->reason = Input::get('reason');
         $data->save();
         return Redirect::to('applyob')->with('message', 'Your Application for Official Business (OB) is successfully send.Please Check Your Notification box to see if your leave  has  been approved.');
     } else {
         return Redirect::to('applyob')->withErrors($validate);
     }
 }
Пример #18
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $rules = array('private' => 'numeric|required', 'title' => 'max:46|required', 'paste' => 'required', 'expire' => 'required|numeric', 'private' => 'required|numeric', 'tags' => 'max:6|alpha');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         $messages = $validator->messages();
         return View::make('paste.form')->withErrors($messages);
     }
     $new_paste = new Paste();
     $new_paste->title = Input::get('title');
     $new_paste->token = Str::random(40);
     $new_paste->delete_token = Str::random(40);
     $new_paste->paste = Input::get('paste');
     $new_paste->private = Input::get('private');
     date_default_timezone_set('UTC');
     $expire_time = date('Y-m-d H:i:s', strtotime(sprintf('now + %s minutes', Input::get('expire'))));
     $new_paste->expire = $expire_time;
     if (!$new_paste->save()) {
         Debugbar::error('Saving failed!');
     }
     // Check if tags are set
     if (Input::has('hidden-tags')) {
         $tags = explode(' ', Input::get('hidden-tags'));
         foreach ($tags as $key => $tag) {
             $tag_model = new Tag();
             $tag_model->tag = $tag;
             $tag_model->paste_id = $new_paste->id;
             $new_paste->tags()->save($tag_model);
         }
     }
     if ($new_paste->id) {
         return Redirect::route('paste.show', $new_paste->token)->withCookie(Cookie::make('edittoken', $new_paste->token, 30));
     }
     return view::make('paste.form', array('page_title' => 'Create a paste'));
 }
Пример #19
0
 public function post_resetlogin()
 {
     $validatekey = Str::random(32, 'alpha');
     $uname = Str::random(16, 'alpha');
     $user = Admin_User::find(Auth::user()->userid);
     $user->username = $uname;
     $user->password = $uname;
     $user->status = 3;
     $user->validationkey = $validatekey;
     $user->save();
     try {
         $mailer = Message::to($user->userprofile->emel);
         $mailer->from('*****@*****.**', 'System Generate');
         $mailer->subject('Account Reset');
         $mailer->body('view: plugins.emailAccReset');
         $mailer->body->username = $uname;
         $mailer->body->password = $uname;
         $mailer->body->key = $key;
         $mailer->html(true);
         $mailer->send();
     } catch (Exception $e) {
         Log::write('email', 'Message was not sent.');
         Log::write('email', 'Mailer error: ' . $e->getMessage());
     }
 }
Пример #20
0
 public function postProfile()
 {
     $msg = '';
     $user_data = Auth::user()->get();
     $inputs = Input::all();
     $rules = array('fname' => 'required', 'lname' => 'required', 'email' => 'required|email', 'state' => 'required');
     $v = Validator::make($inputs, $rules);
     if ($v->fails()) {
         return Redirect::back()->withErrors($v);
     }
     User::where('id', $user_data->id)->update($inputs);
     if (strcmp($user_data->email, $inputs['email']) != 0) {
         //Email Changed
         $random = Str::random(50);
         $new_data = User::find($user_data->id);
         $new_data->status = 0;
         $new_data->activation_token = $random;
         $new_data->save();
         $link = URL::to('front/activate', $random);
         $user_data->link = $link;
         $user_data->custom_message = 'You Have Successfully Change Your Email. ';
         $msg = TempMail::email_activation($user_data);
     }
     return Redirect::back()->with('success', 'Profile Successfully Modified. ' . $msg);
 }
 public function submit_create_documento()
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         // Verifico si el usuario es un Webmaster
         if ($data["user"]->idrol == 1 || $data["user"]->idrol == 2 || $data["user"]->idrol == 4) {
             // Validate the info, create rules for the inputs
             $attributes = array('idtipo_documento' => 'Tipo de Documento', 'nombre' => 'Nombre del Documento', 'autor' => 'Autor', 'codigo_archivamiento' => 'Código de Archivamiento', 'ubicacion' => 'Ubicación', 'descripcion' => 'Descripción', 'archivo' => 'Archivo');
             $messages = array();
             $rules = array('idtipo_documento' => 'required', 'nombre' => 'required|max:100|unique:documento_riesgos|alpha_num_spaces', 'autor' => 'required|max:100|alpha_num_spaces', 'codigo_archivamiento' => 'required|max:100|unique:documento_riesgos|alpha_num', 'ubicacion' => 'required|max:100|alpha_num_spaces', 'descripcion' => 'required|max:200|alpha_num_spaces', 'archivo' => 'max:15360');
             // Run the validation rules on the inputs from the form
             $validator = Validator::make(Input::all(), $rules, $messages, $attributes);
             // If the validator fails, redirect back to the form
             if ($validator->fails()) {
                 return Redirect::to('documentos_riesgos/create_documento')->withErrors($validator)->withInput(Input::all());
             } else {
                 $data["tipo_documentos"] = TipoDocumentoRiesgos::searchTipoDocumentosById(Input::get('idtipo_documento'))->get();
                 $rutaDestino = '';
                 $nombreArchivo = '';
                 if (Input::hasFile('archivo')) {
                     $archivo = Input::file('archivo');
                     $rutaDestino = 'uploads/documentos/riesgos/' . $data["tipo_documentos"][0]->nombre . '/';
                     $nombreArchivo = $archivo->getClientOriginalName();
                     $nombreArchivoEncriptado = Str::random(27) . '.' . pathinfo($nombreArchivo, PATHINFO_EXTENSION);
                     $uploadSuccess = $archivo->move($rutaDestino, $nombreArchivoEncriptado);
                     $documento = new DocumentoRiesgos();
                     $documento->nombre = Input::get('nombre');
                     $documento->nombre_archivo = $nombreArchivo;
                     $documento->nombre_archivo_encriptado = $nombreArchivoEncriptado;
                     $documento->descripcion = Input::get('descripcion');
                     $documento->autor = Input::get('autor');
                     $documento->codigo_archivamiento = Input::get('codigo_archivamiento');
                     $documento->ubicacion = Input::get('ubicacion');
                     $documento->url = $rutaDestino;
                     $documento->id_tipo = Input::get('idtipo_documento');
                     $documento->idestado = 1;
                     $documento->save();
                 } else {
                     $documento = new DocumentoRiesgos();
                     $documento->nombre = Input::get('nombre');
                     $documento->descripcion = Input::get('descripcion');
                     $documento->autor = Input::get('autor');
                     $documento->codigo_archivamiento = Input::get('codigo_archivamiento');
                     $documento->ubicacion = Input::get('ubicacion');
                     $documento->id_tipo = Input::get('idtipo_documento');
                     $documento->idestado = 1;
                     $documento->save();
                 }
                 Session::flash('message', 'Se registró correctamente el Documento.');
                 return Redirect::to('documentos_riesgos/list_documentos');
             }
         } else {
             return View::make('error/error', $data);
         }
     } else {
         return View::make('error/error', $data);
     }
 }
Пример #22
0
 public function run()
 {
     Model::unguard();
     $times = 5;
     for ($i = 0; $i < $times; $i++) {
         Appestablishments::create(array('name' => Str::random(), 'active' => rand(0, 1)));
     }
 }
Пример #23
0
 public function before_insert(Model_User $model)
 {
     $model->salt = Str::random('alnum', 8);
     $model->login_hash = sha1($model->salt . time() . $model->username);
     $model->password = Model_User::hash_password($model->password, $model->salt);
     $model->validated = 1;
     // For now, later it'll be controlled by the settings.
 }
Пример #24
0
 /**
  * Re-send welcome email
  * Have to reset user's hashed password as well
  * Not sure this is a great idea
  */
 public function resendWelcome($user_id)
 {
     $password = Str::random(12);
     $email = DB::table(DB_USERS)->where('id', $user_id)->pluck('email');
     DB::table(DB_USERS)->where('id', $user_id)->update(array('password' => Hash::make($password)));
     self::sendWelcome($email, $password);
     return Redirect::action('UserController@index')->with('user_id', $user_id);
 }
Пример #25
0
 public function post_new()
 {
     $rules = array('title' => 'required|min:5|max:128', 'street' => 'required', 'postalcode' => 'required|match:#^[1-9][0-9]{3}\\h*[A-Z]{2}$#i', 'city' => 'required', 'type' => 'required', 'surface' => 'required|integer', 'price' => 'required|numeric|max:1500|min:100', 'date' => 'required|after:' . date('d-m-Y'), 'pictures' => 'required|image|max:3000', 'register' => 'required', 'email' => 'required|email|same:email2', 'description' => 'required|min:30', 'captchatest' => 'laracaptcha|required', 'terms' => 'accepted');
     $v = Validator::make(Input::all(), $rules, Room::$messages);
     if ($v->fails()) {
         return Redirect::to('kamer-verhuren')->with_errors($v)->with('msg', '<div class="alert alert-error"><strong>Verplichte velden zijn niet volledig ingevuld</strong><br />Loop het formulier nogmaals na.</div>')->with_input();
     } else {
         if (Auth::check()) {
             $status = 'publish';
         } else {
             $status = 'pending';
         }
         $new_room = array('title' => ucfirst(Input::get('title')), 'street' => ucwords(Input::get('street')), 'housenr' => Input::get('housenr'), 'postalcode' => Input::get('postalcode'), 'city' => ucwords(Input::get('city')), 'type' => Input::get('type'), 'surface' => Input::get('surface'), 'price' => Input::get('price'), 'available' => date("Y-m-d", strtotime(Input::get('date'))), 'gender' => Input::get('gender'), 'pets' => Input::get('pets'), 'smoking' => Input::get('smoking'), 'toilet' => Input::get('toilet'), 'shower' => Input::get('shower'), 'kitchen' => Input::get('kitchen'), 'register' => Input::get('register'), 'social' => Input::get('social'), 'email' => strtolower(Input::get('email')), 'description' => ucfirst(Input::get('description')), 'status' => $status, 'url' => Str::slug(Input::get('city')), 'delkey' => Str::random(32, 'alpha'), 'del_date' => date('y-m-d', strtotime('+2 months')));
         $room = new Room($new_room);
         if ($room->save()) {
             $upload_path = path('public') . Photo::$upload_path_room . $room->id;
             if (!File::exists($upload_path)) {
                 File::mkdir($upload_path);
                 chmod($upload_path, 0777);
             }
             $photos = Photo::getNormalizedFiles(Input::file('pictures'));
             foreach ($photos as $photo) {
                 $filename = md5(rand()) . '.jpg';
                 $path_to_file = $upload_path . '/' . $filename;
                 $dynamic_path = '/' . Photo::$upload_path_room . $room->id . '/' . $filename;
                 $success = Resizer::open($photo)->resize(800, 533, 'auto')->save($path_to_file, 80);
                 chmod($path_to_file, 0777);
                 if ($success) {
                     $new_photo = new Photo();
                     $new_photo->location = $dynamic_path;
                     $new_photo->room_id = $room->id;
                     $new_photo->save();
                 }
             }
             Message::send(function ($message) use($room) {
                 $message->to($room->email);
                 $message->from('*****@*****.**', 'Kamergenood');
                 $message->subject('In afwachting op acceptatie: "' . $room->title . '"');
                 $message->body('view: emails.submit');
                 $message->body->id = $room->id;
                 $message->body->title = $room->title;
                 $message->body->price = $room->price;
                 $message->body->type = $room->type;
                 $message->body->surface = $room->surface;
                 $message->body->available = $room->available;
                 $message->body->description = $room->description;
                 $message->body->url = $room->url;
                 $message->body->delkey = $room->delkey;
                 $message->html(true);
             });
             if (Message::was_sent()) {
                 return Redirect::to('kamer-verhuren')->with('msg', '<div class="alert alert-success"><strong>Hartelijk dank voor het vertrouwen in Kamergenood!</strong> De kameradvertentie zal binnen 24 uur worden gecontroleerd en geplaatst.</div>');
             }
         } else {
             return Redirect::to('kamer-verhuren')->with('msg', '<div class="alert alert-error"><strong>Er is iets mis gegaan bij het toevoegen.</strong> Probeer het later nog eens.</div>')->with_input();
         }
     }
 }
 private function copyImage($originalImage)
 {
     $explodedImage1 = explode('/', $originalImage);
     $image1 = end($explodedImage1);
     $imageName1 = Str::random(20) . time() . $image1;
     $image1path = $this->getImagesPath() . $imageName1;
     File::copy($originalImage, $image1path);
     return $imageName1;
 }
Пример #27
0
 public static function getToken()
 {
     $token = Str::random();
     if (sizeof(self::where('token', $token)->get()) > 0) {
         return self::getToken();
     } else {
         return $token;
     }
 }
 public function postStore()
 {
     $id = \Input::get('id');
     /*
      * Validate
      */
     $rules = array('image' => 'mimes:jpg,jpeg,png,gif|max:500', 'name' => 'required|unique:categories,name' . (isset($id) ? ',' . $id : ''), 'short_description' => 'required', 'order' => 'required|min:0');
     $validation = \Validator::make(\Input::all(), $rules);
     if ($validation->passes()) {
         $name = \Input::get('name');
         $short_description = \Input::get('short_description');
         $long_description = \Input::get('long_description');
         $image = \Input::file('image');
         $active = \Input::get('active') == '' ? FALSE : TRUE;
         $order = \Input::get('order');
         $parent_id = \Input::get('parent_id');
         $cn_name = \Input::get('cn_name');
         $cn_short_description = \Input::get('cn_short_description');
         $cn_long_description = \Input::get('cn_long_description');
         $options = array('name' => $cn_name, 'short_description' => $cn_short_description, 'long_description' => $cn_long_description);
         $category = isset($id) ? Category::find($id) : new Category();
         $category->name = $name;
         $category->short_description = $short_description;
         $category->long_description = $long_description;
         $category->active = $active;
         $category->order = $order;
         $category->category_id = $parent_id;
         $category->options = json_encode($options);
         $category->save();
         if (\Input::hasFile('image')) {
             // Delete all existing images for edit
             if (isset($id)) {
                 $category->deleteAllImages();
             }
             //set the name of the file
             $originalFilename = $image->getClientOriginalName();
             $filename = str_replace(' ', '', $name) . \Str::random(20) . '.' . \File::extension($originalFilename);
             //Upload the file
             $isSuccess = $image->move('assets/img/categories', $filename);
             if ($isSuccess) {
                 // create photo
                 $newimage = new Image();
                 $newimage->path = $filename;
                 // save photo to the loaded model
                 $category->images()->save($newimage);
             }
         }
     } else {
         if (isset($id)) {
             return \Redirect::to('admin/categories/edit/' . $id)->withErrors($validation)->withInput();
         } else {
             return \Redirect::to('admin/categories/create')->withErrors($validation)->withInput();
         }
     }
     return \Redirect::to('admin/categories');
 }
Пример #29
0
 public function action_recover($hash = null)
 {
     if (Input::Method() === "POST") {
         if ($user = \Model\Auth_User::find_by_email(Input::POST('email'))) {
             // generate a recovery hash
             $hash = \Auth::instance()->hash_password(\Str::random()) . $user->id;
             // and store it in the user profile
             \Auth::update_user(array('lostpassword_hash' => $hash, 'lostpassword_created' => time()), $user->username);
             // send an email out with a reset link
             \Package::load('email');
             $email = \Email::forge();
             $html = 'Your password recovery link <a href="' . Uri::Create('login/recover/' . $hash) . '">Recover My Password!</a>';
             // use a view file to generate the email message
             $email->html_body($html);
             // give it a subject
             $email->subject(\Settings::Get('site_name') . ' Password Recovery');
             // GET ADMIN EMAIL FROM SETTINGS?
             $admin_email = Settings::get('admin_email');
             if (empty($admin_email) === false) {
                 $from = $admin_email;
             } else {
                 $from = 'support@' . str_replace('http:', '', str_replace('/', '', Uri::Base(false)));
             }
             $email->from($from);
             $email->to($user->email, $user->fullname);
             // and off it goes (if all goes well)!
             try {
                 // send the email
                 $email->send();
                 Session::set('success', 'Email has been sent to ' . $user->email . '! Please check your spam folder!');
             } catch (\Exception $e) {
                 Session::Set('error', 'We failed to send the eamil , contact ' . $admin_email);
                 \Response::redirect_back();
             }
         } else {
             Session::Set('error', 'Sorry there is not a matching email!');
         }
     } elseif (empty($hash) === false) {
         $hash = str_replace(Uri::Create('login/recover/'), '', Uri::current());
         $user = substr($hash, 44);
         if ($user = \Model\Auth_User::find_by_id($user)) {
             // do we have this hash for this user, and hasn't it expired yet , must be within 24 hours
             if (isset($user->lostpassword_hash) and $user->lostpassword_hash == $hash and time() - $user->lostpassword_created < 86400) {
                 // invalidate the hash
                 \Auth::update_user(array('lostpassword_hash' => null, 'lostpassword_created' => null), $user->username);
                 // log the user in and go to the profile to change the password
                 if (\Auth::instance()->force_login($user->id)) {
                     Session::Set('current_password', Auth::reset_password($user->username));
                     Response::Redirect(Uri::Create('user/settings'));
                 }
             }
         }
         Session::Set('error', 'Invalid Hash!');
     }
     $this->template->content = View::forge('login/recover');
 }
Пример #30
0
 public function run()
 {
     // Bring to local scope
     $prefix = $this->prefix;
     $role_id = DB::table($prefix . 'roles')->insertGetId(['name' => Config::get('verify::super_admin'), 'level' => 10, 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     $salt = md5(\Str::random(64) . time());
     $hashed = \Hash::make($salt . 'a52Vaza09@');
     $user_id = DB::table($prefix . 'users')->insertGetId(['email' => '*****@*****.**', 'password' => $hashed, 'salt' => $salt, 'verified' => 1, 'disabled' => 0, 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
     DB::table($prefix . 'role_user')->insert(['role_id' => $role_id, 'user_id' => $user_id, 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
 }