0

We are having the hardest time re-writing this photo-gallery function. It works perfectly on the same server as the images. Now we had to move all images to another server due to costly effects.

The gallery function works great on the same server. When we try a remote server path like: http://www.myotherserver.com -- then that is where it returns NO images ?

We found the "function" that reads / lists the images without an image file, but we can't decode it to use it on a remote server ?

Any help or ideas ? THanks.

Here is the function:

Take note :: we are NOT going to use an .txt file with the image order -- we just want the script to read the directory and list images to use..

/**
 * Check for image order file. In case it does not
 * exists, read the image directory.
 */
  if (is_file($order_file_path . '/' . $order_file_name)) {

  $fp  = fopen($order_file_path . '/' . $order_file_name, "r");
    $row = '';
    $use_order_file = 'true';

    while ($data = fgetcsv ($fp, 1000, ';')) {
        $image_data[] = trim($data[0]);
        $image_file_names[trim($data[0])] = trim($data[0]);
        $num = count($data);
        $row++;

        for ($j = 0; $j < $num; $j++) {
            $content_data_temp['field_' . $j] = $data[$j];
        } 

        $content_data[] = $content_data_temp;
        $content_data_temp = '';
    } 
    fclose ($fp);
} else if (is_dir($image_path)) {
    $content_data = '';
    $handle = opendir($image_path);

    while ($file = readdir($handle)) {
        if (preg_match("/^\.{1,2}$/i", $file)) {
            continue;
        } 
        if (preg_match("/\.[a-z]{3}$/i", $file)) {
            $image_data[] = $file;
            $image_file_names[$file] = $file;
        } 
    } 
    closedir($handle);
} else {
    echo 'Image Path not working';
    exit;
} 

$image_number = count ($image_data);
eberswine
  • 1,224
  • 3
  • 20
  • 39

1 Answers1

1

One option you could look into is just mounting the remote pictures directory as an NFS share. That way, your script will work just fine, as the NFS share acts just like a local directory.

Other than that, you have to keep in mind that from one server you do not have access to the other server filesystem, so this script won't work. A 'dirty' option I can think of is setting up a web server in the pictures machine with indexes on, the navigate to the 'folder' and parse the resulting HTML.

mrzard
  • 311
  • 1
  • 4
  • Interesting. THanks for the suggestion. How would I go about NFS ? ALso, do you think FTP function would work ? – eberswine Sep 20 '12 at 14:51
  • 1
    @eberswine You could probably try with FTP. Take a look at this other question for that: http://stackoverflow.com/questions/4088805/getting-the-list-of-files-over-ftp Also, regarding NFS, there are plenty of tutorials out there, for example http://how-to.linuxcareer.com/how-to-configure-nfs-on-linux – mrzard Sep 20 '12 at 15:08