Shoutbox

Help me please with script - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Skype & Technology (/forumdisplay.php?fid=9)
+---- Forum: Tech Talk (/forumdisplay.php?fid=17)
+----- Thread: Help me please with script (/showthread.php?tid=43694)

Help me please with script by absorbation on 04-26-2005 at 06:04 PM

Dempsey gave me this script to show how many soundpacks are in my soundpacks folder (on the site):


function count_files( $dir )
{
     $retval = 0;
     if( $dir && is_dir( $dir ) )
     {
          if( ($d = opendir( $dir )) !== false )
          {
               while( ($f = readdir( $d )) !== false )
               {
                    if( is_file( $dir . "/" . $f ) ) ++$retval;
               }
               closedir( $d );
          }
     }
     return $retval;
}

print count_files( "/soundpacks" );



I firstly dont get how to use php :$ and how to add it to my homepage. :(

Please, please help me :P


RE: Help me please with script by Eljay on 04-26-2005 at 06:12 PM

open notepad and paste this code into a new file

code:
<?
function count_files( $dir )
{
     $retval = 0;
     if( $dir && is_dir( $dir ) )
     {
          if( ($d = opendir( $dir )) !== false )
          {
               while( ($f = readdir( $d )) !== false )
               {
                    if( is_file( $dir . "/" . $f ) ) ++$retval;
               }
               closedir( $d );
          }
     }
     return $retval;
}

print count_files( "/soundpacks" );
?>


save it as soundpacks.php or whatever and upload
RE: Help me please with script by absorbation on 04-26-2005 at 08:46 PM

Thanks how would i insert the script to work in a page so it says hosting 62 soundpacks or whatever :P


RE: Help me please with script by segosa on 04-26-2005 at 09:05 PM

You need your pages to be .php ones.. and in the place you want it to appear you put..

code:
<?php
function count_files( $dir )
{
     $retval = 0;
     if( $dir && is_dir( $dir ) )
     {
          if( ($d = opendir( $dir )) !== false )
          {
               while( ($f = readdir( $d )) !== false )
               {
                    if( is_file( $dir . "/" . $f ) ) ++$retval;
               }
               closedir( $d );
          }
     }
     return $retval;
}

echo "We have ".count_files( "/soundpacks" )." sound packs..";
?>

or whatever..
RE: Help me please with script by absorbation on 04-26-2005 at 09:31 PM

Thanks alot it really works :D