数据库备份

删除多余工具
This commit is contained in:
2016-07-02 10:42:57 +08:00
parent 53cdded607
commit bc9c6c7401
7 changed files with 5 additions and 771 deletions

View File

@@ -17,6 +17,9 @@
<table class="table table-striped">
<thead>
<tr>
<th width="60">
<input class="check-all" type="checkbox" value="">
</th>
<th width="200">备份名称</th>
<th width="80">卷数</th>
<th width="80">压缩</th>
@@ -29,6 +32,7 @@
<tbody>
{volist name="list" id="data"}
<tr>
<td><input class="ids" type="checkbox" name="tables[]"></td>
<td>{$data.time|date='Ymd-His',###}</td>
<td>{$data.part}</td>
<td>{$data.compress}</td>

View File

@@ -1,114 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace com;
class Cart{
private $goods = 'book';
private $items = array();
public function __construct(){
$this->items = session('sent_cart') ? session('sent_cart') : array();
}
/**
* 添加购物车
* @param integer $id 商品ID标识
* @param integer $num 添加的数量
*/
public function addItem($id,$num=1) {
if ($this->hasItem($id)) {
$this->incNum($id,$num);
return;
}
$this->items[$id] = $num;
session('sent_cart', $this->items);
}
/**
* 判断是否有某个商品
* @param integer $id 商品ID标识
* @return boolean
*/
protected function hasItem($id) {
return isset($this->items[$id]);
}
/**
* 删除商品
* @param integer $id 商品ID标识
*/
public function delItem($id) {
unset($this->items[$id]);
session('sent_cart', $this->items);
}
public function modNum($id,$num=1) {
if (!$this->hasItem($id)) {
return false;
}
$this->items[$id] = $num;
session('sent_cart', $this->items);
}
public function incNum($id,$num=1) {
if ($this->hasItem($id)) {
$this->items[$id] += $num;
}
session('sent_cart', $this->items);
}
public function decNum($id,$num=1) {
if ($this->hasItem($id)) {
$this->items[$id] -= $num;
}
if ($this->items[$id] <1) {
$this->delItem($id);
}
session('sent_cart', $this->items);
}
public function getCount() {
return count($this->items);
}
public function getNum(){
if ($this->getCount() == 0) {
return 0;
}
$sum = 0;
foreach ($this->items as $item) {
$sum += $item;
}
return $sum;
}
public function all(){
$list = array();
foreach ($this->items as $key => $value) {
$goods = \think\Db::name($this->goods)->where(array('id'=>$key))->find();
$list[] = array(
'id' => $goods['id'],
'name' => $goods['book_name'],
'price' => $goods['price'],
'cover_id' => $goods['cover_id'],
'price_count' => $value*$goods['price'],
'num' => $value
);
}
return $list;
}
public function clear() {
$this->items = array();
session('sent_cart', $this->items);
}
}

View File

@@ -207,6 +207,6 @@ class Database{
* 析构方法,用于关闭文件资源
*/
public function __destruct(){
//$this->config['compress'] ? @gzclose($this->fp) : @fclose($this->fp);
$this->config['compress'] ? @gzclose($this->fp) : @fclose($this->fp);
}
}

View File

@@ -1,80 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace com;
class Pay{
/**
* 支付驱动实例
* @var Object
*/
private $payer;
/**
* 配置参数
* @var type
*/
private $config;
public function __construct($driver) {
//获取配置
$this->getConfig($driver);
/* 配置 */
$pos = strrpos($driver, '\\');
$pos = $pos === false ? 0 : $pos + 1;
$apitype = strtolower(substr($driver, $pos));
$this->config['notify_url'] = url('user/pay/notify',array('apitype'=>$apitype), false, true);
$this->config['return_url'] = url("user/pay/returnback", array('apitype' => $apitype, 'method' => 'return'), false, true);
$this->config['pey_type'] = $driver;
/* 设置支付驱动 */
$class = strpos($driver, '\\') ? $driver : 'com\\pay\\driver\\' . ucfirst(strtolower($driver));
$this->setDriver($class, $this->config);
}
/**
* 支付
* @return boolean
*/
public function pay(pay\Input $input){
return $this->payer->pay($input);
}
/**
* 获取配置
* @return array
*/
public function getConfig($driver){
$config = \think\Config::load(APP_PATH . 'pay.php');
$this->config = $config[$driver];
}
/**
* 设置支付驱动
* @param string $class 驱动类名称
*/
private function setDriver($class, $config) {
$this->payer = new $class($config);
if (!$this->payer) {
throw new \think\Exception("不存在支付驱动:{$class}");
}
}
public function __call($method, $arguments) {
if (method_exists($this, $method)) {
return call_user_func_array(array(&$this, $method), $arguments);
} elseif (!empty($this->payer) && $this->payer instanceof Pay\Pay && method_exists($this->payer, $method)) {
return call_user_func_array(array(&$this->payer, $method), $arguments);
}
}
}

View File

@@ -1,176 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace com\pay;
class Input{
protected $_orderNo;
protected $_fee;
protected $_title;
protected $_body;
protected $_callback;
protected $_url;
protected $_uid;
protected $_bank;
protected $_param;
/**
* 设置订单号
* @param type $order_no
* @return \Think\Pay\PayVo
*/
public function setOrderNo($order_no) {
$this->_orderNo = $order_no;
return $this;
}
/**
* 设置商品价格
* @param type $fee
* @return \Think\Pay\PayVo
*/
public function setFee($fee) {
$this->_fee = $fee;
return $this;
}
/**
* 设置商品名称
* @param type $title
* @return \Think\Pay\PayVo
*/
public function setTitle($title) {
$this->_title = $title;
return $this;
}
/**
* 设置商品描述
* @param type $body
* @return \Think\Pay\PayVo
*/
public function setBody($body) {
$this->_body = $body;
return $this;
}
/**
* 设置支付完成后的后续操作接口
* @param type $callback
* @return \Think\Pay\PayVo
*/
public function setCallback($callback) {
$this->_callback = $callback;
return $this;
}
/**
* 设置支付完成后的跳转地址
* @param type $url
* @return \Think\Pay\PayVo
*/
public function setUrl($url) {
$this->_url = $url;
return $this;
}
/**
* 设置订单的额外参数
* @param type $param
* @return \Think\Pay\PayVo
*/
public function setParam($param) {
$this->_param = $param;
return $this;
}
/**
* 设置订单的用户ID
* @param type $param
* @return \Think\Pay\PayVo
*/
public function setUid($uid) {
$this->_uid = $uid;
return $this;
}
public function setBank($bank){
$this->_bank = $bank;
return $this;
}
/**
* 获取订单号
* @return type
*/
public function getOrderNo() {
return $this->_orderNo;
}
/**
* 获取商品价格
* @return type
*/
public function getFee() {
return $this->_fee;
}
/**
* 获取商品名称
* @return type
*/
public function getTitle() {
return $this->_title;
}
/**
* 获取支付完成后的后续操作接口
* @return type
*/
public function getCallback() {
return $this->_callback;
}
/**
* 获取支付完成后的跳转地址
* @return type
*/
public function getUrl() {
return $this->_url;
}
/**
* 获取商品描述
* @return type
*/
public function getBody() {
return $this->_body;
}
/**
* 获取订单的额外参数
* @return type
*/
public function getParam() {
return $this->_param;
}
/**
* 获取用户UID
* @return type
*/
public function getUid() {
return $this->_uid;
}
public function getBank(){
return $this->_bank;
}
}

View File

@@ -1,260 +0,0 @@
<?php
// +----------------------------------------------------------------------
// | SentCMS [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.tensent.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: molong <molong@tensent.cn> <http://www.tensent.cn>
// +----------------------------------------------------------------------
namespace com\pay;
abstract class Pay extends \think\Controller{
protected $config;
protected $info;
public function __construct($config) {
parent::__construct();
$this->config = array_merge($this->config, $config);
}
/**
* 配置检查
* @return boolean
*/
public function check() {
return true;
}
/**
* 验证通过后获取订单信息
* @return type
*/
public function getInfo() {
return $this->info;
}
/**
* 生成订单号
* 可根据自身的业务需求更改
*/
public function createOrderNo() {
$year_code = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J');
return $year_code[intval(date('Y')) - 2010] .
strtoupper(dechex(date('m'))) . date('d') .
substr(time(), -5) . substr(microtime(), 2, 5) . sprintf('d', rand(0, 99));
}
/**
* 建立提交表单
*/
abstract public function pay(\com\pay\Input $input);
/**
* 构造表单
*/
protected function _buildForm($params, $gateway,$is_submit=true, $method = 'post') {
$sHtml = "<meta http-equiv='content-type' content='text/html; charset=utf-8'><form id='paysubmit' name='paysubmit' action='{$gateway}' method='{$method}' target='_blank'>";
foreach ($params as $k => $v) {
$sHtml.= "<input type=\"hidden\" name=\"{$k}\" value=\"{$v}\" />\n";
}
$sHtml = $sHtml . "</form>";
$data = array(
'sHtml' => $sHtml,
'is_submit' => $is_submit,
'params' => $params,
);
return $data;
}
/**
* 支付通知验证
*/
abstract public function verifyNotify($notify);
/**
* 异步通知验证成功返回信息
*/
public function notifySuccess() {
echo "success";
}
final protected function fsockOpen($url, $limit = 0, $post = '', $cookie = '', $bysocket = FALSE, $ip = '', $timeout = 15, $block = TRUE, $encodetype = 'URLENCODE', $allowcurl = TRUE, $position = 0, $files = array()) {
$return = '';
$matches = parse_url($url);
$scheme = $matches['scheme'];
$host = $matches['host'];
$path = $matches['path'] ? $matches['path'] . ($matches['query'] ? '?' . $matches['query'] : '') : '/';
$port = !empty($matches['port']) ? $matches['port'] : ($scheme == 'http' ? '80' : '');
$boundary = $encodetype == 'URLENCODE' ? '' : random(40);
if ($post) {
if (!is_array($post)) {
parse_str($post, $post);
}
$this->formatPostkey($post, $postnew);
$post = $postnew;
}
if (function_exists('curl_init') && function_exists('curl_exec') && $allowcurl) {
$ch = curl_init();
$httpheader = array();
if ($ip) {
$httpheader[] = "Host: " . $host;
}
if ($httpheader) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
}
curl_setopt($ch, CURLOPT_URL, $scheme . '://' . ($ip ? $ip : $host) . ($port ? ':' . $port : '') . $path);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, 1);
if ($post) {
curl_setopt($ch, CURLOPT_POST, 1);
if ($encodetype == 'URLENCODE') {
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
} else {
foreach ($post as $k => $v) {
if (isset($files[$k])) {
$post[$k] = '@' . $files[$k];
}
}
foreach ($files as $k => $file) {
if (!isset($post[$k]) && file_exists($file)) {
$post[$k] = '@' . $file;
}
}
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
}
}
if ($cookie) {
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
}
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
$data = curl_exec($ch);
$status = curl_getinfo($ch);
$errno = curl_errno($ch);
curl_close($ch);
if ($errno || $status['http_code'] != 200) {
return;
} else {
$GLOBALS['filesockheader'] = substr($data, 0, $status['header_size']);
$data = substr($data, $status['header_size']);
return !$limit ? $data : substr($data, 0, $limit);
}
}
if ($post) {
if ($encodetype == 'URLENCODE') {
$data = http_build_query($post);
} else {
$data = '';
foreach ($post as $k => $v) {
$data .= "--$boundary\r\n";
$data .= 'Content-Disposition: form-data; name="' . $k . '"' . (isset($files[$k]) ? '; filename="' . basename($files[$k]) . '"; Content-Type: application/octet-stream' : '') . "\r\n\r\n";
$data .= $v . "\r\n";
}
foreach ($files as $k => $file) {
if (!isset($post[$k]) && file_exists($file)) {
if ($fp = @fopen($file, 'r')) {
$v = fread($fp, filesize($file));
fclose($fp);
$data .= "--$boundary\r\n";
$data .= 'Content-Disposition: form-data; name="' . $k . '"; filename="' . basename($file) . '"; Content-Type: application/octet-stream' . "\r\n\r\n";
$data .= $v . "\r\n";
}
}
}
$data .= "--$boundary\r\n";
}
$out = "POST $path HTTP/1.0\r\n";
$header = "Accept: */*\r\n";
$header .= "Accept-Language: zh-cn\r\n";
$header .= $encodetype == 'URLENCODE' ? "Content-Type: application/x-www-form-urlencoded\r\n" : "Content-Type: multipart/form-data; boundary=$boundary\r\n";
$header .= 'Content-Length: ' . strlen($data) . "\r\n";
$header .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
$header .= "Host: $host:$port\r\n";
$header .= "Connection: Close\r\n";
$header .= "Cache-Control: no-cache\r\n";
$header .= "Cookie: $cookie\r\n\r\n";
$out .= $header;
$out .= $data;
} else {
$out = "GET $path HTTP/1.0\r\n";
$header = "Accept: */*\r\n";
$header .= "Accept-Language: zh-cn\r\n";
$header .= "User-Agent: $_SERVER[HTTP_USER_AGENT]\r\n";
$header .= "Host: $host:$port\r\n";
$header .= "Connection: Close\r\n";
$header .= "Cookie: $cookie\r\n\r\n";
$out .= $header;
}
$fpflag = 0;
if (!$fp = @fsocketopen(($ip ? $ip : $host), $port, $errno, $errstr, $timeout)) {
$context = array(
'http' => array(
'method' => $post ? 'POST' : 'GET',
'header' => $header,
'content' => $post,
'timeout' => $timeout,
),
);
$context = stream_context_create($context);
$fp = @fopen($scheme . '://' . ($ip ? $ip : $host) . ':' . $port . $path, 'b', false, $context);
$fpflag = 1;
}
if (!$fp) {
return '';
} else {
stream_set_blocking($fp, $block);
stream_set_timeout($fp, $timeout);
@fwrite($fp, $out);
$status = stream_get_meta_data($fp);
if (!$status['timed_out']) {
while (!feof($fp) && !$fpflag) {
$header = @fgets($fp);
$headers .= $header;
if ($header && ($header == "\r\n" || $header == "\n")) {
break;
}
}
$GLOBALS['filesockheader'] = $headers;
if ($position) {
for ($i = 0; $i < $position; $i++) {
$char = fgetc($fp);
if ($char == "\n" && $oldchar != "\r") {
$i++;
}
$oldchar = $char;
}
}
if ($limit) {
$return = stream_get_contents($fp, $limit);
} else {
$return = stream_get_contents($fp);
}
}
@fclose($fp);
return $return;
}
}
final protected function formatPostkey($post, &$result, $key = '') {
foreach ($post as $k => $v) {
$_k = $key ? $key . '[' . $k . ']' : $k;
if (is_array($v)) {
$this->formatPostkey($v, $result, $_k);
} else {
$result[$_k] = $v;
}
}
}
}

