-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1ed38a
commit 1150403
Showing
9 changed files
with
476 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Silvio Clecio | ||
Luciano Souza | ||
Joao Morais |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
Captcha plugin. | ||
|
||
Copyright (C) 2013 Silvio Clecio - silvioprog@gmail.com | ||
|
||
This library is free software; you can redistribute it and/or modify it | ||
under the terms of the GNU Library General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or (at your | ||
option) any later version with the following modification: | ||
|
||
As a special exception, the copyright holders of this library give you | ||
permission to link this library with independent modules to produce an | ||
executable, regardless of the license terms of these independent modules,and | ||
to copy and distribute the resulting executable under terms of your choice, | ||
provided that you also meet, for each linked independent module, the terms | ||
and conditions of the license of that module. An independent module is a | ||
module which is not derived from or based on this library. If you modify | ||
this library, you may extend this exception to your version of the library, | ||
but you are not obligated to do so. If you do not wish to do so, delete this | ||
exception statement from your version. | ||
|
||
This program is distributed in the hope that it will be useful, but WITHOUT | ||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License | ||
for more details. | ||
|
||
You should have received a copy of the GNU Library General Public License | ||
along with this library; if not, write to the Free Software Foundation, | ||
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Captcha plugin | ||
============== | ||
|
||
Nowadays, Pascal is fully immersed in web development world. Therefore, it faces the severe issue of spams. | ||
This plugin provides the handling of verification images, usually to block the free and automatic access in login pages. | ||
|
||
Installation | ||
============ | ||
|
||
1. Open the package "captchapkg.lpk", in the dialog that opens, click in "Use >>" and "Add to Project"; | ||
|
||
Steps to run this demo | ||
====================== | ||
|
||
On Windows, copy the DLLs "freetype-6.dll" and "zlib1.dll" and the font "LiberationSerif-Regular.ttf" to your project folder. | ||
|
||
On Linux, copy the font "LiberationSerif-Regular.ttf" to your project folder. | ||
|
||
Enjoy! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
unit Brokers; | ||
|
||
{$mode objfpc}{$H+} | ||
|
||
interface | ||
|
||
uses | ||
BrookFCLCGIBroker; | ||
|
||
implementation | ||
|
||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<CONFIG> | ||
<ProjectOptions> | ||
<Version Value="9"/> | ||
<PathDelim Value="\"/> | ||
<General> | ||
<Flags> | ||
<SaveOnlyProjectUnits Value="True"/> | ||
<Runnable Value="False"/> | ||
</Flags> | ||
<MainUnit Value="0"/> | ||
<UseAppBundle Value="False"/> | ||
<ResourceType Value="res"/> | ||
<ActiveWindowIndexAtStart Value="0"/> | ||
</General> | ||
<i18n> | ||
<EnableI18N LFM="False"/> | ||
</i18n> | ||
<VersionInfo> | ||
<StringTable ProductVersion=""/> | ||
</VersionInfo> | ||
<BuildModes Count="1" Active="Default"> | ||
<Item1 Name="Default" Default="True"/> | ||
</BuildModes> | ||
<PublishOptions> | ||
<Version Value="2"/> | ||
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/> | ||
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/> | ||
</PublishOptions> | ||
<RunParams> | ||
<local> | ||
<FormatVersion Value="1"/> | ||
</local> | ||
</RunParams> | ||
<RequiredPackages Count="3"> | ||
<Item1> | ||
<PackageName Value="CaptchaPkg"/> | ||
</Item1> | ||
<Item2> | ||
<PackageName Value="RUtilsPkg"/> | ||
</Item2> | ||
<Item3> | ||
<PackageName Value="BrookRT"/> | ||
</Item3> | ||
</RequiredPackages> | ||
<Units Count="3"> | ||
<Unit0> | ||
<Filename Value="cgi1.lpr"/> | ||
<IsPartOfProject Value="True"/> | ||
<UnitName Value="cgi1"/> | ||
<IsVisibleTab Value="True"/> | ||
<EditorIndex Value="0"/> | ||
<WindowIndex Value="0"/> | ||
<TopLine Value="1"/> | ||
<CursorPos X="1" Y="1"/> | ||
<UsageCount Value="20"/> | ||
<Loaded Value="True"/> | ||
</Unit0> | ||
<Unit1> | ||
<Filename Value="test.pas"/> | ||
<IsPartOfProject Value="True"/> | ||
<UnitName Value="test"/> | ||
<UsageCount Value="20"/> | ||
</Unit1> | ||
<Unit2> | ||
<Filename Value="brokers.pas"/> | ||
<IsPartOfProject Value="True"/> | ||
<UnitName Value="Brokers"/> | ||
<UsageCount Value="20"/> | ||
</Unit2> | ||
</Units> | ||
</ProjectOptions> | ||
<CompilerOptions> | ||
<Version Value="11"/> | ||
<PathDelim Value="\"/> | ||
<Target> | ||
<Filename Value="cgi1.bf" ApplyConventions="False"/> | ||
</Target> | ||
<SearchPaths> | ||
<IncludeFiles Value="$(ProjOutDir)"/> | ||
</SearchPaths> | ||
<CodeGeneration> | ||
<Optimizations> | ||
<OptimizationLevel Value="2"/> | ||
</Optimizations> | ||
</CodeGeneration> | ||
<Other> | ||
<CompilerMessages> | ||
<MsgFileName Value=""/> | ||
</CompilerMessages> | ||
<CompilerPath Value="$(CompPath)"/> | ||
</Other> | ||
</CompilerOptions> | ||
<Debugging> | ||
<Exceptions Count="3"> | ||
<Item1> | ||
<Name Value="EAbort"/> | ||
</Item1> | ||
<Item2> | ||
<Name Value="ECodetoolError"/> | ||
</Item2> | ||
<Item3> | ||
<Name Value="EFOpenError"/> | ||
</Item3> | ||
</Exceptions> | ||
</Debugging> | ||
<EditorMacros Count="0"/> | ||
</CONFIG> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
program cgi1; | ||
|
||
{$mode objfpc}{$H+} | ||
|
||
uses | ||
BrookApplication, Brokers, test; | ||
|
||
begin | ||
BrookApp.Run; | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
unit test; | ||
|
||
{$mode objfpc}{$H+} | ||
|
||
interface | ||
|
||
uses | ||
BrookAction, Captcha, RUtils, Classes, SysUtils; | ||
|
||
type | ||
TTest = class(TBrookAction) | ||
public | ||
procedure Get; override; | ||
procedure Post; override; | ||
end; | ||
|
||
const | ||
FORM = | ||
'<!DOCTYPE HTML>'+lf+ | ||
'<html lang="pt-BR">'+lf+ | ||
'<head>'+lf+ | ||
' <meta charset="UTF-8">'+lf+ | ||
' <title></title>'+lf+ | ||
'</head>'+lf+ | ||
'<body>'+lf+ | ||
'<img src="data:image/gif;base64,%s"/>'+lf+ | ||
' <form autocomplete="off" action="" method="post">'+lf+ | ||
' <input type="text" name="captcha"/>'+lf+ | ||
' <input type="submit"/>'+lf+ | ||
' </form>'+lf+ | ||
'</body>'+lf+ | ||
'</html>'; | ||
|
||
implementation | ||
|
||
uses | ||
FPWritePNG; | ||
|
||
procedure TTest.Get; | ||
var | ||
VImage: TMemoryImage; | ||
VStream: TMemoryStream; | ||
begin | ||
if not TCaptcha.FontExists(ftLiberationSerifRegularTTF) then | ||
Exit; | ||
VImage := TMemoryImage.Create; | ||
VStream := TMemoryStream.Create; | ||
try | ||
SetCookie('captcha', TCaptcha.Generate(VStream)); | ||
VStream.Seek(0, 0); | ||
Write(FORM, [StreamToBase64(VStream)]); | ||
finally | ||
VStream.Free; | ||
VImage.Free; | ||
end; | ||
end; | ||
|
||
procedure TTest.Post; | ||
begin | ||
if SameText(Fields.Values['captcha'], GetCookie('captcha')) then | ||
Write('OK') | ||
else | ||
Write('Fail'); | ||
end; | ||
|
||
initialization | ||
TTest.Register('*'); | ||
|
||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<CONFIG> | ||
<Package Version="4"> | ||
<PathDelim Value="\"/> | ||
<Name Value="CaptchaPkg"/> | ||
<Author Value="Silvio Clecio - http://silvioprog.com.br"/> | ||
<CompilerOptions> | ||
<Version Value="11"/> | ||
<PathDelim Value="\"/> | ||
<SearchPaths> | ||
<OtherUnitFiles Value="..\src"/> | ||
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/> | ||
</SearchPaths> | ||
<Other> | ||
<CompilerMessages> | ||
<MsgFileName Value=""/> | ||
</CompilerMessages> | ||
<CompilerPath Value="$(CompPath)"/> | ||
</Other> | ||
</CompilerOptions> | ||
<Description Value="Nowadays, Pascal is fully immersed in web development world. Therefore, it faces the severe issue of spams. | ||
This plugin provides the handling of verification images, usually to block the free and automatic access in login pages."/> | ||
<License Value="Please see the LICENSE file."/> | ||
<Version Major="1"/> | ||
<Files Count="1"> | ||
<Item1> | ||
<Filename Value="..\src\captcha.pas"/> | ||
<UnitName Value="Captcha"/> | ||
</Item1> | ||
</Files> | ||
<Type Value="RunTimeOnly"/> | ||
<RequiredPkgs Count="1"> | ||
<Item1> | ||
<PackageName Value="FCL"/> | ||
</Item1> | ||
</RequiredPkgs> | ||
<UsageOptions> | ||
<UnitPath Value="$(PkgOutDir)"/> | ||
</UsageOptions> | ||
<PublishOptions> | ||
<Version Value="2"/> | ||
</PublishOptions> | ||
</Package> | ||
</CONFIG> |
Oops, something went wrong.