public function run()
    {
        DB::table('projects')->delete();
        Project::create(['name' => 'Deployer', 'hash' => str_random(60), 'repository' => 'https://github.com/REBELinBLUE/deployer.git', 'url' => 'http://deployer.app', 'group_id' => 2, 'private_key' => '-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAmrMjtajVvmd99T8xwUNrIFbrzSmZ6VCM89hfm4Ut9atv29gG
l2HFPJY7VtslXDJVL67w5EUMspy82tkAX7F03iaarSsbo6nC16UTfbfNTi44Snm0
T/5RMavSOnOMRJ8BQcfzqge4oIQzVGXOs0YvNFdSt4paBp9dssKS+7yP/hDvgAVz
+LE3IcIeO26aXATcuB4zq3vjaqSzWZGdNhOJZ4EmjgmOq9+k3SAmooHkF+p/14MJ
tq0ZK9KjSGbHfyKMi2EuvwllFCY19eqsV7dcMDIsMKUW2diFC52dJSO+EF47nA/j
sNDisFsIC7DeeVVBl1TpaV9RidqeZmdx+mF9AQIDAQABAoIBAH4qhYAdTx03eGGw
hVqSKmc4nJ05RX4kJKCmoerLZh1LETJh75Y8tchg2cpPdhvILPNzoKD6s41kCR4P
BqAEsUSQhWufka4bwH1w8wGACp+tUFllAqqOxhdVg2IKZKZ+a18DvPS50ViQGPDH
CxnorozoftyTqDJofNlSmN9X/LN+RZ1zRJRaPkBvSkYOCT4gnJLmHLGN7eJsHQeR
EJe83E4VPZ+2faBHEigXAHc4rh63iRxmmqqlcrItXzONZZUOjXwBNqZs4aVl+DZd
1pPiB9nOT9zLiy9ZwHZfIRIF3LkWAVsIkzOPDw9wLNgzI60uiLlYY1ODua8maqDP
m5eOT7ECgYEAzbVdEVngZd/jRlAo/LOLyy6NbZP4fli26hZjJBAJ8HhI93JEcxts
l/1E3rUME2a+F8CQ5FlGP02k66sB5lhzCg81Ym4fxbIP1n09IPmaRzSdM55SpbFy
7OV4VyrJKl7g2Y/utdb17DjYGovu+HX978j1iOH8qUruwAZyWshqdW0CgYEAwIVO
AohxuytN1GlQW4byQvHO4y+AXtZJ4iuBiyOqGhYs8bcnbV3+B0UTHtJyM8Novzj6
OcgiCEHP0Kj6Lj9RYu2sBvsgyfxEURdkHD7DPpYKlheCd7I1a9qk4/UyGx11YdnP
bcqrxv6e2FPBXNZGTXGBmHtIItxHYBEehguRLWUCgYALpR61or7fRYNaMaOAWrGp
OONstpm0nVUNf2LxYa8OW+DVkTRqx7yoBgBmEx2x43kTYyVQp/UgFEcnyDB9V7h7
c0z0W4OU73WSENjrCvY+3a2ghG/tTVRSMNNVK+jjayeTaWB8DsUxMC6bohxPGG7d
qiSsMQ7ajpFhcXv7w6izKQKBgQC+Pz0+vYz+NCXeQRAa0nj29LPIx7kofsRWTz3d
vKmsy7swRhkdN6P/lR/29mnKg1EwnmKP1RjkZfyyKznHl+SaSVoVL/dQAw2TwPS6
AL+6SlU9yw+vrxihc1g8uKICL5M+1hnoWj50EEvyZJoRXuHsR72UbEd1w454/ZHX
TvjxDQKBgCtikMNAqTParY/tX0xNohD7+svTKZt92CxW7Q/17H26ehFKUQvw6Agd
ulR2AVTGi6STEgzXf6UP5CAVhYRw9irCAQYpceL0GVzfZPQsXyLuMCnJ8UD6CBRn
i5vkNY4OZdOuEV9boFOFYa58WRNK7vthHkZJj++Amu3dZ6RHBlLQ
-----END RSA PRIVATE KEY-----', 'public_key' => 'ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCasyO1qNW+Z331PzHBQ2sgVuvNKZnpUIzz2F+bhS31q2/b2Aa' . 'XYcU8ljtW2yVcMlUvrvDkRQyynLza2QBfsXTeJpqtKxujqcLXpRN9t81OLjhKebRP/lExq9I6c4xEnwFBx/OqB7' . 'ighDNUZc6zRi80V1K3iloGn12ywpL7vI/+EO+ABXP4sTchwh47bppcBNy4HjOre+NqpLNZkZ02E4lngSaOCY6r3' . '6TdICaigeQX6n/Xgwm2rRkr0qNIZsd/IoyLYS6/CWUUJjX16qxXt1wwMiwwpRbZ2IULnZ0lI74QXjucD+Ow0OKw' . 'WwgLsN55VUGXVOlpX1GJ2p5mZ3H6YX0B deploy@deployer', 'last_run' => null, 'build_url' => 'http://ci.rebelinblue.com/build-status/image/3?branch=master', 'allow_other_branch' => true, 'include_dev' => false]);
    }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('tasks')->delete();
     for ($i = 0; $i < 5; $i++) {
         DB::table('tasks')->insert(['title' => str_random(10)]);
     }
 }
 public function addMember()
 {
     $password = str_random(6);
     $phone = Input::get('phone');
     $cityid = Input::get('city');
     $user_id = DB::table('users')->insertGetId(['full_name' => Input::get('full_name'), 'email' => Input::get('email'), 'password' => bcrypt($password), 'role_id' => 3, 'location_id' => Input::get('city'), 'phone_number' => $phone]);
     $data = array('full_name' => Input::get('full_name'), 'email' => Input::get('email'), 'phone_number' => Input::get('phone'));
     if ($user_id) {
         DB::table('user_attributes_varchar')->insert(['user_id' => $user_id, 'user_attribute_id' => 7, 'attribute_value' => '1' . str_pad($user_id, 6, '0', STR_PAD_LEFT)]);
         $createPasswordRequest = Password::creatRequestWebsitePassword($data);
         $createPasswordRequest['password'] = $password;
         Mail::send('site.pages.website_admin_registration', ['data' => $createPasswordRequest], function ($message) use($createPasswordRequest) {
             $message->from('*****@*****.**', 'WowTables by GourmetItUp');
             $message->to($createPasswordRequest['email'])->subject('You have been registered as a WowTables member!');
         });
         $city_name = Location::where(['Type' => 'City', 'id' => $cityid])->pluck('name');
         if (empty($city_name)) {
             $city_name = 'mumbai';
         }
         $city = ucfirst($city_name);
         $merge_vars = array('NAME' => isset($createPasswordRequest['userName']) ? $createPasswordRequest['userName'] : '', 'SIGNUPTP' => 'Email', 'BDATE' => '', 'GENDER' => '', 'MERGE11' => 0, 'MERGE17' => 'Admin added account', 'PHONE' => isset($phone) ? $phone : '', 'GROUPINGS' => array(array('id' => 9713, 'groups' => [$city])));
         $this->mailchimp->lists->subscribe($this->listId, ["email" => $createPasswordRequest['email']], $merge_vars, "html", false, true);
         $my_email = $createPasswordRequest['email'];
         $success_message = "Email " . $my_email . " has been registered as a member.";
         $data = array('user_id' => $user_id, 'success_message' => $success_message);
         echo json_encode($data);
     }
 }
 public function save($data)
 {
     if (isset($data['client'])) {
         $client = $this->clientRepo->save($data['client']);
         $data['client_id'] = $client->id;
     }
     $invoice = $this->invoiceRepo->save($data);
     $client = $invoice->client;
     $client->load('contacts');
     $sendInvoiceIds = [];
     foreach ($client->contacts as $contact) {
         if ($contact->send_invoice || count($client->contacts) == 1) {
             $sendInvoiceIds[] = $contact->id;
         }
     }
     foreach ($client->contacts as $contact) {
         $invitation = Invitation::scope()->whereContactId($contact->id)->whereInvoiceId($invoice->id)->first();
         if (in_array($contact->id, $sendInvoiceIds) && !$invitation) {
             $invitation = Invitation::createNew();
             $invitation->invoice_id = $invoice->id;
             $invitation->contact_id = $contact->id;
             $invitation->invitation_key = str_random(RANDOM_KEY_LENGTH);
             $invitation->save();
         } elseif (!in_array($contact->id, $sendInvoiceIds) && $invitation) {
             $invitation->delete();
         }
     }
     return $invoice;
 }
Example #5
0
 public function postNew()
 {
     $validation = new Validators\SeatUserRegisterValidator();
     if ($validation->passes()) {
         // Let's register a user.
         $user = new \User();
         $user->email = Input::get('email');
         $user->username = Input::get('username');
         $user->password = Hash::make(Input::get('password'));
         $user->tsid = Input::get('tsid');
         $user->activation_code = str_random(24);
         $user->activated = 1;
         $user->save();
         // Prepare data to be sent along with the email. These
         // are accessed by their keys in the email template
         $data = array('activation_code' => $user->activation_code);
         // Send the email with the activation link
         Mail::send('emails.auth.register', $data, function ($message) {
             $message->to(Input::get('email'), 'New SeAT User')->subject('SeAT Account Confirmation');
         });
         // And were done. Redirect to the login again
         return Redirect::action('SessionController@getSignIn')->with('success', 'Successfully registered a new account. Please check your email for the activation link.');
     } else {
         return Redirect::back()->withInput()->withErrors($validation->errors);
     }
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     factory(CuentasFacturas\User::class)->create(['name' => 'Luigi', 'username' => 'luigi', 'email' => '*****@*****.**', 'password' => bcrypt('12345'), 'type' => 'administrador', 'remember_token' => str_random(10)]);
     factory(CuentasFacturas\User::class)->create(['name' => 'Admin 12345', 'username' => 'admin', 'email' => '*****@*****.**', 'password' => bcrypt('12345'), 'type' => 'administrador', 'remember_token' => str_random(10)]);
     factory(CuentasFacturas\User::class)->create(['name' => 'Diana', 'username' => 'diana', 'email' => '*****@*****.**', 'password' => bcrypt('12345'), 'type' => 'usuario', 'remember_token' => str_random(10)]);
     factory(CuentasFacturas\User::class, 25)->create();
 }
 public function update($candidate_id)
 {
     try {
         Log::info(Input::all());
         $candidate = Candidate::findOrFail($candidate_id);
         $candidate->fill(Input::all());
         $user = User::find($candidate->user_id);
         if (\Input::has('skills')) {
             $skills = [];
             foreach (\Input::get('skills') as $skill) {
                 $skills[$skill['skill_id']] = ['description' => isset($skill['description']) ? $skill['description'] : '', 'level' => isset($skill['level']) ? $skill['level'] : 0];
             }
             $user->skills()->detach();
             $user->skills()->sync($skills);
         }
         // 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');
             $profile_pic_filename = str_random(6) . '_' . str_replace(' ', '_', $file->getClientOriginalName());
             $uploadSuccess = $file->move($destinationPath, $profile_pic_filename);
             if ($uploadSuccess) {
                 $candidate->profile_pic_filename = $profile_pic_filename;
             }
         }
         $candidate->save();
         $user->candidateProfile->profile_pic_filename = url('/uploads/img/' . $user->candidateProfile->profile_pic_filename);
         $response = $user->candidateProfile;
         $response['skills'] = $user->skills;
         return $this->respondWithArray(['success' => true, 'message' => 'Candidate info updated', 'candidate_profile' => $response]);
     } catch (ModelNotFoundException $e) {
         return $this->setStatusCode(404)->respondWithError('Candidate with ID ' . $candidate_id . ' not found', 404);
     }
 }
