ArizonaJohn Posted June 25, 2009 Share Posted June 25, 2009 Hello, I want the code below to do the following: 1. User enters porn term: go to index.php 2. User enters non-existent non-porn term: go to search2.php. However, it is going to index.php in both cases. How come it is not going to search2.php if the user enters a non-existent non-porn term? Thanks in advance, John $anymatches=mysql_num_rows($result); if ($anymatches == 0) { function check_porn_terms($input) { $porn_terms = array("ass", "asshole", "anal", "adult", "arse", "asshat", "a$$", "a$$hole", "arsehole", "analingus", "areola", "asscheek", "asscheeks", "anus", "bitch", "butt", "bastard", "bdsm", "boobs", "breast", "boob", "blowjob", "booty", "butthole", "bum", "buttsex", "biatch", "buttocks", "badonkadonk", "boner", "bonerizers", "bonerizer", "boners", "bums", "breasticles", "bj", "blumpkin", "bootylicious", "buttcheek", "buttcheeks", "bukkake", "bukakke", "bukake", "bukaki", "bunghole", "cunt", "cock", "clit", "clitorus", "cocksucker", "cum", "cumsucker", "cunnilingus", "cheeks", "cooch", "cumshot", "clitoris", "cooter", "coochie", "coochie-pop", "cuntcake", "cunny", "chode", "cameltoe", "cornhole", "dick", "dong", "dildo", "dicksucker", "dumbass", "dickhead", "dominatrix", "defecate", "defecation", "defecating", "erection", "ejaculation", "ejaculate", "fuck", "fuckface", "fucker", "fucked", "fucking", "fuckhole", "fuckhead", "faggot", "fucktard", "feces", "fetish", "femdom", "fellatio", "fellashio", "funbags", "fap", "full-nude", "full-nudity", "fully-nude", "fullynude", "fullnude", "fullnudity", "gangbang", "genitals", "genitalia", "genatalia", "hustler", "hooters", "hooter", "hardon", "hard-on", "handjob", "hand-job", "horny", "hentai", "intercourse", "jackoff", "jizz", "jackass", "jugs", "jiz", "jism", "jizm", "kunt", "kinky", "knockers", "labia", "masturbate", "moron", "mistress", "merde", "minge", "mooseknuckle", "masterbation", "masterbate", "masturbation", "milf", "milfy", "masturbatory", "nude", "naked", "nipple", "nekkid", "nekid", "nique", "niquer", "nookie", "nudity", "nudography", "nudie", "onanism", "orgasm", "orgy", "pussie", "pussy", "porn", "porno", "playbooy", "playboy", "penthous", "penthouse", "perfect 10", "penis", "pornography", "poop", "pedophile", "pedo", "pedophilia", "beastiality", "necrophilia", "necrophile", "coprophilia", "coprophile", "scat", "scatalogical", "erotic", "pervert", "prostitute", "poon", "poontang", "pecker", "purple-headed", "purplehead", "piss", "pron", "pr0n", "pornstar", "porn-star", "queef", "quim", "rectum", "shit", "shitty", "sex", "shitface", "shithead", "shitfuck", "shit-head", "prostitution", "slut", "sodomize", "sodomized", "sodomite", "sodomy", "skank", "$hit", "s & m ", "s& m ", "s &m", "s & m ", "snatch", "schlong", "spooge", "splooge", "scrotum", "sheisse", "shiesse", "semi-nude", "seminude", "striptease", "strip-tease", "shat", "strapon", "strap-on", "sphincter", "tits", "titties", "titsucker", "tittyfuck", "titty-fuck", "tittiefuck", "twat", "tata", "tatas", "ta-ta", "ta-tas", "testicle", "topless", "top-less"); //add terms here return !preg_match('#\b(' . join('|', array_map('preg_quote', $porn_terms)) . ')\b#i', $input); } if(!check_porn_terms($find)) { session_write_close(); header("Location:http://www.site.com/index.php"); exit; } else{ $find = urlencode($find); session_write_close(); header("Location:http://www.site.com/search2.php?find=$find"); exit; } } Quote Link to comment https://forums.phpfreaks.com/topic/163596-solved-code-not-re-directing-as-i-would-like/ Share on other sites More sharing options...
flyhoney Posted June 25, 2009 Share Posted June 25, 2009 A little code cleanup. <?php function check_porn_terms($input) { $porn_terms = array("ass", "asshole", "anal", "adult", "arse", "asshat", "a$$", "a$$hole", "arsehole", "analingus", "areola", "asscheek", "asscheeks", "anus", "bitch", "butt", "bastard", "bdsm", "boobs", "breast", "boob", "blowjob", "booty", "butthole", "bum", "buttsex", "biatch", "buttocks", "badonkadonk", "boner", "bonerizers", "bonerizer", "boners", "bums", "breasticles", "bj", "blumpkin", "bootylicious", "buttcheek", "buttcheeks", "bukkake", "bukakke", "bukake", "bukaki", "bunghole", "cunt", "cock", "clit", "clitorus", "cocksucker", "cum", "cumsucker", "cunnilingus", "cheeks", "cooch", "cumshot", "clitoris", "cooter", "coochie", "coochie-pop", "cuntcake", "cunny", "chode", "cameltoe", "cornhole", "dick", "dong", "dildo", "dicksucker", "dumbass", "dickhead", "dominatrix", "defecate", "defecation", "defecating", "erection", "ejaculation", "ejaculate", "fuck", "fuckface", "fucker", "fucked", "fucking", "fuckhole", "fuckhead", "faggot", "fucktard", "feces", "fetish", "femdom", "fellatio", "fellashio", "funbags", "fap", "full-nude", "full-nudity", "fully-nude", "fullynude", "fullnude", "fullnudity", "gangbang", "genitals", "genitalia", "genatalia", "hustler", "hooters", "hooter", "hardon", "hard-on", "handjob", "hand-job", "horny", "hentai", "intercourse", "jackoff", "jizz", "jackass", "jugs", "jiz", "jism", "jizm", "kunt", "kinky", "knockers", "labia", "masturbate", "moron", "mistress", "merde", "minge", "mooseknuckle", "masterbation", "masterbate", "masturbation", "milf", "milfy", "masturbatory", "nude", "naked", "nipple", "nekkid", "nekid", "nique", "niquer", "nookie", "nudity", "nudography", "nudie", "onanism", "orgasm", "orgy", "pussie", "pussy", "porn", "porno", "playbooy", "playboy", "penthous", "penthouse", "perfect 10", "penis", "pornography", "poop", "pedophile", "pedo", "pedophilia", "beastiality", "necrophilia", "necrophile", "coprophilia", "coprophile", "scat", "scatalogical", "erotic", "pervert", "prostitute", "poon", "poontang", "pecker", "purple-headed", "purplehead", "piss", "pron", "pr0n", "pornstar", "porn-star", "queef", "quim", "rectum", "shit", "shitty", "sex", "shitface", "shithead", "shitfuck", "shit-head", "prostitution", "slut", "sodomize", "sodomized", "sodomite", "sodomy", "skank", "$hit", "s & m ", "s& m ", "s &m", "s & m ", "snatch", "schlong", "spooge", "splooge", "scrotum", "sheisse", "shiesse", "semi-nude", "seminude", "striptease", "strip-tease", "shat", "strapon", "strap-on", "sphincter", "tits", "titties", "titsucker", "tittyfuck", "titty-fuck", "tittiefuck", "twat", "tata", "tatas", "ta-ta", "ta-tas", "testicle", "topless", "top-less"); //add terms here return (in_array($input, $porn_terms)) ? TRUE : FALSE; } $anymatches = mysql_num_rows($result); if ($anymatches == 0) { if (!check_porn_terms($find)) { session_write_close(); header("Location:http://www.site.com/index.php"); exit; } else { $find = urlencode($find); session_write_close(); header("Location:http://www.site.com/search2.php?find=$find"); exit; } } I imagine you have a garbage in / garbage out scenario. I dont know whats going on in the rest of the code. I would need to see more to know. Quote Link to comment https://forums.phpfreaks.com/topic/163596-solved-code-not-re-directing-as-i-would-like/#findComment-863208 Share on other sites More sharing options...
Adam Posted June 25, 2009 Share Posted June 25, 2009 Looks like you're trying to pass $find to the function, but you're setting it in the 'else' case of it failing. Try moving: $find = urlencode($find); Just after: if ($anymatches == 0) { Quote Link to comment https://forums.phpfreaks.com/topic/163596-solved-code-not-re-directing-as-i-would-like/#findComment-863209 Share on other sites More sharing options...
Adam Posted June 25, 2009 Share Posted June 25, 2009 In-fact, scrub that... Didn't realise this wasn't the complete code, and when I saw that assumed it was $_GET['find'] it was encoding. It's early... Quote Link to comment https://forums.phpfreaks.com/topic/163596-solved-code-not-re-directing-as-i-would-like/#findComment-863213 Share on other sites More sharing options...
ArizonaJohn Posted June 25, 2009 Author Share Posted June 25, 2009 Hello, I figured out my problem: one of my porn terms was "$hit", which apparently is a wild card, and was thus counting anything as a porn term whether it was on my list of terms or not. Quote Link to comment https://forums.phpfreaks.com/topic/163596-solved-code-not-re-directing-as-i-would-like/#findComment-863242 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.