Jump to content

Newbie PHP code help


nsr500rossi

Recommended Posts

Hi,

Can anyone tell me why my filename is being chopped in half when i run my editxml.php command

 

The problem line in the code is:    name=ECO_001.jpg&album=_2006'    it should read  name=ECO_001.jpg&album=Ecofair_2006'

 

This is the code that is created after running the editxml.php command.

 

<?xml version="1.0" encoding="utf-8"?>

<gallery>

<album title="Ecofair 2006" description="Photographs from the 2006 Ecofair in Burgess Hill" lgPath="http://www.michaelshuttleworth.com/Event/albums/Ecofair_2006/lg/" tnPath="http://www.michaelshuttleworth.com/Event/albums/Ecofair_2006/tn/">

<img src="ECO_001.jpg" title="Please click on Photograph to purchase" caption="ECO_001.jpg" link="javascript:NewWindow=window.open('/Payment_page.php?name=ECO_001.jpg&album=_2006','myWindow','width=300,height=700,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes');NewWindow.focus(); void(0);" />

 

</album>

</gallery>

 

Here is the editxml.php code

 

<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], 'Event/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=700,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>

 

A friend of mine wrote the code for me and it works fine on my old website

 

http://www.michaelshuttleworthphotography.co.uk/Event_Photos_Part_1.html

 

As you can see when you click on the image it gets the image info and thumbnail and opens it in a new window.

 

On my new site it is tripping up on getting the thumbnail.

 

Thanks in advance

 

Mike

 

 

 

 

 

 

Link to comment
Share on other sites

Please use


tags. People don't give posts like these much consideration if you don't use them when posting codes.

 

Try replacing you xml file with this:

<?xml version="1.0" encoding="utf-8"?>
<gallery>
   <album title="Ecofair 2006" description="Photographs from the 2006 Ecofair in Burgess Hill" lgPath="http://www.michaelshuttleworth.com/Event/albums/Ecofair_2006/lg/" tnPath="http://www.michaelshuttleworth.com/Event/albums/Ecofair_2006/tn/">
      <img src="ECO_001.jpg" title="Please click on Photograph to purchase" caption="ECO_001.jpg" link="javascript:NewWindow=window.open('/Payment_page.php?name=ECO_001.jpg&album=Ecofair_2006','myWindow','width=300,height=700,toolbar=no,location=no,status=yes,menubar=no,scrollbars=yes,resizable=yes');NewWindow.focus(); void(0);" />
   
   </album>
</gallery>

Link to comment
Share on other sites

Sorry about the lack of


tags.

 

Well i added the Ecofair to the _2006 code in my xml file and it worked.

 

So i know that it can work, but i still have the problem of generating the images.xml file correctly.

 

It is still shortening my thumbnail file name.

 

Still need help please

 

Mike

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.