1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace jumper423\decaptcha\services; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class RuCaptchaFunCaptcha. |
7
|
|
|
*/ |
8
|
|
|
class RuCaptchaFunCaptcha extends RuCaptcha |
9
|
|
|
{ |
10
|
|
|
public function init() |
11
|
|
|
{ |
12
|
|
|
parent::init(); |
13
|
|
|
|
14
|
|
|
unset( |
15
|
|
|
$this->paramsNames[static::ACTION_FIELD_FILE], |
16
|
|
|
$this->paramsNames[static::ACTION_FIELD_PHRASE], |
17
|
|
|
$this->paramsNames[static::ACTION_FIELD_REGSENSE], |
18
|
|
|
$this->paramsNames[static::ACTION_FIELD_NUMERIC], |
19
|
|
|
$this->paramsNames[static::ACTION_FIELD_MIN_LEN], |
20
|
|
|
$this->paramsNames[static::ACTION_FIELD_MAX_LEN], |
21
|
|
|
$this->paramsNames[static::ACTION_FIELD_LANGUAGE], |
22
|
|
|
$this->paramsNames[static::ACTION_FIELD_LANG], |
23
|
|
|
$this->paramsNames[static::ACTION_FIELD_QUESTION], |
24
|
|
|
$this->paramsNames[static::ACTION_FIELD_INSTRUCTIONS], |
25
|
|
|
$this->paramsNames[static::ACTION_FIELD_CALC], |
26
|
|
|
$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_FILE], |
27
|
|
|
$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_PHRASE], |
28
|
|
|
$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_REGSENSE], |
29
|
|
|
$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_NUMERIC], |
30
|
|
|
$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_MIN_LEN], |
31
|
|
|
$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_MAX_LEN], |
32
|
|
|
$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_LANGUAGE], |
33
|
|
|
$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_LANG], |
34
|
|
|
$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_QUESTION], |
35
|
|
|
$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_INSTRUCTIONS], |
36
|
|
|
$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_CALC] |
37
|
|
|
); |
38
|
|
|
|
39
|
|
|
$this->paramsNames[static::ACTION_FIELD_PUBLICKEY] = 'publickey'; |
40
|
|
|
$this->paramsNames[static::ACTION_FIELD_NOJS] = 'nojs'; |
41
|
|
|
$this->paramsNames[static::ACTION_FIELD_USERAGENT] = 'userAgent'; |
42
|
|
|
$this->paramsNames[static::ACTION_FIELD_PAGEURL] = 'pageurl'; |
43
|
|
|
|
44
|
|
|
$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_METHOD][static::PARAM_SLUG_DEFAULT] = 'funcaptcha'; |
45
|
|
|
$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_PUBLICKEY] = [ |
46
|
|
|
static::PARAM_SLUG_REQUIRE => true, |
47
|
|
|
static::PARAM_SLUG_TYPE => static::PARAM_FIELD_TYPE_STRING, |
48
|
|
|
]; |
49
|
|
|
$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_PAGEURL] = [ |
50
|
|
|
static::PARAM_SLUG_REQUIRE => true, |
51
|
|
|
static::PARAM_SLUG_TYPE => static::PARAM_FIELD_TYPE_STRING, |
52
|
|
|
]; |
53
|
|
|
$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_NOJS] = [ |
54
|
|
|
static::PARAM_SLUG_TYPE => static::PARAM_FIELD_TYPE_INTEGER, |
55
|
|
|
static::PARAM_SLUG_DEFAULT => 0, |
56
|
|
|
static::PARAM_SLUG_ENUM => [ |
57
|
|
|
0, |
58
|
|
|
1, |
59
|
|
|
], |
60
|
|
|
]; |
61
|
|
|
$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_USERAGENT] = [ |
62
|
|
|
static::PARAM_SLUG_TYPE => static::PARAM_FIELD_TYPE_STRING, |
63
|
|
|
]; |
64
|
|
|
$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_PROXY] = [ |
65
|
|
|
static::PARAM_SLUG_TYPE => static::PARAM_FIELD_TYPE_STRING, |
66
|
|
|
]; |
67
|
|
|
$this->actions[static::ACTION_RECOGNIZE][static::ACTION_FIELDS][static::ACTION_FIELD_PROXYTYPE] = [ |
68
|
|
|
static::PARAM_SLUG_TYPE => static::PARAM_FIELD_TYPE_STRING, |
69
|
|
|
]; |
70
|
|
|
|
71
|
|
|
$this->wiki->setText(['service', 'name'], [ |
72
|
|
|
'ru' => 'RuCaptcha FunCaptcha', |
73
|
|
|
'en' => 'RuCaptcha FunCaptcha', |
74
|
|
|
]); |
75
|
|
|
$this->wiki->setText(['recognize', 'price'], [ |
76
|
|
|
'ru' => '1000 решений стоят 39 рублей.', |
77
|
|
|
'en' => '1000 for $0,7', |
78
|
|
|
]); |
79
|
|
|
$this->wiki->setText(['recognize', 'desc'], [ |
80
|
|
|
'ru' => '1) Вам нужно найти публичный ключ FunCaptcha. Есть два способа это сделать: вы можете найти div с FunCaptcha и посмотреть на значение параметра data-pkey или же найти элемент с именем (name) fc-token, а из его значения вырезать ключ, который указан после pk. |
81
|
|
|
|
82
|
|
|
2) Узакать эти параметры в методе recognize |
83
|
|
|
|
84
|
|
|
3) Найдите элемент с id fc-token и измените его значение (value) на полученый CODE. |
85
|
|
|
|
86
|
|
|
Важно: если вы используете параметр nojs=1, то API вернёт лишь часть токена в таком виде: 3084f4a302b176cd7.96368058|r=ap-southeast-1 и вам нужно собрать весь токен целиком самостоятельно, используя оригинальное значение fc-token.', |
87
|
|
|
'en' => '1) You need to find the public key FunCaptcha. There are two ways to do this: you can find a div with FunCaptcha and look at the value of the data-pkey parameter, or find an element with the name (name) fc-token, and from its value cut the key that is specified after pk. |
88
|
|
|
|
89
|
|
|
2) See these parameters in the method recognize |
90
|
|
|
|
91
|
|
|
3) Find the element with the id fc-token and change its value to the resulting CODE. |
92
|
|
|
|
93
|
|
|
Important: if you use the nojs = 1 parameter, the API will return only a part of the token in this form: 3084f4a302b176cd7.96368058 | r = ap-southeast-1 and you need to collect the entire token entirely by yourself, using the original fc-token value.', |
94
|
|
|
]); |
95
|
|
|
$this->wiki->setText(['field', 'slug', static::PARAM_SLUG_ENUM, static::ACTION_FIELD_NOJS], [ |
96
|
|
|
'ru' => [ |
97
|
|
|
'0 - использовать JavaScript', |
98
|
|
|
'1 - не использовать JavaScript', |
99
|
|
|
], |
100
|
|
|
'en' => [ |
101
|
|
|
'0 - use javascript', |
102
|
|
|
'1 - do not use javascript', |
103
|
|
|
], |
104
|
|
|
]); |
105
|
|
|
$this->wiki->setText(['recognize', 'data'], [ |
106
|
|
|
static::ACTION_FIELD_PAGEURL => 'http://mysite.com/page/with/funcaptcha/', |
107
|
|
|
static::ACTION_FIELD_PUBLICKEY => '12AB34CD-56F7-AB8C-9D01-2EF3456789A0', |
108
|
|
|
]); |
109
|
|
|
$this->wiki->setText(['recognize', 'file'], false); |
110
|
|
|
$this->wiki->setText(['menu', 'from_service'], [ |
111
|
|
|
RuCaptcha::class, |
112
|
|
|
RuCaptchaClick::class, |
113
|
|
|
RuCaptchaInstruction::class, |
114
|
|
|
RuCaptchaGrid::class, |
115
|
|
|
RuCaptchaReCaptcha::class, |
116
|
|
|
RuCaptchaFunCaptcha::class, |
117
|
|
|
RuCaptchaReCaptchaV3::class, |
118
|
|
|
RuCaptchaGeeTest::class, |
119
|
|
|
]); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function recognize($additionally = [], $null = null) |
123
|
|
|
{ |
124
|
|
|
return parent::recognize(null, $additionally); |
125
|
|
|
} |
126
|
|
|
} |
127
|
|
|
|