-
101 Claimed SEO Secrets A Shoddy SEO Specialist Probably Doesn’t Want You To Start Questioning Them About!
You ought to proof-read it. It contains quite a number of errors in grammar and punctuation.
-
Problem with get_file_contents
I can't do that. The PHP that creates the log is not really editable by me because that's how it has been set up. The data that it contains is not solely for the purpose of banning. Besides, there's no DB. @ ElanMan. Thanks for your example. I'll try that.
-
Problem with get_file_contents
Yes, it's one entry per line, but it comprises the date of entry, the IP, and the referrer, logged by PHP elsewhere. I just want to check and match the IPs from it.
-
Problem with get_file_contents
What's the difference? I thought that strings were the plain text contents of arrays, like array('red','blue','green').
-
Problem with get_file_contents
I can't get the "get_file_contents" function to work for me. Probably something fairly basic but I haven't used this function before. Example code below: <?php // check IP against ban list //$banlist = array('12.34.56.789'); <-- this works when uncommented $banlist = file_get_contents('/logs/ip-log.txt'); $ip = $_SERVER['REMOTE_ADDR']; foreach($banlist as $banned) if (strpos($ip, $banned) !== false) { die('Your IP address is on our ban list.'); } ?> Writing the array directly results in a match, but calling the file as a string does not, and I can't work out why. By the way: this is intended to be used because the usual .htaccess approach is not practical in this case. I would normally opt for that.
-
Recommended books for PHP beginner?
A few more suggestions for you. PHP Solutions by David Powers. It's an easily usable and practical book. Then try PHP Object-orientated Solutions by the same author. I haven't read that yet, but it was recommended to me, so I intend to. I like O'Reilly's PHP Cookbook for dipping in and grabbing solutions as I get more accustomed to it and I know (or find out) what I need to get the examples to work for me. For a more educational approach, O'Reilly's Learn PHP and MySQL is worth reading, although it's perhaps a little bit too academic in style (ie. a bit boring!). Wicked Cool PHP is probably worth having as well, later on: it's not the most thorough book, but it has some examples that I found useful.
-
List with multiple background images
This is not related to your query, but I could not help noticing it. You might run into problems sooner or later if you wrap block-level elements inside inline elements. Even if all appears well, it's still very poor mark up and does no good for accessibility (just listen to LIs and headings all mixed up). If you are doing it primarily for the sake of expanding the anchors, I suggest that you wrap those anchors inside the headings, use divisions instead of list items, and expand the links with jQuery (try biggerlink), a la progressive enhancement. Anchors are inline elements.
-
Performing a function on all post data from a form
Yes, it did come across as a bit offensive. I didn't just jump into PHP without first reading books, website tutorials, and parts of the manual. But what immediately makes perfect sense to some will be a difficult concept for others. My knowledge of it has been slowly getting there over the past year, on and off when I have time for it. My specialisms are IA and UX rather than server-side. No worries, though.
-
Performing a function on all post data from a form
@ Rallport Please elaborate on what your last comment is supposed to mean.
-
Performing a function on all post data from a form
Oh. Did not know that... I hate PHP!
-
Performing a function on all post data from a form
@ Jay How would I get all the post variables into an array? I haven't done that before.
-
Performing a function on all post data from a form
Hmmmm.... OK. Tell me a bit more about this index error!
-
Performing a function on all post data from a form
@ Nathan That looks good. Thanks. I'll try it when I can. @ webdesigner93 Well, we can agree to differ about what constitutes bloat but I definitely don't want to write out 15 isset statements per your example if I can loop through all data in one function instead and avoid too much repetition. But thanks for your input anyway: it is always appreciated.
-
Performing a function on all post data from a form
Thanks for the reply, but I'm not going to run a function across 15 post variables separately. That's exactly the kind of code bloat that I want to avoid if at all possible. That's the point of my question, basically: anything that streamlines the process is welcome.
-
Performing a function on all post data from a form
If I wanted to run a particular function or other bit of code, such as stripslashes used here, on all data coming in from a form before I proceed to check individual variables in the usual way, would this be a good way of doing it? function get($key, $source=$_POST) ( $item = $source[$key]; return stripslashes($item); } Is this code correct? Safe? Reliable? Or not. I have not had a chance to test it yet.