Example #8
0
 public function createPublicCode()
 {
     do {
         $public_code = str_random(40);
     } while ($this->where('public_code', $public_code)->count() > 0);
     return $public_code;
 }
Example #9
0
 /**
  * generate test date applications and users
  * @param int
  * @return mixed
  */
 public function generateTestDate($numberOfDate)
 {
     // process time start
     $pStartTime = microtime(true);
     // faker
     $faker = Factory::create();
     // gender random array
     $genderArr = ['male', 'female'];
     for ($i = 0; $i < $numberOfDate; $i++) {
         // fake user data
         $fakeUserData = ['nickname' => $faker->userName, 'email' => $faker->email, 'password' => bcrypt(str_random(10)), 'real_name' => $faker->firstName, 'sex' => $this->genderArr[rand(0, 1)], 'year' => $faker->year, 'month' => $faker->month, 'date' => $faker->dayOfMonth, 'phone_number' => $faker->phoneNumber, 'confirmed' => 1, 'remember_token' => str_random(10)];
         // create faker user
         $fakeUser = User::create($fakeUserData);
         // time range
         $timeRange = array_rand($this->timeArr, 2);
         // start time
         $startTime = $this->timeArr[$timeRange[1]];
         // end time
         $endTime = $this->timeArr[$timeRange[0]];
         // swap time range if not reasonable
         if ($startTime > $endTime && $startTime != 0 && $endTime != 0) {
             list($startTime, $endTime) = array($endTime, $startTime);
         }
         // fake date applicatoin
         $fakeDateAppData = ['user_id' => $fakeUser->id, 'city' => $this->cityArr[array_rand($this->cityArr, 1)], 'start_time' => $startTime, 'end_time' => $endTime, 'vegetarian_type' => $this->vegetarianTypeArr[array_rand($this->vegetarianTypeArr, 1)], 'meal_type' => $this->mealTypeArr[array_rand($this->mealTypeArr, 1)], 'sex_constraint' => $this->genderArr[array_rand($this->genderArr, 1)]];
         // create fake date applicatoin
         $fakeDateApp = DateApplication::create($fakeDateAppData);
     }
     $pTime = microtime(true) - $pStartTime;
     echo 'process time is ' . $pTime;
 }
