diff options
author | Christoph Brill <egore911@egore911.de> | 2012-01-26 22:33:23 +0100 |
---|---|---|
committer | Christoph Brill <egore911@egore911.de> | 2012-03-26 00:13:35 +0200 |
commit | 0dc4e33cd335bbe26a28a8f11fc31e39ae78e194 (patch) | |
tree | 06a4b4bee96b19aa4a38a856878b15064c92ac1e /index.php | |
parent | c71b8cbf890031e6da5187945c00a2d241ca04f3 (diff) |
Add named a-tags to timestamps
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -215,7 +215,7 @@ if (!isset($date)) { $pattern = '#(^|[^\"=]{1})(http://|ftp://|mailto:|news:)([^\s<>]+)([\s\n<>]|$)#sm'; - + $timehashes = array(); $lines = file(LOG_DIR.$filename); foreach ($lines as $line_num => $line) { if (is_from_selected_channel($line, $channel)) { @@ -231,6 +231,12 @@ if (!isset($date)) { $line = preg_replace($pattern, "\\1<a href=\"\\2\\3\">\\2\\3</a>\\4", $line); } $user_link = '<a style="color: inherit;" href="javascript:addUser(\''.$user_clean.'\');">'.str_replace('<', '<', str_replace('>', '>', $user)).'</a>'; + $time = get_time($line); + if (!in_array($time, $timehashes)) { + $time_link = '<a name="t-'.str_replace(':', '', $time).'">'.$time.'</a>'; + $line = str_replace($time, $time_link, $line); + array_push($timehashes, $time); + } echo str_replace($user, $user_link, $line),'<br/>'; if ($isUser !== false) { echo '</span>'; @@ -240,6 +246,14 @@ if (!isset($date)) { } } +function get_time($line) { + $result = array(); + if (preg_match('=^([0-9:]+)=', $line, $result)) { + return $result[0]; + } + return ""; +} + /* $lines = file('index.txt'); error_reporting(E_ALL); |