Skip to content

Commit

Permalink
第一次提交
Browse files Browse the repository at this point in the history
  • Loading branch information
assimon committed Apr 17, 2018
0 parents commit e676b42
Show file tree
Hide file tree
Showing 440 changed files with 25,215 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
RewriteEngine On
RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php
Binary file added app/.DS_Store
Binary file not shown.
26 changes: 26 additions & 0 deletions app/Config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace YS\app;
class Config{
static function db(){
$db = require 'db.php';
return $db;
}

static function systemInfo()
{
return [
'version' => 'v1.0.bate',
];
}

public function getMailTpl(){
return array(
'卡密发送','管理员通知'
);
}



}
?>
104 changes: 104 additions & 0 deletions app/common.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php
/**
* 求两个日期之间相差的天数
* (针对1970年1月1日之后,求之前可以采用泰勒公式)
* @param string $day1
* @param string $day2
* @return number
*/
function diffBetweenTwoDays ($day1, $day2)
{
$second1 = strtotime($day1);
$second2 = strtotime($day2);

if ($second1 < $second2) {
$tmp = $second2;
$second2 = $second1;
$second1 = $tmp;
}
return ($second1 - $second2) / 86400;
}

/**消息返回
* @param int $status
* @param $data
* @param string $msg
*/
function resMsg($status = 0, $data = null,$msg='')
{
echo json_encode(['status' => $status, 'data' => $data, 'msg' => $msg]);
exit();
}

/**
* 除去数组中的空值和签名参数
* @param $para 签名参数组
* return 去掉空值与签名参数后的新签名参数组
*/
function paraFilter($para) {
$para_filter = array();
while (list ($key, $val) = each ($para)) {
if($key == "sign" || $key == "sign_type" || $val == "")continue;
else $para_filter[$key] = $para[$key];
}
return $para_filter;
}

/**
* 对数组排序
* @param $para 排序前的数组
* return 排序后的数组
*/
function argSort($para) {
ksort($para);
reset($para);
return $para;
}

/**
* 把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
* @param $para 需要拼接的数组
* return 拼接完成以后的字符串
*/
function createLinkstring($para) {
$arg = "";
while (list ($key, $val) = each ($para)) {
$arg.=$key."=".$val."&";
}
//去掉最后一个&字符
$arg = substr($arg,0,count($arg)-2);
//如果存在转义字符,那么去掉转义
if(get_magic_quotes_gpc()){
$arg = stripslashes($arg);
}
return $arg;
}

/**
* 生成md5签名字符串
* @param $prestr 需要签名的字符串
* @param $key 私钥
* return 签名结果
*/
function md5Sign($prestr, $key) {
$prestr = $prestr . $key;
return md5($prestr);
}

/**
* 验证签名
* @param $prestr 需要签名的字符串
* @param $sign 签名结果
* @param $key 私钥
* return 签名结果
*/
function md5Verify($prestr, $sign, $key) {
$prestr = $prestr . $key;
$mysgin = md5($prestr);
if($mysgin == $sign) {
return true;
}
else {
return false;
}
}
85 changes: 85 additions & 0 deletions app/controller/chaka.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php

namespace YS\app\controller;

use YS\app\libs\Controller;

