Personal tools
You are here: Home Linux Gravatars

Gravatars

— filed under: , ,
by Harald Hoyer last modified Sep 24, 2007 12:31

Patch for gravatar-cache to export the mime type.

gravatar-mimetype.patch — differences between files, 1Kb

File contents

diff -ur gravatar-cache/index.php html/gravatar-cache/index.php
--- gravatar-cache/index.php	2006-05-24 03:59:56.000000000 +0200
+++ html/gravatar-cache/index.php	2006-11-28 06:31:47.000000000 +0100
@@ -247,7 +247,7 @@
     $result = false;
     if (ini_get('allow_url_fopen')) {
         // Use the URL file copy.
-        $result = copy($url, $dsttmp);
+        $result = copy($src, $dsttmp);
     } else {
         if (function_exists('curl_init')) {
             // Use CURL
@@ -283,6 +283,7 @@
         // In this case we will ignore and cache the error.
         if (filesize($dsttmp) > 100) {
             rename($dsttmp, $dst);
+	    system("file -bi ". $dst ." > ". $dst .".type");
             return 1;
         }
         gcdebug("Downloaded file too small. Discard.");
@@ -433,6 +434,11 @@
     }
 
     $gravatar_file = get_cachedir().'/'.$gravatar_id;
+
+    if (file_exists($gravatar_file)) {
+	return_file($gravatar_file);
+    }
+
     $neg_handler = 'NegHandler_'.$config['neg_handler'];
     $neg_handler = new $neg_handler;
 
@@ -526,7 +532,11 @@
 
 function return_file($filename) {
     if (file_exists($filename)) {
-        header('Content-Type: application/octet-stream');
+    	if (file_exists($filename.'.type')) {
+		header('Content-Type: '. file_get_contents($filename.'.type'));
+	} else {
+        	header('Content-Type: application/octet-stream');
+	}
         header('Content-Length: '.filesize($filename));
         readfile($filename);
     } else {
Document Actions
  • Print this
  • Hits: 002394