$imode_code = file("$url_file");
$file_name = basename($url_file);
$path = dirname($url_file);
$stripped_path = eregi_replace("^(.{2,6}://)?[^/]*/", "", $path);

$next_path = eregi_replace($stripped_path, "", $path);
$next_path_1 = eregi_replace("/$" , "", $next_path);

// create and open a file to write to
$new_file = "files/".$file_name;
$fh = fopen($new_file , "w");

$lines = count($imode_code);
// echo "Lines = $lines";

for ($i; $i<$lines; $i++) {

// add server path to gifs with front slashes /hello/john.gif
// $imode_code[$i] = eregi_replace("([^\"]+[/+]+[a-z_/-]+[gif]+[/$])",
"$next_path_1\\0",$imode_code[$i]);

// add server path to gifs withour front slashes john.gif
// $imode_code[$i] = eregi_replace("\.gif" ,
"$next_path/\\0",$imode_code[$i]);

// changes links so also for server paths for html + chtml + php

// $imode_code[$i] = eregi_replace("([a-z_]+[.]+[chtml])",
"$next_path_1\\0",$imode_code[$i]);
// $imode_code[$i] = eregi_replace("([^\"]+[a-z_]+[\.html]+[\"$])",
"$next_path_1\\0",$imode_code[$i]);
// $imode_code[$i] = eregi_replace("([^\"]+[a-z_]+[\.php]+[\"$])",
"$next_path_1\\0",$imode_code[$i]);

// replace imode pictos with a real gif
$imode_code[$i] = ereg_replace("&#([0-9]{5});" , "<img
src=\"pictos/\\1.gif\" border=\"0\">" , $imode_code[$i] );

// write the whole lot to file
fputs ($fh, $imode_code[$i]);
}
// close file
fclose($fh);
// display file
echo "<IFRAME border=0 marginWidth=0 src=\"files/$file_name\" frameBorder=0
width=150 height=131 marginheigth=0>
   </IFRAME>";

?>
</body>
</html>


> On Tuesday 30 April 2002 19:17, John Fishworld wrote:
> > Okay right I'm experimenting with an i-mode parser !
> > I copy the file (url entered) to a local location !
> > Then read through the whole file line at a time and change/replace the
> > things that need replaceing !
> > On of the things that I need to replace is the links to the pictures so
> > that they still show even !
> > I've already got from the original file the original location
> > http://www.whatever.com
> > and now want to insert that in front of the gif files
> > ie
> > $imode_code[$i] = eregi_replace("(<img src=).+\.gif\"" ,
> > "\\1$next_path\\2",$imode_code[$i]);
> >
> > There are just gif files in this !
> >
> > Does that make more sense ?
>
> Unfortunately, no. Could you post say 20 lines of this file you're talking
> about.
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
>
> /*
> You are in a maze of little twisting passages, all different.
> */
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to