Current location: Hot Scripts Forums » Programming Languages » PHP » flash xml changes in server won't stay


flash xml changes in server won't stay

Reply
  #1 (permalink)  
Old 03-11-10, 05:25 PM
offtheroad offtheroad is offline
Newbie Coder
 
Join Date: May 2009
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
flash xml changes in server won't stay

When I make changes in my xml file on the server they won't change on my site. I'm on a Mac with the latest Snow Leopard OS. I use Transmit for my ftp browser. I tried editing the xml in Transmit but didn't stay. As soon as I refresh the browser it reverts back to the unchanged xml. I know nothing about php and was hoping someone can please look at my xml & php to see where the problem is.
Thank you
Attached Files
File Type: zip buildGalleries.php.zip (971 Bytes, 19 views)
File Type: zip gallery.zip (2.5 KB, 20 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 03-11-10, 05:28 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
It makes it easier to help you if you post the code, rather than a .zip file.

You can use PHP tags
Quote:
[ php ] <?php echo 'PHP'; ?> [ / php ]
I put spaces in the PHP tags so they would render properly, when you use them for display, there shouldn't be any spaces inside the tags.

If the problem recurs on a browser refresh, it sounds like the code didn't get uploaded to the server.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 03-11-10, 05:35 PM
offtheroad offtheroad is offline
Newbie Coder
 
Join Date: May 2009
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

<?php

$sortorder 
=  $_REQUEST["sortorder"];
$indir "../galleries";
$files opendir($indir);
$outxml "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n";
$outxml .= "<galleries>\n\n";    
while (
$file readdir($files)) {
  if(
is_dir($indir.'/'.$file))
  if (
$file != '.' && $file != '..') {
    {
        
$tmp_outxml[] = $file;
    }
    }
  }
if (
$sortorder == "date")
{
    foreach (
$tmp_outxml as $k => $v)
    {
        
$modified filemtime ($indir.'/'.$v);
        
$moddate[$k] = $modified;
    }
    
array_multisort ($moddate$tmp_outxml);
}
else if (
$sortorder == "random")
{
    
shuffle ($tmp_outxml);
}
else
{
    
sort ($tmp_outxml);
}
foreach (
$tmp_outxml as $v)
{
    
$outxml .= get_folder_xml($indir.'/'.$v,$v);
}
$outxml .= "</galleries>";

closedir($files);  
$fp fopen("../xml/gallery/gallery.xml""w");
fwrite($fp$outxml);
fclose($fp);


function 
get_folder_xml($imageDir,$title)
  {

  
$extensions = array(".jpg"".jpeg"".JPG",".JPEG",".gif",".GIF",".swf",".SWF");
  
$output "";
  
  if(
$folder opendir($imageDir))
    {
    
$filenames=array();
        
    while (
false !== ($file readdir($folder)))
      {
      
$dot strrchr($file'.');
      if(
in_array($dot$extensions))
        {
        
array_push($filenames$file);
        }         
      }
     
$spaceTitle str_replace("_"," ",$title);
     
$newPath str_replace("../","",$imageDir);

    
$output .= "<gallery>\n";
     
$output .= "<title>$spaceTitle</title>\n";
    
$output .= " <images>\n";
    foreach (
$filenames as $source)
      {
      
$imageName str_replace("mainThumb_","",$source);
      
$finalName str_replace("_"," ",$imageName);
    
      
$imageName str_replace($extensions,"",$finalName);
      
$output .= "\t <image src=\"$newPath/$source\" thumb=\"$newPath/thumbs/$source\">$imageName</image>\n";
      }
   
$output .= " </images>\n";
   
$output .= "</gallery>\n\n";
return 
$output;
     
    
closedir($folder);   
    }
  }
?>

Last edited by wirehopper; 03-11-10 at 06:03 PM. Reason: Took spaces out of PHP tags
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 03-11-10, 06:14 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
The XML may be cached in the browser.

You might be able to test for that by adding a query string at the end and then requesting the file again, like so:

http://domain.com/flash.xml?asdfadsfads (random stuff)

If that's the case, you can use Cache-Control headers to prevent caching of that content.

Cache control from PHP PHP: header - Manual
Cache control with Apache Cache Control with htaccess FILES MATCH - Apache - Snipplr

From the snipplr link:
# NONE
<FilesMatch ".(xml)$">
Header unset Cache-Control
Header unset Expires
Header unset Last-Modified
FileETag None
Header unset Pragma
</FilesMatch>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 03-11-10, 06:46 PM
offtheroad offtheroad is offline
Newbie Coder
 
Join Date: May 2009
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
php edit help

I really hate to ask this since you've went further than any other forum, knowing nothing about php, can you show me where exactly to to the code or even better put it in the php I sent? It's the gallery.xml file that I'm having problems with. I also didn't mention but could it be something in the config.xml?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 03-11-10, 08:49 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
If your PHP file is named "file.php" and it is delivering the XML to feed the gallery, with a querystring parameter that indicates the sort order - the URL should be something like:

file.php?sortorder=random

If you request the same file again, because the parameter is the same, the server or browser may cache the content - which is great for performance, but defeats the script. To compensate, you can either send a random string (the time works well), so that each request has a different URL -

file.php?sortorder=random&t=32423

Or you could use the cache control headers at the very top of the file:

PHP Code:

<?php 

header
("Cache-Control: no-cache");
header("Expires: -1");
Posting more code may be helpful. You can use view source to display the output of the PHP code, and the XML as well.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 03-11-10, 09:23 PM
offtheroad offtheroad is offline
Newbie Coder
 
Join Date: May 2009
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
thanks

I'll first give your 3 lines of code a chance, the rest I don't understand. At 62 I'm embracing all the new technology but understanding it is another thing. Thank You.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 03-11-10, 09:55 PM
offtheroad offtheroad is offline
Newbie Coder
 
Join Date: May 2009
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Here is my site
www . 1jimage . com

Last edited by wirehopper; 03-14-10 at 09:10 PM. Reason: Link converted to text
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 03-12-10, 07:00 AM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
The site look really nice. Be sure to put some text in, for search engines.

I don't see anything wrong.

From the code, it looks like you want to present a random list of files for flash to play, is that right?

If so - if the rest of the page is working okay - I wouldn't worry about randomizing - just use what you have.

You might want to optimize some of the images, because the thumbnails seem to take a long time to load (and I have a fast connection). To optimize the images, check the tools you used to create them. Usually, under Save As, there is some sort of Optimize feature. It may also be Save for Web.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #10 (permalink)  
Old 03-12-10, 07:58 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
You could try putting this in a file named .htaccess, in the same directory as the .php / .xml files

Code:
<FilesMatch "\.(php|xml)$">
  Header set Cache-Control: "no-store, no-cache, must-revalidate, pre-check=0, post-check=0, max-age=0"
</FilesMatch>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Create a Quiz with Free Quiz Template in Adobe Flash WPeterson Flash & ActionScript 0 10-22-08 11:54 PM
Flash & XML... scoop Flash & ActionScript 2 09-25-06 01:35 PM
perl xml socket server ... stuck cloudiam Perl 2 02-28-05 10:32 AM


All times are GMT -5. The time now is 01:54 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.