Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. filter_var FILTER_VALIDATE_URL
  2. I had a toshiba satellite for a while. I liked it, except for the glossy finish that left a ton of finger prints all over it. But that's just superficial. As far as performance, I enjoyed it. Too bad my kids broke it :*(
  3. preg_match expects the pattern argument to be formatted as such: "[delimiter][pattern][delimiter][modifier]" The delimiter separates the pattern from any modifiers you might have. It can be pretty much any non-alphanumeric character you want, as long as you remember to escape it if you use it as part of your actual pattern. So for instance, you need to do "~pattern~modifier" or "/pattern/modifier" But you don't actually have any modifiers in there so You just need to do like "~pattern~" So the reason you got that specific error is that you can use [ and ] as the pattern delimiter, so it's seeing your [ at the start of your pattern, then seeing the ] later on and thinking it's the end of your pattern and then thinks what comes next is are modifiers and since the next thing is a + and that's not a valid modifier, it throws an error.
  4. You need to escape a lot of that stuff, as they have special meaning in regex. For example, you have [A-Za-z0-9_] which you know is a character class to specify a range of characters. Well [..] encloses and specifies that it is a character class. But then you turn around and try to use [] to match a literal []...how does the engine know you now want to use those brackets to match literal brackets? Only way for it to know is if you escape the characters \[\] You also have all kinds of stuff in there that just doesn't belong at all. I suggest you go back to reading about what the symbols in a regex pattern actually do. preg_match('/\w+\[\] = \w+/',$i) or if you wanted to capture separate the parts: preg_match('/(\w+\[\]) = (\w+)/',$i,$match)
  5. In your form where you refine search results, how is it setup? some dropdowns/text fields and you resubmit? If you just make your form method='get' instead of 'post' it will make the request to your action='...' as appended to the URL instead of as a post request.
  6. preg_match (regex) can help you out better than what you have now, as far as taking into consideration non-standardized formatting. Things like... - attribute order (ex: content=".." comes before property="..") - spacing between = signs inconsistent (ex: content = "..." vs. content="...") - use of single instead of double quotes (ex: content='...' vs. content="...") - differences in capitalization (ex: CONTENT="..." vs. content="...") - handling when there is no query string on the URL But what would be even better is if you use a DOM parser to parse html content.
  7. As a note, the e modifier basically does the equivalent of running eval on the replacement argument of preg_replace(). So if you use it, you have to have valid php syntax in that argument (treat it as php syntax). In general, if you find yourself in the position of needing to use the e modifier for preg_replace(), you should instead consider using preg_replace_callback.
  8. Pointing out the mistake is okay. But what do you mean by "without any consideration" ? If you are referring to tactfulness in pointing out the mistake, then again, it's a gray area. Examples: "Hey, you made a mistake" is okay. "Wow..I can't believe you would actually say that..." is probably okay. "Holy shit, if I was your boss, I'd fire you for code like that...wtf?" is probably okay, but don't expect to win friends. "You fucking retard, you should just do humanity a favor and die for uttering such crap" is...probably not okay. This is true, which is why I said my very first piece of advice is unless you're willing to stick to your guns, don't say anything at all. There's very little value in someone opting to be offended rather than listening. There's even less value when the "offender" decides to run away from it. I did just mention to stick to your guns, but there's also little to no value in trying to argue a point when it's obvious someone is more interested in salvaging their pride. If it becomes clear that the person isn't really interested in arguing the actual point, and that's all you are interested in doing, then sure, just walk away. But if you wanna call them on their b.s. then sure, go for it. I can't guarantee someone won't close the thread or something but I will say that some of us enjoy a good show and pull up a chair and some popcorn and will watch and lol for a bit, as long as it doesn't get too ugly. I know not everybody agrees with that PoV and for those who have the power to do so, it's within their power to stop it and they can. But as for me, I'm not really interested in policing people's behavior or enforcing my personal idea of what is "civil" to the extent that it is feasible not to do so. Flame wars happen for legitimate reasons, and I'm not gonna punish someone for having the sharper tongue, but I probably will smite someone who is being outright evil about it.
  9. We do promote pointing out inaccurate information. After all, this is primarily a learning site. Our goal is to help people learn something from their problems (and for we ourselves to learn something as well), not just solve stuff for them. My first advice is to not point something out unless you're willing to argue/debate about it, regardless of the issue or how tactful you are. This is especially important for things that are matters of opinion or otherwise subjective. As far as one's attitude in approaching it...it's a big gray area as far as how much or little "tactfulness" we allow. We don't feel we should have to police attitudes, nor do we really want to. Though there is always a limit, if you look around, you will see for yourself that some people have a certain bite that others may or may not like, that we do in fact allow. We generally err on the side of leniency even if you're a bit asshole about things - as long as your corrections/counter arguments are accurate/valid. But having said that, don't expect to win friends or popularity by being a dick about pointing out something wrong.
  10. If you can find an existing active and well supported smf mod that does that, we will consider adding it. Otherwise, I suggest you head to the smf community to ask for this sort of thing, as we aren't the ones who develop the forum software.
  11. What this board is for If you have some code you are wanting people to debug, or a website you are working on that you want people to 'beta test,' post the code/link here. The idea of this forum is that you have finished your code, and now you wish for people to test it for weak spots, logic problems, etc.. While you can of course expect feedback from your testers, if you need more help fixing your code, use the Help forums. This forum is for testing and testing feedback ONLY. This is NOT a "rate my script/site" forum. Please go to the critique forum for that. Try to give a good description of what your code is supposed to be doing. We can do little more than find syntax errors if we don't know what it's supposed to be doing. Your topic doesn't show? All new topics are moderated, meaning that they will not show up until a staff member approves it. Read the rules for posting in this forum and follow the directions. Some advice to be cautious Be very careful on what kind of info you post, especially when it comes to posting links to your site. Posts of this nature are often times aliases of "please try to hack my site and tell me if you do, and how, so I can fix it." We cannot and will not be held liable for any kind of damage or loss that results from you posting any of your stuff here (or anywhere else on the site, for that matter). Not everybody out there is honest. Someone out there may read your post, go to your script, find a security hole and exploit it without telling you, all the while giving you the thumbs up. Rules Regarding "Exploit Scanners" Use of exploit scanners can be an effective way to discover exploits on a website, so we have no intention of banning posting scanner results. But these scanners can also return bogus results. Secondly: Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime. As of now, posting scanner results is only allowed under the following conditions: 1) You must share the name and how to get the scanner 2) You absolutely MUST explain every item in the result (why is this a risk, not just because the scanner says so) As with all forum rules, ignoring these could lead to moderation action. Ignorance of these rules is not a defense. Thank you for your cooperation.
  12. The problem is on line 42
  13. Make use of a version control system with a repository such as svn or git. Make use of a project tracker like redmine. Between these 2 things, you will be able to assign tasks to people, see who is actually contributing what, etc... also for communication, make use of a private forum or irc channel or invest in webex or adobe connect, where everybody can call in to one place and you can broadcast screensharing to whole group, etc...
  14. \n works too. Yeah but it can get messy real quick so it's generally better to stick with $n
  15. ltrim using the 2nd argument would be better, as it will remove it only if it exists. $string = ltrim($string,'/');
  16. click on your name to view your profile, left nav you will see Profile Info > Show Posts http://www.phpfreaks.com/forums/index.php?action=profile;area=showposts;u=103834
  17. $array2string = "\n" . implode("\n", $future_date); // convert array data to string.
  18. $string = preg_replace('~(?<=[0-9]) (?=[0-9])~','',$string); $string = preg_replace('~(?!.*respective)(?<=[0-9]|,) (?=[0-9]|,)~i','',$string);
  19. $text = preg_replace('~(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.\~#?&//=]+)~i', '<a href="' . $linkprefix . '$1">$1</a>', $text); $text = preg_replace('~([\s()\[\{\}])(www.[-a-zA-Z0-9@:%_\+.\~#?&//=]+)~i', '$1<a href="' . $linkprefix . 'http://$2">$2</a>', $text); $text = preg_replace('~([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})~i', '<a href="mailto:$1">$1</a>', $text); Basically the things to note for converting php's posix regex functions to pcre regex are: - The pcre functions need a starting/ending delimiter around the pattern, because pattern modifiers come after the ending delimiter. The delimiter can be pretty much any non-alphanumeric character, as long as you remember to escape the character you choose, if you need to use that character within the pattern. Example: "~pattern~modifier" - The posix functions (ereg) have two separate functions for making case-insensitive (ereg vs. eregi) whereas the pcre functions use the i modifier - posix regex has some "shortcut" character classes like :space: or :alnum: don't work, but do have pcre counterparts. Like \s is for :space: and \w is for :alnum: - The captured groups for replacements are represented by $n instead of \\n
  20. Are you sure you are modifying/uploading to the right place?
  21. You can use cURL to grab the output content of a webpage, yes. But you should first try using file_get_contents as that's a lot easier to use. But either method returns the output content of the page, so you'll have to actually parse the page and grab specific content. For that, you would use regex or a DOM parser
  22. $text = preg_replace('~</?a[^>]*>|(ht|f)tps?:[^ ]*~i','',$text);
  23. $subject = preg_replace('~(<span class="SomeClass">)\s*<span>([0-9]+)</span>~is','$1<input type="text" name="score" value="$2" />',$subject); This could probably stand to be more flexible if you gave more details about the content that is matching...
  24. lol I remember learning pascal in highschool. It was the "introductory" language for computer programming at my highschool. Well, there was this "computer math" class that taught QBasic, but that didn't really count. The actual "computer programming" class started with pascal, then moved on to C and then assembly. But that was like 20 years ago...I'm kinda surprised they still start there...but on the other hand, it is kinda a watered down version of C, maybe it is still okay to start there.../shrugs
  25. post with a .txt extension
×
×
  • 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.