Security
|
|
|
|
<?php // ********* License COMPLETELY FREE NO GUARENTEE ********************
// keycom_class - 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
//
// file settings.php
$tmcvars = "tkey|012243|variable2|value2|b|0|etclike|0|etcgiving|0|etcout|0|my|0|variables|0" ; // see the format is variable|value the seperator is the "|" charactor
//
// 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 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 guarentee
//
// these three below allow you to look up a variable value $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('etclike',88); // set a [key] value (notice the output) echo $ikey->ret_key_val(); // return the [key] string ?>
|
|
|
Usage Example
|
// *****************************
// Examples
// no copyright no guarentee
//
// these three below allow you to look up a variable value
$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('etclike',88); // set a [key] value (notice the output)
echo $ikey->ret_key_val(); // return the [key] string
|
|
|
Rate This Script
|
|
|
|