summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.18/sites/all/modules/captcha/image_captcha/image_captcha.user.inc
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.18/sites/all/modules/captcha/image_captcha/image_captcha.user.inc')
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/captcha/image_captcha/image_captcha.user.inc18
1 files changed, 13 insertions, 5 deletions
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/captcha/image_captcha/image_captcha.user.inc b/kolab.org/www/drupal-7.18/sites/all/modules/captcha/image_captcha/image_captcha.user.inc
index 38434f4..07aeb84 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/captcha/image_captcha/image_captcha.user.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/captcha/image_captcha/image_captcha.user.inc
@@ -11,15 +11,16 @@
/**
* Menu callback function that generates the CAPTCHA image.
*/
-function image_captcha_image($captcha_sid=NULL) {
+function image_captcha_image() {
// If output buffering is on: discard current content and disable further buffering
if (ob_get_level()) {
ob_end_clean();
}
-
- if (!$captcha_sid) {
+
+ if (!isset($_GET['sid'])) {
exit();
}
+ $captcha_sid = $_GET['sid'];
// Get solution (the code to show).
$code = db_query("SELECT solution FROM {captcha_sessions} WHERE csid = :csid",
@@ -96,8 +97,12 @@ function _image_captcha_generate_image($code) {
}
imagefilledrectangle($image, 0, 0, $width, $height, $background_color);
+ // Do we need to draw in RTL mode?
+ global $language;
+ $rtl = $language->direction && ((bool) variable_get('image_captcha_rtl_support', 0));
+
// draw text
- $result = _image_captcha_image_generator_print_string($image, $width, $height, $fonts, $font_size, $code);
+ $result = _image_captcha_image_generator_print_string($image, $width, $height, $fonts, $font_size, $code, $rtl);
if (!$result) {
return FALSE;
}
@@ -230,7 +235,7 @@ function _image_captcha_image_generator_add_dots(&$image, $width, $height, $colo
/**
* Helper function for drawing text on the image.
*/
-function _image_captcha_image_generator_print_string(&$image, $width, $height, $fonts, $font_size, $text) {
+function _image_captcha_image_generator_print_string(&$image, $width, $height, $fonts, $font_size, $text, $rtl=FALSE) {
// get characters
$characters = _image_captcha_utf8_split($text);
$character_quantity = count($characters);
@@ -260,6 +265,9 @@ function _image_captcha_image_generator_print_string(&$image, $width, $height, $
foreach ($characters as $c => $character) {
// initial position of character: in the center of its cage
$center_x = ($c + 0.5) * $ccage_width;
+ if ($rtl) {
+ $center_x = $width - $center_x;
+ }
$center_y = 0.5 * $height;
// Pick a random font from the list.