Jump to content

Recommended Posts

I would really appreciate some help with a php script to change the way it orders some small images in a directory.
As part of my ham radio hobby I have 4 web pages displaying slow scan tv pictures as infinitely scrolling web galleries. Until very recently they worked fine, ordering the images according to their names, which are also the date & time of reception.
However, a change forced on me by the software I use to receive these has messed the system up by changing the structure of the file names. 
To save having to rename some 30,000 images, I now need to sort them by the last modified date, but try as I might, I can't seem to get it to work. This is my existing php script-


<?php
     $dir = "40mArchives/";    
     if(is_dir($dir)){
        if($dd = opendir($dir)){
            while (($f = readdir($dd)) !== false)
                if($f != "." && $f != "..")
                    $files[] = $f;
            closedir($dd);
        } 
// sensible sort
$sortbool = rsort($files,SORT_STRING);     
 
    $n = $_GET["n"];
    $response = "";
        for($i = $n; $i<$n+12; $i++){
           $response = $response.$files[$i%count($files)].';';
        }
        echo $response;
    }
?>

Which has been working well for quite a number of years- despite the fact I think the sort is not quite right- but it seemed like a good idea at the time!
I have tried all manner of different things from web searches over the last month or so, none of which I have been able to persuade to do what I need.
It doesn't help that as I am aging I am finding it more & more difficult to wrap my brain around these things- so any assistance would be very well received!

This is one of my sstv pages-
https://sstv.vk7krj.com/40m.html
and my main web site-
https://vk7krj.com/

Thanks, Ken, vk7krj

Link to comment
https://forums.phpfreaks.com/topic/319508-sort-by-date-modified/
Share on other sites

Posted (edited)

Barand, thanks for taking the time to reply to my question- but after spending yet more hours trying to get this working I am giving up on this solution for now, and having a look at using python to fix the problem instead. I am not a programmer or web developer, just a retired ham trying to make things work the way I want them to. 

I think I can get the errant program to save the files in one directory, then use a python script to rename and move them to the correct directory. Again, I'm no python programmer, but with lots of reading I can usually muddle through. There's quite a bit of python behind my web pages, all of which I wrote myself, and the whole shebang is hosted right here in my radio shack. And like you, I am 75 years young! (and originally from Sheffield, but that was over 50 years ago)

Ken, vk7krj

https://vk7krj.com/index.html

Edited by vk7krj

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.