// calculate filesize $j = 0; $ext = array($strBytes, $strKBytes, $strMBytes, $strGBytes, $strTBytes); $pretty_file_size = $frow['size']; while ($pretty_file_size >= pow(1024, $j)) { ++$j; } $pretty_file_size = round($pretty_file_size / pow(1024, $j - 1) * 100) / 100 . ' ' . $ext[$j - 1]; ?> <h2><?php echo $title; ?> </h2> <table summary="file-details" align="center" width="60%" class='vertical'> <tr><th>File:</th><td><img src="<?php echo getattachmenticon($frow['filename']); ?> " alt="<?php echo $frow['filename']; ?> (<?php echo $pretty_file_size; ?> )" border='0' /> <strong><?php echo $frow['filename']; ?> </strong> (<?php echo $pretty_file_size; ?> )</td></tr>
$sql .= "ORDER by filename "; break; } $result = mysql_query($sql); if (mysql_error()) { trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING); } if (mysql_numrows($result) > 0) { while (list($id, $filename, $size, $userid, $shortdescription, $path, $downloads, $filedate, $fileversion, $expiry, $published) = mysql_fetch_row($result)) { $pretty_file_size = readable_file_size($size); if ($published == 'no') { echo "<tr class='urgent'>"; } else { echo "<tr>"; } echo "<td align='right'><img src=\"" . getattachmenticon($filename) . "\" alt=\"{$filename} ({$pretty_file_size})\" border='0' /></td>"; echo "<td><strong><a href=\"ftp_file_details.php?id={$id}\">{$filename}</a></strong></td>"; echo "<td>{$pretty_file_size}</td>"; echo "<td>{$shortdescription}</td>"; echo "<td>{$fileversion}</td>"; echo "<td>" . ldate($CONFIG['dateformat_filedatetime'], $filedate) . "</td>"; echo "<td>"; if ($expiry == 0) { echo 'Never'; } else { echo ldate($CONFIG['dateformat_filedatetime'], $expiry); } echo "</td>"; echo "<td>{$published}</td>"; echo "</tr>\n"; }
$randvalb = mt_rand() % ($maxVal - $minVal) + $minVal; $randomdir = dechex(crc32($randvala . $randvalb)); $filesize = filesize($source_file); $pretty_file_size = readable_file_size($filesize); // FIXME This temp variable name can't be right can it? INL if (!isset($temp_directory)) { // show form include APPLICATION_INCPATH . 'htmlheader.inc.php'; echo "<h2>{$strFTPPublish}</h2>"; echo "<form name='publishform' action='{$_SERVER['PHP_SELF']}' method='post'>"; echo "<input type='hidden' name='source_file' value='{$source_file}' />"; echo "<input type='hidden' name='destination_file' value='{$destination_file}' />"; echo "<input type='hidden' name='temp_directory' value='{$randomdir}' />"; echo "<input type='hidden' name='ftp_url' value=\"ftp://{$CONFIG['ftp_hostname']}{$CONFIG['ftp_path']}{$randomdir}/{$destination_file}\" />"; echo "<table summary='ftp-publish' align='center' width='60%' class='vertical'>"; echo "<tr><th>{$strPublish}:</th><td><img src='" . getattachmenticon($filename) . "' alt='{$filename} ({$pretty_file_size})' border='0' />"; echo "<strong>{$destination_file}</strong> ({$pretty_file_size})</td></tr>"; echo "<tr><th>{$strTo}:</th><td><code>'ftp://{$CONFIG['ftp_hostname']}{$CONFIG['ftp_path']}{$randomdir}/{$destination_file}</code></td></tr>"; echo "<tr><th>{$strTitle}:</th><td><input type='text' name='shortdescription' maxlength='255' size='40'' /></td></tr>"; echo "<tr><th>{$strDescription}:</th><td><textarea name='longdescription' cols='40' rows='3'></textarea></td></tr>"; echo "<tr><th>{$strFileVersion}:</th><td><input type='text' name='fileversion' maxlength='50' size='10' /></td></tr>"; echo "<tr><th>{$strValid}:</th><td>"; echo "<input type='radio' name='expiry_none' value='time'> {$strForXDaysHoursMinutes}<br /> "; echo "<input maxlength='3' name='expiry_days' value='{$na_days}' onclick=\"window.document.publishform.expiry_none[0].checked = true;\" size='3' /> {$strDays} "; echo "<input maxlength='2' name='expiry_hours' value='{$na_hours}' onclick=\"window.document.publishform.expiry_none[0].checked = true;\" size='3' /> {$strHours} "; echo "<input maxlength='2' name='expiry_minutes' value='{$na_minutes}' onclick=\"window.document.publishform.expiry_none[0].checked = true;\" size='3' /> {$strMinutes}<br />"; echo "<input type='radio' name='expiry_none' value='date'>{$strUntilSpecificDateAndTime}<br /> "; // Print Listboxes for a date selection echo "<select name='day' onclick=\"window.document.publishform.expiry_none[1].checked = true;\">"; for ($t_day = 1; $t_day <= 31; $t_day++) { echo "<option value=\"{$t_day}\" ";
trigger_error("MySQL Query Error " . mysql_error(), E_USER_WARNING); } $obj = mysql_fetch_object($result); // calculate filesize $j = 0; $ext = array($strBytes, $strKBytes, $strMBytes, $strGBytes, $strTBytes); $pretty_file_size = $obj->size; while ($pretty_file_size >= pow(1024, $j)) { ++$j; } $pretty_file_size = round($pretty_file_size / pow(1024, $j - 1) * 100) / 100 . ' ' . $ext[$j - 1]; echo "<h2>{$title}</h2>"; echo "<form action='{$_SERVER['PHP_SELF']}' method='post'>"; echo "<table summary='edit file details' align='center' width='60%' class='vertical'>"; echo "<tr><th>{$strFile}:</th><td>"; echo "<img src='" . getattachmenticon($obj->filename) . "' alt='{$obj->filename} ({$pretty_file_size})' border='0' />"; echo "<strong>{$frow['filename']}</strong> ({$pretty_file_size})</td></tr>"; if ($obj->path == '') { $ftp_path = $CONFIG['ftp_path']; } else { $ftp_path = $CONFIG['ftp_path'] . substr($obj->path, 1) . '/'; } echo "<tr><th>{$strLocation}:</th><td><a href=\"ftp://{$CONFIG['ftp_hostname']}{$ftp_path}{$obj->filename}\"><code>"; echo "ftp://{$CONFIG['ftp_hostname']}{$ftp_path}{$obj->filename}</code></a></td></tr>\n"; echo "<tr><th>{$strTitle}:</th><td>"; echo "<input type='text' size='40' name='shortdescription' value='{$obj->shortdescription}' />"; echo "</td></tr>\n"; echo "<tr><th>{$strCategory}:</th><td>"; echo "<input type='text' size='40' name='webcategory' value='{$obj->webcategory}' />"; echo "</td></tr>\n"; echo "<tr><th>{$strDescription}:</th><td>";
} } echo "<h3>{$strFiles}</h3>"; $filesql = "SELECT *, f.id AS fileid, u.id AS updateid, f.userid AS userid\n FROM `{$dbFiles}` AS f, `{$dbLinks}` AS l, `{$dbUpdates}` AS u\n WHERE f.category='public'\n AND l.linktype='5'\n AND l.linkcolref=f.id\n AND l.origcolref=u.id\n AND u.incidentid='{$incidentid}'\n ORDER BY f.filedate DESC"; $fileresult = mysql_query($filesql); if (mysql_error()) { trigger_error("MySQL Query Error {$sql}" . mysql_error(), E_USER_WARNING); } $delim = $fsdelim; while ($filerow = mysql_fetch_object($fileresult)) { $fileid = intval($filerow->fileid); $filename = cleanvar($filerow->filename); if (strlen($filename) > 30) { $filename = substr($filename, 0, 30) . "..."; } $icon = getattachmenticon($filename); echo "<div class='portalfileicon'><img src='{$icon}' /></div>"; echo "<a href='download.php?id={$fileid}'>{$filename}</a><br />"; if ($filerow->userid != 0) { if ($filerow->usertype == 'contact') { echo sprintf($strUploadedBy, contact_realname($filerow->userid)) . " "; } else { echo sprintf($strUploadedBy, user_realname($filerow->userid)) . " "; } } echo "<br />" . ldate($CONFIG['dateformat_datetime'], mysql2date($filerow->filedate)) . "<br /><br />"; } echo "</div>"; echo "<div id='portalright'>"; while ($update = mysql_fetch_object($result)) { if (empty($firstid)) {
/** * @author Ivan Lucas */ function draw_file_row($file, $fsdelim, $incidentid, $path) { global $CONFIG; $filepathparts = explode($fsdelim, $file); $parts = count($filepathparts); $filename = $filepathparts[$parts - 1]; $filedir = $filepathparts[$parts - 2]; $preview = ''; // reset the preview $filenameparts = explode("-", $filename); $newfilename = cleanvar($filenameparts[1]); if ($filedir != $incidentid) { // files are in a subdirectory //$url="attachments/$id/".substr($filesarray[$c],strrpos($directory,$delim)+1,strlen($filesarray[$c])-strlen(urlencode($filename)).urlencode(filename)); $url = "{$CONFIG['attachment_webpath']}{$incidentid}/{$filedir}/" . str_replace('+', '%20', urlencode($filename)); } else { // files are in the root of the incident attachment directory // $url="attachments/".substr($filesarray[$c],strrpos($directory,$delim)+1,strlen($filesarray[$c])-strlen(urlencode($filename)).urlencode(filename)); $url = "{$CONFIG['attachment_webpath']}{$incidentid}/" . str_replace('+', '%20', urlencode($filename)); } $filesize = filesize($file); $file_size = readable_file_size($filesize); if (function_exists('mime_content_type')) { // FIXME mime_content_type is deprecated $mime_type = mime_content_type($file); } else { // TODO find a reliable cross/platform low dependency way of determining mime type if possibe // At the moment we leave mime_type blank if we can't find mime_content_type $mime_type = ''; } $updateid = str_replace("u", "", $filedir); $sql = "SELECT f.id FROM `{$GLOBALS['dbLinks']}`, `{$GLOBALS['dbFiles']}` AS f "; $sql .= "WHERE linktype = '5' AND origcolref='{$updateid}' "; $sql .= "AND f.id = linkcolref "; $result = mysql_query($sql); $fileobj = mysql_fetch_object($result); $fileid = $fileobj->id; //new-style, can assume the filename is fileid-filename.ext if (is_numeric($filenameparts[0])) { $sql = "SELECT *, f.id AS fileid FROM `{$GLOBALS['dbLinks']}` AS l, "; $sql .= "`{$GLOBALS['dbFiles']}` as f, "; $sql .= "`{$GLOBALS['dbUpdates']}` as u "; $sql .= "WHERE f.id = '{$filenameparts[0]}' "; $sql .= "AND l.origcolref = u.id "; $sql .= "AND l.linkcolref = f.id"; $result = mysql_query($sql); $row = mysql_fetch_object($result); $url = "download.php?id={$row->fileid}"; $filename = $row->filename; } $html = "<tr>"; $html .= "<td align='right' width='5%'>"; $html .= "<a href=\"{$url}\"><img src='" . getattachmenticon($filename) . "' alt='Icon' title='{$filename} ({$file_size})' /></a>"; $html .= " </td>"; $html .= "<td width='30%'><a href='{$url}'"; if (substr($mime_type, 0, 4) == 'text' and $filesize < 512000) { // The file is text, extract some of the contents of the file into a string for a preview $handle = fopen($file, "r"); $preview = fread($handle, 512); // only read this much, we can't preview the whole thing, not enough space fclose($handle); // Make the preview safe to display $preview = nl2br(encode_binary(strip_tags($preview))); $html .= " class='info'><span>{$preview}</span>{$filename}</a>"; } else { $html .= ">{$filename}</a>"; } $html .= "</td>"; $html .= "<td width='20%'>{$file_size}</td>"; $html .= "<td width='20%'>{$mime_type}</td>"; $html .= "<td width='20%'>" . ldate($CONFIG['dateformat_filedatetime'], filemtime($file)) . "</td>"; //$html .= "<td width='5%'><input type='checkbox' name='fileselection[]' value='{$filename}' onclick=\"togglerow(this, 'tt');\"/></td>"; $html .= "</tr>\n"; return $html; }