mirror of
https://github.com/Mibew/mibew.git
synced 2025-03-03 18:38:31 +03:00
Replace "captcha.php" with a controller
This commit is contained in:
parent
36e06aec16
commit
c3fd4941fe
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__) . '/libs/init.php');
|
||||
|
||||
$captcha_code = gen_captcha();
|
||||
$_SESSION["mibew_captcha"] = $captcha_code;
|
||||
draw_captcha($captcha_code);
|
@ -43,8 +43,11 @@ function gen_captcha()
|
||||
* Send captcha image directly to output
|
||||
*
|
||||
* @param string $security_code String to show on captcha
|
||||
* @param $return boolean Indicates if the image should be sent to the browser
|
||||
* or returned as function result.
|
||||
* @return string Image content if $return argument is set to true.
|
||||
*/
|
||||
function draw_captcha($security_code)
|
||||
function draw_captcha($security_code, $return = false)
|
||||
{
|
||||
//Set the image width and height
|
||||
$width = 100;
|
||||
@ -75,12 +78,23 @@ function draw_captcha($security_code)
|
||||
imageline($image, $width / 2 - 14, 0, $width / 2 + 7, $height, $grey);
|
||||
|
||||
|
||||
if ($return) {
|
||||
// Get image content using output bufferezation
|
||||
ob_start();
|
||||
ImageJpeg($image);
|
||||
$result = ob_get_clean();
|
||||
} else {
|
||||
//Tell the browser what kind of file is come in
|
||||
header("Content-Type: image/jpeg");
|
||||
|
||||
//Output the newly created image in jpeg format
|
||||
ImageJpeg($image);
|
||||
}
|
||||
|
||||
//Free up resources
|
||||
ImageDestroy($image);
|
||||
|
||||
if ($return) {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2005-2014 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
namespace Mibew\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
/**
|
||||
* Renders CAPTCHA image.
|
||||
*/
|
||||
class CaptchaController extends AbstractController
|
||||
{
|
||||
/**
|
||||
* Returns captcha image content.
|
||||
*
|
||||
* @param Request $request Incoming request.
|
||||
* @return string Rendered page content.
|
||||
*/
|
||||
public function drawAction(Request $request)
|
||||
{
|
||||
$captcha_code = gen_captcha();
|
||||
$_SESSION["mibew_captcha"] = $captcha_code;
|
||||
$image = draw_captcha($captcha_code, true);
|
||||
|
||||
$response = new Response(
|
||||
$image,
|
||||
Response::HTTP_OK,
|
||||
array('content-type' => 'image/jpeg')
|
||||
);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
@ -3,6 +3,10 @@ button:
|
||||
path: /b
|
||||
defaults: { _controller: Mibew\Controller\ButtonController::indexAction }
|
||||
|
||||
captcha:
|
||||
path: /captcha
|
||||
defaults: { _controller: Mibew\Controller\CaptchaController::drawAction }
|
||||
|
||||
license:
|
||||
path: /license
|
||||
defaults: { _controller: Mibew\Controller\LicenseController::indexAction }
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
(function(){var u=Handlebars.template,v=Handlebars.templates=Handlebars.templates||{};v._logo=u(function(c,a,e,d,b){function g(a,e){var c,f;return c=""+("\n <a onclick=\"window.open('"+h((f=(f=a&&a.page,null==f||!1===f?f:f.mibewHost),typeof f===m?f.apply(a):f))+'\');return false;" href="'+h((f=(f=a&&a.page,null==f||!1===f?f:f.mibewHost),typeof f===m?f.apply(a):f))+'">\n <img src="'+h((f=(f=(f=a&&a.page,null==f||!1===f?f:f.company),null==f||!1===f?f:f.chatLogoURL),
|
||||
typeof f===m?f.apply(a):f))+'" alt=""/>\n </a>\n ')}function k(a,e){var c,f;return c=""+('\n <img src="'+h((f=(f=(f=a&&a.page,null==f||!1===f?f:f.company),null==f||!1===f?f:f.chatLogoURL),typeof f===m?f.apply(a):f))+'" alt=""/>\n ')}function l(a,e){var c,f;return c=""+("\n <a onclick=\"window.open('"+h((f=(f=a&&a.page,null==f||!1===f?f:f.mibewHost),typeof f===m?f.apply(a):f))+'\');return false;" href="'+h((f=(f=a&&a.page,null==f||
|
||||
!1===f?f:f.mibewHost),typeof f===m?f.apply(a):f))+'">\n <img src="'+h((f=(f=a&&a.page,null==f||!1===f?f:f.tplRoot),typeof f===m?f.apply(a):f))+'/images/default-logo.png" alt=""/>\n </a>\n ')}function t(a,e){var c,f;return c=""+('\n <img src="'+h((f=(f=a&&a.page,null==f||!1===f?f:f.tplRoot),typeof f===m?f.apply(a):f))+'/images/default-logo.gif" alt=""/>\n ')}this.compilerInfo=[4,">= 1.0.0"];e=this.merge(e,c.helpers);b=b||{};var n,
|
||||
!1===f?f:f.mibewHost),typeof f===m?f.apply(a):f))+'">\n <img src="'+h((f=(f=a&&a.page,null==f||!1===f?f:f.tplRoot),typeof f===m?f.apply(a):f))+'/images/default-logo.png" alt=""/>\n </a>\n ')}function t(a,e){var c,f;return c=""+('\n <img src="'+h((f=(f=a&&a.page,null==f||!1===f?f:f.tplRoot),typeof f===m?f.apply(a):f))+'/images/default-logo.png" alt=""/>\n ')}this.compilerInfo=[4,">= 1.0.0"];e=this.merge(e,c.helpers);b=b||{};var n,
|
||||
m="function",h=this.escapeExpression,s=this;c='\n<div id="top2">\n <div id="logo">\n ';if((n=e["if"].call(a,(n=(n=a&&a.page,null==n||!1===n?n:n.company),null==n||!1===n?n:n.chatLogoURL),{hash:{},inverse:s.program(6,function(a,c){var b,f;b="\n ";if((f=e["if"].call(a,(f=a&&a.page,null==f||!1===f?f:f.mibewHost),{hash:{},inverse:s.program(9,t,c),fn:s.program(7,l,c),data:c}))||0===f)b+=f;return b+"\n "},b),fn:s.program(1,function(a,c){var b,f;b="\n ";if((f=e["if"].call(a,
|
||||
(f=a&&a.page,null==f||!1===f?f:f.mibewHost),{hash:{},inverse:s.program(4,k,c),fn:s.program(2,g,c),data:c}))||0===f)b+=f;return b+"\n "},b),data:b}))||0===n)c+=n;return c+='\n \n <div id="page-title">'+h((n=(n=a&&a.page,null==n||!1===n?n:n.title),typeof n===m?n.apply(a):n))+'</div>\n <div class="clear"> </div>\n </div>\n</div>'});v.chat_avatar=u(function(c,a,e,d,b){this.compilerInfo=[4,">= 1.0.0"];e=this.merge(e,c.helpers);b=b||{};var g=this.escapeExpression;
|
||||
return(c=e["if"].call(a,a&&a.imageLink,{hash:{},inverse:this.program(3,function(a,e){return'<div class="default-avatar"></div>'},b),fn:this.program(1,function(a,c){var b,d;b='<img src="';(d=e.imageLink)?d=d.call(a,{hash:{},data:c}):(d=a&&a.imageLink,d="function"===typeof d?d.call(a,{hash:{},data:c}):d);return b+=g(d)+'" border="0" alt="" />'},b),data:b}))||0===c?c:""});v.chat_controls_close=u(function(c,a,e,d,b){this.compilerInfo=[4,">= 1.0.0"];e=this.merge(e,c.helpers);b=b||{};var g,k;c=e.helperMissing;
|
||||
@ -39,7 +39,7 @@ g,c),data:c}))||0===d?d:""},b),data:b}))||0===m)c+=m;c+='\n\n <div class="err
|
||||
d);c+=r(m)+'" class="username"/></td>\n </tr>\n <tr>\n <td><strong>'+r((d=e.l10n||a&&a.l10n,h={hash:{},data:b},d?d.call(a,"form.field.name",h):q.call(a,"l10n","form.field.name",h)))+':</strong></td>\n <td><input type="text" name="name" size="50" value="';(d=e.name)?m=d.call(a,{hash:{},data:b}):(d=a&&a.name,m=typeof d===s?d.call(a,{hash:{},data:b}):d);c+=r(m)+'" class="username"/></td>\n </tr>\n ';if((m=e["if"].call(a,a&&a.groups,{hash:{},inverse:p.noop,
|
||||
fn:p.program(4,function(a,d){var c,b,h,g;c=""+('\n <tr>\n <td class="text"><strong>'+r((h=e.l10n||a&&a.l10n,g={hash:{},data:d},h?h.call(a,"form.field.department",g):q.call(a,"l10n","form.field.department",g)))+'</strong></td>\n <td>\n <select name="group" style="min-width:200px;">\n ');if((b=e.each.call(a,a&&a.groups,{hash:{},inverse:p.noop,fn:p.program(5,k,d),data:d}))||0===b)c+=b;c+='\n </select>\n </td>\n </tr>\n <tr>\n <td class="text"><strong>'+
|
||||
r((h=e.l10n||a&&a.l10n,g={hash:{},data:d},h?h.call(a,"form.field.department.description",g):q.call(a,"l10n","form.field.department.description",g)))+'</strong></td>\n <td class="text" id="groupDescription">\n ';if((b=e.each.call(a,a&&a.groups,{hash:{},inverse:p.noop,fn:p.program(8,t,d),data:d}))||0===b)c+=b;return c+"\n </td>\n </tr>\n "},b),data:b}))||0===m)c+=m;c+="\n <tr>\n <td><strong>"+r((d=e.l10n||a&&a.l10n,h={hash:{},data:b},
|
||||
d?d.call(a,"form.field.message",h):q.call(a,"l10n","form.field.message",h)))+':</strong></td>\n <td valign="top">\n <textarea name="message" tabindex="0" cols="40" rows="5">';(d=e.message)?m=d.call(a,{hash:{},data:b}):(d=a&&a.message,m=typeof d===s?d.call(a,{hash:{},data:b}):d);c+=r(m)+"</textarea>\n </td>\n </tr>\n ";if((m=e["if"].call(a,a&&a.showCaptcha,{hash:{},inverse:p.noop,fn:p.program(11,function(a,c){return'\n <tr>\n <td><img id="captcha-img" src="captcha.php"/></td>\n <td><input type="text" name="captcha" size="50" maxlength="15" value="" class="username"/></td>\n </tr>\n '},
|
||||
d?d.call(a,"form.field.message",h):q.call(a,"l10n","form.field.message",h)))+':</strong></td>\n <td valign="top">\n <textarea name="message" tabindex="0" cols="40" rows="5">';(d=e.message)?m=d.call(a,{hash:{},data:b}):(d=a&&a.message,m=typeof d===s?d.call(a,{hash:{},data:b}):d);c+=r(m)+"</textarea>\n </td>\n </tr>\n ";if((m=e["if"].call(a,a&&a.showCaptcha,{hash:{},inverse:p.noop,fn:p.program(11,function(a,c){return'\n <tr>\n <td><img id="captcha-img" src="captcha"/></td>\n <td><input type="text" name="captcha" size="50" maxlength="15" value="" class="username"/></td>\n </tr>\n '},
|
||||
b),data:b}))||0===m)c+=m;return c+='\n </table>\n <a href="javascript:void(0);" class="but" id="send-message">'+r((d=e.l10n||a&&a.l10n,h={hash:{},data:b},d?d.call(a,"mailthread.perform",h):q.call(a,"l10n","mailthread.perform",h)))+'</a>\n <div class="clear"> </div>\n</form>\n<div id="ajax-loader"><img src="'+r((m=(m=a&&a.page,null==m||!1===m?m:m.tplRoot),typeof m===s?m.apply(a):m))+'/images/ajax-loader.gif" alt="Loading..." /></div>'});v.leave_message_layout=u(function(c,a,e,d,b){this.compilerInfo=
|
||||
[4,">= 1.0.0"];e=this.merge(e,c.helpers);d=this.merge(d,c.partials);b=b||{};c="\n";if((a=this.invokePartial(d._logo,"_logo",a,e,d,b))||0===a)c+=a;return c+'\n\n\n<div id="headers">\n <div class="wndb"><div class="wndl"><div class="wndr"><div class="wndt"><div class="wndtl"><div class="wndtr"><div class="wndbl"><div class="wndbr" id="description-region">\n </div></div></div></div></div></div></div></div>\n</div>\n\n\n<div id="content-wrapper"></div>'});v.leave_message_sent_description=u(function(c,
|
||||
a,e,d,b){this.compilerInfo=[4,">= 1.0.0"];e=this.merge(e,c.helpers);b=b||{};var g,k,l;c=e.helperMissing;d=this.escapeExpression;return a=""+('<div class="buttons">\n <a href="javascript:window.close();" title="'+d((k=e.l10n||a&&a.l10n,l={hash:{},data:b},k?k.call(a,"chat.mailthread.sent.close",l):c.call(a,"l10n","chat.mailthread.sent.close",l)))+'">\n <img class="tpl-image iclosewin" src="'+d((g=(g=a&&a.page,null==g||!1===g?g:g.tplRoot),"function"===typeof g?g.apply(a):g))+'/images/free.gif" alt="'+
|
||||
|
@ -41,7 +41,7 @@
|
||||
</tr>
|
||||
{{#if showCaptcha}}
|
||||
<tr>
|
||||
<td><img id="captcha-img" src="captcha.php"/></td>
|
||||
<td><img id="captcha-img" src="captcha"/></td>
|
||||
<td><input type="text" name="captcha" size="50" maxlength="15" value="" class="username"/></td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
|
Loading…
Reference in New Issue
Block a user