PageRenderTime 63ms CodeModel.GetById 19ms 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

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. // 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)

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