<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1400" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Maybe, I can only receive emails on this list 
;)</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Another suggestion where this&nbsp;function would 
be helpfull is in say .....</FONT></DIV>
<DIV><FONT face=Arial size=2>&nbsp;admin/topic.php -- I believe $tid and $topic 
are variables that are passed as GET or POST vars.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>You need to check for both, post is higher in 
presidence and if not set it to '';</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>Just a thought -- I'll stop sharing 
now.</FONT></DIV>
<BLOCKQUOTE dir=ltr 
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
  <A title=geeklog@langfamily.ca href="mailto:geeklog@langfamily.ca">Blaine 
  Lang</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A 
  title=geeklog-devtalk@lists.geeklog.net 
  href="mailto:geeklog-devtalk@lists.geeklog.net">geeklog-devtalk@lists.geeklog.net</A> 
  </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Sunday, February 29, 2004 1:19 
  PM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [geeklog-devtalk] Variable 
  best practices</DIV>
  <DIV><BR></DIV>
  <DIV><FONT face=Arial size=2>I've been wanting to address this issue for a 
  while and have come up with the following function.</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>It will filter either GET, POST or both (as in my 
  need noted below - but look for POST first).</FONT></DIV>
  <DIV><FONT face=Arial size=2>It will appy the data filter - default mode for 
  now.</FONT></DIV>
  <DIV><FONT face=Arial size=2>It will also optionally create GLOBALS out of the 
  variables. This could be used to remove a dependany on 
  Register_globals.</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>Example use:</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>$myvars = 
  array('op','profileid','memberid');<BR>getdata($myvars,true);</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>or </FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>$formvars = array('profile_name','member_num', 
  'member_addr', 'member_city', 'member_phone');<BR>$formdata = 
  array();<BR>$formdata = getdata($formvars,'POST');</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>&lt;&lt; code begin &gt;&gt;</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>function 
  getdata($vars,$setglobal=false,$type='')&nbsp; {<BR>&nbsp; $return_data = 
  array();</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>&nbsp; #setup common reference to SuperGlobals 
  depending which array is needed<BR>&nbsp; if ($type == "GET" OR $type == 
  "POST") {<BR>&nbsp;&nbsp;&nbsp; if ($type=="GET") { $SG_Array=&amp; $_GET; 
  }<BR>&nbsp;&nbsp;&nbsp; if ($type=="POST") { $SG_Array=&amp; $_POST; 
  }</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; # loop through SuperGlobal 
  data array and grab out data for allowed fields if found<BR>&nbsp;&nbsp;&nbsp; 
  foreach($vars as $key)&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if 
  (array_key_exists($key,$SG_Array)) { $return_data[$key]=$SG_Array[$key]; 
  }<BR>&nbsp;&nbsp;&nbsp; }</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>&nbsp; } else {<BR>&nbsp;&nbsp;&nbsp; foreach 
  ($vars as $key) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (array_key_exists($key, 
  $_POST)) { <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $return_data[$key] = 
  $_POST[$key];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } elseif 
  (array_key_exists($key, $_GET)) { 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $return_data[$key] = 
  $_GET[$key];<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp;&nbsp;&nbsp; 
  }<BR>&nbsp; }</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>&nbsp;&nbsp;&nbsp; # loop through $vars array and 
  apply the filter<BR>&nbsp;&nbsp;&nbsp; foreach($vars as $value)&nbsp; 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $return_data[$value]&nbsp; = <FONT 
  face="Times New Roman" 
  size=3>COM_applyFilter</FONT>($return_data[$value]);<BR>&nbsp;&nbsp;&nbsp; 
  }</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>&nbsp; // Optionally set $GLOBALS or return the 
  array<BR>&nbsp; if ($setglobal) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # loop 
  through final data and define all the variables using the $GLOBALS 
  array<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; foreach ($return_data as 
  $key=&gt;$value)&nbsp; {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  $GLOBALS[$key]=$value;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&nbsp; } else 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return $return_data;<BR>&nbsp; 
  }</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>}</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <BLOCKQUOTE dir=ltr 
  style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
    <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
    <DIV 
    style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B> 
    <A title=geeklog@langfamily.ca href="mailto:geeklog@langfamily.ca">Blaine 
    Lang</A> </DIV>
    <DIV style="FONT: 10pt arial"><B>To:</B> <A 
    title=geeklog-devtalk@lists.geeklog.net 
    href="mailto:geeklog-devtalk@lists.geeklog.net">geeklog-devtalk@lists.geeklog.net</A> 
    </DIV>
    <DIV style="FONT: 10pt arial"><B>Sent:</B> Sunday, February 29, 2004 10:19 
    AM</DIV>
    <DIV style="FONT: 10pt arial"><B>Subject:</B> [geeklog-devtalk] Variable 
    best practices</DIV>
    <DIV><FONT face=Arial size=2></FONT><BR></DIV>
    <DIV>As a practce, I try not to have any register_globals dependancies. I 
    will use the full $HTTP_POST_VARS and&nbsp;$HTTP_GET_VARS&nbsp;variable 
    names.&nbsp;I'd lole to use the&nbsp;other supper globals ($_REQUEST, $_POST 
    and $_GET)&nbsp;and are still dependant on&nbsp;php version 4.1 or greater. 
    Most hosting services should be running by now but it can not be assumed I 
    guess.</DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV>I'm filtering all expected POST and GET vars now in my new plugins and 
    there are still times it makes sense to use the same name in the POST and 
    GET. It may be passed in the URL or form so you have to check both but I 
    check the post first as I would use that first if I can post a hidden 
    variable.</DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>Examples are:</FONT></DIV>
    <DIV><FONT face=Arial size=2>using $op to indicate operation. I may be 
    triggered from a link, selectbox, image or button in the UI. I may also have 
    to pass it to another script.</FONT></DIV>
    <DIV><FONT face=Arial size=2>using $page and $sort as part of the page 
    google like navigation (links) but you also need to retain this as hidden 
    fields in forms if you want to retain your page position.</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>I don't see the reason to use different names 
    with the get and post as this allows me more control. I only expect it one 
    way or the other and POST should override get.</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>Hense why I end of having all this extra code 
    at the top of scripts:</FONT></DIV>
    <DIV>&gt; if (isset($HTTP_POST_VARS['op']) ) 
    {<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; $op = 
    clubApplyFilter($HTTP_POST_VARS['op']);<BR>&gt; } elseif 
    (isset($HTTP_GET_VARS['op']) ) {<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; $op = 
    clubApplyFilter($HTTP_GET_VARS['op']);<BR>&gt; } else 
    {<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; $op = '';<BR>&gt; }</DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>Is this how others would approach 
    this?</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>I was thinking if I am having to repeat this 
    practice and common code, others would as well. Extending my class object to 
    handle this would be an advantage.</FONT></DIV>
    <DIV><FONT face=Arial size=2><FONT face="Times New Roman" size=3>$myfilter = 
    new COM_filter;<BR>$myfilter-&gt;_censor = true;<BR>$myfilter -&gt;_jsfilter 
    = true;</FONT><BR></FONT><FONT face=Arial size=2>$op = 
    $myfilter-&gt;_setvar('op', 'text');</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>Cheers,</FONT></DIV>
    <DIV><FONT face=Arial size=2>Blaine</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial 
size=2></FONT>&nbsp;</DIV></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>