mirror of
https://github.com/getnamingo/registry.git
synced 2025-08-05 17:18:04 +02:00
Added TMCH download cron
This commit is contained in:
parent
09ad1050b8
commit
43800b9c15
1 changed files with 48 additions and 0 deletions
48
automation/tmch.php
Normal file
48
automation/tmch.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
$savePath = "/path/to/save/files/"; // Adjust this path as needed.
|
||||
|
||||
$files = [
|
||||
'smdrl' => 'https://ry.marksdb.org/smdrl/smdrl-latest.csv',
|
||||
'surl' => 'https://test.ry.marksdb.org/dnl/surl-latest.csv',
|
||||
'dnl' => 'https://test.ry.marksdb.org/dnl/dnl-latest.csv',
|
||||
'tmch' => 'http://crl.icann.org/tmch.crl'
|
||||
];
|
||||
|
||||
// Configure the username and password for each URL.
|
||||
$credentials = [
|
||||
'smdrl' => ['user' => 'username1', 'pass' => 'password1'],
|
||||
'surl' => ['user' => 'username2', 'pass' => 'password2'],
|
||||
'dnl' => ['user' => 'username3', 'pass' => 'password3']
|
||||
// 'tmch' is not listed here since it doesn't require authentication.
|
||||
];
|
||||
|
||||
foreach ($files as $key => $url) {
|
||||
$ch = curl_init($url);
|
||||
|
||||
// Check if credentials exist for this URL and set them.
|
||||
if (isset($credentials[$key])) {
|
||||
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||
curl_setopt($ch, CURLOPT_USERPWD, $credentials[$key]['user'] . ":" . $credentials[$key]['pass']);
|
||||
}
|
||||
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
|
||||
curl_setopt($ch, CURLOPT_MAXREDIRS, 10);
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
|
||||
|
||||
$data = curl_exec($ch);
|
||||
|
||||
if ($data === false) {
|
||||
echo "Failed to download $url. Error: " . curl_error($ch) . "\n";
|
||||
} else {
|
||||
$filePath = $savePath . basename($url);
|
||||
if (file_put_contents($filePath, $data)) {
|
||||
echo "Successfully downloaded $url to $filePath\n";
|
||||
} else {
|
||||
echo "Failed to save the downloaded file to $filePath\n";
|
||||
}
|
||||
}
|
||||
|
||||
curl_close($ch);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue