LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-16-2018, 07:25 AM   #16
dedec0
Senior Member
 
Registered: May 2007
Posts: 1,372

Original Poster
Rep: Reputation: 51

Now I made an edit in the previous post.

Yesterday I wrote

Quote:
For the GAME idea, if someone knows a simple and easy to use (enough to what I want!) PHP script for listing files, please point. (...)
where should be

Quote:
For the SAME idea, if someone knows a simple and easy to use (enough to what I want!) PHP script for listing files, please point. (...)
The rest seems right.
 
Old 05-16-2018, 01:06 PM   #17
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Here is a quick example to get you started:
PHP Code:
<?php
date_default_timezone_set
('America/Sao_Paulo');
$directory '/my/directory/path';

$files scandir($directory);
$list = [];

foreach (
$files as $name) {
    
$file "$directory/$name";

    
$val = [ 'size'  => is_dir($file) ? '-' filesize($file),
             
'mtime' => filemtime($file),
             
'name'  => $name
           
];
             
    
$list[] = $val;
}

function 
fileDate($time) {
    return 
date ("Y-m-d H:i"$time);
}

function 
fileCustomSize($size) {
    if (
$size 1000) return $size;
    return 
sprintf('%0.1fK'$size/1000);
}
?>

<!DOCTYPE html>
<html>
  <head>
    <title>Index</title>
  </head>
  <body>
<?php
    
foreach ($list as $file) {
        echo 
$file['name'].' '.fileDate($file['mtime']).' '.fileCustomSize($file['size']).'<br>'."\n";
    }
?>
  </body>
</html>
 
1 members found this post helpful.
  


Reply

Tags
apache php php.ini



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
TimeZone Problem shipon_97 Linux - Newbie 10 05-13-2015 09:35 AM
[SOLVED] Possibly a small bug in gvfs slackbuild I found... yars Slackware 2 11-21-2014 12:51 AM
is changing my server's timezone really this difficult? sneakyimp Linux - Server 2 11-02-2012 02:27 AM
TimeZone problem MikeyCarter Fedora 2 03-26-2007 03:16 PM
timezone problem Lord Zoltar Linux - General 5 09-13-2004 10:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration