11 use Symfony\Component\HttpFoundation\Session\Session;
33 $FirstEmpty=
false, $SelElt=
true, $Options=
"", $ReturnKey=
true)
35 $str =
"\n<select name='$SLName' $Options>\n";
36 if ($FirstEmpty ==
true) {
37 $str .=
"<option value='' > </option>\n";
39 foreach ($KeyValArray as $key => $val) {
40 if ($SelElt ==
true) {
41 $SELECTED = ($val == $SelectedVal) ?
"SELECTED" :
"";
43 $SELECTED = ($key == $SelectedVal) ?
"SELECTED" :
"";
45 if ($ReturnKey ==
true) {
46 $str .=
"<option value='$key' $SELECTED>".htmlentities($val, ENT_QUOTES).
"</option>\n";
48 $str .=
"<option value='$val' $SELECTED>".htmlentities($val, ENT_QUOTES).
"</option>\n";
66 function Fatal($msg, $filenm, $lineno)
68 echo
"<hr>FATAL error, File: $filenm, Line number: $lineno<br>";
80 debug_print_backtrace();
102 foreach (array(
'B',
'KB',
'MB',
'GB',
'TB') as $unit) {
104 return(round($bytes, 2) .
' '. $unit);
108 return(round($bytes, 2) .
' PB');
123 if ($duration->y > 0) {
124 $humanDuration .= $duration->y .
" y";
125 } elseif ($duration->m > 0) {
126 $humanDuration .= $duration->m .
" m";
127 } elseif ($duration->days > 0) {
128 $humanDuration .= $duration->days .
" d";
130 $humanDuration .= $duration->h .
"h " . $duration->i .
"m";
132 return $humanDuration;
144 $extpos = strrpos($fname,
'.') + 1;
145 return strtolower(substr($fname, $extpos));
159 if (! is_array($Arr)) {
162 if (array_key_exists($Key, $Arr)) {
179 foreach ($SysConf[
'HOSTS'] as $key => $value) {
180 $options .=
"<option value='$key' SELECTED> $key </option>\n";
200 $connstat = connection_status();
201 if ($connstat != 0) {
202 return _(
"Lost connection.");
205 $session =
new Session();
209 header(
"Expires: ".gmdate(
"D, d M Y H:i:s", mktime(date(
"H")+2, date(
"i"), date(
"s"), date(
"m"), date(
"d"), date(
"Y"))).
" GMT");
210 header(
"Last-Modified: ".gmdate(
"D, d M Y H:i:s").
" GMT");
211 header(
'Content-Description: File Transfer');
212 header(
"Content-Type: $contentType");
213 header(
"Content-Length: ".(
string)(strlen($text)));
214 header(
"Content-Disposition: attachment; filename=\"$name\"");
215 header(
"Content-Transfer-Encoding: binary\n");
218 if ((connection_status() == 0) and ! connection_aborted()) {
221 return _(
"Lost connection.");
235 if (! empty($upload_pk)) {
236 $upload_rec =
GetSingleRec(
"upload",
"where upload_pk='$upload_pk'");
237 if (! empty($upload_rec[
'uploadtree_tablename'])) {
238 return $upload_rec[
'uploadtree_tablename'];
253 if (empty($upload_pk)) {
256 $upload_rec =
GetSingleRec(
"upload",
"where upload_pk='$upload_pk'");
257 $upload_filename = $upload_rec[
'upload_filename'];
258 if (empty($upload_filename)) {
261 return $upload_filename;
274 if (empty($uploadtreeid)) {
277 $upload_rec =
GetSingleRec(
"uploadtree",
"where uploadtree_pk=$uploadtreeid");
278 $uploadid = $upload_rec[
'upload_fk'];
279 if (empty($uploadid)) {
296 if (empty($upload)) {
299 $sql =
"SELECT max(uploadtree_pk) from uploadtree where upload_fk = $upload and parent is null;";
302 $row = pg_fetch_assoc($result);
303 $uploadtree_id = $row[
'max'];
304 pg_free_result($result);
305 return $uploadtree_id;
314 $server_timezone = date_default_timezone_get();
315 $browser_time = new \DateTime($server_time,
new \DateTimeZone($server_timezone));
316 if (array_key_exists(
"timezone", $_SESSION)) {
317 $tz = $_SESSION[
"timezone"];
318 $browser_time->setTimeZone(
new \DateTimeZone($tz));
320 return $browser_time->format(
'Y-m-d H:i:s');
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
GetSingleRec($Table, $Where="")
Retrieve a single database record.
HumanSize( $bytes)
Translate a byte number to a proper type, xxx bytes to xxx B/KB/MB/GB/TB/PB.
DownloadString2File($text, $name, $contentType)
Send a string to a user as a download file.
debugprint($val, $title)
Print debug message.
Array2SingleSelect($KeyValArray, $SLName="unnamed", $SelectedVal="", $FirstEmpty=false, $SelElt=true, $Options="", $ReturnKey=true)
Build a single choice select pulldown.
GetFileExt($fname)
Get File Extension (text after last period)
GetArrayVal($Key, $Arr)
Get the value from a array(map)
GetUploadID($uploadtreeid)
Get upload id through uploadtreeid.
GetUploadtreeTableName($upload_pk)
Get the uploadtree table name for this upload_pk If upload_pk does not exist, return "uploadtree".
Fatal($msg, $filenm, $lineno)
Write message to stdout and die.
HumanDuration(DateInterval $duration)
Convert DateInterval to Human readable format.
HostListOption()
Get host list.
GetUploadName($upload_pk)
Get Upload Name through upload id.
Convert2BrowserTime($server_time)
Convert the server time to browser time.
Get1stUploadtreeID($upload)
Get 1st uploadtree id through upload id.
debugbacktrace()
Debug back trace.
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN