Rev 229 Rev 242
1 <?php 1 <?php
2   2  
3 /** 3 /**
4 * Alternate file to drive the gallery designed to be included within another 4 * Alternate file to drive the gallery designed to be included within another
5 * page. 5 * page.
6 * 6 *
7 * This page will only send content-type headers if they have not already 7 * This page will only send content-type headers if they have not already
8 * been sent. Placing a call to ob_start() within the including page before any 8 * been sent. Placing a call to ob_start() within the including page before any
9 * content has been output will allow singapore to use non-default charsets. 9 * content has been output will allow singapore to use non-default charsets.
10 * 10 *
11 * @package singapore 11 * @package singapore
12 * @author Tamlyn Rhodes <tam at zenology dot co dot uk> 12 * @author Tamlyn Rhodes <tam at zenology dot co dot uk>
13 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License 13 * @license http://opensource.org/licenses/gpl-license.php GNU General Public License
14 * @copyright (c)2003-2005 Tamlyn Rhodes 14 * @copyright (c)2003-2005 Tamlyn Rhodes
15 * @version $Id: external.php,v 1.4 2006/08/07 10:04:28 thepavian Exp $ 15 * @version $Id: external.php,v 1.4 2006/08/07 10:04:28 thepavian Exp $
16 */ 16 */
17   17  
18 //you may leave this blank as it will be automatically detected 18 //you may leave this blank as it will be automatically detected
19 $relativePath = ""; 19 $relativePath = "";
20   20  
21 //check whether this file has been included by another and if 21 //check whether this file has been included by another and if
22 //so calculate the relative path and instantiate $sg with it 22 //so calculate the relative path and instantiate $sg with it
23 if(isset($_SERVER["SCRIPT_FILENAME"]) && realpath(__FILE__) != realpath($_SERVER["SCRIPT_FILENAME"])) { 23 if(isset($_SERVER["SCRIPT_FILENAME"]) && realpath(__FILE__) != realpath($_SERVER["SCRIPT_FILENAME"])) {
24 //split each path into chunks 24 //split each path into chunks
25 $you = explode(DIRECTORY_SEPARATOR,dirname(realpath($_SERVER["SCRIPT_FILENAME"]))); 25 $you = explode(DIRECTORY_SEPARATOR,dirname(realpath($_SERVER["SCRIPT_FILENAME"])));
26 $me = explode(DIRECTORY_SEPARATOR,dirname(realpath(__FILE__))); 26 $me = explode(DIRECTORY_SEPARATOR,dirname(realpath(__FILE__)));
27 $i=0; 27 $i=0;
28 //find at what level paths first differ 28 //find at what level paths first differ
29 while($i<count($you) && $i<count($me) && $you[$i] == $me[$i]) $i++; 29 while($i<count($you) && $i<count($me) && $you[$i] == $me[$i]) $i++;
30 //travel up appropriate number of directories 30 //travel up appropriate number of directories
31 for($j=$i;$j<count($you);$j++) $relativePath .= "../"; 31 for($j=$i;$j<count($you);$j++) $relativePath .= "../";
32 //travel down appropriate directories 32 //travel down appropriate directories
33 for($j=$i;$j<count($me); $j++) $relativePath .= $me[$j]."/"; 33 for($j=$i;$j<count($me); $j++) $relativePath .= $me[$j]."/";
34   34  
35 //otherwise print an error as this is not how external.php is supposed to work. 35 //otherwise print an error as this is not how external.php is supposed to work.
36 } else { 36 } else {
37 die("This file is not intended to be used in this way. Please see the singapore integration guide."); 37 die("This file is not intended to be used in this way. Please see the singapore integration guide.");
38 } 38 }
39 39
40   40  
41 //include main class 41 //include main class
42 require_once $relativePath."includes/singapore.class.php"; 42 require_once $relativePath."includes/singapore.class.php";
43   43  
44 //create a wrapper 44 //create a wrapper
45 $sg = new Singapore($relativePath); 45 $sg = new Singapore($relativePath);
46   46  
47 //send content-type and character encoding header 47 //send content-type and character encoding header
48 if(!headers_sent()) 48 if(!headers_sent())
49 header("Content-type: text/html; charset=".$sg->character_set); 49 header("Content-type: text/html; charset=".$sg->character_set);
50   50  
51 //pass control over to template 51 //pass control over to template
52 @include $sg->config->base_path.$sg->config->pathto_current_template."index.tpl.php"; 52 @include $sg->config->base_path.$sg->config->pathto_current_template."index.tpl.php";
53   53  
54 ?> 54 ?>