HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
Upload Files
File: /www/wwwroot/cms.smpolia.com/addons/H5设计/controller/Index.php
<?php
// +----------------------------------------------------------------------
// | Yzncms [ 御宅男工作室 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2018 http://yzncms.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 御宅男 <530765310@qq.com>
// +----------------------------------------------------------------------

// +----------------------------------------------------------------------
// | api管理
// +----------------------------------------------------------------------
namespace app\diywap\controller;

use app\common\controller\Api;
use think\Db;

class Index extends Api
{

    //初始化
    protected function initialize()
    {
        parent::initialize();
    }

    /**
     * 页面数据
     *
     */
    public function getPage()
    {
        $page_id = $this->request->request('page_id/d');

        if (Db::name("diy_page")->where('status', 1)->order(['id' => 'desc'])->count() <= 0) {
            return $this->error('未定义页面');
        }
        // 页面详情
        $detail = $page_id > 0 ? Db::name("diy_page")->where('id', $page_id)->find() : Db::name("diy_page")->where('page_type', 1)->find();
        if (!$detail) {
            return $this->error('页面错误');
        }
        // 页面diy元素
        return $this->success('', json_decode($detail['page_data']));
    }

    /**
     * 表单字段获取
     */
    public function diyform()
    {
        $id   = $this->request->param('id');
        $form = Db::name('model')->where(['id' => $id, 'module' => 'formguide'])->find();
        if (!$form) {
            $this->error('表单不存在');
        }
        $fields = Db::name('model_field')
            ->where('modelid', $id)
            ->order('listorder DESC,id DESC')->select();
        foreach ($fields as $k => &$v) {
            $v['setting'] = unserialize($v['setting']);
        }
        $this->success('获取成功', [
            'from'   => $form,
            'fields' => $fields,
        ]);
    }

    //表单提交
    public function post()
    {
        $id   = $this->request->param('id');
        $data = $this->request->post();
        $form = Db::name('model')->where(['id' => $id, 'module' => 'formguide'])->find();
        if (!$form) {
            $this->error('表单不存在');
        }
        $setting = unserialize($form['setting']);
        //是否允许同一IP多次提交
        if ((int) $setting['allowmultisubmit'] == 0) {
            $ip    = $this->request->ip();
            $count = Db::name($form['tablename'])->where("ip", $ip)->count();
            if ($count) {
                $this->error('你已经提交过了!');
            }
        }
        //提交间隔
        if ($setting['interval']) {
            $formguide = cookie('formguide_' . $id);
            if ($formguide) {
                $this->error("操作过快,请歇息后再次提交!");
            }
        }
        try {
            (new \app\formguide\model\Formguide)->addFormguideData($id, $data);
        } catch (\Exception $ex) {
            $this->error($ex->getMessage());
        }
        if ($setting['interval']) {
            cookie('formguide_' . $id, 1, $setting['interval']);
        }
        //发送邮件
        if ($setting['mails']) {
            $ems['email'] = $this->setting['mails'];
            $ems['title'] = "[" . $form['name'] . "]表单消息提醒!";
            $ems['msg']   = "刚刚有人在[" . $form['name'] . "]中提交了新的信息,请进入后台查看!";
            $result       = hook('ems_notice', $ems, true, true);
        }
        $this->success('提交成功!');
    }

}