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

Conflicts:
	modules/gallery/views/in_place_edit.html.php
This commit is contained in:
Tim Almdal
2010-01-29 11:39:22 -08:00
7 changed files with 41 additions and 40 deletions
+1 -10
View File
@@ -25,17 +25,8 @@ class Admin_Akismet_Controller extends Admin_Controller {
// @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."));
+11 -6
View File
@@ -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 @@ class akismet_Core {
* @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);
}
}
}
+1 -1
View File
@@ -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>
@@ -70,7 +70,6 @@ class InPlaceEdit_Core {
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;
+3 -5
View File
@@ -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>
@@ -42,7 +42,7 @@ class Admin_Recaptcha_Controller extends Admin_Controller {
} 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");
}
+24 -16
View File
@@ -24,12 +24,16 @@ class recaptcha_Core {
->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 @@ class recaptcha_Core {
* @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 @@ class recaptcha_Core {
$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") {