-
Notifications
You must be signed in to change notification settings - Fork 0
/
articles.php
250 lines (241 loc) · 11.4 KB
/
articles.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
<?php
session_start();
include("includes/functions.php");
include("includes/articles.php");
if(!$USER=displayLogin()){ if(isset($sql)) $sql->close(); exit;}
//----------------------------------------------------------------------------
$SHOWARTICLE = false;
$SHOWSECTION = false;
$SHOWDROPCONF = false;
$ARTSECTIONS = getSections();
$MESSAGE = '';
if (isset($section)){
$SECTION = new section($section);
$SHOWSECTION = true;
$ARTICLES = $SECTION->getSectionArticlesXML();
if (isset($article)){
if (isset($ARTICLES[$article])){
$ARTICLE = $ARTICLES[$article];
if ($ARTICLE->exists){
$SHOWARTICLE = true;
$ARTICLE->loadComments();
}
}
if (isset($action) && $action == 'modify'){
//ñîõðàíèì èçìåíåíèÿ
if (!isset($ARTICLE)){
$ARTICLE = new article($section,$fname,true);
$article = $fname;
}
$ARTICLE->name = $fname;
$ARTICLE->title = $ftitle;
$ARTICLE->date = $fdate;
$ARTICLE->author = $fauthor;
$ARTICLE->keywords = $fkeywords;
$ARTICLE->description = $fdescription;
$ARTICLE->mainpage = (isset($fmainpage)&&'main'==$fmainpage?'main':null);
$ARTICLE->width = $fwidth;
$ARTICLE->orderpage = (isset($forderpage)&&'yes'==$forderpage?'yes':'no');
preg_match('/^([a-z]|[0-9]|_|-)*/', $ARTICLE->name, $matches);
if ($ARTICLE->name == 'noname' || $matches[0] != $ARTICLE->name){ $MESSAGE = 'Íåâåðíûé ID ñòàòüè';}
else{
preg_match('/^([a-z]|[A-Z]|[à-ÿ]|[À-ß]|[0-9]|[-_ .,?!:;\/@#$%*()+=¹"\'])*/', $ARTICLE->title, $matches);
if ($matches[0] != $ARTICLE->title){ $MESSAGE = 'Íåäîïóñòèìûå ñèìâîëû â çàãîëîâêå ñòàòüè.';}
preg_match('/^([a-z]|[A-Z]|[à-ÿ]|[À-ß]|[0-9]|[-_ .,?!:;\/@#$%*()+=¹"\'])*/', $ARTICLE->keywords, $matches);
if ($matches[0] != $ARTICLE->keywords){ $MESSAGE .= ' Íåäîïóñòèìûå ñèìâîëû â ïîëå keywords.';}
preg_match('/^([a-z]|[A-Z]|[à-ÿ]|[À-ß]|[0-9]|[-_ .,?!:;\/@#$%*()+=¹"\'])*/', $ARTICLE->description, $matches);
if ($matches[0] != $ARTICLE->description){ $MESSAGE .= ' Íåäîïóñòèìûå ñèìâîëû â ïîëå description.';}
preg_match('/^([a-z]|[A-Z]|[à-ÿ]|[À-ß]|[0-9]|[-_ .,?!:;\/@#$%*()+=¹"\'])*/', $ARTICLE->author, $matches);
if ($matches[0] != $ARTICLE->author){ $MESSAGE .= ' Íåäîïóñòèìûå ñèìâîëû â ïîëå author.';}
preg_match('/^([a-z]|[A-Z]|[à-ÿ]|[À-ß]|[0-9]|[. -])*/', $ARTICLE->date, $matches);
if ($matches[0] != $ARTICLE->date){ $MESSAGE .= ' Íåäîïóñòèìûå ñèìâîëû â äàòå.';}
}
if (strlen($MESSAGE) == 0) $ARTICLE->save();
//if ($ARTICLE->exists) $SHOWARTICLE = true;
$SHOWARTICLE = true;
}
if (isset($action) && $action == 'modifytext'){
//ñîõðàíèì èçìåíåíèÿ
$ARTICLE->saveContent($fartcontent);
}
if (isset($action) && $action == 'drop_article'){
//ñîõðàíèì èçìåíåíèÿ
$SHOWARTICLE = false;
if(isset($ARTICLE)){
if(isset($conform) && $conform='yes'){if($ARTICLE->drop()) unset($ARTICLES[$article]);}
else $SHOWDROPCONF=true;
}
}
}elseif (isset($action) && $action == 'savesection'){
//ñîõðàíèì âñå â XML
$ARTICLES = $SECTION->getSectionArticlesINI();
foreach($ARTICLES as $art) $art->save(false);
$ARTICLES = $SECTION->getSectionArticlesXML();
}elseif (isset($action) && $action == 'newarticle'){
//Ñîçäàòü íîâóþ ñòàòüþ
$ARTICLE = new article($SECTION->name,'noname',true);
$SHOWARTICLE = true;
}
} else {
$ORDER_ARTICLES = getOrderArticles();
}
header('Content-type: text/html; charset=windows-1251');
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//RU" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML lang="ru,en">
<HEAD>
<TITLE>Ïàíåëü óïðàâëåíèÿ ìàãàçèíîì</TITLE>
<META content="text/html"; charset="windows-1251" http-equiv="Content-Type" />
<link rel="stylesheet" href="prd_main.css"/>
<!--[if IE7]><link rel="stylesheet" type="text/css" href="prd_main_ie.css" media="all" /><![endif]-->
<script language="JavaScript" src="ajax.js"></script>
</HEAD>
<BODY>
<!-- .......................... Çàãîëîâîê .......................... -->
<?php require("templates/menu.htm");?>
<div id=contMain>
<table border="0" cellspacing="0" cellpadding="0" width=100%>
<tr>
<!-- .......................... Ëåâîå ìåíþ .......................... -->
<td valign=top width=170px>
<div class=nav>
<h3>Ðàçäåëû ñòàòåé</h3>
<?php foreach($ARTSECTIONS as $SNAME => $STITLE):?>
<div class=navItem>
<a href=articles.php?section=<?=$SNAME?>><?=$STITLE?></a>
</div>
<?php endforeach ?>
</div>
</td>
<!-- .......................... Ñîäåðæèìîå .......................... -->
<td valign=top>
<div id=catContent>
<br>
<?php if($SHOWDROPCONF):?>
<b>
<font color=red>Âû äåéñòâèòåëüíî õîòèòå óäàëèòü ñòàòüþ?</font>
<br><font color=blue>[<?=$ARTICLE->name?>]</font>
<br><font color=black><?=$ARTICLE->title?></font>
<br>
</b>
<br>
<a href=articles.php?section=<?=$SECTION->name?>&article=<?=$ARTICLE->name?>&action=drop_article&conform=yes>Óäàëèòü</a>
<a href=articles.php?section=<?=$SECTION->name?>>Îòìåíà</a>
<?php elseif($SHOWARTICLE):?>
<form action=articles.php?section=<?=$SECTION->name?>&article=<?=$ARTICLE->name?> method=post>
<input type=hidden name=action value="modify">
<div class=blockhead>Ïàðàìåòðû</div>
<div class=blockedit>
<p><font color=red><?=$MESSAGE?></font></p>
<p><label>ID</label><input type=text name=fname size=60 value="<?=$ARTICLE->name?>">
<input type="checkbox" name="fmainpage" value="main" <?=('main'==$ARTICLE->mainpage?'checked':'')?>><label>Ïîêàçûâàòü íà ãëàâíîé</label>
<input type=text name=fwidth size=10 value="<?=$ARTICLE->width?>">
</p>
<p><label>Çàãîëîâîê</label><input type=text name=ftitle size=100 value="<?=$ARTICLE->title?>"></p>
<p><label>Äàòà</label><input type=text name=fdate size=20 value="<?=$ARTICLE->date?>">
<label>Àâòîð</label><input type=text name=fauthor size=50 value="<?=$ARTICLE->author?>"> </p>
<p><input type="checkbox" name="forderpage" value="yes" <?=('yes'==$ARTICLE->orderpage?'checked':'')?>><label>Ïîêàçûâàòü íà ñòðàíèöå îôîðìëåííîãî çàêàçà</label></p>
<p><label>META.keywords</label><br><input type=text name=fkeywords size=100 value="<?=$ARTICLE->keywords?>"></p>
<p><label>META.description</label><br><textarea name=fdescription cols=100 rows=5><?=$ARTICLE->description?></textarea></p>
<p><input type=submit name="btnsave" value="Ñîõðàíèòü ïàðàìåòðû"></p>
</div>
</form>
<div class=blockhead>Ñîäåðæàíèå</div>
<div class=blockedit>
<form action="articles.php?section=<?=$SECTION->name?>&article=<?=$ARTICLE->name?>" method=post>
<input type=hidden name=action value="modifytext">
<p>
<input type=submit name="btnsave" value="Ñîõðàíèòü ñòàòüþ"> <a target=previewarticle href=<?=$ARTICLE->preview_link?>>Ïðîñìîòð</a>
</p>
<p>
<textarea id=article_content cols=150 rows=30 name=fartcontent><?php $ARTICLE->getContent(); ?></textarea>
</p>
<p>
<input type=submit name="btnsave" value="Ñîõðàíèòü ñòàòüþ">
</p>
</form>
<div>
<form action="index.php" method="post" name=load_file<?=$ARTICLE->name?>>
<input type="hidden" name = "article" value="../articles/<?=$ARTICLE->section?>"/>
<input type="hidden" name = "action" value="load_photo"/>
<label>Çàãðóçèòü ôîòî</label><input name="itemPhoto" type="file" size="40"/>
<a href="javascript:loadFile('<?=$ARTICLE->name?>')"><img src="images/btn-save.jpg" alt="Ñîõðàíèòü èçìåíåíèÿ"></a>
<em id="ajaxmes_load_file<?=$ARTICLE->name?>"></em>
</form>
</div>
</div>
<div class=blockhead>Êîììåíòàðèè</div>
<div class=blockedit>
<form action="articles.php?section=<?=$SECTION->name?>&article=<?=$ARTICLE->name?>" method=post>
<input type=hidden name=action value="modifycomments">
<div class=articlelist>
<?php foreach($ARTICLE->comments as $comment):?>
<div id=comment<?=$comment->id?> class="article comment<?=($comment->status==1?' good_comment':'')?>">
<p>
<?=$comment->id?> <strong><?=$comment->username?></strong> | <?=$comment->add_time?> | <?=$comment->email?>
<br><span><?=$comment->subject?></span> |
<span id=message<?=$comment->id?>>
<?php if($comment->status==0): ?>
<a href="javascript:modifyComment('<?=$ARTICLE->section?>','<?=$ARTICLE->name?>',<?=$comment->id?>,1)">óòâåðäèòü</a>
<?php else:?>
<a href="javascript:modifyComment('<?=$ARTICLE->section?>','<?=$ARTICLE->name?>',<?=$comment->id?>,0)">çàáàíèòü</a>
<?php endif?>
</span>
<br><?=$comment->text?>
</p>
</div>
<?php endforeach?>
</div>
</form>
</div>
<?php elseif ($SHOWSECTION):?>
<h3> <?=$SECTION->title?> </h3>
<br>
<form action=articles.php?section=<?=$SECTION->name?> method=post>
<input type=hidden name=action value="savesection">
<input type=submit name="btnsave" value="Çàãðóçèòü èç INI">
</form>
<form action=articles.php?section=<?=$SECTION->name?> method=post>
<input type=hidden name=action value="newarticle">
<input type=submit name="btnsave" value="Ñîçäàòü">
</form>
<br>
<div class=articlelist>
<?php foreach($ARTICLES as $ANAME => $ARTICLE):?>
<div class="article<?=(!$ARTICLE->text_exists?' no_text':'');?><?=('main'==$ARTICLE->mainpage?' on_main':'');?>">
<a href=articles.php?section=<?=$SECTION->name?>&article=<?=$ARTICLE->name?> ><strong><?=$ARTICLE->title?> <?php if($ARTICLE->orderpage=='yes'):?><img border="0" src="images/ord.jpg"/><?php endif;?></strong></a>
<a href=articles.php?section=<?=$SECTION->name?>&article=<?=$ARTICLE->name?>&action=drop_article>Óäàëèòü</a>
<p><span><?=$ARTICLE->author?></span> | <?=$ARTICLE->date?>
<a href=articles.php?section=<?=$SECTION->name?>&article=<?=$ARTICLE->name?> ><img border="0" src="images/btn_more.gif" align="absmiddle" width="11" height="11" /></a>
</p>
</div>
<?php endforeach;?>
</div>
<?php else:?>
<h3>Ýòè ñòàòüè áóäóò ïîêàçàíû ïîñåòèòåëþ ïîñëå îôîðìëåíèÿ çàêàçà</h3>
<br>
<div class=blockedit><form>Ïîêàçûâàòü <input type=text value=3 size=5> ñòàòåé, âûáðàííûõ â ñëó÷àéíîì ïîðÿäêå </form></div>
<br>
<?php foreach($ORDER_ARTICLES as $ANAME => $ARTICLE):?>
<div class="article<?=(!$ARTICLE->text_exists?' no_text':'');?><?=('main'==$ARTICLE->mainpage?' on_main':'');?>">
<a href=articles.php?section=<?=$ARTICLE->section?>&article=<?=$ARTICLE->name?> ><strong><?=$ARTICLE->title?></strong></a>
<p><span><?=$ARTICLE->author?></span> | <?=$ARTICLE->date?>
<a href=articles.php?section=<?=$ARTICLE->section?>&article=<?=$ARTICLE->name?> ><img border="0" src="images/btn_more.gif" align="absmiddle" width="11" height="11" /></a>
</p>
<p>
<?=$ARTICLE->intro?>
</p>
</div>
<?php endforeach;?>
<?php endif;?>
</div>
</td>
</tr>
</table>
</div>
<!-- .......................... Ïîäâàë .......................... -->
<div id="FooterBar">
</div>
</BODY>
</HTML>
<?php if(isset($sql)) $sql->close();?>