New “gettlds();” version and some related changes
This commit is contained in:
parent
1b939b6dc0
commit
d485b65f68
3 changed files with 1540 additions and 45 deletions
21
index.php
21
index.php
|
@ -17,12 +17,18 @@
|
|||
|
||||
// Logorrh, Verbose, Charliero, Tashugo?
|
||||
|
||||
$dodebug=false;
|
||||
$debug='';
|
||||
|
||||
require 'lib/gettlds.php';
|
||||
$tlds=gettlds();
|
||||
$retlds=implode('|',$tlds);
|
||||
$jstlds="const tlds=['".implode("', '",$tlds)."'];\n";
|
||||
if (@file_put_contents('js/tlds.js',$jstlds)===false)
|
||||
dieyoung('Error: could not save «js/tlds.js»');
|
||||
$tlds=gettlds('storage/tlds.txt',false);// we don't get them in "regex format" because we need them for js too, so we'll rsort them later
|
||||
if (!is_null($tlds['warnings'])) $debug.="GetTLDs warning: {$tlds['warnings']}.<br>\n";
|
||||
rsort($tlds);
|
||||
$retlds=implode('|',$tlds['tlds']);
|
||||
$jstlds="const tlds=['".implode("', '",$tlds['tlds'])."'];\n";
|
||||
$jstldsfp='storage/tlds.js';
|
||||
if (@file_put_contents($jstldsfp,$jstlds)===false)
|
||||
dieyoung("Error: could not save «{$jstldsfp}»");
|
||||
unset($tlds,$jstlds);
|
||||
require 'lib/mastodon.php';
|
||||
require 'lib/ckratelimit.php';
|
||||
|
@ -49,9 +55,6 @@ $now=time();
|
|||
$timeout=5;
|
||||
$formact=preg_replace('#[^/]+$#','',$_SERVER['REQUEST_URI']);
|
||||
|
||||
$dodebug=false;
|
||||
$debug='';
|
||||
|
||||
ini_set('max_execution_time',360);// 6 minutes: default mastodon ratelimits: https://docs.joinmastodon.org/api/rate-limits/
|
||||
$conf=['link'=>"\n\n[This post was split using ".SREPO.']'];
|
||||
if (file_exists(CONFFN)) {
|
||||
|
@ -492,7 +495,7 @@ echo "<!DOCTYPE HTML>
|
|||
<link rel=\"icon\" type=\"image/png\" href=\"imgs/icon-512.png\" sizes=\"512x512\">
|
||||
<link rel=\"apple-touch-icon-precomposed\" href=\"imgs/icon-180.png\">
|
||||
<link rel=\"stylesheet\" type=\"text/css\" href=\"css/main.css?v={$svers}\">
|
||||
<script language=\"JavaScript\" src=\"js/tlds.js?v={$svers}\"></script>
|
||||
<script language=\"JavaScript\" src=\"{$jstldsfp}?v={$svers}\"></script>
|
||||
<script language=\"JavaScript\" src=\"js/main.js?v={$svers}\"></script>
|
||||
<script language=\"JavaScript\">
|
||||
function swpdisp(elem,defdisp,altdisp) {
|
||||
|
|
1560
lib/gettlds.php
1560
lib/gettlds.php
File diff suppressed because one or more lines are too long
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
// Warning: postlength function requires $retlds global variable to be defined,
|
||||
// it has to be a reverse ordered list of "|" separated valid tlds, you can
|
||||
// require gettlds.php in the calling script and use it to set it, like this:
|
||||
// $retlds=gettlds(); $retlds=implode('|',$retlds);
|
||||
// it has to be a reverse ordered list of valid tlds separated by "|", you can
|
||||
// require gettlds.php in the calling script and use it to set it like this:
|
||||
// $retlds=gettlds($path_to_tlds_cache_file,true);
|
||||
|
||||
function validtoken($token) {
|
||||
if (preg_match('#^[A-Za-z0-9_-]{43}$#',$token)===1)
|
||||
|
|
Loading…
Reference in a new issue