Thread: [Openupload-svn-update] SF.net SVN: openupload:[10] trunk/lib
Status: Beta
Brought to you by:
tsdogs
|
From: <ts...@us...> - 2008-10-15 14:02:22
|
Revision: 10
http://openupload.svn.sourceforge.net/openupload/?rev=10&view=rev
Author: tsdogs
Date: 2008-10-15 13:58:01 +0000 (Wed, 15 Oct 2008)
Log Message:
-----------
First svn commit
Added Paths:
-----------
trunk/lib/modules/auth/
trunk/lib/modules/auth/default.inc.php
trunk/lib/modules/db/
trunk/lib/modules/default/
trunk/lib/modules/default/admin.inc.php
trunk/lib/modules/default/auth.inc.php
trunk/lib/modules/default/files.inc.php
trunk/lib/modules/tr/
trunk/lib/modules/tr/array.inc.php
trunk/lib/modules/tr/gettext.inc.php
trunk/lib/smarty/Config_File.class.php
trunk/lib/smarty/Smarty.class.php
trunk/lib/smarty/Smarty_Compiler.class.php
trunk/lib/smarty/debug.tpl
Added: trunk/lib/modules/auth/default.inc.php
===================================================================
--- trunk/lib/modules/auth/default.inc.php (rev 0)
+++ trunk/lib/modules/auth/default.inc.php 2008-10-15 13:58:01 UTC (rev 10)
@@ -0,0 +1,31 @@
+<?php
+/* use the db to Authenticate users */
+class defaultAuth extends authBase {
+
+ function defaultAuth() {
+ }
+
+ function init() {
+ $this->db = app()->db;
+ }
+
+ function authenticate($login,$password) {
+ $res = $this->db->queryUser($login);
+ //echo crypt($password); exit;
+ if ($res['login']==$login and crypt($password,$res['password'])==$res['password']) {
+ return true;
+ }
+ return false;
+ }
+
+ function userInfo($login) {
+ $result = $this->db->queryUser($login);
+ return $result;
+ }
+
+ function addUser($user) {
+ $user['password']=crypt($user['password']);
+ $this->db->addUser($user);
+ }
+}
+?>
\ No newline at end of file
Added: trunk/lib/modules/default/admin.inc.php
===================================================================
--- trunk/lib/modules/default/admin.inc.php (rev 0)
+++ trunk/lib/modules/default/admin.inc.php 2008-10-15 13:58:01 UTC (rev 10)
@@ -0,0 +1,66 @@
+<?php
+
+class AdminModule extends OpenUploadModule {
+var $actions = array (
+ "admin" => array (
+ 1 => "admin",
+ ),
+ "adminsettings" => array (
+ 1 => "settings",
+ ),
+ "adminplugins" => array (
+ 1 => "plugins",
+ ),
+ "adminfiles" => array (
+ 1 => "files",
+ ),
+ "adminusers" => array (
+ 1 => "users",
+ ),
+ "admingroups" => array (
+ 1 => "groups",
+ ),
+ "adminrights" => array (
+ 1 => "rights",
+ ),
+ );
+
+var $page;
+
+ function AdminModule() {
+ $this->menu = array (
+ "admin" => tr("Administration"),
+ );
+ foreach ($this->actions as $a => $v) {
+ $this->page[$a] = array ("title" => tr("Administration"));
+ }
+ }
+
+ function init() {
+ /* only if the user has admin privileges let it see the module */
+
+ }
+
+ function admin() {
+ }
+
+ function users() {
+ }
+
+ function groups() {
+ }
+
+ function rights() {
+ }
+
+ function files() {
+ }
+
+ function plugins() {
+ }
+
+ function settings() {
+ }
+
+}
+?>
\ No newline at end of file
Added: trunk/lib/modules/default/auth.inc.php
===================================================================
--- trunk/lib/modules/default/auth.inc.php (rev 0)
+++ trunk/lib/modules/default/auth.inc.php 2008-10-15 13:58:01 UTC (rev 10)
@@ -0,0 +1,149 @@
+<?php
+
+class AuthModule extends OpenUploadModule {
+var $actions = array (
+ "login" => array (
+ 1 => "loginForm",
+ 2 => "authenticate",
+ ),
+ "logout" => array (
+ 1 => "logout",
+ ),
+ "register" => array (
+ 1 => "registerForm",
+ 2 => "registerConfirm",
+ ),
+ );
+var $page;
+
+ function AuthModule() {
+ $this->page = array (
+ "login" => array (
+ "title" => tr("Login"),
+ ),
+ "register" => array (
+ "title" => tr("User registration"),
+ ),
+ );
+ }
+
+ function init() {
+ if (!app()->user->loggedin()) {
+ $this->menu['login']=tr('Login');
+ } else {
+ $this->menu['logout']=tr('Logout');
+ }
+ $this->tpl->assign('register',app()->checkACL(app()->user->userGroup(),'auth','register')=='allow');
+ }
+
+
+ function loginForm() {
+
+ /* disable login option link */
+ $this->tpl->assign('login',false);
+ $this->page['title']='Login';
+
+ $finfo = array();
+ app()->pluginAction('loginForm',$finfo,false);
+ //app()->mainPage = 'login';
+ }
+
+ function authenticate() {
+ if (!app()->user->authenticate()) {
+ app()->user->logout();
+ return false; /* never reached */
+ }
+ $finfo = array();
+ $result = app()->pluginAction('authenticate',$finfo,true);
+ if (!$result) { /* plugins forced a logout */
+ app()->user->logout();
+ return false; /* never reached */
+ }
+ /* authentication was successfull */
+ redirect();
+ }
+
+ function logout() {
+ app()->user->logout();
+ }
+
+ function registerForm() {
+ global $_SESSION;
+ global $_POST;
+
+ /* ask the plugins if require more options */
+ $result = app()->pluginAction('registerForm',$user);
+ if (!$result) {
+ /* some plugin disabled the registration */
+ redirect();
+ }
+ $this->tpl->assign('register',$_SESSION['register']);
+ }
+
+ function registerConfirm() {
+ global $_SESSION;
+ global $_POST;
+
+ if (isset($_POST['registerlogin'])) {
+ /* check for the unique login */
+ $u = app()->auth->userInfo($_POST['registerlogin']);
+ if ($u['login']!='') {
+ app()->error(tr('Username already taken, choose a new value'));
+ $failed = true;
+ }
+ if (strlen($_POST['registerlogin'])<5) {
+ app()->error(tr('Login name must be at least 5 characters long!'));
+ }
+ if ($_POST['registername']=='') {
+ app()->error(tr('Please insert Full Name'));
+ $failed = true;
+ }
+ if ($_POST['registeremail']=='' or !validEmail($_POST['registeremail'])) {
+ app()->error(tr('Please insert a valid e-mail!'));
+ $failed = true;
+ }
+ if (strlen(trim($_POST['registerpassword']))<5) {
+ app()->error(tr('Password must be at least 5 characters long!'));
+ $failed = true;
+ }
+ if ($_POST['registerpassword']!=$_POST['registerrepassword']) {
+ app()->error(tr('Passwords do not match! please retype.'));
+ $failed = true;
+ }
+ $user['login'] = $_POST['registerlogin'];
+ $user['name'] = $_POST['registername'];
+ $user['password'] = $_POST['registerpassword'];
+ $user['email'] = $_POST['registeremail'];
+ $user['group_id'] = app()->config['register']['default_group'];
+ $user['active'] = 1;
+ $result = app()->pluginAction('registerConfirm',$user);
+ $_SESSION['register']=$user;
+ unset($_SESSION['register']['password']);
+ if (!$result) {
+ $fauled = true;
+ }
+ if ($failed)
+ $this->prevStep(1); /* back to registration form */
+ app()->auth->addUser($user);
+ } else {
+ $this->prevStep(1); /* back to registration form */
+ }
+ unset($_SESSION['register']);
+ /* ask the plugins if require more options */
+ if ($user['active']=='1') {
+ app()->message(tr('Registration completed successfully. Have fun!'));
+ $_POST['username'] = $user['login'];
+ $_POST['pwd'] = $user['password'];
+ /* simulate the user login and proceed */
+ unset($_SESSION['user']);
+ $this->authenticate();
+ }
+ }
+
+ function registerEnable() {
+ /* if everything is ok register the user */
+
+ }
+
+}
+?>
\ No newline at end of file
Added: trunk/lib/modules/default/files.inc.php
===================================================================
--- trunk/lib/modules/default/files.inc.php (rev 0)
+++ trunk/lib/modules/default/files.inc.php 2008-10-15 13:58:01 UTC (rev 10)
@@ -0,0 +1,291 @@
+<?php
+
+class FilesModule extends OpenUploadModule {
+var $actions = array (
+ "u" => array (
+ 1 => "uploadForm",
+ 2 => "uploadOptions",
+ 3 => "uploadConfirm",
+ 4 => "uploadFileInfo",
+ ),
+ "d" => array (
+ 1 => "downloadForm",
+ 2 => "downloadRequest",
+ 3 => "downloadConfirm",
+ ),
+ "g" => array (
+ 1 => "serveFile",
+ ),
+ "r" => array (
+ 1 => "removeRequest",
+ 2 => "removeConfirm",
+ 3 => "removeResult",
+ ),
+ );
+var $page;
+var $menu;
+
+ function FilesModule() {
+ $this->page = array (
+ "u" => array (
+ "title" => tr("File upload"),
+ ),
+ "d" => array (
+ "title" => tr("File download"),
+ ),
+ "r" => array (
+ "title" => tr("File Removal"),
+ ),
+ );
+ $this->menu = array (
+ "u" => tr("File Upload"),
+ //"d" => tr("File Download"),
+ //"r" => tr("File Removal"),
+ );
+
+ }
+
+ function init() {
+ /* initialize */
+ }
+
+ /* real implementation */
+
+ function uploadForm() {
+ global $_SESSION;
+
+ unset($_SESSION['user']['u']);
+ $result = app()->pluginAction('uploadForm',$finfo);
+ }
+
+ function uploadOptions() {
+ global $_SESSION;
+ global $_FILES;
+
+ if (isset($_FILES['upload'])) {
+ /* prepare the file */
+ $tmpname = app()->config['DATA_PATH'].'/tmp/'.randomName();
+ move_uploaded_file($_FILES['upload']['tmp_name'],$tmpname);
+ $_SESSION['user']['u']['tmp']=$tmpname;
+ $_SESSION['user']['u']['mime']=$_FILES['upload']['type'];
+ $_SESSION['user']['u']['name']=$_FILES['upload']['name'];
+ $_SESSION['user']['u']['size']=$_FILES['upload']['size'];
+ $this->nextStep(app()->step);
+ } else if (!isset($_SESSION['user']['u'])) {
+ redirect();
+ }
+ $result = app()->pluginAction('uploadOptions',$_SESSION['user']['u']);
+ if (!$result) { /* some plugin blocked the upload */
+ /* remove the file */
+ redirect();
+ }
+ $this->tpl->assign('finfo',$_SESSION['user']['u']);
+ /* ask for information on the file */
+ }
+
+ function uploadConfirm() {
+ global $_POST;
+ global $_SESSION;
+
+ /* save the file */
+ /* send an e-mail if requested */
+ /* display the information on the upload */
+ if (isset($_POST['description'])) {
+ /* move the file to the actual location */
+ $finfo = $_SESSION['user']['u'];
+ $finfo['description'] = $_POST['description'];
+ /* now check plugins and if ok add file otherwise redirect */
+ $result = app()->pluginAction('uploadConfirm',$finfo);
+ if (!$result)
+ $this->prevStep();
+ /* everything ok then add the file */
+ $finfo['id']= app()->db->newFileId();
+ $finfo['remove']= app()->db->newFileId('remove');
+ app()->db->addFile($finfo);
+ foreach (app()->plugins as $plugin) {
+ if (count($plugin->fields)>0) {
+ foreach ($plugin->fields as $f) {
+ app()->db->addFileOption($finfo,$plugin->name,$f);
+ }
+ }
+ }
+ rename($_SESSION['user']['u']['tmp'],app()->config['DATA_PATH'].'/'.$finfo['id']);
+ $_SESSION['user']['u']=$finfo;
+ $this->nextStep();
+ }
+ }
+
+ function uploadFileInfo() {
+ if (isset($_SESSION['user']['u']['id'])) {
+ $finfo = $_SESSION['user']['u'];
+ /* get the file info */
+ $finfo['downloadlink']= app()->config['WWW_SERVER'].app()->config['WWW_ROOT'].'/?action=d&id='.$finfo['id'];
+ $finfo['removelink']= app()->config['WWW_SERVER'].app()->config['WWW_ROOT'].'/?action=r&id='.$finfo['id'].'&removeid='.$finfo['remove'];
+ $result = app()->pluginAction('uploadFileInfo',$finfo,false);
+ $this->tpl->assign('finfo',$finfo);
+ $this->tpl->assign('webbase',app()->config['WWW_SERVER'].app()->config['WWW_ROOT']);
+ } else {
+ redirect();
+ }
+ }
+
+ function downloadForm() {
+ global $_SESSION;
+ global $_GET;
+
+ unset($_SESSION['user']['d']);
+ if (isset($_GET['id'])) {
+ $_SESSION['user']['d']['id'] = $_GET['id'];
+ $this->nextStep();
+ }
+ $finfo = array();
+ app()->pluginAction('downloadForm',$finfo,false);
+ }
+
+ function downloadRequest() {
+ global $_GET;
+ global $_SESSION;
+
+ $id = '';
+ if (isset($_POST['id'])) {
+ $id = $_POST['id'];
+ } else if (isset($_SESSION['user']['d']['id'])) {
+ $id = $_SESSION['user']['d']['id'];
+ }
+ /* check if download exsists, and what are the properties */
+ if ($id != '') {
+ $finfo = app()->db->getFileInfo($id);
+ if ($finfo['id']!=$id) {
+ app()->error(tr('Requested file does not exsist!'));
+ $this->prevStep();
+ } else {
+ $_SESSION['user']['d']=$finfo;
+ $this->tpl->assign('finfo',$finfo);
+ $result = app()->pluginAction('downloadRequest',$finfo,false);
+ if ($result) {
+ $this->nextStep();
+ }
+ }
+ }
+ }
+
+ function downloadConfirm() {
+
+ /* here we do the actual download of the file */
+ if (!isset($_SESSION['user']['d'])) {
+ redirect();
+ } else if ($_SESSION['user']['d']['candownload']=='ok') {
+ $finfo = $_SESSION['user']['d'];
+ $this->tpl->assign('finfo',$finfo);
+ /* download is allowed */
+ } else {
+ $finfo = $_SESSION['user']['d'];
+ /* check wether the plugins are ok */
+ $result = app()->pluginAction('downloadConfirm',$finfo);
+ if (!$result)
+ $this->prevStep();
+ $_SESSION['user']['d']=$finfo;
+ $_SESSION['user']['d']['candownload']='ok';
+ /* now the user can download it */
+ $this->nextStep(app()->step);
+ }
+ }
+
+ function serveFile() {
+ global $_SESSION;
+ global $_POST;
+
+ /* here we do the actual download of the file */
+ if (!isset($_SESSION['user']['d'])) {
+ redirect();
+ } else if ($_SESSION['user']['d']['candownload']!='ok') {
+ $this->nextStep(2,'d');
+ } else {
+ $finfo = $_SESSION['user']['d'];
+ /* check wether the plugins are ok */
+ $result = app()->pluginAction('serveFile',$finfo);
+ if (!$result)
+ $this->nextStep(3,'d');
+ $_SESSION['user']['d']['candownload']='ok';
+ /* if we got this far the download should begin serving */
+ $file = app()->config['DATA_PATH'].'/'.$finfo['id'];
+ $filesize = filesize($file);
+ ob_clean();
+ header('Content-Type: '.$finfo['mime']);
+ header('Content-Length: '.$filesize);
+ header('Content-Disposition: attachment; filename="'.$finfo['name'].'"');
+ readfile($file);
+ /* file should have been sent now let's reset the download info */
+ $_SESSION['user']['d']['candownload']='ko';
+ exit(0);
+ }
+ }
+
+ function removeRequest() {
+ global $_GET;
+ global $_SESSION;
+
+ $id = '';
+ if (isset($_GET['id'])) {
+ $id = $_GET['id'];
+ } else if (isset($_SESSION['user']['r']['id'])) {
+ $id = $_SESSION['user']['r']['id'];
+ }
+ /* check if download exsists, and what are the properties */
+ if ($id != '') {
+ $finfo = app()->db->getFileInfo($id);
+ if ($finfo['id']!=$id) {
+ app()->error(tr('Wrong file id!'));
+ redirect();
+ } else if ($_GET['removeid']!=$finfo['remove']) {
+ app()->error(tr('Wrong file id!')); /* don't give the user much info on this */
+ redirect();
+ } else {
+ $_SESSION['user']['r']=$finfo;
+ $this->tpl->assign('finfo',$finfo);
+ $result = app()->pluginAction('removeRequest',$finfo,false);
+ if (!$result) {
+ redirect();
+ }
+ }
+ } else {
+ app()->error(tr('Wrong file id!'));
+ redirect();
+ }
+ }
+
+ function removeConfirm() {
+ $finfo = $_SESSION['user']['r'];
+
+ /* here we do the actual download of the file */
+ if (!isset($_SESSION['user']['r'])) {
+ redirect();
+ } else {
+ $finfo = $_SESSION['user']['r'];
+ /* check wether the plugins are ok */
+ $result = app()->pluginAction('removeConfirm',$finfo);
+ if (!$result)
+ $this->prevStep();
+ /* now we can remove the file */
+ app()->db->removeFile($finfo['id']);
+ $file = app()->config['DATA_PATH'].'/'.$finfo['id'];
+ unlink($file);
+ /* display removal confirmation */
+ $this->nextStep();
+ }
+ }
+
+ function removeResult() {
+ if (!isset($_SESSION['user']['r'])) {
+ redirect();
+ } else {
+ $finfo = $_SESSION['user']['r'];
+ $result = app()->pluginAction('removeResult',$finfo,false);
+ $this->tpl->assign('finfo',$finfo);
+ unset($_SESSION['user']['r']); /* remove any file reference */
+ }
+ }
+
+}
+
+?>
\ No newline at end of file
Added: trunk/lib/modules/tr/array.inc.php
===================================================================
--- trunk/lib/modules/tr/array.inc.php (rev 0)
+++ trunk/lib/modules/tr/array.inc.php 2008-10-15 13:58:01 UTC (rev 10)
@@ -0,0 +1,56 @@
+<?php
+
+/* simple array translation */
+
+class ArrayTranslator extends translatorBase {
+var $update = false;
+var $TR;
+
+ function ArrayTranslator() {
+ }
+
+ function init() {
+ $locale = app()->user->userInfo('lang');
+ $lang = app()->db->getLang($locale);
+ $tr = array();
+ $this->files['openupload']=app()->config['INSTALL_ROOT'].'/locale/'.$lang['id'].'.inc.php';
+ if (file_exists($this->files['openupload'])) {
+ require_once($this->files['openupload']);
+ $this->TR['openupload']=$tr;
+ }
+ $tr = array();
+ $this->files['template']=app()->config['INSTALL_ROOT'].'/templates/'.app()->config['site']['template'].'/locale/'.$lang['id'].'.inc.php';
+ if (file_exists($this->files['template'])) {
+ require_once($this->files['template']);
+ $this->TR['template']=$tr;
+ }
+ /* setup page encoding */
+ if (isset($lang['charset']))
+ header('Content-Type: text/html; charset='.$lang['charset']);
+ }
+
+
+ function translate($txt,$domain = 'openupload') {
+
+ if (isset($this->TR[$domain][$txt])) {
+ return $this->TR[$domain][$txt];
+ } else {
+ if ($this->update) {
+ /* add the translation to the file */
+ $f = @fopen($this->files[$domain],'w+');
+ if ($f) {
+ fwrite($f,'<?php'."\n");
+ foreach ($this->TR[$domain] as $k => $v) {
+ fwrite($f,'$tr[\''.str_replace("'","\'",$k).'\']=\''.str_replace("'","\'",$v).'\';'."\n");
+ }
+ fwrite($f,'$tr[\''.str_replace("'","\'",$txt).'\']=\''.str_replace("'","\'",$txt).'\';'."\n");
+ fwrite($f,'?>');
+ fclose($f);
+ $this->TR[$domain][$txt]=$txt;
+ }
+ }
+ return $txt;
+ }
+ }
+}
+?>
\ No newline at end of file
Added: trunk/lib/modules/tr/gettext.inc.php
===================================================================
--- trunk/lib/modules/tr/gettext.inc.php (rev 0)
+++ trunk/lib/modules/tr/gettext.inc.php 2008-10-15 13:58:01 UTC (rev 10)
@@ -0,0 +1,28 @@
+<?php
+
+/* gettext translation module */
+
+class GettextTranslator extends translatorBase {
+
+ function GetTextTranslator() {
+ }
+
+ function init() {
+ $locale = app()->user->userInfo('lang');
+ $lang = app()->db->getLang($locale);
+ putenv("LANG=".$lang['locale']);
+ bindtextdomain('openupload',app()->config['INSTALL_ROOT'].'/locale');
+ bindtextdomain('template',app()->config['INSTALL_ROOT'].'/templates/'.app()->config['site']['template'].'/locale');
+ setlocale(LC_ALL,$lang['locale']);
+ /* setup page encoding */
+ if (isset($lang['charset']))
+ header('Content-Type: text/html; charset='.$lang['charset']);
+ }
+
+
+ function translate($txt,$domain = 'openupload') {
+ textdomain($domain);
+ return gettext($txt);
+ }
+}
+?>
\ No newline at end of file
Added: trunk/lib/smarty/Config_File.class.php
===================================================================
--- trunk/lib/smarty/Config_File.class.php (rev 0)
+++ trunk/lib/smarty/Config_File.class.php 2008-10-15 13:58:01 UTC (rev 10)
@@ -0,0 +1,389 @@
+<?php
+
+/**
+ * Config_File class.
+ *
+ * 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://smarty.php.net/
+ * @version 2.6.20
+ * @copyright Copyright: 2001-2005 New Digital Group, Inc.
+ * @author Andrei Zmievski <an...@ph...>
+ * @access public
+ * @package Smarty
+ */
+
+/* $Id: Config_File.class.php 2702 2007-03-08 19:11:22Z mohrt $ */
+
+/**
+ * Config file reading class
+ * @package Smarty
+ */
+class Config_File {
+ /**#@+
+ * Options
+ * @var boolean
+ */
+ /**
+ * Controls whether variables with the same name overwrite each other.
+ */
+ var $overwrite = true;
+
+ /**
+ * Controls whether config values of on/true/yes and off/false/no get
+ * converted to boolean values automatically.
+ */
+ var $booleanize = true;
+
+ /**
+ * Controls whether hidden config sections/vars are read from the file.
+ */
+ var $read_hidden = true;
+
+ /**
+ * Controls whether or not to fix mac or dos formatted newlines.
+ * If set to true, \r or \r\n will be changed to \n.
+ */
+ var $fix_newlines = true;
+ /**#@-*/
+
+ /** @access private */
+ var $_config_path = "";
+ var $_config_data = array();
+ /**#@-*/
+
+ /**
+ * Constructs a new config file class.
+ *
+ * @param string $config_path (optional) path to the config files
+ */
+ function Config_File($config_path = NULL)
+ {
+ if (isset($config_path))
+ $this->set_path($config_path);
+ }
+
+
+ /**
+ * Set the path where configuration files can be found.
+ *
+ * @param string $config_path path to the config files
+ */
+ function set_path($config_path)
+ {
+ if (!empty($config_path)) {
+ if (!is_string($config_path) || !file_exists($config_path) || !is_dir($config_path)) {
+ $this->_trigger_error_msg("Bad config file path '$config_path'");
+ return;
+ }
+ if(substr($config_path, -1) != DIRECTORY_SEPARATOR) {
+ $config_path .= DIRECTORY_SEPARATOR;
+ }
+
+ $this->_config_path = $config_path;
+ }
+ }
+
+
+ /**
+ * Retrieves config info based on the file, section, and variable name.
+ *
+ * @param string $file_name config file to get info for
+ * @param string $section_name (optional) section to get info for
+ * @param string $var_name (optional) variable to get info for
+ * @return string|array a value or array of values
+ */
+ function get($file_name, $section_name = NULL, $var_name = NULL)
+ {
+ if (empty($file_name)) {
+ $this->_trigger_error_msg('Empty config file name');
+ return;
+ } else {
+ $file_name = $this->_config_path . $file_name;
+ if (!isset($this->_config_data[$file_name]))
+ $this->load_file($file_name, false);
+ }
+
+ if (!empty($var_name)) {
+ if (empty($section_name)) {
+ return $this->_config_data[$file_name]["vars"][$var_name];
+ } else {
+ if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name]))
+ return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name];
+ else
+ return array();
+ }
+ } else {
+ if (empty($section_name)) {
+ return (array)$this->_config_data[$file_name]["vars"];
+ } else {
+ if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"]))
+ return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"];
+ else
+ return array();
+ }
+ }
+ }
+
+
+ /**
+ * Retrieves config info based on the key.
+ *
+ * @param $file_name string config key (filename/section/var)
+ * @return string|array same as get()
+ * @uses get() retrieves information from config file and returns it
+ */
+ function &get_key($config_key)
+ {
+ list($file_name, $section_name, $var_name) = explode('/', $config_key, 3);
+ $result = &$this->get($file_name, $section_name, $var_name);
+ return $result;
+ }
+
+ /**
+ * Get all loaded config file names.
+ *
+ * @return array an array of loaded config file names
+ */
+ function get_file_names()
+ {
+ return array_keys($this->_config_data);
+ }
+
+
+ /**
+ * Get all section names from a loaded file.
+ *
+ * @param string $file_name config file to get section names from
+ * @return array an array of section names from the specified file
+ */
+ function get_section_names($file_name)
+ {
+ $file_name = $this->_config_path . $file_name;
+ if (!isset($this->_config_data[$file_name])) {
+ $this->_trigger_error_msg("Unknown config file '$file_name'");
+ return;
+ }
+
+ return array_keys($this->_config_data[$file_name]["sections"]);
+ }
+
+
+ /**
+ * Get all global or section variable names.
+ *
+ * @param string $file_name config file to get info for
+ * @param string $section_name (optional) section to get info for
+ * @return array an array of variables names from the specified file/section
+ */
+ function get_var_names($file_name, $section = NULL)
+ {
+ if (empty($file_name)) {
+ $this->_trigger_error_msg('Empty config file name');
+ return;
+ } else if (!isset($this->_config_data[$file_name])) {
+ $this->_trigger_error_msg("Unknown config file '$file_name'");
+ return;
+ }
+
+ if (empty($section))
+ return array_keys($this->_config_data[$file_name]["vars"]);
+ else
+ return array_keys($this->_config_data[$file_name]["sections"][$section]["vars"]);
+ }
+
+
+ /**
+ * Clear loaded config data for a certain file or all files.
+ *
+ * @param string $file_name file to clear config data for
+ */
+ function clear($file_name = NULL)
+ {
+ if ($file_name === NULL)
+ $this->_config_data = array();
+ else if (isset($this->_config_data[$file_name]))
+ $this->_config_data[$file_name] = array();
+ }
+
+
+ /**
+ * Load a configuration file manually.
+ *
+ * @param string $file_name file name to load
+ * @param boolean $prepend_path whether current config path should be
+ * prepended to the filename
+ */
+ function load_file($file_name, $prepend_path = true)
+ {
+ if ($prepend_path && $this->_config_path != "")
+ $config_file = $this->_config_path . $file_name;
+ else
+ $config_file = $file_name;
+
+ ini_set('track_errors', true);
+ $fp = @fopen($config_file, "r");
+ if (!is_resource($fp)) {
+ $this->_trigger_error_msg("Could not open config file '$config_file'");
+ return false;
+ }
+
+ $contents = ($size = filesize($config_file)) ? fread($fp, $size) : '';
+ fclose($fp);
+
+ $this->_config_data[$config_file] = $this->parse_contents($contents);
+ return true;
+ }
+
+ /**
+ * Store the contents of a file manually.
+ *
+ * @param string $config_file file name of the related contents
+ * @param string $contents the file-contents to parse
+ */
+ function set_file_contents($config_file, $contents)
+ {
+ $this->_config_data[$config_file] = $this->parse_contents($contents);
+ return true;
+ }
+
+ /**
+ * parse the source of a configuration file manually.
+ *
+ * @param string $contents the file-contents to parse
+ */
+ function parse_contents($contents)
+ {
+ if($this->fix_newlines) {
+ // fix mac/dos formatted newlines
+ $contents = preg_replace('!\r\n?!', "\n", $contents);
+ }
+
+ $config_data = array();
+ $config_data['sections'] = array();
+ $config_data['vars'] = array();
+
+ /* reference to fill with data */
+ $vars =& $config_data['vars'];
+
+ /* parse file line by line */
+ preg_match_all('!^.*\r?\n?!m', $contents, $match);
+ $lines = $match[0];
+ for ($i=0, $count=count($lines); $i<$count; $i++) {
+ $line = $lines[$i];
+ if (empty($line)) continue;
+
+ if ( substr($line, 0, 1) == '[' && preg_match('!^\[(.*?)\]!', $line, $match) ) {
+ /* section found */
+ if (substr($match[1], 0, 1) == '.') {
+ /* hidden section */
+ if ($this->read_hidden) {
+ $section_name = substr($match[1], 1);
+ } else {
+ /* break reference to $vars to ignore hidden section */
+ unset($vars);
+ $vars = array();
+ continue;
+ }
+ } else {
+ $section_name = $match[1];
+ }
+ ...
[truncated message content] |
|
From: <ts...@us...> - 2008-10-18 11:48:53
|
Revision: 36
http://openupload.svn.sourceforge.net/openupload/?rev=36&view=rev
Author: tsdogs
Date: 2008-10-18 11:48:45 +0000 (Sat, 18 Oct 2008)
Log Message:
-----------
Make the requested url the default redirect after login
Modified Paths:
--------------
trunk/lib/main.inc.php
trunk/lib/modules/default/auth.inc.php
trunk/lib/user.inc.php
Modified: trunk/lib/main.inc.php
===================================================================
--- trunk/lib/main.inc.php 2008-10-18 11:23:05 UTC (rev 35)
+++ trunk/lib/main.inc.php 2008-10-18 11:48:45 UTC (rev 36)
@@ -299,9 +299,12 @@
$this->display($this->mainPage);
exit(0);
} else {
+ /* save the requested url */
redirect('?action=login');
}
- }
+ }
+ if ($_SERVER['QUERY_STRING']!='')
+ $_SESSION['requested_url']='?'.$_SERVER['QUERY_STRING'];
redirect();
}
$this->initPlugins();
Modified: trunk/lib/modules/default/auth.inc.php
===================================================================
--- trunk/lib/modules/default/auth.inc.php 2008-10-18 11:23:05 UTC (rev 35)
+++ trunk/lib/modules/default/auth.inc.php 2008-10-18 11:48:45 UTC (rev 36)
@@ -68,7 +68,12 @@
return false; /* never reached */
}
/* authentication was successfull */
- redirect();
+ $url = '';
+ if (isset($_SESSION['requested_url'])) {
+ $url = $_SESSION['requested_url'];
+ unset($_SESSION['requested_url']);
+ }
+ redirect($url);
}
function logout() {
Modified: trunk/lib/user.inc.php
===================================================================
--- trunk/lib/user.inc.php 2008-10-18 11:23:05 UTC (rev 35)
+++ trunk/lib/user.inc.php 2008-10-18 11:48:45 UTC (rev 36)
@@ -81,7 +81,7 @@
/* retrieve user info */
$_SESSION['user'] = $this->auth->info($username);;
/* make the post not be resent on refresh */
- redirect();
+ return true;
} else {
// set the error message for the login
app()->error(tr('Login incorrect!'));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2008-10-23 18:15:57
|
Revision: 68
http://openupload.svn.sourceforge.net/openupload/?rev=68&view=rev
Author: tsdogs
Date: 2008-10-23 18:15:55 +0000 (Thu, 23 Oct 2008)
Log Message:
-----------
First buggy version with ldap authentication
Modified Paths:
--------------
trunk/lib/classes.inc.php
trunk/lib/main.inc.php
trunk/lib/modules/auth/default.inc.php
trunk/lib/modules/db/txt.inc.php
trunk/lib/modules/default/admin.inc.php
trunk/lib/modules/default/auth.inc.php
trunk/lib/modules/default/files.inc.php
trunk/lib/user.inc.php
Added Paths:
-----------
trunk/lib/modules/auth/ldap.inc.php
Modified: trunk/lib/classes.inc.php
===================================================================
--- trunk/lib/classes.inc.php 2008-10-23 11:02:34 UTC (rev 67)
+++ trunk/lib/classes.inc.php 2008-10-23 18:15:55 UTC (rev 68)
@@ -11,11 +11,25 @@
}
class authBase {
-var $features = array();
+var $features = array('adminuser' => 'no', 'admingroup' => 'no');
function authBase() {
}
+ function init() {}
+
+ function authenticate($user,$pwd) { return false; }
+
+ function userinfo($login) { return array(); }
+ function groupinfo($group = '') { return array(); }
+
+ function users() { return array(); }
+ function useradd($user) {}
+ function useredit($user) {}
+ function userdel($id) {}
+ function groupadd($group) {}
+ function groupedit($group) {}
+ function groupdel($id) {}
}
Modified: trunk/lib/main.inc.php
===================================================================
--- trunk/lib/main.inc.php 2008-10-23 11:02:34 UTC (rev 67)
+++ trunk/lib/main.inc.php 2008-10-23 18:15:55 UTC (rev 68)
@@ -75,10 +75,10 @@
$this->user->setInfo('lang',$lang);
}
+//unset($_SESSION['user']);
$this->tr->init();
$this->auth->init();
$this->user->init();
-//unset($_SESSION['user']);
if ($this->user->info('max_upload_size')==0)
$this->user->setInfo('max_upload_size',$this->config['max_upload_size']*1024*1024);
ini_set('max_upload_size',$this->user->info('max_upload_size'));
@@ -227,14 +227,22 @@
function loadACL() {
/* loads the acl from the db */
$group = $this->user->group();
- $this->acl = array_merge($this->db->read('acl',array('group_id' => $group),array('module','action'),'',
- array('group_id','module','action')),
- $this->db->read('acl',array('group_id' => '*'),array('module','action'),'',
- array('group_id','module','action')));
- $this->pluginAcl = $this->db->read('plugin_acl',array('group_id' => $group),array('plugin'),'',array('plugin'));
+ if (is_array($group)) {
+ $this->acl = $this->db->read('acl',array(),array('group_name','module','action'),'',
+ array('group_name','module','action'));
+ $this->pluginAcl = $this->db->read('plugin_acl',array(),array('plugin'),'',array('plugin'));
+ } else {
+ $this->acl = array_merge($this->db->read('acl',array('group_name' => $group),array('module','action'),'',
+ array('group_name','module','action')),
+ $this->db->read('acl',array('group_name' => '*'),array('module','action'),'',
+ array('group_name','module','action')));
+ $this->pluginAcl = $this->db->read('plugin_acl',array('group_name' => $group),array('plugin'),'',array('plugin'));
+ }
}
- function checkACL($group,$module,$action) {
+
+ function checkSingleACL($group,$module,$action) {
+
$result = 'deny'; /* not defined are denyed by default */
if (isset($this->acl[$group][$module][$action])) {
$result = $this->acl[$group][$module][$action]['access'];
@@ -249,7 +257,21 @@
} else if (isset($this->acl['*']['*']['*'])) {
$result = $this->acl['*']['*']['*']['access']; /* this should be avoided imho */
}
+ return $result;
+ }
+ function checkACL($group,$module,$action) {
+ if (is_array($group)) {
+ foreach ($group as $g) {
+ $result = $this->checkSingleACL($g,$module,$action);
+ if ($result == 'allow') {
+ return $result;
+ }
+ }
+ } else {
+ $result = $this->checkSingleACL($group,$module,$action);
+ }
+
if ($this->config['debug_acl'] and $result == 'deny') {
echo '<pre>ACL: '.$result.' - group: '.$group.', module: '.$module.', action: '.$action."\n";
print_r($this->acl);
Modified: trunk/lib/modules/auth/default.inc.php
===================================================================
--- trunk/lib/modules/auth/default.inc.php 2008-10-23 11:02:34 UTC (rev 67)
+++ trunk/lib/modules/auth/default.inc.php 2008-10-23 18:15:55 UTC (rev 68)
@@ -5,8 +5,8 @@
var $userfields;
function defaultAuth() {
- $this->userfields = array('id','login','password','name','group_id','email','lang','reg_date','regid','active');
- $this->features = array('info','add', 'update', 'delete');
+ $this->userfields = array('id','login','password','name','group_name','email','lang','reg_date','regid','active');
+ $this->features = array('useradmin' => 'yes', 'groupadmin' => 'yes');
}
function init() {
@@ -22,26 +22,53 @@
return false;
}
- function info($login) {
+ function userinfo($login) {
$result = $this->db->read('users',array('login' => $login));
+ $result['group']=$result['group_name'];
return $result[0];
}
+
+ function groupinfo($group = '') {
+ if ($group != '') {
+ $result = $this->db->read('groups',array('name' => $group));
+ return $result[0]['name'];
+ } else {
+ $result = $this->db->read('groups');
+ return $result;
+ }
+ }
- function add($user) {
+ function users() {
+ return app()->db->read('users',array(),array('login'));
+ }
+
+ function useradd($user) {
$user['password']=crypt($user['password']);
$this->db->insert('users',$user,$this->userfields);
}
- function update($user,$pwd = false) {
+ function useredit($user,$pwd = false) {
if ($pwd) {
$user['password']=crypt($user['password']);
}
$this->db->update('users',$user,array('id' => $user['id']),$this->userfields);
}
- function delete($id) {
+ function userdel($id) {
$this->db->delete('users',array('login' => $id));
}
+
+ function groupadd($group) {
+ $this->db->insert('groups',$group);
+ }
+
+ function groupedit($group) {
+ app()->db->update('groups',$group,array('name' => $group['name']));
+ }
+
+ function groupdel($group_id) {
+ app()->db->delete('groups',array('name' => $group_id));
+ }
}
?>
\ No newline at end of file
Added: trunk/lib/modules/auth/ldap.inc.php
===================================================================
--- trunk/lib/modules/auth/ldap.inc.php (rev 0)
+++ trunk/lib/modules/auth/ldap.inc.php 2008-10-23 18:15:55 UTC (rev 68)
@@ -0,0 +1,104 @@
+<?php
+
+class ldapAuth extends authBase {
+var $config;
+
+ function ldapAuth() {
+ }
+
+ function init() {
+ $this->config = app()->config['ldap'];
+ $this->ufield = isset($this->config['uid'])?$this->config['uid']:'uid';
+ $this->gfield = isset($this->config['gid'])?$this->config['gid']:'gid';
+ /* cannot add or edit users for now */
+ $this->features = array('useradmin' => 'no', 'groupadmin' => 'no');
+ }
+
+ function authenticate($login,$password) {
+ $ds=ldap_connect($this->config['host']);
+ if ($ds) {
+ $uid = $this->ufield.'='.$login.','.$this->config['userdn'];
+ if (ldap_bind($ds, $uid, $password) ) {
+ /* authentication was successfull, save username and password for additional info */
+ $this->uid = $uid;
+ $this->password = $password;
+ return true;
+ }
+ ldap_close($ds);
+ }
+ return false;
+ }
+
+ function userinfo($login) {
+ $ds=@ldap_connect($this->config['host']);
+ $result = array();
+ if (ldap_bind($ds, $this->config['user'],$this->config['password']) ) {
+ $r = @ldap_search($ds, $this->config['userdn'],
+ '(&('.$this->ufield.'='.$login.')(objectclass='.$this->config['userclass'].'))');
+ if ($r) {
+ $res = @ldap_get_entries($ds, $r);
+ /* associate user fields */
+ $res = $res[0];
+ foreach ($this->config['userfields'] as $n => $f) {
+ $result[$f] = $res[$n][0];
+ }
+ }
+ /* now retrieve the main group */
+ $r = @ldap_search($ds, $this->config['groupdn'],
+ '(&('.$this->gfield.'='.$result['group_id'].')(objectclass='.$this->config['groupclass'].'))');
+ if ($r) {
+ $res = @ldap_get_entries($ds, $r);
+ /* associate user fields */
+ $res = $res[0];
+ foreach ($this->config['groupfields'] as $n => $f) {
+ if ($f == 'name') {
+ $result['group'] = $res[$n][0];
+ }
+ }
+ }
+ if (isset($this->config['sgid'])) {
+ $result['group'] = array($result['group']);
+ $r = @ldap_search($ds, $this->config['groupdn'],
+ '(&('.$this->config['sgid'].'='.$result['login'].')(objectclass='.$this->config['groupclass'].'))');
+ if ($r) {
+ $res = @ldap_get_entries($ds, $r);
+ for ($i = 0; $i<$res['count']; $i++) {
+ foreach ($this->config['sgroupfields'] as $n => $f) {
+ if ($f == 'name') {
+ $result['group'][] = $res[$i][$n][0];
+ }
+ }
+ }
+ }
+ }
+ }
+ ldap_close($ds);
+ return $result;
+ }
+
+ function groupinfo($group = '') {
+ $ds=@ldap_connect($this->config['host']);
+ $result = array();
+ @ldap_bind($ds, $this->config['user'], $this->config['password']);
+ if (group != '') {
+ $r = @ldap_search($ds, $this->config['groupdn'],'(objectclass='.$this->config['groupclass'].')');
+ } else {
+ $r = @ldap_search($ds, $this->config['groupdn'],
+ '(&('.$this->gfield.'='.$group.')(objectclass='.$this->config['groupclass'].'))');
+ }
+ if ($r) {
+ $res = @ldap_get_entries($ds, $r);
+ /* associate user fields */
+ for ($i = 0; $i<$res['count']; $i++) {
+ foreach ($this->config['sgroupfields'] as $n => $f) {
+ $result[$i][$f] = $res[$i][$n][0];
+ }
+ }
+ }
+ ldap_close($ds);
+ return $result;
+ }
+
+}
+
+?>
\ No newline at end of file
Modified: trunk/lib/modules/db/txt.inc.php
===================================================================
--- trunk/lib/modules/db/txt.inc.php 2008-10-23 11:02:34 UTC (rev 67)
+++ trunk/lib/modules/db/txt.inc.php 2008-10-23 18:15:55 UTC (rev 68)
@@ -18,7 +18,7 @@
"users" => array (
"type" => "file",
"fields" => array (
- "id", "login", "password", "name", "group_id", "email", "lang", "reg_date", "regid", "active",
+ "id", "login", "password", "name", "group_name", "email", "lang", "reg_date", "regid", "active",
),
"auto_increment" => "id",
),
@@ -38,7 +38,7 @@
"acl" => array (
"type" => "file",
"fields" => array (
- "id", "module", "action", "group_id", "access",
+ "id", "module", "action", "group_name", "access",
),
"auto_increment" => "id",
),
@@ -51,14 +51,14 @@
"plugin_acl" => array (
"type" => "file",
"fields" => array (
- "id", "group_id", "plugin", "access",
+ "id", "group_name", "plugin", "access",
),
"auto_increment" => "id",
),
"plugin_options" => array (
"type" => "file",
"fields" => array (
- "id", "plugin", "group_id", "name", "value",
+ "id", "plugin", "group_name", "name", "value",
),
"auto_increment" => "id",
),
Modified: trunk/lib/modules/default/admin.inc.php
===================================================================
--- trunk/lib/modules/default/admin.inc.php 2008-10-23 11:02:34 UTC (rev 67)
+++ trunk/lib/modules/default/admin.inc.php 2008-10-23 18:15:55 UTC (rev 68)
@@ -73,20 +73,25 @@
function users() {
/* List the users */
- $users = app()->db->read('users',array(),array('login'));
- $this->tpl->assign('users',$users);
+ if (app()->auth->features['useradmin'] == 'yes') {
+ $users = app()->auth->users();
+ $this->tpl->assign('users',$users);
+ } else {
+ app()->error(tr('User administration not supported by Auth Module'));
+ }
}
function useradd() {
global $_POST;
- $groups = app()->db->read('groups',array(),array('name'));
+ $groups = app()->auth->groupinfo();
+ /* do the assoc */
$this->tpl->assign('groups',$groups);
if (isset($_POST['adduserlogin'])) {
/* add the user */
$user['login']=$_POST['adduserlogin'];
$user['name']=$_POST['addusername'];
- $user['group_id']=$_POST['addusergroup'];
+ $user['group_name']=$_POST['addusergroup'];
$user['email']=$_POST['adduseremail'];
$user['active']=$_POST['adduseractive'];
$user['lang']=$_POST['adduserlang'];
@@ -108,14 +113,14 @@
}
if (!$error) {
$user['password']=$_POST['adduserpassword'];
- app()->auth->add($user);
+ app()->auth->useradd($user);
/* redirect */
$this->nextStep(1);
}
}
if (!isset($user)) {
$user['active']=1;
- $user['group_id']=app()->config['register']['default_group'];
+ $user['group_name']=app()->config['register']['default_group'];
}
$this->tpl->assign('adduser',$user);
}
@@ -124,7 +129,7 @@
global $_GET;
if (isset($_GET['id'])) {
- app()->auth->delete($_GET['id']);
+ app()->auth->userdel($_GET['id']);
}
$this->nextStep(1);
}
@@ -134,11 +139,11 @@
if (isset($_GET['id'])) {
$active=$_GET['active']==1?0:1;
- $user = app()->db->read('users',array('login' => $_GET['id']));
+ $user = app()->auth->userinfo($_GET['id']);
$user = $user[0];
if ($user['login']==$_GET['id']) {
$user['active']=$active;
- app()->auth->update($user,false);
+ app()->auth->useredit($user,false);
}
}
$this->nextStep(1);
@@ -148,13 +153,13 @@
global $_GET;
global $_POST;
/* edit the user */
- $groups = app()->db->read('groups',array(),array('name'));
+ $groups = app()->auth->groupinfo();
$this->tpl->assign('groups',$groups);
if (isset($_POST['login'])) {
- $user = app()->db->read('users',array('login' => $_POST['login']));
+ $user = app()->auth->userinfo($_POST['login']);
$user = $user[0];
$user['name']=$_POST['editusername'];
- $user['group_id']=$_POST['editusergroup'];
+ $user['group_name']=$_POST['editusergroup'];
$user['email']=$_POST['edituseremail'];
$user['lang']=$_POST['edituserlang'];
$user['active']=$_POST['edituseractive'];
@@ -175,20 +180,24 @@
$error = true;
}
if (!$error) {
- app()->auth->update($user);
+ app()->auth->useredit($user);
/* redirect */
$this->nextStep(1);
}
} else {
- $user = app()->db->read('users',array('login' => $_GET['id']));
+ $user = app()->auth->info($_GET['id']);
$user = $user[0];
}
$this->tpl->assign('edituser',$user);
}
function groups() {
- $groups = app()->db->read('groups',array(),array('name'));
- $this->tpl->assign('groups',$groups);
+ if (app()->auth->features['groupadmin']=='yes') {
+ $groups = app()->auth->groupinfo();
+ $this->tpl->assign('groups',$groups);
+ } else {
+ app()->error(tr('Group administration not supported by Auth Module'));
+ }
}
function groupadd() {
@@ -198,7 +207,7 @@
$group['name']=$_POST['addgroupname'];
$group['description']=$_POST['addgroupdescription'];
if ($group['name']!='') {
- app()->db->insert('groups',$group);
+ app()->auth->groupadd($group);
$this->nextStep(1);
} else {
app()->error(tr('Please provide a valid group name!'));
@@ -211,13 +220,12 @@
global $_POST;
global $_GET;
- $group = app()->db->read('groups',array('name' => $_GET['id']));
+ $group = app()->auth->groupinfo();
$group = $group[0];
if (isset($_POST['editgroupname'])) {
$group['name']=$_POST['editgroupname'];
$group['description']=$_POST['editgroupdescription'];
- app()->db->update('groups',$group,array('name' => $group['name']));
- $this->nextStep(1);
+ $this->nextStep(1);
}
app()->tpl->assign('group',$group);
}
@@ -226,17 +234,18 @@
global $_GET;
/* should check if sub users exsist */
if (isset($_GET['id'])) {
- app()->db->delete('groups',array('name' => $_GET['id']));
+ app()->auth->groupdel($_GET['id']);
/* delete all the rights of the group */
- app()->db->delete('acl',array('group_id' => $_GET['id']));
+ app()->db->delete('acl',array('group_name' => $_GET['id']));
+ app()->db->delete('pluins_acl',array('group_name' => $_GET['id']));
}
$this->nextStep(1);
}
function rights() {
- $groups = app()->db->read('groups',array(),array('name'));
+ $groups = app()->auth->groupinfo();
$this->tpl->assign('groups',$groups);
- $rights = app()->db->read('acl',array(),array('group_id','module'));
+ $rights = app()->db->read('acl',array(),array('group_name','module'));
$this->tpl->assign('rights',$rights);
}
@@ -246,19 +255,19 @@
$modules = app()->config['modules'];
$modules['*']='*';
$this->tpl->assign('modules',$modules);
- $groups = app()->db->read('groups',array(),array('name'));
+ $groups = app()->auth->groupinfo();
$groups[]='*';
$this->tpl->assign('groups',$groups);
$access['allow']=tr('Allow');
$access['deny']=tr('Deny');
$this->tpl->assign('access',$access);
$right['module']='*';
- $right['group_id']='*';
+ $right['group_name']='*';
$right['action']='*';
$right['access']='deny';
if (isset($_POST['addrightgroup'])) {
$right['id']='';
- $right['group_id']=$_POST['addrightgroup'];
+ $right['group_name']=$_POST['addrightgroup'];
$right['module']=$_POST['addrightmodule'];
$right['action']=$_POST['addrightaction'];
$right['access']=$_POST['addrightaccess'];
@@ -277,7 +286,7 @@
$modules = app()->config['modules'];
$modules['*']='*';
$this->tpl->assign('modules',$modules);
- $groups = app()->db->read('groups',array(),array('name'));
+ $groups = app()->auth->groupinfo();
$groups[]='*';
$this->tpl->assign('groups',$groups);
$access['allow']=tr('Allow');
@@ -286,7 +295,7 @@
if (isset($_POST['editaclid'])) {
$right = app()->db->read('acl',array('id' => $_POST['editaclid']));
$right = $right[0];
- $right['group_id']=$_POST['editrightgroup'];
+ $right['group_name']=$_POST['editrightgroup'];
$right['module']=$_POST['editrightmodule'];
$right['action']=$_POST['editrightaction'];
$right['access']=$_POST['editrightaccess'];
@@ -316,8 +325,6 @@
$count = app()->db->count('files');
$this->tpl->assign('pages',ceil($count / $NUM)+1);
$this->tpl->assign('pagen',$page);
- $users = app()->db->read('users',array(),array('login'),'',array('id'));
- $this->tpl->assign('users',$users);
$files = app()->db->read('files',array(),array('upload_date desc'),$limit);
$this->tpl->assign('files',$files);
}
@@ -354,7 +361,7 @@
$plugins = app()->config['plugins'];
$this->tpl->assign('pluginslist',$plugins);
- $groups = app()->db->read('groups',array(),array('name'));
+ $groups = app()->auth->groupinfo();
$this->tpl->assign('groups',$groups);
$access['enable']=tr('Enable');
$access['disable']=tr('Disable');
@@ -362,7 +369,7 @@
$plugin['access']='disable';
if (isset($_POST['addplugingroup'])) {
$plugin['id']='';
- $plugin['group_id']=$_POST['addplugingroup'];
+ $plugin['group_name']=$_POST['addplugingroup'];
$plugin['plugin']=$_POST['addpluginplugin'];
$plugin['access']=$_POST['addpluginaccess'];
app()->db->insert('plugin_acl',$plugin);
@@ -379,7 +386,7 @@
$plugin = $plugin[0];
$plugins = app()->config['plugins'];
$this->tpl->assign('pluginslist',$plugins);
- $groups = app()->db->read('groups',array(),array('name'));
+ $groups = app()->auth->groupinfo();
$this->tpl->assign('groups',$groups);
$access['enable']=tr('Enable');
$access['disable']=tr('Disable');
@@ -387,7 +394,7 @@
if (isset($_POST['editpluginid'])) {
$plugin = app()->db->read('plugin_acl',array('id' => $_POST['editpluginid']));
$plugin = $plugin[0];
- $plugin['group_id']=$_POST['editplugingroup'];
+ $plugin['group_name']=$_POST['editplugingroup'];
$plugin['plugin']=$_POST['editpluginplugin'];
$plugin['access']=$_POST['editpluginaccess'];
app()->db->update('plugin_acl',$plugin,array('id' => $_POST['editpluginid']));
Modified: trunk/lib/modules/default/auth.inc.php
===================================================================
--- trunk/lib/modules/default/auth.inc.php 2008-10-23 11:02:34 UTC (rev 67)
+++ trunk/lib/modules/default/auth.inc.php 2008-10-23 18:15:55 UTC (rev 68)
@@ -39,7 +39,8 @@
if (!app()->user->loggedin()) {
$this->menu['login']=tr('Login');
} else {
- $this->menu['profile']=tr('Preferences');
+ if (app()->auth->features['adminusers']=='yes')
+ $this->menu['profile']=tr('Preferences');
$this->menu['logout']=tr('Logout');
}
$this->tpl->assign('register',app()->checkACL(app()->user->group(),'auth','register')=='allow');
@@ -140,7 +141,7 @@
$user['password'] = $_POST['registerpassword'];
$user['email'] = $_POST['registeremail'];
$user['lang'] = $_POST['registerlang'];
- $user['group_id'] = app()->config['register']['default_group'];
+ $user['group_name'] = app()->config['register']['default_group'];
$user['reg_date']=date('Y-m-d H:i:s');
$result = app()->pluginAction('registerConfirm',$user);
$_SESSION['register']=$user;
@@ -233,7 +234,7 @@
}
}
if (!$error) {
- app()->auth->update($user);
+ app()->auth->useredit($user);
app()->user->set($user);
$this->nextStep(1);
}
Modified: trunk/lib/modules/default/files.inc.php
===================================================================
--- trunk/lib/modules/default/files.inc.php 2008-10-23 11:02:34 UTC (rev 67)
+++ trunk/lib/modules/default/files.inc.php 2008-10-23 18:15:55 UTC (rev 68)
@@ -88,7 +88,7 @@
$_SESSION['user']['u']['name']=$_FILES['upload']['name'];
$_SESSION['user']['u']['size']=$_FILES['upload']['size'];
$_SESSION['user']['u']['ip']=$_SERVER['REMOTE_ADDR'];
- $_SESSION['user']['u']['user_id']=app()->user->info('id');
+ $_SESSION['user']['u']['user_login']=app()->user->info('login');
$this->nextStep(app()->step);
}
} else if (!isset($_SESSION['user']['u'])) {
@@ -122,7 +122,7 @@
$finfo['id']= app()->db->newRandomId('files','id');
$finfo['remove']= app()->db->newRandomId('files','remove');
$finfo['upload_date'] = date('Y-m-d H:i:s');
- app()->db->insert('files',$finfo,array('id','name','mime','description','size','remove','user_id','ip','upload_date'));
+ app()->db->insert('files',$finfo,array('id','name','mime','description','size','remove','user_login','ip','upload_date'));
foreach (app()->plugins as $plugin) {
if (count($plugin->fields)>0) {
foreach ($plugin->fields as $f) {
Modified: trunk/lib/user.inc.php
===================================================================
--- trunk/lib/user.inc.php 2008-10-23 11:02:34 UTC (rev 67)
+++ trunk/lib/user.inc.php 2008-10-23 18:15:55 UTC (rev 68)
@@ -38,8 +38,8 @@
}
function group() {
- if ($this->info('group_id')!='')
- $group = $this->info('group_id');
+ if ($this->info('group')!='')
+ $group = $this->info('group');
else
$group = app()->config['register']['nologingroup'];
return $group;
@@ -79,7 +79,7 @@
if ($res) {
$_SESSION['user']['login']=$username;
/* retrieve user info */
- $_SESSION['user'] = $this->auth->info($username);;
+ $_SESSION['user'] = $this->auth->userinfo($username);
/* make the post not be resent on refresh */
return true;
} else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2008-10-24 12:29:49
|
Revision: 78
http://openupload.svn.sourceforge.net/openupload/?rev=78&view=rev
Author: tsdogs
Date: 2008-10-24 11:07:40 +0000 (Fri, 24 Oct 2008)
Log Message:
-----------
Add Active Directory Authentication
Modified Paths:
--------------
trunk/lib/main.inc.php
trunk/lib/modules/auth/ldap.inc.php
Modified: trunk/lib/main.inc.php
===================================================================
--- trunk/lib/main.inc.php 2008-10-24 09:45:48 UTC (rev 77)
+++ trunk/lib/main.inc.php 2008-10-24 11:07:40 UTC (rev 78)
@@ -74,8 +74,6 @@
$user = $this->user->info();
$this->user->setInfo('lang',$lang);
}
-
-//unset($_SESSION['user']);
$this->tr->init();
$this->auth->init();
$this->user->init();
Modified: trunk/lib/modules/auth/ldap.inc.php
===================================================================
--- trunk/lib/modules/auth/ldap.inc.php 2008-10-24 09:45:48 UTC (rev 77)
+++ trunk/lib/modules/auth/ldap.inc.php 2008-10-24 11:07:40 UTC (rev 78)
@@ -18,12 +18,16 @@
$this->ds=@ldap_connect($this->config['host']);
if ($this->ds) {
@ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, 3);
+ @ldap_set_option($this->ds, LDAP_OPT_REFERRALS, 0);
return true;
+ } else {
+ app()->error(tr('LDAP connection failed!'));
}
return false;
}
function disconnect() {
+ @ldap_unbind($this->ds);
@ldap_close($this->ds);
}
@@ -35,7 +39,11 @@
function authenticate($login,$password) {
if ($this->connect()) {
- $uid = $this->ufield.'='.$login.','.$this->config['userdn'];
+ if ($this->config['type'] != 'AD') {
+ $uid = $this->ufield.'='.$login.','.$this->config['userdn'];
+ } else {
+ $uid = $login.'@'.$this->config['domain'];
+ }
if (@ldap_bind($this->ds, $uid, $password)) {
return true;
}
@@ -52,24 +60,47 @@
'(&('.$this->ufield.'='.$login.')(objectclass='.$this->config['userclass'].'))');
if ($r) {
$res = @ldap_get_entries($this->ds, $r);
- /* associate user fields */
+ /* associate user fields */echo '<pre>';
$res = $res[0];
foreach ($this->config['userfields'] as $n => $f) {
- $result[$f] = $res[$n][0];
+ if ($f == 'group_id') {
+ $result[$f] = $res[$n];
+ } else {
+ $result[$f] = $res[$n][0];
+ }
}
}
/* now retrieve the main group */
- $r = @ldap_search($this->ds, $this->config['groupdn'],
- '(&('.$this->gfield.'='.$result['group_id'].')(objectclass='.$this->config['groupclass'].'))');
- if ($r) {
- $res = @ldap_get_entries($this->ds, $r);
- /* associate user fields */
- $res = $res[0];
- foreach ($this->config['groupfields'] as $n => $f) {
- if ($f == 'name') {
- $result['group'] = $res[$n][0];
+ if (is_array($result['group_id'])) {
+ for ($g = 0; $g < $result['group_id']['count']; $g++) {
+ $r = @ldap_search($this->ds, $this->config['groupdn'],
+ '(&('.$this->gfield.'='.$result['group_id'][$g].')(objectclass='.$this->config['groupclass'].'))');
+ if ($r) {
+ $res = @ldap_get_entries($this->ds, $r);
+ /* associate user fields */
+ $res = $res[0];
+ foreach ($this->config['groupfields'] as $n => $f) {
+ if ($f == 'name' and $res[$n][0]!='') {
+ $result['group'][] = $res[$n][0];
+ }
+ }
}
}
+ } else {
+ $r = @ldap_search($this->ds, $this->config['groupdn'],
+ '(&('.$this->gfield.'='.$result['group_id'].')(objectclass='.$this->config['groupclass'].'))');
+ if ($r) {
+ $res = @ldap_get_entries($this->ds, $r);
+ /* associate user fields */
+ for ($i = 0; $i<$res['count']; $i++) {
+ $res = $res[0];
+ foreach ($this->config['groupfields'] as $n => $f) {
+ if ($f == 'name' and $res[$n][0]!='') {
+ $result['group'] = $res[$n][0];
+ }
+ }
+ }
+ }
}
if (isset($this->config['sgid'])) {
$result['group'] = array($result['group']);
@@ -79,7 +110,7 @@
$res = @ldap_get_entries($this->ds, $r);
for ($i = 0; $i<$res['count']; $i++) {
foreach ($this->config['sgroupfields'] as $n => $f) {
- if ($f == 'name') {
+ if ($f == 'name' and $res[$n][0]!='') {
$result['group'][] = $res[$i][$n][0];
}
}
@@ -105,7 +136,7 @@
$res = @ldap_get_entries($this->ds, $r);
/* associate user fields */
for ($i = 0; $i<$res['count']; $i++) {
- foreach ($this->config['sgroupfields'] as $n => $f) {
+ foreach ($this->config['groupfields'] as $n => $f) {
$result[$i][$f] = $res[$i][$n][0];
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2008-12-29 10:53:22
|
Revision: 214
http://openupload.svn.sourceforge.net/openupload/?rev=214&view=rev
Author: tsdogs
Date: 2008-12-29 10:53:18 +0000 (Mon, 29 Dec 2008)
Log Message:
-----------
security fix on windows
a couple of additional config options to better support smarty configurations
Modified Paths:
--------------
trunk/lib/general.inc.php
trunk/lib/main.inc.php
Modified: trunk/lib/general.inc.php
===================================================================
--- trunk/lib/general.inc.php 2008-12-29 09:54:56 UTC (rev 213)
+++ trunk/lib/general.inc.php 2008-12-29 10:53:18 UTC (rev 214)
@@ -4,7 +4,10 @@
ob_start();
session_start();
-define('SMARTY_DIR', $CONFIG['INSTALL_ROOT'].'/lib/smarty/');
+if (isset($CONFIG['SMARTY_DIR']))
+ define('SMARTY_DIR', $CONFIG['SMARTY_DIR']);
+else
+ define('SMARTY_DIR', $CONFIG['INSTALL_ROOT'].'/lib/smarty/');
require(SMARTY_DIR . 'Smarty.class.php');
require_once($CONFIG['INSTALL_ROOT'].'/lib/classes.inc.php');
require_once($CONFIG['INSTALL_ROOT'].'/lib/user.inc.php');
@@ -117,7 +120,7 @@
-- Support on Windows PHP for the function 'checkdnsrr'
used within the 'validEmail' function has been added.
-- Pending further investigation.
- -- Discovery/Solution thanks to: Korn\x8El
+ -- Discovery/Solution thanks to: Korn�l
-- http://hu.php.net/manual/en/function.checkdnsrr.php#75158
*/
function validEmail($email){
@@ -129,7 +132,7 @@
if($recType == ''){
$recType = "MX";
}
- exec("nslookup -type=$recType $hostName", $result);
+ exec("nslookup -type=$recType ".escapeshellcmd($hostName), $result);
// check each line to find the one that starts with the host
// name. If it exists then the function succeeded.
foreach ($result as $line) {
Modified: trunk/lib/main.inc.php
===================================================================
--- trunk/lib/main.inc.php 2008-12-29 09:54:56 UTC (rev 213)
+++ trunk/lib/main.inc.php 2008-12-29 10:53:18 UTC (rev 214)
@@ -22,9 +22,14 @@
/* initialize template engine */
$this->tpl = new Smarty();
$this->tpl->template_dir = $this->config['INSTALL_ROOT'].'/templates';
- $this->tpl->compile_dir = $this->config['INSTALL_ROOT'].'/templates_c/';
- $this->tpl->config_dir = SMARTY_DIR.'/config';
- $this->tpl->cache_dir = $this->config['INSTALL_ROOT'].'/cache';
+ if (isset($this->config['SMARTY_DATA'])) {
+ $this->tpl->compile_dir = $this->config['SMARTY_DATA'].'/templates_c/';
+ $this->tpl->cache_dir = $this->config['SMARTY_DATA'].'/cache';
+ } else {
+ $this->tpl->compile_dir = $this->config['INSTALL_ROOT'].'/templates_c/';
+ $this->tpl->cache_dir = $this->config['INSTALL_ROOT'].'/cache';
+ }
+ $this->tpl->config_dir = SMARTY_DIR.'/configs';
$this->tpl->caching = $this->config['site']['caching'];
$this->page['template']= $this->config['WWW_ROOT'].'/templates/'.$this->config['site']['template'];
@@ -53,7 +58,7 @@
if (isset($this->config['translator'])) {
$trname = $this->config['translator'];
} else {
- $trname = 'gettext';
+ $trname = 'null';
}
require_once($this->config['INSTALL_ROOT'].'/lib/modules/tr/'.$trname.'.inc.php');
$tr = $trname.'Translator';
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2009-08-29 10:58:35
|
Revision: 347
http://openupload.svn.sourceforge.net/openupload/?rev=347&view=rev
Author: tsdogs
Date: 2009-08-29 10:58:27 +0000 (Sat, 29 Aug 2009)
Log Message:
-----------
Add index.html for control to directory listing.
Added Paths:
-----------
trunk/lib/index.html
trunk/lib/modules/auth/index.html
trunk/lib/modules/db/index.html
trunk/lib/modules/default/index.html
trunk/lib/modules/index.html
trunk/lib/modules/tr/index.html
trunk/lib/smarty/configs/index.html
trunk/lib/smarty/index.html
trunk/lib/smarty/internals/index.html
trunk/lib/smarty/plugins/index.html
trunk/lib/smarty_plugins/index.html
Added: trunk/lib/index.html
===================================================================
--- trunk/lib/index.html (rev 0)
+++ trunk/lib/index.html 2009-08-29 10:58:27 UTC (rev 347)
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title>NO ACCESS</title>
+<meta http-equiv="REFRESH" content="0;url=../"></HEAD>
+<BODY>
+No direct access is allowed on this folder.
+</BODY>
+</HTML>
\ No newline at end of file
Added: trunk/lib/modules/auth/index.html
===================================================================
--- trunk/lib/modules/auth/index.html (rev 0)
+++ trunk/lib/modules/auth/index.html 2009-08-29 10:58:27 UTC (rev 347)
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title>NO ACCESS</title>
+<meta http-equiv="REFRESH" content="0;url=../"></HEAD>
+<BODY>
+No direct access is allowed on this folder.
+</BODY>
+</HTML>
\ No newline at end of file
Added: trunk/lib/modules/db/index.html
===================================================================
--- trunk/lib/modules/db/index.html (rev 0)
+++ trunk/lib/modules/db/index.html 2009-08-29 10:58:27 UTC (rev 347)
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title>NO ACCESS</title>
+<meta http-equiv="REFRESH" content="0;url=../"></HEAD>
+<BODY>
+No direct access is allowed on this folder.
+</BODY>
+</HTML>
\ No newline at end of file
Added: trunk/lib/modules/default/index.html
===================================================================
--- trunk/lib/modules/default/index.html (rev 0)
+++ trunk/lib/modules/default/index.html 2009-08-29 10:58:27 UTC (rev 347)
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title>NO ACCESS</title>
+<meta http-equiv="REFRESH" content="0;url=../"></HEAD>
+<BODY>
+No direct access is allowed on this folder.
+</BODY>
+</HTML>
\ No newline at end of file
Added: trunk/lib/modules/index.html
===================================================================
--- trunk/lib/modules/index.html (rev 0)
+++ trunk/lib/modules/index.html 2009-08-29 10:58:27 UTC (rev 347)
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title>NO ACCESS</title>
+<meta http-equiv="REFRESH" content="0;url=../"></HEAD>
+<BODY>
+No direct access is allowed on this folder.
+</BODY>
+</HTML>
\ No newline at end of file
Added: trunk/lib/modules/tr/index.html
===================================================================
--- trunk/lib/modules/tr/index.html (rev 0)
+++ trunk/lib/modules/tr/index.html 2009-08-29 10:58:27 UTC (rev 347)
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title>NO ACCESS</title>
+<meta http-equiv="REFRESH" content="0;url=../"></HEAD>
+<BODY>
+No direct access is allowed on this folder.
+</BODY>
+</HTML>
\ No newline at end of file
Added: trunk/lib/smarty/configs/index.html
===================================================================
--- trunk/lib/smarty/configs/index.html (rev 0)
+++ trunk/lib/smarty/configs/index.html 2009-08-29 10:58:27 UTC (rev 347)
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title>NO ACCESS</title>
+<meta http-equiv="REFRESH" content="0;url=../"></HEAD>
+<BODY>
+No direct access is allowed on this folder.
+</BODY>
+</HTML>
\ No newline at end of file
Added: trunk/lib/smarty/index.html
===================================================================
--- trunk/lib/smarty/index.html (rev 0)
+++ trunk/lib/smarty/index.html 2009-08-29 10:58:27 UTC (rev 347)
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title>NO ACCESS</title>
+<meta http-equiv="REFRESH" content="0;url=../"></HEAD>
+<BODY>
+No direct access is allowed on this folder.
+</BODY>
+</HTML>
\ No newline at end of file
Added: trunk/lib/smarty/internals/index.html
===================================================================
--- trunk/lib/smarty/internals/index.html (rev 0)
+++ trunk/lib/smarty/internals/index.html 2009-08-29 10:58:27 UTC (rev 347)
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title>NO ACCESS</title>
+<meta http-equiv="REFRESH" content="0;url=../"></HEAD>
+<BODY>
+No direct access is allowed on this folder.
+</BODY>
+</HTML>
\ No newline at end of file
Added: trunk/lib/smarty/plugins/index.html
===================================================================
--- trunk/lib/smarty/plugins/index.html (rev 0)
+++ trunk/lib/smarty/plugins/index.html 2009-08-29 10:58:27 UTC (rev 347)
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title>NO ACCESS</title>
+<meta http-equiv="REFRESH" content="0;url=../"></HEAD>
+<BODY>
+No direct access is allowed on this folder.
+</BODY>
+</HTML>
\ No newline at end of file
Added: trunk/lib/smarty_plugins/index.html
===================================================================
--- trunk/lib/smarty_plugins/index.html (rev 0)
+++ trunk/lib/smarty_plugins/index.html 2009-08-29 10:58:27 UTC (rev 347)
@@ -0,0 +1,9 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title>NO ACCESS</title>
+<meta http-equiv="REFRESH" content="0;url=../"></HEAD>
+<BODY>
+No direct access is allowed on this folder.
+</BODY>
+</HTML>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2008-11-07 19:09:05
|
Revision: 131
http://openupload.svn.sourceforge.net/openupload/?rev=131&view=rev
Author: tsdogs
Date: 2008-11-07 19:08:56 +0000 (Fri, 07 Nov 2008)
Log Message:
-----------
Add database connection close
Modified Paths:
--------------
trunk/lib/classes.inc.php
trunk/lib/general.inc.php
trunk/lib/main.inc.php
Modified: trunk/lib/classes.inc.php
===================================================================
--- trunk/lib/classes.inc.php 2008-11-07 19:07:57 UTC (rev 130)
+++ trunk/lib/classes.inc.php 2008-11-07 19:08:56 UTC (rev 131)
@@ -43,6 +43,10 @@
}
+ function free() {
+
+ }
+
function newId($tbl,$field = 'id',$keys = array ()) {
app()->error('Please reimplement: '.$this->name.' newId');
return 0;
Modified: trunk/lib/general.inc.php
===================================================================
--- trunk/lib/general.inc.php 2008-11-07 19:07:57 UTC (rev 130)
+++ trunk/lib/general.inc.php 2008-11-07 19:08:56 UTC (rev 131)
@@ -45,6 +45,7 @@
} else {
header('location: '.$url);
}
+ app()->db->close();
exit(0);
}
Modified: trunk/lib/main.inc.php
===================================================================
--- trunk/lib/main.inc.php 2008-11-07 19:07:57 UTC (rev 130)
+++ trunk/lib/main.inc.php 2008-11-07 19:08:56 UTC (rev 131)
@@ -373,6 +373,7 @@
$this->page['title']= tr('IP Banned');
$this->tpl->assign('page',app()->page);
$this->display($this->mainPage);
+ $this->db->free();
exit;
}
/* depending on the acl some actions need authentication others don't */
@@ -398,6 +399,7 @@
$this->page['content']=tr('THERE HAS BEEN A PERMISSION ERROR. PLEASE TRY ONE OF THE ALLOWED OPTIONS!');
$this->tpl->assign('page',$this->page);
$this->display($this->mainPage);
+ $this->db->free();
exit(0);
} else {
/* save the requested url */
@@ -435,6 +437,7 @@
$this->page['content']=$this->fetch('modules/'.$m->name.'/'.$fun);
$this->tpl->assign('page',$this->page);
$this->display($this->mainPage);
+ $this->db->free();
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2009-08-29 08:34:11
|
Revision: 345
http://openupload.svn.sourceforge.net/openupload/?rev=345&view=rev
Author: tsdogs
Date: 2009-08-29 08:34:03 +0000 (Sat, 29 Aug 2009)
Log Message:
-----------
separate personal plugins from smarty default ones
Added Paths:
-----------
trunk/lib/smarty_plugins/
trunk/lib/smarty_plugins/block.tr.php
trunk/lib/smarty_plugins/function.db_table.php
trunk/lib/smarty_plugins/function.tpl.php
trunk/lib/smarty_plugins/modifier.fsize_format.php
Removed Paths:
-------------
trunk/lib/smarty/plugins/block.tr.php
trunk/lib/smarty/plugins/function.db_table.php
trunk/lib/smarty/plugins/function.tpl.php
trunk/lib/smarty/plugins/modifier.fsize_format.php
Deleted: trunk/lib/smarty/plugins/block.tr.php
===================================================================
--- trunk/lib/smarty/plugins/block.tr.php 2009-08-28 15:16:42 UTC (rev 344)
+++ trunk/lib/smarty/plugins/block.tr.php 2009-08-29 08:34:03 UTC (rev 345)
@@ -1,34 +0,0 @@
-<?php
-/**
- * Smarty plugin
- * @package OpenUpload
- * @subpackage plugins
- */
-
-
-/**
- * Smarty {tr} block plugin
- *
- * Type: block
- * Name: tr
- * Purpose: Translate contained text with a user defined function "translate"
- * @author Alessandro Briosi
- * @param array
- * @param Smarty
- * @return string
- * @uses translate()
- */
-
-function smarty_block_tr($params, $content = null, &$smarty, &$repeat) {
-
- if(!$repeat){
- if (isset($content)) {
-// return htmlentities(translate($content,'template',$params));
- return translate($content, 'template',$params);
- } else {
- return '';
- }
- }
-}
-
-?>
\ No newline at end of file
Deleted: trunk/lib/smarty/plugins/function.db_table.php
===================================================================
--- trunk/lib/smarty/plugins/function.db_table.php 2009-08-28 15:16:42 UTC (rev 344)
+++ trunk/lib/smarty/plugins/function.db_table.php 2009-08-29 08:34:03 UTC (rev 345)
@@ -1,40 +0,0 @@
-<?php
-
-
-
-function smarty_function_db_table($params, &$smarty){
-
- $data = $params['data'];
- isset($params['header'])?$headers = $params['header']:$headers=array();
- isset($params['fields'])?$fields = $params['fields']:$fields=array();
-
- $fields_set = count($fields)>0;
-
- $result = '<table '.$params['tbloptions'].'>';
- $result .= "<tbody>\n";
- if (count($headers)>0){
- $result .= '<tr>';
- foreach ($headers as $val){
- $result .= '<th>'.$val.'</th>';
- }
- $result .= '</tr>';
- }
-
- foreach ($data as $row){
- $result .= '<tr>';
- if ($fields_set) {
- foreach ($fields as $val){
- $result .= '<td>'.htmlentities($row[$val]).'</td>';
- }
- } else {
- foreach ($row as $val){
- $result .= '<td>'.htmlentities($val).'</td>';
- }
- }
- $result .= '</tr>'."\n";
- }
-
- $result .= "</tbody>\n";
- $result .= "</table>\n";
- return $result;
-}
\ No newline at end of file
Deleted: trunk/lib/smarty/plugins/function.tpl.php
===================================================================
--- trunk/lib/smarty/plugins/function.tpl.php 2009-08-28 15:16:42 UTC (rev 344)
+++ trunk/lib/smarty/plugins/function.tpl.php 2009-08-29 08:34:03 UTC (rev 345)
@@ -1,30 +0,0 @@
-<?php
-/**
- * Smarty plugin
- * @package OpenUpload
- * @subpackage plugins
- */
-
-
-/**
- * Smarty {tpl} function plugin
- *
- * Type: function
- * Name: tpl
- * Input:
- * - file (required) - string containing template sub file
- * Purpose: Returns a file from the template folder, if it does not exsist
- * it returns a file from the default template
- * @author Alessandro Briosi
- * @param array
- * @param Smarty
- * @return string
- * @uses template_file
- */
-
-function smarty_function_tpl($params, &$smarty)
-{
- return template_file($params["file"]);
-
-}
-?>
\ No newline at end of file
Deleted: trunk/lib/smarty/plugins/modifier.fsize_format.php
===================================================================
--- trunk/lib/smarty/plugins/modifier.fsize_format.php 2009-08-28 15:16:42 UTC (rev 344)
+++ trunk/lib/smarty/plugins/modifier.fsize_format.php 2009-08-29 08:34:03 UTC (rev 345)
@@ -1,43 +0,0 @@
-<?php
-/*
-* Smarty plugin
-* -------------------------------------------------------------
-* Type: modifier
-* Name: fsize_format
-* Version: 0.1
-* Date: 2003-02-21
-* Author: Joscha Feth, jo...@fe...
-* Purpose: formats a filesize (in bytes) to human-readable format
-* Usage: In the template, use
- {$filesize|fsize_format} => 123.45 B|KB|MB|GB|TB
- or
- {$filesize|fsize_format:"MB"} => 123.45 MB
- or
- {$filesize|fsize_format:"TB":4} => 0.0012 TB
-* Params:
- int size the filesize in bytes
- string format the format, the output shall be: B, KB, MB, GB or TB
- int precision the rounding precision
-* Install: Drop into the plugin directory
-* -------------------------------------------------------------
-*/
-function smarty_modifier_fsize_format($size,$format = '',$precision = 2)
-{
-
- //~ file measurements, could be calculated on the fly, but its faster like that
- $sizes = array();
- $sizes["TB"] = 1099511627776;
- $sizes["GB"] = 1073741824;
- $sizes["MB"] = 1048576;
- $sizes["KB"] = 1024;
- $sizes["B"] = 1;
-
- //~ get "human" filesize
- foreach($sizes AS $unit => $bytes) {
- if($size > $bytes || $unit == strtoupper($format)) {
- //~ return formatted size
- return number_format($size / $bytes,$precision)." ".$unit;
- } //~ end if
- } //~ end foreach
-} //~ end function
-?>
Copied: trunk/lib/smarty_plugins/block.tr.php (from rev 285, trunk/lib/smarty/plugins/block.tr.php)
===================================================================
--- trunk/lib/smarty_plugins/block.tr.php (rev 0)
+++ trunk/lib/smarty_plugins/block.tr.php 2009-08-29 08:34:03 UTC (rev 345)
@@ -0,0 +1,34 @@
+<?php
+/**
+ * Smarty plugin
+ * @package OpenUpload
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {tr} block plugin
+ *
+ * Type: block
+ * Name: tr
+ * Purpose: Translate contained text with a user defined function "translate"
+ * @author Alessandro Briosi
+ * @param array
+ * @param Smarty
+ * @return string
+ * @uses translate()
+ */
+
+function smarty_block_tr($params, $content = null, &$smarty, &$repeat) {
+
+ if(!$repeat){
+ if (isset($content)) {
+// return htmlentities(translate($content,'template',$params));
+ return translate($content, 'template',$params);
+ } else {
+ return '';
+ }
+ }
+}
+
+?>
\ No newline at end of file
Property changes on: trunk/lib/smarty_plugins/block.tr.php
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mergeinfo
+
Copied: trunk/lib/smarty_plugins/function.db_table.php (from rev 285, trunk/lib/smarty/plugins/function.db_table.php)
===================================================================
--- trunk/lib/smarty_plugins/function.db_table.php (rev 0)
+++ trunk/lib/smarty_plugins/function.db_table.php 2009-08-29 08:34:03 UTC (rev 345)
@@ -0,0 +1,40 @@
+<?php
+
+
+
+function smarty_function_db_table($params, &$smarty){
+
+ $data = $params['data'];
+ isset($params['header'])?$headers = $params['header']:$headers=array();
+ isset($params['fields'])?$fields = $params['fields']:$fields=array();
+
+ $fields_set = count($fields)>0;
+
+ $result = '<table '.$params['tbloptions'].'>';
+ $result .= "<tbody>\n";
+ if (count($headers)>0){
+ $result .= '<tr>';
+ foreach ($headers as $val){
+ $result .= '<th>'.$val.'</th>';
+ }
+ $result .= '</tr>';
+ }
+
+ foreach ($data as $row){
+ $result .= '<tr>';
+ if ($fields_set) {
+ foreach ($fields as $val){
+ $result .= '<td>'.htmlentities($row[$val]).'</td>';
+ }
+ } else {
+ foreach ($row as $val){
+ $result .= '<td>'.htmlentities($val).'</td>';
+ }
+ }
+ $result .= '</tr>'."\n";
+ }
+
+ $result .= "</tbody>\n";
+ $result .= "</table>\n";
+ return $result;
+}
\ No newline at end of file
Property changes on: trunk/lib/smarty_plugins/function.db_table.php
___________________________________________________________________
Added: svn:executable
+ *
Added: svn:mergeinfo
+
Copied: trunk/lib/smarty_plugins/function.tpl.php (from rev 285, trunk/lib/smarty/plugins/function.tpl.php)
===================================================================
--- trunk/lib/smarty_plugins/function.tpl.php (rev 0)
+++ trunk/lib/smarty_plugins/function.tpl.php 2009-08-29 08:34:03 UTC (rev 345)
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Smarty plugin
+ * @package OpenUpload
+ * @subpackage plugins
+ */
+
+
+/**
+ * Smarty {tpl} function plugin
+ *
+ * Type: function
+ * Name: tpl
+ * Input:
+ * - file (required) - string containing template sub file
+ * Purpose: Returns a file from the template folder, if it does not exsist
+ * it returns a file from the default template
+ * @author Alessandro Briosi
+ * @param array
+ * @param Smarty
+ * @return string
+ * @uses template_file
+ */
+
+function smarty_function_tpl($params, &$smarty)
+{
+ return template_file($params["file"]);
+
+}
+?>
\ No newline at end of file
Property changes on: trunk/lib/smarty_plugins/function.tpl.php
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/lib/smarty_plugins/modifier.fsize_format.php (from rev 285, trunk/lib/smarty/plugins/modifier.fsize_format.php)
===================================================================
--- trunk/lib/smarty_plugins/modifier.fsize_format.php (rev 0)
+++ trunk/lib/smarty_plugins/modifier.fsize_format.php 2009-08-29 08:34:03 UTC (rev 345)
@@ -0,0 +1,43 @@
+<?php
+/*
+* Smarty plugin
+* -------------------------------------------------------------
+* Type: modifier
+* Name: fsize_format
+* Version: 0.1
+* Date: 2003-02-21
+* Author: Joscha Feth, jo...@fe...
+* Purpose: formats a filesize (in bytes) to human-readable format
+* Usage: In the template, use
+ {$filesize|fsize_format} => 123.45 B|KB|MB|GB|TB
+ or
+ {$filesize|fsize_format:"MB"} => 123.45 MB
+ or
+ {$filesize|fsize_format:"TB":4} => 0.0012 TB
+* Params:
+ int size the filesize in bytes
+ string format the format, the output shall be: B, KB, MB, GB or TB
+ int precision the rounding precision
+* Install: Drop into the plugin directory
+* -------------------------------------------------------------
+*/
+function smarty_modifier_fsize_format($size,$format = '',$precision = 2)
+{
+
+ //~ file measurements, could be calculated on the fly, but its faster like that
+ $sizes = array();
+ $sizes["TB"] = 1099511627776;
+ $sizes["GB"] = 1073741824;
+ $sizes["MB"] = 1048576;
+ $sizes["KB"] = 1024;
+ $sizes["B"] = 1;
+
+ //~ get "human" filesize
+ foreach($sizes AS $unit => $bytes) {
+ if($size > $bytes || $unit == strtoupper($format)) {
+ //~ return formatted size
+ return number_format($size / $bytes,$precision)." ".$unit;
+ } //~ end if
+ } //~ end foreach
+} //~ end function
+?>
Property changes on: trunk/lib/smarty_plugins/modifier.fsize_format.php
___________________________________________________________________
Added: svn:mergeinfo
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2009-11-07 22:45:34
|
Revision: 353
http://openupload.svn.sourceforge.net/openupload/?rev=353&view=rev
Author: tsdogs
Date: 2009-11-07 22:45:26 +0000 (Sat, 07 Nov 2009)
Log Message:
-----------
split base from main application
Modified Paths:
--------------
trunk/lib/main.inc.php
Added Paths:
-----------
trunk/lib/base.inc.php
Added: trunk/lib/base.inc.php
===================================================================
--- trunk/lib/base.inc.php (rev 0)
+++ trunk/lib/base.inc.php 2009-11-07 22:45:26 UTC (rev 353)
@@ -0,0 +1,366 @@
+<?php
+
+/* Base application */
+class baseApplication
+{
+ var $config; /* condifuration */
+ var $modules; /* modules */
+ var $actions; /* actions related to modules */
+ var $page; /* page global config */
+ var $langs; /* contains the languages list */
+ var $acl; /* module acl */
+ var $tr; /* trasnlation */
+ var $name; /* application name */
+
+ function baseApplication($CONFIG) {
+ global $application;
+ global $_GET;
+
+ $application = $this;
+ $this->config = $CONFIG;
+
+ /* initialize template engine */
+ $this->tpl = new Smarty();
+ if (isset($this->config['TEMPLATES_PATH']))
+ $this->tpl->template_dir = $this->config['TEMPLATES_PATH'];
+ else
+ $this->tpl->template_dir = $this->config['INSTALL_ROOT'].'/templates';
+ if (isset($this->config['SMARTY_DATA'])) {
+ $this->tpl->compile_dir = $this->config['SMARTY_DATA'].'/templates_c/';
+ $this->tpl->cache_dir = $this->config['SMARTY_DATA'].'/cache';
+ } else {
+ $this->tpl->compile_dir = $this->config['DATA_PATH'].'/templates_c/';
+ $this->tpl->cache_dir = $this->config['DATA_PATH'].'/cache';
+ }
+ $this->tpl->config_dir = SMARTY_DIR.'/configs';
+ $this->tpl->plugins_dir[] = $this->config['INSTALL_ROOT'].'/lib/smarty_plugins';
+ $this->tpl->caching = $this->config['site']['caching'];
+
+ $this->page['template'] = $this->config['WWW_ROOT'].'/templates/'.$this->config['site']['template'];
+ $this->tpl->assign('template',$this->config['site']['template']);
+
+ /* database module */
+ $dbtype = $this->config['database']['type'];
+ require_once($this->config['INSTALL_ROOT'].'/lib/modules/db/'.$dbtype.'.inc.php');
+ $dbmname = $dbtype.'DB';
+ $this->db = new $dbmname($this->config['database']);
+ $this->db->init(); /* open db connection */
+
+ /* authentication module */
+ if (isset($this->config['auth'])) {
+ $authmname = $this->config['auth'];
+ } else {
+ $authmname = 'default';
+ }
+ require_once($this->config['INSTALL_ROOT'].'/lib/modules/auth/'.$authmname.'.inc.php');
+ $auth = $authmname.'Auth';
+ $this->auth = new $auth();
+
+ $this->user = new OpenUploadUser();
+ $this->user->auth = &$this->auth;
+
+ /* translation module */
+ if (isset($this->config['translator'])) {
+ $trname = $this->config['translator'];
+ } else {
+ $trname = 'null';
+ }
+ require_once($this->config['INSTALL_ROOT'].'/lib/modules/tr/'.$trname.'.inc.php');
+ $tr = $trname.'Translator';
+ $this->tr = new $tr();
+
+ $this->langs = $this->db->read('langs',array('active' => '1'),array('id'),'',array('id'));
+
+ /* check if it was forced */
+ if (isset($_GET['lang'])) {
+ $user = $this->user->info();
+ $user['lang']=$_GET['lang'];
+ $this->user->setInfo('lang',$_GET['lang']);
+ }
+
+ /* configure the language */
+ if ($this->user->info('lang')=='') {
+ $lang = $this->getBrowserLang();
+ $user = $this->user->info();
+ $this->user->setInfo('lang',$lang);
+ }
+ $this->tr->init();
+ $this->auth->init();
+ $this->user->init();
+
+ }
+
+ /* gets the best language match based on browser info */
+ function getBrowserLang() {
+ global $_SERVER;
+
+ /* calculate preferred language */
+ $langs = str_replace(' ','',strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
+ $langs = explode(',',$langs);
+ foreach ($langs as $ls) {
+ $language = explode(';',$ls);
+ foreach ($language as $l) {
+ foreach ($this->langs as $ml) {
+ if (strpos(strtolower($ml['browser']),'['.$l.']')!==FALSE) {
+ return $ml['id'];
+ }
+ if (strpos($l,'-')) {
+ $x = explode('-',$l);
+ if (strpos(strtolower($ml['browser']),'['.$x[0].']')!==FALSE) {
+ return $ml['id'];
+ }
+ }
+ }
+ }
+ }
+ return $this->config['defaultlang'];
+ }
+
+ /* returns the output from the template engine */
+ function fetch($tname) {
+ if (file_exists($this->tpl->template_dir.'/'.$this->config['site']['template'].'/'.$tname.'.tpl')) {
+ return $this->tpl->fetch($this->config['site']['template'].'/'.$tname.'.tpl');
+ } else {
+ return $this->tpl->fetch('default/'.$tname.'.tpl');
+ }
+ }
+
+ function exists($tname) {
+ if (file_exists($this->tpl->template_dir.'/'.$this->config['site']['template'].'/'.$tname.'.tpl')) {
+ return true;
+ } else if (file_exists($this->tpl->template_dir.'/default/'.$tname.'.tpl')){
+ return true;
+ }
+ return false;
+ }
+ /* displays the output from the template engine */
+ function display($tname) {
+ if (file_exists($this->tpl->template_dir.'/'.$this->config['site']['template'].'/'.$tname.'.tpl')) {
+ $this->tpl->display($this->config['site']['template'].'/'.$tname.'.tpl');
+ } else {
+ $this->tpl->display('default/'.$tname.'.tpl');
+ }
+ }
+
+ function initModules() {
+ /* initialize configured modules */
+ foreach ($this->config['modules'] as $module) {
+ /* create and initialize the module */
+ require_once($this->config['INSTALL_ROOT'].'/lib/modules/default/'.$module.'.inc.php');
+ $m = $module.'Module';
+ $m = new $m();
+ $m->name = $module;
+ $m->tpl = &$this->tpl;
+ foreach ($m->actions as $k => $l) {
+ $this->actions[$k] = $m->name;
+ $this->modules[$module] = $m;
+ }
+ }
+ foreach ($this->modules as $m) {
+ $m->init();
+ }
+ }
+
+ function initMenu($group = '',$module) {
+
+ $this->menu['main'] = array();
+ foreach ($this->modules as $m) {
+ if (isset($m->mainmenu)) {
+ foreach ($m->actions as $k => $v) {
+ if ($this->checkACL($group,$m->name,$k) == 'allow') {
+ if (isset($m->mainmenu[$k])) {
+ $this->menu['main'][$k]=$m->mainmenu[$k];
+ }
+ }
+ }
+ }
+ }
+ $this->tpl->assign('menu',$this->menu);
+ }
+
+ function loadACL() {
+ $this->acl = array();
+ }
+
+ function checkSingleACL($group,$module,$action) {
+
+ $result = 'deny'; /* not defined are denyed by default */
+ if (isset($this->acl[$group][$module][$action])) {
+ $result = $this->acl[$group][$module][$action]['access'];
+ } else if (isset($this->acl[$group][$module]['*'])) {
+ $result = $this->acl[$group][$module]['*']['access'];
+ } else if (isset($this->acl[$group]['*']['*'])) {
+ $result = $this->acl[$group]['*']['*']['access'];
+ } else if (isset($this->acl['*'][$module][$action])) {
+ $result = $this->acl['*'][$module][$action];
+ } else if (isset($this->acl['*'][$module]['*'])) {
+ $result = $this->acl['*'][$module]['*']['access'];
+ } else if (isset($this->acl['*']['*']['*'])) {
+ $result = $this->acl['*']['*']['*']['access']; /* this should be avoided imho */
+ }
+ return $result;
+ }
+
+ function checkACL($group,$module,$action) {
+ if (count($this->acl) == 0)
+ return 'allow';
+ if (is_array($group)) {
+ foreach ($group as $g) {
+ $result = $this->checkSingleACL($g,$module,$action);
+ if ($result == 'allow') {
+ return $result;
+ }
+ }
+ } else {
+ $result = $this->checkSingleACL($group,$module,$action);
+ }
+
+ if (isset($this->config['debug_acl']) and $this->config['debug_acl'] and $result == 'deny') {
+ echo '<pre>ACL: '.$result.' - group: '.$group.', module: '.$module.', action: '.$action."\n";
+ print_r($this->acl);
+ echo '</pre>';
+ $result = 'allow';
+ }
+
+ return $result;
+ }
+
+ function log($level,$realaction,$plugin,$result,$moreinfo) {
+
+ }
+
+ function initPlugins() {
+ /* initialize plugin system */
+ $this->pluginOutput = '';
+
+ $this->plugins = array();
+ /* load the plugins */
+ foreach ($this->config['plugins'] as $plugin) {
+ /* include the file */
+ if (file_exists($this->config['INSTALL_ROOT'].'/plugins/'.$plugin.'.inc.php')) {
+ require_once($this->config['INSTALL_ROOT'].'/plugins/'.$plugin.'.inc.php');
+ $pname = $plugin."Plugin";
+ $newp = new $pname();
+ $newp->name = $plugin;
+ $this->plugins[$plugin] = $newp;
+ } else {
+ $this->error(tr('plugin include file not found: %1',$plugin));
+ }
+ }
+ foreach ($this->plugins as $plugin) {
+ $plugin->init();
+ }
+ }
+
+ function pluginAction($action,&$finfo,$stop = true) {
+ //$this->pluginHTML = '';
+ $result = true;
+
+ if (!is_array($this->plugins))
+ return true;
+ foreach ($this->plugins as $plugin) {
+ if (method_exists($plugin,$action)) {
+ /* check plugin acl */
+ $acl = 'disable'; /* disabled by default */
+ if (isset($this->pluginAcl[$plugin->name])) {
+ $acl = $this->pluginAcl[$plugin->name]['access'];
+ }
+ $plugin->pluginHTML = '';
+ if (!$plugin->$action($finfo,$acl)) {
+ if ($stop) {
+ app()->log('security',$action,$plugin->name,'DENY','');
+ return false;
+ }
+ app()->log('info',$action,$plugin->name,'DENY','non blocking');
+ $result = false;
+ }
+ $this->pluginOutput .= $plugin->pluginHTML;
+ }
+ }
+ return $result;
+ }
+
+ function convertSubnet($val) {
+ $sub = array();
+ if ($val<0) $val = 0;
+ if ($val>32) $val = 32;
+ for ($i=0; $i<4; $i++) {
+ $x = 0; /* could be done with a for... */
+ if ($val>0) $x += 128;
+ if ($val>1) $x += 64;
+ if ($val>2) $x += 32;
+ if ($val>3) $x += 16;
+ if ($val>4) $x += 8;
+ if ($val>5) $x += 4;
+ if ($val>6) $x += 2;
+ if ($val>7) $x += 1;
+ $sub[$i] = $x;
+ $val = $val - 8;
+ }
+ return $sub;
+ }
+
+ function matchIP($sip,$exp) {
+ if (strpos($exp,'/')!==FALSE) {
+ $x = explode('/',$exp);
+ $net = $x[0];
+ $sub = $x[1];
+ if (strpos($sub,'.')===FALSE) {
+ /* it's a single number convert to subnet mask*/
+ $sub = $this->convertSubnet($sub);
+ } else {
+ $sub = explode('.',$sub);
+ }
+ } else { /* single ip */
+ $net = $exp;
+ $sub = array(255,255,255,255);
+ }
+ $ip = explode('.',$sip);
+ $net = explode('.',$net);
+
+ /* now do the match */
+ $mip[0] = $ip[0] & $sub[0];
+ $mip[1] = $ip[1] & $sub[1];
+ $mip[2] = $ip[2] & $sub[2];
+ $mip[3] = $ip[3] & $sub[3];
+ $dip[0] = $net[0] & $sub[0];
+ $dip[1] = $net[1] & $sub[1];
+ $dip[2] = $net[2] & $sub[2];
+ $dip[3] = $net[3] & $sub[3];
+ if (($mip[0] == $dip[0]) and ($mip[1] == $dip[1]) and
+ ($mip[2] == $dip[2]) and ($mip[3] == $dip[3]))
+ return true;
+ else
+ return false;
+ }
+
+ /* initialize the run */
+ function setupRun($action,$step) {
+ global $_SERVER;
+
+ $this->mainPage = 'index';
+
+ /* setup the template variable */
+ if (!isset($this->config['defaultaction'])) $this->config['defaultaction']='u';
+
+ $this->action= $action=='' ? $this->config['defaultaction']:$action;
+ $this->step= $step==0 ?1:$step;
+
+ $this->tpl->assign('action',$this->action);
+ $this->tpl->assign('step',$this->step);
+ $this->tpl->assign('nextstep',$this->step+1);
+ $this->tpl->assign('site',$this->config['site']);
+ $this->tpl->assign('script',$_SERVER['PHP_SELF']);
+ $this->tpl->assign('page',$this->page);
+ }
+
+ /* this is the main application function which should be overridden */
+ function run($action = '',$step = 0) {
+ echo 'PLEASE REIMPLEMENT THE BaseApplication::run() FUNCTION!';
+ exit(-1);
+ }
+
+
+}
+
+?>
Modified: trunk/lib/main.inc.php
===================================================================
--- trunk/lib/main.inc.php 2009-11-07 22:44:44 UTC (rev 352)
+++ trunk/lib/main.inc.php 2009-11-07 22:45:26 UTC (rev 353)
@@ -1,6 +1,13 @@
<?php
-class Application {
+function sortTabs($a, $b) {
+ if ($a['priority'] == $b['priority'])
+ return 0;
+ else
+ return ($a['priority'] < $b['priority'])? -1 : 1;
+}
+
+class Application extends baseApplication {
var $db; /* database */
var $auth; /* authentication */
var $tr; /* trasnlation */
@@ -16,84 +23,16 @@
function Application($CONFIG) {
global $application;
+ $this->name = 'Open Upload';
$application = $this;
- $this->config = $CONFIG;
-
- /* initialize template engine */
- $this->tpl = new Smarty();
- $this->tpl->template_dir = $this->config['INSTALL_ROOT'].'/templates';
- if (isset($this->config['SMARTY_DATA'])) {
- $this->tpl->compile_dir = $this->config['SMARTY_DATA'].'/templates_c/';
- $this->tpl->cache_dir = $this->config['SMARTY_DATA'].'/cache';
- } else {
- $this->tpl->compile_dir = $this->config['INSTALL_ROOT'].'/templates_c/';
- $this->tpl->cache_dir = $this->config['INSTALL_ROOT'].'/cache';
- }
- $this->tpl->config_dir = SMARTY_DIR.'/configs';
- $this->tpl->caching = $this->config['site']['caching'];
+ baseApplication::baseApplication($CONFIG);
- $this->page['template']= $this->config['WWW_ROOT'].'/templates/'.$this->config['site']['template'];
-
- /* include the class first */
- $dbtype = $this->config['database']['type'];
- require_once($this->config['INSTALL_ROOT'].'/lib/modules/db/'.$dbtype.'.inc.php');
- $dbmname = $dbtype.'DB';
- $this->db = new $dbmname($this->config['database']);
- $this->db->init(); /* open db connection */
-
- /* authentication module */
- if (isset($this->config['auth'])) {
- $authmname = $this->config['auth'];
- } else {
- $authmname = 'default';
- }
- require_once($this->config['INSTALL_ROOT'].'/lib/modules/auth/'.$authmname.'.inc.php');
- $auth = $authmname.'Auth';
- $this->auth = new $auth();
-
- $this->user = new OpenUploadUser();
- $this->user->auth = &$this->auth;
-
- /* translation module */
- if (isset($this->config['translator'])) {
- $trname = $this->config['translator'];
- } else {
- $trname = 'null';
- }
- require_once($this->config['INSTALL_ROOT'].'/lib/modules/tr/'.$trname.'.inc.php');
- $tr = $trname.'Translator';
- $this->tr = new $tr();
-
- $this->langs = $this->db->read('langs',array('active' => '1'),array('id'),'',array('id'));
-
- /* check if it was forced */
- if (isset($_GET['lang'])) {
- $user = $this->user->info();
- $user['lang']=$_GET['lang'];
- $this->user->setInfo('lang',$_GET['lang']);
- }
-
- /* configure the language */
- if ($this->user->info('lang')=='') {
- $lang = $this->getBrowserLang();
- $user = $this->user->info();
- $this->user->setInfo('lang',$lang);
- }
- $this->tr->init();
- $this->auth->init();
- $this->user->init();
- if ($this->user->info('max_upload_size')==0)
- $this->user->setInfo('max_upload_size',$this->config['max_upload_size']*1024*1024);
- ini_set('max_upload_size',$this->user->info('max_upload_size'));
- ini_set('post_max_size',$this->user->info('max_upload_size'));
-// TODO: should check if this value has been really set or if it was blocked by the PHP
-
$this->config['modules'][]='files';
$this->config['modules'][]='admin';
$this->config['modules'][]='auth';
- $this->loadACL();
$this->initModules();
+ $this->loadACL();
$this->loglevels['error'] = array('id' => 1, 'syslog' => LOG_ERR );
$this->loglevels['security'] = array('id' => 2, 'syslog' => LOG_WARNING );
@@ -101,49 +40,9 @@
$this->loglevels['notice'] = array('id' => 4, 'syslog' => LOG_NOTICE );
$this->loglevels['info'] = array('id' => 5, 'syslog' => LOG_INFO );
$this->loglevels['debug'] = array('id' => 9, 'syslog' => LOG_DEBUG );
- }
- function getBrowserLang() {
- global $_SERVER;
-
- /* calculate preferred language */
- $langs = str_replace(' ','',strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
- $langs = explode(',',$langs);
- foreach ($langs as $ls) {
- $language = explode(';',$ls);
- foreach ($language as $l) {
- foreach ($this->langs as $ml) {
- if (strpos(strtolower($ml['browser']),'['.$l.']')!==FALSE) {
- return $ml['id'];
- }
- if (strpos($l,'-')) {
- $x = explode('-',$l);
- if (strpos(strtolower($ml['browser']),'['.$x[0].']')!==FALSE) {
- return $ml['id'];
- }
- }
- }
- }
- }
- return $this->config['defaultlang'];
}
- function fetch($tname) {
- if (file_exists($this->tpl->template_dir.'/'.$this->config['site']['template'].'/'.$tname.'.tpl')) {
- return $this->tpl->fetch($this->config['site']['template'].'/'.$tname.'.tpl');
- } else {
- return $this->tpl->fetch('default/'.$tname.'.tpl');
- }
- }
-
- function display($tname) {
- if (file_exists($this->tpl->template_dir.'/'.$this->config['site']['template'].'/'.$tname.'.tpl')) {
- $this->tpl->display($this->config['site']['template'].'/'.$tname.'.tpl');
- } else {
- $this->tpl->display('default/'.$tname.'.tpl');
- }
- }
-
function message($msg) {
global $_SESSION;
$_SESSION['user']['messages'][] = $msg;
@@ -192,90 +91,8 @@
}
}
- function initModules() {
- /* initialize configured modules */
- foreach ($this->config['modules'] as $module) {
- /* create and initialize the module */
- require_once($this->config['INSTALL_ROOT'].'/lib/modules/default/'.$module.'.inc.php');
- $m = $module.'Module';
- $m = new $m();
- $m->name = $module;
- $m->tpl = &$this->tpl;
- foreach ($m->actions as $k => $l) {
- $this->actions[$k] = $m->name;
- $this->modules[$module] = $m;
- }
- }
- foreach ($this->modules as $m) {
- $m->init();
- }
- }
- function initMenu($auth = false) {
-
- $this->menu = array();
- foreach ($this->modules as $m) {
- foreach ($m->actions as $k => $a) {
- if (isset($m->menu[$k])) {
- $group = app()->user->group();
- if ($this->checkACL($group,$m->name,$k) == 'allow') {
- $this->menu[$k]=$m->menu[$k];
- }
- }
- }
- }
- $this->tpl->assign('menu',$this->menu);
- }
- function initPlugins() {
- /* initialize plugin system */
-
- $this->plugins = array();
- /* load the plugins */
- foreach ($this->config['plugins'] as $plugin) {
- /* include the file */
- if (file_exists($this->config['INSTALL_ROOT'].'/plugins/'.$plugin.'.inc.php')) {
- require_once($this->config['INSTALL_ROOT'].'/plugins/'.$plugin.'.inc.php');
- $pname = $plugin."Plugin";
- $newp = new $pname();
- $newp->name = $plugin;
- $this->plugins[$plugin] = $newp;
- } else {
- $this->error(tr('plugin include file not found: %1',$plugin));
- }
- }
- foreach ($this->plugins as $plugin) {
- $plugin->init();
- }
- }
-
- function pluginAction($action,&$finfo,$stop = true) {
- $this->pluginHTML = '';
- $result = true;
-
- if (!is_array($this->plugins))
- return true;
- foreach ($this->plugins as $plugin) {
- if (method_exists($plugin,$action)) {
- /* check plugin acl */
- $acl = 'disable'; /* disabled by default */
- if (isset($this->pluginAcl[$plugin->name])) {
- $acl = $this->pluginAcl[$plugin->name]['access'];
- }
- if (!$plugin->$action($finfo,$acl)) {
- if ($stop) {
- app()->log('security',$action,$plugin->name,'DENY','');
- return false;
- }
- app()->log('info',$action,$plugin->name,'DENY','non blocking');
- $result = false;
- }
- $this->pluginHTML .= $plugin->pluginHTML;
- }
- }
- return $result;
- }
-
function loadACL() {
/* loads the acl from the db */
$group = $this->user->group();
@@ -292,102 +109,15 @@
}
}
-
- function checkSingleACL($group,$module,$action) {
-
- $result = 'deny'; /* not defined are denyed by default */
- if (isset($this->acl[$group][$module][$action])) {
- $result = $this->acl[$group][$module][$action]['access'];
- } else if (isset($this->acl[$group][$module]['*'])) {
- $result = $this->acl[$group][$module]['*']['access'];
- } else if (isset($this->acl[$group]['*']['*'])) {
- $result = $this->acl[$group]['*']['*']['access'];
- } else if (isset($this->acl['*'][$module][$action])) {
- $result = $this->acl['*'][$module][$action];
- } else if (isset($this->acl['*'][$module]['*'])) {
- $result = $this->acl['*'][$module]['*']['access'];
- } else if (isset($this->acl['*']['*']['*'])) {
- $result = $this->acl['*']['*']['*']['access']; /* this should be avoided imho */
+ function tab($content,$name = 'default', $priority = 0 ) {
+ $this->tabs[$name]['html'][] = $content;
+ if ($priority<999)
+ $this->tabs[$name]['priority']=$priority;
+ else if (!isset($this->tabs[$name]['priority'])) {
+ $this->tabs[$name]['priority']=999;
}
- return $result;
}
- function checkACL($group,$module,$action) {
- if (is_array($group)) {
- foreach ($group as $g) {
- $result = $this->checkSingleACL($g,$module,$action);
- if ($result == 'allow') {
- return $result;
- }
- }
- } else {
- $result = $this->checkSingleACL($group,$module,$action);
- }
-
- if (isset($this->config['debug_acl']) and $this->config['debug_acl'] and $result == 'deny') {
- echo '<pre>ACL: '.$result.' - group: '.$group.', module: '.$module.', action: '.$action."\n";
- print_r($this->acl);
- echo '</pre>';
- $result = 'allow';
- }
-
- return $result;
- }
-
- function convertSubnet($val) {
- $sub = array();
- if ($val<0) $val = 0;
- if ($val>32) $val = 32;
- for ($i=0; $i<4; $i++) {
- $x = 0; /* could be done with a for... */
- if ($val>0) $x += 128;
- if ($val>1) $x += 64;
- if ($val>2) $x += 32;
- if ($val>3) $x += 16;
- if ($val>4) $x += 8;
- if ($val>5) $x += 4;
- if ($val>6) $x += 2;
- if ($val>7) $x += 1;
- $sub[$i] = $x;
- $val = $val - 8;
- }
- return $sub;
- }
-
- function matchIP($sip,$exp) {
- if (strpos($exp,'/')!==FALSE) {
- $x = explode('/',$exp);
- $net = $x[0];
- $sub = $x[1];
- if (strpos($sub,'.')===FALSE) {
- /* it's a single number convert to subnet mask*/
- $sub = $this->convertSubnet($sub);
- } else {
- $sub = explode('.',$sub);
- }
- } else { /* single ip */
- $net = $exp;
- $sub = array(255,255,255,255);
- }
- $ip = explode('.',$sip);
- $net = explode('.',$net);
-
- /* now do the match */
- $mip[0] = $ip[0] & $sub[0];
- $mip[1] = $ip[1] & $sub[1];
- $mip[2] = $ip[2] & $sub[2];
- $mip[3] = $ip[3] & $sub[3];
- $dip[0] = $net[0] & $sub[0];
- $dip[1] = $net[1] & $sub[1];
- $dip[2] = $net[2] & $sub[2];
- $dip[3] = $net[3] & $sub[3];
- if (($mip[0] == $dip[0]) and ($mip[1] == $dip[1]) and
- ($mip[2] == $dip[2]) and ($mip[3] == $dip[3]))
- return true;
- else
- return false;
- }
-
function banned() {
global $_SERVER;
@@ -407,28 +137,9 @@
global $_SESSION;
global $_GET;
- $this->mainPage = 'index';
+ $this->tabs = array();
+ $this->setupRun($action,$step);
- /* setup the template variable */
- if (!isset($this->config['defaultaction'])) $this->config['defaultaction']='u';
-
- $this->action= $action=='' ? $this->config['defaultaction']:$action;
- $this->step= $step==0 ?1:$step;
-
- $this->tpl->assign('action',$this->action);
- $this->tpl->assign('step',$this->step);
- $this->tpl->assign('nextstep',$this->step+1);
- $this->tpl->assign('site',$this->config['site']);
- $this->tpl->assign('script',$_SERVER['PHP_SELF']);
- $this->tpl->assign('page',$this->page);
-
- if (isset($this->config['multiupload'])) {
- if ($this->config['multiupload']<=0)
- $this->config['multiupload']=1;
- $this->tpl->assign('multiupload',$this->config['multiupload']);
- } else {
- $this->config['multiupload']=1;
- }
/* check for banned IP */
if ($this->banned() != 'allow') {
$this->log('security','banned','','DENY','');
@@ -439,6 +150,7 @@
$this->db->free();
exit;
}
+
/* depending on the acl some actions need authentication others don't */
if (!isset($this->actions[$this->action])) {
/* no module can handle this action */
@@ -477,7 +189,7 @@
}
$this->initPlugins();
- $this->initMenu($this->user->loggedin());
+ $this->initMenu($this->user->group(),$m->name);
/* now run the module */
if (isset($m->actions[$this->action][$this->step])) {
@@ -491,17 +203,28 @@
}
}
$this->tpl->assign('user',$_SESSION['user']);
+ $this->tpl->assign('config',$this->config);
$m->$fun();
+ if (count($this->tabs)>0) {
+ /* sort based on the priority flag */
+ uasort($this->tabs,'sortTabs');
+ $this->tpl->assign('tabs',$this->tabs);
+ $this->pluginOutput .= $this->fetch('tabs');
+ }
+ $this->tpl->assign('plugins',$this->pluginOutput);
+ $this->page['content']=$this->fetch('modules/'.$m->name.'/'.$fun);
- if ($_GET['type']=='ajax') return;
+ if ($_GET['type']=='ajax') {
+ echo $this->page['content'];
+ session_weite_close;
+ exit;
+ }
/* now display the final page */
- $this->tpl->assign('user',$this->user->info());
+ $this->tpl->assign('user',$_SESSION['user']);
$this->tpl->assign('langs',$this->langs);
unset($_SESSION['user']['messages']);
unset($_SESSION['user']['errors']);
- $this->tpl->assign('plugins',$this->pluginHTML);
- $this->page['content']=$this->fetch('modules/'.$m->name.'/'.$fun);
$this->tpl->assign('page',$this->page);
$this->display($this->mainPage);
$this->log('info',$fun,'','ALLOW','');
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ts...@us...> - 2010-03-18 18:15:29
|
Revision: 367
http://openupload.svn.sourceforge.net/openupload/?rev=367&view=rev
Author: tsdogs
Date: 2010-03-18 18:15:22 +0000 (Thu, 18 Mar 2010)
Log Message:
-----------
version 0.5 modifications
Modified Paths:
--------------
trunk/lib/base.inc.php
trunk/lib/classes.inc.php
trunk/lib/general.inc.php
trunk/lib/main.inc.php
Modified: trunk/lib/base.inc.php
===================================================================
--- trunk/lib/base.inc.php 2010-03-18 18:13:47 UTC (rev 366)
+++ trunk/lib/base.inc.php 2010-03-18 18:15:22 UTC (rev 367)
@@ -15,10 +15,12 @@
function baseApplication($CONFIG) {
global $application;
global $_GET;
+ global $_SESSION;
$application = $this;
$this->config = $CONFIG;
+
/* initialize template engine */
$this->tpl = new Smarty();
if (isset($this->config['TEMPLATES_PATH']))
@@ -88,6 +90,8 @@
$this->auth->init();
$this->user->init();
+ /* uploaded files go into my tmp folder */
+ ini_set('upload_tmp_dir',app()->config['DATA_PATH'].'/tmp/');
}
/* gets the best language match based on browser info */
@@ -116,14 +120,6 @@
return $this->config['defaultlang'];
}
- /* returns the output from the template engine */
- function fetch($tname) {
- if (file_exists($this->tpl->template_dir.'/'.$this->config['site']['template'].'/'.$tname.'.tpl')) {
- return $this->tpl->fetch($this->config['site']['template'].'/'.$tname.'.tpl');
- } else {
- return $this->tpl->fetch('default/'.$tname.'.tpl');
- }
- }
function exists($tname) {
if (file_exists($this->tpl->template_dir.'/'.$this->config['site']['template'].'/'.$tname.'.tpl')) {
@@ -133,6 +129,7 @@
}
return false;
}
+
/* displays the output from the template engine */
function display($tname) {
if (file_exists($this->tpl->template_dir.'/'.$this->config['site']['template'].'/'.$tname.'.tpl')) {
@@ -142,6 +139,15 @@
}
}
+ /* returns the output from the template engine */
+ function fetch($tname) {
+ if (file_exists($this->tpl->template_dir.'/'.$this->config['site']['template'].'/'.$tname.'.tpl')) {
+ return $this->tpl->fetch($this->config['site']['template'].'/'.$tname.'.tpl');
+ } else {
+ return $this->tpl->fetch('default/'.$tname.'.tpl');
+ }
+ }
+
function initModules() {
/* initialize configured modules */
foreach ($this->config['modules'] as $module) {
@@ -165,11 +171,11 @@
$this->menu['main'] = array();
foreach ($this->modules as $m) {
- if (isset($m->mainmenu)) {
+ if (isset($m->menu)) {
foreach ($m->actions as $k => $v) {
if ($this->checkACL($group,$m->name,$k) == 'allow') {
- if (isset($m->mainmenu[$k])) {
- $this->menu['main'][$k]=$m->mainmenu[$k];
+ if (isset($m->menu[$k])) {
+ $this->menu['main'][$k]=$m->menu[$k];
}
}
}
@@ -231,7 +237,7 @@
function initPlugins() {
/* initialize plugin system */
- $this->pluginOutput = '';
+ $this->pluginOutput = array();
$this->plugins = array();
/* load the plugins */
@@ -252,8 +258,13 @@
}
}
- function pluginAction($action,&$finfo,$stop = true) {
- //$this->pluginHTML = '';
+ function pluginSetGroup($group) {
+ foreach ($this->plugins as $plugin) {
+ $plugin->group = $group;
+ }
+ }
+
+ function pluginAction($action,&$info,$stop = true) {
$result = true;
if (!is_array($this->plugins))
@@ -261,12 +272,14 @@
foreach ($this->plugins as $plugin) {
if (method_exists($plugin,$action)) {
/* check plugin acl */
+ if ($plugin->group=='') $plugin->group = app()->user->group();
+
$acl = 'disable'; /* disabled by default */
- if (isset($this->pluginAcl[$plugin->name])) {
- $acl = $this->pluginAcl[$plugin->name]['access'];
+ if (isset($this->pluginAcl[$plugin->name]) and isset($this->pluginAcl[$plugin->name][$plugin->group])) {
+ $acl = $this->pluginAcl[$plugin->name][$plugin->group]['access'];
}
- $plugin->pluginHTML = '';
- if (!$plugin->$action($finfo,$acl)) {
+ $plugin->pluginHTML = array();
+ if (!$plugin->$action($info,$acl)) {
if ($stop) {
app()->log('security',$action,$plugin->name,'DENY','');
return false;
@@ -274,7 +287,7 @@
app()->log('info',$action,$plugin->name,'DENY','non blocking');
$result = false;
}
- $this->pluginOutput .= $plugin->pluginHTML;
+ $this->pluginOutput = array_merge($this->pluginOutput, $plugin->pluginHTML);
}
}
return $result;
@@ -363,4 +376,247 @@
}
+
+class BaseUploadModule extends OpenUploadModule {
+
+ function BaseUploadModule() {
+ }
+
+ function setupUpload() {
+
+ /* reset any previous upload setting */
+ $upload = array();
+
+ if (isset(app()->config['multiupload'])) {
+ if (app()->config['multiupload']<=0) {
+ $upload['multiupload']=1;
+ } else {
+ $upload['multiupload']=app()->config['multiupload'];
+ }
+ } else {
+ $upload['multiupload']=1;
+ app()->config['multiupload']=1;
+ }
+
+ /* reset to default */
+ $upload['max_upload_size']=app()->config['max_upload_size']*1024*1024;
+ $result = app()->pluginAction('setupUpload',$upload);
+
+ /* now check if it's allowed by php */
+ if (app()->config['progress']!='cgi') {
+ $upl_size = return_bytes(ini_get('upload_max_filesize'));
+ $post_size = return_bytes(ini_get('post_max_size'));
+ if ($upload['max_upload_size']>$upl_size) {
+ app()->warning(tr('WARNING: upload_max_filesize is lower than the allowed size for the user! [%1M < %2M]',
+ ($upl_size/1024/1024),($upload['max_upload_size']/1024/1024)));
+ $upload['max_upload_size']=$upl_size;
+ }
+ if ($upload['max_upload_size']>$post_size) {
+ app()->warning(tr('WARNING: post_max_size is lower than the allowed size for the user! [%1M < %2M]',
+ ($post_size/1024/1024),($upload['max_upload_size']/1024/1024)));
+ if ($post_size<$upl_size) {
+ $upload['max_upload_size']=$post_size;
+ }
+ }
+ }
+ app()->message(tr('Maximum allowed upload size is %1',number_format($upload['max_upload_size'] / 1048576,0).' MB'));
+ app()->message(tr('Maximum allowed number of files per upload is %1',$upload['multiupload']));
+ $upload['identifier']=randomName(40,40);
+ app()->tpl->assign('uploadscript',$_SERVER['PHP_SELF']);
+ switch (app()->config['progress']) {
+ case 'uploadprogress':
+ $upload['identifiername']='UPLOAD_IDENTIFIER';
+ break;
+ case 'apc':
+ $upload['identifiername']=ini_get('apc.rfc1867_name');
+ break;
+ case 'cgi':
+ $upload['identifier']=randomName(32,32);
+ $this->tpl->assign('uploadscript',app()->config['progress_cgi'].'?upload_id='.session_id());
+ /* update information on the file */
+ $_CGI['temp_dir'] = app()->config['DATA_PATH'].'/tmp/';
+ $_CGI['upload_id'] = $upload['identifier'];
+ $_CGI['upload_dir'] = app()->config['DATA_PATH'].'/tmp/';
+ $_CGI['path_to_link_file'] = '/tmp/'.session_id().'.link';
+ $_CGI['embedded_upload_results'] = 1;
+ $_CGI['redirect_method'] = 1;
+ $_CGI['redirect_url'] = app()->config['WWW_SERVER'].app()->config['WWW_ROOT'].'/index.php?a='.app()->action.'&s='.app()->step;
+ $_CGI['cgi_upload_hook'] = 0;
+ $_CGI['debug_upload'] = 0;
+ $_CGI['delete_link_file'] = 0;
+ $_CGI['purge_temp_dirs'] = 1;
+ $_CGI['report_errors'] = 0;
+ $_CGI['purge_temp_dirs_limit'] = 1;
+ $_CGI['max_upload_size'] = $upload['max_upload_size'];
+ $c = '';
+ foreach ($_CGI as $k => $value) {
+ $c .= $k.'<=>'.$value."\n";
+ }
+ file_put_contents('/tmp/'.session_id().'.link',$c);
+ $upload['identifiername']='UPLOAD_IDENTIFIER';
+ break;
+ default:
+ $upload['identifiername']='UPLOAD_IDENTIFIER';
+ break;
+ }
+ return $upload;
+ }
+
+
+ function uploadProgress() {
+ global $_SESSION;
+
+ if (isset($_SESSION[app()->action]['identifier'])) {
+ $upload = $_SESSION[app()->action];
+ //ob_clean();
+ header("Cache-Control: no-cache, must-revalidate");
+ header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
+ // need this 'cause of IE problems
+ header('Content-Type: text/html; Charset=utf-8');
+
+ $progress = array('complete' => 0, 'total' => 0, 'percentage' => 0, 'files' => 0);
+ switch (app()->config['progress']) {
+ case 'uploadprogress':
+ $res = uploadprogress_get_info($upload['identifier']);
+ if (isset($res['bytes_uploaded'])) {
+ $progress['complete'] = $res['bytes_uploaded'];
+ if ($res['bytes_total']>0) {
+ $progress['total'] = $res['bytes_total'];
+ $progress['percentage'] = floor(($res['bytes_uploaded'] / $res['bytes_total'])*100);
+ }
+ $progress['files'] = $res['files_uploaded'];
+ }
+ break;
+ case 'apc':
+ $res = apc_fetch(ini_get('apc.rfc1867_prefix').$$upload['identifier']);
+ if ($res) {
+ $progress['complete'] = $res['current'];
+ $progress['total'] = $res['total'];
+ if ($res['total']>0)
+ $progress['percentage'] = floor(($res['current'] / $res['total'])*100);
+ $progress['files'] = 0;
+ }
+ break;
+ case 'cgixxx':
+ $res = cgiupload_get_info($$upload['identifier']);
+ if (isset($res['bytes_uploaded'])) {
+ $progress['complete'] = $res['bytes_uploaded'];
+ if ($res['bytes_total']>0) {
+ $progress['total'] = $res['bytes_total'];
+ $progress['percentage'] = floor(($res['bytes_uploaded'] / $res['bytes_total'])*100);
+ }
+ $progress['files'] = $res['files_uploaded'];
+ }
+ break;
+ }
+ app()->tpl->assign('progress',$progress);
+ return;
+ }
+ }
+
+ function setupCGIFiles() {
+ global $_FILES;
+
+ switch (app()->config['progress']) {
+ case 'cgi':
+ /* populate the variables so that it will be available to the following code */
+ if (file_exists('/tmp/'.session_id().'.redirect')) {
+ $hook = file_get_contents('/tmp/'.session_id().'.redirect');
+ $p = new CGIParser();
+ $parsed = $p->parseCGI($hook);
+ $_POST = $parsed['post'];
+ $_FILES = $parsed['files'];
+ if (count($parsed['errors'])>0) {
+ foreach ($parsed['errors'] as $v) {
+ app()->error(tr($v));
+ }
+ }
+ @unlink('/tmp/'.session_id().'.redirect');
+ @unlink('/tmp/'.session_id().'.link');
+ break;
+ }
+ }
+ }
+
+ function validateUploadedFiles(&$upload) {
+ global $_SESSION;
+ global $_SERVER;
+ global $_FILES;
+
+ if (count($_FILES)>0) {
+ if (count($_FILES)>app()->config['multiupload']) {
+ app()->log('warning','uploadForm','','DENY','Too many files!');
+ app()->error(tr('Too many files uploaded! %1',count($_FILES)));
+ return false;
+ }
+ /* check if any upload error occurred */
+ $error = false;
+ $totalsize = 0;
+ foreach ($_FILES as $k => $f) {
+ if ($f['name']!='' and $f['error']>0) {
+ switch ($f['error']) { /* taken from here: http://it.php.net/manual/en/features.file-upload.errors.php */
+ case 1: $msg = tr('Maximum upload size for site wide configuration reached! [%1]', $f['name']); break;
+ case 2: $msg = tr('Maximum file size exceeded! [%1]', $f['name']); break;
+ case 3: $msg = tr('Partial file transfer error! [%1]', $f['name']); break;
+ case 4: $msg = tr('No file was uploaded! [%1]', $f['name']); break;
+ case 6: $msg = tr('Missing temporary directory! [%1]', $f['name']); break;
+ case 7: $msg = tr('Can\'t write to temporary diretory! [%1]', $f['name']); break;
+ case 8: $msg = tr('Upload blocked by extension! [%1]', $f['name']); break;
+ default:
+ $msg = tr('Upload failed for Unknown error code: [%1] ! [%2]',$f['error'], $f['name']); break;
+ }
+ app()->log('warning','uploadForm','','DENY','Upload error: '.$msg);
+ app()->error($msg);
+ $error = true;
+ }
+ $totalsize += $f['size'];
+ }
+ if ($totalsize > $upload['max_upload_size']) {
+ app()->log('warning','uploadFiles','','DENY','Maximum file size exceeded!');
+ app()->error(tr('Maximum file size exceeded!'));
+ $error = true;
+ }
+ if ($error) { return false; }
+ /* no error so far */
+ $tmpname = app()->config['DATA_PATH'].'/tmp/'.randomName();
+ $x = 0;
+ foreach ($_FILES as $k => $f) {
+ /* prepare the file */
+ $tmpnamex = $tmpname;
+ if ($x>0) { $tmpnamex = $tmpname.'_'.$x; }
+ if ($f['tmp_name']!='') {
+ if (app()->config['progress']=='cgi') {
+ $tmpnamex = $f['tmp_name'];
+ } else {
+ // TODO: check if move fails for some reason
+ move_uploaded_file($f['tmp_name'],$tmpnamex);
+ }
+ $files[$x]['tmp']=$tmpnamex;
+ /* get the file mime type, and do not rely on what the browser sends */
+ $mime = get_mime_type($tmpnamex,$f['type']);
+ $files[$x]['mime']=$mime;
+ $files[$x]['name']=$f['name'];
+ $files[$x]['size']=$f['size'];
+ $x++;
+ }
+ }
+ $upload['size']=$totalsize;
+ $upload['files']=$files;
+ return true;
+ }
+ return false;
+ }
+
+ function setupLinks(&$upload,$a1 = 'd', $a2 = 'r') {
+ /* get the file info */
+ $a = 'action'; $i = 'id'; $r = 'removeid';
+ if (app()->config['use_short_links']=='yes') {
+ $a = 'a'; $i = 'i'; $r = 'r';
+ }
+ $upload['downloadlink']= app()->config['WWW_SERVER'].app()->config['WWW_ROOT'].'/?'.$a.'='.$a1.'&'.$i.'='.$upload['id'];
+ $upload['removelink']=app()->config['WWW_SERVER'].app()->config['WWW_ROOT'].
+ '/?'.$a.'='.$a2.'&'.$i.'='.$upload['id'].'&'.$r.'='.$upload['remove'];
+ }
+
+}
?>
Modified: trunk/lib/classes.inc.php
===================================================================
--- trunk/lib/classes.inc.php 2010-03-18 18:13:47 UTC (rev 366)
+++ trunk/lib/classes.inc.php 2010-03-18 18:15:22 UTC (rev 367)
@@ -112,22 +112,18 @@
redirect('?action='.$action.'&step='.$step);
}
- function fileaction() {
- }
-
function init() {
}
}
class OpenUploadPlugin {
- var $pluginHTML = '';
- var $messageHTML;
+ var $pluginHTML = array();
var $name;
var $fields = array();
var $options = array();
var $config = array();
- var $category = 'general';
+ var $group = '';
function OpenUploadPlugin() {
}
@@ -137,9 +133,10 @@
}
function display($tpl) {
- $this->pluginHTML .= app()->fetch('plugins/'.$this->name.'/'.$tpl);
+ $this->pluginHTML[] = 'plugins/'.$this->name.'/'.$tpl;
}
+ /* not really used */
function fetch($tpl) {
return app()->fetch('plugins/'.$this->name.'/'.$tpl);
}
@@ -173,7 +170,11 @@
}
function getGroup($option) {
- $group = app()->user->group();
+ if ($this->group=='') {
+ $group = app()->user->group();
+ } else {
+ $group = $this->group;
+ }
if (is_array($group)) {
/* check for which group there is a configuration */
foreach ($group as $g) {
@@ -206,4 +207,117 @@
}
+
+class CGIParser {
+ var $files;
+ var $post;
+ var $errors;
+ var $element;
+ var $elementname;
+
+ var $state;
+
+ function cgiupload_get_info($fid) {
+ return array();
+ }
+
+ function startElement($parser, $name, $attribs){
+ if ($name == 'post') {
+ $this->state = 0;
+ } else if ($name == 'errors') {
+ $this->state = 1;
+ } else if ($name == 'files') {
+ $this->state = 2;
+ } else if (($this->state==2) and ($name == 'file')) {
+ $this->element=array(); // initialize file
+ $this->elementname='';
+ $this->state=3;
+ }
+ if ($this->tag != '')
+ $this->tags[]=$this->tag;
+ $this->tag = $name;
+ }
+
+ function characterData($parser, $data){
+ switch ($this->state) {
+ case 0:
+ if ($this->tag != 'post')
+ $this->post[$this->tag]=$data;
+ break;
+ case 1:
+ if ($this->tag == 'error') {
+ $this->errors[]=$data;
+ }
+ break;
+ case 2:
+ // ignore files data
+ break;
+ case 3:
+ // inside a file
+ if ($this->tag == 'slot') {
+ $this->elementname = $data;
+ }
+ // ignore file content
+ if ($this->tag != 'file')
+ $this->element[$this->tag]=$data;
+ break;
+ }
+ }
+
+ function endElement($parser, $name){
+ switch ($this->state) {
+ case 0:
+ if ($name == 'post') {
+ $this->state = -1;
+ } else if (!isset($this->post[$this->tag])) {
+ $this->post[$this->tag] = '';
+ }
+ $this->tag = '';
+ break;
+ case 1:
+ if ($name == 'errors') {
+ $this->state = -1;
+ }
+ $this->tag = '';
+ break;
+ case 2:
+ if ($name == 'files') {
+ $this->state = -1;
+ }
+ $this->tag = '';
+ break;
+ case 3:
+ // save the file
+ if ($name == 'file') {
+ if ($this->elementname!='') {
+ $this->files[$this->elementname] = $this->element;
+ } else {
+ /* error parsing files ? */
+ }
+ $this->state = 2;
+ }
+ break;
+ }
+ $this->tag =array_pop($this->tags);
+ }
+
+ function parseCGI($xml) {
+ $this->state = -1;
+ $this->element=array();
+ $this->elementname='';
+ $this->post = array();
+ $this->errors = array();
+ $this->files = array();
+
+ $xml_parser = xml_parser_create();
+ xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false);
+ xml_set_element_handler($xml_parser, array($this,"startElement"), array($this,"endElement"));
+ xml_set_character_data_handler($xml_parser, array($this,"characterData"));
+ xml_parse($xml_parser,$xml);
+ $result = array('post' => $this->post, 'files' => $this->files, 'errors' => $this->errors);
+ return $result;
+ }
+
+}
+
?>
\ No newline at end of file
Modified: trunk/lib/general.inc.php
===================================================================
--- trunk/lib/general.inc.php 2010-03-18 18:13:47 UTC (rev 366)
+++ trunk/lib/general.inc.php 2010-03-18 18:15:22 UTC (rev 367)
@@ -11,8 +11,8 @@
else
define('SMARTY_DIR', $CONFIG['INSTALL_ROOT'].'/lib/smarty/');
require(SMARTY_DIR . 'Smarty.class.php');
+require_once($CONFIG['INSTALL_ROOT'].'/lib/classes.inc.php');
require_once($CONFIG['INSTALL_ROOT'].'/lib/base.inc.php');
-require_once($CONFIG['INSTALL_ROOT'].'/lib/classes.inc.php');
require_once($CONFIG['INSTALL_ROOT'].'/lib/user.inc.php');
require_once($CONFIG['INSTALL_ROOT'].'/lib/main.inc.php');
@@ -165,7 +165,7 @@
// otherwise there was no mail handler for the domain
return false;
}
- return false;
+ return false;
}
}
// End Bug Fix
@@ -232,42 +232,61 @@
return $isValid;
}
-/* this function generates a mail from a template */
-function sendmail($from,$reply,$to,$subject,$template, $attach = array()) {
- $tpl = &app()->tpl;
- $tpl->assign('subject',$subject);
- $tpl->assign('from',$from);
- $tpl->assign('to',$to);
- /* generate a boundary */
- $bound1 = "==Multipart_Bounday_x".md5(time())."x";
- /* generate a second boundary for the alternative */
- $header = "From: ".$from."\nReply-To: ".$reply."\n";
- $header .= "Mime-Version: 1.0\n";
- if (count($attach)>0) {
- $bound2 = "==Multipart_Bounday_z".md5(time())."z";
- $header .= "Content-Type: multipart/mixed;\n boundary=\"".$bound1."\"";
- } else {
- $bound2 = $bound1;
- $header .= "Content-Type: multipart/alternative;\n boundary=\"".$bound1."\"";
+function sendMail($from,$to,$subject,$template,$attach = array() ) {
+ global $CONFIG;
+
+ require_once($CONFIG['INSTALL_ROOT'].'/lib/swift/lib/swift_required.php');
+
+ // multiple recipients
+ $to = split(';',$to);
+
+ $message = Swift_Message::newInstance($subject);
+ $message->setFrom($from);
+ $message->setTo($to);
+ if (app()->exists($template.'Text')) {
+ $message->setBody(app()->fetch($template.'Text'),'text/plain');
+ if (app()->exists($template.'Html')) {
+ $message->addPart(app()->fetch($template.'Html'),'text/html');
+ }
+ } else if (app()->exists($template.'Html')) { /* send only html */
+ $message->setBody(app()->fetch($template.'Html'),'text/html');
+ } else { /* Let's force it to be text/plain */
+ $message->setBody(app()->fetch($template),'text/plain');
}
- $tpl->assign('boudary',$bound2);
- $msg = app()->fetch($template);
- /* now add the attachements */
- if (count($attach)>0) {
+ if (count(attach)>0) {
foreach ($attach as $a) {
- $msg .="--".$bound1."\n";
- $msg .="Content-Type: ".$a['mime'].";\n name=\"".$a['name']."\"\n";
- $msg .="Content-Disposition: attachment; filename=\"".$a['name']."\"\n";
- $msg .="Content-Transfer-Encoding: base64\n\n";
- $msg .=chunk_split(base64_encode(file_get_contents($a['file'])));
+ $message->attach(Swift_Attachment::fromPath($a));
}
- $msg .="\n--".$bound1."--\n";
- $msg .="\n--".$bound2."--\n";
- } else {
- $msg .="\n--".$bound1."--\n";
}
- return mail($to,$subject,$msg,$header,'-f "'.$from.'"');
+ switch ($CONFIG['mail']['transport']) {
+ case 'smtp': /* should be the preferred */
+ $transport = Swift_SmtpTransport::newInstance($CONFIG['mail']['server'],
+ isset($CONFIG['mail']['port'])?$CONFIG['mail']['port']:25);
+ if ($CONFIG['mail']['authrequired']) {
+ $transport->setUsername($CONFIG['mail']['authuser']);
+ $transport->setPassword($CONFIG['mail']['authpassword']);
+ }
+ if (isset($CONFIG['mail']['encrypt'])) {
+ // TODO: check for stream_get_transports()
+ $transport->setEncryption($CONFIG['mail']['encrypt']);
+ }
+ break;
+ case 'sendmail':
+ $transport = Swift_SendmailTransport::newInstance(
+ isset($CONFIG['mail']['sendmail'])?
+ $CONFIG['mail']['sendmail']:'/usr/sbin/sendmail -bs');
+ break;
+ case 'mail':
+ default:
+ $transport = Swift_MailTransport::newInstance();
+ break;
+ }
+
+ $mailer = Swift_Mailer::newInstance($transport);
+
+ $result = $mailer->send($message);
+ return $result;
}
/* from php manual page */
Modified: trunk/lib/main.inc.php
===================================================================
--- trunk/lib/main.inc.php 2010-03-18 18:13:47 UTC (rev 366)
+++ trunk/lib/main.inc.php 2010-03-18 18:15:22 UTC (rev 367)
@@ -1,12 +1,5 @@
<?php
-function sortTabs($a, $b) {
- if ($a['priority'] == $b['priority'])
- return 0;
- else
- return ($a['priority'] < $b['priority'])? -1 : 1;
-}
-
class Application extends baseApplication {
var $db; /* database */
var $auth; /* authentication */
@@ -27,7 +20,8 @@
$application = $this;
baseApplication::baseApplication($CONFIG);
- $this->config['modules'][]='files';
+ $this->config['modules'][]='upload';
+ $this->config['modules'][]='invitation';
$this->config['modules'][]='admin';
$this->config['modules'][]='auth';
@@ -45,16 +39,32 @@
function message($msg) {
global $_SESSION;
- $_SESSION['user']['messages'][] = $msg;
- $this->log('info','','','MESSAGE',$msg);
+
+ /* add the message if not already in the stack */
+ if (!is_array($_SESSION['user']['messages']) or
+ array_search($msg,$_SESSION['user']['messages'])===FALSE) {
+ $_SESSION['user']['messages'][] = $msg;
+ $this->log('info','','','MESSAGE',$msg);
+ }
}
function error($msg) {
global $_SESSION;
- $_SESSION['user']['errors'][] = $msg;
- $this->log('info','','','ERROR',$msg);
+
+ /* add the error if not already in the stack */
+ if (!is_array($_SESSION['user']['errors']) or
+ array_search($msg,$_SESSION['user']['errors'])===FALSE) {
+ $_SESSION['user']['errors'][] = $msg;
+ $this->log('info','','','ERROR',$msg);
+ }
}
+ function warning($msg) {
+ global $_SESSION;
+ $_SESSION['user']['warnings'][] = $msg;
+ $this->log('info','','','WARNING',$msg);
+ }
+
function log($level,$realaction,$plugin,$result,$moreinfo) {
global $_SERVER;
@@ -92,6 +102,12 @@
}
+ function _sortTabs($a, $b) {
+ if ($a['priority'] == $b['priority'])
+ return 0;
+ else
+ return ($a['priority'] < $b['priority'])? -1 : 1;
+ }
function loadACL() {
/* loads the acl from the db */
@@ -99,14 +115,16 @@
if (is_array($group)) {
$this->acl = $this->db->read('acl',array(),array('group_name','module','action'),'',
array('group_name','module','action'));
- $this->pluginAcl = $this->db->read('plugin_acl',array(),array('plugin'),'',array('plugin'));
+// $this->pluginAcl = $this->db->read('plugin_acl',array(),array('plugin'),'',array('plugin'));
} else {
$this->acl = array_merge($this->db->read('acl',array('group_name' => $group),array('module','action'),'',
array('group_name','module','action')),
$this->db->read('acl',array('group_name' => '*'),array('module','action'),'',
array('group_name','module','action')));
- $this->pluginAcl = $this->db->read('plugin_acl',array('group_name' => $group),array('plugin'),'',array('plugin'));
+// $this->pluginAcl = $this->db->read('plugin_acl',array('group_name' => $group),array('plugin'),'',array('plugin'));
}
+ // need to load all the plugin acl as group can change on the actions
+ $this->pluginAcl = $this->db->read('plugin_acl',array(),array('plugin','group_name'),'',array('plugin','group_name'));
}
function tab($content,$name = 'default', $priority = 0 ) {
@@ -118,6 +136,25 @@
}
}
+ function addContent($content, $name = 'page', $priority = 0) {
+ $this->contents[$name]['html'][] = $content;
+ if ($priority<999)
+ $this->contents[$name]['priority']=$priority;
+ else if (!isset($this->contents[$name]['priority'])) {
+ $this->contents[$name]['priority']=999;
+ }
+ }
+
+ function getContent($name) {
+ $result = '';
+ if (isset($this->contents[$name])) {
+ foreach ($this->contents[$name]['html'] as $c) {
+ $result .= $c;
+ }
+ }
+ return $result;
+ }
+
function banned() {
global $_SERVER;
@@ -138,6 +175,7 @@
global $_GET;
$this->tabs = array();
+ $this->contents = array();
$this->setupRun($action,$step);
/* check for banned IP */
@@ -145,6 +183,7 @@
$this->log('security','banned','','DENY','');
$this->page['content'] = $this->fetch('banned');
$this->page['title']= tr('IP Banned');
+ $this->addContent($this->page['content']);
$this->tpl->assign('page',app()->page);
$this->display($this->mainPage);
$this->db->free();
@@ -174,19 +213,21 @@
unset($_SESSION['user']['messages']);
unset($_SESSION['user']['errors']);
$this->page['content']=tr('THERE HAS BEEN A PERMISSION ERROR. PLEASE TRY ONE OF THE ALLOWED OPTIONS!');
+ $this->addContent($this->page['content'],'page');
$this->tpl->assign('page',$this->page);
$this->display($this->mainPage);
$this->db->free();
exit(0);
} else {
/* save the requested url */
- redirect('?action=login');
+ redirect('?a=login');
}
}
if ($_SERVER['QUERY_STRING']!='')
$_SESSION['requested_url']='?'.$_SERVER['QUERY_STRING'];
redirect();
}
+
$this->initPlugins();
$this->initMenu($this->user->group(),$m->name);
@@ -202,28 +243,47 @@
$this->page[$k] = $v;
}
}
+ $this->tpl->assign('langs',$this->langs);
$this->tpl->assign('user',$_SESSION['user']);
$this->tpl->assign('config',$this->config);
+
$m->$fun();
+
+
+ /* now populate the plugin html */
+ if (count($this->pluginOutput)>0) {
+ foreach ($this->pluginOutput as $t) {
+ $this->addContent($this->fetch($t),'plugins');
+ }
+ }
+
+ /* if for some reason we want to have the content relocated in the page we need this (i.e. in the tabs)*/
+ if ($this->exists('modules/'.$m->name.'/'.$fun.'.pre')) {
+ $this->addContent($this->fetch('modules/'.$m->name.'/'.$fun.'.pre'),'page',1);
+ }
+
if (count($this->tabs)>0) {
/* sort based on the priority flag */
- uasort($this->tabs,'sortTabs');
+ uasort($this->tabs,array($this, '_sortTabs'));
$this->tpl->assign('tabs',$this->tabs);
- $this->pluginOutput .= $this->fetch('tabs');
+ $this->addContent($this->fetch('tabs'),'plugins');
}
- $this->tpl->assign('plugins',$this->pluginOutput);
- $this->page['content']=$this->fetch('modules/'.$m->name.'/'.$fun);
+ $this->tpl->assign('plugins',$this->getContent('plugins'));
+ $this->addContent($this->fetch('modules/'.$m->name.'/'.$fun),'page',1);
+
if ($_GET['type']=='ajax') {
- echo $this->page['content'];
- session_weite_close;
+ echo $this->getContent('page');
+ session_write_close();
exit;
}
+ /* backward compatibility */
+ $this->page['content']=$this->getContent('page');
/* ...
[truncated message content] |