Security
|
|
|
|
<?php // ********* License COMPLETELY FREE NO Guarantee ********************
// keycom_class keycom_class_v2 - where security is essential. Cookieless passing of post variables.
// This class will enable the user to pass all necessary variables in a
// secure fasion to the child php page.
// it accomplishes this by creating objects that search and or replace the
// variables one desires to pass in a conacated string
// This is shot # 2 on crating classes so beware
// Thanks for your interest. Ian A. Stewart
// ************** examples for use see bottom of listing **********
//$ikey = new keycom($tmcvars); // instantiate
//$ikey->set_var_name('tkey'); // set the search variable
//$ikey->find_val(); // execute the search
//echo $ikey->ret_var_val(); // return the found search
// the two below are the ones that set a new key value and return it
//$ikey->set_tkey('tband_rsn',88); // set a [key] value
//echo $ikey->ret_key_val(); // return the [key] strinn
// $ikey->find_n_return('etclike') // returns the value of etclike
// file settings.php
$tmcvars = "junk|0|tkey|012243|variable2|value2|b|0|etclike|test|etcgiving|0|etcout|0|my|0|variables|0" ;
// see the format is variable|value the seperator is the "|" charactor
// added junk to the first field to take care of bug
// see bottom for examples of use [by Ian A. Stewart] World Multcast.inc
//
//include_once '../someincludepath/yoursettings.php'; put your vars shown above in your settings file
class keycom {// class block begin var $tmcvars = "";
var $var_name = "";
var $var_val = "";
function find_n_return($bx){ $this->set_var_name($bx); $this->find_val();
return $this->var_val;
}
function keycom($tmcvars)
{ //echo "Master Data Set to $tmcvars <br>"; $this->tmcvars = $tmcvars; //$this->a = explode('|',$this->tmcvars); }
function set_var_name($var_name){ $this->var_name = $var_name;
}
function set_tkey($key_val,$new_val){ $a = explode('|',$this->tmcvars);
$xx = 0;
//echo $a[1];
while (isset($a[$xx]))
{
//echo $key_val;
if ($a[$xx] == $key_val)
{
$a[$xx + 1] = $new_val;
$this->tmcvars = implode('|',$a);
}// echo $a[$xx]; echo '<br>';
$xx++;
}
}
function ret_var_val(){
return $this->var_val;
}
function ret_key_val(){
return $this->tmcvars;
}
function find_val()
{ //echo $this->var_name; $a = explode('|',$this->tmcvars);
$xx = 0;
//echo 'test'.$a[1];
while (isset($a[$xx]))
{
if ($a[$xx] == $this->var_name)
{
$this->var_val = $a[$xx + 1];
return $this->var_val;
//echo $a[$xx]; echo '<br>';
}
$xx++;
}
}
} // class block end
// *****************************
// Examples
// no Copyright no Guarantee
//
// these three below allow you to look up a variable valeu $ikey = new keycom($tmcvars); // instantiate echo "instantiated value = ";
echo $ikey->ret_key_val().'<br>'; //
echo $ikey->find_n_return('etclike').'<br>'; // return the found search
//
// the two below are the ones that set a new key value and return it $ikey->set_tkey('etclike',88); // set a [key] value (notice the output) echo $ikey->ret_key_val(); // return the whole [key] string
?>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|