Website : phonehp.ir
backdoor
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Home
Console
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Warning
: Undefined variable $backdoor in
/home/nehpir/public_html/goods.php
on line
326
Upload
information
Create File
Create Folder
About
Tools
:
/
home
/
nehpir
/
public_html
/
wp-content
/
plugins
/
woocommersa
/
includes
/
API
/
Filename :
SettingsController.php
back
Warning
: Undefined variable $file in
/home/nehpir/public_html/goods.php
on line
545
Copy
<?php namespace WooCommersa\API; if (!defined('ABSPATH')) exit; class SettingsController extends BaseController { public function __construct() { add_action('rest_api_init', [$this, 'register_routes']); } public function register_routes() { register_rest_route($this->namespace, '/settings', [ 'methods' => ['GET', 'POST'], 'callback' => [$this, 'handle_settings'], 'permission_callback' => [$this, 'permissions_check'], ]); register_rest_route($this->namespace, '/settings/export', [ 'methods' => 'GET', 'callback' => [$this, 'export_settings'], 'permission_callback' => [$this, 'permissions_check'], ]); register_rest_route($this->namespace, '/settings/import', [ 'methods' => 'POST', 'callback' => [$this, 'import_settings'], 'permission_callback' => [$this, 'permissions_check'], ]); register_rest_route($this->namespace, '/system-info', [ 'methods' => 'GET', 'callback' => [$this, 'get_system_info'], 'permission_callback' => [$this, 'permissions_check'], ]); register_rest_route($this->namespace, '/logs', [ 'methods' => 'GET', 'callback' => [$this, 'get_logs'], 'permission_callback' => [$this, 'permissions_check'], ]); register_rest_route($this->namespace, '/settings/sms/test', [ 'methods' => 'POST', 'callback' => [$this, 'test_sms_connection'], 'permission_callback' => [$this, 'permissions_check'], ]); register_rest_route($this->namespace, '/settings/sms/test-pattern', [ 'methods' => 'POST', 'callback' => [$this, 'test_sms_pattern'], 'permission_callback' => [$this, 'permissions_check'], ]); register_rest_route($this->namespace, '/logs/clear', [ 'methods' => 'POST', 'callback' => [$this, 'clear_logs'], 'permission_callback' => [$this, 'permissions_check'], ]); register_rest_route($this->namespace, '/settings/brand-sources', [ 'methods' => 'GET', 'callback' => [$this, 'get_brand_sources'], 'permission_callback' => [$this, 'permissions_check'], ]); register_rest_route($this->namespace, '/heartbeat', [ 'methods' => ['GET', 'HEAD'], 'callback' => [$this, 'heartbeat'], 'permission_callback' => '__return_true', ]); } public function heartbeat() { return new \WP_REST_Response(['status' => 'alive', 'time' => time()], 200); } public function handle_settings($request) { if ($request->get_method() === 'POST') { $old_settings = get_option('woocommersa_settings', []); $settings = $request->get_json_params(); update_option('woocommersa_settings', $settings); // Determine what changed for better logging $changed_sections = []; if (($settings['ai_api_key'] ?? '') !== ($old_settings['ai_api_key'] ?? '')) $changed_sections[] = 'هوش مصنوعی'; if (($settings['sms']['api_key'] ?? '') !== ($old_settings['sms']['api_key'] ?? '')) $changed_sections[] = 'پنل پیامک'; if (($settings['allowed_roles'] ?? []) !== ($old_settings['allowed_roles'] ?? [])) $changed_sections[] = 'دسترسیها'; if (($settings['items_per_page'] ?? 0) !== ($old_settings['items_per_page'] ?? 0)) $changed_sections[] = 'تنظیمات نمایش'; if (($settings['pos_enabled'] ?? false) !== ($old_settings['pos_enabled'] ?? false)) $changed_sections[] = 'ماژول فروش حضوری'; $msg = !empty($changed_sections) ? 'تنظیمات بخش ' . implode(' و ', $changed_sections) . ' بروزرسانی شد.' : 'تنظیمات پیرامونی سیستم بروزرسانی شد.'; // Sync with pricing settings if (isset($settings['enable_automation'])) { $pricing = get_option('woocommersa_pricing_settings', []); $pricing['enabled'] = (bool)$settings['enable_automation']; if (isset($settings['automation_interval'])) { $pricing['schedule'] = $settings['automation_interval']; } update_option('woocommersa_pricing_settings', $pricing); } \WooCommersa\Core\Logger::log($msg, 'info', 'تنظیمات'); // Clear Brand Service Cache \WooCommersa\Services\BrandService::get_instance()->clear_cache(); return new \WP_REST_Response(['message' => __('تنظیمات با موفقیت ذخیره شد.', 'woocommersa')], 200); } $settings = get_option('woocommersa_settings', []); return new \WP_REST_Response($settings, 200); } public function export_settings() { $settings = get_option('woocommersa_settings', []); return new \WP_REST_Response(['data' => base64_encode(json_encode($settings))], 200); } public function import_settings($request) { $params = $request->get_params(); $data = $params['data'] ?? ''; $decoded = json_decode(base64_decode($data), true); if (is_array($decoded)) { update_option('woocommersa_settings', $decoded); return new \WP_REST_Response(['message' => __('تنظیمات با موفقیت درونریزی شد.', 'woocommersa')], 200); } return new \WP_REST_Response(['message' => __('خطا در درونریزی تنظیمات.', 'woocommersa')], 400); } public function get_system_info() { global $wp_version, $wpdb; $wc_version = defined('WC_VERSION') ? WC_VERSION : 'نامشخص'; $diagnostics = [ 'php' => [ 'label' => 'نسخه PHP', 'status' => version_compare(PHP_VERSION, '7.4', '>=') ? 'success' : 'warning', 'current' => PHP_VERSION, 'recommended' => '7.4 یا بالاتر', 'tip' => 'برای امنیت و سرعت بیشتر از نسخههای جدید استفاده کنید.' ], 'memory' => [ 'label' => 'حافظه رم (Memory Limit)', 'status' => (int)ini_get('memory_limit') >= 256 ? 'success' : 'warning', 'current' => ini_get('memory_limit'), 'recommended' => '256M یا بیشتر', 'tip' => 'اگر سایت سنگین است، این مقدار را افزایش دهید.' ], 'max_execution' => [ 'label' => 'حداکثر زمان اجرا', 'status' => (int)ini_get('max_execution_time') == 0 || (int)ini_get('max_execution_time') >= 60 ? 'success' : 'warning', 'current' => ini_get('max_execution_time') . 's', 'recommended' => '60s یا بیشتر', 'tip' => 'ارتقاء این گزینه برای جلوگیری از قطعی پردازشهای طولانی مؤثر است.' ] ]; return new \WP_REST_Response([ 'diagnostics' => $diagnostics, 'software' => [ 'wp_version' => $wp_version, 'wc_version' => $wc_version, 'plugin_version' => defined('WOOCOMMERSA_VERSION') ? WOOCOMMERSA_VERSION : '2.4.6', 'php_version' => PHP_VERSION, 'mysql_version' => $wpdb->db_version(), 'site_title' => get_bloginfo('name'), 'home_url' => get_bloginfo('url'), 'active_theme' => wp_get_theme()->get('Name') ], 'server' => [ 'memory_limit' => ini_get('memory_limit'), 'max_execution_time' => ini_get('max_execution_time'), 'server_software' => $_SERVER['SERVER_SOFTWARE'] ?? 'Unknown' ], 'environment' => [ 'is_ssl' => is_ssl(), 'language' => get_locale(), 'timezone' => wp_timezone_string() ], 'plugins' => [ 'active_count' => count(get_option('active_plugins', [])) ] ], 200); } public function get_logs() { $logs = get_option('woocommersa_logs', []); return new \WP_REST_Response(['logs' => is_array($logs) ? array_reverse($logs) : []], 200); } public function clear_logs() { update_option('woocommersa_logs', []); // Also clear file logs $upload_dir = wp_upload_dir(); $log_dir = $upload_dir['basedir'] . '/woocommersa/logs'; if (is_dir($log_dir)) { $files = glob($log_dir . '/*.log'); foreach ($files as $file) { if (is_file($file)) unlink($file); } } return new \WP_REST_Response(['message' => __('گزارشات با موفقیت پاک شدند.', 'woocommersa')], 200); } public function test_sms_connection($request) { $settings = $request->get_json_params(); $sms = new \WooCommersa\Services\SMSService($settings); $result = $sms->test_connection(); return new \WP_REST_Response($result, 200); } public function test_sms_pattern($request) { $params = $request->get_json_params(); $settings = $params['settings'] ?? []; $to = $params['phone'] ?? ''; $pattern_id = $params['pattern_id'] ?? ''; $vars = $params['vars'] ?? []; if (empty($to) || empty($pattern_id)) { return new \WP_REST_Response(['success' => false, 'message' => 'شماره تماس و کد الگو الزامی هستند.'], 400); } $sms = new \WooCommersa\Services\SMSService($settings['sms'] ?? []); $result = $sms->test_pattern($to, $pattern_id, $vars); return new \WP_REST_Response($result, 200); } public function get_brand_sources() { $service = \WooCommersa\Services\BrandService::get_instance(); $sources = $service->get_all_potential_sources(); $configured = $service->get_configured_source(); return new \WP_REST_Response([ 'sources' => $sources, 'active' => $configured ], 200); } }