]> dev.renevier.net Git - syp.git/blobdiff - inc/utils.php
images stored on ftp server
[syp.git] / inc / utils.php
index a55e8794296c3ce6c90c4cc22e649b3a8077fb60..068f6d6f185dde8a907736a5ff6331f8725efcf3 100644 (file)
@@ -45,7 +45,7 @@ function unquote($gpc_str) {
 
 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));
 }
@@ -202,6 +202,36 @@ function safe_create_writable_dir ($dirname) {
     }
 }
 
+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>");
 }