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