Jump to content

hellonoko

Members
  • Posts

    213
  • Joined

  • Last visited

Posts posted by hellonoko

  1. When I take out the if (is_dir) statment in this code it echo's the directories.

     

    When I put it in to check if they are directories it only display . and ..

     

    <?php
    
    $users_directory = "/home2/sharingi/public_html/subdomains";
    
    if ($dir_handle = opendir($users_directory))
    {
    	while (false !== ($file = readdir($dir_handle)))
    	{
    		if( is_dir($file) )
    		{
    			echo $file;
    			echo "<br>";
    		}
    	}
    
    }
    closedir($dir_handle);
    ?>
    

  2. My below code displays a directory contents listing.

     

    I am trying to make it separate the files into blocks based on the day value of the modified date of the file.

     

    While looping through the files. If the date of the last file displayed is different than the current file the script inserts a second <br>

     

    For some reason though I can not get it to put the double breaks in the correct place.

     

    http://www.sharingizcaring.com/REPOSITORY/

     

    <?php
    
    include '../menu.php';
    
    echo '<br>';
    
    include '../count2.php';
    
       	$arr = array();
    
       	foreach (glob("*.*") as $filename) 
       	{
          	$arr[$filename] = filemtime($filename);
        	//echo $filename . " was last modified on " . date('M d Y, h:i:m', filemtime($filename)) . "<br>";    
       	}
    
       ///
       
       //asort($arr);
       //echo "<br>";
    
    //foreach($arr as $key => $value) 
       	//{
        //	echo "$key was last modified on " . date('M d Y, h:i:m', $value) . "<br>";
       	//}
    
    ///
    
       	arsort($arr);
       	echo "<br>";
    
    $olddate = 0;
    
       	foreach($arr as $key => $value) 
    {
         
    	if ( $key !== "filelist3.php" && $key !== "index.php" )
    	{
    
    		echo $date = date("d", filemtime($key));
    
    		if ( $date !== $olddate )
    		{
    			echo "<br><br>";				
    		}
    		else
    		{
    			echo "<br>";
    		}
    
    
    
    		print "<object type=\"application/x-shockwave-flash\" data=\"http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key&b_colors=,,ff0000,&\" width=\"17\" height=\"17\"";
             	print "<param name=\"movie\" value=\"http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key&b_colors=,,ff0000,&\"</object>";
    
             	//print "<img src=\"noflash.gif\" width=\"17\" height=\"17\" alt=\"\" />";
             	print "<span class=small_font><a href=\"http://www.sharingizcaring.com/REPOSITORY/$key\" class=".color()."> $key</a></span>";
    
    
    
    		$olddate = $date;	
    
    		//echo "<br>";
    
    
    
    	}
       	} 
    
    function color()
    {
    
    	$color =  rand( 1,7);
    
    	if ($color == 1)
    	{
    		return "red";
    	}
    	if ($color == 2)
    	{
    		return "green";
    	}
    	if ($color == 3)
    	{
    		return "blue";
    	}
    	if ($color == 4)
    	{
    		return "yellow";
    	}
    	if ($color == 5)
    	{
    		return "babyblue";
    	}
    	if ($color == 6)
    	{
    		return "purple";
    	}
    	if ($color == 7)
    	{
    		return "grey";
    	}
    }
    ?>
    
    </body>
    </html>

     

  3. I have a simple script that list a directories contents.

    I am trying to cause it to insert double <br> tags whenever it detects files of a different day.

     

    Thus grouping the files by day modified.

     

    $olddate = 0;
    
       	foreach($arr as $key => $value) 
    {
         
    	if ( $key !== "filelist3.php" && $key !== "index.php" )
    	{
    
    
    
    		print "<object type=\"application/x-shockwave-flash\" data=\"http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key&b_colors=,,ff0000,&\" width=\"17\" height=\"17\"";
             	print "<param name=\"movie\" value=\"http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key&b_colors=,,ff0000,&\"</object>";
    
             	//print "<img src=\"noflash.gif\" width=\"17\" height=\"17\" alt=\"\" />";
             	print "<span class=small_font><a href=\"http://www.sharingizcaring.com/REPOSITORY/$key\" class=".color()."> $key</a></span>";
    
    
    
    		echo $date = date("d", filemtime($key));
    
    		echo "<br>";
    
    		if ( $date !== $olddate && $olddate !== 0 )
    		{
    			echo "<br>";
    		}
    
    		$olddate = $date;
    	}
       	} 

     

    It compares the modified day of the current file to that of the last one and if it finds a difference it causes a second <br>

     

    For some reason I can't get the second <br> to appear in the correct spot though. It is always one line too low.

     

    http://www.sharingizcaring.com/REPOSITORY/

     

    Any ideas?

     

     

  4. After I cleaned up some quotes...

     

    <?php
       $dir = "/home2/sharingi/public_html/subdomains";
       $dh = opendir($dir);
       while (false !== ($filename = readdir($dh)))
       {
          if ($filename !== "." && $filename !== "..")
          {
             $files['$filename'] = count(glob("/home2/sharingi/public_html/subdomains/" . $filename . "/filez/" . "*.mp3"));   
          }
       }
            ksort($files);
            
    	foreach($files as $file => $count) echo $file . ":"  . $count . "<br>";
    ?>

     

    Returns

     

     

     

    $filename:2

     

     

     

    Thats all.

    ?

  5. My script below enters the name of a directory and the count of its contents into an array.

     

    I think I captures the information correctly.

     

    However I am not sure how to get it to echo it back out.

     

    <?php
    
    $dir = "/home2/sharingi/public_html/subdomains";
    
    $dh = opendir($dir);
    
    
    while (false !== ($filename = readdir($dh)))
    {
    	if ($filename !== "." && $filename !== "..")
    	{
    
    		$files['name'] = $filename;
    
    		$files['count'] = count(glob("/home2/sharingi/public_html/subdomains/" . $filename . "/filez/" . "*.mp3"));	
    
    		echo $files['name'];
    		echo '<br>';
    		echo $files['count'];
    		echo '<br>';
    
    	}
    }

     

    Basically I am trying display a sorted list of the directories and their count.

     

    Folder1 10

    Folder2 6

    Folder3 2

     

    Thanks,

    ian

  6. I think I see how this works but isn't it still going to not work for me since I need a count of files not the size.

     

    If use A had 10 files all totaling 1meg and user B had 2 files each 10megs then I still need to sort user A first.

     

    Here is my newest code that reads all the info into an array. I think it works correct but I am not sure how to get it to display the info.

     

    <?php
    
    $dir = "/home2/sharingi/public_html/subdomains";
    
    $dh = opendir($dir);
    
    
    
    while (false !== ($filename = readdir($dh)))
    {
    	if ($filename !== "." && $filename !== "..")
    	{
    
    		$files['name'] = $filename;
    
    		$files['count'] = count(glob("/home2/sharingi/public_html/subdomains/" . $filename . "/filez/" . "*.mp3"));
    
    
    		echo $files['name'];
    		echo '<br>';
    		echo $files['count'];
    		echo '<br>';
    
    	}
    }

  7. no idea how this works but returns:

     

    ()

    /home2/sharingi/public_html/subdomains/raphael/cgi-bin (4)

    /home2/sharingi/public_html/subdomains/raphael/tmp (4)

    /home2/sharingi/public_html/subdomains/iana/cgi-bin (4)

    /home2/sharingi/public_html/subdomains/test/tmp (4)

    /home2/sharingi/public_html/subdomains/iana/tmp (4)

    /home2/sharingi/public_html/subdomains/test/cgi-bin (4)

    /home2/sharingi/public_html/subdomains/iana/filez (4264)

    /home2/sharingi/public_html/subdomains/iana (4304)

    /home2/sharingi/public_html/subdomains/raphael/filez (14692)

    /home2/sharingi/public_html/subdomains/raphael (14732)

    /home2/sharingi/public_html/subdomains/test/filez (131628)

    /home2/sharingi/public_html/subdomains/test (131668)

    /home2/sharingi/public_html/subdomains (150708)

     

     

    was hoping for something more like.

     

    test 13

    raphael 2

    iana 1

  8. I am trying to display a list of directories an the count of their file contents sorted by volume.

     

    Have been playing around with a few things but I can't quite get it to work.

     

    <?php
    
    $dir = "/home2/sharingi/public_html/subdomains";
    
    $dh = opendir($dir);
    
    while (false !== ($filename = readdir($dh)))
    {
    	if ($filename !== "." && $filename !== "..")
    	{
    		//$files[] = $filename;
    
    		//$files[] = count(glob("/home2/sharingi/public_html/subdomains/" . $filename . "/filez/" . "*.mp3"));
    
    		$files['user'][$x] = $filename;
    		$files['count'][$x] = $files[] = count(glob("/home2/sharingi/public_html/subdomains/" . $filename . "/filez/" . "*.mp3"));
    
    		$x++;
    
    	}
    }
    
    sort ($files);
    
    //for $i = 0; $i < sizeof($files); $i++;
    //{
    //	echo $files['user'][$value];
    //	echo '<br>';
    //	echo $files['count'][$value];
    //	echo '<br>';
    
    //	i++;
    //}
    
    foreach ( $files as $value)
    {
    	echo $files['user'][$value];
    	echo '<br>';
    	echo $files['count'][$value];
    	echo '<br>';
    }
    
    //unset $value;
    
    //print_r($files);
    
    ?>
    

     

    Any suggestions?

  9. I have a directory /subdomains/

     

    And inside of that directory is a user folder /mike/  /bob/ /tim/  etc.

     

    I have written a simple scrip to count the files inside the user folder:

     

    <?php
    
    session_start();
    
    echo "<title>count</title>";
    
    $dir = "subdomains/" . $_SESSION['login'] . "/filez/";
    
    $count = count(glob($dir . "*.mp3"));
    
    echo $_SESSION['login'];
    echo '<br>';
    echo $count;
    
    ?>

     

     

    What I am now trying to do is put this script inside a script that can go through each directory and count the number of files and then sort them by most to least.

     

    So I can return:

     

    Mike 10

    Bob 8

    Jim 5

     

    and so on.

     

    I think I need to place it all in a loop that places each directory count into a array as it goes through the directories in /subdomains/ but I am not sure how to work with directories in that way.

     

    Thanks in advance,

    ian

  10. sprintf() does not do anything.

     

    when i un-escape my quotes it fails.

     

    			
    		sprintf( "<object type="application/x-shockwave-flash" data="http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key" width="17" height="17">");
             	sprintf( "<param name="movie" value="http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key"/>");
    
             	sprintf( "<img src="noflash.gif" width="17" height="17" alt="" />");
             	sprintf( "$key<br>");

  11. My below code displays a list of mp3s in a directory each with a mini mp3 player to listen to it.

     

    Depending on how I work the quotes for it either only the first flash music player shows up. Or all the songs shows up but the flash players are broken.

     

    Any suggestions?

     

    <?php
    
       	$arr = array();
    
       	foreach (glob("*.*") as $filename) 
       	{
          	$arr[$filename] = filemtime($filename);
    
       	}
    
    
       	arsort($arr);
       	echo "<br>";
    
       	foreach($arr as $key => $value) 
    {
        	
    	if ( $key !== "filelist3.php")
    	{
    
    
    		echo '<object type=\"application/x-shockwave-flash\" data=\"http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key\" width=\"17\" height=\"17\">';
             	echo '<param name=\"movie\" value=\"http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key\"/>';
    
             	echo '<img src=\"noflash.gif\" width=\"17\" height=\"17\" alt=\"\" />';
             	echo "$key<br>";
    	}
       	} 
    ?>

  12. Escaped the quotes and does not have any errors but still only displays one song. And not the first one.

     

    www.sharingizcaring.com/REPOSITORY/filelist3.php

     

    <?php
    
       	$arr = array();
    
       	foreach (glob("*.*") as $filename) 
       	{
          	$arr[$filename] = filemtime($filename);
        	//echo $filename . " was last modified on " . date('M d Y, h:i:m', filemtime($filename)) . "<br>";    
       	}
    
       ///
       
       //asort($arr);
       //echo "<br>";
    
    //foreach($arr as $key => $value) 
       	//{
        //	echo "$key was last modified on " . date('M d Y, h:i:m', $value) . "<br>";
       	//}
    
    ///
    
       	arsort($arr);
       	echo "<br>";
    
       	foreach($arr as $key => $value) 
    {
        	
    	if ( $key !== "filelist3.php")
    	{
    
    
    		echo "<object type=\"application/x-shockwave-flash\" data=\"http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key\" width=\"17\" height=\"17\">";
             	echo "<param name=\"movie\" value=\"http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key\"/>";
    
             	echo "<img src=\"noflash.gif\" width=\"17\" height=\"17\" alt=\"\" />";
             	echo "$key<br>";
    	}
       	} 
    ?>

     

    Tried it with soft quotes on the outside '<object.....

     

    And that does not break the loop but breaks the Flash. That is how it is now.

  13. full code:

     

    <?php
    
       	$arr = array();
    
       	foreach (glob("*.*") as $filename) 
       	{
          	$arr[$filename] = filemtime($filename);
        	//echo $filename . " was last modified on " . date('M d Y, h:i:m', filemtime($filename)) . "<br>";    
       	}
    
       ///
       
       //asort($arr);
       //echo "<br>";
    
    //foreach($arr as $key => $value) 
       	//{
        //	echo "$key was last modified on " . date('M d Y, h:i:m', $value) . "<br>";
       	//}
    
    ///
    
       	arsort($arr);
       	echo "<br>";
    
       	foreach($arr as $key => $value) 
    {
        	
    	if ( $key !== "filelist3.php")
    	{
    
    		echo "<object type="application/x-shockwave-flash" data="http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key" width="17" height="17">";
             	echo "<param name="movie" value="http://www.sharingizcaring.com/button/musicplayer.swf?&song_url=http://www.sharingizcaring.com/REPOSITORY/$key"/>";
    
             	echo "<img src="noflash.gif" width="17" height="17" alt="" />";
             	echo "$key<br>";
    	}
       	} 
    ?>

  14. thorpe. your version returns:

     

    Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home2/sharingi/public_html/REPOSITORY/filelist3.php on line 32

     

    blade that is what i also though he meant but that did not work either.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.