37 lines
1.2 KiB
PHP
37 lines
1.2 KiB
PHP
|
<?php
|
||
|
$link = pg_connect("dbname=metadata user=gis password=gispassword host=210.77.68.241");
|
||
|
if (!$link)
|
||
|
{
|
||
|
die("Error in connection: " . pg_last_error());
|
||
|
}
|
||
|
$sql="select dataorder.userid,dataset.path from dataorder left join dataset on dataorder.uuid=dataset.uuid
|
||
|
where dataorder.status in (0,5) and dataset.host='ftp2.westgis.ac.cn' and dataset.path<>''
|
||
|
and dataorder.ts_approved<now()-interval '3 months'
|
||
|
and dataorder.ts_approved>=now()-interval '4 months'
|
||
|
and dataorder.selection is null";
|
||
|
$result = pg_query($link, $sql);
|
||
|
$numrows = pg_num_rows($result);
|
||
|
|
||
|
$content='';
|
||
|
for($ri = 0; $ri < $numrows; $ri++)
|
||
|
{
|
||
|
$row = pg_fetch_array($result, $ri);
|
||
|
$content.='# path: '.$row['path']."\n";
|
||
|
$content.='umount "/home/ftp/westdc_'.$row['userid'].'/'.preg_replace('/^.+[\\\\\\/]/', '', rtrim($row['path'],'/')).'"'."\n";
|
||
|
}
|
||
|
|
||
|
$filename='./ftp-umount.sh';
|
||
|
if (!empty($content))
|
||
|
if (!file_put_contents($filename, $content, LOCK_EX))
|
||
|
{
|
||
|
sleep(1);
|
||
|
if (!file_put_contents($filename, $content, LOCK_EX))
|
||
|
{
|
||
|
sleep(1);
|
||
|
if (!file_put_contents($filename, $content, LOCK_EX))
|
||
|
die("error in write proftp-user.sh");
|
||
|
}
|
||
|
}
|
||
|
pg_free_result($result);
|
||
|
pg_close($link);
|
||
|
?>
|