Toggle navigation
Toggle navigation
This project
Loading...
Sign in
wangshusheng
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to dashboard
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
周少峰
9 years ago
Commit
900c574f9c7ff6497f654bde62df960579a81680
1 parent
ce1b10a8
address , coupon
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
90 additions
and
6 deletions
library/WebPlugin/Encryption.php
yohobuy/www.yohobuy.com/application/controllers/Coupon.php
yohobuy/www.yohobuy.com/application/models/Index/Coupon.php
yohobuy/www.yohobuy.com/application/models/Shopping/Cart.php
yohobuy/www.yohobuy.com/application/modules/Cart/controllers/Index.php
library/WebPlugin/Encryption.php
0 → 100644
View file @
900c574
<?php
/**
* 加密解密
*/
namespace
WebPlugin
;
class
Encryption
{
// 密钥
private
static
$key
=
'123'
;
// 加密
public
static
function
encrypt
(
$data
)
{
$char
=
''
;
$str
=
''
;
$key
=
md5
(
self
::
$key
);
$x
=
0
;
$len
=
strlen
(
$data
);
$l
=
strlen
(
$key
);
for
(
$i
=
0
;
$i
<
$len
;
$i
++
)
{
if
(
$x
==
$l
)
{
$x
=
0
;
}
$char
.=
$key
{
$x
};
$x
++
;
}
for
(
$i
=
0
;
$i
<
$len
;
$i
++
)
{
$str
.=
chr
(
ord
(
$data
{
$i
})
+
(
ord
(
$char
{
$i
}))
%
256
);
}
return
base64_encode
(
$str
);
}
//解密
public
static
function
decrypt
(
$data
)
{
$char
=
''
;
$str
=
''
;
$key
=
md5
(
self
::
$key
);
$x
=
0
;
$data
=
base64_decode
(
$data
);
$len
=
strlen
(
$data
);
$l
=
strlen
(
$key
);
for
(
$i
=
0
;
$i
<
$len
;
$i
++
)
{
if
(
$x
==
$l
)
{
$x
=
+
0
;
}
$char
.=
substr
(
$key
,
$x
,
1
);
$x
++
;
}
for
(
$i
=
0
;
$i
<
$len
;
$i
++
)
{
if
(
ord
(
substr
(
$data
,
$i
,
1
))
<
ord
(
substr
(
$char
,
$i
,
1
)))
{
$str
.=
chr
((
ord
(
substr
(
$data
,
$i
,
1
))
+
256
)
-
ord
(
substr
(
$char
,
$i
,
1
)));
}
else
{
$str
.=
chr
(
ord
(
substr
(
$data
,
$i
,
1
))
-
ord
(
substr
(
$char
,
$i
,
1
)));
}
}
return
$str
;
}
}
\ No newline at end of file
...
...
yohobuy/www.yohobuy.com/application/controllers/Coupon.php
View file @
900c574
...
...
@@ -2,6 +2,7 @@
use
Action\WebAction
;
use
WebPlugin\Helpers
;
use
WebPlugin\Encryption
;
use
Index\HomeModel
;
use
Index\CouponModel
;
use
LibModels\Web\Home\CouponData
;
...
...
@@ -29,7 +30,7 @@ class CouponController extends WebAction
* 领券页面控制器
*/
public
function
indexAction
()
{
{
$channel
=
Helpers
::
getChannelNameByCookie
();
//领券频道头部
$this
->
setWebNavHeader
(
$channel
);
...
...
@@ -52,6 +53,11 @@ class CouponController extends WebAction
break
;
}
$couponId
=
$this
->
get
(
'id'
,
''
);
if
(
empty
(
$couponId
))
{
break
;
}
//解密
$couponId
=
Encryption
::
decrypt
(
$couponId
);
$uid
=
$this
->
getUid
();
if
(
!
$uid
)
{
$playUrl
=
Helpers
::
url
(
'/coupon/index'
);
...
...
yohobuy/www.yohobuy.com/application/models/Index/Coupon.php
View file @
900c574
...
...
@@ -4,6 +4,7 @@ namespace Index;
use
WebPlugin\Helpers
;
use
WebPlugin\Images
;
use
WebPlugin\Encryption
;
use
Index\HomeModel
;
use
LibModels\Web\Home\CouponData
;
...
...
@@ -60,7 +61,7 @@ class CouponModel
);
foreach
(
$couponlistval
[
'data'
]
as
$couponskey
=>
$couponsval
)
{
$result
[
'categories'
][
$i
][
'coupons'
][
$couponskey
]
=
array
(
'id'
=>
$couponsval
[
'couponID'
],
//
优惠券号
'id'
=>
Encryption
::
encrypt
(
$couponsval
[
'couponID'
]),
//加密
优惠券号
'img'
=>
Images
::
getForceSourceUrl
(
$couponsval
[
'image'
][
'src'
]),
//优惠券图片
'url'
=>
Helpers
::
getUrlSafe
(
$couponsval
[
'image'
][
'url'
])
//去逛逛链接
);
...
...
yohobuy/www.yohobuy.com/application/models/Shopping/Cart.php
View file @
900c574
...
...
@@ -12,6 +12,7 @@ use WebPlugin\Images;
use
Configs\WebCacheConfig
;
use
Hood\Core\Security\AuthCode
;
use
WebPlugin\UdpLog
;
use
WebPlugin\Encryption
;
use
Configs\ChannelConfig
;
/**
...
...
@@ -980,7 +981,7 @@ class CartModel
$mobile
=
substr
(
$mobile
,
0
,
3
)
.
'****'
.
substr
(
$mobile
,
7
);
$build
=
array
();
$build
[
'id'
]
=
$value
[
'address_id'
]
;
$build
[
'id'
]
=
Encryption
::
encrypt
(
$value
[
'address_id'
])
;
$build
[
'user'
]
=
$value
[
'consignee'
];
$build
[
'address'
]
=
$value
[
'area'
]
.
$value
[
'address'
]
.
' '
.
$value
[
'zip_code'
]
.
' '
.
$mobile
.
' '
.
$value
[
'phone'
];
$build
[
'checked'
]
=
$value
[
'is_default'
]
===
'Y'
;
...
...
yohobuy/www.yohobuy.com/application/modules/Cart/controllers/Index.php
View file @
900c574
...
...
@@ -4,6 +4,7 @@ use Action\WebAction;
use
WebPlugin\Helpers
;
use
Shopping\CartModel
;
use
WebPlugin\UdpLog
;
use
WebPlugin\Encryption
;
/**
* 购物车相关的控制器
...
...
@@ -269,6 +270,8 @@ class IndexController extends WebAction
if
(
$this
->
isAjax
())
{
$uid
=
$this
->
getUid
(
false
);
$addressId
=
$this
->
post
(
'id'
);
//解密
$addressId
=
intval
(
Encryption
::
decrypt
(
$addressId
));
$result
=
CartModel
::
setDefaultAddress
(
$uid
,
$addressId
);
}
...
...
@@ -295,7 +298,9 @@ class IndexController extends WebAction
if
(
$this
->
isAjax
())
{
$uid
=
$this
->
getUid
(
false
);
$id
=
$this
->
post
(
'id'
,
null
);
$id
=
$this
->
post
(
'id'
,
null
);
//TODO
//解密
$id
=
intval
(
Encryption
::
decrypt
(
$id
));
$address
=
$this
->
post
(
'address'
,
''
);
$areaCode
=
$this
->
post
(
'areaCode'
,
''
);
$consignee
=
$this
->
post
(
'consignee'
,
''
);
...
...
@@ -327,7 +332,8 @@ class IndexController extends WebAction
if
(
$this
->
isAjax
())
{
$uid
=
$this
->
getUid
(
false
);
$addressId
=
$this
->
post
(
'id'
);
$addressId
=
$this
->
post
(
'id'
);
// TODO
$addressId
=
intval
(
Encryption
::
decrypt
(
$addressId
));
$result
=
CartModel
::
delAddress
(
$uid
,
$addressId
);
}
...
...
@@ -435,7 +441,9 @@ class IndexController extends WebAction
break
;
}
$addressId
=
$this
->
post
(
'addressId'
,
null
);
$addressId
=
$this
->
post
(
'addressId'
,
null
);
//TODO
//解密
$addressId
=
intval
(
Encryption
::
decrypt
(
$addressId
));
$cartType
=
$this
->
post
(
'cartType'
,
'ordinary'
);
// 默认普通购物车
$deliveryTimeId
=
$this
->
post
(
'deliveryTimeId'
,
1
);
// 默认只工作日配送
$deliveryWayId
=
$this
->
post
(
'deliveryWayId'
,
1
);
// 默认普通快递
...
...
Please
register
or
login
to post a comment