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//cs.wgegeghx.com/application/formguide/controller/Info.php
<?php

// | 表单信息管理

namespace app\formguide\controller;

use app\common\controller\Adminbase;
use app\formguide\model\Formguide as Formguide_Model;
use think\Db;

class Info extends AdminBase
{
    /**
     * @var Formguide_Model
     */
    private $Formguide_Model;

    protected function initialize()
    {
        parent::initialize();
        $this->Formguide_Model = new Formguide_Model;
    }

    //信息列表
    public function index()
    {
        $formid = $this->request->param('formid/d', 0);
        if ($this->request->isAjax()) {
            $modelCache = cache("Model");
            $tableName = $modelCache[$formid]['tablename'];

            $this->modelClass = Db::name($tableName);
            list($page, $limit, $where) = $this->buildTableParames();

            $total = Db::name($tableName)->where($where)->count();
            $_list = Db::name($tableName)->where($where)->page($page, $limit)->order(['id' => 'desc'])->withAttr('inputtime', function ($value, $data) {
                return date('Y-m-d H:i:s', $value);
            })->select();
            
            foreach($_list as $k=>$v){
                if(array_key_exists("mid", $v)){
                    $_list[$k]['mname'] = db("member")->WHERE('id', $v['mid'])->value('username');
                }
                if(array_key_exists("courseid", $v)){
                    $_list[$k]['courseName'] = db("courselist")->WHERE('id', $v['courseid'])->value('title');
                }
            }
            
            $result = array("code" => 0, "count" => $total, "data" => $_list);
            return json($result);
        } else {
            $fieldList = Db::name('ModelField')->where('modelid', $formid)->where('status', 1)->select();
            $this->assign('formStr', $this->getTableList($fieldList));
            $this->assign('formid', $formid);
            return $this->fetch();
        }

    }

    //删除信息
    public function del()
    {
        $formid = $this->request->param('formid/d', 0);
        $ids = $this->request->param('ids/a', null);
        if (empty($ids) || !$formid) {
            $this->error('参数错误!');
        }
        if (!is_array($ids)) {
            $ids = array(0 => $ids);
        }
        try {
            foreach ($ids as $id) {
                $this->Formguide_Model->deleteModelData($formid, $id);
            }
        } catch (\Exception $ex) {
            $this->error($ex->getMessage());
        }
        $this->success('删除成功!');
    }

    //信息查看
    public function public_view()
    {
        $id = $this->request->param('id', 0);
        $formid = $this->request->param('formid', 0);
        $fieldList = $this->Formguide_Model->getFieldInfo($formid, $id);
        $this->assign([
            'fieldList' => $fieldList,
            'id' =>$id
        ]);
        return $this->fetch();
    }

    public function saveView(){
        $id = input("id");
        $data = input("post.");
        db('form_id')->WHERE('id', $id)->update($data);
    }

    public function getTableList($fieldList = [])
    {
        $htmlstr = "";
        foreach ($fieldList as $k => $v) {
            if ($v['type'] == "datetime") {
                $htmlstr .= "{ field: '" . $v['name'] . "',title: '" . $v['title'] . "',templet: function(d){ return layui.formatDateTime(d." . $v['name'] . ") } },\n";
            } elseif ($v['type'] != "image" && $v['type'] != "images" && $v['type'] != "file" && $v['type'] != "files") {
                $htmlstr .= "{ field: '" . $v['name'] . "', align: 'left',title: '" . $v['title'] . "' },\n";
            }
        }
        return $htmlstr;
    }

}