View File

@@ -1,140 +0,0 @@
<?php
namespace com\pay\driver;
class Alipay extends \com\pay\Pay {
protected $gateway = 'https://mapi.alipay.com/gateway.do';
protected $verify_url = 'http://notify.alipay.com/trade/notify_query.do';
protected $config = array(
'email' => '',
'key' => '',
'partner' => '',
);
public function check() {
if (!$this->config['email'] || !$this->config['key'] || !$this->config['partner']) {
E("支付宝账号未开通!");
}
return true;
}
public function pay(\com\pay\Input $input) {
$param = array(
'service' => 'create_direct_pay_by_user',
'payment_type' => '1',
'_input_charset' => 'utf-8',
'seller_email' => $this->config['email'],
'partner' => $this->config['partner'],
'notify_url' => $this->config['notify_url'],
'return_url' => $this->config['return_url'],
'out_trade_no' => $input->getOrderNo(),
'subject' => $input->getTitle(),
'body' => $input->getBody(),
'total_fee' => $input->getFee()
);
ksort($param);
reset($param);
$arg = '';
foreach ($param as $key => $value) {
if ($value) {
$arg .= "$key=$value&";
}
}
//echo substr($arg, 0, -1) . $this->config['key'];exit();
$param['sign'] = md5(substr($arg, 0, -1) . $this->config['key']);
$param['sign_type'] = 'MD5';
$sHtml = $this->_buildForm($param, $this->gateway,true, 'get');
return $sHtml;
}
/**
* 获取返回时的签名验证结果
* @param $para_temp 通知返回来的参数数组
* @param $sign 返回的签名结果
* @return 签名验证结果
*/
protected function getSignVeryfy($param, $sign) {
//除去待签名参数数组中的空值和签名参数
$param_filter = array();
while (list ($key, $val) = each($param)) {
if ($key == "sign" || $key == "sign_type" || $val == "") {
continue;
} else {
$param_filter[$key] = $param[$key];
}
}
ksort($param_filter);
reset($param_filter);
//把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
$prestr = "";
while (list ($key, $val) = each($param_filter)) {
$prestr.=$key . "=" . $val . "&";
}
//去掉最后一个&字符
$prestr = substr($prestr, 0, -1);
$prestr = $prestr . $this->config['key'];
$mysgin = md5($prestr);
if ($mysgin == $sign) {
return true;
} else {
return false;
}
}
/**
* 针对notify_url验证消息是否是支付宝发出的合法消息
* @return 验证结果
*/
public function verifyNotify($notify) {
//生成签名结果
$isSign = $this->getSignVeryfy($notify, $notify["sign"]);
//获取支付宝远程服务器ATN结果验证是否是支付宝发来的消息
$responseTxt = 'true';
if (!empty($notify["notify_id"])) {
$responseTxt = $this->getResponse($notify["notify_id"]);
}
if (preg_match("/true$/i", $responseTxt) && $isSign) {
$this->setInfo($notify);
return $this->info;
} else {
return false;
}
}
protected function setInfo($notify) {
$info = array();
//支付状态
$info['status'] = ($notify['trade_status'] == 'TRADE_FINISHED' || $notify['trade_status'] == 'TRADE_SUCCESS') ? true : false;
$info['total_fee'] = $notify['total_fee'];
$info['out_trade_no'] = $notify['out_trade_no'];
$this->info = $info;
}
/**
* 获取远程服务器ATN结果,验证返回URL
* @param $notify_id 通知校验ID
* @return 服务器ATN结果
* 验证结果集:
* invalid命令参数不对 出现这个错误请检测返回处理中partner和key是否为空
* true 返回正确信息
* false 请检查防火墙或者是服务器阻止端口问题以及验证时间是否超过一分钟
*/
protected function getResponse($notify_id) {
$partner = $this->config['partner'];
$veryfy_url = $this->verify_url . "?partner=" . $partner . "&notify_id=" . $notify_id;
$responseTxt = $this->fsockOpen($veryfy_url);
return $responseTxt;
}
}