1 | <?php |
---|
2 | // Chech whether we are indeed included by Piwigo. |
---|
3 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
4 | |
---|
5 | function plugin_install() |
---|
6 | { |
---|
7 | global $prefixeTable, $conf; |
---|
8 | |
---|
9 | $query = 'SHOW TABLES LIKE "' . $prefixeTable . 'evil_blog"'; |
---|
10 | $result = pwg_query($query); |
---|
11 | if (!mysql_fetch_row($result)) |
---|
12 | { |
---|
13 | $query = |
---|
14 | 'CREATE TABLE ' . $prefixeTable . 'evil_blog ( |
---|
15 | id INT( 1 ) NOT NULL AUTO_INCREMENT, |
---|
16 | date DATETIME NOT NULL, |
---|
17 | header VARCHAR( 255 ) NOT NULL , |
---|
18 | text LONGTEXT NOT NULL , |
---|
19 | PRIMARY KEY (id)) |
---|
20 | DEFAULT CHARACTER SET utf8'; |
---|
21 | pwg_query($query); |
---|
22 | }else{ |
---|
23 | $query = |
---|
24 | 'SHOW FIELDS FROM"' . $prefixeTable . 'evil_blog"'; |
---|
25 | $result = pwg_query($query); |
---|
26 | } |
---|
27 | |
---|
28 | $config = array( |
---|
29 | 'blog_name' => 'News', |
---|
30 | 'posts_per_page' => 3, |
---|
31 | 'blog_description' => 'News Blog', |
---|
32 | 'show_on_main_page' => 'on', |
---|
33 | 'show_on_category_page' => 'on', |
---|
34 | 'show_number' => 'on', |
---|
35 | 'show_date' => 'on', |
---|
36 | 'date_format' => 'H.i d/m/Y' |
---|
37 | ); |
---|
38 | |
---|
39 | if (isset($conf['evil_blog'])) |
---|
40 | { |
---|
41 | $query = |
---|
42 | 'UPDATE '.CONFIG_TABLE.' SET value = "'.pwg_db_real_escape_string(serialize($config)).'" WHERE param = "evil_blog"'; |
---|
43 | |
---|
44 | } else { |
---|
45 | $query = |
---|
46 | 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
47 | VALUES ("evil_blog" , "'.pwg_db_real_escape_string(serialize($config)).'" , "Evil_Blog configuration");'; |
---|
48 | } |
---|
49 | pwg_query($query); |
---|
50 | } |
---|
51 | |
---|
52 | function plugin_activate() |
---|
53 | { |
---|
54 | global $prefixeTable, $conf; |
---|
55 | |
---|
56 | $query = 'SHOW TABLES LIKE "' . $prefixeTable . 'evil_blog"'; |
---|
57 | $result = pwg_query($query); |
---|
58 | if (!mysql_fetch_row($result)) |
---|
59 | { |
---|
60 | $query = |
---|
61 | 'CREATE TABLE ' . $prefixeTable . 'evil_blog ( |
---|
62 | id INT( 1 ) NOT NULL AUTO_INCREMENT, |
---|
63 | date DATETIME NOT NULL, |
---|
64 | header VARCHAR( 255 ) NOT NULL , |
---|
65 | text LONGTEXT NOT NULL , |
---|
66 | PRIMARY KEY (id)) |
---|
67 | DEFAULT CHARACTER SET utf8'; |
---|
68 | pwg_query($query.';'); |
---|
69 | }/*else{ |
---|
70 | $result = pwg_query("SHOW FIELDS FROM " . $prefixeTable . "evil_blog;"); |
---|
71 | $description = false; |
---|
72 | While ($row = pwg_db_fetch_assoc($result)) { |
---|
73 | if ($row['Field']=='description') {$description=true; break;} |
---|
74 | } |
---|
75 | if (!$description) { |
---|
76 | $result = pwg_query("ALTER TABLE " . $prefixeTable . "evil_blog CHANGE `text` `description` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;"); |
---|
77 | $result = pwg_query("ALTER TABLE " . $prefixeTable . "evil_blog ADD `text` LONGTEXT NOT NULL ;"); |
---|
78 | } |
---|
79 | }*/ |
---|
80 | |
---|
81 | $config = array( |
---|
82 | 'blog_name' => 'News', |
---|
83 | 'posts_per_page' => 3, |
---|
84 | 'blog_description' => 'News Blog', |
---|
85 | 'show_on_main_page' => 'on', |
---|
86 | 'show_on_category_page' => 'on', |
---|
87 | 'show_number' => 'on', |
---|
88 | 'show_date' => 'on', |
---|
89 | 'date_format' => 'H.i d/m/Y' |
---|
90 | ); |
---|
91 | |
---|
92 | if (isset($conf['evil_blog'])) |
---|
93 | { |
---|
94 | $query = |
---|
95 | 'UPDATE '.CONFIG_TABLE.' SET value = "'.pwg_db_real_escape_string(serialize($config)).'" WHERE param = "evil_blog"'; |
---|
96 | |
---|
97 | } else { |
---|
98 | $query = |
---|
99 | 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment) |
---|
100 | VALUES ("evil_blog" , "'.pwg_db_real_escape_string(serialize($config)).'" , "Evil_Blog configuration");'; |
---|
101 | } |
---|
102 | pwg_query($query); |
---|
103 | } |
---|
104 | |
---|
105 | function plugin_uninstall() |
---|
106 | { |
---|
107 | global $prefixeTable; |
---|
108 | pwg_query('DROP TABLE ' . $prefixeTable . 'evil_blog;'); |
---|
109 | pwg_query('DELETE FROM ' . CONFIG_TABLE . ' WHERE '.CONFIG_TABLE.'.param="evil_blog" LIMIT 1;'); |
---|
110 | unset($conf['evil_blog']); |
---|
111 | } |
---|
112 | ?> |
---|