42 $FirstEmpty=
false, $SelElt=
true, $Options=
"", $ReturnKey=
true)
44 $str =
"\n<select name='$SLName' $Options>\n";
45 if ($FirstEmpty ==
true) {
46 $str .=
"<option value='' > </option>\n";
48 foreach ($KeyValArray as $key => $val) {
49 if ($SelElt ==
true) {
50 $SELECTED = ($val == $SelectedVal) ?
"SELECTED" :
"";
52 $SELECTED = ($key == $SelectedVal) ?
"SELECTED" :
"";
54 if ($ReturnKey ==
true) {
55 $str .=
"<option value='$key' $SELECTED>".htmlentities($val, ENT_QUOTES).
"</option>\n";
57 $str .=
"<option value='$val' $SELECTED>".htmlentities($val, ENT_QUOTES).
"</option>\n";
75 function Fatal($msg, $filenm, $lineno)
77 echo
"<hr>FATAL error, File: $filenm, Line number: $lineno<br>";
89 debug_print_backtrace();
100 echo $title,
"<pre>";
111 foreach (array(
'B',
'KB',
'MB',
'GB',
'TB') as $unit) {
113 return(round($bytes, 2) .
' '. $unit);
117 return(round($bytes, 2) .
' PB');
129 $extpos = strrpos($fname,
'.') + 1;
130 $extension = strtolower(substr($fname, $extpos));
145 if (! is_array($Arr)) {
148 if (array_key_exists($Key, $Arr)) {
165 foreach ($SysConf[
'HOSTS'] as $key => $value) {
166 $options .=
"<option value='$key' SELECTED> $key </option>\n";
186 $connstat = connection_status();
187 if ($connstat != 0) {
188 return _(
"Lost connection.");
191 $session =
new Session();
195 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");
196 header(
"Last-Modified: ".gmdate(
"D, d M Y H:i:s").
" GMT");
197 header(
'Content-Description: File Transfer');
198 header(
"Content-Type: $contentType");
199 header(
"Content-Length: ".(
string)(strlen($text)));
200 header(
"Content-Disposition: attachment; filename=\"$name\"");
201 header(
"Content-Transfer-Encoding: binary\n");
204 if ((connection_status() == 0) and ! connection_aborted()) {
207 return _(
"Lost connection.");
221 if (! empty($upload_pk)) {
222 $upload_rec =
GetSingleRec(
"upload",
"where upload_pk='$upload_pk'");
223 if (! empty($upload_rec[
'uploadtree_tablename'])) {
224 return $upload_rec[
'uploadtree_tablename'];
239 if (empty($upload_pk)) {
242 $upload_rec =
GetSingleRec(
"upload",
"where upload_pk='$upload_pk'");
243 $upload_filename = $upload_rec[
'upload_filename'];
244 if (empty($upload_filename)) {
247 return $upload_filename;
260 if (empty($uploadtreeid)) {
263 $upload_rec =
GetSingleRec(
"uploadtree",
"where uploadtree_pk=$uploadtreeid");
264 $uploadid = $upload_rec[
'upload_fk'];
265 if (empty($uploadid)) {
282 if (empty($upload)) {
285 $sql =
"SELECT max(uploadtree_pk) from uploadtree where upload_fk = $upload and parent is null;";
286 $result = pg_query($PG_CONN, $sql);
288 $row = pg_fetch_assoc($result);
289 $uploadtree_id = $row[
'max'];
290 pg_free_result($result);
291 return $uploadtree_id;
300 $server_timezone = date_default_timezone_get();
301 $browser_time = new \DateTime($server_time,
new \DateTimeZone($server_timezone));
302 if (array_key_exists(
"timezone", $_SESSION)) {
303 $tz = $_SESSION[
"timezone"];
304 $browser_time->setTimeZone(
new \DateTimeZone($tz));
306 $time = $browser_time->format(
'Y-m-d H:i:s');
DownloadString2File($text, $name, $contentType)
Send a string to a user as a download file.
Convert2BrowserTime($server_time)
Convert the server time to browser time.
GetSingleRec($Table, $Where="")
Retrieve a single database record.
GetUploadID($uploadtreeid)
Get upload id through uploadtreeid.
debugprint($val, $title)
Print debug message.
HostListOption()
Get host list.
GetFileExt($fname)
Get File Extension (text after last period)
foreach($Options as $Option=> $OptVal) if(0==$reference_flag &&0==$nomos_flag) $PG_CONN
HumanSize($bytes)
Translate a byte number to a proper type, xxx bytes to xxx B/KB/MB/GB/TB/PB.
DBCheckResult($result, $sql, $filenm, $lineno)
Check the postgres result for unexpected errors. If found, treat them as fatal.
GetArrayVal($Key, $Arr)
Get the value from a array(map)
Array2SingleSelect($KeyValArray, $SLName="unnamed", $SelectedVal="", $FirstEmpty=false, $SelElt=true, $Options="", $ReturnKey=true)
Build a single choice select pulldown.
debugbacktrace()
Debug back trace.
GetUploadName($upload_pk)
Get Upload Name through upload id.
Get1stUploadtreeID($upload)
Get 1st uploadtree id through upload id.
Fatal($msg, $filenm, $lineno)
Write message to stdout and die.
GetUploadtreeTableName($upload_pk)
Get the uploadtree table name for this upload_pk If upload_pk does not exist, return "uploadtree"...