From: Joey Schulze
Date: Mon, 23 Jun 2008 17:13:23 +0000 (+0000)
Subject: Import of the current version of www.zeitungsliste.de
X-Git-Url: https://git.infodrom.org/?p=infodrom.org%2Fwww.zeitungsliste.de;a=commitdiff_plain;h=7a22e791954eeaed5a80b5be71c77c91b6c593cd
Import of the current version of zeitungsliste.de
---
7a22e791954eeaed5a80b5be71c77c91b6c593cd
diff --git a/bin/zeitungen-checkrobots b/bin/zeitungen-checkrobots
new file mode 100755
index 0000000..6191748
--- /dev/null
+++ b/bin/zeitungen-checkrobots
@@ -0,0 +1,49 @@
+#! /usr/bin/php
+open_log_file($log)) {
+ while ($line = $logparser->get_line()) {
+
+ if (strpos($line, "GET /robots.txt HTTP/") !== false) {
+ $parts = $logparser->format_line($line);
+
+ $_SERVER['HTTP_USER_AGENT'] = $parts['agent'];
+
+ if (!is_spider())
+ $notfound[] = $parts['agent'];
+ }
+ }
+ $logparser->close_log_file();
+} else {
+ echo "Cannot open $log\n";
+ exit(1);
+}
+
+if (count($notfound)) {
+ $header[] = 'From: Zeitungsliste ';
+ $header[] = 'To: Joey Schulze ';
+ $header[] = 'MIME-Version: 1.0';
+ $header[] = 'Content-type: text/plain; charset=utf-8';
+ $header[] = 'Content-Disposition: inline';
+ $header[] = 'Content-Transfer-Encoding: 8bit';
+
+ $to = 'joey@infodrom.org';
+ $subject = 'Spider nicht erkannt';
+ $body = "Die folgenden Spider wurden nicht anhand ihres UserAgent-Kennung\n".
+ "erkannt:\n\n";
+
+ foreach ($notfound as $agent)
+ $body .= " " . $agent . "\n";
+
+ mail ($to, $subject, $body, implode("\n", $header));
+}
+
+?>
\ No newline at end of file
diff --git a/bin/zeitungen-rdf b/bin/zeitungen-rdf
new file mode 100755
index 0000000..ceb080d
--- /dev/null
+++ b/bin/zeitungen-rdf
@@ -0,0 +1,84 @@
+#! /usr/bin/perl
+
+# zeitungen-rdf - Build RDF file for www.zeitungsliste.de
+# Copyright (c) 2008 Joey Schulze
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+
+use strict;
+use warnings;
+
+use DBI;
+use XML::RSS;
+use Algorithm::Diff;
+
+my %cfg = ('home' => 'http://www.zeitungsliste.de/',
+ 'webdir' => '/var/www/www.zeitungsliste.de');
+
+my $dsn = 'dbi:Pg:dbname=zlist';
+
+my $dbh = DBI->connect('dbi:Pg:dbname=zlist') or die "Can't connect to database\n";
+
+sub fetchnew
+{
+ my $query = q{SELECT id,name,description FROM zeitungen
+ WHERE deleted IS false AND changed > now() - interval'3 months'
+ ORDER BY changed DESC};
+
+ my $sth = $dbh->prepare ($query) or die "Can't prepare Query: $DBI::errstr\n";
+ my $rv = $sth->execute or die "Can't execute query: $DBI::errstr\n";
+
+ my @ret = ();
+ push @ret, [$_->{id},$_->{name},$_->{description}] while ($_ = $sth->fetchrow_hashref);
+
+ return \@ret;
+}
+
+sub rdf_new
+{
+ my $fname = shift;
+ my $papers = fetchnew();
+
+ my $rss = new XML::RSS (version => '1.0', encoding => 'utf-8');
+ $rss->channel (
+ title => 'Zeitungsliste',
+ description => 'Zeitungen im Netz',
+ link => $cfg{'home'},
+ );
+
+ foreach my $paper (@$papers) {
+ # printf "%d: %s\n%s\n", $paper->[0], $paper->[1], $paper->[2];
+
+ $rss->add_item (
+ title => $paper->[1],
+ description => $paper->[2],
+ link => sprintf('%szeitung/%d.html', $cfg{'home'}, $paper->[0]),
+ );
+ }
+
+ if (-e $fname) {
+ my @new = split (/\n/, $rss->as_string);
+ open (F, $fname);
+ chomp(my @old = );
+ close (F);
+
+ my @diff = Algorithm::Diff::diff (\@old, \@new);
+ $rss->save ($fname) if (@diff);
+ } else {
+ $rss->save ($fname);
+ }
+}
+
+rdf_new($cfg{webdir} . '/zeitungen.rdf');
diff --git a/bin/zeitungen-tidy b/bin/zeitungen-tidy
new file mode 100755
index 0000000..51f98f3
--- /dev/null
+++ b/bin/zeitungen-tidy
@@ -0,0 +1,82 @@
+#! /usr/bin/perl
+
+# zeitungen-tidy - Daily Tidy run for www.zeitungsliste.de
+# Copyright (c) 2008 Joey Schulze
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
+
+use strict;
+use warnings;
+
+use DBI;
+
+my $dsn = 'dbi:Pg:dbname=zlist';
+
+my $dbh = DBI->connect('dbi:Pg:dbname=zlist') or die "Can't connect to database\n";
+
+sub tidy_online
+{
+ my $query = q{SELECT uid FROM online WHERE activity < now() - interval'12 hours'};
+
+ my $sth = $dbh->prepare ($query) or die "Can't prepare Query: $DBI::errstr\n";
+ my $rv = $sth->execute or die "Can't execute query: $DBI::errstr\n";
+
+ my @uids = ();
+ push @uids, $_->{uid} while ($_ = $sth->fetchrow_hashref);
+
+ if ($#uids > -1) {
+ $query = sprintf('DELETE FROM online WHERE uid in (%s)',
+ join(',', @uids));
+ $dbh->do($query);
+ }
+}
+
+sub archive_topics
+{
+ my $query = q{SELECT id FROM topics WHERE archived IS false AND modified < now() - interval'2 weeks'};
+
+ my $sth = $dbh->prepare ($query) or die "Can't prepare Query: $DBI::errstr\n";
+ my $rv = $sth->execute or die "Can't execute query: $DBI::errstr\n";
+
+ my @ids = ();
+ push @ids, $_->{id} while ($_ = $sth->fetchrow_hashref);
+
+ if ($#ids > -1) {
+ $query = sprintf('UPDATE topics SET archived=true WHERE id in (%s)',
+ join(',', @ids));
+ $dbh->do($query);
+ }
+}
+
+sub tidy_tags
+{
+ my $query = q{SELECT id FROM tags WHERE id NOT IN (SELECT DISTINCT tag FROM zeitung_tags)};
+
+ my $sth = $dbh->prepare ($query) or die "Can't prepare Query: $DBI::errstr\n";
+ my $rv = $sth->execute or die "Can't execute query: $DBI::errstr\n";
+
+ my @ids = ();
+ push @ids, $_->{id} while ($_ = $sth->fetchrow_hashref);
+
+ if ($#ids > -1) {
+ $query = sprintf('DELETE FROM SET tags WHERE id in (%s)',
+ join(',', @ids));
+ $dbh->do($query);
+ }
+}
+
+tidy_online;
+archive_topics;
+# tidy_tags;
diff --git a/lib/ajax.inc b/lib/ajax.inc
new file mode 100644
index 0000000..2c0e495
--- /dev/null
+++ b/lib/ajax.inc
@@ -0,0 +1,65 @@
+ array('lib' => 'search.inc',
+ 'func' => 'ajax_search_check'),
+ 'passwd_check' => array('lib' => 'login.inc',
+ 'func' => 'ajax_passwd_check'),
+ 'nickname_check' => array('lib' => 'login.inc',
+ 'func' => 'ajax_nickname_check'),
+ 'tag_add' => array('lib' => 'tags.inc',
+ 'func' => 'ajax_tag_add'),
+ 'tag_del' => array('lib' => 'tags.inc',
+ 'func' => 'ajax_tag_del'),
+ 'tag_new' => array('lib' => 'tags.inc',
+ 'func' => 'ajax_tag_new'),
+ 'tag_exists' => array('lib' => 'tags.inc',
+ 'func' => 'ajax_tag_exists'),
+ 'bookmark_up' => array('lib' => 'bookmarks.inc',
+ 'func' => 'ajax_bookmark_up'),
+ 'bookmark_down' => array('lib' => 'bookmarks.inc',
+ 'func' => 'ajax_bookmark_down'),
+ 'bookmark_del' => array('lib' => 'bookmarks.inc',
+ 'func' => 'ajax_bookmark_del'),
+ 'bookmark_add' => array('lib' => 'bookmarks.inc',
+ 'func' => 'ajax_bookmark_add'),
+ 'zeitung_check_url' => array('lib' => 'zeitung.inc',
+ 'func' => 'ajax_zeitung_check_url'),
+ );
+
+function dumpinfo()
+{
+ global $_SERVER;
+ global $_POST;
+ global $_GET;
+
+ $info = "\$_SERVER = " . var_export($_SERVER, true);
+ $info .= "\n\$_POST = " . var_export($_POST, true);
+ $info .= "\n\$_GET = " . var_export($_GET, true);
+
+ $f = fopen("/tmp/zlist.dump", "w");
+ fwrite($f, $info);
+ fclose($f);
+}
+
+function ajax_process()
+{
+ global $functions;
+ global $_POST;
+
+ dumpinfo();
+
+ if (strlen($_POST['function']) && array_key_exists($_POST['function'], $functions)) {
+ if (array_key_exists('lib', $functions[$_POST['function']]))
+ include_once($functions[$_POST['function']]['lib']);
+ if (array_key_exists('func', $functions[$_POST['function']])) {
+ if (function_exists($functions[$_POST['function']]['func']))
+ return $functions[$_POST['function']]['func']();
+ else
+ return false;
+ }
+ }
+
+ return false;
+}
+
+?>
\ No newline at end of file
diff --git a/lib/board.inc b/lib/board.inc
new file mode 100644
index 0000000..61b70fb
--- /dev/null
+++ b/lib/board.inc
@@ -0,0 +1,149 @@
+ $zid);
+ if (!isset($_POST['zeitung'])) {
+ $ret .= information('Sie beginnen eine neue Diskussion im Forum.');
+ } else {
+ $replace['topic'] = htmlspecialchars($_POST['topic']);
+ $replace['body'] = string_sanitise($_POST['body']);
+
+ if (strlen($_POST['topic'])) {
+ if (strlen($_POST['body'])) {
+ if (($tid = topic_add($zid, $replace['topic'], $replace['body'])) !== false) {
+ header(sprintf('Location: %stopic/%d.html', $cfg['home'], $tid));
+ } else
+ $ret .= warning('Es ist ein Datenbankfehler aufgetreten.');
+ } else
+ $ret .= warning('Sie haben keinen Text für die Diskussion angegeben!');
+ } else
+ $ret .= warning('Sie haben keinen Titel für die Diskussion angegeben!');
+ }
+
+ $ret .= load_javascript('topic.js') . load_template('topic.html', $replace);
+ }
+ }
+
+ return $ret;
+}
+
+// Sideeffect: May set $zlist['redirect']
+function process_reply()
+{
+ global $cfg;
+ global $zlist;
+ global $_GET;
+ global $_POST;
+
+ if (isset($_GET['topic']) && is_numeric($_GET['topic']))
+ $topic = $_GET['topic'];
+ elseif (isset($_POST['topic']) && is_numeric($_POST['topic']))
+ $topic = $_POST['topic'];
+ else
+ $ret = warning('Keine passende Diskussion gefunden!');
+
+ if (isset($topic)) {
+ $discussion = format_topic($topic);
+ if (isset($zlist['zid'])) {
+ $ret .= format_newspaper($zlist['zid'], true);
+
+ if (isset($_POST['body'])) {
+ if (article_add($topic, string_sanitise($_POST['body'])) === true) {
+ $ret .= information('Danke für Ihren Beitrag. Sie werden automatisch zur Diskussion weitergeleitet.');
+ header(sprintf('Location: %stopic/%d.html', $cfg['home'], $topic));
+ } else {
+ $ret .= warning('Ihr Beitrag konnte nicht aufgenommen werden.');
+ $ret .= $discussion;
+ $replace = array('topic' => $topic,
+ 'title' => $zlist['topic'],
+ 'body' => htmlspecialchars($_POST['body']));
+ $ret .= load_javascript('reply.js') . load_template('reply.html', $replace);
+ }
+ } else {
+ $ret .= $discussion;
+ $replace = array('topic' => $topic,
+ 'title' => $zlist['topic']);
+ $ret .= load_javascript('reply.js') . load_template('reply.html', $replace);
+ }
+ } else
+ $ret .= $discussion;
+ }
+
+ return $ret;
+}
+
+?>
\ No newline at end of file
diff --git a/lib/bookmarks.inc b/lib/bookmarks.inc
new file mode 100644
index 0000000..842db68
--- /dev/null
+++ b/lib/bookmarks.inc
@@ -0,0 +1,215 @@
+
+
+
+%d
+
+
+ |
+
+%s |
+';
+
+ $ret .= '';
+ for ($n=0; $n < pg_NumRows ($sth); $n++) {
+ $row = pg_fetch_array ($sth, $n);
+
+ if (javascript_ok()) {
+ $link_up = sprintf('href="bookmark.html" onclick="return bookmark_action(\'up\',%d);"', $row['zeitung']);
+ $link_down = sprintf('href="bookmark.html" onclick="return bookmark_action(\'down\',%d);"', $row['zeitung']);
+ $link_del = sprintf('href="bookmark.html" onclick="return bookmark_action(\'del\',%d);"', $row['zeitung']);
+ } else {
+ $link_up = sprintf('href="bookmark.html?zeitung=%d&action=up"', $row['zeitung']);
+ $link_down = sprintf('href="bookmark.html?zeitung=%d&action=down"', $row['zeitung']);
+ $link_del = sprintf('href="bookmark.html?zeitung=%d&action=delete"', $row['zeitung']);
+ }
+
+ $ret .= sprintf($rowf,
+ $link_up, $row['priority'], $link_down, $link_del,
+ $row['zeitung'], $row['name']);
+ }
+ $ret .= '
';
+
+
+ return $ret;
+}
+
+function bookmarks_manage()
+{
+ global $_SESSION;
+
+ if (!isset($_SESSION['uid']))
+ return notfound();
+
+ $ret = 'Verwaltung der persönlichen Lesezeichen
';
+
+ $ret .= '';
+ $ret .= load_javascript('bookmarks.js');
+ $ret .= format_bookmarks();
+ $ret .= '
';
+
+ return $ret;
+}
+
+function process_bookmark()
+{
+ global $_SESSION;
+ global $_SERVER;
+ global $_GET;
+ global $zlist;
+ global $cfg;
+
+ if (!isset($_SESSION['uid']))
+ return notfound();
+
+ if (empty($_SERVER['QUERY_STRING'])) {
+ return bookmarks_manage();
+ } elseif (!isset($_GET['zeitung']) || !is_numeric($_GET['zeitung'])) {
+ if (isset($_SERVER['HTTP_REFERER']))
+ $zlist['redirect'] = substr($_SERVER['HTTP_REFERER'], strlen($zlist['home']));
+ return warning('Keine Zeitung oder Magazin gefunden.');
+ } elseif (isset($_GET['action'])) {
+ if ($_GET['action'] == 'up')
+ bookmark_up($_GET['zeitung'], $_SESSION['uid']);
+ elseif ($_GET['action'] == 'down')
+ bookmark_down($_GET['zeitung'], $_SESSION['uid']);
+ elseif ($_GET['action'] == 'delete')
+ bookmark_delete($_GET['zeitung'], $_SESSION['uid']);
+ else
+ return notfound();
+ header('Location: ' . $cfg['home'] . 'bookmark.html');
+ exit;
+ } else {
+ bookmark_add($_GET['zeitung'], $_SESSION['uid']);
+ if (isset($_SERVER['HTTP_REFERER'])) {
+ header('Location: ' . $_SERVER['HTTP_REFERER']);
+ exit;
+ } else
+ return information('Ihr Lesezeichen wurde hinzugefügt');
+ }
+}
+
+function ajax_bookmark_check()
+{
+ global $_POST;
+ global $_SESSION;
+
+ if (!isset($_POST['zeitung']) || !is_numeric($_POST['zeitung']) ||
+ !isset($_SESSION['uid']))
+ return false;
+
+ return true;
+}
+
+function ajax_bookmark_up()
+{
+ global $_POST;
+ global $_SESSION;
+
+ if (!ajax_bookmark_check())
+ return false;
+
+ bookmark_up($_POST['zeitung'], $_SESSION['uid']);
+
+ return format_bookmarks();
+}
+
+function ajax_bookmark_down()
+{
+ global $_POST;
+ global $_SESSION;
+
+ if (!ajax_bookmark_check())
+ return false;
+
+ bookmark_down($_POST['zeitung'], $_SESSION['uid']);
+
+ return format_bookmarks();
+}
+
+function ajax_bookmark_del()
+{
+ global $_POST;
+ global $_SESSION;
+
+ if (!ajax_bookmark_check())
+ return false;
+
+ bookmark_delete($_POST['zeitung'], $_SESSION['uid']);
+
+ return format_bookmarks();
+}
+
+function ajax_bookmark_add()
+{
+ global $_POST;
+ global $_SESSION;
+
+ if (!ajax_bookmark_check())
+ return false;
+
+ bookmark_add($_POST['zeitung'], $_SESSION['uid']);
+
+ return format_info_bookmarks();
+}
+
+
+?>
\ No newline at end of file
diff --git a/lib/core.inc b/lib/core.inc
new file mode 100644
index 0000000..0b157b9
--- /dev/null
+++ b/lib/core.inc
@@ -0,0 +1,186 @@
+
, , ,
,
+function string_sanitise($text)
+{
+ $ntext = preg_replace (array('/"\']*)["\']?>([^<]*)<\/a>/i'),
+ array('[[$1][$2]]'),
+ $text);
+
+ $ntext = htmlspecialchars($ntext, ENT_QUOTES);
+
+ $ntext = preg_replace(array('/<(\/?(p|br|b|em))>/i',
+ '/\[\[([^\]]+)\]\[([^\]]+)\]\]/'),
+ array('<$1>','$2'),
+ $ntext);
+
+ return $ntext;
+}
+
+function basepath()
+{
+ global $cfg;
+ global $_SERVER;
+
+ $pos = strpos(strtolower($cfg['home']), strtolower($_SERVER['SERVER_NAME']));
+ $base = substr($cfg['home'], $pos+strlen($_SERVER['SERVER_NAME']));
+
+ $pos = strpos($_SERVER['REQUEST_URI'], "?");
+ if ($pos === false)
+ $uri = $_SERVER['REQUEST_URI'];
+ else
+ $uri = substr($_SERVER['REQUEST_URI'], 0, $pos);
+
+ if (strpos($uri, $base) === 0) {
+ $cfg['path'] = substr($uri, strlen($base));
+ $pos = strrpos($cfg['path'], '/');
+ if ($pos !== false) {
+ $cfg['dir'] = substr($cfg['path'], 0, $pos);
+ }
+ return str_repeat("../", substr_count($cfg['path'], "/"));
+ }
+}
+
+function logged_in()
+{
+ global $_SESSION;
+
+ return isset($_SESSION['uid']);
+}
+
+function javascript_ok()
+{
+ global $_SESSION;
+
+ if (!logged_in())
+ return true;
+
+ if ($_SESSION['javascript'] == true)
+ return true;
+
+ return false;
+}
+
+function is_spider()
+{
+ global $_SERVER;
+ global $_SESSION;
+
+ if (isset($_SESSION['uid']))
+ if (isset($_SESSION['robot']))
+ return $_SESSION['robot'];
+
+ if (strpos($_SERVER['HTTP_USER_AGENT'], 'Yahoo! Slurp') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'Googlebot') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'Mediapartners-Google') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'VoilaBot') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'Gigabot/3.0') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'Speedy Spider') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'LinkWalker/2.0') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'proximic') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'Yeti/1.0') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'Eurobot/1.0') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'MnoGoSearch/') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'ia_archiver') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'Seekbot/1.0') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'MyEngines-Bot') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'larbin_') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'findlinks/1') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'holmes/3.12') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'NoteworthyBot/0.1') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'Eurosoft-Bot') !== false ||
+ strpos($_SERVER['HTTP_USER_AGENT'], 'msnbot') !== false) {
+ strpos($_SERVER['HTTP_USER_AGENT'], 'Cityreview Robot') !== false) {
+ if (isset($_SESSION['uid']))
+ $_SESSION['robot'] = true;
+ return true;
+ }
+
+ if (isset($_SESSION['uid']))
+ $_SESSION['robot'] = false;
+ return false;
+}
+
+function format_info_bookmarks()
+{
+ global $_SESSION;
+ global $cfg;
+
+ if (!isset($_SESSION['uid']))
+ return false;
+
+ $query = sprintf("SELECT zeitung,name FROM bookmarks " .
+ "JOIN zeitungen ON zeitungen.id = zeitung " .
+ "WHERE uid = %d " .
+ "ORDER BY priority,name LIMIT 20",
+ $_SESSION['uid']);
+
+ $sth = db_query($query);
+
+ if ($sth === false || pg_NumRows ($sth) == 0)
+ return false;
+
+ $ret = '';
+ for ($n=0; $n < pg_NumRows ($sth); $n++) {
+ $row = pg_fetch_array ($sth, $n);
+ $ret .= sprintf('- %s
',
+ $cfg['basepath'], $row['zeitung'], $row['name']);
+ }
+ $ret .= '
';
+
+ return $ret;
+}
+
+?>
\ No newline at end of file
diff --git a/lib/extern/apache-log-parser.php b/lib/extern/apache-log-parser.php
new file mode 100644
index 0000000..a4d6883
--- /dev/null
+++ b/lib/extern/apache-log-parser.php
@@ -0,0 +1,102 @@
+format_log_line($line); // format the line
+
+ if (isset($logs[0])) // check that it formated OK
+ {
+ $formated_log = array(); // make an array to store the lin info in
+ $formated_log['ip'] = $logs[1];
+ $formated_log['identity'] = $logs[2];
+ $formated_log['user'] = $logs[2];
+ $formated_log['date'] = $logs[4];
+ $formated_log['time'] = $logs[5];
+ $formated_log['timezone'] = $logs[6];
+ $formated_log['method'] = $logs[7];
+ $formated_log['path'] = $logs[8];
+ $formated_log['protocal'] = $logs[9];
+ $formated_log['status'] = $logs[10];
+ $formated_log['bytes'] = $logs[11];
+ $formated_log['referer'] = $logs[12];
+ $formated_log['agent'] = $logs[13];
+ return $formated_log; // return the array of info
+ }
+ else
+ {
+ $this->badRows++; // if the row is not in the right format add it to the bad rows
+ return false;
+ }
+ }
+
+ function open_log_file($file_name)
+ {
+ $this->fp = fopen($file_name, 'r'); // open the file
+ if (!$this->fp)
+ {
+ return false; // return false on fail
+ }
+ return true; // return true on sucsess
+ }
+
+ function close_log_file()
+ {
+ return fclose($this->fp); // close the file
+ }
+
+ // gets a line from the log file
+ function get_line()
+ {
+ if (feof($this->fp))
+ {
+ return false;
+ }
+ $line = fgets ($this->fp, 1024);
+ return $line;
+ }
+
+}
+?>
diff --git a/lib/extern/rfc822.php b/lib/extern/rfc822.php
new file mode 100644
index 0000000..7e6b702
--- /dev/null
+++ b/lib/extern/rfc822.php
@@ -0,0 +1,36 @@
+ #
+# This code is licensed under a Creative Commons Attribution-ShareAlike 2.5 License #
+# http://creativecommons.org/licenses/by-sa/2.5/ #
+# #
+# Revision 2 #
+# #
+######################################################################################
+
+
+function is_valid_email_address($email){
+ $qtext = '[^\\x0d\\x22\\x5c\\x80-\\xff]';
+ $dtext = '[^\\x0d\\x5b-\\x5d\\x80-\\xff]';
+ $char = '[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'.
+ '\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]';
+ $atom = "$char+";
+
+ $quoted_pair = '\\x5c[\\x00-\\x7f]';
+ $domain_literal = "\\x5b($dtext|$quoted_pair)*\\x5d";
+ $quoted_string = "\\x22($qtext|$quoted_pair)*\\x22";
+ $domain_ref = $atom;
+ $top_domain = "[a-zA-Z]{2,10}";
+ $sub_domain = "($domain_ref|$domain_literal)";
+ $word = "($atom|$quoted_string)";
+ $domain = "$sub_domain(\\x2e$sub_domain)*\\x2e$top_domain";
+ $local_part = "$word(\\x2e$word)*";
+ $addr_spec = "$local_part\\x40$domain";
+ return preg_match("!^$addr_spec$!", $email) ? 1 : 0;
+ }
+
+?>
diff --git a/lib/footer.inc b/lib/footer.inc
new file mode 100644
index 0000000..cb1f74f
--- /dev/null
+++ b/lib/footer.inc
@@ -0,0 +1,8 @@
+
+
+
+