#!/usr/bin/perl # # filechucker.cgi # # This program is the copyrighted work of Encodable Industries. # Redistribution is prohibited, and copies are permitted only for # backup purposes. You are free to modify the program for your # own use, but you may not distribute any modified copies of it. # # Use of this program requires a one-time license fee. You can # obtain a license here: # # http://encodable.com/filechucker/#license # # This software comes with no warranty. The author and many other # people have found it to be useful, and it is our hope that you # find it useful as well, but it comes with no guarantees. Under # no circumstances shall Encodable Industries be held liable in # any situation arising from your use of this program. We are # generally happy to provide support to all our users, but we can # make no guarantee of support. # # For more information about this program, as well as for help # and support, please visit the following pages: # # Homepage: http://encodable.com/filechucker/ # Contact: http://encodable.com/contact/ $ENV{PATH} = '/bin:/usr/bin'; delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; ($ENV{DOCUMENT_ROOT}) = ($ENV{DOCUMENT_ROOT} =~ /(.*)/); # untaint. my %PREF = (); ### ### User preferences section: adjust these variables ### to suit your own server/setup/tastes. ### ############################################################################ # Title appearing at the top of the page. # $PREF{title} = "FileChucker"; ############################################################################ # Text appearing below the title, before the upload form. # $PREF{intro} = qq`
Upload some files!
`; ############################################################################ # Choose whether the script should display a link to the list of # uploaded files. Note that "members" includes "admins" and # "strangers" includes everyone (i.e. members and admins too). # $PREF{show_link_to_uploads_for_strangers} = 'yes'; $PREF{show_link_to_uploads_for_members} = 'yes'; $PREF{show_link_to_uploads_for_admins} = 'yes'; ############################################################################ # Allow the user to upload multiple files at the same time, up # to this limit. # $PREF{max_files_allowed} = 10; ############################################################################ ### ### The rest of the PREFs are optional and/or unnecessary to ### change most of the time. Try to get the script running ### without changing them first, then adjust them if you want. ### ############################################################################ # Set the maximum size file that can be uploaded. One megabyte # is 1024*1024*1; 5 MB is 1024*1024*5, etc. # $PREF{sizelimit} = 1024*1024*20; ############################################################################ # You can allow or disallow uploads based on file extension. Each of these # two preferences takes a list of extensions separated by commas and/or # spaces. Note that the period must be included with the extension. For # example: # # $PREF{only_allow_these_file_extensions} = '.jpg, .png, .gif'; # # Finally, note that these are not case sensitive. # $PREF{only_allow_these_file_extensions} = ''; $PREF{disallow_these_file_extensions} = '.php .php3 .php4 .php5 .cgi .pl .sh .py .htaccess .htpasswd'; $PREF{allow_files_without_extensions} = 'yes'; ############################################################################ # In both filenames and directory names, convert spaces to underscores, # and remove anything that's not in the set [0-9A-Za-z._-]. # $PREF{clean_up_filenames} = 'no'; ############################################################################ # By default, if you upload a file that's 1 megabyte or bigger, # the file sizes and upload rate will be in MB and MB/s. If # you want to force them to always be in KB instead, set these. # $PREF{force_KB_for_size_display} = 'no'; $PREF{force_KB_for_transfer_rate_display} = 'yes'; ############################################################################ # Options for controlling the display of the uploaded-files list. # You can set the unit, number of decimal places, and the color # that the rows turn to when you hover the mouse over them. You # can also specify how the date should be displayed. Google for # "unix man pages: date (1)" (or just run "man date" on any Unix # system) for more information on the date format. # $PREF{unit_for_size_display_in_uploaded_files_list} = 'KB'; # can be KB, MB, or mixed. $PREF{num_decimals_for_uploaded_files_list_sizes} = 0; $PREF{display_shortened_filename_if_longer_than} = 40; # characters. $PREF{filelist_row_hover_bgcolor} = '#e9e9e9'; $PREF{filelist_row_normal_bgcolor} = 'transparent'; $PREF{date_format_for_filelist} = '%b%d, %I:%M%P'; #$PREF{date_format_for_filelist} = '%Y-%m-%d, %I:%M %P'; #$PREF{date_format_for_filelist} = '%a %b %d, %Y, %H:%M'; #$PREF{date_format_for_filelist} = '%I:%M %P %b %d %Y'; $PREF{only_show_files_with_these_extensions} = ''; $PREF{hide_files_with_these_extensions} = '.php .php3 .php4 .php5 .cgi .pl .sh .py .htaccess .htpasswd'; ############################################################################ # By default, when an upload begins, the progress bar pops out of nowhere # and displays below the "Begin Upload" button. If you want, you can set # this preference so that it clears the rest of the page first, so that the # progress bar & table are the only thing on the screen during the upload. # $PREF{clear_page_during_upload} = 'yes'; ############################################################################ # Password hashes (optional): if you want to require a password # for access to the uploader and/or the list of uploaded files, # you need to set these. Go to: # # yoursite.com/cgi-bin/upload/filechucker.cgi?makePasswordHash # # ...enter the password you want to use into that page, and it # will generate a "hash" of the password, which is a string that # looks something like this: # # cdfc81932491375c34c842bcebc7dc15 # # Copy and paste the hash into one of the following preferences. # Then when you want to log in, enter the password, not the hash. # (This is so that we don't store the actual password on disk, which # would be very insecure.) # # We specify two possible user-levels: member and admin. If you # want, you can use just one of them, and have a single password # for both uploading and viewing the file-list. Or you can specify # both, and set the "must_be_" preferences accordingly, so that only # the admin can view the uploaded files. Or vice-versa. Or you # could require no password to view the file-list, but require one # to upload. Etc, etc. Just set the prefs accordingly. # # Note that the admin is automatically a "member" too, so someone # with the admin password automatically has access to anything that # requires the member password. # # Finally, note that to delete uploaded files, you must be logged # in as admin. So you probably at least want to create the admin # password hash, even if you don't set any of the upload/list prefs # to yes. # $PREF{member_password_hash} = ''; $PREF{admin_password_hash} = '2bac61f75416e291f332dbf88e63c5db'; $PREF{must_be_member_to_upload} = 'no'; $PREF{must_be_admin_to_upload} = 'no'; $PREF{must_be_member_to_list_files} = 'no'; $PREF{must_be_admin_to_list_files} = 'no'; $PREF{must_be_member_to_view_upload_info} = 'no'; $PREF{must_be_admin_to_view_upload_info} = 'no'; $PREF{must_be_member_to_move_items} = 'no'; $PREF{must_be_admin_to_move_items} = 'no'; $PREF{must_be_member_to_make_folder_thru_fileman} = 'no'; $PREF{must_be_admin_to_make_folder_thru_fileman} = 'no'; ############################################################################ # Once you allow someone to download a file from your uploads area, # they will know the path to all your uploads. If you don't want # them to be able to see all the other files by just visiting that # directory's address, you'll need to put a .htaccess file in that # directory with the line "Options -Indexes" (without quotes). # However, as long as they know the address, they can still try to # guess filenames that might be in there. As an extra security # precaution, you can set serialize_all_uploads, which adds a long # pseudo-random number to each filename, making it virtually # impossible that someone could guess the name of a file in the # directory. # $PREF{serialize_all_uploads} = 'no'; ############################################################################ # Even if you don't want to serialize ALL uploads, it can be useful to # automatically serialize an upload if a file with the same name already # exists in the uploads directory. If you'd rather have files get over- # written when a new file with the same name is uploaded, then set this. # $PREF{overwrite_existing_files} = 'no'; ############################################################################ # You can have a datestamp (YYYYMMDD-HHMM) added to the filename for # each upload. It will be added to the end, right before the extension. # $PREF{datestamp_all_uploads} = 'no'; ############################################################################ # FileChucker can automatically rename every file that gets uploaded, # based on a format that you specify here. Note that for this PREF, # the part after the equal sign must be enclosed in single-quotes # (most of the PREFs are that way anyway, even though double-quotes # would work too; but for this one they MUST be single-quotes). # # You can use the following variables in your filename formatting: # # $o - original filename from the user's computer (without extension) # # $e - extension from original filename (without leading period) # # $u - name of user's private directory (null unless you've # enabled the userdir PREFs below) # # $n - sequence number of this file within its original upload # (set to 1 if only a single file was uploaded) # # You can also use variables of the form %v to insert date/time # values based on the standard date formatting variables; Google for # "unix man pages: date (1)" (or just run "man date" on any Unix # system) for more information on the date format. # # Finally, you can include variables from either the URL or from a # cookie by using $URL{varname} or $COOKIE{cookiename}. # # And anything not preceded by a dollar-sign or a percent-sign will be # passed straight through as literal text. # # For example, if you set: # # $PREF{reformat_filenames_for_all_uploads} = '%Y%m%d-$u_$n-$COOKIE{foo}-$o.$e'; # # ...and then a user uploads 3 files, on say Feb 28 2006, then they # will be renamed to: # # 20060228-userdirname_1-fooCookieValue-originalfilename.ext # 20060228-userdirname_2-fooCookieValue-originalfilename.ext # 20060228-userdirname_3-fooCookieValue-originalfilename.ext # # Finally note that to disable this, you must comment it out or set # it to null (''). # $PREF{reformat_filenames_for_all_uploads} = ''; ############################################################################ # Create an info file for each upload, containing info like the uploader's # IP/hostname/user-agent, timestamps, elapsed time, etc. # $PREF{store_info_about_each_upload} = 'yes'; ############################################################################ # Allow the uploader to enter comments about the file(s) they are # uploading. There will be one comments box per file. Note that # this requires you to enable the store_info_about_each_upload PREF. # $PREF{display_comments_box_for_uploads} = 'no'; $PREF{comments_box_intro} = 'Enter any comments/info about this file:'; $PREF{comments_box_size} = '350x45'; # in pixels. ############################################################################ # Some servers seem to not set $ENV{DOCUMENT_ROOT} properly (in one case, # for users who serve pages from their home directories), so we'll make # our own version. Most of the time it should be set to the doc-root, # but if necessary you can adjust this here. # $PREF{DOCROOT} = $ENV{DOCUMENT_ROOT}; ############################################################################ # This is where the uploaded files will go. It must be world-readable # and world-writable, aka "chmod a+rwx" or "chmod 0777". Set this to # "/dev/null" if you want the files to not be saved at all. # $PREF{uploaded_files_dir} = '/uploads'; ############################################################################ # The previous 'uploaded_files_dir' preference can specify one of three # types of directories: # # - absolute: for example /home/anthony/uploaded_files/ on Unix systems, # or c:\uploaded_files on Windows systems. # # - absolute_within_docroot: if you set uploaded_files_dir to '/uploaded_files' # and your DOCROOT is /var/www then it will be at /var/www/uploaded_files. # Or if your DOCROOT is c:\inetpub\wwwroot then it will be at # c:\inetpub\wwwroot\uploaded_files. # # - relative: the directory will be located in the same place as this script, # so if you put the script at /var/www/cgi-bin/uploads/filechucker.cgi then # the directory will be at /var/www/cgi-bin/uploads/uploaded_files. # $PREF{uploaded_files_dir_type} = 'absolute_within_docroot'; ############################################################################ # If you set uploaded_files_dir_type to absolute, then we won't be able to # link to the files from your website, because they aren't in the DOCROOT. # That's probably not what you wanted, but if it really is, and you're doing # something like manually moving the files to somewhere else within your # DOCROOT later, then enter that path here. Otherwise just leave this # commented out. # #$PREF{uploaded_files_urlpath} = ''; ############################################################################ # This is where logfiles are stored. This must be world-readable and # world-writable. But if you're going to enable the database-backend option # (see below), then you can skip the logpath PREFs. # $PREF{logpath} = 'logs'; ############################################################################ # The previous 'logpath' preference can specify one of three # types of directories: # # - absolute: for example /home/anthony/logs/ on Unix systems, # or c:\logs on Windows systems. # # - absolute_within_docroot: if you set logpath to '/logs' # and your DOCROOT is /var/www then it will be at /var/www/logs. # Or if your DOCROOT is c:\inetpub\wwwroot then it will be at # c:\inetpub\wwwroot\logs. # # - relative: the directory will be located in the same place as this script, # so if you put the script at /var/www/cgi-bin/uploads/filechucker.cgi then # the directory will be at /var/www/cgi-bin/uploads/logs. # $PREF{logpath_type} = 'relative'; ############################################################################ # The logfiles are just used during each upload, to keep track of # how much data has been sent, how much time has elapsed, etc. # They aren't used at all after an upload has completed, so you # probably want them deleted right away. Note that these are # different from the info-files which tell you who uploaded what. # $PREF{delete_logfiles_immediately} = 'yes'; ############################################################################ # If you're using SSI: # () # or a PHP include: # () # to display this script at a shorter URL (like mysite.com/upload/ instead # of mysite.com/cgi-bin/upload/filechucker.cgi) then enter that shorter URL # here. Otherwise leave it set to $ENV{SCRIPT_NAME}. # $PREF{here} = $ENV{SCRIPT_NAME}; ############################################################################ # You can have the script send you an email whenever a new upload happens. # It can be sent to as many recipients as you want. Most of the email PREFs # are fairly self-explanatory, but here are a few notes: the sender address # doesn't have to be a real address, but it DOES have to end with a real # domain name. The smtp server is probably localhost or mail.yoursite.com, # and we'll try both smtp and sendmail when trying to send an email. The # email type can be either html or text, and the failure action can be # either die_on_email_error or null, in which case we'll just ignore the # error. # $PREF{send_email_notifications} = 'no'; $PREF{email_notification_recipient_1} = 'me@mysite.com'; $PREF{sender_email_address} = 'filechucker@mysite.com'; $PREF{smtp_server} = 'localhost'; $PREF{path_to_sendmail} = '/usr/sbin/sendmail'; $PREF{email_type} = 'html'; $PREF{email_subject} = "New upload on mysite.com"; $PREF{email_failure_action} = 'die_on_email_error'; ############################################################################ # This prints some debugging output in an HTML comment at the bottom of the # page, if you pass "debug" as the query-string. Don't enable it unless # you can't get the script to work and you want to try and figure out why. # $PREF{enable_debug} = 'no'; ############################################################################ # Enable this when you're first trying to get the script running; disable # it after the script is working properly on your server. # $PREF{show_errors_in_browser} = 'yes'; ############################################################################ # By default, if your server's version of the CGI.pm module is >= 3.03, # then we'll use its upload hook. If it's older than 3.03, we'll do it # manually, since older versions don't support the upload hook. This # means we can't show the counts for number of files completed/remaining, # but if your server has an ancient version of the CGI.pm module, then # you have no choice. Anyway, this PREF is in case the script isn't # working for you, even though you DO have v3.03 or newer. Setting this # to 'yes' will force the manual behavior, and the only loss will be the # aforementioned files-completed/files-remaining; the time and size will # still display properly. # $PREF{disable_upload_hook} = 'no'; ############################################################################ # FileChucker can use a database backend instead of diskfiles to store # its temporary working data, if you'd like. There's really no benefit # of one method over the other (and on servers that perform write-caching, # thus preventing the progress bar from working properly, the database # backend doesn't actually work around the problem, as we had thought it # might). # $PREF{use_database_backend} = 'no'; ############################################################################ # The database name can optionally also have a :hostname after the # database-name. Here are two commented-out examples for reference: # # $PREF{dbname} = 'mydbname'; # $PREF{dbname} = 'mydbname:mydbhost'; # #$PREF{dbname} = 'mydbname:mydbhost'; ############################################################################ # Your database username and password. It needs privileges for INSERT, # UPDATE, SELECT, DELETE, and CREATE. If you're paranoid and don't want # to give it CREATE privs, then see the create_db_table() function to find # out the column types, so you can create the table manually. # $PREF{dbuser} = ''; $PREF{dbpass} = ''; ############################################################################ # The name of our table in your database. # $PREF{enc_uploader_table_name} = 'enc_upload_info'; ############################################################################ # You probably don't want the database entries filling up your DB since # they don't actually contain any useful information after the upload is # complete. But you can disable this if for some reason you want them kept. # Note that this doesn't delete the uploaded files; they aren't stored in # the database. # $PREF{delete_database_entires} = 'yes'; ############################################################################ # Allow users to upload to subdirectories if they want. # $PREF{enable_subdirs} = 'yes'; ############################################################################ # Allow users to create new subdirectories (but only within your # uploaded_files_dir, of course). # $PREF{enable_new_subdir_creation} = 'yes'; $PREF{max_num_of_subdir_levels} = 4; $PREF{max_length_of_new_subdir_names} = 25; ############################################################################ # Only allow each user to access their own upload directory. The user's # directory is determined by the preferences you set below; it will either # come from ?userdir=foo on the URL, or from a username cookie that's set # by your site's existing login framework. If you don't want any kind of # username-based directories, and you want all users to be able to upload # to wherever they want, then don't set this. # $PREF{enable_username_based_subdirs} = 'no'; ############################################################################ # If you're dropping FileChucker into an existing system with lots of # users, you may not want to manually create a user subdirectory for each # one. In that case you can enable this, and then anyone who visits with # ?userdir=foo or with foo in their username cookie will cause the username # directory to be created automatically. # $PREF{auto_create_userdirs} = 'no'; ############################################################################ # Enable ?userdir=username (or ?userdir=whatever) on the URL to automatically # select the upload subdirectory. Note that this is probably insecure and # you should use enable_userdir_from_cookie instead. # $PREF{enable_userdir_on_url} = 'no'; ############################################################################ # If you want to use ?userdir=username (or ?userdir=whatever) on the URL, to # automatically select the directory into which the user's files will be # uploaded, then you may also want to set url_without_userdir_is_error, so # that sneaky users can't try to manually manipulate the URL and remove the # username, gaining access to all the other users' upload directories. # $PREF{url_without_userdir_is_error} = 'yes'; ############################################################################ # If you want per-username upload subdirectories, and you already have some # kind of login framework in place on your site that stores usernames in # cookies, then you can use this to automatically choose the right subdir # based on the value in the cookie. This means that each user will only # be able to view and upload to his own subdirectory within your # uploaded_files_dir. # $PREF{enable_userdir_from_cookie} = 'no'; $PREF{userdir_cookie_name} = 'username'; ############################################################################ # After a successful upload, we normally display a page that says # "upload complete" and lists the uploaded files, their sizes, etc. # If you want, you can redirect to some other page instead. This # value MUST start with http:// or https:// and it MUST be enclosed # in single-quotes, not double-quotes. Note that you can include # variables in the value from either the URL or from a cookie by # using $URL{varname} or $COOKIE{cookiename}. For example: # # $PREF{after_upload_redirect_to} = 'http://mysite.com/foo/bar/?baz=$URL{baz}&bim=$COOKIE{bim}'; # $PREF{after_upload_redirect_to} = ''; ############################################################################ ### ### End of user preferences section. You probably don't want to mess with ### anything below here unless you really know what you're doing. ### ############################################################################ my $version = "2.55t"; if($ENV{QUERY_STRING} eq 'version') { print "Content-type: text/plain\n\n"; print "$version\n"; exit; } my ($cwd) = ($ENV{SCRIPT_FILENAME} =~ m!^(.+)/.*?$!); chdir $cwd; $| = 1; use strict; #use warnings; if($PREF{show_errors_in_browser} =~ /yes/i) { use CGI::Carp 'fatalsToBrowser'; } use Fcntl; use CGI; use POSIX; use CGI qw/:standard/; eval { require DBI; }; die "$0: $@\n" if $@ && $PREF{use_database_backend} =~ /yes/i; eval { require IO::Socket; }; die "$0: $@\n" if $@ && $PREF{use_ipc_backend} =~ /yes/i; my $qs = $ENV{QUERY_STRING}; load_prefs(); my $output_started = 0; my $starttime = time; my $total_upload_size = (); my $errorlogfh = (); my %temp = (); my $num_files_in_progress_or_done = 0; my $total_file_count = $qs =~ /(?:^|&)items=(\d+)(?:&|$)/ ? $1 : 1; my $dbh = $PREF{use_database_backend} =~ /yes/i ? get_db_connection() : ''; my $ampm = lc(strftime("%p", localtime(time))); my $shortdatetime = strftime("%a%b%d,%Y,%I:%M", localtime(time)).$ampm; my $shortdatetime_forfilename = strftime("%a%b%d,%Y,%Hh%Mm%Ss", localtime(time)).$ampm; my $datestring8 = strftime("%Y%m%d", localtime(time)); $CGI::POST_MAX = $PREF{sizelimit} =~ /^\d+$/ ? $PREF{sizelimit} : 1024 * 1024 * 3; my (%DLOG, %TOLDPROGRESSSERVER, $dlog) = (); #open($dlog, ">>logs/fcdebug.log") or die "$0: couldn't open debug log for appending: $!\n"; if($qs =~ /serial=(\d+)&action=get_progress_and_size/) { print "Cache-Control: no-store, no-cache\n"; print "Content-type: text/xml\n\n"; my ($progress,$currentfile,$totalfiles,$size,$elapsedtime) = get_progress_and_size($1); if($progress eq 'ENOLOG') { print "ERROR: the log file hasn't been created yet; probably your server is doing some write-caching so the log doesn't get created when we create it -- it actually gets created AFTER the upload is complete, making progress reporting impossible."; exit; } elsif($progress eq 'ENORAWPOST') { print "ERROR: the rawpost file hasn't been created yet; probably your server is doing some write-caching so the file doesn't get created when we create it -- it actually gets created AFTER the upload is complete, making progress reporting impossible."; exit; } my $toobig = $size > $CGI::POST_MAX ? '|toobig' : ''; my $finished_file_count = $currentfile ? $currentfile - 1 : 0; my $output = "$progress|$size|$elapsedtime|$finished_file_count|$total_file_count" . $toobig; print $output; } elsif($qs =~ /(?:^|&)action=listfiles(?:&|$)/) { list_uploaded_files(); } elsif($qs eq 'makePasswordHash') { make_password_hash(); } elsif($qs =~ /(?:^login$|action=login&target=(.+?)(&|$))/) { do_login($1); } elsif($qs eq 'logout') { do_logout(); } #elsif($qs eq 'get_logo') #{ # my $logo = get_logo(); # print "Content-type: image/png\n\n"; # print `uudecode -o /dev/stdout $logo`; #} elsif($qs =~ /action=delete(?:&path=(.*?))?&(file|dir)=(.+?)(&really=yes)?(?:&|$)/) { delete_item($1,$2,$3,$4); } elsif($qs =~ /action=(move|rename)&(file|folder)=(.+?)&src=(.*?)(?:&dst=(.+?))?(?:&|$)/) { move_item($1,$2,$3,$4,$5); } elsif($qs =~ /action=fileinfo&path=(.*?)&file=(.+?)(?:&|$)/) { show_fileinfo($1, $2); } elsif($qs =~ /action=mkdir(?:&path=(.+?)(?:&dirname=(.+))?)?(?:&|$)/) { make_dir($1,$2); } elsif($ENV{REQUEST_METHOD} =~ /post/i) { process_upload(); } else { print_new_upload_form(); } sub print_new_upload_form() { do_authentication('upload','redirect'); start_html_output('Upload a file', 'css', 'js'); my $numitems = $qs =~ /(?:^|&)items=(\d+)(?:&|$)/ ? $1 : 1; $numitems = 1 if $numitems > $PREF{max_files_allowed}; print qq`Files | Size | Time | |
Total | $total_file_count | ? | ??:??:?? |
Completed | 0 | 0 | 00:00:00 |
Remaining | $total_file_count | ? | ??:??:?? |
', '
'); ($h3,$h3end,$h4,$h4end,$p,$pEnd) = ('', '
', '', '
'); } else { $pEnd = "\n"; } my $message = qq`${h3}New File(s) Uploaded${h3end}\n` . qq`\n${h4}Upload Started: $shortdatetime${h4end}` . qq`\n${h4}Upload Finished: $shortdatetime_end${h4end}` . qq`\n${h4}Uploader's IP Address: $ip${h4end}` . qq`\n${h4}Uploader's Hostname: $host${h4end}` . qq`\n${h4}Uploader's User-Agent: $ENV{HTTP_USER_AGENT}${h4end}` . qq`\n\n${h4}Total Uploaded Data: $uploadsize${h4end}` . qq`\n`; for(my $i=1; $i<=$numitems; $i++) { next if $files_left_blank_by_user{$i}; my ($file, $size, $link) = ($output{"linktofile_for_email$i"}, $output{"filesize$i"}, undef); if($PREF{email_type} =~ /html/i) { #($link,$file) = ($file =~ m!$PREF{up_icon} [Parent Directory] | `; print qq`-- | `; $parent_dir = $parent_dir ? "$PREF{uploaded_files_realpath}/$parent_dir" : $PREF{uploaded_files_realpath}; # must remove trailing slash or stat doesn't work on Win32. my $mtime = strftime($dateformat, localtime((stat($parent_dir))[9])); my $ctime = strftime($dateformat, localtime((stat($parent_dir))[10])); print qq`$mtime | `; print qq`-- | `; print qq`-- | ` if user_has_move_rights(); # no move link on Parent Directory. print qq`-- | ` if admin_is_logged_in(); # no delete link on Parent Directory. print qq`||
$PREF{dir_icon} $displayname | `; print qq`-- | `; my $mtime = strftime($dateformat, localtime((stat($fulldir))[9])); my $ctime = strftime($dateformat, localtime((stat($fulldir))[10])); print qq`$mtime | `; print qq`-- | `; print qq`mv | ` if user_has_move_rights(); print qq`del | ` if admin_is_logged_in(); print qq`||
$PREF{file_icon} $displayname | `; my $size = -s "$PREF{uploaded_files_realpath}/$path$file"; my $numdec = $PREF{num_decimals_for_uploaded_files_list_sizes} =~ /^(\d+)$/ ? $1 : 0; if($PREF{unit_for_size_display_in_uploaded_files_list} =~ /MB/i) { $size = sprintf("%.${numdec}f", $size /= 1024*1024); $size .= ' MB'; } elsif($PREF{unit_for_size_display_in_uploaded_files_list} =~ /KB/i) { $size = sprintf("%.${numdec}f", $size /= 1024); $size .= ' KB'; } else { if($size >= 1024*1024) { $size = sprintf("%.${numdec}f", $size /= 1024*1024); $size .= ' MB'; } else { $size = sprintf("%.${numdec}f", $size /= 1024); $size .= ' KB'; } } print qq`$size | `; my $fulldir = "$PREF{uploaded_files_realpath}/$path"; my $mtime = strftime($dateformat, localtime((stat("$fulldir$file"))[9])); my $ctime = strftime($dateformat, localtime((stat("$fulldir$file"))[10])); print qq`$mtime | `; #print qq`move | `; #print qq`move | `; my $info_link = user_has_info_rights() && -e get_info_filename_withpath("$PREF{uploaded_files_urlpath}/$path$file") ? qq`info` : '--'; print qq`$info_link | `; print qq`mv | ` if user_has_move_rights(); print qq`del | ` if admin_is_logged_in(); print qq`
$PREF{file_icon} $displayname | `; my $size = -s "$PREF{uploaded_files_realpath}/$file"; my $numdec = $PREF{num_decimals_for_uploaded_files_list_sizes} =~ /^(\d+)$/ ? $1 : 0; if($PREF{unit_for_size_display_in_uploaded_files_list} =~ /MB/i) { $size = sprintf("%.${numdec}f", $size /= 1024*1024); $size .= ' MB'; } elsif($PREF{unit_for_size_display_in_uploaded_files_list} =~ /KB/i) { $size = sprintf("%.${numdec}f", $size /= 1024); $size .= ' KB'; } else { if($size >= 1024*1024) { $size = sprintf("%.${numdec}f", $size /= 1024*1024); $size .= ' MB'; } else { $size = sprintf("%.${numdec}f", $size /= 1024); $size .= ' KB'; } } print qq`$size | `; my $fulldir = "$PREF{uploaded_files_realpath}/"; my $mtime = strftime($dateformat, localtime((stat("$fulldir$file"))[9])); my $ctime = strftime($dateformat, localtime((stat("$fulldir$file"))[10])); print qq`$mtime | `; my $info_link = user_has_info_rights() && -e get_info_filename_withpath("$PREF{uploaded_files_urlpath}/$file") ? qq`info` : '--'; print qq`$info_link | `; print qq`del | ` if admin_is_logged_in(); print qq`
However, there was a problem removing the infofile:
$infofile_error
\n\n`; } } else { my $infofile_errors = delete_directory($diskitem); print qq`
However, there were problems deleting the infofile(s):
` . join "\n
", @$infofile_errors . qq`\n
`; } } print_footer_links('back','list'); finish_html_output('power'); } else { start_html_output('Confirm deletion', 'css'); if($itemtype eq 'file') { print qq`$siteitem
` . qq`\n`; my ($filecount, $dircount) = count_items($diskitem); if($filecount || $dircount) { print qq`\nThis directory contains $filecount file(s) and $dircount folder(s). ` . qq`\nIf you delete it, they will all be deleted too. Are you sure you want ` . qq`\nto delete this directory and all its contents?
` . qq`\n`; } } print qq`\n` . qq`\n`; finish_html_output('power'); } } sub move_item { my $action = shift; my $itemtype = shift; my $item = shift; my $src = shift; my $dst = shift; unless(user_has_move_rights()) { start_html_output('Error: Authentication Required', 'css', 'js'); print qq`$item
` . qq`$urlsrc
` . qq`$item
` . qq`$dst
` . qq`
However, there were problems moving the infofile(s):
` . join "\n
", @infofile_errors . qq`\n
`; } print_footer_links('back','list'); finish_html_output('power'); } else { die_nice($errormsg); } } } else { start_html_output("Move/Rename $itemtype", 'css'); print qq`$item
` . qq`\n$urlsrc
` . qq`\n$item
` . qq`\n\n\n`; my $closed_pretag_already = 0; foreach my $line (@contents) { if($line =~ /^(Uploader's user-agent: )(.*)$/) { print qq`\n
`; } elsif($line =~ /^(Uploader's comments:)$/) { print qq`\n
' . $line; } else { print $line; } } print qq`\n