PageRenderTime 115ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 2ms

/components/com_breezingforms/facileforms.process.php

https://bitbucket.org/izubizarreta/https-bitbucket.org-bityvip-alpes
PHP | 6664 lines | 5891 code | 594 blank | 179 comment | 1593 complexity | 4bbee968557cf120285e4689635c3aae MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, LGPL-2.1, MIT, LGPL-3.0, LGPL-2.0, JSON
  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. defined('_JEXEC') or die('Direct Access to this location is not allowed.');
  10. class bfMobile {
  11. public $isMobile = false;
  12. }
  13. $mainframe = JFactory::getApplication();
  14. $ff_processor = null;
  15. define('_FF_PACKBREAKAFTER', 250);
  16. define('_FF_STATUS_OK', 0);
  17. define('_FF_STATUS_UNPUBLISHED', 1);
  18. define('_FF_STATUS_SAVERECORD_FAILED', 2);
  19. define('_FF_STATUS_SAVESUBRECORD_FAILED', 3);
  20. define('_FF_STATUS_UPLOAD_FAILED', 4);
  21. define('_FF_STATUS_SENDMAIL_FAILED', 5);
  22. define('_FF_STATUS_ATTACHMENT_FAILED', 6);
  23. define('_FF_STATUS_CAPTCHA_FAILED', 7);
  24. define('_FF_STATUS_FILE_EXTENSION_NOT_ALLOWED', 8);
  25. define('_FF_DATA_ID', 0);
  26. define('_FF_DATA_NAME', 1);
  27. define('_FF_DATA_TITLE', 2);
  28. define('_FF_DATA_TYPE', 3);
  29. define('_FF_DATA_VALUE', 4);
  30. define('_FF_DATA_FILE_SERVERPATH', 5);
  31. define('_FF_IGNORE_STRICT', 1);
  32. define('_FF_TRACE_NAMELIMIT', 100);
  33. // tracemode bits
  34. define('_FF_TRACEMODE_EVAL', 8);
  35. define('_FF_TRACEMODE_PIECE', 16);
  36. define('_FF_TRACEMODE_FUNCTION', 32);
  37. define('_FF_TRACEMODE_MESSAGE', 64);
  38. define('_FF_TRACEMODE_LOCAL', 128);
  39. define('_FF_TRACEMODE_DIRECT', 256);
  40. define('_FF_TRACEMODE_APPEND', 512);
  41. define('_FF_TRACEMODE_DISABLE', 1024);
  42. define('_FF_TRACEMODE_FIRST', 2048);
  43. // tracemode masks
  44. define('_FF_TRACEMODE_PRIORITY', 7);
  45. define('_FF_TRACEMODE_TOPIC', 120);
  46. define('_FF_TRACEMODE_VARIABLE', 248);
  47. // debugging flags
  48. define('_FF_DEBUG_PATCHEDCODE', 1);
  49. define('_FF_DEBUG_ENTER', 2);
  50. define('_FF_DEBUG_EXIT', 4);
  51. define('_FF_DEBUG_DIRECTIVE', 8);
  52. define('_FF_DEBUG', 0);
  53. function ff_trace($msg = null) {
  54. global $ff_processor;
  55. if ($ff_processor->dying ||
  56. ($ff_processor->traceMode & _FF_TRACEMODE_DISABLE) ||
  57. !($ff_processor->traceMode & _FF_TRACEMODE_MESSAGE))
  58. return;
  59. $level = count($ff_processor->traceStack);
  60. $trc = '';
  61. for ($l = 0; $l < $level; $l++)
  62. $trc .= ' ';
  63. $trc .= BFText::_('COM_BREEZINGFORMS_PROCESS_MSGUNKNOWN') . ": $msg\n";
  64. $ff_processor->traceBuffer .= htmlspecialchars($trc, ENT_QUOTES);
  65. if ($ff_processor->traceMode & _FF_TRACEMODE_DIRECT)
  66. $ff_processor->dumpTrace();
  67. }
  68. // ff_trace
  69. function _ff_trace($line, $msg = null) {
  70. global $ff_processor;
  71. // version for patched code
  72. if ($ff_processor->dying || ($ff_processor->traceMode & _FF_TRACEMODE_DISABLE))
  73. return;
  74. $level = count($ff_processor->traceStack);
  75. if ($msg && ($ff_processor->traceMode & _FF_TRACEMODE_MESSAGE)) {
  76. $trc = '';
  77. for ($l = 0; $l < $level; $l++)
  78. $trc .= ' ';
  79. $trc .= BFText::_('COM_BREEZINGFORMS_PROCESS_LINE') . " $line: $msg\n";
  80. $ff_processor->traceBuffer .= htmlspecialchars($trc, ENT_QUOTES);
  81. if ($ff_processor->traceMode & _FF_TRACEMODE_DIRECT)
  82. $ff_processor->dumpTrace();
  83. } // if
  84. if ($level)
  85. $ff_processor->traceStack[$level - 1][3] = $line;
  86. }
  87. // _ff_trace
  88. function _ff_getMode(&$newmode, &$name) {
  89. global $ff_processor;
  90. $oldmode = $ff_processor->traceMode;
  91. if (_FF_DEBUG & _FF_DEBUG_ENTER)
  92. $ff_processor->traceBuffer .=
  93. htmlspecialchars(
  94. "\n_FF_DEBUG_ENTER:" .
  95. "\n Name = $name" .
  96. "\n Old mode before = " . $ff_processor->dispTraceMode($oldmode) .
  97. "\n New mode before = " . $ff_processor->dispTraceMode($newmode), ENT_QUOTES
  98. );
  99. if (is_null($newmode) || ($newmode & _FF_TRACEMODE_PRIORITY) < ($oldmode & _FF_TRACEMODE_PRIORITY)) {
  100. $newmode = $oldmode;
  101. $ret = $oldmode;
  102. } else {
  103. $newmode = ($oldmode & ~_FF_TRACEMODE_VARIABLE) | ($newmode & _FF_TRACEMODE_VARIABLE);
  104. if ($oldmode != $newmode)
  105. $ff_processor->traceMode = $newmode;
  106. $ret = ($newmode & _FF_TRACEMODE_LOCAL) ? $oldmode : $newmode;
  107. } // if
  108. if (_FF_DEBUG & _FF_DEBUG_ENTER) {
  109. $ff_processor->traceBuffer .=
  110. htmlspecialchars(
  111. "\n Old mode compiled = " . $ff_processor->dispTraceMode($ret) .
  112. "\n New mode compiled = " . $ff_processor->dispTraceMode($newmode) .
  113. "\n", ENT_QUOTES
  114. );
  115. if ($ff_processor->traceMode & _FF_TRACEMODE_DIRECT)
  116. $ff_processor->dumpTrace();
  117. } // if
  118. return $ret;
  119. }
  120. // _ff_getmode
  121. function _ff_tracePiece($newmode, $name, $line, $type, $id, $pane) {
  122. global $ff_processor;
  123. if ($ff_processor->dying || ($ff_processor->traceMode & _FF_TRACEMODE_DISABLE))
  124. return;
  125. $oldmode = _ff_getMode($newmode, $name);
  126. if ($newmode & _FF_TRACEMODE_PIECE) {
  127. $level = count($ff_processor->traceStack);
  128. for ($l = 0; $l < $level; $l++)
  129. $ff_processor->traceBuffer .= ' ';
  130. $ff_processor->traceBuffer .=
  131. htmlspecialchars(
  132. "+" . BFText::_('COM_BREEZINGFORMS_PROCESS_ENTER') . " $name " . BFText::_('COM_BREEZINGFORMS_PROCESS_ATLINE') . " $line\n", ENT_QUOTES
  133. );
  134. if ($ff_processor->traceMode & _FF_TRACEMODE_DIRECT)
  135. $ff_processor->dumpTrace();
  136. } // if
  137. array_push($ff_processor->traceStack, array($oldmode, 'p', $name, $line, $type, $id, $pane));
  138. }
  139. // _ff_tracePiece
  140. function _ff_traceFunction($newmode, $name, $line, $type, $id, $pane, &$args) {
  141. global $ff_processor;
  142. if ($ff_processor->dying || ($ff_processor->traceMode & _FF_TRACEMODE_DISABLE))
  143. return;
  144. $oldmode = _ff_getMode($newmode, $name);
  145. if ($newmode & _FF_TRACEMODE_FUNCTION) {
  146. $level = count($ff_processor->traceStack);
  147. $trc = '';
  148. for ($l = 0; $l < $level; $l++)
  149. $trc .= ' ';
  150. $trc .= "+" . BFText::_('COM_BREEZINGFORMS_PROCESS_ENTER') . " $name(";
  151. if ($args) {
  152. $next = false;
  153. foreach ($args as $arg) {
  154. if ($next)
  155. $trc .= ', '; else
  156. $next = true;
  157. if (is_null($arg))
  158. $trc .= 'null';
  159. else
  160. if (is_bool($arg)) {
  161. $trc .= $arg ? 'true' : 'false';
  162. } else
  163. if (is_numeric($arg))
  164. $trc .= $arg;
  165. else
  166. if (is_string($arg)) {
  167. $arg = preg_replace('/([\\s]+)/si', ' ', $arg);
  168. if (strlen($arg) > _FF_TRACE_NAMELIMIT)
  169. $arg = substr($arg, 0, _FF_TRACE_NAMELIMIT - 3) . '...';
  170. $trc .= "'$arg'";
  171. } else
  172. if (is_array($arg))
  173. $trc .= BFText::_('COM_BREEZINGFORMS_PROCESS_ARRAY');
  174. else
  175. if (is_object($arg))
  176. $trc .= BFText::_('COM_BREEZINGFORMS_PROCESS_OBJECT');
  177. else
  178. if (is_resource($arg))
  179. $trc .= BFText::_('COM_BREEZINGFORMS_PROCESS_RESOURCE');
  180. else
  181. $trc .= _FACILEFORMS_PROCESS_UNKTYPE;
  182. } // foreach
  183. } // if
  184. $trc .= ") " . BFText::_('COM_BREEZINGFORMS_PROCESS_ATLINE') . " $line\n";
  185. $ff_processor->traceBuffer .= htmlspecialchars($trc, ENT_QUOTES);
  186. if ($ff_processor->traceMode & _FF_TRACEMODE_DIRECT)
  187. $ff_processor->dumpTrace();
  188. } // if
  189. array_push($ff_processor->traceStack, array($oldmode, 'f', $name, $line, $type, $id, $pane));
  190. }
  191. // _ff_traceFunction
  192. function _ff_traceExit($line, $retval=null) {
  193. global $ff_processor;
  194. if ($ff_processor->dying || ($ff_processor->traceMode & _FF_TRACEMODE_DISABLE))
  195. return;
  196. $info = array_pop($ff_processor->traceStack);
  197. if ($info) {
  198. $oldmode = $ff_processor->traceMode;
  199. $newmode = $info[0];
  200. $kind = $info[1];
  201. $name = $info[2];
  202. $type = $info[4];
  203. $id = $info[5];
  204. $pane = $info[6];
  205. if (_FF_DEBUG & _FF_DEBUG_EXIT) {
  206. $ff_processor->traceBuffer .=
  207. htmlspecialchars(
  208. "\n_FF_DEBUG_EXIT:" .
  209. "\n Info = $kind $name at line $line" .
  210. "\n Old mode = " . $ff_processor->dispTraceMode($oldmode) .
  211. "\n New mode = " . $ff_processor->dispTraceMode($newmode) .
  212. "\n", ENT_QUOTES
  213. );
  214. if ($ff_processor->traceMode & _FF_TRACEMODE_DIRECT)
  215. $ff_processor->dumpTrace();
  216. } // if
  217. if ($kind == 'p')
  218. $visible = $oldmode & _FF_TRACEMODE_PIECE;
  219. else
  220. $visible = $oldmode & _FF_TRACEMODE_FUNCTION;
  221. if ($visible) {
  222. $level = count($ff_processor->traceStack);
  223. for ($l = 0; $l < $level; $l++)
  224. $ff_processor->traceBuffer .= ' ';
  225. $ff_processor->traceBuffer .=
  226. htmlspecialchars(
  227. "-" . BFText::_('COM_BREEZINGFORMS_PROCESS_LEAVE') . " $name " . BFText::_('COM_BREEZINGFORMS_PROCESS_ATLINE') . " $line\n", ENT_QUOTES
  228. );
  229. if ($oldmode & _FF_TRACEMODE_DIRECT)
  230. $ff_processor->dumpTrace();
  231. } // if
  232. if ($oldmode != $newmode)
  233. $ff_processor->traceMode =
  234. ($oldmode & ~_FF_TRACEMODE_VARIABLE) | ($newmode & _FF_TRACEMODE_VARIABLE);
  235. } else {
  236. $ff_processor->traceBuffer .= htmlspecialchars(BFText::_('COM_BREEZINGFORMS_PROCESS_WARNSTK') . "\n", ENT_QUOTES);
  237. if ($ff_processor->traceMode & _FF_TRACEMODE_DIRECT)
  238. $ff_processor->dumpTrace();
  239. $type = $id = $pane = null;
  240. $name = BFText::_('COM_BREEZINGFORMS_PROCESS_UNKNOWN');
  241. } // if
  242. return $retval;
  243. }
  244. // _ff_traceExit
  245. function _ff_errorHandler($errno, $errstr, $errfile, $errline) {
  246. global $ff_processor, $ff_mossite, $database;
  247. $database = JFactory::getDBO();
  248. if (isset($ff_processor->dying) && $ff_processor->dying)
  249. return;
  250. $msg = "\n<strong>*** " . htmlspecialchars(BFText::_('COM_BREEZINGFORMS_PROCESS_EXCAUGHT'), ENT_QUOTES) . " ***</strong>\n" .
  251. htmlspecialchars(BFText::_('COM_BREEZINGFORMS_PROCESS_PHPLEVEL') . ' ', ENT_QUOTES);
  252. $fail = false;
  253. if (!defined('E_DEPRECATED')) {
  254. define('E_DEPRECATED', 8192);
  255. }
  256. switch ($errno) {
  257. case E_WARNING : $msg .= "E_WARNING";
  258. break;
  259. case E_NOTICE : $msg .= "E_NOTICE";
  260. break;
  261. case E_USER_ERROR : $msg .= "E_USER_ERROR";
  262. $fail = true;
  263. break;
  264. case E_USER_WARNING: $msg .= "E_USER_WARNING";
  265. break;
  266. case E_USER_NOTICE : $msg .= "E_USER_NOTICE";
  267. break;
  268. case E_DEPRECATED : $msg .= "E_DEPRECATED";
  269. break;
  270. case 2048 :
  271. if (_FF_IGNORE_STRICT)
  272. return;
  273. $msg .= "E_STRICT";
  274. break;
  275. default : $msg .= $errno;
  276. $fail = true;
  277. } // switch
  278. $msg .= htmlspecialchars(
  279. "\n" . BFText::_('COM_BREEZINGFORMS_PROCESS_PHPFILE') . " $errfile\n" .
  280. BFText::_('COM_BREEZINGFORMS_PROCESS_PHPLINE') . " $errline\n", ENT_QUOTES
  281. );
  282. $n = 0;
  283. if (isset($ff_processor)) {
  284. $n = count($ff_processor->traceStack);
  285. }
  286. if ($n) {
  287. $info = $ff_processor->traceStack[$n - 1];
  288. $name = htmlspecialchars($info[2] . ' ' . BFText::_('COM_BREEZINGFORMS_PROCESS_ATLINE') . ' ' . $info[3], ENT_QUOTES);
  289. $type = $info[4];
  290. $id = $info[5];
  291. $pane = $info[6];
  292. if ($type && $id && $ff_processor->runmode != _FF_RUNMODE_FRONTEND) {
  293. $url = $ff_mossite . '/administrator/index.php?option=com_breezingforms&format=html&tmpl=component';
  294. $what = $id;
  295. switch ($type) {
  296. case 'f':
  297. $url .=
  298. '&act=editpage' .
  299. '&task=editform' .
  300. '&form=' . $ff_processor->form;
  301. if ($ff_processor->formrow->package != '')
  302. $url .= '&pkg=' . urlencode($ff_processor->formrow->package);
  303. if ($pane > 0)
  304. $url .= '&tabpane=' . $pane;
  305. $what = 'form ' . $ff_processor->formrow->name;
  306. break;
  307. case 'e':
  308. $page = 1;
  309. foreach ($ff_processor->rows as $row)
  310. if ($row->id == $id) {
  311. $page = $row->page;
  312. $what = $row->name;
  313. break;
  314. } // if
  315. $what = 'element ' . $what;
  316. $url .=
  317. '&act=editpage' .
  318. '&task=edit' .
  319. '&form=' . $ff_processor->form .
  320. '&page=' . $page .
  321. '&ids[]=' . $id;
  322. if ($ff_processor->formrow->package != '')
  323. $url .= '&pkg=' . urlencode($ff_processor->formrow->package);
  324. if ($pane > 0)
  325. $url .= '&tabpane=' . $pane;
  326. break;
  327. case 'p':
  328. $package = '';
  329. $database->setQuery("select name, package from #__facileforms_pieces where id=$id");
  330. $rows = $database->loadObjectList();
  331. if (count($rows)) {
  332. $package = $rows[0]->package;
  333. $what = $rows[0]->name;
  334. }
  335. $what = 'piece ' . $what;
  336. $url .=
  337. '&act=managepieces' .
  338. '&task=edit' .
  339. '&ids[]=' . $id;
  340. if ($package != '')
  341. $url .= '&pkg=' . urlencode($package);
  342. break;
  343. case 's':
  344. $package = '';
  345. $database->setQuery("select name, package from #__facileforms_scripts where id=$id");
  346. $rows = $database->loadObjectList();
  347. if (count($rows)) {
  348. $package = $rows[0]->package;
  349. $what = $rows[0]->name;
  350. }
  351. $what = 'script ' . $what;
  352. $url .=
  353. '&act=managescripts' .
  354. '&task=edit' .
  355. '&ids[]=' . $id;
  356. if ($package != '')
  357. $url .= '&pkg=' . urlencode($package);
  358. break;
  359. default:
  360. $url = null;
  361. } // switch
  362. if ($url)
  363. $name = '<a href="#" ' .
  364. 'onMouseOver="window.status=\'Open ' . $what . '\';return true;" ' .
  365. 'onMouseOut="window.status=\'\';return true;" ' .
  366. 'onClick="ff_redirectParent(\'' . htmlspecialchars($url, ENT_QUOTES) . '\');return true;"' .
  367. '>' . $name . '</a>';
  368. } // if
  369. $msg .= htmlspecialchars(BFText::_('COM_BREEZINGFORMS_PROCESS_LASTPOS'), ENT_QUOTES) . ' ' . $name . "\n";
  370. } // if
  371. $msg .= htmlspecialchars(BFText::_('COM_BREEZINGFORMS_PROCESS_ERRMSG') . " $errstr\n\n", ENT_QUOTES);
  372. if ($fail) {
  373. if (isset($ff_processor)) {
  374. $ff_processor->traceBuffer .= $msg;
  375. $ff_processor->suicide();
  376. }
  377. } else
  378. if (isset($ff_processor)) {
  379. if (($ff_processor->traceMode & _FF_TRACEMODE_DISABLE) == 0) {
  380. $ff_processor->traceBuffer .= $msg;
  381. if ($ff_processor->traceMode & _FF_TRACEMODE_DIRECT)
  382. $ff_processor->dumpTrace();
  383. }
  384. } // if
  385. }
  386. // _ff_errorHandler
  387. class HTML_facileFormsProcessor {
  388. var $okrun = null; // running is allowed
  389. var $ip = null; // visitor ip
  390. var $agent = null; // visitor agent
  391. var $browser = null; // visitors browser
  392. var $opsys = null; // visitors operating system
  393. var $provider = null; // visitors provider
  394. var $submitted = null; // submit date/time
  395. var $formrow = null; // form row
  396. var $form = null; // form #
  397. var $form_id = null; // html form id
  398. var $page = null; // page id
  399. var $target = null; // target form name
  400. var $rows = null; // element rows
  401. var $rowcount = null; // # of element rows
  402. var $runmode = null; // current run mode _FF_RUNMODE_...
  403. var $inline = null; // inline preview
  404. var $inframe = null; // running in a frame
  405. var $template = null; // 0-frontend 1-backend
  406. var $homepage = null; // home page
  407. var $mospath = null; // mos absolute path
  408. var $images = null; // ff_images path
  409. var $uploads = null; // ff_uploads path
  410. var $border = null; // show border
  411. var $align = null; // form alignment
  412. var $top = null; // top margin
  413. var $suffix = null; // class name suffix
  414. var $status = null; // submit return status
  415. var $message = null; // submit return message
  416. var $record_id = null; // id of saved record
  417. var $submitdata = null; // submitted data
  418. var $savedata = null; // data for db save
  419. var $maildata = null; // data for mail notification
  420. var $sfdata = null;
  421. var $xmldata = null; // data for xml attachment
  422. var $mb_xmldata = null; // data for mailback attachments
  423. var $queryCols = null; // query column definitions
  424. var $queryRows = null; // query rows
  425. var $showgrid = null; // show grid in preview
  426. var $findtags = null; // tags to be replaced
  427. var $replacetags = null; // tag replacements
  428. var $dying = null; // form is dying
  429. var $errrep = null; // remember old error reporting
  430. var $traceMode = null; // trace mode
  431. var $traceStack = null; // trace stack
  432. var $traceBuffer = null; // trace buffer
  433. var $user_id = null;
  434. var $username = null;
  435. var $user_full_name = null;
  436. var $mailbackRecipients = array();
  437. var $editable = null;
  438. var $editable_override = null;
  439. var $sendNotificationAfterPayment = false;
  440. public $draggableDivIds = array();
  441. public $isMobile = false;
  442. public $quickmode = null;
  443. function HTML_facileFormsProcessor(
  444. $runmode, // _FF_RUNMODE_FRONTEND, ..._BACKEND, ..._PREVIEW
  445. $inframe, // run in iframe
  446. $form, // form id
  447. $page = 1, // page #
  448. $border = 0, // show border
  449. $align = 1, // align code
  450. $top = 0, // top margin
  451. $target = '', // target form name
  452. $suffix = '', // class name suffix
  453. $editable = 0, $editable_override = 0) {
  454. global $database, $ff_config, $ff_mossite, $ff_mospath, $ff_processor;
  455. $ff_processor = $this;
  456. $database = JFactory::getDBO();
  457. $this->dying = false;
  458. $this->runmode = $runmode;
  459. $this->inframe = $inframe;
  460. $this->form = $form;
  461. $this->page = $page;
  462. $this->border = $border;
  463. $this->align = $align;
  464. $this->top = $top;
  465. $this->target = $target;
  466. $this->suffix = trim($suffix);
  467. $this->editable = $editable;
  468. $this->editable_override = $editable_override;
  469. if (!class_exists('JBrowser')) {
  470. require_once(JPATH_SITE . '/libraries/joomla/environment/browser.php');
  471. }
  472. $this->ip = $_SERVER['REMOTE_ADDR'];
  473. $this->agent = JBrowser::getInstance()->getAgentString();
  474. $this->browser = JBrowser::getInstance()->getAgentString();
  475. $jbrowserInstance = JBrowser::getInstance();
  476. $this->opsys = $jbrowserInstance->getPlatform();
  477. if ($ff_config->getprovider == 0)
  478. $this->provider = BFText::_('COM_BREEZINGFORMS_PROCESS_UNKNOWN');
  479. else {
  480. $host = @GetHostByAddr($this->ip);
  481. $this->provider = preg_replace('/^./', '', strchr($host, '.'));
  482. } // if
  483. $this->submitted = date('Y-m-d H:i:s');
  484. /*
  485. $format = JText::_('DATE_FORMAT_LC2');
  486. if ( !$format ) {
  487. $this->submitted = date('Y-m-d H:i:s');
  488. }else{
  489. $config = JFactory::getConfig();
  490. $offset = $config->getValue('config.offset');
  491. $instance = JFactory::getDate(date('Y-m-d H:i:s'));
  492. $instance->setOffset($offset);
  493. $this->submitted = $instance->toFormat($format);
  494. } */
  495. $this->formrow = new facileFormsForms($database);
  496. $this->formrow->load($form);
  497. if ($this->formrow->published) {
  498. $database->setQuery(
  499. "select * from #__facileforms_elements " .
  500. "where form=" . $this->form . " and published=1 " .
  501. "order by page, ordering"
  502. );
  503. $this->rows = $database->loadObjectList();
  504. $this->rowcount = count($this->rows);
  505. } // if
  506. $this->inline = 0;
  507. $this->template = 0;
  508. $this->form_id = "ff_form" . $form;
  509. if ($runmode == _FF_RUNMODE_FRONTEND) {
  510. $this->homepage = $ff_mossite;
  511. } else {
  512. if ($this->inframe) {
  513. $this->homepage = $ff_mossite . '/administrator/index.php?tmpl=component';
  514. if ($this->formrow->runmode == 2)
  515. $this->template++;
  516. } else {
  517. $this->template++;
  518. if ($runmode == _FF_RUNMODE_PREVIEW) {
  519. $this->inline = 1;
  520. $this->form_id = "adminForm";
  521. } // if
  522. $this->homepage = 'index.php?tmpl=component';
  523. } // if
  524. } // if
  525. $this->mospath = $ff_mospath;
  526. $this->mossite = $ff_mossite;
  527. $this->findtags =
  528. array(
  529. '{ff_currentpage}',
  530. '{ff_lastpage}',
  531. '{ff_name}',
  532. '{ff_title}',
  533. '{ff_homepage}',
  534. '{mospath}',
  535. '{mossite}'
  536. );
  537. $this->replacetags =
  538. array(
  539. $this->page,
  540. $this->formrow->pages,
  541. $this->formrow->name,
  542. $this->formrow->title,
  543. $this->homepage,
  544. $this->mospath,
  545. $this->mossite
  546. );
  547. $this->images = str_replace($this->findtags, $this->replacetags, $ff_config->images);
  548. $this->findtags[] = '{ff_images}';
  549. $this->replacetags[] = $this->images;
  550. $this->uploads = str_replace($this->findtags, $this->replacetags, $ff_config->uploads);
  551. $this->findtags[] = '{ff_uploads}';
  552. $this->replacetags[] = $this->uploads;
  553. // CONTENTBUILDER
  554. $this->findtags[] = '{CBSite}';
  555. $this->replacetags[] = JPATH_SITE;
  556. $this->findtags[] = '{cbsite}';
  557. $this->replacetags[] = JPATH_SITE;
  558. $this->showgrid =
  559. $runmode == _FF_RUNMODE_PREVIEW
  560. && $this->formrow->prevmode > 0
  561. && $ff_config->gridshow == 1
  562. && $ff_config->gridsize > 1;
  563. $this->okrun = $this->formrow->published;
  564. if ($this->okrun)
  565. switch ($this->runmode) {
  566. case _FF_RUNMODE_FRONTEND:
  567. $this->okrun = ($this->formrow->runmode == 0 || $this->formrow->runmode == 1);
  568. break;
  569. case _FF_RUNMODE_BACKEND:
  570. $this->okrun = ($this->formrow->runmode == 0 || $this->formrow->runmode == 2);
  571. break;
  572. default:;
  573. } // switch
  574. $this->traceMode = _FF_TRACEMODE_FIRST;
  575. $this->traceStack = array();
  576. $this->traceBuffer = null;
  577. }
  578. // HTML_facileFormsProcessor
  579. function dispTraceMode($mode) {
  580. if (!is_int($mode))
  581. return $mode;
  582. $m = '(';
  583. if ($mode & _FF_TRACEMODE_FIRST)
  584. $m .= 'first ';
  585. $m .= ( $mode & _FF_TRACEMODE_DIRECT ? 'direct' : $mode & _FF_TRACEMODE_APPEND ? 'append' : 'popup');
  586. if ($mode & _FF_TRACEMODE_DISABLE)
  587. $m .= ' disable';
  588. else {
  589. switch ($mode & _FF_TRACEMODE_PRIORITY) {
  590. case 0: $m .= ' minimum';
  591. break;
  592. case 1: $m .= ' low';
  593. break;
  594. case 2: $m .= ' normal';
  595. break;
  596. case 3: $m .= ' high';
  597. break;
  598. default: $m .= ' maximum';
  599. break;
  600. } // switch
  601. $m .= $mode & _FF_TRACEMODE_LOCAL ? ' local' : ' global';
  602. switch ($mode & _FF_TRACEMODE_TOPIC) {
  603. case 0 : $m .= ' none';
  604. break;
  605. case _FF_TRACEMODE_TOPIC: $m .= ' all';
  606. break;
  607. default:
  608. if ($mode & _FF_TRACEMODE_EVAL)
  609. $m .= ' eval';
  610. if ($mode & _FF_TRACEMODE_PIECE)
  611. $m .= ' piece';
  612. if ($mode & _FF_TRACEMODE_FUNCTION)
  613. $m .= ' function';
  614. if ($mode & _FF_TRACEMODE_MESSAGE)
  615. $m .= ' message';
  616. } // switch
  617. } // if
  618. return $m . ')';
  619. }
  620. // dispTraceMode
  621. function trim(&$code) {
  622. $len = strlen($code);
  623. if (!$len)
  624. return false;
  625. if (strpos(" \t\r\n", $code{0}) === false && strpos(" \t\r\n", $code{$len - 1}) === false)
  626. return true;
  627. $code = trim($code);
  628. return $code != '';
  629. }
  630. // trim
  631. function nonblank(&$code) {
  632. return preg_match("/[^\\s]+/si", $code);
  633. }
  634. // nonblank
  635. function getClassName($classdef) {
  636. $name = '';
  637. if (strpos($classdef, ';') === false)
  638. $name = $classdef;
  639. else {
  640. $defs = explode(';', $classdef);
  641. $name = $defs[$this->template];
  642. } // if
  643. if ($this->trim($name))
  644. $name .= $this->suffix;
  645. return $name;
  646. }
  647. // getClassName
  648. function expJsValue($mixed, $indent='') {
  649. if (is_null($mixed))
  650. return $indent . 'null';
  651. if (is_bool($mixed))
  652. return $mixed ? $indent . 'true' : $indent . 'false';
  653. if (is_numeric($mixed))
  654. return $indent . $mixed;
  655. if (is_string($mixed))
  656. return
  657. $indent . "'" .
  658. str_replace(
  659. array("\\", "'", "\r", "<", "\n"), array("\\\\", "\\'", "\\r", "\\074", "\\n'+" . nl() . $indent . "'"), $mixed
  660. ) .
  661. "'";
  662. if (is_array($mixed)) {
  663. $dst = $indent . '[' . nl();
  664. $next = false;
  665. foreach ($mixed as $value) {
  666. if ($next)
  667. $dst .= "," . nl(); else
  668. $next = true;
  669. $dst .= $this->expJsValue($value, $indent . "\t");
  670. } // foreach
  671. return $dst . nl() . $indent . ']';
  672. } // if
  673. if (is_object($mixed)) {
  674. $dst = $indent . '{' . nl();
  675. $arr = get_object_vars($mixed);
  676. $next = false;
  677. foreach ($arr as $key => $value) {
  678. if ($next)
  679. $dst .= "," . nl(); else
  680. $next = true;
  681. $dst .= $indent . $key . ":" . nl() . $this->expJsValue($value, $indent . "\t");
  682. } // foreach
  683. return $dst . nl() . $indent . '}';
  684. } // if
  685. // not supported types
  686. if (is_resource($mixed))
  687. return $indent . "'" . BFText::_('COM_BREEZINGFORMS_PROCESS_RESOURCE') . "'";
  688. return $indent . "'" . BFText::_('COM_BREEZINGFORMS_PROCESS_UNKNOWN') . "'";
  689. }
  690. // expJsValue
  691. function expJsVar($name, $mixed) {
  692. return $name . ' = ' . $this->expJsValue($mixed) . ';' . nl();
  693. }
  694. // expJsVar
  695. function dumpTrace() {
  696. if ($this->traceMode & _FF_TRACEMODE_DIRECT) {
  697. $html = ob_get_contents();
  698. ob_end_clean();
  699. echo htmlspecialchars($html, ENT_QUOTES) . $this->traceBuffer;
  700. ob_start();
  701. $this->traceBuffer = null;
  702. return;
  703. } // if
  704. if (!$this->traceBuffer)
  705. return;
  706. if ($this->traceMode & _FF_TRACEMODE_APPEND) {
  707. echo '<pre>' . $this->traceBuffer . '</pre>';
  708. $this->traceBuffer = null;
  709. return;
  710. } // if
  711. echo
  712. '<script type="text/javascript">' . nl() .
  713. '<!--' . nl() .
  714. $this->expJsVar('if(typeof ff_processor != "undefined")ff_processor.traceBuffer', $this->traceBuffer);
  715. if ($this->dying)
  716. echo 'onload = ff_traceWindow();' . nl();
  717. echo
  718. '-->' . nl() .
  719. '</script>' . nl();
  720. $this->traceBuffer = null;
  721. }
  722. // dumpTrace
  723. function traceEval($name) {
  724. if (($this->traceMode & _FF_TRACEMODE_DISABLE) ||
  725. !($this->traceMode & _FF_TRACEMODE_EVAL) ||
  726. $this->dying)
  727. return;
  728. $level = count($this->traceStack);
  729. for ($l = 0; $l < $level; $l++)
  730. $this->traceBuffer .= ' ';
  731. $this->traceBuffer .= htmlspecialchars("eval($name)\n", ENT_QUOTES);
  732. if ($this->traceMode & _FF_TRACEMODE_DIRECT)
  733. $this->dumpTrace();
  734. }
  735. // traceEval
  736. function suicide() {
  737. if ($this->dying)
  738. return false;
  739. $this->dying = true;
  740. $this->errrep = error_reporting(0);
  741. return true;
  742. }
  743. // suicide
  744. function bury() {
  745. if (!$this->dying)
  746. return false;
  747. if ($this->traceMode & _FF_TRACEMODE_DIRECT)
  748. $this->dumpTrace();
  749. ob_end_clean();
  750. if ($this->traceMode & _FF_TRACEMODE_DIRECT)
  751. echo '</pre>'; else
  752. $this->dumpTrace();
  753. error_reporting($this->errrep);
  754. restore_error_handler();
  755. return true;
  756. }
  757. // bury
  758. function findToken(&$code, &$spos, &$offs) {
  759. $srch = '#(function|return|_ff_trace|ff_trace[ \\t]*\\(|//|/\*|\*/|\\\\"|\\\\\'|{|}|\(|\)|;|"|\'|\n)#si';
  760. $match = array();
  761. if (!preg_match($srch, $code, $match, PREG_OFFSET_CAPTURE, $spos))
  762. return '';
  763. $token = strtolower($match[0][0]);
  764. $offs = $match[0][1];
  765. $spos = $offs + strlen($token);
  766. return $token;
  767. }
  768. // findToken
  769. function findRealToken(&$code, &$spos, &$offs, &$line) {
  770. $linecmt = $blockcmt = false;
  771. $quote = null;
  772. for (;;) {
  773. $token = preg_replace('/[ \\t]*/', '', $this->findToken($code, $spos, $offs));
  774. switch ($token) {
  775. case '':
  776. return '';
  777. case 'function':
  778. case 'return';
  779. case 'ff_trace(';
  780. case '{':
  781. case '}':
  782. case '(':
  783. case ')':
  784. case ';':
  785. if (!$linecmt && !$blockcmt && !$quote)
  786. return $token;
  787. break;
  788. case "\n":
  789. $line++;
  790. $linecmt = false;
  791. break;
  792. case '//':
  793. if (!$blockcmt && !$quote)
  794. $linecmt = true;
  795. break;
  796. case '/*':
  797. if (!$linecmt && !$quote)
  798. $longcmt = true;
  799. break;
  800. case '"':
  801. case "'":
  802. if ($quote == $token)
  803. $quote = null;
  804. else
  805. if (!$linecmt && !$blockcmt && !$quote)
  806. $quote = $token;
  807. break;
  808. default:
  809. break;
  810. } // switch
  811. } // for
  812. }
  813. // findRealToken
  814. function patchCode($mode, $code, $name, $type, $id, $pane) {
  815. $flevel = $cpos = $spos = $offs = 0;
  816. $bye = false;
  817. $fstack = array();
  818. $line = 1;
  819. if ($type && $id) {
  820. $type = "'$type'";
  821. if (!$pane)
  822. $pane = 'null';
  823. } else
  824. $type = $id = $pane = 'null';
  825. $name = str_replace("'", "\\'", $name);
  826. $dst = "_ff_tracePiece($mode,'$name',$line,$type,$id,$pane);";
  827. while (!$bye) {
  828. switch ($this->findRealToken($code, $spos, $offs, $line)) {
  829. case '': $bye = true;
  830. break;
  831. case 'function':
  832. $brk = false;
  833. while (!$brk) {
  834. // consume tokens until finding the opening bracket
  835. switch ($this->findRealToken($code, $spos, $offs, $line)) {
  836. case '': $bye = $brk = true;
  837. break;
  838. case '{':
  839. $dst .=
  840. substr($code, $cpos, $spos - $cpos) .
  841. '$_ff_traceArgs = func_get_args();' .
  842. '_ff_traceFunction(' . $mode . ',__FUNCTION__,' . $line . ',' . $type . ',' . $id . ',' . $pane . ',$_ff_traceArgs);' .
  843. '$_ff_traceArgs=null;';
  844. $cpos = $spos;
  845. if ($flevel)
  846. array_push($fstack, $flevel);
  847. $flevel = 1;
  848. $brk = true;
  849. break;
  850. default:;
  851. } // switch
  852. } // while
  853. break;
  854. case 'return':
  855. $dst .= substr($code, $cpos, $spos - $cpos);
  856. $cpos = $spos;
  857. $brk = false;
  858. while (!$brk) {
  859. // consume tokens until semicolon found
  860. switch ($this->findRealToken($code, $spos, $offs, $line)) {
  861. case '': $bye = $brk = true;
  862. break;
  863. case ';':
  864. $arg = substr($code, $cpos, $offs - $cpos);
  865. if ($this->nonblank($arg))
  866. $dst .= ' _ff_traceExit(' . $line . ',' . $arg . ');';
  867. else
  868. $dst .= ' _ff_traceExit(' . $line . ');';
  869. $cpos = $spos;
  870. $brk = true;
  871. break;
  872. default:;
  873. } // switch
  874. } // while
  875. break;
  876. case 'ff_trace(':
  877. $dst .= substr($code, $cpos, $offs - $cpos);
  878. $cpos = $spos;
  879. $brk = false;
  880. $lvl = 0;
  881. while (!$brk) {
  882. // consume tokens until finding the closing bracket
  883. switch ($this->findRealToken($code, $spos, $offs, $line)) {
  884. case '': $bye = $brk = true;
  885. break;
  886. case '(': $lvl++;
  887. break;
  888. case ')':
  889. if ($lvl)
  890. $lvl--; else
  891. $brk = true;
  892. break;
  893. default:;
  894. } // switch
  895. } // while
  896. $par = $offs == $cpos ? '' : substr($code, $cpos, $offs - $cpos);
  897. $dst .= " _ff_trace($line";
  898. if ($this->nonblank($par))
  899. $dst .= ',';
  900. break;
  901. case '{':
  902. if ($flevel > 0)
  903. $flevel++;
  904. break;
  905. case '}';
  906. if ($flevel > 0) {
  907. $flevel--;
  908. if (!$flevel) {
  909. $dst .= substr($code, $cpos, $offs - $cpos) . ' _ff_traceExit(' . $line . ');}';
  910. $cpos = $spos;
  911. if (count($fstack))
  912. $flevel = array_pop($fstack);
  913. } // if
  914. } // if
  915. break;
  916. default:
  917. } // switch
  918. } // while
  919. $spos = strlen($code);
  920. if ($cpos < $spos)
  921. $dst .= substr($code, $cpos, $spos - $cpos);
  922. $line--;
  923. $dst .= "_ff_traceExit($line);";
  924. if (_FF_DEBUG & _FF_DEBUG_PATCHEDCODE) {
  925. $this->traceBuffer .=
  926. htmlspecialchars(
  927. "\n_FF_DEBUG_PATCHEDCODE:" .
  928. "\n Mode = " . $this->dispTraceMode($mode) .
  929. "\n Name = $name" .
  930. "\n Link = $type $id $pane" .
  931. "\n------ begin patched code ------" .
  932. "\n$dst" .
  933. "\n------- end patched code -------" .
  934. "\n", ENT_QUOTES
  935. );
  936. if ($this->traceMode & _FF_TRACEMODE_DIRECT)
  937. $this->dumpTrace();
  938. } // if
  939. return $dst;
  940. }
  941. // patchCode
  942. function prepareEvalCode(&$code, $name, $type, $id, $pane) {
  943. if ($this->dying)
  944. return false;
  945. if (!$this->nonblank($code))
  946. return false;
  947. $code .= "\n/*'/*\"/**/;"; // closes all comments and strings that my be open
  948. $disable = ($this->traceMode & _FF_TRACEMODE_DISABLE) ? true : false;
  949. if (!$disable) {
  950. $mode = 'null';
  951. $srch =
  952. '#' .
  953. '^[\\s]*(//\+trace|/\*\+trace)' .
  954. '[ \\t]*([\\w]+)?' .
  955. '[ \\t]*([\\w]+)?' .
  956. '[ \\t]*([\\w]+)?' .
  957. '[ \\t]*([\\w]+)?' .
  958. '[ \\t]*([\\w]+)?' .
  959. '[ \\t]*([\\w]+)?' .
  960. '[ \\t]*(\\*/|\\r\\n)?' .
  961. '#';
  962. $match = array();
  963. if (preg_match($srch, $code, $match)) {
  964. $mode = 2;
  965. $append = $direct = $xeval = $piece = $func = $msg = false;
  966. $local = $def = true;
  967. for ($m = 2; $m < count($match); $m++)
  968. switch ($match[$m]) {
  969. // disable
  970. case 'dis' :
  971. case 'disable' : $disable = true;
  972. break;
  973. // mode
  974. case 'pop' :
  975. case 'popup' : $direct = $append = false;
  976. break;
  977. case 'app' :
  978. case 'append' : $append = true;
  979. $direct = false;
  980. break;
  981. case 'dir' :
  982. case 'direct' : $direct = true;
  983. $append = false;
  984. break;
  985. // priority
  986. case 'min' :
  987. case 'minimum' : $mode = 0;
  988. break;
  989. case 'low' : $mode = 1;
  990. break;
  991. case 'nor' :
  992. case 'normal' : $mode = 2;
  993. break;
  994. case 'hig' :
  995. case 'high' : $mode = 3;
  996. break;
  997. case 'max' :
  998. case 'maximum' : $mode = 4;
  999. break;
  1000. // scope
  1001. case 'glo' :
  1002. case 'global' : $local = false;
  1003. break;
  1004. case 'loc' :
  1005. case 'local' : $local = true;
  1006. break;
  1007. // topics
  1008. case 'all' : $def = false;
  1009. $xeval = $piece = $func = $msg = true;
  1010. break;
  1011. case 'non' :
  1012. case 'none' : $def = $xeval = $piece = $func = $msg = false;
  1013. break;
  1014. case 'eva' :
  1015. case 'eval' : $def = false;
  1016. $xeval = true;
  1017. break;
  1018. case 'pie' :
  1019. case 'piece' : $def = false;
  1020. $piece = true;
  1021. break;
  1022. case 'fun' :
  1023. case 'function': $def = false;
  1024. $func = true;
  1025. break;
  1026. case 'mes' :
  1027. case 'message' : $def = false;
  1028. $msg = true;
  1029. break;
  1030. default : break;
  1031. } // switch
  1032. if ($def) {
  1033. $xeval = false;
  1034. $piece = $func = $msg = true;
  1035. }
  1036. if ($xeval)
  1037. $mode |= _FF_TRACEMODE_EVAL;
  1038. if ($piece)
  1039. $mode |= _FF_TRACEMODE_PIECE;
  1040. if ($func)
  1041. $mode |= _FF_TRACEMODE_FUNCTION;
  1042. if ($msg)
  1043. $mode |= _FF_TRACEMODE_MESSAGE;
  1044. if ($local)
  1045. $mode |= _FF_TRACEMODE_LOCAL;
  1046. $first = ($this->traceMode & _FF_TRACEMODE_FIRST) ? true : false;
  1047. if ($first) {
  1048. $oldMode = $this->traceMode;
  1049. $this->traceMode = 0;
  1050. if ($disable)
  1051. $this->traceMode |= _FF_TRACEMODE_DISABLE;
  1052. if ($append)
  1053. $this->traceMode |= _FF_TRACEMODE_APPEND;
  1054. if ($direct) {
  1055. $this->traceMode |= _FF_TRACEMODE_DIRECT;
  1056. $html = ob_get_contents();
  1057. ob_end_clean();
  1058. echo '<pre>' . htmlspecialchars($html, ENT_QUOTES);
  1059. ob_start();
  1060. } // if
  1061. } else
  1062. $disable = false;
  1063. if (_FF_DEBUG & _FF_DEBUG_DIRECTIVE) {
  1064. $_deb = "\n_FF_DEBUG_DIRECTIVE:";
  1065. if ($first)
  1066. $_deb .= "\n Previous mode=" . $this->dispTraceMode($oldMode);
  1067. $_deb .=
  1068. "\n Trace mode =" . $this->dispTraceMode($this->traceMode) .
  1069. "\n New mode =" . $this->dispTraceMode($mode) .
  1070. "\n";
  1071. $this->traceBuffer .= htmlspecialchars($_deb, ENT_QUOTES);
  1072. if ($this->traceMode & _FF_TRACEMODE_DIRECT)
  1073. $this->dumpTrace();
  1074. } // if
  1075. } // if trace directive
  1076. if (!$disable) {
  1077. if (!$name) {
  1078. $name = preg_replace('/([\\s]+)/si', ' ', $code);
  1079. if (strlen($name) > _FF_TRACE_NAMELIMIT)
  1080. $name = substr($code, 0, _FF_TRACE_NAMELIMIT - 3) . '...';
  1081. } // if
  1082. $code = $this->patchCode($mode, $code, $name, $type, $id, $pane);
  1083. } // if
  1084. } // if trace not disabled
  1085. $code = str_replace($this->findtags, $this->replacetags, $code);
  1086. return true;
  1087. }
  1088. // prepareEvalCode
  1089. function getPieceById($id, $name=null) {
  1090. if ($this->dying)
  1091. return '';
  1092. global $database;
  1093. $database = JFactory::getDBO();
  1094. $database->setQuery(
  1095. 'select code, name from #__facileforms_pieces ' .
  1096. 'where id=' . $id . ' and published=1 '
  1097. );
  1098. $rows = $database->loadObjectList();
  1099. if ($rows && count($rows)) {
  1100. $name = $rows[0]->name;
  1101. return $rows[0]->code;
  1102. } // if
  1103. return '';
  1104. }
  1105. // getPieceById
  1106. function getPieceByName($name, $id=null) {
  1107. if ($this->dying)
  1108. return '';
  1109. global $database;
  1110. $database = JFactory::getDBO();
  1111. $database->setQuery(
  1112. 'select id, code from #__facileforms_pieces ' .
  1113. 'where name=\'' . $name . '\' and published=1 ' .
  1114. 'order by id desc'
  1115. );
  1116. $rows = $database->loadObjectList();
  1117. if ($rows && count($rows)) {
  1118. $id = $rows[0]->id;
  1119. return $rows[0]->code;
  1120. } // if
  1121. return '';
  1122. }
  1123. // getPieceByName
  1124. function execPiece($code, $name, $type, $id, $pane) {
  1125. $ret = '';
  1126. if ($this->prepareEvalCode($code, $name, $type, $id, $pane)) {
  1127. $this->traceEval($name);
  1128. $ret = eval($code);
  1129. } // if
  1130. return $ret;
  1131. }
  1132. // execPiece
  1133. function execPieceById($id) {
  1134. $name = null;
  1135. $code = $this->getPieceById($id, $name);
  1136. return $this->execPiece($code, BFText::_('COM_BREEZINGFORMS_PROCESS_PIECE') . " $name", 'p', $id, null);
  1137. }
  1138. // execPieceById
  1139. function execPieceByName($name) {
  1140. $id = null;
  1141. $code = $this->getPieceByName($name, $id);
  1142. return $this->execPiece($code, BFText::_('COM_BREEZINGFORMS_PROCESS_PIECE') . " $name", 'p', $id, null);
  1143. }
  1144. // execPieceByName
  1145. function replaceCode($code, $name, $type, $id, $pane) {
  1146. if ($this->dying)
  1147. return '';
  1148. $p1 = 0;
  1149. $l = strlen($code);
  1150. $c = '';
  1151. $n = 0;
  1152. while ($p1 < $l) {
  1153. $p2 = strpos($code, '<?php', $p1);
  1154. if ($p2 === false)
  1155. $p2 = $l;
  1156. $c .= substr($code, $p1, $p2 - $p1);
  1157. $p1 = $p2;
  1158. if ($p1 < $l) {
  1159. $p1 += 5;
  1160. $p2 = strpos($code, '?>', $p1);
  1161. if ($p2 === false)
  1162. $p2 = $l;
  1163. $n++;
  1164. $c .= $this->execPiece(substr($code, $p1, $p2 - $p1), $name . "[$n]", $type, $id, $pane);
  1165. if ($this->dying)
  1166. return '';
  1167. $p1 = $p2 + 2;
  1168. } // if
  1169. } // while
  1170. return str_replace($this->findtags, $this->replacetags, $c);
  1171. }
  1172. // replaceCode
  1173. function compileQueryCol(&$elem, &$coldef) {
  1174. $coldef->comp = array();
  1175. if ($this->trim(str_replace($this->findtags, $this->replacetags, $coldef->value))) {
  1176. $c = $p1 = 0;
  1177. $l = strlen($coldef->value);
  1178. while ($p1 < $l) {
  1179. $p2 = strpos($coldef->value, '<?php', $p1);
  1180. if ($p2 === false)
  1181. $p2 = $l;
  1182. $coldef->comp[$c] = array(
  1183. false,
  1184. str_replace(
  1185. $this->findtags, $this->replacetags, trim(substr($coldef->value, $p1, $p2 - $p1))
  1186. )
  1187. );
  1188. if ($this->trim($coldef->comp[$c][1]))
  1189. $c++;
  1190. $p1 = $p2;
  1191. if ($p1 < $l) {
  1192. $p1 += 5;
  1193. $p2 = strpos($coldef->value, '?>', $p1);
  1194. if ($p2 === false)
  1195. $p2 = $l;
  1196. $coldef->comp[$c] = array(true, substr($coldef->value, $p1, $p2 - $p1));
  1197. if ($this->prepareEvalCode(
  1198. $coldef->comp[$c][1], BFText::_('COM_BREEZINGFORMS_PROCESS_QVALUEOF') . " " . $elem->name . "::" . $coldef->name, 'e', $elem->id, 2
  1199. )
  1200. )
  1201. $c++;
  1202. $p1 = $p2 + 2;
  1203. } // if
  1204. } // while
  1205. if ($c > count($coldef->comp))
  1206. array_pop($coldef->comp);
  1207. } // if non-empty
  1208. }
  1209. // compileQueryCol
  1210. function execQueryValue($code, &$elem, &$row, &$coldef, $value) {
  1211. $this->traceEval(BFText::_('COM_BREEZINGFORMS_PROCESS_QVALUEOF') . " " . $elem->name . "::" . $coldef->name);
  1212. return eval($code);
  1213. }
  1214. // execQueryValue
  1215. function execQuery(&$elem, &$valrows, &$coldefs) {
  1216. $ret = null;
  1217. $code = $elem->data2;
  1218. if ($this->prepareEvalCode($code, BFText::_('COM_BREEZINGFORMS_PROCESS_QPIECEOF') . " " . $elem->name, 'e', $elem->id, 1)) {
  1219. $rows = array();
  1220. $this->traceEval(BFText::_('COM_BREEZINGFORMS_PROCESS_QPIECEOF') . " " . $elem->name);
  1221. eval($code);
  1222. $rcnt = count($rows);
  1223. $ccnt = count($coldefs);
  1224. $valrows = array();
  1225. for ($r = 0; $r < $rcnt; $r++) {
  1226. $row = &$rows[$r];
  1227. $valrow = array();
  1228. for ($c = 0; $c < $ccnt; $c++) {
  1229. $coldef = &$coldefs[$c];
  1230. $cname = $coldef->name;
  1231. $value = isset($row->$cname) ? str_replace($this->findtags, $this->replacetags, $row->$cname) : '';
  1232. $xcnt = count($coldef->comp);
  1233. if (!$xcnt)
  1234. $valrow[] = $value;
  1235. else {
  1236. $val = '';
  1237. for ($x = 0; $x < $xcnt; $x++) {
  1238. $val .= $coldef->comp[$x][0] ? $this->execQueryValue($coldef->comp[$x][1], $elem, $row, $coldef, $value) : $coldef->comp[$x][1];
  1239. if ($this->dying)
  1240. break;
  1241. } // for
  1242. $valrow[] = str_replace($this->findtags, $this->replacetags, $val);
  1243. } // if
  1244. unset($coldef);
  1245. if ($this->dying)
  1246. break;
  1247. } // for
  1248. $valrows[] = $valrow;
  1249. unset($row);
  1250. if ($this->dying)
  1251. break;
  1252. } // for
  1253. $rows = null;
  1254. } // if
  1255. }
  1256. // execQuery
  1257. function script2clause(&$row) {
  1258. if ($this->dying)
  1259. return '';
  1260. global $database;
  1261. $database = JFactory::getDBO();
  1262. $funcname = '';
  1263. switch ($row->script2cond) {
  1264. case 1:
  1265. $database->setQuery(
  1266. "select name from #__facileforms_scripts " .
  1267. "where id=" . $row->script2id . " and published=1 "
  1268. );
  1269. $funcname = $database->loadResult();
  1270. break;
  1271. case 2:
  1272. $funcname = 'ff_' . $row->name . '_action';
  1273. break;
  1274. default:
  1275. break;
  1276. } // switch
  1277. $attribs = '';
  1278. if ($funcname != '') {
  1279. if ($row->script2flag1)
  1280. $attribs .= ' onclick="' . $funcname . '(this,\'click\');"';
  1281. if ($row->script2flag2)
  1282. $attribs .= ' onblur="' . $funcname . '(this,\'blur\');"';
  1283. if ($row->script2flag3)
  1284. $attribs .= ' onchange="' . $funcname . '(this,\'change\');"';
  1285. if ($row->script2flag4)
  1286. $attribs .= ' onfocus="' . $funcname . '(this,\'focus\');"';
  1287. if ($row->script2flag5)
  1288. $attribs .= ' onselect="' . $funcname . '(this,\'select\');"';
  1289. } // if
  1290. return $attribs;
  1291. }
  1292. // script2clause
  1293. function loadBuiltins(&$library) {
  1294. global $database, $ff_config, $ff_request;
  1295. $database = JFactory::getDBO();
  1296. if ($this->dying)
  1297. return;
  1298. $library[] = array('FF_STATUS_OK', 'var FF_STATUS_OK = ' . _FF_STATUS_OK . ';');
  1299. $library[] = array('FF_STATUS_UNPUBLISHED', 'var FF_STATUS_UNPUBLISHED = ' . _FF_STATUS_UNPUBLISHED . ';');
  1300. $library[] = array('FF_STATUS_SAVERECORD_FAILED', 'var FF_STATUS_SAVERECORD_FAILED = ' . _FF_STATUS_SAVERECORD_FAILED . ';');
  1301. $library[] = array('FF_STATUS_SAVESUBRECORD_FAILED', 'var FF_STATUS_SAVESUBRECORD_FAILED = ' . _FF_STATUS_SAVESUBRECORD_FAILED . ';');
  1302. $library[] = array('FF_STATUS_UPLOAD_FAILED', 'var FF_STATUS_UPLOAD_FAILED = ' . _FF_STATUS_UPLOAD_FAILED . ';');
  1303. $library[] = array('FF_STATUS_SENDMAIL_FAILED', 'var FF_STATUS_SENDMAIL_FAILED = ' . _FF_STATUS_SENDMAIL_FAILED . ';');
  1304. $library[] = array('FF_STATUS_ATTACHMENT_FAILED', 'var FF_STATUS_ATTACHMENT_FAILED = ' . _FF_STATUS_ATTACHMENT_FAILED . ';');
  1305. $library[] = array('ff_homepage', "var ff_homepage = '" . $this->homepage . "';");
  1306. $library[] = array('ff_currentpage', "var ff_currentpage = " . $this->page . ";");
  1307. $library[] = array('ff_lastpage', "var ff_lastpage = " . $this->formrow->pages . ";");
  1308. $library[] = array('ff_images', "var ff_images = '" . $this->images . "';");
  1309. $library[] = array('ff_validationFocusName', "var ff_validationFocusName = '';");
  1310. $library[] = array('ff_currentheight', "var ff_currentheight = 0;");
  1311. $code = "var ff_elements = [" . nl();
  1312. for ($i = 0; $i < $this->rowcount; $i++) {
  1313. $row = $this->rows[$i];
  1314. $endline = "," . nl();
  1315. if ($i == $this->rowcount - 1)
  1316. $endline = nl();
  1317. switch ($row->type) {
  1318. case "Hidden Input":
  1319. $code .= " ['ff_elem" . $row->id . "', 'ff_elem" . $row->id . "', '" . $row->name . "', " . $row->page . ", " . $row->id . "]" . $endline;
  1320. break;
  1321. case "Static Text":
  1322. case "Rectangle":
  1323. case "Tooltip":
  1324. case "Icon":
  1325. $code .= " ['ff_div" . $row->id . "', 'ff_div" . $row->id . "', '" . $row->name . "', " . $row->page . ", " . $row->id . "]" . $endline;
  1326. break;
  1327. default:
  1328. $code .= " ['ff_elem" . $row->id . "', 'ff_div" . $row->id . "', '" . $row->name . "', " . $row->page . ", " . $row->id . "]" . $endline;
  1329. } // switch
  1330. } // for
  1331. $code .= "];";
  1332. $library[] = array('ff_elements', $code);
  1333. $code = "var ff_param = new Object();";
  1334. reset($ff_request);
  1335. while (list($prop, $val) = each($ff_request))
  1336. if (substr($prop, 0, 9) == 'ff_param_')
  1337. $code .= nl() . "ff_param." . substr($prop, 9) . " = '" . $val . "';";
  1338. $library[] = array('ff_param', $code);
  1339. $library[] = array('ff_getElementByIndex',
  1340. "function ff_getElementByIndex(index)" . nl() .
  1341. "{" . nl() .
  1342. " if (index >= 0 && index < ff_elements.length)" . nl() .
  1343. " return eval('document." . $this->form_id . ".'+ff_elements[index][0]);" . nl() .
  1344. " return null;" . nl() .
  1345. "} // ff_getElementByIndex"
  1346. );
  1347. $library[] = array('ff_getElementByName',
  1348. "function ff_getElementByName(name)" . nl() .
  1349. "{" . nl() .
  1350. " if (name.substr(0,6) == 'ff_nm_') name = name.substring(6,name.length-2);" . nl() .
  1351. " for (var i = 0; i < ff_elements.length; i++)" . nl() .
  1352. " if (ff_elements[i][2]==name)" . nl() .
  1353. " return eval('document." . $this->form_id . ".'+ff_elements[i][0]);" . nl() .
  1354. " return null;" . nl() .
  1355. "} // ff_getElementByName"
  1356. );
  1357. $library[] = array('ff_getPageByName',
  1358. "function ff_getPageByName(name)" . nl() .
  1359. "{" . nl() .
  1360. " if (name.substr(0,6) == 'ff_nm_') name = name.substring(6,name.length-2);" . nl() .
  1361. " for (var i = 0; i < ff_elements.length; i++)" . nl() .
  1362. " if (ff_elements[i][2]==name)" . nl() .
  1363. " return ff_elements[i][3];" . nl() .
  1364. " return 0;" . nl() .
  1365. "} // ff_getPageByName"
  1366. );
  1367. $library[] = array('ff_getDivByName',
  1368. "function ff_getDivByName(name)" . nl() .
  1369. "{" . nl() .
  1370. " if (name.substr(0,6) == 'ff_nm_') name = name.substring(6,name.length-2);" . nl() .
  1371. " for (var i = 0; i < ff_elements.length; i++)" . nl() .
  1372. " if (ff_elements[i][2]==name)" . nl() .
  1373. " return document.getElementById(ff_elements[i][1]);" . nl() .
  1374. " return null;" . nl() .
  1375. "} // ff_getDivByName"
  1376. );
  1377. $library[] = array('ff_getIdByName',
  1378. "function ff_getIdByName(name)" . nl() .
  1379. "{" . nl() .
  1380. " if (name.substr(0,6) == 'ff_nm_') name = name.substring(6,name.length-2);" . nl() .
  1381. " for (var i = 0; i < ff_elements.length; i++)" . nl() .
  1382. " if (ff_elements[i][2]==name)" . nl() .
  1383. " return ff_elements[i][4];" . nl() .
  1384. " return null;" . nl() .
  1385. "} // ff_getIdByName"
  1386. );
  1387. $library[] = array('ff_getForm',
  1388. "function ff_getForm()" . nl() .
  1389. "{" . nl() .
  1390. " return document." . $this->form_id . ";" . nl() .
  1391. "} // ff_getForm"
  1392. );
  1393. $code = "function ff_submitForm()" . nl() .
  1394. "{bfCheckCaptcha();}" . nl();
  1395. $code.= "function ff_submitForm2()" . nl() .
  1396. "{" . nl();
  1397. if ($this->inline)
  1398. $code .= " submitform('submit');" . nl();
  1399. else
  1400. $code .= " document." . $this->form_id . ".submit();" . nl();
  1401. $code .= "} // ff_submitForm";
  1402. $library[] = array('ff_submitForm', $code);
  1403. $library[] = array('ff_validationFocus',
  1404. "function ff_validationFocus(name)" . nl() .
  1405. "{" . nl() .
  1406. " if (name==undefined || name=='') {" . nl() .
  1407. " // set focus if name of first failing element was set" . nl() .
  1408. " if (ff_validationFocusName!='') {" . nl() .
  1409. " ff_switchpage(ff_getPageByName(ff_validationFocusName));" . nl() .
  1410. " if(ff_getElementByName(ff_validationFocusName).focus){" . nl() .
  1411. " ff_getElementByName(ff_validationFocusName).focus();" . nl() .
  1412. " }" . nl() .
  1413. " } // if" . nl() .
  1414. " } else {" . nl() .
  1415. " // store name if this is the first failing element" . nl() .
  1416. " if (ff_validationFocusName=='')" . nl() .
  1417. " ff_validationFocusName = name;" . nl() .
  1418. " } // if" . nl() .
  1419. "} // ff_validationFocus"
  1420. );
  1421. $code = "function ff_validation(page)" . nl() .
  1422. "{" . nl() .
  1423. " if(typeof inlineErrorElements != 'undefined') inlineErrorElements = new Array();" . nl() .
  1424. " error = '';" . nl() .
  1425. " ff_validationFocusName = '';" . nl();
  1426. $curr = -1;
  1427. for ($i = 0; $i < $this->rowcount; $i++) {
  1428. $row = $this->rows[$i];
  1429. $funcname = '';
  1430. switch ($row->script3cond) {
  1431. case 1:
  1432. $database->setQuery(
  1433. "select name from #__facileforms_scripts " .
  1434. "where id=" . $row->script3id . " and published=1 "
  1435. );
  1436. $funcname = $database->loadResult();
  1437. break;
  1438. case 2:
  1439. $funcname = 'ff_' . $row->name . '_validation';
  1440. break;
  1441. default:
  1442. break;
  1443. } // switch
  1444. if ($funcname != '') {
  1445. if ($row->page != $curr) {
  1446. if ($curr > 0)
  1447. $code .= " } // if" . nl();
  1448. $code .= " if (page==" . $row->page . " || page==0) {" . nl();
  1449. $curr = $row->page;
  1450. } // if
  1451. if ($this->trim($row->script3msg))
  1452. $msg = addslashes($row->script3msg) . "\\n"; else
  1453. $msg = "";
  1454. $code .= " if( typeof bfDeactivateField == 'undefined' || !bfDeactivateField['ff_nm_" . $row->name . "[]'] ){ " . nl();
  1455. $code .= " errorout = " . $funcname . "(document." . $this->form_id . "['ff_nm_" . $row->name . "[]'],\"" . $msg . "\");" . nl();
  1456. $code .= " error += errorout" . nl();
  1457. $code .= " if(typeof inlineErrorElements != 'undefined'){" . nl();
  1458. $code .= " inlineErrorElements.push([\"" . $row->name . "\",errorout]);" . nl();
  1459. $code .= " }" . nl();
  1460. $code .= "}" . nl();
  1461. } // if
  1462. } // for
  1463. if ($curr > 0)
  1464. $code .= " } // if" . nl();
  1465. $code .= 'if(error != "" && document.getElementById(\'ff_capimgValue\')){
  1466. document.getElementById(\'ff_capimgValue\').src = \'' . JURI::root(true) . (JFactory::getApplication()->isAdmin() ? '/administrator' : '') . '/components/com_breezingforms/images/captcha/securimage_show.php?bfMathRandom=\' + Math.random();
  1467. document.getElementById(\'bfCaptchaEntry\').value = "";
  1468. }';
  1469. $code .= " return error;" . nl() .
  1470. "} // ff_validation";
  1471. $library[] = array('ff_validation', $code);
  1472. // ff_initialize
  1473. $code = "function ff_initialize(condition)" . nl() .
  1474. "{" . nl();
  1475. $formentry = false;
  1476. $funcname = '';
  1477. switch ($this->formrow->script1cond) {
  1478. case 1:
  1479. $database->setQuery(
  1480. "select name from #__facileforms_scripts " .
  1481. "where id=" . $this->formrow->script1id . " and published=1 "
  1482. );
  1483. $funcname = $database->loadResult();
  1484. break;
  1485. case 2:
  1486. $funcname = 'ff_' . $this->formrow->name . '_init';
  1487. break;
  1488. default:
  1489. break;
  1490. } // switch
  1491. if ($funcname != '') {
  1492. $code .= " if (condition=='formentry') {" . nl() .
  1493. " " . $funcname . "();" . nl();
  1494. $formentry = true;
  1495. } // if
  1496. for ($i = 0; $i < $this->rowcount; $i++) {
  1497. $row = $this->rows[$i];
  1498. $funcname = '';
  1499. switch ($row->script1cond) {
  1500. case 1:
  1501. $database->setQuery(
  1502. "select name from #__facileforms_scripts " .
  1503. "where id=" . $row->script1id . " and published=1 "
  1504. );
  1505. $funcname = $database->loadResult();
  1506. break;
  1507. case 2:
  1508. $funcname = 'ff_' . $row->name . '_init';
  1509. break;
  1510. default:
  1511. break;
  1512. } // switch
  1513. if ($funcname != '') {
  1514. if ($row->script1flag1) {
  1515. if (!$formentry) {
  1516. $code .= " if (condition=='formentry') {" . nl();
  1517. $formentry = true;
  1518. } // if
  1519. $code .= " " . $funcname . "(document." . $this->form_id . "['ff_nm_" . $row->name . "[]'], condition);" . nl();
  1520. } // if
  1521. } // if
  1522. } // for
  1523. $pageentry = false;
  1524. $curr = -1;
  1525. for ($i = 0; $i < $this->rowcount; $i++) {
  1526. $row = $this->rows[$i];
  1527. $funcname = '';
  1528. switch ($row->script1cond) {
  1529. case 1:
  1530. $database->setQuery(
  1531. "select name from #__facileforms_scripts " .
  1532. "where id=" . $row->script1id . " and published=1 "
  1533. );
  1534. $funcname = $database->loadResult();
  1535. break;
  1536. case 2:
  1537. $funcname = 'ff_' . $row->name . '_init';
  1538. break;
  1539. default:
  1540. break;
  1541. } // switch
  1542. if ($funcname != '') {
  1543. if ($row->script1flag2) { // page entry
  1544. if ($formentry) {
  1545. $code .= " } else" . nl();
  1546. $formentry = false;
  1547. } // if
  1548. if (!$pageentry) {
  1549. $code .= " if (condition=='pageentry') {" . nl();
  1550. $pageentry = true;
  1551. } // if
  1552. if ($curr != $row->page) {
  1553. if ($curr > 0)
  1554. $code .= " } // if" . nl();
  1555. $code .= " if (ff_currentpage==" . $row->page . ") {" . nl();
  1556. $curr = $row->page;
  1557. } // if
  1558. $code .= " " . $funcname . "(document." . $this->form_id . ".ff_elem" . $row->id . ", condition);" . nl();
  1559. } // if
  1560. } // if
  1561. } // for
  1562. if ($curr > 0)
  1563. $code .= " } // if" . nl();
  1564. if ($formentry || $pageentry)
  1565. $code .= " } // if" . nl();
  1566. $code .= "} // ff_initialize";
  1567. $library[] = array('ff_initialize', $code);
  1568. if ($this->showgrid) {
  1569. if ($this->formrow->widthmode)
  1570. $width = $this->formrow->prevwidth;
  1571. else
  1572. $width = $this->formrow->width;
  1573. $library[] = array('ff_showgrid',
  1574. "var ff_gridvcnt = 0;" . nl() .
  1575. "var ff_gridhcnt = 0;" . nl() .
  1576. "var ff_gridheight = " . $this->formrow->height . ";" . nl() .
  1577. nl() .
  1578. "function ff_showgrid()" . nl() .
  1579. "{" . nl() .
  1580. " var i, e, s;" . nl() .
  1581. " var hcnt = parseInt(ff_gridheight / " . $ff_config->gridsize . ")+1;" . nl() .
  1582. " var vcnt = parseInt(" . $width . " / " . $ff_config->gridsize . ")+1;" . nl() .
  1583. " var formdiv = document.getElementById('ff_formdiv" . $this->form . "');" . nl() .
  1584. " var firstelem = formdiv.firstChild;" . nl() .
  1585. " for (i = ff_gridhcnt; i < hcnt; i++) {" . nl() .
  1586. " e = document.createElement('div');" . nl() .
  1587. " e.id = 'ff_gridh'+i;" . nl() .
  1588. " s = e.style;" . nl() .
  1589. " s.position = 'absolute';" . nl() .
  1590. " s.left = '0px';" . nl() .
  1591. " s.top = (i*" . $ff_config->gridsize . ")+'px';" . nl() .
  1592. " s.width = '" . $width . "px';" . nl() .
  1593. " s.fontSize = '0px';" . nl() .
  1594. " s.lineHeight = '1px';" . nl() .
  1595. " s.height = '1px';" . nl() .
  1596. " if (i % 2)" . nl() .
  1597. " s.background = '" . $ff_config->gridcolor2 . "';" . nl() .
  1598. " else" . nl() .
  1599. " s.background = '" . $ff_config->gridcolor1 . "';" . nl() .
  1600. " formdiv.insertBefore(e,firstelem);" . nl() .
  1601. " } // for" . nl() .
  1602. " if (hcnt > ff_gridhcnt) ff_gridhcnt = hcnt;" . nl() .
  1603. " for (i = 0; i < ff_gridvcnt; i++)" . nl() .
  1604. " document.getElementById('ff_gridv'+i).style.height = ff_gridheight+'px';" . nl() .
  1605. " for (i = ff_gridvcnt; i < vcnt; i++) {" . nl() .
  1606. " e = document.createElement('div');" . nl() .
  1607. " e.id = 'ff_gridv'+i;" . nl() .
  1608. " s = e.style;" . nl() .
  1609. " s.position = 'absolute';" . nl() .
  1610. " s.left = (i*" . $ff_config->gridsize . ")+'px';" . nl() .
  1611. " s.top = '0px';" . nl() .
  1612. " s.width = '1px';" . nl() .
  1613. " s.height = ff_gridheight+'px';" . nl() .
  1614. " if (i % 2)" . nl() .
  1615. " s.background = '" . $ff_config->gridcolor2 . "';" . nl() .
  1616. " else" . nl() .
  1617. " s.background = '" . $ff_config->gridcolor1 . "';" . nl() .
  1618. " formdiv.insertBefore(e,firstelem);" . nl() .
  1619. " } // for" . nl() .
  1620. " if (vcnt > ff_gridvcnt) ff_gridvcnt = vcnt;" . nl() .
  1621. "} // ff_showgrid"
  1622. );
  1623. } // if
  1624. // ff_resizePage
  1625. $code =
  1626. "function ff_resizepage(mode, value)" . nl() .
  1627. "{" . nl() .
  1628. " var height = 0;" . nl() .
  1629. " if (mode > 0) {" . nl() .
  1630. " for (var i = 0; i < ff_elements.length; i++) {" . nl() .
  1631. " if (mode==2 || ff_elements[i][3]==ff_currentpage) {" . nl() .
  1632. " e = document.getElementById(ff_elements[i][1]);" . nl() .
  1633. " if(e){" . nl() .
  1634. " h = e.offsetTop+e.offsetHeight;" . nl() .
  1635. " if (h > height) height = h;" . nl() .
  1636. " }" . nl() .
  1637. " } // if" . nl() .
  1638. " } // for" . nl() .
  1639. " } // if" . nl() .
  1640. " var totheight = height+value;" . nl() .
  1641. " if ((mode==2 && totheight>ff_currentheight) || (mode!=2 && totheight!=ff_currentheight)) {" . nl();
  1642. if ($this->inframe) {
  1643. $fn = ($this->runmode == _FF_RUNMODE_PREVIEW) ? 'ff_prevframe' : ('ff_frame' . $this->form);
  1644. $code .=
  1645. " parent.document.getElementById('" . $fn . "').style.height = totheight+'px';" . nl() .
  1646. " parent.window.scrollTo(0,0);" . nl() .
  1647. " document.getElementById('ff_formdiv" . $this->form . "').style.height = height+'px';" . nl() .
  1648. " window.scrollTo(0,0);" . nl();
  1649. } // if
  1650. else
  1651. $code .=
  1652. " document.getElementById('ff_formdiv" . $this->form . "').style.height = totheight+'px';" . nl() .
  1653. " window.scrollTo(0,0);" . nl();
  1654. $code .=
  1655. " ff_currentheight = totheight;" . nl();
  1656. if ($this->showgrid) {
  1657. $code .=
  1658. " ff_gridheight = totheight;" . nl() .
  1659. " ff_showgrid();" . nl();
  1660. } // if
  1661. $code .=
  1662. " } // if" . nl() .
  1663. "} // ff_resizepage";
  1664. $library[] = array('ff_resizepage', $code);
  1665. if ($this->formrow->template_code_processed == '') {
  1666. // ff_switchpage
  1667. $code = "function ff_switchpage(page)" . nl() .
  1668. "{;" . nl() .
  1669. " if (page>=1 && page<=ff_lastpage && page!=ff_currentpage) {" . nl() .
  1670. " vis = 'visible';" . nl();
  1671. $curr = -1;
  1672. for ($i = 0; $i < $this->rowcount; $i++) {
  1673. $row = $this->rows[$i];
  1674. if ($row->type != "Hidden Input") {
  1675. if ($row->page != $curr) {
  1676. if ($curr >= 1)
  1677. $code .= " } // if" . nl();
  1678. $code .= " if (page==" . $row->page . " || ff_currentpage==" . $row->page . ") {" . nl() .
  1679. " if (page==" . $row->page . ") vis = 'visible'; else vis = 'hidden';" . nl();
  1680. $curr = $row->page;
  1681. } // if
  1682. $code .= " document.getElementById('ff_div" . $row->id . "').style.visibility=vis;" . nl();
  1683. } // if
  1684. } // for
  1685. if ($curr >= 1)
  1686. $code .= " } // if" . nl();
  1687. $code .= " ff_currentpage = page;" . nl();
  1688. if ($this->formrow->heightmode == 1)
  1689. $code .=
  1690. " ff_resizepage(" . $this->formrow->heightmode . ", " . $this->formrow->height . ");" . nl();
  1691. $code .= " ff_initialize('pageentry');" . nl() .
  1692. " } // if" . nl() .
  1693. "} // ff_switchpage";
  1694. }
  1695. else {
  1696. $visPages = '';
  1697. $pagesSize = isset($this->formrow->pages) ? intval($this->formrow->pages) : 1;
  1698. for ($pageCnt = 1; $pageCnt <= $pagesSize; $pageCnt++) {
  1699. $visPages .= 'if(document.getElementById("bfPage' . $pageCnt . '"))document.getElementById("bfPage' . $pageCnt . '").style.display = "none";';
  1700. }
  1701. $code = 'function ff_switchpage(page){
  1702. ' . $visPages . '
  1703. if(document.getElementById("bfPage"+page))document.getElementById("bfPage"+page).style.display = "";
  1704. ff_currentpage = page;
  1705. ' . ($this->formrow->heightmode == 1 ? "ff_resizepage(" . $this->formrow->heightmode . ", " . $this->formrow->height . ");" : "") . '
  1706. ff_initialize("pageentry");
  1707. }';
  1708. }
  1709. $library[] = array('ff_switchpage', $code);
  1710. }
  1711. // loadBuiltins
  1712. function loadScripts(&$library) {
  1713. global $database;
  1714. $database = JFactory::getDBO();
  1715. if ($this->dying)
  1716. return;
  1717. $database->setQuery(
  1718. "select id, name, code from #__facileforms_scripts " .
  1719. "where published=1 " .
  1720. "order by type, title, name, id desc"
  1721. );
  1722. $rows = $database->loadObjectList();
  1723. $cnt = count($rows);
  1724. for ($i = 0; $i < $cnt; $i++) {
  1725. $row = $rows[$i];
  1726. $library[] = array(trim($row->name), $row->code, 's', $row->id, null);
  1727. } // if
  1728. }
  1729. // loadScripts
  1730. function compressJavascript($str) {
  1731. if ($this->dying)
  1732. return '';
  1733. $str = str_replace("\r", "", $str);
  1734. $lines = explode("\n", $str);
  1735. $code = '';
  1736. $skip = '';
  1737. $lcnt = 0;
  1738. if (count($lines))
  1739. foreach ($lines as $line) {
  1740. $ll = strlen($line);
  1741. $quote = '';
  1742. $ws = false;
  1743. $escape = false;
  1744. for ($j = 0; $j < $ll; $j++) {
  1745. $c = substr($line, $j, 1);
  1746. $d = substr($line, $j, 2);
  1747. if ($quote != '') {
  1748. // in literal
  1749. if ($escape) {
  1750. $code .= $c;
  1751. $lcnt++;
  1752. $escape = false;
  1753. } else
  1754. if ($c == "\\") {
  1755. $code .= $c;
  1756. $lcnt++;
  1757. $escape = true;
  1758. } else
  1759. if ($d == $quote . $quote) {
  1760. $code .= $d;
  1761. $lcnt += 2;
  1762. $j += 2;
  1763. } else {
  1764. $code .= $c;
  1765. $lcnt++;
  1766. if ($c == $quote)
  1767. $quote = '';
  1768. } // if
  1769. } else {
  1770. // not in literal
  1771. if ($d == $skip) {
  1772. $skip = '';
  1773. $j += 2;
  1774. } else
  1775. if ($skip == '') {
  1776. if ($d == '/*') {
  1777. $skip = '*/';
  1778. $j += 2;
  1779. } else
  1780. if ($d == '//')
  1781. break;
  1782. else
  1783. switch ($c) {
  1784. case ' ':
  1785. case "\t":
  1786. case "\n":
  1787. if ($lcnt)
  1788. $ws = true;
  1789. break;
  1790. case '"':
  1791. case "'":
  1792. if ($ws) {
  1793. $b = substr($code, strlen($code) - 1, 1);
  1794. if ($b == '_' || ($b >= '0' && $b <= '9') || ($b >= 'a' && $b <= 'z') || ($b >= 'A' && $b <= 'Z')) {
  1795. $code .= ' ';
  1796. $lcnt++;
  1797. } // if
  1798. $ws = false;
  1799. } // if
  1800. $quote = $c;
  1801. $code .= $c;
  1802. $lcnt++;
  1803. break;
  1804. default:
  1805. if ($ws) {
  1806. if ($c == '_' || ($c >= '0' && $c <= '9') || ($c >= 'a' && $c <= 'z') || ($c >= 'A' && $c <= 'Z')) {
  1807. $b = substr($code, strlen($code) - 1, 1);
  1808. if ($b == '_' || ($b >= '0' && $b <= '9') || ($b >= 'a' && $b <= 'z') || ($b >= 'A' && $b <= 'Z')) {
  1809. $code .= ' ';
  1810. $lcnt++;
  1811. } // if
  1812. } // if
  1813. $ws = false;
  1814. } // if
  1815. $code .= $c;
  1816. $lcnt++;
  1817. } // switch
  1818. } // if
  1819. } // else
  1820. } // for
  1821. if ($lcnt) {
  1822. if ($lcnt > _FF_PACKBREAKAFTER) {
  1823. $code .= nl();
  1824. $lcnt = 0;
  1825. } else {
  1826. if (strpos(',;:{}=[(+-*%', substr($code, strlen($code) - 1, 1)) === false) {
  1827. $code .= nl();
  1828. $lcnt = 0;
  1829. } // if
  1830. } // if
  1831. } // if
  1832. } // foreach
  1833. if ($lcnt)
  1834. $code .= nl();
  1835. return $code;
  1836. }
  1837. // compressJavascript
  1838. function linkcode($func, &$library, &$linked, $code, $type=null, $id=null, $pane=null) {
  1839. global $ff_config;
  1840. if ($this->dying)
  1841. return;
  1842. if ($func != '#scanonly') {
  1843. // check if function allready linked
  1844. if (in_array($func, $linked))
  1845. return;
  1846. // remember me
  1847. $linked[] = $func;
  1848. } // if
  1849. // scan the code for library identifiers
  1850. preg_match_all("/[A-Za-z0-9_]+/s", $code, $matches, PREG_PATTERN_ORDER);
  1851. $idents = $matches[0];
  1852. $cnt = count($library);
  1853. for ($i = 0; $i < $cnt; $i++) {
  1854. $libname = $library[$i][0];
  1855. if ($libname != '' && in_array($libname, $idents)) {
  1856. $library[$i][0] = ''; // invalidate
  1857. $ltype = $lid = $lpane = null;
  1858. if (count($library[$i]) > 4) {
  1859. $ltype = $library[$i][2];
  1860. $lid = $library[$i][3];
  1861. $lpane = $library[$i][4];
  1862. } // if
  1863. $this->linkcode($libname, $library, $linked, $library[$i][1], $ltype, $lid, $lpane);
  1864. if ($this->dying)
  1865. return '';
  1866. } // if
  1867. } // for
  1868. if ($func != '#scanonly') {
  1869. // emit the code
  1870. if ($ff_config->compress)
  1871. echo $this->compressJavascript(
  1872. $this->replaceCode($code, BFText::_('COM_BREEZINGFORMS_PROCESS_SCRIPT') . " $func", $type, $id, $pane)
  1873. );
  1874. else
  1875. echo $this->replaceCode($code, BFText::_('COM_BREEZINGFORMS_PROCESS_SCRIPT') . " $func", $type, $id, $pane) . nl() . nl();
  1876. } // if
  1877. }
  1878. // linkcode
  1879. function addFunction($cond, $id, $name, $code, &$library, &$linked, $type, $rowid, $pane) {
  1880. global $database;
  1881. $database = JFactory::getDBO();
  1882. if ($this->dying)
  1883. return;
  1884. switch ($cond) {
  1885. case 1:
  1886. $database->setQuery(
  1887. "select name, code from #__facileforms_scripts " .
  1888. "where id=" . $id . " and published=1"
  1889. );
  1890. $rows = $database->loadObjectList();
  1891. if (count($rows) > 0) {
  1892. $row = $rows[0];
  1893. if ($this->trim($row->name) && $this->nonblank($row->code)) {
  1894. $this->linkcode($row->name, $library, $linked, $row->code, 's', $id, null);
  1895. if ($this->dying)
  1896. return;
  1897. } // if
  1898. } // if
  1899. break;
  1900. case 2:
  1901. if ($this->trim($name) && $this->nonblank($code)) {
  1902. $this->linkcode($name, $library, $linked, $code, $type, $rowid, $pane);
  1903. if ($this->dying)
  1904. return;
  1905. } // if
  1906. break;
  1907. default:
  1908. break;
  1909. } // switch
  1910. }
  1911. // addFunction
  1912. function header() {
  1913. global $ff_comsite, $ff_config;
  1914. $code =
  1915. 'ff_processor = new Object();' . nl() .
  1916. $this->expJsVar('ff_processor.okrun ', $this->okrun) .
  1917. $this->expJsVar('ff_processor.ip ', $this->ip) .
  1918. $this->expJsVar('ff_processor.agent ', $this->agent) .
  1919. $this->expJsVar('ff_processor.browser ', $this->browser) .
  1920. $this->expJsVar('ff_processor.opsys ', $this->opsys) .
  1921. $this->expJsVar('ff_processor.provider ', $this->provider) .
  1922. $this->expJsVar('ff_processor.submitted ', $this->submitted) .
  1923. $this->expJsVar('ff_processor.form ', $this->form) .
  1924. $this->expJsVar('ff_processor.form_id ', $this->form_id) .
  1925. $this->expJsVar('ff_processor.page ', $this->page) .
  1926. $this->expJsVar('ff_processor.target ', $this->target) .
  1927. $this->expJsVar('ff_processor.runmode ', $this->runmode) .
  1928. $this->expJsVar('ff_processor.inframe ', $this->inframe) .
  1929. $this->expJsVar('ff_processor.inline ', $this->inline) .
  1930. $this->expJsVar('ff_processor.template ', $this->template) .
  1931. $this->expJsVar('ff_processor.homepage ', $this->homepage) .
  1932. $this->expJsVar('ff_processor.mossite ', $this->mossite) .
  1933. //$this->expJsVar('ff_processor.mospath ', $this->mospath).
  1934. $this->expJsVar('ff_processor.images ', $this->images) .
  1935. //$this->expJsVar('ff_processor.uploads ', $this->uploads).
  1936. $this->expJsVar('ff_processor.border ', $this->border) .
  1937. $this->expJsVar('ff_processor.align ', $this->align) .
  1938. $this->expJsVar('ff_processor.top ', $this->top) .
  1939. $this->expJsVar('ff_processor.suffix ', $this->suffix) .
  1940. $this->expJsVar('ff_processor.status ', $this->status) .
  1941. $this->expJsVar('ff_processor.message ', $this->message) .
  1942. $this->expJsVar('ff_processor.record_id ', $this->record_id) .
  1943. $this->expJsVar('ff_processor.showgrid ', $this->showgrid) .
  1944. $this->expJsVar('ff_processor.traceBuffer', $this->traceBuffer);
  1945. return
  1946. '<script type="text/javascript">' . nl() .
  1947. '<!--' . nl() .
  1948. ($ff_config->compress ? $this->compressJavascript($code) : $code) .
  1949. '//-->' . nl() .
  1950. '</script>' . nl() .
  1951. '<script type="text/javascript" src="' . JURI::root(true) . '/components/com_breezingforms/facileforms.js"></script>' . nl();
  1952. }
  1953. // header
  1954. function cbCreatePathByTokens($path, array $rows){
  1955. if(strpos(strtolower($path), '{cbsite}') === 0){
  1956. $path = str_replace(array('{cbsite}','{CBSite}'), array(JPATH_SITE, JPATH_SITE), $path);
  1957. }
  1958. if( strpos( $path, '|' ) === false ){
  1959. return $path;
  1960. }
  1961. $path = str_replace('|', DS, $path);
  1962. foreach($rows As $row){
  1963. $value = JRequest::getVar( 'ff_nm_' . $row->name, array(), 'POST', 'ARRAY', JREQUEST_ALLOWRAW );
  1964. $value = implode(DS, $value);
  1965. if(trim($value) == ''){
  1966. $value = '_empty_';
  1967. }
  1968. $path = str_replace('{'.strtolower($row->name).':value}', trim($value), $path);
  1969. }
  1970. $path = str_replace('{userid}', JFactory::getUser()->get('id', 0), $path);
  1971. $path = str_replace('{username}', JFactory::getUser()->get('username', 'anonymous') . '_' . JFactory::getUser()->get('id', 0), $path);
  1972. $path = str_replace('{name}', JFactory::getUser()->get('name', 'Anonymous') . '_' . JFactory::getUser()->get('id', 0), $path);
  1973. $_now = JFactory::getDate();
  1974. $path = str_replace('{date}', $_now->toMySQL(), $path);
  1975. $path = str_replace('{time}', $_now->toFormat('%H:%M:%S'), $path);
  1976. $path = str_replace('{date}', $_now->toMySQL(), $path);
  1977. $path = str_replace('{datetime}', $_now->toFormat(), $path);
  1978. $endpath = contentbuilder::makeSafeFolder($path);
  1979. $parts = explode(DS, $endpath);
  1980. $inner_path = '';
  1981. foreach( $parts As $part ){
  1982. if( !JFolder::exists( $inner_path.$part ) ) {
  1983. $inner_path .= DS;
  1984. }
  1985. JFolder::create($inner_path.$part);
  1986. $inner_path .= $part;
  1987. }
  1988. return $endpath;
  1989. }
  1990. function cbCheckPermissions() {
  1991. // CONTENTBUILDER BEGIN
  1992. jimport('joomla.filesystem.file');
  1993. $cbData = null;
  1994. $cbForm = null;
  1995. $cbRecord = null;
  1996. $cbFrontend = true;
  1997. $cbFull = false;
  1998. if (JFile::exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_contentbuilder' . DS . 'contentbuilder.xml')) {
  1999. if (JFactory::getApplication()->isAdmin()) {
  2000. $cbFrontend = false;
  2001. }
  2002. if ($cbFrontend) {
  2003. JFactory::getLanguage()->load('com_contentbuilder');
  2004. } else {
  2005. JFactory::getLanguage()->load('com_contentbuilder', JPATH_SITE . DS . 'administrator');
  2006. }
  2007. $db = JFactory::getDBO();
  2008. require_once(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_contentbuilder' . DS . 'classes' . DS . 'contentbuilder.php');
  2009. $db->setQuery("Select `id` From #__contentbuilder_forms Where `type` = 'com_breezingforms' And `reference_id` = " . intval($this->form) . " And published = 1");
  2010. $cbForms = $db->loadResultArray();
  2011. // if no BF form is associated with contentbuilder, we don't need no further checks
  2012. if(!count($cbForms)){
  2013. return array('form' => $cbForm, 'record' => $cbRecord, 'frontend' => $cbFrontend, 'data' => $cbData, 'full' => $cbFull);
  2014. }
  2015. // test if there is any published contentbuilder view that allows to create new submissions
  2016. if (!JRequest::getInt('cb_record_id', 0) || !JRequest::getInt('cb_form_id', 0)) {
  2017. $cbAuth = false;
  2018. foreach ($cbForms As $cbFormId) {
  2019. contentbuilder::setPermissions($cbFormId, 0, $cbFrontend ? '_fe' : '');
  2020. if ($cbFrontend) {
  2021. $cbAuth = contentbuilder::authorizeFe('new');
  2022. } else {
  2023. $cbAuth = contentbuilder::authorize('new');
  2024. }
  2025. if ($cbAuth) {
  2026. break;
  2027. }
  2028. }
  2029. if (count($cbForms) && !$cbAuth) {
  2030. JError::raiseError(403, JText::_('COM_CONTENTBUILDER_PERMISSIONS_NEW_NOT_ALLOWED'));
  2031. }
  2032. }
  2033. if (JRequest::getInt('cb_form_id', 0)) {
  2034. // test the permissions of given record
  2035. if (JRequest::getInt('cb_record_id', 0)) {
  2036. contentbuilder::setPermissions(JRequest::getInt('cb_form_id', 0), JRequest::getInt('cb_record_id', 0), $cbFrontend ? '_fe' : '');
  2037. contentbuilder::checkPermissions('edit', JText::_('COM_CONTENTBUILDER_PERMISSIONS_EDIT_NOT_ALLOWED'), $cbFrontend ? '_fe' : '');
  2038. } else {
  2039. contentbuilder::setPermissions(JRequest::getInt('cb_form_id', 0), 0, $cbFrontend ? '_fe' : '');
  2040. contentbuilder::checkPermissions('new', JText::_('COM_CONTENTBUILDER_PERMISSIONS_NEW_NOT_ALLOWED'), $cbFrontend ? '_fe' : '');
  2041. }
  2042. $db->setQuery("Select * From #__contentbuilder_forms Where id = " . JRequest::getInt('cb_form_id', 0) . " And published = 1");
  2043. $cbData = $db->loadAssoc();
  2044. if (is_array($cbData)) {
  2045. $cbFull = $cbFrontend ? contentbuilder::authorizeFe('fullarticle') : contentbuilder::authorize('fullarticle');
  2046. $cbForm = contentbuilder::getForm('com_breezingforms', $cbData['reference_id']);
  2047. $cbRecord = $cbForm->getRecord(JRequest::getInt('cb_record_id', 0), $cbData['published_only'], $cbFrontend ? ( $cbData['own_only_fe'] ? JFactory::getUser()->get('id', 0) : -1 ) : ( $cbData['own_only'] ? JFactory::getUser()->get('id', 0) : -1 ), $cbFrontend ? $cbData['show_all_languages_fe'] : true );
  2048. if(!count($cbRecord) && !JRequest::getBool('cbIsNew')){
  2049. JError::raiseError(404, JText::_('COM_CONTENTBUILDER_RECORD_NOT_FOUND'));
  2050. }
  2051. }
  2052. }
  2053. }
  2054. return array('form' => $cbForm, 'record' => $cbRecord, 'frontend' => $cbFrontend, 'data' => $cbData, 'full' => $cbFull);
  2055. // CONTENTBUILDER END
  2056. }
  2057. function view() {
  2058. global $ff_mospath, $ff_mossite, $database, $my;
  2059. global $ff_config, $ff_version, $ff_comsite, $ff_otherparams;
  2060. //set globals
  2061. global $record;
  2062. $this->execPieceByName('ff_InitLib');
  2063. $usuario = 107;
  2064. $plan = $_SESSION['plan'];
  2065. if ($plan=="") {
  2066. $plan = 2;
  2067. }
  2068. $seccion = $_SESSION['seccion'];
  2069. if ($seccion=="") {
  2070. $seccion = 3;
  2071. }
  2072. $query = "select * from pp9i_facileforms_subrecords where idusuario=" . $usuario . " and idplan=" . . " and idmenu=" . $seccion;
  2073. $rowsNew = ff_select($query);
  2074. foreach($rowsNew as $query2) {
  2075. echo "id value " . $query2->id;
  2076. }
  2077. $is_mobile_type = '';
  2078. if( trim($this->formrow->template_code_processed) == 'QuickMode' ){
  2079. if( isset($_GET['non_mobile']) && JRequest::getBool('non_mobile', 0) ){
  2080. JFactory::getSession()->clear('com_breezingforms.mobile');
  2081. } else if( isset($_GET['mobile']) && JRequest::getBool('mobile', 0) ){
  2082. JFactory::getSession()->set('com_breezingforms.mobile', true);
  2083. }
  2084. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php');
  2085. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php');
  2086. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/crosstec/functions/helpers.php');
  2087. $dataObject = Zend_Json::decode( base64_decode($this->formrow->template_code) );
  2088. $rootMdata = $dataObject['properties'];
  2089. $is_device = false;
  2090. $useragent = $_SERVER['HTTP_USER_AGENT'];
  2091. if(JRequest::getVar('ff_applic','') != 'mod_facileforms' && JRequest::getInt('ff_frame', 0) != 1 && bf_is_mobile())
  2092. {
  2093. $is_device = true;
  2094. $this->isMobile = isset($rootMdata['mobileEnabled']) && isset($rootMdata['forceMobile']) && $rootMdata['mobileEnabled'] && $rootMdata['forceMobile'] ? true : ( isset($rootMdata['mobileEnabled']) && isset($rootMdata['forceMobile']) && $rootMdata['mobileEnabled'] && JFactory::getSession()->get('com_breezingforms.mobile', false) ? true : false );
  2095. }else
  2096. $this->isMobile = false;
  2097. if( $is_device && isset($rootMdata['mobileEnabled']) && isset($rootMdata['forceMobile']) && $rootMdata['mobileEnabled'] && !$rootMdata['forceMobile'] ){
  2098. $is_mobile_type = 'choose';
  2099. }
  2100. if(!$this->isMobile || ( $this->isMobile && JRequest::getVar('ff_task','') == 'submit') ){
  2101. // nothing
  2102. } else {
  2103. // transforming recaptcha into captcha due to compatibility on mobiles
  2104. if($this->isMobile){
  2105. for ($i = 0; $i < $this->rowcount; $i++) {
  2106. $row = $this->rows[$i];
  2107. if( $row->type == "ReCaptcha" ){
  2108. $this->rows[$i]->type = 'Captcha';
  2109. break;
  2110. }
  2111. }
  2112. ob_end_clean();
  2113. ob_start();
  2114. require_once(JPATH_SITE . '/administrator/components/com_breezingforms/libraries/crosstec/classes/BFQuickModeMobile.php');
  2115. $quickMode = new BFQuickModeMobile($this);
  2116. if( isset($rootMdata['mobileEnabled']) && isset($rootMdata['forceMobile']) && $rootMdata['mobileEnabled'] && $rootMdata['forceMobile'] ){
  2117. $quickMode->forceMobileUrl = isset( $rootMdata['forceMobileUrl'] ) ? $rootMdata['forceMobileUrl'] : 'index.php';
  2118. }
  2119. }
  2120. }
  2121. }
  2122. // CONTENTBUILDER BEGIN
  2123. $cbResult = $this->cbCheckPermissions();
  2124. $cbForm = $cbResult['form'];
  2125. $cbRecord = $cbResult['record'];
  2126. $cbFrontend = $cbResult['frontend'];
  2127. $cbFull = $cbResult['full'];
  2128. // CONTENTBUILDER END
  2129. $database = JFactory::getDBO();
  2130. $mainframe = JFactory::getApplication();
  2131. if (!$this->okrun)
  2132. return;
  2133. set_error_handler('_ff_errorHandler');
  2134. ob_start();
  2135. echo $this->header();
  2136. $this->queryCols = array();
  2137. $this->queryRows = array();
  2138. if ($this->runmode == _FF_RUNMODE_PREVIEW) {
  2139. echo '<script type="text/javascript" src="' . JURI::root() . 'administrator/components/com_breezingforms/libraries/wz_dragdrop/wz_dragdrop.js"></script>';
  2140. }
  2141. if (trim($this->formrow->template_code_processed) == 'QuickMode')
  2142. echo '<table width="100%" style="display:none" border="0" id="bfReCaptchaWrap"><tr><td><div id="bfReCaptchaDiv"></div></td></tr></table>';
  2143. echo '<div id="ff_formdiv' . $this->form . '"';
  2144. if ($this->formrow->class1 != '' && $this->formrow->template_code == '')
  2145. echo ' class="' . $this->getClassName($this->formrow->class1) . '"';
  2146. echo '><div class="bfPage-tl"><div class="bfPage-tr"><div class="bfPage-t"></div></div></div><div class="bfPage-l"><div class="bfPage-r"><div class="bfPage-m bfClearfix">' . nl();
  2147. $this->status = JRequest::getCmd('ff_status', '');
  2148. $this->message = JRequest::getVar('ff_message', '');
  2149. // handle Before Form piece
  2150. $code = '';
  2151. switch ($this->formrow->piece1cond) {
  2152. case 1: // library
  2153. $database->setQuery(
  2154. 'select name, code from #__facileforms_pieces ' .
  2155. 'where id=' . $this->formrow->piece1id . ' and published=1 '
  2156. );
  2157. $rows = $database->loadObjectList();
  2158. if (count($rows))
  2159. echo $this->execPiece($rows[0]->code, BFText::_('COM_BREEZINGFORMS_PROCESS_BFPIECE') . " " . $rows[0]->name, 'p', $this->formrow->piece1id, null);
  2160. break;
  2161. case 2: // custom code
  2162. echo $this->execPiece($this->formrow->piece1code, BFText::_('COM_BREEZINGFORMS_PROCESS_BFPIECEC'), 'f', $this->form, 2);
  2163. break;
  2164. default:
  2165. break;
  2166. } // switch
  2167. if ($this->bury())
  2168. return;
  2169. $cntFiles = 0;
  2170. $fileExtensionsCheck = 'function checkFileExtensions(){';
  2171. for ($i = 0; $i < $this->rowcount; $i++) {
  2172. $row = $this->rows[$i];
  2173. if ($row->type == 'File Upload' && trim($this->formrow->template_code) != '') {
  2174. if (trim($row->data2) != '') {
  2175. $exts = explode(',', $row->data2);
  2176. $extsCount = count($exts);
  2177. $fileExtensionsCheck .= 'var ff_elem' . $row->id . 'Exts = false;';
  2178. for ($x = 0; $x < $extsCount; $x++) {
  2179. $fileExtensionsCheck .= '
  2180. if(!ff_elem' . $row->id . 'Exts && document.getElementById("ff_elem' . $row->id . '").value.toLowerCase().lastIndexOf(".' . strtolower(trim($exts[$x])) . '") != -1){
  2181. ff_elem' . $row->id . 'Exts = true;
  2182. }else if(!ff_elem' . $row->id . 'Exts && document.getElementById("ff_elem' . $row->id . '").value == ""){
  2183. ff_elem' . $row->id . 'Exts = true;
  2184. }';
  2185. }
  2186. $fileExtensionsCheck .= '
  2187. if(!ff_elem' . $row->id . 'Exts){
  2188. if(typeof bfUseErrorAlerts == "undefined"){
  2189. alert("' . addslashes(BFText::_('COM_BREEZINGFORMS_FILE_EXTENSION_NOT_ALLOWED')) . '");
  2190. } else {
  2191. bfShowErrors("' . addslashes(BFText::_('COM_BREEZINGFORMS_FILE_EXTENSION_NOT_ALLOWED')) . '");
  2192. }
  2193. if(ff_currentpage != ' . $row->page . ')ff_switchpage(' . $row->page . ');
  2194. return false;
  2195. }
  2196. ';
  2197. $cntFiles++;
  2198. }
  2199. }
  2200. }
  2201. $fileExtensionsCheck .= '
  2202. return true;
  2203. }
  2204. ';
  2205. $capFunc = 'function bfCheckCaptcha(){if(checkFileExtensions())ff_submitForm2();}';
  2206. for ($i = 0; $i < $this->rowcount; $i++) {
  2207. $row = $this->rows[$i];
  2208. if ($row->type == "Captcha") {
  2209. $capFunc = '
  2210. function bfAjaxObject101() {
  2211. this.createRequestObject = function() {
  2212. try {
  2213. var ro = new XMLHttpRequest();
  2214. }
  2215. catch (e) {
  2216. var ro = new ActiveXObject("Microsoft.XMLHTTP");
  2217. }
  2218. return ro;
  2219. }
  2220. this.sndReq = function(action, url, data) {
  2221. if (action.toUpperCase() == "POST") {
  2222. this.http.open(action,url,true);
  2223. this.http.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  2224. this.http.onreadystatechange = this.handleResponse;
  2225. this.http.send(data);
  2226. }
  2227. else {
  2228. this.http.open(action,url + "?" + data,true);
  2229. this.http.onreadystatechange = this.handleResponse;
  2230. this.http.send(null);
  2231. }
  2232. }
  2233. this.handleResponse = function() {
  2234. if ( me.http.readyState == 4) {
  2235. if (typeof me.funcDone == "function") { me.funcDone();}
  2236. var rawdata = me.http.responseText.split("|");
  2237. for ( var i = 0; i < rawdata.length; i++ ) {
  2238. var item = (rawdata[i]).split("=>");
  2239. if (item[0] != "") {
  2240. if (item[1].substr(0,3) == "%V%" ) {
  2241. document.getElementById(item[0]).value = item[1].substring(3);
  2242. }
  2243. else {
  2244. if(item[1] == "true"){
  2245. if(typeof bfDoFlashUpload != \'undefined\'){
  2246. bfDoFlashUpload();
  2247. } else {
  2248. ff_submitForm2();
  2249. }
  2250. } else {
  2251. if(typeof JQuery != "undefined" && JQuery("#bfSubmitMessage"))
  2252. {
  2253. JQuery("#bfSubmitMessage").css("visibility","hidden");
  2254. }
  2255. if(typeof bfUseErrorAlerts == "undefined"){
  2256. alert("' . addslashes(BFText::_('COM_BREEZINGFORMS_CAPTCHA_MISSING_WRONG')) . '");
  2257. } else {
  2258. if(typeof inlineErrorElements != "undefined"){
  2259. inlineErrorElements.push(["bfCaptchaEntry","' . addslashes(BFText::_('COM_BREEZINGFORMS_CAPTCHA_MISSING_WRONG')) . '"]);
  2260. }
  2261. bfShowErrors("' . addslashes(BFText::_('COM_BREEZINGFORMS_CAPTCHA_MISSING_WRONG')) . '");
  2262. }
  2263. document.getElementById(\'ff_capimgValue\').src = \'' . JURI::root(true) . (JFactory::getApplication()->isAdmin() ? '/administrator' : '') . '/components/com_breezingforms/images/captcha/securimage_show.php?bfMathRandom=\' + Math.random();
  2264. document.getElementById(\'bfCaptchaEntry\').value = "";
  2265. if(ff_currentpage != ' . $row->page . ')ff_switchpage(' . $row->page . ');
  2266. document.getElementById(\'bfCaptchaEntry\').focus();
  2267. }
  2268. }
  2269. }
  2270. }
  2271. }
  2272. if ((me.http.readyState == 1) && (typeof me.funcWait == "function")) { me.funcWait(); }
  2273. }
  2274. var me = this;
  2275. this.http = this.createRequestObject();
  2276. var funcWait = null;
  2277. var funcDone = null;
  2278. }
  2279. function bfCheckCaptcha(){
  2280. if(checkFileExtensions()){
  2281. var ao = new bfAjaxObject101();
  2282. ao.sndReq("get","' . JURI::root(true) . ( JFactory::getApplication()->isAdmin() ? '/administrator/' : (BFJoomlaConfig::get('config.sef') && !BFJoomlaConfig::get('config.sef_rewrite') ? '/index.php/' : '/').(JRequest::getCmd('lang','') && BFJoomlaConfig::get('config.sef') ? JRequest::getCmd('lang','') . ( BFJoomlaConfig::get('config.sef_rewrite') ? '/index.php' : '/' ) : 'index.php') ) . '?lang='.JRequest::getCmd('lang','').'&raw=true&option=com_breezingforms&checkCaptcha=true&Itemid=' . JRequest::getInt('Itemid', 0) . '&value="+document.getElementById("bfCaptchaEntry").value,"");
  2283. }
  2284. }';
  2285. break;
  2286. } else if ($row->type == "ReCaptcha") {
  2287. $capFunc = 'var bfReCaptchaLoaded = true;
  2288. function bfCheckCaptcha(){
  2289. if(checkFileExtensions()){
  2290. function bfValidateCaptcha()
  2291. {
  2292. challengeField = JQuery("input#recaptcha_challenge_field").val();
  2293. responseField = JQuery("input#recaptcha_response_field").val();
  2294. var html = JQuery.ajax({
  2295. type: "POST",
  2296. url: "' . JURI::root(true) . ( JFactory::getApplication()->isAdmin() ? '/administrator/' : (BFJoomlaConfig::get('config.sef') && !BFJoomlaConfig::get('config.sef_rewrite') ? '/index.php/' : '/').(JRequest::getCmd('lang','') && BFJoomlaConfig::get('config.sef') ? JRequest::getCmd('lang','') . ( BFJoomlaConfig::get('config.sef_rewrite') ? '/index.php' : '/' ) : 'index.php') ) . '?lang='.JRequest::getCmd('lang','').'&raw=true&option=com_breezingforms&bfReCaptcha=true&form=' . $this->form . '&Itemid=' . JRequest::getInt('Itemid', 0) . '",
  2297. data: "recaptcha_challenge_field=" + challengeField + "&recaptcha_response_field=" + responseField,
  2298. async: false
  2299. }).responseText;
  2300. if (html.replace(/^\s+|\s+$/, "") == "success")
  2301. {
  2302. if(typeof bfDoFlashUpload != \'undefined\'){
  2303. bfDoFlashUpload();
  2304. } else {
  2305. ff_submitForm2();
  2306. }
  2307. }
  2308. else
  2309. {
  2310. if(typeof bfUseErrorAlerts == "undefined"){
  2311. alert("' . addslashes(BFText::_('COM_BREEZINGFORMS_CAPTCHA_MISSING_WRONG')) . '");
  2312. } else {
  2313. if(typeof inlineErrorElements != "undefined"){
  2314. inlineErrorElements.push(["bfReCaptchaEntry","' . addslashes(BFText::_('COM_BREEZINGFORMS_CAPTCHA_MISSING_WRONG')) . '"]);
  2315. }
  2316. bfShowErrors("' . addslashes(BFText::_('COM_BREEZINGFORMS_CAPTCHA_MISSING_WRONG')) . '");
  2317. }
  2318. if(ff_currentpage != ' . $row->page . ')ff_switchpage(' . $row->page . ');
  2319. Recaptcha.focus_response_field();
  2320. Recaptcha.reload();
  2321. }
  2322. }
  2323. bfValidateCaptcha();
  2324. }
  2325. }';
  2326. }
  2327. }
  2328. echo
  2329. '<script type="text/javascript">' . nl() .
  2330. '<!--' . nl() .
  2331. '' . nl() .
  2332. $fileExtensionsCheck .
  2333. $capFunc;
  2334. // create library list
  2335. $library = array();
  2336. $this->loadBuiltins($library);
  2337. $this->loadScripts($library);
  2338. // start linking
  2339. $linked = array();
  2340. if ($this->status == '') {
  2341. $code = "onload = function()" . nl() .
  2342. "{" . nl() .
  2343. " ff_initialize('formentry');" . nl() .
  2344. " ff_initialize('pageentry');" . nl();
  2345. if ($this->formrow->heightmode)
  2346. $code .= " ff_resizepage(" . $this->formrow->heightmode . ", " . $this->formrow->height . ");" . nl();
  2347. if ($this->showgrid)
  2348. $code .= " ff_showgrid();" . nl();
  2349. $code .=
  2350. " if (ff_processor && ff_processor.traceBuffer) ff_traceWindow();" . nl() .
  2351. "} // onload";
  2352. $this->linkcode('onload', $library, $linked, $code);
  2353. } else {
  2354. $funcname = "";
  2355. switch ($this->formrow->script2cond) {
  2356. case 1:
  2357. $database->setQuery(
  2358. "select name from #__facileforms_scripts " .
  2359. "where id=" . $this->formrow->script2id . " and published=1 "
  2360. );
  2361. $funcname = $database->loadResult();
  2362. break;
  2363. case 2:
  2364. $funcname = "ff_" . $this->formrow->name . "_submitted";
  2365. break;
  2366. default:
  2367. break;
  2368. } // switch
  2369. if ($funcname != '' || $this->formrow->heightmode || $this->showgrid) {
  2370. $code = "onload = function()" . nl() .
  2371. "{" . nl();
  2372. if ($this->formrow->heightmode)
  2373. $code .=" ff_resizepage(" . $this->formrow->heightmode . ", " . $this->formrow->height . ");" . nl();
  2374. if ($this->showgrid)
  2375. $code .=" ff_showgrid();" . nl();
  2376. if ($funcname != '')
  2377. $code .=" " . $funcname . "(" . $this->status . ",\"" . str_replace("\n", '', str_replace("\r", '', stripcslashes($this->message))) . "\");" . nl();
  2378. $code .= "} // onload";
  2379. $this->linkcode('onload', $library, $linked, $code);
  2380. } // if
  2381. } // if
  2382. if ($this->bury())
  2383. return;
  2384. // add form scripts
  2385. $this->addFunction(
  2386. $this->formrow->script1cond, $this->formrow->script1id, 'ff_' . $this->formrow->name . '_init', $this->formrow->script1code, $library, $linked, 'f', $this->form, 1
  2387. );
  2388. if ($this->bury())
  2389. return;
  2390. $this->addFunction(
  2391. $this->formrow->script2cond, $this->formrow->script2id, 'ff_' . $this->formrow->name . '_submitted', $this->formrow->script2code, $library, $linked, 'f', $this->form, 1
  2392. );
  2393. if ($this->bury())
  2394. return;
  2395. // all element scripts & static text/HTML
  2396. $icons = 0;
  2397. $tooltips = 0;
  2398. $qcheckboxes = 0;
  2399. $qcode = '';
  2400. for ($i = 0; $i < $this->rowcount; $i++) {
  2401. $row = & $this->rows[$i];
  2402. $this->draggableDivIds[] = 'ff_div' . $row->id;
  2403. if ($row->type == "Icon")
  2404. $icons++;
  2405. if ($row->type == "Tooltip")
  2406. $tooltips++;
  2407. if ($row->type == "Query List") {
  2408. if ($row->flag2)
  2409. $qcheckboxes++;
  2410. // load column definitions
  2411. $this->queryCols['ff_' . $row->id] = array();
  2412. $cols = & $this->queryCols['ff_' . $row->id];
  2413. if ($this->trim($row->data3)) {
  2414. $cls = explode("\n", $row->data3);
  2415. for ($c = 0; $c < count($cls); $c++) {
  2416. if ($cls[$c] != '') {
  2417. $col = ''; // instead of unset
  2418. $col = new facileFormsQuerycols;
  2419. $col->unpack($cls[$c]);
  2420. $this->compileQueryCol($row, $col);
  2421. $cols[] = $col;
  2422. } // if
  2423. } // for
  2424. } // if
  2425. $colcnt = count($cols);
  2426. $checkbox = 0;
  2427. if ($row->flag2)
  2428. $checkbox = $row->flag2;
  2429. $header = 0;
  2430. if ($row->flag1)
  2431. $header = 1;
  2432. // get pagenav
  2433. $pagenav = 1;
  2434. $settings = explode("\n", $row->data1);
  2435. if (count($settings) > 8 && $this->trim($settings[8]))
  2436. $pagenav = $settings[8];
  2437. // export the javascript parameters
  2438. $qcode .= nl() .
  2439. 'ff_queryCurrPage[' . $row->id . '] = 1;' . nl() .
  2440. 'ff_queryPageSize[' . $row->id . '] = ' . $row->height . ';' . nl() .
  2441. 'ff_queryCheckbox[' . $row->id . '] = ' . $checkbox . ';' . nl() .
  2442. 'ff_queryHeader[' . $row->id . '] = ' . $header . ';' . nl() .
  2443. 'ff_queryPagenav[' . $row->id . '] = ' . $pagenav . ';' . nl() .
  2444. 'ff_queryCols[' . $row->id . '] = [';
  2445. for ($c = 0; $c < $colcnt; $c++) {
  2446. if ($cols[$c]->thspan > 0)
  2447. $qcode .= '1'; else
  2448. $qcode .= '0';
  2449. if ($c < $colcnt - 1)
  2450. $qcode .= ',';
  2451. } // for
  2452. $qcode .= '];' . nl();
  2453. // execute the query and export it to javascript
  2454. $this->queryRows['ff_' . $row->id] = array();
  2455. $this->execQuery($row, $this->queryRows['ff_' . $row->id], $cols);
  2456. $qcode .= 'ff_queryRows[' . $row->id . '] = ' . $this->expJsValue($this->queryRows['ff_' . $row->id]) . ';' . nl();
  2457. unset($cols);
  2458. if ($this->bury())
  2459. return;
  2460. } // if
  2461. $this->addFunction(
  2462. $row->script1cond, $row->script1id, 'ff_' . $row->name . '_init', $row->script1code, $library, $linked, 'e', $row->id, 1
  2463. );
  2464. if ($this->bury()) {
  2465. unset($row);
  2466. return;
  2467. }
  2468. $this->addFunction(
  2469. $row->script2cond, $row->script2id, 'ff_' . $row->name . '_action', $row->script2code, $library, $linked, 'e', $row->id, 1
  2470. );
  2471. if ($this->bury()) {
  2472. unset($row);
  2473. return;
  2474. }
  2475. $this->addFunction(
  2476. $row->script3cond, $row->script3id, 'ff_' . $row->name . '_validate', $row->script3code, $library, $linked, 'e', $row->id, 1
  2477. );
  2478. if ($this->bury()) {
  2479. ob_end_clean();
  2480. return;
  2481. }
  2482. if ($row->type == 'Static Text/HTML')
  2483. $this->linkcode('#scanonly', $library, $linked, $row->data1);
  2484. unset($row);
  2485. if ($this->bury())
  2486. return;
  2487. } // for
  2488. if ($icons > 0) {
  2489. $this->linkcode('ff_hideIconBorder', $library, $linked, 'function ff_hideIconBorder(element)' . nl() .
  2490. '{' . nl() .
  2491. ' element.style.border = "none";' . nl() .
  2492. '} // ff_hideIconBorder'
  2493. );
  2494. if ($this->bury())
  2495. return;
  2496. $this->linkcode('ff_dispIconBorder', $library, $linked, 'function ff_dispIconBorder(element)' . nl() .
  2497. '{' . nl() .
  2498. ' element.style.border = "1px outset";' . nl() .
  2499. '} // ff_dispIconBorder'
  2500. );
  2501. if ($this->bury())
  2502. return;
  2503. } // if
  2504. if ($qcode != '') {
  2505. $library[] = array('ff_queryCurrPage', 'var ff_queryCurrPage = new Array();');
  2506. $library[] = array('ff_queryPageSize', 'var ff_queryPageSize = new Array();');
  2507. $library[] = array('ff_queryCols', 'var ff_queryCols = new Array();');
  2508. $library[] = array('ff_queryCheckbox', 'var ff_queryCheckbox = new Array();');
  2509. $library[] = array('ff_queryHeader', 'var ff_queryHeader = new Array();');
  2510. $library[] = array('ff_queryPagenav', 'var ff_queryPagenav = new Array();');
  2511. $library[] = array('ff_queryRows', 'var ff_queryRows = new Array();' . nl() . $qcode);
  2512. $library[] = array('ff_selectAllQueryRows',
  2513. 'function ff_selectAllQueryRows(id,checked)' . nl() .
  2514. '{' . nl() .
  2515. ' if (!ff_queryCheckbox[id]) return;' . nl() .
  2516. ' var cnt = ff_queryRows[id].length;' . nl() .
  2517. ' var pagesize = ff_queryPageSize[id];' . nl() .
  2518. ' if (pagesize > 0) {' . nl() .
  2519. ' lastpage = parseInt((cnt+pagesize-1)/pagesize);' . nl() .
  2520. ' if (lastpage == 1)' . nl() .
  2521. ' pagesize = cnt;' . nl() .
  2522. ' else {' . nl() .
  2523. ' var currpage = ff_queryCurrPage[id];' . nl() .
  2524. ' var p;' . nl() .
  2525. ' for (p = 1; p < currpage; p++) cnt -= pagesize;' . nl() .
  2526. ' if (cnt > pagesize) cnt = pagesize;' . nl() .
  2527. ' } // if' . nl() .
  2528. ' } // if' . nl() .
  2529. ' var curr;' . nl() .
  2530. ' for (curr = 0; curr < cnt; curr++)' . nl() .
  2531. ' document.getElementById(\'ff_cb\'+id+\'_\'+curr).checked = checked;' . nl() .
  2532. ' for (curr = cnt; curr < pagesize; curr++)' . nl() .
  2533. ' document.getElementById(\'ff_cb\'+id+\'_\'+curr).checked = false;' . nl() .
  2534. ' if (ff_queryCheckbox[id]==1)' . nl() .
  2535. ' document.getElementById(\'ff_cb\'+id).checked = checked;' . nl() .
  2536. '} // ff_selectAllQueryRows'
  2537. );
  2538. $code =
  2539. 'function ff_dispQueryPage(id,page)' . nl() .
  2540. '{' . nl() .
  2541. ' var forced = false;' . nl() .
  2542. ' if (arguments.length>2) forced = arguments[2];' . nl() .
  2543. ' var qrows = ff_queryRows[id];' . nl() .
  2544. ' var cnt = qrows.length;' . nl() .
  2545. ' var currpage = ff_queryCurrPage[id];' . nl() .
  2546. ' var pagesize = ff_queryPageSize[id];' . nl() .
  2547. ' var pagenav = ff_queryPagenav[id];' . nl() .
  2548. ' var lastpage = 1;' . nl() .
  2549. ' if (pagesize > 0) {' . nl() .
  2550. ' lastpage = parseInt((cnt+pagesize-1)/pagesize);' . nl() .
  2551. ' if (lastpage == 1) pagesize = cnt;' . nl() .
  2552. ' } // if' . nl() .
  2553. ' if (page < 1) page = 1;' . nl() .
  2554. ' if (page > lastpage) page = lastpage;' . nl() .
  2555. ' if (!forced && page == currpage) return;' . nl() .
  2556. ' var p, c;' . nl() .
  2557. ' for (p = 1; p < page; p++) cnt -= pagesize;' . nl() .
  2558. ' if (cnt > pagesize) cnt = pagesize;' . nl() .
  2559. ' var start = (page-1) * pagesize;' . nl() .
  2560. ' var rows = document.getElementById(\'ff_elem\'+id).rows;' . nl() .
  2561. ' var cols = ff_queryCols[id];' . nl() .
  2562. ' var checkbox = ff_queryCheckbox[id];' . nl() .
  2563. ' var header = ff_queryHeader[id];' . nl() .
  2564. ' for (p = 0; p < cnt; p++) {' . nl() .
  2565. ' var qrow = qrows[start+p];' . nl() .
  2566. ' var row = rows[header+p];' . nl() .
  2567. ' var cc = 0;' . nl() .
  2568. ' for (c = 0; c < cols.length; c++)' . nl() .
  2569. ' if (cols[c]) {' . nl() .
  2570. ' if (c==0 && checkbox>0) {' . nl() .
  2571. ' document.getElementById(\'ff_cb\'+id+\'_\'+p).value = qrow[c];' . nl() .
  2572. ' cc++;' . nl() .
  2573. ' } else' . nl() .
  2574. ' row.cells[cc++].innerHTML = qrow[c];' . nl() .
  2575. ' } // if' . nl() .
  2576. ' row.style.display = \'\';' . nl() .
  2577. ' } // for' . nl() .
  2578. ' for (p = cnt; p < pagesize; p++) {' . nl() .
  2579. ' var row = rows[p+header];' . nl() .
  2580. ' row.style.display = \'none\';' . nl() .
  2581. ' } // for' . nl() .
  2582. ' if (pagenav > 0 && pagesize > 0) {' . nl() .
  2583. ' var navi = \'\';' . nl() .
  2584. ' if (pagenav<=4) {' . nl() .
  2585. ' if (page>1) navi += \'<a href="javascript:ff_dispQueryPage(\'+id+\',1);">\';' . nl() .
  2586. ' navi += \'&lt;&lt;\';' . nl() .
  2587. ' if (pagenav<=2) navi += \' ' . BFText::_('COM_BREEZINGFORMS_PROCESS_PAGESTART') . '\';' . nl() .
  2588. ' if (page>1) navi += \'<\/a>\';' . nl() .
  2589. ' navi += \' \';' . nl() .
  2590. ' if (page>1) navi += \'<a href="javascript:ff_dispQueryPage(\'+id+\',\'+(page-1)+\');">\';' . nl() .
  2591. ' navi += \'&lt;\';' . nl() .
  2592. ' if (pagenav<=2) navi += \' ' . BFText::_('COM_BREEZINGFORMS_PROCESS_PAGEPREV') . '\';' . nl() .
  2593. ' if (page>1) navi += \'<\/a>\';' . nl() .
  2594. ' navi += \' \';' . nl() .
  2595. ' } // if' . nl() .
  2596. ' if (pagenav % 2) {' . nl() .
  2597. ' for (p = 1; p <= lastpage; p++)' . nl() .
  2598. ' if (p == page) ' . nl() .
  2599. ' navi += p+\' \';' . nl() .
  2600. ' else' . nl() .
  2601. ' navi += \'<a href="javascript:ff_dispQueryPage(\'+id+\',\'+p+\');">\'+p+\'<\/a> \';' . nl() .
  2602. ' } // if' . nl() .
  2603. ' if (pagenav<=4) {' . nl() .
  2604. ' if (page<lastpage) navi += \'<a href="javascript:ff_dispQueryPage(\'+id+\',\'+(page+1)+\');">\';' . nl() .
  2605. ' if (pagenav<=2) navi += \'' . BFText::_('COM_BREEZINGFORMS_PROCESS_PAGENEXT') . ' \';' . nl() .
  2606. ' navi += \'&gt;\';' . nl() .
  2607. ' if (page<lastpage) navi += \'<\/a>\';' . nl() .
  2608. ' navi += \' \';' . nl() .
  2609. ' if (page<lastpage) navi += \'<a href="javascript:ff_dispQueryPage(\'+id+\',\'+lastpage+\');">\';' . nl() .
  2610. ' if (pagenav<=2) navi += \'' . BFText::_('COM_BREEZINGFORMS_PROCESS_PAGEEND') . ' \';' . nl() .
  2611. ' navi += \'&gt;&gt;\';' . nl() .
  2612. ' if (page<lastpage) navi += \'<\/a>\';' . nl() .
  2613. ' } // if' . nl() .
  2614. ' rows[header+pagesize].cells[0].innerHTML = navi;' . nl() .
  2615. ' } // if' . nl() .
  2616. ' ff_queryCurrPage[id] = page;' . nl();
  2617. if ($qcheckboxes)
  2618. $code .=
  2619. ' if (checkbox) ff_selectAllQueryRows(id, false);' . nl();
  2620. if ($this->formrow->heightmode > 0)
  2621. $code .=
  2622. ' ff_resizepage(' . $this->formrow->heightmode . ', ' . $this->formrow->height . ');' . nl();
  2623. if ($this->inframe)
  2624. $code .=
  2625. ' parent.window.scrollTo(0,0);' . nl();
  2626. $code .=
  2627. ' window.scrollTo(0,0);' . nl() .
  2628. '} // ff_dispQueryPage';
  2629. $this->linkcode('ff_dispQueryPage', $library, $linked, $code);
  2630. if ($this->bury())
  2631. return;
  2632. } // if
  2633. echo '//-->' . nl() .
  2634. '</script>' . nl();
  2635. if ($icons > 0)
  2636. echo '<script language="JavaScript" src="' . $ff_mossite . '/components/com_breezingforms/libraries/js/joomla.javascript.js" type="text/javascript"></script>' . nl();
  2637. if ($tooltips > 0) {
  2638. echo '<script language="Javascript" src="' . $ff_mossite . '/components/com_breezingforms/libraries/js/overlib_mini.js" type="text/javascript"></script>' . nl();
  2639. if ($this->inframe)
  2640. echo '<div id="overDiv" style="position:absolute;visibility:hidden;z-index:1000;"></div>' . nl();
  2641. } // if
  2642. if (!$this->inline) {
  2643. $url = ($this->inframe) ? $ff_mossite . '/index.php?format=html&tmpl=component' : (($this->runmode == _FF_RUNMODE_FRONTEND) ? '' : 'index.php?format=html' . ( JRequest::getCmd('tmpl','') ? '&tmpl='.JRequest::getCmd('tmpl','') : '' ));
  2644. $params = ' action="' . $url . '"' .
  2645. ' method="post"' .
  2646. ' name="' . $this->form_id . '"' .
  2647. ' id="' . $this->form_id . '"' .
  2648. ' enctype="multipart/form-data"';
  2649. if ($this->formrow->class2 != '')
  2650. $params .= ' class="' . $this->getClassName($this->formrow->class2) . '"';
  2651. echo '<form data-ajax="false" ' . $params . ' accept-charset="utf-8" onsubmit="return false;" class="bfQuickMode">' . nl();
  2652. } // if
  2653. $js = '';
  2654. if ($this->editable && $cbRecord === null) {
  2655. $db = JFactory::getDBO();
  2656. $db->setQuery("Select id, form From #__facileforms_records Where form = " . $db->Quote($this->form) . " And user_id = " . $db->Quote(JFactory::getUser()->get('id', -1)) . " And user_id <> 0 And archived = 0 Order By id Desc Limit 1");
  2657. $recordsResult = $db->loadObjectList();
  2658. if (count($recordsResult) != 0) {
  2659. $db->setQuery("Select * From #__facileforms_subrecords Where record = " . $recordsResult[0]->id . "");
  2660. $recordEntries = $db->loadObjectList();
  2661. $js = '';
  2662. foreach ($recordEntries As $recordEntry) {
  2663. switch ($recordEntry->type) {
  2664. case 'Textarea':
  2665. case 'Text':
  2666. case 'Hidden Input':
  2667. case 'Calendar':
  2668. $js .= 'if(document.getElementById("ff_elem' . $recordEntry->element . '"))document.getElementById("ff_elem' . $recordEntry->element . '").value="' . str_replace("\n", "\\n", str_replace("\r", "\\r", addslashes($recordEntry->value))) . '";' . "\n";
  2669. break;
  2670. case 'Checkbox':
  2671. $js .= 'if(document.getElementById("ff_elem' . $recordEntry->element . '"))document.getElementById("ff_elem' . $recordEntry->element . '").checked = true;' . "\n";
  2672. break;
  2673. case 'Checkbox Group':
  2674. $js .= '
  2675. for(var i = 0;i < document.ff_form' . $this->form . '.elements.length;i++){
  2676. if(document.ff_form' . $this->form . '.elements[i].type == "checkbox" && document.ff_form' . $this->form . '.elements[i].name == "ff_nm_' . $recordEntry->name . '[]" && document.ff_form' . $this->form . '.elements[i].value == "' . str_replace("\n", "\\n", str_replace("\r", "\\r", addslashes($recordEntry->value))) . '"){
  2677. document.ff_form' . $this->form . '.elements[i].checked = true;
  2678. }
  2679. }' . "\n";
  2680. break;
  2681. case 'Radio Button':
  2682. case 'Radio Group':
  2683. $js .= '
  2684. for(var i = 0;i < document.ff_form' . $this->form . '.elements.length;i++){
  2685. if(document.ff_form' . $this->form . '.elements[i].type == "radio" && document.ff_form' . $this->form . '.elements[i].name == "ff_nm_' . $recordEntry->name . '[]" && document.ff_form' . $this->form . '.elements[i].value == "' . str_replace("\n", "\\n", str_replace("\r", "\\r", addslashes($recordEntry->value))) . '"){
  2686. document.ff_form' . $this->form . '.elements[i].checked = true;
  2687. }
  2688. }' . "\n";
  2689. break;
  2690. case 'Select List':
  2691. $js .= 'for(var i = 0; i < document.getElementById("ff_elem' . $recordEntry->element . '").options.length; i++){
  2692. if(document.getElementById("ff_elem' . $recordEntry->element . '").options[i].value == "' . str_replace("\n", "\\n", str_replace("\r", "\\r", addslashes($recordEntry->value))) . '"){
  2693. document.getElementById("ff_elem' . $recordEntry->element . '").options[i].selected = true;
  2694. }
  2695. }' . "\n";
  2696. break;
  2697. }
  2698. }
  2699. echo '
  2700. <script type="text/javascript">
  2701. <!--' . nl() . '
  2702. function bfLoadEditable(){
  2703. ' . $js . '
  2704. // legacy seccode removal
  2705. for(var i = 0;i < document.ff_form' . $this->form . '.elements.length;i++){
  2706. if(document.ff_form' . $this->form . '.elements[i].name == "ff_nm_seccode[]"){
  2707. document.ff_form' . $this->form . '.elements[i].value = "";
  2708. }
  2709. }
  2710. }
  2711. ' . nl() . '//-->
  2712. </script>
  2713. ' . nl();
  2714. }
  2715. }
  2716. // CONTENTBUILDER BEGIN
  2717. if ($cbRecord !== null) {
  2718. require_once(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_contentbuilder' . DS . 'classes' . DS . 'contentbuilder.php');
  2719. $cbNonEditableFields = contentbuilder::getListNonEditableElements($cbResult['data']['id']);
  2720. foreach ($cbRecord As $cbEntry) {
  2721. if (!in_array($cbEntry->recElementId, $cbNonEditableFields)) {
  2722. switch ($cbEntry->recType) {
  2723. case 'File Upload':
  2724. if (trim($this->formrow->template_code_processed) == 'QuickMode') {
  2725. require_once(JPATH_COMPONENT_ADMINISTRATOR . DS . 'classes' . DS . 'contentbuilder_helpers.php');
  2726. $cbOut = '';
  2727. $cbFiles = explode("\n", str_replace("\r", "", $cbEntry->recValue));
  2728. $i = 0;
  2729. $cnt = count($cbFiles);
  2730. foreach ($cbFiles As $cbFile) {
  2731. if (trim($cbFile)) {
  2732. $cbOut .= '<div><input type=\"checkbox\" onchange=\"bfCheckUploadValidation(\'cb_delete_'.$cbEntry->recElementId.'\','.$cnt.',\'ff_nm_'.$cbEntry->recName.'[]\')\" value=\"1\" name=\"cb_delete_'.$cbEntry->recElementId.'['.$i.']\" id=\"cb_delete_'.$cbEntry->recElementId.'_'.$i.'\"/> <label style=\"margin-left: 5px;\" for=\"cb_delete_'.$cbEntry->recElementId.'_'.$i.'\">' . addslashes(basename(contentbuilder_wordwrap($cbFile, 150, "<br>", true))) . '</label><br/><br/></div>';
  2733. $js .= 'bfDeactivateField["ff_nm_'.$cbEntry->recName.'[]"]=true;'.nl();
  2734. $i++;
  2735. }
  2736. }
  2737. $js .= '
  2738. if (document.createTextNode){
  2739. if(document.getElementById("ff_elem' . $cbEntry->recElementId . 'Uploader")){
  2740. var mydiv = document.createElement("div");
  2741. mydiv.innerHTML = "<br/>' . $cbOut . '";
  2742. JQuery("#ff_elem' . $cbEntry->recElementId . '_files").append(mydiv);
  2743. } else {
  2744. var mydiv = document.createElement("div");
  2745. mydiv.innerHTML = "' . $cbOut . '";
  2746. mydiv.innerHTML = "<br/><br/>" + mydiv.innerHTML;
  2747. JQuery("#ff_elem' . $cbEntry->recElementId . '_files").append(mydiv);
  2748. }
  2749. }'.nl();
  2750. }
  2751. break;
  2752. case 'Textarea':
  2753. case 'Text':
  2754. case 'Hidden Input':
  2755. case 'Calendar':
  2756. $js .= 'if(document.getElementById("ff_elem' . $cbEntry->recElementId . '"))document.getElementById("ff_elem' . $cbEntry->recElementId . '").value="' . str_replace("\n", "\\n", str_replace("\r", "\\r", addslashes($cbEntry->recValue))) . '";' .nl();
  2757. break;
  2758. case 'Checkbox':
  2759. case 'Checkbox Group':
  2760. $cbValues = explode(',', $cbEntry->recValue);
  2761. foreach ($cbValues As $cbValue) {
  2762. $cbValue = trim($cbValue);
  2763. $js .= '
  2764. for(var i = 0;i < document.ff_form' . $this->form . '.elements.length;i++){
  2765. if(document.ff_form' . $this->form . '.elements[i].type == "checkbox" && document.ff_form' . $this->form . '.elements[i].name == "ff_nm_' . $cbEntry->recName . '[]" && document.ff_form' . $this->form . '.elements[i].value == "' . str_replace("\n", "\\n", str_replace("\r", "\\r", addslashes($cbValue))) . '"){
  2766. document.ff_form' . $this->form . '.elements[i].checked = true;
  2767. }
  2768. }' . nl();
  2769. }
  2770. break;
  2771. case 'Radio Button':
  2772. case 'Radio Group':
  2773. $cbValues = explode(',', $cbEntry->recValue);
  2774. foreach ($cbValues As $cbValue) {
  2775. $cbValue = trim($cbValue);
  2776. $js .= '
  2777. for(var i = 0;i < document.ff_form' . $this->form . '.elements.length;i++){
  2778. if(document.ff_form' . $this->form . '.elements[i].type == "radio" && document.ff_form' . $this->form . '.elements[i].name == "ff_nm_' . $cbEntry->recName . '[]" && document.ff_form' . $this->form . '.elements[i].value == "' . str_replace("\n", "\\n", str_replace("\r", "\\r", addslashes($cbValue))) . '"){
  2779. document.ff_form' . $this->form . '.elements[i].checked = true;
  2780. }
  2781. }' . nl();
  2782. }
  2783. break;
  2784. case 'Select List':
  2785. $cbValues = explode(',', $cbEntry->recValue);
  2786. foreach ($cbValues As $cbValue) {
  2787. $cbValue = trim($cbValue);
  2788. $js .= 'for(var i = 0; i < document.getElementById("ff_elem' . $cbEntry->recElementId . '").options.length; i++){
  2789. if(document.getElementById("ff_elem' . $cbEntry->recElementId . '").options[i].value == "' . str_replace("\n", "\\n", str_replace("\r", "\\r", addslashes($cbValue))) . '"){
  2790. document.getElementById("ff_elem' . $cbEntry->recElementId . '").options[i].selected = true;
  2791. }
  2792. }' . nl();
  2793. }
  2794. break;
  2795. }
  2796. }
  2797. }
  2798. echo '
  2799. <script type="text/javascript">
  2800. <!--' . nl() . '
  2801. function bfCheckUploadValidation(deletegroup, cnt, deactivatable){
  2802. var checked = 0;
  2803. for(var i = 0; i < cnt; i++){
  2804. if(document.getElementsByName(deletegroup+"["+i+"]")[0].checked){
  2805. checked++;
  2806. }
  2807. }
  2808. if(checked == cnt){
  2809. bfDeactivateField[deactivatable]=false;
  2810. }else{
  2811. bfDeactivateField[deactivatable]=true;
  2812. }
  2813. }
  2814. function bfLoadContentBuilderEditable(){
  2815. ' . $js . '
  2816. // legacy seccode removal
  2817. for(var i = 0;i < document.ff_form' . $this->form . '.elements.length;i++){
  2818. if(document.ff_form' . $this->form . '.elements[i].name == "ff_nm_seccode[]"){
  2819. document.ff_form' . $this->form . '.elements[i].value = "";
  2820. }
  2821. }
  2822. }
  2823. ' . nl() . '//-->
  2824. </script>
  2825. ' . nl();
  2826. }
  2827. $cbNonEditableFields = array();
  2828. if ($cbForm !== null) {
  2829. require_once(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_contentbuilder' . DS . 'classes' . DS . 'contentbuilder.php');
  2830. $cbNonEditableFields = contentbuilder::getListNonEditableElements($cbResult['data']['id']);
  2831. if (count($cbNonEditableFields)) {
  2832. JFactory::getDocument()->addScriptDeclaration('<!--' . nl() . 'var bfDeactivateField = new Array();' . nl() . '//-->');
  2833. echo '<script type="text/javascript">' . nl();
  2834. echo '<!--' . nl();
  2835. echo 'function bfDisableContentBuilderFields(){' . nl();
  2836. }
  2837. foreach ($cbNonEditableFields As $cbNonEditableField) {
  2838. echo 'if(typeof document.getElementById("ff_elem' . $cbNonEditableField . '").disabled != "undefined"){' . nl();
  2839. echo 'bfCbName = document.getElementById("ff_elem' . $cbNonEditableField . '").name;' . nl();
  2840. echo 'if(typeof document.getElementsByName != "undefined"){' . nl();
  2841. echo 'bfCbElements = document.getElementsByName(bfCbName);' . nl();
  2842. echo 'for(var i = 0; i < bfCbElements.length; i++){' . nl();
  2843. echo 'if(typeof bfCbElements[i].disabled != "undefined"){' . nl();
  2844. echo 'bfCbElements[i].disabled = true;' . nl();
  2845. echo '}' . nl();
  2846. echo 'bfDeactivateField[bfCbName]=true;' . nl();
  2847. echo 'if(typeof JQuery != "undefined"){ JQuery("#bfElemWrap'.$cbNonEditableField.'").css("display", "none"); }'. nl();
  2848. echo '}' . nl();
  2849. echo '}else{' . nl();
  2850. echo 'document.getElementById("ff_elem' . $cbNonEditableField . '").disabled = true;' . nl();
  2851. echo 'bfDeactivateField[bfCbName]=true;' . nl();
  2852. echo 'if(typeof JQuery != "undefined"){ JQuery("#bfElemWrap'.$cbNonEditableField.'").css("display", "none"); }'. nl();
  2853. echo '}' . nl();
  2854. echo '}' . nl();
  2855. }
  2856. if (count($cbNonEditableFields)) {
  2857. echo '}' . nl();
  2858. echo '//-->' . nl();
  2859. echo '</script>' . nl();
  2860. }
  2861. }
  2862. // CONTENTBUILDER END
  2863. if (trim($this->formrow->template_code_processed) == '') {
  2864. for ($i = 0; $i < $this->rowcount; $i++) {
  2865. //Añadir aqui un apartado.
  2866. $ActualElement = $rowsNew[$i];
  2867. $row = & $this->rows[$i];
  2868. if (!is_numeric($row->width))
  2869. $row->width = 0;
  2870. if (!is_numeric($row->height))
  2871. $row->height = 0;
  2872. if ($row->type != 'Query List') {
  2873. $data1 = $this->replaceCode($row->data1, "data1 of $row->name", 'e', $row->id, 0);
  2874. if ($this->bury())
  2875. return;
  2876. $data2 = $this->replaceCode($row->data2, "data2 of $row->name", 'e', $row->id, 0);
  2877. if ($this->bury())
  2878. return;
  2879. $data3 = $this->replaceCode($row->data3, "data3 of $row->name", 'e', $row->id, 0);
  2880. if ($this->bury())
  2881. return;
  2882. } // if
  2883. $attribs = 'position:absolute;z-index:' . $i . ';';
  2884. if ($row->posx >= 0)
  2885. $attribs .= 'left:' . $row->posx; else
  2886. $attribs .= 'right:' . (-$row->posx);
  2887. if ($row->posxmode)
  2888. $attribs .= '%;'; else
  2889. $attribs .= 'px;';
  2890. if ($row->posy >= 0)
  2891. $attribs .= 'top:' . $row->posy; else
  2892. $attribs .= 'bottom:' . (-$row->posy);
  2893. if ($row->posymode)
  2894. $attribs .= '%;'; else
  2895. $attribs .= 'px;';
  2896. $class1 = '';
  2897. if ($row->class1 != '')
  2898. $class1 = ' class="' . $this->getClassName($row->class1) . '"';
  2899. $class2 = '';
  2900. if ($row->class2 != '')
  2901. $class2 = ' class="' . $this->getClassName($row->class2) . '"';
  2902. switch ($row->type) {
  2903. case 'Static Text/HTML':
  2904. case 'Rectangle':
  2905. case 'Image':
  2906. if ($row->height > 0) {
  2907. $attribs .= 'height:' . $row->height;
  2908. if ($row->heightmode)
  2909. $attribs .= '%;'; else
  2910. $attribs .= 'px;';
  2911. } // if
  2912. case 'Query List':
  2913. if ($row->width > 0) {
  2914. $attribs .= 'width:' . $row->width;
  2915. if ($row->widthmode)
  2916. $attribs .= '%;'; else
  2917. $attribs .= 'px;';
  2918. } // if
  2919. default:
  2920. break;
  2921. } // switch
  2922. if ($row->page != $this->page)
  2923. $attribs .= 'visibility:hidden;';
  2924. switch ($row->type) {
  2925. case 'Static Text/HTML':
  2926. echo indentc(1) . '<div id="ff_div' . $row->id . '" style="' . $attribs . '"' . $class1 . '>' . $data1 . '</div>' . nl();
  2927. break;
  2928. case 'Rectangle':
  2929. if ($data1 != '')
  2930. $attribs .= 'border:' . $data1 . ';';
  2931. if ($data2 != '')
  2932. $attribs .= 'background-color:' . $data2 . ';';
  2933. echo indentc(1) . '<div id="ff_div' . $row->id . '" style="font-size:0px;' . $attribs . '"' . $class1 . '></div>' . nl();
  2934. break;
  2935. case 'Image':
  2936. echo indentc(1) . '<div id="ff_div' . $row->id . '" style="' . $attribs . '"' . $class1 . '>' . nlc();
  2937. $attribs = '';
  2938. if ($row->width > 0)
  2939. $attribs .= 'width="' . $row->width . '" ';
  2940. if ($row->height > 0)
  2941. $attribs .= 'height="' . $row->height . '" ';
  2942. echo indentc(2) . '<img id="ff_elem' . $row->id . '" src="' . $data1 . '" alt="' . $data2 . '" border="0" ' . $attribs . $class2 . '/>' . nlc();
  2943. echo indentc(1) . '</div>' . nl();
  2944. break;
  2945. case 'Tooltip':
  2946. echo indentc(1) . '<div id="ff_div' . $row->id . '" style="' . $attribs . '" onMouseOver="return overlib(\'' . expstring($data2) . '\',CAPTION,\'' . $row->title . '\',BELOW,RIGHT);" onMouseOut="return nd();"' . $class1 . '>' . nlc();
  2947. switch ($row->flag1) {
  2948. case 0: $url = $ff_mossite . '/components/com_breezingforms/images/tooltip.png';
  2949. break;
  2950. case 1: $url = $ff_mossite . '/components/com_breezingforms/images/warning.png';
  2951. break;
  2952. default: $url = $data1;
  2953. } // switch
  2954. echo indentc(2) . '<img src="' . $url . '" alt="" border="0"' . $class2 . '/>' . nlc();
  2955. echo indentc(1) . '</div>' . nl();
  2956. break;
  2957. case 'Hidden Input':
  2958. echo indentc(1) . '<input id="ff_elem' . $row->id . '" type="hidden" name="ff_nm_' . $row->name . '[]" value="' . $data1 . '" />' . nl();
  2959. break;
  2960. case 'Checkbox':
  2961. echo indentc(1) . '<div id="ff_div' . $row->id . '" style="' . $attribs . '"' . $class1 . '>' . nlc();
  2962. $valueGlobal = ff_setChecked('ff_nm_' . $row->name . '[]',$ActualElement);
  2963. $attribs = '';
  2964. if ($row->flag1)
  2965. $attribs .= ' checked="checked"';
  2966. if ($row->flag2)
  2967. $attribs .= ' disabled="disabled"';
  2968. $attribs .= $this->script2clause($row);
  2969. echo indentc(2) . '<input id="ff_elem' . $row->id . '" type="checkbox" name="ff_nm_' . $row->name . '[]" value="' . $valueGlobal . '"' . $attribs . $class2 . '/><label id="ff_lbl' . $row->id . '" for="ff_elem' . $row->id . '"> ' . $data2 . '</label>' . nlc();
  2970. echo indentc(1) . '</div>' . nl();
  2971. break;
  2972. case 'Radio Button':
  2973. echo indentc(1) . '<div id="ff_div' . $row->id . '" style="' . $attribs . '"' . $class1 . '>' . nlc();
  2974. $attribs = '';
  2975. if ($row->flag1)
  2976. $attribs .= ' checked="checked"';
  2977. if ($row->flag2)
  2978. $attribs .= ' disabled="disabled"';
  2979. $attribs .= $this->script2clause($row);
  2980. echo indentc(2) . '<input id="ff_elem' . $row->id . '" type="radio" name="ff_nm_' . $row->name . '[]" value="' . $data1 . '"' . $attribs . $class2 . '/><label id="ff_lbl' . $row->id . '" for="ff_elem' . $row->id . '"> ' . $data2 . '</label>' . nlc();
  2981. echo indentc(1) . '</div>' . nl();
  2982. break;
  2983. case 'Regular Button':
  2984. echo indentc(1) . '<div id="ff_div' . $row->id . '" style="' . $attribs . '"' . $class1 . '>' . nlc();
  2985. $attribs = '';
  2986. if ($row->flag2)
  2987. $attribs .= ' disabled="disabled"';
  2988. $attribs .= $this->script2clause($row);
  2989. echo indentc(2) . '<input id="ff_elem' . $row->id . '" type="button" name="ff_nm_' . $row->name . '" value="' . $data2 . '"' . $attribs . $class2 . '/>' . nlc();
  2990. echo indentc(1) . '</div>' . nl();
  2991. break;
  2992. case 'Graphic Button':
  2993. echo indentc(1) . '<div id="ff_div' . $row->id . '" style="' . $attribs . '"' . $class1 . '>' . nlc();
  2994. $attribs = '';
  2995. if ($row->flag2)
  2996. $attribs .= ' disabled="disabled"';
  2997. $attribs .= $this->script2clause($row);
  2998. echo indentc(2) . '<button id="ff_elem' . $row->id . '" type="button" name="ff_nm_' . $row->name . '" value="' . $data2 . '"' . $attribs . $class2 . '>' . nlc();
  2999. $attribs = '';
  3000. if ($row->width > 0)
  3001. $attribs .= 'width="' . $row->width . '" ';
  3002. if ($row->height > 0)
  3003. $attribs .= 'height="' . $row->height . '" ';
  3004. switch ($row->flag1) {
  3005. case 0: // none
  3006. echo indentc(3) . '<table cellpadding="0" cellspacing="6" border="0">' . nlc();
  3007. echo indentc(4) . '<tr><td>' . nlc();
  3008. echo indentc(5) . '<img id="ff_img' . $row->id . '" src="' . $data1 . '" alt="' . $data2 . '" border="0" ' . $attribs . '/>' . nlc();
  3009. echo indentc(4) . '</td></tr>' . nlc();
  3010. echo indentc(3) . '</table>' . nlc();
  3011. break;
  3012. case 1: // below
  3013. echo indentc(3) . '<table cellpadding="0" cellspacing="6" border="0">' . nlc();
  3014. echo indentc(4) . '<tr><td nowrap style="text-align:center">' . nlc();
  3015. echo indentc(5) . '<img id="ff_img' . $row->id . '" src="' . $data1 . '" alt="" border="0" ' . $attribs . '/><br/>' . nlc();
  3016. echo indentc(5) . $data2 . nlc();
  3017. echo indentc(4) . '</td></tr>' . nlc();
  3018. echo indentc(3) . '</table>' . nlc();
  3019. break;
  3020. case 2: // above
  3021. echo indentc(3) . '<table cellpadding="0" cellspacing="6" border="0">' . nlc();
  3022. echo indentc(4) . '<tr><td nowrap style="text-align:center">' . nlc();
  3023. echo indentc(5) . $data2 . '<br/>' . nlc();
  3024. echo indentc(5) . '<img id="ff_img' . $row->id . '" src="' . $data1 . '" alt="" border="0" ' . $attribs . '/>' . nlc();
  3025. echo indentc(4) . '</td></tr>' . nlc();
  3026. echo indentc(3) . '</table>.nlc()';
  3027. break;
  3028. case 3: // left
  3029. echo indentc(3) . '<table cellpadding="0" cellspacing="6" border="0">' . nlc();
  3030. echo indentc(4) . '<tr>' . nlc();
  3031. echo indentc(5) . '<td>' . $data2 . '</td>' . nlc();
  3032. echo indentc(5) . '<td><img id="ff_img' . $row->id . '" src="' . $data1 . '" alt="" border="0" ' . $attribs . '/></td>' . nlc();
  3033. echo indentc(4) . '</tr>' . nlc();
  3034. echo indentc(3) . '</table>' . nlc();
  3035. break;
  3036. default: // assume right
  3037. echo indentc(3) . '<table cellpadding="0" cellspacing="6" border="0">' . nlc();
  3038. echo indentc(4) . '<tr>' . nlc();
  3039. echo indentc(5) . '<td><img id="ff_img' . $row->id . '" src="' . $data1 . '" alt="" border="0" ' . $attribs . '/></td>' . nlc();
  3040. echo indentc(5) . '<td>' . $data2 . '</td>' . nlc();
  3041. echo indentc(4) . '</tr>' . nlc();
  3042. echo indentc(3) . '</table>' . nlc();
  3043. break;
  3044. } // switch
  3045. echo indentc(2) . '</button>' . nlc();
  3046. echo indentc(1) . '</div>' . nl();
  3047. break;
  3048. case 'Icon':
  3049. if ($row->flag2)
  3050. echo indentc(1) . '<div id="ff_div' . $row->id . '" onmouseout="ff_hideIconBorder(this);" onmouseover="ff_dispIconBorder(this);" style="padding:3px;' . $attribs . '"' . $class1 . '>' . nlc();
  3051. else
  3052. echo indentc(1) . '<div id="ff_div' . $row->id . '" style="' . $attribs . '"' . $class1 . '>' . nlc();
  3053. $swap = '';
  3054. if ($data3 != '')
  3055. $swap = 'onmouseout="MM_swapImgRestore();" onmouseover="MM_swapImage(\'ff_img' . $row->id . '\',\'\',\'' . $data3 . '\',1);" ';
  3056. $swap .= $this->script2clause($row);
  3057. $attribs = '';
  3058. if ($row->width > 0)
  3059. $attribs .= 'width="' . $row->width . '" ';
  3060. if ($row->height > 0)
  3061. $attribs .= 'height="' . $row->height . '" ';
  3062. switch ($row->flag1) {
  3063. case 0: // none
  3064. echo indentc(2) . '<span id="ff_elem' . $row->id . '" ' . $swap . '>' . nlc();
  3065. echo indentc(3) . '<img id="ff_img' . $row->id . '" src="' . $data1 . '" alt="" border="0" align="middle" ' . $attribs . $class2 . '/>' . nlc();
  3066. echo indentc(2) . '</span>' . nlc();
  3067. break;
  3068. case 1: // below
  3069. echo indentc(2) . '<table id="ff_elem' . $row->id . '" cellpadding="1" cellspacing="0" border="0" ' . $swap . '>' . nlc();
  3070. echo indentc(3) . '<tr><td style="text-align:center;"><img id="ff_img' . $row->id . '" src="' . $data1 . '" alt="" border="0" align="middle" ' . $attribs . $class2 . '/></td></tr>' . nlc();
  3071. echo indentc(3) . '<tr><td style="text-align:center;">' . $data2 . '</td></tr>' . nlc();
  3072. echo indentc(2) . '</table>' . nlc();
  3073. break;
  3074. case 2: // above
  3075. echo indentc(2) . '<table id="ff_elem' . $row->id . '" cellpadding="2" cellspacing="0" border="0" ' . $swap . '>' . nlc();
  3076. echo indentc(3) . '<tr><td style="text-align:center;">' . $data2 . '</td></tr>' . nlc();
  3077. echo indentc(3) . '<tr><td style="text-align:center;"><img id="ff_img' . $row->id . '" src="' . $data1 . '" alt="" border="0" align="middle" ' . $attribs . $class2 . '/></td></tr>' . nlc();
  3078. echo indentc(2) . '</table>' . nlc();
  3079. break;
  3080. case 3: // left
  3081. echo indentc(2) . '<span id="ff_elem' . $row->id . '" ' . $swap . ' style="vertical-align:middle;">' . nlc();
  3082. echo indentc(3) . $data2 . ' &nbsp;<img id="ff_img' . $row->id . '" src="' . $data1 . '" alt="" border="0" align="middle" ' . $attribs . $class2 . '/>' . nlc();
  3083. echo indentc(2) . '</span>' . nlc();
  3084. break;
  3085. default: // assume right
  3086. echo indentc(2) . '<span id="ff_elem' . $row->id . '" ' . $swap . ' style="vertical-align:middle;">' . nlc();
  3087. echo indentc(3) . '<img id="ff_img' . $row->id . '" src="' . $data1 . '" alt="" border="0" align="middle" ' . $attribs . $class2 . '/>&nbsp; ' . $data2 . nlc();
  3088. echo indentc(2) . '</span>' . nlc();
  3089. break;
  3090. } // switch
  3091. echo indentc(1) . '</div>' . nl();
  3092. break;
  3093. case 'Select List':
  3094. echo indentc(1) . '<div id="ff_div' . $row->id . '" style="' . $attribs . '"' . $class1 . '>' . nlc();
  3095. $attribs = '';
  3096. $styles = '';
  3097. $valueGlobal = ff_setSelected('ff_nm_' . $row->name . '[]',$ActualElement);
  3098. if ($row->width > 0)
  3099. $styles .= 'width:' . $row->width . 'px;';
  3100. if ($row->height > 0)
  3101. $styles .= 'height:' . $row->height . 'px;';
  3102. if ($row->flag1)
  3103. $attribs .= ' multiple="multiple"';
  3104. if ($row->flag2)
  3105. $attribs .= ' disabled="disabled"';
  3106. $attribs .= $this->script2clause($row);
  3107. if ($data1 != '')
  3108. $attribs .= ' size="' . $data1 . '"';
  3109. if ($styles != '')
  3110. $attribs .= ' style="' . $styles . '"';
  3111. echo indentc(2) . '<select id="ff_elem' . $row->id . '" name="ff_nm_' . $row->name . '[]" ' . $attribs . $class2 . '>' . nlc();
  3112. $options = explode('\n', preg_replace('/([\\r\\n])/s', '\n', $data2));
  3113. $cnt = count($options);
  3114. for ($o = 0; $o < $cnt; $o++) {
  3115. $opt = explode(";", $options[$o]);
  3116. $selected = '';
  3117. switch (count($opt)) {
  3118. case 0:
  3119. break;
  3120. case 1:
  3121. if ($this->trim($opt[0])) {
  3122. $selected = '0';
  3123. $value = $text = $opt[0];
  3124. } // if
  3125. break;
  3126. case 2:
  3127. $selected = $opt[0];
  3128. $value = $text = $opt[1];
  3129. break;
  3130. default:
  3131. $selected = $opt[0];
  3132. $text = $opt[1];
  3133. $value = $opt[2];
  3134. } // switch
  3135. if ($this->trim($selected)) {
  3136. $attribs = '';
  3137. if ($this->trim($value)) {
  3138. if ($value == '""' || $value == "''")
  3139. $value = '';
  3140. $attribs .= ' value="' . htmlspecialchars($value, ENT_QUOTES) . '"';
  3141. } // if
  3142. if ($selected == 1)
  3143. $attribs .= ' selected="selected"';
  3144. //echo indentc(3) . '<option' . $attribs . '>' . htmlspecialchars(trim($text), ENT_QUOTES) . '</option>' . nlc();
  3145. echo indentc(3) . '<option' . $attribs . '>' . $valueGlobal . '</option>' . nlc();
  3146. } // if
  3147. } // for
  3148. echo indentc(2) . '</select>' . nlc();
  3149. echo indentc(1) . '</div>' . nl();
  3150. break;
  3151. case 'Text':
  3152. echo indentc(1) . '<div id="ff_div' . $row->id . '" style="' . $attribs . '"' . $class1 . '>' . nlc();
  3153. $attribs = '';
  3154. if ($row->width > 0) {
  3155. if ($row->widthmode > 0)
  3156. $attribs .= ' style="width:' . $row->width . 'px;"';
  3157. else
  3158. $attribs .= ' size="' . $row->width . '"';
  3159. } // if
  3160. if ($row->height > 0)
  3161. $attribs .= ' maxlength="' . $row->height . '"';
  3162. if ($row->flag1)
  3163. $attribs .= ' type="password"';
  3164. else
  3165. $attribs .= ' type="text"';
  3166. switch ($row->flag2) {
  3167. case 1: $attribs .= ' disabled="disabled"';
  3168. break;
  3169. case 2: $attribs .= ' readonly="readonly"';
  3170. break;
  3171. default: break;
  3172. } // switch
  3173. $attribs .= $this->script2clause($row);
  3174. //$valueGlobal = ff_setValue('ff_nm_' . $row->name . '[]',$ActualElement);
  3175. echo indentc(2) . '<input id="ff_elem' . $row->id . '"' . $attribs . ' name="ff_nm_' . $row->name . '[]" value="' . $data1 . '"' . $class2 . '/>' . nlc();
  3176. $valueGlobal = ff_setValue('ff_nm_' . $row->name . '[]',$ActualElement);
  3177. echo "Value Global " . $valueGlobal;
  3178. echo indentc(1) . '</div>' . nl();
  3179. break;
  3180. case 'Textarea':
  3181. echo indentc(1) . '<div id="ff_div' . $row->id . '" style="' . $attribs . '"' . $class1 . '>' . nlc();
  3182. $attribs = '';
  3183. $styles = '';
  3184. switch ($row->flag2) {
  3185. case 1: $attribs .= ' disabled="disabled"';
  3186. break;
  3187. case 2: $attribs .= ' readonly="readonly"';
  3188. break;
  3189. default: break;
  3190. } // switch
  3191. if ($row->width > 0) {
  3192. if ($row->widthmode > 0)
  3193. $styles .= 'width:' . $row->width . 'px;';
  3194. else
  3195. $attribs .= ' cols="' . $row->width . '"';
  3196. } // if
  3197. if ($row->height > 0) {
  3198. if ($row->heightmode > 0)
  3199. $styles .= 'height:' . $row->height . 'px;';
  3200. else {
  3201. $height = $row->height;
  3202. if ($height > 1 && stristr($this->browser, 'mozilla'))
  3203. $height--;
  3204. $attribs .= ' rows="' . $height . '"';
  3205. } // if
  3206. } // if
  3207. if ($styles != '')
  3208. $attribs .= ' style="' . $styles . '"';
  3209. $attribs .= $this->script2clause($row);
  3210. echo indentc(2) . '<textarea id="ff_elem' . $row->id . '" name="ff_nm_' . $row->name . '[]"' . $attribs . $class2 . '>' . $data1 . '</textarea>' . nlc();
  3211. $valueGlobal = ff_setValue('ff_nm_' . $row->name . '[]',$ActualElement);
  3212. echo indentc(1) . '</div>' . nl();
  3213. break;
  3214. case 'File Upload':
  3215. echo indentc(1) . '<div id="ff_div' . $row->id . '" style="' . $attribs . '"' . $class1 . '>' . nlc();
  3216. $attribs = '';
  3217. if ($row->width > 0)
  3218. $attribs .= ' size="' . $row->width . '"';
  3219. if ($row->height > 0)
  3220. $attribs .= ' maxlength="' . $row->height . '"';
  3221. if ($row->flag2)
  3222. $attribs .= ' disabled="disabled"';
  3223. if ($row->data2 != '')
  3224. $attribs .= ' accept="' . $data2 . '"';
  3225. $attribs .= $this->script2clause($row);
  3226. echo indentc(2) . '<input id="ff_elem' . $row->id . '"' . $attribs . ' type="file" name="ff_nm_' . $row->name . '[]"' . $class2 . '/>' . nlc();
  3227. echo indentc(1) . '</div>' . nl();
  3228. break;
  3229. case 'Captcha':
  3230. if(JFactory::getApplication()->isSite())
  3231. {
  3232. $captcha_url = JURI::root(true).'/components/com_breezingforms/images/captcha/securimage_show.php';
  3233. }
  3234. else
  3235. {
  3236. $captcha_url = JURI::root(true).'/administrator/components/com_breezingforms/images/captcha/securimage_show.php';
  3237. }
  3238. echo indentc(1) . '<div id="ff_div' . $row->id . '" style="' . $attribs . '"' . $class1 . '>' . nlc();
  3239. $attribs = '';
  3240. if ($row->width > 0)
  3241. $attribs .= 'width:' . $row->width . 'px;';
  3242. if ($row->height > 0)
  3243. $attribs .= 'height:' . $row->height . 'px;';
  3244. echo '<img id="ff_capimgValue" class="ff_capimg" src="'.$captcha_url.'"/>';
  3245. echo '<br/>';
  3246. echo '<input type="text" style="' . $attribs . '" name="bfCaptchaEntry" id="bfCaptchaEntry" />';
  3247. //echo '<br/>';
  3248. echo '<a href="#" onclick="document.getElementById(\'bfCaptchaEntry\').value=\'\';document.getElementById(\'bfCaptchaEntry\').focus();document.getElementById(\'ff_capimgValue\').src = \'' . $captcha_url . '?bfCaptcha=true&bfMathRandom=\' + Math.random(); return false"><img src="' . JURI::root() . 'components/com_breezingforms/images/captcha/refresh-captcha.png" border="0" /></a>';
  3249. echo indentc(1) . '</div>' . nl();
  3250. break;
  3251. case 'Query List':
  3252. echo indentc(1) . '<div id="ff_div' . $row->id . '" style="' . $attribs . '"' . $class1 . '>' . nlc();
  3253. // unpack settings
  3254. $settings = explode("\n", $row->data1);
  3255. $scnt = count($settings);
  3256. for ($s = 0; $s < $scnt; $s++)
  3257. $this->trim($settings[$s]);
  3258. $trhclass = '';
  3259. $tr1class = '';
  3260. $tr2class = '';
  3261. $trfclass = '';
  3262. $tdfclass = '';
  3263. $pagenav = 1;
  3264. $attribs = '';
  3265. if ($scnt > 0 && $settings[0] != '')
  3266. $attribs .= ' border="' . $settings[0] . '"';
  3267. if ($scnt > 1 && $settings[1] != '')
  3268. $attribs .= ' cellspacing="' . $settings[1] . '"';
  3269. if ($scnt > 2 && $settings[2] != '')
  3270. $attribs .= ' cellpadding="' . $settings[2] . '"';
  3271. if ($scnt > 3 && $settings[3] != '')
  3272. $trhclass = ' class="' . $this->getClassName($settings[3]) . '"';
  3273. if ($scnt > 4 && $settings[4] != '')
  3274. $tr1class = ' class="' . $this->getClassName($settings[4]) . '"';
  3275. if ($scnt > 5 && $settings[5] != '')
  3276. $tr2class = ' class="' . $this->getClassName($settings[5]) . '"';
  3277. if ($scnt > 6 && $settings[6] != '')
  3278. $trfclass = ' class="' . $this->getClassName($settings[6]) . '"';
  3279. if ($scnt > 7 && $settings[7] != '')
  3280. $tdfclass = ' class="' . $this->getClassName($settings[7]) . '"';
  3281. if ($scnt > 8 && $settings[8] != '')
  3282. $pagenav = $settings[8];
  3283. if ($row->width > 0)
  3284. $attribs .= ' width="100%"';
  3285. // display 1st page of table
  3286. echo indentc(2) . '<table id="ff_elem' . $row->id . '"' . $attribs . $class2 . '>' . nl();
  3287. $cols = & $this->queryCols['ff_' . $row->id];
  3288. $colcnt = count($cols);
  3289. // display header
  3290. if ($row->flag1) {
  3291. echo indentc(3) . '<tr' . $trhclass . '>' . nlc();
  3292. $skip = 0;
  3293. for ($c = 0; $c < $colcnt; $c++)
  3294. if ($skip > 0)
  3295. $skip--; else {
  3296. $col = & $cols[$c];
  3297. if ($col->thspan > 0) {
  3298. $attribs = '';
  3299. $style = '';
  3300. switch ($col->thalign) {
  3301. case 1: $style .= 'text-align:left;';
  3302. break;
  3303. case 2: $style .= 'text-align:center;';
  3304. break;
  3305. case 3: $style .= 'text-align:right;';
  3306. break;
  3307. case 4: $style .= 'text-align:justify;';
  3308. break;
  3309. default:;
  3310. } // switch
  3311. switch ($col->thvalign) {
  3312. case 1: $attribs .= ' valign="top"';
  3313. break;
  3314. case 2: $attribs .= ' valign="middle"';
  3315. break;
  3316. case 3: $attribs .= ' valign="bottom"';
  3317. break;
  3318. case 4: $attribs .= ' valign="baseline"';
  3319. break;
  3320. default:;
  3321. } // switch
  3322. if ($col->thwrap == 1)
  3323. $attribs .= ' nowrap="nowrap"';
  3324. if ($col->thspan > 1) {
  3325. $attribs .= ' colspan="' . $col->thspan . '"';
  3326. $skip = $col->thspan - 1;
  3327. } // if
  3328. if ($col->class1 != '')
  3329. $attribs .= ' class="' . $this->getClassName($col->class1) . '"';
  3330. if (intval($col->width) > 0 && !$skip) {
  3331. $style .= 'width:' . $col->width;
  3332. if ($col->widthmd)
  3333. $style .= '%;'; else
  3334. $style .= 'px;';
  3335. } // if
  3336. if ($style != '')
  3337. $attribs .= ' style="' . $style . '"';
  3338. if ($c == 0 && $row->flag2 > 0) {
  3339. if ($row->flag2 == 1)
  3340. echo indentc(4) . '<th' . $attribs . '><input type="checkbox" id="ff_cb' . $row->id . '" onclick="ff_selectAllQueryRows(' . $row->id . ',this.checked);" /></th>' . nlc();
  3341. else
  3342. echo indentc(4) . '<th' . $attribs . '></th>' . nlc();
  3343. } else
  3344. echo indentc(4) . '<th' . $attribs . '>' . $this->replaceCode($col->title, BFText::_('COM_BREEZINGFORMS_PROCESS_QTITLEOF') . " $row->name::$col->name", 'e', $row->id, 2) . '</th>' . nlc();
  3345. } // if
  3346. unset($col);
  3347. } // if
  3348. echo indentc(3) . '</tr>' . nl();
  3349. } // if
  3350. // display data rows
  3351. $qrows = & $this->queryRows['ff_' . $row->id];
  3352. $qcnt = count($qrows);
  3353. $k = 1;
  3354. if ($row->height > 0 && $qcnt > $row->height)
  3355. $qcnt = $row->height;
  3356. for ($q = 0; $q < $qcnt; $q++) {
  3357. $qrow = & $qrows[$q];
  3358. if ($k == 1)
  3359. $cl = $tr1class; else
  3360. $cl = $tr2class;
  3361. echo indentc(3) . '<tr' . $cl . '>' . nlc();
  3362. $skip = 0;
  3363. for ($c = 0; $c < $colcnt; $c++) {
  3364. $col = & $cols[$c];
  3365. if ($col->thspan > 0) {
  3366. $attribs = '';
  3367. $style = '';
  3368. switch ($col->align) {
  3369. case 1: $style .= 'text-align:left;';
  3370. break;
  3371. case 2: $style .= 'text-align:center;';
  3372. break;
  3373. case 3: $style .= 'text-align:right;';
  3374. break;
  3375. case 4: $style .= 'text-align:justify;';
  3376. break;
  3377. default:;
  3378. } // switch
  3379. switch ($col->valign) {
  3380. case 1: $attribs .= ' valign="top"';
  3381. break;
  3382. case 2: $attribs .= ' valign="middle"';
  3383. break;
  3384. case 3: $attribs .= ' valign="bottom"';
  3385. break;
  3386. case 4: $attribs .= ' valign="baseline"';
  3387. break;
  3388. default:;
  3389. } // switch
  3390. if ($col->wrap == 1)
  3391. $attribs .= ' nowrap="nowrap"';
  3392. if ($k == 1)
  3393. $cl = $col->class2; else
  3394. $cl = $col->class3;
  3395. if ($cl != '')
  3396. $attribs .= ' class="' . $this->getClassName($cl) . '"';
  3397. if (!$skip && $col->thspan > 1)
  3398. $skip = $col->thspan;
  3399. if ($skip && $q == 0)
  3400. if (intval($col->width) > 0) {
  3401. $style .= 'width:' . $col->width;
  3402. if ($col->widthmd)
  3403. $style .= '%;'; else
  3404. $style .= 'px;';
  3405. } // if
  3406. if ($skip > 0)
  3407. $skip--;
  3408. if ($style != '')
  3409. $attribs .= ' style="' . $style . '"';
  3410. if ($c == 0 && $row->flag2 > 0) {
  3411. if ($row->flag2 == 1)
  3412. echo indentc(4) . '<td' . $attribs . '><input type="checkbox" id="ff_cb' . $row->id . '_' . $q . '" value="' . $qrow[$c] . '" name="ff_nm_' . $row->name . '[]"/></td>' . nlc();
  3413. else
  3414. echo indentc(4) . '<td' . $attribs . '><input type="radio" id="ff_cb' . $row->id . '_' . $q . '" value="' . $qrow[$c] . '" name="ff_nm_' . $row->name . '[]"/></td>' . nlc();
  3415. } else
  3416. echo indentc(4) . '<td' . $attribs . '>' . $qrow[$c] . '</td>' . nlc();
  3417. } // if
  3418. unset($col);
  3419. if ($this->dying)
  3420. break;
  3421. } // for
  3422. echo indentc(3) . '</tr>' . nl();
  3423. $k = 3 - $k;
  3424. unset($qrow);
  3425. if ($this->dying)
  3426. break;
  3427. } // for
  3428. if ($this->bury())
  3429. return;
  3430. // display footer
  3431. if ($row->height > 0 && $pagenav > 0) {
  3432. $span = 0;
  3433. for ($c = 0; $c < $colcnt; $c++)
  3434. if ($cols[$c]->thspan > 0)
  3435. $span++;
  3436. $pages = intval((count($qrows) + $row->height - 1) / $row->height);
  3437. echo indentc(3) . '<tr' . $trfclass . '>' . nlc();
  3438. echo indentc(4) . '<td colspan="' . $span . '"' . $tdfclass . '>' . nlc();
  3439. if ($pages > 1) {
  3440. echo indentc(5);
  3441. if ($pagenav <= 4)
  3442. echo '&lt;&lt; ';
  3443. if ($pagenav <= 2)
  3444. echo BFText::_('COM_BREEZINGFORMS_PROCESS_PAGESTART') . ' ';
  3445. if ($pagenav <= 4)
  3446. echo '&lt; ';
  3447. if ($pagenav <= 2)
  3448. echo BFText::_('COM_BREEZINGFORMS_PROCESS_PAGEPREV') . ' ';
  3449. echo nlc();
  3450. if ($pagenav % 2) {
  3451. echo indentc(5);
  3452. echo '1 ';
  3453. for ($p = 2; $p <= $pages; $p++)
  3454. echo indentc(5) . '<a href="javascript:ff_dispQueryPage(' . $row->id . ',' . $p . ');">' . $p . '</a> ' . nlc();
  3455. echo nlc();
  3456. } // if
  3457. if ($pagenav <= 4) {
  3458. echo indentc(5) . '<a href="javascript:ff_dispQueryPage(' . $row->id . ',2);">';
  3459. if ($pagenav <= 2)
  3460. echo BFText::_('COM_BREEZINGFORMS_PROCESS_PAGENEXT') . ' ';
  3461. echo '&gt;</a> ' . nlc();
  3462. echo indentc(5) . '<a href="javascript:ff_dispQueryPage(' . $row->id . ',' . $pages . ');">';
  3463. if ($pagenav <= 2)
  3464. echo BFText::_('COM_BREEZINGFORMS_PROCESS_PAGEEND') . ' ';
  3465. echo '&gt;&gt;</a>' . nlc();
  3466. } // if
  3467. } // if
  3468. echo indentc(4) . '</td>' . nlc();
  3469. echo indentc(3) . '</tr>' . nl();
  3470. } // if
  3471. // table end
  3472. echo indentc(2) . '</table>' . nlc();
  3473. echo indentc(1) . '</div>' . nl();
  3474. unset($qrows);
  3475. unset($cols);
  3476. break;
  3477. default:
  3478. break;
  3479. } // switch
  3480. unset($row);
  3481. } // for
  3482. } else if (trim($this->formrow->template_code_processed) == 'QuickMode') {
  3483. if($this->isMobile){
  3484. // nothing
  3485. }else{
  3486. require_once(JPATH_SITE . '/administrator/components/com_breezingforms/libraries/crosstec/classes/BFQuickMode.php');
  3487. $quickMode = new BFQuickMode($this);
  3488. $this->quickmode = $quickMode;
  3489. }
  3490. if( $is_mobile_type == 'choose' ) {
  3491. $return_url = JURI::getInstance()->toString();
  3492. $return_url = (strstr($return_url,'?non_mobile=1') !== false ? str_replace('?non_mobile=1','',$return_url) : str_replace('&non_mobile=1','',$return_url));
  3493. $return_url = $return_url.(strstr($return_url,'?') !== false ? '&' : '?') . 'mobile=1';
  3494. echo '<div style="display: block; text-align: center;"><button class="ff_elem" onclick="location.href=\''.$return_url.'\';"><span>'.JText::_('COM_BREEZINGFORMS_MOBILE_VERSION').'</span></button></div><div></div>';
  3495. }
  3496. $quickMode->render();
  3497. } else { // case if forms done with the easy mode
  3498. // always load calendar
  3499. JHTML::_('behavior.calendar');
  3500. echo '
  3501. <style type="text/css">
  3502. ul.droppableArea, ul.droppableArea li { background-image: none; list-style: none; }
  3503. li.ff_listItem { width: auto; list-style: none; }
  3504. li.ff_listItem .ff_div { width: auto; float: left; }
  3505. .ff_label { outline: none; }
  3506. .ff_elem { float: left; }
  3507. .ff_dragBox { display: none; }
  3508. </style>
  3509. ' . nl();
  3510. echo $this->formrow->template_code_processed;
  3511. $visPages = '';
  3512. $pagesSize = isset($this->formrow->pages) ? intval($this->formrow->pages) : 1;
  3513. for ($pageCnt = 1; $pageCnt <= $pagesSize; $pageCnt++) {
  3514. $visPages .= 'if(document.getElementById("bfPage' . $pageCnt . '"))document.getElementById("bfPage' . $pageCnt . '").style.display = "none";';
  3515. }
  3516. echo '<script type="text/javascript">
  3517. <!--
  3518. ' . $visPages . ';
  3519. if(document.getElementById("bfPage' . $this->page . '"))document.getElementById("bfPage' . $this->page . '").style.display = "";
  3520. //-->
  3521. </script>' . nl();
  3522. }
  3523. if ($this->editable) {
  3524. echo '<script type="text/javascript"><!--' . nl() . 'if(typeof bfLoadEditable != "undefined") { bfLoadEditable(); }' . nl() . '//--></script>' . nl();
  3525. }
  3526. if ($cbRecord !== null) {
  3527. echo '<script type="text/javascript"><!--' . nl() . 'bfLoadContentBuilderEditable();' . nl() . '//--></script>' . nl();
  3528. }
  3529. if ($cbForm !== null && count($cbNonEditableFields)) {
  3530. echo '<script type="text/javascript"><!--' . nl() . 'bfDisableContentBuilderFields();' . nl() . '//--></script>' . nl();
  3531. }
  3532. // CONTENTBUILDER
  3533. // writing hidden input for groups. helps on recording updates, otherwise no value would be transferred.
  3534. // the "cbGroupMark" won't be stored.
  3535. if ($cbForm !== null) {
  3536. for ($i = 0; $i < $this->rowcount; $i++) {
  3537. $row = $this->rows[$i];
  3538. switch ($row->type) {
  3539. case 'Checkbox':
  3540. case 'Checkbox Group':
  3541. case 'Radio Button':
  3542. case 'Radio Group':
  3543. case 'Select List':
  3544. // temporary removed until further clarification if needed or not as this will interfere with javasripts on group elements (loosing their type)
  3545. //echo '<input type="hidden" name="ff_nm_' . $row->name . '[]" value="cbGroupMark"/>' . nl();
  3546. break;
  3547. }
  3548. }
  3549. }
  3550. $paymentMethod = '';
  3551. for ($i = 0; $i < $this->rowcount; $i++) {
  3552. $row = $this->rows[$i];
  3553. if ($row->type == "PayPal" || $row->type == "Sofortueberweisung") {
  3554. echo indentc(1) . '<input type="hidden" name="ff_payment_method" id="bfPaymentMethod" value=""/>' . nl();
  3555. break;
  3556. }
  3557. }
  3558. switch ($this->runmode) {
  3559. case _FF_RUNMODE_FRONTEND:
  3560. echo indentc(1) . '<input type="hidden" name="ff_contentid" value="' . JRequest::getInt('ff_contentid', 0) . '"/>' . nl() .
  3561. indentc(1) . '<input type="hidden" name="ff_applic" value="' . JRequest::getWord('ff_applic', '') . '"/>' . nl() .
  3562. indentc(1) . '<input type="hidden" name="ff_module_id" value="' . JRequest::getInt('ff_module_id', 0) . '"/>' . nl();
  3563. echo indentc(1) . '<input type="hidden" name="ff_form" value="' . $this->form . '"/>' . nl() .
  3564. indentc(1) . '<input type="hidden" name="ff_task" value="submit"/>' . nl();
  3565. if ($this->target > 1)
  3566. echo indentc(1) . '<input type="hidden" name="ff_target" value="' . $this->target . '"/>' . nl();
  3567. if ($this->inframe)
  3568. echo indentc(1) . '<input type="hidden" name="ff_frame" value="1"/>' . nl();
  3569. if ($this->border)
  3570. echo indentc(1) . '<input type="hidden" name="ff_border" value="1"/>' . nl();
  3571. if ($this->page != 1)
  3572. echo indentc(1) . '<input type="hidden" name="ff_page" value="' . $this->page . '"/>' . nl();
  3573. if ($this->align != 1)
  3574. echo indentc(1) . '<input type="hidden" name="ff_align" value="' . $this->align . '"/>' . nl();
  3575. if ($this->top != 0)
  3576. echo indentc(1) . '<input type="hidden" name="ff_top" value="' . $this->top . '"/>' . nl();
  3577. reset($ff_otherparams);
  3578. while (list($prop, $val) = each($ff_otherparams))
  3579. echo indentc(1) . '<input type="hidden" name="' . $prop . '" value="' . $val . '"/>' . nl();
  3580. if (isset($_REQUEST['cb_form_id']) && isset($_REQUEST['cb_record_id'])) {
  3581. echo '<input type="hidden" name="cb_form_id" value="' . JRequest::getInt('cb_form_id', 0) . '"/>' . nl();
  3582. echo '<input type="hidden" name="cb_record_id" value="' . JRequest::getInt('cb_record_id', 0) . '"/>' . nl();
  3583. echo '<input type="hidden" name="return" value="' . JRequest::getVar('return', '') . '"/>' . nl();
  3584. }
  3585. echo '</form>' . nl();
  3586. break;
  3587. case _FF_RUNMODE_BACKEND:
  3588. echo indentc(1) . '<input type="hidden" name="option" value="com_breezingforms"/>' . nl() .
  3589. indentc(1) . '<input type="hidden" name="act" value="run"/>' . nl() .
  3590. indentc(1) . '<input type="hidden" name="ff_form" value="' . $this->form . '"/>' . nl() .
  3591. indentc(1) . '<input type="hidden" name="ff_task" value="submit"/>' . nl() .
  3592. indentc(1) . '<input type="hidden" name="ff_contentid" value="' . JRequest::getInt('ff_contentid', 0) . '"/>' . nl() .
  3593. indentc(1) . '<input type="hidden" name="ff_applic" value="' . JRequest::getWord('ff_applic', '') . '"/>' . nl() .
  3594. indentc(1) . '<input type="hidden" name="ff_module_id" value="' . JRequest::getInt('ff_module_id', 0) . '"/>' . nl() .
  3595. indentc(1) . '<input type="hidden" name="ff_runmode" value="' . $this->runmode . '"/>' . nl();
  3596. if ($this->target > 1)
  3597. echo indentc(1) . '<input type="hidden" name="ff_target" value="' . $this->target . '"/>' . nl();
  3598. if ($this->inframe)
  3599. echo indentc(1) . '<input type="hidden" name="ff_frame" value="1"/>' . nl();
  3600. if ($this->border)
  3601. echo indentc(1) . '<input type="hidden" name="ff_border" value="1"/>' . nl();
  3602. if ($this->page != 1)
  3603. echo indentc(1) . '<input type="hidden" name="ff_page" value="' . $this->page . '"/>' . nl();
  3604. if ($this->align != 1)
  3605. echo indentc(1) . '<input type="hidden" name="ff_align" value="' . $this->align . '"/>' . nl();
  3606. if ($this->top != 0)
  3607. echo indentc(1) . '<input type="hidden" name="ff_top" value="' . $this->top . '"/>' . nl();
  3608. if (isset($_REQUEST['cb_form_id']) && isset($_REQUEST['cb_record_id'])) {
  3609. echo '<input type="hidden" name="cb_form_id" value="' . JRequest::getInt('cb_form_id', 0) . '"/>' . nl();
  3610. echo '<input type="hidden" name="cb_record_id" value="' . JRequest::getInt('cb_record_id', 0) . '"/>' . nl();
  3611. echo '<input type="hidden" name="return" value="' . JRequest::getVar('return', '') . '"/>' . nl();
  3612. }
  3613. //echo '<input type="hidden" name="tmpl" value="' . JRequest::getCmd('tmpl', '') . '"/>' . nl();
  3614. echo '</form>' . nl();
  3615. break;
  3616. default: // _FF_RUNMODE_PREVIEW:
  3617. if ($this->inframe) {
  3618. echo indentc(1) . '<input type="hidden" name="option" value="com_breezingforms"/>' . nl() .
  3619. indentc(1) . '<input type="hidden" name="ff_frame" value="1"/>' . nl() .
  3620. indentc(1) . '<input type="hidden" name="ff_form" value="' . $this->form . '"/>' . nl() .
  3621. indentc(1) . '<input type="hidden" name="ff_task" value="submit"/>' . nl() .
  3622. indentc(1) . '<input type="hidden" name="ff_contentid" value="' . JRequest::getInt('ff_contentid', 0) . '"/>' . nl() .
  3623. indentc(1) . '<input type="hidden" name="ff_applic" value="' . JRequest::getWord('ff_applic', '') . '"/>' . nl() .
  3624. indentc(1) . '<input type="hidden" name="ff_module_id" value="' . JRequest::getInt('ff_module_id', 0) . '"/>' . nl() .
  3625. indentc(1) . '<input type="hidden" name="ff_runmode" value="' . $this->runmode . '"/>' . nl();
  3626. if ($this->page != 1)
  3627. echo indentc(1) . '<input type="hidden" name="ff_page" value="' . $this->page . '"/>' . nl();
  3628. if (isset($_REQUEST['cb_form_id']) && isset($_REQUEST['cb_record_id'])) {
  3629. echo '<input type="hidden" name="cb_form_id" value="' . JRequest::getInt('cb_form_id', 0) . '"/>' . nl();
  3630. echo '<input type="hidden" name="cb_record_id" value="' . JRequest::getInt('cb_record_id', 0) . '"/>' . nl();
  3631. echo '<input type="hidden" name="return" value="' . JRequest::getVar('return', '') . '"/>' . nl();
  3632. }
  3633. echo '</form>' . nl();
  3634. } // if
  3635. } // if
  3636. // handle After Form piece
  3637. $code = '';
  3638. switch ($this->formrow->piece2cond) {
  3639. case 1: // library
  3640. $database->setQuery(
  3641. "select name, code from #__facileforms_pieces " .
  3642. "where id=" . $this->formrow->piece2id . " and published=1 "
  3643. );
  3644. $rows = $database->loadObjectList();
  3645. if (count($rows))
  3646. echo $this->execPiece(
  3647. $rows[0]->code, BFText::_('COM_BREEZINGFORMS_PROCESS_AFPIECE') . " " . $rows[0]->name, 'p', $this->formrow->piece2id, null
  3648. );
  3649. break;
  3650. case 2: // custom code
  3651. echo $this->execPiece(
  3652. $this->formrow->piece2code, BFText::_('COM_BREEZINGFORMS_PROCESS_AFPIECEC'), 'f', $this->form, 2
  3653. );
  3654. break;
  3655. default:
  3656. break;
  3657. } // switch
  3658. if ($this->bury())
  3659. return;
  3660. echo '</div></div></div><div class="bfPage-bl"><div class="bfPage-br"><div class="bfPage-b"></div></div></div></div><!-- form end -->' . nl();
  3661. if ($this->traceMode & _FF_TRACEMODE_DIRECT) {
  3662. $this->dumpTrace();
  3663. ob_end_flush();
  3664. echo '</pre>';
  3665. } else {
  3666. ob_end_flush();
  3667. $this->dumpTrace();
  3668. } // if
  3669. restore_error_handler();
  3670. if (trim($this->formrow->template_code_processed) == 'QuickMode' && $this->isMobile) {
  3671. $contents = ob_get_contents();
  3672. ob_end_clean();
  3673. echo '<!DOCTYPE html>
  3674. <html>
  3675. <head>
  3676. <title>'.JFactory::getDocument()->getTitle().'</title>
  3677. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  3678. <meta name="viewport" content="width=device-width, initial-scale=1">';
  3679. echo $quickMode->fetchHead(JFactory::getDocument()->getHeadData());
  3680. echo $quickMode->headers();
  3681. echo '</head>'."\n";
  3682. echo '<body>'."\n";
  3683. echo $contents;
  3684. echo '
  3685. </body>'."\n".'</html>';
  3686. exit;
  3687. }
  3688. }
  3689. // view
  3690. function logToDatabase($cbResult = null) { // CONTENTBUILDER
  3691. global $database, $ff_config;
  3692. $database = JFactory::getDBO();
  3693. if ($this->dying)
  3694. return;
  3695. if (!is_object($cbResult['form']) && $this->editable && $this->editable_override) {
  3696. $database->setQuery("Select id From #__facileforms_records Where form = " . $database->Quote($this->form) . " And user_id = " . $database->Quote(JFactory::getUser()->get('id', 0)) . " And user_id <> 0");
  3697. $records = $database->loadObjectList();
  3698. foreach ($records As $record) {
  3699. $database->setQuery("Delete From #__facileforms_subrecords Where record = " . $record->id);
  3700. $database->query();
  3701. $database->setQuery("Delete From #__facileforms_records Where id = " . $record->id);
  3702. $database->query();
  3703. }
  3704. }
  3705. $record = new facileFormsRecords($database);
  3706. $record->submitted = $this->submitted;
  3707. $record->form = $this->form;
  3708. $record->title = $this->formrow->title;
  3709. $record->name = $this->formrow->name;
  3710. $record->ip = $this->ip;
  3711. $record->browser = $this->browser;
  3712. $record->opsys = $this->opsys;
  3713. $record->provider = $this->provider;
  3714. $record->viewed = 0;
  3715. $record->exported = 0;
  3716. $record->archived = 0;
  3717. if (JFactory::getUser()->get('id', 0) > 0) {
  3718. $record->user_id = JFactory::getUser()->get('id', 0);
  3719. $record->username = JFactory::getUser()->get('username', '');
  3720. $record->user_full_name = JFactory::getUser()->get('name', '');
  3721. } else {
  3722. $record->user_id = JFactory::getUser()->get('id', 0);
  3723. $record->username = '-';
  3724. $record->user_full_name = '-';
  3725. }
  3726. // CONTENTBUILDER WILL TAKE OVER SAVING/UPDATE IF EXISTS
  3727. $cbFileFields = array();
  3728. if (!is_object($cbResult['form'])) {
  3729. if (!$record->store()) {
  3730. $this->status = _FF_STATUS_SAVERECORD_FAILED;
  3731. $this->message = $record->getError();
  3732. return;
  3733. } // if
  3734. $record_return = $record->id;
  3735. if($record_return && JFile::exists(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_contentbuilder' . DS . 'contentbuilder.xml')){
  3736. $last_update = JFactory::getDate();
  3737. $last_update = $last_update->toMySQL();
  3738. $db = JFactory::getDBO();
  3739. $db->setQuery("Select id From #__contentbuilder_records Where `type` = 'com_breezingforms' And `reference_id` = ".$db->Quote($this->form)." And record_id = " . $db->Quote($record_return));
  3740. $res = $db->loadResult();
  3741. if(!$res){
  3742. $db->setQuery("Insert Into #__contentbuilder_records (session_id,`type`,last_update, published, record_id, reference_id) Values ('".JFactory::getSession()->getId()."','com_breezingforms',".$db->Quote($last_update).",0, ".$db->Quote($record_return).", ".$db->Quote($this->form).")");
  3743. $db->query();
  3744. }else{
  3745. $db->setQuery("Update #__contentbuilder_records Set last_update = ".$db->Quote($last_update).",edited = edited + 1 Where `type` = 'com_breezingforms' And `reference_id` = ".$db->Quote($this->form)." And record_id = " . $db->Quote($record_return));
  3746. $db->query();
  3747. }
  3748. }
  3749. }
  3750. $this->record_id = $record->id;
  3751. $names = array();
  3752. $subrecord = new facileFormsSubrecords($database);
  3753. $subrecord->record = $record->id;
  3754. if (count($this->savedata)) {
  3755. $cbData = array();
  3756. // CONTENTBUILDER file deletion/upgrade
  3757. if (is_object($cbResult['form'])) {
  3758. $db = JFactory::getDBO();
  3759. $db->setQuery('Select SQL_CALC_FOUND_ROWS * From #__contentbuilder_forms Where id = ' . JRequest::getInt('cb_form_id', 0) . ' And published = 1');
  3760. $_settings = $db->loadObject();
  3761. $_record = $cbResult['form']->getRecord(JRequest::getInt('record_id',0), $_settings->published_only, $cbResult['frontend'] ? ( $_settings->own_only_fe ? JFactory::getUser()->get('id', 0) : -1 ) : ( $_settings->own_only ? JFactory::getUser()->get('id', 0) : -1 ), true );
  3762. foreach($_record As $_rec){
  3763. $_files_deleted = array();
  3764. if($_rec->recType == 'File Upload'){
  3765. $_array = JRequest::getVar('cb_delete_'.$_rec->recElementId, array(),'','ARRAY');
  3766. foreach($_array As $_key => $_arr){
  3767. if($_arr == 1){
  3768. $_values = explode("\n", $_rec->recValue);
  3769. if( isset($_values[$_key]) ){
  3770. if(strpos(strtolower($_values[$_key]), '{cbsite}') === 0){
  3771. $_values[$_key] = str_replace(array('{cbsite}','{CBSite}'), array(JPATH_SITE, JPATH_SITE), $_values[$_key]);
  3772. }
  3773. if(JFile::exists($_values[$_key])){
  3774. JFile::delete($_values[$_key]);
  3775. }
  3776. if(!isset($_files_deleted[$_rec->recElementId])){
  3777. $_files_deleted[$_rec->recElementId] = array();
  3778. }
  3779. $_files_deleted[$_rec->recElementId][] = $_key;
  3780. }
  3781. }
  3782. }
  3783. if(isset($_files_deleted[$_rec->recElementId]) && is_array($_files_deleted[$_rec->recElementId]) && count($_files_deleted[$_rec->recElementId])){
  3784. $_i = 0;
  3785. foreach($this->savedata as $data){
  3786. if($data[_FF_DATA_ID] == $_rec->recElementId){
  3787. $_is_values = explode("\n", $_rec->recValue);
  3788. $_j = 0;
  3789. foreach($_is_values As $_is_value){
  3790. if( !in_array($_j, $_files_deleted[$_rec->recElementId]) ){
  3791. $this->savedata[$_i][_FF_DATA_VALUE] .= $_is_value . "\n";
  3792. }
  3793. $_j++;
  3794. }
  3795. $this->savedata[$_i][_FF_DATA_VALUE] = rtrim($this->savedata[$_i][_FF_DATA_VALUE]);
  3796. break;
  3797. }
  3798. $_i++;
  3799. }
  3800. }
  3801. else{
  3802. $found = false;
  3803. $_i = 0;
  3804. foreach($this->savedata as $data){
  3805. if($data[_FF_DATA_ID] == $_rec->recElementId && $data[_FF_DATA_VALUE] != ''){
  3806. $found = true;
  3807. if($_rec->recValue != ''){
  3808. $_values = explode("\n", $_rec->recValue);
  3809. foreach($_values As $_value){
  3810. if(strpos(strtolower($_value), '{cbsite}') === 0){
  3811. $_value = str_replace(array('{cbsite}','{CBSite}'), array(JPATH_SITE, JPATH_SITE), $_value);
  3812. }
  3813. if(JFile::exists($_value)){
  3814. JFile::delete($_value);
  3815. }
  3816. }
  3817. }
  3818. break;
  3819. }
  3820. $_i++;
  3821. }
  3822. if(!$found){
  3823. $next = count($this->savedata);
  3824. $this->savedata[$next] = array();
  3825. $this->savedata[$next][_FF_DATA_ID] = $_rec->recElementId;
  3826. $this->savedata[$next][_FF_DATA_NAME] = $_rec->recName;
  3827. $this->savedata[$next][_FF_DATA_TITLE] = $_rec->recTitle;
  3828. $this->savedata[$next][_FF_DATA_TYPE] = $_rec->recType;
  3829. $this->savedata[$next][_FF_DATA_VALUE] = '';
  3830. $_is_values = explode("\n", $_rec->recValue);
  3831. foreach($_is_values As $_is_value){
  3832. $this->savedata[$next][_FF_DATA_VALUE] .= $_is_value . "\n";
  3833. }
  3834. $this->savedata[$next][_FF_DATA_VALUE] = rtrim($this->savedata[$next][_FF_DATA_VALUE]);
  3835. }
  3836. }
  3837. }
  3838. }
  3839. }
  3840. $_savedata = array();
  3841. if (!is_object($cbResult['form'])) {
  3842. foreach ($this->savedata as $data) {
  3843. if($data[_FF_DATA_TYPE] == 'File Upload'){
  3844. if(!isset($_savedata[$data[_FF_DATA_ID]])){
  3845. $_savedata[$data[_FF_DATA_ID]] = '';
  3846. }
  3847. $_savedata[$data[_FF_DATA_ID]] .= $data[_FF_DATA_VALUE]."\n";
  3848. }
  3849. }
  3850. }
  3851. $isset = array();
  3852. foreach ($this->savedata as $data) {
  3853. // CONTENTBUILDER WILL TAKE OVER SAVING/UPDATE IF EXISTS
  3854. if (!is_object($cbResult['form'])) {
  3855. $subrecord->id = NULL;
  3856. $subrecord->element = $data[_FF_DATA_ID];
  3857. $subrecord->name = $data[_FF_DATA_NAME];
  3858. $subrecord->title = $data[_FF_DATA_TITLE];
  3859. $subrecord->type = $data[_FF_DATA_TYPE];
  3860. if(isset($_savedata[$data[_FF_DATA_ID]]) && !isset($isset[$data[_FF_DATA_ID]])){
  3861. $subrecord->value = trim($_savedata[$data[_FF_DATA_ID]]);
  3862. }else{
  3863. $subrecord->value = $data[_FF_DATA_VALUE];
  3864. }
  3865. if(!isset($isset[$data[_FF_DATA_ID]])){
  3866. if (!$subrecord->store()) {
  3867. $this->status = _FF_STATUS_SAVESUBRECORD_FAILED;
  3868. $this->message = $subrecord->getError();
  3869. return;
  3870. }
  3871. }
  3872. if($data[_FF_DATA_TYPE] == 'File Upload'){
  3873. $isset[$data[_FF_DATA_ID]] = true;
  3874. }
  3875. } else {
  3876. require_once(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_contentbuilder' . DS . 'classes' . DS . 'contentbuilder.php');
  3877. $cbNonEditableFields = contentbuilder::getListNonEditableElements($cbResult['data']['id']);
  3878. if (!in_array($data[_FF_DATA_ID], $cbNonEditableFields)) {
  3879. switch ($data[_FF_DATA_TYPE]) {
  3880. case 'Checkbox':
  3881. case 'Checkbox Group':
  3882. case 'Radio Button':
  3883. case 'Radio Group':
  3884. case 'Select List':
  3885. if (!isset($cbData[$data[_FF_DATA_ID]])) {
  3886. $cbData[$data[_FF_DATA_ID]] = array();
  3887. }
  3888. $cbData[$data[_FF_DATA_ID]][] = $data[_FF_DATA_VALUE];
  3889. break;
  3890. case 'File Upload':
  3891. if (!isset($cbData[$data[_FF_DATA_ID]])) {
  3892. $cbData[$data[_FF_DATA_ID]] = '';
  3893. $cbFileFields[] = $data[_FF_DATA_ID];
  3894. }
  3895. $cbData[$data[_FF_DATA_ID]] .= $data[_FF_DATA_VALUE] . "\n";
  3896. break;
  3897. default:
  3898. $cbData[$data[_FF_DATA_ID]] = $data[_FF_DATA_VALUE];
  3899. }
  3900. }
  3901. }
  3902. } // foreach
  3903. // CONTENTBUILDER BEGIN
  3904. if (is_object($cbResult['form'])) {
  3905. JPluginHelper::importPlugin('contentbuilder_submit');
  3906. $submit_dispatcher = JDispatcher::getInstance();
  3907. jimport('joomla.version');
  3908. $version = new JVersion();
  3909. $is15 = true;
  3910. if (version_compare($version->getShortVersion(), '1.6', '>=')) {
  3911. $is15 = false;
  3912. }
  3913. $values = array();
  3914. $names = $cbResult['form']->getAllElements();
  3915. foreach ($names As $id => $name) {
  3916. if (isset($cbData[$id])) {
  3917. if (in_array($id, $cbFileFields) && trim($cbData[$id]) == '') {
  3918. $values[$id] = '';
  3919. } else if (in_array($id, $cbFileFields) && trim($cbData[$id]) != '') {
  3920. $values[$id] = trim($cbData[$id]);
  3921. } else {
  3922. $values[$id] = $cbData[$id];
  3923. }
  3924. }
  3925. }
  3926. $submit_before_result = $submit_dispatcher->trigger('onBeforeSubmit', array(JRequest::getInt('cb_record_id', 0), $cbResult['form'], $values));
  3927. $record_return = $cbResult['form']->saveRecord(JRequest::getInt('cb_record_id', 0), $values);
  3928. $db = JFactory::getDBO();
  3929. $db->setQuery('Select SQL_CALC_FOUND_ROWS * From #__contentbuilder_forms Where id = ' . JRequest::getInt('cb_form_id', 0) . ' And published = 1');
  3930. $cbData = $db->loadObject();
  3931. if($record_return){
  3932. $this->record_id = $record_return;
  3933. $sef = '';
  3934. $ignore_lang_code = '*';
  3935. if($cbResult['data']['default_lang_code_ignore']){
  3936. jimport('joomla.version');
  3937. $version = new JVersion();
  3938. if(version_compare($version->getShortVersion(), '1.6', '>=')){
  3939. $db->setQuery("Select lang_code From #__languages Where published = 1 And sef = " . $db->Quote(trim(JRequest::getCmd('lang',''))));
  3940. $ignore_lang_code = $db->loadResult();
  3941. if(!$ignore_lang_code){
  3942. $ignore_lang_code = '*';
  3943. }
  3944. }
  3945. else
  3946. {
  3947. $codes = contentbuilder::getLanguageCodes();
  3948. foreach($codes As $code){
  3949. if(strstr(strtolower($code), strtolower(trim(JRequest::getCmd('lang','')))) !== false){
  3950. $ignore_lang_code = strtolower($code);
  3951. break;
  3952. }
  3953. }
  3954. }
  3955. $sef = trim(JRequest::getCmd('lang',''));
  3956. if($ignore_lang_code == '*'){
  3957. $sef = '';
  3958. }
  3959. } else {
  3960. jimport('joomla.version');
  3961. $version = new JVersion();
  3962. if(version_compare($version->getShortVersion(), '1.6', '>=')){
  3963. $db->setQuery("Select sef From #__languages Where published = 1 And lang_code = " . $db->Quote($cbResult['data']['default_lang_code']));
  3964. $sef = $db->loadResult();
  3965. } else {
  3966. $codes = contentbuilder::getLanguageCodes();
  3967. foreach($codes As $code){
  3968. if($code == $cbResult['data']['default_lang_code']){
  3969. $sef = explode('-', $code);
  3970. if(count($sef)){
  3971. $sef = strtolower($sef[0]);
  3972. }
  3973. break;
  3974. }
  3975. }
  3976. }
  3977. }
  3978. $language = $cbResult['data']['default_lang_code_ignore'] ? $ignore_lang_code : $cbResult['data']['default_lang_code'];
  3979. $db->setQuery("Select id From #__contentbuilder_records Where `type` = 'com_breezingforms' And `reference_id` = ".$db->Quote($cbResult['form']->getReferenceId())." And record_id = " . $db->Quote($record_return));
  3980. $res = $db->loadResult();
  3981. $last_update = JFactory::getDate();
  3982. $last_update = $last_update->toMySQL();
  3983. if(!$res){
  3984. $is_future = 0;
  3985. $created_up = JFactory::getDate();
  3986. $created_up = $created_up->toMySQL();
  3987. if(intval($cbData->default_publish_up_days) != 0){
  3988. $is_future = 1;
  3989. $date = JFactory::getDate(strtotime('now +'.intval($cbData->default_publish_up_days).' days'));
  3990. $created_up = $date->toMySQL();
  3991. }
  3992. $created_down = '0000-00-00 00:00:00';
  3993. if(intval($cbData->default_publish_down_days) != 0){
  3994. $date = JFactory::getDate(strtotime($created_up.' +'.intval($cbData->default_publish_down_days).' days'));
  3995. $created_down = $date->toMySQL();
  3996. }
  3997. $db->setQuery("Insert Into #__contentbuilder_records (session_id,`type`,last_update,is_future,lang_code, sef, published, record_id, reference_id, publish_up, publish_down) Values ('".JFactory::getSession()->getId()."','com_breezingforms',".$db->Quote($last_update).",$is_future, ".$db->Quote($language).",".$db->Quote(trim($sef)).",".$db->Quote($cbData->auto_publish && !$is_future ? 1 : 0).", ".$db->Quote($record_return).", ".$db->Quote($cbResult['form']->getReferenceId()).", ".$db->Quote($created_up).", ".$db->Quote($created_down).")");
  3998. $db->query();
  3999. }else{
  4000. $db->setQuery("Update #__contentbuilder_records Set last_update = ".$db->Quote($last_update).",lang_code = ".$db->Quote($language).", sef = ".$db->Quote(trim($sef)).", edited = edited + 1 Where `type` = 'com_breezingforms' And `reference_id` = ".$db->Quote($cbResult['form']->getReferenceId())." And record_id = " . $db->Quote($record_return));
  4001. $db->query();
  4002. }
  4003. }
  4004. $article_id = 0;
  4005. // creating the article
  4006. if (is_object($cbData) && $cbData->create_articles) {
  4007. JRequest::setVar('cb_category_id',null);
  4008. JRequest::setVar('cb_controller',null);
  4009. jimport('joomla.version');
  4010. $version = new JVersion();
  4011. if(JFactory::getApplication()->isSite() && JRequest::getInt('Itemid',0)){
  4012. if (version_compare($version->getShortVersion(), '1.6', '>=')) {
  4013. $menu = JSite::getMenu();
  4014. $item = $menu->getActive();
  4015. if (is_object($item)) {
  4016. JRequest::setVar('cb_category_id', $item->params->get('cb_category_id', null));
  4017. JRequest::setVar('cb_controller', $item->params->get('cb_controller', null));
  4018. }
  4019. } else {
  4020. $params = JComponentHelper::getParams('com_contentbuilder');
  4021. JRequest::setVar('cb_category_id', $params->get('cb_category_id', null));
  4022. JRequest::setVar('cb_controller', $params->get('cb_controller', null));
  4023. }
  4024. }
  4025. $cbData->page_title = $cbData->use_view_name_as_title ? $cbData->name : $cbResult['form']->getPageTitle();
  4026. $cbData->labels = $cbResult['form']->getElementLabels();
  4027. $ids = array();
  4028. foreach ($cbData->labels As $reference_id => $label) {
  4029. $ids[] = $db->Quote($reference_id);
  4030. }
  4031. $cbData->labels = array();
  4032. if (count($ids)) {
  4033. $db->setQuery("Select Distinct `label`, reference_id From #__contentbuilder_elements Where form_id = " . JRequest::getInt('cb_form_id', 0) . " And reference_id In (" . implode(',', $ids) . ") And published = 1 Order By ordering");
  4034. $rows = $db->loadAssocList();
  4035. $ids = array();
  4036. foreach ($rows As $row) {
  4037. $ids[] = $row['reference_id'];
  4038. }
  4039. }
  4040. $cbData->items = $cbResult['form']->getRecord($record_return, $cbData->published_only, $cbResult['frontend'] ? ( $cbData->own_only_fe ? JFactory::getUser()->get('id', 0) : -1 ) : ( $cbData->own_only ? JFactory::getUser()->get('id', 0) : -1 ), true );
  4041. if(!count($cbData->items)){
  4042. JError::raiseError(404, JText::_('COM_CONTENTBUILDER_RECORD_NOT_FOUND'));
  4043. }
  4044. $config = array();
  4045. $full = false;
  4046. $article_id = contentbuilder::createArticle(JRequest::getInt('cb_form_id', 0), $record_return, $cbData->items, $ids, $cbData->title_field, $cbResult['form']->getRecordMetadata($record_return), $config, $full, true, JRequest::getVar('cb_category_id',null));
  4047. $cache = JFactory::getCache('com_content');
  4048. $cache->clean();
  4049. $cache = JFactory::getCache('com_contentbuilder');
  4050. $cache->clean();
  4051. }
  4052. $submit_after_result = $submit_dispatcher->trigger('onAfterSubmit', array($record_return, $article_id, $cbResult['form'], $values));
  4053. }
  4054. // CONTENTBUILDER END
  4055. }
  4056. require_once(JPATH_SITE . '/administrator/components/com_breezingforms/libraries/crosstec/classes/BFIntegrate.php');
  4057. $integrate = new BFIntegrate($this->form);
  4058. if (count($this->savedata))
  4059. foreach ($this->savedata as $data) {
  4060. $integrate->field($data);
  4061. }
  4062. $integrate->commit();
  4063. if(isset($record_return)){
  4064. return $record_return;
  4065. }
  4066. }
  4067. // logToDatabase
  4068. function sendMail($from, $fromname, $recipient, $subject, $body, $attachment = NULL, $html = NULL, $cc = NULL, $bcc = NULL) {
  4069. if ($this->dying)
  4070. return;
  4071. $mail = bf_createMail($from, $fromname, $subject, $body);
  4072. if (is_array($recipient))
  4073. foreach ($recipient as $to)
  4074. $mail->AddAddress($to);
  4075. else
  4076. $mail->AddAddress($recipient);
  4077. if ($attachment) {
  4078. if (is_array($attachment)) {
  4079. $attCnt = count($attachment);
  4080. for ($i = 0; $i < $attCnt; $i++) {
  4081. $mail->AddAttachment($attachment[$i]);
  4082. }
  4083. }else
  4084. $mail->AddAttachment($attachment);
  4085. } // if
  4086. if (isset($html))
  4087. $mail->IsHTML($html);
  4088. if (isset($cc)) {
  4089. if (is_array($cc))
  4090. foreach ($cc as $to)
  4091. $mail->AddCC($to);
  4092. else
  4093. $mail->AddCC($cc);
  4094. } // if
  4095. if (isset($bcc)) {
  4096. if (is_array($bcc))
  4097. foreach ($bcc as $to)
  4098. $mail->AddBCC($to);
  4099. else
  4100. $mail->AddBCC($bcc);
  4101. } // if
  4102. if (!$mail->Send()) {
  4103. $this->status = _FF_STATUS_SENDMAIL_FAILED;
  4104. $this->message = $mail->ErrorInfo;
  4105. } // if
  4106. }
  4107. // sendMail
  4108. function exppdf($filter = array(), $mailback = false) {
  4109. global $ff_compath;
  4110. $file = JPATH_SITE . '/media/breezingforms/pdftpl/' . $this->formrow->name . '_pdf_attachment.php';
  4111. if (!JFile::exists($file)) {
  4112. $file = JPATH_SITE . '/media/breezingforms/pdftpl/pdf_attachment.php';
  4113. }
  4114. if ($mailback) {
  4115. $mb_file = JPATH_SITE . '/media/breezingforms/pdftpl/' . $this->formrow->name . '_pdf_mailback_attachment.php';
  4116. if (JFile::exists($mb_file)) {
  4117. $file = $mb_file;
  4118. } else {
  4119. $mb_file = JPATH_SITE . '/media/breezingforms/pdftpl/pdf_mailback_attachment.php';
  4120. if (JFile::exists($mb_file)) {
  4121. $file = $mb_file;
  4122. }
  4123. }
  4124. }
  4125. $processed = array();
  4126. $xmldata = array();
  4127. $_xmldata = $this->xmldata;
  4128. if ($mailback) {
  4129. $_xmldata = $this->mb_xmldata;
  4130. }
  4131. foreach ($_xmldata as $data) {
  4132. if (!in_array($data[_FF_DATA_NAME], $filter) && !in_array($data[_FF_DATA_NAME], $processed)) {
  4133. $xmldata[] = $data;
  4134. //$processed[] = $data[_FF_DATA_NAME];
  4135. }
  4136. }
  4137. ob_start();
  4138. require($file);
  4139. $c = ob_get_contents();
  4140. ob_end_clean();
  4141. require_once(JPATH_SITE . '/administrator/components/com_breezingforms/libraries/tcpdf/tcpdf.php');
  4142. $pdf = new TCPDF();
  4143. $pdf->setPrintHeader(false);
  4144. $pdf->AddPage();
  4145. $pdf->writeHTML($c);
  4146. mt_srand();
  4147. $pdfname = $ff_compath . '/exports/ffexport-pdf-' . date('YmdHis') . '-' . mt_rand(0, mt_getrandmax()) . '.pdf';
  4148. $pdf->lastPage();
  4149. $pdf->Output($pdfname, "F");
  4150. return $pdfname;
  4151. }
  4152. function expcsv($filter = array(), $mailback = false) {
  4153. global $ff_config;
  4154. $csvdelimiter = stripslashes($ff_config->csvdelimiter);
  4155. $csvquote = stripslashes($ff_config->csvquote);
  4156. $cellnewline = $ff_config->cellnewline == 0 ? "\n" : "\\n";
  4157. $fields = array();
  4158. $lines = array();
  4159. $lineNum = count($lines);
  4160. $fields['ZZZ_A_FORM'] = true;
  4161. $fields['ZZZ_B_SUBMITTED'] = true;
  4162. $fields['ZZZ_C_IP'] = true;
  4163. $fields['ZZZ_D_BROWSER'] = true;
  4164. $fields['ZZZ_E_OPSYS'] = true;
  4165. $lines[$lineNum]['ZZZ_A_FORM'][] = $this->form;
  4166. $lines[$lineNum]['ZZZ_B_SUBMITTED'][] = $this->submitted;
  4167. $lines[$lineNum]['ZZZ_C_IP'][] = $this->ip;
  4168. $lines[$lineNum]['ZZZ_D_BROWSER'][] = $this->browser;
  4169. $lines[$lineNum]['ZZZ_E_OPSYS'][] = $this->opsys;
  4170. $xmldata = $this->xmldata;
  4171. if ($mailback) {
  4172. $xmldata = $this->mb_xmldata;
  4173. }
  4174. $processed = array();
  4175. if (count($xmldata)) {
  4176. foreach ($xmldata as $data) {
  4177. if (!in_array($data[_FF_DATA_NAME], $filter) && !in_array($data[_FF_DATA_NAME], $processed)) {
  4178. $fields[strtoupper($data[_FF_DATA_NAME])] = true;
  4179. $lines[$lineNum][strtoupper($data[_FF_DATA_NAME])][] = is_array($data[_FF_DATA_VALUE]) ? implode('|', $data[_FF_DATA_VALUE]) : $data[_FF_DATA_VALUE];
  4180. //$processed[] = $data[_FF_DATA_NAME];
  4181. }
  4182. } // foreach
  4183. }
  4184. $head = '';
  4185. ksort($fields);
  4186. $lineLength = count($lines);
  4187. foreach ($fields As $fieldName => $null) {
  4188. $head .= $csvquote . $fieldName . $csvquote . $csvdelimiter;
  4189. }
  4190. $head = substr($head, 0, strlen($head) - 1) . nl();
  4191. $out = '';
  4192. for ($i = 0; $i < $lineLength; $i++) {
  4193. ksort($lines[$i]);
  4194. foreach ($lines[$i] As $line) {
  4195. $out .= $csvquote . str_replace($csvquote, $csvquote . $csvquote, str_replace("\n", $cellnewline, str_replace("\r", "", implode('|', $line)))) . $csvquote . $csvdelimiter;
  4196. }
  4197. $out = substr($out, 0, strlen($out) - 1);
  4198. $out .= nl();
  4199. }
  4200. mt_srand();
  4201. $csvname = JPATH_SITE . '/components/com_breezingforms/exports/ffexport-' . date('YmdHis') . '-' . mt_rand(0, mt_getrandmax()) . '.csv';
  4202. JFile::makeSafe($csvname);
  4203. if (function_exists('mb_convert_encoding')) {
  4204. $to_encoding = 'UTF-16LE';
  4205. $from_encoding = 'UTF-8';
  4206. $chrchr = chr(255) . chr(254) . mb_convert_encoding($head . $out, $to_encoding, $from_encoding);
  4207. if (!JFile::write($csvname, $chrchr)) {
  4208. $this->status = _FF_STATUS_ATTACHMENT_FAILED;
  4209. } // if
  4210. } else {
  4211. if (!JFile::write($csvname, $head . $out)) {
  4212. $this->status = _FF_STATUS_ATTACHMENT_FAILED;
  4213. } // if
  4214. }
  4215. return $csvname;
  4216. }
  4217. function expxml($filter = array(), $mailback = false) {
  4218. global $ff_compath, $ff_version, $mosConfig_fileperms;
  4219. if ($this->dying)
  4220. return '';
  4221. mt_srand();
  4222. $xmlname = $ff_compath . '/exports/ffexport-' . date('YmdHis') . '-' . mt_rand(0, mt_getrandmax()) . '.xml';
  4223. $xml = '<?xml version="1.0" encoding="utf-8" ?>' . nl() .
  4224. '<FacileFormsExport type="records" version="' . $ff_version . '">' . nl() .
  4225. indent(1) . '<exportdate>' . date('Y-m-d H:i:s') . '</exportdate>' . nl();
  4226. if ($this->record_id != '')
  4227. $xml .= indent(1) . '<record id="' . $this->record_id . '">' . nl();
  4228. else
  4229. $xml .= indent(1) . '<record>' . nl();
  4230. $xml .= indent(2) . '<submitted>' . $this->submitted . '</submitted>' . nl() .
  4231. indent(2) . '<form>' . $this->form . '</form>' . nl() .
  4232. indent(2) . '<title>' . htmlspecialchars($this->formrow->title, ENT_QUOTES, 'UTF-8') . '</title>' . nl() .
  4233. indent(2) . '<name>' . $this->formrow->name . '</name>' . nl() .
  4234. indent(2) . '<ip>' . $this->ip . '</ip>' . nl() .
  4235. indent(2) . '<browser>' . htmlspecialchars($this->browser, ENT_QUOTES, 'UTF-8') . '</browser>' . nl() .
  4236. indent(2) . '<opsys>' . htmlspecialchars($this->opsys, ENT_QUOTES, 'UTF-8') . '</opsys>' . nl() .
  4237. indent(2) . '<provider>' . $this->provider . '</provider>' . nl() .
  4238. indent(2) . '<viewed>0</viewed>' . nl() .
  4239. indent(2) . '<exported>0</exported>' . nl() .
  4240. indent(2) . '<archived>0</archived>' . nl();
  4241. $processed = array();
  4242. $xmldata = $this->xmldata;
  4243. if ($mailback) {
  4244. $xmldata = $this->mb_xmldata;
  4245. }
  4246. if (count($xmldata))
  4247. foreach ($xmldata as $data) {
  4248. if (!in_array($data[_FF_DATA_NAME], $filter) && !in_array($data[_FF_DATA_NAME], $processed)) {
  4249. $xml .= indent(2) . '<subrecord>' . nl() .
  4250. indent(3) . '<element>' . $data[_FF_DATA_ID] . '</element>' . nl() .
  4251. indent(3) . '<name>' . $data[_FF_DATA_NAME] . '</name>' . nl() .
  4252. indent(3) . '<title>' . htmlspecialchars($data[_FF_DATA_TITLE], ENT_QUOTES, 'UTF-8') . '</title>' . nl() .
  4253. indent(3) . '<type>' . $data[_FF_DATA_TYPE] . '</type>' . nl() .
  4254. indent(3) . '<value>' . htmlspecialchars(is_array($data[_FF_DATA_VALUE]) ? implode('|', $data[_FF_DATA_VALUE]) : $data[_FF_DATA_VALUE], ENT_QUOTES, 'UTF-8') . '</value>' . nl() .
  4255. indent(2) . '</subrecord>' . nl();
  4256. //$processed[] = $data[_FF_DATA_NAME];
  4257. }
  4258. } // foreach
  4259. $xml .= indent(1) . '</record>' . nl() .
  4260. '</FacileFormsExport>' . nl();
  4261. JFile::makeSafe($xmlname);
  4262. if (!JFile::write($xmlname, $xml)) {
  4263. $this->status = _FF_STATUS_ATTACHMENT_FAILED;
  4264. } // if
  4265. return $xmlname;
  4266. }
  4267. // expxml
  4268. function sendEmailNotification() {
  4269. global $ff_config;
  4270. $mainframe = JFactory::getApplication();
  4271. if ($this->dying)
  4272. return;
  4273. $from = $this->formrow->alt_mailfrom != '' ? $this->formrow->alt_mailfrom : $mainframe->getCfg('mailfrom');
  4274. $fromname = $this->formrow->alt_fromname != '' ? $this->formrow->alt_fromname : $mainframe->getCfg('fromname');
  4275. if ($this->formrow->emailntf == 2)
  4276. $recipient = $this->formrow->emailadr;
  4277. else
  4278. $recipient = $ff_config->emailadr;
  4279. $recipients = explode(';', $recipient);
  4280. $recipientsSize = count($recipients);
  4281. // dynamic receipients
  4282. for($i = 0; $i < $recipientsSize; $i++){
  4283. if( bf_startsWith(trim($recipients[$i]), '{' ) && bf_endsWith(trim($recipients[$i]), '}' ) ){
  4284. $from_ = trim($recipients[$i]);
  4285. $from_ = trim($from_, '{}');
  4286. $froms = explode(':', $from_);
  4287. $field = $froms[0];
  4288. if (count($this->maildata)) {
  4289. foreach ($this->maildata as $DATA) {
  4290. if( strtolower($DATA[_FF_DATA_NAME]) == strtolower($field) ){
  4291. if(isset($froms[1])){
  4292. $valuepairs = explode(',', $froms[1]);
  4293. foreach($valuepairs As $valuepair){
  4294. $keyval = explode('>',trim($valuepair));
  4295. $key = trim($keyval[0]);
  4296. if(isset($keyval[1])){
  4297. $value = trim($keyval[1]);
  4298. if( strtolower($key) == strtolower($DATA[_FF_DATA_VALUE]) ){
  4299. $recipients[$i] = $value;
  4300. break;
  4301. }
  4302. }
  4303. }
  4304. }
  4305. else{
  4306. $recipients[$i] = $DATA[_FF_DATA_VALUE];
  4307. }
  4308. break;
  4309. }
  4310. }
  4311. }
  4312. }
  4313. }
  4314. $subject = BFText::_('COM_BREEZINGFORMS_PROCESS_FORMRECRECEIVED');
  4315. if ($this->formrow->custom_mail_subject != '') {
  4316. $subject = $this->formrow->custom_mail_subject;
  4317. }
  4318. $body = '';
  4319. $isHtml = false;
  4320. if ($this->formrow->email_type == 0) {
  4321. $foundTpl = false;
  4322. $tplFile = '';
  4323. $formTxtFile = JPATH_SITE . '/media/breezingforms/mailtpl/' . $this->formrow->name . '.txt.php';
  4324. $formHtmlFile = JPATH_SITE . '/media/breezingforms/mailtpl/' . $this->formrow->name . '.html.php';
  4325. $defaultTxtFile = JPATH_SITE . '/media/breezingforms/mailtpl/mailtpl.txt.php';
  4326. $defaultHtmlFile = JPATH_SITE . '/media/breezingforms/mailtpl/mailtpl.html.php';
  4327. if (@file_exists($formHtmlFile) && @is_readable($formHtmlFile)) {
  4328. $tplFile = $formHtmlFile;
  4329. $foundTpl = true;
  4330. $isHtml = true;
  4331. } else if (@file_exists($formTxtFile) && @is_readable($formTxtFile)) {
  4332. $tplFile = $formTxtFile;
  4333. $foundTpl = true;
  4334. } else if (@file_exists($defaultHtmlFile) && @is_readable($defaultHtmlFile)) {
  4335. $tplFile = $defaultHtmlFile;
  4336. $foundTpl = true;
  4337. $isHtml = true;
  4338. } else if (@file_exists($defaultTxtFile) && @is_readable($defaultTxtFile)) {
  4339. $tplFile = $defaultTxtFile;
  4340. $foundTpl = true;
  4341. }
  4342. if ($foundTpl) {
  4343. $NL = nl();
  4344. $PROCESS_RECORDSAVEDID = '';
  4345. $RECORD_ID = '';
  4346. if ($this->record_id != '') {
  4347. $PROCESS_RECORDSAVEDID = BFText::_('COM_BREEZINGFORMS_PROCESS_RECORDSAVEDID');
  4348. $RECORD_ID = $this->record_id;
  4349. }
  4350. $PROCESS_FORMID = BFText::_('COM_BREEZINGFORMS_PROCESS_FORMID');
  4351. $FORM = $this->form;
  4352. $PROCESS_FORMTITLE = BFText::_('COM_BREEZINGFORMS_PROCESS_FORMTITLE');
  4353. $TITLE = $this->formrow->title;
  4354. $PROCESS_FORMNAME = BFText::_('COM_BREEZINGFORMS_PROCESS_FORMNAME');
  4355. $NAME = $this->formrow->name;
  4356. $PROCESS_SUBMITTEDAT = BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTEDAT');
  4357. $SUBMITTED = $this->submitted;
  4358. $PROCESS_SUBMITTERIP = BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERIP');
  4359. $IP = $this->ip;
  4360. $PROCESS_PROVIDER = BFText::_('COM_BREEZINGFORMS_PROCESS_PROVIDER');
  4361. $PROVIDER = $this->provider;
  4362. $PROCESS_BROWSER = BFText::_('COM_BREEZINGFORMS_PROCESS_BROWSER');
  4363. $BROWSER = $this->browser;
  4364. $PROCESS_OPSYS = BFText::_('COM_BREEZINGFORMS_PROCESS_OPSYS');
  4365. $OPSYS = $this->opsys;
  4366. $PROCESS_SUBMITTERID = BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERID');
  4367. $SUBMITTERID = 0;
  4368. $PROCESS_SUBMITTERUSERNAME = BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERUSERNAME');
  4369. $SUBMITTERUSERNAME = '-';
  4370. $PROCESS_SUBMITTERFULLNAME = BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERFULLNAME');
  4371. $SUBMITTERFULLNAME = '-';
  4372. if (JFactory::getUser()->get('id', 0) > 0) {
  4373. $SUBMITTERID = JFactory::getUser()->get('id', 0);
  4374. $SUBMITTERUSERNAME = JFactory::getUser()->get('username', '');
  4375. $SUBMITTERFULLNAME = JFactory::getUser()->get('name', '');
  4376. }
  4377. $MAILDATA = array();
  4378. if (count($this->maildata)) {
  4379. foreach ($this->maildata as $DATA) {
  4380. $subject = str_replace('{' . $DATA[_FF_DATA_NAME] . ':label}', $DATA[_FF_DATA_TITLE], $subject);
  4381. $subject = str_replace('{' . $DATA[_FF_DATA_NAME] . ':title}', $DATA[_FF_DATA_TITLE], $subject);
  4382. $subject = str_replace('{' . $DATA[_FF_DATA_NAME] . ':value}', $DATA[_FF_DATA_VALUE], $subject);
  4383. $subject = str_replace('{' . $DATA[_FF_DATA_NAME] . '}', $DATA[_FF_DATA_VALUE], $subject);
  4384. $MAILDATA[] = $DATA;
  4385. }
  4386. }
  4387. ob_start();
  4388. include($tplFile);
  4389. $body = ob_get_contents();
  4390. ob_end_clean();
  4391. } else {
  4392. // fallback if no template exists
  4393. if ($this->record_id != '')
  4394. $body .= BFText::_('COM_BREEZINGFORMS_PROCESS_RECORDSAVEDID') . " " . $this->record_id . nl() . nl();
  4395. $body .=
  4396. BFText::_('COM_BREEZINGFORMS_PROCESS_FORMID') . ": " . $this->form . nl() .
  4397. BFText::_('COM_BREEZINGFORMS_PROCESS_FORMTITLE') . ": " . $this->formrow->title . nl() .
  4398. BFText::_('COM_BREEZINGFORMS_PROCESS_FORMNAME') . ": " . $this->formrow->name . nl() . nl() .
  4399. BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTEDAT') . ": " . $this->submitted . nl() .
  4400. BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERIP') . ": " . $this->ip . nl() .
  4401. BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERID') . ": " . JFactory::getUser()->get('id', 0) . nl() .
  4402. BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERUSERNAME') . ": " . JFactory::getUser()->get('username', '') . nl() .
  4403. BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERFULLNAME') . ": " . JFactory::getUser()->get('name', '') . nl() .
  4404. BFText::_('COM_BREEZINGFORMS_PROCESS_PROVIDER') . ": " . $this->provider . nl() .
  4405. BFText::_('COM_BREEZINGFORMS_PROCESS_BROWSER') . ": " . $this->browser . nl() .
  4406. BFText::_('COM_BREEZINGFORMS_PROCESS_OPSYS') . ": " . $this->opsys . nl() . nl();
  4407. if (count($this->maildata)) {
  4408. foreach ($this->maildata as $data) {
  4409. $subject = str_replace('{' . $data[_FF_DATA_NAME] . ':label}', $data[_FF_DATA_TITLE], $subject);
  4410. $subject = str_replace('{' . $data[_FF_DATA_NAME] . ':title}', $data[_FF_DATA_TITLE], $subject);
  4411. $subject = str_replace('{' . $data[_FF_DATA_NAME] . ':value}', $data[_FF_DATA_VALUE], $subject);
  4412. $subject = str_replace('{' . $data[_FF_DATA_NAME] . '}', $data[_FF_DATA_VALUE], $subject);
  4413. $body .= $data[_FF_DATA_TITLE] . ": " . $data[_FF_DATA_VALUE] . nl();
  4414. }
  4415. }
  4416. }
  4417. } else {
  4418. $body = $this->formrow->email_custom_template;
  4419. $RECORD_ID = '';
  4420. if ($this->record_id != '') {
  4421. $RECORD_ID = $this->record_id;
  4422. }
  4423. $FORM = $this->form;
  4424. $TITLE = $this->formrow->title;
  4425. $FORMNAME = $this->formrow->name;
  4426. $SUBMITTED = $this->submitted;
  4427. $IP = $this->ip;
  4428. $PROVIDER = $this->provider;
  4429. $BROWSER = $this->browser;
  4430. $OPSYS = $this->opsys;
  4431. $SUBMITTERID = 0;
  4432. $SUBMITTERUSERNAME = '-';
  4433. $SUBMITTERFULLNAME = '-';
  4434. if (JFactory::getUser()->get('id', 0) > 0) {
  4435. $SUBMITTERID = JFactory::getUser()->get('id', 0);
  4436. $SUBMITTERUSERNAME = JFactory::getUser()->get('username', '');
  4437. $SUBMITTERFULLNAME = JFactory::getUser()->get('name', '');
  4438. }
  4439. $body = str_replace('{BF_RECORD_ID:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_RECORDSAVEDID'), $body);
  4440. $body = str_replace('{BF_RECORD_ID:value}', $RECORD_ID, $body);
  4441. $body = str_replace('{BF_FORM_ID:label}', BFText::_('Form ID'), $body);
  4442. $body = str_replace('{BF_FORM_ID:value}', $this->form_id, $body);
  4443. $body = str_replace('{BF_FORM:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_FORMID'), $body);
  4444. $body = str_replace('{BF_FORM:value}', $FORM, $body);
  4445. $body = str_replace('{BF_TITLE:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_FORMTITLE'), $body);
  4446. $body = str_replace('{BF_TITLE:value}', $TITLE, $body);
  4447. $body = str_replace('{BF_FORMNAME:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_FORMNAME'), $body);
  4448. $body = str_replace('{BF_FORMNAME:value}', $FORMNAME, $body);
  4449. $body = str_replace('{BF_SUBMITTED:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTEDAT'), $body);
  4450. $body = str_replace('{BF_SUBMITTED:value}', $SUBMITTED, $body);
  4451. $body = str_replace('{BF_IP:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERIP'), $body);
  4452. $body = str_replace('{BF_IP:value}', $IP, $body);
  4453. $body = str_replace('{BF_PROVIDER:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_PROVIDER'), $body);
  4454. $body = str_replace('{BF_PROVIDER:value}', $PROVIDER, $body);
  4455. $body = str_replace('{BF_BROWSER:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_BROWSER'), $body);
  4456. $body = str_replace('{BF_BROWSER:value}', $BROWSER, $body);
  4457. $body = str_replace('{BF_OPSYS:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_OPSYS'), $body);
  4458. $body = str_replace('{BF_OPSYS:value}', $OPSYS, $body);
  4459. $body = str_replace('{BF_SUBMITTERID:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERID'), $body);
  4460. $body = str_replace('{BF_SUBMITTERID:value}', $SUBMITTERID, $body);
  4461. $body = str_replace('{BF_SUBMITTERUSERNAME:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERUSERNAME'), $body);
  4462. $body = str_replace('{BF_SUBMITTERUSERNAME:value}', $SUBMITTERUSERNAME, $body);
  4463. $body = str_replace('{BF_SUBMITTERFULLNAME:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERFULLNAME'), $body);
  4464. $body = str_replace('{BF_SUBMITTERFULLNAME:value}', $SUBMITTERFULLNAME, $body);
  4465. if (count($this->maildata)) {
  4466. foreach ($this->maildata as $data) {
  4467. $subject = str_replace('{' . $data[_FF_DATA_NAME] . ':label}', $data[_FF_DATA_TITLE], $subject);
  4468. $subject = str_replace('{' . $data[_FF_DATA_NAME] . ':title}', $data[_FF_DATA_TITLE], $subject);
  4469. $subject = str_replace('{' . $data[_FF_DATA_NAME] . ':value}', $data[_FF_DATA_VALUE], $subject);
  4470. $subject = str_replace('{' . $data[_FF_DATA_NAME] . '}', $data[_FF_DATA_VALUE], $subject);
  4471. $body = str_replace('{' . $data[_FF_DATA_NAME] . ':label}', $data[_FF_DATA_TITLE], $body);
  4472. if ($this->formrow->email_custom_html) {
  4473. $body = str_replace('{' . $data[_FF_DATA_NAME] . ':value}', str_replace(array("\n","\r"),array('<br/>',''),$data[_FF_DATA_VALUE]), $body);
  4474. } else {
  4475. $body = str_replace('{' . $data[_FF_DATA_NAME] . ':value}', $data[_FF_DATA_VALUE], $body);
  4476. }
  4477. }
  4478. }
  4479. $body = preg_replace("/{([a-zA-Z0-9_\-])*:(label|value)}/", '', $body);
  4480. if ($this->formrow->email_custom_html) {
  4481. $isHtml = true;
  4482. }
  4483. }
  4484. $attachment = NULL;
  4485. if ($this->formrow->emailxml > 0 && $this->formrow->emailxml < 3) {
  4486. $attachment = $this->expxml();
  4487. if ($this->status != _FF_STATUS_OK)
  4488. return;
  4489. }
  4490. else if ($this->formrow->emailxml == 3) {
  4491. $attachment = $this->expcsv();
  4492. if ($this->status != _FF_STATUS_OK)
  4493. return;
  4494. }
  4495. else if ($this->formrow->emailxml == 4) {
  4496. $attachment = $this->exppdf();
  4497. if ($this->status != _FF_STATUS_OK)
  4498. return;
  4499. }
  4500. $sender = JRequest::getVar('mailbackSender', array());
  4501. for ($i = 0; $i < $this->rowcount; $i++) {
  4502. $row = $this->rows[$i];
  4503. $mb = JRequest::getVar('ff_nm_' . $row->name, '');
  4504. //if ($row->mailback==1) {
  4505. $mbCnt = count($mb);
  4506. for ($x = 0; $x < $mbCnt; $x++) {
  4507. if (isset($mb[$x]) && trim($mb[$x]) != '' && bf_is_email(trim($mb[$x]))) {
  4508. if (isset($sender[$row->name])) {
  4509. $from = trim($mb[$x]);
  4510. $fromname = trim($mb[$x]);
  4511. break;
  4512. }
  4513. }
  4514. }
  4515. //}
  4516. }
  4517. // dynamic mailfroms
  4518. if( bf_startsWith(trim($from), '{' ) && bf_endsWith(trim($from), '}' ) ){
  4519. $from_ = trim($from);
  4520. $from_ = trim($from_, '{}');
  4521. $froms = explode(':', $from_);
  4522. $field = $froms[0];
  4523. if (count($this->maildata)) {
  4524. foreach ($this->maildata as $DATA) {
  4525. if( strtolower($DATA[_FF_DATA_NAME]) == strtolower($field) ){
  4526. if(isset($froms[1])){
  4527. $valuepairs = explode(',', $froms[1]);
  4528. foreach($valuepairs As $valuepair){
  4529. $keyval = explode('>',trim($valuepair));
  4530. $key = trim($keyval[0]);
  4531. if(isset($keyval[1])){
  4532. $value = trim($keyval[1]);
  4533. if( strtolower($key) == strtolower($DATA[_FF_DATA_VALUE]) ){
  4534. $from = $value;
  4535. break;
  4536. }
  4537. }
  4538. }
  4539. }
  4540. else{
  4541. $from = $DATA[_FF_DATA_VALUE];
  4542. }
  4543. break;
  4544. }
  4545. }
  4546. }
  4547. }
  4548. if( bf_startsWith(trim($fromname), '{' ) && bf_endsWith(trim($fromname), '}' ) ){
  4549. $fromname_ = trim($fromname);
  4550. $fromname_ = trim($fromname_, '{}');
  4551. $froms = explode(':', $fromname_);
  4552. $field = $froms[0];
  4553. if (count($this->maildata)) {
  4554. foreach ($this->maildata as $DATA) {
  4555. if( strtolower($DATA[_FF_DATA_NAME]) == strtolower($field) ){
  4556. if(isset($froms[1])){
  4557. $valuepairs = explode(',', $froms[1]);
  4558. foreach($valuepairs As $valuepair){
  4559. $keyval = explode('>',trim($valuepair));
  4560. $key = trim($keyval[0]);
  4561. if(isset($keyval[1])){
  4562. $value = trim($keyval[1]);
  4563. if( strtolower($key) == strtolower($DATA[_FF_DATA_VALUE]) ){
  4564. $fromname = $value;
  4565. break;
  4566. }
  4567. }
  4568. }
  4569. }
  4570. else{
  4571. $fromname = $DATA[_FF_DATA_VALUE];
  4572. }
  4573. break;
  4574. }
  4575. }
  4576. }
  4577. }
  4578. $attachToAdminMail = JRequest::getVar('attachToAdminMail', array());
  4579. if (count($this->maildata)) {
  4580. foreach ($this->maildata as $data) {
  4581. if (isset($attachToAdminMail[$data[_FF_DATA_NAME]])) {
  4582. if (isset($data[_FF_DATA_FILE_SERVERPATH])) {
  4583. $testEx = explode("\n", trim($data[_FF_DATA_FILE_SERVERPATH]));
  4584. $cntTestEx = count($testEx);
  4585. if ($cntTestEx > 1) {
  4586. for ($ex = 0; $ex < $cntTestEx; $ex++) {
  4587. if (!is_array($attachment) && $attachment != '') {
  4588. $attachment = array_merge(array(trim($testEx[$ex])), array($attachment));
  4589. } else if (is_array($attachment)) {
  4590. $attachment = array_merge(array(trim($testEx[$ex])), $attachment);
  4591. } else {
  4592. $attachment = trim($testEx[$ex]);
  4593. }
  4594. }
  4595. } else {
  4596. if (!is_array($attachment) && $attachment != '') {
  4597. $attachment = array_merge(array(trim($data[_FF_DATA_FILE_SERVERPATH])), array($attachment));
  4598. } else if (is_array($attachment)) {
  4599. $attachment = array_merge(array(trim($data[_FF_DATA_FILE_SERVERPATH])), $attachment);
  4600. } else {
  4601. $attachment = trim($data[_FF_DATA_FILE_SERVERPATH]);
  4602. }
  4603. }
  4604. }
  4605. }
  4606. }
  4607. }
  4608. if (!$this->sendNotificationAfterPayment) {
  4609. for ($i = 0; $i < $recipientsSize; $i++) {
  4610. $this->sendMail($from, $fromname, $recipients[$i], $subject, $body, $attachment, $isHtml);
  4611. }
  4612. } else {
  4613. $paymentCache = JPATH_SITE . '/media/breezingforms/payment_cache/';
  4614. mt_srand();
  4615. $paymentFile = $this->form . '_' . $this->record_id . '_admin_' . md5(date('YmdHis') . mt_rand(0, mt_getrandmax())) . '.txt';
  4616. $i = 0;
  4617. while (JFile::exists($paymentCache . $paymentFile)) {
  4618. if ($i > 1000) {
  4619. break;
  4620. }
  4621. mt_srand();
  4622. $paymentFile = $this->form . '_' . $this->record_id . '_admin_' . md5(date('YmdHis') . mt_rand(0, mt_getrandmax())) . '.txt';
  4623. $i++;
  4624. }
  4625. if (!JFile::exists($paymentCache . $paymentFile)) {
  4626. JFile::write($paymentCache . $paymentFile, serialize(array(
  4627. 'from' => $from,
  4628. 'fromname' => $fromname,
  4629. 'recipients' => $recipients,
  4630. 'subject' => $subject,
  4631. 'body' => $body,
  4632. 'attachment' => $attachment,
  4633. 'isHtml' => $isHtml
  4634. )));
  4635. }
  4636. }
  4637. }
  4638. // sendEmailNotification
  4639. function sendMailbackNotification() {
  4640. global $ff_config;
  4641. $mainframe = JFactory::getApplication();
  4642. if ($this->dying)
  4643. return;
  4644. $from = $this->formrow->mb_alt_mailfrom != '' ? $this->formrow->mb_alt_mailfrom : $mainframe->getCfg('mailfrom');
  4645. $fromname = $this->formrow->mb_alt_fromname != '' ? $this->formrow->mb_alt_fromname : $mainframe->getCfg('fromname');
  4646. $customSender = false;
  4647. $accept = JRequest::getVar('mailbackConnectWith', array());
  4648. $sender = JRequest::getVar('mailbackSender', array());
  4649. $attachToUserMail = JRequest::getVar('attachToUserMail', array());
  4650. $mailbackfiles = array();
  4651. $recipients = array();
  4652. for ($i = 0; $i < $this->rowcount; $i++) {
  4653. $row = $this->rows[$i];
  4654. $mb = JRequest::getVar('ff_nm_' . $row->name, '');
  4655. if ($row->mailback == 1) {
  4656. $mbCnt = count($mb);
  4657. for ($x = 0; $x < $mbCnt; $x++) {
  4658. if (isset($mb[$x]) && trim($mb[$x]) != '' && bf_is_email(trim($mb[$x]))) {
  4659. $yesno = array('false', '');
  4660. $checked = array('');
  4661. if (isset($accept[$row->name])) {
  4662. $yesno = explode('_', $accept[$row->name]);
  4663. $checked = JRequest::getVar('ff_nm_' . $yesno[1], '');
  4664. }
  4665. //if (isset($sender[$row->name]) && !$customSender) {
  4666. // $from = trim($mb[$x]);
  4667. // $fromname = trim($mb[$x]);
  4668. // $customSender = true;
  4669. //}
  4670. if (!isset($accept[$row->name]) || ( isset($accept[$row->name]) && $yesno[0] == 'true' && $checked[0] != '' )) {
  4671. $recipients[] = trim($mb[$x]);
  4672. if (!isset($mailbackfiles[trim($mb[$x])]))
  4673. $mailbackfiles[trim($mb[$x])] = array();
  4674. if (count($this->maildata)) {
  4675. foreach ($this->maildata as $data) {
  4676. if (isset($data[_FF_DATA_FILE_SERVERPATH])) {
  4677. if (isset($attachToUserMail[$data[_FF_DATA_NAME]])) {
  4678. $testEx = explode("\n", trim($data[_FF_DATA_FILE_SERVERPATH]));
  4679. $cntTestEx = count($testEx);
  4680. if ($cntTestEx > 1) {
  4681. for ($ex = 0; $ex < $cntTestEx; $ex++) {
  4682. $mailbackfiles[trim($mb[$x])][] = trim($testEx[$ex]);
  4683. }
  4684. } else {
  4685. $mailbackfiles[trim($mb[$x])][] = trim($data[_FF_DATA_FILE_SERVERPATH]);
  4686. }
  4687. }
  4688. }
  4689. }
  4690. }
  4691. if (trim($row->mailbackfile) != '' && file_exists(trim($row->mailbackfile))) {
  4692. $mailbackfiles[trim($mb[$x])][] = trim($row->mailbackfile);
  4693. }
  4694. }
  4695. }
  4696. }
  4697. }
  4698. }
  4699. $recipientsSize = count($recipients);
  4700. $subject = BFText::_('COM_BREEZINGFORMS_PROCESS_FORMRECRECEIVED');
  4701. if ($this->formrow->mb_custom_mail_subject != '') {
  4702. $subject = $this->formrow->mb_custom_mail_subject;
  4703. }
  4704. $body = '';
  4705. $isHtml = false;
  4706. $filter = array();
  4707. require_once(JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php');
  4708. require_once(JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php');
  4709. $areas = Zend_Json::decode($this->formrow->template_areas);
  4710. if (trim($this->formrow->template_code_processed) == 'QuickMode' && is_array($areas)) {
  4711. foreach ($areas As $area) { // don't worry, size is only 1 in QM
  4712. if (isset($area['elements'])) {
  4713. foreach ($area['elements'] As $element) {
  4714. if (isset($element['hideInMailback']) && $element['hideInMailback'] && isset($element['name'])) {
  4715. $filter[] = $element['name'];
  4716. }
  4717. }
  4718. }
  4719. break; // just in case
  4720. }
  4721. }
  4722. // dynamic mailfroms
  4723. if( bf_startsWith(trim($from), '{' ) && bf_endsWith(trim($from), '}' ) ){
  4724. $from_ = trim($from);
  4725. $from_ = trim($from_, '{}');
  4726. $froms = explode(':', $from_);
  4727. $field = $froms[0];
  4728. if (count($this->maildata)) {
  4729. foreach ($this->maildata as $DATA) {
  4730. if (!in_array($DATA[_FF_DATA_NAME], $filter)) {
  4731. if( strtolower($DATA[_FF_DATA_NAME]) == strtolower($field) ){
  4732. if(isset($froms[1])){
  4733. $valuepairs = explode(',', $froms[1]);
  4734. foreach($valuepairs As $valuepair){
  4735. $keyval = explode('>',trim($valuepair));
  4736. $key = trim($keyval[0]);
  4737. if(isset($keyval[1])){
  4738. $value = trim($keyval[1]);
  4739. if( strtolower($key) == strtolower($DATA[_FF_DATA_VALUE]) ){
  4740. $from = $value;
  4741. break;
  4742. }
  4743. }
  4744. }
  4745. }
  4746. else{
  4747. $from = $DATA[_FF_DATA_VALUE];
  4748. }
  4749. break;
  4750. }
  4751. }
  4752. }
  4753. }
  4754. }
  4755. if( bf_startsWith(trim($fromname), '{' ) && bf_endsWith(trim($fromname), '}' ) ){
  4756. $fromname_ = trim($fromname);
  4757. $fromname_ = trim($fromname_, '{}');
  4758. $froms = explode(':', $fromname_);
  4759. $field = $froms[0];
  4760. if (count($this->maildata)) {
  4761. foreach ($this->maildata as $DATA) {
  4762. if (!in_array($DATA[_FF_DATA_NAME], $filter)) {
  4763. if( strtolower($DATA[_FF_DATA_NAME]) == strtolower($field) ){
  4764. if(isset($froms[1])){
  4765. $valuepairs = explode(',', $froms[1]);
  4766. foreach($valuepairs As $valuepair){
  4767. $keyval = explode('>',trim($valuepair));
  4768. $key = trim($keyval[0]);
  4769. if(isset($keyval[1])){
  4770. $value = trim($keyval[1]);
  4771. if( strtolower($key) == strtolower($DATA[_FF_DATA_VALUE]) ){
  4772. $fromname = $value;
  4773. break;
  4774. }
  4775. }
  4776. }
  4777. }
  4778. else{
  4779. $fromname = $DATA[_FF_DATA_VALUE];
  4780. }
  4781. break;
  4782. }
  4783. }
  4784. }
  4785. }
  4786. }
  4787. if ($this->formrow->mb_email_type == 0) {
  4788. $foundTpl = false;
  4789. $tplFile = '';
  4790. $formTxtFile = JPATH_SITE . '/media/breezingforms/mailtpl/' . $this->formrow->name . '_mailback.txt.php';
  4791. $formHtmlFile = JPATH_SITE . '/media/breezingforms/mailtpl/' . $this->formrow->name . '_mailback.html.php';
  4792. $defaultTxtFile = JPATH_SITE . '/media/breezingforms/mailtpl/mailbacktpl.txt.php';
  4793. $defaultHtmlFile = JPATH_SITE . '/media/breezingforms/mailtpl/mailbacktpl.html.php';
  4794. if (@file_exists($formHtmlFile) && @is_readable($formHtmlFile)) {
  4795. $tplFile = $formHtmlFile;
  4796. $foundTpl = true;
  4797. $isHtml = true;
  4798. } else if (@file_exists($formTxtFile) && @is_readable($formTxtFile)) {
  4799. $tplFile = $formTxtFile;
  4800. $foundTpl = true;
  4801. } else if (@file_exists($defaultHtmlFile) && @is_readable($defaultHtmlFile)) {
  4802. $tplFile = $defaultHtmlFile;
  4803. $foundTpl = true;
  4804. $isHtml = true;
  4805. } else if (@file_exists($defaultTxtFile) && @is_readable($defaultTxtFile)) {
  4806. $tplFile = $defaultTxtFile;
  4807. $foundTpl = true;
  4808. }
  4809. if ($foundTpl) {
  4810. $NL = nl();
  4811. $PROCESS_RECORDSAVEDID = '';
  4812. $RECORD_ID = '';
  4813. if ($this->record_id != '') {
  4814. $PROCESS_RECORDSAVEDID = BFText::_('COM_BREEZINGFORMS_PROCESS_RECORDSAVEDID');
  4815. $RECORD_ID = $this->record_id;
  4816. }
  4817. $PROCESS_FORMID = BFText::_('COM_BREEZINGFORMS_PROCESS_FORMID');
  4818. $FORM = $this->form;
  4819. $PROCESS_FORMTITLE = BFText::_('COM_BREEZINGFORMS_PROCESS_FORMTITLE');
  4820. $TITLE = $this->formrow->title;
  4821. $PROCESS_FORMNAME = BFText::_('COM_BREEZINGFORMS_PROCESS_FORMNAME');
  4822. $NAME = $this->formrow->name;
  4823. $PROCESS_SUBMITTEDAT = BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTEDAT');
  4824. $SUBMITTED = $this->submitted;
  4825. $PROCESS_SUBMITTERIP = BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERIP');
  4826. $IP = $this->ip;
  4827. $PROCESS_PROVIDER = BFText::_('COM_BREEZINGFORMS_PROCESS_PROVIDER');
  4828. $PROVIDER = $this->provider;
  4829. $PROCESS_BROWSER = BFText::_('COM_BREEZINGFORMS_PROCESS_BROWSER');
  4830. $BROWSER = $this->browser;
  4831. $PROCESS_OPSYS = BFText::_('COM_BREEZINGFORMS_PROCESS_OPSYS');
  4832. $OPSYS = $this->opsys;
  4833. $PROCESS_SUBMITTERID = BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERID');
  4834. $SUBMITTERID = 0;
  4835. $PROCESS_SUBMITTERUSERNAME = BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERUSERNAME');
  4836. $SUBMITTERUSERNAME = '-';
  4837. $PROCESS_SUBMITTERFULLNAME = BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERFULLNAME');
  4838. $SUBMITTERFULLNAME = '-';
  4839. if (JFactory::getUser()->get('id', 0) > 0) {
  4840. $SUBMITTERID = JFactory::getUser()->get('id', 0);
  4841. $SUBMITTERUSERNAME = JFactory::getUser()->get('username', '');
  4842. $SUBMITTERFULLNAME = JFactory::getUser()->get('name', '');
  4843. }
  4844. $MAILDATA = array();
  4845. if (count($this->maildata)) {
  4846. foreach ($this->maildata as $DATA) {
  4847. if (!in_array($DATA[_FF_DATA_NAME], $filter)) {
  4848. $subject = str_replace('{' . $DATA[_FF_DATA_NAME] . ':label}', $DATA[_FF_DATA_TITLE], $subject);
  4849. $subject = str_replace('{' . $DATA[_FF_DATA_NAME] . ':title}', $DATA[_FF_DATA_TITLE], $subject);
  4850. $subject = str_replace('{' . $DATA[_FF_DATA_NAME] . ':value}', $DATA[_FF_DATA_VALUE], $subject);
  4851. $subject = str_replace('{' . $DATA[_FF_DATA_NAME] . '}', $DATA[_FF_DATA_VALUE], $subject);
  4852. $MAILDATA[] = $DATA;
  4853. }
  4854. }
  4855. }
  4856. ob_start();
  4857. include($tplFile);
  4858. $body = ob_get_contents();
  4859. ob_end_clean();
  4860. } else {
  4861. // fallback if no template exists
  4862. if ($this->record_id != '')
  4863. $body .= BFText::_('COM_BREEZINGFORMS_PROCESS_RECORDSAVEDID') . " " . $this->record_id . nl() . nl();
  4864. $body .=
  4865. BFText::_('COM_BREEZINGFORMS_PROCESS_FORMID') . ": " . $this->form . nl() .
  4866. BFText::_('COM_BREEZINGFORMS_PROCESS_FORMTITLE') . ": " . $this->formrow->title . nl() .
  4867. BFText::_('COM_BREEZINGFORMS_PROCESS_FORMNAME') . ": " . $this->formrow->name . nl() . nl() .
  4868. BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTEDAT') . ": " . $this->submitted . nl() .
  4869. BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERIP') . ": " . $this->ip . nl() .
  4870. BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERID') . ": " . JFactory::getUser()->get('id', 0) . nl() .
  4871. BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERUSERNAME') . ": " . JFactory::getUser()->get('username', '') . nl() .
  4872. BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERFULLNAME') . ": " . JFactory::getUser()->get('name', '') . nl() .
  4873. BFText::_('COM_BREEZINGFORMS_PROCESS_PROVIDER') . ": " . $this->provider . nl() .
  4874. BFText::_('COM_BREEZINGFORMS_PROCESS_BROWSER') . ": " . $this->browser . nl() .
  4875. BFText::_('COM_BREEZINGFORMS_PROCESS_OPSYS') . ": " . $this->opsys . nl() . nl();
  4876. if (count($this->maildata)) {
  4877. foreach ($this->maildata as $data) {
  4878. $subject = str_replace('{' . $data[_FF_DATA_NAME] . ':label}', $data[_FF_DATA_TITLE], $subject);
  4879. $subject = str_replace('{' . $data[_FF_DATA_NAME] . ':title}', $data[_FF_DATA_TITLE], $subject);
  4880. $subject = str_replace('{' . $data[_FF_DATA_NAME] . ':value}', $data[_FF_DATA_VALUE], $subject);
  4881. $subject = str_replace('{' . $data[_FF_DATA_NAME] . '}', $data[_FF_DATA_VALUE], $subject);
  4882. if (!in_array($data[_FF_DATA_NAME], $filter)) {
  4883. $body .= $data[_FF_DATA_TITLE] . ": " . $data[_FF_DATA_VALUE] . nl();
  4884. }
  4885. }
  4886. }
  4887. }
  4888. } else {
  4889. $body = $this->formrow->mb_email_custom_template;
  4890. $RECORD_ID = '';
  4891. if ($this->record_id != '') {
  4892. $RECORD_ID = $this->record_id;
  4893. }
  4894. $FORM = $this->form;
  4895. $TITLE = $this->formrow->title;
  4896. $FORMNAME = $this->formrow->name;
  4897. $SUBMITTED = $this->submitted;
  4898. $IP = $this->ip;
  4899. $PROVIDER = $this->provider;
  4900. $BROWSER = $this->browser;
  4901. $OPSYS = $this->opsys;
  4902. $SUBMITTERID = 0;
  4903. $SUBMITTERUSERNAME = '-';
  4904. $SUBMITTERFULLNAME = '-';
  4905. if (JFactory::getUser()->get('id', 0) > 0) {
  4906. $SUBMITTERID = JFactory::getUser()->get('id', 0);
  4907. $SUBMITTERUSERNAME = JFactory::getUser()->get('username', '');
  4908. $SUBMITTERFULLNAME = JFactory::getUser()->get('name', '');
  4909. }
  4910. $body = str_replace('{BF_RECORD_ID:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_RECORDSAVEDID'), $body);
  4911. $body = str_replace('{BF_RECORD_ID:value}', $RECORD_ID, $body);
  4912. $body = str_replace('{BF_FORM_ID:label}', BFText::_('Form ID'), $body);
  4913. $body = str_replace('{BF_FORM_ID:value}', $this->form_id, $body);
  4914. $body = str_replace('{BF_FORM:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_FORMID'), $body);
  4915. $body = str_replace('{BF_FORM:value}', $FORM, $body);
  4916. $body = str_replace('{BF_TITLE:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_FORMTITLE'), $body);
  4917. $body = str_replace('{BF_TITLE:value}', $TITLE, $body);
  4918. $body = str_replace('{BF_FORMNAME:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_FORMNAME'), $body);
  4919. $body = str_replace('{BF_FORMNAME:value}', $FORMNAME, $body);
  4920. $body = str_replace('{BF_SUBMITTED:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTEDAT'), $body);
  4921. $body = str_replace('{BF_SUBMITTED:value}', $SUBMITTED, $body);
  4922. $body = str_replace('{BF_IP:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERIP'), $body);
  4923. $body = str_replace('{BF_IP:value}', $IP, $body);
  4924. $body = str_replace('{BF_PROVIDER:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_PROVIDER'), $body);
  4925. $body = str_replace('{BF_PROVIDER:value}', $PROVIDER, $body);
  4926. $body = str_replace('{BF_BROWSER:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_BROWSER'), $body);
  4927. $body = str_replace('{BF_BROWSER:value}', $BROWSER, $body);
  4928. $body = str_replace('{BF_OPSYS:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_OPSYS'), $body);
  4929. $body = str_replace('{BF_OPSYS:value}', $OPSYS, $body);
  4930. $body = str_replace('{BF_SUBMITTERID:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERID'), $body);
  4931. $body = str_replace('{BF_SUBMITTERID:value}', $SUBMITTERID, $body);
  4932. $body = str_replace('{BF_SUBMITTERUSERNAME:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERUSERNAME'), $body);
  4933. $body = str_replace('{BF_SUBMITTERUSERNAME:value}', $SUBMITTERUSERNAME, $body);
  4934. $body = str_replace('{BF_SUBMITTERFULLNAME:label}', BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITTERFULLNAME'), $body);
  4935. $body = str_replace('{BF_SUBMITTERFULLNAME:value}', $SUBMITTERFULLNAME, $body);
  4936. if (count($this->maildata)) {
  4937. foreach ($this->maildata as $data) {
  4938. $subject = str_replace('{' . $data[_FF_DATA_NAME] . ':label}', $data[_FF_DATA_TITLE], $subject);
  4939. $subject = str_replace('{' . $data[_FF_DATA_NAME] . ':title}', $data[_FF_DATA_TITLE], $subject);
  4940. $subject = str_replace('{' . $data[_FF_DATA_NAME] . ':value}', $data[_FF_DATA_VALUE], $subject);
  4941. $subject = str_replace('{' . $data[_FF_DATA_NAME] . '}', $data[_FF_DATA_VALUE], $subject);
  4942. if (!in_array($data[_FF_DATA_NAME], $filter)) {
  4943. $body = str_replace('{' . $data[_FF_DATA_NAME] . ':label}', $data[_FF_DATA_TITLE], $body);
  4944. if ($this->formrow->mb_email_custom_html) {
  4945. $body = str_replace('{' . $data[_FF_DATA_NAME] . ':value}', str_replace(array("\n","\r"),array('<br/>',''),$data[_FF_DATA_VALUE]), $body);
  4946. } else {
  4947. $body = str_replace('{' . $data[_FF_DATA_NAME] . ':value}', $data[_FF_DATA_VALUE], $body);
  4948. }
  4949. } else {
  4950. $body = str_replace('{' . $data[_FF_DATA_NAME] . ':label}', '', $body);
  4951. $body = str_replace('{' . $data[_FF_DATA_NAME] . ':value}', '', $body);
  4952. }
  4953. }
  4954. }
  4955. $body = preg_replace("/{([a-zA-Z0-9_\-])*:(label|value)}/", '', $body);
  4956. if ($this->formrow->mb_email_custom_html) {
  4957. $isHtml = true;
  4958. }
  4959. }
  4960. $attachment = NULL;
  4961. if ($this->formrow->mb_emailxml > 0 && $this->formrow->mb_emailxml < 3) {
  4962. $attachment = $this->expxml($filter, true);
  4963. if ($this->status != _FF_STATUS_OK)
  4964. return;
  4965. }
  4966. else if ($this->formrow->mb_emailxml == 3) {
  4967. $attachment = $this->expcsv($filter, true);
  4968. if ($this->status != _FF_STATUS_OK)
  4969. return;
  4970. }
  4971. else if ($this->formrow->mb_emailxml == 4) {
  4972. $attachment = $this->exppdf($filter, true);
  4973. if ($this->status != _FF_STATUS_OK)
  4974. return;
  4975. }
  4976. if (!$this->sendNotificationAfterPayment) {
  4977. for ($i = 0; $i < $recipientsSize; $i++) {
  4978. if (isset($mailbackfiles[$recipients[$i]])) {
  4979. if (!is_array($attachment) && $attachment != '') {
  4980. $attachment = array_merge($mailbackfiles[$recipients[$i]], array($attachment));
  4981. } else if (is_array($attachment)) {
  4982. $attachment = array_merge($mailbackfiles[$recipients[$i]], $attachment);
  4983. } else {
  4984. $attachment = $mailbackfiles[$recipients[$i]];
  4985. }
  4986. }
  4987. $this->sendMail($from, $fromname, $recipients[$i], $subject, $body, $attachment, $isHtml);
  4988. }
  4989. } else {
  4990. $paymentCache = JPATH_SITE . '/media/breezingforms/payment_cache/';
  4991. mt_srand();
  4992. $paymentFile = $this->form . '_' . $this->record_id . '_mailback_' . md5(date('YmdHis') . mt_rand(0, mt_getrandmax())) . '.txt';
  4993. $i = 0;
  4994. while (JFile::exists($paymentCache . $paymentFile)) {
  4995. if ($i > 1000) {
  4996. break;
  4997. }
  4998. mt_srand();
  4999. $paymentFile = $this->form . '_' . $this->record_id . '_mailback_' . md5(date('YmdHis') . mt_rand(0, mt_getrandmax())) . '.txt';
  5000. $i++;
  5001. }
  5002. if (!JFile::exists($paymentCache . $paymentFile)) {
  5003. for ($i = 0; $i < $recipientsSize; $i++) {
  5004. if (isset($mailbackfiles[$recipients[$i]])) {
  5005. if (!is_array($attachment) && $attachment != '') {
  5006. $attachment = array_merge($mailbackfiles[$recipients[$i]], array($attachment));
  5007. } else if (is_array($attachment)) {
  5008. $attachment = array_merge($mailbackfiles[$recipients[$i]], $attachment);
  5009. } else {
  5010. $attachment = $mailbackfiles[$recipients[$i]];
  5011. }
  5012. }
  5013. }
  5014. JFile::write($paymentCache . $paymentFile, serialize(array(
  5015. 'from' => $from,
  5016. 'fromname' => $fromname,
  5017. 'recipients' => $recipients,
  5018. 'subject' => $subject,
  5019. 'body' => $body,
  5020. 'attachment' => $attachment,
  5021. 'isHtml' => $isHtml
  5022. )));
  5023. }
  5024. }
  5025. $this->mailbackRecipients = $recipients;
  5026. }
  5027. function sendMailChimpNotification() {
  5028. $mainframe = JFactory::getApplication();
  5029. // listSubscribe(string apikey, string id, string email_address, array merge_vars, string email_type, boolean double_optin, boolean update_existing, boolean replace_interests, boolean send_welcome)
  5030. if (!class_exists('MCAPI')) {
  5031. require_once(JPATH_SITE . '/administrator/components/com_breezingforms/libraries/mailchimp/MCAPI.class.php');
  5032. }
  5033. if (trim($this->formrow->mailchimp_email_field) != '' && trim($this->formrow->mailchimp_api_key) != '' && trim($this->formrow->mailchimp_list_id) != '' && count($this->maildata)) {
  5034. $email = '';
  5035. $htmlTextMobile = 'text';
  5036. $checked = true;
  5037. $unsubsribe = false;
  5038. $mergeVars = array();
  5039. $htmlTextMobileField = trim($this->formrow->mailchimp_text_html_mobile_field);
  5040. $checkboxField = trim($this->formrow->mailchimp_checkbox_field);
  5041. $unsubscribeField = trim($this->formrow->mailchimp_unsubscribe_field);
  5042. $emailField = trim($this->formrow->mailchimp_email_field);
  5043. $mergeVarFields = explode(',', str_replace(' ', '', $this->formrow->mailchimp_mergevars));
  5044. $api = new MCAPI(trim($this->formrow->mailchimp_api_key));
  5045. $list_id = trim($this->formrow->mailchimp_list_id);
  5046. if ($checkboxField != '') {
  5047. $box = JRequest::getVar('ff_nm_' . $checkboxField, array(''));
  5048. if (isset($box[0]) && $box[0] != '') {
  5049. $checked = true;
  5050. } else {
  5051. $checked = false;
  5052. }
  5053. }
  5054. if ($unsubscribeField != '') {
  5055. $box = JRequest::getVar('ff_nm_' . $unsubscribeField, array(''));
  5056. if (isset($box[0]) && $box[0] != '') {
  5057. $unsubsribe = true;
  5058. }
  5059. }
  5060. if ($htmlTextMobileField != '') {
  5061. $selection = JRequest::getVar('ff_nm_' . $htmlTextMobileField, array(''));
  5062. if (isset($selection[0]) && $selection[0] != '') {
  5063. $htmlTextMobile = $selection[0];
  5064. }
  5065. } else {
  5066. $htmlTextMobile = $this->formrow->mailchimp_default_type;
  5067. }
  5068. foreach ($this->maildata as $data) {
  5069. switch ($data[_FF_DATA_NAME]) {
  5070. case $emailField:
  5071. $email = bf_is_email(trim($data[_FF_DATA_VALUE])) ? trim($data[_FF_DATA_VALUE]) : '';
  5072. break;
  5073. default:
  5074. if (in_array($data[_FF_DATA_NAME], $mergeVarFields)) {
  5075. $mergeVars[$data[_FF_DATA_NAME]] = $data[_FF_DATA_VALUE];
  5076. }
  5077. }
  5078. }
  5079. if ($email != '' && $checked) {
  5080. if ($api->listSubscribe($list_id, $email, count($mergeVars) == 0 ? '' : $mergeVars, $htmlTextMobile, $this->formrow->mailchimp_double_optin, $this->formrow->mailchimp_update_existing, $this->formrow->mailchimp_replace_interests, $this->formrow->mailchimp_send_welcome) !== true) {
  5081. if ($this->formrow->mailchimp_send_errors) {
  5082. $from = $this->formrow->alt_mailfrom != '' ? $this->formrow->alt_mailfrom : $mainframe->getCfg('mailfrom');
  5083. $fromname = $this->formrow->alt_fromname != '' ? $this->formrow->alt_fromname : $mainframe->getCfg('fromname');
  5084. $this->sendMail($from, $fromname, $from, 'MailChimp API Error', 'Could not send data to MailChimp for email: ' . $email . "\n\nReason (code " . $api->errorCode . "): " . $api->errorMessage);
  5085. }
  5086. }
  5087. }
  5088. if ($email != '' && $unsubsribe) {
  5089. if ($api->listUnsubscribe($list_id, $email, $this->formrow->mailchimp_delete_member, $this->formrow->mailchimp_send_goodbye, $this->formrow->mailchimp_send_notify) !== true) {
  5090. if ($this->formrow->mailchimp_send_errors) {
  5091. $from = $this->formrow->alt_mailfrom != '' ? $this->formrow->alt_mailfrom : $mainframe->getCfg('mailfrom');
  5092. $fromname = $this->formrow->alt_fromname != '' ? $this->formrow->alt_fromname : $mainframe->getCfg('fromname');
  5093. $this->sendMail($from, $fromname, $from, 'MailChimp API Error', 'Could not send unsubscribe data to MailChimp for email: ' . $email . "\n\nReason (code " . $api->errorCode . "): " . $api->errorMessage);
  5094. }
  5095. }
  5096. }
  5097. }
  5098. }
  5099. function saveUpload($filename, $userfile_name, $destpath, $timestamp, $useUrl = false, $useUrlDownloadDirectory = '') {
  5100. global $ff_config, $mosConfig_fileperms;
  5101. if ($this->dying)
  5102. return '';
  5103. $baseDir = JPath::clean(str_replace($this->findtags, $this->replacetags, $destpath));
  5104. if (!file_exists($baseDir)) {
  5105. $this->status = _FF_STATUS_UPLOAD_FAILED;
  5106. $this->message = BFText::_('COM_BREEZINGFORMS_PROCESS_DIRNOTEXISTS');
  5107. return '';
  5108. } // if
  5109. if ($timestamp)
  5110. $userfile_name = date('YmdHis') . '_' . $userfile_name;
  5111. $path = $baseDir . DS . $userfile_name;
  5112. //if ($timestamp) $path .= '.'.date('YmdHis');
  5113. if (JFile::exists($path)) {
  5114. $rnd = md5(mt_rand(0, mt_getrandmax()));
  5115. $path = $baseDir . DS . $rnd . '_' . $userfile_name;
  5116. //if ($timestamp) $path .= '.'.date('YmdHis');
  5117. if (JFile::exists($path)) {
  5118. $this->status = _FF_STATUS_UPLOAD_FAILED;
  5119. $this->message = BFText::_('COM_BREEZINGFORMS_PROCESS_FILEEXISTS');
  5120. return '';
  5121. }
  5122. } // if
  5123. if (!move_uploaded_file($filename, $path)) {
  5124. $this->status = _FF_STATUS_UPLOAD_FAILED;
  5125. $this->message = BFText::_('COM_BREEZINGFORMS_PROCESS_FILEMOVEFAILED');
  5126. return '';
  5127. } // if
  5128. $filemode = NULL;
  5129. if (isset($mosConfig_fileperms)) {
  5130. if ($mosConfig_fileperms != '')
  5131. $filemode = octdec($mosConfig_fileperms);
  5132. } else
  5133. $filemode = 0644;
  5134. if (isset($filemode)) {
  5135. if (!@chmod($path, $filemode)) {
  5136. $this->status = _FF_STATUS_UPLOAD_FAILED;
  5137. $this->message = BFText::_('COM_BREEZINGFORMS_PROCESS_FILECHMODFAILED');
  5138. return '';
  5139. } // if
  5140. } // if
  5141. $serverPath = $path;
  5142. if ($useUrl && $useUrlDownloadDirectory != '') {
  5143. $path = $useUrlDownloadDirectory . '/' . basename($path);
  5144. }
  5145. return array('default' => $path, 'server' => $serverPath);
  5146. }
  5147. public function findQuickModeElement( array $dataObject, $needle){
  5148. if($dataObject['properties']['type'] == 'element'
  5149. && isset($dataObject['properties']['bfName'])
  5150. && $dataObject['properties']['bfName'] == $needle){
  5151. return $dataObject;
  5152. }
  5153. if(isset($dataObject['children']) && count($dataObject['children']) != 0){
  5154. $childrenAmount = count($dataObject['children']);
  5155. for($i = 0; $i < $childrenAmount; $i++){
  5156. $child = $this->findQuickModeElement( $dataObject['children'][$i], $needle );
  5157. if($child !== null){
  5158. return $child;
  5159. }
  5160. }
  5161. }
  5162. return null;
  5163. }
  5164. // saveUpload
  5165. function collectSubmitdata($cbResult = null) {
  5166. if ($this->dying || $this->submitdata)
  5167. return;
  5168. $this->submitdata = array();
  5169. $this->savedata = array();
  5170. $this->maildata = array();
  5171. $this->sfdata = array();
  5172. $this->xmldata = array();
  5173. $names = array();
  5174. if (count($this->rows))
  5175. foreach ($this->rows as $row) {
  5176. if (!in_array($row->name, $names)) {
  5177. switch ($row->type) {
  5178. case 'File Upload':
  5179. // CONTENTBUILDER
  5180. if ($cbResult !== null && isset($cbResult['data']) && $cbResult['data'] != null) {
  5181. $rowdata1 = JPath::clean(str_replace($this->findtags, $this->replacetags, $row->data1));
  5182. if ($cbResult['data']['protect_upload_directory']) {
  5183. if (JFolder::exists($rowdata1) && !JFile::exists($rowdata1 . '/' . '.htaccess'))
  5184. JFile::write($rowdata1 . '/' . '.htaccess', $def = 'deny from all');
  5185. } else {
  5186. if (JFolder::exists($rowdata1) && JFile::exists($rowdata1 . '/' . '.htaccess'))
  5187. JFile::delete($rowdata1 . '/' . '.htaccess');
  5188. }
  5189. }
  5190. require_once(JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php');
  5191. require_once(JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php');
  5192. $areas = Zend_Json::decode($this->formrow->template_areas);
  5193. $useUrl = false;
  5194. $useUrlDownloadDirectory = '';
  5195. if (trim($this->formrow->template_code_processed) == 'QuickMode' && is_array($areas)) {
  5196. foreach ($areas As $area) { // don't worry, size is only 1 in QM
  5197. if (isset($area['elements'])) {
  5198. foreach ($area['elements'] As $element) {
  5199. if (isset($element['options']) && isset($element['options']['useUrl']) && isset($element['name']) && trim($element['name']) == trim($row->name) && isset($element['internalType']) && $element['internalType'] == 'bfFile') {
  5200. $useUrl = $element['options']['useUrl'];
  5201. $useUrlDownloadDirectory = $element['options']['useUrlDownloadDirectory'];
  5202. break;
  5203. }
  5204. }
  5205. }
  5206. break; // just in case
  5207. }
  5208. }
  5209. $uploadfiles = isset($_FILES['ff_nm_' . $row->name]) ? $_FILES['ff_nm_' . $row->name] : null;
  5210. if ($this->formrow->template_code != '' && isset($_FILES['ff_nm_' . $row->name]) && $_FILES['ff_nm_' . $row->name]['tmp_name'][0] != '' && trim($row->data2) != '') {
  5211. $fileName = $_FILES['ff_nm_' . $row->name]['name'][0];
  5212. $ext = strtolower(substr($fileName, strrpos($fileName, '.') + 1));
  5213. $allowedExtensions = explode(',', strtolower(str_replace(' ', '', trim($row->data2))));
  5214. if (!in_array($ext, $allowedExtensions)) {
  5215. $this->status = _FF_STATUS_FILE_EXTENSION_NOT_ALLOWED;
  5216. return;
  5217. }
  5218. }
  5219. $paths = array();
  5220. $serverPaths = array();
  5221. // CONTENTBUILDER
  5222. $is_relative = array();
  5223. if ($uploadfiles) {
  5224. $name = $uploadfiles['name'];
  5225. $tmp_name = $uploadfiles['tmp_name'];
  5226. $cnt = count($name);
  5227. for ($i = 0; $i < $cnt; $i++) {
  5228. $path = '';
  5229. if ($name[$i] != '') {
  5230. $allowed = "/[^a-z0-9\\.\\-\\_]/i";
  5231. $rowpath1 = $row->data1;
  5232. //if ($cbResult !== null && isset($cbResult['data']) && $cbResult['data'] != null) {
  5233. $rowpath1 = $this->cbCreatePathByTokens($rowpath1, $this->rows);
  5234. //}
  5235. $pathInfo = $this->saveUpload($tmp_name[$i], preg_replace($allowed, "_", $name[$i]), $rowpath1, $row->flag1, $useUrl, $useUrlDownloadDirectory);
  5236. $path = $pathInfo['default'];
  5237. $serverPath = $pathInfo['server'];
  5238. if ($this->status != _FF_STATUS_OK)
  5239. return;
  5240. $paths[] = $path;
  5241. $serverPaths[] = $serverPath;
  5242. $this->submitdata[] = array($row->id, $row->name, $row->title, $row->type, $path);
  5243. // CONTENTBUILDER
  5244. if(strpos(strtolower($row->data1), '{cbsite}') === 0){
  5245. $is_relative[$serverPath] = true;
  5246. }
  5247. } // if
  5248. } // for
  5249. } // if
  5250. if (JRequest::getVar('bfFlashUploadTicket', '') != '') {
  5251. $tickets = JFactory::getSession()->get('bfFlashUploadTickets', array());
  5252. mt_srand();
  5253. if (isset($tickets[JRequest::getVar('bfFlashUploadTicket', mt_rand(0, mt_getrandmax()))])) {
  5254. $sourcePath = JPATH_SITE . '/components/com_breezingforms/uploads/';
  5255. if (@file_exists($sourcePath) && @is_readable($sourcePath) && @is_dir($sourcePath) && $handle = @opendir($sourcePath)) {
  5256. while (false !== ($file = @readdir($handle))) {
  5257. if ($file != "." && $file != "..") {
  5258. $parts = explode('_', $file);
  5259. if (count($parts) >= 5) {
  5260. if ($parts[count($parts) - 1] == 'flashtmp') {
  5261. if ($parts[count($parts) - 3] == JRequest::getVar('bfFlashUploadTicket', '')) {
  5262. if ($parts[count($parts) - 4] == $row->name) {
  5263. unset($parts[count($parts) - 1]);
  5264. unset($parts[count($parts) - 1]);
  5265. unset($parts[count($parts) - 1]);
  5266. unset($parts[count($parts) - 1]);
  5267. $userfile_name = implode('_', $parts);
  5268. $rowpath1 = $row->data1;
  5269. //if ($cbResult !== null && isset($cbResult['data']) && $cbResult['data'] != null) {
  5270. $rowpath1 = $this->cbCreatePathByTokens($rowpath1, $this->rows);
  5271. //}
  5272. $baseDir = JPath::clean(str_replace($this->findtags, $this->replacetags, $rowpath1));
  5273. if ($row->flag1)
  5274. $userfile_name = date('YmdHis') . '_' . $userfile_name;
  5275. $path = $baseDir . DS . $userfile_name;
  5276. //if ($row->flag1) $path .= '.'.date('YmdHis');
  5277. if (file_exists($path)) {
  5278. $rnd = md5(mt_rand(0, mt_getrandmax()));
  5279. $path = $baseDir . DS . $rnd . '_' . $userfile_name;
  5280. //if ($row->flag1) $path .= '.'.date('YmdHis');
  5281. if (file_exists($path)) {
  5282. $this->status = _FF_STATUS_UPLOAD_FAILED;
  5283. $this->message = BFText::_('COM_BREEZINGFORMS_PROCESS_FILEEXISTS');
  5284. return '';
  5285. }
  5286. } // if
  5287. $ext = strtolower(substr($userfile_name, strrpos($userfile_name, '.') + 1));
  5288. $allowedExtensions = explode(',', strtolower(str_replace(' ', '', trim($row->data2))));
  5289. if (!in_array($ext, $allowedExtensions)) {
  5290. $this->status = _FF_STATUS_FILE_EXTENSION_NOT_ALLOWED;
  5291. }
  5292. if ($this->status != _FF_STATUS_OK)
  5293. return;
  5294. if (@is_readable($sourcePath . $file) && @file_exists($baseDir) && @is_dir($baseDir)) {
  5295. @JFile::copy($sourcePath . $file, $path);
  5296. } else {
  5297. $this->status = _FF_STATUS_UPLOAD_FAILED;
  5298. $this->message = BFText::_('COM_BREEZINGFORMS_PROCESS_FILEMOVEFAILED');
  5299. return;
  5300. }
  5301. @JFile::delete($sourcePath . $file);
  5302. $serverPath = $path;
  5303. if ($useUrl && $useUrlDownloadDirectory != '') {
  5304. $path = $useUrlDownloadDirectory . '/' . basename($path);
  5305. }
  5306. $paths[] = $path;
  5307. $serverPaths[] = $serverPath;
  5308. $this->submitdata[] = array($row->id, $row->name, $row->title, $row->type, $path);
  5309. // CONTENTBUILDER
  5310. if(strpos(strtolower($row->data1), '{cbsite}') === 0){
  5311. $is_relative[$serverPath] = true;
  5312. }
  5313. }
  5314. }
  5315. }
  5316. }
  5317. }
  5318. }
  5319. @closedir($handle);
  5320. }
  5321. }
  5322. }
  5323. if (!count($paths))
  5324. $paths = array();
  5325. if ($row->logging == 1) {
  5326. // db and attachment
  5327. foreach($serverPaths As $serverPath){
  5328. // CONTENTBUILDER: to keep the relative path with prefix
  5329. $savedata_path = $serverPath;
  5330. foreach($this->findtags As $tag){
  5331. if(strtolower($tag) == '{cbsite}' && isset($is_relative[$serverPath]) && $is_relative[$serverPath]){
  5332. $savedata_path = JPath::clean(str_replace(array(JPATH_SITE, JPATH_SITE), array('{cbsite}','{CBSite}'), $savedata_path));
  5333. }
  5334. }
  5335. if (($this->formrow->dblog == 1 && $savedata_path != '') ||
  5336. $this->formrow->dblog == 2 || ( $cbResult != null && $cbResult['record'] != null) )
  5337. $this->savedata[] = array($row->id, $row->name, $row->title, $row->type, $savedata_path);
  5338. }
  5339. foreach ($paths as $path) {
  5340. if (( ($this->formrow->emaillog == 1 && $this->trim($path)) ||
  5341. $this->formrow->emaillog == 2 ) && ($this->formrow->emailxml == 1 ||
  5342. $this->formrow->emailxml == 2 || $this->formrow->emailxml == 3 || $this->formrow->emailxml == 4))
  5343. $this->xmldata[] = array($row->id, $row->name, $row->title, $row->type, $path);
  5344. if (( ($this->formrow->emaillog == 1 && $this->trim($path)) ||
  5345. $this->formrow->mb_emaillog == 2 ) && ($this->formrow->mb_emailxml == 1 ||
  5346. $this->formrow->mb_emailxml == 2 || $this->formrow->mb_emailxml == 3 || $this->formrow->mb_emailxml == 4))
  5347. $this->mb_xmldata[] = array($row->id, $row->name, $row->title, $row->type, $path);
  5348. } // foreach
  5349. if (!count($paths)) {
  5350. if (($this->formrow->dblog == 1) ||
  5351. $this->formrow->dblog == 2)
  5352. $this->savedata[] = array($row->id, $row->name, $row->title, $row->type, '');
  5353. if ($this->formrow->emaillog == 2 && ($this->formrow->emailxml == 1 ||
  5354. $this->formrow->emailxml == 2 || $this->formrow->emailxml == 3 || $this->formrow->emailxml == 4))
  5355. $this->xmldata[] = array($row->id, $row->name, $row->title, $row->type, '');
  5356. if ($this->formrow->mb_emaillog == 2 && ($this->formrow->mb_emailxml == 1 ||
  5357. $this->formrow->mb_emailxml == 2 || $this->formrow->mb_emailxml == 3 || $this->formrow->mb_emailxml == 4))
  5358. $this->mb_xmldata[] = array($row->id, $row->name, $row->title, $row->type, '');
  5359. }
  5360. // mail
  5361. $paths = implode(nl(), $paths);
  5362. $serverPaths = implode(nl(), $serverPaths);
  5363. if($this->trim($paths)){
  5364. $this->sfadata[] = array($row->id, $row->name, $row->title, $row->type, $paths, $serverPaths);
  5365. }
  5366. if (($this->formrow->emaillog == 1 && $this->trim($paths)) ||
  5367. $this->formrow->emaillog == 2)
  5368. $this->maildata[] = array($row->id, $row->name, $row->title, $row->type, $paths, $serverPaths);
  5369. } // if
  5370. break;
  5371. case 'Text':
  5372. case 'Textarea':
  5373. case 'Checkbox':
  5374. case 'Radio Button':
  5375. case 'Select List':
  5376. case 'Query List':
  5377. case 'Radio Group':
  5378. case 'Checkbox Group':
  5379. case 'Calendar':
  5380. case 'Hidden Input':
  5381. if ($row->logging == 1) {
  5382. $values = @JRequest::getVar("ff_nm_" . $row->name, array(''));
  5383. if( $row->type == 'Textarea' ){
  5384. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php');
  5385. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php');
  5386. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/crosstec/functions/helpers.php');
  5387. if(trim($this->formrow->template_code_processed) == 'QuickMode'){
  5388. $dataObject = Zend_Json::decode( base64_decode($this->formrow->template_code) );
  5389. $qmelement = $this->findQuickModeElement($dataObject, $row->name);
  5390. if($qmelement !== null && isset($qmelement['properties']['is_html']) && $qmelement['properties']['is_html']){
  5391. $values = JRequest::getVar( "ff_nm_" . $row->name, array(''), 'POST', 'ARRAY', JREQUEST_ALLOWRAW );
  5392. }
  5393. }
  5394. }
  5395. foreach ($values as $value) {
  5396. // for db
  5397. if (($this->formrow->dblog == 1 && $value != '') ||
  5398. $this->formrow->dblog == 2 || ( $cbResult != null && $cbResult['record'] != null))
  5399. $this->savedata[] = array($row->id, $row->name, $row->title, $row->type, $value);
  5400. // CONTENTBUILDER
  5401. $loadData = true;
  5402. switch ($row->type) {
  5403. case 'Checkbox':
  5404. case 'Checkbox Group':
  5405. case 'Radio Button':
  5406. case 'Radio Group':
  5407. case 'Select List':
  5408. if ($value == 'cbGroupMark') {
  5409. $loadData = false;
  5410. }
  5411. break;
  5412. }
  5413. if ($loadData) {
  5414. // submitdata
  5415. if ($this->trim($value))
  5416. $this->submitdata[] = array($row->id, $row->name, $row->title, $row->type, $value);
  5417. if (($this->formrow->emaillog == 1 && $this->trim($value)) ||
  5418. $this->formrow->emaillog == 2 && ( ($this->formrow->emailxml == 1 ||
  5419. $this->formrow->emailxml == 2 || $this->formrow->emailxml == 3 || $this->formrow->emailxml == 4)))
  5420. $this->xmldata[] = array($row->id, $row->name, $row->title, $row->type, $value);
  5421. if (($this->formrow->mb_emaillog == 1 && $this->trim($value)) ||
  5422. $this->formrow->mb_emaillog == 2 && ( ($this->formrow->mb_emailxml == 1 ||
  5423. $this->formrow->mb_emailxml == 2 || $this->formrow->mb_emailxml == 3 || $this->formrow->mb_emailxml == 4)))
  5424. $this->mb_xmldata[] = array($row->id, $row->name, $row->title, $row->type, $value);
  5425. }
  5426. } // foreach
  5427. // for mail
  5428. $sfvalues = $values;
  5429. if ($row->type == 'Textarea'){
  5430. $values = implode(nl(), $values);
  5431. $sfvalues = implode(nl(), $sfvalues);
  5432. } else {
  5433. // CONTENTBUILDER
  5434. $useNewValues = false;
  5435. $newValues = array();
  5436. $sfnewValues = array();
  5437. foreach ($values as $value) {
  5438. switch ($row->type) {
  5439. case 'Checkbox':
  5440. case 'Checkbox Group':
  5441. case 'Radio Button':
  5442. case 'Radio Group':
  5443. case 'Select List':
  5444. if ($value != 'cbGroupMark') {
  5445. $newValues[] = $value;
  5446. $sfnewValues[] = $value;
  5447. } else {
  5448. $useNewValues = true;
  5449. }
  5450. break;
  5451. }
  5452. }
  5453. if ($useNewValues) {
  5454. $values = implode(', ', $newValues);
  5455. $sfvalues = implode(';', $sfnewValues);
  5456. } else {
  5457. $values = implode(', ', $values);
  5458. $sfvalues = implode(';', $sfvalues);
  5459. }
  5460. }
  5461. if($this->trim($sfvalues)){
  5462. $this->sfdata[] = array($row->id, $row->name, $row->title, $row->type, $sfvalues);
  5463. }
  5464. if (($this->formrow->emaillog == 1 && $this->trim($values)) ||
  5465. $this->formrow->emaillog == 2)
  5466. $this->maildata[] = array($row->id, $row->name, $row->title, $row->type, $values);
  5467. } // if logging
  5468. break;
  5469. default:;
  5470. } // switch
  5471. $names[] = $row->name;
  5472. } // if
  5473. } // for
  5474. }
  5475. // collectSubmitdata
  5476. function submit() {
  5477. global $database, $ff_config, $ff_comsite, $ff_mossite, $ff_otherparams;
  5478. // CONTENTBUILDER BEGIN
  5479. $cbRecordId = 0;
  5480. $cbEmailNotifications = false;
  5481. $cbEmailUpdateNotifications = false;
  5482. $cbResult = $this->cbCheckPermissions();
  5483. if ($cbResult['data'] !== null && $cbResult['data']['email_notifications']) {
  5484. if (!JRequest::getInt('cb_record_id', 0)) {
  5485. $cbEmailNotifications = true;
  5486. } else {
  5487. $cbEmailNotifications = false;
  5488. }
  5489. }
  5490. if ($cbResult['data'] !== null && $cbResult['data']['email_update_notifications']) {
  5491. if (JRequest::getInt('cb_record_id', 0)) {
  5492. $cbEmailUpdateNotifications = true;
  5493. } else {
  5494. $cbEmailUpdateNotifications = false;
  5495. }
  5496. }
  5497. if ($cbResult['data'] === null) {
  5498. $cbEmailNotifications = true;
  5499. $cbEmailUpdateNotifications = true;
  5500. }
  5501. // CONTENTBUILDER END
  5502. $database = JFactory::getDBO();
  5503. if (!$this->okrun)
  5504. return;
  5505. // currently only available in classic mode
  5506. if (trim($this->formrow->template_code_processed) == '') {
  5507. set_error_handler('_ff_errorHandler');
  5508. }
  5509. ob_start();
  5510. $this->record_id = '';
  5511. $this->status = _FF_STATUS_OK;
  5512. $this->message = '';
  5513. $this->sendNotificationAfterPayment = false;
  5514. // handle Begin Submit piece
  5515. $halt = false;
  5516. $this->collectSubmitdata($cbResult);
  5517. if (!$halt) {
  5518. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php');
  5519. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php');
  5520. require_once(JPATH_SITE.'/administrator/components/com_breezingforms/libraries/crosstec/functions/helpers.php');
  5521. $dataObject = Zend_Json::decode( base64_decode($this->formrow->template_code) );
  5522. $rootMdata = $dataObject['properties'];
  5523. if(JRequest::getVar('ff_applic','') != 'mod_facileforms' && JRequest::getInt('ff_frame', 0) != 1 && bf_is_mobile())
  5524. {
  5525. $is_device = true;
  5526. $this->isMobile = isset($rootMdata['mobileEnabled']) && isset($rootMdata['forceMobile']) && $rootMdata['mobileEnabled'] && $rootMdata['forceMobile'] ? true : ( isset($rootMdata['mobileEnabled']) && isset($rootMdata['forceMobile']) && $rootMdata['mobileEnabled'] && JFactory::getSession()->get('com_breezingforms.mobile', false) ? true : false );
  5527. }else
  5528. $this->isMobile = false;
  5529. // transforming recaptcha into captcha due to compatibility on mobiles
  5530. if($this->isMobile && trim($this->formrow->template_code_processed) == 'QuickMode'){
  5531. for ($i = 0; $i < $this->rowcount; $i++) {
  5532. $row = $this->rows[$i];
  5533. if( $row->type == "ReCaptcha" ){
  5534. $this->rows[$i]->type = 'Captcha';
  5535. break;
  5536. }
  5537. }
  5538. }
  5539. for ($i = 0; $i < $this->rowcount; $i++) {
  5540. $row = $this->rows[$i];
  5541. if ($row->type == "Captcha") {
  5542. require_once(JPATH_SITE . '/components/com_breezingforms/images/captcha/securimage.php');
  5543. $securimage = new Securimage();
  5544. if (!$securimage->check(JRequest::getVar('bfCaptchaEntry', ''))) {
  5545. $halt = true;
  5546. $this->status = _FF_STATUS_CAPTCHA_FAILED;
  5547. exit;
  5548. }
  5549. break;
  5550. } else
  5551. if ($row->type == "ReCaptcha") {
  5552. if (!JFactory::getSession()->get('bfrecapsuccess', false)) {
  5553. $halt = true;
  5554. $this->status = _FF_STATUS_CAPTCHA_FAILED;
  5555. exit;
  5556. }
  5557. JFactory::getSession()->set('bfrecapsuccess', false);
  5558. break;
  5559. }
  5560. }
  5561. require_once(JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php');
  5562. require_once(JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php');
  5563. $areas = Zend_Json::decode($this->formrow->template_areas);
  5564. if (is_array($areas)) {
  5565. switch (JRequest::getVar('ff_payment_method', '')) {
  5566. case 'PayPal':
  5567. case 'Sofortueberweisung':
  5568. foreach ($areas As $area) {
  5569. foreach ($area['elements'] As $element) {
  5570. if ($element['internalType'] == 'bfPayPal' || $element['internalType'] == 'bfSofortueberweisung') {
  5571. $options = $element['options'];
  5572. if (isset($options['sendNotificationAfterPayment']) && $options['sendNotificationAfterPayment']) {
  5573. $this->sendNotificationAfterPayment = true;
  5574. }
  5575. }
  5576. }
  5577. }
  5578. }
  5579. }
  5580. }
  5581. if (!$halt) {
  5582. $code = '';
  5583. switch ($this->formrow->piece3cond) {
  5584. case 1: // library
  5585. $database->setQuery(
  5586. "select name, code from #__facileforms_pieces " .
  5587. "where id=" . $this->formrow->piece3id . " and published=1 "
  5588. );
  5589. $rows = $database->loadObjectList();
  5590. if (count($rows))
  5591. echo $this->execPiece(
  5592. $rows[0]->code, BFText::_('COM_BREEZINGFORMS_PROCESS_BSPIECE') . " " . $rows[0]->name, 'p', $this->formrow->piece3id, null
  5593. );
  5594. break;
  5595. case 2: // custom code
  5596. echo $this->execPiece(
  5597. $this->formrow->piece3code, BFText::_('COM_BREEZINGFORMS_PROCESS_BSPIECEC'), 'f', $this->form, 3
  5598. );
  5599. break;
  5600. default:
  5601. break;
  5602. } // switch
  5603. if ($this->bury())
  5604. return;
  5605. if ($this->status == _FF_STATUS_OK) {
  5606. if (!$this->formrow->published) {
  5607. $this->status = _FF_STATUS_UNPUBLISHED;
  5608. } else {
  5609. if ($this->status == _FF_STATUS_OK) {
  5610. if ($this->formrow->dblog > 0)
  5611. $cbRecordId = $this->logToDatabase($cbResult);
  5612. if ($this->status == _FF_STATUS_OK) {
  5613. if ($this->formrow->emailntf > 0 && ( $cbEmailNotifications || $cbEmailUpdateNotifications )) { // CONTENTBUILDER
  5614. $this->sendEmailNotification();
  5615. }
  5616. if ($this->formrow->mb_emailntf > 0 && ( $cbEmailNotifications || $cbEmailUpdateNotifications )) { // CONTENTBUILDER
  5617. $this->sendMailbackNotification();
  5618. }
  5619. $this->sendMailChimpNotification();
  5620. $tickets = JFactory::getSession()->get('bfFlashUploadTickets', array());
  5621. mt_srand();
  5622. if (isset($tickets[JRequest::getVar('bfFlashUploadTicket', mt_rand(0, mt_getrandmax()))])) {
  5623. unset($tickets[JRequest::getVar('bfFlashUploadTicket')]);
  5624. JFactory::getSession()->set('bfFlashUploadTickets', $tickets);
  5625. }
  5626. }
  5627. } // if
  5628. } // if
  5629. } // if
  5630. // handle End Submit piece
  5631. $code = '';
  5632. switch ($this->formrow->piece4cond) {
  5633. case 1: // library
  5634. $database->setQuery(
  5635. "select name, code from #__facileforms_pieces " .
  5636. "where id=" . $this->formrow->piece4id . " and published=1 "
  5637. );
  5638. $rows = $database->loadObjectList();
  5639. if (count($rows))
  5640. echo $this->execPiece(
  5641. $rows[0]->code, BFText::_('COM_BREEZINGFORMS_PROCESS_ESPIECE') . " " . $rows[0]->name, 'p', $this->formrow->piece4id, null
  5642. );
  5643. break;
  5644. case 2: // custom code
  5645. echo $this->execPiece(
  5646. $this->formrow->piece4code, BFText::_('COM_BREEZINGFORMS_PROCESS_ESPIECEC'), 'f', $this->form, 3
  5647. );
  5648. break;
  5649. default:
  5650. break;
  5651. } // switch
  5652. if ($this->bury())
  5653. return;
  5654. }
  5655. switch ($this->status) {
  5656. case _FF_STATUS_OK:
  5657. $message = BFText::_('COM_BREEZINGFORMS_PROCESS_SUBMITSUCCESS');
  5658. break;
  5659. case _FF_STATUS_UNPUBLISHED:
  5660. $message = BFText::_('COM_BREEZINGFORMS_PROCESS_UNPUBLISHED');
  5661. break;
  5662. case _FF_STATUS_SAVERECORD_FAILED:
  5663. $message = BFText::_('COM_BREEZINGFORMS_PROCESS_SAVERECFAILED');
  5664. break;
  5665. case _FF_STATUS_SAVESUBRECORD_FAILED:
  5666. $message = BFText::_('COM_BREEZINGFORMS_PROCESS_SAVESUBFAILED');
  5667. break;
  5668. case _FF_STATUS_UPLOAD_FAILED:
  5669. $message = BFText::_('COM_BREEZINGFORMS_PROCESS_UPLOADFAILED');
  5670. break;
  5671. case _FF_STATUS_SENDMAIL_FAILED:
  5672. $message = BFText::_('COM_BREEZINGFORMS_PROCESS_SENDMAILFAILED');
  5673. break;
  5674. case _FF_STATUS_ATTACHMENT_FAILED:
  5675. $message = BFText::_('COM_BREEZINGFORMS_PROCESS_ATTACHMTFAILED');
  5676. break;
  5677. case _FF_STATUS_CAPTCHA_FAILED:
  5678. $message = BFText::_('COM_BREEZINGFORMS_CAPTCHA_ENTRY_FAILED');
  5679. break;
  5680. case _FF_STATUS_FILE_EXTENSION_NOT_ALLOWED:
  5681. $message = BFText::_('COM_BREEZINGFORMS_FILE_EXTENSION_NOT_ALLOWED');
  5682. break;
  5683. default:
  5684. $message = '';
  5685. // custom piece status and message
  5686. break;
  5687. } // switch
  5688. // built in PayPal action
  5689. $paymentAction = false;
  5690. if ($this->formrow->template_code != '') {
  5691. require_once(JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Decoder.php');
  5692. require_once(JPATH_SITE . '/administrator/components/com_breezingforms/libraries/Zend/Json/Encoder.php');
  5693. $areas = Zend_Json::decode($this->formrow->template_areas);
  5694. if (is_array($areas)) {
  5695. jimport('joomla.version');
  5696. $version = new JVersion();
  5697. $j15 = true;
  5698. if (version_compare($version->getShortVersion(), '1.6', '>=')) {
  5699. $j15 = false;
  5700. }
  5701. $paymentAction = true;
  5702. switch (JRequest::getVar('ff_payment_method', '')) {
  5703. case 'PayPal':
  5704. foreach ($areas As $area) {
  5705. foreach ($area['elements'] As $element) {
  5706. if ($element['internalType'] == 'bfPayPal') {
  5707. $options = $element['options'];
  5708. $business = $options['business'];
  5709. $paypal = 'https://www.paypal.com';
  5710. if ($options['testaccount']) {
  5711. $paypal = 'https://www.sandbox.paypal.com';
  5712. $business = $options['testBusiness'];
  5713. }
  5714. $returnurl = htmlentities(JURI::root() . "index.php?option=com_breezingforms&confirmPayPal=true&form_id=" . $this->form . "&record_id=" . $this->record_id);
  5715. $cancelurl = htmlentities(JURI::root() . "index.php?msg=" . BFText::_('COM_BREEZINGFORMS_Transaction cancelled by user!'));
  5716. $html = '';
  5717. if (!$this->inline)
  5718. $html .= '<html><head></head><body>';
  5719. JHTML::_('behavior.modal');
  5720. $ppselect = JRequest::getVar('ff_nm_bfPaymentSelect', array());
  5721. if (count($ppselect) != 0) {
  5722. $ppselected = explode('|', $ppselect[0]);
  5723. if (count($ppselected) == 4) {
  5724. $options['itemname'] = $ppselected[0];
  5725. $options['itemnumber'] = $ppselected[1];
  5726. $options['amount'] = $ppselected[2];
  5727. $options['tax'] = $ppselected[3];
  5728. }
  5729. }
  5730. // keeping this for compat reasons
  5731. $ppselect = JRequest::getVar('ff_nm_PayPalSelect', array());
  5732. if (count($ppselect) != 0) {
  5733. $ppselected = explode('|', $ppselect[0]);
  5734. if (count($ppselected) == 4) {
  5735. $options['itemname'] = $ppselected[0];
  5736. $options['itemnumber'] = $ppselected[1];
  5737. $options['amount'] = $ppselected[2];
  5738. $options['tax'] = $ppselected[3];
  5739. }
  5740. }
  5741. // compat end
  5742. $html .= "<form name=\"ff_submitform\" action=\"" . $paypal . "/cgi-bin/webscr\" method=\"post\">";
  5743. $html .= "<input type=\"hidden\" name=\"cmd\" value=\"_xclick\"/>";
  5744. $html .= "<input type=\"hidden\" name=\"business\" value=\"" . $business . "\"/>";
  5745. $html .= "<input type=\"hidden\" name=\"item_name\" value=\"" . $options['itemname'] . "\"/>";
  5746. $html .= "<input type=\"hidden\" name=\"item_number\" value=\"" . $options['itemnumber'] . "\"/>";
  5747. $html .= "<input type=\"hidden\" name=\"amount\" value=\"" . $options['amount'] . "\"/>";
  5748. $html .= "<input type=\"hidden\" name=\"tax\" value=\"" . $options['tax'] . "\"/>";
  5749. $html .= "<input type=\"hidden\" name=\"no_shipping\" value=\"1\"/>";
  5750. $html .= "<input type=\"hidden\" name=\"no_note\" value=\"1\"/>";
  5751. if ($options['useIpn']) {
  5752. $html .= "<input type=\"hidden\" name=\"notify_url\" value=\"" . htmlentities(JURI::root() . "index.php?option=com_breezingforms&confirmPayPalIpn=true&raw=true&form_id=" . $this->form . "&record_id=" . $this->record_id) . "\"/>";
  5753. if ($options['testaccount']) {
  5754. $html .= "<input type=\"hidden\" name=\"test_ipn\" value=\"1\"/>";
  5755. }
  5756. } else {
  5757. $html .= "<input type=\"hidden\" name=\"notify_url\" value=\"" . $returnurl . "\"/>";
  5758. }
  5759. $html .= "<input type=\"hidden\" name=\"return\" value=\"" . $returnurl . "\"/>";
  5760. $html .= "<input type=\"hidden\" name=\"cancel_return\" value=\"" . $cancelurl . "\"/>";
  5761. $html .= "<input type=\"hidden\" name=\"rm\" value=\"2\"/>";
  5762. $html .= "<input type=\"hidden\" name=\"lc\" value=\"" . $options['locale'] . "\"/>";
  5763. //$html .= "<input type=\"hidden\" name=\"pal\" value=\"D6MXR7SEX68LU\"/>";
  5764. $html .= "<input type=\"hidden\" name=\"currency_code\" value=\"" . strtoupper($options['currencyCode']) . "\"/>";
  5765. if (!$this->inline)
  5766. $html .= "</form></body></html>";
  5767. // TODO: let the user decide to use modal or simple alert
  5768. if ($j15) {
  5769. $html .= '<script type="text/javascript">' . nl() .
  5770. indentc(1) . '<!--' . nl() .
  5771. indentc(2) . '
  5772. SqueezeBox.initialize({});
  5773. SqueezeBox.loadModal = function(modalUrl,handler,x,y) {
  5774. this.initialize();
  5775. var options = $merge(options || {}, Json.evaluate("{handler: \'" + handler + "\', size: {x: " + x +", y: " + y + "}}"));
  5776. this.setOptions(this.presets, options);
  5777. this.assignOptions();
  5778. this.setContent(handler,modalUrl);
  5779. };
  5780. SqueezeBox.loadModal("' . JURI::root() . 'index.php?raw=true&option=com_breezingforms&showPayPalConnectMsg=true","iframe",300,100);
  5781. ' . nl() .
  5782. indentc(1) . '// -->' . nl() .
  5783. '</script>' . nl();
  5784. }
  5785. $html .= '<script type="text/javascript"><!--' . nl() . 'document.ff_submitform.submit();' . nl() . '//--></script>';
  5786. echo $html;
  5787. break;
  5788. }
  5789. }
  5790. }
  5791. break;
  5792. case 'Sofortueberweisung':
  5793. foreach ($areas As $area) {
  5794. foreach ($area['elements'] As $element) {
  5795. if ($element['internalType'] == 'bfSofortueberweisung') {
  5796. $html = '';
  5797. if (!$this->inline)
  5798. $html .= '<html><head></head><body>';
  5799. JHTML::_('behavior.modal');
  5800. $options = $element['options'];
  5801. $ppselect = JRequest::getVar('ff_nm_bfPaymentSelect', array());
  5802. if (count($ppselect) != 0) {
  5803. $ppselected = explode('|', $ppselect[0]);
  5804. if (count($ppselected) == 4) {
  5805. $options['reason_1'] = $ppselected[0];
  5806. $options['reason_2'] = $ppselected[1];
  5807. $options['amount'] = $ppselected[2];
  5808. if ($ppselected[3] != '' && intval($ppselected[3]) > 0) {
  5809. $options['amount'] = '' . doubleval($options['amount']) + doubleval($ppselected[3]);
  5810. }
  5811. }
  5812. }
  5813. $options['amount'] = str_replace('.', ',', $options['amount']);
  5814. $hash = '';
  5815. if (isset($options['project_password']) && trim($options['project_password']) != '') {
  5816. $data = array(
  5817. $options['user_id'], // user_id
  5818. $options['project_id'], // project_id
  5819. '', // sender_holder
  5820. '', // sender_account_number
  5821. '', // sender_bank_code
  5822. '', // sender_country_id
  5823. $options['amount'], // amount
  5824. // currency_id, Pflichtparameter bei Hash-Berechnung
  5825. $options['currency_id'],
  5826. $options['reason_1'], // reason_1
  5827. $options['reason_2'], // reason_2
  5828. $this->form, // user_variable_0
  5829. $this->record_id, // user_variable_1
  5830. (isset($options['mailback']) && $options['mailback'] ? implode('###', $this->mailbackRecipients) : ''), // user_variable_2
  5831. '', // user_variable_3
  5832. '', // user_variable_4
  5833. '', // user_variable_5
  5834. $options['project_password'] // project_password
  5835. );
  5836. $data_implode = implode('|', $data);
  5837. $gen = sha1($data_implode);
  5838. $hash = '<input type="hidden" name="hash" value="' . $gen . '" />';
  5839. }
  5840. $mailback = '';
  5841. if (isset($options['mailback']) && $options['mailback']) {
  5842. $mailback = '<input type="hidden" name="user_variable_2" value="' . implode('###', $this->mailbackRecipients) . '" />';
  5843. }
  5844. $html .= '
  5845. <!-- sofortüberweisung.de -->
  5846. <form method="post" name="ff_submitform" action="https://www.sofortueberweisung.de/payment/start">
  5847. <input type="hidden" name="user_id" value="' . $options['user_id'] . '" />
  5848. <input type="hidden" name="project_id" value="' . $options['project_id'] . '" />
  5849. <input type="hidden" name="reason_1" value="' . $options['reason_1'] . '" />
  5850. <input type="hidden" name="reason_2" value="' . $options['reason_2'] . '" />
  5851. <input type="hidden" name="amount" value="' . $options['amount'] . '" />
  5852. <input type="hidden" name="currency_id" value="' . $options['currency_id'] . '" />
  5853. <input type="hidden" name="language_id" value="' . $options['language_id'] . '" />
  5854. <input type="hidden" name="user_variable_0" value="' . $this->form . '" />
  5855. <input type="hidden" name="user_variable_1" value="' . $this->record_id . '" />
  5856. ' . $mailback . '
  5857. ' . $hash . '
  5858. </form>
  5859. <!-- sofortüberweisung.de -->
  5860. ';
  5861. if ($j15) {
  5862. // TODO: let the user decide to use modal or simple alert
  5863. $html .= '<script type="text/javascript">' . nl() .
  5864. indentc(1) . '<!--' . nl() .
  5865. indentc(2) . '
  5866. SqueezeBox.initialize({});
  5867. SqueezeBox.loadModal = function(modalUrl,handler,x,y) {
  5868. this.initialize();
  5869. var options = $merge(options || {}, Json.evaluate("{handler: \'" + handler + "\', size: {x: " + x +", y: " + y + "}}"));
  5870. this.setOptions(this.presets, options);
  5871. this.assignOptions();
  5872. this.setContent(handler,modalUrl);
  5873. };
  5874. SqueezeBox.loadModal("' . JURI::root() . 'index.php?raw=true&option=com_breezingforms&showPayPalConnectMsg=true","iframe",300,100);
  5875. ' . nl() .
  5876. indentc(1) . '// -->' . nl() .
  5877. '</script>' . nl();
  5878. }
  5879. $html .= '<script type="text/javascript"><!--' . nl() . 'document.ff_submitform.submit();' . nl() . '//--></script>';
  5880. if (!$this->inline)
  5881. $html .= "</form></body></html>";
  5882. echo $html;
  5883. break;
  5884. }
  5885. }
  5886. }
  5887. break;
  5888. default:
  5889. $paymentAction = false;
  5890. }
  5891. }
  5892. }
  5893. // CONTENTBUILDER
  5894. if (JRequest::getVar('cb_controller',null) != 'edit' && $cbRecordId && is_array($cbResult) && isset($cbResult['data']) && isset($cbResult['data']['id']) && $cbResult['data']['id']) {
  5895. if($cbRecordId){
  5896. $return = JRequest::getVar('return','');
  5897. if( $return ){
  5898. $return = base64_decode($return);
  5899. if( JURI::isInternal($return) ){
  5900. JFactory::getApplication()->redirect($return, $msg);
  5901. }
  5902. }
  5903. }
  5904. if( $cbResult['data']['force_login'] ){
  5905. jimport('joomla.version');
  5906. $version = new JVersion();
  5907. $is15 = true;
  5908. if (version_compare($version->getShortVersion(), '1.6', '>=')) {
  5909. $is15 = false;
  5910. }
  5911. if( !JFactory::getUser()->get('id', 0) ){
  5912. if(!$is15){
  5913. JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_users&view=login&Itemid='.JRequest::getInt('Itemid', 0), false));
  5914. }
  5915. else
  5916. {
  5917. JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_user&view=login&Itemid='.JRequest::getInt('Itemid', 0), false));
  5918. }
  5919. }else{
  5920. if(!$is15){
  5921. JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_users&view=profile&Itemid='.JRequest::getInt('Itemid', 0), false));
  5922. }
  5923. else
  5924. {
  5925. JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_user&view=user&Itemid='.JRequest::getInt('Itemid', 0), false));
  5926. }
  5927. }
  5928. }
  5929. else if( trim($cbResult['data']['force_url']) ){
  5930. JFactory::getApplication()->redirect(trim($cbResult['data']['force_url']));
  5931. }
  5932. JFactory::getApplication()->redirect(JRoute::_('index.php?option=com_contentbuilder&controller=details&Itemid='.JRequest::getInt('Itemid',0).'&backtolist=' . JRequest::getInt('backtolist', 0) . '&id=' . $cbResult['data']['id'] . '&record_id=' . $cbRecordId . '&limitstart=' . JRequest::getInt('limitstart', 0) . '&filter_order=' . JRequest::getCmd('filter_order'), false), BFText::_('COM_CONTENTBUILDER_SAVED'));
  5933. }
  5934. if (!$paymentAction) {
  5935. if ($message == '')
  5936. $message = $this->message;
  5937. else {
  5938. if ($this->message != '')
  5939. $message .= ":" . nl() . $this->message;
  5940. } // if
  5941. if (!$this->inline) {
  5942. $url = ($this->inframe) ? $ff_mossite . '/index.php?format=html&tmpl=component' : (($this->runmode == _FF_RUNMODE_FRONTEND) ? '' : 'index.php?format=html' . (JRequest::getCmd('tmpl','') ? '&tmpl='.JRequest::getCmd('tmpl','') : '') );
  5943. echo '<form name="ff_submitform" action="' . $url . '" method="post">' . nl();
  5944. } // if
  5945. switch ($this->runmode) {
  5946. case _FF_RUNMODE_FRONTEND:
  5947. echo indentc(1) . '<input type="hidden" name="ff_form" value="' . $this->form . '"/>' . nl();
  5948. if ($this->target > 1)
  5949. echo indentc(1) . '<input type="hidden" name="ff_target" value="' . $this->target . '"/>' . nl();
  5950. if ($this->inframe)
  5951. echo indentc(1) . '<input type="hidden" name="ff_frame" value="1"/>' . nl();
  5952. if ($this->border)
  5953. echo indentc(1) . '<input type="hidden" name="ff_border" value="1"/>' . nl();
  5954. if ($this->page != 1)
  5955. indentc(1) . '<input type="hidden" name="ff_page" value="' . $this->page . '"/>' . nl();
  5956. if ($this->align != 1)
  5957. echo indentc(1) . '<input type="hidden" name="ff_align" value="' . $this->align . '"/>' . nl();
  5958. if ($this->top != 0)
  5959. echo indentc(1) . '<input type="hidden" name="ff_top" value="' . $this->top . '"/>' . nl();
  5960. reset($ff_otherparams);
  5961. while (list($prop, $val) = each($ff_otherparams))
  5962. echo indentc(1) . '<input type="hidden" name="' . $prop . '" value="' . $val . '"/>' . nl();
  5963. break;
  5964. case _FF_RUNMODE_BACKEND:
  5965. echo indentc(1) . '<input type="hidden" name="option" value="com_breezingforms"/>' . nl() .
  5966. indentc(1) . '<input type="hidden" name="act" value="run"/>' . nl() .
  5967. indentc(1) . '<input type="hidden" name="ff_form" value="' . $this->form . '"/>' . nl() .
  5968. indentc(1) . '<input type="hidden" name="ff_runmode" value="' . $this->runmode . '"/>' . nl();
  5969. if ($this->target > 1)
  5970. echo indentc(1) . '<input type="hidden" name="ff_target" value="' . $this->target . '"/>' . nl();
  5971. if ($this->inframe)
  5972. echo indentc(1) . '<input type="hidden" name="ff_frame" value="1"/>' . nl();
  5973. if ($this->border)
  5974. echo indentc(1) . '<input type="hidden" name="ff_border" value="1"/>' . nl();
  5975. if ($this->page != 1)
  5976. indentc(1) . '<input type="hidden" name="ff_page" value="' . $this->page . '"/>' . nl();
  5977. if ($this->align != 1)
  5978. echo indentc(1) . '<input type="hidden" name="ff_align" value="' . $this->align . '"/>' . nl();
  5979. if ($this->top != 0)
  5980. echo indentc(1) . '<input type="hidden" name="ff_top" value="' . $this->top . '"/>' . nl();
  5981. break;
  5982. default: // _FF_RUNMODE_PREVIEW:
  5983. if ($this->inframe) {
  5984. echo indentc(1) . '<input type="hidden" name="option" value="com_breezingforms"/>' . nl() .
  5985. indentc(1) . '<input type="hidden" name="ff_frame" value="1"/>' . nl() .
  5986. indentc(1) . '<input type="hidden" name="ff_form" value="' . $this->form . '"/>' . nl() .
  5987. indentc(1) . '<input type="hidden" name="ff_runmode" value="' . $this->runmode . '"/>' . nl();
  5988. if ($this->page != 1)
  5989. indentc(1) . '<input type="hidden" name="ff_page" value="' . $this->page . '"/>' . nl();
  5990. } // if
  5991. } // if
  5992. echo indentc(1) . '<input type="hidden" name="ff_contentid" value="' . JRequest::getInt('ff_contentid', 0) . '"/>' . nl() .
  5993. indentc(1) . '<input type="hidden" name="ff_applic" value="' . JRequest::getWord('ff_applic', '') . '"/>' . nl() .
  5994. indentc(1) . '<input type="hidden" name="ff_module_id" value="' . JRequest::getInt('ff_module_id', 0) . '"/>' . nl() .
  5995. indentc(1) . '<input type="hidden" name="ff_status" value="' . $this->status . '"/>' . nl() .
  5996. indentc(1) . '<input type="hidden" name="ff_message" value="' . addcslashes($message, "\0..\37!@\@\177..\377") . '"/>' . nl();
  5997. if (isset($_REQUEST['cb_form_id']) && isset($_REQUEST['cb_record_id'])) {
  5998. echo indentc(1) . '<input type="hidden" name="cb_form_id" value="' . JRequest::getInt('cb_form_id', 0) . '"/>' . nl();
  5999. echo indentc(1) . '<input type="hidden" name="cb_record_id" value="' . JRequest::getInt('cb_record_id', 0) . '"/>' . nl();
  6000. echo indentc(1) . '<input type="hidden" name="return" value="' . JRequest::getVar('return', '') . '"/>' . nl();
  6001. }
  6002. // TODO: turn off tracing in the options
  6003. if ($this->traceMode & _FF_TRACEMODE_DIRECT) {
  6004. $this->dumpTrace();
  6005. ob_end_flush();
  6006. echo '</pre>';
  6007. } else {
  6008. ob_end_flush();
  6009. $this->dumpTrace();
  6010. } // if
  6011. restore_error_handler();
  6012. if (!$this->inline) {
  6013. echo '</form>' . nl() .
  6014. '<script type="text/javascript">' . nl() .
  6015. indentc(1) . '<!--' . nl() .
  6016. indentc(2) . 'document.ff_submitform.submit();' . nl() .
  6017. indentc(1) . '// -->' . nl() .
  6018. '</script>' . nl() .
  6019. '</body>' . nl() .
  6020. '</html>' . nl();
  6021. } // if
  6022. }
  6023. unset($_SESSION['ff_editable_overridePlg' . JRequest::getInt('ff_contentid', 0) . $this->form_id]);
  6024. unset($_SESSION['ff_editablePlg' . JRequest::getInt('ff_contentid', 0) . $this->form_id]);
  6025. JFactory::getSession()->set('ff_editableMod' . JRequest::getInt('ff_module_id', 0) . $this->form_id, 0);
  6026. JFactory::getSession()->set('ff_editable_overrideMod' . JRequest::getInt('ff_module_id', 0) . $this->form_id, 0);
  6027. }
  6028. // submit
  6029. }
  6030. // HTML_facileFormsProcessor
  6031. ?>