[7445] | 1 | <?php |
---|
| 2 | |
---|
| 3 | function plugin_activate() |
---|
| 4 | { |
---|
| 5 | $query = ' |
---|
| 6 | SELECT |
---|
| 7 | value |
---|
| 8 | FROM '.CONFIG_TABLE.' |
---|
| 9 | WHERE param=\'statistics\' |
---|
| 10 | ;'; |
---|
| 11 | $result = pwg_query($query); |
---|
| 12 | if ($row = pwg_db_fetch_assoc($result)) |
---|
| 13 | { |
---|
| 14 | if (!preg_match('/^a:/', $row['value'])) |
---|
| 15 | { |
---|
| 16 | $old_conf = explode("," , $row['value']); |
---|
| 17 | |
---|
| 18 | $conf_statistics = array( |
---|
| 19 | 'content' => $old_conf[2], |
---|
| 20 | 'header' => ($old_conf[0] == 'on'), |
---|
| 21 | 'tail' => ($old_conf[1] == 'on'), |
---|
| 22 | 'exclude_admin' => ($old_conf[3] == 'on'), |
---|
| 23 | 'exclude_guest' => ($old_conf[4] == 'on'), |
---|
| 24 | ); |
---|
| 25 | |
---|
| 26 | $query = ' |
---|
| 27 | UPDATE '.CONFIG_TABLE.' |
---|
| 28 | SET value = \''.pwg_db_real_escape_string(serialize($conf_statistics)).'\' |
---|
| 29 | WHERE param=\'statistics\' |
---|
| 30 | ;'; |
---|
| 31 | pwg_query($query); |
---|
| 32 | } |
---|
| 33 | } |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | function plugin_install() |
---|
| 37 | { |
---|
| 38 | $conf_statistics = array( |
---|
| 39 | 'content' => '', |
---|
| 40 | 'header' => false, |
---|
| 41 | 'tail' => true, |
---|
| 42 | 'exclude_admin' => false, |
---|
| 43 | 'exclude_guest' => false, |
---|
| 44 | ); |
---|
| 45 | |
---|
| 46 | $query = ' |
---|
| 47 | INSERT INTO '.CONFIG_TABLE.' (param,value,comment) |
---|
| 48 | VALUES ( |
---|
| 49 | \'statistics\', |
---|
| 50 | \''.pwg_db_real_escape_string(serialize($conf_statistics)).'\', |
---|
| 51 | \'Parameters of Statistics plugin\' |
---|
| 52 | ) |
---|
| 53 | ;'; |
---|
| 54 | pwg_query($query); |
---|
| 55 | } |
---|
| 56 | |
---|
| 57 | function plugin_uninstall() |
---|
| 58 | { |
---|
| 59 | $query = ' |
---|
| 60 | DELETE FROM '.CONFIG_TABLE.' |
---|
| 61 | WHERE param=\'statistics\' |
---|
| 62 | ;'; |
---|
| 63 | pwg_query($query); |
---|
| 64 | } |
---|
| 65 | ?> |
---|