Jump to content

[SOLVED] Problem with a constant?


Cory94bailly

Recommended Posts

Error:

TotalLogFolder:/home/cory/logs/MASSattack/2009/February

Log_Write:

LogFolder:MASSattack

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/cory/htdocs/massattack/includes/log.php:18) in /home/cory/htdocs/massattack/includes/log.php on line 25

 

Warning: chmod() [function.chmod]: No such file or directory in /home/cory/htdocs/massattack/includes/log.php on line 29

Cant open log file!

 

 

Code:

<?php
if (!defined('admin')) {
    die("Hacking Attempt.");
}
if(!is_dir("/home/cory/logs/".LogFolder."/".date("Y"))) {
mkdir("/home/cory/logs/".LogFolder."/".date("Y"), 0777);
}
if(!is_dir("/home/cory/logs/".LogFolder."/".date("Y")."/".date("F"))) {
mkdir("/home/cory/logs/".LogFolder."/".date("Y")."/".date("F"), 0777);
}
define("TotalLogFolder","/home/cory/logs/".LogFolder."/".date("Y")."/".date("F"));
if (file_exists(TotalLogFolder."/".date("j").".txt")) {
    define("Log_Write",fopen($file, "a")); //If the file exists, writing will just use the same file.
} else {
    define("Log_Write",fopen($file, "x")); //If the file does not exist, create the file and add the line.
}

echo "TotalLogFolder:" . TotalLogFolder;
echo "<br />";
echo "Log_Write:" . Log_Write;
echo "<br />";
echo "LogFolder:" . LogFolder;
echo "<br />";

session_start();
//Everything connected, GOOD!
//Now time to log everything they do >:]
$file = TotalLogFolder."/".date("j").".txt"; //The file you are targeting..
$open = 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..
?>

 

That is the WHOLE script so please don't say "What is line ...?"

 

 

It is saying those lines at the top because I was echoing to check and it seems that "Log_Write" is not working.

 

I think that "Log_Write" is the only problem..

 

Any fixes possibly?

 

(Also: Ignore the header errors, I know it's because I echoed)

Link to comment
https://forums.phpfreaks.com/topic/145603-solved-problem-with-a-constant/
Share on other sites

So could I do this?

if (file_exists(TotalLogFolder."/".date("j").".txt")) {
    $Log_Write = fopen($file, "a"); //If the file exists, writing will just use the same file.
} else {
    $Log_Write = fopen($file, "x"); //If the file does not exist, create the file and add the line.
}

 

I did that, echoed it and still get a blank.

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.