DirPHP crystalpage.sourceforge.net / code / index.php

*** PHP FILE DISPLAY STARTS HERE ***

<?php
/**
  +----------------------------------------------------------------------+
  | Crystalpage 3.0 - Content Management System                          |
  +----------------------------------------------------------------------+
  | Copyright (c) 2006 Karim Agha                                        |
  +----------------------------------------------------------------------+
  | This software is released under the Simian Public License.           |
  | Please see the accompanying file LICENSE for licensing details!      |
  |                                                                      |
  | You should have received a copy of the Simian Public License         |
  | along with this program; if not, write to Simian Systems,            |
  | 101-314 Broadway, Winnipeg, MB, R3C 0S7, CANADA.  The Simian         |
  | Public License is also available at the following web site           |
  | address: <http://www.simian.ca/license.php>                          |
  +----------------------------------------------------------------------+
  | @package Crystalpage CMS 3.0                                         |
  | @version 3.0 Alpha                                                   |
  | @author Crystalpage development team                                 |
  +----------------------------------------------------------------------+
  */


/**
 * This is the ajax processing file, it handle the AJAX request
 *
 */

define('CRYSTALPAGE_',true);
define('DEBUG',true);
/* include the initialaization file, which ckes for new extensions, check for the user, connects to the database,
and generally start crystalpage */
//require_once("init.php");
/* $_CP varialble, the variable that holds all the various crystalpage values */
$_CP = array();
/* included files */
/* the config.php caused errors whe not using chdir() */
chdir('cpLib/pear/');
require_once(
"Config.php");
require_once(
'XML/Parser.php');
require_once(
'XML/Util.php');
//require_once("Log.php");
chdir('../../');



require_once(
"cpLib/pear/adodb/adodb.inc.php");
require_once(
"cpLib/class.Extension.php");
require_once(
"cpLib/class.StartupExtension.php");
require_once(
"cpLib/class.Log.php");
require_once(
"cpLib/class.config.php");
require_once(
"cpLib/class.user.php");
require_once(
"cpLib/class.panels.php");
require_once(
"cpLib/class.block.php");
require_once(
"cpLib/class.layoutParser.php");
require_once(
"cpLib/class.TagHandler.php");
require_once(
"cpLib/class.ExtTagHandler.php");
require_once(
"cpLib/class.messaging.php");
require_once(
"prado/framework/prado.php");
/* End of included files */

/* Now i will create an __autoload() function, that will include files with the classes
in case the file is not included, notice that in all my classes and files i use the
naming style: class.[className].php *//*
function __autoload($className) {
$className = strtolower($className);
require_once("class.$className.php");
}*/
/* end of __autoload decleration */


$_CP['config'] = parse_ini_file("systemConfig/mainConfig.ini.php",true);
$_CP['Log'] = &Log::factory('file'$_CP['config']['Paths']['LogsDir'].date("d-m-Y").".log"'TEST');


/* Creating a database connection, before doing anything this is nessesary because some startup
modules might need database connectivity */

$_DB = &ADONewConnection($_CP['config']['Database']['Driver']);


if(
defined('DEBUG')) {
    
$_DB->Debug true;
}
if(
$_CP['config']['Database']['Persistent'] == 0) {
    
$_DB->Connect($_CP['config']['Database']['Host'],
    
$_CP['config']['Database']['User'],
    
$_CP['config']['Database']['Password'],
    
$_CP['config']['Database']['Database']);
} else {
    
$_DB->PConnect($_CP['config']['Database']['Host'],
    
$_CP['config']['Database']['User'],
    
$_CP['config']['Database']['Password'],
    
$_CP['config']['Database']['Database']);
}
$_CP['dbPrefix'] = $_CP['config']['Database']['Prefix'];
/* This array holds the loaded extensions and their data */

$_CP['loadedExt'] = array();
$_CP['extManager'] = new StartupExtension();
$_CP['extManager']->CheckAndInstall();
/* Loading the DBConfig table into an array $_CFG */

$c = new CPConfig();
$c->FillConfigArray();
$_CFG $c->ConfigArray;

