function showOutput() { $testResponse = new xajaxResponse(); $testResponse->alert("Hello"); $testResponse2 = new xajaxResponse(); $testResponse2->loadCommands($testResponse); $testResponse2->replace("this", "is", "a", "replacement]]>"); $testResponseOutput = htmlspecialchars($testResponse2->getOutput()); $objResponse = new xajaxResponse(); $objResponse->assign("submittedDiv", "innerHTML", $testResponseOutput); $aValues = array(); $aValues[] = "Yippie"; $objResponse->setReturnValue($aValues); return $objResponse; }
function smarty_function_xajax_response($params, &$smarty) { $return = ''; if (isset($params['content']) && $params['content'] != '') { global $smarty, $ajaxlib; include_once 'lib/ajax/xajax.inc.php'; if ($ajaxlib && $ajaxlib->canProcessRequests()) { $objResponse = new xajaxResponse(); $objResponse->assign('tiki-center', 'innerHTML', $params['content']); $return = $objResponse->getOutput(); unset($objResponse); } } return $return; }
function showOutput() { $testResponse = new xajaxResponse(); $testResponse->alert("Edit this test and uncomment lines in the showOutput() method to test plugin calling"); // PHP4 & PHP5 $testResponse->plugin("testPlugin", "testMethod"); // PHP5 ONLY - Uncomment to test //$testResponse->plugin("testPlugin")->testMethod(); // PHP5 ONLY - Uncomment to test //$testResponse->testPlugin->testMethod(); $testResponseOutput = htmlspecialchars($testResponse->getOutput()); $objResponse = new xajaxResponse(); $objResponse->assign("submittedDiv", "innerHTML", $testResponseOutput); $objResponse->plugin('testPlugin', 'testMethod'); return $objResponse; }
function showOutput() { $testResponse = new xajaxResponse(); $testResponse->alert("This is the text that would be displayed in an alert box."); // PHP4 & PHP5 if (isset($_GET['methodOne'])) { eval('$testResponse->plugin("testPlugin", "testMethod");'); } // PHP5 ONLY - Uncomment to test if (isset($_GET['methodTwo'])) { eval('$testResponse->plugin("testPlugin")->testMethod();'); } // PHP5 ONLY - Uncomment to test if (isset($_GET['methodThree'])) { eval('$testResponse->testPlugin->testMethod();'); } $testResponseOutput = '<pre>' . htmlspecialchars(str_replace("><", ">\n<", $testResponse->getOutput())) . '</pre>'; $objResponse = new xajaxResponse(); $objResponse->assign("submittedDiv", "innerHTML", $testResponseOutput); if (isset($_GET['methodOne'])) { eval('$objResponse->plugin("testPlugin", "testMethod");'); } if (isset($_GET['methodTwo'])) { eval('$objResponse->plugin("testPlugin")->testMethod();'); } if (isset($_GET['methodThree'])) { eval('$objResponse->testPlugin->testMethod();'); } return $objResponse; }
function sql_error($query, $values, $result) { global $ADODB_LASTDB, $smarty, $prefs, $ajaxlib; trigger_error($ADODB_LASTDB . " error: " . htmlspecialchars($this->db->ErrorMsg()) . " in query:<br /><pre>\n" . htmlspecialchars($query) . "\n</pre><br />", E_USER_WARNING); // only for debugging. //trigger_error($ADODB_LASTDB . " error: " . $this->db->ErrorMsg(). " in query:<br />" . $query . "<br />", E_USER_WARNING); $outp = "<div class='simplebox'><b>" . htmlspecialchars(tra("An error occured in a database query!")) . "</b></div>"; $outp .= "<br /><table class='form'>"; $outp .= "<tr class='heading'><td colspan='2'>Context:</td></tr>"; $outp .= "<tr class='formcolor'><td>File</td><td>" . htmlspecialchars(basename($_SERVER['SCRIPT_NAME'])) . "</td></tr>"; $outp .= "<tr class='formcolor'><td>Url</td><td>" . htmlspecialchars(basename($_SERVER['REQUEST_URI'])) . "</td></tr>"; $outp .= "<tr class='heading'><td colspan='2'>Query:</td></tr>"; $outp .= "<tr class='formcolor'><td colspan='2'><tt>" . htmlspecialchars($query) . "</tt></td></tr>"; $outp .= "<tr class='heading'><td colspan='2'>Values:</td></tr>"; foreach ($values as $k => $v) { if (is_null($v)) { $v = '<i>NULL</i>'; } else { $v = htmlspecialchars($v); } $outp .= "<tr class='formcolor'><td>" . htmlspecialchars($k) . "</td><td>{$v}</td></tr>"; } $outp .= "<tr class='heading'><td colspan='2'>Message:</td></tr><tr class='formcolor'><td colspan='2'>" . htmlspecialchars($this->db->ErrorMsg()) . "</td></tr>\n"; $q = $query; foreach ($values as $v) { if (is_null($v)) { $v = 'NULL'; } else { $v = "'" . addslashes($v) . "'"; } $pos = strpos($q, '?'); if ($pos !== FALSE) { $q = substr($q, 0, $pos) . "{$v}" . substr($q, $pos + 1); } } $outp .= "<tr class='heading'><td colspan='2'>Built query was probably:</td></tr><tr class='formcolor'><td colspan='2'>" . htmlspecialchars($q) . "</td></tr>\n"; if (function_exists('xdebug_get_function_stack')) { function mydumpstack($stack) { $o = ''; foreach ($stack as $line) { $o .= '* ' . $line['file'] . " : " . $line['line'] . " -> " . $line['function'] . "(" . var_export($line['params'], true) . ")<br />"; } return $o; } $outp .= "<tr class='heading'><th>Stack Trace</th><td>" . mydumpstack(xdebug_get_function_stack()) . "</td></tr>"; } $outp .= "</table>"; //if($result===false) echo "<br>\$result is false"; //if($result===null) echo "<br>\$result is null"; //if(empty($result)) echo "<br>\$result is empty"; $showviaajax = false; if ($prefs['feature_ajax'] == 'y') { global $ajaxlib; include_once 'lib/ajax/xajax.inc.php'; if ($ajaxlib && $ajaxlib->canProcessRequests()) { // this was a xajax request -> return a xajax answer $objResponse = new xajaxResponse(); $page = "<html><head>"; $page .= " <title>Tiki SQL Error (xajax)</title>"; $page .= " <link rel='stylesheet' href='styles/tikineat.css' type='text/css' />"; $page .= "</head><body>{$outp}</body></html>"; $page = addslashes(str_replace(array("\n", "\r"), array(' ', ' '), $page)); $objResponse->addScript("bugwin=window.open('', 'tikierror', 'width=760,height=500,scrollbars=1,resizable=1');" . "bugwin.document.write('{$page}');"); echo $objResponse->getOutput(); die; } } if (!isset($_SESSION['fatal_error'])) { // Do not show the error if an error has already occured during the same script execution (error.tpl already called), // because tiki should have died before another error. // This happens when error.tpl is called by tiki.sql... and tiki.sql is also called again in error.tpl, entering in an infinite loop. require_once 'tiki-setup.php'; if ($smarty) { $smarty->assign('msg', $outp); $_SESSION['fatal_error'] = 'y'; $smarty->display('error.tpl'); unset($_SESSION['fatal_error']); } else { echo $outp; } die; } }