'United States', 'DE' => 'Germany', 'GB' => 'United Kingdom', 'FR' => 'France',
'NL' => 'Netherlands', 'CA' => 'Canada', 'SG' => 'Singapore', 'JP' => 'Japan',
'BR' => 'Brazil', 'PL' => 'Poland', 'UA' => 'Ukraine', 'IN' => 'India',
'IT' => 'Italy', 'ES' => 'Spain', 'AU' => 'Australia', 'KR' => 'South Korea',
'HK' => 'Hong Kong', 'SE' => 'Sweden', 'FI' => 'Finland', 'CH' => 'Switzerland',
'AT' => 'Austria', 'CZ' => 'Czechia', 'RO' => 'Romania', 'TR' => 'Turkey',
'ID' => 'Indonesia', 'VN' => 'Vietnam', 'TH' => 'Thailand', 'MX' => 'Mexico',
'AR' => 'Argentina', 'ZA' => 'South Africa',
];
$countryName = $cc !== '' ? ($countryNames[$cc] ?? $cc) : '';
$allJsonPath = '/home/s4m/web/s4m.online/public_html/free-proxies/all.json';
$matchedRows = [];
$totalPoolCount = 0;
if (is_readable($allJsonPath)) {
$decoded = json_decode((string)file_get_contents($allJsonPath), true);
if (is_array($decoded)) {
$totalPoolCount = count($decoded);
foreach ($decoded as $row) {
if (!is_array($row)) continue;
if ($cc !== '' && strtoupper((string)($row['country'] ?? '')) !== $cc) continue;
if ($proto !== '' && strtolower((string)($row['protocol'] ?? '')) !== $proto) continue;
$matchedRows[] = $row;
}
}
}
if ($sample === 1) {
header('Content-Type: text/plain; charset=utf-8');
$fnSuffix = ($cc !== '' ? '-' . strtolower($cc) : '') . ($proto !== '' ? '-' . $proto : '');
header('Content-Disposition: attachment; filename="s4m-proxy-sample' . $fnSuffix . '-20.txt"');
if (!empty($matchedRows)) {
$slice = array_slice($matchedRows, 0, 20);
foreach ($slice as $r) {
echo ($r['ip'] ?? '') . ':' . ($r['port'] ?? '') . "\n";
}
} elseif (is_readable('/home/s4m/web/s4m.online/public_html/free-proxies/all.txt')) {
$lines = array_slice(file('/home/s4m/web/s4m.online/public_html/free-proxies/all.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES), 0, 20);
echo implode("\n", $lines) . "\n";
} else {
echo "socks5://149.202.80.42:1080\nsocks5://51.178.231.89:1080\nhttp://135.125.104.8:3128\n";
}
exit;
}
header('Content-Type: text/html; charset=utf-8');
$h = static fn(string $s): string => htmlspecialchars($s, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
$scopeLabel = '';
if ($countryName !== '' && $proto !== '') {
$scopeLabel = $countryName . ' (' . strtoupper($proto) . ')';
} elseif ($countryName !== '') {
$scopeLabel = $countryName . ' (' . $cc . ')';
} elseif ($proto !== '') {
$scopeLabel = strtoupper($proto);
}
$pageTitle = $scopeLabel !== ''
? 'Live Proxy List Export · ' . $scopeLabel . ' (TXT, CSV, JSON) — s4m.online'
: 'Live Proxy List Export (TXT, CSV, JSON) — s4m.online';
$tplFile = '/home/s4m/web/s4m.online/public_html/pricing/index.html';
$tpl = is_readable($tplFile) ? (string)file_get_contents($tplFile) : '';
$mainStart = strpos($tpl, '
Continuously checked HTTP, HTTPS, SOCKS4 and SOCKS5 proxies= $scopeLabel !== '' ? ' for ' . $h($scopeLabel) . '' : '' ?> in TXT, CSV and JSON formats, plus authenticated dedicated proxy plans.