function DeleteUploadedFiles($where, $table = "") { global $conn, $gstrSQL; $sql = gSQLWhere($where); $rs = db_query($sql, $conn); if (!($data = db_fetch_array($rs))) { return; } foreach ($data as $field => $value) { if (strlen($value) && GetEditFormat($field) == EDIT_FORMAT_FILE) { $isAbs = GetFieldData($table, $field, "Absolute", false); $filename = GetUploadFolder($field) . $value; if (!$isAbs) { $filename = getabspath($filename); } runner_delete_file($filename); if (GetCreateThumbnail($field)) { $filename = GetUploadFolder($field) . GetThumbnailPrefix($field) . $value; if (!$isAbs) { $filename = getabspath($filename); } runner_delete_file($filename); } } } }
function prepare_upload($field, $controltype, $postfilename, $value, $table, $id, &$pageObject) { $abs = GetFieldData($table, $field, "Absolute", false); $file =& $_FILES["value_" . GoodFieldName($field) . "_" . $id]; if ($file["error"] || $value == "") { return false; } if (substr($controltype, 6, 1) == "1") { if (strlen($postfilename)) { $pageObject->filesToDelete[] = new DeleteFile($postfilename, GetUploadFolder($field, $table), $abs); if (GetCreateThumbnail($field, $table)) { $pageObject->filesToDelete[] = new DeleteFile(GetThumbnailPrefix($field, $table) . $postfilename, GetUploadFolder($field, $table), $abs); } } return ""; } if (substr($controltype, 6, 1) == "0") { return false; } if (strlen($file['tmp_name'])) { if (!ResizeOnUpload($field, $table)) { $pageObject->filesToMove[] = new MoveFile($file['tmp_name'], $value, GetUploadFolder($field, $table), $abs); } else { $contents = myfile_get_contents($file['tmp_name']); $ext = CheckImageExtension($file["name"]); $thumb = CreateThumbnail($contents, GetNewImageSize($field, $table), $ext); $pageObject->filesToSave[] = new SaveFile($thumb, $value, GetUploadFolder($field, $table), $abs); } } return $value; }
/** * Proccess record values * * @param array $record * @param array $data * @param string $keylink */ function proccessRecordValue(&$data, &$keylink, $listFieldInfo) { $value = ""; if ($listFieldInfo['viewFormat'] == FORMAT_DATABASE_IMAGE) { if (ShowThumbnail($listFieldInfo['fName'], $this->tName)) { $thumbPref = GetThumbnailPrefix($listFieldInfo['fName'], $this->tName); $value .= "<a"; if (IsUseiBox($listFieldInfo['fName'], $this->tName)) { $value .= " rel='ibox'"; } else { $value .= " target=_blank"; } $value .= " href='imager.php?table=" . $this->shortTableName . "&field=" . rawurlencode($listFieldInfo['fName']) . $keylink . "'>"; $value .= "<img border=0"; if ($this->is508) { $value .= " alt=\"Image from DB\""; } $value .= " src='imager.php?table=" . $this->shortTableName . "&field=" . rawurlencode($thumbPref) . "&alt=" . rawurlencode($listFieldInfo['fName']) . $keylink . "'>"; $value .= "</a>"; } else { $value = "<img"; if ($this->is508) { $value .= " alt=\"Image from DB\""; } $imgWidth = GetImageWidth($listFieldInfo['fName'], $this->tName); $value .= $imgWidth ? " width=" . $imgWidth : ""; $imgHeight = GetImageHeight($listFieldInfo['fName'], $this->tName); $value .= $imgHeight ? " height=" . $imgHeight : ""; $value .= " border=0"; $value .= " src='imager.php?table=" . $this->shortTableName . "&field=" . rawurlencode($listFieldInfo['fName']) . $keylink . "'>"; } } else { if ($listFieldInfo['viewFormat'] == FORMAT_FILE_IMAGE) { if (CheckImageExtension($data[$listFieldInfo['fName']])) { if (ShowThumbnail($listFieldInfo['fName'], $this->tName)) { // show thumbnail $thumbPref = GetThumbnailPrefix($listFieldInfo['fName'], $this->tName); $thumbname = $thumbPref . $data[$listFieldInfo['fName']]; if (substr(GetLinkPrefix($listFieldInfo['fName'], $this->tName), 0, 7) != "http://" && !myfile_exists(GetUploadFolder($listFieldInfo['fName']) . $thumbname)) { $thumbname = $data[$listFieldInfo['fName']]; } $value = "<a"; if (IsUseiBox($listFieldInfo['fName'], $this->tName)) { $value .= " rel='ibox'"; } else { $value .= " target=_blank"; } $value .= " href=\"" . htmlspecialchars(AddLinkPrefix($listFieldInfo['fName'], $data[$listFieldInfo['fName']])) . "\">"; $value .= "<img"; if ($thumbname == $data[$listFieldInfo['fName']]) { $imgWidth = GetImageWidth($listFieldInfo['fName'], $this->tName); $value .= $imgWidth ? " width=" . $imgWidth : ""; $imgHeight = GetImageHeight($listFieldInfo['fName'], $this->tName); $value .= $imgHeight ? " height=" . $imgHeight : ""; } $value .= " border=0"; if ($this->is508) { $value .= " alt=\"" . htmlspecialchars($data[$listFieldInfo['fName']]) . "\""; } $value .= " src=\"" . htmlspecialchars(AddLinkPrefix($listFieldInfo['fName'], $thumbname)) . "\"></a>"; } else { $value = "<img"; $imgWidth = GetImageWidth($listFieldInfo['fName'], $this->tName); $value .= $imgWidth ? " width=" . $imgWidth : ""; $imgHeight = GetImageHeight($listFieldInfo['fName'], $this->tName); $value .= $imgHeight ? " height=" . $imgHeight : ""; $value .= " border=0"; if ($this->is508) { $value .= " alt=\"" . htmlspecialchars($data[$listFieldInfo['fName']]) . "\""; } $value .= " src=\"" . htmlspecialchars(AddLinkPrefix($listFieldInfo['fName'], $data[$listFieldInfo['fName']])) . "\">"; } } } else { if ($listFieldInfo['viewFormat'] == FORMAT_DATABASE_FILE) { $fileNameF = GetFilenameField($listFieldInfo['fName'], $this->tName); if ($fileNameF) { $fileName = $data[$fileNameF]; if (!$fileName) { $fileName = "file.bin"; } } else { $fileName = "file.bin"; } if (strlen($data[$listFieldInfo['fName']])) { $value = "<a href='getfile.php?table=" . $this->shortTableName . "&filename=" . rawurlencode($fileName) . "&field=" . rawurlencode($listFieldInfo['fName']) . $keylink . "'>"; $value .= htmlspecialchars($fileName); $value .= "</a>"; } } else { if ($listFieldInfo['viewFormat'] == FORMAT_AUDIO) { $fileName = GetData($data, $listFieldInfo['fName'], FORMAT_NONE); $fieldIsUrl = GetFieldData($this->tName, $listFieldInfo['fName'], "fieldIsVideoUrl", false); if (strlen($fileName)) { $absFileName = ""; if (!$fieldIsUrl && GetFieldData($this->tName, $listFieldInfo['fName'], "Absolute", false)) { $absFileName = GetUploadFolder($listFieldInfo['fName']) . $fileName; } elseif (!$fieldIsUrl) { $absFileName = getabspath(GetUploadFolder($listFieldInfo['fName']) . $fileName); } // if file if ($fieldIsUrl || file_exists($absFileName)) { $titleField = GetFieldData($this->tName, $listFieldInfo['fName'], 'audioTitleField', ""); $title = ""; if ($titleField) { $title = htmlspecialchars(GetData($data, $titleField, ViewFormat($titleField, $titleField))); } if ($fieldIsUrl) { $href = $fileName; } else { $href = 'download.php?table=' . $this->shortTableName . '&field=' . rawurlencode($listFieldInfo['fName']) . $keylink; } $value = '<a class="htrack" type="audio/mpeg" title="' . $title . '" href="' . $href . '">' . $title . '</a>'; } } } else { if ($listFieldInfo['viewFormat'] == FORMAT_DATABASE_AUDIO) { $titleField = GetFieldData($this->tName, $listFieldInfo['fName'], 'audioTitleField', ""); $title = ""; if ($titleField) { $title = htmlspecialchars(GetData($data, $titleField, ViewFormat($titleField, $titleField))); } if (@$data[$listFieldInfo['fName']] != NULL) { $value = '<a class="htrack" type="audio/mpeg" title="' . $title . '" href="getfile.php?table=' . $this->shortTableName . '&field=' . rawurlencode($listFieldInfo['fName']) . $keylink . '">' . $title . '</a>'; } else { $value = $title; } } else { if ($listFieldInfo['viewFormat'] == FORMAT_VIDEO) { $value = ""; $fieldIsUrl = GetFieldData($this->tName, $listFieldInfo['fName'], "fieldIsVideoUrl", false); $fileName = GetData($data, $listFieldInfo['fName'], FORMAT_NONE); if (strlen($fileName)) { $absFileName = ""; if (!$fieldIsUrl && GetFieldData($this->tName, $listFieldInfo['fName'], "Absolute", false)) { $absFileName = GetUploadFolder($listFieldInfo['fName']) . $fileName; } elseif (!$fieldIsUrl) { $absFileName = getabspath(GetUploadFolder($listFieldInfo['fName']) . $fileName); } // if file if ($fieldIsUrl || file_exists($absFileName)) { $videoId = 'video_' . GoodFieldName(htmlspecialchars($listFieldInfo['fName'])) . '_' . $this->recId; if ($fieldIsUrl) { $href = $fileName; } else { $href = 'download.php?table=' . $this->shortTableName . '&field=' . rawurlencode($listFieldInfo['fName']) . $keylink; } $value = '<a href="' . $href . '" style="display:block;width:' . GetFieldData($this->tName, $listFieldInfo['fName'], 'videoWidth', "") . 'px;height:' . GetFieldData($this->tName, $listFieldInfo['fName'], 'videoHeight', "") . 'px;" id="' . $videoId . '"></a>'; $this->controlsMap['video'][] = $videoId; } } } else { if ($listFieldInfo['viewFormat'] == FORMAT_DATABASE_VIDEO) { if (@$data[$listFieldInfo['fName']] != NULL) { $videoId = 'video_' . GoodFieldName(htmlspecialchars($listFieldInfo['fName'])) . '_' . $this->recId; $value = '<a href="getfile.php?table=' . $this->shortTableName . '&field=' . rawurlencode($listFieldInfo['fName']) . $keylink . '" style="display:block;width:' . GetFieldData($this->tName, $listFieldInfo['fName'], 'videoWidth', 0) . 'px;height:' . GetFieldData($this->tName, $listFieldInfo['fName'], 'videoHeight', 0) . 'px;" id="' . $videoId . '"></a>'; $this->controlsMap['video'][] = $videoId; } } else { if ($listFieldInfo['viewFormat'] == FORMAT_MAP) { $value = '<div id="littleMap_' . GoodFieldName($listFieldInfo['fName']) . '_' . $this->recId . '" style="width: ' . $this->googleMapCfg['fieldsAsMap'][$listFieldInfo['fName']]['width'] . 'px; height: ' . $this->googleMapCfg['fieldsAsMap'][$listFieldInfo['fName']]['height'] . 'px;"></div>'; } else { if (($listFieldInfo['editFormat'] == EDIT_FORMAT_LOOKUP_WIZARD || $listFieldInfo['editFormat'] == EDIT_FORMAT_RADIO) && GetLookupType($listFieldInfo['fName'], $this->tName) == LT_LOOKUPTABLE && GetLWLinkField($listFieldInfo['fName'], $this->tName) != GetLWDisplayField($listFieldInfo['fName'], $this->tName)) { $value = DisplayLookupWizard($listFieldInfo['fName'], $data[$listFieldInfo['fName']], $data, $keylink, MODE_LIST); } else { if (NeedEncode($listFieldInfo['fName'], $this->tName)) { $value = ProcessLargeText(GetData($data, $listFieldInfo['fName'], $listFieldInfo['viewFormat']), "field=" . rawurlencode($listFieldInfo['fName']) . $keylink, "", MODE_LIST); } else { $value = GetData($data, $listFieldInfo['fName'], $listFieldInfo['viewFormat']); } } } } } } } } } } // create address field as center link $value = $this->addCenterLink($value, $listFieldInfo['fName']); return $value; }