Odyssey
arsdump.prg
1 <?php
2  $monLibrary= dirname(__FILE__) . "/../library";
3  require_once("$monLibrary/cu_top.i");
4  require_once("$monLibrary/ck_hticket.i");
5 
6  if (!CheckPerm($link, $Hu, basename($_SERVER['SCRIPT_NAME']), $_SERVER['REMOTE_ADDR'])) {
7  // ** Permissions failed
8  // ** redirect to new page
9  header("Location: /hcuadm/hcu_noperm.prg");
10  exit;
11  }
12 
13 $dms_ok=array('action'=>'string','Fs'=>'string','Cn'=>'string','Pass'=>'string','Clw'=>'digits','pktdays'=>'digits','maxfail'=>'digits','Tc'=>'string','R1'=>'string','R2'=>'string','R3'=>'string','R4'=>'string','R5'=>'string','Amt'=>'string');
14 
15 dms_import($dms_ok);
16 
17 #error_reporting (E_ALL);
18 error_reporting (E_ERROR | E_WARNING | E_PARSE);
19 echo "<html><LINK REL=stylesheet HREF='/monitor/css/dms.css' TYPE='text/css'>";
20 $action = (empty($action) ? "Show" : $action);
21 
22 $host = substr($_SERVER['SERVER_NAME'], 0,strpos($_SERVER['SERVER_NAME'], "."));
23 
24 $histdays=30;
25 $Clw=300;
26 
27 switch ($action) {
28 case "Show":
29 # show forms for fetch/post
30 
31 print <<<EOF
32  <head><title>ARU Dump</title></head><body bgcolor=#FFFFFF>
33  <div align='center' class='usu'>$host Live ARU Tester</div>
34  <table width=98% cellpadding=2><tr>
35  <td valign=top align=center width=34%>
36  <form action="$PHP_SELF?action='fetch'">
37  <input type='hidden' name='Fs' value='http://192.168.169.53/hculive7/ARS_livedb.mp'>
38  <table cellpadding=2>
39  <tr><td class='bar' colspan=2 align=center>Fetch ARU Packet</td></tr>
40  <tr><td class='dtl' align="right">Member: </td>
41  <td><input type=text name="Cn" size=10></td></tr>
42  <tr><td class='dtl' align="right">Password: </td>
43  <td><input type=password name="Pass" size=10 MAXLENGTH="8"></td></tr>
44  <tr><td class='dtl' align="right">Query Delay: </td>
45  <td><input type=text name="Clw" size=10 value=1></td></tr>
46  <tr><td class='dtl' align="right">Maximum History Days: </td>
47  <td><input type=text name="pktdays" size=5 value='30'></td>
48  </tr>
49  <tr><td class='dtl' align="right">Maximum Login Failures: </td>
50  <td><input type=text name="maxfail" size=5 value='5'></td>
51  </tr>
52  <tr><td colspan=2 align="center">
53  <input type=submit name="action" value="Fetch" class='bar'>
54  </td></tr>
55  </table>
56  </form>
57  </td><td valign=top align=center width=33%>
58  <form action="$PHP_SELF?action='retrieve'">
59  <input type='hidden' name='Fs' value='http://192.168.169.53/hculive7/ARS_livedb.mp'>
60  <table cellpadding=2>
61  <tr><td class='bar' colspan=2 align=center>Cross-Accounts</td></tr>
62  <tr><td class='dtl' align="right">Member: </td>
63  <td><input type=text name="Cn" size=10></td></tr>
64  <tr><td colspan=2 align="center">
65  <input type=submit name="action" value="Retrieve" class='bar'></td></tr>
66  </table>
67  </form>
68  </td><td valign=top align=center width=*>
69  <form action="$PHP_SELF?action='post'">
70  <input type='hidden' name='Fs' value='http://192.168.169.53/hculive7/ARS_livedb.mp'>
71  <table cellpadding=2>
72  <tr><td class='bar' colspan=2 align=center>Post ARU Packet</td></tr>
73  <tr><td class='dtl' align="right">Member: </td>
74  <td><input type=text name="Cn" size=10></td></tr>
75  <tr><td class='dtl' align="right">Transaction Code: </td>
76  <td><select name="Tc">
77  <option>AT</option>
78  <option>LP</option>
79  <option>LA</option>
80  <option>CW</option>
81  <option>CP</option>
82  <option>MD</option>
83  <option>MA</option>
84  <option>ES</option>
85  </select>
86  </td></tr>
87  <tr><td class='dtl' align="right">Ref 1 (From Sfx): </td>
88  <td><input type=text name="R1" size=10 value=1></td></tr>
89  <tr><td class='dtl' align="right">Ref 2 (To Sfx): </td>
90  <td><input type=text name="R2" size=10 value=1></td></tr>
91  <tr><td class='dtl' align="right">Ref 3 (email): </td>
92  <td><input type=text name="R3" size=10 value=1></td></tr>
93  <tr><td class='dtl' align="right">Ref 4 (To misc): </td>
94  <td><input type=text name="R4" size=10 value=1></td></tr>
95  <tr><td class='dtl' align="right">Ref 5 (To Mem): </td>
96  <td><input type=text name="R5" size=10 value=1></td></tr>
97  <tr><td class='dtl' align="right">Amount: </td>
98  <td><input type=text name="Amt" size=10></td></tr>
99  <tr><td colspan=2 align="center">
100  <input type=submit name="action" value="Post" class='bar'></td></tr>
101  </table>
102  </form>
103  </td>
104  </tr></table></body></html>
105 EOF;
106 exit;
107 case "Fetch":
108 # check parameters
109 # get a packet
110 if (empty($pktdays)) { $pktdays = 30; }
111 print "<html><head><title>ARU Fetch</title></head><body bgcolor=#FFFFFF>
112  Fetching packet using parameters<ul>
113  <li>Member: $Cn</li>
114  <li>Password: $Pass</li>
115  <li>Fetched from: $Fs</li>
116  <li>URL: $URL</li>
117  <li>Wait between calls: $Clw</li>
118  <li>Last Packet Stamp: $pktstamp</li>
119  <li>Requested Max Days: $pktdays</li>
120  <li>Requested Max Fail: $maxfail</li>
121  </ul><br>";
122  fetch_packet($Fs, $Cn, $Clw, $pktstamp, $Pass, $pktdays, $maxfail);
123 exit;
124 break;
125 case "Retrieve":
126 # check parameters
127 # get a packet
128 print "<html><head><title>Cross-Account Retrieve</title></head><body bgcolor=#FFFFFF>
129  Retrieving Cross-Account Authorizations using parameters<ul>
130  <li>Member: $Cn</li>
131  <li>Fetched from: $Fs</li>
132  </ul><br>";
133  fetch_xac($Fs, $Cn);
134 exit;
135 break;
136 case "Post":
137 # check parameters
138 # post a packet
139 $R2 = (trim($R2) == "" ? "NULL" : $R2);
140 $R3 = (trim($R3) == "" ? "NULL" : $R3);
141 $R4 = (trim($R4) == "" ? "NULL" : $R4);
142 $R5 = (trim($R5) == "" ? "NULL" : $R5);
143 print "<html><head><title>ARU Post</title></head><body bgcolor=#FFFFFF>
144  Posting packet using parameters<ul>
145  <li>Member: $Cn</li>
146  <li>Posted to: $Fs</li>
147  <li>Txn Code: $Tc</li>
148  <li>Ref1: $R1</li>
149  <li>Ref2: $R2</li>
150  <li>Ref3: $R3</li>
151  <li>Ref4: $R4</li>
152  <li>Ref5: $R5</li>
153  <li>Amount: $Amt</li>
154  <li>URL: $Fs?member=$Cn&type=T&tran_code=$Tc&ref1=$R1&ref2=$R2&ref3=$R3&ref4=$R4&ref5=$R5&amount=$Amt</li>
155  </ul><br>";
156 post_packet($Fs, $Cn, $Tc, $R1, $R2, $R3, $R4, $R5, $Amt);
157 exit;
158 break;
159 }
160 function fetch_packet($Fs, $Cn, $Clw, $pktstamp, $Pass, $pktdays, $maxfail) {
161 
162 $pktstamp = (empty($pktstamp) ? 1 : $pktstamp);
163 $pktdate = (empty($pktdate) ? date("D M j Y H:i:s T") : $pktdate);
164 $Clw = (($Clw == 0 || is_null($Clw)) ? 300 : $Clw);
165 
166 $threshold = mktime() - $Clw;
167 $fs = date("D M j Y H:i:s T",$pktstamp);
168 $ft = date("D M j Y H:i:s T",$threshold);
169 if ($pktstamp > $threshold) {
170  print "Too soon to ask again<br>
171  Last Stamp: $fs<br>
172  Threshold: $ft<br></body></html>";
173 } else {
174 
175  # if the last packet was fairly recent only fetch 7 days
176  # "recent" defined as 3 times the packet timeout setting
177  $threshold = mktime() - (3 * $Clw);
178  if (empty($cutoff)) { $cutoff = '20000101'; }
179  if (empty($histdays)) { $histdays = 0; }
180 # 946710000 is the timestamp for 20000101
181  if ($pktstamp >946710000 && $histdays > 0 && $cutoff == 20000101) {
182  # calculate cutoff as pktstamp - interval($histdays days)
183  if ($pktstamp > $threshold) {
184  # last packet age is less than 3 times the packet timeout setting
185  # set cutoff for 7 days
186  $cutoff = date("Ymd",mktime()-604800);
187  } else {
188  $cutoff = date("Ymd",$pktstamp-(86400 * $histdays));
189  }
190  }
191  $URL="?member=$Cn&type=I&pktdays=$pktdays&maxfail=$maxfail";
192  if (!empty($Pass)) {
193  $URL.="&pass=$Pass";
194  }
195  $fd = @fopen ("$Fs$URL", "r");
196 
197 if ($fd) {
198  while ($buff = fread ($fd, 1500)) {
199  $packet .= $buff;
200  }
201  $packet = HTMLSpecialChars($packet);
202  print "<br>URL: $URL<br><pre>$packet</pre></body></html>";
203 } else {
204  print "Couldn't get a packet!<br>$php_errormsg</body></html>";
205 }
206 }
207 }
208 
209 #
210 function fetch_xac($Fs, $Cn) {
211 
212  $URL="?member=$Cn&type=X";
213  $fd = @fopen ("$Fs$URL", "r");
214 
215 if ($fd) {
216  while ($buff = fread ($fd, 1500)) {
217  $packet .= $buff;
218  }
219 
220  $packet = HTMLSpecialChars($packet);
221  print "<br>URL: $URL<br><pre>$packet</pre></body></html>";
222 } else {
223  print "Couldn't get a packet!<br>$php_errormsg</body></html>";
224 }
225 }
226 
227 
228 function post_packet($Fs, $Cn, $Tc, $R1, $R2, $R3, $R4, $R5, $Amt) {
229 global $Fs;
230 
231 $URL = "?member=$Cn&type=T&tran_code=$Tc&ref1=$R1&ref2=$R2&ref3=$R3&ref4=$R4&ref5=$R5&amount=$Amt";
232 $fd = @fopen ("$Fs$URL", "r");
233 
234 if ($fd) {
235  while ($buff = fread ($fd, 1500)) {
236  $packet .= $buff;
237  }
238 
239  $packet = HTMLSpecialChars($packet);
240  print "<pre>$packet</pre></body></html>";
241 
242 } else {
243  print "Couldn't get a packet!<br>$php_errormsg<br>";
244  print "URL=$Fs?member=$Cn&type=T&tran_code=$Tc&ref1=$R1&ref2=$R2&ref3=$R3&ref4=$R4&ref5=$R5&amount=$Amt<br>";
245 }
246 }
247 
248 function showquoted(&$val) {
249  if (is_array($val)) {
250  array_walk($val, 'showquoted');
251  return;
252  }
253  $val = htmlentities($val);
254 }
255 ?>