Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. This is pretty much what I do, as well. At face value I can see why people would do that, especially in a loosely typed language like php. But yeah...nonetheless, I too find it annoying.
  2. Hello Shadowing, It looks like you want to 1) Match for a standard American telephone number 2) Reject certain phone numbers because they are fake. #1 is fairly easy, especially if you take the approach of not caring what the actual format is (different people use different formats; some people wrap the area code in parens, some people use hyphens while others use dots, etc...) by just stripping out anything that is not a number and then counting for 10 digits. #2 on the other hand is pretty arbitrary. The only realistic thing you can do is either a) have a whitelist of all valid U.S. phone numbers. This is not feasible because it is a very large, ever changing list. Or b) make a blacklist of the more common bullshit numbers people try to use. This is by far more feasible, but it will never be perfect, and there's no way to really make anything perfect, short of attempting option "a". One possible compromise would be to make a whitelist of all currently known area codes. The list isn't all *that* long, but more importantly, even though the area code list can change...it is not something that changes very often. You can even see from the link a bunch that aren't actually in use yet but are reserved or up and coming. Yeah..still kinda a pita to maintain but you shouldn't have to check very often. So anyways, I separated area code and local number black lists into two separate arrays in code below so it will be easier to go that route if you wanna. But also since it is separated, will have the added bonus of catching numbers like '1110000000'. But as far as the local number blacklist...TBH I would not recommend adding anything else to that list. For example, one of your "baddie" phone numbers "6661234" ...this is more than likely a valid number. I know for a fact that "666" is a valid local prefix in some areas, and I'm almost 100% positive most phone companies just randomly pick the last 4 digits or pick the "next available increment" when assigning you a phone number. So anyways, with all that in mind, here is my suggested solution (this is example code to get the concept...you may wanna organize this how you see fit, according to whatever other code you have...for example, make the blacklist some object property etc...): function validatePhoneNumber ($number) { // black list of common fake area codes $blacklist['a'] = array('000','111','222','333','444', '555','666','777','888','999', '123','098','987'); // black list of common fake local numbers $blacklist['l'] = array('0000000','1111111','2222222','3333333','4444444', '5555555','6666666','7777777','8888888','9999999', '4567890','7654321','1234567','6543210'); // strip everything but the numbers $number = preg_replace("~[^0-9]~","",$number); // number is bad if not 10 digits if ( strlen($number)!=10 ) return false; $a = substr($number,0,3); $l = substr($number,-7); // number is bad if area code in blacklist if ( in_array($a,$blacklist['a']) ) return false; // number is bad if local number in blacklist if ( in_array($l,$blacklist['l']) ) return false; // number is good return true; }
  3. We cannot really enforce sticky orders, it's not how SMF works. Stickies are ordered same way as non-stickied: most recent response response (last post descending), and you can reorder by clicking on column headers. There is no way to say "no matter what, make this sticky #1". But you make a fair enough point about adding to it, so I unlocked it. Regex for the most part hasn't really changed though, so even if the resources are *old*, if the links still work (not gonna lie, haven't checked), they should still be viable. But again, you make a fair point about being able to contribute new links/tuts, so I unlocked the thread and merged your thread with it. My guess is it was probably a more popular topic back then and so someone decided to sticky it. Or...someone could have been particularly proud of the solution and happened to have powers to sticky...who knows. In any case, I will agree that it doesn't currently warrant being stickied. Thread unlocked. Gonna have to disagree on this one. I think I'm going to have to dust off my copy and recheck, but I coulda swore it did in fact cover \K...and pretty much everything under the sun. Sure, there have been *some* changes to regex since 2006, but truth is, despite its age, this book remains king of "learn absolutely everything you ever wanted to know about regex". I challenge you to find a more thorough, more recent, etc.. book. Even for the changes that have been made since then...they aren't for beginners or even intermediates anyways. But I will agree it doesn't deserve a separate sticky from a "resources" thread, so I unstickied it.
  4. This topic has been moved to FAQ/Code Snippet Repository. http://www.phpfreaks.com/forums/index.php?topic=122857.0
  5. sidenote @ ragax: you use commas for pattern delimiters? eww ... that makes for unnecessary escaping should you need to for instance do [0-9]{1,10}
  6. You are right, regex cannot tell whether the date is valid or not, and since it cannot do that, there's no point in doing even most of what you did, because you will have to validate it by some other means anyways. So all you really *need* is something like this: ~[0-9]+/[0-9]+/[0-9]+~
  7. Yes, you can request a username change. There is a sticky in this forum for making requests.
  8. Then delete my account, or just edit the code out in the reported threads. We don't delete accounts either. Again I would ask you to read the rules. But as a show of good will, I did edit out a url and some db info in one of your posts (we don't really have to do even that, btw). But yeah...we don't delete content...we are here to provide help and resource for others. It's anti-productive to go deleting stuff...especially stuff marked as solved...on that note...you really wanna repay the free help you got by asking for it to be removed? that doesn't sound very grateful...
  9. p.s. - I see 2 entries in the "report to mod" section by you, both less than an hour ago (one of them was actually timestamped after this this thread...)...even if it were something we do, less than an hour by no means constitutes being ignored.
  10. We do not remove posted content, please read the rules for further details.
  11. .josh

    Regex

    this question has been asked a lot of times, please try searching the regex forum.
  12. The non-regex approach: $string='http://maps.google.com/maps?q=46.055603,14.507732&num=1&t=m&z=12'; $parts = parse_url($string); parse_str($parts['query'],$params); $q = explode(',',$params['q']);
  13. $data does not exist within your getText() function. You either need to pass it as an argument or declare it as a globally scoped variable within your function.
  14. You just don't know how to use it right. I know, because I've watched you use it no i'm talking about the actual web developer addon, not the built-in web developer tools stuff. But yes I do readily admit I'm not pro at the built-in chrome developer tools quite yet...It wasn't all *that* long ago since I finally gave in to you bugging me about using chrome more!
  15. You just don't know how to use it right. I know, because I've watched you use it no i'm talking about the actual web developer addon, not the built-in web developer tools stuff.
  16. main thing that keeps me using firefox is a couple of web analytics addons that make it easier to do my job, that are FF specific. Also, the chrome version of the web developer addon isn't as robust as FF's
  17. "Cloud computing" from an average user's perspective (not a developer or company offering a service) is really more about having less actual hardware and software physically in front of them, being able to access their personal stuff (email, games, whatever) from any device anywhere, not just sitting in front of their computer at home. Rewind the clock a couple decades when a lot of "computers" at businesses were really just dummy terminals hooked up to a single computer... that's IMO kind of where I see the future going...going back to the principles of the past, only better technology involved.
  18. .josh

    Adobe Shadow

    Looks pretty impressive, could have come in handy for a few projects I've done in the past...
  19. Meh, I still use Firefox 100%. Chrome is getting there, but the addons for Firefox just make it unbeatable. I'm in the same boat...I really wanna switch to Chrome but the addons keep me on FireFox
  20. aaah I guess chrome doesn't have it. I did find it in FireFox...pretty cool
  21. well i found the rightclick > inspect element but I seemed to have lost my "3d" ...
  22. .josh

    Wow.

    Did they do it? who knows. Far fetched? Certainly not. Big companies and institutions are not shortsighted like the average retarded monkey teenagers who can't see much farther into the future than the time it takes to microwave a hotpocket. It's not even a particularly complex plan, either. The fact that people don't give the people who run this world anywhere near as much credit or caution as they should...
  23. A "CMS Dashboard" is like any other web page in principle. The basic GA implementation is to slap some javascript on a page and it will report to GA a page view, along with some other "top level" stuff like what browser was used, etc... GA does provide custom coding options (populating certain GA object properties and/or calling certain object methods) that let you record events on a page. What those events are and how you choose to implement the code for it is up to you.
  24. what realm/faction do you play?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.