Add netbeans project
[contractdashboard.git] / cutenews / inc / main.mdu
1 <?PHP
2 //If member access level is commenter, redirect him to personal options
3 if($member_db[1] == 4 and $action == "dologin"){ header("Location: $config_http_script_dir/index.php?mod=options&action=personal"); exit; }
4
5
6 echoheader("home", "Welcome");
7
8 if(!is_readable("./data/archives")){ die("Error !!!<br />Can not open directory ./archives for reading, check if it exists or is properly CHMOD'ed"); }
9 if(!is_readable("./data/news.txt")){ die("Error !!!<br />Can not open file news.txt for reading, check if it exists or is properly CHMOD'ed"); }
10 if(!is_readable("./data/comments.txt")){ die("Error !!!<br />Can not open file comments.txt for reading, check if it exists or is properly CHMOD'ed"); }
11
12
13 // Some Stats
14 $count_postponed_news = 0;
15 $count_unapproved_news = 0;
16 $todaynews = 0;
17 $count_comments = 0;
18 $count_my_news = 0;
19 $count_new_news = 0;
20 $news_db = file("./data/news.txt");
21 foreach ($news_db as $line)
22 {
23 $item_db = explode("|",$line);
24 $itemdate = date("d/m/y",$item_db[0]);
25 if($itemdate == date("d/m/y")) {
26 $todaynews++;
27 if($item_db[1] == $member_db[2]) $count_my_news++;
28 if(($item_db[0] > $member_db[9]) and ($member_db[9] != '')) $count_new_news++;
29 }
30 }
31 $stats_news = count( $news_db );
32 $stats_users = count( file("./data/users.db.php") ) - 1;
33 $count_postponed_news = count( file("./data/postponed_news.txt") );
34 if($count_postponed_news > 0){
35 ResynchronizePostponed();
36 }
37
38 if($config_auto_archive == "yes"){
39 ResynchronizeAutoArchive();
40 }
41
42 $count_unapproved_news = count( file("./data/unapproved_news.txt") );
43
44 $stats_archives = 0;
45 $handle = opendir("./data/archives");
46 while (FALSE !== ($file = readdir($handle)))
47 {
48 if( preg_match("/.news.arch/",$file) ){$stats_archives++;}
49 }
50 closedir($handle);
51 // $stats_news_size = formatsize(filesize("./data/news.txt"));
52 // $stats_comments_size = formatsize(filesize("./data/comments.txt"));
53
54 // Count Comments
55 $all_comments = file("./data/comments.txt");
56 foreach($all_comments as $news_comments){
57 $single_news_comments = explode("|>|", $news_comments);
58 $individual_comments = explode("||", $single_news_comments[1]);
59 $count_comments += count($individual_comments) - 1;
60 }
61 // Define Welcome Message
62 echo"<table border=0 cellpading=0 cellspacing=0 width=654>
63 <tr><td width=650 colspan=5 height=1>
64 &nbsp;
65
66 <SCRIPT LANGUAGE=\"JavaScript\">
67 <!-- Begin
68 datetoday = new Date();
69 timenow=datetoday.getTime();
70 datetoday.setTime(timenow);
71 thehour = datetoday.getHours();
72 if (thehour < 9 ) display = \"Morning\";
73 else if (thehour < 12) display = \"Day\";
74 else if (thehour < 17) display = \"Afternoon\";
75 else if (thehour < 20) display = \"Evening\";
76 else display = \"Night\";
77 var greeting = (\"Good \" + display);
78 document.write(greeting);
79 // End -->
80 </script>
81
82 $member_db[2]";
83
84 if($todaynews != 1){ $s = "s"; }
85 if($member_db[1] != 4){
86 if($stats_users > 1){
87 $rand_msg[] = ", we have <b>$count_new_news</b> new articles since your last login (@ ".date("r",$member_db[9])." )";
88 $rand_msg[] = ", we have <b>$count_new_news</b> new articles since your last login (@ ".date("r",$member_db[9])." )";
89 $rand_msg[] = ", we have <b>$count_new_news</b> new articles since your last login (@ ".date("r",$member_db[9])." )";
90 }
91 if($todaynews == 0){
92 $rand_msg[] = ", we don't have new articles today";
93 $rand_msg[] = ", we don't have new articles today";
94 $rand_msg[] = ", we don't have new articles today, the first one can be yours.";
95 $rand_msg[] = ", we don't have new articles today, the first one can be yours.";
96 }
97 elseif($count_my_news == 0){
98 if($todaynews == 1){
99 $rand_msg[] = ", today we have <b>$todaynews</b> new article{$s} but it is not yours";
100 }else{
101 $rand_msg[] = ", today we have <b>$todaynews</b> new article{$s} but <b>$count_my_news</b> of them are yours";
102 }
103 }
104 elseif($count_my_news == $todaynews){
105 if($count_my_news == 1){
106 $rand_msg[] = ", today we have <b>$todaynews</b> new article{$s} and you wrote it";
107 $rand_msg[] = ", today we have <b>$todaynews</b> new article{$s} and you wrote it";
108 $rand_msg[] = ", today we have <b>$todaynews</b> new article{$s} and you wrote it";
109 }else{
110 $rand_msg[] = ", today we have <b>$todaynews</b> new article{$s} and you wrote all of them";
111 $rand_msg[] = ", today we have <b>$todaynews</b> new article{$s} and all are yours";
112 $rand_msg[] = ", today we have <b>$todaynews</b> new article{$s}, want to <a href=\"$PHP_SELF?mod=addnews&action=addnews\"><b>add</b></a> some more?";
113 }
114 }
115 else{
116 if($count_my_news == 1){ $rand_msg[] = ", today we have <b>$todaynews</b> new article{$s}, <b>1</b> of them is yours"; }
117 else{ $rand_msg[] = ", today we have <b>$todaynews</b> new article{$s}, <b>$count_my_news</b> of them are yours"; }
118 }
119 $rand_msg[] = ", are you in a mood of <a href=\"$PHP_SELF?mod=addnews&action=addnews\"><b>adding</b></a> some news?";
120 $rand_msg[] = ", today we have <b>$todaynews</b> new article{$s}, from total <b>$stats_news</b>";
121 if($member_db[9] != ""){
122 $rand_msg[] = ", your last login was on ".date("d M Y H:i:s", $member_db[9]);
123 $rand_msg[] = ", your last login was on ".date("d M Y H:i:s", $member_db[9]);
124 }
125
126 $rand_msg[] = "";
127
128 srand((double) microtime() * 1000000);
129 echo $rand_msg[rand(0, count($rand_msg)-1)]."<br /><br /></td></tr>";
130 }
131
132
133 //----------------------------------
134 // Notify user if the news were auto-archived
135 //----------------------------------
136
137 //get last auto-archive date
138 $ladb_content = file("$cutepath/data/auto_archive.db.php");
139 list($last_archived[year], $last_archived[month]) = split("\|", $ladb_content[0] );
140 $last_login_year = date("Y", ($member_db[9] || time()) );
141 $last_login_month = date("n", ($member_db[9] || time()) );
142
143 if((int)$last_login_month < (int)$last_archived[month] and $last_login_year <= $last_archived[year]){
144
145 echo"<tr><td style='padding:3px; border:1px dashed orange; background-color:yellow;' colspan=5 height=1>
146 <b>Attention!</b><br>
147 CuteNews has performed auto-archive opperation since your last login at ".date("d M Y H:i:s", $member_db[9])."<br>
148 If you don't want your news to be auto-archived every month,<br>
149 you can swith this option off from <a href=\"?mod=options&action=syscon\">System Configurations</a>.
150
151 </td></tr>";
152
153 }
154 //----------------------------------
155 // Do we have enough free space ?
156 //----------------------------------
157 $dfs = @disk_free_space("./");
158 // $dfs = 5341;
159 if($dfs and $dfs < 10240){
160 $freespace = formatsize($dfs);
161 echo"<tr><td style='padding:3px; border:1px dashed red; background-color:#FFB9B9;' colspan=5 height=1>
162 <b>Warning!</b><br>
163 According to CuteNews, your estimated free space is $freespace. Take action to enlarge your free space or
164 some data files could be damaged during the writing procedure. <a href=\"?mod=tools&action=backup\">Backup your data now</a>.
165 </td></tr>";
166 }
167
168 //----------------------------------
169 // Install script still exists ?
170 //----------------------------------
171 if ($action == 'delete-install'){ @unlink('./inc/install.mdu'); }
172 if(file_exists('./inc/install.mdu')){
173 $freespace = formatsize($dfs);
174 echo"<tr><td style='padding:3px; border:1px dashed orange; background-color:yellow;' colspan=5 height=1>
175 <b>Attention!</b><br>
176 CuteNews found that the installation module is still located in the /inc folder.<br>
177 Please delete or rename the <b>/inc/install.mdu</b> file for security reasons.<br><br>
178 <a href='$PHP_SELFT?mod=main&action=delete-install'><b>(try to delete the file automatically)</b></a><br>&nbsp;
179 </td></tr>";
180 }
181
182 //----------------------------------
183 // Are we using SafeSkin ?
184 //----------------------------------
185 if($using_safe_skin){
186 $freespace = formatsize($dfs);
187 echo"<tr><td style='padding:3px; border:1px dashed orange; background-color:yellow;' colspan=5 height=1>
188 <b>Attention!</b><br>
189 CuteNews was unable to load the selected '$config_skin' skin, and automatically reverted to the default one.<br>
190 Please ensure that the proper skin files exist, or select another skin.
191 </td></tr>";
192 }
193
194 //----------------------------------
195 // Is our PHP version old ?
196 //----------------------------------
197 if($phpversion and $phpversion < '4.1.0'){
198 $freespace = formatsize($dfs);
199 echo"<tr><td style='padding:3px; border:1px dashed orange; background-color:yellow;' colspan=5 height=1>
200 <b>Attention!</b><br>
201 Your version of PHP ($phpversion) is too old. Please consider contacting your server administrator and updating to the
202 latest stable PHP version.
203 </td></tr>";
204 }
205
206
207 // Show Some stats
208 if($member_db[1] == 1){
209 echo "<tr><td valign=middle height=1 bgcolor=#F7F6F4 width=286 colspan=2>
210 &nbsp;<b>Some stats</b>
211 <td valign=middle height=1 width=35>
212 <td valign=middle height=1 bgcolor=#F7F6F4 width=326 colspan=2>
213 &nbsp;<b>System SelfCheck</b>
214 </tr>
215
216 <tr>
217 <td valign=middle height=1 width=137>
218 &nbsp; <a title='View all Active News (Edit News)' href='$PHP_SELF?mod=editnews&action=list'>Active News</a>
219 <td valign=middle height=1 width=146>
220 $stats_news
221 <td valign=middle height=1 width=37>
222 <td valign=middle height=1 width=201>
223 &nbsp; Can write to news.txt
224 <td valign=middle style='text-align:center' height=1 >";
225
226 if(is_writable("./data/news.txt")){ echo "<font color=green>Yes</font>"; }
227 else{ echo "<font color=red>No</font>"; }
228
229 echo"</tr>
230
231 <tr>
232 <td valign=middle height=1 width=137>
233 &nbsp; <a title='View all Postponed Articles' href='$PHP_SELF?mod=editnews&action=list&source=postponed'>Postponed News</a>
234 <td valign=middle height=1 width=146>
235 $count_postponed_news
236 <td valign=middle height=1 width=37>
237 <td valign=middle height=1 width=201>
238 &nbsp; Can write to postponed_news.txt
239 <td valign=middle height=1 style='text-align:center' >";
240
241 if(is_writable("./data/postponed_news.txt")){ echo "<font color=green>Yes</font>"; }
242 else{ echo "<font color=red>No</font>"; }
243
244 echo"</tr>
245
246 <tr>
247 <td valign=middle height=1 width=137>
248 &nbsp; <a title='View all Unapproved Articles' href='$PHP_SELF?mod=editnews&action=list&source=unapproved'>Unapproved News</a>
249 <td valign=middle height=1 width=146> ";
250 if($count_unapproved_news > 0){
251 echo"<span style='background-color:yellow;'>$count_unapproved_news</span>";
252 }else{
253 echo"$count_unapproved_news";
254 }
255 echo"<td valign=middle height=1 width=37>
256 <td valign=middle height=1 width=201>
257 &nbsp; Can write to unapproved news
258 <td valign=middle height=1 style='text-align:center'>";
259
260 if(is_writable("./data/unapproved_news.txt")){ echo "<font color=green>Yes</font>"; }
261 else{ echo "<font color=red>No</font>"; }
262
263 echo"</tr>
264
265 <tr>
266 <td valign=middle height=1 width=137>
267 &nbsp; Active Comments
268 <td valign=middle height=1 width=146>
269 $count_comments
270 <td valign=middle height=1 width=37>
271 <td valign=middle height=1 width=201>
272 &nbsp; Can write to comments.txt
273 <td valign=middle height=1 style='text-align:center'>";
274
275 if(is_writable("./data/comments.txt")){ echo "<font color=green>Yes</font>"; }
276 else{ echo "<font color=red>No</font>"; }
277
278 echo"</tr>
279 <tr>
280 <td width=137 valign=middle height=1>
281 &nbsp; <a title='View all Archives (Archives Manager)' href='$PHP_SELF?mod=tools&action=archive'>Archives</a>
282 <td width=146 valign=middle height=1>
283 $stats_archives
284 <td width=37 valign=middle height=1>
285 <td width=201 valign=middle height=1>
286 &nbsp; Can write to users.db.php
287 <td width=121 valign=middle style='text-align:center' height=1>";
288
289 if(is_writable("./data/users.db.php")){ echo "<font color=green>Yes</font>"; }
290 else{ echo "<font color=red>No</font>"; }
291
292 echo"</tr>
293 <tr>
294 <td width=137 valign=middle height=1>
295 &nbsp; <a title='View all Users (Add/Edit Users)' href='$PHP_SELF?mod=editusers&action=list'>Users</a>
296 <td width=146 valign=middle height=1>
297 $stats_users
298 <td width=37 valign=middle height=1>
299 <td width=201 valign=middle height=1>
300 &nbsp; Can write to archives dir
301 <td width=121 valign=middle style='text-align:center' height=1>";
302
303 if(is_writable("./data/archives")){ echo "<font color=green>Yes</font>"; }
304 else{ echo "<font color=red>No</font>"; }
305
306 echo"</tr>
307
308
309 ";
310 }
311 echo"</table>";
312
313 echofooter();
314 ?>