Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Scriptino per mostrare l'ultima data di modifica

    Quando modifico un file, cerco di ricordarmi di andare ad aggiornare l'ultima data di modifica del sito in un piccolo riquadro nel menù di sinistra.
    Esiste qualcosa che, una volta al giorno, vada a controllare le date di modifica di tutti i file, prenda quella data, e la mostri automaticamente, permettendomi di lasciar aggiornare la data automaticamente?
    grazie
    My site www.flapane.com - MY GALLERY - MY BLOG
    PC Intel i3-2120 - Ibook 12'' 1,33ghz 1.5GB 160GB - MBP 15'' i7 2,2ghz - Samsung S4 Mini - Sony a6000 - YamahaP90

  2. #2
    Ne ho trovato uno in giro e l'ho adattato per mostrare a video il risultato, mostrando il prima e il dopo della funziona, per capire se effettivamente facesse il suo lavoro, e convertito il timestamp in data...
    Ora devo solo capire come scrivere il valore in un file... la funzione cerca anche nelle subdir, e impiega circa un secondo a mostrare l'output, con 3200 files.

    http://www.flapane.com/time.php
    Codice PHP:
    <?php

    // Only take into account those files whose extensions you want to show.
    $allowedExtensions = array(
      
    'gif',
      
    'rar',
      
    'pdf',
      
    'txt'
    );

    function 
    filemtime_r($path)
    {
        global 
    $allowedExtensions;
       
        if (!
    file_exists($path))
            return 
    0;
       
        
    $extension end(explode("."$path));    
        if (
    is_file($path) && in_array($extension$allowedExtensions))
            return 
    filemtime($path);
        
    $ret 0;
       
         foreach (
    glob($path."/*") as $fn)
         {
            if (
    filemtime_r($fn) > $ret)
                
    $ret filemtime_r($fn);   
                
    // This will return a timestamp, you will have to use date().
         
    }
        return 
    $ret;   
    }
    $mostra 0;
    echo 
    "Before the function, mostra = "$mostra ."
    "
    ;
    $mostra filemtime_r("/home/flapanec/public_html/");
    echo 
    "After the function, mostra = " $mostra ."
    "
    ;
    echo 
    date("r",$mostra);

    ?>
    My site www.flapane.com - MY GALLERY - MY BLOG
    PC Intel i3-2120 - Ibook 12'' 1,33ghz 1.5GB 160GB - MBP 15'' i7 2,2ghz - Samsung S4 Mini - Sony a6000 - YamahaP90

  3. #3
    Adattandola così sono riuscito a fargli fare quello che mi serviva, magari servirà a qualcuno

    Codice PHP:
    <?php
    $fp 
    fopen('time.txt''w');
    // Only take into account those files whose extensions you want to show.
    $allowedExtensions = array(
      
    'deb',
      
    'htm',
      
    'html',
      
    'php',
      
    'sh',
      
    'zip',
      
    'rar',
      
    'jpg',
      
    'js'
    );

    function 
    filemtime_r($path)
    {
        global 
    $allowedExtensions;
       
        if (!
    file_exists($path))
            return 
    0;
       
        
    $extension end(explode("."$path));    
        if (
    is_file($path) && in_array($extension$allowedExtensions))
            return 
    filemtime($path);
        
    $ret 0;
       
         foreach (
    glob($path."/*") as $fn)
         {
            if (
    filemtime_r($fn) > $ret)
                
    $ret filemtime_r($fn);   
                
    // This will return a timestamp, you will have to use date().
         
    }
        return 
    $ret;   
    }

    $mostra filemtime_r("/path/to/");
    $scrivi date('j M y'$mostra);

    fwrite($fp$scrivi);
    fclose($fp); 

    ?>
    My site www.flapane.com - MY GALLERY - MY BLOG
    PC Intel i3-2120 - Ibook 12'' 1,33ghz 1.5GB 160GB - MBP 15'' i7 2,2ghz - Samsung S4 Mini - Sony a6000 - YamahaP90

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.