TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-20-2009, 06:08 AM   #1 (permalink)
The Acquainted
 
Peuplarchie's Avatar
 
Join Date: May 2008
Location: Québec
Posts: 104
Thanks: 10
Peuplarchie is on a distinguished road
Application List part of the Session array from a link.

Good day all,
I guess I'll simplified my question :
Sorry for the ones that saay that I'm repeating.
I have an array of file and folder that I push to session arrays like that :

PHP Code:

<?php
 $session_start
();

$directory "Art/";
function 
dirList ($directory)
{
 
    
//create 2 arrays - one for folders and one for files
   
$folders = array();
   
$files = array();
 
    
// create a handler for the directory
    
$handler opendir($directory);
 
    
// keep going until all files in directory have been read
while (false !== ($file readdir($handler))) {  
 
        
// if $file isn't this directory or its parent,
        // add it to the results array
        
if ($file != '.' && $file != '..')
       
        
// If file is directory, mark it in bold.
       
if(is_dir($directory.$file)) {
        
array_push($folders,$file);
        
            if (
time() - filemtime($directory.$file) < 604800) {
    
$folder_modified[] = "<span style=\"color:#DB1212;\"><img src=\"minus_icon.gif\" id=\"plusminusimg".preg_replace('/\//','_',$directory."".$file)."\" onclick=\"Toggle('".preg_replace('/\//','_',$directory."".$file)."'); return false;\" /><a href=\"#\" style=\"color:#DB1212;\" onclick=\"load('folder_view.php?dir=".$directory."&file=".$file."','boxdisp');return false;\"><b>".$file."</b></a>";
} elseif (
time() - filemtime($directory.$file) < 31556926) {
    
$folder_modified[] = "<span style=\"color:#003366;\"><img src=\minus_icon.gif\"  id=\"plusminusimg".preg_replace('/\//','_',$directory."".$file)."\"  onclick=\"Toggle('".preg_replace('/\//','_',$directory."".$file)."'); return false;\" /><a href=\"#\" style=\"color:#003366;\" onclick=\"load('folder_view.php?dir=".$directory."&file=".$file."','boxdisp');return false;\"><b>".$file."</b></a>";
} else {
$folder_modified[] = "<span style=\"color:#000000;\"><img src=\"minus_icon.gif\"  id=\"plusminusimg".preg_replace('/\//','_',$directory."".$file)."\"  onclick=\"Toggle('".preg_replace('/\//','_',$directory."".$file)."'); return false;\" /><a href=\"#\" style=\"color:#000000;\" onclick=\"load('folder_view.php?dir=".$directory."&file=".$file."','boxdisp');return false;\"><b>".$file."</b></a>";}
 
        
       
        
// Else not styled
        
}else{
        
array_push($files,$file);
     
$filenamecor substr($file0, -4);
    if (
time() - filemtime($directory.$file) < 604800) {
    
$file_modified[] = '<span style="color:#DB1212;">'.$filenamecor.'<span>';
} elseif (
time() - filemtime($directory.$file) < 31556926) {
    
$file_modified[] = '<span style="color:#003366;">'.$filenamecor.'<span>';
} else {
$file_modified[] = '<span style="color:#000000;">'.$filenamecor.'<span>';}
 
 
    }

    }
               
$_SESSION['folders']=$folders;  
       
$_SESSION['files']=$files;  
 
    echo 
"<ul id=\"".preg_replace('/\//','_',substr($directory,0,strlen($directory)-1))."\">\n"//start a new unordered list for every iteration through dirList
 
$dircor $directory;
    
// tidy up: close the handler
    
closedir($handler);
    foreach(
$folders as $folder=>$file) {
        
      echo 
"<li id=\"pic\"><div class=\"folder\">".$folder_modified[$folder]."</div>"//echo the folder name enclosed in a list item
        
dirList($directory.$file.'/'); //loop through the contents of $folder
      
echo "</li>\n"//close this list item after all files and folders in $folder have been looped through
   
   
    
}
 
    foreach(
$files as $key=>$file) {

      echo 
"<li id=\"pic\"><a href=\"index.html\" onclick=\"load('image_view.php?dir=".$dircor."&file=".$file."','boxdisp');return false;\">&nbsp;".$file_modified[$key]."</a></li>\n"//echo the file name enclosed in a list item
    
}
 
 
    echo 
"</ul>\n"//close the unordered list
}


dirList($directory);
 
?>

</div>

Now, like you can see , each file and folders are links.
I have no problem looking at the files, but for the folder I should be able to see all the file in that directory, non recursively listed from the arrays like here is my code now :

PHP Code:



<?PHP
session_start
(); 

$dir $_GET['dir'];
$file $_GET['file'];


foreach(
$_SESSION['folders'] as $role ) {
    
    echo 
$role;

}

echo 
"<br>";


?>
Thnaks !
__________________
That's why we are not alone on earth... let's build !
Peuplarchie is offline  
Reply With Quote
Old 04-20-2009, 03:37 PM   #2 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

You have this:

Code:
$session_start();

But it should just be this:

Code:
session_start();

I'm testing this against my mySQL directory and I am getting an error on line 39:

Warning: filemtime() [function.filemtime]: stat failed for /usr/local/mysqldocs in /usr/local/apache/public/directory_session.php on line 39


which is this line:

Code:
if (time() - filemtime($directory.$file) < 604800) {
allworknoplay is offline  
Reply With Quote
Old 04-20-2009, 04:13 PM   #3 (permalink)
The Acquainted
 
Peuplarchie's Avatar
 
Join Date: May 2008
Location: Québec
Posts: 104
Thanks: 10
Peuplarchie is on a distinguished road
Default

I can't use a database for this.
__________________
That's why we are not alone on earth... let's build !
Peuplarchie is offline  
Reply With Quote
Old 04-20-2009, 04:17 PM   #4 (permalink)
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

Quote:
Originally Posted by Peuplarchie View Post
I can't use a database for this.
I didn't say i was using a database, I said I was using my DB directory to test this.
allworknoplay is offline  
Reply With Quote
Old 04-20-2009, 07:07 PM   #5 (permalink)
The Acquainted
 
Peuplarchie's Avatar
 
Join Date: May 2008
Location: Québec
Posts: 104
Thanks: 10
Peuplarchie is on a distinguished road
Default

it doesn't give me any error ?
__________________
That's why we are not alone on earth... let's build !
Peuplarchie is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a gallery class Tanax Advanced PHP Programming 25 02-19-2013 04:25 AM
Session array and diplaying images on other file Peuplarchie General 0 04-20-2009 04:32 AM
array elements into variables and values Dave Absolute Beginners 7 06-20-2008 01:56 PM
Understanding the Life of a Session Wildhoney General 6 10-27-2007 02:34 AM
Part 1: Getting Started with Array Functions Wildhoney Absolute Beginners 6 10-01-2007 10:53 AM


All times are GMT. The time now is 03:13 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design