Example #10
0
 public function store()
 {
     //存储数据
     $market = new Market();
     $market->title1 = $this->request->get('title1');
     $market->sc_price = $this->request->get('sc_price');
     $market->cb_price = $this->request->get('cb_price');
     $market->desc = $this->request->get('desc');
     $market->amount = $this->request->get('amount');
     $market->rank = $this->request->get('rank');
     $market->alibaba1 = $this->request->get('alibaba1');
     $market->alibaba2 = $this->request->get('alibaba2');
     $market->investigators = $this->request->get('investigators');
     $market->save();
     //获取图片
     $images = $this->request->file('images');
     foreach ($images as $image) {
         //获取图片名称
         $fileName = md5(uniqid(str_random(10)));
         //
         try {
             \Image::make($image)->resize(100, 100)->save('uploads/images/' . $fileName . '.jpg');
             //存储图片
             $marketImage = new MarketImage();
             $marketImage->image = 'uploads/images/' . $fileName . '.jpg';
             $marketImage->market_id = $market->id;
             $marketImage->save();
         } catch (\Exception $e) {
             //图片上传失败
             dd($e->getMessage());
         }
     }
     //通过循环存储照片
 }
Example #11
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     for ($count = 1; $count <= 10; $count++) {
         $thread_id = rand(1, DB::table('threads')->count());
         $position = Helper::appendZero($count, 5);
         $user_id = rand(1, DB::table('users')->count());
         DB::table('replies')->insert(['thread_id' => $thread_id, 'user_id' => $user_id, 'content' => str_random(100), 'position' => $position . ',', 'depth' => 0]);
         DB::table('threads')->where('id', $thread_id)->increment('comment_count');
         DB::table('users')->where('id', $user_id)->increment('comment_count');
         $author_id = DB::table('threads')->where('id', $thread_id)->first()->author_id;
         DB::table('notifications')->insert(['type' => 1, 'user_id' => $author_id, 'content_id' => $count]);
     }
     for ($count = 11; $count <= 30; $count++) {
         $parent_id = rand(1, DB::table('replies')->count());
         $parent = DB::table('replies')->where('id', $parent_id)->first();
         $position = $parent->position . Helper::appendZero($count, 5) . ',';
         $thread_id = $parent->thread_id;
         $user_id = rand(1, DB::table('users')->count());
         DB::table('replies')->insert(['thread_id' => $thread_id, 'user_id' => $user_id, 'content' => str_random(100), 'parent_id' => $parent_id, 'depth' => $parent->depth + 1, 'position' => $position]);
         DB::table('threads')->where('id', $thread_id)->increment('comment_count');
         DB::table('users')->where('id', $user_id)->increment('comment_count');
         $author_id = DB::table('threads')->where('id', $thread_id)->first()->author_id;
         DB::table('notifications')->insert(['type' => 1, 'user_id' => $author_id, 'content_id' => $thread_id]);
     }
 }
 public function run()
 {
     #Criação de Cliente
     factory(Cliente::class)->create(['name' => 'Cliente', 'email' => '*****@*****.**', 'password' => bcrypt(1234), 'remember_token' => str_random(10)]);
     #Criação de Motorista
     factory(Motorista::class)->create(['name' => 'Motorista', 'email' => '*****@*****.**', 'password' => bcrypt(1234), 'remember_token' => str_random(10)]);
 }
