$report_row = ''; try { // Parameter check if (isset($argv[1]) === false) { throw new Exception('01'); } // Source CSV $src_csv_name = $argv[1]; $src_csv_path = SRC_PATH . '/' . $src_csv_name; // Source CSV exist check if (file_exists($src_csv_path) === false) { throw new Exception('02'); } // New CSV list($csv_name, $csv_ext) = explode('.', $src_csv_name); $new_csv_name = $csv_name . '_' . ClassDate::now('ymdHis') . '.csv'; $new_csv_path = CSV_PATH . '/' . $new_csv_name; // Get CSV content $data = $csv->getData($src_csv_path); // Connect to Mysql $mysql->connect(); $mysql->setDbName(DB_NAME); $mysql->setDbEnc(DB_ENC); // Write CSV fields $csv->setData($new_csv_path, $report_fields); // Parse CSV content foreach ($data as $row_data) { $id = $row_data[0]; $sn = $row_data[2]; $trade_day = ClassDate::format($query_format, $row_data[10] . '000000'); $refund_day = ClassDate::format($query_format, $row_data[11] . '000000');
<?php include 'config/ZipConfig.php'; include LIB_PATH . '/ClassZip.php'; include LIB_PATH . '/ClassPassword.php'; include LIB_PATH . '/ClassDate.php'; include LIB_PATH . '/ClassDisp.php'; // Set zip file name if (isset($argv[1]) === false) { $zip_name = ClassDate::now('Ymd'); } else { $zip_name = $argv[1]; } // Generate a 8 bits password $zip_password = ClassPassword::randomKey(); // Zip the files $zip = new ClassZip(); $zip->zipDir(SRC_PATH, $zip_name, $zip_password); // Chang to zip directory $result = rename($zip_name, ZIP_PATH . '/' . $zip_name); if ($result === false) { ClassDisp::dispString('Move zip file failed'); } // Display the messages ClassDisp::dispString('Zip: ' . $zip_name); ClassDisp::dispString('Password: ' . $zip_password); ClassDisp::dispArray($zip->getOutput());