diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 51fea41744d..00000000000 --- a/.gitattributes +++ /dev/null @@ -1,22 +0,0 @@ -# This file tells which files and directories should be ignored and -# NOT downloaded when using composer to pull down a project with -# the --prefer-dist option selected. Used to remove development -# specific files so user has a clean download. - -# git files -.gitattributes export-ignore -# .gitignore - -# helper config files -.travis.yml export-ignore -phpdoc.dist.xml export-ignore - -# Misc other files -readme.rst - -# They don't want all of our tests... -tests/codeigniter/ export-ignore -tests/travis/ export-ignore - -# User Guide Source Files -user_guide_src diff --git a/.htaccess b/.htaccess new file mode 100644 index 00000000000..9e25198b5a4 --- /dev/null +++ b/.htaccess @@ -0,0 +1,4 @@ +RewriteEngine On +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^(.*)$ index.php/$1 [L] \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2cb2c1fac2f..00000000000 --- a/.travis.yml +++ /dev/null @@ -1,60 +0,0 @@ -language: php -dist: precise - -php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - 7.2 - - 7.3 - - master - - hhvm - -env: - - DB=mysql - - DB=mysqli - - DB=pgsql - - DB=sqlite - - DB=pdo/mysql - - DB=pdo/pgsql - - DB=pdo/sqlite - -sudo: false - -before_script: - - sh -c "composer install --dev --no-progress" - - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS ci_test;' -U postgres; fi" - - sh -c "if [ '$DB' = 'pgsql' ] || [ '$DB' = 'pdo/pgsql' ]; then psql -c 'create database ci_test;' -U postgres; fi" - - sh -c "if [ '$DB' = 'mysql' ] || [ '$DB' = 'mysqli' ] || [ '$DB' = 'pdo/mysql' ]; then mysql -e 'create database IF NOT EXISTS ci_test;'; fi" - -script: php -d zend.enable_gc=0 -d date.timezone=UTC -d mbstring.func_overload=7 -d mbstring.internal_encoding=UTF-8 vendor/bin/phpunit --coverage-text --configuration tests/travis/$DB.phpunit.xml - -matrix: - allow_failures: - - php: hhvm - - php: master - exclude: - - php: hhvm - env: DB=pgsql - - php: hhvm - env: DB=pdo/pgsql - - php: 7.0 - env: DB=mysql - - php: 7.1 - env: DB=mysql - - php: 7.2 - env: DB=mysql - - php: 7.3 - env: DB=mysql - - php: master - env: DB=mysql - -branches: - only: - - develop - - 3.0-stable - - 3.1-stable - - /^feature\/.+$/ diff --git a/application/config/autoload.php b/application/config/autoload.php index 7cdc9013c11..4b95fc5b41c 100644 --- a/application/config/autoload.php +++ b/application/config/autoload.php @@ -58,7 +58,7 @@ | | $autoload['libraries'] = array('user_agent' => 'ua'); */ -$autoload['libraries'] = array(); +$autoload['libraries'] = array('database', 'session', 'form_validation'); /* | ------------------------------------------------------------------- @@ -89,7 +89,7 @@ | | $autoload['helper'] = array('url', 'file'); */ -$autoload['helper'] = array(); +$autoload['helper'] = array('url', 'file', 'form', 'security'); /* | ------------------------------------------------------------------- diff --git a/application/config/config.php b/application/config/config.php index 10315220e04..5a165d19cd0 100644 --- a/application/config/config.php +++ b/application/config/config.php @@ -23,7 +23,7 @@ | a PHP script and you can easily do that on your own. | */ -$config['base_url'] = ''; +$config['base_url'] = 'http://localhost/vietgram/'; /* |-------------------------------------------------------------------------- @@ -35,7 +35,7 @@ | variable so that it is blank. | */ -$config['index_page'] = 'index.php'; +$config['index_page'] = ''; /* |-------------------------------------------------------------------------- diff --git a/application/config/constants.php b/application/config/constants.php index 18d3b4b76ff..b5b241cd1ae 100644 --- a/application/config/constants.php +++ b/application/config/constants.php @@ -1,6 +1,10 @@ '', 'hostname' => 'localhost', - 'username' => '', + 'username' => 'root', 'password' => '', - 'database' => '', + 'database' => 'instagram_1301180294', 'dbdriver' => 'mysqli', 'dbprefix' => '', 'pconnect' => FALSE, diff --git a/application/config/routes.php b/application/config/routes.php index 1b45740d7c7..5ed0cf870dc 100644 --- a/application/config/routes.php +++ b/application/config/routes.php @@ -49,6 +49,6 @@ | Examples: my-controller/index -> my_controller/index | my-controller/my-method -> my_controller/my_method */ -$route['default_controller'] = 'welcome'; +$route['default_controller'] = 'Auth'; $route['404_override'] = ''; $route['translate_uri_dashes'] = FALSE; diff --git a/application/config/user_agents.php b/application/config/user_agents.php index c1581e5cd3f..c4429aac55f 100644 --- a/application/config/user_agents.php +++ b/application/config/user_agents.php @@ -152,6 +152,11 @@ 'open web' => 'Open Web', 'openweb' => 'OpenWeb', 'meizu' => 'Meizu', + 'huawei' => 'Huawei', + 'xiaomi' => 'Xiaomi', + 'oppo' => 'Oppo', + 'vivo' => 'Vivo', + 'infinix' => 'Infinix', // Operating Systems 'android' => 'Android', diff --git a/application/controllers/Auth.php b/application/controllers/Auth.php new file mode 100644 index 00000000000..f308c941220 --- /dev/null +++ b/application/controllers/Auth.php @@ -0,0 +1,51 @@ +load->model('M_User'); + } + + public function index() { + $this->form_validation->set_rules('username', 'Username', 'required|trim'); + $this->form_validation->set_rules('password', 'Password', 'required|trim'); + + if ($this->form_validation->run() == FALSE) { + $this->load->view('V_login'); + } else { + $this->_do_login(); + } + } + + private function _do_login() { + $username = $this->input->post('username'); + $password = $this->input->post('password'); + + $user = $this->M_User->checkUser($username, $password); + + // if user avail + if ($user) { + $profile = $this->M_User->getProfile($user['username']); + + $this->session->set_userdata($profile); + redirect('User'); + } else { + redirect('Auth'); + } + } + + public function do_logout() { + $this->session->unset_userdata('username'); + redirect('Auth'); + } + +} + +?> diff --git a/application/controllers/User.php b/application/controllers/User.php new file mode 100644 index 00000000000..b6c26cc2d16 --- /dev/null +++ b/application/controllers/User.php @@ -0,0 +1,88 @@ +session->userdata('username')) { + redirect('Auth'); + } + + $this->load->model('M_User'); + } + + public function index() { + $this->load->view('V_profile'); + } + + public function load_explore() { + $this->load->view('V_explore'); + } + + public function load_feed() { + $this->load->view('V_feed'); + } + + public function load_editProfile() { + $this->load->view('V_edit-profile'); + } + + public function load_uploadPhoto() { + $this->load->view('V_upload-photo'); + } + + public function do_editProfile() { + $this->form_validation->set_rules('name', 'Name', 'required'); + $this->form_validation->set_rules('username', 'Username', 'required|trim'); + $this->form_validation->set_rules('website', 'Website', 'required|trim'); + $this->form_validation->set_rules('bio', 'Bio', 'required'); + $this->form_validation->set_rules('email', 'Email', 'required|trim'); + $this->form_validation->set_rules('phonenumber', 'Phonenumber', 'required|trim'); + $this->form_validation->set_rules('gender', 'Username', 'required'); + + $username = $this->session->userdata('username'); + + $dataProfile = [ + 'name' => $this->input->post('name'), + 'username' => $this->input->post('username'), + 'website' => $this->input->post('website'), + 'bio' => $this->input->post('bio'), + 'email' => $this->input->post('email'), + 'phonenumber' => $this->input->post('phonenumber'), + 'gender' => $this->input->post('gender') + ]; + + $dataUser = [ + 'username' => $this->input->post('username'), + 'email' => $this->input->post('email') + ]; + + $this->M_User->editProfile($dataProfile, $username); + $this->M_User->editUser($dataUser, $username); + $this->session->set_userdata($dataProfile); + redirect('User'); + } + + public function do_uploadPhoto() { + $data = []; + + $upload = $this->M_User->uploadPhoto(); + + if ($upload['result'] == 'success') { + $this->M_User->saveIntoDatabase($upload); + redirect('User'); + } else { + $data['message'] = $upload['error']; + redirect('User/load_uploadPhoto'); + } + } + +} + +?> \ No newline at end of file diff --git a/application/controllers/Welcome.php b/application/controllers/Welcome.php deleted file mode 100644 index 9213c0cf545..00000000000 --- a/application/controllers/Welcome.php +++ /dev/null @@ -1,25 +0,0 @@ - - * @see https://codeigniter.com/user_guide/general/urls.html - */ - public function index() - { - $this->load->view('welcome_message'); - } -} diff --git a/application/controllers/index.html b/application/controllers/index.html deleted file mode 100644 index b702fbc3967..00000000000 --- a/application/controllers/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - -
-Directory access is forbidden.
- - - diff --git a/application/models/M_User.php b/application/models/M_User.php new file mode 100644 index 00000000000..cc4cc04ba8b --- /dev/null +++ b/application/models/M_User.php @@ -0,0 +1,68 @@ +db->get_where('user', [ + 'username' => $username, + 'password' => $password + ])->row_array(); + } + + public function getProfile($username) { + return $this->db->get_where('profile', [ + 'username' => $username + ])->row_array(); + } + + public function editProfile($data, $username) { + $this->db->where('username', $username); + $this->db->update('profile', $data); + } + + public function editUser($data, $username) { + $this->db->where('username', $username); + $this->db->update('user', $data); + } + + // Upload Image ----------------------------- + public function uploadPhoto() { + $config['upload_path'] = './assets/images/'; + $config['allowed_types'] = 'jpg|png|jpeg'; + $config['max_size'] = 2048; + $config['remove_spcae'] = TRUE; + + $this->load->library('upload', $config); + if ($this->upload->do_upload('image')) { + $result = [ + 'result' => 'success', + 'file' => $this->upload->data(), + 'error' => '', + ]; + return $result; + } else { + $result = [ + 'result' => 'error', + 'file' => '', + 'error' => $this->upload->display_errors(), + ]; + return $result; + } + } + + public function saveIntoDatabase($upload) { + $data = [ + 'url' => $upload['file']['file_name'], + 'caption' => $this->input->post('caption'), + 'like' => 225, + ]; + $this->db->insert('photo', $data); + } + +} + +?> \ No newline at end of file diff --git a/application/models/index.html b/application/models/index.html deleted file mode 100644 index b702fbc3967..00000000000 --- a/application/models/index.html +++ /dev/null @@ -1,11 +0,0 @@ - - - -Directory access is forbidden.
- - - diff --git a/application/views/V_edit-profile.php b/application/views/V_edit-profile.php new file mode 100644 index 00000000000..f6f9653a966 --- /dev/null +++ b/application/views/V_edit-profile.php @@ -0,0 +1,122 @@ + + + + + + + + + + + +
+
+
+
+
+
+
+
+
+
+ = $this->session->userdata('name'); ?>
+
+
+ = $this->session->userdata('bio'); ?>
+ = $this->session->userdata('website'); ?>
+
+
+
+
+
+
+
+
+ Directory access is forbidden.
- - - diff --git a/application/views/links.html b/application/views/links.html new file mode 100644 index 00000000000..c51b80c483e --- /dev/null +++ b/application/views/links.html @@ -0,0 +1,28 @@ + + + + + + + + + +The page you are looking at is being generated dynamically by CodeIgniter.
- -If you would like to edit this page you'll find it located at:
-application/views/welcome_message.php
-
- The corresponding controller for this page is found at:
-application/controllers/Welcome.php
-
- If you are exploring CodeIgniter for the very first time, you should start by reading the User Guide.
-' ; - $pre_close = ''; + $pre_close = ''; } $output .= '
' ; - $pre_close = ''; + $pre_close = ''; } $output .= '
';
-
- $xss_clean_return = $this->security->xss_clean($harm_string, TRUE);
-
-// $this->assertTrue($xss_clean_return);
- }
-
- // --------------------------------------------------------------------
-
- public function test_xss_clean_image_invalid()
- {
- $harm_string = '