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
/
Repositories
/
Filename :
HistoryRepository.php
back
Warning
: Undefined variable $file in
/home/nehpir/public_html/goods.php
on line
545
Copy
<?php namespace WooCommersa\Repositories; if (!defined('ABSPATH')) exit; class HistoryRepository { /** * Record a change in history */ /** * Get records from history */ public function get_history($params = []) { global $wpdb; $table = $wpdb->prefix . 'woocommersa_history'; $type = !empty($params['type']) ? sanitize_text_field($params['type']) : ''; $date_from = !empty($params['date_from']) ? sanitize_text_field($params['date_from']) : ''; $date_to = !empty($params['date_to']) ? sanitize_text_field($params['date_to']) : ''; $q = !empty($params['q']) ? sanitize_text_field($params['q']) : ''; $query = "SELECT h.*, p.post_title as product_name, u.display_name as user_name FROM $table h LEFT JOIN {$wpdb->posts} p ON h.product_id = p.ID LEFT JOIN {$wpdb->users} u ON h.user_id = u.ID WHERE 1=1"; if ($type) { if ($type === 'price') { $query .= " AND h.field_name IN ('regular_price', 'sale_price', 'cost_price')"; } elseif ($type === 'stock') { $query .= " AND h.field_name IN ('stock', 'stock_status', 'manage_stock')"; } elseif ($type === 'product') { $query .= " AND h.field_name IN ('name', 'sku', 'status', 'categories', 'seo_title', 'seo_description', 'seo_keywords')"; } elseif ($type === 'coupon') { $query .= " AND h.field_name LIKE 'coupon_%'"; } elseif ($type === 'seo') { $query .= " AND h.field_name IN ('seo_title', 'seo_description', 'seo_keywords', 'seo_robots', 'seo_redirect')"; } else { $query .= $wpdb->prepare(" AND h.field_name = %s", $type); } } if ($date_from) $query .= $wpdb->prepare(" AND h.date >= %s", $date_from . ' 00:00:00'); if ($date_to) $query .= $wpdb->prepare(" AND h.date <= %s", $date_to . ' 23:59:59'); if ($q) $query .= $wpdb->prepare(" AND (p.post_title LIKE %s OR h.batch_id LIKE %s OR h.field_name LIKE %s)", "%$q%", "%$q%", "%$q%"); $query .= " ORDER BY h.id DESC LIMIT 200"; $results = $wpdb->get_results($query); return $results; } public function record($user_id, $product_id, $field, $old, $new, $batch_id = '', $source = 'manual') { global $wpdb; $table = $wpdb->prefix . 'woocommersa_history'; return $wpdb->insert($table, [ 'user_id' => $user_id, 'product_id' => $product_id, 'field_name' => $field, 'old_value' => is_array($old) ? json_encode($old) : $old, 'new_value' => is_array($new) ? json_encode($new) : $new, 'batch_id' => $batch_id, 'source' => $source, 'date' => current_time('mysql') ]); } /** * Rollback a specific batch */ public function rollback($batch_id) { global $wpdb; $table = $wpdb->prefix . 'woocommersa_history'; $records = $wpdb->get_results($wpdb->prepare( "SELECT * FROM $table WHERE batch_id = %s", $batch_id )); if (empty($records)) return false; $success_count = 0; foreach ($records as $record) { $id = $record->product_id; $field = $record->field_name; $old_val = $record->old_value; // Handle JSON encoded values if (is_string($old_val) && strpos($old_val, '{') === 0) { $old_val = json_decode($old_val, true); } $product = wc_get_product($id); if ($product) { switch ($field) { case 'regular_price': $product->set_regular_price($old_val); break; case 'sale_price': $product->set_sale_price($old_val); break; case 'stock': $product->set_stock_quantity($old_val); break; case 'stock_status': $product->set_stock_status($old_val); break; case 'sku': $product->set_sku($old_val); break; case 'status': $product->set_status($old_val); break; case 'manage_stock': $product->set_manage_stock($old_val === '1' || $old_val === 'yes'); break; case 'seo_title': SEOAdapter::update_meta($id, 'title', $old_val); break; case 'seo_description': SEOAdapter::update_meta($id, 'description', $old_val); break; case 'seo_keywords': SEOAdapter::update_meta($id, 'keywords', $old_val); break; case 'seo_robots': SEOAdapter::update_meta($id, 'robots', $old_val); break; case 'faq_schema': SEOAdapter::engine()->meta()->update($id, ['faq_schema' => $old_val]); break; case 'image_alt': $thumb_id = get_post_thumbnail_id($id); if ($thumb_id) update_post_meta($thumb_id, '_wp_attachment_image_alt', $old_val); break; case 'cost_price': update_post_meta($id, '_cost_price', $old_val); break; case 'seo_redirect': update_post_meta($id, '_woocommersa_redirect_url', $old_val); break; default: if (strpos($field, '_') === 0) { update_post_meta($id, $field, $old_val); } break; } $product->save(); $success_count++; } elseif (strpos($field, 'coupon_') === 0) { $coupon = new \WC_Coupon($id); if ($coupon->get_id()) { $c_field = str_replace('coupon_', '', $field); switch ($c_field) { case 'code': $coupon->set_code($old_val); break; case 'amount': $coupon->set_amount($old_val); break; case 'type': $coupon->set_discount_type($old_val); break; case 'expiry_date': $coupon->set_date_expires($old_val); break; case 'usage_limit': $coupon->set_usage_limit($old_val); break; case 'minimum_amount': $coupon->set_minimum_amount($old_val); break; case 'description': $coupon->set_description($old_val); break; } $coupon->save(); $success_count++; } } } // Clean up history after rollback $wpdb->delete($table, ['batch_id' => $batch_id]); return $success_count > 0; } }