Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> v2.4 RN Issues
Author Message
dad7732
RavenNuke(tm) Development Team



Joined: Mar 18, 2007
Posts: 1242

PostPosted: Tue Feb 01, 2011 11:30 pm Reply with quote

Is there a way, in the Terms of Service document to add:

Your UserAgent: xxxxxxx
Your IP Address: xxx.xxx.xxx

I tried to add some code but it only displayed the code.
 
View user's profile Send private message
spasticdonkey
RavenNuke(tm) Development Team



Joined: Dec 02, 2006
Posts: 1693
Location: Texas, USA

PostPosted: Wed Feb 02, 2011 2:36 am Reply with quote

I would probably add your code for IP and user agent to classes/class.legal_document.php, then look for the "Make any necessary tag replacements" section and add some replacements for ip and agent. Then you can call them in the templates the same as you can the site, country, and date. Noticed that section is still using ereg, this is an untested preg_replace sample:

Code:
      $docText = preg_replace('/\[sitename\]', $sitename, $docText);

      $docText = preg_replace('/\[country\]', $this->docCountry, $docText);
      $docText = preg_replace('/\[date\]', $dateS, $docText);
      $docText = preg_replace('/\[ip\]', $UserIP, $docText);
      $docText = preg_replace('/\[agent\]', $UserAgent, $docText);


Where $UserIP and $UserAgent are your pre-formatted/validated IP and agent. Then call [ip] and [agent] from your docs.
 
View user's profile Send private message Visit poster's website
dad7732







PostPosted: Wed Feb 02, 2011 8:06 am Reply with quote

Didn't work. Changed preg to eregi and still didn't work because if "preg" was entered I got an error something about no ending delimiter ('/').

I embedded [ip] and [agent] and it remained as such in the document. It seems that $UserIP and $UserAgent aren't defined like $sitename is for instance. I even added $UserIP and $UserAgent to the global string and still no luck.

To verify that it still works, I embedded [sitename] and it was replaced by the site name.

Thanks
 
spasticdonkey







PostPosted: Wed Feb 02, 2011 10:37 am Reply with quote

You would have to add code for the $UserIP and $UserAgent, prior to the text replacement. The IP is fairly simple

Code:
$UserIP = $_SERVER['REMOTE_ADDR'];


the user agent is a little trickier, I might look at using something like this [ Only registered users can see links on this board! Get registered or login! ]

(not the get_browser function (overkill) but the user submitted alternative)

You could also look at the includes/counter.php and see how it is done there, although that is also still using ereg and is somewhat dated.

As for the preg_match it was a shot in the dark so lets try and get an ereg version working first.
 
dad7732







PostPosted: Wed Feb 02, 2011 10:42 am Reply with quote

Still doestn't work, here is what the addition looks like:
Code:


$UserIP = $_SERVER['REMOTE_ADDR'];
$docText = $this->doc['text'];
$docText = eregi_replace('\[sitename\]', $sitename, $docText);
$docText = eregi_replace('\[country\]', $this->docCountry, $docText);
$docText = eregi_replace('\[date\]', $dateS, $docText);
$docText = eregi_replace('/\[ip\]', $UserIP, $docText);
$docText = eregi_replace('/\[agent\]', $UserAgent, $docText);
if (empty($docText)) $docText = $lgl_lang['LGL_ERRDB_TRANSNOTFOUND'];
$s = '';
$s .= '<div><table ' . LGL_STYLE_DOC . '><tr><td>' . $docText . '</td></tr></table></div>';
      return $s;


Last edited by dad7732 on Wed Feb 02, 2011 11:08 am; edited 1 time in total 
spasticdonkey







PostPosted: Wed Feb 02, 2011 10:54 am Reply with quote

since we are using eregi try it like so

Code:
$docText = eregi_replace('\[ip\]', $UserIP, $docText);

$docText = eregi_replace('\[agent\]', $UserAgent, $docText);
 
dad7732







PostPosted: Wed Feb 02, 2011 11:18 am Reply with quote

Whoaaa .. that works!! was just a matter of a \ in the right spot looks like. The IP works, now to see if the useragent works.

It doesn't .. Sad
 
dad7732







PostPosted: Sat Feb 05, 2011 11:30 am Reply with quote

Aha, got it!

Code:


$UserIP = $_SERVER['REMOTE_ADDR'];
$UserAgent = $_SERVER['HTTP_USER_AGENT'];


Thanks for all the insight, etc.

Cheers
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> v2.4 RN Issues

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©