Odyssey
RestrictTran.prg
1 <?php
2 require_once("dms_imp_val.i");
3 
4 $dms_ok=array('set_restrict'=>'string','unset_restrict'=>'string',
5 'mode'=>'string','ft'=>'digits');
6 dms_import($dms_ok);
7 
8  $err_msg = "";
9  // ** CHECK FOR SETTING THE VALUE
10  if (isset($set_restrict)) {
11  // ** SET THE VALUE TO RESTRICT
12  $Tran_Ret = Restrict_Tran('rt');
13  if ($Tran_Ret == "000") {
14  $err_msg = "Transactions are now set to restricted.";
15  } else {
16  $err_msg = "An error occurred while trying to set transactions to restricted. Please try again.";
17  }
18  } elseif (isset($unset_restrict)) {
19  // ** UNSET THE RESTRICT VALUE
20  $Tran_Ret = Restrict_Tran('ut');
21  if ($Tran_Ret == "000") {
22  $err_msg = "Transactions have been set to unrestricted.";
23  } else {
24  $err_msg = "An error occurred while trying to unrestrict transactions. Please try again.";
25  }
26  }
27 
28 
29  // ** Get the current status of the flag
30  $Tran_Ret = Restrict_Tran('qt');
31  switch ($Tran_Ret) {
32  case "999":
33  $restrict_set = true;
34  break;
35  case "000":
36  $restrict_set = false;
37  break;
38  default:
39  // ** FOR ALL ELSE -- FUNCTION FAILED
40  break;
41  }
42 ?>
43  <form name="checkinfo" method="post" action="<?php echo $menu_link; ?>?ft=<?php echo intval($ft); ?>">
44  <input type="hidden" name="mode" value="VIEW">
45  <br>
46  <table width="90%" border=0 cellpadding=0 cellspacing=0>
47  <tr>
48  <td class="bar" align="center">
49  Restrict Transactions for <?php echo $Cu; ?>
50  </td>
51  </tr>
52  <?php if ($err_msg != ""): ?>
53  <tr>
54  <td class="msg" align="center">
55  <?php echo $err_msg; ?>
56  </td>
57  </tr>
58  <?php endif; ?>
59  <tr>
60  <td align=center class='dtl'>
61  <font size="4" color="red">
62  WARNING!<br>
63  This will restrict all transactions from being processed. <br>Be sure this is what you want to do.
64  </font>
65  </td>
66  </tr>
67  <tr>
68  <td class='dtl'>
69  Currently Restrict Transactions is set to
70  <span style="font-weight: bold; color: red;" class="err2"><?php echo ($restrict_set ? "Restrict" : "UnRestrict"); ?></span>
71  </td>
72  </tr>
73  <tr><td class="dtl"><hr></td></tr>
74  <tr>
75  <td class='dtl'>
76  You may change the transactions setting for <?php echo $Cu; ?> by selecting a button below.
77  </td>
78  </tr>
79  <tr>
80  <td class='dtl'>
81  <input type="submit" value="Set to Restrict" name="set_restrict">
82  <input type="submit" value="Set to UnRestrict" name="unset_restrict">
83  </td>
84  </tr>
85  <tr><td class="dtl">&nbsp;</td></tr>
86  </table>
87  </td></tr></table>
88  </form>
89 
90 <?php
91 
92 /*
93  * Function: Restrict_Tran
94  * Purpose: this function will get the status and set the Restrict function based on the parameter passed
95  * Parameters: stat_type - qt -- Query For the current Transaction Setting
96  rt -- Set the Transactions to Restricted
97  ut -- Set the Transactions to UnRestricted
98 */
99 function Restrict_Tran($stat_type) {
100 global $Cu, $dbh;
101 
102  // ** FOR THIS CU -- Setup information so I can contact the CORE system
103  $sql = "SELECT liveserver
104  FROM cuadmin
105  WHERE cu = '$Cu' ";
106  $sth = db_query($sql,$dbh);
107  list($Cs) = db_fetch_array($sth,0);
108  db_free_result($sth);
109 
110  $FETCHER = $Cs;
111 
112  // ** FETCH STATUS
113  $fd = @fopen("$FETCHER?type=$stat_type&member=99999999", "r");
114  if ($fd) {
115  // ** Start reading file
116  while ($buff = fread ($fd, 1500)) {
117  $packet .= $buff;
118  }
119 
120  // break file up into pieces
121  $pktpieces = array();
122  $pktpattern='/<([^<>\/]*)>(.*)<\/\\1>/Us';
123  $inqpattern='/<\/*Inquiry>/i';
124 
125 
126  preg_match_all("$pktpattern",preg_replace($inqpattern,"",$packet),$pktpieces);
127 
128  array_shift($pktpieces);
129  foreach ($pktpieces[0] as $pos => $tag) {
130  $tags[(strtolower($tag))] = $pos;
131  }
132  array_shift($pktpieces);
133  list($mem, $pcutoff) = explode("\t",$pktpieces[0][($tags['parameters'])]);
134  // if the packet presents a cutoff date, let it override our request
135  $cutoff = (trim($pcutoff) == "" ? trim($cutoff) : trim($pcutoff));
136  list($mem, $statcode, $statdesc) = explode("\t",$pktpieces[0][($tags['status'])]);
137 
138  fclose($fd);
139  } else {
140  $statcode = "";
141  }
142 
143  return $statcode;
144 }
145 ?>