1 | <?php |
---|
2 | // Chech whether we are indeed included by Piwigo. |
---|
3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
4 | |
---|
5 | // Fetch the template. |
---|
6 | global $template, $conf, $page; |
---|
7 | |
---|
8 | if (isset($_POST['submit_post'])) {//äîáàâëåíèå ïîñòà // write new post in db |
---|
9 | $result = pwg_query("insert into ".Evil_Blog_Table." values (NULL, NOW() , '". $_POST['post_header']."', '".$_POST['post_textarea']."')"); |
---|
10 | array_push($page['infos'], l10n('post_is_saved')); |
---|
11 | } |
---|
12 | |
---|
13 | if (!empty($_POST['del'])) {//óäàëåíèå ïîñòà // deleting post from db |
---|
14 | $result = pwg_query("DELETE FROM ".Evil_Blog_Table." WHERE ".Evil_Blog_Table.".id = ".$_POST['del']." LIMIT 1"); |
---|
15 | array_push($page['infos'], l10n('post_is_deleted')); |
---|
16 | } |
---|
17 | |
---|
18 | if (!empty($_POST['edit_post_id'])) { |
---|
19 | $result = pwg_query("UPDATE ".Evil_Blog_Table." |
---|
20 | SET ".Evil_Blog_Table.".header='".$_POST['edit_post_header']."', |
---|
21 | ".Evil_Blog_Table.".text='".$_POST['edit_post_text']."' |
---|
22 | WHERE ".Evil_Blog_Table.".id='".$_POST['edit_post_id']."' LIMIT 1"); |
---|
23 | array_push($page['infos'], l10n('post_modified')); |
---|
24 | } |
---|
25 | |
---|
26 | $eb_conf = @unserialize($conf['evil_blog']); |
---|
27 | $post_per_page = $eb_conf['posts_per_page']; |
---|
28 | |
---|
29 | $row = pwg_db_fetch_assoc(pwg_query("SELECT COUNT(*) FROM `".Evil_Blog_Table."`"));; |
---|
30 | |
---|
31 | //$pages - number of pages in all blog |
---|
32 | //$npage - page on which we look |
---|
33 | if ($row["COUNT(*)"] % $post_per_page != 0) { |
---|
34 | $pages = floor($row["COUNT(*)"] / $post_per_page)+1; |
---|
35 | } else {$pages = floor($row["COUNT(*)"] / $post_per_page);} |
---|
36 | if ((empty($_POST['npage'])) or ($_POST['npage']<=1)) { |
---|
37 | $number = 0; |
---|
38 | $npage = 1; |
---|
39 | } else { |
---|
40 | $npage = $_POST['npage']; |
---|
41 | if ($npage<=$pages) { |
---|
42 | $number=($npage-1)*$post_per_page; |
---|
43 | } else { |
---|
44 | $number=($pages-1)*$post_per_page; |
---|
45 | $npage=$pages; |
---|
46 | } |
---|
47 | } |
---|
48 | |
---|
49 | $query = "SELECT * |
---|
50 | FROM `".Evil_Blog_Table."` |
---|
51 | WHERE 1 |
---|
52 | ORDER BY `date` DESC |
---|
53 | LIMIT ".$number.",".$post_per_page; |
---|
54 | $result = pwg_query($query); |
---|
55 | $qwe = 0; |
---|
56 | while ($row = pwg_db_fetch_assoc($result)) {//áîëåå âìåíÿåìàÿ îáðàáîòêà ðåçóëüòàòà èç áàçû, íóæíî äëÿ íîðìàëüíîé ðàáîòû SMARTY |
---|
57 | $row1[$qwe] = $row; |
---|
58 | $qwe++; |
---|
59 | } |
---|
60 | if (!empty($row1)) { |
---|
61 | $template->assign('row', $row1); |
---|
62 | } |
---|
63 | $template->assign('npage', $npage); |
---|
64 | $template->assign('pages', $pages); |
---|
65 | for ($it=1; $it<=$pages; $it++) {//ñîçäàíèå ìàññèâà ñ íîìåðàìè ñòðàíèö //create array with numbers of pages |
---|
66 | $pagi[$it] = $it; |
---|
67 | } |
---|
68 | if (!empty($pagi)) { |
---|
69 | $template->assign('pagi', $pagi); |
---|
70 | } |
---|
71 | $template->assign('blog_name', $eb_conf['blog_name']); |
---|
72 | |
---|
73 | //âêëþ÷àåì FCKeditor |
---|
74 | $FCKEA = pwg_db_fetch_assoc(pwg_query("SELECT state FROM " . PLUGINS_TABLE . " WHERE id = 'FCKEditor';")); |
---|
75 | if($FCKEA['state'] == 'active') set_fckeditor_instance($areas='post_textarea', $toolbar='Full', $width='900px', $height='200px'); |
---|
76 | |
---|
77 | $template->set_filenames( array('plugin_admin_content' => dirname(__FILE__).'/manage.tpl') ); |
---|
78 | $template->assign_var_from_handle( 'ADMIN_CONTENT', 'plugin_admin_content'); |
---|
79 | |
---|
80 | ?> |
---|