enwikipedia-acc /
waca
| 1 | <?php |
||
| 2 | /****************************************************************************** |
||
| 3 | * Wikipedia Account Creation Assistance tool * |
||
| 4 | * ACC Development Team. Please see team.json for a list of contributors. * |
||
| 5 | * * |
||
| 6 | * This is free and unencumbered software released into the public domain. * |
||
| 7 | * Please see LICENSE.md for the full licencing statement. * |
||
| 8 | ******************************************************************************/ |
||
| 9 | |||
| 10 | /** |
||
| 11 | * @param string $input IP address |
||
| 12 | * |
||
| 13 | * @return string Hex representation of IP. |
||
| 14 | */ |
||
| 15 | function smarty_modifier_iphex($input) |
||
| 16 | { |
||
| 17 | $output = $input; |
||
| 18 | |||
| 19 | if (filter_var($input, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) !== false) { |
||
| 20 | $octets = explode('.', $input); |
||
| 21 | $output = ''; |
||
| 22 | foreach ($octets as $octet) { |
||
| 23 | $output .= str_pad(dechex($octet), 2, '0', STR_PAD_LEFT); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 24 | } |
||
| 25 | |||
| 26 | $output = str_pad($output, 32, '0', STR_PAD_LEFT); |
||
| 27 | } |
||
| 28 | |||
| 29 | return $output; |
||
| 30 | } |
||
| 31 |