Example #13
0
function encriptar_contra($contra = null)
{
    if ($contra == null) {
        $contra = str_random(10);
    }
    return \Hash::make($contra);
}
Example #14
0
 public function postPublish()
 {
     $msg = 'Report Successfully Published';
     $inputs = Input::except('notify');
     foreach (Input::all() as $key => $single_input) {
         if (empty($single_input) && (stristr($key, 'state') || stristr($key, 'city'))) {
             unset($inputs[$key]);
         }
     }
     $inputs['dob'] = GlobalFunc::set_date_format(Input::get('dob'));
     $inputs['found_date'] = GlobalFunc::set_date_format(Input::get('found_date'));
     if (!Input::hasFile('kid_image')) {
         unset($inputs['kid_image']);
     } else {
         $file = Input::file('kid_image');
         $destination_path = 'admin/images/upload/';
         $filename = str_random(15) . '.' . $file->getClientOriginalExtension();
         $file->move($destination_path, $filename);
         $inputs['kid_image'] = $destination_path . $filename;
     }
     if (Input::get('clicked') == 'Success') {
         // if the report is marked as a success
         $inputs['status'] = 9;
         $msg = 'Report Successfully Marked As Success';
     } else {
         //if the report is updated or published
         $inputs['status'] = 1;
     }
     unset($inputs['clicked']);
     Found::where('id', '=', Input::get('id'))->update($inputs);
     return Redirect::to('admin/found/published')->with('success', $msg);
 }
