/[drupal]/contributions/modules/logotool/logo.php
ViewVC logotype

Contents of /contributions/modules/logotool/logo.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download) (as text)
Thu Apr 12 13:51:04 2007 UTC (2 years, 7 months ago) by pobster
Branch: MAIN
CVS Tags: DRUPAL-5--2-2, DRUPAL-5--2-3, DRUPAL-5--2-0, DRUPAL-5--2-1, HEAD
Changes since 1.2: +2 -2 lines
File MIME type: text/x-php
First draft at implementing locales...  Needs testing/ work
1 <?php
2 // $Id$
3
4 /**
5 * Create an image and display a message in it (for error reporting)
6 */
7 function logotool_display_error($text = "Error Creating Logo") {
8 $im = imagecreate(181, 20);
9 $bg = imagecolorallocate($im, 255, 255, 255);
10 $textcolor = imagecolorallocate($im, 255, 0, 0);
11 imagestring($im, 5, 2, 1, $text, $textcolor);
12 header("Content-type: image/png");
13 imagepng($im);
14 imagedestroy($im);
15 } // logotool_display_error
16
17 // Include a few Drupal files and allow us to access 'variable_get'
18 include_once('./includes/image.inc');
19 include_once('./includes/file.inc');
20 include_once('./includes/bootstrap.inc');
21 drupal_bootstrap(DRUPAL_BOOTSTRAP_LATE_PAGE_CACHE);
22 define('LT_CWD', file_directory_path().'/logos');
23
24 // Check whether there's a logo path supplied (and make sure it resides in the logos directory to prevent exploits)
25 // else use the logo contained in the logotool_logo variable
26 $logo = $_GET['logo'] ? $_GET['logo'] : variable_get('logotool_logo', '');
27 $logo = realpath(file_check_location(sprintf("%s/%s", variable_get('logotool_folder', LT_CWD), $logo), variable_get('logotool_folder', LT_CWD)));
28
29 // If logo doesn't exist return an error
30 if (!$logo && variable_get('logotool_logo', '') != variable_get('logotool_path', 'misc/druplicon.png')) {
31 logotool_display_error("Logo Not Found");
32 return;
33 }
34 elseif (!$logo && variable_get('logotool_logo', '') == variable_get('logotool_path', 'misc/druplicon.png')) {
35 $logo = variable_get('logotool_path', 'misc/druplicon.png');
36 }
37
38 // Return image information
39 $info = image_get_info($logo);
40
41 // If file is not an image file (or is unsupported) then return an error
42 if (!$info['mime_type']) {
43 logotool_display_error("Unsupported Filetype");
44 return;
45 }
46
47 // Display headers so browser knows we're outputting an image
48 $headers = array('Content-Type: '.$info['mime_type']);
49 foreach ($headers as $header) {
50 header($header);
51 }
52
53 // Output image
54 $im = @readfile($logo);
55
56 // If there's been a problem, report it
57 if (!$im) logotool_display_error();

  ViewVC Help
Powered by ViewVC 1.1.2