function _install() { global $db; $db->execute(CREATE_CSV_FORMAT_TYPES); $db->execute(CREATE_CSV_FORMATS); $db->execute(CREATE_CSV_COLUMNS); $db->execute(CREATE_CSV_FORMAT_COLUMNS); $insert_sql = sprintf(INSERT_CSV_FORMAT_TYPES, MODULE_PRODUCT_CSV_FORMAT_TYPES_1, MODULE_PRODUCT_CSV_FORMAT_TYPES_2, MODULE_PRODUCT_CSV_FORMAT_TYPES_3); $db->execute($insert_sql); foreach ($GLOBALS['MODULE_PRODUCT_CSV_COLUMNS'] as $val) { if (preg_match('/:LANGUAGE_ID/', $val['name'])) { zen_set_column_with_language(INSERT_CSV_COLUMNS, $val); continue; } $insert_sql = sprintf(INSERT_CSV_COLUMNS, $val['column_id'], $val['type_id'], $val['name'], $val['validate'], $val['dbtable'], $val['dbcolumn']); $db->execute($insert_sql); } $ProductCSV = new ProductCSV(); for ($i = 1; $i <= 3; $i++) { $columns = $ProductCSV->getFormatColumns($i); $count = 0; $values = array(); foreach ($columns as $val) { $count++; $values[$count] = $val['id']; } switch ($i) { case 1: $name = MODULE_PRODUCT_CSV_FORMAT_PRODUCT_ALL; break; case 2: $name = MODULE_PRODUCT_CSV_FORMAT_CATEGORY_ALL; break; case 3: $name = MODULE_PRODUCT_CSV_FORMAT_OPTION_ALL; break; } $ProductCSV->setFormat($i, $name, $values); } }
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); } } } } } // ファイル取得
<?php if (!defined('IS_ADMIN_FLAG')) { die('Illegal Access'); } ini_set('include_path', ini_get('include_path') . ':' . dirname(__FILE__) . '/pear:'); require 'File/CSV.php'; $ProductCSV = new ProductCSV(); $action = isset($_GET['action']) ? $_GET['action'] : ''; // delete format if ($action == 'delete') { if (isset($_GET['fID'])) { $ProductCSV->deleteFormat($_GET['fID']); } zen_redirect(zen_href_link(FILENAME_ADDON_MODULES_ADMIN, 'module=product_csv/csv_format')); } if ($action == 'return') { if (array_key_exists('csv_format_type_id', $_POST)) { $_SESSION['product_csv']['csv_format_type_id'] = $_POST['csv_format_type_id']; } if (array_key_exists('csv_format_name', $_POST)) { $_SESSION['product_csv']['csv_format_name'] = $_POST['csv_format_name']; } if (array_key_exists('fID', $_POST)) { $_SESSION['product_csv']['fID'] = $_POST['fID']; } if (array_key_exists('csv_format_column', $_POST)) { $_SESSION['product_csv']['csv_format_column'] = $_POST['csv_format_column']; } $_SESSION['product_csv']['returned'] = true; switch ($_POST['return_to']) {
<?php if (!defined('IS_ADMIN_FLAG')) { die('Illegal Access'); } ini_set('include_path', ini_get('include_path') . ':' . dirname(__FILE__) . '/pear:'); 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') {