File: /www/wwwroot//bs.kntsleep.com/system/web/feedback/feedback.class.php
<?php
/*
* Copyright (c) Huyin Information Technology Co., Ltd. All Rights Reserved.
* BOSSCMS Content Management System (https://www.bosscms.net/)
*/
defined('IS_OK') or exit('Access Forbidden');
into::basic_class('web');
class feedback extends web
{
public function form()
{
global $G;
if(isset($G['post'])){
$items = arrExist($G['post'],'items');
if(!is_numeric($items) && $items){
die();
}
$data = page::config_option($items);
$content = '';
if($data){
$G['config'] = array_merge($data, $G['config']);
}
$form = page::form($items);
if($G['config']['feedback_open']){
if($G['config']['feedback_captcha'] && (!session::get('captcha') || arrExist($G['post'],'captcha')!=session::get('captcha'))){
alert($G['config']['feedback_captcha_error']);
}
$uping = 0;
foreach($form as $v){
if($v['must']){
if(($v['style']==8 && $_FILES['params'.$v['id']]['error']!=0) || ($v['style']!=8 && !$G['post']['params'.$v['id']])){
alert($v['title'].'不能为空');
}
}
if($v['style']==8){
$uping++;
}
}
if($uping){
into::basic_class('upload');
foreach($form as $v){
if($v['style']==8 && $_FILES['params'.$v['id']]['error']==0){
upload::$maxsize = $G['config']['upload_maxsize']*1024*1024;
upload::$extension = json::decode($v['param']);
if(upload::files($_FILES['params'.$v['id']]) && upload::$path){
$img = str_replace('../../','../',upload::$path);
if(strstr($img,'/photo/')){
$G['post']['params'.$v['id']] = "<img src={$img} check width=30 height=30 />";
}else{
$G['post']['params'.$v['id']] = "<a href={$img} color=blue target=_blank>{$G['config']['download_file']}</a>";
}
}else{
alert(upload::$msg?upload::$msg:'文件上传失败');
}
}
}
}
$post = array();
foreach($form as $v){
$post['params'.$v['id']] = $str = $G['post']['params'.$v['id']];
$content .= "<tr>
<td><b>{$v['title']}</b> </td>
<td><p>".(is_array($str)?implode(' ',$str):$str)."</p></td>
</tr>";
}
if($content){
$content = '<table>'.$content.'</table>';
}
$data = array(
'param' => json::enfilter($post),
'parent' => $items,
'reply' => '',
'manager' => '0',
'ctime' => TIME,
'mtime' => 0,
'ip' => getIP(),
'display' => 0
);
$res = mysql::select_one('ctime','feedback',"ip='{$data['ip']}'",'ctime DESC,id DESC');
if($data['ctime'] - $res['ctime'] > 60){
if(mysql::insert($data, 'feedback')){
if($G['config']['feedback_mail']){
into::basic_class('mailto');
if($G['email']){
mailto::send($G['config']['feedback_recipient'],$G['config']['feedback_title'],$content);
}
}
alert($G['config']['feedback_success'], $_SERVER['HTTP_REFERER']);
}else{
alert('提交失败!');
}
}else{
alert($G['config']['feedback_quick']);
}
}else{
alert('反馈表单处于关闭状态,请启用!');
}
}
}
}
?>