Example #15
0
 /**
  * Creates a user on the panel. Returns the created user's ID.
  *
  * @param  string       $email
  * @param  string|null  $password An unhashed version of the user's password.
  * @return bool|integer
  */
 public function create($email, $password = null, $admin = false)
 {
     $validator = Validator::make(['email' => $email, 'password' => $password, 'root_admin' => $admin], ['email' => 'required|email|unique:users,email', 'password' => 'nullable|regex:((?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{8,})', 'root_admin' => 'required|boolean']);
     // Run validator, throw catchable and displayable exception if it fails.
     // Exception includes a JSON result of failed validation rules.
     if ($validator->fails()) {
         throw new DisplayValidationException($validator->errors());
     }
     DB::beginTransaction();
     try {
         $user = new Models\User();
         $uuid = new UuidService();
         $user->uuid = $uuid->generate('users', 'uuid');
         $user->email = $email;
         $user->password = Hash::make(is_null($password) ? str_random(30) : $password);
         $user->language = 'en';
         $user->root_admin = $admin ? 1 : 0;
         $user->save();
         // Setup a Password Reset to use when they set a password.
         $token = str_random(32);
         DB::table('password_resets')->insert(['email' => $user->email, 'token' => $token, 'created_at' => Carbon::now()->toDateTimeString()]);
         $user->notify(new AccountCreated($token));
         DB::commit();
         return $user->id;
     } catch (\Exception $ex) {
         DB::rollBack();
         throw $ex;
     }
 }
Example #16
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function postCreate(UserRequest $request)
 {
     $user = new User();
     $user->name = $request->name;
     $user->tipo_usuario = $request->tipo_usuario;
     $user->username = $request->username;
     $user->email = $request->email;
     $user->password = bcrypt($request->password);
     $user->confirmation_code = str_random(32);
     $user->confirmed = $request->confirmed;
     $picture = "";
     if ($request->hasFile('image')) {
         $file = $request->file('image');
         $filename = $file->getClientOriginalName();
         $extension = $file->getClientOriginalExtension();
         $picture = sha1($filename . time()) . '.' . $extension;
         $destinationPath = public_path() . '/uploads/users/fotos/';
         $request->file('image')->move($destinationPath, $picture);
         $path2 = public_path() . '/uploads/users/fotos/thumbs/';
         Thumbnail::generate_image_thumbnail($destinationPath . $picture, $path2 . $picture);
     }
     $user->filename = $picture;
     if ($user->save()) {
         return redirect("/admin/users");
     }
 }
