Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/plugins/AP_reCAPTCHA.php
blob: 2a56e0473b1d2a636b2d1d2fdde6d71893dc76be (plain)
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
<?php

/**
 * New reCAPTCHA plugin for FluxBB
 *
 * Created by Franz Liedke
 */

// Make sure no one attempts to run this script "directly"
if (!defined('PUN'))
    exit;

// Tell admin_loader.php that this is indeed a plugin and that it is loaded
define('PUN_PLUGIN_LOADED', 1);

// Load language file
if (file_exists(PUN_ROOT.'lang/'.$pun_user['language'].'/recaptcha_addon.php'))
    require PUN_ROOT.'lang/'.$pun_user['language'].'/recaptcha_addon.php';
else
    require PUN_ROOT.'lang/English/recaptcha_addon.php';

// Store the config
if (isset($_POST['process_form']))
{
    $enabled = isset($_POST['recaptcha_enabled']) ? 1 : 0;
    $site_key = isset($_POST['recaptcha_site_key']) ? pun_trim($_POST['recaptcha_site_key']) : '';
    $secret_key = isset($_POST['recaptcha_secret_key']) ? pun_trim($_POST['recaptcha_secret_key']) : '';
    $location_register = isset($_POST['recaptcha_location_register']) ? 1 : 0;
    $location_login = isset($_POST['recaptcha_location_login']) ? 1 : 0;
    $location_guestpost = isset($_POST['recaptcha_location_guestpost']) ? 1 : 0;

    foreach (compact('enabled', 'site_key', 'secret_key', 'location_register', 'location_login', 'location_guestpost') as $key => $value)
    {
        $key = 'recaptcha_'.$key;

        if (isset($pun_config[$key]))
            $db->query('UPDATE '.$db->prefix.'config SET conf_value = \''.$db->escape($value).'\' WHERE conf_name = \''.$db->escape($key).'\'') or error('Unable to update config value for '.$key, __FILE__, __LINE__, $db->error());
        else
            $db->query('INSERT INTO '.$db->prefix.'config (conf_name, conf_value) VALUES (\''.$db->escape($key).'\', \''.$db->escape($value).'\')') or error('Unable to store config value for '.$key, __FILE__, __LINE__, $db->error());
    }

    // Regenerate the config cache
    if (!defined('FORUM_CACHE_FUNCTIONS_LOADED'))
        require PUN_ROOT.'include/cache.php';

    generate_config_cache();

    redirect('admin_loader.php?plugin=AP_reCAPTCHA.php', $lang_recaptcha['Settings saved']);
}


// Display the admin navigation menu
generate_admin_menu($plugin);

?>

<div class="blockform">
    <h2><span><?= $lang_recaptcha['reCAPTCHA'] ?></span></h2>
    <div class="box">
        <form id="recaptcha" method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>">
            <div class="inform">
                <fieldset>
                    <legend><?= $lang_recaptcha['General']; ?></legend>
                    <div class="infldset">
                        <p>
                            <?= $lang_recaptcha['General description']; ?>
                        </p>
                        <table class="aligntop" cellspacing="0">
                            <tr>
                                <th scope="row"><?= $lang_recaptcha['Enable']; ?></th>
                                <td>
                                    <input type="checkbox" name="recaptcha_enabled" <?= empty($pun_config['recaptcha_enabled']) ? '' : 'checked' ?> />
                                </td>
                            </tr>
                            <tr>
                                <th scope="row"><?= $lang_recaptcha['Site key']; ?></th>
                                <td>
                                    <input type="text" name="recaptcha_site_key" size="40" value="<?php if (!empty($pun_config['recaptcha_site_key'])) echo pun_htmlspecialchars($pun_config['recaptcha_site_key']); ?>" />
                                </td>
                            </tr>
                            <tr>
                                <th scope="row"><?= $lang_recaptcha['Secret key']; ?></th>
                                <td>
                                    <input type="text" name="recaptcha_secret_key" size="40" value="<?php if (!empty($pun_config['recaptcha_secret_key'])) echo pun_htmlspecialchars($pun_config['recaptcha_secret_key']); ?>" />
                                </td>
                            </tr>
                        </table>
                    </div>
                </fieldset>

                <fieldset>
                    <legend><?= $lang_recaptcha['Locations']; ?></legend>
                    <div class="infldset">
                        <p>
                            <?= $lang_recaptcha['Locations description']; ?>
                        </p>
                        <table class="aligntop" cellspacing="0">
                            <tr>
                                <th scope="row"><?= $lang_recaptcha['Register']; ?></th>
                                <td>
                                    <input type="checkbox" name="recaptcha_location_register" <?= empty($pun_config['recaptcha_location_register']) ? '' : 'checked' ?> />
                                </td>
                            </tr>
                            <tr>
                                <th scope="row"><?= $lang_recaptcha['Login']; ?></th>
                                <td>
                                    <input type="checkbox" name="recaptcha_location_login" <?= empty($pun_config['recaptcha_location_login']) ? '' : 'checked' ?> />
                                </td>
                            </tr>
                            <tr>
                                <th scope="row"><?= $lang_recaptcha['Guest post']; ?></th>
                                <td>
                                    <input type="checkbox" name="recaptcha_location_guestpost" <?= empty($pun_config['recaptcha_location_guestpost']) ? '' : 'checked' ?> />
                                </td>
                            </tr>
                        </table>
                    </div>
                </fieldset>
            </div>
            <p class="submitend"><input type="submit" name="process_form" value="<?= $lang_recaptcha['Save'] ?>" /></p>
        </form>
    </div>
</div>