Jump to content

.josh

Staff Alumni
  • Posts

    14,780
  • Joined

  • Last visited

  • Days Won

    43

Everything posted by .josh

  1. No... there could be reasons why you wouldn't want people to snoop around your stuff even though you are not doing anything illegal. Like for instance things that would be embarrassing, just guarding your private life, or protecting yourself from power abuse. dunno.. I guess my own experiences with the law gives me a vastly different PoV about how blurry and wide that 'probable cause' line is.
  2. They love it so much they put their business dependencies on beta products?
  3. when you put a limit on the explode, if there's more matches than the limit, the rest is put into a string in the last element.
  4. oops my bad. Thought OP said chars not word. Slight variation of haku's... <?php $string = "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; $result = explode(' ',$string,26); array_pop($result); $result = implode(' ',$result) . '...'; ?>
  5. funny thing about probable cause is that saying no gives them probable cause.
  6. umm..you said your preg_replace already worked on your file. Just do the same thing to the $filename before you run the query...
  7. <?php $string = "blahblah_blah_stuff.php"; $postfix = $postfix[count($postfix = preg_split('/_|\./',$string))-2]; echo $postfix; ?>
  8. You did a preg_preplace on the $file_name2 and renamed it in the directory but you never did it to $filename in your query.
  9. <?php /******************************************************************************* **Description: returns string with all the words filtered, preserving the non-masked characters' case in the matched word. **Syntax: string filter(string $str[, bool $is_whole_word]); **Parameters: str - The string to be filtered is_whole_word - If set to TRUE, only whole words will be filtered. If set to FALSE, it will match words within words. Defaults to TRUE if not specified. **Examples: echo filter("FucK you moTherfUckeR"); // output: F*cK you moTherfUckeR echo filter("FucK you moTherfUckeR", false); // output: F*cK you moTherf*ckeR **Internal Syntax & Parameters: $wordlist = array($key1 => $value1[, $key2 => $value2, [etc..]]]); key - The word to search for. value - The filter for the key. Even if is_whole_word is set to FALSE, only the the key substring of the word will be masked. In principle, anything that evaluates (strtolower($value{$pos}) == strtolower($badword{$pos})) to FALSE will be considered a mask. Examples: key: sex value | badword | replacement s3x | sex | s3x s3x | SEX | S3X * | sex | * **** | sex | **** s3x | sexual | s3xual s3x | SeXual | S3Xual * | sexual | *ual s3x | asexual | as3xual * | asexual | a*ual *******************************************************************************/ /*** function filter **********************************************************/ function filter($string, $wholeword = true) { // list of words and filters $wordlist = array('shit' => 'sh!t', 'suck' => 'svck', 'dang' => 'darn', 'fuck' => 'f*ck', 'sex' => 's3x', 'bitch' => 'b!tch', 'cunt' => 'cvnt', 'cock' => 'c0ck', 'ass' => 'arse', 'nigger' => 'negro', 'whore' => 'wh0re', 'dick' => 'd!ck'); // for each word in the list of words to replace... foreach ($wordlist as $word => $filter) { // find all instances of current bad word $word = ($wholeword == true)? "/\b{$word}\b/i" : "/{$word}/i"; preg_match_all($word, $string, $matches); // for each bad word found.... foreach ($matches[0] as $bword) { // init the string (so it resets each loop iteration) $replacement = ''; // find out how many letters are in the filter $count = strlen($filter); // for each letter in the filter... for ($pos = 0; $pos < $count; $pos++) { // compare the current letter to the letter in the bad word // if it's the same (case insensitive), use the bad word letter // if it's not the same use the filter letter. // In this manner, the replacement word is built $replacement .= (strcasecmp($filter{$pos},$bword{$pos}) == 0)? $bword{$pos} : $filter{$pos}; } // end for pos // pattern slightly varies, depending on wholeword $pattern = ($wholeword == true)? "/\b{$bword}\b/" : "/{$bword}/"; // switch out the bad word with the replacement $string = preg_replace($pattern, $replacement, $string); } // end foreach match } // end foreach wordlist // return result return $string; } // *** End function filter ************************************************** // example use: $string = 'sex sexual asexual'; echo "original: $string <br/>"; echo "whole word: " . filter($string) . "<br>"; echo "all matched: " . filter($string, false); /******** output: ************** original: sex sexual asexual whole word: s3x sexual asexual all matched: s3x s3xual as3xual ********************************/ ?>
  10. If you in the U.S. I would think that is illegal, unless you gave them permission. In my opinion, I would put that on the same level as breaking an entering, or a police officer that enters your house without a warrant. umm...no. Police officers don't own your house and they aren't your legal guardian. What part of "The school becomes your legal guardian" do you not understand? That's like saying your parents need a warrant to go into your room.
  11. They probably do store it in their db encrypted. They probably just have a custom encryption algorithm that's reversible. But they probably do that, instead of something non-reversible like md5 because they probably don't store any information that's sensitive enough to warrant it (like credit card numbers, etc...). They probably figure that the convenience of just telling you your password is a fair trade off for the lesser security, given the lack of sensitivity in account info.
  12. .josh

    Finally!

    It's because I'm here. When I turn off the computer, the whole internet gets put on hold.
  13. Get a cellphone that plays mp3's. Problem solved. On a more serious note, I do agree with the school in that it should be taken away on-sight during class. But between classes/lunch/whatever, I don't think it should be taken away.
  14. Okay, $wordlist is made up of word=>filter. If the filter is the same length as the word, it will do a case-insensitive replacement on the bad word. If it is not the same length, it will replace the bad word with the filter, regardless of case. That is because it is assumed that if the filter is not the same length as the word, you are wanting it replaced with some kind of message like *** removed *** or something. Also, the only way the case-insensitive replacement will even work, is if it's the same length. So for example on word 'dang' filter -> match = result d*ng -> DANG = D*NG ***g -> DANG = ***G d**g -> DANG = D**G d* -> DANG = d* d*** -> DANG = D*** d**** -> DANG = d**** ** SOME MESSAGE ** -> DANG = ** SOME MESSAGE You don't have to use *'s you can use whatever you want. You can even use a mix filter -> match = result d&&g -> danG = d&&G &*nG -> DanG = &*nG dnag -> DANG = DnaG gnad -> DANG = gnad darn -> DANG = DArn <?php $comment = 'Dang this Crap, I want to DaNG shoot somebody. crAp But that ShooT DARN would be dangerous!'; $wordlist = array('dang' => 'd*ng','crap' => 'c**p','shoot' => 's****', 'darn' => '** REMOVED **'); foreach ($wordlist as $word => $filter) { preg_match_all("/\b{$word}\b/i", $comment, $matches); foreach ($matches[0] as $bword) { if (strlen($filter) == strlen($bword)) { $replacement = ''; $count = strlen($filter); for ($pos = 0; $pos < $count; $pos++) { $replacement .= (strcasecmp($filter{$pos},$bword{$pos}) == 0)? $bword{$pos} : $filter{$pos}; } // end for pos } else { $replacement = $filter; } // end if strlen $comment = preg_replace("/{$bword}/", $replacement, $comment); } // end foreach matches } // end foreach wordlist echo $comment; ?>
  15. here I even condensed it some more... <?php $comment = 'Dang this Crap, I want to DaNG shoot somebody.crAp But that would be dangerous!'; $wordlist = array('dang','crap','shoot'); foreach ($wordlist as $word) { preg_match_all("/\b{$word}\b/i", $comment, $m); foreach($m[0] as $val) { $replacement = preg_replace("/[aeiou]/i","*",$val); $comment = preg_replace("/{$val}/", $replacement, $comment); } } echo $comment; ?>
  16. Okay first off, dunno where that word list is coming from. But it looks like you are just putting *'s where the vowels are, so I don't really see the point in you keeping a word=>replacement combo like that. I'd just keep a list of the words and use some regex to replace the vowels with *'s. 2nd...okay I'm sure there is probably a way better way to do this, but uh...yeah, there you have it. <?php // example string $comment = 'Dang this Crap, I want to DaNG shoot somebody. crAp But that would be dangerous!'; // array of naughty words $wordlist = array('dang','crap','shoot'); // for each word in the naughty list... foreach ($wordlist as $word) { // see if there is a match in $comment preg_match_all("/\b{$word}\b/i", $comment, $m); // if there is, add it to list of matches $matches .= "," . implode(',',$m[0]); } // trim off the leading comma from the loop $matches = ltrim($matches, ','); // explode it into an array. Now you have an array of all the bad words in $comment, case preserved. $matches = explode(',',$matches); // for each badword found... foreach ($matches as $w) { // replace the vowels with a *, but make it a new array, so as to preserve the original words $replacement[] = preg_replace("/[aeiou]/i","*",$w); } // for each badword found in $comment... foreach($matches as $key => $val) { // replace the word with the replacement $comment = preg_replace("/{$val}/", $replacement[$key], $comment); } echo $comment; ?>
  17. INSERT INTO TABLENAME (column1, column2, etc...) VALUES (value1, value2, etc...) Are you sure that $id is your table name?
  18. 10k users = 100 servers.
  19. well, you could setup that script on an entirely different server for every 100 or so users
  20. nope. mysql_fetch_assoc has an internal logic switch to ensure that people cannot spam.
  21. Maybe I'm misunderstanding you, but if you're just pulling data out of one table and putting it into another, there's no reason for you to be using striplashes or mysql_real_escape_string at all. The only time you need to do any of that sort of thing is when the data is coming from the user.
  22. column name from your badword query is 'word' but you use 'badword' inside your foreach loop. So either change 'word' to 'badword' in your query or else change 'badword' to 'word inside your foreach loop $b[] = $v['word'];
  23. You're gonna have to start with only assigning your data to an array in your while loop, because there's no way you can build your table like that from inside that loop. Then you're going to have to make some nested loops to create some nested tables. In short, that's going to involve a complete code rewrite.
  24. yeah i changed it right after i posted. look again. i accidentally put 0 instead of replacement as key in foreach loop
×
×
  • 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.