Jump to content

oracle259

Members
  • Posts

    119
  • Joined

  • Last visited

    Never

Everything posted by oracle259

  1. Ok i read up on str_replace and ur right its exactly what i was looking for. But im still somewhat confused so let me tell u what im tryin to do. Basically, i need a function that would check a userid for profanity eg fshit.%4m would not be accepted as a proper userid. The banned words would be stored in a mysql database and userids would be checked against it. Ok now need to know if im on the right track with the following code: <?php $sql = "SEARCH profanity FROM filter"; $result = @mysql_query($sql); while ($words = @mysql_fetch_array($result, MYSQL_BOTH) { $profanity[] = $words[profanity]; } $kill_characters = array ('.', '-', '_'); $kill_num = range(0,9); $kill_all = array_merge($kill_num, $kill_characters); $userid = str_replace($kill_all, '' ", $userid); $obscene = $profanity[]; foreach ($obscene as $obscenities) { if (stristr(trim($userid), $obscenities)) {   $match = similar_text($userid, $obscenities, $percent);   $percent = round($percent, 2);   if ($percent >= '50') {   echo "Sorry, username <b>$userid</b> is too vulgar. Please select another username."; } else { echo "Congratulations, username <b>$userid</b> is available."; } } else { echo "Congratulations, username <b>$userid</b> is available."; } } ?> Where am i going wrong?  ???
  2. Not certain which forum this belongs in but here goes. How can I explode numbers and symbols from a mysql query. eg.  if  i have a table with column pwd which contains  2 row with the following information: w2@%Def1IP!4m bn3tj45#m%$nt ??? how do i go about exploding the numbers and symbols to get a result that gives me the following output: array("wDefIPm","bntjmnt") If you have any suggestions i would really appreciate it
  3. Thanks  :D That must be more than i need. but do i still need to set AUTO_INCREMENT = 18446744073709551615 OR is $sql="CREATE TABLE 'records' ( 'id' bigint(20) unsigned NOT NULL auto_increment, PRIMARY KEY ('id') ) ENGINE=MyISAM just fine
  4. I'm currently building an application that will be used for quite sometime (say 8-10yrs) before the data is expected to be redundant so i need to know what is the largest auto_increment value possible. So far i have dbConnection() or die("Couldn't connect to database"); $sql="CREATE TABLE 'records' ( 'id' bigint(20) unsigned NOT NULL auto_increment, PRIMARY KEY ('id') ) ENGINE=MyISAM AUTO_INCREMENT=10000000000000000000"; $result = dbQuery($sql) or die("Couldn't execute sql"); I know this should be enough but i'm curious as to what is the largest auto_increment possible?  ???
  5. try this pattern: ^(?=.*?[\d])?(?=.*?[a-zA-Z])(?=.*?[\-\_])?[a-zA-Z][\-\w]{8,25}$/s note the {8,25} this requires that usernames are at least 8 characters but no more than 25 characters long. Why? I have found that very long usernames cause trouble in the long run. If you want more combinations allow dots(.) or other symbol in your usernames. To remove this restriction simply replace {8,25} with * or +
  6. Hi I need to know to what extent can we use variable with regex e.g. is it possible to do this: $var1 = "abc.gov.jm"; $var2 = "defg.gov.au"; /^(?=.*?[a-zA-Z])(?:[a-zA-Z][0-9\-\.\_]?)+@(?:$var1|$var2)$/ or if not what is the best way of achieving the same thing
  7. ok i read up on preg_match but the php manual recommends using strpos as it is faster. So let me know if this code would surffice: <?php $password = 'p.oracle259-ender'; $userid  = 'oracle259'; $inpass = strpos($password, $userid); if ($incheck === true) {   echo "Error: Sorry password cannot contain your set userid'"; } else {   encrypt password   make password DB safe   insert password into DB }
  8. Also can i use variables like $pwd and $userid in other regex
  9. ok but would preg_match work for lets say the password is p.oracle259-ender and userid is oracle259?
  10. I needed to know how to create a regex to ban passwords that contain a user's given userid or email. I considered using similar_text but i'm not so familiar with that function and i think regex may be more efficient. Thanks :D
  11. Wildbug your a genius. Its much better to just eliminate the 12 possible combinations from consideration that leaves roughly 114 remaining combinations. Thanks
  12. Sorry i should have explained further. The expression is meant to match patterns like A1111 or B2222 or E9999 only that is why i wanted to see if it could be done another way. ;)
  13. The aim of the exercise is to ban users from selecting weak PINs. Each PIN starts with 1 uppercase letter and ends with 4 numbers. eg A2587. However, a PIN such as A1234 could be easily guessed. Therefore, my questions are: 1. How do i go about creating an expression that matches the uppercase letter and 4 consecutive numbers? eg A2345, B2345, C2345, etc 2. How do i make the expression sensitive to ascending or descending order? eg A2345, A5432 or B2345, B5432. Thanks in advance
  14. I'm new to php and regex, as such i have been practicing. But its not only important that i learn how to simply write these expressions i also need to learn how to optimize then. I recently wrote this expression ^[A-Z]{1}([1]{4}|[2]{4}|[3]{4}|[5]{4}|[6]{4}|[7]{4}|[8]{4}|[9]{4})$ Its meant to validate a 5 character alphanumeric PIN that starts with an uppercase letter and 4 digits (no zeros). Now i know it works but its not very pretty as u can see. My question is this how can i optimize it.
  15. Thank you guys for all your help in answering all my questionsand for your patience. Also Special thanks to Karma: +0/-0
  16. Alright i think I have got it. Please see the final expression ^[a-zA-Z]?(?=.*?[\d])(?=.*?[A-Z])(?=.*?[\W])[\w\W]{8,15}$ I ran i through the Regex Coach and it passed. However, if you guys see any weaknesses or know of a better way of achieving the same results please let me know. Thanks
  17. Ok i read some more tutorials on regular expressions and came up with this. ^(?=.*?[0-9])(?=.*?[A-Z])(?=.*?[\W])[a-zA-Z0-9\W]{7,}$ It's close to the final expression that i need but its weak in 1 key area. The 7-digit sequence may start with a number, which i dont want it to do. If you guys have any ideas please let me know. Also if u have any tips on refining or optimizing the expression please let me know also. Thanks in advance for your help.
  18. Basically, what i want to do is to ensure that when registering users use strong passwords, ie at least one number, uppercase letter and symbol.  What i need to know therefore is how do i go about accomplishing this.
  19. Hi, I need your help badly I am new to php and regular expression,, so please bear with me. I need to know how do i create an eregi pattern that will ensure the following password match. Password may start with a number, lower or upper case letter, but must include at least one number. I tried this pattern ^[a-zA-Z0-9]{0,7}[0-9]*[a-zA-Z0-9]*$ But it is clearly weak as it will validate abcdefg5hi but not 1234567T890 Please help this is driving me nuts.
×
×
  • 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.