Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
tetiana yaremko
/
web-app-group2
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
e34c3533
authored
Apr 23, 2020
by
tetiana yaremko
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
ready to deploy
parent
a72ced74
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
61 additions
and
25 deletions
application/config/config.php
application/config/database.php
application/config/routes.php
application/controllers/Admin.php
application/controllers/Auth.php
application/controllers/Cart.php
application/hooks/acl.php
application/models/Auth_model.php
application/models/Register_model.php
application/views/login1.php
application/views/templates/home_t.php
asset/js/scrypt.js
application/config/config.php
View file @
e34c3533
...
@@ -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'
);
/*
/*
|--------------------------------------------------------------------------
|--------------------------------------------------------------------------
...
...
application/config/database.php
View file @
e34c3533
...
@@ -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'
=>
''
,
...
...
application/config/routes.php
View file @
e34c3533
...
@@ -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
;
application/controllers/Admin.php
View file @
e34c3533
...
@@ -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'
);
...
...
application/controllers/Auth.php
View file @
e34c3533
<?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
();
...
...
application/controllers/Cart.php
View file @
e34c3533
...
@@ -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
();
...
...
application/hooks/acl.php
View file @
e34c3533
...
@@ -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'
][
'reset
P
assword'
]
=
true
;
$allowAll
[
'auth'
][
'reset
p
assword'
]
=
true
;
$allowAll
[
'auth'
][
'change
P
assword'
]
=
true
;
$allowAll
[
'auth'
][
'change
p
assword'
]
=
true
;
$allowAll
[
'auth'
][
'verify'
]
=
true
;
$allowAll
[
'auth'
][
'verify'
]
=
true
;
$allowAll
[
'home'
][
'products'
]
=
true
;
$allowAll
[
'home'
][
'products'
]
=
true
;
...
...
application/models/Auth_model.php
View file @
e34c3533
...
@@ -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
));
...
...
application/models/Register_model.php
View file @
e34c3533
...
@@ -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'
=>
'tetian
k
ayaremko@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'
,
...
...
application/views/login1.php
View file @
e34c3533
...
@@ -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"
>
×
</span></button>
<button
type=
"button"
class=
"close"
data-dismiss=
"alert"
aria-label=
"Close"
><span
aria-hidden=
"true"
>
×
</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"
/>
...
...
application/views/templates/home_t.php
View file @
e34c3533
...
@@ -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>
...
...
asset/js/scrypt.js
View file @
e34c3533
...
@@ -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();
})
})
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment