2017-01-01 13:31:24 +01:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
Copyright 2016 Daniil Gentili
|
|
|
|
(https://daniil.it)
|
|
|
|
This file is part of MadelineProto.
|
|
|
|
MadelineProto is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
MadelineProto is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License along with MadelineProto.
|
|
|
|
If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
require 'vendor/autoload.php';
|
2017-01-04 13:22:03 +01:00
|
|
|
//require '../db:id.php';
|
2017-01-01 13:31:24 +01:00
|
|
|
|
2017-01-04 13:22:03 +01:00
|
|
|
//$select = $pdo->prepare('SELECT * FROM ul');
|
|
|
|
//$select->execute();
|
|
|
|
//$pdores = $select->fetchAll(PDO::FETCH_ASSOC);
|
2017-01-01 13:31:24 +01:00
|
|
|
|
2017-01-01 15:12:46 +01:00
|
|
|
function foreach_offset_length($string)
|
2017-01-01 13:32:20 +01:00
|
|
|
{
|
2017-01-01 15:12:46 +01:00
|
|
|
$res = [];
|
2017-01-01 13:31:24 +01:00
|
|
|
$strlen = strlen($string);
|
|
|
|
for ($offset = 0; $offset < strlen($string); $offset++) {
|
2017-01-04 13:22:03 +01:00
|
|
|
for ($length = $strlen - $offset; $length > 0; $length--) {
|
2017-01-01 13:31:24 +01:00
|
|
|
$s = substr($string, $offset, $length);
|
2017-01-04 13:22:03 +01:00
|
|
|
$number = (string) (new \phpseclib\Math\BigInteger(strrev($s), 256));
|
|
|
|
//$number = ord($s);
|
2017-01-01 17:13:19 +01:00
|
|
|
$res[] = ['number' => $number, 'offset' => $offset, 'length' => $length];
|
2017-01-01 15:12:46 +01:00
|
|
|
}
|
|
|
|
}
|
2017-01-01 17:13:19 +01:00
|
|
|
|
2017-01-01 15:12:46 +01:00
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
$res = [];
|
2017-01-04 13:22:03 +01:00
|
|
|
$pdores = [['file_id' => 'AwADBAADiQEAAo_aCgYAAc-fglzxcY0C']];
|
2017-01-02 19:50:37 +01:00
|
|
|
foreach ($pdores as $r) {
|
|
|
|
$base256 = base64url_decode($r['file_id']);
|
2017-01-01 15:12:46 +01:00
|
|
|
$res = foreach_offset_length($base256);
|
|
|
|
if (!isset($same)) {
|
|
|
|
$same = $res;
|
|
|
|
} else {
|
|
|
|
foreach ($same as $key => $s) {
|
|
|
|
if (!in_array($s, $res)) {
|
|
|
|
unset($same[$key]);
|
|
|
|
}
|
2017-01-01 13:31:24 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2017-01-04 13:22:03 +01:00
|
|
|
var_dump($res);
|
2017-01-01 13:32:20 +01:00
|
|
|
function base64url_decode($data)
|
|
|
|
{
|
|
|
|
return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT));
|
2017-01-01 13:31:24 +01:00
|
|
|
}
|