Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. well he said he tried a urlencoded & and it didn't work. I suspect he's decoding it before parsing it.
  2. This topic has been moved to Third Party PHP Scripts. http://www.phpfreaks.com/forums/index.php?topic=351619.0
  3. would help if you show a full example URL and the code you're currently using.
  4. Other than unnecessarily escaping your forward slashes (they mean nothing special in regex, the only time you need to escape them is if you are using them as pattern delimiter, which you are not (you are using "~")), the regex works fine. example: $links = array( "http://www.example.com/news/somearticle1", "http://www.example.com/news/somearticle2/2", "http://www.example.com/news/somearticle3/3", "http://www.example.com/news/somearticle4/44", ); foreach ($links as &$link) { $link = preg_replace('~/?\d*/?$~', '', $link); } print_r($links); output: Array ( [0] => http://www.example.com/news/somearticle [1] => http://www.example.com/news/somearticle2 [2] => http://www.example.com/news/somearticle3 [3] => http://www.example.com/news/somearticle4 ) So your problem is somewhere else in your code. Maybe you are preg_replacing the wrong variable or assigning results to wrong variable (like a typo or something). Maybe later on you use the wrong variable to add new number on. Who knows, I'm just throwing out random guesses since you have no other code posted.
  5. And what about the other ~185 (+/- a few depending on who you ask) independent countries? @TLG: LOL@pic
  6. USA of course. We're holding aliens hostage in area 51, duh.
  7. You asked for a push in the right direction and I explained what more you need to do. If you and your friend "cobbled" that together then you should have enough understanding to read what I wrote and apply it. Was there something in particular you didn't understand in my response? Do you need some clarification on a particular point in my reply? No offense, but I'm not sure what more I can do for you, short of writing the code for you...responding something vague like "I need help" when I gave you the help you asked for to me means what you're *really* asking for is for me to write your code for you, which I'm not going to do, because: 1) This smells like homework. What is the point in taking a class in something if you're just going to c/p and not actually learn anything 2) I'm not here to write your code for you. Unless you wanna pay me, then I will write it for you. This sort of conflicts with the first point but I'm not your dad; if you wanna waste your time in class not learning anything then that's on you.
  8. non-regex on-liner alternative: $string = implode("/",array_slice(explode("/",$string,4),0,3));
  9. This part needs to be modified: document.write(wordsArray[i]+ "<br />") // Output each word to the document and add a line break after each one if(wordsArray[i].indexOf("a") > -1) // Check to see if the word contains a letter a { aWordCount +=1; // If the word contains a letter a, add one to the count } You need to remove the linebreak tag from your document.write so that you can add the letter count next to the word. Or better yet, move your document.write below the code that determines how many instances of "a" are in it, so that you can document.write() everything in one go. Then inside your condition.. You need to either loop through each letter in wordsArray and increment a variable (example: numLetter) each time it matches the letter "a", or use a .match() regex instead of .indexOf() to match for it and count the returned results and put it into numLetter. Also note that you are currently doing a case-sensitive search, so for instance, it will not count the "A" in "Andy". Since you probably want it to be case-insensitive, you will need to first wordsArray.toLowercase() or use the i modifier if you opt for the regex approach. Finally, you will need to actually document.write numLetter after this code (and then add the linebreak tag) so that it will show the result next to the word.
  10. Because I don't know how you are handling the keyword(s) to look for, and how you are looking to handle results, you may need to tweak this to suit your needs...but here is a function to get you started, based on the content you provided. /** * get_ids_by_keyword returns a list of thread IDs based off given keywords * @param string $content is the content to scrape * @param mixed $keyWords is a string (for a single keyword) or an array of * key words to search. * @param bool $pMatch is a flag to determine whether or not to match full * or partial words. Default is full match * @param bool $cs is a flag to determine whether or not search should * be case-sensitive. Default is case-insensitive * return mixed If results found, a multi-dim associative array is returned, * following this format: keyword => (id => instances). * NOTE: if $cs==false, keyword is returned lowercased. * If no keywords were matched, return false. */ function get_ids_by_keyword ($content, $keyWords, $pMatch = false, $cs = false) { if (!is_array($keyWords)) $keyWords = array($keyWords); $keyWords = implode('|', $keyWords); $results = array(); $b = ($pMatch == false) ? '\b' : ''; $c = ($cs == false) ? 'i' : ''; preg_match_all('~<span class="(?:comment)?postername">.*?<span id="no(?:thread|rep)(\d+)">.*?<blockquote>(.*?)</blockquote>~s',$content,$posts); foreach ($posts[2] as $i => $post) { if ( preg_match_all('~'.$b.'('.$keyWords.')'.$b.'~'.$c, $post, $keyWordFound) ) { foreach ($keyWordFound[1] as $kwf) { if ($c) $kwf = strtolower($kwf); $cid = $posts[1][$i]; $results[$kwf][$cid] = ( isset($results[$kwf][$cid]) ) ? ++$results[$kwf][$cid] : 1; } } } return ( count($results)>0 ) ? $results : false; } // end get_ids_by_keyword Basically you call the function passing the content to be scraped, and the keyword(s) you want to look for. It will then return a multi-dim associative array of the keyword(s) found, the post id of the post (including replies to posts) the keyword was found in, and how many instances of the keyword was found in the post. By default the function performs a case-insenstive full word search. There are optional arguments to make it case-sensitive and also return match for partial matches. Example 1: case in-sensitive full word search of 4 words within content of OP example. Notice how "boring" is not returned because the only instance similar within the content is "boringly" but this is flagged as a full word match. $keyWords = array('a','problem','boring','let'); print_r(get_ids_by_keyword($content, $keyWords)); Output Array ( [a] => Array ( [373301167] => 2 [373301334] => 1 ) [problem] => Array ( [373301167] => 1 [373301334] => 1 ) [let] => Array ( [373300183] => 1 ) ) Example 2: case in-sensitive partial word search of same 4 words. Now "boring" is matched because we flag it for partial matches. Also we get a lot of matches on "a" because it found a lot of them within words. $keyWords = array('a','problem','boring','let'); print_r(get_ids_by_keyword($content, $keyWords, true)); Output Array ( [a] => Array ( [373301167] => 9 [373301257] => 1 [373301298] => 3 [373301334] => 6 [373300183] => 2 [373301286] => 1 [373301297] => 1 ) [problem] => Array ( [373301167] => 1 [373301334] => 1 ) [let] => Array ( [373300183] => 1 ) [boring] => Array ( [373300183] => 1 ) ) Example 2: case sensitive partial word search. The first keyword is now capitalized. $keyWords = array('A','problem','boring','let'); print_r(get_ids_by_keyword($content, $keyWords, false, true)); Output: Array ( [problem] => Array ( [373301167] => 1 [373301334] => 1 ) )
  11. @shamuraq a) the most immediate reason your preg_replace didn't work was because you have spaces between the part of your pattern that match for the numbers vs. the /, so it expects for instance "1 / 2" not "1/2". b) supposing your string does have a fraction with spaces in it like "1 / 2" your replacement basically just swaps out the "/" for a "|"...which..why? You said you wanted to mark it up with some html strong... @QuickOldCar: couple things about your regex.. a) since you are matching for a / it would be cleaner to pick a different pattern delimiter so you don't have to escape it in the pattern. b) [..] is a character class. It means to match any one thing inside the bracket. It is good for if you want to match for more than 1 thing like something in a range. For example [a-z0-9] will match any 1 letter or number. Since you are only matching for one thing (a "/"), while it *technically* works, there's no need for a character class. c) Your pattern will only match single-digit fractions. For instance, it will not match 1/10 (it will only match 1/1 part of it). @shamuraq: Here is a pattern for you: $pattern = '~([0-9]+\s?+/\s?[0-9]+)~'; This will capture the entire fraction $1 or \1 for your $replacement variable. This pattern will allow for both "1/2" and "1 / 2". If you only want it to match if no spaces, remove the two "\s?" parts.
  12. Well php is a loosely (weak) typed language...
  13. Installing WordPress isn't all *that* hard if you know what you're doing, and everything you listed I believe is already built-into it or has extensions for it, even multiple authors/blogs (WP used to have a separate multi-author/blog system at mu.wordpress.org but they have since combined it all into one system). It does take a bit more skill to customize it in the way of looks though..if you're looking to do a fully custom implementation. There are a ton of out-of-the-box skins/themes available for free or cheap if you're willing to settle for that though. But is it worth paying someone else $500 for? I know a lot of people who offer WP installs/customizations as part of their services (I know some people who ONLY offer that as a service) and they generally charge $300-$500 to do it, depending on how much customization you want. But I've also seen a lot of people charge a hell of a lot more...usually larger companies will charge more because they deal with larger clients. IMO it is worth the price if you don't want to take the time to learn it and do it yourself. Again, it's not terribly hard to do it if you know what you're doing, but it could quickly become really frustrating if other things prevent you from having a smooth install, like having to tweak/fix other server settings that are otherwise preventing it from going smoothly. But if you are interested in learning web dev stuff then it would probably be better for you to do it yourself; it's as good as any other place to get your feet wet. If you do opt to pay for someone to do it, I would find out if they are offer any kind of training to walk you through the interface, see where/how to do the stuff you want, etc... this may or may not be included in that price, and if you don't opt for that service, you may find yourself spending a fair chunk of time sorting that out, as well.
  14. You can work yourself up to at least Guru membergroup status and be able to post tutorials yourself. Or you can submit to can submit the tutorial to us for review.
  15. This thread is not meant to promote using frameworks instead of using core javascript for everything. That is just silly. Frameworks are not alternative languages, they are tools built on existing languages to make certain things easier. This thread is about using a framework for AJAX specifically.
  16. 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.
  17. ...and you are NOT using a framework like jQuery or Prototype, think long and hard to come up with a very good reason why you are not! In all my years of coding, the only valid reason I have ever seen for not using one of these tools, is because someone is trying to learn it the old fashioned way (but not necessarily actually build websites with it). Or...someone is trying to build their own framework. That's it! IMO there has been no other reason worthy enough to warrant not using jQuery or the like! "It will bloat my website, increase page load time, blahblah" is not a good enough reason! These frameworks are compacted and browsers will cache them! So if you post an AJAX question here and your code and/or question does not involve the use of an existing framework like jQuery, then be prepared for you first response to be something along the lines of "Why aren't you using a framework?" Seriously. It is super easy. Way easier than that code you're trying to post. Save yourself the headache. Get jQuery or similar. DO IT.
  18. Also, since we probably won't be jumping in individually welcoming every single person comes by, here's your generic welcome message: Greetings, ___________ ! Thank you for joining the board! Feel free to ask any question, but please don't be stupid about it. Make an effort to pick the right forum, make an effort to be detailed about your question, make an effort to read relevant stickies/rules, and we'll make an effort to help you. .CV
  19. http://www.phpfreaks.com/tutorial/php-basic-database-handling
  20. "level system" is pretty ambiguous... care to be more specific?
  21. http://www.phpfreaks.com/tutorial/php-add-text-to-image
  22. GENERAL RULES AND GUIDELINES FOR POSTING This forum is not meant to be a formal freelance service system. It is available for those who wish to seek out services or work from other people, as a courtesy to the members of the phpfreaks community. phpfreaks.com does not specialize in freelance services. This forum is an informal mechanism, as a courtesy to the community. We have no formal mechanism in place (like escrow) to guarantee payment, refund, work done, etc... phpfreaks.com shall not be held responsible for any losses you incur. we have never and continue to not act as any kind of mediator or verification/compensation source for people/organizations who use those forums. We will not be held responsible/liable for any damages, loss, etc. that occur from use of those forums. If you hire someone and they rip you off, don't come crying to us. If someone hires you and they rip you off, don't come crying to us. Those forums are a convenience. If you want something more official that offers guarantees, go to a real freelance site! If you have any questions regarding the freelance forum, feel free to ask them here. RULES: WHERE TO POST:If you want to offer your services, post in the Service Offerings sub-forum.If you want to offer a job or position of employment, post in the Job Offerings sub-forum. DO NOT post your 'resume' in job posting threads. You must directly contact the person you wish to reply to. The only reason replies are allowed is to ask for clarification/details about the job. Failure to adhere to this rule will result in all kinds of things, like you getting banned, or us disallowing replies. DO NOT make more than one thread offering your services. You can edit/reply to your thread to reflect additions/changes. DO NOT post advertisements to other sites offering freelance system services. For example, rentacoder.com, odesk.com, etc.. we have no partiality for or against those sites, but posts such as those are regarded as advertisement, which is against our main site rules. We fully acknowledge that this freelance system is limited, but we aren't here to provide free advertising for other places. If you prefer to do actual business through one of those sites, please specify in direct contacts with the person. You are allowed, as a freelancer or freelance company, to post a link to your personal portfolio/company to those sites, or a site that you own. But general promotions to those other sites are not allowed. GUIDELINES: When posting in the freelancing forum it's important that you provide a way for users to contact you. They will not be able to reply to your topics so they need a way to contact you privately. This can be using PMs, emails, any type of instant messaging service (MSN, Gtalk, AIM, Jabber, etc.) or however you see fit.The more specific you are about your skills, previous experience(s), availability, rates, etc.. the better your chances of getting serious inquiries. Posting vague "I'm available for anything and everything" might get more inquiries on average, but there's a good chance that it will come to nothing, based on any number of things that you could have posted here in the first place. Better to receive 10 emails from people who have some idea of your qualifications/terms, than 100 emails that don't.Be honest about your skills. All day long we see people posting about how they jumped on a job and bit off more than they could chew. They tell the client they can do everything they need and more, promise them the moon, and then promptly crap their pants about 5 minutes into it. Don't be that person! Some people get lucky and figure it out. Some people get lucky and get help that figures it out. Most people end up having to give up the project. Which leads us to....Wasting people's time and money. You waste the client's time. You waste your own time. That bad rep will more than likely come back to haunt you. All day long we get people trying to get us to delete their posts because they don't want their skeletons to come out of the closet (no we won't hide them for you). So be smart! Do the simplest easiest thing to avoid all this headache: be truthful about your skills. If you feel that being truthful will limit your potential clients, then get off your bum and hit the books. You can't seriously be in the business of trying to con people, are you?Be very clear about what you are doing. Some clients know your job, and are just looking for extra set of hands. Most do not, and therefore seek someone who does. Therefore, if you want to avoid headaches, it is your responsibility to be very clear about what it is you're going to do. What you're willing to do. What kind of support you offer after the fact, etc... on that note..Be up front and thorough about your prices. Take a look at the situation. Quote a price for it. Quote prices for things that might come up later. The more you have to go back later saying that xyz was unforseen or xyz wasn't part of the deal, regardless of whether or not you are in the right, the more you are going to come off as shady, to the client. It's like when you take your car to a mechanic and that funny noise goes from being one little $50 thing to a $2000 rebuild because the mechanic kept coming back to you saying something else is wrong. That stuff may indeed be needed, but the fact that you didn't think about it and let them know ahead of time speaks volumes about your skills as a coder. Some things just aren't foreseeable. Most things are.
  23. I believe thorpe is working on something like that right now. Don't have an ETA or anything.
  24. How about a captcha tutorial? Lots of them around, but we're supposed to be a resource, right? I may do it myself, if someone else doesn't volunteer.
  25. Honestly I don't really see anybody writing a tutorial like that on a technical level (actual code). Maybe on some kind of abstract level, like conveying general principles and program flow and good design, advice and pitfalls, etc.. but most tutorials that involve actual code are for teaching how to make building blocks. Things like forums and blogs and cms' are more like actual buildings, not building blocks. If you sit down and break down for instance all the things in a forum, you will quite easily find tutorials for just about all of those 'building blocks.' I suggest you either do that, or maybe find an open source version of one of those things and jump into it, instead.
×
×
  • 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.