Here are a few tips to get things working:
(1) In your 'config.php' file, change the content type to application/xml. (I have already changed this in the post where you found the code.)
(2) The $gallery[$i] entries already contain file extensions so adding .jpg to them breaks the filenames.
(3) There are no spaces between the attributes in your <juiceboxgallery> tag which causes XML parsing errors.
(4) The sourcePath entries are required only for editing galleries in JuiceboxBuilder-Pro which may need to know where the original images are stored on your hard drive if reprocessing the images is required (for example to remove a watermark or resize the images). They can safely be removed.
Try the following:
<?php
header("Content-type: application/xml");
function GetDirArray($folder)
{
$handle=opendir($folder);
while ($file=readdir($handle))
{
if ($file!="." && $file!="..")
{
$ret[count($ret)]=$file;
}
}
closedir($handle);
sort($ret);
return $ret;
}
$gallery=GetDirArray('images');
echo '<?xml version="1.0" encoding="UTF-8"?>';
echo '<juiceboxgallery
resizeOnImport="false"
useThumbDots="false"
useFullscreenExpand="false"
imageFrameColor="rgba(255,255,255,1)"
changeImageOnHover="true"
showAutoPlayButton="false"
showInfoButton="false"
showImageNumber="true"
shareFacebook="true"
shareTwitter="true"
shareGPlus="true"
showSmallBackButton="true"
backButtonPosition="OVERLAY"
backButtonUseIcon="true"
backButtonHAlign="LEFT"
>';
for ($i=0; $i<sizeof($gallery); $i++)
{
echo '<image imageURL="images/'.$gallery[$i].'" ';
echo 'thumbURL="thumbs/'.$gallery[$i].'" ';
echo 'linkURL="images/'.$gallery[$i].'" ';
echo 'linkTarget="_blank">';
echo '<title><![CDATA['.$gallery[$i].']]></title>';
echo '<caption><![CDATA[]]></caption>';
echo '</image>';
}
echo '</juiceboxgallery>';
?>