Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit c759411

Browse files
Code cleanup.
1 parent 33426fa commit c759411

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

‎src/PDO.Log.class.php

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
11
<?php
2-
class Log
2+
class PDOLog
33
{
4-
private $path = '/logs/';
5-
public function __construct()
6-
{
7-
$this->path = dirname(__FILE__) . $this->path;
8-
}
9-
10-
public function write($message, $fileSalt)
11-
{
12-
$date = new DateTime();
13-
$log = $this->path . $date->format('Y-m-d') . "-" . md5($date->format('Y-m-d') . $fileSalt) . ".txt";
14-
if (is_dir($this->path)) {
15-
if (!file_exists($log)) {
16-
$fh = fopen($log, 'a+') or die("Fatal Error !");
17-
$logcontent = "Time : " . $date->format('H:i:s') . "\r\n" . $message . "\r\n";
18-
fwrite($fh, $logcontent);
19-
fclose($fh);
20-
} else {
21-
$this->edit($log, $date, $message);
22-
}
23-
} else {
24-
if (mkdir($this->path, 0777) === true) {
25-
$this->write($message, $fileSalt);
26-
}
27-
}
28-
}
29-
private function edit($log, $date, $message)
30-
{
31-
$logcontent = "Time : " . $date->format('H:i:s') . "\r\n" . $message . "\r\n\r\n";
32-
$logcontent = $logcontent . file_get_contents($log);
33-
file_put_contents($log, $logcontent);
34-
}
4+
private $path = '/logs/';
5+
public function __construct()
6+
{
7+
$this->path = __DIR__ . $this->path;
8+
}
9+
10+
public function write($message, $fileSalt)
11+
{
12+
$date = new DateTime();
13+
$log = $this->path . $date->format('Y-m-d') . "-" . md5($date->format('Y-m-d') . $fileSalt) . ".txt";
14+
if (is_dir($this->path)) {
15+
if (!file_exists($log)) {
16+
$fh = fopen($log, 'a+') or die("Fatal Error !");
17+
$logcontent = "Time : " . $date->format('H:i:s') . "\r\n" . $message . "\r\n";
18+
fwrite($fh, $logcontent);
19+
fclose($fh);
20+
} else {
21+
$this->edit($log, $date, $message);
22+
}
23+
} else {
24+
if (mkdir($this->path, 0777) === true) {
25+
$this->write($message, $fileSalt);
26+
}
27+
}
28+
}
29+
private function edit($log,DateTime $date, $message)
30+
{
31+
$logcontent = "Time : " . $date->format('H:i:s') . "\r\n" . $message . "\r\n\r\n";
32+
$logcontent = $logcontent . file_get_contents($log);
33+
file_put_contents($log, $logcontent);
34+
}
3535
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /