403Webshell
Server IP : 156.238.232.47  /  Your IP : 216.73.216.150
Web Server : nginx/1.25.3
System : Linux C202504152095410 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : www ( 1000)
PHP Version : 8.3.25
Disable Function : 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
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /www/data/wwwroot/2025_04_20_01/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/data/wwwroot/2025_04_20_01/check_shop.php
<?php
/**
 * 商城配置和字段配置检查脚本
 * 访问地址: http://www.lvyou1.com:81/check_shop.php
 */
error_reporting(E_ALL);
ini_set('display_errors', 1);

define('IS_API', true);
require_once dirname(__FILE__) . '/core/startup.php';

app()->init();

$pdo = Db::connect()->pdo;

echo "<h1>商城配置检查</h1>";
echo "<pre>";

try {
    // 1. 检查商城开关
    echo "=== 1. 检查商城开关配置 ===\n";
    $shopOpen = Db::name('users_config')
        ->where('name', 'shop_open')
        ->where('inc_type', 'shop')
        ->value('value');
    
    echo "shop_open 值: " . ($shopOpen ?: '未设置') . "\n";
    
    if (empty($shopOpen) || $shopOpen != 1) {
        echo "⚠ 商城开关未开启,需要设置 shop_open = 1\n";
        
        if (empty($shopOpen)) {
            Db::name('users_config')->insert([
                'name' => 'shop_open',
                'value' => 1,
                'inc_type' => 'shop',
                'lang' => 'cn'
            ]);
        } else {
            Db::name('users_config')
                ->where('name', 'shop_open')
                ->where('inc_type', 'shop')
                ->setField('value', 1);
        }
        echo "✓ 已开启商城功能\n";
    } else {
        echo "✓ 商城开关已开启\n";
    }
    
    // 2. 检查产品价格字段配置
    echo "\n=== 2. 检查产品价格字段 ===\n";
    $fieldConfig = Db::name('channelfield')
        ->where('name', 'users_price')
        ->where('channel_id', 2)
        ->find();
    
    if (!$fieldConfig) {
        echo "⚠ users_price 字段不存在,正在添加...\n";
        $fieldId = Db::name('channelfield')->insertGetId([
            'name' => 'users_price',
            'channel_id' => 2,
            'title' => '产品价格',
            'dtype' => 'decimal',
            'dfvalue' => '0.00',
            'maxlength' => 10,
            'defaultvalue' => '0.00',
            'ifeditable' => 1,
            'ifmain' => 1,
            'ifcontrol' => 0,
            'status' => 1
        ]);
        echo "✓ 已添加 users_price 字段, ID: $fieldId\n";
    } else {
        echo "users_price 字段配置:\n";
        echo "  - ID: {$fieldConfig['id']}\n";
        echo "  - name: {$fieldConfig['name']}\n";
        echo "  - title: {$fieldConfig['title']}\n";
        echo "  - dtype: {$fieldConfig['dtype']}\n";
        echo "  - ifmain: {$fieldConfig['ifmain']}\n";
        echo "  - ifeditable: {$fieldConfig['ifeditable']}\n";
        echo "  - ifcontrol: {$fieldConfig['ifcontrol']}\n";
        echo "  - status: {$fieldConfig['status']}\n";
        
        // 修复配置
        $needFix = false;
        $fixSql = [];
        
        if ($fieldConfig['ifmain'] != 1) { $needFix = true; $fixSql['ifmain'] = 1; }
        if ($fieldConfig['ifeditable'] != 1) { $needFix = true; $fixSql['ifeditable'] = 1; }
        if ($fieldConfig['ifcontrol'] != 0) { $needFix = true; $fixSql['ifcontrol'] = 0; }
        if ($fieldConfig['status'] != 1) { $needFix = true; $fixSql['status'] = 1; }
        
        if ($needFix) {
            echo "⚠ 需要修复字段配置...\n";
            Db::name('channelfield')->where('id', $fieldConfig['id'])->update($fixSql);
            echo "✓ 已修复字段配置\n";
        } else {
            echo "✓ 字段配置正确\n";
        }
    }
    
    // 3. 检查字段是否在 ifcontrolRow 中可见
    echo "\n=== 3. 检查字段控制查询 ===\n";
    $ifcontrolRow = Db::name('channelfield')
        ->field('id,name')
        ->where([
            'channel_id' => 2,
            'ifmain' => 1,
            'ifeditable' => 1,
            'ifcontrol' => 0,
            'status' => 1,
        ])
        ->getAllWithIndex('name');
    
    echo "符合条件的字段:\n";
    foreach ($ifcontrolRow as $name => $row) {
        echo "  - $name (ID: {$row['id']})\n";
    }
    
    if (isset($ifcontrolRow['users_price'])) {
        echo "✓ users_price 在控制列表中\n";
    } else {
        echo "⚠ users_price 不在控制列表中 - 这可能是显示问题的原因\n";
    }
    
    // 4. 确保商城配置正确传递所有必要的值
    echo "\n=== 4. 检查商城配置详情 ===\n";
    $shopConfigs = Db::name('users_config')
        ->where('inc_type', 'shop')
        ->select();
    
    echo "商城配置项:\n";
    foreach ($shopConfigs as $config) {
        echo "  - {$config['name']}: {$config['value']}\n";
    }
    
    // 如果 shop_open_spec 不存在,添加它并设置为 0(单规格模式)
    $specConfig = Db::name('users_config')
        ->where('name', 'shop_open_spec')
        ->where('inc_type', 'shop')
        ->find();
    
    if (!$specConfig) {
        echo "\n添加 shop_open_spec 配置...\n";
        Db::name('users_config')->insert([
            'name' => 'shop_open_spec',
            'value' => 0,
            'inc_type' => 'shop',
            'lang' => 'cn'
        ]);
        echo "✓ 已添加 shop_open_spec = 0 (单规格模式)\n";
    }
    
    // 5. 清除缓存
    echo "\n=== 5. 清除缓存 ===\n";
    $cacheDir = dirname(__FILE__) . '/data/runtime/';
    if (is_dir($cacheDir)) {
        function recursive_delete($dir) {
            if (!is_dir($dir)) return true;
            $files = array_diff(scandir($dir), array('.','..'));
            foreach ($files as $file) {
                $path = "$dir/$file";
                if (is_dir($path)) {
                    recursive_delete($path);
                } else {
                    @unlink($path);
                }
            }
            return @rmdir($dir);
        }
        recursive_delete($cacheDir);
        echo "✓ 已清除数据缓存\n";
    }
    
    echo "\n=== 完成 ===\n";
    echo "\n请: \n";
    echo "1. 清除浏览器缓存\n";
    echo "2. 刷新后台产品编辑页面\n";
    echo "3. 查看是否显示价格字段\n";
    echo "4. 如果仍不显示,请检查模板中是否有条件判断导致字段隐藏\n";
    
} catch (Exception $e) {
    echo "\n错误: " . $e->getMessage() . "\n";
}

Youez - 2016 - github.com/yon3zu
LinuXploit