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

CANT DELETE FILES

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

Post a reply
3 posts • Page 1 of 1

Postby kostassite » Fri Mar 09, 2007 6:28 pm

Hi, i would like to delete the logs file that are in data/private/logs
but I can't neither from ftp nor control panel. how i will delete these files. i dont want to delete everything, only old files

thanks
kostassite
New member
 
Posts: 2
Joined: Tue Mar 06, 2007 8:58 pm
Top

Postby pinup57 » Sat Mar 10, 2007 10:39 am

You can't do that by ftp, because the files were created by a script so it's the server who owns the files (Apache for instance). You must use a script to delete them, or have your host support do it for you.

Example code:

Code: Select all
<?php


// recurses into a directory and empties it
// copy this code in a text file and name it something like pfc_purge.php
//place it at the root of your site (to avoid open_basedir restrictions)and call it with your browser
//be careful, don't proceed if you don't understand this
//use at own risk

function purge($dir)
{
$handle = opendir($dir);
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..")
{
if (is_dir($dir.$file))
{
purge ($dir.$file."/");
rmdir($dir.$file);
}
else
{
unlink($dir.$file);
}
}
}
closedir($handle);
}

?>
<?php

//adjust your paths to reflect your setup
//comment out the directories you don't want to clear
//ATTENTION this code deletes everything in these directories
//backup files you want you keep first

purge("/home/usr/www/chat/data/private/cache/");
purge("/home/usr/www/chat/data/private/chat/");
purge("/home/usr/www/chat/data/private/logs/");
echo "Succesfully cleared the PhpFreeChat cache, chat and logs directories";
?>

There are other possibilities of doing this differently, search the forum for other code examples!

Dirk
Last edited by pinup57 on Sat Mar 10, 2007 10:43 am, edited 1 time in total.
pinup57
Member
 
Posts: 89
Joined: Sat Feb 24, 2007 8:13 am
Top

Postby alien » Wed Mar 14, 2007 10:49 pm

I tried your script, but always get error message about open basedir restrictions. I put purge file in htdocs of my site, it is my root. Where else should I put that file?

Thanks
alien
New member
 
Posts: 1
Joined: Wed Mar 14, 2007 10:43 pm
Top


Post a reply
3 posts • Page 1 of 1

Return to General Support (v1.x)

Who is online

Users browsing this forum: No registered users and 7 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