Example #17
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(ProjetRequest $request)
 {
     $projet = new Projet();
     $image = $request->file('image');
     if ($image->isValid()) {
         $chemin = 'uploads';
         $extension = $image->getClientOriginalExtension();
         do {
             $nom = str_random(10) . '.' . $extension;
         } while (file_exists($chemin . '/' . $nom));
         if ($image->move($chemin, $nom)) {
             $projet->imageUne = $nom;
         }
     }
     $projet->titre = $request->input('titre');
     $projet->resume = $request->input('resume');
     $projet->dateCreation = $request->input('date');
     $projet->lien = $request->input('lien');
     $projet->outils = $request->input('outils');
     $projet->description = $request->input('description');
     $projet->cupofcoffee = $request->input('cupofcoffee');
     $projet->save();
     $projets = projet::all();
     return view('projet/liste', ['projets' => $projets]);
 }
 /**
  * This function create employee
  * when data is posted from 
  * /admin/employee/create
  */
 public function postCreate()
 {
     // Check validation
     $validator = Validator::make(Input::all(), Employee::$rulesForCreate, Employee::$messages);
     // If failed then redirect to employee-create-get route with
     // validation error and input old
     if ($validator->fails()) {
         return Redirect::route('employee-create-get')->withErrors($validator)->withInput();
     }
     // If validation is not failed then create employee
     $employee = Employee::create(array('first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name'), 'age' => Input::get('age'), 'gender' => Input::get('gender'), 'DOB' => DateFormat::store(Input::get('DOB')), 'present_address' => Input::get('present_address'), 'permanent_address' => Input::get('permanent_address'), 'city' => Input::get('city'), 'state' => Input::get('state'), 'country' => Input::get('country'), 'mobile_no' => Input::get('mobile_no'), 'email' => Input::get('email'), 'created_by' => Session::get('username')));
     // Also create user account for the employee
     $user = User::create(array('details_id' => $employee->id, 'username' => Input::get('username'), 'email' => $employee->email, 'user_level' => Input::get('userlevel'), 'active' => 0));
     // generate random code and password
     $password = str_random(10);
     $code = str_random(60);
     $newHashPassword = Hash::make($password);
     // Save new password and code
     $user->password_tmp = $newHashPassword;
     $user->activation_code = $code;
     if ($user->save()) {
         // Send email to the employee.
         // This email contains username,password,activation link
         Mail::send('emails.auth.activation', array('first_name' => $employee->first_name, 'last_name' => $employee->last_name, 'username' => $user->username, 'password' => $password, 'activation_link' => URL::route('activation-get', $code)), function ($message) use($user) {
             $message->to($user->email, $user->username)->subject('Confirm Activation');
         });
     }
     return View::make('adminArea.employee.create')->with('success', 'Activation link has been sent successfully');
 }
Example #19
0
 /**
  * Boot the model.
  *
  * @return void
  */
 public static function boot()
 {
     parent::boot();
     static::creating(function ($user) {
         $user->token = str_random(30);
     });
 }
 public function postRegister(Request $request)
 {
     $validator = $this->validator($request->all());
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $activation_code = str_random(60) . $request->input('email');
     $user = new User();
     $user->username = $request->input('username');
     $user->name = $request->input('name');
     $user->lastname = $request->input('lastname');
     $user->birthdate = $request->input('birthdate');
     $user->email = $request->input('email');
     $user->password = bcrypt($request->input('password'));
     $user->activation_code = $activation_code;
     if ($user->save()) {
         $data = array('name' => $user->name, 'code' => $activation_code);
         \Mail::queue('emails.activateAccount', $data, function ($message) use($user) {
             $message->to($user->email, 'Please activate your account.');
         });
         return view('user.activateAccount');
     } else {
         Flash::message('Your account couldn\'t be create please try again');
         return redirect()->back()->withInput();
     }
 }
 public function store(PostRequest $request)
 {
     if (Input::has('link')) {
         $input['link'] = Input::get('link');
         $info = Embed::create($input['link']);
         if ($info->image == null) {
             $embed_data = ['text' => $info->description];
         } else {
             if ($info->description == null) {
                 $embed_data = ['text' => ''];
             } else {
                 $orig = pathinfo($info->image, PATHINFO_EXTENSION);
                 $qmark = str_contains($orig, '?');
                 if ($qmark == false) {
                     $extension = $orig;
                 } else {
                     $extension = substr($orig, 0, strpos($orig, '?'));
                 }
                 $newName = public_path() . '/images/' . str_random(8) . ".{$extension}";
                 if (File::exists($newName)) {
                     $imageToken = substr(sha1(mt_rand()), 0, 5);
                     $newName = public_path() . '/images/' . str_random(8) . '-' . $imageToken . ".{$extension}";
                 }
                 $image = Image::make($info->image)->fit(70, 70)->save($newName);
                 $embed_data = ['text' => $info->description, 'image' => basename($newName)];
             }
         }
         Auth::user()->posts()->create(array_merge($request->all(), $embed_data));
         return redirect('/subreddit');
     }
     Auth::user()->posts()->create($request->all());
     return redirect('/subreddit');
 }
Example #22
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     Model::unguard();
     // $this->call(UserTableSeeder::class);
     DB::table('users')->insert(['email' => str_random(10) . '@gmail.com', 'name' => str_random(10), 'lastname' => str_random(10), 'password' => bcrypt('secret')]);
     Model::reguard();
 }
Example #23
0
 public function it_find_visitor_when_visitor_sid_is_not_set_on_session(Request $request)
 {
     $visitor = new VisitorModel();
     $visitor->sid = str_random(25);
     $request->session()->has('visitor_log_sid')->shouldBeCalled()->willReturn(false);
     $this->findCurrent()->shouldReturn(false);
 }
