root/trunk/plog-thumb.php

Revision 588, 1.3 KB (checked in by kimparsell, 3 weeks ago)

+ Minor markup changes for install/upgrade process.
+ Minor admin section changes to make action notices consistent.
+ Miscellaneous cleanup.

Line 
1<?php
2
3// This is mostly an interface for the XML service to get thumbnail URLs
4// without having to generate the thumb at the time that the URL is
5// needed.
6
7require(dirname(__FILE__)."/plog-globals.php");
8require(dirname(__FILE__)."/plog-include/plog-functions.php");
9
10/**
11* plog-thumb.php interface for XML service
12*
13* Purpose: Provide a link to a thumbnail for a picture even when the thumbnail
14* may not have been generated yet.
15*
16* @param int id (required)
17* @param int type (default 1, any of 1,2,3,4)
18*/
19
20if (!isset($_REQUEST["id"]) || (intval($_REQUEST["id"]) == 0)) exit;
21if (!isset($_REQUEST["type"])) $_REQUEST["type"] = 1;
22
23$query = "SELECT
24    `path`,
25    `id`
26    FROM `plogger_pictures`
27    WHERE `id`=".intval($_REQUEST["id"]);
28$result = run_query($query);
29$thumb = mysql_fetch_assoc($result);
30
31$thumb["type"] = intval($_REQUEST["type"]);
32
33$path = generate_thumb($thumb["path"], $thumb["id"], $thumb["type"]);
34
35// make sure the generated url and the browser url have the same domain syntax
36$browser_www = strpos($_SERVER['HTTP_HOST'], 'www');
37$thumb_www = strpos($path, 'www');
38if ($browser_www !== $thumb_www) {
39    if ($browser_www === false) {
40        $path = str_replace('www', '', $path);
41    } else {
42        $path = str_replace('//', '//www.', $path);
43    }
44}
45
46header("Location: ".$path);
47exit;
48
49?>
Note: See TracBrowser for help on using the browser.