33 lines
1.0 KiB
PHP
Executable File
33 lines
1.0 KiB
PHP
Executable File
<?php
|
|
$link = pg_connect("dbname=metadata user=gis password=gispassword host=210.77.68.241");
|
|
$host='ftp2.westgis.ac.cn';
|
|
$sql="select d.uuid,sum(df.filesize) as volume,count(df.id) as fcount,d.path from dataset d left join mdstatus ms on d.uuid=ms.uuid
|
|
left join datafile df on d.id=df.dsid
|
|
where ms.status>4 and d.host='".$host."' group by d.id,d.uuid,d.path";
|
|
$result = pg_query($link, $sql);
|
|
$numrows = pg_num_rows($result);
|
|
$content='';
|
|
for($ri = 0; $ri < $numrows; $ri++)
|
|
{
|
|
$row = pg_fetch_array($result, $ri);
|
|
$content.=$row['uuid']."\t";
|
|
$content.=$row['volume']."\t";
|
|
$content.=$row['fcount']."\t";
|
|
$content.=$row['path']."\n";
|
|
}
|
|
|
|
$filename='./dataset-0.txt';
|
|
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 dataset-0.txt");
|
|
}
|
|
}
|
|
pg_free_result($result);
|
|
pg_close($link);
|