10/01/2006, 02:38
|
| | Fecha de Ingreso: noviembre-2005
Mensajes: 55
Antigüedad: 19 años Puntos: 0 | |
Dos. ************************************************** ****
************************************************** ****
4) result.php:
<html xmlns="" xml:lang="cs" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
<meta name="author" content="" />
<title>JSRS Select Demo - page #2</title>
<style type="text/css">
/* <![CDATA[ */
@import url(./style.css);
/* ]]> */
</style>
<script type="text/javascript" src="jsrsClient.js"></script>
<script type="text/javascript" src="selectphp.js"></script>
</head>
<?php
$make = isset($_POST['lstMake']) ? $_POST['lstMake'] : -99;
$model = isset($_POST['lstModel']) ? $_POST['lstModel'] : -99;
$options = isset($_POST['lstOptions']) ? $_POST['lstOptions'] : -99;
$options2 = isset($_POST['lstOptions2']) ? $_POST['lstOptions2'] : -99;
?>
<body onload="preselect('<?php echo $make;?>', '<?php echo $model;?>', '<?php echo $options;?>', '<?php echo $options2;?>', 1);">
<h2>JSRS Select Box Filling Demo - page #2</h2>
<form name="QForm" action="./select.php" method="post">
<fieldset>
<legend>Result from previous selects</legend>
<p>
<label for="lstMake">Make</label>
<select name="lstMake" id="lstMake">
<option>--------- Not Yet Loaded ---------</option>
</select>
</p>
<p>
<label for="lstModel">Model</label>
<select name="lstModel" id="lstModel">
<option>--------- Not Yet Loaded ---------</option>
</select>
</p>
<p>
<label for="lstOptions">Options</label>
<select name="lstOptions" id="lstOptions">
<option>--------- Not Yet Loaded ---------</option>
</select>
</p>
<p>
<label for="lstOptions2">Options</label>
<select name="lstOptions2" id="lstOptions2">
<option>--------- Not Yet Loaded ---------</option>
</select>
</p>
</fieldset>
<p><input type="submit" name="cmdBack" value="Back" id="cmdSubmit" /></p>
</form>
Thanks to Milfson () for the preselection code!
</body>
</html>
************************************************** ****
************************************************** ****
5) jsrsServer.php.inc:
<?php
//
// jsrsServer.php - javascript remote scripting server include
//
// see jsrsClient.js for version info
//
function jsrsDispatch($validFuncs ){
$func = jsrsBuildFunc($validFuncs);
if ($func != ""){
$retval = "";
eval("\$retval = " . $func . ";");
if (strlen($retval)>0){
jsrsReturn($retval."");
} else {
jsrsReturn("");
}
} else {
jsrsReturnError("function builds as empty string");
}
}
function jsrsReturn($payload) {
global $C;
if(isset($_POST['C'])) $C = $_POST['C'];
if(isset($_GET['C'])) $C = $_GET['C'];
Print (
"<html><head></head><body onload=\"p=document.layers?parentLayer:window.pare nt;p.jsrsLoaded('"
. $C . "');\">jsrsPayload:<br>"
. "<form name=\"jsrs_Form\"><textarea name=\"jsrs_Payload\" id=\"jsrs_Payload\">"
. jsrsEscape($payload) . "</textarea></form></body></html>");
exit();
}
function jsrsEscape($str){
// escape ampersands so special chars aren't interpreted
$tmp = ereg_replace( "&", "&", $str );
// escape slashes with whacks so end tags don't interfere with return html
return ereg_replace( "\/" , "\\/",$tmp);
}
/////////////////////////////
//
// user functions
function jsrsReturnError($str){
global $C;
if(isset($_POST['C'])) $C = $_POST['C'];
if(isset($_GET['C'])) $C = $_GET['C'];
// escape quotes
$cleanStr = ereg_replace("\'","\\'",$str);
// !!!! --- Warning -- !!!
$cleanStr = "jsrsError: " . ereg_replace("\"", "\\\"", $cleanStr);
print ("<html><head></head><body "
. "onload=\"p=document.layers?parentLayer:window.par ent;p.jsrsError('" . $C . "','" . urlencode($str) . "');\">"
. $cleanStr . "</body></html>" );
exit();
}
function jsrsArrayToString( $a, $delim ){
// user function to flatten 1-dim array to string for return to client
$d = "~";
if (!isset($delim)) $d = $delim;
return implode($a,$d);
}
function jsrsBuildFunc($validFuncs) {
$F = '';
if(isset($_POST['F'])) {
$F = $_POST['F'];
$method = 'post';
}
if(isset($_GET['F'])) {
$F = $_GET['F'];
$method = 'get';
}
$func = "";
if ($F != "") {
$func = $F;
// make sure it's in the dispatch list
if (strpos(strtoupper($validFuncs),strtoupper($func)) ===false)
jsrsReturnError($func . " is not a valid function" );
$func .= "(";
switch($method){
case 'post':
foreach($_POST['P'] as $index => $value){
$func .= '"'.substr($value, 1, strlen($value)-2).'",';
}
break;
case 'get':
foreach($_GET['P'] as $index => $value){
$func .= '"'.substr($value, 1, strlen($value)-2).'",';
}
break;
}
if (substr($func,strlen($func)-1,1)==",")
$func = substr($func,0,strlen($func)-1);
$func .= ")";
}
return $func;
}
function jsrsEvalEscape($thing) {
$tmp = ereg_replace($thing,"\r\n","\n");
return $tmp;
}
function jsrsVBArrayToString($a,$delim) {
// --- not use in PHP see jsrsArrayToString method
return jsrsArrayToString($a,$delim);
}
?>
************************************************** ****
************************************************** **** |