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
/
www
/
wp-content
/
plugins
/
woocommersa
/
includes
/
Services
/
Filename :
ExportService.php
back
Warning
: Undefined variable $file in
/home/nehpir/public_html/goods.php
on line
545
Copy
<?php namespace WooCommersa\Services; if (!defined('ABSPATH')) exit; class ExportService { public function generate_csv($params) { $repository = new \WooCommersa\Repositories\ProductRepository(); $params['per_page'] = -1; // Export all matching products $data = $repository->get_products($params); $products = $data['products'] ?? []; $filename = 'woocommersa_export_' . date('Y-m-d_H-i') . '.csv'; $upload_dir = wp_upload_dir(); $filepath = $upload_dir['basedir'] . '/' . $filename; $handle = fopen($filepath, 'w'); // Add UTF-8 BOM for Excel fprintf($handle, chr(0xEF).chr(0xBB).chr(0xBF)); // Allowed columns map $all_fields = [ 'شناسه' => 'id', 'شناسه محصول (SKU)' => 'sku', 'نام محصول' => 'name', 'نوع محصول' => 'type', 'قیمت اصلی' => 'regular_price', 'قیمت ویژه' => 'sale_price', 'تاریخ شروع حراج' => 'sale_from', 'تاریخ پایان حراج' => 'sale_to', 'موجودی' => 'stock', 'وضعیت موجودی' => 'stock_status', 'مدیریت موجودی' => 'manage_stock', 'دستهبندیها' => 'categories', 'عنوان سئو' => 'seo_title', 'توضیحات سئو' => 'seo_description', 'کلمات کلیدی سئو' => 'seo_keywords' ]; $selected_keys = !empty($params['columns']) ? explode(',', $params['columns']) : array_keys($all_fields); // Force ID, SKU, Name if (!in_array('شناسه', $selected_keys)) array_unshift($selected_keys, 'شناسه'); if (!in_array('شناسه محصول (SKU)', $selected_keys)) array_splice($selected_keys, 1, 0, 'شناسه محصول (SKU)'); if (!in_array('نام محصول', $selected_keys)) array_splice($selected_keys, 2, 0, 'نام محصول'); $header = []; foreach ($selected_keys as $key) { if (isset($all_fields[$key])) { $header[] = $key; } } fputcsv($handle, $header); foreach ($products as $p) { $row = []; foreach ($header as $h) { $field = $all_fields[$h]; $val = $p[$field] ?? ''; if ($field === 'manage_stock') { $val = $val ? 'yes' : 'no'; } elseif ($field === 'categories') { $val = is_array($val) ? implode(', ', $val) : $val; } $row[] = $val; } fputcsv($handle, $row); } fclose($handle); return [ 'url' => $upload_dir['baseurl'] . '/' . $filename, 'path' => $filepath, 'filename' => $filename, 'count' => count($products) ]; } public function export_to_csv($rows, $filename) { $filename .= '.csv'; header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename="' . $filename . '"'); $output = fopen('php://output', 'w'); fprintf($output, chr(0xEF).chr(0xBB).chr(0xBF)); // UTF-8 BOM foreach ($rows as $row) { fputcsv($output, $row); } fclose($output); exit; } public function export_to_pdf($rows, $title) { $site_name = get_bloginfo('name'); header('Content-Type: text/html; charset=utf-8'); ?> <!DOCTYPE html> <html dir="rtl"> <head> <meta charset="UTF-8"> <title><?php echo esc_html($title); ?></title> <style> body { font-family: 'Tahoma', 'Arial', sans-serif; padding: 50px; color: #1e293b; background: #fff; line-height: 1.6; } .report-container { max-width: 1000px; margin: 0 auto; border: 1px solid #e2e8f0; padding: 40px; border-radius: 12px; box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1); } .header-flex { display: flex; justify-content: space-between; align-items: center; border-bottom: 3px solid #0f172a; padding-bottom: 20px; margin-bottom: 30px; } .header-flex h1 { margin: 0; font-size: 24px; color: #0f172a; } .date-badge { background: #f1f5f9; padding: 8px 16px; border-radius: 6px; font-size: 12px; font-weight: bold; } table { width: 100%; border-collapse: collapse; margin-top: 20px; } th { background-color: #f8fafc; color: #475569; font-weight: 800; text-align: right; padding: 15px 12px; border-bottom: 2px solid #e2e8f0; font-size: 13px; } td { padding: 15px 12px; border-bottom: 1px solid #f1f5f9; font-size: 13px; color: #334155; } tr:nth-child(even) { background-color: #fcfcfc; } .footer { margin-top: 60px; text-align: center; font-size: 11px; color: #94a3b8; border-top: 1px solid #e2e8f0; padding-top: 30px; } .footer b { color: #0f172a; } .site-brand { font-size: 14px; margin-bottom: 5px; color: #334155; } @media print { .no-print { display: none; } body { padding: 0; } .report-container { border: none; box-shadow: none; } } </style> </head> <body onload="window.print()"> <div class="report-container"> <div class="header-flex"> <h1><?php echo esc_html($title); ?></h1> <div class="date-badge">گزارش رسمی فروش</div> </div> <table> <thead> <tr> <?php foreach ($rows[0] as $h): ?><th><?php echo esc_html($h); ?></th><?php endforeach; ?> </tr> </thead> <tbody> <?php for ($i = 1; $i < count($rows); $i++): ?> <tr> <?php foreach ($rows[$i] as $val): ?><td><?php echo esc_html(is_numeric($val) ? number_format($val) : $val); ?></td><?php endforeach; ?> </tr> <?php endfor; ?> </tbody> </table> <div class="footer"> <div class="site-brand">این گزارش توسط سامانه <b><?php echo esc_html($site_name); ?></b> تهیه شده است.</div> <div>قدرت گرفته از <b>افزونه ووکامرسا (WooCommersa)</b></div> </div> </div> </body> </html> <?php exit; } }