请个位大大请教小弟。。 有关以下的 php coding, 小弟还是新手。。
蓝色的部份小弟有些不明。。。
<html>
<head>
<!-- external css file -->
<link href="./wsbs.css" type="text/css" rel="stylesheet" />
<?php
include 'dbheader.php';
?>
<style type=text/css>
.body
{
font-family:verdana;
font-size:9pt;
}
</style>
</head>
<body class=body>
<?php
// Where the file is going to be placed
$target_path = "input\\";
$attachment_location = $target_path;
//$question_id = $_REQUEST['question_id'];
$currDate = time();
$now = date('YmdHis',$currDate);
$seq_no = $now;
$attachment_name = $_FILES['uploadedfile']['name'];
$attachment_type = 'D';
$attachment_size = $_FILES['uploadedfile']['size'];
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']);
$bStatus = 0;
if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded";
$bStatus = 1;
} else{
echo "There was an error uploading the file to $target_path, please try again!";
print_r($_FILES);
}
// create an record in attachment table
if($bStatus == 1)
{
// process payment file
$fh = fopen($target_path, "r" ;
while(!feof($fh))
{
$lines = fgets($fh, 2048);
//echo "<br>".$lines;
if(substr($lines,0,1) == '0')
{
$serial = substr($lines,1,6);
if(trim($serial) == "" break;
$proc_date = substr($lines,7,8);
$tot_rec = substr($lines,15,7);
$sign = substr($lines,22,1);
$tot_amt = substr($lines,23,8).".".substr($lines,31,2);
$cps_pc = substr($lines,35,4);
echo "<br>";
echo "Serial :".$serial."<br>";
echo " rocDate :".$proc_date."<br>";
echo "TotRec :".$tot_rec."<br>";
echo "Sign :".$sign."<br>";
echo "TotAmt :".$tot_amt."<br>";
echo "CPCCycle :".$cps_pc."<br><br>";
echo "<table border=1 cellpadding=0 cellspacing=0><tr>";
echo "<td class=field_name>pmt_date</td>";
echo "<td class=field_name>pmt_off_code</td>";
echo "<td class=field_name>counter</td>";
echo "<td class=field_name>occur</td>";
echo "<td class=field_name>seq_no</td>";
echo "<td class=field_name>sign2</td>";
echo "<td class=field_name>trans_amt</td>";
echo "<td class=field_name>rev_code</td>";
echo "<td class=field_name>adj_code</td>";
echo "<td class=field_name>acct_no</td>";
echo "<td class=field_name>serv_no</td>";
echo "<td class=field_name>pmt_mode</td>";
echo "<td class=field_name>rec_no</td>";
echo "<td class=field_name>tlx_bill</td>";
echo "<td class=field_name>proc_date</td>";
echo "<td class=field_name>doc_no</td>";
echo "<td class=field_name>bill_no</td>";
echo "<td class=field_name>ref_no</td>";
echo "<td class=field_name>status</td>";
echo "</tr>";
}
else if(substr($lines,0,1) == '2')
{
$pmt_date = substr($lines,1,8);
$pmt_off_code = substr($lines,9,4);
$counter = substr($lines,13,2);
$occur = substr($lines,15,2);
$seq_no = substr($lines,17,4);
$sign2 = substr($lines,21,1);
$trans_amt = substr($lines,22,8).".".substr($lines,30,2);
$rev_code = substr($lines,32,3);
$adj_code = substr($lines,35,2);
$acct_no = substr($lines,37,14);
$serv_no = substr($lines,51,16);
$pmt_mode = substr($lines,67,1);
$rec_no = substr($lines,68,8);
$tlx_bill = substr($lines,76,8);
$proc_date = substr($lines,84,8);
$doc_no = substr($lines,100,16);
$bill_no = substr($lines,116,10);
$ref_no = substr($lines,126,20);
$sql = "SELECT count(*) from payment where volser_no = '".
$serial."' and acct_no = '".$acct_no.
"' and pmt_receipt_no = '".$rec_no.
"' and to_char(pmt_recd_date,'YYYYMMDD') = '".$pmt_date."'";
$stid = ociparse($conn, $sql);
if(!$stid)
{
$e = oci_error($conn);
print htmlentities($e['message']);
exit;
}
$r = ociexecute($stid);
if(!$r)
{
$e = oci_error($conn);
print htmlentities($e['message']);
exit;
}
if(ocifetch($stid))
{
$cnt = ociresult($stid, 1);
}
if($cnt <= 0)
{
$sql = "INSERT into payment (pmt_id, bci, acct_no, pmt_recd_date, " .
"pmt_receipt_no, pmt_recd_by, payment_mode, pmt_amt, ".
"cycle_num, sum_code, sub_sum_code, orgin_cycle_no, ".
"document_no, bill_num, reference_no, volser_no, ".
"serv_type,rev_code) values (pmt_id_seq.nextval, 'WBE00Z21', '".
$acct_no."',to_date('".$pmt_date."','YYYYMMDD'),'".
$rec_no."', '".$pmt_off_code."-".$counter."-".$occur."','".
$pmt_mode."', '".$trans_amt."','".
$seq_no."', 'DSK01', 'DBK01','".$cps_cp."','".
$doc_no."','".$bill_no."','".$ref_no."', '".$serial."', 'F','".$rev_code."')";
//echo "<br>".$sql;
//return;
$stid = ociparse($conn, $sql);
if(!$stid)
{
$e = oci_error($conn);
print htmlentities($e['message']);
exit;
}
$r = ociexecute($stid);
if(!$r)
{
$e = oci_error($conn);
print htmlentities($e['message']);
exit;
}
$status = 'OK';
}
else
{
$status = 'DUP';
}
echo "<tr>";
echo "<td class=serv_detail>".$pmt_date."</td>";
echo "<td class=serv_detail>".$pmt_off_code."</td>";
echo "<td class=serv_detail>".$counter."</td>";
echo "<td class=serv_detail>".$occur."</td>";
echo "<td class=serv_detail>".$seq_no."</td>";
echo "<td class=serv_detail>".$sign2."</td>";
echo "<td class=serv_detail>".$trans_amt."</td>";
echo "<td class=serv_detail>".$rev_code."</td>";
echo "<td class=serv_detail>".$adj_code."</td>";
echo "<td class=serv_detail>".$acct_no."</td>";
echo "<td class=serv_detail2><b>".$serv_no."</b></td>";
echo "<td class=serv_detail>".$pmt_mode."</td>";
echo "<td class=serv_detail>".$rec_no."</td>";
echo "<td class=serv_detail>".$tlx_bill."</td>";
echo "<td class=serv_detail>".$proc_date."</td>";
echo "<td class=serv_detail>".$doc_no."</td>";
echo "<td class=serv_detail>".$bill_no."</td>";
echo "<td class=serv_detail>".$ref_no."</td>";
echo "<td class=serv_detail>".$status."</td>";
echo "</tr>";
}
}
echo "</table>";
fclose($fh);
}
?>
<?php
# close the connection
$conn->Close();
?>
</body>
</html> |