/* Searching the Extension Directory for startup extensions that will be executed now */
if ($dir_handle opendir('extensions/')) {


    
$files scandir('extensions/');

    for(
$i=2;$i count($files); $i++) {
        if(
is_dir('extensions/'.$files[$i]) && 'extensions/'.$files[$i] != "." && 'extensions/'.$files[$i] != "..") {
            
$files_in_dir scandir('extensions/'.$files[$i]);
            if(
in_array("ext.xml",$files_in_dir))
            {
                
$extCH = new Config;
                
/* check in the ext.xml if the extension type is startup */
                
$root =&$extCH->parseConfig('extensions/'.$files[$i].'/ext.xml''XML');
                
$settings $root->toArray();
                if(
strtolower($settings['root']['Extension']['Type']) == 'startup')
                {
                    
$_CP['extManager']->ExecuteExtension(($settings['root']['Extension']['ShortName']));
                }

            }
        }
    }
}

/* creating i18n function, without class to help get the string faster without the need to write function and
class prefix, this is the only exception where OO is not used. 
function _($string) {
    global $_CFG;
    $string = trim(strtolower($string));
    $language = $_CFG['system_language'];
    require_once("i18n/lang.$language.php");

    if(!empty($cp_Lang[$string])) {
        return $cp_Lang[$string];
    } else {
        return $string;
    }

}
/* end of _function this function shall be used as follows: _("Text to translate");*/

/* Initialize user class and look for a logged user, if found continue to the mainPanel, if not
show the loginPanel and die() */
$_USER = new UserBE();
switch (
$_GET['action']) {

    case 
"msgUpdate":
    
$msgs = new Messaging();
    
$unread $msgs->GetUnreadCount();
    if(
$unread 0) {
        echo 
"msgStat|<a class='usr' href='index.php?runlevel=usermessages'>You have ($unread) new message(s)</a>";
    } else {
        echo 
"msgStat|<a class='usr' href='index.php?runlevel=usermessages'>You have no new message</a>";
    }
    break;
    
    case 
'SaveUserGeneralData':
        
$uzr = new UserBE();
        
$dataString $_GET['data'];
        
$vals explode("#",$dataString);
        
$uzr->UserName $vals[0];
        
$uzr->CurrentUser $vals[0];
        
$uzr->ReadUserParams();
        
        
$uzr->UserParams['user_realname'] = $vals[1];
        
$uzr->UserParams['user_email'] = $vals[2];
        
$uzr->UserParams['user_tel'] = $vals[3];
        
$uzr->UserParams['user_active'] = $vals[4];
        
$uzr->UserParams['user_location'] = $vals[5];
        
$uzr->UserParams['user_website'] = $vals[6];
        
$uzr->SetUserParams($uzr->UserParams);
        
        
    break;
    
    case 
"SendMessage1":
        
$dataString $_GET['data'];
        
$vals explode("#",$dataString);
        
$msg = new Message();
        
$msg->messageBody $vals[2];
        
$msg->messageHeader $vals[1];
        
$msg->messageTarget $vals[0];
        
$msg->messageFlags $vals[3];
        
Messaging::SendMessage($msg);
    break;
    
    case 
'changeUserPassword':
        
$uzr = new UserBE();
        
$dataString $_GET['data'];
        
$vals explode("#",$dataString);
        
$uzr->UserName $vals[1];
        
$uzr->CurrentUser $vals[1];
        
        
$uzr->ReadUserParams();
        
$uzr->UserParams['user_password'] = $vals[0];
        
        
$uzr->SetUserParams($uzr->UserParams);
    break;
    
    case 
'GeneralUserEdit':
        
$uzr = new UserBE();
        
$uzr->UserName $_GET['user_name'];
        
$uzr->ReadUserParams();
        
$return $uzr->UserParams['user_name']."#".
                  
$uzr->UserParams['user_realname']."#".
                  
$uzr->UserParams['user_email']."#".
                  
$uzr->UserParams['user_tel']."#".
                  
$uzr->UserParams['user_active']."#".
                  
$uzr->UserParams['user_location']."#".
                  
$uzr->UserParams['user_website']."#";
                  
        echo 
$return;
    break;
    
    
    case 
'CheckForUser':
        
$uzer = new UserBE();
        
$present $uzer->UserExistByName($_GET['data']);
        if(
$present) {
            echo 
"true";
        } else {
            echo 
"false";
        }
    break;
        

    default:
    break;
}

switch(
$_POST)
{
        
    case 
'SaveUserGeneralData':
        
$uzr = new UserBE();
        
$dataString $_POST['Data'];
        
$vals explode("#",$dataString);
        
print_r($vals);
    break;
}

?>
1

*** PHP FILE DISPLAY ENDS HERE ***

DirPHP - version 1.0 - Created & Maintained by Stuart Montgomery
Written in Object Oriented PHP <http://scripts.ensitehosting.com/>