<?php
/**
* @author Andrew Cobby <hide@address.com>
* @copyright Andrew Cobby 2007
* @package Sneaky
* @version 1.11
* This file is part of Sneaky.
*
* Sneaky is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Sneaky is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* All third party applications may have different licensing.
* See the license folder for more information.
*
*****************************************
** Project: Sneaky CMS/Framework
** Version 1.11
** File: include.php
** Purpose: include file, multi-purpose
*****************************************
*
*/
// Define error report, once your site is up and 100% fully function set it to 0.
error_reporting(E_ERROR | E_WARNING | E_PARSE);
/**
* url()
* Get the url of the website.
* @return string
*/
function url(){
// get server protocol
$sp = $_SERVER['SERVER_PROTOCOL'];
$sp = explode ('/', $sp);
$protocol = strtolower($sp[0]);
// add protocol
$url = $protocol."://".$_SERVER['SERVER_NAME'];
// get the script path
$path = $_SERVER['PHP_SELF'];
// separate path by /
$path = explode('/', $path);
$final = '';
// join parts, start at 1 to remove first blank and end 2 early to skip includes and filename name
for($i=1; $i<count($path)-1; $i++){
$final .= "/".$path[$i];
}
// add trailing /
$final .= "/";
// join parts
$ret = $url.$final;
return $ret;
}
// Set Constants
/**
* @constant string
* DIRSEP = Directory Separator
*/
if(!defined('DIRSEP')){
define('DIRSEP', DIRECTORY_SEPARATOR);
}
// get the sites server directory.
$site_path = realpath(dirname(__FILE__) . DIRSEP . '..' . DIRSEP);
/**
* @constant string
* site_path = sites server directory
* @see $site_path
*/
if(!defined('site_path')){
define('site_path', $site_path);
}
/**
* @constant string
* site_url = url()
* @see url()
*/
if(!defined('site_url')){
define('site_url', url());
}
/**
* @constant string
* cache_path = Sneaky cache directory
*/
if(!defined('cache_path')){
define('cache_path', site_path.DIRSEP.'cache'.DIRSEP);
}
// include registry class
include site_path.DIRSEP.'classes'.DIRSEP.'reg.class.php';
// define registry class
$reg = new reg;
// return files/folders in the classes folder
$scandir = scandir(site_path."classes\\");
// loops through classes folder, if the file is name *.class.php, it will create a new class in the registry named *
// (where * is the name of the class and file.)
foreach($scandir as $val){
if(preg_match("+.class.php+", $val)){
$val = substr($val, 0 ,-10);
if(($val != 'Smarty_Compiler') && ($val != 'Config_File') && ($val != 'reg')){
include_once site_path."classes\\".$val.".class.php";
$reg[$val] = new $val($reg);
}
}
}
// include site configuration
include site_path.DIRSEP.'includes'.DIRSEP.'config.php';
// define url settings
/**
* @see config.php
*/
if(!isset($settings['tidyurls'])){
define('redirectURL', site_url.'index.php?file=');
define('iniGET', '&');
define('addGET', '&');
define('ext', NULL);
}else{
define('redirectURL', site_url);
define('iniGET', '?');
define('addGET', '&');
define('ext', '.php');
}
// load the url settings to an array
$urls = array(
'site' => site_url,
'redirect' => redirectURL,
'iniGET' => iniGET,
'addGET' => addGET,
'ext' => ext);
?>