• 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

Clear cache with php

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

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

Post a reply
4 posts • Page 1 of 1

Postby Fredkl » Fri Dec 01, 2006 9:55 am

My code below to delete cache :
Warning : as it is now when I call the function , I also delete .htaccess file set the pass while calling function to delete what you want , place this file in chat root.

You must set correct permissions on folder 777.

function deleteDir($dir)
{
if (substr($dir, strlen($dir)-1, 1) != '/')
$dir .= '/';

echo $dir.'
';

if ($handle = opendir($dir))
{
while ($obj = readdir($handle))
{
if ($obj != '.' && $obj != '..')
{
if (is_dir($dir.$obj))
{
if (!deleteDir($dir.$obj))
return false;
}
elseif (is_file($dir.$obj))
{
if (!unlink($dir.$obj))
return false;
}
}
}

closedir($handle);

if (!@rmdir($dir))
return false;
return true;

}
return false;
}
if (@opendir('data/public')) {
deleteDir('data/public');
deleteDir('data/private');
echo 'Above cache list has been cleared! - You can close the window';
}else{echo 'Chat cache is already empty!';}
Fredkl
New member
 
Posts: 4
Joined: Fri Dec 01, 2006 9:45 am
Top

Postby MirrorOnTheWall » Mon Dec 04, 2006 11:00 pm

THANK YOU so much for this!! it's been very helpful for me!!

I'm glad to see that around this great tool, a great community is growing up :)
Last edited by MirrorOnTheWall on Mon Dec 04, 2006 11:00 pm, edited 1 time in total.
MirrorOnTheWall
New member
 
Posts: 1
Joined: Mon Dec 04, 2006 9:13 pm
Top

Postby markdarb » Wed Dec 13, 2006 11:24 pm

What exactly does deleting the cache do? Does it reset some sort of configuration, or delete the history of all messages, or something else? For that matter, does phpfreechat keep a history of all chats, or just a history of the specified length?

I ask because one of the rooms on my chat freezes from time to time, and I can't figure out how to unfreeze it, but sometimes manage to accidentally. If clearing the cache will quickly solve the problem whenever this happens then that would be very useful, but if it deletes any archives then I wouldn't be so keen.
markdarb
New member
 
Posts: 3
Joined: Fri Dec 08, 2006 2:50 am
Top

Postby mikez » Thu Dec 14, 2006 9:43 pm

This function deletes EVERYTHING within the private and public directories. This means that all chat data and logs will be deleted.

It's a great utility when working on your chat and you need to 'wipe the slate' every now and then. Even for production sites, you can always back up your important data and run this function if you ever need to clear out your metadata.
mikez
Member
 
Posts: 29
Joined: Wed Dec 13, 2006 1:24 am
Top


Post a reply
4 posts • Page 1 of 1

Return to Contributions (v1.x)

Who is online

Users browsing this forum: No registered users and 8 guests

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