コード例 #1
0
                send_html_mail(UNSUCCESS_PRODUCT_CSV_IMPORT . $file, $msg);
            } else {
                if (is_readable($to_path . $file)) {
                    if (strpos($file, "products") === 0) {
                        $csv_format_id = 1;
                    }
                    if (strpos($file, "categories") === 0) {
                        $csv_format_id = 2;
                    }
                    if (strpos($file, "options") === 0) {
                        $csv_format_id = 3;
                    }
                    $zco_notifier = new notifier();
                    $ProductCSV = new ProductCSV();
                    $template = new template_func(DIR_WS_TEMPLATES);
                    ProductCSV::import($to_path . $file, $csv_format_id, true, false);
                    $email = file_get_contents("includes/addon_modules/product_csv/email/email_template_default.html");
                    $email = str_replace('$EMAIL_SUBJECT', sprintf(PRODUCT_CSV_IMPORTED, $file), $email);
                    $email = str_replace('$EMAIL_MESSAGE_HTML', $body, $email);
                    product_csv_import_write_log("INFO", $file . "\n" . $email);
                    send_html_mail(SUCCESS_PRODUCT_CSV_IMPORT . $file, $email);
                } else {
                    $msg = ERROR_PRODUCT_CSV_IMPORT_FILE_READ . "(" . $to_path . $file . ")";
                    product_csv_import_write_log("ERROR", $msg);
                    send_html_mail(UNSUCCESS_PRODUCT_CSV_IMPORT . $file, $msg);
                }
            }
        }
    }
}
// ファイル取得
コード例 #2
0
require dirname(__FILE__) . "/pear/File/CSV.php";
$ProductCSV = new ProductCSV();
$action = isset($_GET['action']) ? $_GET['action'] : '';
$zco_notifier->notify('NOTIFY_PRODUCT_CSV_BEFORE_ACTION');
if ($action == 'return') {
    $_SESSION['product_csv'] = $_POST;
    zen_redirect(zen_href_link(FILENAME_ADDON_MODULES_ADMIN, 'module=product_csv', 'NONSSL'));
}
if ($action == 'import') {
    // update
    if (isset($_POST['upfile']) && $_FILES['file'] && $_FILES['file']['size'] > 0) {
        $tempfile = DIR_FS_CATALOG . '/temp/import_' . date('YmdHis') . '.csv';
        move_uploaded_file($_FILES['file']['tmp_name'], $tempfile);
    }
    if (is_readable($tempfile)) {
        $ProductCSV->import($tempfile, $_POST['csv_format_id'], isset($_POST['ignore_first_line']));
    } else {
        $messageStack->add(PRODUCT_CSV_ERROR_READ, 'caution');
    }
    // make return button
    $return_button = zen_draw_form('return', FILENAME_ADDON_MODULES_ADMIN, 'module=product_csv&action=return', 'post');
    $return_button .= zen_draw_hidden_field('csv_format_id', $_POST['csv_format_id']);
    $return_button .= zen_draw_hidden_field('ignore_first_line', $_POST['ignore_first_line']);
    $return_button .= '<input type="submit" value="' . PRODUCT_CSV_RETURN_TEXT . '" name="submit"/></form>';
} elseif ($action == 'export') {
    // prepare conf for File::CSV
    $format = $ProductCSV->getFormatById($_POST['csv_format_id']);
    $conf['fields'] = count($format['columns']);
    $conf['sep'] = MODULE_PRODUCT_CSV_EXPORT_CONFIG_SEP;
    $conf['quote'] = MODULE_PRODUCT_CSV_EXPORT_CONFIG_QUOTE;
    $conf['crlf'] = MODULE_PRODUCT_CSV_EXPORT_CONFIG_EOL;