473,794 Members | 2,880 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

eregi

Hi, (new to group and a php novice)

I'm editing some files using exapmles for reference.

Expand|Select|Wrap|Line Numbers
  1. (1) // if (!eregi("admin.php", $_SERVER['SCRIPT_NAME'])) { die ("Access
  2. Denied"); }
  3. (2) if ( !defined('ADMIN_FILE') ){ die("Access Denied"); }
  4.  
Why is (1) always TRUE?
Why does (2) do what (1) doesn't?
Should all instances of (1) be replaced with (2)?

Thanks for any advice.
--
fade2gray
(Invalid return address, please reply to newsgroup).
Jun 2 '07 #1
1 2030
At Sat, 02 Jun 2007 10:58:13 +0100, fade2gray let h(is|er) monkeys type:
Hi, (new to group and a php novice)

I'm editing some files using exapmles for reference.

Expand|Select|Wrap|Line Numbers
  1. (1) // if (!eregi("admin.php", $_SERVER['SCRIPT_NAME'])) { die ("Access
  2. Denied"); }
  3. (2) if ( !defined('ADMIN_FILE') ){ die("Access Denied"); }
  4.  

Why is (1) always TRUE?
Why does (2) do what (1) doesn't?
Should all instances of (1) be replaced with (2)?

Thanks for any advice.
Is (1) TRUE or eregi("admin.ph p", $_SERVER['SCRIPT_NAME'])) ???
Don't use ereg and eregi. Deprecated in 5, will be removed in 6. If you
need regex, use the preg_match() family.
What's in $_SERVER['SCRIPT_NAME']?
Personally I wouldn't use regex functions when regular string functions
can do the job. Much faster.

@ (2): entirely different test, unrelated to (1).

Which one's the better option depends entirely on what your program looks
like.

Sh.

--
Schraalhans Keukenmeester - sc*********@the .Spamtrapexampl e.nl
[Remove the lowercase part of Spamtrap to send me a message]

"strcmp('apples ','oranges') < 0"

Jun 2 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2383
by: fartsniff | last post by:
Hello all. I am starting to work on a URL "cleaner" of sorts. The code below is only checking for a few simple entries on the URL, but for some reason it is not replacing them with "" when found. $qs and $clean_qs produce the same results. Also, can someone who is fluent with regex stuff take a look at my eregi expressions ? Im not sure if this is the most efficient way of
1
1844
by: Ralph Freshour | last post by:
Can someone please tell me why this function always evaluates to true regardless of what I enter? Thanks... if (!eregi ("A-Za-z", $frm_member_name)) { // invalid characters $php_login_status = "not ok";
5
6918
by: Jane Doe | last post by:
Hi I took a quick look in the archives, but didn't find an answer to this one. I'd like to display a list of HTML files in a directory, showing the author's name between brackets after the file name. I can successfully extract the TITLE section, but no luck with the AUTHOR part. Any idea why?
1
3802
by: NimP | last post by:
Hi,. I'm trying to detect any links that are contained within an html page using eregi pattern matching. I was wondering if there are any pattern matching geniuses out there who could write a pattern that merges all the different manners in which a link could be wriiten, Current patterns I can think of include: <a href=x.com> no spaces betwen href, equals and url, no quotation marks around url <a href =x.com> space between href and...
5
2763
by: george | last post by:
(driving me nuts) Hi there. I wonder if anyone can help? I'm including a page from Google in search.php, passing some parameters. So far so good. Then I'm asking to look through that Google page for a text match, and return true or false. eregi returns false whatever the case, similar_text returns true whatever the case. Can someone sort me out - oops, HELP me out ?
2
4034
by: Frank | last post by:
I'm having trouble detecting whitespaces in strings. Set up this test: echo "<br>example 1:".intval(eregi("^\s","teststring")); echo "<br>example 2:".intval(eregi("^\s","test string")); Both resulting in 0 (zero) also tried and without result
25
6510
by: Dynamo | last post by:
Hi The following script was taken from John Coggeshall's (PHP consultant) in his article on Zends site at http://www.zend.com/zend/spotlight/ev12apr.php // Get the email address to validate $email = $_POST // Use John Coggeshalls script to validate the email address if(!eregi("^+(\.+)*@+(\.+)*(\.{2,3})$", $email) { echo "The e-mail was not valid";
1
1726
by: news | last post by:
God, I have read every comment in php.net eregi and Google searched, and I have tried so many different attempts...this is the closest I've gotten to verify a variable contains only: alphanumerics, spaces, underscore, hyphen, period, apostrophe if(eregi("^+$", $value)) { return true; }
4
2463
by: Nel | last post by:
Hi all, I am struggling with understanding a small eregi problem in php4. My code: <?PHP $htmlsource = '<img src="pics/hotdog.gif"> text text <img src="pics/silly%20sausage.gif"> '; eregi('(=")(pics/)(+...)(")',$htmlsource,$imagesintext); ?>
0
9672
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10213
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10163
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6779
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.