×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

turning images on and off
2

turning images on and off

turning images on and off

(OP)

CODE

sub HtmlFilter
{
local($filter) = @_;
#
# The following filters the HTML images
# out, if they are disallowed.  The code
# after this, filters out all HTML if it
# is disallowed.
#
if ($no_html_images eq "off")
{
    $filter =~ s/<(IMG\s*SRC.*)>/&LT;$1&GT;/ig;
} # End of parsing out no images

if ($no_html eq "on")
{
    $filter =~ s/<([^>]+)>/\&LT;$1&GT;/ig;
} # End of No html                                         

$filter;

Is there a way to toggle the $no_html_images on and off?

CODE

</TR>
<TR>
<TD ALIGHT=RIGHT>Pic on or off:</TD>
 <TD><select size=1 name=no_html_images>
  <option selected value=ON>ON</option>
  <option value=OFF>OFF</option>
  </select></TD>

I tryed it this way no luck

MA WarGod

I believe if someone can think it, it can be programmed

RE: turning images on and off

you send upper-case "ON":

<option selected value=ON>ON</option>

but you check for lower-case "on"

if ($no_html eq "on")

change the above line to:

if ($no_html eq 'ON')



- Kevin, perl coder unexceptional!

RE: turning images on and off

(OP)
Oh I get it now Thak You Kevin..
and I am still working with the format You gave for begaining.
so thank You again

RE: turning images on and off

(OP)
no still not working

CODE

sub HtmlFilter
{
local($filter) = @_;
#
# The following filters the HTML images
# out, if they are disallowed.  The code
# after this, filters out all HTML if it
# is disallowed.
#
if ($no_html_images eq "off")
{
    $filter =~ s/<(IMG\s*SRC.*)>/&LT;$1&GT;/ig;
} # End of parsing out no images

if ($no_html eq "on")
{
    $filter =~ s/<([^>]+)>/\&LT;$1&GT;/ig;
} # End of No html                                         

$filter;

} # End of HTML Filter

CODE

<TD ALIGHT=RIGHT>Pic on or off:</TD>
 <TD><select size=1 name=no_html_images>
  <option selected value=on>ON</option>
  <option value=off>OFF</option>
  </select></TD>

or should I from the sub different
like
if ($no_html_images eq "$_")
{
    $filter =~ s/<(IMG\s*SRC.*)>/&LT;$1&GT;/ig;
} # End of parsing out no images

if ($no_html eq "off")
{
    $filter =~ s/<([^>]+)>/\&LT;$1&GT;/ig;
} # End of No html                                         

$filter;


????????

RE: turning images on and off

can you see a problem here?

CODE

if ($no_html_images eq "off")
{
    $filter =~ s/<(IMG\s*SRC.*)>/&LT;$1&GT;/ig;
} # End of parsing out no images

if ($no_html eq "on")

or is it supposed to be like that?

- Kevin, perl coder unexceptional!

RE: turning images on and off

I think you'll save yourself a lot of brain ache down the road if you eliminate the double negative: does "no_html_images=off" mean you get images or you don't?

Furthermore, testing for "off" and "on" is asking for trouble once you start passing values of "Off", or "ON", or " off", or whatever else. Get used to thinking like a computer and use 1 for yes, 0 for no. Actually, it's quite common in CGI programming to treat any non-zero, non-null value as "yes" and 0 or "" as "no" - so your form could be like this:

CODE

<input type="checkbox" checked="checked" value="1" name="images_allowed">
And your perl would be like this

CODE

unless ($images_allowed)
{
    $filter =~ s/<(IMG\s*SRC.*)>/&LT;$1&GT;/ig;
} # End of parsing out no images
(assuming you've done the necessary work to get the form parameter into $images_allowed first)

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close