Jump to content

Jragon

Members
  • Posts

    148
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Jragon

  1. This is the output i'm getting strings are coool 0c5099c965217e2e75722bc5f762ecdf ô@GSÁsÖ ðÀÔïÐQ¦¡b\rOˆJÎì…h.î]˜¿³£këóÂEc?UXªÕd+¬ÿ±5¶Tŧµ the thing that is not working is: the string replace thing in the cryptc function because the strtoarr is not working correctly The string 'strings are coool' should be a hole load of gobeldegoop also when it encrypts it dosent update the mysql database joel24: Hey joel What i want the function to output is eather 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM ,.' or the decipher code in an array so it can be used to do the string replace thing Thanks Jraagon
  2. Hello, I've made a huge functions list that use functions in that list its sort of confusing my functions: <?php function strtoarr($option){ if($option == 'abc'){ $string = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM ,.'; }else{ $string = $option; } $array = array(str_split($string)); } function randstr($length) { $chars = '!"£\$%^&*()_+-=1234567890¬`¦QWERTYUIOP{}[]ASDFGHJKL:@~|ZXCVBNM<>?,.;\#\qwertyuioplkjhgfdsazxcvbnm©ˆ…–—˜¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ €™'; //$chars = '!"£\$%^&*()_+-=1234567890¬` ¦QWERTYUIOP{}[]ASDFGHJKL:@~|ZXCVBNM<>?,.;\'\# \ qwertyuioplkjhgfdsazxcvbnm©ˆ…˜↑↓←→–—≈&#160;&#161;&#162;&#163;&#164;&#165;&#166;&#167;&#168;&#169;&#170;&#171;&#172;&#173;&#174;&#175;°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ €™'; $str = substr( str_shuffle( $chars ), 0, $length ); return $str; } function cryptc($code, $string, $type){ if($type == 'decrypt'){ if(getmd5($code) != false){ $replace = strtoarr('decrypt'); $find = strtoarr(getmd5($code)); $result = strtr($string, $find, $replace); return $result; } }else{ include("connect.php"); $find = strtoarr('abc'); $replace = randstr(55); $md5 = md5($replace); $query = sprintf("INSERT INTO decipher (md5_code, decipher_code) VALUES('%s', '%s')", mysql_real_escape_string($md5), mysql_real_escape_string($replace)); mysql_query($query); $result = strtr($string, $find, $replace); return $result . '<br />' . $md5; } } function getmd5($code){ include("connect.php"); $query = sprintf("SELECT decipher_code FROM decipher WHERE md5_code = '%s'", mysql_real_escape_string($code)); $numrows = mysql_num_rows(mysql_query($query)); $result = mysql_query($query); if($numrows = 1){ while(mysql_fetch_assoc($result)){ return $row[1]; } }else{ return false; } } ?> What i want it to do is encrypt using a random code or decrypt using a code from the database and right now its not doing eather I know what the problem is: What is happening is that when strtoarr function functions it dosent return anything, what i want it to do is return somthing in array format. Any ideas on how i could this Thanks Jragon
  3. I'm getting this: Warning: array_rand() expects parameter 1 to be array, null given in C:\xampp\htdocs\makecode\includes\inlude.php on line 202 Thanks Jragon
  4. Hey guys, I getting a problem with my ranbom string crater My function: function randstr($length){ $characters = '0123456789QWERTYUIOPLKJHGFDSAZXCVBNM<>?:@~}{+_)(*&^%\$£!¬`-=[\'],./¦'; $string =''; for ($p = 0; $p < $length; $p++) { $string .= $characters[mt_rand(0, strlen($characters))]; } return $string; } What happens: when i spefafi the length it dosent allwas keep to that length(the length is 55 chariters) Also what i want it to do is only have 1 of each chariters. Thanks Jragon
  5. will it add '' in between them?
  6. No it will be a random string with many symbols and other stuff that is about 185 charicters long
  7. Hello, I need to make a string ' $sting = 'abc' ' to and array ' $sting = array('a', 'b', 'c') ' Any idea on how i could do this would be much apreachated Thanks Jarogn
  8. Hello, I got an error: Parse error: syntax error, unexpected T_STRING in C:\xampp\htdocs\md5\includes\functions.php on line 9 My code: <?php function encrypt($string){ include("connect.php"); $md5 = md5($string); $query = sprintf("SELECT * FROM md5 WHERE md5='%s'", mysql_real_escape_string($md5)); $numrows = mysql_num_rows(mysql_query($query)); if($numrows == 0){ $query = sprintf("INSERT INTO md5 (string, md5string) values('%s', '%s')" mysql_real_escape_string($string), mysql_real_escape_string($md5)); mysql_query($query); } return $md5; } function decrypt($md5){ include("connect.php"); $query = sprintf("SELECT * FROM md5 WHERE md5='%s'", mysql_real_escape_string($md5)); $numrows = mysql_num_rows(mysql_query($query)); if($numrows = 1){ $query = sprintf("SELECT * FROM md5 WHERE md5='%s'", mysql_real_escape_string($md5)); $result = mysql_query($query); while(mysql_fetch_assoc($result)){ return 'Your encrypted hash was ' . $md5 . ' and your decrypted hash is ' . $row['string']; } }else{ return 'Sorry that MD5 hash dose not exist on our database.'; } } ?> also there is a strange '` ' with out quotes in the top of my index page My code: <?php include("includes/header.php"); ?> <?php require("includes/connect.php"); ?> <?php include("includes/functions.php"); ?> <form action="" method="post"> <table align="center"> <tr> <td align="center"> Encrypt<input type="radio" name="type" value="encrypt"/> </td> </tr> <tr> <td align="center"> Decrypt<input type="radio" name="type" value="decrypt"/> </td> </tr> <?php if($_POST['type'] == 'encrypt'){ echo ' <tr> <td align="center""> String to be Encrypted <input type="text" name="string"/> </td> </tr>'; }else{ echo ' <tr> <td align="center"> Hash to be Decrypted <input type="text" name="hash"/> </td> </tr>'; } ?> <tr> <td align="center"> <input type="submit" name="submit" value="Submit"/> </td> </tr>' </table> </form> <?php include("includes/footer.php"); ?> I know that its not in any of the included files cos in my browser preview its there and the browser preveew only dose html Thanks Jraogn
  9. Hey guys, I was wondering how i could put a foreach statement into varible or array. My code: <?php function permute($array,$positions,&$perms,$previous = null) { if($positions > 0) { if(!isset($previous)) { $previous = array(); } foreach($array as $element) { $tempPrevious = $previous; $tempPrevious[] = $element; permute($array,$positions-1,$perms,$tempPrevious); } } else { $perms[] = $previous; } } $perms = array(); $letters = array('a','b','c','d', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'x'); $numofletters = 3; permute($letters, $numofletters, $perms); foreach($perms as $key => $row){ foreach($row as $letter){ echo $letter; } echo '<br />'; } ?> It creates random letter arrangements and i want to put those letters in to a array so that it would look like this: $1 = array('aaa', 'aab' ECT) and then i want to put it in to a while loop and MD5 it so it will look somthing like this: while($letterarray){ echo $letterarray; echo md5($letterarry); } so in the end it will out put somthing like this: word md5ed word word md5ed word word md5ed word word md5ed word word md5ed word word md5ed word word md5ed word word md5ed word Any help would be much appreciated Thanks Jraogn
  10. The error in my salt.php was: <?php function assign_rand_value($num) { // accepts 1 - 36 switch($num) { case "1": $rand_value = "a"; break; case "2": $rand_value = "b"; break; case "3": $rand_value = "c"; break; case "4": $rand_value = "d"; break; case "5": $rand_value = "e"; break; case "6": $rand_value = "f"; break; case "7": $rand_value = "g"; break; case "8": $rand_value = "h"; break; case "9": $rand_value = "i"; break; case "10": $rand_value = "j"; break; case "11": $rand_value = "k"; break; case "12": $rand_value = "l"; break; case "13": $rand_value = "m"; break; case "14": $rand_value = "n"; break; case "15": $rand_value = "o"; break; case "16": $rand_value = "p"; break; case "17": $rand_value = "q"; break; case "18": $rand_value = "r"; break; case "19": $rand_value = "s"; break; case "20": $rand_value = "t"; break; case "21": $rand_value = "u"; break; case "22": $rand_value = "v"; break; case "23": $rand_value = "w"; break; case "24": $rand_value = "x"; break; case "25": $rand_value = "y"; break; case "26": $rand_value = "z"; break; case "27": $rand_value = "0"; break; case "28": $rand_value = "1"; break; case "29": $rand_value = "2"; break; case "30": $rand_value = "3"; break; case "31": $rand_value = "4"; break; case "32": $rand_value = "5"; break; case "33": $rand_value = "6"; break; case "34": $rand_value = "7"; break; case "35": $rand_value = "8"; break; case "36": $rand_value = "9"; break; } return $rand_value; } function salt($length) { if($length>0) { $rand_id=""; for($i=1; $i<=$length; $i++) { mt_srand((double)microtime() * 1000000); $num = mt_rand(1,36); $rand_id .= assign_rand_value($num); } } return $rand_id; } echo salt(10); ?> echo salt(10); The last line
  11. My session is not working for somereaseon My index code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>VisualUpload Share what you see</title> </head> <body bgcolor="#f1f1f1" text="#000000" link="33cc00" vlink="33cc00" alink="33cc00"> <table align="center" width="95%" bgcolor="#ffffff" style="border-color: #999999; border-style:solid;border-width:1px" border="0"> <tr> <td> <table> <tr> <td width="50%"> <img src="images/logo.png" /> </td> <td> <form method="post" action="login.php" > <table width="100%"> <tr> <td> Username: </td> <td> <input type="text" name="user" size="16" maxlength="25"/> <a href="register.php">Register</a> </td> </tr><tr> <td> Password: </td> <td> <input type="password" name="pass" size="16" maxlength="25"/> <input type="submit" value="Log in"/> </td> </tr> </table> </form> </td> </tr> </table> <?php if (isset($_SESSION['user'])){ echo '<tr> <td> <table width="100%"> <tr> <td width="20%" valign="top"> <font size="4"> <a href="upload.php"><strong>Upload</strong></a><br /> <a href="albums.php"><strong>Albums</strong></a><br /> <a href="profile.php"><strong>Profile</strong></a><br /> </font> </td> <td valign="top"> <font size="4"> <b>Recant Images</b><br /> <font size="2"> You Haven\'t uploaded any picturs!<br /> </font> </font> <font size="4"> <b>Recant Videos</b><br /> <font size="2"> You Haven\'t uploaded any videos!<br /> </font> </font> </td> </tr> </table> </td> </tr>'; } ?> </td> </tr> </table> </body> </html> my login code: <?php session_start; include("getsalt.php"); require("connect.php"); include("getname.php"); $post_username = $_POST['user']; $post_password = $_POST['pass']; if (isset($post_password) && isset($post_username)){ if(strlen($post_username)>25||strlen($post_password)>25){ die('Username or password character length too long!'); }else{ //convert pass to md5 $salt = getsalt($post_username); $post_password = md5($salt.$post_password); $login = sprintf("SELECT * FROM user WHERE username='%s' AND password = '%s'", mysql_real_escape_string($post_username), mysql_real_escape_string($post_password)); $rowcount = mysql_num_rows(mysql_query($login)); if ($rowcount == 1){ $_SESSION['user'] = $post_username; $name = getname($post_username); echo 'Welcome ' . $name . '!<br /> Please click <a href="index.php">here</a> to go back to the main page.'; } } }else{ die('Please enter a useranme and password'); } ?> Please help Thanks Jragon
  12. Hey, When i atemt to tun this srcipt i get an error: Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\visualupload\login.php on line 17 My code: <?php include("getsalt.php"); require("connect.php"); $post_username = $_POST['user']; $post_password = $_POST['pass']; if (isset($post_password) && isset($post_username)){ if(strlen($post_username)>25||strlen($post_password)>25){ die('Username or password character length too long!'); }else{ //convert pass to md5 $salt = getsalt($post_username); $post_password = md5($salt.$post_password); $login = sprintf('SELECT * FROM user WHERE username=`%s` AND password = `%s`', mysql_real_escape_string($post_username), mysql_real_escape_string($post_password)); $rowcount = mysql_num_rows(mysql_query($login)); echo $rowcount; if ($rowcount == 1){ $_SESSION['user'] = $post_username; } } }else{ die('Please enter a useranme and password'); } ?>
  13. Hey, for some reason my incripted password is 49 charicters long? My code: <?php include("salt.php"); $pass = 'hello'; $salt = salt(12); $md5 = md5($salt.$pass); echo $md5 . '<br />' . $salt; ?> My pass: lujxikk46nx7l2m94e85ea73176c48d8723fb18211c4a9499 My salt: g4zv7b0zitd9
  14. its half working now what i get stdClass Object ( [salt] => akldflasjkdf ) akldflasjkdf
  15. This is my dumb for the table -- phpMyAdmin SQL Dump -- version 3.2.4 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Jul 22, 2010 at 10:19 AM -- Server version: 5.1.41 -- PHP Version: 5.3.1 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `visualupload` -- -- -------------------------------------------------------- -- -- Table structure for table `user` -- CREATE TABLE IF NOT EXISTS `user` ( `id` int(11) NOT NULL AUTO_INCREMENT, `firstname` varchar(25) NOT NULL, `lastname` varchar(25) NOT NULL, `username` varchar(25) NOT NULL, `password` varchar(32) NOT NULL, `dob` date NOT NULL, `gender` varchar(1) NOT NULL, `salt` varchar(12) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Dumping data for table `user` -- INSERT INTO `user` (`id`, `firstname`, `lastname`, `username`, `password`, `dob`, `gender`, `salt`) VALUES (1, 'Rory', 'Anderson', 'rory', 'hello', '2010-07-07', 'm', 'akldflasjkdf'); Nothing still
  16. Ok so i tried your script and now i get nothing
  17. Ok so i have done that this is my function: <?php function getsalt($user){ include("connect.php"); $query = 'SELECT salt FROM user WHERE username = "$user"'; $salt = mysql_query($query); return $salt; } echo getsalt('rory'); ?> But all I'm getting is: Resource id #4 Thanks Jragon
  18. Thanks I was using it to get the salt of my password
  19. Hey guys, I was wondering how i could get a specific peace of information about the user? I know how to select the basics but i dont know how to get a specific peace of info Thanks Jraogn
  20. Hi jd307, The ENDHTML is called a heredoc http://php.net/manual/en/language.types.string.php Thanks for the help.
  21. Hey guys Form is submiting get instead of post & My if sstatment is not working My code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>VisualUpload Share what you see</title> </head> <body bgcolor="#f1f1f1" text="#000000" link="33cc00" vlink="33cc00" alink="33cc00"> <table align="center" width="95%" bgcolor="#ffffff" style="border-color: #999999; border-style:solid;border-width:1px" border="0"> <tr> <td> <table> <tr> <td width="50%"> <img src="images/logo.png" /> </td> <td> <form method="post" action="login.php" > <table width="100%"> <tr> <td> Username: </td> <td> <input type="text" name="user" size="16" maxlength="25"/> <a href="register.php">Register</a> </td> </tr><tr> <td> Password: </td> <td> <input type="password" name="pass" size="16" maxlength="25"/> <input type="submit" value="Log in"/> </td> </tr> </table> </form> </td> </tr> </table> <?php if (isset($_COOKIE['user'])){ echo <<<ENDHTML <tr> <td> <table width="100%"> <tr> <td width="20%" valign="top"> <font size="4"> <a href="upload.php"><strong>Upload</strong></a><br /> <a href="albums.php"><strong>Albums</strong></a><br /> <a href="profile.php"><strong>Profile</strong></a><br /> </font> </td> <td valign="top"> <font size="4"> <b>Recant Images</b><br /> <font size="2"> You Haven't uploaded any picturs!<br /> </font> </font> <font size="4"> <b>Recant Videos</b><br /> <font size="2"> You Haven't uploaded any videos!<br /> </font> </font> </td> </tr> </table> </td> </tr> ENDHTML; } ?> </td> </tr> </table> </body> </html> I have no idea whats wrong with it i have looked to see if i can see anything Thanks Jragon
  22. Now all I'm getting is 4 q Thanks jragon I also fixed 2 errors with the $encrypt and a ;
×
×
  • 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.