Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of git@github.com:gallery/gallery3

Conflicts:
	modules/gallery/views/in_place_edit.html.php
  • Loading branch information...
commit e4d9ea3394ee2db82d9dee6c6ed78543fd0f78fb 2 parents 1bc0d05 + 660130c
@talmdal talmdal authored
View
11 modules/akismet/controllers/admin_akismet.php
@@ -25,17 +25,8 @@ public function index() {
// @todo move the "post" handler part of this code into a separate function
access::verify_csrf();
- $valid = $form->validate();
-
- if ($valid) {
+ if ($form->validate()) {
$new_key = $form->configure_akismet->api_key->value;
- if ($new_key && !akismet::validate_key($new_key)) {
- $form->configure_akismet->api_key->add_error("invalid", 1);
- $valid = false;
- }
- }
-
- if ($valid) {
$old_key = module::get_var("akismet", "api_key");
if ($old_key && !$new_key) {
message::success(t("Your Akismet key has been cleared."));
View
17 modules/akismet/helpers/akismet.php
@@ -23,8 +23,9 @@ class akismet_Core {
static function get_configure_form() {
$form = new Forge("admin/akismet", "", "post", array("id" => "g-configure-akismet-form"));
$group = $form->group("configure_akismet")->label(t("Configure Akismet"));
- $group->input("api_key")->label(t("API Key"))->value(module::get_var("akismet", "api_key"));
- $group->api_key->error_messages("invalid", t("The API key you provided is invalid."));
+ $group->input("api_key")->label(t("API Key"))->value(module::get_var("akismet", "api_key"))
+ ->callback("akismet::validate_key")
+ ->error_messages("invalid", t("The API key you provided is invalid."));
$group->submit("")->value(t("Save"));
return $form;
}
@@ -82,10 +83,14 @@ static function submit_ham($comment) {
* @param string $api_key the API key
* @return boolean
*/
- static function validate_key($api_key) {
- $request = self::_build_verify_request($api_key);
- $response = self::_http_post($request, "rest.akismet.com");
- return "valid" == $response->body[0];
+ static function validate_key($api_key_input) {
+ if ($api_key_input->value) {
+ $request = self::_build_verify_request($api_key_input->value);
+ $response = self::_http_post($request, "rest.akismet.com");
+ if ("valid" != $response->body[0]) {
+ $api_key_input->add_error("invalid", 1);
+ }
+ }
}
View
2  modules/digibug/views/digibug_form.html.php
@@ -3,7 +3,7 @@
<body>
<?= form::open("http://www.digibug.com/dapi/order.php") ?>
<?= form::hidden($order_parms) ?>
- <?= form::close() ?>
+ </form>
<script type="text/javascript">
document.forms[0].submit();
</script>
View
1  modules/gallery/libraries/InPlaceEdit.php
@@ -70,7 +70,6 @@ public function validate() {
public function render() {
$v = new View("in_place_edit.html");
- $v->hidden = array("csrf" => access::csrf_token());
$v->action = url::site($this->action);
$v->form = $this->form;
$v->errors = $this->errors;
View
8 modules/gallery/views/in_place_edit.html.php
@@ -1,5 +1,5 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
-<?= form::open($action, array("method" => "post", "id" => "g-in-place-edit-form", "class" => "g-short-form"), $hidden) ?>
+<?= form::open($action, array("method" => "post", "id" => "g-in-place-edit-form", "class" => "g-short-form")) ?>
<?= access::csrf_form_field() ?>
<ul>
<li<? if (!empty($errors["input"])): ?> class="g-error"<? endif ?>>
@@ -10,8 +10,6 @@
</li>
<li><a href="#" class="g-cancel"><?= t("Cancel") ?></a></li>
</ul>
-</form/>
-<? if (!empty($errors["input"])): ?>
-<div id="g-in-place-edit-message" class="g-error"><?= $errors["input"] ?></div>
-<? endif ?>
+</form>
+
View
2  modules/recaptcha/controllers/admin_recaptcha.php
@@ -42,7 +42,7 @@ public function index() {
} else {
module::set_var("recaptcha", "public_key", "");
module::set_var("recaptcha", "private_key", "");
- message::success(t("reCAPTCHA disabled!"));
+ message::success(t("No keys provided. reCAPTCHA is disabled!"));
log::success("recaptcha", t("reCAPTCHA public and private keys cleared"));
url::redirect("admin/recaptcha");
}
View
40 modules/recaptcha/helpers/recaptcha.php
@@ -24,12 +24,16 @@ static function get_configure_form() {
->label(t("Configure reCAPTCHA"));
$group->input("public_key")
->label(t("Public Key"))
- ->value(module::get_var("recaptcha", "public_key"));
- $group->public_key->error_messages("invalid", t("The public key you provided is invalid."));
+ ->value(module::get_var("recaptcha", "public_key"))
+ ->rules("required")
+ ->error_messages("required", t("You must enter a public key"))
+ ->error_messages("invalid", t("This public key is invalid"));
$group->input("private_key")
->label(t("Private Key"))
- ->value(module::get_var("recaptcha", "private_key"));
- $group->private_key->error_messages("invalid", t("The private key you provided is invalid."));
+ ->value(module::get_var("recaptcha", "private_key"))
+ ->callback("recaptcha::verify_key")
+ ->error_messages("required", t("You must enter a private key"))
+ ->error_messages("invalid", t("This private key is invalid"));
$group->submit("")->value(t("Save"));
$site_domain = urlencode(stripslashes($_SERVER["HTTP_HOST"]));
@@ -55,19 +59,23 @@ static function check_config() {
* @param string $private_key
* @return boolean
*/
- static function verify_key($private_key) {
+ static function verify_key($private_key_input) {
+ if (!$private_key_input->value) {
+ $private_key_input->add_error("required", 1);
+ return;
+ }
+
$remote_ip = Input::instance()->server("REMOTE_ADDR");
$response = self::_http_post("api-verify.recaptcha.net", "/verify",
- array("privatekey" => $private_key,
+ array("privatekey" => $private_key_input->value,
"remoteip" => $remote_ip,
"challenge" => "right",
"response" => "wrong"));
- $answers = explode("\n", $response[1]);
- if (trim($answers[0]) == "true") {
- return null;
- } else {
- return $answers[1];
+ if ($response[1] == "false\ninvalid-site-private-key") {
+ // This is the only thing I can figure out how to verify.
+ // See http://recaptcha.net/apidocs/captcha for possible return values
+ $private_key_input->add_error("invalid", 1);
}
}
@@ -80,16 +88,16 @@ static function is_recaptcha_valid($challenge, $response, $private_key) {
$input = Input::instance();
$remote_ip = $input->server("REMOTE_ADDR");
- //discard spam submissions
+ // discard spam submissions
if (empty($challenge) || empty($response)) {
return "incorrect-captcha-sol";
}
$response = self::_http_post("api-verify.recaptcha.net", "/verify",
- array ("privatekey" => $private_key,
- "remoteip" => $remote_ip,
- "challenge" => $challenge,
- "response" => $response));
+ array("privatekey" => $private_key,
+ "remoteip" => $remote_ip,
+ "challenge" => $challenge,
+ "response" => $response));
$answers = explode ("\n", $response [1]);
if (trim ($answers [0]) == "true") {
Please sign in to comment.
Something went wrong with that request. Please try again.