X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=scripts%2Fimage.ml;h=66cd06258fd2d9708c5631ac7e5f08d09a828482;hb=e336401181f56f19ec18175d47462e7a5d5f07e2;hp=05589501f291a6492ecb3dcb4a478f60423324df;hpb=3f0bcc30ff112dc38e882f4f08b8c37d693799ef;p=cocanwiki.git diff --git a/scripts/image.ml b/scripts/image.ml index 0558950..66cd062 100644 --- a/scripts/image.ml +++ b/scripts/image.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: image.ml,v 1.11 2004/10/24 11:34:37 rich Exp $ + * $Id: image.ml,v 1.14 2004/12/01 13:55:55 rich Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ open ExtString open Cocanwiki -let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ = +let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} _ = let image = q#param "image" in let is_thumbnail = q#param_true "thumbnail" in let version = @@ -58,15 +58,13 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ = with Not_found -> raise (HttpError cHTTP_NOT_FOUND) in - (* If deleted, refuse to serve this image except if called from the - * deleted images page. - *) + (* If deleted, refuse to serve this image except if shown on the site. *) if deleted then ( let referer = try Table.get (Request.headers_in r) "Referer" with Not_found -> "" in let ok = - try String.find referer "/_images?deleted"; true - with String.Invalid_string -> false in + try String.find referer hostname; true + with Invalid_string -> false in if not ok then ( prerr_endline "image.ml: bandwidth theft avoided"; @@ -74,9 +72,8 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ = ) ); - if version <> None then - (* Set a medium-length expiry time on this resource. *) - Table.set (Request.headers_out r) "Expires" (Expires.medium ()); + (* Set a medium-length expiry time on this resource. *) + Table.set (Request.headers_out r) "Expires" (Expires.medium ()); (* Content-length header. *) Table.set (Request.headers_out r) "Content-Length"