• Forum
  • Doc
  • Screenshots
  • Download
  • Donate
  • Contributors
  • Contact
  • Follow @phpfreechat
  • DEMO
  • Board index ‹ Version 1.x branch ‹ Contributions (v1.x)
  • Change font size
  • FAQ
  • Register
  • Login

Cleaning /data/private files...

Post a bug fix, a new feature, a theme ...

Moderators: OldWolf, re*s.t.a.r.s.*2

Post a reply
2 posts • Page 1 of 1

Postby rmff » Fri Mar 16, 2007 2:45 am

For who want to clean session chat files and don't have user privileges to do that, a create a PHP script for search and delete these files.

This is useful when you are config and testing the chat.

Enjoy it.

[]'s,
Rafael.

Code: Select all
<?
// REMOVE ALL CACHE, LOGS AND CHAT HISTORY FILES STORAGE IN /PHPFREECHAT/DATA/PRIVATE

// Based in script posted by <torch at torchsdomain dot com> on PHP site.

$pathToChatBase = "/home/rafael/public_html/phpfreechat";

function rfr($path,$match){
   echo "<BR>CURRENT DIR: ".$path."<BR>";
   static $deld = 0, $dsize = 0;
   $dirs = glob($path."*");
   $files = glob($path.$match);
   foreach($files as $file){
     if(is_file($file)){
         $dsize += filesize($file);
         if (unlink($file)){
          echo "<BR>Removed file: $file";
       }else{
          echo "<BR>NOT removed file: $file";
       }
      
         $deld++;
     }
   }
   foreach($dirs as $dir){
     if(is_dir($dir)){
         $dir = basename($dir) . "/";
         rfr($path.$dir,$match);
     }
   }
   foreach($dirs as $dir){
     if(is_dir($dir)){
         if (rmdir($dir)){
          echo "<BR>Removed dir: $dir";
       }else{
          echo "<BR>NOT removed dir: $dir";
       }
     }
   }
   echo "<BR><BR>$deld files deleted with a total size of $dsize bytes<BR><BR>";
}

rfr($pathToChatBase.'/data/private/chat/','*');
rfr($pathToChatBase.'/data/private/cache/','*');
rfr($pathToChatBase.'/data/private/logs/','*');
rfr($pathToChatBase.'/data/private/','debugchat*');
?>
Last edited by rmff on Fri Mar 16, 2007 2:49 am, edited 1 time in total.
rmff
New member
 
Posts: 2
Joined: Fri Mar 16, 2007 1:01 am
Location: Brazil
  • Website
Top

Postby benjam » Sun Jul 08, 2007 8:26 am

another thing you can do...

replace the following line:
$pathToChatBase = "/home/rafael/public_html/phpfreechat";

with this one:
$pathToChatBase = dirname(__FILE__);

and put the file in the phpfreechat directory and it will work for everybody everywhere, no config required.

i would also recommend that you add the following to the top of the file:
if ('your_pass' != $_GET['pass']) {
exit;
}


then (if the file is named remove_files.php) the script will fail unless the URL is entered in the browser as .../remove_files.php?pass=your_pass

which will keep your files a little bit safer.
benjam
New member
 
Posts: 2
Joined: Sun Jul 08, 2007 8:21 am
Top


Post a reply
2 posts • Page 1 of 1

Return to Contributions (v1.x)

Who is online

Users browsing this forum: No registered users and 3 guests

  • Board index
  • The team • Delete all board cookies • All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
cron
Sign in
Wrong credentials
Sign up I forgot my password
.
jeu-gratuit.net | more partners
Fork me on GitHub