Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Ade

Members
  • Joined

  • Last visited

  1. You ought to proof-read it. It contains quite a number of errors in grammar and punctuation.
  2. 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.
  3. 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.
  4. What's the difference? I thought that strings were the plain text contents of arrays, like array('red','blue','green').
  5. 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.
  6. 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.
  7. 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.
  8. 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.
  9. @ Rallport Please elaborate on what your last comment is supposed to mean.
  10. Oh. Did not know that... I hate PHP!
  11. @ Jay How would I get all the post variables into an array? I haven't done that before.
  12. Hmmmm.... OK. Tell me a bit more about this index error!
  13. @ 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.
  14. 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.
  15. 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.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.