nsr500rossi Posted January 17, 2008 Share Posted January 17, 2008 Hi I have an editxml.php file that takes this code: Hi <img src="RLW_001.jpg" title="Please click on photograph to purhase" caption="RLW_001.jpg" link="" /> and when run, turns it into this code: <img src="BST 001.jpg" title="Please click on photograph to purchase" caption="BST 001.jpg" link="javascript:NewWindow=window.open('/Payment_page.php?name=BST 001.jpg&album=Brighton speed trials 2006','myWindow','width=300,height=660,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes');NewWindow.focus(); void(0);" /> I need to change the editxml.php so that it creates a xml file like this <img src="ECO_007.jpg" title="Please click on Photograph to purchase" caption="ECO_007.jpg" link="http://www.michaelshuttleworth.com/Payment_page2.php?name=ECO_007.jpg&album=Ecofair_2006" target="_self" /> Ignore the filenames (i have taken them from different sources) Here is the editxml.php code that needs changing: <html> <head> <title>PHP Test</title> </head> <body> <?php $file = "images.xml"; $descriptor = fopen ($file, "r"); $contents = fread($descriptor , filesize($file)); $album = ''; $pos1 = strpos($contents, 'javascript:NewWindow'); if ($pos1 == false) { $pieces = explode('link=""', $contents); $op = ""; for ($i = 0; $i < count($pieces); $i++) { $tnpos = strpos($pieces[$i], 'tnPath="'); if ($tnpos !== false) { $titpos = strpos($pieces[$i], 'ssp_director/albums/', $tnpos); $titpos += 20; $titend = strpos($pieces[$i], '/', $titpos) - $titpos; $album = substr($pieces[$i], $titpos, $titend); //echo $album; } $halves = explode('<img src="', $pieces[$i]); $fileid = substr($halves[1], 0, 7); if (count($halves) > 1) { $halves[0] .= '<img src="'; $pos1 = strpos($halves[1], 'unavailable'); if ($pos1 == false) { $halves[1] .= "link=\"javascript:NewWindow=window.open('/Payment_page.php?name=" . $fileid . ".jpg&album=" . $album . "','myWindow','width=300,height=730,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes');NewWindow.focus(); void(0);\""; } else { $halves[1] .= 'link=""'; } } $op .= $halves[0] . $halves[1]; } fclose($descriptor); unlink($file); //$descriptor = fopen ('images.txt', "w"); $descriptor = fopen ($file, "w"); fwrite($descriptor,$op); echo 'done! '; echo count($pieces); echo ' pieces processed'; fclose($descriptor); } else { echo 'This file has been processed already'; } ?> </body> </html> I guess the javascript newwindow code needs replacing, i have tried but can't quite get it right. If anyone out there can show me what to change i would be so so grateful. Many thanks Mike Quote Link to comment https://forums.phpfreaks.com/topic/86533-in-need-of-help-with-code-easy-for-everyone-but-me/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.