Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Rotua Panjaitan
yii2
Commits
3d5388ff
Commit
3d5388ff
authored
Aug 03, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reorganized captcha code.
parent
9f4ccb62
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
36 additions
and
25 deletions
+36
-25
SiteController.php
apps/advanced/frontend/controllers/SiteController.php
+1
-1
contact.php
apps/advanced/frontend/views/site/contact.php
+1
-1
SiteController.php
apps/basic/controllers/SiteController.php
+1
-1
contact.php
apps/basic/views/site/contact.php
+1
-1
assets.php
framework/yii/assets.php
+1
-1
yii.captcha.js
framework/yii/assets/yii.captcha.js
+1
-1
Model.php
framework/yii/base/Model.php
+2
-2
Captcha.php
framework/yii/captcha/Captcha.php
+3
-2
CaptchaAction.php
framework/yii/captcha/CaptchaAction.php
+6
-5
CaptchaAsset.php
framework/yii/captcha/CaptchaAsset.php
+2
-1
CaptchaValidator.php
framework/yii/captcha/CaptchaValidator.php
+4
-2
SpicyRice.md
framework/yii/captcha/SpicyRice.md
+0
-0
SpicyRice.ttf
framework/yii/captcha/SpicyRice.ttf
+0
-0
classes.php
framework/yii/classes.php
+11
-5
Validator.php
framework/yii/validators/Validator.php
+1
-1
Singer.php
tests/unit/data/base/Singer.php
+1
-1
No files found.
apps/advanced/frontend/controllers/SiteController.php
View file @
3d5388ff
...
...
@@ -16,7 +16,7 @@ class SiteController extends Controller
{
return
array
(
'captcha'
=>
array
(
'class'
=>
'yii\
web
\CaptchaAction'
,
'class'
=>
'yii\
captcha
\CaptchaAction'
,
),
);
}
...
...
apps/advanced/frontend/views/site/contact.php
View file @
3d5388ff
<?php
use
yii\helpers\Html
;
use
yii\widgets\ActiveForm
;
use
yii\
widgets
\Captcha
;
use
yii\
captcha
\Captcha
;
/**
* @var yii\base\View $this
...
...
apps/basic/controllers/SiteController.php
View file @
3d5388ff
...
...
@@ -13,7 +13,7 @@ class SiteController extends Controller
{
return
array
(
'captcha'
=>
array
(
'class'
=>
'yii\
web
\CaptchaAction'
,
'class'
=>
'yii\
captcha
\CaptchaAction'
,
'fixedVerifyCode'
=>
YII_ENV_DEV
?
'testme'
:
null
,
),
);
...
...
apps/basic/views/site/contact.php
View file @
3d5388ff
<?php
use
yii\helpers\Html
;
use
yii\widgets\ActiveForm
;
use
yii\
widgets
\Captcha
;
use
yii\
captcha
\Captcha
;
/**
* @var yii\base\View $this
...
...
framework/yii/assets.php
View file @
3d5388ff
...
...
@@ -6,6 +6,6 @@ return array(
yii\validators\PunycodeAsset
::
className
(),
yii\validators\ValidationAsset
::
className
(),
yii\widgets\ActiveFormAsset
::
className
(),
yii\
widgets
\CaptchaAsset
::
className
(),
yii\
captcha
\CaptchaAsset
::
className
(),
yii\widgets\MaskedInputAsset
::
className
(),
);
framework/yii/assets/yii.captcha.js
View file @
3d5388ff
/**
* Yii Captcha widget.
*
* This is the JavaScript widget used by the yii\
widgets
\Captcha widget.
* This is the JavaScript widget used by the yii\
captcha
\Captcha widget.
*
* @link http://www.yiiframework.com/
* @copyright Copyright (c) 2008 Yii Software LLC
...
...
framework/yii/base/Model.php
View file @
3d5388ff
...
...
@@ -117,8 +117,8 @@ class Model extends Component implements \IteratorAggregate, \ArrayAccess
* array('password', 'compare', 'compareAttribute' => 'password2', 'on' => 'register'),
* // an inline validator defined via the "authenticate()" method in the model class
* array('password', 'authenticate', 'on' => 'login'),
* // a validator of class "
Captcha
Validator"
* array('
captcha', 'Captcha
Validator'),
* // a validator of class "
DateRange
Validator"
* array('
dateRange', 'DateRange
Validator'),
* );
* ~~~
*
...
...
framework/yii/
widgets
/Captcha.php
→
framework/yii/
captcha
/Captcha.php
View file @
3d5388ff
...
...
@@ -5,13 +5,14 @@
* @license http://www.yiiframework.com/license/
*/
namespace
yii\
widgets
;
namespace
yii\
Captcha
;
use
Yii
;
use
yii\base\InvalidConfigException
;
use
yii\helpers\Html
;
use
yii\helpers\Json
;
use
yii\web\CaptchaAction
;
use
yii\widgets\InputWidget
;
/**
* Captcha renders a CAPTCHA image and an input field that takes user-entered verification code.
...
...
framework/yii/
web
/CaptchaAction.php
→
framework/yii/
captcha
/CaptchaAction.php
View file @
3d5388ff
...
...
@@ -5,12 +5,11 @@
* @license http://www.yiiframework.com/license/
*/
namespace
yii\
web
;
namespace
yii\
captcha
;
use
Yii
;
use
yii\base\Action
;
use
yii\base\InvalidConfigException
;
use
yii\widgets\Captcha
;
/**
* CaptchaAction renders a CAPTCHA image.
...
...
@@ -85,7 +84,7 @@ class CaptchaAction extends Action
/**
* @var string the TrueType font file. This can be either a file path or path alias.
*/
public
$fontFile
=
'@yii/
web
/SpicyRice.ttf'
;
public
$fontFile
=
'@yii/
captcha
/SpicyRice.ttf'
;
/**
* @var string the fixed verification code. When this property is set,
* [[getVerifyCode()]] will always return the value of this property.
...
...
@@ -116,12 +115,14 @@ class CaptchaAction extends Action
if
(
isset
(
$_GET
[
self
::
REFRESH_GET_VAR
]))
{
// AJAX request for regenerating code
$code
=
$this
->
getVerifyCode
(
true
);
/** @var \yii\web\Controller $controller */
$controller
=
$this
->
controller
;
return
json_encode
(
array
(
'hash1'
=>
$this
->
generateValidationHash
(
$code
),
'hash2'
=>
$this
->
generateValidationHash
(
strtolower
(
$code
)),
// we add a random 'v' parameter so that FireFox can refresh the image
// when src attribute of image tag is changed
'url'
=>
$
this
->
controller
->
createUrl
(
$this
->
id
,
array
(
'v'
=>
uniqid
())),
'url'
=>
$controller
->
createUrl
(
$this
->
id
,
array
(
'v'
=>
uniqid
())),
));
}
else
{
$this
->
setHttpHeaders
();
...
...
@@ -153,7 +154,7 @@ class CaptchaAction extends Action
return
$this
->
fixedVerifyCode
;
}
$session
=
Yii
::
$app
->
session
;
$session
=
Yii
::
$app
->
getSession
()
;
$session
->
open
();
$name
=
$this
->
getSessionKey
();
if
(
$session
[
$name
]
===
null
||
$regenerate
)
{
...
...
framework/yii/
widgets
/CaptchaAsset.php
→
framework/yii/
captcha
/CaptchaAsset.php
View file @
3d5388ff
...
...
@@ -5,7 +5,8 @@
* @license http://www.yiiframework.com/license/
*/
namespace
yii\widgets
;
namespace
yii\captcha
;
use
yii\web\AssetBundle
;
/**
...
...
framework/yii/
validators
/CaptchaValidator.php
→
framework/yii/
captcha
/CaptchaValidator.php
View file @
3d5388ff
...
...
@@ -5,11 +5,13 @@
* @license http://www.yiiframework.com/license/
*/
namespace
yii\
validators
;
namespace
yii\
captcha
;
use
Yii
;
use
yii\base\InvalidConfigException
;
use
yii\helpers\Html
;
use
yii\validators\ValidationAsset
;
use
yii\validators\Validator
;
/**
* CaptchaValidator validates that the attribute value is the same as the verification code displayed in the CAPTCHA.
...
...
@@ -74,7 +76,7 @@ class CaptchaValidator extends Validator
/**
* Returns the CAPTCHA action object.
* @throws InvalidConfigException
* @return \yii\
web
\CaptchaAction the action object
* @return \yii\
captcha
\CaptchaAction the action object
*/
public
function
getCaptchaAction
()
{
...
...
framework/yii/
web
/SpicyRice.md
→
framework/yii/
captcha
/SpicyRice.md
View file @
3d5388ff
File moved
framework/yii/
web
/SpicyRice.ttf
→
framework/yii/
captcha
/SpicyRice.ttf
View file @
3d5388ff
File moved
framework/yii/classes.php
View file @
3d5388ff
...
...
@@ -91,6 +91,10 @@ return array(
'yii\caching\WinCache'
=>
YII_PATH
.
'/caching/WinCache.php'
,
'yii\caching\XCache'
=>
YII_PATH
.
'/caching/XCache.php'
,
'yii\caching\ZendDataCache'
=>
YII_PATH
.
'/caching/ZendDataCache.php'
,
'yii\captcha\Captcha'
=>
YII_PATH
.
'/captcha/Captcha.php'
,
'yii\captcha\CaptchaAction'
=>
YII_PATH
.
'/captcha/CaptchaAction.php'
,
'yii\captcha\CaptchaAsset'
=>
YII_PATH
.
'/captcha/CaptchaAsset.php'
,
'yii\captcha\CaptchaValidator'
=>
YII_PATH
.
'/captcha/CaptchaValidator.php'
,
'yii\data\ActiveDataProvider'
=>
YII_PATH
.
'/data/ActiveDataProvider.php'
,
'yii\data\ArrayDataProvider'
=>
YII_PATH
.
'/data/ArrayDataProvider.php'
,
'yii\data\DataProvider'
=>
YII_PATH
.
'/data/DataProvider.php'
,
...
...
@@ -167,7 +171,6 @@ return array(
'yii\rbac\PhpManager'
=>
YII_PATH
.
'/rbac/PhpManager.php'
,
'yii\requirements\YiiRequirementChecker'
=>
YII_PATH
.
'/requirements/YiiRequirementChecker.php'
,
'yii\validators\BooleanValidator'
=>
YII_PATH
.
'/validators/BooleanValidator.php'
,
'yii\validators\CaptchaValidator'
=>
YII_PATH
.
'/validators/CaptchaValidator.php'
,
'yii\validators\CompareValidator'
=>
YII_PATH
.
'/validators/CompareValidator.php'
,
'yii\validators\DateValidator'
=>
YII_PATH
.
'/validators/DateValidator.php'
,
'yii\validators\DefaultValueValidator'
=>
YII_PATH
.
'/validators/DefaultValueValidator.php'
,
...
...
@@ -193,7 +196,6 @@ return array(
'yii\web\AssetConverter'
=>
YII_PATH
.
'/web/AssetConverter.php'
,
'yii\web\AssetManager'
=>
YII_PATH
.
'/web/AssetManager.php'
,
'yii\web\CacheSession'
=>
YII_PATH
.
'/web/CacheSession.php'
,
'yii\web\CaptchaAction'
=>
YII_PATH
.
'/web/CaptchaAction.php'
,
'yii\web\Controller'
=>
YII_PATH
.
'/web/Controller.php'
,
'yii\web\Cookie'
=>
YII_PATH
.
'/web/Cookie.php'
,
'yii\web\CookieCollection'
=>
YII_PATH
.
'/web/CookieCollection.php'
,
...
...
@@ -225,14 +227,18 @@ return array(
'yii\widgets\ActiveFormAsset'
=>
YII_PATH
.
'/widgets/ActiveFormAsset.php'
,
'yii\widgets\Block'
=>
YII_PATH
.
'/widgets/Block.php'
,
'yii\widgets\Breadcrumbs'
=>
YII_PATH
.
'/widgets/Breadcrumbs.php'
,
'yii\widgets\Captcha'
=>
YII_PATH
.
'/widgets/Captcha.php'
,
'yii\widgets\CaptchaAsset'
=>
YII_PATH
.
'/widgets/CaptchaAsset.php'
,
'yii\widgets\ContentDecorator'
=>
YII_PATH
.
'/widgets/ContentDecorator.php'
,
'yii\widgets\DetailView'
=>
YII_PATH
.
'/widgets/DetailView.php'
,
'yii\widgets\FragmentCache'
=>
YII_PATH
.
'/widgets/FragmentCache.php'
,
'yii\widgets\grid\CheckboxColumn'
=>
YII_PATH
.
'/widgets/grid/CheckboxColumn.php'
,
'yii\widgets\grid\Column'
=>
YII_PATH
.
'/widgets/grid/Column.php'
,
'yii\widgets\grid\DataColumn'
=>
YII_PATH
.
'/widgets/grid/DataColumn.php'
,
'yii\widgets\GridView'
=>
YII_PATH
.
'/widgets/GridView.php'
,
'yii\widgets\InputWidget'
=>
YII_PATH
.
'/widgets/InputWidget.php'
,
'yii\widgets\LinkPager'
=>
YII_PATH
.
'/widgets/LinkPager.php'
,
'yii\widgets\ListPager'
=>
YII_PATH
.
'/widgets/ListPager.php'
,
'yii\widgets\LinkSorter'
=>
YII_PATH
.
'/widgets/LinkSorter.php'
,
'yii\widgets\ListView'
=>
YII_PATH
.
'/widgets/ListView.php'
,
'yii\widgets\ListViewBase'
=>
YII_PATH
.
'/widgets/ListViewBase.php'
,
'yii\widgets\MaskedInput'
=>
YII_PATH
.
'/widgets/MaskedInput.php'
,
'yii\widgets\MaskedInputAsset'
=>
YII_PATH
.
'/widgets/MaskedInputAsset.php'
,
'yii\widgets\Menu'
=>
YII_PATH
.
'/widgets/Menu.php'
,
...
...
framework/yii/validators/Validator.php
View file @
3d5388ff
...
...
@@ -49,7 +49,7 @@ abstract class Validator extends Component
*/
public
static
$builtInValidators
=
array
(
'boolean'
=>
'yii\validators\BooleanValidator'
,
'captcha'
=>
'yii\
validators
\CaptchaValidator'
,
'captcha'
=>
'yii\
captcha
\CaptchaValidator'
,
'compare'
=>
'yii\validators\CompareValidator'
,
'date'
=>
'yii\validators\DateValidator'
,
'default'
=>
'yii\validators\DefaultValueValidator'
,
...
...
tests/unit/data/base/Singer.php
View file @
3d5388ff
...
...
@@ -15,7 +15,7 @@ class Singer extends Model
return
array
(
array
(
'lastName'
,
'default'
,
'value'
=>
'Lennon'
),
array
(
'lastName'
,
'required'
),
array
(
'underscore_style'
,
'yii\
validators
\CaptchaValidator'
),
array
(
'underscore_style'
,
'yii\
captcha
\CaptchaValidator'
),
);
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment