Jump to content

Fopen/Fwrite not working as it should? (Maybe a permissions problem..?)


Cory94bailly

Recommended Posts

Code:

<?php
if (!defined('index')) {
    die("Hacking Attempt.");
}
if(!is_dir("/home/cory/logs/".LogFolder."/".date("Y"))) { //Check if the folder of the year exists
mkdir("/home/cory/logs/".LogFolder."/".date("Y"), 0777); //If not, create it.
}
if(!is_dir("/home/cory/logs/".LogFolder."/".date("Y")."/".date("F"))) { //Check if the folder of the month exists.
mkdir("/home/cory/logs/".LogFolder."/".date("Y")."/".date("F"), 0777); //If not, create it.
}
define("TotalLogFolder","/home/cory/logs/".LogFolder."/".date("Y")."/".date("F"));
if (file_exists(TotalLogFolder."/".date("j").".txt")) { //Check if the day's log exists.
    $Log_Write = "a"; //If the file exists, writing will just use the same file.
} else {
    $Log_Write = "x"; //If the file does not exist, create the file and add the line.
}
session_start();
//Everything connected, GOOD!
//Now time to log everything they do >:]
$file = TotalLogFolder."/".date("j").".txt"; //The file you are targeting..
$open = fopen($file, $Log_Write) or chmod($file, 0777); //Opening the file.
$info = "$date | $time | $page | $ip | $hostname \n"; //What to write.
if(!$open){
die('Cant open log file!');
}
$t = fwrite($open, $info); //Write to file..
fclose($open); //Close file..

$file = "/home/cory/logs/MASSattack.txt"; //The file you are targeting..
$open = fopen($file, "a") or chmod($file, 0777); //Opening the file.
$info = "$date | $time | $page | $ip | $hostname \n"; //What to write.
if(!$open){
die('Cant open log file!');
}
$t = fwrite($open, $info); //Write to file..
fclose($open); //Close file..
?>

 

That all work(s)/(ed) for about 3 days...

 

I have 5 files in the February folder ("17.txt", "18.txt", "19.txt", "20.txt", "21.txt")

 

I can open 17, 18, and 19 but if I try to open 20 or 21, i get: "550 Failed to open file. : /logs/MASSattack/2009/February/21.txt"

 

The thing(s) that is (are) weird is that for 17,18,and 19 the permissions are set to '644' and 20/21 are set to '600'.. I didn't change any permissions in that folder.

The folder permissions are all at '777' so that's not it..

 

If I try to change permissions on 20 and 21, I get this: "550 SITE CHMOD command failed. : /logs/MASSattack/2009/February/0777 20.txt"

 

What could be the problem?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.