PageRenderTime 123ms CodeModel.GetById 48ms RepoModel.GetById 8ms app.codeStats 2ms

/components/com_breezingforms/facileforms.process.php

https://bitbucket.org/izubizarreta/https-bitbucket.org-bityvip-alpes
PHP | 6664 lines | 5891 code | 594 blank | 179 comment | 1593 complexity | 4bbee968557cf120285e4689635c3aae MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, LGPL-2.1, MIT, LGPL-3.0, LGPL-2.0, JSON

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

  1. <?php
  2. /**
  3. * BreezingForms - A Joomla Forms Application
  4. * @version 1.8
  5. * @package BreezingForms
  6. * @copyright (C) 2008-2012 by Markus Bopp
  7. * @license Released under the terms of the GNU General Public License
  8. * */
  9. defined('_JEXEC') or die('Direct Access to this location is not allowed.');
  10. class bfMobile {
  11. public $isMobile = false;
  12. }
  13. $mainframe = JFactory::getApplication();
  14. $ff_processor = null;
  15. define('_FF_PACKBREAKAFTER', 250);
  16. define('_FF_STATUS_OK', 0);
  17. define('_FF_STATUS_UNPUBLISHED', 1);
  18. define('_FF_STATUS_SAVERECORD_FAILED', 2);
  19. define('_FF_STATUS_SAVESUBRECORD_FAILED', 3);
  20. define('_FF_STATUS_UPLOAD_FAILED', 4);
  21. define('_FF_STATUS_SENDMAIL_FAILED', 5);
  22. define('_FF_STATUS_ATTACHMENT_FAILED', 6);
  23. define('_FF_STATUS_CAPTCHA_FAILED', 7);
  24. define('_FF_STATUS_FILE_EXTENSION_NOT_ALLOWED', 8);
  25. define('_FF_DATA_ID', 0);
  26. define('_FF_DATA_NAME', 1);
  27. define('_FF_DATA_TITLE', 2);
  28. define('_FF_DATA_TYPE', 3);
  29. define('_FF_DATA_VALUE', 4);
  30. define('_FF_DATA_FILE_SERVERPATH', 5);
  31. define('_FF_IGNORE_STRICT', 1);
  32. define('_FF_TRACE_NAMELIMIT', 100);
  33. // tracemode bits
  34. define('_FF_TRACEMODE_EVAL', 8);
  35. define('_FF_TRACEMODE_PIECE', 16);
  36. define('_FF_TRACEMODE_FUNCTION', 32);
  37. define('_FF_TRACEMODE_MESSAGE', 64);
  38. define('_FF_TRACEMODE_LOCAL', 128);
  39. define('_FF_TRACEMODE_DIRECT', 256);
  40. define('_FF_TRACEMODE_APPEND', 512);
  41. define('_FF_TRACEMODE_DISABLE', 1024);
  42. define('_FF_TRACEMODE_FIRST', 2048);
  43. // tracemode masks
  44. define('_FF_TRACEMODE_PRIORITY', 7);
  45. define('_FF_TRACEMODE_TOPIC', 120);
  46. define('_FF_TRACEMODE_VARIABLE', 248);
  47. // debugging flags
  48. define('_FF_DEBUG_PATCHEDCODE', 1);
  49. define('_FF_DEBUG_ENTER', 2);
  50. define('_FF_DEBUG_EXIT', 4);
  51. define('_FF_DEBUG_DIRECTIVE', 8);
  52. define('_FF_DEBUG', 0);
  53. function ff_trace($msg = null) {
  54. global $ff_processor;
  55. if ($ff_processor->dying ||
  56. ($ff_processor->traceMode & _FF_TRACEMODE_DISABLE) ||
  57. !($ff_processor->traceMode & _FF_TRACEMODE_MESSAGE))
  58. return;
  59. $level = count($ff_processor->traceStack);
  60. $trc = '';
  61. for ($l = 0; $l < $level; $l++)
  62. $trc .= ' ';
  63. $trc .= BFText::_('COM_BREEZINGFORMS_PROCESS_MSGUNKNOWN') . ": $msg\n";
  64. $ff_processor->traceBuffer .= htmlspecialchars($trc, ENT_QUOTES);
  65. if ($ff_processor->traceMode & _FF_TRACEMODE_DIRECT)
  66. $ff_processor->dumpTrace();
  67. }
  68. // ff_trace
  69. function _ff_trace($line, $msg = null) {
  70. global $ff_processor;
  71. // version for patched code
  72. if ($ff_processor->dying || ($ff_processor->traceMode & _FF_TRACEMODE_DISABLE))
  73. return;
  74. $level = count($ff_processor->traceStack);
  75. if ($msg && ($ff_processor->traceMode & _FF_TRACEMODE_MESSAGE)) {
  76. $trc = '';
  77. for ($l = 0; $l < $level; $l++)
  78. $trc .= ' ';
  79. $trc .= BFText::_('COM_BREEZINGFORMS_PROCESS_LINE') . " $line: $msg\n";
  80. $ff_processor->traceBuffer .= htmlspecialchars($trc, ENT_QUOTES);
  81. if ($ff_processor->traceMode & _FF_TRACEMODE_DIRECT)
  82. $ff_processor->dumpTrace();
  83. } // if
  84. if ($level)
  85. $ff_processor->traceStack[$level - 1][3] = $line;
  86. }
  87. // _ff_trace
  88. function _ff_getMode(&$newmode, &$name) {
  89. global $ff_processor;
  90. $oldmode = $ff_processor->traceMode;
  91. if (_FF_DEBUG & _FF_DEBUG_ENTER)
  92. $ff_processor->traceBuffer .=
  93. htmlspecialchars(
  94. "\n_FF_DEBUG_ENTER:" .
  95. "\n Name = $name" .
  96. "\n Old mode before = " . $ff_processor->dispTraceMode($oldmode) .
  97. "\n New mode before = " . $ff_processor->dispTraceMode($newmode), ENT_QUOTES
  98. );
  99. if (is_null($newmode) || ($newmode & _FF_TRACEMODE_PRIORITY) < ($oldmode & _FF_TRACEMODE_PRIORITY)) {
  100. $newmode = $oldmode;
  101. $ret = $oldmode;
  102. } else {
  103. $newmode = ($oldmode & ~_FF_TRACEMODE_VARIABLE) | ($newmode & _FF_TRACEMODE_VARIABLE);
  104. if ($oldmode != $newmode)
  105. $ff_processor->traceMode = $newmode;
  106. $ret = ($newmode & _FF_TRACEMODE_LOCAL) ? $oldmode : $newmode;
  107. } // if
  108. if (_FF_DEBUG & _FF_DEBUG_ENTER) {
  109. $ff_processor->traceBuffer .=
  110. htmlspecialchars(
  111. "\n Old mode compiled = " . $ff_processor->dispTraceMode($ret) .
  112. "\n New mode compiled = " . $ff_processor->dispTraceMode($newmode) .
  113. "\n", ENT_QUOTES
  114. );
  115. if ($ff_processor->traceMode & _FF_TRACEMODE_DIRECT)
  116. $ff_processor->dumpTrace();
  117. } // if
  118. return $ret;
  119. }
  120. // _ff_getmode
  121. function _ff_tracePiece($newmode, $name, $line, $type, $id, $pane) {
  122. global $ff_processor;
  123. if ($ff_processor->dying || ($ff_processor->traceMode & _FF_TRACEMODE_DISABLE))
  124. return;
  125. $oldmode = _ff_getMode($newmode, $name);
  126. if ($newmode & _FF_TRACEMODE_PIECE) {
  127. $level = count($ff_processor->traceStack);
  128. for ($l = 0; $l < $level; $l++)
  129. $ff_processor->traceBuffer .= ' ';
  130. $ff_processor->traceBuffer .=
  131. htmlspecialchars(
  132. "+" . BFText::_('COM_BREEZINGFORMS_PROCESS_ENTER') . " $name " . BFText::_('COM_BREEZINGFORMS_PROCESS_ATLINE') . " $line\n", ENT_QUOTES
  133. );
  134. if ($ff_processor->traceMode & _FF_TRACEMODE_DIRECT)
  135. $ff_processor->dumpTrace();
  136. } // if
  137. array_push($ff_processor->traceStack, array($oldmode, 'p', $name, $line, $type, $id, $pane));
  138. }
  139. // _ff_tracePiece
  140. function _ff_traceFunction($newmode, $name, $line, $type, $id, $pane, &$args) {
  141. global $ff_processor;
  142. if ($ff_processor->dying || ($ff_processor->traceMode & _FF_TRACEMODE_DISABLE))
  143. return;
  144. $oldmode = _ff_getMode($newmode, $name);
  145. if ($newmode & _FF_TRACEMODE_FUNCTION) {
  146. $level = count($ff_processor->traceStack);
  147. $trc = '';
  148. for ($l = 0; $l < $level; $l++)
  149. $trc .= ' ';
  150. $trc .= "+" . BFText::_('COM_BREEZINGFORMS_PROCESS_ENTER') . " $name(";
  151. if ($args) {
  152. $next = false;
  153. foreach ($args as $arg) {
  154. if ($next)
  155. $trc .= ', '; else
  156. $next = true;
  157. if (is_null($arg))
  158. $trc .= 'null';
  159. else
  160. if (is_bool($arg)) {
  161. $trc .= $arg ? 'true' : 'false';
  162. } else
  163. if (is_numeric($arg))
  164. $trc .= $arg;
  165. else
  166. if (is_string($arg)) {
  167. $arg = preg_replace('/([\\s]+)/si', ' ', $arg);
  168. if (strlen($arg) > _FF_TRACE_NAMELIMIT)
  169. $arg = substr($arg, 0, _FF_TRACE_NAMELIMIT - 3) . '...';
  170. $trc .= "'$arg'";
  171. } else
  172. if (is_array($arg))
  173. $trc .= BFText::_('COM_BREEZINGFORMS_PROCESS_ARRAY');
  174. else
  175. if (is_object($arg))
  176. $trc .= BFText::_('COM_BREEZINGFORMS_PROCESS_OBJECT');
  177. else
  178. if (is_resource($arg))
  179. $trc .= BFText::_('COM_BREEZINGFORMS_PROCESS_RESOURCE');
  180. else
  181. $trc .= _FACILEFORMS_PROCESS_UNKTYPE;
  182. } // foreach
  183. } // if
  184. $trc .= ") " . BFText::_('COM_BREEZINGFORMS_PROCESS_ATLINE') . " $line\n";
  185. $ff_processor->traceBuffer .= htmlspecialchars($trc, ENT_QUOTES);
  186. if ($ff_processor->traceMode & _FF_TRACEMODE_DIRECT)
  187. $ff_processor->dumpTrace();
  188. } // if
  189. array_push($ff_processor->traceStack, array($oldmode, 'f', $name, $line, $type, $id, $pane));
  190. }
  191. // _ff_traceFunction
  192. function _ff_traceExit($line, $retval=null) {
  193. global $ff_processor;
  194. if ($ff_processor->dying || ($ff_processor->traceMode & _FF_TRACEMODE_DISABLE))
  195. return;
  196. $info = array_pop($ff_processor->traceStack);
  197. if ($info) {
  198. $oldmode = $ff_processor->traceMode;
  199. $newmode = $info[0];
  200. $kind = $info[1];
  201. $name = $info[2];
  202. $type = $info[4];
  203. $id = $info[5];
  204. $pane = $info[6];
  205. if (_FF_DEBUG & _FF_DEBUG_EXIT) {
  206. $ff_processor->traceBuffer .=
  207. htmlspecialchars(
  208. "\n_FF_DEBUG_EXIT:" .
  209. "\n Info = $kind $name at line $line" .
  210. "\n Old mode = " . $ff_processor->dispTraceMode($oldmode) .
  211. "\n New mode = " . $ff_processor->dispTraceMode($newmode) .
  212. "\n", ENT_QUOTES
  213. );
  214. if ($ff_processor->traceMode & _FF_TRACEMODE_DIRECT)
  215. $ff_processor->dumpTrace();
  216. } // if
  217. if ($kind == 'p')
  218. $visible = $oldmode & _FF_TRACEMODE_PIECE;
  219. else
  220. $visible = $oldmode & _FF_TRACEMODE_FUNCTION;
  221. if ($visible) {
  222. $level = count($ff_processor->traceStack);
  223. for ($l = 0; $l < $level; $l++)
  224. $ff_processor->traceBuffer .= ' ';
  225. $ff_processor->traceBuffer .=
  226. htmlspecialchars(
  227. "-" . BFText::_('COM_BREEZINGFORMS_PROCESS_LEAVE') . " $name " . BFText::_('COM_BREEZINGFORMS_PROCESS_ATLINE') . " $line\n", ENT_QUOTES
  228. );
  229. if ($oldmode & _FF_TRACEMODE_DIRECT)
  230. $ff_processor->dumpTrace();
  231. } // if
  232. if ($oldmode != $newmode)
  233. $ff_processor->traceMode =
  234. ($oldmode & ~_FF_TRACEMODE_VARIABLE) | ($newmode & _FF_TRACEMODE_VARIABLE);
  235. } else {
  236. $ff_processor->traceBuffer .= htmlspecialchars(BFText::_('COM_BREEZINGFORMS_PROCESS_WARNSTK') . "\n", ENT_QUOTES);
  237. if ($ff_processor->traceMode & _FF_TRACEMODE_DIRECT)
  238. $ff_processor->dumpTrace();
  239. $type = $id = $pane = null;
  240. $name = BFText::_('COM_BREEZINGFORMS_PROCESS_UNKNOWN');
  241. } // if
  242. return $retval;
  243. }
  244. // _ff_traceExit
  245. function _ff_errorHandler($errno, $errstr, $errfile, $errline) {
  246. global $ff_processor, $ff_mossite, $database;
  247. $database = JFactory::getDBO();
  248. if (isset($ff_processor->dying) && $ff_processor->dying)
  249. return;
  250. $msg = "\n<strong>*** " . htmlspecialchars(BFText::_('COM_BREEZINGFORMS_PROCESS_EXCAUGHT'), ENT_QUOTES) . " ***</strong>\n" .
  251. htmlspecialchars(BFText::_('COM_BREEZINGFORMS_PROCESS_PHPLEVEL') . ' ', ENT_QUOTES);
  252. $fail = false;
  253. if (!defined('E_DEPRECATED')) {
  254. define('E_DEPRECATED', 8192);
  255. }
  256. switch ($errno) {
  257. case E_WARNING : $msg .= "E_WARNING";
  258. break;
  259. case E_NOTICE : $msg .= "E_NOTICE";
  260. break;
  261. case E_USER_ERROR : $msg .= "E_USER_ERROR";
  262. $fail = true;
  263. break;
  264. case E_USER_WARNING: $msg .= "E_USER_WARNING";
  265. break;
  266. case E_USER_NOTICE : $msg .= "E_USER_NOTICE";
  267. break;
  268. case E_DEPRECATED : $msg .= "E_DEPRECATED";
  269. break;
  270. case 2048 :
  271. if (_FF_IGNORE_STRICT)
  272. return;
  273. $msg .= "E_STRICT";
  274. break;
  275. default : $msg .= $errno;
  276. $fail = true;
  277. } // switch
  278. $msg .= htmlspecialchars(
  279. "\n" . BFText::_('COM_BREEZINGFORMS_PROCESS_PHPFILE') . " $errfile\n" .
  280. BFText::_('COM_BREEZINGFORMS_PROCESS_PHPLINE') . " $errline\n", ENT_QUOTES
  281. );
  282. $n = 0;
  283. if (isset($ff_processor)) {
  284. $n = count($ff_processor->traceStack);
  285. }
  286. if ($n) {
  287. $info = $ff_processor->traceStack[$n - 1];
  288. $name = htmlspecialchars($info[2] . ' ' . BFText::_('COM_BREEZINGFORMS_PROCESS_ATLINE') . ' ' . $info[3], ENT_QUOTES);
  289. $type = $info[4];
  290. $id = $info[5];
  291. $pane = $info[6];
  292. if ($type && $id && $ff_processor->runmode != _FF_RUNMODE_FRONTEND) {
  293. $url = $ff_mossite . '/administrator/index.php?option=com_breezingforms&format=html&tmpl=component';
  294. $what = $id;
  295. switch ($type) {
  296. case 'f':
  297. $url .=
  298. '&act=editpage' .
  299. '&task=editform' .
  300. '&form=' . $ff_processor->form;
  301. if ($ff_processor->formrow->package != '')
  302. $url .= '&pkg=' . urlencode($ff_processor->formrow->package);
  303. if ($pane > 0)
  304. $url .= '&tabpane=' . $pane;
  305. $what = 'form ' . $ff_processor->formrow->name;
  306. break;
  307. case 'e':
  308. $page = 1;
  309. foreach ($ff_processor->rows as $row)
  310. if ($row->id == $id) {
  311. $page = $row->page;
  312. $what = $row->name;
  313. break;
  314. } // if
  315. $what = 'element ' . $what;
  316. $url .=
  317. '&act=editpage' .
  318. '&task=edit' .
  319. '&form=' . $ff_processor->form .
  320. '&page=' . $page .
  321. '&ids[]=' . $id;
  322. if ($ff_processor->formrow->package != '')
  323. $url .= '&pkg=' . urlencode($ff_processor->formrow->package);
  324. if ($pane > 0)
  325. $url .= '&tabpane=' . $pane;
  326. break;
  327. case 'p':
  328. $package = '';
  329. $database->setQuery("select name, package from #__facileforms_pieces where id=$id");
  330. $rows = $database->loadObjectList();
  331. if (count($rows)) {
  332. $package = $rows[0]->package;
  333. $what = $rows[0]->name;
  334. }
  335. $what = 'piece ' . $what;
  336. $url .=
  337. '&act=managepieces' .
  338. '&task=edit' .
  339. '&ids[]=' . $id;
  340. if ($package != '')
  341. $url .= '&pkg=' . urlencode($package);
  342. break;
  343. case 's':
  344. $package = '';
  345. $database->setQuery("select name, package from #__facileforms_scripts where id=$id");
  346. $rows = $database->loadObjectList();
  347. if (count($rows)) {
  348. $package = $rows[0]->package;
  349. $what = $rows[0]->name;
  350. }
  351. $what = 'script ' . $what;
  352. $url .=
  353. '&act=managescripts' .
  354. '&task=edit' .
  355. '&ids[]=' . $id;
  356. if ($package != '')
  357. $url .= '&pkg=' . urlencode($package);
  358. break;
  359. default:
  360. $url = null;
  361. } // switch
  362. if ($url)
  363. $name = '<a href="#" ' .
  364. 'onMouseOver="window.status=\'Open ' . $what . '\';return true;" ' .
  365. 'onMouseOut="window.status=\'\';return true;" ' .
  366. 'onClick="ff_redirectParent(\'' . htmlspecialchars($url, ENT_QUOTES) . '\');return true;"' .
  367. '>' . $name . '</a>';
  368. } // if
  369. $msg .= htmlspecialchars(BFText::_('COM_BREEZINGFORMS_PROCESS_LASTPOS'), ENT_QUOTES) . ' ' . $name . "\n";
  370. } // if
  371. $msg .= htmlspecialchars(BFText::_('COM_BREEZINGFORMS_PROCESS_ERRMSG') . " $errstr\n\n", ENT_QUOTES);
  372. if ($fail) {
  373. if (isset($ff_processor)) {
  374. $ff_processor->traceBuffer .= $msg;
  375. $ff_processor->suicide();
  376. }
  377. } else
  378. if (isset($ff_processor)) {
  379. if (($ff_processor->traceMode & _FF_TRACEMODE_DISABLE) == 0) {
  380. $ff_processor->traceBuffer .= $msg;
  381. if ($ff_processor->traceMode & _FF_TRACEMODE_DIRECT)
  382. $ff_processor->dumpTrace();
  383. }
  384. } // if
  385. }
  386. // _ff_errorHandler
  387. class HTML_facileFormsProcessor {
  388. var $okrun = null; // running is allowed
  389. var $ip = null; // visitor ip
  390. var $agent = null; // visitor agent
  391. var $browser = null; // visitors browser
  392. var $opsys = null; // visitors operating system
  393. var $provider = null; // visitors provider
  394. var $submitted = null; // submit date/time
  395. var $formrow = null; // form row
  396. var $form = null; // form #
  397. var $form_id = null; // html form id
  398. var $page = null; // page id
  399. var $target = null; // target form name
  400. var $rows = null; // element rows
  401. var $rowcount = null; // # of element rows
  402. var $runmode = null; // current run mode _FF_RUNMODE_...
  403. var $inline = null; // inline preview
  404. var $inframe = null; // running in a frame
  405. var $template = null; // 0-frontend 1-backend
  406. var $homepage = null; // home page
  407. var $mospath = null; // mos absolute path
  408. var $images = null; // ff_images path
  409. var $uploads = null; // ff_uploads path
  410. var $border = null; // show border
  411. var $align = null; // form alignment
  412. var $top = null; // top margin
  413. var $suffix = null; // class name suffix
  414. var $status = null; // submit return status
  415. var $message = null; // submit return message
  416. var $record_id = null; // id of saved record
  417. var $submitdata = null; // submitted data
  418. var $savedata = null; // data for db save
  419. var $maildata = null; // data for mail notification
  420. var $sfdata = null;
  421. var $xmldata = null; // data for xml attachment
  422. var $mb_xmldata = null; // data for mailback attachments
  423. var $queryCols = null; // query column definitions
  424. var $queryRows = null; // query rows
  425. var $showgrid = null; // show grid in preview
  426. var $findtags = null; // tags to be replaced
  427. var $replacetags = null; // tag replacements
  428. var $dying = null; // form is dying
  429. var $errrep = null; // remember old error reporting
  430. var $traceMode = null; // trace mode
  431. var $traceStack = null; // trace stack
  432. var $traceBuffer = null; // trace buffer
  433. var $user_id = null;
  434. var $username = null;
  435. var $user_full_name = null;
  436. var $mailbackRecipients = array();
  437. var $editable = null;
  438. var $editable_override = null;
  439. var $sendNotificationAfterPayment = false;
  440. public $draggableDivIds = array();
  441. public $isMobile = false;
  442. public $quickmode = null;
  443. function HTML_facileFormsProcessor(
  444. $runmode, // _FF_RUNMODE_FRONTEND, ..._BACKEND, ..._PREVIEW
  445. $inframe, // run in iframe
  446. $form, // form id
  447. $page = 1, // page #
  448. $border = 0, // show border
  449. $align = 1, // align code
  450. $top = 0, // top margin
  451. $target = '', // target form name
  452. $suffix = '', // class name suffix
  453. $editable = 0, $editable_override = 0) {
  454. global $database, $ff_config, $ff_mossite, $ff_mospath, $ff_processor;
  455. $ff_processor = $this;
  456. $database = JFactory::getDBO();
  457. $this->dying = false;
  458. $this->runmode = $runmode;
  459. $this->inframe = $inframe;
  460. $this->form = $form;
  461. $this->page = $page;
  462. $this->border = $border;
  463. $this->align = $align;
  464. $this->top = $top;
  465. $this->target = $target;
  466. $this->suffix = trim($suffix);
  467. $this->editable = $editable;
  468. $this->editable_override = $editable_override;
  469. if (!class_exists('JBrowser')) {
  470. require_once(JPATH_SITE . '/libraries/joomla/environment/browser.php');
  471. }
  472. $this->ip = $_SERVER['REMOTE_ADDR'];
  473. $this->agent = JBrowser::getInstance()->getAgentString();
  474. $this->browser = JBrowser::getInstance()->getAgentString();
  475. $jbrowserInstance = JBrowser::getInstance();
  476. $this->opsys = $jbrowserInstance->getPlatform();
  477. if ($ff_config->getprovider == 0)
  478. $this->provider = BFText::_('COM_BREEZINGFORMS_PROCESS_UNKNOWN');
  479. else {
  480. $host = @GetHostByAddr($this->ip);
  481. $this->provider = preg_replace('/^./', '', strchr($host, '.'));
  482. } // if
  483. $this->submitted = date('Y-m-d H:i:s');
  484. /*
  485. $format = JText::_('DATE_FORMAT_LC2');
  486. if ( !$format ) {
  487. $this->submitted = date('Y-m-d H:i:s');
  488. }else{
  489. $config = JFactory::getConfig();
  490. $offset = $config->getValue('config.offset');
  491. $instance = JFactory::getDate(date('Y-m-d H:i:s'));
  492. $instance->setOffset($offset);
  493. $this->submitted = $instance->toFormat($format);
  494. } */
  495. $this->formrow = new facileFormsForms($database);
  496. $this->formrow->load($form);
  497. if ($this->formrow->published) {
  498. $database->setQuery(
  499. "select * from #__facileforms_elements " .
  500. "where form=" . $this->form . " and published=1 " .
  501. "order by page, ordering"
  502. );
  503. $this->rows = $database->loadObjectList();
  504. $this->rowcount = count($this->rows);
  505. } // if
  506. $this->inline = 0;
  507. $this->template = 0;
  508. $this->form_id = "ff_form" . $form;
  509. if ($runmode == _FF_RUNMODE_FRONTEND) {
  510. $this->homepage = $ff_mossite;
  511. } else {
  512. if ($this->inframe) {
  513. $this->homepage = $ff_mossite . '/administrator/index.php?tmpl=component';
  514. if ($this->formrow->runmode == 2)
  515. $this->template++;
  516. } else {
  517. $this->template++;
  518. if ($runmode == _FF_RUNMODE_PREVIEW) {
  519. $this->inline = 1;
  520. $this->form_id = "adminForm";
  521. } // if
  522. $this->homepage = 'index.php?tmpl=component';
  523. } // if
  524. } // if
  525. $this->mospath = $ff_mospath;
  526. $this->mossite = $ff_mossite;
  527. $this->findtags =
  528. array(
  529. '{ff_currentpage}',
  530. '{ff_lastpage}',
  531. '{ff_name}',
  532. '{ff_title}',
  533. '{ff_homepage}',
  534. '{mospath}',
  535. '{mossite}'
  536. );
  537. $this->replacetags =
  538. array(
  539. $this->page,
  540. $this->formrow->pages,
  541. $this->formrow->name,
  542. $this->formrow->title,
  543. $this->homepage,
  544. $this->mospath,
  545. $this->mossite
  546. );
  547. $this->images = str_replace($this->findtags, $this->replacetags, $ff_config->images);
  548. $this->findtags[] = '{ff_images}';
  549. $this->replacetags[] = $this->images;
  550. $this->uploads = str_replace($this->findtags, $this->replacetags, $ff_config->uploads);
  551. $this->findtags[] = '{ff_uploads}';
  552. $this->replacetags[] = $this->uploads;
  553. // CONTENTBUILDER
  554. $this->findtags[] = '{CBSite}';
  555. $this->replacetags[] = JPATH_SITE;
  556. $this->findtags[] = '{cbsite}';
  557. $this->replacetags[] = JPATH_SITE;
  558. $this->showgrid =
  559. $runmode == _FF_RUNMODE_PREVIEW
  560. && $this->formrow->prevmode > 0
  561. && $ff_config->gridshow == 1
  562. && $ff_config->gridsize > 1;
  563. $this->okrun = $this->formrow->published;
  564. if ($this->okrun)
  565. switch ($this->runmode) {
  566. case _FF_RUNMODE_FRONTEND:
  567. $this->okrun = ($this->formrow->runmode == 0 || $this->formrow->runmode == 1);
  568. break;
  569. case _FF_RUNMODE_BACKEND:
  570. $this->okrun = ($this->formrow->runmode == 0 || $this->formrow->runmode == 2);
  571. break;
  572. default:;
  573. } // switch
  574. $this->traceMode = _FF_TRACEMODE_FIRST;
  575. $this->traceStack = array();
  576. $this->traceBuffer = null;
  577. }
  578. // HTML_facileFormsProcessor
  579. function dispTraceMode($mode) {
  580. if (!is_int($mode))
  581. return $mode;
  582. $m = '(';
  583. if ($mode & _FF_TRACEMODE_FIRST)
  584. $m .= 'first ';
  585. $m .= ( $mode & _FF_TRACEMODE_DIRECT ? 'direct' : $mode & _FF_TRACEMODE_APPEND ? 'append' : 'popup');
  586. if ($mode & _FF_TRACEMODE_DISABLE)
  587. $m .= ' disable';
  588. else {
  589. switch ($mode & _FF_TRACEMODE_PRIORITY) {
  590. case 0: $m .= ' minimum';
  591. break;
  592. case 1: $m .= ' low';
  593. break;
  594. case 2: $m .= ' normal';
  595. break;
  596. case 3: $m .= ' high';
  597. break;
  598. default: $m .= ' maximum';
  599. break;
  600. } // switch
  601. $m .= $mode & _FF_TRACEMODE_LOCAL ? ' local' : ' global';
  602. switch ($mode & _FF_TRACEMODE_TOPIC) {
  603. case 0 : $m .= ' none';
  604. break;
  605. case _FF_TRACEMODE_TOPIC: $m .= ' all';
  606. break;
  607. default:
  608. if ($mode & _FF_TRACEMODE_EVAL)
  609. $m .= ' eval';
  610. if ($mode & _FF_TRACEMODE_PIECE)
  611. $m .= ' piece';
  612. if ($mode & _FF_TRACEMODE_FUNCTION)
  613. $m .= ' function';
  614. if ($mode & _FF_TRACEMODE_MESSAGE)
  615. $m .= ' message';
  616. } // switch
  617. } // if
  618. return $m . ')';
  619. }
  620. // dispTraceMode
  621. function trim(&$code) {
  622. $len = strlen($code);
  623. if (!$len)
  624. return false;
  625. if (strpos(" \t\r\n", $code{0}) === false && strpos(" \t\r\n", $code{$len - 1}) === false)
  626. return true;
  627. $code = trim($code);
  628. return $code != '';
  629. }
  630. // trim
  631. function nonblank(&$code) {
  632. return preg_match("/[^\\s]+/si", $code);
  633. }
  634. // nonblank
  635. function getClassName($classdef) {
  636. $name = '';
  637. if (strpos($classdef, ';') === false)
  638. $name = $classdef;
  639. else {
  640. $defs = explode(';', $classdef);
  641. $name = $defs[$this->template];
  642. } // if
  643. if ($this->trim($name))
  644. $name .= $this->suffix;
  645. return $name;
  646. }
  647. // getClassName
  648. function expJsValue($mixed, $indent='') {
  649. if (is_null($mixed))
  650. return $indent . 'null';
  651. if (is_bool($mixed))
  652. return $mixed ? $indent . 'true' : $indent . 'false';
  653. if (is_numeric($mixed))
  654. return $indent . $mixed;
  655. if (is_string($mixed))
  656. return
  657. $indent . "'" .
  658. str_replace(
  659. array("\\", "'", "\r", "<", "\n"), array("\\\\", "\\'", "\\r", "\\074", "\\n'+" . nl() . $indent . "'"), $mixed
  660. ) .
  661. "'";
  662. if (is_array($mixed)) {
  663. $dst = $indent . '[' . nl();
  664. $next = false;
  665. foreach ($mixed as $value) {
  666. if ($next)
  667. $dst .= "," . nl(); else
  668. $next = true;
  669. $dst .= $this->expJsValue($value, $indent . "\t");
  670. } // foreach
  671. return $dst . nl() . $indent . ']';
  672. } // if
  673. if (is_object($mixed)) {
  674. $dst = $indent . '{' . nl();
  675. $arr = get_object_vars($mixed);
  676. $next = false;
  677. foreach ($arr as $key => $value) {
  678. if ($next)
  679. $dst .= "," . nl(); else
  680. $next = true;
  681. $dst .= $indent . $key . ":" . nl() . $this->expJsValue($value, $indent . "\t");
  682. } // foreach
  683. return $dst . nl() . $indent . '}';
  684. } // if
  685. // not supported types
  686. if (is_resource($mixed))
  687. return $indent . "'" . BFText::_('COM_BREEZINGFORMS_PROCESS_RESOURCE') . "'";
  688. return $indent . "'" . BFText::_('COM_BREEZINGFORMS_PROCESS_UNKNOWN') . "'";
  689. }
  690. // expJsValue
  691. function expJsVar($name, $mixed) {
  692. return $name . ' = ' . $this->expJsValue($mixed) . ';' . nl();
  693. }
  694. // expJsVar
  695. function dumpTrace() {
  696. if ($this->traceMode & _FF_TRACEMODE_DIRECT) {
  697. $html = ob_get_contents();
  698. ob_end_clean();
  699. echo htmlspecialchars($html, ENT_QUOTES) . $this->traceBuffer;
  700. ob_start();
  701. $this->traceBuffer = null;
  702. return;
  703. } // if
  704. if (!$this->traceBuffer)
  705. return;
  706. if ($this->traceMode & _FF_TRACEMODE_APPEND) {
  707. echo '<pre>' . $this->traceBuffer . '</pre>';
  708. $this->traceBuffer = null;
  709. return;
  710. } // if
  711. echo
  712. '<script type="text/javascript">' . nl() .
  713. '<!--' . nl() .
  714. $this->expJsVar('if(typeof ff_processor != "undefined")ff_processor.traceBuffer', $this->traceBuffer);
  715. if ($this->dying)
  716. echo 'onload = ff_traceWindow();' . nl();
  717. echo
  718. '-->' . nl() .
  719. '</script>' . nl();
  720. $this->traceBuffer = null;
  721. }
  722. // dumpTrace
  723. function traceEval($name) {
  724. if (($this->traceMode & _FF_TRACEMODE_DISABLE) ||
  725. !($this->traceMode & _FF_TRACEMODE_EVAL) ||
  726. $this->dying)
  727. return;
  728. $level = count($this->traceStack);
  729. for ($l = 0; $l < $level; $l++)
  730. $this->traceBuffer .= ' ';
  731. $this->traceBuffer .= htmlspecialchars("eval($name)\n", ENT_QUOTES);
  732. if ($this->traceMode & _FF_TRACEMODE_DIRECT)
  733. $this->dumpTrace();
  734. }
  735. // traceEval
  736. function suicide() {
  737. if ($this->dying)
  738. return false;
  739. $this->dying = true;
  740. $this->errrep = error_reporting(0);
  741. return true;
  742. }
  743. // suicide
  744. function bury() {
  745. if (!$this->dying)
  746. return false;
  747. if ($this->traceMode & _FF_TRACEMODE_DIRECT)
  748. $this->dumpTrace();
  749. ob_end_clean();
  750. if ($this->traceMode & _FF_TRACEMODE_DIRECT)
  751. echo '</pre>'; else
  752. $this->dumpTrace();
  753. error_reporting($this->errrep);
  754. restore_error_handler();
  755. return true;
  756. }
  757. // bury
  758. function findToken(&$code, &$spos, &$offs) {
  759. $srch = '#(function|return|_ff_trace|ff_trace[ \\t]*\\(|//|/\*|\*/|\\\\"|\\\\\'|{|}|\(|\)|;|"|\'|\n)#si';
  760. $match = array();
  761. if (!preg_match($srch, $code, $match, PREG_OFFSET_CAPTURE, $spos))
  762. return '';
  763. $token = strtolower($match[0][0]);
  764. $offs = $match[0][1];
  765. $spos = $offs + strlen($token);
  766. return $token;
  767. }
  768. // findToken
  769. function findRealToken(&$code, &$spos, &$offs, &$line) {
  770. $linecmt = $blockcmt = false;
  771. $quote = null;
  772. for (;;) {
  773. $token = preg_replace('/[ \\t]*/', '', $this->findToken($code, $spos, $offs));
  774. switch ($token) {
  775. case '':
  776. return '';
  777. case 'function':
  778. case 'return';
  779. case 'ff_trace(';
  780. case '{':
  781. case '}':
  782. case '(':
  783. case ')':
  784. case ';':
  785. if (!$linecmt && !$blockcmt && !$quote)
  786. return $token;
  787. break;
  788. case "\n":
  789. $line++;
  790. $linecmt = false;
  791. break;
  792. case '//':
  793. if (!$blockcmt && !$quote)
  794. $linecmt = true;
  795. break;
  796. case '/*':
  797. if (!$linecmt && !$quote)
  798. $longcmt = true;
  799. break;
  800. case '"':
  801. case "'":
  802. if ($quote == $token)
  803. $quote = null;
  804. else
  805. if (!$linecmt && !$blockcmt && !$quote)
  806. $quote = $token;
  807. break;
  808. default:
  809. break;
  810. } // switch
  811. } // for
  812. }
  813. // findRealToken
  814. function patchCode($mode, $code, $name, $type, $id, $pane) {
  815. $flevel = $cpos = $spos = $offs = 0;
  816. $bye = false;
  817. $fstack = array();
  818. $line = 1;
  819. if ($type && $id) {
  820. $type = "'$type'";
  821. if (!$pane)
  822. $pane = 'null';
  823. } else
  824. $type = $id = $pane = 'null';
  825. $name = str_replace("'", "\\'", $name);
  826. $dst = "_ff_tracePiece($mode,'$name',$line,$type,$id,$pane);";
  827. while (!$bye) {
  828. switch ($this->findRealToken($code, $spos, $offs, $line)) {
  829. case '': $bye = true;
  830. break;
  831. case 'function':
  832. $brk = false;
  833. while (!$brk) {
  834. // consume tokens until finding the opening bracket
  835. switch ($this->findRealToken($code, $spos, $offs, $line)) {
  836. case '': $bye = $brk = true;
  837. break;
  838. case '{':
  839. $dst .=
  840. substr($code, $cpos, $spos - $cpos) .
  841. '$_ff_traceArgs = func_get_args();' .
  842. '_ff_traceFunction(' . $mode . ',__FUNCTION__,' . $line . ',' . $type . ',' . $id . ',' . $pane . ',$_ff_traceArgs);' .
  843. '$_ff_traceArgs=null;';
  844. $cpos = $spos;
  845. if ($flevel)
  846. array_push($fstack, $flevel);
  847. $flevel = 1;
  848. $brk = true;
  849. break;
  850. default:;
  851. } // switch
  852. } // while
  853. break;
  854. case 'return':
  855. $dst .= substr($code, $cpos, $spos - $cpos);
  856. $cpos = $spos;
  857. $brk = false;
  858. while (!$brk) {
  859. // consume tokens until semicolon found
  860. switch ($this->findRealToken($code, $spos, $offs, $line)) {
  861. case '': $bye = $brk = true;
  862. break;
  863. case ';':
  864. $arg = substr($code, $cpos, $offs - $cpos);
  865. if ($this->nonblank($arg))
  866. $dst .= ' _ff_traceExit(' . $line . ',' . $arg . ');';
  867. else
  868. $dst .= ' _ff_traceExit(' . $line . ');';
  869. $cpos = $spos;
  870. $brk = true;
  871. break;
  872. default:;
  873. } // switch
  874. } // while
  875. break;
  876. case 'ff_trace(':
  877. $dst .= substr($code, $cpos, $offs - $cpos);
  878. $cpos = $spos;
  879. $brk = false;
  880. $lvl = 0;
  881. while (!$brk) {
  882. // consume tokens until finding the closing bracket
  883. switch ($this->findRealToken($code, $spos, $offs, $line)) {
  884. case '': $bye = $brk = true;
  885. break;
  886. case '(': $lvl++;
  887. break;
  888. case ')':
  889. if ($lvl)
  890. $lvl--; else
  891. $brk = true;
  892. break;
  893. default:;
  894. } // switch
  895. } // while
  896. $par = $offs == $cpos ? '' : substr($code, $cpos, $offs - $cpos);
  897. $dst .= " _ff_trace($line";
  898. if ($this->nonblank($par))
  899. $dst .= ',';
  900. break;
  901. case '{':
  902. if ($flevel > 0)
  903. $flevel++;
  904. break;
  905. case '}';
  906. if ($flevel > 0) {
  907. $flevel--;
  908. if (!$flevel) {
  909. $dst .= substr($code, $cpos, $offs - $cpos) . ' _ff_traceExit(' . $line . ');}';
  910. $cpos = $spos;
  911. if (count($fstack))
  912. $flevel = array_pop($fstack);
  913. } // if
  914. } // if
  915. break;
  916. default:
  917. } // switch
  918. } // while
  919. $spos = strlen($code);
  920. if ($cpos < $spos)
  921. $dst .= substr($code, $cpos, $spos - $cpos);
  922. $line--;
  923. $dst .= "_ff_traceExit($line);";
  924. if (_FF_DEBUG & _FF_DEBUG_PATCHEDCODE) {
  925. $this->traceBuffer .=
  926. htmlspecialchars(
  927. "\n_FF_DEBUG_PATCHEDCODE:" .
  928. "\n Mode = " . $this->dispTraceMode($mode) .
  929. "\n Name = $name" .
  930. "\n Link = $type $id $pane" .
  931. "\n------ begin patched code ------" .
  932. "\n$dst" .
  933. "\n------- end patched code -------" .
  934. "\n", ENT_QUOTES
  935. );
  936. if ($this->traceMode & _FF_TRACEMODE_DIRECT)
  937. $this->dumpTrace();
  938. } // if
  939. return $dst;
  940. }
  941. // patchCode
  942. function prepareEvalCode(&$code, $name, $type, $id, $pane) {
  943. if ($this->dying)
  944. return false;
  945. if (!$this->nonblank($code))
  946. return false;
  947. $code .= "\n/*'/*\"/**/;"; // closes all comments and strings that my be open
  948. $disable = ($this->traceMode & _FF_TRACEMODE_DISABLE) ? true : false;
  949. if (!$disable) {
  950. $mode = 'null';
  951. $srch =
  952. '#' .
  953. '^[\\s]*(//\+trace|/\*\+trace)' .
  954. '[ \\t]*([\\w]+)?' .
  955. '[ \\t]*([\\w]+)?' .
  956. '[ \\t]*([\\w]+)?' .
  957. '[ \\t]*([\\w]+)?' .
  958. '[ \\t]*([\\w]+)?' .
  959. '[ \\t]*([\\w]+)?' .
  960. '[ \\t]*(\\*/|\\r\\n)?' .
  961. '#';
  962. $match = array();
  963. if (preg_match($srch, $code, $match)) {
  964. $mode = 2;
  965. $append = $direct = $xeval = $piece = $func = $msg = false;
  966. $local = $def = true;
  967. for ($m = 2; $m < count($match); $m++)
  968. switch ($match[$m]) {
  969. // disable
  970. case 'dis' :
  971. case 'disable' : $disable = true;
  972. break;
  973. // mode
  974. case 'pop' :
  975. case 'popup' : $direct = $append = false;
  976. break;
  977. case 'app' :
  978. case 'append' : $append = true;
  979. $direct = false;
  980. break;
  981. case 'dir' :
  982. case 'direct' : $direct = true;
  983. $append = false;
  984. break;
  985. // priority
  986. case 'min' :
  987. case 'minimum' : $mode = 0;
  988. break;
  989. case 'low' : $mode = 1;
  990. break;
  991. case 'nor' :
  992. case 'normal' : $mode = 2;
  993. break;
  994. case 'hig' :
  995. case 'high' : $mode = 3;
  996. break;
  997. case 'max' :
  998. case 'maximum' : $mode = 4;
  999. break;
  1000. // scope
  1001. case 'glo' :
  1002. case 'global' : $local = false;
  1003. break;
  1004. case 'loc' :
  1005. case 'local' : $local = true;
  1006. break;
  1007. // topics
  1008. case 'all' : $def = false;
  1009. $xeval = $piece = $func = $msg = true;
  1010. break;
  1011. case 'non' :
  1012. case 'none' : $def = $xeval = $piece = $func = $msg = false;
  1013. break;
  1014. case 'eva' :
  1015. case 'eval' : $def = false;
  1016. $xeval = true;
  1017. break;
  1018. case 'pie' :
  1019. case 'piece' : $def = false;
  1020. $piece = true;
  1021. break;
  1022. case 'fun' :
  1023. case 'function': $def = false;
  1024. $func = true;
  1025. break;
  1026. case 'mes' :
  1027. case 'message' : $def = false;
  1028. $msg = true;
  1029. break;
  1030. default : break;
  1031. } // switch
  1032. if ($def) {
  1033. $xeval = false;
  1034. $piece = $func = $msg = true;
  1035. }
  1036. if ($xeval)
  1037. $mode |= _FF_TRACEMODE_EVAL;
  1038. if ($piece)
  1039. $mode |= _FF_TRACEMODE_PIECE;
  1040. if ($func)
  1041. $mode |= _FF_TRACEMODE_FUNCTION;
  1042. if ($msg)
  1043. $mode |= _FF_TRACEMODE_MESSAGE;
  1044. if ($local)
  1045. $mode |= _FF_TRACEMODE_LOCAL;
  1046. $first = ($this->traceMode & _FF_TRACEMODE_FIRST) ? true : false;
  1047. if ($first) {
  1048. $oldMode = $this->traceMode;
  1049. $this->traceMode = 0;
  1050. if ($disable)
  1051. $this->traceMode |= _FF_TRACEMODE_DISABLE;
  1052. if ($append)
  1053. $this->traceMode |= _FF_TRACEMODE_APPEND;
  1054. if ($direct) {
  1055. $this->traceMode |= _FF_TRACEMODE_DIRECT;
  1056. $html = ob_get_contents();
  1057. ob_end_clean();
  1058. echo '<pre>' . htmlspecialchars($html, ENT_QUOTES);
  1059. ob_start();
  1060. } // if
  1061. } else
  1062. $disable = false;
  1063. if (_FF_DEBUG & _FF_DEBUG_DIRECTIVE) {
  1064. $_deb = "\n_FF_DEBUG_DIRECTIVE:";
  1065. if ($first)
  1066. $_deb .= "\n Previous mode=" . $this->dispTraceMode($oldMode);
  1067. $_deb .=
  1068. "\n Trace mode =" . $this->dispTraceMode($this->traceMode) .
  1069. "\n New mode =" . $this->dispTraceMode($mode) .
  1070. "\n";
  1071. $this->traceBuffer .= htmlspecialchars($_deb, ENT_QUOTES);
  1072. if ($this->traceMode & _FF_TRACEMODE_DIRECT)
  1073. $this->dumpTrace();
  1074. } // if
  1075. } // if trace directive
  1076. if (!$disable) {
  1077. if (!$name) {
  1078. $name = preg_replace('/([\\s]+)/si', ' ', $code);
  1079. if (strlen($name) > _FF_TRACE_NAMELIMIT)
  1080. $name = substr($code, 0, _FF_TRACE_NAMELIMIT - 3) . '...';
  1081. } // if
  1082. $code = $this->patchCode($mode, $code, $name, $type, $id, $pane);
  1083. } // if
  1084. } // if trace not disabled
  1085. $code = str_replace($this->findtags, $this->replacetags, $code);
  1086. return true;
  1087. }
  1088. // prepareEvalCode
  1089. function getPieceById($id, $name=null) {
  1090. if ($this->dying)
  1091. return '';
  1092. global $database;
  1093. $database = JFactory::getDBO();
  1094. $database->setQuery(
  1095. 'select code, name from #__facileforms_pieces ' .
  1096. 'where id=' . $id . ' and published=1 '
  1097. );
  1098. $rows = $database->loadObjectList();
  1099. if ($rows && count($rows)) {
  1100. $name = $rows[0]->name;
  1101. return $rows[0]->code;
  1102. } // if
  1103. return '';
  1104. }
  1105. // getPieceById
  1106. function getPieceByName($name, $id=null) {
  1107. if ($this->dying)
  1108. return '';
  1109. global $database;
  1110. $database = JFactory::getDBO();
  1111. $database->setQuery(
  1112. 'select id, code from #__facileforms_pieces ' .
  1113. 'where name=\'' . $name . '\' and published=1 ' .
  1114. 'order by id desc'
  1115. );
  1116. $rows = $database->loadObjectList();
  1117. if ($rows && count($rows)) {
  1118. $id = $rows[0]->id;
  1119. return $rows[0]->code;
  1120. } // if
  1121. return '';
  1122. }
  1123. // getPieceByName
  1124. function execPiece($code, $name, $type, $id, $pane) {
  1125. $ret = '';
  1126. if ($this->prepareEvalCode($code, $name, $type, $id, $pane)) {
  1127. $this->traceEval($name);
  1128. $ret = eval($code);
  1129. } // if
  1130. return $ret;
  1131. }
  1132. // execPiece
  1133. function execPieceById($id) {
  1134. $name = null;
  1135. $code = $this->getPieceById($id, $name);
  1136. return $this->execPiece($code, BFText::_('COM_BREEZINGFORMS_PROCESS_PIECE') . " $name", 'p', $id, null);
  1137. }
  1138. // execPieceById
  1139. function execPieceByName($name) {
  1140. $id = null;
  1141. $code = $this->getPieceByName($name, $id);
  1142. return $this->execPiece($code, BFText::_('COM_BREEZINGFORMS_PROCESS_PIECE') . " $name", 'p', $id, null);
  1143. }
  1144. // execPieceByName
  1145. function replaceCode($code, $name, $type, $id, $pane) {
  1146. if ($this->dying)
  1147. return '';
  1148. $p1 = 0;
  1149. $l = strlen($code);
  1150. $c = '';
  1151. $n = 0;
  1152. while ($p1 < $l) {
  1153. $p2 = strpos($code, '<?php', $p1);
  1154. if ($p2 === false)
  1155. $p2 = $l;
  1156. $c .= substr($code, $p1, $p2 - $p1);
  1157. $p1 = $p2;
  1158. if ($p1 < $l) {
  1159. $p1 += 5;
  1160. $p2 = strpos($code, '?>', $p1);
  1161. if ($p2 === false)
  1162. $p2 = $l;
  1163. $n++;
  1164. $c .= $this->execPiece(substr($code, $p1, $p2 - $p1), $name . "[$n]", $type, $id, $pane);
  1165. if ($this->dying)
  1166. return '';
  1167. $p1 = $p2 + 2;
  1168. } // if
  1169. } // while
  1170. return str_replace($this->findtags, $this->replacetags, $c);
  1171. }
  1172. // replaceCode
  1173. function compileQueryCol(&$elem, &$coldef) {
  1174. $coldef->comp = array();
  1175. if ($this->trim(str_replace($this->findtags, $this->replacetags, $coldef->value))) {
  1176. $c = $p1 = 0;
  1177. $l = strlen($coldef->value);
  1178. while ($p1 < $l) {
  1179. $p2 = strpos($coldef->value, '<?php', $p1);
  1180. if ($p2 === false)
  1181. $p2 = $l;
  1182. $coldef->comp[$c] = array(
  1183. false,
  1184. str_replace(
  1185. $this->findtags, $this->replacetags, trim(substr($coldef->value, $p1, $p2 - $p1))
  1186. )
  1187. );
  1188. if ($this->trim($coldef->comp[$c][1]))
  1189. $c++;
  1190. $p1 = $p2;
  1191. if ($p1 < $l) {
  1192. $p1 += 5;
  1193. $p2 = strpos($coldef->value, '?>', $p1);
  1194. if ($p2 === false)
  1195. $p2 = $l;
  1196. $coldef->comp[$c] = array(true, substr($coldef->value, $p1, $p2 - $p1));
  1197. if ($this->prepareEvalCode(
  1198. $coldef->comp[$c][1], BFText::_('COM_BREEZINGFORMS_PROCESS_QVALUEOF') . " " . $elem->name . "::" . $coldef->name, 'e', $elem->id, 2
  1199. )
  1200. )
  1201. $c++;
  1202. $p1 = $p2 + 2;
  1203. } // if
  1204. } // while
  1205. if ($c > count($coldef->comp))
  1206. array_pop($coldef->comp);
  1207. } // if non-empty
  1208. }
  1209. // compileQueryCol
  1210. function execQueryValue($code, &$elem, &$row, &$coldef, $value) {
  1211. $this->traceEval(BFText::_('COM_BREEZINGFORMS_PROCESS_QVALUEOF') . " " . $elem->name . "::" . $coldef->name);
  1212. return eval($code);
  1213. }
  1214. // execQueryValue
  1215. function execQuery(&$elem, &$valrows, &$coldefs) {
  1216. $ret = null;
  1217. $code = $elem->data2;
  1218. if ($this->prepareEvalCode($code, BFText::_('COM_BREEZINGFORMS_PROCESS_QPIECEOF') . " " . $elem->name, 'e', $elem->id, 1)) {
  1219. $rows = array();
  1220. $this->traceEval(BFText::_('COM_BREEZINGFORMS_PROCESS_QPIECEOF') . " " . $elem->name);
  1221. eval($code);
  1222. $rcnt = count($rows);
  1223. $ccnt = count($coldefs);
  1224. $valrows = array();
  1225. for ($r = 0; $r < $rcnt; $r++) {
  1226. $row = &$rows[$r];
  1227. $valrow = array();
  1228. for ($c = 0; $c < $ccnt; $c++) {
  1229. $coldef = &$coldefs[$c];
  1230. $cname = $coldef->name;
  1231. $value = isset($row->$cname) ? str_replace($this->findtags, $this->replacetags, $row->$cname) : '';
  1232. $xcnt = count($coldef->comp);
  1233. if (!$xcnt)
  1234. $valrow[] = $value;
  1235. else {
  1236. $val = '';
  1237. for ($x =

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