Odyssey
tr_export.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('w'=>'digits','user_name'=>'string','wc'=>'string','set_trunc'=>'string','unset_trunc'=>'string');
14 
15 dms_import($dms_ok);
16 
17  if (isset($w) == false || $w > 2) $w = "1";
18 
19  $dbh = $link;
20 
21  switch ($w):
22 
23  case "1":
24  cu_header("Truncate Export");
25 
26  $tr_hist = $sql_row['histtrunc'];
27 
28 ?>
29  <form action="tr_export.prg" method="post" onsubmit='return confirm( "Are you sure?" )'>
30  <input type="hidden" value="<?php echo $user_name; ?>" name="user_name">
31  <input type="hidden" value="<?php echo $wc; ?>" name="wc">
32  <input type="hidden" value="2" name="w">
33  <table border=0 align=center cellpadding=3 cellspacing=0 width=500 class="dmsbg"><tr><td>
34  <table border=0 cellpadding=1 cellspacing=0 width="100%" bgcolor=white>
35  <tr>
36  <td class='bar' align=center>
37  Reset Export
38  </td>
39  </tr>
40  <tr>
41  <td align=center class='dtl' style="background-color:#CCCC00;">
42  <font size="4">
43  CAUTION!<br>
44  This will delete the export id log of this Credit Union.
45  </font>
46  </td>
47  </tr>
48  <tr>
49  <td class='dtl' style='padding:10px;'>
50  The export id log file will be backed up and truncated. The only reason for this is if the core system
51  has started using ids that are lower than the highest id in the current export file.
52  </td>
53  </tr>
54  <tr>
55  <td class='dtl' style='padding:10px;'>
56  Are you sure you want to truncate the file for this credit union (<?php echo $user_name ?>)?
57  </td>
58  </tr>
59  <tr>
60  <td class='dtl'>
61  <table style="width:100%; text-align:center;">
62  <tr>
63  <td><input type="submit" id="submit" value="Yes" name="do_truncate"></td>
64  <td><input type="button" value="No" onClick="location.href='<?php echo "$infourl/hcuadm/cuview.prg?user_name=$user_name&wc=$wc" ?>'"></td>
65  </tr>
66  </table>
67  </td>
68  </tr>
69  </table>
70  </td></tr></table>
71 <?php
72  break;
73  case "2":
74  // make a backup (overwritting if necessary) and then truncate the file
75  $filePath = "/home/$user_name/tmp/";
76  $sourceName = "exportid.log";
77  $destName = "exportid.logO";
78 
79  // blindly copy
80  $result = copy( $filePath . $sourceName, $filePath . $destName );
81 
82  if ( $result ) {
83  $handle = fopen( $filePath . $sourceName, "w" );
84  if ( $handle ) {
85  fclose( $handle );
86  }
87  }
88 
89  if ( !$result || !$handle ) {
90  cu_header("Truncate Export");
91  print ("<form>");
92  cu_message("Unexpected errors!<br>Try again.");
93  if ( !result ) {
94  cu_message( "Copy to backup failed." );
95  } else {
96  cu_message( "Truncating file failed." );
97  }
98  }
99  else {
100  // Redirect to the main page
101  header("Location: $infourl/hcuadm/cuview.prg?user_name=$user_name&wc=$wc");
102  exit;
103  }
104 ?>
105 
106 <?php
107  break;
108  endswitch;
109 ?>
110 
111  </form>
112  </body>
113  </html>