Skip to content

Commit

Permalink
Fixed issue: Captchas not displaying
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@11099 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
c-schmitz committed Oct 4, 2011
1 parent ea43942 commit 52d1108
Show file tree
Hide file tree
Showing 11 changed files with 123 additions and 11 deletions.
106 changes: 106 additions & 0 deletions application/controllers/verification.php
@@ -0,0 +1,106 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
* LimeSurvey
* Copyright (C) 2007 The LimeSurvey Project Team / Carsten Schmitz
* All rights reserved.
* License: GNU/GPL License v2 or later, see LICENSE.php
* LimeSurvey is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*
* $Id: survey.php 10433 2011-07-06 14:18:45Z dionet $
*
*/

class verification extends CI_Controller {

function __construct()
{
parent::__construct();
}

function image()
{
$rootdir=$this->config->item('rootdir');

// header for png
Header("Content-Type: image/png");

// Create Image
$im = ImageCreate(75, 20);
$white = ImageColorAllocate($im, 255, 255, 255);
$black = ImageColorAllocate($im, 0, 0, 0);
$red = ImageColorAllocate($im, 255, 0, 0);
$blue = ImageColorAllocate($im, 0, 0, 255);
$grey_shade = ImageColorAllocate($im, 204, 204, 204);

// Create the random numberes
srand((double)microtime()*1000000);

$num1 = rand(1,5);
$found = false;
while ($found == false)
{
$num2 = rand(1,100);
if (preg_match('/^[0-9]+$/', $num2/5))
{
$found = true;
break;
}
}
$font_c_rand = rand(1,3);
if ($font_c_rand == 1)
{
$font_color = $black;
} else if ($font_c_rand == 2)
{
$font_color = $red;
} else if ($font_c_rand == 3)
{
$font_color = $blue;
}

$font_rand = rand(1,3);
if ($font_rand == 1)
{
$font = $rootdir.DIRECTORY_SEPARATOR."fonts".DIRECTORY_SEPARATOR."verabd.ttf";
} else if ($font_rand == 2) {
$font = $rootdir.DIRECTORY_SEPARATOR."fonts".DIRECTORY_SEPARATOR."vera.ttf";
} else if ($font_rand == 3)
{
$font = $rootdir.DIRECTORY_SEPARATOR."fonts".DIRECTORY_SEPARATOR."verait.ttf";
}

$line_rand = rand(1,3);
if ($line_rand == 1)
{
$line_color = $black;
} else if ($line_rand == 2)
{
$line_color = $red;
} else if ($line_rand == 3)
{
$line_color = $blue;
}

// Fill image, make transparent
ImageFill($im, 0, 0, $grey_shade);
//imagecolortransparent ($im, $white);
imageline($im,0,0,0,20,$line_color);
imageline($im,74,0,74,19,$line_color);
imageline($im,0,0,74,0,$line_color);
imageline($im,0,19,74,19,$line_color);
// Write math question in a nice TTF Font
ImageTTFText($im, 10, 0, 3, 16,$font_color, $font, $num1." + ".$num2." =" );

// Display Image
ImagePNG($im);
ImageDestroy($im);

// Add the answer to the session
$_SESSION['secanswer'] = $num1+$num2;
}
}

8 changes: 4 additions & 4 deletions application/helpers/frontend_helper.php
Expand Up @@ -1391,7 +1391,7 @@ function SendSubmitNotifications()
}

$sFrom = $thissurvey['adminname'].' <'.$thissurvey['adminemail'].'>';

