|
From: <txm...@us...> - 2014-04-21 13:26:38
|
Revision: 12465
http://sourceforge.net/p/xoops/svn/12465
Author: txmodxoops
Date: 2014-04-21 13:26:32 +0000 (Mon, 21 Apr 2014)
Log Message:
-----------
Continuous integration
Added helper.php & request.php classes
Modified Paths:
--------------
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/fields.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/index.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/modules.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/tables.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/building.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/modules.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/tables.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/css/admin/style.css
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/include/common.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/js/functions.js
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/language/english/admin.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/templates/admin/tdmcreate_fields.html
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/templates/admin/tdmcreate_modules.html
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/templates/admin/tdmcreate_tables.html
Added Paths:
-----------
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/helper.php
XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/request.php
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php 2014-04-20 09:47:08 UTC (rev 12464)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/building.php 2014-04-21 13:26:32 UTC (rev 12465)
@@ -20,9 +20,9 @@
*/
include 'header.php';
$op = TDMCreate_CleanVars( $_REQUEST, 'op', 'default', 'string' );
-
-if (isset($_REQUEST['mod_name'])) {
- $modules =& $modulesHandler->get($_REQUEST['mod_name']);
+$mname = TDMCreate_CleanVars( $_REQUEST, 'mod_name', '', 'string' );
+if ( $mname ) {
+ $modules =& $modulesHandler->get( $mname );
} else {
$modules =& $modulesHandler;
}
@@ -51,7 +51,7 @@
/*} else {
$GLOBALS['xoopsTpl']->assign('base_architecture', false);
}*/
- $mod_name = 'uploads/tdmcreate/modules/' . str_replace(' ', '', strtolower($modules->getVar('mod_name')));
+ $mod_name = 'uploads/tdmcreate/modules/' . str_replace(' ', '', strtolower($mod_name));
// Creation of the structure of folders and files
$GLOBALS['xoopsTpl']->assign('build_list', 'Under new construction - Temporary build only folders of this selected module "'.$mod_name.'/"');
if ( $modules->getVar('mod_install') == 1 ) {
@@ -67,13 +67,14 @@
$nb_modules = $modulesHandler->getObjects(null);
if ( $nb_modules == 0 ) {
redirect_header('modules.php?op=new', 2, _AM_TDMCREATE_NOTMODULES );
- }
+ }
+ unset($nb_modules);
// Redirect if there aren't tables
$nb_tables = $tablesHandler->getObjects(null);
if ($nb_tables == 0) {
redirect_header('tables.php?op=new', 2, _AM_TDMCREATE_NOTTABLES );
}
-
+ unset($nb_tables);
include_once TDMC_PATH . '/class/building.php';
$handler = TDMCreateBuilding::getInstance();
$form = $handler->getForm();
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/fields.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/fields.php 2014-04-20 09:47:08 UTC (rev 12464)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/fields.php 2014-04-21 13:26:32 UTC (rev 12465)
@@ -20,25 +20,38 @@
*/
include 'header.php';
// Recovered value of arguments op in the URL $
-$op = TDMCreate_CleanVars($_REQUEST, 'op', 'list', 'string');
+//$op = TDMCreate_CleanVars($_REQUEST, 'op', 'list', 'string');
+$tdmcreate = TDMCreate::getInstance();
+$op = TDMCreateRequest::getString('op', 'list');
// Get table Variables
$table_id = TDMCreate_CleanVars($_REQUEST, 'table_id');
$table_mid = TDMCreate_CleanVars($_REQUEST, 'table_mid');
$table_nbfields = TDMCreate_CleanVars($_REQUEST, 'table_nbfields');
$table_fieldname = TDMCreate_CleanVars($_REQUEST, 'table_fieldname', '', 'string');
+/*$table_id = TDMCreateRequest::getInt('table_id');
+$table_mid = TDMCreateRequest::getInt('table_mid');
+$table_nbfields = TDMCreateRequest::getInt('table_nbfields');
+$table_fieldname = TDMCreateRequest::getString('table_fieldname', '');*/
// Get field Variables
-$field_id = TDMCreate_CleanVars($_REQUEST, 'field_id');
+/*$field_id = TDMCreate_CleanVars($_REQUEST, 'field_id');
$field_mid = TDMCreate_CleanVars($_REQUEST, 'field_mid');
$field_tid = TDMCreate_CleanVars($_REQUEST, 'field_tid');
$field_numb = TDMCreate_CleanVars($_REQUEST, 'field_numb');
-$field_name = TDMCreate_CleanVars($_REQUEST, 'field_name', '', 'string');
+$field_name = TDMCreate_CleanVars($_REQUEST, 'field_name', '', 'string');*/
+$field_id = TDMCreateRequest::getInt('field_id');
+$field_mid = TDMCreateRequest::getInt('field_mid');
+$field_tid = TDMCreateRequest::getInt('field_tid');
+$field_numb = TDMCreateRequest::getInt('field_numb');
+$field_name = TDMCreateRequest::getString('field_name', '');
//
switch ($op)
{
case 'list':
default:
- $limit = $GLOBALS['xoopsModuleConfig']['fields_adminpager'];
- $start = TDMCreate_CleanVars($_REQUEST, 'start', 0);
+ //$limit = $GLOBALS['xoopsModuleConfig']['fields_adminpager'];
+ //$start = TDMCreate_CleanVars($_REQUEST, 'start', 0);
+ $start = TDMCreateRequest::getInt('start', 0);
+ $limit = TDMCreateRequest::getInt('limit', $tdmcreate->getConfig('fields_adminpager'));
// Define main template
$template_main = 'tdmcreate_fields.html';
$GLOBALS['xoTheme']->addStylesheet( 'modules/TDMCreate/css/admin/style.css' );
@@ -54,7 +67,13 @@
$nb_modules = $modulesHandler->getObjects(null);
if ( $nb_modules == 0 ) {
redirect_header('modules.php?op=new', 2, _AM_TDMCREATE_NOTMODULES );
- }
+ }
+ unset($nb_modules);
+ $nb_tables = $tablesHandler->getObjects(null);
+ if ($nb_tables == 0) {
+ redirect_header('tables.php?op=new', 2, _AM_TDMCREATE_NOTTABLES );
+ }
+ unset($nb_tables);
// Get the list of tables
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('table_mid', $table_mid));
@@ -63,10 +82,7 @@
$criteria->setOrder('ASC');
$nb_tables = $tablesHandler->getCount($criteria);
$tables_arr = $tablesHandler->getAll($criteria);
- unset($criteria);
- if ($nb_tables == 0) {
- redirect_header('tables.php?op=new', 2, _AM_TDMCREATE_NOTTABLES );
- }
+ unset($criteria);
if ($nb_tables > 0)
{
foreach (array_keys($tables_arr) as $t)
@@ -169,8 +185,8 @@
'field_required' => (($_REQUEST['field_required'][$i] == 1) ? '1' : '0')
);
}
- foreach ($datas as $data => $value) {
- $obj->setVars(array($data, $value));
+ foreach ($datas as $value) {
+ $obj->setVars( $value );
$fieldsHandler->insert($obj);
}
}
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/index.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/index.php 2014-04-20 09:47:08 UTC (rev 12464)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/index.php 2014-04-21 13:26:32 UTC (rev 12465)
@@ -22,11 +22,13 @@
$criteria = new CriteriaCompo();
$count_modules = $modulesHandler->getCount($criteria);
$count_tables = $tablesHandler->getCount($criteria);
+$count_fields = $fieldsHandler->getCount($criteria);
unset($criteria);
$template_main = 'tdmcreate_index.html';
$adminMenu->addInfoBox(_AM_TDMCREATE_ADMIN_NUMMODULES) ;
$adminMenu->addInfoBoxLine(_AM_TDMCREATE_ADMIN_NUMMODULES, '<label>' ._AM_TDMCREATE_THEREARE_NUMMODULES. '</label>', $count_modules, 'Green') ;
$adminMenu->addInfoBoxLine(_AM_TDMCREATE_ADMIN_NUMMODULES, '<label>' ._AM_TDMCREATE_THEREARE_NUMTABLES. '</label>', $count_tables, 'Orange');
+$adminMenu->addInfoBoxLine(_AM_TDMCREATE_ADMIN_NUMMODULES, '<label>' ._AM_TDMCREATE_THEREARE_NUMFIELDS. '</label>', $count_fields, 'Gray');
//$xoopsOption['template_main'] = 'tdmcreate_index.html';
$GLOBALS['xoopsTpl']->assign('navigation', $adminMenu->addNavigation('index.php'));
$GLOBALS['xoopsTpl']->assign('index', $adminMenu->renderIndex());
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/modules.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/modules.php 2014-04-20 09:47:08 UTC (rev 12464)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/modules.php 2014-04-21 13:26:32 UTC (rev 12465)
@@ -19,15 +19,22 @@
* @version $Id: 1.59 modules.php 11297 2013-03-24 10:58:10Z timgno $
*/
include 'header.php';
-// Recovered the value of the argument op in the URL $
-$op = TDMCreate_CleanVars($_REQUEST, 'op', 'list', 'string');
-$mod_id = TDMCreate_CleanVars($_REQUEST, 'mod_id');
+// Recovered value of argument op in the URL $
+//$op = TDMCreate_CleanVars($_REQUEST, 'op', 'list', 'string');
+//$mod_id = TDMCreate_CleanVars($_REQUEST, 'mod_id');
+$tdmcreate = TDMCreate::getInstance();
+$op = TDMCreateRequest::getString('op', 'list');
+//
+$mod_id = TDMCreateRequest::getInt('mod_id');
+//
switch ($op)
{
case 'list':
default:
- $limit = $GLOBALS['xoopsModuleConfig']['modules_adminpager'];
- $start = TDMCreate_CleanVars($_REQUEST, 'start', 0);
+ //$limit = $GLOBALS['xoopsModuleConfig']['modules_adminpager'];
+ //$start = TDMCreate_CleanVars($_REQUEST, 'start', 0);
+ $start = TDMCreateRequest::getInt('start', 0);
+ $limit = TDMCreateRequest::getInt('limit', $tdmcreate->getConfig('modules_adminpager'));
// Define main template
$template_main = 'tdmcreate_modules.html';
$GLOBALS['xoTheme']->addStylesheet( 'modules/TDMCreate/css/admin/style.css' );
@@ -39,11 +46,15 @@
$criteria = new CriteriaCompo();
$criteria->setSort('mod_id ASC, mod_name');
$criteria->setOrder('ASC');
- $numrows = $modulesHandler->getCount();
+ $nb_modules = $modulesHandler->getCount();
$mods_arr = $modulesHandler->getAll( $criteria );
- unset($criteria);
+ unset($criteria);
+ // Redirect if there aren't modules
+ if ( $nb_modules == 0 ) {
+ redirect_header('modules.php?op=new', 2, _AM_TDMCREATE_NOTMODULES );
+ }
// Display modules list
- if ($numrows>0)
+ if ($nb_modules > 0)
{
foreach (array_keys($mods_arr) as $i)
{
@@ -62,9 +73,9 @@
$GLOBALS['xoopsTpl']->append('modules_list', $mod);
unset($mod);
}
- if ( $numrows > $limit ) {
+ if ( $nb_modules > $limit ) {
include_once XOOPS_ROOT_PATH . '/class/pagenav.php';
- $pagenav = new XoopsPageNav($numrows, $limit, $start, 'start', 'op=list&limit=' . $limit);
+ $pagenav = new XoopsPageNav($nb_modules, $limit, $start, 'start', 'op=list&limit=' . $limit);
$GLOBALS['xoopsTpl']->assign('pagenav', $pagenav->renderNav(4));
}
} else {
@@ -115,8 +126,8 @@
'mod_manual_file' => $_POST['mod_manual_file']));
//Form mod_image
include_once XOOPS_ROOT_PATH . '/class/uploader.php';
- $uploader = new XoopsMediaUploader(TDMC_UPLOAD_IMGMOD_PATH, $GLOBALS['xoopsModuleConfig']['mimetypes'],
- $GLOBALS['xoopsModuleConfig']['maxsize'], null, null);
+ $uploader = new XoopsMediaUploader(TDMC_UPLOAD_IMGMOD_PATH, $tdmcreate->getConfig('mimetypes'),
+ $tdmcreate->getConfig('maxsize'), null, null);
if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
$extension = preg_replace( '/^.+\.([^.]+)$/sU' , '\\1' , $_FILES['attachedfile']['name']);
$name_img = $_GET['mod_name'].'_slogo.'.$extension;
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/tables.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/tables.php 2014-04-20 09:47:08 UTC (rev 12464)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/admin/tables.php 2014-04-21 13:26:32 UTC (rev 12465)
@@ -20,20 +20,31 @@
*/
include 'header.php';
// Recovered value of arguments op in the URL $
-$op = TDMCreate_CleanVars($_REQUEST, 'op', 'list', 'string');
+//$op = TDMCreate_CleanVars($_REQUEST, 'op', 'list', 'string');
+$tdmcreate = TDMCreate::getInstance();
+$op = TDMCreateRequest::getString('op', 'list');
//
-$mod_id = TDMCreate_CleanVars($_REQUEST, 'mod_id');
+/*$mod_id = TDMCreate_CleanVars($_REQUEST, 'mod_id');
$table_id = TDMCreate_CleanVars($_REQUEST, 'table_id');
$table_mid = TDMCreate_CleanVars($_REQUEST, 'table_mid');
$table_nbfields = TDMCreate_CleanVars($_REQUEST, 'table_nbfields');
-$table_fieldname = TDMCreate_CleanVars($_REQUEST, 'table_fieldname', '', 'string');
+$table_fieldname = TDMCreate_CleanVars($_REQUEST, 'table_fieldname', '', 'string');*/
//
+$mod_id = TDMCreateRequest::getInt('mod_id');
+//
+$table_id = TDMCreateRequest::getInt('table_id');
+$table_mid = TDMCreateRequest::getInt('table_mid');
+$table_nbfields = TDMCreateRequest::getInt('table_nbfields');
+$table_fieldname = TDMCreateRequest::getString('table_fieldname', '');
+//
switch ($op)
{
case 'list':
default:
- $limit = $GLOBALS['xoopsModuleConfig']['tables_adminpager'];
- $start = TDMCreate_CleanVars($_REQUEST, 'start', 0);
+ //$limit = $GLOBALS['xoopsModuleConfig']['tables_adminpager'];
+ //$start = TDMCreate_CleanVars($_REQUEST, 'start', 0);
+ $start = TDMCreateRequest::getInt('start', 0);
+ $limit = TDMCreateRequest::getInt('limit', $tdmcreate->getConfig('tables_adminpager'));
// Define main template
$template_main = 'tdmcreate_tables.html';
$GLOBALS['xoTheme']->addStylesheet( 'modules/TDMCreate/css/admin/style.css' );
@@ -44,7 +55,7 @@
$GLOBALS['xoopsTpl']->assign('tdmc_url', TDMC_URL);
$GLOBALS['xoopsTpl']->assign('tdmc_icons_url', TDMC_ICONS_URL);
$GLOBALS['xoopsTpl']->assign('tdmc_upload_imgmod_url', TDMC_UPLOAD_IMGMOD_URL);
- //$GLOBALS['xoopsTpl']->assign('tdmc_upload_table_url', TDMC_UPLOAD_IMGTAB_URL);
+ //$GLOBALS['xoopsTpl']->assign('tdmc_upload_imgtab_url', TDMC_UPLOAD_IMGTAB_URL);
$GLOBALS['xoopsTpl']->assign('pathIcon32', $pathIcon32);
// Get the list of modules
$criteria = new CriteriaCompo();
@@ -56,7 +67,12 @@
redirect_header('modules.php?op=new', 2, _AM_TDMCREATE_NOTMODULES );
}
$mods_arr = $modulesHandler->getAll($criteria);
- unset($criteria);
+ unset($criteria);
+ $nb_tables = $tablesHandler->getObjects(null);
+ if ($nb_tables == 0) {
+ redirect_header('tables.php?op=new', 2, _AM_TDMCREATE_NOTTABLES );
+ }
+ unset($nb_tables);
// Display modules list
if ( $nb_modules > 0 )
{
@@ -159,8 +175,8 @@
}else{
$uploaddir = TDMC_UPLOAD_PATH.'/images/tables';
}
- $uploader = new XoopsMediaUploader($uploaddir, xoops_getModuleOption('mimetypes'),
- xoops_getModuleOption('maxsize'), null, null);
+ $uploader = new XoopsMediaUploader($uploaddir, $tdmcreate->getConfig('mimetypes'),
+ $tdmcreate->getConfig('maxsize'), null, null);
if ($uploader->fetchMedia($_POST['xoops_upload_file'][0])) {
$extension = preg_replace( '/^.+\.([^.]+)$/sU' , '\\1' , $_FILES['table_image']['name']);
$name_img = $_GET['table_name'].'.'.$extension;
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/building.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/building.php 2014-04-20 09:47:08 UTC (rev 12464)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/building.php 2014-04-21 13:26:32 UTC (rev 12465)
@@ -10,24 +10,33 @@
*/
/**
- * Xoops Javascript class
+ * TDMCreateBuilding class
*
* @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
- * @package media
+ * @package tdmcreate
* @since 2.5.x
* @author TDM TEAM DEV MODULE
- * @version $Id: modules.php 12209 2013-10-23 02:49:09Z beckmi $ modules.php 11114 2013-02-13 10:22:12Z timgno $
+ * @version $Id: modules.php 12425 2014-02-23 22:40:09Z timgno $
*/
defined('XOOPS_ROOT_PATH') or die('Restricted access');
class TDMCreateBuilding extends XoopsObject
{
- // Constructor
+ /**
+ * @var mixed
+ */
+ private $tdmc = null;
+
+ /*
+ * @public function constructor class
+ * @param null
+ */
public function __construct()
{
- $this->XoopsObject();
+ $this->XoopsObject();
+ $this->tdmc = TDMCreate::getInstance();
}
/*
@@ -50,7 +59,7 @@
}
xoops_load('XoopsFormLoader');
$form = new XoopsThemeForm(_AM_TDMCREATE_ADMIN_CONST, 'buildform', $action, 'post', true);
- $modulesHandler =& xoops_getModuleHandler('modules', 'TDMCreate');
+ $modulesHandler =& $this->tdmc->getHandler('modules');
$mod_select = new XoopsFormSelect(_AM_TDMCREATE_CONST_MODULES, 'mod_name', 'mod_name');
$mod_select->addOptionArray($modulesHandler->getList());
$form->addElement($mod_select, true);
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php 2014-04-20 09:47:08 UTC (rev 12464)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/fields.php 2014-04-21 13:26:32 UTC (rev 12465)
@@ -99,7 +99,7 @@
$form->setExtra('enctype="multipart/form-data"');
$tablesHandler = xoops_getModuleHandler('tables');
- $fieldsHandler = xoops_getModuleHandler('fields');
+ //$fieldsHandler = xoops_getModuleHandler('fields');
$fieldelementsHandler =& xoops_getModuleHandler('fieldelements');
$fieldtypeHandler =& xoops_getModuleHandler('fieldtype');
$fieldattrsHandler =& xoops_getModuleHandler('fieldattributes');
@@ -122,7 +122,7 @@
$form->addElement(new TDMCreateFormLabel('</tr></thead>'));
$form->addElement(new TDMCreateFormLabel('<tbody>'));
- $fields = $fieldsHandler->getObjects(null);
+ //$fields = $fieldsHandler->getObjects(null);
$class = '';
for($i = 1; $i <= $field_numb; $i++)
@@ -132,8 +132,8 @@
// Index ID
$form->addElement(new TDMCreateFormLabel('<td class="center">'.$i.'</td>'));
// Field Name
- $field_name = $isNew ? (!empty($f_name) ? $f_name . '_' : '') : $this->getVar('field_name');
- $field_name = new XoopsFormText(_AM_TDMCREATE_FIELD_NAME, 'field_name['.$i.']', 15, 255, $field_name);
+ $this_field_name = $isNew ? (!empty($f_name) ? $f_name . '_' : '') : $this->getVar('field_name');
+ $field_name = new XoopsFormText(_AM_TDMCREATE_FIELD_NAME, 'field_name['.$i.']', 15, 255, $this_field_name);
$form->addElement(new TDMCreateFormLabel('<td class="center">'.$field_name->render().'</td>'));
// Field Type
$fieldtype_select = new XoopsFormSelect(_AM_TDMCREATE_FIELD_TYPE, 'field_type['.$i.']', $this->getVar('field_type'));
Added: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/helper.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/helper.php (rev 0)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/helper.php 2014-04-21 13:26:32 UTC (rev 12465)
@@ -0,0 +1,173 @@
+<?php
+/*
+ You may not change or alter any portion of this comment or credits
+ of supporting developers from this source code or any supporting source code
+ which is considered copyrighted (c) material of the original comment or credit authors.
+
+ This program 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.
+ */
+/**
+ * tdmcreate module
+ *
+ * @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
+ * @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
+ * @package tdmcreate
+ * @since 2.5.0
+ * @author trabis <lus...@gm...>
+ * @version $Id: tdmcreate.php 12258 2014-04-12 23:45:12Z timgno $
+ */
+defined('XOOPS_ROOT_PATH') or die('Restricted access');
+
+class TDMCreate
+{
+ /**
+ * @var string
+ */
+ private $dirname = null;
+ /**
+ * @var string
+ */
+ private $module = null;
+ /**
+ * @var string
+ */
+ private $handler = null;
+ /**
+ * @var string
+ */
+ private $config = null;
+ /**
+ * @var string
+ */
+ private $debug = null;
+ /**
+ * @var array
+ */
+ private $debugArray = array();
+ /*
+ * @protected function constructor class
+ * @param mixed $debug
+ */
+ protected function __construct($debug)
+ {
+ $this->debug = $debug;
+ $this->dirname = basename(dirname(dirname(__FILE__)));
+ }
+ /*
+ * @static function &getInstance
+ * @param mixed $debug
+ */
+ public static function &getInstance($debug = false)
+ {
+ static $instance = false;
+ if (!$instance) {
+ $instance = new self($debug);
+ }
+ return $instance;
+ }
+ /*
+ * @static function getModule
+ * @param null
+ */
+ public function &getModule()
+ {
+ if ($this->module == null) {
+ $this->initModule();
+ }
+ return $this->module;
+ }
+ /*
+ * @static function getConfig
+ * @param string $name
+ */
+ public function getConfig($name = null)
+ {
+ if ($this->config == null) {
+ $this->initConfig();
+ }
+ if (!$name) {
+ $this->addLog("Getting all config");
+ return $this->config;
+ }
+ if (!isset($this->config[$name])) {
+ $this->addLog("ERROR :: CONFIG '{$name}' does not exist");
+ return null;
+ }
+ $this->addLog("Getting config '{$name}' : " . $this->config[$name]);
+ return $this->config[$name];
+ }
+ /*
+ * @static function setConfig
+ * @param string $name
+ * @param mixed $value
+ */
+ public function setConfig($name = null, $value = null)
+ {
+ if ($this->config == null) {
+ $this->initConfig();
+ }
+ $this->config[$name] = $value;
+ $this->addLog("Setting config '{$name}' : " . $this->config[$name]);
+ return $this->config[$name];
+ }
+ /*
+ * @static function getHandler
+ * @param string $name
+ */
+ public function &getHandler($name)
+ {
+ if (!isset($this->handler[$name . '_handler'])) {
+ $this->initHandler($name);
+ }
+ $this->addLog("Getting handler '{$name}'");
+ return $this->handler[$name . '_handler'];
+ }
+ /*
+ * @static function initModule
+ * @param null
+ */
+ public function initModule()
+ {
+ global $xoopsModule;
+ if (isset($xoopsModule) && is_object($xoopsModule) && $xoopsModule->getVar('dirname') == $this->dirname) {
+ $this->module = $xoopsModule;
+ } else {
+ $hModule = xoops_gethandler('module');
+ $this->module = $hModule->getByDirname($this->dirname);
+ }
+ $this->addLog('INIT MODULE');
+ }
+ /*
+ * @static function initConfig
+ * @param null
+ */
+ public function initConfig()
+ {
+ $this->addLog('INIT CONFIG');
+ $hModConfig = xoops_gethandler('config');
+ $this->config = $hModConfig->getConfigsByCat(0, $this->getModule()->getVar('mid'));
+ }
+ /*
+ * @static function initHandler
+ * @param string $name
+ */
+ public function initHandler($name)
+ {
+ $this->addLog('INIT ' . $name . ' HANDLER');
+ $this->handler[$name . '_handler'] = xoops_getModuleHandler($name, $this->dirname);
+ }
+ /*
+ * @static function addLog
+ * @param string $log
+ */
+ public function addLog($log)
+ {
+ if ($this->debug) {
+ if (is_object($GLOBALS['xoopsLogger'])) {
+ $GLOBALS['xoopsLogger']->addExtra($this->module->name(), $log);
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/modules.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/modules.php 2014-04-20 09:47:08 UTC (rev 12464)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/modules.php 2014-04-21 13:26:32 UTC (rev 12465)
@@ -10,11 +10,11 @@
*/
/**
- * Xoops Javascript class
+ * modules class
*
* @copyright The XOOPS Project http://sourceforge.net/projects/xoops/
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
- * @package media
+ * @package tdmcreate
* @since 2.5.x
* @author TDM TEAM DEV MODULE
* @version $Id: modules.php 12209 2013-10-23 02:49:09Z beckmi $
@@ -28,50 +28,56 @@
*/
class TDMCreateModules extends XoopsObject
{
+ /**
+ * Instance of TDMCreate class
+ *
+ * @var mixed
+ */
+ private $tdmcreate = null;
/*
* @public function constructor class
* @param null
*/
public function __construct()
{
- $this->XoopsObject();
+ $this->tdmcreate = TDMCreate::getInstance();
$this->initVar('mod_id',XOBJ_DTYPE_INT);
- $this->initVar('mod_name',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['name']);
- $this->initVar('mod_version',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['version']);
- $this->initVar('mod_since',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['since']);
- $this->initVar('mod_min_php',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['min_php']);
- $this->initVar('mod_min_xoops',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['min_xoops']);
- $this->initVar('mod_min_admin',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['min_admin']);
- $this->initVar('mod_min_mysql',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['min_mysql']);
- $this->initVar('mod_description',XOBJ_DTYPE_TXTAREA, $GLOBALS['xoopsModuleConfig']['description']);
- $this->initVar('mod_author',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['author']);
- $this->initVar('mod_author_mail',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['author_email']);
- $this->initVar('mod_author_website_url',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['author_website_url']);
- $this->initVar('mod_author_website_name',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['author_website_name']);
- $this->initVar('mod_credits',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['credits']);
- $this->initVar('mod_license',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['license']);
- $this->initVar('mod_release_info',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['release_info']);
- $this->initVar('mod_release_file',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['release_file']);
- $this->initVar('mod_manual',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['manual']);
- $this->initVar('mod_manual_file',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['manual_file']);
+ $this->initVar('mod_name',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('name'));
+ $this->initVar('mod_version',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('version'));
+ $this->initVar('mod_since',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('since'));
+ $this->initVar('mod_min_php',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('min_php'));
+ $this->initVar('mod_min_xoops',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('min_xoops'));
+ $this->initVar('mod_min_admin',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('min_admin'));
+ $this->initVar('mod_min_mysql',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('min_mysql'));
+ $this->initVar('mod_description',XOBJ_DTYPE_TXTAREA, $this->tdmcreate->getConfig('description'));
+ $this->initVar('mod_author',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('author'));
+ $this->initVar('mod_author_mail',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('author_email'));
+ $this->initVar('mod_author_website_url',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('author_website_url'));
+ $this->initVar('mod_author_website_name',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('author_website_name'));
+ $this->initVar('mod_credits',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('credits'));
+ $this->initVar('mod_license',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('license'));
+ $this->initVar('mod_release_info',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('release_info'));
+ $this->initVar('mod_release_file',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('release_file'));
+ $this->initVar('mod_manual',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('manual'));
+ $this->initVar('mod_manual_file',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('manual_file'));
$this->initVar('mod_image',XOBJ_DTYPE_TXTBOX, null);
- $this->initVar('mod_demo_site_url',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['demo_site_url']);
- $this->initVar('mod_demo_site_name',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['demo_site_name']);
- $this->initVar('mod_support_url',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['support_url']);
- $this->initVar('mod_support_name',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['support_name']);
- $this->initVar('mod_website_url',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['website_url']);
- $this->initVar('mod_website_name',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['website_name']);
- $this->initVar('mod_release',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['release_date']);
- $this->initVar('mod_status',XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['status']);
- $this->initVar('mod_admin',XOBJ_DTYPE_INT,$GLOBALS['xoopsModuleConfig']['display_admin']);
- $this->initVar('mod_user',XOBJ_DTYPE_INT, $GLOBALS['xoopsModuleConfig']['display_user']);
- $this->initVar('mod_search',XOBJ_DTYPE_INT, $GLOBALS['xoopsModuleConfig']['active_search']);
- $this->initVar('mod_comments',XOBJ_DTYPE_INT, $GLOBALS['xoopsModuleConfig']['active_comments']);
- $this->initVar('mod_notifications', XOBJ_DTYPE_INT, $GLOBALS['xoopsModuleConfig']['active_notifications']);
- $this->initVar('mod_permissions', XOBJ_DTYPE_INT, $GLOBALS['xoopsModuleConfig']['active_permissions']);
- $this->initVar('mod_install', XOBJ_DTYPE_INT, $GLOBALS['xoopsModuleConfig']['inroot_install']);
- $this->initVar('mod_donations', XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['donations']);
- $this->initVar('mod_subversion', XOBJ_DTYPE_TXTBOX, $GLOBALS['xoopsModuleConfig']['subversion']);
+ $this->initVar('mod_demo_site_url',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('demo_site_url'));
+ $this->initVar('mod_demo_site_name',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('demo_site_name'));
+ $this->initVar('mod_support_url',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('support_url'));
+ $this->initVar('mod_support_name',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('support_name'));
+ $this->initVar('mod_website_url',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('website_url'));
+ $this->initVar('mod_website_name',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('website_name'));
+ $this->initVar('mod_release',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('release_date'));
+ $this->initVar('mod_status',XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('status'));
+ $this->initVar('mod_admin',XOBJ_DTYPE_INT, $this->tdmcreate->getConfig('display_admin'));
+ $this->initVar('mod_user',XOBJ_DTYPE_INT, $this->tdmcreate->getConfig('display_user'));
+ $this->initVar('mod_search',XOBJ_DTYPE_INT, $this->tdmcreate->getConfig('active_search'));
+ $this->initVar('mod_comments',XOBJ_DTYPE_INT, $this->tdmcreate->getConfig('active_comments'));
+ $this->initVar('mod_notifications', XOBJ_DTYPE_INT, $this->tdmcreate->getConfig('active_notifications'));
+ $this->initVar('mod_permissions', XOBJ_DTYPE_INT, $this->tdmcreate->getConfig('active_permissions'));
+ $this->initVar('mod_install', XOBJ_DTYPE_INT, $this->tdmcreate->getConfig('inroot_install'));
+ $this->initVar('mod_donations', XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('donations'));
+ $this->initVar('mod_subversion', XOBJ_DTYPE_TXTBOX, $this->tdmcreate->getConfig('subversion'));
}
/*
@@ -159,7 +165,7 @@
$imgtray->addElement( new XoopsFormLabel( '', "<br /><img src='" . TDMC_UPLOAD_IMGMOD_URL . "/" . $mod_image . "' name='image3' id='image3' alt='' /><br />" ) );
$fileseltray = new XoopsFormElementTray('', '<br />');
- $fileseltray->addElement(new XoopsFormFile(_AM_TDMCREATE_FORMUPLOAD, 'attachedfile', $GLOBALS['xoopsModuleConfig']['maxsize']));
+ $fileseltray->addElement(new XoopsFormFile(_AM_TDMCREATE_FORMUPLOAD, 'attachedfile', $this->tdmcreate->getConfig('maxsize')));
$fileseltray->addElement(new XoopsFormLabel(''));
$imgtray->addElement($fileseltray);
$form->addElement($imgtray);
Added: XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/request.php
===================================================================
--- XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/request.php (rev 0)
+++ XoopsModules/TDMCreate/branches/timgno/1.91/TDMCreate/class/request.php 2014-04-21 13:26:32 UTC (rev 12465)
@@ -0,0 +1,941 @@
+<?php
+/*
+ You may not change or alter any portion of this comment or credits
+ of supporting developers from this source code or any supporting source code
+ which is considered copyrighted (c) material of the original comment or credit authors.
+
+ This program 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.
+ */
+/**
+ * Request class
+ *
+ * @copyright Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
+ * @license GNU/GPL, see LICENSE.php
+ * Joomla! is free software. This version may have been modified pursuant
+ * to the GNU General Public License, and as distributed it includes or
+ * is derivative of works licensed under the GNU General Public License or
+ * other free or open source software licenses.
+ * See COPYRIGHT.php for copyright notices and details.
+ * @package TDMCreate
+ * @since 1.0
+ * @author trabis <lus...@gm...>
+ * @version $Id: request.php 10374 2012-12-12 23:39:48Z trabis $
+ * @version $Id: request.php 12424 2014-04-18 22:11:14Z timgno $
+ */
+
+/**
+ * Set the available masks for cleaning variables
+ */
+define('TDMCREATE_REQUEST_NOTRIM', 1);
+define('TDMCREATE_REQUEST_ALLOWRAW', 2);
+define('TDMCREATE_REQUEST_ALLOWHTML', 4);
+
+/**
+ * TDMCreateRequest Class
+ * This class serves to provide a common interface to access
+ * request variables. This includes $_POST, $_GET, and naturally $_REQUEST. Variables
+ * can be passed through an input filter to avoid injection or returned raw.
+ */
+class TDMCreateRequest
+{
+
+ /**
+ * Gets the request method
+ *
+ * @return string
+ */
+ static function getOptions()
+ {
+ $method = strtoupper($_SERVER['REQUEST_METHOD']);
+ return $method;
+ }
+
+ /**
+ * Fetches and returns a given variable.
+ * The default behaviour is fetching variables depending on the
+ * current request method: GET and HEAD will result in returning
+ * an entry from $_GET, POST and PUT will result in returning an
+ * entry from $_POST.
+ * You can force the source by setting the $hash parameter:
+ * post $_POST
+ * get $_GET
+ * files $_FILES
+ * cookie $_COOKIE
+ * env $_ENV
+ * server $_SERVER
+ * method via current $_SERVER['REQUEST_METHOD']
+ * default $_REQUEST
+ *
+ * @static
+ *
+ * @param string $name Variable name
+ * @param string $default Default value if the variable does not exist
+ * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
+ * @param string $type Return type for the variable, for valid values see {@link JFilterInput::clean()}
+ * @param int $mask Filter mask for the variable
+ *
+ * @return mixed Requested variable
+ */
+ static function getVar($name, $default = null, $hash = 'default', $type = 'none', $mask = 0)
+ {
+ // Ensure hash and type are uppercase
+ $hash = strtoupper($hash);
+ if ($hash === 'METHOD') {
+ $hash = strtoupper($_SERVER['REQUEST_METHOD']);
+ }
+ $type = strtoupper($type);
+ // Get the input hash
+ switch ($hash) {
+ case 'GET' :
+ $input = & $_GET;
+ break;
+ case 'POST' :
+ $input = & $_POST;
+ break;
+ case 'FILES' :
+ $input = & $_FILES;
+ break;
+ case 'COOKIE' :
+ $input = & $_COOKIE;
+ break;
+ case 'ENV' :
+ $input = & $_ENV;
+ break;
+ case 'SERVER' :
+ $input = & $_SERVER;
+ break;
+ default:
+ $input = & $_REQUEST;
+ $hash = 'REQUEST';
+ break;
+ }
+ if (isset($input[$name]) && $input[$name] !== null) {
+ // Get the variable from the input hash and clean it
+ $var = TDMCreateRequest::_cleanVar($input[$name], $mask, $type);
+ // Handle magic quotes compatability
+ if (get_magic_quotes_gpc() && ($var != $default) && ($hash != 'FILES')) {
+ $var = TDMCreateRequest::_stripSlashesRecursive($var);
+ }
+ } else if ($default !== null) {
+ // Clean the default value
+ $var = TDMCreateRequest::_cleanVar($default, $mask, $type);
+ } else {
+ $var = $default;
+ }
+ return $var;
+ }
+
+ /**
+ * Fetches and returns a given filtered variable. The integer
+ * filter will allow only digits to be returned. This is currently
+ * only a proxy function for getVar().
+ * See getVar() for more in-depth documentation on the parameters.
+ *
+ * @static
+ *
+ * @param string $name Variable name
+ * @param int $default Default value if the variable does not exist
+ * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
+ *
+ * @return integer Requested variable
+ */
+ static function getInt($name, $default = 0, $hash = 'default')
+ {
+ return TDMCreateRequest::getVar($name, $default, $hash, 'int');
+ }
+
+ /**
+ * Fetches and returns a given filtered variable. The float
+ * filter only allows digits and periods. This is currently
+ * only a proxy function for getVar().
+ * See getVar() for more in-depth documentation on the parameters.
+ *
+ * @static
+ *
+ * @param string $name Variable name
+ * @param float $default Default value if the variable does not exist
+ * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
+ *
+ * @return float Requested variable
+ */
+ static function getFloat($name, $default = 0.0, $hash = 'default')
+ {
+ return TDMCreateRequest::getVar($name, $default, $hash, 'float');
+ }
+
+ /**
+ * Fetches and returns a given filtered variable. The bool
+ * filter will only return true/false bool values. This is
+ * currently only a proxy function for getVar().
+ * See getVar() for more in-depth documentation on the parameters.
+ *
+ * @static
+ *
+ * @param string $name Variable name
+ * @param bool $default Default value if the variable does not exist
+ * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
+ *
+ * @return bool Requested variable
+ */
+ static function getBool($name, $default = false, $hash = 'default')
+ {
+ return TDMCreateRequest::getVar($name, $default, $hash, 'bool');
+ }
+
+ /**
+ * Fetches and returns a given filtered variable. The word
+ * filter only allows the characters [A-Za-z_]. This is currently
+ * only a proxy function for getVar().
+ * See getVar() for more in-depth documentation on the parameters.
+ *
+ * @static
+ *
+ * @param string $name Variable name
+ * @param string $default Default value if the variable does not exist
+ * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
+ *
+ * @return string Requested variable
+ */
+ static function getWord($name, $default = '', $hash = 'default')
+ {
+ return TDMCreateRequest::getVar($name, $default, $hash, 'word');
+ }
+
+ /**
+ * Fetches and returns a given filtered variable. The cmd
+ * filter only allows the characters [A-Za-z0-9.-_]. This is
+ * currently only a proxy function for getVar().
+ * See getVar() for more in-depth documentation on the parameters.
+ *
+ * @static
+ *
+ * @param string $name Variable name
+ * @param string $default Default value if the variable does not exist
+ * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
+ *
+ * @return string Requested variable
+ */
+ static function getCmd($name, $default = '', $hash = 'default')
+ {
+ return TDMCreateRequest::getVar($name, $default, $hash, 'cmd');
+ }
+
+ /**
+ * Fetches and returns a given filtered variable. The string
+ * filter deletes 'bad' HTML code, if not overridden by the mask.
+ * This is currently only a proxy function for getVar().
+ * See getVar() for more in-depth documentation on the parameters.
+ *
+ * @static
+ *
+ * @param string $name Variable name
+ * @param string $default Default value if the variable does not exist
+ * @param string $hash Where the var should come from (POST, GET, FILES, COOKIE, METHOD)
+ * @param int $mask Filter mask for the variable
+ *
+ * @return string Requested variable
+ */
+ static function getString($name, $default = '', $hash = 'default', $mask = 0)
+ {
+ // Cast to string, in case JREQUEST_ALLOWRAW was specified for mask
+ return (string)TDMCreateRequest::getVar($name, $default, $hash, 'string', $mask);
+ }
+
+ static function getArray($name, $default = array(), $hash = 'default')
+ {
+ return TDMCreateRequest::getVar($name, $default, $hash, 'array');
+ }
+
+ static function getText($name, $default = '', $hash = 'default')
+ {
+ return (string)TDMCreateRequest::getVar($name, $default, $hash, 'string', TDMCREATE_REQUEST_ALLOWRAW);
+ }
+
+ /**
+ * Set a variabe in on of the request variables
+ *
+ * @access public
+ *
+ * @param string $name Name
+ * @param string $value Value
+ * @param string $hash Hash
+ * @param boolean $overwrite Boolean
+ *
+ * @return string Previous value
+ */
+ static function setVar($name, $value = null, $hash = 'method', $overwrite = true)
+ {
+ //If overwrite is true, makes sure the variable hasn't been set yet
+ if (!$overwrite && array_key_exists($name, $_REQUEST)) {
+ return $_REQUEST[$name];
+ }
+ // Get the request hash value
+ $hash = strtoupper($hash);
+ if ($hash === 'METHOD') {
+ $hash = strtoupper($_SERVER['REQUEST_METHOD']);
+ }
+ $previous = array_key_exists($name, $_REQUEST) ? $_REQUEST[$name] : null;
+ switch ($hash) {
+ case 'GET' :
+ $_GET[$name] = $value;
+ $_REQUEST[$name] = $value;
+ break;
+ case 'POST' :
+ $_POST[$name] = $value;
+ $_REQUEST[$name] = $value;
+ break;
+ case 'COOKIE' :
+ $_COOKIE[$name] = $value;
+ $_REQUEST[$name] = $value;
+ break;
+ case 'FILES' :
+ $_FILES[$name] = $value;
+ break;
+ case 'ENV' :
+ $_ENV['name'] = $value;
+ break;
+ case 'SERVER' :
+ $_SERVER['name'] = $value;
+ break;
+ }
+ return $previous;
+ }
+
+ /**
+ * Fetches and returns a request array.
+ * The default behaviour is fetching variables depending on the
+ * current request method: GET and HEAD will result in returning
+ * $_GET, POST and PUT will result in returning $_POST.
+ * You can force the source by setting the $hash parameter:
+ * post $_POST
+ * get $_GET
+ * files $_FILES
+ * cookie $_COOKIE
+ * env $_ENV
+ * server $_SERVER
+ * method via current $_SERVER['REQUEST_METHOD']
+ * default $_REQUEST
+ *
+ * @static
+ *
+ * @param string $hash to get (POST, GET, FILES, METHOD)
+ * @param int $mask Filter mask for the variable
+ *
+ * @return mixed Request hash
+ */
+ static function get($hash = 'default', $mask = 0)
+ {
+ $hash = strtoupper($hash);
+ if ($hash === 'METHOD') {
+ $hash = strtoupper($_SERVER['REQUEST_METHOD']);
+ }
+ switch ($hash) {
+ case 'GET' :
+ $input = $_GET;
+ break;
+ case 'POST' :
+ $input = $_POST;
+ break;
+ case 'FILES' :
+ $input = $_FILES;
+ break;
+ case 'COOKIE' :
+ $input = $_COOKIE;
+ break;
+ case 'ENV' :
+ $input = & $_ENV;
+ break;
+ case 'SERVER' :
+ $input = & $_SERVER;
+ break;
+ default:
+ $input = $_REQUEST;
+ break;
+ }
+ $result = TDMCreateRequest::_cleanVar($input, $mask);
+ // Handle magic quotes compatability
+ if (get_magic_quotes_gpc() && ($hash != 'FILES')) {
+ $result = TDMCreateRequest::_stripSlashesRecursive($result);
+ }
+ return $result;
+ }
+
+ /**
+ * Sets a request variable
+ *
+ * @param array $array An associative array of key-value pairs
+ * @param string $hash The request variable to set (POST, GET, FILES, METHOD)
+ * @param boolean $overwrite If true and an existing key is found, the value is overwritten, otherwise it is ingored
+ */
+ static function set($array, $hash = 'default', $overwrite = true)
+ {
+ foreach ($array as $key => $value) {
+ TDMCreateRequest::setVar($key, $value, $hash, $overwrite);
+ }
+ }
+
+ /**
+ * Cleans the request from script injection.
+ *
+ * @static
+ * @return void
+ */
+ static function clean()
+ {
+ TDMCreateRequest::_cleanArray($_FILES);
+ TDMCreateRequest::_cleanArray($_ENV);
+ TDMCreateRequest::_cleanArray($_GET);
+ TDMCreateRequest::_cleanArray($_POST);
+ TDMCreateRequest::_cleanArray($_COOKIE);
+ TDMCreateRequest::_cleanArray($_SERVER);
+ if (isset($_SESSION)) {
+ TDMCreateRequest::_cleanArray($_SESSION);
+ }
+ $REQUEST = $_REQUEST;
+ $GET = $_GET;
+ $POST = $_POST;
+ $COOKIE = $_COOKIE;
+ $FILES = $_FILES;
+ $ENV = $_ENV;
+ $SERVER = $_SERVER;
+ if (isset ($_SESSION)) {
+ $SESSION = $_SESSION;
+ }
+ foreach ($GLOBALS as $key => $value) {
+ if ($key != 'GLOBALS') {
+ unset($GLOBALS[$key]);
+ }
+ }
+ $_REQUEST = $REQUEST;
+ $_GET = $GET;
+ $_POST = $POST;
+ $_COOKIE = $COOKIE;
+ $_FILES = $FILES;
+ $_ENV = $ENV;
+ $_SERVER = $SERVER;
+ if (isset($SESSION)) {
+ $_SESSION = $SESSION;
+ }
+ }
+
+ /**
+ * Adds an array to the GLOBALS array and checks that the GLOBALS variable is not being attacked
+ *
+ * @access protected
+ *
+ * @param array $array Array to clean
+ * @param boolean $globalise True if the array is to be added to the GLOBALS
+ */
+ static function _cleanArray(&$array, $globalise = false)
+ {
+ static $banned = array('_files', '_env', '_get', '_post', '_cookie', '_server', '_session', 'globals');
+ foreach ($array as $key => $value) {
+ // PHP GLOBALS injection bug
+ $failed = in_array(strtolower($key), $banned);
+ // PHP Zend_Hash_Del_Key_Or_Index bug
+ $failed |= is_numeric($key);
+ if ($failed) {
+ exit('Illegal variable <strong>' . implode('</strong> or <strong>', $banned) . '</strong> passed to script.');
+ }
+ if ($globalise) {
+ $GLOBALS[$key] = $value;
+ }
+ }
+ }
+
+ /**
+ * Clean up an input variable.
+ *
+ * @param mixed $var The input variable.
+ * @param int $mask Filter bit mask. 1=no trim: If this flag is cleared and the
+ * input is a string, the string will have leading and trailing whitespace
+ * trimmed. 2=allow_raw: If set, no more filtering is performed, higher bits
+ * are ignored. 4=allow_html: HTML is allowed, but passed through a safe
+ * HTML filter first. If set, no more filtering is performed. If no bits
+ * other than the 1 bit is set, a strict filter is applied.
+ * @param string $type The variable type {@see JFilterInput::clean()}.
+ *
+ * @return string
+ */
+ static function _cleanVar($var, $mask = 0, $type = null)
+ {
+ // Static input filters for specific settings
+ static $noHtmlFilter = null;
+ static $safeHtmlFilter = null;
+ // If the no trim flag is not set, trim the variable
+ if (!($mask & 1) && is_string($var)) {
+ $var = trim($var);
+ }
+ // Now we handle input filtering
+ if ($mask & 2) {
+ // If the allow raw flag is set, do not modify the variable
+ } else if ($mask & 4) {
+ // If the allow html flag is set, apply a safe html filter to the variable
+ if (is_null($safeHtmlFilter)) {
+ $safeHtmlFilter = TDMCreateFilterInput::getInstance(null, null, 1, 1);
+ }
+ $var = $safeHtmlFilter->clean($var, $type);
+ } else {
+ // Since no allow flags were set, we will apply the most strict filter to the variable
+ if (is_null($noHtmlFilter)) {
+ $noHtmlFilter = TDMCreateFilterInput::getInstance( /* $tags, $attr, $tag_method, $attr_method, $xss_auto */);
+ }
+ $var = $noHtmlFilter->clean($var, $type);
+ }
+ return $var;
+ }
+
+ /**
+ * Strips slashes recursively on an array
+ *
+ * @access protected
+ *
+ * @param array $value Array of (nested arrays of) strings
+ *
+ * @return array|string The input array with stripshlashes applied to it
+ */
+ protected function _stripSlashesRecursive($value)
+ {
+ $value = is_array($value) ? array_map(array('TDMCreateRequest', '_stripSlashesRecursive'), $value) : stripslashes($value);
+ return $value;
+ }
+}
+
+/**
+ * TDMCreateInput is a class for filtering input from any data source
+ * Forked from the php input filter library by: Daniel Morris <da...@ro...>
+ * Original Contributors: Gianpaolo Racca, Ghislain Picard, Marco Wandschneider, Chris Tobin and Andrew Eddie.
+ *
+ * @author Louis Landry <lou...@jo...>
+ */
+class TDMCreateFilterInput
+{
+ var $tagsArray; // default = empty array
+ var $attrArray; // default = empty array
+ var $tagsMethod; // default = 0
+ var $attrMethod; // default = 0
+ var $xssAuto; // default = 1
+ var $tagBlacklist = array('applet', 'body', 'bgsound', 'base', 'basefont', 'embed', 'frame', 'frameset', 'head', 'html', 'id', 'iframe', 'ilayer', 'layer', 'link', 'meta', 'name', 'object', 'script', 'style', 'title', 'xml');
+ var $attrBlacklist = array('action', 'background', 'codebase', 'dynsrc', 'lowsrc'); // also will strip ALL event handlers
+ /**
+ * Constructor for inputFilter class. Only first parameter is required.
+ *
+ * @access protected
+ *
+ * @param array $tagsArray list of user-defined tags
+ * @param array $attrArray list of user-defined attributes
+ * @param int $tagsMethod WhiteList method = 0, BlackList method = 1
+ * @param int $attrMethod WhiteList method = 0, BlackList method = 1
+ * @param int $xssAuto Only auto clean essentials = 0, Allow clean blacklisted tags/attr = 1
+ */
+ public function __construct($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1)
+ {
+ // Make sure user defined arrays are in lowercase
+ $tagsArray = array_map('strtolower', (array)$tagsArray);
+ $attrArray = array_map('strtolower', (array)$attrArray);
+ // Assign member variables
+ $this->tagsArray = $tagsArray;
+ $this->attrArray = $attrArray;
+ $this->tagsMethod = $tagsMethod;
+ $this->attrMethod = $attrMethod;
+ $this->xssAuto = $xssAuto;
+ }
+
+ /**
+ * Returns a reference to an input filter object, only creating it if it doesn't already exist.
+ * This method must be invoked as:
+ * <pre> $filter = & TDMCreateFilterInput::getInstance();</pre>
+ *
+ * @static
+ *
+ * @param array $tagsArray list of user-defined tags
+ * @param array $attrArray list of user-defined attributes
+ * @param int $tagsMethod WhiteList method = 0, BlackList method = 1
+ * @param int $attrMethod WhiteList method = 0, BlackList method = 1
+ * @param int $xssAuto Only auto clean essentials = 0, Allow clean blacklisted tags/attr = 1
+ *
+ * @return object The TDMCreateFilterInput object.
+ * @since 1.5
+ */
+ public function & getInstance($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1)
+ {
+ static $instances;
+ $sig = md5(serialize(array($tagsArray, $attrArray, $tagsMethod, $attrMethod, $xssAuto)));
+ if (!isset ($instances)) {
+ $instances = array();
+ }
+ if (empty ($instances[$sig])) {
+ $instances[$sig] = new TDMCreateFilterInput($tagsArray, $attrArray, $tagsMethod, $attrMethod, $xssAuto);
+ }
+ return $instances[$sig];
+ }
+
+ /**
+ * Method to be called by another php script. Processes for XSS and
+ * specified bad code.
+ *
+ * @access public
+ *
+ * @param mixed $source Input string/array-of-string to be 'cleaned'
+ * @param string $type Return type for the variable (INT, FLOAT, BOOLEAN, WORD, ALNUM, CMD, BASE64, STRING, ARRAY, PATH, NONE)
+ *
+ * @return mixed 'Cleaned' version of input parameter
+ * @static
+ */
+ public function clean($source, $type = 'string')
+ {
+ // Handle the type constraint
+ switch (strtoupper($type)) {
+ case 'INT' :
+ case 'INTEGER' :
+ // Only use the first integer value
+ preg_match('/-?[0-9]+/', (string)$source, $matches);
+ $result = @ (int)$matches[0];
+ break;
+ case 'FLOAT' :
+ case 'DOUBLE' :
+ // Only use the first floating point value
+ preg_match('/-?[0-9]+(\.[0-9]+)?/', (string)$source, $matches);
+ $result = @ (float)$matches[0];
+ break;
+ case 'BOOL' :
+ case 'BOOLEAN' :
+ $result = (bool)$source;
+ break;
+ case 'WORD' :
+ $result = (string)preg_replace('/[^A-Z_]/i', '', $source);
+ break;
+ case 'ALNUM' :
+ $result = (string)preg_replace('/[^A-Z0-9]/i', '', $source);
+ break;
+ case 'CMD' :
+ $result = (string)preg_replace('/[^A-Z0-9_\.-]/i', '', $source);
+ $result = ltrim($result, '.');
+ break;
+ case 'BASE64' :
+ $result = (string)preg_replace('/[^A-Z0-9\/+=]/i', '', $source);
+ break;
+ case 'STRING' :
+ // Check for static usage and assign $filter the proper variable
+ if (isset($this) && is_a($this, 'TDMCreateFilterInput')) {
+ $filter =& $this;
+ } else {
+ $filter = TDMCreateFilterInput::getInstance();
+ }
+ $result = (string)$filter->_remove($filter->_decode((string)$source));
+ break;
+ case 'ARRAY' :
+ $result = (array)$source;
+ break;
+ case 'PATH' :
+ $pattern = '/^[A-Za-z0-9_-]+[A-Za-z0-9_\.-]*([\\\\\/][A-Za-z0-9_-]+[A-Za-z0-9_\.-]*)*$/';
+ preg_match($pattern, (string)$source, $matches);
+ $result = @ (string)$matches[0];
+ break;
+ case 'USERNAME' :
+ $result = (string)preg_replace('/[\x00-\x1F\x7F<>"\'%&]/', '', $source);
+ break;
+ default :
+ // Check for static usage and assign $filter the proper variable
+ if (is_object($this) && get_class($this) == 'TDMCreateFilterInput') {
+ $filter =& $this;
+ } else {
+ $filter = TDMCreateFilterInput::getInstance();
+ }
+ // Are we dealing with an array?
+ if (is_array($source)) {
+ foreach ($source as $key => $value) {
+ // filter element for XSS and other 'bad' code etc.
+ if (is_string($value)) {
+ $source[$key] = $filter->_remove($filter->_decode($value));
+ }
+ }
+ $result = $source;
+ } else {
+ // Or a string?
+ if (is_string($source) && !empty ($source)) {
+ // filter source for XSS and other 'bad' code etc.
+ $result = $filter->_remove($filter->_decode($source));
+ } else {
+ // Not an array or string.. return the passed parameter
+ $result = $source;
+ }
+ }
+ break;
+ }
+ return $result;
+ }
+
+ /**
+ * Function to determine if content...
[truncated message content] |