Example #1
0
     $sql .= 'WHERE 1=1 ';
     $sql .= 'AND (gosn = "' . $sn . '" OR bksn = "' . $sn . '")';
     $sql .= ' AND (LEFT(rtime, 10) = "' . $trade_day . '" OR LEFT(rtime, 10) = "' . $refund_day . '")';
     $sql .= ' AND (AES_DECRYPT(goid, "' . KEY . '") = "' . $id . '"';
     $sql .= ' OR AES_DECRYPT(bkid, "' . KEY . '") = "' . $id . '")';
     $sql .= ' AND RIGHT(card8, 4) = "' . $card4 . '"';
     $sql .= ' ORDER BY amount DESC';
     // Query railway detail
     $detail = $mysql->query($sql);
     // Generate a report row
     if (count($detail) > 0) {
         $pay_amount = $detail[0]['amount'];
         $refund_amount = $detail[1]['amount'];
         $fee = $pay_amount + $refund_amount;
         $pay_day = ClassDate::format($csv_format, $detail[0]['rtime']);
         $refund_day = ClassDate::format($csv_format, $detail[1]['rtime']);
         // Set the check fields
         $temp_data = [];
         foreach ($check_fields as $field) {
             if ($detail[0][$field] === $detail[1][$field]) {
                 array_push($temp_data, $detail[0][$field]);
             }
         }
         // Set the rest fields
         foreach ($set_fields as $field) {
             array_push($temp_data, ${$field});
         }
         // Write to new CSV
         $csv->setData($new_csv_path, $temp_data, true);
     }
 }
Example #2
0
<?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());