// ftp publishing require 'core.php'; require APPLICATION_LIBPATH . 'functions.inc.php'; // This page requires authentication require APPLICATION_LIBPATH . 'auth.inc.php'; // External variables $file = cleanvar($_REQUEST['file']); $action = cleanvar($_REQUEST['action']); $max_filesize = return_bytes($CONFIG['upload_max_filesize']); if (empty($action)) { include APPLICATION_INCPATH . 'htmlheader.inc.php'; echo "<h2>Upload Public File</h2>"; echo "<p align='center'>IMPORTANT: Files published here are <strong>public</strong> and available to all ftp users.</p>"; echo "<form name='publishform' action='{$_SERVER['PHP_SELF']}' method='post' enctype='multipart/form-data'>"; echo "<table class='vertical'>"; echo "<tr><th>File <small>(<" . readable_file_size($max_filesize) . ")</small>:</th>"; echo "<td class='shade2'><input type='hidden' name='MAX_FILE_SIZE' value='{$max_filesize}' />"; echo "<input type='file' name='file' size='40'' /></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>{$strExpire}:</th><td>"; echo "<input type='radio' name='expiry_none' value='time'' /> In <em>x</em> days, hours, minutes<br /> "; echo "<input maxlength='3' name='expiry_days' value='{$na_days}' onclick=\"window.document.publishform.expiry_none[0].checked = true;\" size='3'' /> Days "; echo "<input maxlength='2' name='expiry_hours' value='{$na_hours}' onclick=\"window.document.publishform.expiry_none[0].checked = true;\" size='3'' /> Hours "; echo "<input maxlength='2' name='expiry_minutes' value='{$na_minutes}' onclick=\"window.document.publishform.expiry_none[0].checked = true;\" size='3'' /> Minutes<br />"; echo "<input type='radio' name='expiry_none' value='date'' />On specified Date<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}\" ";
/** * Update page */ function display_update_page($draftid = -1) { global $id; global $incidentid; global $action; global $CONFIG; global $iconset; global $now; global $dbDrafts; global $sit; if ($draftid != -1) { $draftsql = "SELECT * FROM `{$dbDrafts}` WHERE id = {$draftid}"; $draftresult = mysql_query($draftsql); if (mysql_error()) { trigger_error(mysql_error(), E_USER_WARNING); } $draftobj = mysql_fetch_object($draftresult); $metadata = explode("|", $draftobj->meta); } // No update body text detected show update form ?> <script type="text/javascript"> <!-- function deleteOption(object) { var Current = object.updatetype.selectedIndex; object.updatetype.options[Current] = null; } function notarget(object) { // remove last option var length = object.updatetype.length; if (length > 6) { object.updatetype.selectedIndex=6; var Current = object.updatetype.selectedIndex; object.updatetype.options[Current] = null; } object.priority.value=object.storepriority.value; //object.priority.disabled=true; object.priority.disabled=false; object.updatetype.selectedIndex=0; object.updatetype.disabled=false; } function initialresponse(object) { // remove last option var length = object.updatetype.length; if (length > 6) { object.updatetype.selectedIndex=6; var Current = object.updatetype.selectedIndex; object.updatetype.options[Current] = null; } object.priority.value=object.storepriority.value; object.priority.disabled=true; object.updatetype.selectedIndex=0; object.updatetype.disabled=false; } function actionplan(object) { // remove last option var length = object.updatetype.length; if (length > 6) { object.updatetype.selectedIndex=6; var Current = object.updatetype.selectedIndex; object.updatetype.options[Current] = null; } var defaultSelected = true; var selected = true; var optionName = new Option('Action Plan', 'actionplan', defaultSelected, selected) var length = object.updatetype.length; object.updatetype.options[length] = optionName; object.priority.value=object.storepriority.value; object.priority.disabled=true; object.updatetype.disabled=true; } function reprioritise(object) { // remove last option var length = object.updatetype.length; if (length > 6) { object.updatetype.selectedIndex=6; var Current = object.updatetype.selectedIndex; object.updatetype.options[Current] = null; } // add new option var defaultSelected = true; var selected = true; var optionName = new Option('Reprioritise', 'solution', defaultSelected, selected) var length = object.updatetype.length; object.updatetype.options[length] = optionName; object.priority.disabled=false; document.updateform.priority.disabled=false; object.updatetype.disabled=true; } function probdef(object) { // remove last option var length = object.updatetype.length; if (length > 6) { object.updatetype.selectedIndex=6; var Current = object.updatetype.selectedIndex; object.updatetype.options[Current] = null; } var defaultSelected = true; var selected = true; var optionName = new Option('Problem Definition', 'probdef', defaultSelected, selected) var length = object.updatetype.length; object.updatetype.options[length] = optionName; object.priority.value=object.storepriority.value; object.priority.disabled=true; object.updatetype.disabled=true; } function replaceOption(object) { var Current = object.updatetype.selectedIndex; object.updatetype.options[Current].text = object.currentText.value; object.updatetype.options[Current].value = object.currentText.value; } <?php echo "var draftid = {$draftid}"; ?> // Auto save function save_content(){ var xmlhttp=false; if (!xmlhttp && typeof XMLHttpRequest!='undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp=false; } } if (!xmlhttp && window.createRequest) { try { xmlhttp = window.createRequest(); } catch (e) { xmlhttp=false; } } var toPass = $('updatelog').value; //alert(toPass.value); var meta = $('target').value+"|"+$('updatetype').value+"|"+$('cust_vis').checked+"|"; meta += $('priority').value+"|"+$('newstatus').value+"|"+$('nextaction').value+"|"; if (toPass != '') { // xmlhttp.open("GET", "ajaxdata.php?action=auto_save&userid="+<?php echo $_SESSION['userid']; ?> +"&type=update&incidentid="+<?php echo $id; ?> +"&draftid="+draftid+"&meta="+meta+"&content="+escape(toPass), true); var url = "ajaxdata.php"; var params = "action=auto_save&userid="+<?php echo $_SESSION['userid']; ?> +"&type=update&incidentid="+<?php echo $id; ?> +"&draftid="+draftid+"&meta="+meta+"&content="+escape(toPass); xmlhttp.open("POST", url, true) xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xmlhttp.setRequestHeader("Content-length", params.length); xmlhttp.setRequestHeader("Connection", "close"); xmlhttp.onreadystatechange=function() { //remove this in the future after testing if (xmlhttp.readyState==4) { if (xmlhttp.responseText != ''){ //alert(xmlhttp.responseText); if (draftid == -1) { draftid = xmlhttp.responseText; $('draftid').value = draftid; } var currentTime = new Date(); var hours = currentTime.getHours(); var minutes = currentTime.getMinutes(); if (minutes < 10) { minutes = "0"+minutes; } var seconds = currentTime.getSeconds(); if (seconds < 10) { seconds = "0"+seconds; } $('updatestr').innerHTML = '<?php echo "<a href=\"javascript:save_content();\">" . icon('save', 16, $GLOBALS['strSaveDraft']) . "</a> " . icon('info', 16, $GLOBALS['strDraftLastSaved']) . " "; ?> ' + hours + ':' + minutes + ':' + seconds; } } } xmlhttp.send(params); } } setInterval("save_content()", 10000); //every 10 seconds //--> </script> <?php echo show_form_errors('update'); clear_form_errors('update'); //echo "<form action='".$_SERVER['PHP_SELF']."?id={$id}&draftid={$draftid}' method='post' name='updateform' id='updateform' enctype='multipart/form-data'>"; echo "<form action='" . $_SERVER['PHP_SELF'] . "?id={$id}' method='post' name='updateform' id='updateform' enctype='multipart/form-data'>"; echo "<table class='vertical'>"; echo "<tr>"; echo "<th align='right' width='20%;'>{$GLOBALS['strSLATarget']}"; echo icon('sla', 16) . "</th>"; echo "<td class='shade2'>"; $target = incident_get_next_target($id); $targetNone = ''; $targetInitialresponse = ''; $targetProbdef = ''; $targetActionplan = ''; $targetSolution = ''; $typeResearch = ''; $typeEmailin = ''; $typeEmailout = ''; $typePhonecallin = ''; $typePhonecallout = ''; $typeExternalinfo = ''; $typeReviewmet = ''; if (!empty($metadata)) { switch ($metadata[0]) { case 'none': $targetNone = " SELECTED "; break; case 'initialresponse': $targetInitialresponse = " SELECTED "; break; case 'probdef': $targetProbdef = " SELECTED "; break; case 'actionplan': $targetActionplan = " SELECTED "; break; case 'solution': $targetSolution = " SELECTED "; break; } switch ($metadata[1]) { case 'research': $typeResearch = " SELECTED "; break; case 'emailin': $typeEmailin = " SELECTED "; break; case 'emailout': $typeEmailout = " SELECTED "; break; case 'phonecallin': $typePhonecallin = " SELECTED "; break; case 'phonecallout': $typePhonecallout = " SELECTED "; break; case 'externalinfo': $typeExternalinfo = " SELECTED "; break; case 'reviewmet': $typeReviewmet = " SELECTED "; break; } } echo "<select name='target' id='target' class='dropdown'>\n"; echo "<option value='none' {$targetNone} onclick='notarget(this.form)'>{$GLOBALS['strNone']}</option>\n"; switch ($target->type) { case 'initialresponse': echo "<option value='initialresponse' {$targetInitialresponse} style='text-indent: 15px; height: 17px; background-image: url({$CONFIG['application_webpath']}images/icons/{$iconset}/16x16/initialresponse.png); background-repeat: no-repeat;' onclick='initialresponse(this.form)' >{$GLOBALS['strInitialResponse']}</option>\n"; echo "<option value='probdef' {$targetProbdef} style='text-indent: 15px; height: 17px; background-image: url({$CONFIG['application_webpath']}images/icons/{$iconset}/16x16/probdef.png); background-repeat: no-repeat;' onclick='probdef(this.form)'>{$GLOBALS['strProblemDefinition']}</option>\n"; echo "<option value='actionplan' {$targetActionplan} style='text-indent: 15px; height: 17px; background-image: url({$CONFIG['application_webpath']}images/icons/{$iconset}/16x16/actionplan.png); background-repeat: no-repeat;' onclick='actionplan(this.form)'>{$GLOBALS['strActionPlan']}</option>\n"; echo "<option value='solution' {$targetSolution} style='text-indent: 15px; height: 17px; background-image: url({$CONFIG['application_webpath']}images/icons/{$iconset}/16x16/solution.png); background-repeat: no-repeat;' onclick='reprioritise(this.form)'>{$GLOBALS['strResolutionReprioritisation']}</option>\n"; break; case 'probdef': echo "<option value='probdef' {$targetProbdef} style='text-indent: 15px; height: 17px; background-image: url({$CONFIG['application_webpath']}images/icons/{$iconset}/16x16/probdef.png); background-repeat: no-repeat;' onclick='probdef(this.form)'>{$GLOBALS['strProblemDefinition']}</option>\n"; echo "<option value='actionplan' {$targetActionplan} style='text-indent: 15px; height: 17px; background-image: url({$CONFIG['application_webpath']}images/icons/{$iconset}/16x16/actionplan.png); background-repeat: no-repeat;' onclick='actionplan(this.form)'>{$GLOBALS['strActionPlan']}</option>\n"; echo "<option value='solution' {$targetSolution} style='text-indent: 15px; height: 17px; background-image: url({$CONFIG['application_webpath']}images/icons/{$iconset}/16x16/solution.png); background-repeat: no-repeat;' onclick='reprioritise(this.form)'>{$GLOBALS['strResolutionReprioritisation']}</option>\n"; break; case 'actionplan': echo "<option value='actionplan' {$targetActionplan} style='text-indent: 15px; height: 17px; background-image: url({$CONFIG['application_webpath']}images/icons/{$iconset}/16x16/actionplan.png); background-repeat: no-repeat;' onclick='actionplan(this.form)'>{$GLOBALS['strActionPlan']}</option>\n"; echo "<option value='solution' {$targetSolution} style='text-indent: 15px; height: 17px; background-image: url({$CONFIG['application_webpath']}images/icons/{$iconset}/16x16/solution.png); background-repeat: no-repeat;' onclick='reprioritise(this.form)'>{$GLOBALS['strResolutionReprioritisation']}</option>\n"; break; case 'solution': echo "<option value='solution' {$targetSolution} style='text-indent: 15px; height: 17px; background-image: url({$CONFIG['application_webpath']}images/icons/{$iconset}/16x16/solution.png); background-repeat: no-repeat;' onclick='reprioritise(this.form)'>{$GLOBALS['strResolutionReprioritisation']}</option>\n"; break; } echo "</select>\n"; echo "</td></tr>\n"; echo "<tr><th align='right'>{$GLOBALS['strUpdateType']}</th>"; echo "<td class='shade1'>"; echo "<select name='updatetype' id='updatetype' class='dropdown'>"; /* if ($target->type!='actionplan' && $target->type!='solution') echo "<option value='probdef'>Problem Definition</option>\n"; if ($target->type!='solution') echo "<option value='actionplan'>Action Plan</option>\n"; */ echo "<option value='research' {$typeResearch} selected='selected' style='text-indent: 15px; height: 17px; background-image: url({$CONFIG['application_webpath']}images/icons/{$iconset}/16x16/research.png); background-repeat: no-repeat;'>{$GLOBALS['strResearchNotes']}</option>\n"; echo "<option value='emailin' {$typeEmailin} style='text-indent: 15px; height: 17px; background-image: url({$CONFIG['application_webpath']}images/icons/{$iconset}/16x16/emailin.png); background-repeat: no-repeat;'>{$GLOBALS['strEmailFromCustomer']}</option>\n"; echo "<option value='emailout' {$typeEmailout} style='text-indent: 15px; height: 17px; background-image: url({$CONFIG['application_webpath']}images/icons/{$iconset}/16x16/emailout.png); background-repeat: no-repeat;'>{$GLOBALS['strEmailToCustomer']}</option>\n"; echo "<option value='phonecallin' {$typePhonecallin} style='text-indent: 15px; height: 17px; background-image: url({$CONFIG['application_webpath']}images/icons/{$iconset}/16x16/callin.png); background-repeat: no-repeat;'>{$GLOBALS['strCallFromCustomer']}</option>\n"; echo "<option value='phonecallout' {$typePhonecallout} style='text-indent: 15px; height: 17px; background-image: url({$CONFIG['application_webpath']}images/icons/{$iconset}/16x16/callout.png); background-repeat: no-repeat;'>{$GLOBALS['strCallToCustomer']}</option>\n"; echo "<option value='externalinfo' {$typeExternalinfo} style='text-indent: 15px; height: 17px; background-image: url({$CONFIG['application_webpath']}images/icons/{$iconset}/16x16/externalinfo.png); background-repeat: no-repeat;'>{$GLOBALS['strExternalInfo']}</option>\n"; echo "<option value='reviewmet' {$typeReviewmet} style='text-indent: 15px; height: 17px; background-image: url({$CONFIG['application_webpath']}images/icons/{$iconset}/16x16/review.png); background-repeat: no-repeat;'>{$GLOBALS['strReview']}</option>\n"; echo "</select>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<th align='right'>{$GLOBALS['strUpdate']}<br />"; echo "<span class='required'>{$GLOBALS['strRequired']}</span></th>"; echo "<td class='shade1'>"; $checkbox = ''; if (!empty($metadata)) { if ($metadata[2] == "true") { $checkbox = "checked='checked'"; } } else { $checkbox = "checked='checked'"; } echo "<label><input type='checkbox' name='cust_vis' id='cust_vis' "; echo "{$checkbox} value='yes' /> {$GLOBALS['strMakeVisibleInPortal']}<label><br />"; echo bbcode_toolbar('updatelog'); echo "<textarea name='bodytext' id='updatelog' rows='13' cols='50'>"; if ($draftid != -1) { echo $draftobj->content; } echo "</textarea>"; echo "<div id='updatestr'><a href='javascript:save_content();'>" . icon('save', 16, $GLOBALS['strSaveDraft']) . "</a></div>"; echo "</td></tr>"; if ($target->type == 'initialresponse') { $disable_priority = TRUE; } else { $disable_priority = FALSE; } echo "<tr><th align='right'>{$GLOBALS['strNewPriority']}</th>"; echo "<td class='shade1'>"; // // FIXME fix maximum priority // $servicelevel=maintenance_servicelevel(incident_maintid($id)); // if ($servicelevel == 2 || $servicelevel == 5) $maxpriority = 4; // else $maxpriority = 3; $maxpriority = 4; $setPriorityTo = incident_priority($id); if (!empty($metadata)) { $setPriorityTo = $metadata[3]; } echo priority_drop_down("newpriority", $setPriorityTo, $maxpriority, $disable_priority); //id='priority echo "</td></tr>\n"; echo "<tr>"; echo "<th align='right'>{$GLOBALS['strNewStatus']}</th>"; $setStatusTo = incident_status($id); $disabled = FALSE; //we do this so if you update another user's incident, it defaults to active if ($sit[2] != incident_owner($incidentid)) { $setStatusTo = '0'; } elseif (!empty($metadata)) { $setStatusTo = $metadata[4]; } echo "<td class='shade1'>" . incidentstatus_drop_down("newstatus", $setStatusTo) . "</td>"; echo "</tr>"; echo "<tr>"; echo "<th align='right'>{$GLOBALS['strNextAction']}</th>"; $nextAction = ''; if (!empty($metadata)) { $nextAction = $metadata[5]; } echo "<td class='shade2'><input type='text' name='nextaction' "; echo "id='nextaction' maxlength='50' size='30' value='{$nextAction}' /></td></tr>"; echo "<tr>"; echo "<th align='right'>"; echo "<strong>{$GLOBALS['strTimeToNextAction']}</strong></th>"; echo "<td class='shade2'>"; echo show_next_action(); echo "</td></tr>"; echo "<tr>"; // calculate upload filesize $att_file_size = readable_file_size($CONFIG['upload_max_filesize']); echo "<th align='right'>{$GLOBALS['strAttachFile']}"; echo " (<{$att_file_size})</th>"; echo "<td class='shade1'><input type='hidden' name='MAX_FILE_SIZE' value='{$CONFIG['upload_max_filesize']}' />"; echo "<input type='file' name='attachment' size='40' maxfilesize='{$CONFIG['upload_max_filesize']}' /></td>"; echo "</tr>"; echo "</table>"; echo "<p class='center'>"; echo "<input type='hidden' name='action' value='update' />"; if ($draftid == -1) { $localdraft = ''; } else { $localdraft = $draftid; } echo "<input type='hidden' name='draftid' id='draftid' value='{$localdraft}' />"; echo "<input type='hidden' name='storepriority' value='" . incident_priority($id) . "' />"; echo "<input type='submit' name='submit' value='{$GLOBALS['strUpdateIncident']}' /></p>"; echo "</form>"; }
$sql .= "ORDER BY filedate "; break; case 'published': $sql .= "ORDER BY published "; break; default: $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 "</a>"; if ($num_attachments > 0) { echo ' ' . icon('attach', 16, '', "{$strAttachments}: {$num_attachments}"); } } echo "</td>"; // echo "<td><pre>".print_r($incoming,true)."</pre><hr /></td>"; // Date echo "<td>"; if (!empty($update->timestamp)) { echo date($CONFIG['dateformat_datetime'], $update->timestamp); } echo "</td>"; // Size echo "<td style='white-space:nowrap;'>"; echo readable_file_size(strlen($update->bodytext)); echo "</td>"; echo "</tr>"; if ($shade == 'shade1') { $shade = 'shade2'; } else { $shade = 'shade1'; } } echo "<tr>"; // Select All echo "<td>" . html_checkbox('item', FALSE, '', "onclick=\"checkAll('inboxform', this.checked);\"") . "</td>"; // Operation echo "<td colspan='*'>"; echo "<select name='action'>"; echo "<option value='' selected='selected'></option>";
if (trim($ccemail) == ",") { $ccemail = ''; } if (substr($ccemail, 0, 1) == ",") { $ccfield = substr($ccemail, 1, strlen($ccemail)); } echo "<tr><th>{$strCC}</th><td><input maxlength='100' name='ccfield' "; echo "id='ccfield' size='40' value=\"{$ccemail}\" /></td></tr>\n"; echo "<tr><th>{$strBCC}</th><td><input maxlength='100' name='bccfield' "; echo "id='bccfield' size='40' value=\"{$bccemail}\" /></td></tr>\n"; echo "<tr><th>{$strTo}</th><td><input maxlength='100' name='tofield' "; echo "id='tofield' size='40' value=\"{$toemail}\" /></td></tr>\n"; echo "<tr><th>{$strSubject}</th><td><input maxlength='255' "; echo "name='subjectfield' id='subjectfield' size='40' value=\"{$subject}\" /></td></tr>\n"; echo "<tr><th>{$strAttachment}"; $file_size = readable_file_size($CONFIG['upload_max_filesize']); echo "(< {$file_size})"; echo "</th><td>"; echo "<input type='hidden' name='MAX_FILE_SIZE' value='{$CONFIG['upload_max_filesize']}' />"; echo "<input type='file' name='attachment' size='40' maxfilesize='{$CONFIG['upload_max_filesize']}' />"; echo "</td></tr>"; echo "<tr><th>{$strMessage}</th><td>"; echo "<textarea name='bodytext' id='bodytext' rows='20' cols='65'>"; echo $body; echo "</textarea>"; echo "<div id='updatestr'><a href='javascript:save_content();'>" . icon('save', 16, $strSaveDraft) . "</a></div>"; echo "</td></tr>"; plugin_do('incident_email_form2'); echo "</table>"; echo "<p align='center'>"; echo "<input name='newincidentstatus' id='newincidentstatus' type='hidden' value='{$newincidentstatus}' />";
/** * @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; }