文件
mashangyoujiu/Application/NotifyApi/Controller/SystemAddonsController.class.php

60 行
1.7 KiB
PHP
可执行文件

<?php
namespace NotifyApi\Controller;
use Common\Model\RetailPlugModel;
use Think\Controller;
//[1.5.22]
/**
* 付费插件处理
* Class SystemAddonsController
* @package NotifyApi\Controller
*/
class SystemAddonsController extends Controller
{
/**
* 购买插件回调
*/
public function buyNotify()
{
$post = I('post.');
file_put_contents('./buy_plug_log.txt', date('Y-m-d H:i:s') . ' ' . json_encode($post) . "\r\n", FILE_APPEND);
$key = C('ADDONS_BUY_KEY');
$postSign = $post['sign'];
unset($post['sign']);
$sign = createSign($post, $key); //生成签名
if ($sign == $postSign) {
//验签成功 往插件表里面插入一条数据
$PlugModel = new RetailPlugModel();
$plug = $PlugModel->getFind(array('identification' => $post['identification']));
if (!empty($plug)) {
echo 'the plug-in already exists';
exit;
}
$item = array(
'plug_name' => $post['name'],
'icon_url' => $post['img'],
'information' => $post['brief_introduction'],
'identification' => $post['identification'],
'private_key' => $post['key'],
'version' => $post['version'],
'addtime' => time(),
'origin_type' => 2,
'is_install' => 0,
'class_id' => 8,
'type' => 1,
'status' => 1,
);
$add = $PlugModel->addOrder($item);
if ($add) {
echo 'success';
} else {
echo 'insert fail';
}
} else {
echo 'sign fail';
}
}
}