function EditBanner() { $dataset = new A_DataSet(STRUCTURE); $dataset->fields = array("name", "idcat", "url", "showurl", "date", "target", "text", "width", "height", "show", "active"); $_REQUEST['name'] = strclear($_REQUEST['name']); $_REQUEST['idcat'] = $_REQUEST['idcat2']; $_REQUEST['active'] = isset($_REQUEST['active']) ? 'Y' : 'N'; $_REQUEST['url'] = urldecode($_REQUEST['url']); if (isset($_REQUEST['showall'])) { $_REQUEST['showurl'] = ""; } elseif ($_REQUEST['showurl']) { $showurls = explode("\n", $_REQUEST['showurl']); foreach ($showurls as $i => $url) { if ($url = urldecode($url)) { $showurls[$i] = $url; } else { unset($showurls[$i]); } } $_REQUEST['showurl'] = implode("\n", $showurls); } if (isset($_REQUEST['date'])) { $_REQUEST['date'] = "Y"; array_push($dataset->fields, "date1", "date2"); } else { $_REQUEST['date'] = "N"; } if (!isset($_REQUEST['showall'])) { $_REQUEST['show'] = !empty($_REQUEST['show']) ? serialize($_REQUEST['show']) : ""; } else { $_REQUEST['show'] = ""; } $banner_ext = array("gif", "jpg", "jpeg", "png", "swf"); if (isset($_FILES['bannerfile']['tmp_name']) && file_exists($_FILES['bannerfile']['tmp_name'])) { $ext = $basename = ""; escapeFileName($_FILES['bannerfile']['name'], $ext, $basename); $basename = translit($basename); if (in_array($ext, $banner_ext)) { delfile($dataset->data['filepath']); mk_dir($path = "files/" . DOMAIN . "/rek_images"); $_REQUEST["filepath"] = $path . "/{$basename}.{$ext}"; $i = 1; while (is_file($_REQUEST["filepath"])) { $_REQUEST["filepath"] = $path . "/{$basename}_" . sprintf("%02d", $i++) . ".{$ext}"; } copyfile($_FILES['bannerfile']['tmp_name'], $_REQUEST["filepath"]); $_REQUEST["type"] = $ext == "swf" ? "flash" : "image"; array_push($dataset->fields, "filepath", "type"); if ($_REQUEST["type"] == "image") { require_once 'Image/Transform.php'; $it = Image_Transform::factory('GD'); $it->load($_FILES['bannerfile']['tmp_name']); $_REQUEST["width"] = $it->img_x; $_REQUEST["height"] = $it->img_y; } } } return $dataset->Update(); }
/** Function taken from Mini Front Page * Modified by Andrea Forghieri - Solidsystem * * * This function creates a thumbnail preview from an image * @param string $file source file (complete with path) * @param string $thumb filename to be given to the thumb (complete with path) * @param string $ext Extension of the source file * @param int &$newheight height of the thumbnail * @param int &$newwidth width of the thumbnail * @param bool aspect preserve aspect (true / false) * @param integer $quality quality of the image (0 worst - 100 best) * @return boolean return false if */ function cp_thumbIt($file, $thumb, $ext, &$new_width, &$new_height, $aspect, $quality) { $filename = escapeFileName($file); $img_info = getimagesize($file); if (!$img_info) { return false; } $orig_width = $img_info[0]; $orig_height = $img_info[1]; calcThumbSize($orig_width, $orig_height, $new_width, $new_height, $aspect); switch (strtolower($ext)) { case 'jpg': case 'jpeg': $im = imagecreatefromjpeg($file); $tim = imagecreatetruecolor($new_width, $new_height); cp_ImageCopyResampleBicubic($tim, $im, 0, 0, 0, 0, $new_width, $new_height, $orig_width, $orig_height); imagedestroy($im); imagejpeg($tim, rawurldecode($thumb), $quality); imagedestroy($tim); break; case 'png': $im = imagecreatefrompng($file); $tim = imagecreatetruecolor($new_width, $new_height); cp_ImageCopyResampleBicubic($tim, $im, 0, 0, 0, 0, $new_width, $new_height, $orig_width, $orig_height); imagedestroy($im); imagepng($tim, rawurldecode($thumb)); imagedestroy($tim); break; case 'gif': if (function_exists("imagegif")) { $im = imagecreatefromgif($file); $tim = imagecreatetruecolor($new_width, $new_height); cp_ImageCopyResampleBicubic($tim, $im, 0, 0, 0, 0, $new_width, $new_height, $orig_width, $orig_height); imagedestroy($im); imagegif($tim, rawurldecode($thumb)); imagedestroy($tim); } break; default: break; } return true; }