22 return (($mode & 1 << 18) + ($mode & 0040000) != 0);
31 return (($mode & 1 << 28) != 0);
40 return (($mode & 1 << 29) != 0);
58 if (($Mode & 0120000) == 0120000) {
69 if ($Mode & 0000400) {
74 if ($Mode & 0000200) {
79 if ($Mode & 0000100) {
80 if ($Mode & 0004000) {
86 if ($Mode & 0004000) {
93 if ($Mode & 0000040) {
98 if ($Mode & 0000020) {
103 if ($Mode & 0000010) {
104 if ($Mode & 0002000) {
110 if ($Mode & 0002000) {
117 if ($Mode & 0000004) {
122 if ($Mode & 0000002) {
127 if ($Mode & 0000001) {
128 if ($Mode & 0001000) {
134 if ($Mode & 0001000) {
144 $DirGetNonArtifact_Prepared=0;
163 global $DirGetNonArtifact_Prepared;
165 $dbManager = $container->get(
'db.manager');
166 if (! $DirGetNonArtifact_Prepared) {
167 $DirGetNonArtifact_Prepared=1;
168 $sql =
"SELECT * FROM $uploadtree_tablename LEFT JOIN pfile ON pfile_pk = pfile_fk WHERE parent = $1";
169 $dbManager->prepare($stmt=__METHOD__.
".$uploadtree_tablename",$sql);
170 $result = $dbManager->execute($stmt,array($UploadtreePk));
171 while ($child = $dbManager->fetchArray($result)) {
172 $Children[] = $child;
174 $dbManager->freeResult($result);
177 foreach ($Children as $C) {
178 if (empty($C[
'ufile_mode'])) {
182 return($UploadtreePk);
184 if (($C[
'ufile_name'] ==
'artifact.dir') ||
185 ($C[
'ufile_name'] ==
'artifact.unpacked')) {
189 if (! empty($Recurse)) {
192 return($UploadtreePk);
207 return(strcasecmp($a[
'ufile_name'],$b[
'ufile_name']));
222 function Dir2Path($uploadtree_pk, $uploadtree_tablename=
'uploadtree')
226 $uploadtreeArray = array();
228 if (empty($uploadtree_pk)) {
229 return $uploadtreeArray;
232 while (! empty($uploadtree_pk)) {
233 $sql =
"SELECT parent, upload_fk, ufile_mode, ufile_name, uploadtree_pk from $uploadtree_tablename where uploadtree_pk='$uploadtree_pk'";
236 $Row = pg_fetch_assoc($result);
237 pg_free_result($result);
239 array_unshift($uploadtreeArray, $Row);
241 $uploadtree_pk = $Row[
'parent'];
244 return($uploadtreeArray);
264 $ShowBox=1, $ShowMicro=NULL, $Enumerate=-1, $PreText=
'', $PostText=
'', $uploadtree_tablename=
"uploadtree")
268 $V .=
"<div class='alert alert-info' style='padding:5px;'>\n";
271 if ($Enumerate >= 0) {
272 $V .=
"<table border=0 width='100%'><tr><td width='5%'>";
273 $V .=
"<font size='+2'>" . number_format($Enumerate,0,
"",
",") .
":</font>";
283 $Path =
Dir2Path($UploadtreePk, $uploadtree_tablename);
284 $Last = &$Path[count($Path)-1];
287 if (! empty($PreText)) {
288 $V .=
"$PreText<br>\n";
293 $V .=
"<b>$text</b>: ";
294 if (array_key_exists(0, $Path)) {
297 for ($i = 0; $i < count($List); $i ++) {
298 $Folder = $List[$i][
'folder_pk'];
299 $FolderName = htmlentities($List[$i][
'folder_name']);
300 $V .=
"<b><a href='$Uri2&folder=$Folder'>$FolderName</a></b>/ ";
305 if (count($Path) == - 1) {
306 $Upload = $Path[0][
'upload_fk'];
307 $UploadName = htmlentities($Path[0][
'ufile_name']);
308 $UploadtreePk = $Path[0][
'uploadtree_pk'];
309 $V .=
"<br><b><a href='$Uri2&folder=$Folder&upload=$Upload&item=$UploadtreePk'>$UploadName</a></b>";
315 for ($p = 0; ! empty($Path[$p][
'uploadtree_pk']); $p ++) {
317 if (empty($P[
'ufile_name'])) {
320 $UploadtreePk = $P[
'uploadtree_pk'];
324 if (! empty($LinkLast) || ($P != $Last)) {
328 $V .=
"<a href='$Uri&upload=" . $P[
'upload_fk'] . $Opt .
"&item=" . $UploadtreePk .
"'>";
331 if (
Isdir($P[
'ufile_mode'])) {
332 $V .= $P[
'ufile_name'];
334 $V .=
"<b>" . $P[
'ufile_name'] .
"</b>";
337 if (! empty($LinkLast) || ($P != $Last)) {
342 if (! empty($ShowMicro)) {
347 if ($Enumerate >= 0) {
349 $V .=
" $PostText";
351 $V .=
"</td></tr></table>";
374 function Dir2BrowseUpload ($Mod, $UploadPk, $LinkLast=NULL, $ShowBox=1, $ShowMicro=NULL, $uploadtree_tablename=
'uploadtree')
378 $sql =
"SELECT uploadtree_pk FROM upload INNER JOIN $uploadtree_tablename ON upload_fk = '$UploadPk' AND parent is null;";
381 $row = pg_fetch_assoc($result);
382 $UploadtreePk = $row[
'uploadtree_pk'];
383 pg_free_result($result);
384 return(
Dir2Browse($Mod,$UploadtreePk,$LinkLast,$ShowBox,$ShowMicro, -1,
'',
'', $uploadtree_tablename));
403 function Dir2FileList (&$Listing, $IfDirPlugin, $IfFilePlugin, $Count=-1, $ShowPhrase=0)
407 while (($R = pg_fetch_assoc($Listing)) && ! empty($R[
'uploadtree_pk'])) {
408 if (array_key_exists(
"licenses", $R)) {
409 $Licenses = $R[
"licenses"];
415 if ($ShowPhrase && ! empty($R[
'phrase_text'])) {
417 $Phrase =
"<b>$text:</b> " . htmlentities($R[
'phrase_text']);
422 $V .=
Dir2Browse(
"browse",$R[
'uploadtree_pk'],$IfDirPlugin,1,
423 null,$Count,$Phrase, $Licenses) .
"\n";
424 }
else if ($R[
'pfile_fk'] != $LastPfilePk) {
426 $V .=
Dir2Browse(
"browse",$R[
'uploadtree_pk'],$IfFilePlugin,1,
427 null,$Count,$Phrase, $Licenses) .
"\n";
428 $LastPfilePk = $R[
'pfile_fk'];
430 $V .=
"<div style='margin-left:2em;'>";
431 $V .=
Dir2Browse(
"browse",$R[
'uploadtree_pk'],$IfFilePlugin,1,
432 null,$Count,$Phrase, $Licenses) .
"\n";
458 foreach ($Listing as $R) {
459 if (array_key_exists(
"licenses", $R)) {
460 $Licenses = $R[
"licenses"];
466 if ($ShowPhrase && ! empty($R[
'phrase_text'])) {
468 $Phrase =
"<b>$text:</b> " . htmlentities($R[
'phrase_text']);
475 $V .=
Dir2Browse(
"browse",$R[
'uploadtree_pk'],$IfDirPlugin,1,NULL,$Count,$Phrase,$Licenses,$uploadtree_tablename) .
"\n";
476 }
else if ($R[
'pfile_fk'] != $LastPfilePk) {
478 $V .=
Dir2Browse(
"browse",$R[
'uploadtree_pk'],$IfFilePlugin,1,NULL,$Count,$Phrase,$Licenses,$uploadtree_tablename) .
"\n";
479 $LastPfilePk = $R[
'pfile_fk'];
481 $V .=
"<div style='margin-left:2em;'>";
482 $V .=
Dir2Browse(
"browse",$R[
'uploadtree_pk'],$IfFilePlugin,1,NULL,$Count,$Phrase,$Licenses,$uploadtree_tablename) .
"\n";
504 function GetNonArtifactChildren($uploadtree_pk, $uploadtree_tablename=
'uploadtree')
508 $dbManager = $container->get(
'db.manager');
511 $sql =
"select {$uploadtree_tablename}.*, pfile_size, pfile_mimetypefk from $uploadtree_tablename
512 left outer join pfile on (pfile_pk=pfile_fk)
513 where parent=$1 ORDER BY lft";
514 $dbManager->prepare($stmt=__METHOD__.
"$uploadtree_tablename",$sql);
515 $result = $dbManager->execute($stmt,array($uploadtree_pk));
516 $children = $dbManager->fetchAll($result);
517 $dbManager->freeResult($result);
518 if (count($children) == 0) {
525 $foundChildren = array();
526 foreach ($children as $key => $child) {
528 unset($children[$key]);
530 $NonAChildren = GetNonArtifactChildren($child[
'uploadtree_pk'], $uploadtree_tablename);
532 $foundChildren = array_merge($foundChildren, $NonAChildren);
536 $foundChildren[$key] = $child;
540 return $foundChildren;
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
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....
_DirCmp($a, $b)
Compare function for usort() on directory items.
Dir2BrowseUpload($Mod, $UploadPk, $LinkLast=NULL, $ShowBox=1, $ShowMicro=NULL, $uploadtree_tablename='uploadtree')
Get an html links string of a file browse path.
DirGetNonArtifact($UploadtreePk, $uploadtree_tablename='uploadtree')
Given an artifact directory (uploadtree_pk), return the first non-artifact directory (uploadtree_pk).
DirMode2String($Mode)
Convert a file mode to string values.
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....
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.
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.
Traceback_uri()
Get the URI without query to this location.
Traceback_parm_keep($List)
Create a new URI, keeping only these items.
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
int IsDir(char *Fname)
Given a filename, is it a directory?