Commit e34c3533 by tetiana yaremko

ready to deploy

parent a72ced74
...@@ -326,6 +326,7 @@ $config['cache_query_string'] = FALSE; ...@@ -326,6 +326,7 @@ $config['cache_query_string'] = FALSE;
| |
*/ */
$config['encryption_key'] = 'femEDWTX$AQ@6HggkKn8RWGf!*ufK?KC'; $config['encryption_key'] = 'femEDWTX$AQ@6HggkKn8RWGf!*ufK?KC';
//femEDWTX$AQ@6HggkKn8RWGf!*ufK?KC
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
...@@ -461,8 +462,13 @@ $config['csrf_protection'] = true; ...@@ -461,8 +462,13 @@ $config['csrf_protection'] = true;
$config['csrf_token_name'] = 'csrf_test_name'; $config['csrf_token_name'] = 'csrf_test_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name'; $config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200; $config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = TRUE; $config['csrf_regenerate'] = false;
$config['csrf_exclude_uris'] = array(); $config['csrf_exclude_uris'] = array(
'cart/add_to_cart', 'cart/load_cart',
'home/products', 'cart/delete_product_from_cart', 'cart/increase_qty', 'cart/decrease_qty',
'auth/resetpassword'
);
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
......
...@@ -78,6 +78,9 @@ $db['default'] = array( ...@@ -78,6 +78,9 @@ $db['default'] = array(
'hostname' => '104.199.82.156', 'hostname' => '104.199.82.156',
'username' => 'tetiana', 'username' => 'tetiana',
'password' => 'yaremko_tetiana', 'password' => 'yaremko_tetiana',
// 'hostname' => 'localhost',
// 'username' => 'root',
// 'password' => '',
'database' => 'mydb', 'database' => 'mydb',
'dbdriver' => 'mysqli', 'dbdriver' => 'mysqli',
'dbprefix' => '', 'dbprefix' => '',
......
...@@ -49,6 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); ...@@ -49,6 +49,7 @@ defined('BASEPATH') OR exit('No direct script access allowed');
| Examples: my-controller/index -> my_controller/index | Examples: my-controller/index -> my_controller/index
| my-controller/my-method -> my_controller/my_method | my-controller/my-method -> my_controller/my_method
*/ */
$route['default_controller'] = 'auth/login'; $route['default_controller'] = 'welcome';
//$route['default_controller'] = 'auth/login';
$route['404_override'] = ''; $route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE; $route['translate_uri_dashes'] = FALSE;
...@@ -49,7 +49,6 @@ class Admin extends CI_Controller { ...@@ -49,7 +49,6 @@ class Admin extends CI_Controller {
} }
} }
$this->load->view('admin/aside'); $this->load->view('admin/aside');
$this->load->view('admin/add_product'); $this->load->view('admin/add_product');
} }
...@@ -57,7 +56,6 @@ class Admin extends CI_Controller { ...@@ -57,7 +56,6 @@ class Admin extends CI_Controller {
public function product_inventory() { public function product_inventory() {
$this->load->model('Admin_model', 'admin'); $this->load->model('Admin_model', 'admin');
$data=$this->admin->get_data(); $data=$this->admin->get_data();
$this->load->view('admin/aside'); $this->load->view('admin/aside');
......
<?php <?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Auth extends CI_Controller class Auth extends CI_Controller
{ {
...@@ -6,6 +7,7 @@ class Auth extends CI_Controller ...@@ -6,6 +7,7 @@ class Auth extends CI_Controller
function __construct() function __construct()
{ {
parent::__construct(); parent::__construct();
} }
public function logged_in_check() public function logged_in_check()
...@@ -27,9 +29,12 @@ class Auth extends CI_Controller ...@@ -27,9 +29,12 @@ class Auth extends CI_Controller
{ {
$this->logged_in_check(); $this->logged_in_check();
$this->form_validation->set_rules("email", "Email", "trim|required");
$this->form_validation->set_rules("email", "Email", "trim|required|valid_email");
$this->form_validation->set_rules("password", "Password", "trim|required"); $this->form_validation->set_rules("password", "Password", "trim|required");
if ($this->form_validation->run() == true) { if ($this->form_validation->run() == true) {
$this->load->model('auth_model', 'auth'); $this->load->model('auth_model', 'auth');
$this->load->model('Cart_model', 'cmodel'); $this->load->model('Cart_model', 'cmodel');
$status = $this->auth->validate(); $status = $this->auth->validate();
...@@ -45,7 +50,6 @@ class Auth extends CI_Controller ...@@ -45,7 +50,6 @@ class Auth extends CI_Controller
$this->session->set_userdata($this->auth->get_data()); $this->session->set_userdata($this->auth->get_data());
$this->session->set_userdata("logged_in", true); $this->session->set_userdata("logged_in", true);
$data=$this->cmodel->getAllFromCart(); $data=$this->cmodel->getAllFromCart();
$this->cmodel->set_user_cart($this->session->userdata('email'), $data); $this->cmodel->set_user_cart($this->session->userdata('email'), $data);
...@@ -91,6 +95,7 @@ class Auth extends CI_Controller ...@@ -91,6 +95,7 @@ class Auth extends CI_Controller
} }
public function verify () { public function verify () {
require_once(APPPATH.'libraries/random.php');
$email=$this->input->get('email'); $email=$this->input->get('email');
$token= $this->input->get('token'); $token= $this->input->get('token');
...@@ -118,6 +123,7 @@ class Auth extends CI_Controller ...@@ -118,6 +123,7 @@ class Auth extends CI_Controller
} }
public function forgotPassword () { public function forgotPassword () {
require_once(APPPATH.'libraries/random.php');
$this->form_validation->set_rules("email", "Email", "trim|required"); $this->form_validation->set_rules("email", "Email", "trim|required");
if($this->form_validation->run() == false) { if($this->form_validation->run() == false) {
$this->load->view('forgotPassword'); $this->load->view('forgotPassword');
...@@ -148,6 +154,7 @@ class Auth extends CI_Controller ...@@ -148,6 +154,7 @@ class Auth extends CI_Controller
public function resetPassword() { public function resetPassword() {
require_once(APPPATH.'libraries/random.php');
$email =$this->input->get('email'); $email =$this->input->get('email');
$token =$this->input->get('token'); $token =$this->input->get('token');
$user = $this->db->get_where('users', array('email'=>$email))->row_array(); $user = $this->db->get_where('users', array('email'=>$email))->row_array();
......
...@@ -16,6 +16,8 @@ class Cart extends CI_Controller ...@@ -16,6 +16,8 @@ class Cart extends CI_Controller
} else { } else {
$this->cmodel->add_to_cart($prod_id); $this->cmodel->add_to_cart($prod_id);
} }
echo $this->show_cart(); echo $this->show_cart();
} }
...@@ -23,9 +25,12 @@ class Cart extends CI_Controller ...@@ -23,9 +25,12 @@ class Cart extends CI_Controller
$this->cart->destroy(); $this->cart->destroy();
$this->load->model('Cart_model', 'cmodel'); $this->load->model('Cart_model', 'cmodel');
$data=$this->cmodel->getAllFromCart(); $data=$this->cmodel->getAllFromCart();
//$data['token'] = $this->security->get_csrf_hash();
if ($this->session->userdata("logged_in")) { if ($this->session->userdata("logged_in")) {
//$this->cmodel->set_user_cart($this->session->userdata('email'), $data); //$this->cmodel->set_user_cart($this->session->userdata('email'), $data);
$data=$this->cmodel->getAllFromUserCart($this->session->userdata('email')); $data=$this->cmodel->getAllFromUserCart($this->session->userdata('email'));
//$data['token'] = $this->security->get_csrf_hash();
} }
...@@ -84,9 +89,11 @@ class Cart extends CI_Controller ...@@ -84,9 +89,11 @@ class Cart extends CI_Controller
'; ';
return $output; return $output;
} }
//load mini-cart //load mini-cart
public function load_cart(){ public function load_cart(){
echo $this->show_cart(); echo $this->show_cart();
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
$allowAll['auth']['register']=true; $allowAll['auth']['register']=true;
$allowAll['auth']['forgotPassword']=true; $allowAll['auth']['forgotPassword']=true;
$allowAll['auth']['logout']=true; $allowAll['auth']['logout']=true;
$allowAll['auth']['resetPassword']=true; $allowAll['auth']['resetpassword']=true;
$allowAll['auth']['changePassword']=true; $allowAll['auth']['changepassword']=true;
$allowAll['auth']['verify'] =true; $allowAll['auth']['verify'] =true;
$allowAll['home']['products']=true; $allowAll['home']['products']=true;
......
...@@ -3,9 +3,11 @@ ...@@ -3,9 +3,11 @@
class Auth_model extends CI_Model { class Auth_model extends CI_Model {
private $_data=array(); private $_data=array();
public function validate() { public function validate() {
$email =$this->input->post('email'); $email =$this->security->xss_clean($this->input->post('email'));
$password =md5($this->input->post('password')); $password =$this->security->xss_clean(md5($this->input->post('password')));
$this->db->select('*'); $this->db->select('*');
$this->db->from('users'); $this->db->from('users');
$this->db->where('email', $email); $this->db->where('email', $email);
...@@ -57,9 +59,9 @@ class Auth_model extends CI_Model { ...@@ -57,9 +59,9 @@ class Auth_model extends CI_Model {
public function updateEmail() public function updateEmail()
{ {
$new_email = $this->input->post('new_email'); $new_email = $this->security->xss_clean($this->input->post('new_email'));
$new_name = $this->input->post('new_name'); $new_name = $this->security->xss_clean($this->input->post('new_name'));
$new_surname = $this->input->post('new_surname'); $new_surname = $this->security->xss_clean($this->input->post('new_surname'));
$session_email = $this->session->userdata('email'); $session_email = $this->session->userdata('email');
$user = $this->db->get_where('users', array('email' => $session_email)); $user = $this->db->get_where('users', array('email' => $session_email));
......
...@@ -35,8 +35,8 @@ class Register_model extends CI_Model { ...@@ -35,8 +35,8 @@ class Register_model extends CI_Model {
$config = array( $config = array(
'protocol'=>'smtp', 'protocol'=>'smtp',
'smtp_host'=>'ssl://smtp.googlemail.com', 'smtp_host'=>'ssl://smtp.googlemail.com',
'smtp_user'=>'tetiankayaremko@gmail.com', 'smtp_user'=>'tetianayaremko@gmail.com',
'smtp_pass'=>'tetiana_yaremko1995', 'smtp_pass'=>'55aKenuh',
'smtp_port'=> '465', 'smtp_port'=> '465',
'mailtype'=> 'html', 'mailtype'=> 'html',
'charset'=> 'iso-8859-1', 'charset'=> 'iso-8859-1',
......
...@@ -35,19 +35,20 @@ ...@@ -35,19 +35,20 @@
<h3>Existing customer</h3> <h3>Existing customer</h3>
<?php $error = $this->session->flashdata("error")?> <?php $error = $this->session->flashdata("error")?>
<div class="alert alert-<?php echo $error ? 'warning' : 'info' ?> alert-dismissible" role="alert"> <div class="alert alert-<?php echo $error ? 'warning' : 'info' ?> alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<?php echo $error ? $error : 'Enter your username and password' ?>
</div>
<?php echo $error ? $error : 'Enter your username and password' ?>
</div>
<?php echo form_open(); ?> <?php echo form_open(); ?>
<?php $error =form_error("email", "<p class='text-danger'>", '</p>');?> <?php $error =form_error("email", "<small class='text-danger'>", '</small>');?>
<div class="form-group <?php echo $error ? 'has-error' : '' ?>"> <div class="form-group <?php echo $error ? 'has-error' : '' ?>">
<label for="email">Email</label> <label for="email">Email</label>
<input type="email" value="<?php echo set_value("email") ?>" name="email"/> <input type="email" value="<?php echo set_value("email") ?>" name="email"/>
<div class="input-error"> <?php echo $error; ?> </div> <div class="input-error"> <?php echo $error; ?> </div>
</div> </div>
<?php $error =form_error("password", "<p class='text-danger'>", '</p>');?> <?php $error =form_error("password", "<small class='text-danger'>", '</small>');?>
<div class="form-group"> <div class="form-group">
<label for="password">Password</label> <label for="password">Password</label>
<input type="password" name="password"/> <input type="password" name="password"/>
......
...@@ -97,11 +97,13 @@ ...@@ -97,11 +97,13 @@
<?php if($item->status=='sold'): ?> <?php if($item->status=='sold'): ?>
<p class="sold-btn">Sold out</p> <p class="sold-btn">Sold out</p>
<?php else: ?> <?php else: ?>
<button class="cart-btn" id="<?php echo $item->id;?>" data-butnid="<?php echo $item->id;?>" data-productid="<?php echo $item->id;?>" data-productartist="<?php echo $item->artist;?>"
data-producttitle="<?php echo $item->title;?>" data-productprice="<?php echo $item->price;?>" data-productimage="<?php echo $item->image;?>"> <button class="cart-btn" id="<?php echo $item->id;?>" data-butnid="<?php echo $item->id;?>" data-productid="<?php echo $item->id;?>" data-productartist="<?php echo $item->artist;?>"
data-producttitle="<?php echo $item->title;?>" data-productprice="<?php echo $item->price;?>" data-productimage="<?php echo $item->image;?>" value="add to cart" >
<i class="fa fa-shopping-cart"></i> <i class="fa fa-shopping-cart"></i>
Add to cart Add to cart
</button> </button>
<?php endif; ?> <?php endif; ?>
</div> </div>
...@@ -137,6 +139,7 @@ ...@@ -137,6 +139,7 @@
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
baseUrl = '<?php echo base_url(); ?>'; baseUrl = '<?php echo base_url(); ?>';
// csrf_value = '<?php echo $this->security->get_csrf_hash(); ?>';
</script> </script>
<script src="<?php echo base_url(); ?>asset/js/scrypt.js"></script> <script src="<?php echo base_url(); ?>asset/js/scrypt.js"></script>
<script src="<?php echo base_url(); ?>asset/js/jquery-3.3.1.min.js"></script> <script src="<?php echo base_url(); ?>asset/js/jquery-3.3.1.min.js"></script>
......
...@@ -31,10 +31,14 @@ $(document).ready(function() { ...@@ -31,10 +31,14 @@ $(document).ready(function() {
{ {
$('#detail-cart').html(data); $('#detail-cart').html(data);
} }
}); });
} }
$('.cart-btn').click(function () {
$('.cart-btn').click(function (event) {
var product_id = $(this).data("productid"); var product_id = $(this).data("productid");
var product_artist = $(this).data("productartist"); var product_artist = $(this).data("productartist");
var product_title = $(this).data("producttitle"); var product_title = $(this).data("producttitle");
...@@ -47,10 +51,14 @@ $(document).ready(function() { ...@@ -47,10 +51,14 @@ $(document).ready(function() {
method : "POST", method : "POST",
data : {product_id: product_id, product_artist: product_artist, product_title: product_title, product_price: product_price, quantity:quantity, image:image}, data : {product_id: product_id, product_artist: product_artist, product_title: product_title, product_price: product_price, quantity:quantity, image:image},
success: function(data){ success: function(data){
$('.cart-btn').val(data.token);
load_cart_data(); load_cart_data();
showCart(); showCart();
}, },
}); });
//el.stopImmediatePropagation();
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment