Skip to content

Commit

Permalink
Fixed SourceForge Bug #108355
Browse files Browse the repository at this point in the history
Fixed a small problem in admin.pl in the topic editor where, if the topic
images directory is empty, the code would print a <SELECT> list with 0
items. It now prints a warning with a textbox containing the current
filename instead.
  • Loading branch information
Xliff committed Jun 27, 2000
1 parent 4c40d5c commit dbf6c96
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 20 deletions.
9 changes: 9 additions & 0 deletions CHANGES
Expand Up @@ -45,6 +45,15 @@ slash-1.0.6, 2000.06.xx
user's moderation is voted fair or unfair is now counted in
users_info (columns m2fair and m2unfair)

* Fixed small bug in admin.pl which would result in bugs while saving
and editing topics if $I{basedir} was not derived from $I{datadir}
(ie, if the 2 directories were on different partitions)

* If there were no images in the topic images directory, the topic
editor would display a select list with no items. Now, a warning
is displayed and the user is given an input box filled with the
current filename.


slash-1.0.5, 2000.06.13
-----------------------
Expand Down
29 changes: 19 additions & 10 deletions public_html/admin.pl
Expand Up @@ -798,7 +798,7 @@ sub topicEd {
return if $I{U}{aseclev} < 1;
my ($tid, $width, $height, $alttext, $image, @available_images);

opendir(DIR,"$I{datadir}/public_html/images/topics");
opendir(DIR,"$I{basedir}/images/topics");
@available_images = grep(!/^\./, readdir(DIR));
closedir(DIR);

Expand Down Expand Up @@ -831,19 +831,28 @@ sub topicEd {
<BR>Alt Text<BR>
<INPUT TYPE="TEXT" NAME="alttext" VALUE="$alttext"><BR>
<BR>Image<BR>
<SELECT name="image">
EOT

print qq|<OPTION value="">Select an image</OPTION>| if $I{F}{topicnew};
for(@available_images) {
my ($selected);
$selected = "SELECTED" if ($_ eq $image);
print qq|<OPTION value="$_" $selected>$_</OPTION>\n|;
$selected = '';
if (@available_images) {
print qq|<SELECT name="image">|;
qq|<OPTION value="">Select an image</OPTION>| if $I{F}{topicnew};
for(@available_images) {
my ($selected);
$selected = "SELECTED" if ($_ eq $image);
print qq|<OPTION value="$_" $selected>$_</OPTION>\n|;
$selected = '';
}
print '</SELECT>';
} else {
# If we don't have images in the proper place, print a message
# and use a regular text input field.
print <<EOT;
<P>No images were found in the topic images directory (&lt;basedir&gt;/images/topics).<BR>
<INPUT TYPE="TEXT" NAME="image" VALUE="$image"><BR><BR>
EOT
}

print <<EOT;
</SELECT>
<INPUT TYPE="SUBMIT" NAME="topicsave" VALUE="Save Topic">
<INPUT TYPE="SUBMIT" NAME="topicdelete" VALUE="Delete Topic">
EOT
Expand All @@ -869,7 +878,7 @@ sub topicSave {
if ($I{F}{tid}) {
my($rows) = sqlSelect('count(*)', 'topics', 'tid=' . $I{dbh}->quote($I{F}{tid}));
if (!$I{F}{width} && !$I{F}{height}) {
@{ $I{F} }{'width', 'height'} = imgsize("$I{datadir}/public_html/images/topics/$I{F}{image}");
@{ $I{F} }{'width', 'height'} = imgsize("$I{basedir}/images/topics/$I{F}{image}");
}
if($rows == 0 ) {
sqlInsert('topics', {
Expand Down
29 changes: 19 additions & 10 deletions themes/slashcode/htdocs/admin.pl
Expand Up @@ -798,7 +798,7 @@ sub topicEd {
return if $I{U}{aseclev} < 1;
my ($tid, $width, $height, $alttext, $image, @available_images);

opendir(DIR,"$I{datadir}/public_html/images/topics");
opendir(DIR,"$I{basedir}/images/topics");
@available_images = grep(!/^\./, readdir(DIR));
closedir(DIR);

Expand Down Expand Up @@ -831,19 +831,28 @@ sub topicEd {
<BR>Alt Text<BR>
<INPUT TYPE="TEXT" NAME="alttext" VALUE="$alttext"><BR>
<BR>Image<BR>
<SELECT name="image">
EOT

print qq|<OPTION value="">Select an image</OPTION>| if $I{F}{topicnew};
for(@available_images) {
my ($selected);
$selected = "SELECTED" if ($_ eq $image);
print qq|<OPTION value="$_" $selected>$_</OPTION>\n|;
$selected = '';
if (@available_images) {
print qq|<SELECT name="image">|;
qq|<OPTION value="">Select an image</OPTION>| if $I{F}{topicnew};
for(@available_images) {
my ($selected);
$selected = "SELECTED" if ($_ eq $image);
print qq|<OPTION value="$_" $selected>$_</OPTION>\n|;
$selected = '';
}
print '</SELECT>';
} else {
# If we don't have images in the proper place, print a message
# and use a regular text input field.
print <<EOT;
<P>No images were found in the topic images directory (&lt;basedir&gt;/images/topics).<BR>
<INPUT TYPE="TEXT" NAME="image" VALUE="$image"><BR><BR>
EOT
}

print <<EOT;
</SELECT>
<INPUT TYPE="SUBMIT" NAME="topicsave" VALUE="Save Topic">
<INPUT TYPE="SUBMIT" NAME="topicdelete" VALUE="Delete Topic">
EOT
Expand All @@ -869,7 +878,7 @@ sub topicSave {
if ($I{F}{tid}) {
my($rows) = sqlSelect('count(*)', 'topics', 'tid=' . $I{dbh}->quote($I{F}{tid}));
if (!$I{F}{width} && !$I{F}{height}) {
@{ $I{F} }{'width', 'height'} = imgsize("$I{datadir}/public_html/images/topics/$I{F}{image}");
@{ $I{F} }{'width', 'height'} = imgsize("$I{basedir}/images/topics/$I{F}{image}");
}
if($rows == 0 ) {
sqlInsert('topics', {
Expand Down

0 comments on commit dbf6c96

Please sign in to comment.