|
|
1 |
<?PHP
|
|
|
2 |
|
|
|
3 |
if($member_db[1] != 1){ msg("error", "Access Denied", "You don't have permission for this section"); }
|
|
|
4 |
$success = FALSE;
|
|
|
5 |
// ********************************************************************************
|
|
|
6 |
// Archive
|
|
|
7 |
// ********************************************************************************
|
|
|
8 |
if($action == "archive")
|
|
|
9 |
{
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
// ***************************
|
|
|
13 |
// Un-Archive
|
|
|
14 |
// ***************************
|
|
|
15 |
if($subaction == "unarchive" and $aid != "" and isset($aid)){
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
if(!$handle = opendir("$cutepath/data/archives")){ die("<center>Unable to open directory $cutepath/data/archive</center>"); }
|
|
|
19 |
while (false !== ($file = readdir($handle)))
|
|
|
20 |
{
|
|
|
21 |
if ($file == "$aid.news.arch")
|
|
|
22 |
{
|
|
|
23 |
$newsfile = fopen("$cutepath/data/news.txt", 'a');
|
|
|
24 |
$newsarch = file("$cutepath/data/archives/$file");
|
|
|
25 |
foreach ($newsarch as $newsline)
|
|
|
26 |
{
|
|
|
27 |
fwrite($newsfile,$newsline);
|
|
|
28 |
}
|
|
|
29 |
fclose($newsfile);
|
|
|
30 |
unlink("$cutepath/data/archives/$file");
|
|
|
31 |
}
|
|
|
32 |
elseif ($file == "$aid.comments.arch")
|
|
|
33 |
{
|
|
|
34 |
$commfile = fopen("$cutepath/data/comments.txt", 'a');
|
|
|
35 |
$commarch = file("$cutepath/data/archives/$file");
|
|
|
36 |
foreach ($commarch as $commline)
|
|
|
37 |
{
|
|
|
38 |
fwrite($commfile,$commline);
|
|
|
39 |
}
|
|
|
40 |
fclose($commfile);
|
|
|
41 |
unlink("$cutepath/data/archives/$file");
|
|
|
42 |
}
|
|
|
43 |
}
|
|
|
44 |
closedir($handle);
|
|
|
45 |
|
|
|
46 |
}//end Un-Archive function
|
|
|
47 |
|
|
|
48 |
|
|
|
49 |
echoheader("archives", "Archives");
|
|
|
50 |
|
|
|
51 |
echo<<<HTML
|
|
|
52 |
|
|
|
53 |
<script language="javascript">
|
|
|
54 |
function confirmdelete(id,news){
|
|
|
55 |
var agree=confirm("Do you really want to permanently delete this archive ?\\nAll ("+news+") news and comments in it will be deleted.");
|
|
|
56 |
if (agree)
|
|
|
57 |
document.location="$PHP_SELF?mod=tools&action=dodeletearchive&archive="+id;
|
|
|
58 |
}
|
|
|
59 |
</script>
|
|
|
60 |
<form method=post action="$PHP_SELF"><table border=0 cellpading=0 cellspacing=0 width="645" >
|
|
|
61 |
<td width=321 height="33">
|
|
|
62 |
<b>Send news to archive</b>
|
|
|
63 |
<table border=0 cellpading=0 cellspacing=0 width=300 class="panel" cellpadding="10" >
|
|
|
64 |
<tr>
|
|
|
65 |
<td width=304 height="25">
|
|
|
66 |
<p align="center">
|
|
|
67 |
<input type=submit value="Proceed with archiving ...">
|
|
|
68 |
</tr>
|
|
|
69 |
|
|
|
70 |
</table>
|
|
|
71 |
<input type=hidden name=action value=doarchive>
|
|
|
72 |
<input type=hidden name=mod value=tools>
|
|
|
73 |
</form>
|
|
|
74 |
|
|
|
75 |
<td width=320 height="33" align="center">
|
|
|
76 |
<!-- HELP -->
|
|
|
77 |
|
|
|
78 |
<table height="25" cellspacing="0" cellpadding="0">
|
|
|
79 |
<tr>
|
|
|
80 |
<td width="25" align=middle><img border="0" src="skins/images/help_small.gif"></td>
|
|
|
81 |
<td > <a onClick="javascript:Help('archives')" href="#">Explaining archives and<br>
|
|
|
82 |
Their usage</a></td>
|
|
|
83 |
</tr>
|
|
|
84 |
</table>
|
|
|
85 |
|
|
|
86 |
<tr>
|
|
|
87 |
<td width=654 colspan="2" height="11">
|
|
|
88 |
<img height=20 border=0 src="skins/images/blank.gif" width=1>
|
|
|
89 |
<br> </tr>
|
|
|
90 |
<tr>
|
|
|
91 |
<td width=654 colspan=2 height=14>
|
|
|
92 |
<b>Available archives</b>
|
|
|
93 |
</tr>
|
|
|
94 |
<tr>
|
|
|
95 |
|
|
|
96 |
<td width=654 colspan=2 height=1>
|
|
|
97 |
<table width=641 height=100% cellspacing=0 cellpadding=0>
|
|
|
98 |
<tr>
|
|
|
99 |
<td width=8 bgcolor=#F7F6F4> </td>
|
|
|
100 |
<td width=160 bgcolor=#F7F6F4><u>archivation date</u></td>
|
|
|
101 |
<td width=222 bgcolor=#F7F6F4><u>duration</u></td>
|
|
|
102 |
<td width=81 bgcolor=#F7F6F4><u>news</u></td>
|
|
|
103 |
<td width=110 bgcolor=#F7F6F4><u><!--action--></u></td>
|
|
|
104 |
|
|
|
105 |
</tr>
|
|
|
106 |
HTML;
|
|
|
107 |
|
|
|
108 |
if(!$handle = opendir("./data/archives")){ die("<center>Can not open directory $cutepath/data/archives "); }
|
|
|
109 |
while (false !== ($file = readdir($handle)))
|
|
|
110 |
{
|
|
|
111 |
if($file != "." and $file != ".." and !is_dir("./data/archives/$file") and eregi("news.arch", $file))
|
|
|
112 |
{
|
|
|
113 |
|
|
|
114 |
$file_arr = explode(".", $file);
|
|
|
115 |
$id = $file_arr[0];
|
|
|
116 |
|
|
|
117 |
$news_lines = file("./data/archives/$file");
|
|
|
118 |
$creation_date = date("d F Y",$file_arr[0]);
|
|
|
119 |
$count = count($news_lines);
|
|
|
120 |
$last = $count-1;
|
|
|
121 |
$first_news_arr = explode("|", $news_lines[$last]);
|
|
|
122 |
$last_news_arr = explode("|", $news_lines[0]);
|
|
|
123 |
|
|
|
124 |
$first_timestamp = $first_news_arr[0];
|
|
|
125 |
$last_timestamp = $last_news_arr[0];
|
|
|
126 |
|
|
|
127 |
$duration = (date("d M Y",$first_timestamp) ." - ". date("d M Y",$last_timestamp) );
|
|
|
128 |
echo "
|
|
|
129 |
<tr>
|
|
|
130 |
<td ></td>
|
|
|
131 |
<td >$creation_date</td>
|
|
|
132 |
<td >$duration</td>
|
|
|
133 |
<td >$count</td>
|
|
|
134 |
<td ><a title='Edit the news in this archive' href=\"$PHP_SELF?mod=editnews&action=list&source=$id\">[edit]</a> <a title='restore news from this archive to active news' href=\"$PHP_SELF?mod=tools&action=archive&subaction=unarchive&aid=$id\">[unarchive]</a> <a title='Delete this archive' onClick=\"javascript:confirmdelete('$id', '$count');\" href=\"#\">[delete]</a></td>
|
|
|
135 |
</tr>
|
|
|
136 |
";
|
|
|
137 |
}
|
|
|
138 |
}
|
|
|
139 |
closedir($handle);
|
|
|
140 |
|
|
|
141 |
if($count == 0){
|
|
|
142 |
echo"<tr><td align=center colspan=6><br>There are no archives</td></tr>";
|
|
|
143 |
}
|
|
|
144 |
|
|
|
145 |
echo<<<HTML
|
|
|
146 |
</table>
|
|
|
147 |
</table>
|
|
|
148 |
HTML;
|
|
|
149 |
|
|
|
150 |
echofooter();
|
|
|
151 |
}
|
|
|
152 |
// ********************************************************************************
|
|
|
153 |
// Make Archive
|
|
|
154 |
// ********************************************************************************
|
|
|
155 |
elseif($action == "doarchive")
|
|
|
156 |
{
|
|
|
157 |
if(filesize("./data/news.txt") == 0){ msg("error", "Error !!!", "Sorry but there are no news to be archived", "$PHP_SELF?mod=tools&action=archive"); }
|
|
|
158 |
if(filesize("./data/comments.txt") == 0){ msg("error", "Error !!!", "The comments file is empty and can not be archived", "$PHP_SELF?mod=tools&action=archive"); }
|
|
|
159 |
|
|
|
160 |
$arch_name = time()+($config_date_adjust*60);
|
|
|
161 |
if(!@copy("./data/news.txt","./data/archives/$arch_name.news.arch")) { msg("error","Error !!!","Can not create file ./data/archives/$arch_name.news.arch", "$PHP_SELF?mod=tools&action=archive");}
|
|
|
162 |
if(!@copy("./data/comments.txt","./data/archives/$arch_name.comments.arch")) { msg("error","Error !!!","Can not create file ./data/archives/$arch_name.comments.arch", "$PHP_SELF?mod=tools&action=archive");}
|
|
|
163 |
|
|
|
164 |
$handle = fopen("./data/news.txt","w");
|
|
|
165 |
fclose($handle);
|
|
|
166 |
$handle = fopen("./data/comments.txt","w");
|
|
|
167 |
fclose($handle);
|
|
|
168 |
|
|
|
169 |
msg("archives", "Archive Saved", "  All active news were successfully added to archives file with name <b>$arch_name.news.arch</b>", "$PHP_SELF?mod=tools&action=archive");
|
|
|
170 |
}
|
|
|
171 |
// ********************************************************************************
|
|
|
172 |
// Do Delete Archive
|
|
|
173 |
// ********************************************************************************
|
|
|
174 |
elseif($action == "dodeletearchive"){
|
|
|
175 |
$success = 0;
|
|
|
176 |
if(!$handle = opendir("./data/archives")){ die("<center>Can not open directory $cutepath/data/archive "); }
|
|
|
177 |
while (false !== ($file = readdir($handle))){
|
|
|
178 |
if($file == "$archive.news.arch" or $file == "$archive.comments.arch"){
|
|
|
179 |
unlink("./data/archives/$file"); $success ++;
|
|
|
180 |
}
|
|
|
181 |
}
|
|
|
182 |
closedir($handle);
|
|
|
183 |
|
|
|
184 |
if($success == 2){
|
|
|
185 |
msg("info", "Arhcive Deleted", "The archive was successfully deleted", "$PHP_SELF?mod=tools&action=archive");
|
|
|
186 |
}elseif($success == 1){
|
|
|
187 |
msg("error", "Error !!!", "Either the comments part or the news part of the archive was not deleted", "$PHP_SELF?mod=tools&action=archive");
|
|
|
188 |
}else{
|
|
|
189 |
msg("error", "Error !!!", "The archive you specified was not deleted, it is not on the server or you don't have permissions to delete it", "$PHP_SELF?mod=tools&action=archive");
|
|
|
190 |
}
|
|
|
191 |
|
|
|
192 |
}
|
|
|
193 |
// ********************************************************************************
|
|
|
194 |
// Backup News and archives
|
|
|
195 |
// ********************************************************************************
|
|
|
196 |
elseif($action == "backup")
|
|
|
197 |
{
|
|
|
198 |
echoheader("options", "Backup");
|
|
|
199 |
echo'
|
|
|
200 |
<script language="javascript">
|
|
|
201 |
function confirmdelete(id){
|
|
|
202 |
var agree=confirm("Do you really want to permanently delete this backup ?");
|
|
|
203 |
if (agree)
|
|
|
204 |
document.location="index.php?mod=tools&action=dodeletebackup&backup="+id;
|
|
|
205 |
}
|
|
|
206 |
function confirmrestore(id){
|
|
|
207 |
var agree=confirm("Do you really want to restore your news from this backup ?\nAll current news and archives will be overwritten.");
|
|
|
208 |
if (agree)
|
|
|
209 |
document.location="index.php?mod=tools&action=dorestorebackup&backup="+id;
|
|
|
210 |
}
|
|
|
211 |
</script>
|
|
|
212 |
<table border=0 cellpading=0 cellspacing=0 width="645" >
|
|
|
213 |
<td width=321 height="33">
|
|
|
214 |
<b>Create BackUp</b>
|
|