PageRenderTime 50ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 2ms

/components/com_breezingforms/facileforms.process.php

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