|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace jumper423\decaptcha\core; |
|
4
|
|
|
|
|
5
|
|
|
use jumper423\decaptcha\services\RuCaptcha; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Class DeCaptchaAbstract. |
|
9
|
|
|
*/ |
|
10
|
|
|
class DeCaptchaWiki |
|
11
|
|
|
{ |
|
12
|
|
|
public function view(){ |
|
13
|
|
|
$rucaptcha = new RuCaptcha([]); |
|
14
|
|
|
/* |
|
15
|
|
|
* Markdown | Less | Pretty |
|
16
|
|
|
--- | --- | --- |
|
17
|
|
|
*Still* | `renders` | **nicely** |
|
18
|
|
|
1 | 2 | 3 |
|
19
|
|
|
* |
|
20
|
|
|
* */ |
|
21
|
|
|
echo " Название | Код | Тип | Обязательное значение | Значение по умолчания | Возможные значения | Описание " . PHP_EOL; |
|
22
|
|
|
echo " --- | --- | --- | --- | --- | ---| --- " . PHP_EOL; |
|
23
|
|
|
$rr = (new \ReflectionClass($rucaptcha))->getConstants(); |
|
24
|
|
|
// print_r($rr); |
|
|
|
|
|
|
25
|
|
|
foreach ($rucaptcha->actions[RuCaptcha::ACTION_RECOGNIZE][RuCaptcha::ACTION_FIELDS] as $param => $setting) { |
|
26
|
|
|
if (array_key_exists(RuCaptcha::PARAM_SLUG_NOTWIKI, $setting) && $setting[RuCaptcha::PARAM_SLUG_NOTWIKI] === true) { |
|
27
|
|
|
continue; |
|
28
|
|
|
} |
|
29
|
|
|
echo " {$this->ggg($rr, 'ACTION_FIELD_', $param)} |"; |
|
30
|
|
|
echo " {$this->ggg($rr, 'ACTION_FIELD_', $param)} |"; |
|
31
|
|
|
echo " ".substr($this->ggg($rr, 'PARAM_FIELD_TYPE_', $setting[RuCaptcha::PARAM_SLUG_TYPE]), 17) ." |"; |
|
32
|
|
|
echo " ".(array_key_exists(RuCaptcha::PARAM_SLUG_REQUIRE, $setting) ? '+' : '-') ." |"; |
|
33
|
|
|
echo " ".(array_key_exists(RuCaptcha::PARAM_SLUG_DEFAULT, $setting) ? $setting[RuCaptcha::PARAM_SLUG_DEFAULT] : '') ." |"; |
|
34
|
|
|
echo " |"; |
|
35
|
|
|
echo " ". PHP_EOL; |
|
36
|
|
|
// echo " --- | --- | --- | --- | ---| --- " . PHP_EOL; |
|
|
|
|
|
|
37
|
|
|
// print_r($params); |
|
38
|
|
|
} |
|
39
|
|
|
// $rr = get_defined_constants(true); |
|
|
|
|
|
|
40
|
|
|
// print_r(array_keys($rr)); |
|
41
|
|
|
// print_r($rr); |
|
42
|
|
|
// file_put_contents(__DIR__ . '/12331123', json_encode(get_defined_constants(true))); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function ggg($constants, $keyMask, $value){ |
|
46
|
|
|
foreach ($constants as $key => $val) { |
|
47
|
|
|
if (stripos($key, $keyMask) !== false && $val === $value) { |
|
48
|
|
|
return $key; |
|
49
|
|
|
} |
|
50
|
|
|
} |
|
51
|
|
|
return null; |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.