It's been several years since I did all that, it's kinda of fuzzy, but I do have all the files I worked with so I should be able to figure out what's happening. Let's simplify, and just have one upload and no checkbox for now...
Change this...
<tr><td align="right" valign="top">Current Image 1:</td>
<td><img src="<%build_upload_url%>/<%Image_1%>" /><div class="formhelp">[<%Image_1%>]</div></td></tr>
<%endif%>
<tr><td align="right" valign="top">Delete Image 1? <input type="checkbox" name="image_1_delete" value="yes"></td></tr>
<tr><td align="right" valign="top">Image 1</td>
<td><input name="Image_1" type="file" value="" /><input type="hidden" name="Image_1_Transfer" value="<%Image_1%>" /></td></tr>
<tr><td align="right" valign="top">Caption 1:</td>
<td><textarea wrap="virtual" input name="Caption_1" value="" rows="3" cols="42"><%Caption_1%></textarea></td></tr>
<%if Image_2%>
<tr><td align="right" valign="top">Current Image 2:</td>
<td><img src="<%build_upload_url%>/<%Image_2%>" /><div class="formhelp">[<%Image_2%>]</div></td></tr>
<%endif%>
<tr><td align="right" valign="top">Delete Image 2?</td>
<td><input type="checkbox" name="image_2_delete" value="yes"></td></tr>
<tr><td align="right" valign="top">Image 2</td>
<td><input name="Image_2" type="file" value="" /><input type="hidden" name="Image_2_Transfer" value="<%Image_2%>" /></td></tr>
<tr><td align="right" valign="top">Caption 2:</td>
<td><textarea wrap="virtual" input name="Caption_2" value="" rows="3" cols="42"><%Caption_2%></textarea></td></tr>
To this...
<%if Image_1%>
<tr><td align="right" valign="top">Current Image 1:</td>
<td><img src="<%build_upload_url%>/<%Image_1%>" /> </td></tr>
<%endif%>
<tr><td align="right" valign="top">Image 1</td>
<td><input name="Image_1" type="file" value="" /><input type="hidden" name="Image_1_Transfer" value="<%Image_1%>" /></td></tr>
<tr><td align="right" valign="top">Caption 1:</td>
<td><textarea wrap="virtual" input name="Caption_1" value="" rows="3" cols="42"><%Caption_1%></textarea></td></tr>
Don't worry about changing links.def or the data files.
Image_1: $original{'Image_1'} Just a question, shouldn't this be $in instead of $original ? Probably...
Change this...
if (($in{'image_' . $fnum . '_delete'} eq "yes") &&
(length($in{'Image_' . $fnum . '_Transfer'}) > 1)) {
# So first remove any previously uploaded files in that file(x) position
unlink "$upload_path/$in{'Image_' . $fnum . '_Transfer'}";
} # close LT 'if delete_image'
else { #LT
&site_html_modify_failure("To replace an existing image you need to check the \'delete image\' box.") and return;
} # close LT 'else'
# Now let's go ahead and upload that new file
# changed to append Link ID instead of random number >
$file_name = $in{$db_key} . $file_name; # Prevent files being overwritten by appending Link ID
# < changed to append Link ID
to this:
I'm having trouble getting the link ID in add.cgi, as the file is names before the form is parsed, so ID does not work. Works in modify, since the link is already numbered.
For the security mod,it's much simpler to kill the reversal thing; remove this: my $reversed = reverse $in{'Password'};
and change this: if (($data[$db_user] eq $in{'Username'}) and ($data[$db_pw] eq $reversed)) {
to: if (($data[$db_user] eq $in{'Username'}) and ($data[$db_pw] eq $in('Password'))) {
Usually try only one mod at a time, or you'll bury yourself in confusing code changes!
Gotta run right now, see what these changes do for you...
Leonard
aka PerlFlunkie
Change this...
Code:
<%if Image_1%> <tr><td align="right" valign="top">Current Image 1:</td>
<td><img src="<%build_upload_url%>/<%Image_1%>" /><div class="formhelp">[<%Image_1%>]</div></td></tr>
<%endif%>
<tr><td align="right" valign="top">Delete Image 1? <input type="checkbox" name="image_1_delete" value="yes"></td></tr>
<tr><td align="right" valign="top">Image 1</td>
<td><input name="Image_1" type="file" value="" /><input type="hidden" name="Image_1_Transfer" value="<%Image_1%>" /></td></tr>
<tr><td align="right" valign="top">Caption 1:</td>
<td><textarea wrap="virtual" input name="Caption_1" value="" rows="3" cols="42"><%Caption_1%></textarea></td></tr>
<%if Image_2%>
<tr><td align="right" valign="top">Current Image 2:</td>
<td><img src="<%build_upload_url%>/<%Image_2%>" /><div class="formhelp">[<%Image_2%>]</div></td></tr>
<%endif%>
<tr><td align="right" valign="top">Delete Image 2?</td>
<td><input type="checkbox" name="image_2_delete" value="yes"></td></tr>
<tr><td align="right" valign="top">Image 2</td>
<td><input name="Image_2" type="file" value="" /><input type="hidden" name="Image_2_Transfer" value="<%Image_2%>" /></td></tr>
<tr><td align="right" valign="top">Caption 2:</td>
<td><textarea wrap="virtual" input name="Caption_2" value="" rows="3" cols="42"><%Caption_2%></textarea></td></tr>
To this...
Code:
<%if Image_1%>
<tr><td align="right" valign="top">Current Image 1:</td>
<td><img src="<%build_upload_url%>/<%Image_1%>" /> </td></tr>
<%endif%>
<tr><td align="right" valign="top">Image 1</td>
<td><input name="Image_1" type="file" value="" /><input type="hidden" name="Image_1_Transfer" value="<%Image_1%>" /></td></tr>
<tr><td align="right" valign="top">Caption 1:</td>
<td><textarea wrap="virtual" input name="Caption_1" value="" rows="3" cols="42"><%Caption_1%></textarea></td></tr>
Don't worry about changing links.def or the data files.
Image_1: $original{'Image_1'} Just a question, shouldn't this be $in instead of $original ? Probably...
Change this...
Code:
## LT added 'if delete_image' here... if (($in{'image_' . $fnum . '_delete'} eq "yes") &&
(length($in{'Image_' . $fnum . '_Transfer'}) > 1)) {
# So first remove any previously uploaded files in that file(x) position
unlink "$upload_path/$in{'Image_' . $fnum . '_Transfer'}";
} # close LT 'if delete_image'
else { #LT
&site_html_modify_failure("To replace an existing image you need to check the \'delete image\' box.") and return;
} # close LT 'else'
# Now let's go ahead and upload that new file
# changed to append Link ID instead of random number >
$file_name = $in{$db_key} . $file_name; # Prevent files being overwritten by appending Link ID
# < changed to append Link ID
to this:
Code:
# Now let's go ahead and upload that new fileI'm having trouble getting the link ID in add.cgi, as the file is names before the form is parsed, so ID does not work. Works in modify, since the link is already numbered.
For the security mod,it's much simpler to kill the reversal thing; remove this: my $reversed = reverse $in{'Password'};
and change this: if (($data[$db_user] eq $in{'Username'}) and ($data[$db_pw] eq $reversed)) {
to: if (($data[$db_user] eq $in{'Username'}) and ($data[$db_pw] eq $in('Password'))) {
Usually try only one mod at a time, or you'll bury yourself in confusing code changes!
Gotta run right now, see what these changes do for you...
Leonard
aka PerlFlunkie