Re: testing string for substring

From: Agelmar (ifetteNOSPAM_at_comcast.net)
Date: 03/30/04


Date: Mon, 29 Mar 2004 21:52:34 -0500

Bart Nessux wrote:
> Bart Nessux wrote:
>
>> I have some php scripts that I use on several machines. Each machine
>> has an identical copy of a mysql database that the scripts run
>> against. The only differences in the DBs are the user names and
>> passwords (they all differ). Fortunately, each machine is a
>> different version of Unix or Linux, so I've instructed the script to
>> do a uname test before connecting to the local database. However, I
>> don't know how to test the variable that contains the uname string.
>>
>> $x = php_uname();
>> print $x;
>> // The print looks like this:
>> Linux localhost 2.4.22-gentoo-r5 #4 Mon Feb 2 18:28:44 EST 2004
>> i686 if ($x contains "gentoo") // How do I test this string
>> for "gentoo" {
>> connect to this db
>> }
>> else
>> ......
>
> I got this to work:
>
> $id_system = php_uname();
> if (ereg("gentoo", "$id_system", $matches))
> {
> connect to this db
> }
> ......

Do not use ereg. Ereg is doing regular expression matches, which is much
more powerful (and slower) than what you're looking for. Try simply doing
if(strstr($id_system, "gentoo"))

And btw, putting a variable in quotes is another big performance hit -
there's no need, essentially you're forcing PHP to make a string that has
the variable in it, when the variable itself is already a string in this
case.



Relevant Pages

  • Re: another POST from perl question
    ... *both* a query string appended to the URL, ... or two specific pieces of information appear in their server logs, ... > support doesn't support scripts, ... You should also ask tech support if they don't *support* scripts, ...
    (comp.lang.perl.misc)
  • Re: another POST from perl question
    ... *both* a query string appended to the URL, ... or two specific pieces of information appear in their server logs, ... > support doesn't support scripts, ... You should also ask tech support if they don't *support* scripts, ...
    (perl.beginners)
  • Re: modify sIDHistory
    ... try using the clone principal scripts from MS. (reskit or supp. ... > selected sidHistory and pasted the octet value of the user sid that I ... >> Public Sub ClonePrincipal(ByVal srcDC As String, ByVal srcDom As String, ...
    (microsoft.public.windows.server.active_directory)
  • Re: Interesting webserver intrusion (apache 1.3.31, mod_ssl 2.8.18, php 4.3.7)
    ... since they managed to execute commands via Apache. ... and 30 minutes before one of the scripts was uploaded. ... Sounds like one of the many PHP scripts is exploitable. ... this means that the exploit would allow the attacker to run ...
    (Incidents)
  • RE: Adding Groups on the basis of text in a VBScript
    ... Firstly we need to read multiple text files, which are acting as logon ... If the Datalink string is present the filename of the file being read should ... > WScript.Echo " You are a member of Domain Admins " ... >> scripts which utilize vbscript. ...
    (microsoft.public.windows.server.scripting)