BeCastWebEngine/inc/ajax.class.php

112 lines
3.8 KiB
PHP
Raw Permalink Normal View History

2025-06-20 19:10:23 +02:00
<?php
/**
* Project: astat - simple site engine
* File: /inc/ajax.class.php
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @link http://www.astat.org SVN: $URL: http://svn.astat.org/astat/trunk/inc/ajax.class.php $
* @copyright 2009 becast.at
* @author Bernhard Jaud <bernhard at becast dot at>
* @package astat core
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
* @version $Id: ajax.class.php 31 2009-06-20 20:41:07Z genuineparts $
*/
$module["core"]["name"]="Ajax Class";
$module["core"]["ver"]="0.6.0";
use Smarty\Smarty;
class ajax{
var $db;
var $log;
var $tpl;
function __construct(& $db,& $log,& $tpl) {
global $config;
$this->log = & $log;
$this->db = & $db;
$this->tpl = & $tpl;
}
function get_ajax_module($task,$subtask=""){
global $config, $userdata, $core, $db, $userinfo, $tpl, $error, $session, $meta, $mod, $plugin;
include dirname(dirname(__FILE__)).'/class_templates/ajax_module.template.php';
$content="";
if (strpos($task, '://') !== FALSE || strpos($task, '../') !== FALSE){
$this->tpl->assign('messagetitle',"Intruder Alert!");
$this->tpl->assign('message', "Unser System hat festgestellt das ein XSS Versuch erfolgt ist.<br />Wir haben alle Daten geloggt und eine E-Mail an den Administrator wurde versandt.");
if($config["logging"])
$this->log->write("XSS ATTACK: Someone tried calling ".$task."!",1);
return $tpl->fetch('message.tpl',"INTRUDER");
}elseif((file_exists("modules/".$task."/" . $task . ".ajax.php") && is_array($core->mod_[$task]) )|| $task==""){
if($task!=""){
include 'modules/'.$task.'/' . $task. '.ajax.php';
if(class_exists($task)){
$mod = new $task();
$root = $_SERVER['DOCUMENT_ROOT'] . $config["path"];
if(isset($config["theme"]) && is_dir($root . '/modules/'.$task.'/templates/'.$config["theme"]) && !$mod -> uses_default_templates){
$mod -> tpl-> setTemplateDir($root . '/modules/'.$task.'/templates/'.$config["theme"]);
}elseif($mod -> uses_default_templates){
if(isset($config["theme"]) && is_dir($root . '/themes/'.$config["theme"])){
$mod -> tpl-> setTemplateDir($root . '/themes/'.$config["theme"]);
}else{
$mod -> tpl-> setTemplateDir($root . '/themes/default');
}
}else{
$mod -> tpl-> setTemplateDir($root . '/modules/'.$task.'/templates/default');
}
if($subtask!=""){
$subtask="sub_".$subtask;
if(!is_callable(array($mod,$subtask))){
if($config["logging"])
$this->log->write("FATAL ERROR: Modul ".$task." was found, but does not contain FUNCTION ".$subtask."!",1);
return $error->http_error("404");
}else{
$content.=$mod->$subtask();
}
}else{
$content.=$mod->ajax();
}
}else{
if($config["logging"])
$this->log->write("FATAL ERROR: Modul ".$task." was found, but does not contain CLASS ".$task."!",1);
return $error->http_error("404");
}
}
}else{
if($config["logging"])
$this->log->write("Modul ".$task." not found!",2);
return $error->http_error("404");
}
echo $content;
}
}
?>