Comparing strings... need advice. :)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I am looking for the most secure/efficient way to compare these two strings:

/folder1/folder2/folder3/folder4/
/folder1/folder2/folder3/folder4/file.php

Basically I am trying to setup as many security features as possible for a simplistic (home-grown/hand-coded) CMS...

This appears to work:

$haystack = '/folder1/folder2/folder3/folder4/someFileName.php';
$needle = '/folder1/folder2/folder3/folder4/';
if(substr_count($haystack, $needle) === 1) echo "yea";

Before making changes to "someFileName.php" I want to make sure it is within the allowed path ($needle).

I would appreciate any advice. Even RTFM is cool.  :D

Many TIA,
Cheers,
Micky

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux