[PHP] re: files

2001-05-23 Thread Jon Yaggie

Okay thanks perhaps i am using an old manual.  I think i downloaded it about three 
months ago but this function is not present there . .. 


Jon



[PHP] Re: files

2001-09-08 Thread Richard Lynch

There's a Un*x utility for automagically doing this, but it leaves the new
file blank, almost for sure...
man logrotate

Can we safely assume no *other* PHP script is going to be trying to write to
this chat file while you're messing with it?  If not, you really need to
move to a database solution...

I guess you could try to http://php.net/flock your file everywhere before
you open it for writing, but that sure won't scale up well!

Depending on whether or not you can get all the lines you want to keep in
RAM or not, you could either:
- not so large, last 1/4th fits in RAM 
$filename = "./chat/chat.txt";
$file = fopen($filename, 'r') or die("Could not open $filename.");
$text = fseek($file, filesize($filename)*0.75);
$partial_line = fgets($file, 1000);
$recent = fread($file, filesize($filename));
fclose($file);
$file = fopen($filename, 'w') or die("Could not open $filename");
fwrite($file, $recent);
fclose($file);


If the file might be too big for this, you'll need to read a piece at a time
and write it out to some other file, and then use http://php.net/copy

--
WARNING [EMAIL PROTECTED] address is an endangered species -- Use
[EMAIL PROTECTED]
Wanna help me out?  Like Music?  Buy a CD: http://l-i-e.com/artists.htm
Volunteer a little time: http://chatmusic.com/volunteer.htm
- Original Message -
From: Gerard Samuel <[EMAIL PROTECTED]>
Newsgroups: php.general
To: PHP <[EMAIL PROTECTED]>
Sent: Saturday, September 08, 2001 12:11 AM
Subject: files


> hey, I have a large file and I want to keep the last x row of it.  I
> figured out how to navigate to the point where I want to extract the
> data, but I cant figure out how to extact from the file current $fp and
> write out the data to another file.
> Think of it like this, when the file gets to be x bytes, get the last 20
> lines from it and copy it to another file, so that I could dump the old
> and replace it witht the new
> Thanks.
>
>
> <--snip of example code-->
> $fp = fopen("./chat/chat.txt", "r+");
> $size = filesize("chat/chat.txt");
> $count = 0;
> while (!@feof($fp)) {
>  $lines = fgets($fp, 4096);
>  $count = $count + 1;
> }
> $count--; // return the correct # of lines in file
> echo "Lines: $count";
> $offset = round($count - ($count / 4));
> echo "Offset: $offset";
>
> $count = 0;
> rewind($fp);
> while ($count < $offset) {
>  $lines = fgets($fp, 4096);
>  $count = $count + 1;
> }
> echo "New Offset: $count";
> $file = fread($fp);
> if (!copy($file, $file.'.bak')) {
>  print ("failed to copy $file...\n");
> }
>
> fclose($fp);
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] re: files

2001-05-23 Thread Christian Reiniger

On Wednesday 23 May 2001 17:03, Jon Yaggie wrote:
> Okay thanks perhaps i am using an old manual.  I think i downloaded it
> about three months ago but this function is not present there . ..

Bad excuse. That function has been in there since at least the early PHP3 
versions.

-- 
Christian Reiniger
LGDC Webmaster (http://sunsite.dk/lgdc/)

/* you are not expected to understand this */

- from the UNIX V6 kernel source

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] RE: Files only available via HTTPS

2001-02-02 Thread Ayan R. Kayal

Add this to httpd.conf:


SSLRequireSSL   


O- ~ARK
CFO, Hmedicine.com, Inc.

> -Original Message-
> From: Michael Conley [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, February 01, 2001 7:29 PM
> 
> I have several PHP files that I only want users to be able to access via
> HTTPS.  How can I control that on an Apache 1.3.14 server running 
> on RedHat
> 7?  I have openssl and mod_ssl working fine.  Currently, I can 
> access all of
> the files on my site via either http or https.  I want to keep 
> certain files
> (with interesting information) from being accessed via http.  I 
> realize this
> isn't really a PHP question, but I have no idea how to do this.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]