[8030] | 1 | <?php |
---|
| 2 | function plugin_install() |
---|
| 3 | { |
---|
[8054] | 4 | global $conf; |
---|
| 5 | |
---|
| 6 | if (!isset($conf['captcha_publickey'])) |
---|
| 7 | { |
---|
| 8 | $q = 'INSERT INTO '.CONFIG_TABLE.' (param,value,comment) VALUES ("captcha_publickey","","Captcha public key");'; |
---|
| 9 | pwg_query($q); |
---|
| 10 | } |
---|
| 11 | |
---|
| 12 | if (!isset($conf['captcha_privatekey'])) |
---|
| 13 | { |
---|
| 14 | $q = 'INSERT INTO '.CONFIG_TABLE.' (param,value,comment) VALUES ("captcha_privatekey","","Captcha private key");'; |
---|
| 15 | pwg_query($q); |
---|
| 16 | } |
---|
| 17 | |
---|
| 18 | if (!isset($conf['captcha_theme'])) |
---|
| 19 | { |
---|
| 20 | $q = 'INSERT INTO '.CONFIG_TABLE.' (param,value,comment) VALUES ("captcha_theme","red","Captcha theme");'; |
---|
| 21 | pwg_query($q); |
---|
| 22 | } |
---|
[8030] | 23 | } |
---|
| 24 | |
---|
[8054] | 25 | function plugin_activate($id, $version, &$errors) |
---|
[8034] | 26 | { |
---|
| 27 | global $conf; |
---|
[8030] | 28 | |
---|
[8034] | 29 | if (!isset($conf['captcha_theme'])) |
---|
| 30 | { |
---|
[8054] | 31 | plugin_install(); |
---|
[8034] | 32 | } |
---|
[8054] | 33 | |
---|
| 34 | // Check if API is responding |
---|
| 35 | include(PHPWG_PLUGINS_PATH.basename(dirname(__FILE__)).'/recaptchalib.php'); |
---|
| 36 | $response = _recaptcha_http_post(RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify", array ()); |
---|
| 37 | $answers = explode ("\n", $response [1]); |
---|
| 38 | |
---|
| 39 | if ($answers[0] != 'true' and $answers[0] != 'false') |
---|
| 40 | { |
---|
| 41 | array_push($errors, l10n('Piwigo can\'t connect to reCaptcha server')); |
---|
| 42 | } |
---|
[8034] | 43 | } |
---|
| 44 | |
---|
| 45 | |
---|
[8030] | 46 | function plugin_uninstall() |
---|
| 47 | { |
---|
[8034] | 48 | foreach (array('captcha_publickey','captcha_privatekey', 'captcha_theme') as $param) |
---|
[8030] | 49 | { |
---|
[8054] | 50 | $q = 'DELETE FROM '.CONFIG_TABLE.' WHERE param="'.$param.'" LIMIT 1'; |
---|
[8030] | 51 | pwg_query( $q ); |
---|
| 52 | } |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | ?> |
---|