/usr/share/php/xajax/tests/charEncodingTest.php is in php-xajax 0.5-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | <?php
require_once("../xajax_core/xajax.inc.php");
function setOptions($formData)
{
$_SESSION['useEncoding'] = $formData['useEncoding'];
$_SESSION['htmlEntities'] = (boolean)$formData['htmlEntities'];
$_SESSION['decodeUTF8'] = (boolean)$formData['decodeUTF8'];
$objResponse = new xajaxResponse();
$objResponse->alert("Your options have been saved.");
return $objResponse;
}
function testForm($strText, $formData, $arrArray)
{
//global $useEncoding, $htmlEntities;
//$objResponse = new xajaxResponse($useEncoding, $htmlEntities);
// encoding parameters are not retreived automatically from the xajax object
$objResponse = new xajaxResponse();
$data = "Text:\n" . $strText;
$data .= "\n\nFormData:\n" . print_r($formData, true);
$data .= "\n\nArray:\n" .print_r($arrArray, true);
$objResponse->alert($data);
$objResponse->assign("submittedDiv", "innerHTML", "<pre>".$data."</pre>");
return $objResponse;
}
$useEncoding = "UTF-8";
$htmlEntities = false;
$decodeUTF8 = false;
session_start();
session_name("xajaxCharEncodingTest");
if (@$_GET['refresh'] == "yes") {
session_destroy();
header("location: charEncodingTest.php");
exit();
}
if (isset($_SESSION['useEncoding'])) {
$useEncoding = $_SESSION['useEncoding'];
}
if (isset($_SESSION['htmlEntities'])) {
$htmlEntities = $_SESSION['htmlEntities'];
}
if (isset($_SESSION['decodeUTF8'])) {
$decodeUTF8 = $_SESSION['decodeUTF8'];
}
$xajax = new xajax();
$xajax->configure('javascript URI', '../');
$xajax->configure('characterEncoding', $useEncoding);
if ($htmlEntities) {
$xajax->configure("outputEntities", true);
}
if ($decodeUTF8) {
$xajax->configure("decodeUTF8Input", true);
}
$xajax->configure('debug', true);
$xajax->registerFunction('setOptions');
$xajax->registerFunction('testForm');
$xajax->processRequest();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Character Encoding Test | xajax Tests</title>
<?php
$xajax->printJavascript()
?>
<script type="text/javascript">
function getTestArray()
{
var text = xajax.$('textField1').value;
var testArray = new Array();
testArray[0] = text;
testArray[1] = text;
testArray[text] = new Array();
testArray[text][0] = text;
testArray[text][1] = text;
testArray[3] = new Array();
testArray[3][0] = text;
testArray[3][1] = text;
testArray[3][2] = new Array();
testArray[3][2][0] = text;
testArray[3][2][1] = text;
return testArray;
}
function callXajax()
{
var txt = xajax.$('textField1').value;
var frm = xajax.getFormValues('testForm1');
var arr = getTestArray();
xajax_testForm(txt,frm,arr);
}
</script>
</head>
<body>
<h2><a href="index.php">xajax Tests</a></h2>
<h1>Character Encoding Test</h1>
<h2>Options Form</h2>
<p><strong>NOTE:</strong> if you change these options, make sure you click the Save Options button or the options won't be used.</p>
<form id="optionsForm" onsubmit="return false;">
<p>Encoding: <input type="text" value="<?php echo $useEncoding ?>" name="useEncoding" /><br />
Output HTML Entities? <input type="radio" name="htmlEntities" value="1" <?php if ($htmlEntities) echo ' checked="checked"' ?>/> Yes
<input type="radio" name="htmlEntities" value="0" <?php if (!$htmlEntities) echo ' checked="checked"' ?>/> No<br />
Decode UTF-8 Input? <input type="radio" name="decodeUTF8" value="1" <?php if ($decodeUTF8) echo ' checked="checked"' ?>/> Yes
<input type="radio" name="decodeUTF8" value="0" <?php if (!$decodeUTF8) echo ' checked="checked"' ?>/> No<br />
<p><input type="submit" value="Save Options" onclick="xajax_setOptions(xajax.getFormValues('optionsForm')); return false;" /></p>
</form>
<p><a href="charEncodingTest.php?refresh=yes">Clear and Refresh</a></p>
<h2>Text Test Form</h2>
<p><a href="http://www.i18nguy.com/unicode-example.html" target="_blank">Here are some Unicode examples</a> you can paste into the text box below. You can see <a href="http://www.unicode.org/iuc/iuc10/languages.html" target="_blank">more examples and a list of standard encoding schemes here</a>.</p>
<form id="testForm1" onsubmit="return false;">
<p><input type="text" value="Enter test text here" id="textField1" name="textField1" size="60" /></p>
<p><input type="submit" value="Submit Text" onclick="callXajax(); return false;" /></p>
</form>
<div id="submittedDiv"></div>
<div id="debugDiv"></div>
</body>
</html>
|