Example #24
0
 public function index(Request $request)
 {
     //处理分享次数加1
     $this->_shareTimes($request);
     $key = 'bonus_' . $this->user->getKey() . '_game';
     if (!Cache::has($key)) {
         $times = 1;
         Cache::forever($key, $times);
     } else {
         $times = intval(Cache::get($key, 0));
     }
     $this->_wechat = $this->getJsParameters();
     $this->_times = $times;
     $this->_uid = $this->user->getKey();
     $this->_type_id = 3;
     $this->_data = ['title' => '美猴捞红包', 'imgUrl' => 'plugins/img/m/monkey/monkey_main.jpg', 'desc' => '参加游戏,赢取猴子新年红包。'];
     $this->_bonus_cnt = ActivityBonus::where('uid', $this->user->getKey())->where('status', 0)->count();
     $stores_ids = $this->user->stores->pluck('id')->toArray();
     $stores_id = array_pop($stores_ids);
     $this->_share_url = url('m/home?sid=' . $stores_id . '&redirect_url=' . urlencode(url('m/game/loading') . '?uid=' . $this->_uid));
     $this->_save_put_code = str_random(40);
     $save_code_key = 'save_put_code_' . $this->user->getKey();
     session([$save_code_key => $this->_save_put_code]);
     //查找中奖列表
     $this->_bonus_list = ActivityBonus::with(['users'])->orderBy('created_at', 'desc')->take(9)->get();
     return $this->view('monkey::m.game');
 }
Example #25
0
 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 10; $i++) {
         $user = User::create(array('email' => $faker->email, 'username' => $faker->unique->username, 'password' => $faker->word, 'remember_token' => str_random(50)));
     }
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('users', function (Blueprint $table) {
         $table->increments('id');
         $table->string('name');
         $table->string('email')->unique();
         $table->string('password');
         $table->boolean('active');
         $table->boolean('banned');
         $table->string('register_ip');
         $table->string('country_code');
         $table->string('locale');
         $table->string('activation_key');
         $table->boolean('su');
         $table->rememberToken();
         $table->timestamps();
     });
     $user = \Laralum::newUser();
     $user->name = env('USER_NAME', 'admin');
     $user->email = env('USER_EMAIL', '*****@*****.**');
     $user->password = bcrypt(env('USER_PASSWORD', 'admin123'));
     $user->active = true;
     $user->banned = false;
     $user->register_ip = "";
     $user->country_code = env('USER_COUNTRY_CODE', 'ES');
     $user->locale = env('USER_LOCALE', 'en');
     $user->activation_key = str_random(25);
     $user->su = true;
     $user->save();
 }
