for oldposts:
// Get $searchType from the input, where oldmsgID=>oldposts
$searchType = "oldposts"; // by oldmsgID
// Get $ID from the input (should be >= 1)
// $ID = "28228";
$ID = "25000030";
$dirName = (strlen($ID) <= 5 ? "0" : substr($ID, 0, -5));
// $pageName = substr($ID, -2);
$pageName = (strlen($ID) < 5 ? "0xx" : substr($ID, 0, -2) . "xx");
$url = "http://loyce.club/archive/$searchType/$dirName/$pageName.html#msg$ID";
echo $url;
// http://loyce.club/archive/oldposts/0/282xx.html#msg28228
// http://loyce.club/archive/oldposts/250/250000xx.html#msg25000030
And by adding
posts, topics and members we get:
$urlBase = "http://loyce.club/archive";
// Get $searchType from the input, where oldmsgID=>oldposts, msgID=>posts, topicID=>topics and userID=>members
$searchType = "posts"; // by msgID
// Get $ID from the input (should be >= 1)
$ID = "28228";
$countDigits = ($searchType === "oldposts" ? 5 : 4);
$dirName = (strlen($ID) <= $countDigits ? "0" : substr($ID, 0, -$countDigits));
$pageName = (strlen($ID) < $countDigits ? "0xx" : substr($ID, 0, -2) . "xx");
$url = ($searchType === "oldposts" ? "$urlBase/$searchType/$dirName/$pageName.html#msg$ID" : "$urlBase/$searchType/$dirName/$ID.html");
echo $url;
What is the logic of detecting low/high post numbers?