File: /home/nexper/public_html/67.225.167.226/public_html/es/components/com_facileforms/facileforms.php
<?php
/**
* FacileForms - A Joomla Forms Application
* @version 1.4.7
* @package FacileForms
* @copyright (C) 2004-2006 by Peter Koch
* @license Released under the terms of the GNU General Public License
*
* This is the main component entry point that will be called by joomla or mambo
* after after calling
*
* http://siteurl/index.php?option=com_facileforms......
* or
* http://siteurl/index2.php?option=com_facileforms......
*
* The first form is the normal call from frontend where the whole page is
* displayed by uting the template. The second form is a display of the plain
* form, wich is used to run in iframe or in popup windows.
**/
defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );
require_once(JPATH_SITE . '/administrator/components/com_facileforms/libraries/crosstec/classes/BFText.php');
require_once(JPATH_SITE . '/administrator/components/com_facileforms/libraries/crosstec/classes/BFTableElements.php');
require_once(JPATH_SITE . '/administrator/components/com_facileforms/libraries/crosstec/functions/helpers.php');
require_once(JPATH_SITE . '/administrator/components/com_facileforms/libraries/crosstec/constants.php');
$db = JFactory::getDBO();
$db->setQuery("Select id From #__plugins Where element = 'legacy' And published = 0");
$legacyResult = $db->loadObjectList();
// this include has to stay here and not inside the legacy check
require_once( JPATH_SITE . '/administrator/components/com_facileforms/classloader.php' );
if(count($legacyResult) == 1 && !isset($ff_runningAsModule)){
function include_all_once ($pattern) {
foreach (glob($pattern) as $file) {
if(!preg_match("/mysqli\.php$/",$file) && !preg_match("/mysql\.php$/",$file))
require_once $file;
}
}
include_all_once( JPATH_SITE . '/administrator/components/com_facileforms/legacyclasses/*.php' );
}
// declare global variables
global
$database, // joomla/mambo database object
$ff_version, // FacileForms version number
$ff_config, // FacileForms configuration object
$ff_mospath, // path to root of joomla/mambo
$ff_compath, // path to component frontend root
$ff_mossite, // url of the site root
$ff_request, // array of request parameters ff_param_*
$ff_processor, // current form procesor object
$ff_target; // index of form on current page
$database = JFactory::getDBO();
// declare local vars
// (1) only used in component space and not plain form)
$plainform = 0; // running as plain form by index2.php
$formid = null; // form id number
$formname = null; // form name
$task = 'view'; // either 'view' or 'submit'
$page = 1; // page to display
$inframe = 0; // run in iframe
$border = 0; // show a border around the form (1)
$align = 1; // 0-left 1-center 2-right (1)
$left = 0; // left margin in px (1)
$top = 0; // top margin in px (1)
$suffix = ''; // CSS class suffix
$parprv = ''; // private parameters
$runmode = 0; // run mode
$pagetitle = true; // set page title
$runmode = @JRequest::getVar('ff_runmode', $runmode);
// get paths
$ff_mospath = JPATH_SITE;
$ff_compath = $ff_mospath.'/components/com_facileforms';
// load config and initialize globals
require_once($ff_compath.'/facileforms.class.php');
$ff_config = new facileFormsConf();
initFacileForms();
// check for plain form
$plainform = basename($_SERVER['PHP_SELF'])=='index2.php';
// CROSSTEC: NOT NECESSARY ANYMORE
// open session if necessary
//if (!session_id()) session_start();
// create target id for this form and check if ff params are ment for this target
if (!$ff_target) $ff_target = 1; else $ff_target++;
$parent_target = @JRequest::getVar( 'ff_target', 1);
$my_ff_params = $plainform || $parent_target==$ff_target;
// clear list of request parameters
$ff_request = array();
if(!JRequest::getBool('showSecImage')) {
if ($runmode==_FF_RUNMODE_FRONTEND) {
// is this called by a module?
if (isset($ff_applic) && $ff_applic=='mod_facileforms') {
// get the module parameters
$formname = $params->get('ff_mod_name');
$page = intval($params->get('ff_mod_page', $page));
$inframe = intval($params->get('ff_mod_frame', $inframe));
$border = intval($params->get('ff_mod_border', $border));
$align = intval($params->get('ff_mod_align', $align));
$left = intval($params->get('ff_mod_left', $left));
$top = intval($params->get('ff_mod_top', $top));
$suffix = $params->get('ff_mod_suffix', '');
$parprv = $params->get('ff_mod_parprv', '');
addRequestParams($params->get('ff_mod_parpub', ''));
$pagetitle = false;
} else
// is this called with an Itemid?
if (JRequest::getVar( 'Itemid', 0) > 1) {
// get parameters from menu
$menu = new mosMenu($database);
$menu->load(JRequest::getVar( 'Itemid', 0));
$params = new JParameter($menu->params);
$formname = $params->get('ff_com_name');
$page = intval($params->get('ff_com_page', $page));
$inframe = intval($params->get('ff_com_frame', $inframe));
$border = intval($params->get('ff_com_border', $border));
$align = intval($params->get('ff_com_align', $align));
$left = intval($params->get('ff_com_left', $left));
$top = intval($params->get('ff_com_top', $top));
$suffix = $params->get('ff_com_suffix', '');
$parprv = $params->get('ff_com_parprv', '');
addRequestParams($params->get('ff_com_parpub', ''));
} // if
} // if
if ($my_ff_params) {
// allow overriding by url params
$formid = @JRequest::getVar( 'ff_form', $formid);
if ($formid==null)
$formname = @JRequest::getVar('ff_name', $formname);
else
$formname = null;
$task = @JRequest::getVar('ff_task', $task);
$page = @JRequest::getVar('ff_page', $page);
$inframe = @JRequest::getVar('ff_frame', $inframe);
$border = @JRequest::getVar('ff_border', $border);
$align1 = @JRequest::getVar('ff_align', -1);
if ($align1>=0) {
$align = @JRequest::getVar( 'ff_align', $align);
$left = 0;
if ($align>2) { $left = $align; $align = 3; }
} // if
$top = @JRequest::getVar('ff_top',$top);
$suffix = @JRequest::getVar('ff_suffix',$suffix);
} // if
// load form
$ok = true;
if (is_numeric($formid)) {
$database->setQuery(
"select * from #__facileforms_forms ".
"where id=$formid and published=1"
);
$forms = $database->loadObjectList();
if (count($forms) < 1) {
echo '[Form '.$formid.' not found!]';
$ok = false;
} else
$form = $forms[0];
} else
if ($formname != null) {
$database->setQuery(
"select * from #__facileforms_forms ".
"where name='$formname' and published=1 ".
"order by ordering, id"
);
$forms = $database->loadObjectList();
if (count($forms) < 1) {
echo '[Form '.$formname.' not found!]';
$ok = false;
} else
$form = $forms[0];
} else {
echo '[No form id or name provided!]';
$ok = false;
} // if
if ($ok) {
if ($pagetitle && $form->title != '') $mainframe->setPageTitle($form->title);
if ($form->name==$formname) addRequestParams($parprv);
if ($my_ff_params) {
reset($_REQUEST);
while (list($prop, $val) = each($_REQUEST))
if (!is_array($val) && substr($prop,0,9)=='ff_param_')
$ff_request[$prop] = $val;
} // if
if ($inframe && !$plainform) {
// open frame and detach processing
$divstyle = 'width:100%;';
switch ($align) {
case 0: $divstyle .= 'text-align:left;'; break;
case 1: $divstyle .= 'text-align:center;'; break;
case 2: $divstyle .= 'text-align:right;'; break;
case 3: if ($left > 0) $divstyle .= 'padding-left:'.$left.'px;'; break;
default: break;
} // switch
if ($top > 0) $divstyle .= 'padding-top:'.$top.'px;';
$framewidth = 'width="'.$form->width.($form->widthmode?'%" ':'" ');
$frameheight = '';
if (!$form->heightmode) $frameheight = 'height="'.$form->height.'" ';
$url = $ff_mossite.'/index2.php'
.'?option=com_facileforms'
.'&Itemid='.((JRequest::getVar( 'Itemid', 0) > 0 && $Itemid < 99999999) ? $Itemid : 1)
.'&ff_form='.$form->id
.'&ff_frame=1';
if ($page != 1) $url .= '&ff_page='.$page;
if ($border) $url .= '&ff_border=1';
if ($parent_target > 1) $url .= '&ff_target='.$parent_target;
reset($ff_request);
while (list($prop, $val) = each($ff_request)) $url .= '&'.$prop.'='.urlencode($val);
$params = 'id="ff_frame'.$form->id.'" '.
'src="'.$url.'" '.
$framewidth.
$frameheight.
'frameborder="'.$border.'" '.
'allowtransparency="true" '.
'scrolling="no" ';
// DO NOT REMOVE OR CHANGE OR OTHERWISE MAKE INVISIBLE THE FOLLOWING COPYRIGHT MESSAGE
// FAILURE TO COMPLY IS A DIRECT VIOLATION OF THE GNU GENERAL PUBLIC LICENSE
// http://www.gnu.org/copyleft/gpl.html
echo "\n<!-- BreezingForms V".$ff_version." Copyright(c) 2008 by Markus Bopp | FacileForms Copyright 2004-2006 by Peter Koch, Chur, Switzerland. All rights reserved. -->\n";
// END OF COPYRIGHT
echo '<div style="'.$divstyle.'">'."\n".
"<iframe ".$params.">\n".
"<p>Sorry, your browser cannot display frames!</p>\n".
"</iframe>\n".
"</div>\n";
} else {
// process inline
$myUser = JFactory::getUser();
$database->setQuery("select id from #__users where lower(username)=lower('".$myUser->get('username','')."')");
$id = $database->loadResult();
if ($id) $myUser->get('id',-1);
require_once($ff_compath.'/facileforms.process.php');
if ($task == 'view') {
$div1style = '';
$div2style = '';
$fullwidth = $form->widthmode && $form->width>=100;
if ($form->widthmode) {
$div1style .= 'min-width:10px;';
$div2style .= 'min-width:10px;';
} // if
$div2style .= 'width:'.($fullwidth?'100':$form->width).($form->widthmode?'%':'px').';';
if (!$form->heightmode) $div2style .= 'height:'.$form->height.'px;';
if ($plainform) {
$div2style .= 'position:absolute;top:0px;left:0px;margin:0px;';
} else {
$div1style .= 'width:100%;';
$div2style .= 'position:relative;overflow:hidden;';
if ($border) $div2style .= 'border:1px solid black;';
if (!$fullwidth) {
switch ($align) {
case 1:
$div1style .= 'text-align:center;';
$div2style .= 'text-align:left;margin-left:auto;margin-right:auto;';
break;
case 2:
$div1style .= 'text-align:right;';
$div2style .= 'text-align:left;margin-left:auto;margin-right:0px;';
break;
case 3:
if ($left > 0) $div2style .= 'margin-left:'.$left.'px;';
default:
break;
} // switch
} // if
if ($top > 0) $div2style .= 'margin-top:'.$top.'px;';
} // if
ob_start();
// DO NOT REMOVE OR CHANGE OR OTHERWISE MAKE INVISIBLE THE FOLLOWING COPYRIGHT MESSAGE
// FAILURE TO COMPLY IS A DIRECT VIOLATION OF THE GNU GENERAL PUBLIC LICENSE
// http://www.gnu.org/copyleft/gpl.html
echo "\n<!-- BreezingForms V".$ff_version." Copyright(c) 2008 by Markus Bopp | FacileForms Copyright 2004-2006 by Peter Koch, Chur, Switzerland. All rights reserved. -->\n";
// END OF COPYRIGHT
if (!$plainform) echo '<div style="'.$div1style.'">'."\n";
echo '<div style="'.$div2style.'">'."\n";
} // if task = view
if ($left > 3) $align = $left;
$ff_processor = new HTML_facileFormsProcessor(
$runmode, $inframe, $form->id, $page, $border,
$align, $top, $ff_target, $suffix
);
if ($task == 'submit')
$ff_processor->submit();
else {
$ff_processor->view();
echo "</div>\n";
if (!$plainform) echo "</div>\n";
if ($runmode==_FF_RUNMODE_PREVIEW) {
$mouseOvers = '';
$draggableIds = '';
$draggableSize = count($ff_processor->draggableDivIds);
for($x = 0; $x < $draggableSize;$x++){
if($x+1 < $draggableSize){
$draggableIds .= '"'.$ff_processor->draggableDivIds[$x].'",';
} else {
$draggableIds .= '"'.$ff_processor->draggableDivIds[$x].'"';
}
$mouseOvers .= '
if(document.getElementById("'.$ff_processor->draggableDivIds[$x].'")){
var '.$ff_processor->draggableDivIds[$x].'_paddingRTmp;
var '.$ff_processor->draggableDivIds[$x].'_paddingLTmp;
var '.$ff_processor->draggableDivIds[$x].'_colorTmp;
document.getElementById("'.$ff_processor->draggableDivIds[$x].'").onmouseover =
function(e){
'.$ff_processor->draggableDivIds[$x].'_colorTmp = document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.backgroundColor;
'.$ff_processor->draggableDivIds[$x].'_paddingRTmp = document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.paddingRight;
'.$ff_processor->draggableDivIds[$x].'_paddingLTmp = document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.paddingLeft;
document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.paddingRight = "10px";
document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.paddingLeft = "10px";
document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.backgroundColor = "red";
};
document.getElementById("'.$ff_processor->draggableDivIds[$x].'").onmouseout =
function(e){
document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.paddingRight= '.$ff_processor->draggableDivIds[$x].'_paddingRTmp;
document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.paddingLight= '.$ff_processor->draggableDivIds[$x].'_paddingLTmp;
document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.backgroundColor = '.$ff_processor->draggableDivIds[$x].'_colorTmp;
};
}
';
}
echo '
<script>
'.$mouseOvers.'
SET_DHTML('.$draggableIds.');
function my_DragFunc(){
parent.document.adminForm.savepos.disabled = false;
// TODO: when undo is enabled, drag and drop is not possible. needs to be solved
//parent.document.adminForm.restpos.disabled = false;
}
function my_DropFunc(){
parent.document.getElementById("ff_itemPositions").value = "";
for(var i = 0; i < parent.ff_coords.length;i++){
eval("var cb = parent.document.adminForm.cb"+i+";");
var itemComma = "";
if(i+1 < parent.ff_coords.length){
itemComma = ",";
} else {
itemComma = "";
}
parent.document.getElementById("ff_itemPositions").value +=
cb.value+":"+document.getElementById("ff_div"+cb.value).style.zIndex+itemComma;
}
for(var i = 0; i < parent.ff_coords.length;i++){
eval("var cb = parent.document.adminForm.cb"+i+";");
if(document.getElementById("ff_div"+cb.value) == document.getElementById(dd.obj.id)){
parent.ff_coords[i][2] = dd.obj.x;
parent.ff_coords[i][5] = dd.obj.y;
break;
}
}
}
</script>';
}
ob_end_flush();
} // if
} // if
} // if
} else {
header("Content-Type: image/png");
$captchaDir = JPATH_SITE . '/administrator/components/com_facileforms/captchas';
if(file_exists($captchaDir) && is_dir($captchaDir)){
$sizeAvailableCaptchas = count(glob("$captchaDir/*.png"));
$sizeAvailableCaptchas = $sizeAvailableCaptchas > mt_getrandmax() ? mt_getrandmax() : $sizeAvailableCaptchas;
mt_srand();
$captchaBgNum = mt_rand(0, $sizeAvailableCaptchas-1);
$i = 0;
$handle = opendir($captchaDir);
while (false!==($file = readdir($handle))) {
if ($file != "." && $file != ".." && strtolower($file) != ".svn" && strtolower($file) != ".cvs") {
$pathinfo = pathinfo($file);
$extension = $pathinfo['extension'];
if(strtolower($extension) == 'png'){
if($captchaBgNum == $i){
$bbox = imagettfbbox (14, 0, $captchaDir . '/fontfile.ttf', JFactory::getSession()->get('ff_seccode'));
//print_r($bbox);
$textWidth = $bbox[2] - $bbox[0];
$textHeight = $bbox[3] - $bbox[5];
$imgHandle = imagecreatefrompng($captchaDir . '/' . $file);
imagettftext($imgHandle, 14, 0, (imagesx($imgHandle)-$textWidth)/2, (imagesy($imgHandle)+$textHeight)/2, '0x000000', $captchaDir . '/fontfile.ttf', JFactory::getSession()->get('ff_seccode'));
imagepng($imgHandle);
imagedestroy($imgHandle);
break;
}
$i++;
}
}
}
closedir($handle);
}
exit;
}
?>