Topic: xmlDataPath outside active web directory??

I'm trying to reach a gallery.xml file that is outside the active web directory and every path I try will not work(gallery not found error).  Does anyone know how to set the correct absolute path for javascript?  Below is the index.html code:

    <script type="text/javascript">
   
        var fo = new SWFObject("viewer.swf", "viewer", "100%", "100%", "8", "#181818");
       
        // SIMPLEVIEWER CONFIGURATION OPTIONS
        // To use an option, uncomment it by removing the "//" at the start of the line
       
        fo.addVariable("xmlDataPath", "/home/mysecr73/imagine/gallery.xml");
        //fo.addVariable("firstImageIndex", "5");   
        //fo.addVariable("langOpenImage", "Open Image in New Window");
        //fo.addVariable("langAbout", "About");   
        //fo.addVariable("preloaderColor", "0xFFFFFF");
       
        fo.write("flashcontent");   
    </script>

The index.html above is at the path= /home/mysecr73/public_html/view3/index.html
and I want to read the gallery.xml from /home/mysecr73/imagine/gallery.xml

I've tried setting the xmlDataPath to:
"/home/mysecr73/imagine/gallery.xml" or "home/mysecr73/imagine/gallery.xml" and others but nothing works. 
There has to be a way to get outside the public_html directory.

Re: xmlDataPath outside active web directory??

Found a way for it to work!

I wanted to store my images outside the active web directory for greater security and made a php script that the thumbPath and imagePath point to and it works.  SO now every image can be stored and read from outside the active web directory. 

I realize any image displayed on a browser can be taken but this makes it more work.

Re: xmlDataPath outside active web directory??

WoW still cannot respond because:

In order to try to prevent spammers, we do not allow our users to post U R L s or enter personal data into their profile until they have posted at least 5 legitimate posts and have been with us for more than 5 days. We appreciate your understanding in this matter in order to help us eliminate spam from this forum. If you have somehow gotten this message even though you meet both of the criteria, please let us know ASAP.

Re: xmlDataPath outside active web directory??

I'll help guide you. 
Again I wanted to make it more difficult for people to come and download my images (which cannot be 100% prevented).  My site is also driven by multiple users with their own photo galleries (database).  So when you click on a user’s gallery only their pictures will come up. 

Step 1.  Ditch gallery.xml!
There are different ways to generate the xml file with php but the first one I found was at this link.  Below is my edited version of this new file we can name newgallery.php.

<?php 
echo &#40;'<?xml version="1.0" encoding="UTF-8"?>'&#41;; 
if&#40;!isset&#40;$imagePath&#41;&#41; &#123; $imagePath = "imageviewer.php?path=/"; &#125; 
if&#40;!isset&#40;$thumbPath&#41;&#41; &#123; $thumbPath = "thumbviewer.php?path=/"; &#125; 
if&#40;!isset&#40;$maxImageHeighth&#41;&#41; &#123; $maxImageHeight = "480"; &#125; 
if&#40;!isset&#40;$maxImageWidth&#41;&#41; &#123; $maxImageWidth = "480"; &#125; 
if&#40;!isset&#40;$textColor&#41;&#41; &#123; $textColor = "0xFFFFFF"; &#125; 
if&#40;!isset&#40;$frameColor&#41;&#41; &#123; $frameColor = "0xFFFFFF"; &#125; 
if&#40;!isset&#40;$frameWidth&#41;&#41; &#123; $frameWidth = "20"; &#125; 
if&#40;!isset&#40;$stagePadding&#41;&#41; &#123; $stagePadding = "40"; &#125; 
if&#40;!isset&#40;$thumbnailColumns&#41;&#41; &#123; $thumbnailColumns = "3"; &#125; 
if&#40;!isset&#40;$thumbnailRows&#41;&#41; &#123; $thumbnailRows = "3"; &#125; 
if&#40;!isset&#40;$navPosition&#41;&#41; &#123; $navPosition = "left"; &#125; 
if&#40;!isset&#40;$title&#41;&#41; &#123; $title = "Steal these photos!"; &#125; 
if&#40;!isset&#40;$enableRightClickOpen&#41;&#41; &#123; $enableRightClickOpen = "true"; &#125; 
if&#40;!isset&#40;$backgroundImagePath&#41;&#41; &#123; $backgroundImagePath = ""; &#125; 

$verz = opendir&#40;"/your/path/to/images/here/"&#41;; 
$data = "<simpleviewerGallery maxImageHeighth='".$maxImageHeight."' maxImageWidth='".$maxImageWidth."' 
textColor='".$textColor."' frameColor='".$frameColor."' frameWidth='".$frameWidth."' stagePadding='".$stagePadding."' 
navPadding="40" thumbnailColumns='".$thumbnailColumns."' thumbnailRows='".$thumbnailRows."' navPosition='".$navPosition."' 
vAlign="center" hAlign="center" title='".$title."' enableRightClickOpen='".$enableRightClickOpen."' backgroundImagePath='".$backgroundImagePath."' 
thumbPath='".$thumbPath."' imagePath='".$imagePath."' >"; 
while&#40;$file = readdir&#40;$verz&#41;&#41;&#123; 
if&#40;!is_dir&#40;$file&#41; && substr&#40;$file,-3&#41; == jpg&#41; &#123; 
$data .= "<image><filename>".$file."</filename><caption>".$file."</caption></image>"; 
&#125; 
&#125; 
closedir&#40;$verz&#41;; 
$data .= "</simpleviewerGallery>"; 
$data = utf8_encode&#40;$data&#41;; 
$xmlData = simplexml_load_string&#40;$data&#41;; 
echo $xmlData->asXML&#40;&#41;; 
?>

