phpgtk__legacy/wiki1/wiki.d/PmWiki.UploadsAdmin

22 lines
8.5 KiB
Text

version=pmwiki-1.0.5
newline=²
text=PmWiki has a feature script called @@upload.php@@ that allows users to upload files to the wiki server from a web browser. These files can then be easily accessed using markup within wiki pages. This page describes how to install and configure the upload feature.²²!!!Some notes about security²²1. Keep in mind that letting users (anonymously!) upload files to your web server does entail some amount of risk. The @@upload.php@@ script has been designed to reduce the hazards, but {{WikiAdministrator}}s should be aware that the potential for vulnerabilities exist, and that misconfiguration of the upload utility could lead to unwanted consequences.²²2. By default, authorized users are able to overwrite files that have already been uploaded, without the possibility of restoring the previous version of the file. If you want to disallow users from being able to overwrite files that have already been uploaded, add the following line to ''config.php'':²² $EnableUploadOverwrite = 0;²²!!!Basic installation²²The ''upload.php'' script is automatically included from ''stdconfig.php'' if the $EnableUpload variable is true in ''config.php''. In addition, ''config.php'' can set the $UploadDir and $UploadUrlFmt variables to specify the local directory where uploaded files should be stored, and the URL that can be used to access that directory. By default, $UploadDir and $UploadFmt assume that uploads will be stored in a directory called ''uploads'' within the current directory (usually the one containing ''pmwiki.php''). In addition, ''config.php'' should also set a default upload password (see PasswordsAdmin).²²Thus, a basic ''config.php'' for uploads might look like:² ² <?php² $EnableUpload = 1;² $UploadDir = "/home/john/public_html/uploads";² $UploadUrlFmt = [="http://www.john.com/~john/uploads";=]² $DefaultPasswords['upload'] = crypt('mysecret');² ## more configuration entries here...² ?>²²For the upload feature to work properly, the directory given by [=$UploadDir=] must be writable by the web server process, and it must be in a location that is accessible to the web somewhere (e.g., in a subdirectory of ''public_html''). The WikiAdministrator can either create the upload directory manually, or PmWiki will attempt to create the directory when it is run with the upload feature enabled. To have PmWiki automatically create the directory, (1) change the permissions of the parent directory to 2777, (2) execute PmWiki with the upload feature enabled, (3) verify that the upload directory is created, and (4) restore the parent directory's permissions to their previous value (755 is generally "safe"). ²²For example, if the upload directory is going to be "/home/john/public_html/uploads", one would do "@@chmod 2777 /home/john/public_html@@", execute ''pmwiki.php'', make sure that the upload directory was created ("@@ls /home/john/public_html@@"), and restore the permissions of the parent to normal ("@@chmod 755 /home/john/public_html@@").²²Once the upload feature is enabled, users can access the upload form by adding "?action=upload" to the end of a normal PmWiki URL. The user will be prompted for an upload password similar to the way other pages ask for passwords (see {{Passwords}} and PasswordsAdmin for information about setting passwords on pages, groups, and the entire site).²²Another way to access the upload form to insert the markup "@@[=Attach:filename.ext=]@@" into an existing page, where @@filename.ext@@ is the name of a new file to be uploaded. When the page is displayed, a '?-link' will be added to the end of the markup to take the author to the upload page.²²By default, PmWiki will organize the uploaded files into separate subdirectories for each group. This can be changed by modifying the $UploadPrefixFmt variable.²²!!!Restricting uploaded files²²The ''upload.php'' script performs a number of verifications on an uploaded file before storing it in the upload directory. The basic verifications are described below.²²'''filenames''' - the name for the uploaded file can contain only letters, digits, underscores, hyphens, and periods, and the name must begin and end with a letter or digit. The variable [=$UploadNamePattern=] controls the names for uploaded files.²²'''file extension''' - only files with approved extensions such as ".gif", ".jpg", ".doc", etc. are allowed to be uploaded to the web server. This is vitally important for server security, since the web server might attempt to execute or specially process files with extensions like ".php", ".cgi", etc. ²²'''file size''' - By default ''upload.php'' limits all uploads to 50K bytes, as specified by the $UploadMaxSize variable. Thus, to limit all uploads to 100K, simply specify²² $UploadMaxSize = 100000;²²However, ''upload.php'' allows maximum file sizes to be specified for each type of file uploaded. Thus, an administrator can restrict ".gif" and ".jpeg" files to 20K, ".doc" files to 200K, and all others to the size given by $UploadMaxSize. The $UploadExtSize array is used to determine which file extensions are valid and the maximum upload size (in bytes) for each file type. For example:²² $UploadExtSize['gif'] = 20000; # limit .gif files to 20K²²Setting an entry to zero disables file uploads of that type altogether:²² $UploadExtSize['zip'] = 0; # disallow .zip files ²²Another array called $UploadExts is used to fill $UploadExtSize with extensions that should be limited to $UploadMaxSize. By default $UploadExts has a number of popular (and "safe") file extensions in it, but this can be changed if the administrator wants to drastically limit the types of uploads. For example:²² $UploadExts = array('gif','jpeg','jpg','png','ppt'); ² $UploadMaxSize = 20000;² $UploadExtSize['ppt'] = 150000;² $UploadExtSize['doc'] = 150000;²²allows only GIF, JPEG, and PNG files up to 20K, [=PowerPoint=] and Word files up to 150K, and all other file types are refused.²²There are two other factors involved that affect upload file sizes. In Apache 2.0, there is a [=LimitRequestBody=] directive that controls the maximum size of anything that is posted (including file uploads). Apache has this defaulted to unlimited size. However, some Linux distributions including Red Hat limit postings to 512K so this may need to be changed or increased.²For this action you only have to edit the ''php.conf'' file located in your apache configuration directory (mostly ''/etc/httpd/conf.d'') ²²PHP itself has two limits on file uploads. The first is the upload_max_filesize parameter, which is set to 2M by default. The second is post_max_size, which is set to 6M by default.²²With the variables in place--PmWiki's maximum file size, Apache's request-size limits, and the PHP file size parameters, the maximum uploaded file size will be the smallest of the three variables. ²²''TODO: finish documenting UploadsAdmin''²²!!!Other notes²²* Note that read access to uploaded files is not controlled by any of the page or group attributes--uploaded files are accessible even if pages are protected by read passwords.²²%trail%<<|PmWiki.DocumentationIndex|>>
time=1104152923
host=68.167.115.34
agent=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.1) Gecko/20040707
rev=49
post= Save
name=PmWiki.UploadsAdmin
author=scott
diff:1100969967:1084549470:=6d5²< [[http://diskrecovery.raidrescue.com/ _]] [[http://disksos.raidrescue.com/ _]] [[http://diskrescue.raidrescue.com/ _]] [[http://ibmrecovery.raidrescue.com/ _]] [[http://ibmsos.raidrescue.com/ _]] [[http://ibmrescue.raidrescue.com/ _]] [[http://wdrecovery.raidrescue.com/ _]]²
author:1100969967=data
host:1100969967=210.90.223.227
diff:1100979603:1100969967:=5a6²> [[http://diskrecovery.raidrescue.com/ _]] [[http://disksos.raidrescue.com/ _]] [[http://diskrescue.raidrescue.com/ _]] [[http://ibmrecovery.raidrescue.com/ _]] [[http://ibmsos.raidrescue.com/ _]] [[http://ibmrescue.raidrescue.com/ _]] [[http://wdrecovery.raidrescue.com/ _]]²
author:1100979603=scott
host:1100979603=68.193.191.197
diff:1103972959:1100979603:=24d23²< [[http://www.blogcn.com/user23/recovery/index.html _]] [[http://www.blogcn.com/user23/rescue/index.html _]] [[http://freehost18.websamba.com/rescue/ _]] [[http://www.freewebs.com/datarestore/ _]]²
author:1103972959=
host:1103972959=210.90.223.227
diff:1104152923:1103972959:=23a24²> [[http://www.blogcn.com/user23/recovery/index.html _]] [[http://www.blogcn.com/user23/rescue/index.html _]] [[http://freehost18.websamba.com/rescue/ _]] [[http://www.freewebs.com/datarestore/ _]]²
author:1104152923=scott
host:1104152923=68.167.115.34