Ejemplo n.º 1
0
 public function store()
 {
     Notes::where('email', Auth::user()->email)->update(array('notes' => Input::get('notes')));
     TBD::where('email', Auth::user()->email)->update(array('tbd' => Input::get('tbd')));
     $input = Input::all();
     for ($i = 0; $i < count($input); $i++) {
         if (!Links::where('links', '=', Input::get("link{$i}"))->exists()) {
             if (Input::get("link{$i}") != "") {
                 Links::insert(array('email' => Auth::user()->email, 'links' => Input::get("link{$i}")));
             }
         }
     }
     if (Input::hasFile('photo')) {
         $count = Image::where('email', Auth::user()->email)->count();
         if ($count >= 4) {
             echo "USER CAN ONLY HAVE 4 PHOTOS MAX";
             return Redirect::back();
         }
         $extension = Input::file('photo')->getClientOriginalExtension();
         if ($extension == "gif" || $extension == "jpeg") {
             Image::insert(array('email' => Auth::user()->email, 'image' => file_get_contents(Input::file('photo'))));
         } else {
             echo "CAN ONLY DO GIF OR JPEG";
         }
     }
     $imageCount = Image::where('email', Auth::user()->email)->count();
     for ($i = 0; $i < $imageCount - 1; $i++) {
         if (Input::get("delete{$i}") != null) {
             $imageTable = Image::where('email', Auth::user()->email)->get();
             //echo $imageTable[$i+1]["id"];
             Image::where('id', $imageTable[$i]["id"])->delete();
         }
     }
     return Redirect::to('profile');
 }
Ejemplo n.º 2
0
 public function store()
 {
     if (!Input::has('email', 'password', 'confirmPassword')) {
         $this->failure("Must fill in the values");
     }
     if (Input::get('password') != Input::get('confirmPassword')) {
         $this->failure("PASSWORDS NOT THE SAME");
     }
     $rules = array('email' => 'unique:users,email');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         $this->failure('That email address is already registered. You sure you don\'t have an account?');
     }
     if (!filter_var(Input::get('email'), FILTER_VALIDATE_EMAIL)) {
         $this->failure("username must be an email");
     }
     $verificationCode = md5(time());
     User::insert(array('email' => Input::get('email'), 'password' => Hash::make(Input::get('password')), 'verification' => $verificationCode));
     Image::insert(array('email' => Input::get('email'), 'image' => ''));
     Notes::insert(array('email' => Input::get('email'), 'notes' => ''));
     TBD::insert(array('email' => Input::get('email'), 'tbd' => ''));
     Links::insert(array('email' => Input::get('email'), 'links' => ''));
     Mail::send('emails.emailMessage', array('code' => $verificationCode, 'email' => Input::get('email')), function ($message) {
         $message->to('*****@*****.**', 'Jan Ycasas')->subject('Welcome!');
     });
     echo "Go Log In";
     return Redirect::to('/');
 }
Ejemplo n.º 3
0
 function save_field()
 {
     return $this->container->save_field($this);
 }
 public function submitPage()
 {
     $timeDiff = round(abs(time() - $_SESSION["time"]) / 60, 2) . " minute";
     if ($timeDiff >= 20) {
         exit("LOGGED OUT OF INACTIVE. <a href='home'>Log In</a>");
     }
     $userID = $_POST["userID"];
     $result = Image::where('userID', $userID)->count();
     if (file_exists($_FILES['photo']['tmp_name']) || is_uploaded_file($_FILES['photo']['tmp_name'])) {
         $result++;
     }
     if ($result >= 4) {
         echo $result;
         exit("CAN ONLY HAVE 4 IMAGES GO BACK");
     }
     $id = Image::select('id')->where('userID', $userID)->get()->toArray();
     for ($i = 0; $i < $result; $i++) {
         if (isset($_POST["delete{$i}"])) {
             Image::where('id', $id[$i]["id"])->delete();
         }
     }
     Notes::where('userID', $_POST["userID"])->update(array('notes' => $_POST["notes"]));
     TBD::where('userID', $_POST["userID"])->update(array('tbd' => $_POST["tbd"]));
     $emailArray = array();
     for ($i = 0; $i < 10; $i++) {
         if (isset($_POST["website{$i}"]) && $_POST["website{$i}"] != "") {
             array_push($emailArray, $_POST["website{$i}"]);
         }
     }
     for ($i = 0; $i < count($emailArray); $i++) {
         $result = Website::select('website')->where('website', $emailArray[$i])->get();
         if ($result == "[]") {
             Website::insert(array('userID' => $userID, 'website' => $emailArray[$i]));
         }
     }
     if ($_FILES['photo']['error'] === UPLOAD_ERR_OK) {
         if ($_FILES['photo']['type'] == "image/jpeg" || $_FILES['photo']['type'] == "image/jpg" || $_FILES['photo']['type'] == "image/gif") {
             Image::insert(array('userID' => $userID, 'image' => file_get_contents($_FILES['photo']['tmp_name'])));
         }
     }
     $profile = $this->returnProfile($_POST["userID"]);
     return View::make('profile')->with('userProfile', $profile);
 }