$redata=compact(array_keys(get_defined_vars()));
if (count($aEmailNotificationTo)>0)
{
Expand Down Expand Up @@ -1555,7 +1555,7 @@ function buildsurveysession($surveyid)
if (function_exists("ImageCreate") && captcha_enabled('surveyaccessscreen', $thissurvey['usecaptcha']))
{
echo "<tr>
<td align='center' valign='middle'><label for='captcha'>".$clang->gT("Security question:")."</label></td><td align='left' valign='middle'><table><tr><td valign='middle'><img src='$rooturl/verification.php?sid=$surveyid' alt='captcha' /></td>
<td align='center' valign='middle'><label for='captcha'>".$clang->gT("Security question:")."</label></td><td align='left' valign='middle'><table><tr><td valign='middle'><img src='".site_url('/verification/image')."' alt='captcha' /></td>
<td valign='middle'><input id='captcha' type='text' size='5' maxlength='3' name='loadsecurity' value='' /></td></tr></table>
</td>
</tr>";
Expand Down Expand Up @@ -1632,7 +1632,7 @@ function buildsurveysession($surveyid)
if (function_exists("ImageCreate") && captcha_enabled('surveyaccessscreen', $thissurvey['usecaptcha']))
{
echo "<li>
<label for='captchaimage'>".$clang->gT("Security Question")."</label><img id='captchaimage' src='$rooturl/verification.php?sid=$surveyid' alt='captcha' /><input type='text' size='5' maxlength='3' name='loadsecurity' value='' />
<label for='captchaimage'>".$clang->gT("Security Question")."</label><img id='captchaimage' src='".site_url('/verification/image')."' alt='captcha' /><input type='text' size='5' maxlength='3' name='loadsecurity' value='' />
</li>";
}
echo "<li>
Expand Down Expand Up @@ -1805,7 +1805,7 @@ function buildsurveysession($surveyid)
if (function_exists("ImageCreate") && captcha_enabled('surveyaccessscreen', $thissurvey['usecaptcha']))
{
echo "<li>
<label for='captchaimage'>".$clang->gT("Security Question")."</label><img id='captchaimage' src='$rooturl/verification.php?sid=$surveyid' alt='captcha' /><input type='text' size='5' maxlength='3' name='loadsecurity' value='' />
<label for='captchaimage'>".$clang->gT("Security Question")."</label><img id='captchaimage' src='".site_url('/verification/image')."' alt='captcha' /><input type='text' size='5' maxlength='3' name='loadsecurity' value='' />
</li>";
}
echo "<li><input class='submit' type='submit' value='".$clang->gT("Continue")."' /></li>
Expand Down
6 changes: 3 additions & 3 deletions application/helpers/replacements_helper.php
Expand Up @@ -495,7 +495,7 @@ function templatereplace($line, $replacements=array(),&$redata=array(), $debugSr
$_saveform .= "' /></td></tr>\n";
if (isset($thissurvey['usecaptcha']) && function_exists("ImageCreate") && captcha_enabled('saveandloadscreen', $thissurvey['usecaptcha']))
{
$_saveform .="<tr><td align='right'>" . $clang->gT("Security Question") . ":</td><td><table><tr><td valign='middle'><img src='{$captchapath}verification.php?sid=$_surveyid' alt='' /></td><td valign='middle' style='text-align:left'><input type='text' size='5' maxlength='3' name='loadsecurity' value='' /></td></tr></table></td></tr>\n";
$_saveform .="<tr><td align='right'>" . $clang->gT("Security Question") . ":</td><td><table><tr><td valign='middle'><img src='".site_url('/verification/image')."' alt='' /></td><td valign='middle' style='text-align:left'><input type='text' size='5' maxlength='3' name='loadsecurity' value='' /></td></tr></table></td></tr>\n";
}
$_saveform .= "<tr><td align='right'></td><td></td></tr>\n"
. "<tr><td></td><td><input type='submit' id='savebutton' name='savesubmit' value='" . $clang->gT("Save Now") . "' /></td></tr>\n"
Expand All @@ -516,7 +516,7 @@ function templatereplace($line, $replacements=array(),&$redata=array(), $debugSr
$_loadform .= "' /></td></tr>\n";
if (isset($thissurvey['usecaptcha']) && function_exists("ImageCreate") && captcha_enabled('saveandloadscreen', $thissurvey['usecaptcha']))
{
$_loadform .="<tr><td align='right'>" . $clang->gT("Security Question") . ":</td><td><table><tr><td valign='middle'><img src='{$captchapath}verification.php?sid=$_surveyid' alt='' /></td><td valign='middle'><input type='text' size='5' maxlength='3' name='loadsecurity' value='' alt=''/></td></tr></table></td></tr>\n";
$_loadform .="<tr><td align='right'>" . $clang->gT("Security Question") . ":</td><td><table><tr><td valign='middle'><img src='".site_url('/verification/image')."' alt='' /></td><td valign='middle'><input type='text' size='5' maxlength='3' name='loadsecurity' value='' alt=''/></td></tr></table></td></tr>\n";
}
$_loadform .="<tr><td align='right'></td><td></td></tr>\n"
. "<tr><td></td><td><input type='submit' id='loadbutton' value='" . $clang->gT("Load Now") . "' /></td></tr></table>\n";
Expand Down Expand Up @@ -561,7 +561,7 @@ function templatereplace($line, $replacements=array(),&$redata=array(), $debugSr
$_registerform .= " /></td></tr>\n";
if (isset($thissurvey['usecaptcha']) && function_exists("ImageCreate") && captcha_enabled('registrationscreen', $thissurvey['usecaptcha']))
{
$_registerform .="<tr><td align='right'>" . $clang->gT("Security Question") . ":</td><td><table><tr><td valign='middle'><img src='{$captchapath}verification.php?sid=$surveyid' alt='' /></td><td valign='middle'><input type='text' size='5' maxlength='3' name='loadsecurity' value='' /></td></tr></table></td></tr>\n";
$_registerform .="<tr><td align='right'>" . $clang->gT("Security Question") . ":</td><td><table><tr><td valign='middle'><img src='".site_url('/verification/image')."' alt='' /></td><td valign='middle'><input type='text' size='5' maxlength='3' name='loadsecurity' value='' /></td></tr></table></td></tr>\n";
}
$_registerform .= "<tr><td></td><td><input id='registercontinue' class='submit' type='submit' value='" . $clang->gT("Continue") . "' />"
. "</td></tr>\n"
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/update/upgrade-all_helper.php
Expand Up @@ -66,7 +66,7 @@ function db_upgrade_all($oldversion) {
'type' => 'VARCHAR',
'constraint' => '50',
),
'targetsqid' => array(
'targetqid' => array(
'type' => 'INT',
'null' => TRUE,
),
Expand Down
6 changes: 3 additions & 3 deletions application/views/admin/survey/surveybar_view.php
Expand Up @@ -129,17 +129,17 @@
<?php if($respstatsread && $surveyexport) {
if ($activated){?>
<li><a href='<?php echo site_url("admin/export/survey/exportarchive/$surveyid");?>' >
<img src='<?php echo $imageurl;?>/export_30.png' alt='' width="30" height="30"/> <?php echo $clang->gT("Survey archive (.lsa)");?></a></li>
<img src='<?php echo $imageurl;?>/export_30.png' alt='' width="30" height="30"/> <?php echo $clang->gT("Survey archive (.zip)");?></a></li>
<?php }
else
{?>
<li><a href="#" onclick="alert('<?php echo $clang->gT("You can only archive active surveys.", "js");?>');" >
<img src='<?php echo $imageurl;?>/export_disabled_30.png' alt='' width="30" height="30"/> <?php echo $clang->gT("Survey archive (.lsa)");?></a></li><?php
<img src='<?php echo $imageurl;?>/export_disabled_30.png' alt='' width="30" height="30"/> <?php echo $clang->gT("Survey archive (.zip)");?></a></li><?php
}
}?>
<?php if($surveyexport) { ?>
<li><a href='<?php echo site_url("admin/export/survey/exportstructurequexml/$surveyid");?>' >
<img src='<?php echo $imageurl;?>/export_30.png' alt='' width="30" height="30"/> <?php echo $clang->gT("queXML format (*.xlm)");?></a>
<img src='<?php echo $imageurl;?>/export_30.png' alt='' width="30" height="30"/> <?php echo $clang->gT("queXML format (*.xml)");?></a>
<?php } ?>

</ul>
Expand Down
Binary file added fonts/KacstFarsi.ttf
Binary file not shown.
Binary file added fonts/KacstOffice.ttf
Binary file not shown.
6 changes: 6 additions & 0 deletions fonts/fireflysung - Chinese.ttf.txt
@@ -0,0 +1,6 @@
For package size reasons the Firefly Sung font to show Chinese characters in the statistics graphs
is not included with LimeSurvey.

Please download it from http://cle.linux.org.tw/fonts/FireFly/fireflysung-1.3.0.tar.gz
and put the fireflysung.tff file into the /fonts directory of your LimeSurvey installation.

Binary file added fonts/vera.ttf
Binary file not shown.
Binary file added fonts/verabd.ttf
Binary file not shown.
Binary file added fonts/verait.ttf
Binary file not shown.

0 comments on commit 52d1108

Please sign in to comment.