2 $monLibrary= dirname(__FILE__) .
"/../library";
3 require_once(
"$monLibrary/cu_top.i");
4 require_once(
"$monLibrary/ck_hticket.i");
6 if (!CheckPerm($link, $Hu, basename($_SERVER[
'SCRIPT_NAME']), $_SERVER[
'REMOTE_ADDR'])) {
9 header(
"Location: /hcuadm/hcu_noperm.prg");
13 $dms_ok=array(
'action'=>
'string',
'MAX_FILE_SIZE'=>
'string',
'csub'=>
'string',
14 'upload_file'=>
'string',
'Upload'=>
'string',
'delete'=>
'array',
15 'DFiles'=>
'string',
'mdir'=>
'string',
'newfolder'=>
'string',
16 'ndir'=>
'string',
'cpath'=>
'string',
'view'=>
'string',
'efile'=>
'string',
'cdir'=>
'string',
17 'script_doc'=>
'string',
'act'=>
'string');
23 $top_dir=
"/home/httpd/homecu/monitor/hcudocs";
24 $HCUDocs_MaxPreviousVersion = 5;
28 $allowed_dir = array();
29 $allowed_files = array();
30 $allowed_subs=array();
35 $allow_multi_subdir =
true;
39 $allowed_dir[] =
"HomeCU";
41 $allowed_dir[] =
"Core_Vendors";
42 $allowed_subs[]=
"select trim(vendor) from cuvendors order by vendor;";
43 $allowed_dir[] =
"Image_Vendors";
44 $allowed_subs[]=
"select trim(img) from cuimagevendors order by img;";
45 $allowed_dir[] =
"SSO_Partners";
46 $allowed_subs[]=
"select trim(ssovendor) from cussovendors order by ssovendor;";
48 if ((isset($ndir) ==
true && strlen($ndir) > 0) ) {
51 if (strpos(strrev($csub),
"/") !==
false) {
52 $cdir = substr($csub, 0, strlen($csub) - strpos(strrev($csub),
"/") - 1);
53 $cpath = $top_dir . ($cdir ==
'' ?
"" :
"/$cdir");
54 $csub = substr($cpath, strpos($cpath,$top_dir) + 1 + strlen($top_dir));
62 $cpath = $top_dir . ($csub ==
'' ?
"" :
"/$csub") .
"/$ndir";
63 $csub = substr($cpath, strpos($cpath,$top_dir) + 1 + strlen($top_dir));
65 } elseif (isset($csub) ==
true) {
66 $cpath = $top_dir . ($csub ==
'' ?
"" :
"/$csub");
67 if (strpos($csub,
"/")) {
68 $cdir = substr(strrchr($csub,
"/"), 1);
72 #$msg="csub $csub : cpath $cpath : cdir $cdir"; 79 if (!is_dir($cpath)) {
80 $msg=
"Requested subdirectory $ndir not found. Starting at the top!";
90 if (strpos($cpath, $top_dir) !==
false) {
91 $dir_pos = strpos($cpath, $top_dir);
92 $cspath = substr($cpath, $dir_pos + 1 + strlen($top_dir));
100 $self=$_SERVER[
'PHP_SELF'];
102 $action = (empty($action) ?
"none" : $action);
103 $action = strtolower($action);
147 function create_dir() {
148 global $msg, $mdir, $top_dir, $cpath, $csub, $cdir, $allowed_dir;
154 $dir_to_create = trim($mdir);
155 if (strlen($dir_to_create) == 0) {
156 $msg =
"Problem creating the directory. Please select again.";
158 if (in_array($mdir, $allowed_dir)) {
159 $path_to_dir = $top_dir .
"/" . $dir_to_create;
161 $cdir = basename(rtrim($cpath,
'/'));
162 $path_to_dir = $cpath .
"/" . $dir_to_create;
165 if (is_dir($path_to_dir)) {
166 $msg =
"The directory already exists. It was not created.";
169 if (@mkdir($path_to_dir, 0755) ===
false) {
171 $msg =
"Unknown error creating the directory ($path_to_dir). ";
174 $msg =
"SUCCESS -- a new folder named $dir_to_create was created.";
181 function create_subdir() {
182 global $msg, $allowed_dir, $top_dir, $allow_subdir, $allow_multi_subdir, $max_subdir, $csub, $newfolder, $cdir;
190 $cdir = basename(rtrim(($top_dir . ($csub ==
'' ?
"" :
"/$csub")),
'/'));
191 if ($allow_subdir ==
true) {
194 $mdir = intval($mdir);
198 $newfolder = preg_replace(
"/\W/",
"", $newfolder);
200 $dir_to_create = trim($csub) .
"/" . $newfolder;
201 if (strlen($dir_to_create) == 0) {
202 $msg =
"Problem creating the directory. Please select again.";
206 if ($allow_multi_subdir ==
true || ((array_search($csub, $allowed_dir) !==
false))) {
210 $dirpath = $top_dir .
"/" . $csub;
213 if ($fhandle = @opendir($dirpath)) {
214 while (
false !== ($file = readdir($fhandle))) {
215 if (($file !=
".") && ($file !=
"..") && (substr($file, 0, 1) !=
".")) {
218 if (is_dir($dirpath .
"/" . $file)) {
220 $dirlist[count($dirlist)] = $file;
226 $dirlist_count = count($dirlist);
228 if ($dirlist_count < $max_subdir) {
229 $path_to_dir = $top_dir .
"/" . $dir_to_create;
231 if (is_dir($path_to_dir)) {
232 $msg =
"The directory already exists. It can not be created.";
235 if (@mkdir($path_to_dir, 0755) ===
false) {
237 $msg =
"Unknown error creating the directory. <br> 238 You may need to contact HomeCU for additional help .";
241 $msg =
"SUCCESS -- a new folder named $dir_to_create was created.";
246 $msg =
"Maximum number of folders has been reached. You will need to remove a folder before adding additional.";
250 $msg =
"Unable to create the new folder. Custom folders are only allowed in the top most folder.";
256 $msg =
"Creating subdirectories is NOT allowed.";
260 function print_help($all=
false) {
265 print (
"<script language=\"javascript\">\n 270 function show_help(marker) { 272 var wind_options = \"\"; 273 wind_options = \"toolbar=1,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=0,width=500,height=340\"; 274 helpwin=window.open(\"DocHelp.html#\" + marker,\"_Help\", wind_options); 286 function img_help($mrk) {
287 return "<a href=\"javascript:show_help('$mrk');\"><img src=\"/monitor/images/q1.gif\" border=0 alt=\"View Help\" valign=\"top\"></a>";
291 function print_status() {
292 global $msg, $dir, $self, $cdir, $cpath, $top_dir, $cspath, $csub, $allowed_dir, $allowed_subs, $allowed_files, $allow_subdir, $allow_multi_subdir, $max_subdir, $HCUDocs_MaxPreviousVersion, $view;
294 header(
"Expires: Sat 20 May 1995 03:32:38 GMT");
295 header(
"Pragma: no-cache");
296 header(
"Cache-Control: no-cache, must-revalidate");
301 $viewAll = ($view ==
'ALL' ? true :
false);
305 print
"<html><head><title>HCU_Docs</title> 306 <LINK REL=stylesheet HREF='/monitor/css/monitor.css' TYPE='text/css'> 310 <script type=
"text/javascript" language=
"javascript">
312 <?php print_help(); ?>
314 function check_delete() {
320 if (document.forms[0].elements[
'delete[]'][idx] ==
null) {
322 if (document.forms[0].elements[
'delete[]'] !=
null) {
323 if (document.forms[0].elements[
'delete[]'].checked ==
true) {
328 while (document.forms[0].elements[
'delete[]'][idx]) {
329 if (document.forms[0].elements[
'delete[]'][idx].checked ==
true)
334 if (pt_del ==
true) {
335 if (confirm(
'Are you sure you want to delete the selected files or folders?'))
343 function check_upload() {
351 fullPath = document.forms[0].elements[
'upload_file'].value;
352 lastSlash = fullPath.lastIndexOf(
"\\")
353 fileName = fullPath.substring(lastSlash+1,fullPath.length)
355 fileName = fileName.replace(/[ ;]{1}/g,
"_");
357 if (fileName ==
'') {
360 if (document.forms[0].elements[
'delete[]']) {
361 while (document.forms[0].elements[
'delete[]'][idx]) {
362 if (document.forms[0].elements[
'delete[]'][idx].value == fileName)
369 if (confirm(
'You are about to overwrite the file "' + fileName +
'". Is this what you want to do.')) {
377 function confirm_dir(sdir) {
380 var msg =
"This will create the private directory '" + sdir +
"'. Are you sure you want to continue?";
383 function dir_create(sdir,csub) {
389 url =
"<?php echo $self; ?>?action=create&csub=" + csub +
"&mdir=" + sdir;
390 document.location = url;
392 function new_folder(cur_sub) {
395 foldername = window.prompt(
"Please enter a name for the new directory",
"Folder1");
397 if (foldername !=
null) {
399 foldername = foldername.replace(/\W/g,
"");
400 if (foldername.length > 30) {
401 window.alert (
"The new folder name is NOT allowed to be more than 30 characters. Please enter a shorter name.");
403 url =
"<?php echo $self;?>?action=createsub&csub=" + escape(cur_sub) +
"&newfolder=" + foldername;
404 document.location = url;
410 <form method=
"post" action=
"<?php echo $self ?>" enctype=
"multipart/form-data" >
411 <input type=
"hidden" name=
"action" value=
"upload">
412 <input type=
"hidden" name=
"MAX_FILE_SIZE" value=
"15000000">
413 <input type=
"hidden" name=
"csub" value=
"<?php echo $cspath; ?>">
414 <input type=
"hidden" name=
"cdir" value=
"<?php echo $cdir; ?>">
415 <input type=
"hidden" name=
"cpath" value=
"<?php echo $cpath; ?>">
416 <br><div align=center><table width=95% border=0 cellspacing=0 cellpadding=4>
417 <tr><td colspan=4
class=
"bar" align=center>HomeCU Documents</td></tr>
419 <td
class=
"hdrl"> </td>
420 <td
class=
"hdrl"><a href=
"<?php echo $infourl; ?>/hcuadm/cuilist" target=
"_parent">Credit Union List</a></td>
421 <td colspan=2
class=
"hdrl"><?php echo ($cspath ==
"" ?
" " :
"Folder: $cspath"); ?></td>
423 <?php
if (!(($top_dir == $cpath) && ($top_upload ==
false))): ?>
425 <td colspan=
"4" class=
"dtl" align=
"center">
427 <input type=
"file" name=
"upload_file" size=30><?php echo img_help(
"choose"); ?>
428 <input type=
"submit" name=
"Upload" value=
"Upload File" onclick=
"return check_upload();">
429 <?php echo img_help(
"upload"); ?>
433 <?php
if ($msg !=
""): ?>
435 <td
class=
"msg" colspan=1 align=right><img alt=
"black" src=
'/monitor/images/alert.black.gif'></td>
436 <td
class=
"msg" colspan=3><?php echo $msg ?></td>
447 if ($fhandle = @opendir($cpath)) {
448 while (
false !== ($file = readdir($fhandle))) {
449 if (($file ==
"..") ) {
456 if ((strpos($cpath, $top_dir) !==
false) && ($cpath != $top_dir)) {
458 $dirlist[count($dirlist)] = $file;
462 } elseif (($cpath == $top_dir)) {
464 if (is_file($cpath .
"/" . $file)) {
466 if (in_array($file, $allowed_files))
467 $filelist[count($filelist)] = $file;
470 if (in_array($file, $allowed_dir))
471 $dirlist[count($dirlist)] = $file;
477 } elseif ((($file !=
".") || $viewAll) && ($file !=
"..") ) {
480 if (is_file($cpath .
"/" . $file)) {
481 $filelist[count($filelist)] = $file;
483 if (substr($file, 0, 1) !=
".") {
484 $dirlist[count($dirlist)] = $file;
496 if ($cpath == $top_dir || in_array($cdir, $allowed_dir)) {
497 $help_act = img_help(
"active");
500 <td
class=
"hdr"> </td>
501 <td
class=
"hdr" colspan=
"3">
502 Active Directories $help_act
507 $dirlist_count = count($dirlist);
508 if ($dirlist_count > 0) {
510 array_multisort ($dirlist, SORT_ASC, SORT_STRING);
512 $help_del = img_help(
"deletefolder");
513 foreach ($dirlist as $shortname) {
514 $ftime=date(
"m/d/y g:i:s A",filemtime(
"$cpath/$shortname"));
515 $fenc = urlencode($ftime);
517 if ($shortname ==
"..") {
518 $dirname =
"Parent Folder";
520 $helpdir =
" " . img_help(
"parent");
523 $dirname = $shortname;
526 if ($cpath != $top_dir) {
527 $delurl =
"<input type=\"checkbox\" name=\"delete[]\" value=\"$shortname\">Delete $help_del";
532 $new_file_link =
"<a href='$self?action=edit&act=NEW&csub=" . urlencode($csub) .
"&cdir=" . urlencode($cdir) .
"&efile=$viewpath'><img src='/monitor/images/new.gif' border='0' alt='New HTML File'></a>";
533 $all_file_link =
"<a href='$self?csub=" . urlencode($csub) .
"&cdir=" . urlencode($cdir) . ($view !=
"ALL" ?
"&view=ALL" :
"") .
"'><img src='/monitor/images/quill.gif' border='0' alt='Show All Files'></a>";
537 <a href=
"$self?ndir=$shortname&csub=$cspath">
538 <img src=
'/monitor/images/{$dirgif}.gif' border=
'0' alt=
'Change Folders'></a>
540 <td
class=
"dtll"><a href=
"$self?ndir=$shortname&csub=$cspath">$dirname</a>$helpdir</td>
541 <td
class=
"dtll" nowrap>$ftime</td>
542 <td
class=
"dtll" colspan=
"1">
549 if ($allow_subdir ==
true 550 && (($allow_multi_subdir ==
true || (array_search($cspath, $allowed_dir) !==
false)) && $dirgif ==
"pardir")
551 && ($dirlist_count <= $max_subdir)) {
552 $helpdir =
" " . img_help(
"newfolder");
557 <a href=
"javascript:new_folder('$cspath')">
558 <img src=
'/monitor/images/folderin.gif' border=
'0' alt=
'New Folder'></a>
560 <td
class=
"dtll"><a href=
"javascript:new_folder('$cspath')">New Folder</a>$helpdir</td>
561 <td
class=
"dtll" nowrap>$ftime</td>
562 <td
class=
"dtll" colspan=
"1">
567 <td
class=
"dtll" colspan=
"4"><hr></td>
570 <td
class=
"dtll" colspan=
"4">
581 if (count($filelist) > 0) {
584 foreach ($filelist as $shortname) {
588 if ((substr($shortname, 0, 1) !=
".") || $viewAll) {
592 $ftime=date(
"m/d/y g:i:s A",filemtime(
"$cpath/$shortname"));
595 $file_version_list =
"$ftime <input type='hidden' name='file_version_{$filecount}' value='$shortname'>";
597 $file_version_list=
"<option value='$shortname'>Current - $ftime</option>";
598 for ($idxFileVersion = 1; $idxFileVersion <= $HCUDocs_MaxPreviousVersion; $idxFileVersion++) {
599 $file_version_name =
"$cpath/.{$shortname}.{$idxFileVersion}";
601 if (file_exists($file_version_name)) {
602 $sel_file_val =
".$shortname.$idxFileVersion";
603 $ftime=date(
"m/d/y g:i:s A",filemtime($file_version_name));
604 $file_version_list .=
"<option value='{$sel_file_val}'>{$ftime}</option>";
607 $file_version_list =
"<select name=\"file_version_{$filecount}\" >$file_version_list </select>";
611 $fenc = urlencode($ftime);
612 $viewpath = urlencode(
"$shortname");
614 $filepath = ($cspath ==
"" ?
"/$viewpath" :
"/$cspath/$viewpath");
616 $help_del = img_help(
"delete");
617 $help_file =
" " . img_help(
"filelist");
620 $show_edit_link =
"";
621 if ((strtolower(substr($shortname, (strrpos($shortname,
".") ===
false ? strlen($shortname) : strrpos($shortname,
".")))) ==
".html") && !$viewAll) {
622 $show_edit_link =
"<a href='$self?action=edit&csub=" . urlencode($csub) .
"&cdir=" . urlencode($cdir) .
"&efile=$viewpath'><img src='/monitor/images/a.gif' border='0' alt='Edit File'></a>";
623 } elseif ($viewAll && substr($shortname, 0,1) ==
".") {
624 $show_edit_link =
"<a href='$self?action=restore&csub=" . urlencode($csub) .
"&cdir=" . urlencode($cdir) .
"&efile=$viewpath'><img src='/monitor/images/transfer.gif' border='0' alt='Restore File'></a>";
627 <script language=
"javascript">
629 function Build_File_Link( view_file_idx ) {
633 var file_root =
"/monitor/hcudocs/$cspath";
635 var sel_object = document.getElementById(
"file_version_" + view_file_idx);
636 if (sel_object ==
null) {
637 sel_object = document.forms[0].elements[
'file_version_' + view_file_idx];
640 if (sel_object ==
null) {
641 window.alert (
'Unable to find the file you selected');
645 if (sel_object.type ==
"hidden") {
646 var sel_filename = sel_object.value;
649 file_url =
"$infourl" + file_root +
"/" + sel_filename;
651 var sel_idx = sel_object.selectedIndex;
652 var sel_filename = sel_object.options[sel_idx].value;
655 file_url =
"$infourl" + file_root +
"/" + sel_filename;
660 newwin = window.open(file_url);
669 <a href=
"javascript:void(0);" onClick=
"Build_File_Link('{$filecount}');" ><img src=
'/monitor/images/index.gif' border=
'0' alt=
'View File'></a>
672 <td
class=
"dtll">$shortname $help_file</td>
673 <td
class=
"dtll">$file_version_list</td>
675 <input type=
"checkbox" name=
"delete[]" value=
"$shortname">Delete
687 if (count($filelist) == 0 && count($dirlist) == 0) {
690 <td
class=
"dtll" colspan=
"4">
691 No active directories found.
695 <tr><td colspan=
"4" class=
"dtll"><hr></td></tr>
697 } elseif ((($top_dir == $cpath) && ($top_upload ==
false))){
699 <tr><td colspan=
"4" class=
"dtll"><hr></td></tr>
702 $help_delsel = img_help(
"deleteselected");
704 <tr><td colspan=
"4" class=
"dtll"><hr></td></tr>
706 <td colspan=
"3" class=
"dtll"> </td>
708 <input type=
"submit" name=
"DFiles" value=
"Delete Selected" onclick=
"return check_delete();">
720 if ((count($dirlist) < count($allowed_dir)) && ($cpath == $top_dir)) {
721 $help_in = img_help(
"inactive");
724 <td
class=
"hdr"> </td>
725 <td
class=
"hdr" colspan=
"3">
726 Inactive Directories $help_in
730 <td
class=
"dtll" colspan=
"4">
731 To activate a
private directory click on the folder or the directory name.
736 foreach ($allowed_dir as $key => $value) {
737 if (!in_array($value, $dirlist)) {
741 <a href=
"javascript:dir_create('$value','$cdir')" onclick=
"return confirm_dir('$value');">
742 <img src=
'/monitor/images/folderin.gif' border=
'0' alt=
'Create Directory'></a>
744 <td
class=
"dtll"><a href=
"javascript:dir_create('$value','$cdir')" onclick=
"return confirm_dir('$value');">$value</a></td>
745 <td
class=
"dtll" colspan=
"2"> </td>
752 } elseif ((count($dirlist) >= count($allowed_dir)) && ($cpath == $top_dir)) {
755 <td
class=
"hdr"> </td>
756 <td
class=
"hdr" colspan=
"3">
761 <td
class=
"dtll" colspan=
"4">
762 No inactive directories found.
771 if ($cpath != $top_dir && in_array($cdir, $allowed_dir)){
772 $allowkey=array_search(
"$cdir",$allowed_dir);
773 $allowsql=$allowed_subs[$allowkey];
774 $rs = db_query($allowsql, $link);
775 if(db_num_rows($rs) > 0) {
776 for ($row=0;list($allow) = db_fetch_array($rs,$row); $row++) {
780 $help_in = img_help(
"inactive");
783 <td
class=
"hdr"> </td>
784 <td
class=
"hdr" colspan=
"3">
785 Inactive Directories $help_in
789 <td
class=
"dtll" colspan=
"4">
790 To activate a
private directory click on the folder or the directory name.
795 foreach ($allowed as $key => $value) {
796 if (!in_array($value, $dirlist)) {
800 <a href=
"javascript:dir_create('$value','$cdir')" onclick=
"return confirm_dir('$value');">
801 <img src=
'/monitor/images/folderin.gif' border=
'0' alt=
'Create Directory'></a>
803 <td
class=
"dtll"><a href=
"javascript:dir_create('$value','$cdir')" onclick=
"return confirm_dir('$value');">$value</a></td>
804 <td
class=
"dtll" colspan=
"2"> </td>
813 <td
class=
"hdr"> </td>
814 <td
class=
"hdr" colspan=
"3">
819 <td
class=
"dtll" colspan=
"4">
820 No inactive directories found.
827 if ($cpath == $top_dir || in_array($cdir, $allowed_dir)) {
828 print
"<tr><td colspan=\"4\" class=\"dtll\"><hr></td></tr> 834 function view_form() {
841 $file_path =
"$top_dir/$cspath/$file";
842 $form = file($file_path);
843 if (is_array($form)){
844 print implode(
"", $form);
846 print
"Cannot open $file_path";
850 function save_form() {
851 global $script_doc, $efile, $msg, $replace, $csub, $delete, $top_dir, $Upload, $DFiles, $err_msg, $cdir, $cspath;
854 rotate_file ($efile, $top_dir .
"/" . $cspath);
858 $filepath_name = $top_dir .
"/" . $cspath .
"/" . $efile;
859 if ($fp = fopen($filepath_name,
"w")) {
860 if (!fwrite ($fp, $script_doc)) {
872 function post_form() {
874 global $msg, $upload_file, $upload_file_name, $upload_file_size, $upload_file_type, $replace, $csub, $delete, $top_dir, $Upload, $DFiles, $err_msg, $cdir, $cspath;
876 $cdir = basename(rtrim(($top_dir . ($csub ==
'' ?
"" :
"/$csub")),
'/'));
877 if ((isset($Upload)) && ($Upload !=
'')) {
879 if (!is_uploaded_file($_FILES[
'upload_file'][
'tmp_name']) || ($_FILES[
'upload_file'][
'size'] < 1)) {
880 switch ($_FILES[
'upload_file'][
'error']) {
882 $up_err =
"0: No error, the file was uploaded successfully";
885 $up_err =
"1: The upload is larger than the amount allowable by the upload_max_filesize directive in the php.ini";
886 $up_err =
"1: The file you tried to upload is just too big. The allowable limit is 40mb.";
889 $up_err =
"2: The upload is larger than the MAX_FILE_SIZE directive that was specified via html";
890 $up_err =
"2: The file you tried to upload is just too big. The allowable limit is 15mb.";
893 $up_err =
"3: The file was only partially uploaded";
896 $up_err =
"4: no file was uploaded";
903 $filedir = $top_dir . ($csub ==
'' ?
"" :
"/$csub");
906 $find_ary = array(
"\\",
"/",
" ",
";");
907 $rpl_ary = array(
"_",
"_",
"_",
"_");
908 $us_file_name = str_replace($find_ary, $rpl_ary, $_FILES[
'upload_file'][
'name']);
909 # make sure we still have a valid file name: 910 if (
"$us_file_name" ==
"") {
911 $up_err =
"Error Reported - Invalid Upload to HomeCU Directory";
915 if (
"$up_err" !=
"") {
917 Upload File Error --\n 918 Client Information \n 919 Client Filename: {$_FILES['upload_file']['name']}\n 920 Client Filesize: {$_FILES['upload_file']['size']}\n 921 Client Filetype: {$_FILES['upload_file']['type']}\n\n 922 Client IP: {$_SERVER['REMOTE_ADDR']}\n\n 923 Web Server Information \n 924 Temp File Name - {$_FILES['upload_file']['tmp_name']} 925 Error Reported - $up_err\n\n 929 $notify->line = __LINE__;
930 $notify->file = __FILE__;
931 $notify->callingfunction = __FUNCTION__;
933 $notify->mailto =
"miki@homecu.net";
934 $notify->subject =
"HomeCU Directories upload error";
943 There was an error uploading the file <b>{$_FILES[
'upload_file'][
'name']}</b>.<br>
944 The error reported was: <b>$up_err</b>.<br>
945 Please retry uploading the file.<br>
946 If the problem persists call DMS and report the problem.
955 rotate_file ($us_file_name, $filedir.
"/");
958 $filename = $filedir .
"/" . $us_file_name;
960 if (!move_uploaded_file($_FILES[
'upload_file'][
'tmp_name'], $filename)) {
961 unlink ($_FILES[
'upload_file'][
'tmp_name']);
965 Uh-oh, couldn
't post the file where it belongs. Not sure what happened. Better call DMS. 968 // File was moved change the mod settings 969 $rc = @chmod($filename, 0644); 974 if ((isset($DFiles)) && ($DFiles != '')) { 975 // Now do any of the other postings, such as delete files 976 if (isset($delete)) { 977 foreach ($delete as $filename) { 978 // Be sure there are not / or \ in the file name 979 $us_file_name = str_replace("/", "", $filename); 980 $us_file_name = str_replace("\\", "", $us_file_name); 983 // If checked then we delete the file 984 $delete_file = $top_dir . ($csub == '' ? "" : "/$csub") . "/" . $us_file_name; 985 //$delete_file = $top_dir . ($csub == '' ? "" : "/$csub") . "/" . $filename; 986 //$delete_file = $top_dir . "/" . $csub . "/" . $filename; 988 if (file_exists($delete_file)) { 989 if (is_file($delete_file)) { 991 // ** allow the removal of files that start with "." 992 if (substr($us_file_name, 0, 1) == ".") { 993 if (!@unlink ($delete_file)) { 994 // This will unlink the file from this directory 995 $msg .= "Unable to delete the file! Please try again.<br>"; 997 $msg .= "The file '$filename
' was deleted successfully.<br>"; 1000 // ** Changed this to now rotate the file through the historical process 1001 // * and not have a "current" file 1002 rotate_file ($us_file_name, $top_dir . "/" . $cspath); 1004 } elseif (is_dir($delete_file)) { 1006 $directory_empty = TRUE; 1007 $directory = dir($delete_file); 1008 while (FALSE !== ($item = $directory->read())) { 1009 // If an item is not "." or "..", dir is not empty 1010 if ($item != '.
' && $item != '..
') { 1011 $directory_empty = FALSE; 1015 $directory->close(); 1016 if(($directory_empty == TRUE) && ( @rmdir ($delete_file))) { 1017 $msg .= "The folder '$filename
' was deleted successfully.<br>"; 1019 $msg .= "Unable to delete folder '$filename
'! Please be sure the folder is empty.<br>"; 1028 function restore_file() { 1030 global $self, $efile, $msg, $replace, $csub, $delete, $top_dir, $Upload, $DFiles, $err_msg, $cdir, $cspath, $HCUDocs_MaxPreviousVersion; 1032 // Technically.. I should only be able to restore historical files, I am trying to NOT allow current file to be restored.. makes little sense.. 1033 // So what I need to do is get the original filename from the restored file 1037 $restore_file_tmpname = ""; 1038 $restore_file_basename = $efile; // start with current name 1040 // * trim leading "." 1041 if (substr($restore_file_basename, 0, 1) == ".") { 1042 $restore_file_basename = substr($restore_file_basename, 1); 1044 // * Now truncate the end where the .X may exist 1045 $restore_file_basename = substr($restore_file_basename, 0, strrpos($restore_file_basename, ".")); 1047 $restore_file_tmpname = "." . $restore_file_basename . "." . ($HCUDocs_MaxPreviousVersion + 1); 1049 $restore_file_directory = $top_dir . "/" . $cspath . "/"; 1050 // This is what I was thinking 1051 if (is_file($restore_file_directory . $efile)) { 1053 // Rename the file we are going to restore to .{HCUDocMaximum + 1} 1054 // print "<Br> RENAME - " . $restore_file_directory . $efile . " to " . $restore_file_directory . $restore_file_tmpname; 1055 if (@copy($restore_file_directory . $efile, $restore_file_directory . $restore_file_tmpname)) { 1057 // Next call the Rotate File Function .. Rotate all through 1058 rotate_file ($restore_file_basename, $restore_file_directory); 1059 // print "<br> ROTATE FILE file: " . $restore_file_basename . " dir: " . $restore_file_directory; 1061 // Rename the .{HCUDocMaximum + 1} to current file 1062 @rename($restore_file_directory . $restore_file_tmpname, $restore_file_directory . $restore_file_basename); 1063 // print "<br>RENAME tmp - " . $restore_file_directory . $restore_file_tmpname . " to " . $restore_file_directory . $restore_file_basename; 1067 } // DO NOTHING IF FILE NOT FOUND 1070 function edit_form() { 1072 global $self, $efile, $msg, $replace, $csub, $delete, $top_dir, $Upload, $DFiles, $err_msg, $cdir, $cspath, $act; 1077 // print "efile - $efile<bR>csub - $csub<br>cdir - $cdir<br>cspath - $cspath<br>"; 1079 $folder_path = ($cspath == "" ? " " : "Folder: <a href='$self?cdir=$cdir&csub=$cspath
'>$cspath</a>"); 1083 $folder_path .= " / NEW FILE"; 1084 $filename_formedit = "<input type=\"text\" name=\"efile_new\" value=\"\">.html"; 1086 $folder_path .= " / $efile"; 1088 print <<< print_html 1089 <html><head><title>HCU_Docs</title> 1090 <LINK REL=stylesheet HREF='/monitor/css/monitor.css
' TYPE='text/css
'> 1093 <form method="post" action="$self" enctype="multipart/form-data"> 1094 <input type="hidden" name="action" value="upload"> 1095 <input type="hidden" name="csub" value="$cspath"> 1096 <input type="hidden" name="cdir" value="$cdir"> 1097 <input type="hidden" name="cpath" value="$cpath"> 1098 <br><div align=center><table width=95% border=0 cellspacing=0 cellpadding=4> 1099 <tr><td colspan=4 class="bar" align=center>HomeCU Documents</td></tr> 1101 <td class="hdrl"> </td> 1102 <td class="hdrl"><a href="{$infourl}/hcuadm/cuilist.prg" target="_parent">Credit Union List</a></td> 1103 <td colspan=2 class="hdrl">$folder_path $filename_formedit</td> 1106 <td colspan=4 class="dtl" align="center"> 1110 $filename_formedit = ""; 1111 $filenew = (strtoupper($act) == "NEW"); 1114 // ** Possibly create a new blank file for this, maybe for NEW require a name for the file 1118 // Read the file and send the information to the text area 1119 $cu_file = $top_dir . "/" . $csub . "/" . $efile; 1120 $file_opened = false; 1121 if (file_exists($cu_file)) { 1122 if ($fp = fopen($cu_file, "r")) { 1123 $file_opened = true; 1124 $contents = fread($fp, filesize($cu_file)); 1128 // $filename_formedit = "$efile<input type=\"hidden\" name=\"efile\" value=\"$efile\">"; 1132 // ** For .html extended files -- I want to include the TinyMCE insert 1133 $textarea_TinyMCE = ""; 1135 if ((strtolower(substr($cu_file, (strrpos($cu_file, ".") === false ? strlen($cu_file) : strrpos($cu_file, ".")))) == ".html") || $filenew) { 1136 $textarea_TinyMCE = <<< set_TinyMCE 1137 <script type="text/javascript" src="/monitor/tinymce/jscripts/tiny_mce/tiny_mce.js"></script> 1139 <script type="text/javascript"> 1144 plugins : "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template", 1147 theme_advanced_buttons1 : "save, bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect", 1148 theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor", 1149 theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", 1150 theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,blockquote,pagebreak,|,insertfile,insertimage", 1151 theme_advanced_toolbar_location : "top", 1152 theme_advanced_toolbar_align : "left", 1153 theme_advanced_statusbar_location : "bottom", 1154 theme_advanced_resizing : true, 1158 skin_variant : "silver", 1159 save_enablewhendirty : true, 1160 save_onsavecallback : "savefile" 1162 // Example content CSS (should be your site CSS) 1163 // content_css : "css/example.css", 1166 function savefile () { 1168 // * *Be sure the filename was enterred if this is NEW 1169 // if it is new, then put the filename + .html into the efile hidden field.. 1170 // This becomes the new filename 1171 var objfilename = document.forms[0].elements['efile_new
']; 1172 var objsavedfilename = document.forms[0].elements['efile
']; 1173 var isnewdoc = objfilename != null; 1174 var savefileok = true; 1177 // ** Be sure they have entered a filename for the form 1178 if (objfilename.value == "") { 1179 window.alert ("Enter file name for this new file."); 1182 // *Save the file name to be saved 1183 objsavedfilename.value = objfilename.value + ".html"; 1187 // *FORCE THE SUBMIT 1189 document.forms[0].submit(); 1198 if (($file_opened == true && !$filenew) || ($filenew)) { 1199 $showcontents=htmlspecialchars($contents); 1200 print <<< print_html 1204 <script language="javascript"> 1207 function Preview() { 1208 win = window.open("","htmlWin","scrollbars=1,menubar=1,status=1") 1209 //win.document.write("<BASE HREF='" + document.Tag.baseHref.value + "'>") 1210 win.document.write("<P>") 1211 win.document.write(document.preview.script_doc.value) 1212 win.document.write("</P>") 1216 <form name="preview" action="$self" method="post"> 1217 <input type="hidden" name="action" value="saveedit"> 1218 <input type="hidden" name="csub" value="$cspath"> 1219 <input type="hidden" name="cdir" value="$cdir"> 1220 <input type="hidden" name="cpath" value="$cpath>"> 1221 <input type="hidden" name="efile" value="$efile"> 1223 <textarea name="script_doc" rows=50 cols=90>$showcontents</textarea> 1227 // Problem opening the file 1229 <table align=center border=0 cellpadding=0 cellspacing=0 width=
"60%" class=
"dmsbg"><tr><td>
1230 <table border=0 cellpadding=0 cellspacing=0 width=
"100%">
1233 An incorrect selection was made, please go back to the <a href=
"' . $self . '">menu</a><br>
1238 </td></tr></table>
'; 1241 print <<< print_html 1250 function rotate_file($HCUDocs_Filename, $HCUDocs_Directory) { 1252 // ** This function will rotate the current file along with the max number of 'hidden
' previous versions 1253 // * and rotate through {max previous version} - 1 renamed to {max previous version} and finally current name 1254 // * renamed to {previous version}.1 1256 global $cpath, $top_dir, $HCUDocs_MaxPreviousVersion; 1258 // global $msg, $upload_file, $upload_file_name, $upload_file_size, $upload_file_type, $replace, $csub, $delete, $top_dir, $Upload, $DFiles, $err_msg, $cdir, $cspath; 1260 // $cdir = basename(rtrim(($top_dir . ($csub == '' ? "" : "/$csub")),'/
')); 1262 // Process will be as follows 1263 // * - Delete {Filename}.{MaxVersions} 1264 // * - Loop through remaining previous version, renaming extension to be Numeric + 1 1265 // * - Rename {Filename} to {Filename}.1 1268 // $HCUDocs_Filename = ""; 1269 // $HCUDocs_Directory = ""; 1270 // $HCUDocs_MaxPreviousVersion = 5; 1272 // ** Check to see if Directory has a "/" at the end.. If NOT , then add it 1273 $HCUDocs_Directory .= (substr($HCUDocs_Directory, -1) != "/" ? "/" : ""); 1277 $LoopFilename = "$HCUDocs_Directory" . "." . $HCUDocs_Filename . ".$HCUDocs_MaxPreviousVersion"; 1278 // * First look for the MAX previous version of file and delete if found 1280 if (file_exists($LoopFilename)) { 1281 if (is_file($Loopfilename)) { 1282 if (!@unlink ($delete_file)) { 1283 // NOT ABLE TO DELETE FILE 1293 // * NOW LOOP THROUGH REMAINING Version Numbers, reording {Max -1 } to {Max}, {Max - 2} to {Max - 1}, etc 1294 for ($idxPreVersion = $HCUDocs_MaxPreviousVersion - 1; $idxPreVersion > 0; $idxPreVersion--) { 1295 $LoopFilename = "$HCUDocs_Directory" . "." . $HCUDocs_Filename . ".$idxPreVersion"; 1296 $LoopNewName = "$HCUDocs_Directory" . "." . $HCUDocs_Filename . "." . ($idxPreVersion + 1); 1297 if (file_exists($LoopFilename)) { 1298 // ** File exists.. Rename to be (idxPreVersion) 1299 if (! @rename($LoopFilename, $LoopNewName)) { 1300 // file could NOT be renamed 1306 // ** Rename the original file 1307 $LoopFilename = $HCUDocs_Directory . $HCUDocs_Filename; 1308 $LoopNewName = $HCUDocs_Directory . "." . $HCUDocs_Filename . ".1"; 1310 // ** ONLY Rename if the original file it really exists 1311 if (file_exists($LoopFilename)) { 1312 if (! @rename($LoopFilename, $LoopNewName)) { 1314 // ** COULD NOT RENAME 1320 // ** NOW we should have the hidden files setup... ready to either upload the new file 1321 // ** Or save a file