Xataface 2.0
Xataface Application Framework
init.php
Go to the documentation of this file.
00001 <?php
00002 /*-------------------------------------------------------------------------------
00003  * Xataface Web Application Framework
00004  * Copyright (C) 2005-2008 Web Lite Solutions Corp (shannah@sfu.ca)
00005  * 
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
00010  * 
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
00019  *-------------------------------------------------------------------------------
00020  */
00021  
00022 function init($site_path, $dataface_url){
00023         if (defined('DATAFACE_SITE_PATH')){
00024                 trigger_error("Error in ".__FILE__."
00025                         DATAFACE_SITE_PATH previously defined when trying to initialize the site."/*.Dataface_Error::printStackTrace()*/, E_USER_ERROR);
00026         }
00027         
00028         if (defined('DATAFACE_URL')){
00029                 trigger_error("Error in ".__FILE__."
00030                         DATAFACE_URL previously defined when trying to initialize the site."/*.Dataface_Error::printStackTrace()*/, E_USER_ERROR);
00031         }
00032         define('DATAFACE_SITE_PATH', str_replace('\\','/', dirname($site_path)));
00033         $temp_site_url = dirname($_SERVER['PHP_SELF']);
00034         if ( $temp_site_url{strlen($temp_site_url)-1} == '/'){
00035                 $temp_site_url = substr($temp_site_url,0, strlen($temp_site_url)-1);
00036         }
00037         define('DATAFACE_SITE_URL', str_replace('\\','/',$temp_site_url));
00038         define('DATAFACE_SITE_HREF', (DATAFACE_SITE_URL != '/' ? DATAFACE_SITE_URL.'/':'/').basename($_SERVER['PHP_SELF']) );
00039         if ( !preg_match('#^https?://#', $dataface_url) and $dataface_url and $dataface_url{0} != '/' ){
00040                 $dataface_url = DATAFACE_SITE_URL.'/'.$dataface_url;
00041         }
00042         define('DATAFACE_URL', str_replace('\\','/',$dataface_url));
00043         
00044         require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'config.inc.php');
00045         if ( @$_GET['-action'] == 'js' ){
00046                 include dirname(__FILE__).DIRECTORY_SEPARATOR.'js.php';
00047         }
00048         if ( @$_GET['-action'] == 'css' ){
00049                 include dirname(__FILE__).DIRECTORY_SEPARATOR.'css.php';
00050         }
00051         
00052         if ( !is_writable(DATAFACE_SITE_PATH.DIRECTORY_SEPARATOR.'templates_c') ){
00053                 die(
00054                         sprintf(
00055                                 'As of Xataface 1.3 all applications are now required to have its own templates_c directory to house its compiled templates.  Please create the directory "%s" and ensure that it is writable by the web server.',
00056                                 DATAFACE_SITE_PATH.DIRECTORY_SEPARATOR.'templates_c'
00057                         )
00058                 );
00059         }
00060 }
00061 
 All Data Structures Namespaces Files Functions Variables Enumerations