PageRenderTime 62ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 0ms

/components/com_breezingforms/breezingforms.php

https://bitbucket.org/izubizarreta/https-bitbucket.org-bityvip
PHP | 1552 lines | 491 code | 68 blank | 993 comment | 160 complexity | 3967ac3673f3bee75d141749f29cdefb MD5 | raw file
Possible License(s): LGPL-3.0, LGPL-2.0, JSON, GPL-2.0, BSD-3-Clause, LGPL-2.1, MIT

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * BreezingForms - A Joomla Forms Application
  4. * @version 1.8
  5. * @package BreezingForms
  6. * @copyright (C) 2008-2012 by Markus Bopp
  7. * @license Released under the terms of the GNU General Public License
  8. *
  9. * This is the main component entry point that will be called by joomla or mambo
  10. * after after calling
  11. *
  12. * http://siteurl/index.php?option=com_breezingforms......
  13. * The first form is the normal call from frontend where the whole page is
  14. * displayed by uting the template. The second form is a display of the plain
  15. * form, wich is used to run in iframe or in popup windows.
  16. **/
  17. defined( '_JEXEC' ) or die( 'Direct Access to this location is not allowed.' );
  18. if(!defined('DS')){
  19. define('DS', DIRECTORY_SEPARATOR);
  20. }
  21. require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_breezingforms'.DS.'libraries'.DS.'crosstec'.DS.'classes'.DS.'BFJoomlaConfig.php');
  22. $mainframe = JFactory::getApplication();
  23. $cache = JFactory::getCache();
  24. $cache->setCaching(false);
  25. jimport('joomla.filesystem.file');
  26. require_once(JPATH_SITE . '/administrator/components/com_breezingforms/libraries/crosstec/classes/BFText.php');
  27. require_once(JPATH_SITE . '/administrator/components/com_breezingforms/libraries/crosstec/classes/BFTableElements.php');
  28. require_once(JPATH_SITE . '/administrator/components/com_breezingforms/libraries/crosstec/functions/helpers.php');
  29. require_once(JPATH_SITE . '/administrator/components/com_breezingforms/libraries/crosstec/constants.php');
  30. // declare global variables
  31. global
  32. $database, // joomla/mambo database object
  33. $ff_version, // FacileForms version number
  34. $ff_config, // FacileForms configuration object
  35. $ff_mospath, // path to root of joomla/mambo
  36. $ff_compath, // path to component frontend root
  37. $ff_mossite, // url of the site root
  38. $ff_request, // array of request parameters ff_param_*
  39. $ff_processor, // current form procesor object
  40. $ff_target; // index of form on current page
  41. $database = $db = JFactory::getDBO();
  42. // declare local vars
  43. // (1) only used in component space and not plain form)
  44. $plainform = 0; // running as plain form by index.php?tmpl=component
  45. $formid = null; // form id number
  46. $formname = null; // form name
  47. $task = 'view'; // either 'view' or 'submit'
  48. $page = 1; // page to display
  49. $inframe = 0; // run in iframe
  50. $border = 0; // show a border around the form (1)
  51. $align = 1; // 0-left 1-center 2-right (1)
  52. $left = 0; // left margin in px (1)
  53. $top = 0; // top margin in px (1)
  54. $suffix = ''; // CSS class suffix
  55. $parprv = ''; // private parameters
  56. $runmode = 0; // run mode
  57. $pagetitle = true; // set page title
  58. $editable = 0;
  59. $editable_override = 0;
  60. $menu_item_title = '';
  61. $menu_item_show_page_heading = 0;
  62. $menu_item_page_heading = '';
  63. $menu_item_meta_description = '';
  64. $menu_item_meta_keywords = '';
  65. $menu_item_robots = '';
  66. if(!isset($xModuleId)){
  67. $xModuleId = 0;
  68. }
  69. if(!isset($ff_applic)){
  70. $ff_applic = '';
  71. }
  72. $runmode = @JRequest::getVar('ff_runmode', $runmode);
  73. // get paths
  74. $ff_mospath = JPATH_SITE;
  75. $ff_compath = $ff_mospath.'/components/com_breezingforms';
  76. // load config and initialize globals
  77. require_once($ff_compath.'/facileforms.class.php');
  78. $ff_config = new facileFormsConf();
  79. initFacileForms();
  80. // check for plain form
  81. $plainform = JRequest::getWord('tmpl','') == 'component';
  82. // create target id for this form and check if ff params are ment for this target
  83. if (!$ff_target) $ff_target = 1; else $ff_target++;
  84. $parent_target = @JRequest::getVar( 'ff_target', 1);
  85. $my_ff_params = $plainform || $parent_target==$ff_target;
  86. // clear list of request parameters
  87. $ff_request = array();
  88. if(
  89. !JRequest::getBool('showSecImage') &&
  90. !JRequest::getBool('bfCaptcha') &&
  91. !JRequest::getBool('bfReCaptcha') &&
  92. !JRequest::getBool('checkCaptcha') &&
  93. !JRequest::getBool('confirmPayPal') &&
  94. !JRequest::getBool('confirmPayPalIpn') &&
  95. !JRequest::getBool('paypalDownload') &&
  96. !JRequest::getBool('showPayPalConnectMsg') &&
  97. !JRequest::getBool('successSofortueberweisung') &&
  98. !JRequest::getBool('confirmSofortueberweisung') &&
  99. !JRequest::getBool('sofortueberweisungDownload') &&
  100. !JRequest::getBool('flashUpload')
  101. ) {
  102. JRequest::setVar('format', 'html');
  103. if ($runmode==_FF_RUNMODE_FRONTEND) {
  104. // is this called by a module?
  105. if (isset($ff_applic) && $ff_applic=='mod_facileforms') {
  106. // get the module parameters
  107. $formname = $params->get('ff_mod_name');
  108. $page = intval($params->get('ff_mod_page', $page));
  109. $inframe = intval($params->get('ff_mod_frame', $inframe));
  110. $border = intval($params->get('ff_mod_border', $border));
  111. $align = intval($params->get('ff_mod_align', $align));
  112. $left = intval($params->get('ff_mod_left', $left));
  113. $top = intval($params->get('ff_mod_top', $top));
  114. $suffix = $params->get('ff_mod_suffix', '');
  115. $parprv = $params->get('ff_mod_parprv', '');
  116. addRequestParams($params->get('ff_mod_parpub', ''));
  117. $pagetitle = false;
  118. JFactory::getSession()->set('ff_editableMod'. $xModuleId . $formname, intval($params->get('ff_mod_editable', $editable)));
  119. JFactory::getSession()->set('ff_editable_overrideMod'. $xModuleId . $formname, intval($params->get('ff_mod_editable_override', $editable_override)));
  120. } else if (isset($ff_applic) && $ff_applic=='plg_facileforms') {
  121. $formname = JRequest::getVar('ff_name','');
  122. $page = JRequest::getVar('ff_page',1);
  123. $inframe = JRequest::getVar('ff_frame','');
  124. $border = JRequest::getVar('ff_border','');
  125. $align = JRequest::getVar('ff_border','');
  126. $editable = intval($plg_editable);
  127. $editable_override = intval($plg_editable_override);
  128. $left = '';
  129. $top = '';
  130. $suffix = JRequest::getVar('ff_suffix','');
  131. $parprv = '';
  132. addRequestParams('');
  133. } else {
  134. // is this called with an Itemid?
  135. if (JRequest::getInt( 'Itemid', 0) > 1 && JRequest::getVar('ff_applic','') != 'mod_facileforms' && JRequest::getVar('ff_applic','') != 'plg_facileforms') {
  136. jimport('joomla.version');
  137. $version = new JVersion();
  138. if(version_compare($version->getShortVersion(), '3.0', '>=')){
  139. $menu = JSite::getMenu()->getActive();
  140. $params = $menu->params;
  141. }else{
  142. // get parameters from menu
  143. $menu = JTable::getInstance('menu');
  144. $menu->load(JRequest::getInt( 'Itemid', 0));
  145. jimport( 'joomla.html.parameter' );
  146. $params = new JParameter($menu->params);
  147. }
  148. $menu_item_title = $params->get('page_title','');
  149. $menu_item_show_page_heading = $params->get('show_page_heading',0);
  150. $menu_item_page_heading = $params->get('page_heading','');
  151. $menu_item_meta_description = $params->get('menu-meta_description','');
  152. $menu_item_meta_keywords = $params->get('menu-meta_keywords','');
  153. $menu_item_robots = $params->get('robots','');
  154. if($menu_item_meta_description){
  155. JFactory::getDocument()->setMetaData('description', $menu_item_meta_description);
  156. }
  157. if($menu_item_meta_keywords){
  158. JFactory::getDocument()->setMetaData('keywords', $menu_item_meta_keywords);
  159. }
  160. if($menu_item_robots){
  161. JFactory::getDocument()->setMetaData('robots', $menu_item_robots);
  162. }
  163. $formname = $params->get('ff_com_name');
  164. $page = intval($params->get('ff_com_page', $page));
  165. $inframe = intval($params->get('ff_com_frame', $inframe));
  166. $border = intval($params->get('ff_com_border', $border));
  167. $align = intval($params->get('ff_com_align', $align));
  168. $left = intval($params->get('ff_com_left', $left));
  169. $top = intval($params->get('ff_com_top', $top));
  170. $editable = intval($params->get('ff_com_editable', $editable));
  171. $editable_override = intval($params->get('ff_com_editable_override', $editable_override));
  172. $suffix = $params->get('ff_com_suffix', '');
  173. $parprv = $params->get('ff_com_parprv', '');
  174. addRequestParams($params->get('ff_com_parpub', ''));
  175. } // if
  176. }
  177. } // if
  178. if ($my_ff_params) {
  179. // allow overriding by url params
  180. $formid = @JRequest::getVar( 'ff_form', $formid);
  181. if ($formid==null)
  182. $formname = @JRequest::getVar('ff_name', $formname);
  183. else
  184. $formname = null;
  185. $task = @JRequest::getVar('ff_task', $task);
  186. $page = @JRequest::getVar('ff_page', $page);
  187. $inframe = @JRequest::getVar('ff_frame', $inframe);
  188. $border = @JRequest::getVar('ff_border', $border);
  189. $align1 = @JRequest::getVar('ff_align', -1);
  190. if ($align1>=0) {
  191. $align = @JRequest::getVar( 'ff_align', $align);
  192. $left = 0;
  193. if ($align>2) { $left = $align; $align = 3; }
  194. } // if
  195. $top = @JRequest::getVar('ff_top',$top);
  196. $suffix = @JRequest::getVar('ff_suffix',$suffix);
  197. }
  198. // load form
  199. $ok = true;
  200. if (is_numeric($formid)) {
  201. $database->setQuery(
  202. "select * from #__facileforms_forms ".
  203. "where id=$formid and published=1"
  204. );
  205. $forms = $database->loadObjectList();
  206. if (count($forms) < 1) {
  207. echo '[Form '.$formid.' not found!]';
  208. $ok = false;
  209. } else
  210. $form = $forms[0];
  211. } else
  212. if ($formname != null) {
  213. $database->setQuery(
  214. "select * from #__facileforms_forms ".
  215. "where name=".$database->Quote($formname)." and published=1 ".
  216. "order by ordering, id"
  217. );
  218. $forms = $database->loadObjectList();
  219. if (count($forms) < 1) {
  220. echo '[Form '.$formname.' not found!]';
  221. $ok = false;
  222. } else
  223. $form = $forms[0];
  224. } else {
  225. echo '[No form id or name provided!]';
  226. $ok = false;
  227. } // if
  228. if ($ok) {
  229. // set by plugin
  230. if(isset($_SESSION['ff_editablePlg'.$form->name]) && $_SESSION['ff_editablePlg'.JRequest::getInt('ff_contentid',0) . $form->name] != 0 && ( JRequest::getVar('ff_applic')=='plg_facileforms' || ( isset($ff_applic) && $ff_applic == 'plg_facileforms' )) ){
  231. $editable = $_SESSION['ff_editablePlg'.JRequest::getInt('ff_contentid',0) . $form->name];
  232. }
  233. // set by plugin
  234. if(isset($_SESSION['ff_editable_overridePlg'.$form->name]) && $_SESSION['ff_editable_overridePlg'.JRequest::getInt('ff_contentid',0) . $form->name] != 0 && ( JRequest::getVar('ff_applic')=='plg_facileforms' || ( isset($ff_applic) && $ff_applic == 'plg_facileforms' )) ){
  235. $editable_override = $_SESSION['ff_editable_overridePlg'.JRequest::getInt('ff_contentid',0) . $form->name];
  236. }
  237. // set by module
  238. if(( JRequest::getVar('ff_applic')=='mod_facileforms' || ( isset($ff_applic) && $ff_applic == 'mod_facileforms' )) ){
  239. if(JFactory::getSession()->get('ff_editableMod'. $xModuleId . $form->name, 0) != 0){
  240. $editable = JFactory::getSession()->get('ff_editableMod'.$xModuleId . $form->name, 0);
  241. } else if(JFactory::getSession()->get('ff_editableMod'. JRequest::getInt('ff_module_id',0) . $form->name, 0) != 0){
  242. $editable = JFactory::getSession()->get('ff_editableMod'.JRequest::getInt('ff_module_id',0) . $form->name, 0);
  243. }
  244. }
  245. // set by module
  246. if(( JRequest::getVar('ff_applic')=='mod_facileforms' || ( isset($ff_applic) && $ff_applic == 'mod_facileforms' )) ){
  247. if(JFactory::getSession()->get('ff_editable_overrideMod'. $xModuleId . $form->name, 0) != 0){
  248. $editable_override = JFactory::getSession()->get('ff_editable_overrideMod'.$xModuleId . $form->name, 0);
  249. } else if(JFactory::getSession()->get('ff_editable_overrideMod'. JRequest::getInt('ff_module_id',0) . $form->name, 0) != 0){
  250. $editable_override = JFactory::getSession()->get('ff_editable_overrideMod'.JRequest::getInt('ff_module_id',0) . $form->name, 0);
  251. }
  252. }
  253. if ( (!isset($ff_applic) || $ff_applic!='plg_facileforms') && $pagetitle && $form->title != '' && !(JRequest::getInt('cb_form_id',0) || JRequest::getCmd('cb_record_id','') )) { if($menu_item_title != '') { JFactory::getDocument()->setTitle($menu_item_title); } else { JFactory::getDocument()->setTitle($form->title); } }
  254. if ($form->name==$formname) addRequestParams($parprv);
  255. if ($my_ff_params) {
  256. reset($_REQUEST);
  257. while (list($prop, $val) = each($_REQUEST))
  258. if (!is_array($val) && substr($prop,0,9)=='ff_param_')
  259. $ff_request[$prop] = $val;
  260. } // if
  261. if ($inframe && !$plainform) {
  262. // open frame and detach processing
  263. $divstyle = 'width:100%;';
  264. switch ($align) {
  265. case 0: $divstyle .= 'text-align:left;'; break;
  266. case 1: $divstyle .= 'text-align:center;'; break;
  267. case 2: $divstyle .= 'text-align:right;'; break;
  268. case 3: if ($left > 0) $divstyle .= 'padding-left:'.$left.'px;'; break;
  269. default: break;
  270. } // switch
  271. if ($top > 0) $divstyle .= 'padding-top:'.$top.'px;';
  272. $framewidth = 'width="'.$form->width.($form->widthmode?'%" ':'" ');
  273. $frameheight = '';
  274. if (!$form->heightmode) $frameheight = 'height="'.$form->height.'" ';
  275. $url = $ff_mossite.'/index.php'
  276. .'?option=com_breezingforms'
  277. .'&amp;Itemid='.((JRequest::getInt( 'Itemid', 0) > 0 && JRequest::getInt( 'Itemid', 0) < 99999999) ? JRequest::getInt( 'Itemid', 0) : 0)
  278. .'&amp;ff_form='.$form->id
  279. .'&amp;ff_applic='.$ff_applic
  280. .'&amp;ff_module_id='.$xModuleId
  281. .'&amp;format=html'
  282. .'&amp;tmpl=component'
  283. .'&amp;ff_frame=1';
  284. if ($page != 1) $url .= '&amp;ff_page='.$page;
  285. if ($border) $url .= '&amp;ff_border=1';
  286. if ($parent_target > 1) $url .= '&amp;ff_target='.$parent_target;
  287. reset($ff_request);
  288. while (list($prop, $val) = each($ff_request)) $url .= '&amp;'.$prop.'='.urlencode($val);
  289. $params = 'id="ff_frame'.$form->id.'" '.
  290. 'src="'.$url.'" '.
  291. $framewidth.
  292. $frameheight.
  293. 'frameborder="'.$border.'" '.
  294. 'allowtransparency="true" '.
  295. 'scrolling="no" ';
  296. // DO NOT REMOVE OR CHANGE OR OTHERWISE MAKE INVISIBLE THE FOLLOWING COPYRIGHT MESSAGE
  297. // FAILURE TO COMPLY IS A DIRECT VIOLATION OF THE GNU GENERAL PUBLIC LICENSE
  298. // http://www.gnu.org/copyleft/gpl.html
  299. echo "\n<!-- BreezingForms V".$ff_version." Copyright(c) 2008-2009 by Markus Bopp | FacileForms Copyright 2004-2006 by Peter Koch, Chur, Switzerland. All rights reserved. -->\n";
  300. // END OF COPYRIGHT
  301. echo '<div class="bfClearfix" style="'.$divstyle.'">'."\n".
  302. "<iframe ".$params.">\n".
  303. "<p>Sorry, your browser cannot display frames!</p>\n".
  304. "</iframe>\n".
  305. "</div>\n";
  306. } else {
  307. if($menu_item_show_page_heading){
  308. echo '<h1>'.( $menu_item_title != '' ? ( $menu_item_page_heading != '' ? $menu_item_page_heading : $menu_item_title ) : $form->title ).'</h1>'."\n";
  309. }
  310. // process inline
  311. $myUser = JFactory::getUser();
  312. $database->setQuery("select id from #__users where lower(username)=lower('".$myUser->get('username','')."')");
  313. $id = $database->loadResult();
  314. if ($id) $myUser->get('id',-1);
  315. require_once($ff_compath.'/facileforms.process.php');
  316. if ($task == 'view') {
  317. $div1style = '';
  318. $div2style = '';
  319. if ($form->template_code == '') {
  320. $fullwidth = $form->widthmode && $form->width>=100;
  321. if ($form->widthmode) {
  322. $div1style .= 'min-width:10px;';
  323. $div2style .= 'min-width:10px;';
  324. } // if
  325. $div2style .= 'width:'.($fullwidth?'100':$form->width).($form->widthmode?'%':'px').';';
  326. if (!$form->heightmode) $div2style .= 'height:'.$form->height.'px;';
  327. if ($plainform) {
  328. $div2style .= 'position:absolute;top:0px;left:0px;margin:0px;';
  329. } else {
  330. $div1style .= 'width:100%;';
  331. $div2style .= 'position:relative;overflow:hidden;';
  332. if ($border) $div2style .= 'border:1px solid black;';
  333. if (!$fullwidth) {
  334. switch ($align) {
  335. case 1:
  336. $div1style .= 'text-align:center;';
  337. $div2style .= 'text-align:left;margin-left:auto;margin-right:auto;';
  338. break;
  339. case 2:
  340. $div1style .= 'text-align:right;';
  341. $div2style .= 'text-align:left;margin-left:auto;margin-right:0px;';
  342. break;
  343. case 3:
  344. if ($left > 0) $div2style .= 'margin-left:'.$left.'px;';
  345. default:
  346. break;
  347. } // switch
  348. } // if
  349. if ($top > 0) $div2style .= 'margin-top:'.$top.'px;';
  350. } // if
  351. }
  352. ob_start();
  353. // DO NOT REMOVE OR CHANGE OR OTHERWISE MAKE INVISIBLE THE FOLLOWING COPYRIGHT MESSAGE
  354. // FAILURE TO COMPLY IS A DIRECT VIOLATION OF THE GNU GENERAL PUBLIC LICENSE
  355. // http://www.gnu.org/copyleft/gpl.html
  356. echo "\n<!-- BreezingForms V".$ff_version." Copyright(c) 2008-2009 by Markus Bopp | FacileForms Copyright 2004-2006 by Peter Koch, Chur, Switzerland. All rights reserved. -->\n";
  357. // END OF COPYRIGHT
  358. $bfStyle = '';
  359. if ($form->template_code == '') {
  360. $bfStyle = ' style="'.$div1style.'"';
  361. }
  362. if (!$plainform) echo '<div class="bfClearfix"'.$bfStyle.'>'."\n";
  363. if(trim($form->template_code_processed) == ''){
  364. echo '<div class="bfClearfix" style="'.$div2style.'">'."\n";
  365. }
  366. } // if task = view
  367. if ($left > 3) $align = $left;
  368. // remove temporary flash upload files if any
  369. $sourcePath = JPATH_SITE . '/components/com_breezingforms/uploads/';
  370. if (@file_exists($sourcePath) && @is_readable($sourcePath) && @is_dir($sourcePath) && $handle = @opendir($sourcePath)) {
  371. while (false !== ($file = @readdir($handle))) {
  372. if($file!="." && $file!=".."){
  373. $parts = explode('_', $file);
  374. if(count($parts)>=5){
  375. if($parts[count($parts)-1] == 'flashtmp'){
  376. if (@JFile::exists($sourcePath.$file) && @is_readable($sourcePath.$file)){
  377. $fileCreationTime = @filectime($sourcePath.$file);
  378. $fileAge = time() - $fileCreationTime;
  379. if($fileAge >= 3600){
  380. @JFile::delete($sourcePath.$file);
  381. }
  382. }
  383. }
  384. }
  385. }
  386. }
  387. @closedir($handle);
  388. }
  389. // purge payment cache
  390. $sourcePath = JPATH_SITE . '/media/breezingforms/payment_cache/';
  391. if (@file_exists($sourcePath) && @is_readable($sourcePath) && @is_dir($sourcePath) && $handle = @opendir($sourcePath)) {
  392. while (false !== ($file = @readdir($handle))) {
  393. if($file!="." && $file!="..") {
  394. $parts = explode('_', $file);
  395. if(count($parts)==4) {
  396. if (@JFile::exists($sourcePath.$file) && @is_readable($sourcePath.$file)) {
  397. $fileCreationTime = @filectime($sourcePath.$file);
  398. $fileAge = time() - $fileCreationTime;
  399. if($fileAge >= 3600) {
  400. @JFile::delete($sourcePath.$file);
  401. }
  402. }
  403. }
  404. }
  405. }
  406. @closedir($handle);
  407. }
  408. $ff_processor = new HTML_facileFormsProcessor(
  409. $runmode, $inframe, $form->id, $page, $border,
  410. $align, $top, $ff_target, $suffix, $editable, $editable_override
  411. );
  412. if ($task == 'submit'){
  413. $ff_processor->submit();
  414. } else {
  415. $ff_processor->view();
  416. if(trim($form->template_code_processed) == ''){
  417. echo "</div>\n";
  418. }
  419. if(trim($form->template_code_processed) == 'QuickMode') echo '<br/><br/><div align="center"><a href="http://crosstec.de/en/extensions/joomla-forms-download.html" target="_blank">Joomla!&reg; Forms Download</a></div>';
  420. if (!$plainform) echo "</div>\n";
  421. if ($runmode==_FF_RUNMODE_PREVIEW) {
  422. $mouseOvers = '';
  423. $draggableIds = '';
  424. $draggableSize = count($ff_processor->draggableDivIds);
  425. for($x = 0; $x < $draggableSize;$x++){
  426. if($x+1 < $draggableSize){
  427. $draggableIds .= '"'.$ff_processor->draggableDivIds[$x].'",';
  428. } else {
  429. $draggableIds .= '"'.$ff_processor->draggableDivIds[$x].'"';
  430. }
  431. $mouseOvers .= '
  432. var '.$ff_processor->draggableDivIds[$x].'_paddingRTmp;
  433. var '.$ff_processor->draggableDivIds[$x].'_paddingLTmp;
  434. var '.$ff_processor->draggableDivIds[$x].'_colorTmp;
  435. '.$ff_processor->draggableDivIds[$x].'_colorTmp = document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.backgroundColor;
  436. '.$ff_processor->draggableDivIds[$x].'_paddingRTmp = document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.paddingRight;
  437. '.$ff_processor->draggableDivIds[$x].'_paddingLTmp = document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.paddingLeft;
  438. '.$ff_processor->draggableDivIds[$x].'_paddingTTmp = document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.paddingTop;
  439. '.$ff_processor->draggableDivIds[$x].'_paddingBTmp = document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.paddingBottom;
  440. function bfItemOver_'.$ff_processor->draggableDivIds[$x].'(e){
  441. if(document.getElementById("'.$ff_processor->draggableDivIds[$x].'")){
  442. document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.cursor="pointer";
  443. document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.paddingRight = "10px";
  444. document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.paddingLeft = "10px";
  445. document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.paddingTop = "0px";
  446. document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.paddingBottom = "0px";
  447. document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.backgroundColor = "red";
  448. parent.document.getElementById("hoverItem_'.$ff_processor->draggableDivIds[$x].'").style.backgroundColor = "#cccccc";
  449. }
  450. }
  451. function bfItemOut_'.$ff_processor->draggableDivIds[$x].'(e){
  452. if(document.getElementById("'.$ff_processor->draggableDivIds[$x].'")){
  453. document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.cursor="";
  454. document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.paddingRight= '.$ff_processor->draggableDivIds[$x].'_paddingRTmp;
  455. document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.paddingLeft= '.$ff_processor->draggableDivIds[$x].'_paddingLTmp;
  456. document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.paddingTop= '.$ff_processor->draggableDivIds[$x].'_paddingTTmp;
  457. document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.paddingBottom= '.$ff_processor->draggableDivIds[$x].'_paddingBTmp;
  458. document.getElementById("'.$ff_processor->draggableDivIds[$x].'").style.backgroundColor = '.$ff_processor->draggableDivIds[$x].'_colorTmp;
  459. parent.document.getElementById("hoverItem_'.$ff_processor->draggableDivIds[$x].'").style.backgroundColor = "";
  460. }
  461. }
  462. if(document.getElementById("'.$ff_processor->draggableDivIds[$x].'")){
  463. document.getElementById("'.$ff_processor->draggableDivIds[$x].'").onmouseover = bfItemOver_'.$ff_processor->draggableDivIds[$x].';
  464. document.getElementById("'.$ff_processor->draggableDivIds[$x].'").onmouseout = bfItemOut_'.$ff_processor->draggableDivIds[$x].';
  465. }
  466. ';
  467. }
  468. echo '
  469. <script>
  470. SET_DHTML('.$draggableIds.');
  471. '.$mouseOvers.'
  472. function my_DragFunc(){
  473. parent.document.adminForm.savepos.disabled = false;
  474. // TODO: when undo is enabled, drag and drop is not possible. needs to be solved
  475. //parent.document.adminForm.restpos.disabled = false;
  476. }
  477. function my_DropFunc(){
  478. parent.document.getElementById("ff_itemPositions").value = "";
  479. for(var i = 0; i < parent.ff_coords.length;i++){
  480. eval("var cb = parent.document.adminForm.cb"+i+";");
  481. var itemComma = "";
  482. if(i+1 < parent.ff_coords.length){
  483. itemComma = ",";
  484. } else {
  485. itemComma = "";
  486. }
  487. parent.document.getElementById("ff_itemPositions").value +=
  488. cb.value+":"+document.getElementById("ff_div"+cb.value).style.zIndex+itemComma;
  489. }
  490. for(var i = 0; i < parent.ff_coords.length;i++){
  491. eval("var cb = parent.document.adminForm.cb"+i+";");
  492. if(document.getElementById("ff_div"+cb.value) == document.getElementById(dd.obj.id)){
  493. parent.ff_coords[i][2] = dd.obj.x;
  494. parent.ff_coords[i][5] = dd.obj.y;
  495. break;
  496. }
  497. }
  498. }
  499. </script>';
  500. }
  501. ob_end_flush();
  502. } // if
  503. } // if
  504. } // if
  505. } else if(JRequest::getBool('showSecImage')) {
  506. JRequest::setVar('format', 'raw');
  507. header("Content-Type: image/png");
  508. $captchaDir = JPATH_SITE . '/administrator/components/com_breezingforms/captchas';
  509. if(file_exists($captchaDir) && is_dir($captchaDir)){
  510. $sizeAvailableCaptchas = count(glob("$captchaDir/*.png"));
  511. $sizeAvailableCaptchas = $sizeAvailableCaptchas > mt_getrandmax() ? mt_getrandmax() : $sizeAvailableCaptchas;
  512. mt_srand();
  513. $captchaBgNum = mt_rand(0, $sizeAvailableCaptchas-1);
  514. $i = 0;
  515. $handle = opendir($captchaDir);
  516. while (false!==($file = readdir($handle))) {
  517. if ($file != "." && $file != ".." && strtolower($file) != ".svn" && strtolower($file) != ".cvs") {
  518. $pathinfo = pathinfo($file);
  519. $extension = $pathinfo['extension'];
  520. if(strtolower($extension) == 'png'){
  521. if($captchaBgNum == $i){
  522. $bbox = imagettfbbox (14, 0, $captchaDir . '/fontfile.ttf', JFactory::getSession()->get('ff_seccode'));
  523. //print_r($bbox);
  524. $textWidth = $bbox[2] - $bbox[0];
  525. $textHeight = $bbox[3] - $bbox[5];
  526. $imgHandle = imagecreatefrompng($captchaDir . '/' . $file);
  527. imagettftext($imgHandle, 14, 0, (imagesx($imgHandle)-$textWidth)/2, (imagesy($imgHandle)+$textHeight)/2, '0x000000', $captchaDir . '/fontfile.ttf', JFactory::getSession()->get('ff_seccode'));
  528. imagepng($imgHandle);
  529. imagedestroy($imgHandle);
  530. break;
  531. }
  532. $i++;
  533. }
  534. }
  535. }
  536. closedir($handle);
  537. }
  538. exit;
  539. } else if(JRequest::getBool('bfReCaptcha')){
  540. ob_end_clean();
  541. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php');
  542. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php');
  543. $db->setQuery( "Select * From #__facileforms_forms Where id = " . $db->Quote( JRequest::getInt('form',-1) ) );
  544. $list = $db->loadObjectList();
  545. if(count($list) == 0){
  546. exit;
  547. }
  548. $form = $list[0];
  549. $areas = Zend_Json::decode($form->template_areas);
  550. foreach($areas As $area){
  551. foreach($area['elements'] As $element){
  552. if($element['bfType'] == 'ReCaptcha'){
  553. if(!function_exists('recaptcha_check_answer')){
  554. require_once(JPATH_SITE . '/administrator/components/com_breezingforms/libraries/recaptcha/recaptchalib.php');
  555. }
  556. $publickey = $element['pubkey']; // you got this from the signup page
  557. $privatekey = $element['privkey'];
  558. $resp = recaptcha_check_answer ($privatekey,
  559. $_SERVER["REMOTE_ADDR"],
  560. isset( $_POST["recaptcha_challenge_field"] ) ? $_POST["recaptcha_challenge_field"] : '' ,
  561. isset($_POST["recaptcha_response_field"]) ? $_POST["recaptcha_response_field"] : '' );
  562. JFactory::getSession()->set('bfrecapsuccess',false);
  563. if ($resp->is_valid) {
  564. echo 'success';
  565. JFactory::getSession()->set('bfrecapsuccess',true);
  566. }
  567. else
  568. {
  569. die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
  570. "(reCAPTCHA said: " . $resp->error . ")");
  571. }
  572. exit;
  573. }
  574. }
  575. }
  576. exit;
  577. } else if(JRequest::getBool('checkCaptcha')){
  578. @ob_end_clean();
  579. require_once(JPATH_SITE . '/components/com_breezingforms/images/captcha/securimage.php');
  580. $securimage = new Securimage();
  581. if(!$securimage->check(str_replace('?','',JRequest::getVar('value', '')))){
  582. echo 'capResult=>false';
  583. } else {
  584. echo 'capResult=>true';
  585. }
  586. exit;
  587. } else if(JRequest::getBool('confirmPayPalIpn') && ( !isset($ff_applic) || $ff_applic == '' ) ){
  588. JRequest::setVar('format', 'html');
  589. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php');
  590. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php');
  591. $db->setQuery( "Select * From #__facileforms_forms Where id = " . $db->Quote( JRequest::getInt('form_id',-1) ) );
  592. $list = $db->loadObjectList();
  593. if(count($list) == 0){
  594. header("Status: 200 OK");
  595. exit;
  596. }
  597. $form = $list[0];
  598. $areas = Zend_Json::decode($form->template_areas);
  599. if(!is_array($areas)){
  600. header("Status: 200 OK");
  601. exit;
  602. }
  603. foreach($areas As $area){
  604. foreach($area['elements'] As $element){
  605. if($element['internalType'] == 'bfPayPal'){
  606. $options = $element['options'];
  607. $auth_token = $options['token'];
  608. $paypal = 'https://www.paypal.com';
  609. if($options['testaccount']){
  610. $paypal = 'https://www.sandbox.paypal.com';
  611. $auth_token = $options['testToken'];
  612. }
  613. $req = 'cmd=_notify-validate';
  614. $tx_token = JRequest::getVar('txn_id', 0 );
  615. foreach ($_POST as $key => $value) {
  616. $value = urlencode(stripslashes($value));
  617. $req .= "&$key=$value";
  618. }
  619. $header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
  620. $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
  621. $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
  622. $pointer = null;
  623. $res = '';
  624. if (function_exists('curl_init')) {
  625. $ch = curl_init();
  626. $pointer = $ch;
  627. curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
  628. curl_setopt($ch,CURLOPT_URL, $paypal.'/cgi-bin/webscr');
  629. curl_setopt($ch,CURLOPT_POST,1);
  630. curl_setopt($ch,CURLOPT_POSTFIELDS,$req);
  631. ob_start();
  632. curl_exec($ch);
  633. $res=ob_get_contents();
  634. } else {
  635. // try fsockopen
  636. $fp = fsockopen ($paypal, 80, $errno, $errstr, 30);
  637. $pointer = $fp;
  638. fputs ($fp, $header . $req);
  639. $headerdone = false;
  640. while (!feof($fp)) {
  641. $line = fgets ($fp, 1024);
  642. if (strcmp($line, "\r\n") == 0) {
  643. $headerdone = true;
  644. }
  645. else if ($headerdone)
  646. {
  647. $res .= $line;
  648. }
  649. }
  650. }
  651. $lines = explode("\n", $res);
  652. if (strcmp ($lines[0], "VERIFIED") == 0) {
  653. $query = "SELECT * FROM #__facileforms_records WHERE id = '".JRequest::getInt('record_id', -1)."' LIMIT 1";
  654. $db->setQuery($query);
  655. $txid = $db->loadObjectList();
  656. if (count($txid) != 0) {
  657. if($txid[0]->paypal_tx_id == ''){
  658. $db->setQuery("
  659. Update
  660. #__facileforms_records
  661. Set
  662. paypal_tx_id = ".$db->Quote('PayPal: ' . $tx_token . ' (VALID)').",
  663. paypal_payment_date = ".$db->Quote(date('Y-m-d H:i:s')).",
  664. paypal_testaccount = ".$db->Quote($options['testaccount'] ? 1 : 0).",
  665. paypal_download_tries = 0
  666. Where
  667. id = '".JRequest::getInt('record_id', -1)."'
  668. ");
  669. $db->query();
  670. // trigger a script after succeeded payment?
  671. if(JFile::exists(JPATH_SITE . '/bf_paypalipn_success.php')){
  672. require_once(JPATH_SITE . '/bf_paypalipn_success.php');
  673. }
  674. // send mail after succeeded payment?
  675. if( isset( $options['sendNotificationAfterPayment'] ) && $options['sendNotificationAfterPayment'] ) {
  676. bf_sendNotificationByPaymentCache(JRequest::getInt('form_id',-1),JRequest::getInt('record_id', -1),'admin');
  677. bf_sendNotificationByPaymentCache(JRequest::getInt('form_id',-1),JRequest::getInt('record_id', -1),'mailback');
  678. }
  679. }
  680. header("Status: 200 OK");
  681. }
  682. header("Status: 200 OK");
  683. }
  684. else if (strcmp ($lines[0], "INVALID") == 0) {
  685. $query = "SELECT * FROM #__facileforms_records WHERE id = '".JRequest::getInt('record_id', -1)."' LIMIT 1";
  686. $db->setQuery($query);
  687. $txid = $db->loadObjectList();
  688. if (count($txid) != 0) {
  689. $db->setQuery("
  690. Update
  691. #__facileforms_records
  692. Set
  693. paypal_tx_id = ".$db->Quote('PayPal: ' . $tx_token . ' (INVALID)').",
  694. paypal_payment_date = ".$db->Quote(date('Y-m-d H:i:s')).",
  695. paypal_testaccount = ".$db->Quote($options['testaccount'] ? 1 : 0).",
  696. paypal_download_tries = 0
  697. Where
  698. id = '".JRequest::getInt('record_id', -1)."'
  699. ");
  700. $db->query();
  701. }
  702. header("Status: 200 OK");
  703. }
  704. header("Status: 200 OK");
  705. // should be kept open until sending the status headers
  706. if (function_exists('curl_init')) {
  707. curl_close($pointer);
  708. ob_end_clean();
  709. }
  710. else
  711. {
  712. fclose ($pointer);
  713. }
  714. break;
  715. }
  716. }
  717. }
  718. } else if(JRequest::getBool('confirmPayPal') && ( !isset($ff_applic) || $ff_applic == '' ) ){
  719. JRequest::setVar('format', 'html');
  720. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php');
  721. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php');
  722. $db->setQuery( "Select * From #__facileforms_forms Where id = " . $db->Quote( JRequest::getInt('form_id',-1) ) );
  723. $list = $db->loadObjectList();
  724. if(count($list) == 0){
  725. BFRedirect(JURI::root(), BFText::_('COM_BREEZINGFORMS_FORM_DOES_NOT_EXIST'));
  726. exit;
  727. }
  728. $form = $list[0];
  729. $areas = Zend_Json::decode($form->template_areas);
  730. if(!is_array($areas)){
  731. BFRedirect(JURI::root(), BFText::_('COM_BREEZINGFORMS_COULD_NOT_FIND_PAYPAL_DATA'));
  732. exit;
  733. }
  734. foreach($areas As $area){
  735. $checkPP = true;
  736. foreach($area['elements'] As $element){
  737. if($element['name'] == 'PayPalSelect' || $element['name'] == 'BfPaymentSelect'){
  738. $checkPP = false;
  739. break;
  740. }
  741. }
  742. foreach($area['elements'] As $element){
  743. if($element['internalType'] == 'bfPayPal'){
  744. $options = $element['options'];
  745. $auth_token = $options['token'];
  746. $paypal = 'https://www.paypal.com';
  747. if($options['testaccount']){
  748. $paypal = 'https://www.sandbox.paypal.com';
  749. $auth_token = $options['testToken'];
  750. }
  751. $req = 'cmd=_notify-synch';
  752. $tx_token = JRequest::getVar('tx', 0 );
  753. $req .= "&tx=".urlencode($tx_token)."&at=".urlencode($auth_token);
  754. $header = "POST /cgi-bin/webscr HTTP/1.0\r\n";
  755. $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
  756. $header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
  757. if (function_exists('curl_init')) {
  758. $ch = curl_init();
  759. curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
  760. curl_setopt($ch,CURLOPT_URL, $paypal.'/cgi-bin/webscr');
  761. curl_setopt($ch,CURLOPT_POST,1);
  762. curl_setopt($ch,CURLOPT_POSTFIELDS,$req);
  763. ob_start();
  764. curl_exec($ch);
  765. $res=ob_get_contents();
  766. curl_close($ch);
  767. ob_end_clean();
  768. } else {
  769. // try fsockopen
  770. $fp = fsockopen ($paypal, 80, $errno, $errstr, 30);
  771. fputs ($fp, $header . $req);
  772. $res = '';
  773. $headerdone = false;
  774. while (!feof($fp)) {
  775. $line = fgets ($fp, 1024);
  776. if (strcmp($line, "\r\n") == 0) {
  777. $headerdone = true;
  778. }
  779. else if ($headerdone)
  780. {
  781. $res .= $line;
  782. }
  783. }
  784. fclose ($fp);
  785. }
  786. $lines = explode("\n", $res);
  787. $keyarray = array();
  788. if (strcmp ($lines[0], "SUCCESS") == 0) {
  789. for ($i=1; $i<count($lines);$i++){
  790. if ($lines[$i] != "") {
  791. list($key,$val) = explode("=", $lines[$i]);
  792. $keyarray[urldecode($key)] = urldecode($val);
  793. }
  794. }
  795. if ($checkPP && ( ( $options['amount'] > 0 && $keyarray['mc_gross'] != (doubleval($options['amount'])+doubleval($options['tax'])) ) || $keyarray['mc_currency'] != strtoupper($options['currencyCode']) ) ) {
  796. $success = false;
  797. $msg = JText::_("Payment was not correct (amount/currency)");
  798. require_once(JPATH_SITE . '/media/breezingforms/downloadtpl/error.php');
  799. }else{
  800. $query = "SELECT * FROM #__facileforms_records WHERE id = '".JRequest::getInt('record_id', -1)."' LIMIT 1";
  801. $db->setQuery($query);
  802. $txid = $db->loadObjectList();
  803. if (count($txid) != 0) {
  804. if($txid[0]->paypal_tx_id == ''){
  805. $db->setQuery("
  806. Update
  807. #__facileforms_records
  808. Set
  809. paypal_tx_id = ".$db->Quote('PayPal: ' . $tx_token).",
  810. paypal_payment_date = ".$db->Quote(date('Y-m-d H:i:s',strtotime($keyarray["payment_date"]))).",
  811. paypal_testaccount = ".$db->Quote($options['testaccount'] ? 1 : 0).",
  812. paypal_download_tries = 0
  813. Where
  814. id = '".JRequest::getInt('record_id', -1)."'
  815. ");
  816. $db->query();
  817. // trigger a script after succeeded payment?
  818. if(JFile::exists(JPATH_SITE . '/bf_paypal_success.php')){
  819. require_once(JPATH_SITE . '/bf_paypal_success.php');
  820. }
  821. // send mail after succeeded payment?
  822. if( isset( $options['sendNotificationAfterPayment'] ) && $options['sendNotificationAfterPayment'] ){
  823. bf_sendNotificationByPaymentCache(JRequest::getInt('form_id',-1),JRequest::getInt('record_id', -1),'admin');
  824. bf_sendNotificationByPaymentCache(JRequest::getInt('form_id',-1),JRequest::getInt('record_id', -1),'mailback');
  825. }
  826. if($options['downloadableFile']){
  827. $record_id = JRequest::getInt('record_id', -1);
  828. $tries = $options['downloadTries'];
  829. $form_id = JRequest::getInt('form_id',-1);
  830. require_once(JPATH_SITE . '/media/breezingforms/downloadtpl/download.php');
  831. } else {
  832. if($options['thankYouPage'] != ''){
  833. BFRedirect($options['thankYouPage']);
  834. } else {
  835. BFRedirect(JURI::root(), BFText::_('COM_BREEZINGFORMS_THANK_YOU_FOR_PAYING_WITH_PAYPAL'));
  836. }
  837. }
  838. $success = true;
  839. } else {
  840. if($options['downloadableFile']){
  841. $record_id = JRequest::getInt('record_id', -1);
  842. $tries = $options['downloadTries'];
  843. $form_id = JRequest::getInt('form_id',-1);
  844. require_once(JPATH_SITE . '/media/breezingforms/downloadtpl/download.php');
  845. }
  846. else
  847. {
  848. if($options['useIpn'])
  849. {
  850. if($options['thankYouPage'] != ''){
  851. BFRedirect($options['thankYouPage']);
  852. } else {
  853. BFRedirect(JURI::root(), BFText::_('COM_BREEZINGFORMS_THANK_YOU_FOR_PAYING_WITH_PAYPAL'));
  854. }
  855. }
  856. else
  857. {
  858. $success = false;
  859. $msg = JText::_("This transaction was already processed");
  860. require_once(JPATH_SITE . '/media/breezingforms/downloadtpl/error.php');
  861. }
  862. }
  863. }
  864. }
  865. else
  866. {
  867. $success = false;
  868. $msg = JText::_("Could not find record!");
  869. require_once(JPATH_SITE . '/media/breezingforms/downloadtpl/error.php');
  870. }
  871. }
  872. }
  873. else if (strcmp ($lines[0], "FAIL") == 0) {
  874. $success = false;
  875. $msg = JText::_("Verification failed");
  876. require_once(JPATH_SITE . '/media/breezingforms/downloadtpl/error.php');
  877. }
  878. else {
  879. $success = false;
  880. $msg = JText::_("Verification did not return any values");
  881. require_once(JPATH_SITE . '/media/breezingforms/downloadtpl/error.php');
  882. }
  883. break;
  884. }
  885. }
  886. }
  887. } else if(JRequest::getBool('paypalDownload') && ( !isset($ff_applic) || $ff_applic == '' ) ){
  888. JRequest::setVar('format', 'raw');
  889. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php');
  890. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php');
  891. $db->setQuery( "Select * From #__facileforms_forms Where id = " . $db->Quote( JRequest::getInt('form',-1) ) );
  892. $list = $db->loadObjectList();
  893. if(count($list) == 0){
  894. BFRedirect(JURI::root(), BFText::_('COM_BREEZINGFORMS_FORM_DOES_NOT_EXIST'));
  895. exit;
  896. }
  897. $form = $list[0];
  898. $areas = Zend_Json::decode($form->template_areas);
  899. if(!is_array($areas)){
  900. BFRedirect(JURI::root(), BFText::_('COM_BREEZINGFORMS_COULD_NOT_FIND_PAYPAL_DATA'));
  901. }
  902. foreach($areas As $area){
  903. foreach($area['elements'] As $element){
  904. if($element['internalType'] == 'bfPayPal'){
  905. $options = $element['options'];
  906. if($options['downloadableFile']){
  907. $file = $options['filepath'];
  908. $db->setQuery("
  909. Select paypal_download_tries From
  910. #__facileforms_records
  911. Where
  912. id = '".JRequest::getInt('record_id', -1)."'
  913. And
  914. (
  915. paypal_tx_id = ".$db->Quote('PayPal: ' . JRequest::getVar('tx',''))."
  916. Or
  917. paypal_tx_id = ".$db->Quote('PayPal: ' . JRequest::getVar('tx','') . ' (VALID)')."
  918. )
  919. ");
  920. $downloads = $db->loadObjectList();
  921. if(count($downloads) == 1){
  922. if($downloads[0]->paypal_download_tries < $options['downloadTries']){
  923. $db->setQuery("
  924. Update
  925. #__facileforms_records
  926. Set
  927. paypal_download_tries = paypal_download_tries + 1
  928. Where
  929. id = '".JRequest::getInt('record_id', -1)."'
  930. And
  931. (
  932. paypal_tx_id = ".$db->Quote('PayPal: ' . JRequest::getVar('tx',''))."
  933. Or
  934. paypal_tx_id = ".$db->Quote('PayPal: ' . JRequest::getVar('tx','') . ' (VALID)')."
  935. )
  936. ");
  937. $db->query();
  938. if(!file_exists($file)) {
  939. BFRedirect(JURI::root(), BFText::_('COM_BREEZINGFORMS_COULD_NOT_FIND_DOWNLOAD_FILE'));
  940. }
  941. header('Content-Description: File Transfer');
  942. header('Content-Type: application/octet-stream');
  943. header('Content-Disposition: attachment; filename='.basename($file));
  944. header('Content-Transfer-Encoding: binary');
  945. header('Expires: 0');
  946. header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
  947. header('Pragma: public');
  948. header('Content-Length: ' . filesize($file));
  949. ob_clean();
  950. flush();
  951. readfile($file) or die("Error reading the file ".$file);
  952. exit;
  953. } else {
  954. BFRedirect(JURI::root(), BFText::_('COM_BREEZINGFORMS_MAX_DOWNLOAD_TRIES_REACHED'));
  955. }
  956. } else {
  957. BFRedirect(JURI::root(), BFText::_('COM_BREEZINGFORMS_DOWNLOAD_NOT_POSSIBLE'));
  958. }
  959. } else {
  960. BFRedirect(JURI::root(), BFText::_('COM_BREEZINGFORMS_NO_DOWNLOADABLE_PRODUCT'));
  961. }
  962. break;
  963. }
  964. }
  965. }
  966. } else if(JRequest::getBool('showPayPalConnectMsg')){
  967. JRequest::setVar('format', 'html');
  968. $style = '<link rel="stylesheet" href="'.JURI::root().'templates/'.$mainframe->getTemplate().'/css/template.css" type="text/css" />';
  969. echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  970. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="'.strtolower(JFactory::getLanguage()->getTag()).'" lang="'.strtolower(JFactory::getLanguage()->getTag()).'" >
  971. <head>'.$style.'</head>
  972. <div class="payPalConnectMsg">
  973. <div class="paymentConnectMsg">
  974. '.BFText::_('COM_BREEZINGFORMS_PLEASE_WAIT_REQUEST').'
  975. </div>
  976. </div>
  977. </body>';
  978. } else if(JRequest::getBool('successSofortueberweisung')){
  979. JRequest::setVar('format', 'html');
  980. $tx_token = JRequest::getVar('tx','');
  981. if($tx_token == ''){
  982. $msg = JText::_("This transaction id is empty!");
  983. require_once(JPATH_SITE . '/media/breezingforms/downloadtpl/error.php');
  984. }
  985. else {
  986. $formId = JRequest::getInt('user_variable_0','');
  987. $recordId = JRequest::getInt('user_variable_1','');
  988. if($formId != '' && $recordId != ''){
  989. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php');
  990. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php');
  991. $db->setQuery( "Select * From #__facileforms_forms Where id = " . $db->Quote( $formId ) );
  992. $list = $db->loadObjectList();
  993. if(count($list) == 0){
  994. BFRedirect(JURI::root(), BFText::_('COM_BREEZINGFORMS_FORM_DOES_NOT_EXIST'));
  995. exit;
  996. }
  997. $form = $list[0];
  998. $areas = Zend_Json::decode($form->template_areas);
  999. if(!is_array($areas)){
  1000. BFRedirect(JURI::root(), BFText::_('COM_BREEZINGFORMS_COULD_NOT_FIND_SU_DATA'));
  1001. }
  1002. foreach($areas As $area){
  1003. foreach($area['elements'] As $element){
  1004. if($element['internalType'] == 'bfSofortueberweisung'){
  1005. $options = $element['options'];
  1006. if($opti

Large files files are truncated, but you can click here to view the full file