Example #27
0
 /**
  * susbscribe valid, unique $request['email'] to
  * boston meshnet mailing list -- thank you finn!
  **/
 public function subscribe($email)
 {
     $base_uri = 'https://lists.projectmesh.net/cgi-bin/mailman/subscribe/boston';
     $client = new \Guzzle\Service\Client(['base_uri' => 'https://lists.projectmesh.net/cgi-bin/mailman/subscribe/boston', 'timeout' => 7]);
     $randStrng = str_random(12);
     error_log(json_encode(['$randStrng' => $randStrng]));
     $request = $client->post($base_uri, ['content-type' => 'application/x-www-form-urlencoded'], []);
     $data = ['email' => $email, 'pw' => $randStrng, 'pw-conf' => $randStrng, 'digest' => 0, 'email-button' => 'Subscribe'];
     $request->setBody($data);
     $response = $request->send();
     /* Pending mailserver install..
     
             $data = (object) [
                         'lists'   => '*****@*****.**',
                         'lists_public' => '*****@*****.**',
                         'from'    => $email,
                         'subject' => 'Mailing List Request from Boston Meshnet (via Bostonmesh.net Website)',
                         'artisan' => '*****@*****.**',
                     ] ;
     
             $success = Mail::send('emails.subscribe', [ 'data' => $data ], function ($message) use($data) {
                 $message->from($data->from);
                 $message->to($data->lists)
                             ->cc($data->artisan)
                             ->cc($data->from)
                             ->subject($data->subject);
             });
     
             error_log(json_encode(['subscribe' => $success]));
             */
     $success = true;
     return ['success' => $success];
 }
 public function postEdit($id, Request $request)
 {
     $speaker = $request->all();
     //create paper
     $rand = str_random();
     $file = $request->file('file');
     if ($request->hasFile('file')) {
         $image['name'] = $rand . '_' . $file->getClientOriginalName();
         $image['original_name'] = $file->getClientOriginalName();
         $image['description'] = "Paper template";
         $image['type'] = $file->getClientOriginalExtension();
         $image['img_type'] = "paper";
         $image = File::create($image);
         $file->move('assets/files', $rand . '_' . $file->getClientOriginalName());
         $speaker['file_id'] = $image->id;
     }
     //create image
     $file = $request->file('image');
     if ($request->hasFile('image')) {
         $paper['name'] = $rand . '_' . $file->getClientOriginalName();
         $paper['original_name'] = $file->getClientOriginalName();
         $paper['description'] = "Keynote Speaker";
         $paper['type'] = $file->getClientOriginalExtension();
         $paper['img_type'] = "image";
         $paper = File::create($paper);
         $file->move('assets/images/speaker', $rand . '_' . $file->getClientOriginalName());
         $speaker['image_id'] = $paper->id;
     }
     //create speaker
     Speaker::find($id)->update($speaker);
     $speaker = Speaker::findOrFail($id);
     $speaker->slug = str_slug($speaker->name . '-' . $speaker->id, '-');
     $speaker->save();
     return redirect()->action('Admin\\KeynoteSpeakerController@getIndex')->with('success', 'edit');
 }
 public function create(Request $data)
 {
     $validator = Validator::make($data->all(), ['name' => 'required|max:255', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|confirmed|min:6']);
     if ($validator->fails()) {
         $this->throwValidationException($data, $validator);
     }
     $user = new User();
     $activation_code = str_random(60) . $data['email'];
     $user->name = $data['name'];
     $user->email = $data['email'];
     $user->password = bcrypt($data['password']);
     $user->how_know = $data['how_know'];
     $user->activation_code = $activation_code;
     if ($user->save()) {
         $to = $data['email'];
         // subject
         $subject = 'Verification Required';
         // message
         $message = "\n\t\t\t\t<div style='line-height:1'>\n\t\t\t\t\t<div style='width:700px;margin:0 auto;margin-top:20px;padding:0px;background:#f5f5f5;border:1px solid #d2d2d2;border-radius:5px;font-family:Arial,Helvetica,sans-serif'>\n\t\t\t\t\t<div style='width:700px;margin:0px;padding:20px 0px 20px 0px;background:url(https://ci4.googleusercontent.com/proxy/U9DVvzyQQifr6SPalG_Od_DoppU3VoTGQ_PsL0zGu6CNvmYzsnGQ6kaGbuRdwluMALk7IZCWqMOxM-XtCO772qA7_Zqx=s0-d-e1-ft#{{url('images/logo.png')}}) top left repeat;border-radius:5px 5px 0px 0px;text-align:center'><img src='{{url('images/logo.png')}}' ></div>\n\t\t\t\t\t    <div style='width:660px;margin:10px 0px 0px 0px;padding:20px;font-size:12px;color:#262626;line-height:18px'>\n\t\t\t\t\t    \t<p>Dear  <a href='mailto:premsingh57@gmail.com' target='_blank'>premsingh57@gmail.com</a>,</p>\n\t\t\t\t\t        <p>You are receiving this email because you are requested to  create new account on Omni Text Solution. Please click on the link below to complete your confirmation.</p>\n\n\t\t\t\t\t\t\t<div style='text-align:center;padding:10px 0px'><a style='font-size:14px;font-weight:bold;color:#fff;background:#2dcc70;text-decoration:none;border-radius:5px;padding:8px 15px' target='_blank'>Confirm</a></div>\n\n\t\t\t\t\t\t\t<p>If you think that you shouldn't have received this email, you can safely ignore it.</p>\n\n\t\t\t\t\t\t\t<p>Thank you,</p>\n\t\t\t\t\t\t\t<p>Omni Text Solution</p><div></div><div >\n\t\t\t\t\t    \t\n\t\t\t\t\t    </div></div></div>\n\t\t\t\t</div>\n\t\t\t";
         // To send HTML mail, the Content-type header must be set
         $headers = 'MIME-Version: 1.0' . "\r\n";
         $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
         $headers .= "From: donotreply@omnitext.com" . "\r\n";
         mail($to, $subject, $message, $headers);
         \Session::flash('success_message', "Activation link is send to {$data['email']}. Please activite your account");
         return view('auth.register');
     }
 }
Example #30
0
 private function getSalt()
 {
     if (empty($this->salt)) {
         $this->salt = str_random(32);
     }
     return $this->salt;
 }