<?php
//If member access level is commenter, redirect him to personal options
if($member_db[1] == 4 and $action == \"dologin\"){ header(\"Location: $config_http_script_dir/index.php?mod=options&action=personal\"); exit; }
echoheader(\"home\", \"Welcome\");
if(!is_readable(\"./data/archives\")){ die(\"Error !!!<br />Can not open directory ./archives for reading, check if it exists or is properly CHMOD'ed\"); } if(!is_readable(\"./data/news.txt\")){ die(\"Error !!!<br />Can not open file news.txt for reading, check if it exists or is properly CH OD'ed\"); }
if(!is_readable(\"./data/comments.txt\")){ die(\"Error !!!<br />Can not open file comments.txt for reading, check if it exists or is properl
CHMOD'ed\"); }
// Some Stats
$todaynews = 0;
$count_comments = 0;
$count_my_news = 0;
$count_new_news = 0;
$news_db = file(\"./data/news.txt\");
foreach ($news_db as $line)
{
$item_db = explode(\"|\",$line);
$itemdate = date(\"d/m/y\",$item_db[0]);
if($itemdate == date(\"d/m/y\")) {
$todaynews++;
if($item_db[1] == $member_db[2]) $count_my_news++;
if(($item_db[0] > $member_db[9]) and ($member_db[9] != '')) $count_new_news++;
}
}
$stats_news = count( $news_db );
$stats_users = count( file(\"./data/users.db.php\") ) - 1;
$stats_archives = 0;
$handle = opendir(\"./data/archives\");
while (FALSE !== ($file = readdir($handle)))
{
if( preg_match(\"/.news.arch/\",$file) ){$stats_archives++;}
}
closedir($handle);
$stats_news_size = formatsize(filesize(\"./data/news.txt\"));
$stats_comments_size = formatsize(filesize(\"./data/comments.txt\"));
// Count Comments
$all_comments = file(\"./data/comments.txt\");
foreach($all_comments as $news_comments){
$single_news_comments = explode(\"|>|\", $news_comments);
$individual_comments = explode(\"||\", $single_news_comments[1]);
$count_comments += count($individual_comments) - 1;
}
// Define Welcome Message
echo\"<table border=0 cellpading=0 cellspacing=0 width=654>
<td width=650 colspan=5 height=1>
<script LANGUAGE=\"JavaScript\">
<!-- Begin
timenow=datetoday.getTime();
datetoday.setTime(timenow);
thehour = datetoday.getHours();
if (thehour < 9 ) display = \"Morning\";
else if (thehour < 12) display = \"Day\";
else if (thehour < 17) display = \"Afternoon\";
else if (thehour < 20) display = \"Evening\";
else display = \"Night\";
var greeting = (\"Good \" + display);
document.write(greeting);
// End -->
</script>
$member_db[2]\";
if($todaynews != 1){ $s = \"s\"; }
if($member_db[1] != 4){
if($stats_users > 1){
$rand_msg[] = \", we have <b>$count_new_news</b> new articles since your last login\";
$rand_msg[] = \", we have <b>$count_new_news</b> new articles since your last login\";
$rand_msg[] = \", we have <b>$count_new_news</b> new articles since your last login\";
}
if($todaynews == 0){
$rand_msg[] = \", we don't have new articles today\";
$rand_msg[] = \", we don't have new articles today, the first one can be yours.\";
}
elseif($count_my_news == 0){
if($todaynews == 1){
$rand_msg[] = \", today we have <b>$todaynews</b> new article{$s} but it is not yours\";
}else{
$rand_msg[] = \", today we have <b>$todaynews</b> new article{$s} but <b>$count_my_news</b> of them are yours\";
}
}
elseif($count_my_news == $todaynews){
if($count_my_news == 1){
$rand_msg[] = \", today we have <b>$todaynews</b> new article{$s} and you wrote it\";
}else{
$rand_msg[] = \", today we have <b>$todaynews</b> new article{$s} and you wrote all of them\";
$rand_msg[] = \", today we have <b>$todaynews</b> new article{$s} and all are yours\";
$rand_msg[] = \", today we have <b>$todaynews</b> new article{$s}, want to <a href=\"$PHP_SELF?mod=addnews&action=addnews\">add</a> some more?\";
}
}
else{
if($count_my_news == 1){ $rand_msg[] = \", today we have <b>$todaynews</b> new article{$s}, <b>1</b> of them is yours\"; }
else{ $rand_msg[] = \", today we have <b>$todaynews</b> new article{$s}, <b>$count_my_news</b> of them are yours\"; }
}
$rand_msg[] = \", are you in a mood of <a href=\"$PHP_SELF?mod=addnews&action=addnews\">adding</a> some news?\";
$rand_msg[] = \", today we have <b>$todaynews</b> new article{$s}, from total <b>$stats_news</b>\";
if($member_db[9] != \"\"){
$rand_msg[] = \", your last login was on \".date(\"j M Y H:i:s\", $member_db[9]);
$rand_msg[] = \", your last login was on \".date(\"d M Y H:i:s\", $member_db[9]);
}
$rand_msg[] = \"\";
srand((double) microtime() * 1000000);
echo $rand_msg[rand(0, count($rand_msg)-1)].\"<br /><br />\";
}
if($member_db[1] == 1){
echo \"<tr><td valign=middle height=1 bgcolor=#F7F6F4 width=286 colspan=2>
<b>Some stats</b>
<td valign=middle height=1 width=35>
<td valign=middle height=1 bgcolor=#F7F6F4 width=326 colspan=2>
<b>System SelfCheck</b>
</tr>
<tr>
<td valign=middle height=1 width=137>
Active News
<td valign=middle height=1 width=146>
$stats_news
<td valign=middle height=1 width=37>
<td valign=middle height=1 width=201>
Can write to news.txt
<td valign=middle height=1 width=121>\";
if(is_writable(\"./data/news.txt\")){ echo \"<font color=green>Yes</font>\"; }
else{ echo \"<font color=red>No</font>\"; }
echo\"</tr>
<tr>
<td valign=middle height=1 width=137>
Active Comments
<td valign=middle height=1 width=146>
$count_comments
<td valign=middle height=1 width=37>
<td valign=middle height=1 width=201>
Can write to comments.txt
<td valign=middle height=1 width=121>\";
if(is_writable(\"./data/comments.txt\")){ echo \"<font color=green>Yes</font>\"; }
else{ echo \"<font color=red>No</font>\"; }
echo\"</tr>
<tr>
<td width=137 valign=middle height=1>
Archives
<td width=146 valign=middle height=1>
$stats_archives
<td width=37 valign=middle height=1>
<td width=201 valign=middle height=1>
Can write to users.db.php
<td width=121 valign=middle height=1>\";
if(is_writable(\"./data/users.db.php\")){ echo \"<font color=green>Yes</font>\"; }
else{ echo \"<font color=red>No</font>\"; }
echo\"</tr>
<tr>
<td width=137 valign=middle height=1>
Users
<td width=146 valign=middle height=1>
$stats_users
<td width=37 valign=middle height=1>
<td width=201 valign=middle height=1>
Can write to archives dir
<td width=121 valign=middle height=1>\";
if(is_writable(\"./data/archives\")){ echo \"<font color=green>Yes</font>\"; }
else{ echo \"<font color=red>No</font>\"; }
echo\"</tr>
<tr>
<td width=137 valign=middle height=1>
News.txt Size
<td width=146 valign=middle height=1>
$stats_news_size
<td width=37 valign=middle height=1>
<td width=201 valign=middle height=1>
<td width=121 valign=middle height=1>
</tr>
<tr>
<td width=137 valign=middle height=1>
Comments.txt Size
<td width=146 valign=middle height=1>
$stats_comments_size
<td width=37 valign=middle height=1>
<td width=201 valign=middle height=1>
<td width=121 valign=middle height=1>
</tr>
\";
}
echo\"</table>\";
echofooter();
?>