0 || $offlineappid>0)) { die("Error in parameter."); } $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.selection is null"; if ($onlineappid>0) $sql.=" and (dataset.lang='' or dataset.lang in (select lang from onlineapp where id=".$onlineappid.")) and dataorder.onlineappid=".$onlineappid; else if ($offlineappid>0) $sql.=" and dataorder.offlineappid=".$offlineappid; $result = pg_query($link, $sql); $numrows = pg_num_rows($result); // Loop on rows in the result set. $content=''; for($ri = 0; $ri < $numrows; $ri++) { $row = pg_fetch_array($result, $ri); $content.='# path: '.$row['path']."\n"; $content.='mkdir -p "/home/ftp/westdc_'.$row['userid'].'/'.preg_replace('/^.+[\\\\\\/]/', '', rtrim($row['path'],'/')).'"'."\n"; $content.='mount --bind "'.$row['path'].'" "/home/ftp/westdc_'.$row['userid'].'/'.preg_replace('/^.+[\\\\\\/]/', '', rtrim($row['path'],'/')).'"'."\n"; } $sql="select distinct dataorder.userid,dataset.path,dataservice.uuid from dataorder left join dataset on dataorder.uuid=dataset.uuid left join dataservice on dataorder.uuid=dataservice.uuid where dataorder.status in (0,5) and dataset.host='ftp2.westgis.ac.cn' and dataset.path<>'' and dataorder.selection is not null and dataservice.service_type in (1,2)"; if ($onlineappid>0) $sql.=" and dataorder.onlineappid=".$onlineappid; else if ($offlineappid>0) $sql.=" and dataorder.offlineappid=".$offlineappid; $result = pg_query($link, $sql); $numrows = pg_num_rows($result); $basepath='/disk1/WestDC/wsndata/'; for($ri = 0; $ri < $numrows; $ri++) { $row = pg_fetch_array($result, $ri); $content.='# path: '.$row['path']."\n"; $content.='mkdir -p "/home/ftp/westdc_'.$row['userid'].'/wsn_'.$row['userid'].'"'."\n"; $content.='mount --bind "'.$basepath.'wsn_'.$row['userid'].'" "/home/ftp/westdc_'.$row['userid'].'/wsn_'.$row['userid'].'"'."\n"; } $filename='./proftp-user.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); ?>