27 $Usage =
"Usage: " . basename($argv[0]) .
" 28 -u upload id :: upload id 29 -t uploadtree id :: uploadtree id 30 -c sysconfdir :: optional - Specify the directory for the system configuration 31 --user username :: user name 32 --password password :: password 33 -b bucket id :: bucket id 34 -a bucket agent id :: bucket agent id 35 -n nomos agent id :: nomos agent id 36 -X excluding :: Exclude files containing [free text] in the path. 37 'mac/' should exclude all files in the mac directory. 38 'mac' and it should exclude all files in any directory containing the substring 'mac' 39 '/mac' and it should exclude all files in any directory that starts with 'mac' 43 $upload = $item = $bucket = $bucket_agent = $nomos_agent =
"";
46 $longopts = array(
"user:",
"password:");
47 $options = getopt(
"c:u:t:b:a:n:hX:", $longopts);
48 if (empty($options) || ! is_array($options)) {
55 foreach ($options as $option => $value) {
66 $bucket_agent = $value;
69 $nomos_agent = $value;
87 print
"unknown option $option\n";
92 if (!(is_numeric($item)) && !(is_numeric($upload))) {
93 print
"At least provide uploadtree_id or upload_id.\n";
100 if (is_numeric($item)) {
102 }
else if (empty($item) && is_numeric($upload)) {
104 if (empty($uploadtree1stid)) {
105 print
"Upload $upload does not exist.\n";
109 $item = $uploadtree1stid;
117 print
"Uploadtree ID $item does not exist.\n";
120 }
else if (empty($upload)) {
123 print
"Uploadtree ID $item does not under Upload $upload.\n";
129 if (!is_numeric($bucket) || !is_numeric($bucket_agent) || !is_numeric($nomos_agent)) {
130 print
"please enter the correct bucket agent ID and nomos agent ID and bucket ID.\n";
132 Usage4Options($upload, $item);
140 if (empty($return_value)) {
141 $text = _(
"The user '$user' has no permission to read the information of upload $upload\n");
146 require_once(
"$MODDIR/lib/php/common.php");
149 GetBucketList($bucket, $bucket_agent, $nomos_agent, $item, $upload);
161 function GetBucketList($bucket_pk, $bucket_agent, $nomos_agent, $uploadtree_pk, $upload_pk = 0)
167 $sql =
"SELECT bucket_name from bucket_def where bucket_pk = $bucket_pk;";
168 $result = pg_query($PG_CONN, $sql);
170 $row = pg_fetch_assoc($result);
171 pg_free_result($result);
176 $sql =
"SELECT upload_fk, lft, rgt, uploadtree_pk from $uploadtree_tablename";
178 if ($uploadtree_pk) {
179 $sql .=
" where uploadtree_pk='$uploadtree_pk';";
181 $sql .=
" where upload_fk='$upload_pk' and parent is null;";
183 $result = pg_query($PG_CONN, $sql);
185 $toprow = pg_fetch_assoc($result);
186 $uploadtree_pk = $toprow[
'uploadtree_pk'];
187 pg_free_result($result);
189 if (empty($toprow)) {
190 print
"Sorry, Can not find upload $upload_pk.\n";
194 print
"For uploadtree $uploadtree_pk under upload $upload_pk has bucket $row[bucket_name]:\n";
196 $sql =
"select uploadtree_pk, ufile_name, lft, rgt from $uploadtree_tablename, bucket_file 197 where upload_fk=$upload_pk 198 and lft>'$toprow[lft]' and rgt<'$toprow[rgt]' 199 and ((ufile_mode & (1<<28)) = 0) and ((ufile_mode & (1<<29)) = 0) and bucket_file.pfile_fk = $uploadtree_tablename.pfile_fk 200 and bucket_fk = '$bucket_pk' and agent_fk = '$bucket_agent' and nomosagent_fk = '$nomos_agent' 201 order by uploadtree_pk";
202 $outerresult = pg_query($PG_CONN, $sql);
206 while ($row = pg_fetch_assoc($outerresult)) {
207 $filepatharray =
Dir2Path($row[
'uploadtree_pk'], $uploadtree_tablename);
209 foreach ($filepatharray as $uploadtreeRow) {
210 if (! empty($filepath)) {
214 if (1 == $excluding_flag) {
218 $filepath .= $uploadtreeRow[
'ufile_name'];
220 if (1 == $excluding_flag) {
227 pg_free_result($outerresult);
230 function Usage4Options($UploadID, $item)
233 $sql =
"SELECT agent_fk as bucket_agent_id, nomosagent_fk as nomos_agent_id, bucket_pk as bucket_id, bucket_ars.bucketpool_fk as bucketpoo_id, bucket_name from bucket_ars right join bucket_def on bucket_def.bucketpool_fk = bucket_ars.bucketpool_fk where upload_fk = '$UploadID';";
234 $result = pg_query($PG_CONN, $sql);
236 $bucket_arr = pg_fetch_all($result);
237 pg_free_result($result);
238 $clause4uploadtree =
"";
240 $clause4uploadtree =
" uploadtree $item";
243 print
"For".
"$clause4uploadtree under upload $UploadID, you can specify options below: \n 248 print_r($bucket_arr);
250 print
"Please confirm uploadtree $item under upload $UploadID has done one bucket scanning.\n";
FUNCTION char * GetUploadtreeTableName(PGconn *pgConn, int upload_pk)
Get the uploadtree table name for this upload_pk If upload_pk does not exist, return "uploadtree"...
account_check(&$user, &$passwd, &$group="")
check if this account is correct
Dir2Path($uploadtree_pk, $uploadtree_tablename='uploadtree')
Return the path (without artifacts) of an uploadtree_pk.
ContainExcludeString($FilePath, $ExcludingText)
Check if one file path contains an excluding text.
GetUploadID($uploadtreeid)
Get upload id through uploadtreeid.
foreach($options as $option=> $value) if(!(is_numeric($item))&&!(is_numeric($upload))) $upload_from_item
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
read_permission($upload, $user)
Check if the user has the permission to read the copyright/license/etc information of this upload...
GetBucketList($bucket_pk, $bucket_agent, $nomos_agent, $uploadtree_pk, $upload_pk=0)
get bucket list of one specified upload or all uploads
Get1stUploadtreeID($upload)
Get 1st uploadtree id through upload id.