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/www.elwrky.com/application/admin/controller/Ajax.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>
// +----------------------------------------------------------------------

// +----------------------------------------------------------------------
// | 后台常用ajax
// +----------------------------------------------------------------------
namespace app\admin\controller;

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

class Ajax extends Adminbase
{
    //过滤内容的敏感词
    public function filterWord($content)
    {
        $content = $this->request->post('content');
        // 获取感词库文件路径
        $wordFilePath = ROOT_PATH . 'data/words.txt';
        $handle       = \util\SensitiveHelper::init()->setTreeByFile($wordFilePath);
        $word         = $handle->getBadWord($content);
        if ($word) {
            $this->error('内容包含违禁词!', null, $word);
        } else {
            $this->success('内容没有违禁词!');
        }
    }

    /**
     * 生成后缀图标
     */
    public function icon()
    {
        $suffix = $this->request->request("suffix");
        header('Content-type: image/svg+xml');
        $suffix = $suffix ? $suffix : "FILE";
        echo build_suffix_image($suffix);
        exit;
    }

    /**
     * 高级下拉菜单url 同模型所有栏目
     * url:/admin/ajax/category // 同模型的所有栏目  /admin/ajax/category/modelid/2 其他模型的ID
     * field:catname
     * key:id
     * pagination:true
     * page_size:10
     * multiple:true
     * max:10
     * order:id
     */

    public function category(){
        $modelid = $this->request->param('modelid/d', 0);
        $catid = $this->request->param('catid/d', 0);
        if (!$modelid){ //同步发布
            $catCache  = cache('catCache'); //从缓存中得到模型ID
            $modelid   = $catCache['modelid'];
            $catid     = $catCache['catid'];
            //相同模型并且不含当前栏目并且是终极栏目
            $wheres = 'modelid =' . $modelid .' AND child = 0 AND id <>' . $catid;
        } else {
            //关联其他模型栏目
            $wheres = 'modelid =' . $modelid .' AND child = 0';
        }
        $this->modelClass = Db::name('category');
        //如果发送的来源是Selectpage,则转发到Selectpage
        if ($this->request->request('keyField')) {
            return $this->selectpage($wheres);
        }
    }

    /**
     * 高级下拉菜单url 会员级别
     */

    public function memberGroup(){
        $wheres = '' ;
        $this->modelClass = Db::name('member_group');
        //如果发送的来源是Selectpage,则转发到Selectpage
        if ($this->request->request('keyField')) {
            return $this->selectpage($wheres);
        }
    }

    /**
     * 高级下拉菜单url 会员列表
     */

    public function member(){
        $wheres = '' ;
        $this->modelClass = Db::name('member');
        //如果发送的来源是Selectpage,则转发到Selectpage
        if ($this->request->request('keyField')) {
            return $this->selectpage($wheres);
        }
    }

    /**
     * 高级下拉菜单url 专题列表
     */

    public function special(){
        $wheres   = '';
        $onSiteId = onSiteId();
        $wheres = 'sites =' . $onSiteId;
        $this->modelClass = Db::name('special');
        if ($this->request->request('keyField')) {
            return $this->selectpage($wheres);
        }
    }

    /**
     * 高级下拉菜单url 专题列表
     */

    public function flag(){
        $wheres   = '';
        $onSiteId = onSiteId();
        $wheres   = 'sites =' . $onSiteId;
        $this->modelClass = Db::name('flag');
        if ($this->request->request('keyField')) {
            return $this->selectpage($wheres);
        }
    }

    /**
     *  获取标题拼音
     */

    public function getTitlePinyin()
    {
        $config = isset(cache("Cms_Config")['show_url_mode']) && 1 == cache("Cms_Config")['show_url_mode'];
        $title = $this->request->post("title");
        //分隔符
        $delimiter = $this->request->post("delimiter", "");
        $pinyin = new \Overtrue\Pinyin\Pinyin('Overtrue\Pinyin\MemoryFileDictLoader');
        if ($title) {
            if ($config) {
                $result = $pinyin->permalink($title, $delimiter);
                $this->success("", null, ['pinyin' => $result]);
            } else {
                $this->error();
            }
        } else {
            $this->error('标题不为能空');
        }
    }
}