Advertisement
Advertisement
| 08.26.2008 at 12:10PM PDT, ID: 23679726 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: |
============================================== upload.php
<body>
<div id="uploader_form">
<div id="headtitle"><center><h5><b>File Upload!</b></h5></center></div>
<div id="comments"><p><h6>To upload a file/s, fill out the form below:</h6><p></div>
<!-- ############################################################# -->
<form enctype="multipart/form-data" action="/cgi-bin/file-upload.cgi" method="post">
<div id="inputs_container">
<div id="div_file01" class="input_wrapper">
<label for="file-to-upload-01"><h5>File 1:</h5></label>
<input type="file" class="file" name="file-to-upload-01" id="file-to-upload-01" size="12">
</div>
<div id="div_file02" class="input_wrapper">
<label for="file-to-upload-02"><h5>File 2:</h5></label>
<input type="file" class="file" name="file-to-upload-02" id="file-to-upload-02" size="12">
</div>
<div id="div_file03" class="input_wrapper">
<label for="file-to-upload-03"><h5>File 3:</h5></label>
<input type="file" class="file" name="file-to-upload-03" id="file-to-upload-03" size="12">
</div>
<div id="div_file04" class="input_wrapper">
<label for="file-to-upload-04"><h5>File 4:</h5></label>
<input type="file" class="file" name="file-to-upload-04" id="file-to-upload-04" size="12">
</div>
<div id="div_file05" class="input_wrapper">
<label for="file-to-upload-05"><h5>File 5:</h5></label>
<input type="file" class="file" name="file-to-upload-05" id="file-to-upload-05" size="12">
</div>
<div id="div_file06" class="input_wrapper">
<label for="file-to-upload-06"><h5>File 6:</h5></label>
<input type="file" class="file" name="file-to-upload-06" id="file-to-upload-06" size="12">
</div>
<div id="div_file07" class="input_wrapper">
<label for="file-to-upload-07"><h5>File 7:</h5></label>
<input type="file" class="file" name="file-to-upload-07" id="file-to-upload-07" size="12">
</div>
<div id="div_file08" class="input_wrapper">
<label for="file-to-upload-08"><h5>File 8:</h5></label>
<input type="file" class="file" name="file-to-upload-08" id="file-to-upload-08" size="12">
</div>
<div id="div_file09" class="input_wrapper">
<label for="file-to-upload-09"><h5>File 9:</h5></label>
<input type="file" class="file" name="file-to-upload-09" id="file-to-upload-09" size="12">
</div>
<div id="div_file10" class="input_wrapper">
<label for="file-to-upload-10"><h5>File 10:</h5></label>
<input type="file" class="file" name="file-to-upload-10" id="file-to-upload-10" size="12">
</div>
<div id="uploadyourfile"><input type="submit" value="Upload File(s)!"></div>
<div id="resetform"><input type="reset" value="Reset Form"></div>
</form>
</div> <!-- end of div inputs_container -->
<div id="footers">
<font size="-2">
<a href="mailto:shmh@bigpond.net.au">Simmo</A> -
<a href="<?php $_SERVER['SERVER_NAME'];?>/simeswiki/menu1_home.php">Sime's Wiki Home Page</a>
</font>
</div>
<!-- ############################################################# -->
<hr class="hrline" size=1 style="top:8%;">
<hr class="hrline" size=1 style="top:95.5%;">
</div> <!-- end of uploader_form -->
<div id="output_results" style="position:absolute; left: 50%; top: 1%; width:20%; height: 30%; background:gold;">
.................what id like is for the output of the cgi file (cgi-bin/file-upload.cgi) seen here ..................
</div>
</body>
====================================================== file-upload.cgi
#!/usr/bin/perl
BEGIN {
# ooPLACEHOLDERoo #
$SAVE_DIRECTORY = "/var/www/html/simeswiki/uploader";
#
# --> Variable:
# $SAVE_DIRECTORY
# --> Function:
# Defines the path to the directory
# on the server that should be used
# as the folder to save files into.
# --> Directory Permissions:
# a+rwx
# --> Additional Notes:
# This path should not have a
# trailing forward slash. Also
# remember that this is a path, not
# a URL. Use something similar to:
#
# /home/myself/www/uploads
#
$MAXIMUM_UPLOAD = 0;
#
# --> Variable:
# $MAXIMUM_UPLOAD
# --> Function:
# Defines the number of bytes that
# can be uploaded. Files that exceed
# this limit will not be saved on the
# server.
# --> Additional Notes:
# Set this to zero in order to
# disable size checking.
#
$ALLOW_INDEX = 0;
#
# --> Variable:
# $ALLOW_INDEX
# --> Function:
# If set to zero, files whose
# names begin with the word
# index will not be saved.
#
# Set to one to allow files
# named index* to be uploaded.
# --> Additional Notes:
#
$SUCCESS_LOCATION = ""
#
# --> Variable:
# $SUCCESS_LOCATION
# --> Function:
# Defines the URL that users
# should be redirected to if
# the script works properly. If
# this is left blank, a default
# page will be returned to the
# user.
# --> Additional Notes:
# This is a COMPLETE URL, not
# a path.
}
#
# End of Configurable Options.
$| = 1;
chop $SAVE_DIRECTORY if ($SAVE_DIRECTORY =~ /\/$/);
use CGI qw(:standard);
$query = new CGI;
if ( (!(-e $SAVE_DIRECTORY)) ||
(!(-W $SAVE_DIRECTORY)) ||
(!(-d $SAVE_DIRECTORY)) ) {
print header;
print <<__END_OF_HTML_CODE__;
<HTML>
<HEAD>
<TITLE>Error: Bad Directory</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H1>Bad Directory</H1>
<P>
The directory you specified:
<BR>
<BLOCKQUOTE>
<TT>\$SAVE_DIRECTORY = "<B>$SAVE_DIRECTORY</B>";</TT>
</BLOCKQUOTE>
<BR>
is invalid. This problem is caused by one of the three following reasons:
<OL>
<LI>The directory doesn't exist. Make sure that this directory is a complete path name, not
a URL or something similar. It should look similar to <TT>/home/username/public_html/uploads</TT>
<P>
<LI>The directory isn't writable. Make sure that this directory is writable by all users. At
your UNIX command prompt, type <TT>chmod 777 $SAVE_DIRECTORY</TT>
<P>
<LI>The directory you specified isn't really a directory. Make sure that this is indeed a directory
and not a file.
</OL>
<HR SIZE=1>
<CENTER><A HREF="http://www.terminalp.com/scripts/">Sime's Scripts</A></CENTER>
</BODY>
</HTML>
__END_OF_HTML_CODE__
exit;
}
foreach $key (sort {$a <=> $b} $query->param()) {
next if ($key =~ /^\s*$/);
next if ($query->param($key) =~ /^\s*$/);
next if ($key !~ /^file-to-upload-(\d+)$/);
$Number = $1;
if ($query->param($key) =~ /([^\/\\]+)$/) {
$Filename = $1;
$Filename =~ s/^\.+//;
$File_Handle = $query->param($key);
if (!$ALLOW_INDEX && $Filename =~ /^index/i) {
print header;
print <<__END_OF_HTML_CODE__;
<HTML>
<HEAD>
<TITLE>Error: Filename Problem</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H1>Filename Problem</H1>
<P>
You attempted to upload a file that isn't properly formatted. The system administrator
has decided that you can't upload files that begin with the word '<B>index</B>'. Please
rename the file on your computer, and try uploading it again.
<P>
<HR SIZE=1>
<CENTER><A HREF="http://www.terminalp.com/scripts/">Jeff's Scripts</A></CENTER>
</BODY>
</HTML>
__END_OF_HTML_CODE__
exit;
}
} else {
$FILENAME_IN_QUESTION = $query->param($key);
print header;
print <<__END_OF_HTML_CODE__;
<HTML>
<HEAD>
<TITLE>Error: Filename Problem</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H1>Filename Problem</H1>
<P>
You attempted to upload a file that isn't properly formatted. The file in question
is <TT><B>$FILENAME_IN_QUESTION</B></TT> Please rename the file on your computer, and
attempt to upload it again. Files may not have forward or backward slashes in their
names. Also, they may not be prefixed with one (or more) periods.
<P>
<HR SIZE=1>
<CENTER><A HREF="http://www.terminalp.com/scripts/">Jeff's Scripts</A></CENTER>
</BODY>
</HTML>
__END_OF_HTML_CODE__
exit;
}
if (!open(OUTFILE, ">$SAVE_DIRECTORY\/$Filename")) {
print "Content-type: text/plain\n\n";
print "-------------------------\n";
print "Error:\n";
print "-------------------------\n";
print "File: $SAVE_DIRECTORY\/$Filename\n";
print "-------------------------\n";
print "There was an error opening the Output File\n";
print "for Writing.\n\n";
print "Make sure that the directory:\n";
print "$SAVE_DIRECTORY\n";
print "has been chmodded with the permissions '777'.\n\n";
print "Also, make sure that if your attempting\n";
print "to overwrite an existing file, that the\n";
print "existing file is chmodded '666' or better.\n\n";
print "The Error message below should help you diagnose\n";
print "the problem.\n\n";
print "Error: $!\n";
exit;
}
undef $BytesRead;
undef $Buffer;
while ($Bytes = read($File_Handle,$Buffer,1024)) {
$BytesRead += $Bytes;
print OUTFILE $Buffer;
}
push(@Files_Written, "$SAVE_DIRECTORY\/$Filename");
$TOTAL_BYTES += $BytesRead;
$Confirmation{$File_Handle} = $BytesRead;
close($File_Handle);
close(OUTFILE);
chmod (0666, "$SAVE_DIRECTORY\/$Filename");
}
$FILES_UPLOADED = scalar(keys(%Confirmation));
if ($TOTAL_BYTES > $MAXIMUM_UPLOAD && $MAXIMUM_UPLOAD > 0) {
foreach $File (@Files_Written) {
unlink $File;
}
print header;
print <<__END_OF_HTML_CODE__;
<HTML>
<HEAD>
<TITLE>Error: Limit Reached</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H1>Limit Reached</H1>
<P>
You have reached your upload limit. You attempted to upload <B>$FILES_UPLOADED</B> files, totalling
<B>$TOTAL_BYTES</B>. This exceeds the maximum limit of <B>$MAXIMUM_UPLOAD</B> bytes, set by the system
administrator. <B>None</B> of your files were successfully saved. Please try again.
<P>
<HR SIZE=1>
<CENTER><A HREF="http://www.terminalp.com/scripts/">Jeff's Scripts</A></CENTER>
</BODY>
</HTML>
__END_OF_HTML_CODE__
exit;
}
if ($SUCCESS_LOCATION !~ /^\s*$/) {
print $query->redirect($SUCCESS_LOCATION);
} else {
print header;
print <<__END_OF_HTML_CODE__;
<HTML>
<HEAD>
<TITLE>Upload Finished</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H1>Upload Finished</H1>
<P>
You uploaded <B>$FILES_UPLOADED</B> files totalling <B>$TOTAL_BYTES</B> total bytes. Individual
file information is listed below:
<PRE>
__END_OF_HTML_CODE__
foreach $key (keys (%Confirmation)) {
print "$key - $Confirmation{$key} bytes\n";
}
print <<__END_OF_HTML_CODE__;
</PRE>
<P>
Thank you for using the File Upload! system.
<P>
<HR SIZE=1>
</BODY>
</HTML>
__END_OF_HTML_CODE__
exit;
}
# ---------------------------------------------------------------------
# EOF
================================================================
|