westdc-zf1/htdocs/proftp_sync.php

37 lines
1.5 KiB
PHP
Raw Normal View History

2010-11-08 02:27:39 +00:00
<?php
//sync proftp data directory
ini_set('display_errors', 1);
date_default_timezone_set('Asia/Shanghai');
setlocale(LC_ALL, 'zh_CN.UTF8');
// directory setup and class loading
set_include_path('.' . PATH_SEPARATOR . '../include/'
. PATH_SEPARATOR . '../application/models'
. PATH_SEPARATOR . '../application/default/controllers'
. PATH_SEPARATOR . get_include_path());
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);
// load configuration
$config = new Zend_Config_Ini('../application/config.ini', 'general');
$registry = Zend_Registry::getInstance();
$registry->set('config', $config);
// setup database
$db = Zend_Db::factory($config->db);
2014-04-29 03:33:04 +00:00
@$date=$_REQUEST["date"];
if (empty($date)) $date=date('Y-m-d',strtotime('-2 month'));
$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+interval '1 minute')>='".$date."'";
2010-11-08 02:27:39 +00:00
$rs=$db->fetchAll($sql);
print '# date: '.$date."\n";
foreach($rs as $r)
{
print '# path: '.$r['path']."\n";
print 'mkdir -p "/home/ftp/westdc_'.$r['userid'].'/'.basename($r['path']).'"'."\n";
print 'mount --bind "'.$r['path'].'" "/home/ftp/westdc_'.$r['userid'].'/'.basename($r['path']).'"'."\n";
}
//todo: add umount command if user has downloaded the data
?>