16 $Usage =
"Usage: " . basename($argv[0]) .
"
17 -u upload id :: upload id
18 -t uploadtree id :: uploadtree id
19 -c sysconfdir :: optional - Specify the directory for the system configuration
20 --user username :: user name
21 --password password :: password
22 -b bucket id :: bucket id
23 -a bucket agent id :: bucket agent id
24 -n nomos agent id :: nomos agent id
25 -X excluding :: Exclude files containing [free text] in the path.
26 'mac/' should exclude all files in the mac directory.
27 'mac' and it should exclude all files in any directory containing the substring 'mac'
28 '/mac' and it should exclude all files in any directory that starts with 'mac'
32 $upload = $item = $bucket = $bucket_agent = $nomos_agent =
"";
35 $longopts = array(
"user:",
"password:");
36 $options = getopt(
"c:u:t:b:a:n:hX:", $longopts);
37 if (empty($options) || ! is_array($options)) {
44 foreach ($options as $option => $value) {
55 $bucket_agent = $value;
58 $nomos_agent = $value;
76 print
"unknown option $option\n";
81 if (!(is_numeric($item)) && !(is_numeric($upload))) {
82 print
"At least provide uploadtree_id or upload_id.\n";
89 if (is_numeric($item)) {
91 }
else if (empty($item) && is_numeric($upload)) {
93 if (empty($uploadtree1stid)) {
94 print
"Upload $upload does not exist.\n";
98 $item = $uploadtree1stid;
106 print
"Uploadtree ID $item does not exist.\n";
109 }
else if (empty($upload)) {
112 print
"Uploadtree ID $item does not under Upload $upload.\n";
118 if (!is_numeric($bucket) || !is_numeric($bucket_agent) || !is_numeric($nomos_agent)) {
119 print
"please enter the correct bucket agent ID and nomos agent ID and bucket ID.\n";
121 Usage4Options($upload, $item);
129 if (empty($return_value)) {
130 $text = _(
"The user '$user' has no permission to read the information of upload $upload\n");
135 require_once(
"$MODDIR/lib/php/common.php");
138 GetBucketList($bucket, $bucket_agent, $nomos_agent, $item, $upload);
150 function GetBucketList($bucket_pk, $bucket_agent, $nomos_agent, $uploadtree_pk, $upload_pk = 0)
156 $sql =
"SELECT bucket_name from bucket_def where bucket_pk = $bucket_pk;";
159 $row = pg_fetch_assoc($result);
160 pg_free_result($result);
165 $sql =
"SELECT upload_fk, lft, rgt, uploadtree_pk from $uploadtree_tablename";
167 if ($uploadtree_pk) {
168 $sql .=
" where uploadtree_pk='$uploadtree_pk';";
170 $sql .=
" where upload_fk='$upload_pk' and parent is null;";
174 $toprow = pg_fetch_assoc($result);
175 $uploadtree_pk = $toprow[
'uploadtree_pk'];
176 pg_free_result($result);
178 if (empty($toprow)) {
179 print
"Sorry, Can not find upload $upload_pk.\n";
183 print
"For uploadtree $uploadtree_pk under upload $upload_pk has bucket $row[bucket_name]:\n";
185 $sql =
"select uploadtree_pk, ufile_name, lft, rgt from $uploadtree_tablename, bucket_file
186 where upload_fk=$upload_pk
187 and lft>'$toprow[lft]' and rgt<'$toprow[rgt]'
188 and ((ufile_mode & (1<<28)) = 0) and ((ufile_mode & (1<<29)) = 0) and bucket_file.pfile_fk = $uploadtree_tablename.pfile_fk
189 and bucket_fk = '$bucket_pk' and agent_fk = '$bucket_agent' and nomosagent_fk = '$nomos_agent'
190 order by uploadtree_pk";
191 $outerresult = pg_query(
$PG_CONN, $sql);
195 while ($row = pg_fetch_assoc($outerresult)) {
196 $filepatharray =
Dir2Path($row[
'uploadtree_pk'], $uploadtree_tablename);
198 foreach ($filepatharray as $uploadtreeRow) {
199 if (! empty($filepath)) {
203 if (1 == $excluding_flag) {
207 $filepath .= $uploadtreeRow[
'ufile_name'];
209 if (1 == $excluding_flag) {
216 pg_free_result($outerresult);
219 function Usage4Options($UploadID, $item)
222 $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';";
225 $bucket_arr = pg_fetch_all($result);
226 pg_free_result($result);
227 $clause4uploadtree =
"";
229 $clause4uploadtree =
" uploadtree $item";
232 print
"For".
"$clause4uploadtree under upload $UploadID, you can specify options below: \n
237 print_r($bucket_arr);
239 print
"Please confirm uploadtree $item under upload $UploadID has done one bucket scanning.\n";
read_permission($upload, $user)
Check if the user has the permission to read the copyright/license/etc information of this upload.
account_check(&$user, &$passwd, &$group="")
check if this account is correct
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
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.
Get1stUploadtreeID($upload)
Get 1st uploadtree id through upload id.
GetBucketList($bucket_pk, $bucket_agent, $nomos_agent, $uploadtree_pk, $upload_pk=0)
get bucket list of one specified upload or all uploads
foreach($options as $option=> $value) if(!(is_numeric($item)) &&!(is_numeric($upload))) $upload_from_item
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".
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN