• User

    random.php collegato a database access

    ciao a tutti!
    per diverso tempo ho utilizzato il codice qui sotto per prelevare "random" le immagini presenti in cartelle specifiche intervenendo manualmente sul file random.php.
    adesso però utilizzo un database access per gestire le gallerie fotografiche e, dal momento che non sono riuscito a trovare un codice simile in asp, vorrei sapere come bisogna modificare quello attuale aggiungendo i vari collegamenti al file gallery.mdb, in modo che il PERCORSO_FOTO si aggiorni in automatico in base all'ultima galleria inserita.

    [php]
    <?php
    // If the images are in the same directory, leave it blank.
    $folder = '../../PERCORSO_FOTO/';
    $exts = 'jpg jpeg png gif';
    $files = array(); $i = -1; // Initialize some variables
    if ('' == $folder) $folder = './';
    $handle = opendir($folder);
    $exts = explode(' ', $exts);
    while (false !== ($file = readdir($handle))) {
    foreach($exts as $ext) { // for each extension check the extension
    if (preg_match('/.'.$ext.'$/i', $file, $test)) {
    $files[] = $file;
    ++$i;
    }
    }
    }
    closedir($handle); // We're not using it anymore
    mt_srand((double)microtime()*1000000); // seed for PHP < 4.2
    $rand = mt_rand(0, $i); // $i was incremented as we went along
    header('Location: '.$folder.$files[$rand]);
    ?>

    <img src="http://www.sito.it/random.php">[/php]


  • User

    nessuno che sa darmi un aiutino? 😞