33 return (($mode & 1 << 18) + ($mode & 0040000) != 0);
42 return (($mode & 1 << 28) != 0);
51 return (($mode & 1 << 29) != 0);
69 if (($Mode & 0120000) == 0120000) {
80 if ($Mode & 0000400) {
85 if ($Mode & 0000200) {
90 if ($Mode & 0000100) {
91 if ($Mode & 0004000) {
97 if ($Mode & 0004000) {
104 if ($Mode & 0000040) {
109 if ($Mode & 0000020) {
114 if ($Mode & 0000010) {
115 if ($Mode & 0002000) {
121 if ($Mode & 0002000) {
128 if ($Mode & 0000004) {
133 if ($Mode & 0000002) {
138 if ($Mode & 0000001) {
139 if ($Mode & 0001000) {
145 if ($Mode & 0001000) {
155 $DirGetNonArtifact_Prepared=0;
174 global $DirGetNonArtifact_Prepared;
176 $dbManager = $container->get(
'db.manager');
177 if (! $DirGetNonArtifact_Prepared) {
178 $DirGetNonArtifact_Prepared=1;
179 $sql =
"SELECT * FROM $uploadtree_tablename LEFT JOIN pfile ON pfile_pk = pfile_fk WHERE parent = $1";
180 $dbManager->prepare($stmt=__METHOD__.
".$uploadtree_tablename",$sql);
181 $result = $dbManager->execute($stmt,array($UploadtreePk));
182 while ($child = $dbManager->fetchArray($result)) {
183 $Children[] = $child;
185 $dbManager->freeResult($result);
188 foreach ($Children as $C) {
189 if (empty($C[
'ufile_mode'])) {
193 return($UploadtreePk);
195 if (($C[
'ufile_name'] ==
'artifact.dir') ||
196 ($C[
'ufile_name'] ==
'artifact.unpacked')) {
200 if (! empty($Recurse)) {
203 return($UploadtreePk);
218 return(strcasecmp($a[
'ufile_name'],$b[
'ufile_name']));
233 function Dir2Path($uploadtree_pk, $uploadtree_tablename=
'uploadtree')
237 $uploadtreeArray = array();
239 if (empty($uploadtree_pk)) {
240 return $uploadtreeArray;
243 while (! empty($uploadtree_pk)) {
244 $sql =
"SELECT parent, upload_fk, ufile_mode, ufile_name, uploadtree_pk from $uploadtree_tablename where uploadtree_pk='$uploadtree_pk'";
245 $result = pg_query($PG_CONN, $sql);
247 $Row = pg_fetch_assoc($result);
248 pg_free_result($result);
250 array_unshift($uploadtreeArray, $Row);
252 $uploadtree_pk = $Row[
'parent'];
255 return($uploadtreeArray);
275 $ShowBox=1, $ShowMicro=NULL, $Enumerate=-1, $PreText=
'', $PostText=
'', $uploadtree_tablename=
"uploadtree")
279 $V .=
"<div style='border: thin dotted gray; background-color:lightyellow'>\n";
282 if ($Enumerate >= 0) {
283 $V .=
"<table border=0 width='100%'><tr><td width='5%'>";
284 $V .=
"<font size='+2'>" . number_format($Enumerate,0,
"",
",") .
":</font>";
294 $Path =
Dir2Path($UploadtreePk, $uploadtree_tablename);
295 $Last = &$Path[count($Path)-1];
297 $V .=
"<font class='text'>\n";
300 if (! empty($PreText)) {
301 $V .=
"$PreText<br>\n";
306 $V .=
"<b>$text</b>: ";
307 if (array_key_exists(0, $Path)) {
310 for ($i = 0; $i < count($List); $i ++) {
311 $Folder = $List[$i][
'folder_pk'];
312 $FolderName = htmlentities($List[$i][
'folder_name']);
313 $V .=
"<b><a href='$Uri2&folder=$Folder'>$FolderName</a></b>/ ";
318 if (count($Path) == - 1) {
319 $Upload = $Path[0][
'upload_fk'];
320 $UploadName = htmlentities($Path[0][
'ufile_name']);
321 $UploadtreePk = $Path[0][
'uploadtree_pk'];
322 $V .=
"<br><b><a href='$Uri2&folder=$Folder&upload=$Upload&item=$UploadtreePk'>$UploadName</a></b>";
328 for ($p = 0; ! empty($Path[$p][
'uploadtree_pk']); $p ++) {
330 if (empty($P[
'ufile_name'])) {
333 $UploadtreePk = $P[
'uploadtree_pk'];
337 if (! empty($LinkLast) || ($P != $Last)) {
341 $V .=
"<a href='$Uri&upload=" . $P[
'upload_fk'] . $Opt .
"&item=" . $UploadtreePk .
"'>";
344 if (
Isdir($P[
'ufile_mode'])) {
345 $V .= $P[
'ufile_name'];
347 $V .=
"<b>" . $P[
'ufile_name'] .
"</b>";
350 if (! empty($LinkLast) || ($P != $Last)) {
356 if (! empty($ShowMicro)) {
361 if ($Enumerate >= 0) {
363 $V .=
" $PostText";
365 $V .=
"</td></tr></table>";
388 function Dir2BrowseUpload ($Mod, $UploadPk, $LinkLast=NULL, $ShowBox=1, $ShowMicro=NULL, $uploadtree_tablename=
'uploadtree')
392 $sql =
"SELECT uploadtree_pk FROM upload INNER JOIN $uploadtree_tablename ON upload_fk = '$UploadPk' AND parent is null;";
393 $result = pg_query($PG_CONN, $sql);
395 $row = pg_fetch_assoc($result);
396 $UploadtreePk = $row[
'uploadtree_pk'];
397 pg_free_result($result);
398 return(
Dir2Browse($Mod,$UploadtreePk,$LinkLast,$ShowBox,$ShowMicro, -1,
'',
'', $uploadtree_tablename));
417 function Dir2FileList (&$Listing, $IfDirPlugin, $IfFilePlugin, $Count=-1, $ShowPhrase=0)
421 while (($R = pg_fetch_assoc($Listing)) && ! empty($R[
'uploadtree_pk'])) {
422 if (array_key_exists(
"licenses", $R)) {
423 $Licenses = $R[
"licenses"];
429 if ($ShowPhrase && ! empty($R[
'phrase_text'])) {
431 $Phrase =
"<b>$text:</b> " . htmlentities($R[
'phrase_text']);
436 $V .=
Dir2Browse(
"browse",$R[
'uploadtree_pk'],$IfDirPlugin,1,
437 null,$Count,$Phrase, $Licenses) .
"\n";
438 }
else if ($R[
'pfile_fk'] != $LastPfilePk) {
440 $V .=
Dir2Browse(
"browse",$R[
'uploadtree_pk'],$IfFilePlugin,1,
441 null,$Count,$Phrase, $Licenses) .
"\n";
442 $LastPfilePk = $R[
'pfile_fk'];
444 $V .=
"<div style='margin-left:2em;'>";
445 $V .=
Dir2Browse(
"browse",$R[
'uploadtree_pk'],$IfFilePlugin,1,
446 null,$Count,$Phrase, $Licenses) .
"\n";
472 foreach ($Listing as $R) {
473 if (array_key_exists(
"licenses", $R)) {
474 $Licenses = $R[
"licenses"];
480 if ($ShowPhrase && ! empty($R[
'phrase_text'])) {
482 $Phrase =
"<b>$text:</b> " . htmlentities($R[
'phrase_text']);
489 $V .=
Dir2Browse(
"browse",$R[
'uploadtree_pk'],$IfDirPlugin,1,NULL,$Count,$Phrase,$Licenses,$uploadtree_tablename) .
"\n";
490 }
else if ($R[
'pfile_fk'] != $LastPfilePk) {
492 $V .=
Dir2Browse(
"browse",$R[
'uploadtree_pk'],$IfFilePlugin,1,NULL,$Count,$Phrase,$Licenses,$uploadtree_tablename) .
"\n";
493 $LastPfilePk = $R[
'pfile_fk'];
495 $V .=
"<div style='margin-left:2em;'>";
496 $V .=
Dir2Browse(
"browse",$R[
'uploadtree_pk'],$IfFilePlugin,1,NULL,$Count,$Phrase,$Licenses,$uploadtree_tablename) .
"\n";
518 function GetNonArtifactChildren($uploadtree_pk, $uploadtree_tablename=
'uploadtree')
522 $dbManager = $container->get(
'db.manager');
525 $sql =
"select {$uploadtree_tablename}.*, pfile_size, pfile_mimetypefk from $uploadtree_tablename 526 left outer join pfile on (pfile_pk=pfile_fk) 527 where parent=$1 ORDER BY lft";
528 $dbManager->prepare($stmt=__METHOD__.
"$uploadtree_tablename",$sql);
529 $result = $dbManager->execute($stmt,array($uploadtree_pk));
530 $children = $dbManager->fetchAll($result);
531 $dbManager->freeResult($result);
532 if (count($children) == 0) {
539 $foundChildren = array();
540 foreach ($children as $key => $child) {
543 unset($children[$key]);
544 $NonAChildren = GetNonArtifactChildren($child[
'uploadtree_pk'], $uploadtree_tablename);
546 $foundChildren = array_merge($foundChildren, $NonAChildren);
549 unset($children[$key]);
552 $foundChildren[$key] = $child;
556 return $foundChildren;
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"...
Dir2Browse($Mod, $UploadtreePk, $LinkLast=NULL, $ShowBox=1, $ShowMicro=NULL, $Enumerate=-1, $PreText='', $PostText='', $uploadtree_tablename="uploadtree")
Get an html linked string of a file browse path.
Traceback_uri()
Get the URI without query to this location.
Dir2FileList(&$Listing, $IfDirPlugin, $IfFilePlugin, $Count=-1, $ShowPhrase=0)
Given an array of pfiles/uploadtree, sorted by pfile, list all of the breadcrumbs for each file...
Dir2Path($uploadtree_pk, $uploadtree_tablename='uploadtree')
Return the path (without artifacts) of an uploadtree_pk.
FolderGetFromUpload($Uploadpk, $Folder=-1, $Stop=-1)
DEPRECATED! Given an upload number, return the folder path in an array containing folder_pk and name...
DirMode2String($Mode)
Convert a file mode to string values.
int IsDir(char *Fname)
Given a filename, is it a directory?
UploadtreeFileList($Listing, $IfDirPlugin, $IfFilePlugin, $Count=-1, $ShowPhrase=0)
Given an array of pfiles/uploadtree, sorted by pfile, list all of the breadcrumbs for each file...
DirGetNonArtifact($UploadtreePk, $uploadtree_tablename='uploadtree')
Given an artifact directory (uploadtree_pk), return the first non-artifact directory (uploadtree_pk)...
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
_DirCmp($a, $b)
Compare function for usort() on directory items.
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
Traceback_parm_keep($List)
Create a new URI, keeping only these items.
Dir2BrowseUpload($Mod, $UploadPk, $LinkLast=NULL, $ShowBox=1, $ShowMicro=NULL, $uploadtree_tablename='uploadtree')
Get an html links string of a file browse path.