class chaka extends Controller
{
public function index()
{
$this->put('chaka.php');
}

/**
* 查询订单
*/
public function orderList()
{
$data = $this->getReqdata($_POST);
$cons = '';
$consArr = [];
$cons .= $cons ? ' and ' : '';
$cons .= 'otype = ?';
$consArr[] = $data['otype'];
if ($data['otype'] == 0) {
if (trim($data['otype']) == "") resMsg(0, null, '查询密码不能为空');
$cons .= ' and chapwd = ?';
$consArr[] = $data['chapwd'];
}
$cons .= ' and account = ?';
$consArr[] = $data['account'];
$cons .= ' and status <> 0 ';
$orders = $this->model()->select()->from('orders')->where(array('fields' => $cons, 'values' => $consArr))->orderby('ctime desc')->fetchAll();
if (!$orders) resMsg(0, null, '没有查询到订单记录,请检查密码是否正确或是否支付成功!');
$html = '';
$orderType = ['自动发卡', '手工订单'];
$orderStatus = [
1 => "<span class=\"am-badge am-badge-warning am-radius\">待处理</span>",
2 => " <span class=\"am-badge am-badge-primary am-radius\">已处理</span>",
3 => " <span class=\"am-badge am-badge-success am-radius\">已完成</span>",
4 => " <span class=\"am-badge am-badge-danger am-radius\">处理失败</span>",
5 => " <span class=\"am-badge am-badge-danger am-radius\">发卡失败</span>",
];


foreach ($orders as $v) {
$html .= "<tr>
<td>" . $v['orderid'] . "</td>
<td>" . $v['oname'] . "</td>
<td>
<span class=\"am-badge am-badge-success am-radius\">" . $orderType[$v['otype']] . "</span>
</td>
<td class=\"am-hide-sm-only\">" . $v['onum'] . "</td>
<td class=\"am-hide-sm-only\">" . $v['omoney'] . "</td>
<td class=\"am-hide-sm-only\">" . $v['cmoney'] . "</td>
<td class=\"am-hide-sm-only\">" . $v['account'] . "</td>
<td>
<span class=\"am-badge am-badge-success am-radius\">" . $v['paytype'] . "</span>
</td>
<td>" . $orderStatus[$v['status']] . "</td>
<td class=\"am-hide-sm-only\">" . date('Y-m-d H:i', $v['ctime']) . "</td>
<td>
<div class=\"am-btn-toolbar\">
<div class=\"am-btn-group am-btn-group-xs\">
<button onclick=\"orderInfo('" . $v['orderid'] . "')\"
class=\"am-btn am-btn-default \"><span class=\"am-icon-eye\"></span>订单详情
</button>
</div>
</div>
</td>
</tr>";
}
resMsg(1, $html);

}

public function orderInfo()
{
$id = $this->req->post('id') ? $this->req->post('id') : 0;
$data = $this->model()->select()->from('orders')->where(array('fields' => 'orderid=?', 'values' => array($id)))->fetchRow();
if (!$data) resMsg(0, null, '订单不存在');
resMsg(1, $data, 'ok');
}
}
38 changes: 38 additions & 0 deletions app/controller/chkcode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php
namespace YS\app\controller;

/**验证码生成
* Class chkcode
* @package YS\app\controller
*/
class chkcode
{
function index()
{
$randCode = '';
$chars = '23456789';
for ($i = 0; $i < 5; $i++) {
$randCode .= substr($chars, mt_rand(0, strlen($chars) - 1), 1);
}
$_SESSION['chkcode'] = strtolower($randCode);
$img = imagecreate(70, 22);
$bgColor = isset($_GET['mode']) && $_GET['mode'] == 't' ? imagecolorallocate($img, 245, 245, 245) : imagecolorallocate($img, 255, 255, 255);
$pixColor = imagecolorallocate($img, mt_rand(30, 180), mt_rand(10, 100), mt_rand(40, 250));
for ($i = 0; $i < 5; $i++) {
$x = $i * 13 + mt_rand(0, 4) - 2;
$y = mt_rand(0, 3);
$text_color = imagecolorallocate($img, mt_rand(30, 180), mt_rand(10, 100), mt_rand(40, 250));
imagechar($img, 5, $x + 5, $y + 3, $randCode[$i], $text_color);
}
for ($j = 0; $j < 60; $j++) {
$x = mt_rand(0, 70);
$y = mt_rand(0, 22);
imagesetpixel($img, $x, $y, $pixColor);
}
ob_clean();
header('Content-Type: image/jpeg');
imagejpeg($img);
imagedestroy($img);
}
}
?>
Loading

0 comments on commit e676b42

Please sign in to comment.