Step 2. Edit simpleviewer.fla

//load XM data

//set default xmlPath
var xmlPath = "newgallery.php"
//get xml data Path from flashVars
if &#40;_root.xmlDataPath != undefined&#41;&#123;
    xmlPath = _root.xmlDataPath;
&#125;

If you have flash you can edit the xmlDataPath variable to point directly to newgallery.php so you don’t have to have the file name exposed in the index.html.  You don’t have to do this but it’s a little more secure.  Upload your new viewer.swf.

Step 3. Create a new file.
I could not figure out how to make absolute paths work in simpleviewer.  The website said they did but I’m a noob and could not get it working.  Instead I created a 2 new files with the same code in each.  One file for the image folder and one for the thumb folder.  Make sure your path is correct for each folder in each file.  If you do not know your path see step 4.  Name one file imageviewer.php and the other thumbviewer.php and place them in your viewer directory with newgallery.php and your index.html.

<?php
$path = $_GET&#91;'path'&#93;;
$base_path = "/your/absolute/path/to/images&#40;or thumb&#41;/";
$newpath = $base_path.$path;
readfile&#40;"$newpath"&#41;;
echo $newpath;
?>

Step 4. Update your paths
Update the image and thumb directory paths in newgallery.php.  These are the 2 folders that store the images and you must move them OUTSIDE the active web directory somewhere.   If you don’t know how to find your path place the code below in a php file and upload it to your simpleviewer folder and access the file on your favorite web browser.

newgallery.php
makes sure these 3 variables are correct&#58;
$imagePath 
$thumbPath 
$verz


<?php 
echo &#40;'<?xml version="1.0" encoding="UTF-8"?>'&#41;; 
if&#40;!isset&#40;$imagePath&#41;&#41; &#123; $imagePath = "imageviewer.php?path=/"; &#125; 
if&#40;!isset&#40;$thumbPath&#41;&#41; &#123; $thumbPath = "thumbviewer.php?path=/"; &#125; 
if&#40;!isset&#40;$maxImageHeighth&#41;&#41; &#123; $maxImageHeight = "480"; &#125; 
if&#40;!isset&#40;$maxImageWidth&#41;&#41; &#123; $maxImageWidth = "480"; &#125; 
if&#40;!isset&#40;$textColor&#41;&#41; &#123; $textColor = "0xFFFFFF"; &#125; 
if&#40;!isset&#40;$frameColor&#41;&#41; &#123; $frameColor = "0xFFFFFF"; &#125; 
if&#40;!isset&#40;$frameWidth&#41;&#41; &#123; $frameWidth = "20"; &#125; 
if&#40;!isset&#40;$stagePadding&#41;&#41; &#123; $stagePadding = "40"; &#125; 
if&#40;!isset&#40;$thumbnailColumns&#41;&#41; &#123; $thumbnailColumns = "3"; &#125; 
if&#40;!isset&#40;$thumbnailRows&#41;&#41; &#123; $thumbnailRows = "3"; &#125; 
if&#40;!isset&#40;$navPosition&#41;&#41; &#123; $navPosition = "left"; &#125; 
if&#40;!isset&#40;$title&#41;&#41; &#123; $title = "Steal these photos!"; &#125; 
if&#40;!isset&#40;$enableRightClickOpen&#41;&#41; &#123; $enableRightClickOpen = "true"; &#125; 
if&#40;!isset&#40;$backgroundImagePath&#41;&#41; &#123; $backgroundImagePath = ""; &#125; 

$verz = opendir&#40;"/your/absolute path/to/images/here/"&#41;; 

Code for a server path file if needed:

<?php echo $_SERVER&#91;'DOCUMENT_ROOT'&#93;; ?>

Step 5. Upload files
Upload the 3 files (newgallery.php, thumbviewer.php, imageviewer.php) to the same directory as the index.html and viewer.swf.  Delelte the gallery.xml, image and thumb folders and everything should work.  If it doesn’t make sure your paths are all correct.  Make sure the new thumb and images folders outside the active directory have the proper chmod setting to allow your new files to read them.  Newgallery.php will only work with php5 or higher.


You can view my demo here.
All the photos are outside the active web directory.  Simpleviewer even lets you disable right-clicks on the images and if you edited the .fla file, you can view the source but it won’t help you finding your newgallery.php or the image viewer files.  This code is very simple and doesn’t help with security from variables passed to the image viewers which you can add as I have done on my own.  The newgallery.php rocks because it’s completely customizable!  I’ve taken it a few steps further and mine reads from a database of users so I can use this one file to generate a new gallery for each user’s images all from a database.  Hope this helps  big_smile