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
/
Core
/
Filename :
JobManager.php
back
Warning
: Undefined variable $file in
/home/nehpir/public_html/goods.php
on line
545
Copy
<?php namespace WooCommersa\Core; if (!defined('ABSPATH')) exit; class JobManager { public static function create_job($type, $items, $data = []) { $job_id = 'job_' . wp_generate_password(8, false); $job_data = [ 'id' => $job_id, 'type' => $type, 'status' => 'pending', 'progress' => 0, 'total' => count($items), 'processed' => 0, 'items' => $items, 'data' => $data, 'cursor' => 0, 'failed_ids' => [], 'retries' => 0, 'error_count' => 0, 'last_error' => '', 'created_at' => current_time('mysql'), 'last_update' => current_time('mysql') ]; update_option('wm_job_' . $job_id, $job_data); // Track the job in a central list $recent_jobs = get_option('wm_recent_jobs', []); $recent_jobs[] = [ 'id' => $job_id, 'type' => $type, 'status' => 'pending', 'created_at' => $job_data['created_at'] ]; // Keep last 20 jobs if (count($recent_jobs) > 20) array_shift($recent_jobs); update_option('wm_recent_jobs', $recent_jobs); // Schedule immediate processing via WP Cron wp_schedule_single_event(time(), 'wm_process_job', [$job_id]); return $job_id; } public static function list_recent_jobs($type = null) { $recent_jobs = get_option('wm_recent_jobs', []); if ($type) { $recent_jobs = array_filter($recent_jobs, fn($j) => str_starts_with($j['type'], $type)); } $detailed_jobs = []; foreach ($recent_jobs as $j) { $job = self::get_job($j['id']); if ($job) { $detailed_jobs[] = $job; } } return array_reverse($detailed_jobs); } public static function get_job($job_id) { return get_option('wm_job_' . $job_id); } public static function update_job($job_id, $data) { $job = self::get_job($job_id); if ($job) { $job = array_merge($job, $data); $job['last_update'] = current_time('mysql'); update_option('wm_job_' . $job_id, $job); // Also update status in recent_jobs list (with locking) if (isset($data['status'])) { $lock_key = 'wm_recent_jobs_lock'; $lock_id = wp_generate_password(8, false); $tries = 0; while ($tries < 10 && !add_transient($lock_key, $lock_id, 5)) { usleep(500000); // 0.5s pause $tries++; } $recent = get_option('wm_recent_jobs', []); $changed = false; foreach ($recent as &$rj) { if ($rj['id'] === $job_id) { $rj['status'] = $data['status']; $changed = true; } } if ($changed) { update_option('wm_recent_jobs', $recent); } if (get_transient($lock_key) === $lock_id) { delete_transient($lock_key); } } } } public static function cancel_job($job_id) { $job = self::get_job($job_id); if ($job) { self::update_job($job_id, ['status' => 'cancelled']); delete_transient('wm_processing_' . $job_id); return true; } return false; } public static function check_stuck_jobs() { $recent = get_option('wm_recent_jobs', []); $now = current_time('timestamp'); foreach ($recent as $rj) { if ($rj['status'] === 'processing' || $rj['status'] === 'pending') { $job = self::get_job($rj['id']); if (!$job) continue; $last_update = strtotime($job['last_update']); $diff = $now - $last_update; // If no update for 5 minutes and no lock exists, or if it's pending for too long if ($diff > 300 && !get_transient('wm_processing_' . $rj['id'])) { if (($job['retries'] ?? 0) < 3) { self::update_job($rj['id'], [ 'status' => 'pending', 'retries' => ($job['retries'] ?? 0) + 1 ]); wp_schedule_single_event(time() + 10, 'wm_process_job', [$rj['id']]); } else { self::update_job($rj['id'], [ 'status' => 'failed', 'last_error' => 'عملیات به دلیل توقف طولانی و عدم پاسخگویی سرور متوقف شد.' ]); } } } } } }