function thumb_url_from_imgpath ($filename) {
if (defined ("THUMBSDIRURL") && (strlen (THUMBSDIRURL) != 0)) {
- return rtrim (THUMBSDIRURL, '/') . "/_mini" . rawurlencode ($filename);
+ return rtrim (THUMBSDIRURL, '/') . "/mini_" . rawurlencode ($filename);
}
return full_url_from_path (getthumbsdir () . "/mini_" . rawurlencode ($filename));
}
return "$proto://$host$port$path";
}
+function create_thumbnail_or_copy ($filename, $destfile) {
+ try {
+ $thumbnail_ok = create_thumbnail ($filename, $destfile);
+ } catch (Exception $e) {
+ $thumbnail_ok = false;
+ }
+ if (!$thumbnail_ok) {
+ if (!copy ($filename, $destfile)) {
+ return false;
+ }
+ }
+ return true;
+}
+
function create_thumbnail ($filename, $destfile) {
+ if (!function_exists ("imagecreatefromjpeg")
+ || !function_exists ("imagecreatefrompng")) {
+ return false;
+ }
$ext = strtolower (ext_safe ($filename));
if ($ext == "jpg" || $ext == "jpeg") {
$image = imagecreatefromjpeg ($filename);
}
}
+function delete_from_ftp ($file) {
+ $ftp_conn = ftp_connect (FTPSERVER);
+ $login = ftp_login ($ftp_conn, FTPUSER, FTPPASS);
+ if ((!$ftp_conn) || (!$login)) {
+ server_error ();
+ }
+ $target = sprintf ("%s/%s", FTPROOTDIR, $file);
+ $deleted = ftp_delete ($ftp_conn, $target);
+
+ if (!$deleted) {
+ server_error ();
+ }
+ ftp_close ($ftp_conn);
+}
+
+function send_to_ftp ($file) {
+ $ftp_conn = ftp_connect (FTPSERVER);
+ $login = ftp_login ($ftp_conn, FTPUSER, FTPPASS);
+ if ((!$ftp_conn) || (!$login)) {
+ server_error ();
+ }
+ $dest = sprintf ("%s/%s", FTPROOTDIR, $file);
+ $upload = ftp_put ($ftp_conn, $dest, $file, FTP_BINARY);
+
+ if (!$upload) {
+ server_error ();
+ }
+ ftp_close ($ftp_conn);
+}
+
function leave () {
exit ("\n</body></html>");
}