Forum Moderators: coopster

Message Too Old, No Replies

Remove gif / jpg in php

         

armator

6:11 pm on Jun 1, 2005 (gmt 0)

10+ Year Member



Thanks again your previous helps for my problem.

I am asking again your help for my problem in your previous code that I am connecting to another server with your code which it is giving error on status bar the reason of gif & jpg.

Could you please help me which command I have to add to remove gif & jpg in your code that your previous code are as follows;

<?php

$file = fopen("http://www.domain.com/test.asp", "r") or die("Serverla ileti?im sa?lanamady!");
while(!feof($file)){
$line = trim(fgets($file));
$line = str_replace("<a", "<a target=\"_blank\"", $line);
$text .= $line;
}
fclose($file);
echo $text;
?>

Thanks advance your kind help for my problem.

Best Regards
armator

mcibor

10:01 pm on Jun 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi!

<?php

$file = fopen("http://www.domain.com/test.asp", "r") or die("Serverla ileti?im sa?lanamady!");
while(!feof($file)){
$line = fgets($file);//I wouldn't write trim to preserve the layout of the source
$line = str_replace("<a", "<a target=\"_blank\"", $line);
$text .= $line."\n";
}
fclose($file);
$begin = 0;
$end = 0;
while(($begin = strpos($text, "<img", $end))!== false)
{
$end = strpos($text, ">", $begin) + 1;
$t_start = substr($text, 0, $begin);
$t_end = substr($text, $end, strlen($text) - $end);
$text = $t_start.$t_end;
}
echo $text;
?>

I know that this code looks a bit horrifying at the first sight, but it works!
Michal Cibor

armator

8:28 am on Jun 2, 2005 (gmt 0)

10+ Year Member



Dear Michal Cibor

Thanks again your kind help.
It is running very good.

Could you please tell me?
How we can change table / tr / td colors if we wish.

Thanks advance your kind help.

Best Regards
Metin Mentes

mcibor

8:50 am on Jun 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<table class="a" style="background-color: rgb(205, 205, 205);"> or in css
TABLE.a
{
background-color: rgb(190, 180, 170);
}

you can also change color on mouseover and mouseout
<td style="background-color: rgb(1, 1, 1);" onmouseover="this.style.backgroundColor='#FEFEFE'" onmouseout="this.style.backgroundColor='rgb(1,1,1)';">

Best regards!
But you should really use more google ( [google.com...] )

Michal Cibor

armator

9:16 am on Jun 2, 2005 (gmt 0)

10+ Year Member



Dear Michal Cibor

Thanks your quick reply.

I am using style css in php that it is sometimes changing font colors & sizes which I am giving you as below.
But I would like to learn which command we can add in your previous code to change tr's / td's color & size .

My style css;

<style>
body {
background-color: #FFFFFF;
font-family: Arial, Verdana, sans-serif;
font-size: 0px;
color: #000000;
}

a { font-family: Arial, Verdana, sans-serif; font-size: 0px ; color: #ffffff; text-decoration: none}

a:hover { font-family: Arial, Verdana, sans-serif; font-size: 0px; color: #ffffff; background-color: #ffffff}

table { font-family: Arial, Verdana, sans-serif; font-size: 0px; color: #000000; margin-top: 11px; margin-right: 0px; margin-bottom: 0px; margin-left: -1px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px }

td { background-color: #ffffff; }

.note { font-family: Arial, Verdana, sans-serif; font-size: 0px; color: #000000;
font-weight: bold;}
</style>

Thanks again your kind interest and help.

Best Regards
Metin Mentes

mcibor

10:00 am on Jun 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



A, now I understand. SO what you need is to get rid of <style...</style> and put in your own. This is how to do that:


...
while(($begin = strpos($text, "<img", $end))!== false)
{
}

$t_style = "<style...</style>";//your whole style text
if(($style_begin = strpos($text, "<style"))!== false) $style_end = strpos($text, "</style>", $style_begin) + 8;
elseif(($style_begin = strpos($text, "<link"))!== false) $style_end = strpos($text, ">", $style_begin);
else
{$style_begin = strpos($text, "</head>"); $style_end = $style_begin;}
$t_style_begin = substr($text, 0, $begin);
$t_style_end = substr($text, $end, strlen($text) - $end);
$text = $t_style_begin.$t_style.$t_style_end;
echo $text;
?>


This should change style to what you need
Michal Cibor

armator

11:46 am on Jun 2, 2005 (gmt 0)

10+ Year Member



Dear Michal Cibor

Thanks your kind helps.

Have a nice day.

Best Regards
Metin Mentes