コード例 #1
0
ファイル: projects.php プロジェクト: niceit/tranit-tracker
 public function post_new()
 {
     $image = 'uploads/project/projectDefault.png';
     if (\Laravel\Input::has_file('image')) {
         $img = \Laravel\Input::file('image');
         if ($img['size'] > 100000) {
             return Redirect::to('projects/new')->with_input()->with('notice-error', __('tinyissue.file_sizes_errors'));
         }
         $arr_size = getimagesize($img['tmp_name']);
         if ($arr_size[0] > 200 && $arr_size[1] > 200) {
             return Redirect::to('projects/new')->with_input()->with('notice-error', __('tinyissue.file_size_errors'));
         }
         $destination = "../uploads/project/";
         $extensions = array('image/png', 'image/jpg', 'image/jpeg');
         if (in_array($img['type'], $extensions)) {
             $name = md5($img['name'] . rand(11111, 99999)) . "." . $this->extensions($img['type']);
             \Laravel\Input::upload('image', $destination, $name);
             $image = 'uploads/project/' . $name;
         } else {
             return Redirect::to('projects/new')->with_input()->with('notice-error', __('tinyissue.file_type_errors'));
         }
     }
     $create = Project::create_project(Input::all(), $image);
     if ($create['success']) {
         return Redirect::to($create['project']->to());
     }
     return Redirect::to('projects/new')->with_errors($create['errors'])->with('notice-error', __('tinyissue.we_have_some_errors'));
 }
コード例 #2
0
ファイル: users.php プロジェクト: niceit/tranit-tracker
 public function post_edit($user_id)
 {
     $avatar = '';
     if (\Laravel\Input::has_file('avatar')) {
         $img = \Laravel\Input::file('avatar');
         if ($img['size'] > 100000) {
             return Redirect::to('administration/users/edit/' . $user_id)->with_input()->with('notice-error', __('tinyissue.file_sizes_errors'));
         }
         $arr_size = getimagesize($img['tmp_name']);
         if ($arr_size[0] > 200 && $arr_size[1] > 200) {
             return Redirect::to('administration/users/edit/' . $user_id)->with_input()->with('notice-error', __('tinyissue.file_size_errors'));
         }
         $destination = "../uploads/avatar/";
         $extensions = array('image/png', 'image/jpg', 'image/jpeg');
         if (in_array($img['type'], $extensions)) {
             $name = md5($img['name'] . rand(11111, 99999)) . "." . $this->extensions($img['type']);
             \Laravel\Input::upload('avatar', $destination, $name);
             $avatar = 'uploads/avatar/' . $name;
         } else {
             return Redirect::to('administration/users/edit/' . $user_id)->with_input()->with('notice-error', __('tinyissue.file_type_errors'));
         }
     }
     $update = User::update_user(Input::all(), $user_id, $avatar);
     if (!$update['success']) {
         return Redirect::to('administration/users/edit/' . $user_id)->with_input()->with_errors($update['errors'])->with('notice-error', __('tinyissue.we_have_some_errors'));
     }
     return Redirect::to('administration/users')->with('notice', __('tinyissue.user_updated'));
 }
コード例 #3
0
ファイル: project.php プロジェクト: niceit/tranit-tracker
 public function post_edit()
 {
     /* Delete the project */
     if (Input::get('delete')) {
         Project::delete_project(Project::current());
         return Redirect::to('projects')->with('notice', __('tinyissue.project_has_been_deleted'));
     }
     $image = '';
     if (\Laravel\Input::has_file('image')) {
         $img = \Laravel\Input::file('image');
         if ($img['size'] > 100000) {
             return Redirect::to(Project::current()->to('edit'))->with_input()->with('notice-error', __('tinyissue.file_sizes_errors'));
         }
         $arr_size = getimagesize($img['tmp_name']);
         if ($arr_size[0] > 200 && $arr_size[1] > 200) {
             return Redirect::to(Project::current()->to('edit'))->with_input()->with('notice-error', __('tinyissue.file_size_errors'));
         }
         $destination = "../uploads/project/";
         $extensions = array('image/png', 'image/jpg', 'image/jpeg');
         if (in_array($img['type'], $extensions)) {
             $name = md5($img['name'] . rand(11111, 99999)) . "." . $this->extensions($img['type']);
             \Laravel\Input::upload('image', $destination, $name);
             $image = 'uploads/project/' . $name;
         } else {
             return Redirect::to(Project::current()->to('edit'))->with_input()->with('notice-error', __('tinyissue.file_type_errors'));
         }
     }
     /* Update the project */
     $update = Project::update_project(Input::all(), Project::current(), $image);
     if ($update['success']) {
         return Redirect::to(Project::current()->to('edit'))->with('notice', __('tinyissue.project_has_been_updated'));
     }
     return Redirect::to(Project::current()->to('edit'))->with_errors($update['errors'])->with('notice-error', __('tinyissue.we_have_some_errors'));
 }