blackenedheart Posted November 13, 2013 Share Posted November 13, 2013 Hi, I asked some questions about this cipher idea I had a long time ago. I have been working on it, and ultimately, it never worked. Can anyone tell me why? I feel like we were close. <? session_start(); echo '<br> <body bgcolor="#000000" text="#FFFFFF" link="#FF0000"> <p style="text-align: center; font-family: Courier, monospace; font-size: 24px; color: #FFF;">SESSION STARTED</p><br>'; // our sequence container if (!isset($_SESSION['sequence']) || (isset($_GET['sequence']) && $_GET['sequence'] === 'clear')) { $_SESSION['sequence'] = array(); echo '<br> <body bgcolor="#000000" text="#FFFFFF" link="#FF0000"> <p style="text-align: center; font-family: Courier, monospace; font-size: 24px; color: #FFF;">SEQUENCE CONTAINER INITIALIZED</p><br>'; } // user passed a code, store the code in the sequence container if (isset($_GET['code'])) { $_SESSION['sequence'][] = (int) $_GET['code']; echo '<br> <body bgcolor="#000000" text="#FFFFFF" link="#FF0000"> <p style="text-align: center; font-family: Courier, monospace; font-size: 24px; color: #FFF;">CODE WAS STORED IN SEQUENCE CONTAINER</p><br>'; } // user asked us to verify what is currently in the sequence container if (isset($_GET['verify']) && !empty($_SESSION['sequence'])) { $db = mysqli_connect('XXX', 'XXX', 'XXX', 'XXX') or die('Database has left the building!'); echo '<br> <body bgcolor="#000000" text="#FFFFFF" link="#FF0000"> <p style="text-align: center; font-family: Courier, monospace; font-size: 24px; color: #FFF;">CONNECTION TO DATABASE SUCCESSFUL/p><br>'; if($stmt = mysqli_prepare ($db, 'SELECT `username` FROM `users` WHERE `cipher` = ?')) { echo '<br>prepare statement is working<br>'; $sequence = implode(',', $_SESSION['sequence']); $stmt->bind_param('s', sha1($sequence)); $stmt->execute(); $stmt->bind_result($username); $stmt->fetch(); } } echo '<br> <body bgcolor="#000000" text="#FFFFFF" link="#FF0000"> <p style="text-align: center; font-family: Courier, monospace; font-size: 24px; color: #FFF;">ARRAY BOUND TO SEQUENCE</p><br>'; // our numbers $numbers = range(1, 25); // corresponding images echo '<br> <body bgcolor="#000000" text="#FFFFFF" link="#FF0000"> <p style="text-align: center; font-family: Courier, monospace; font-size: 24px; color: #FFF;">SEQUENCE WAS COMPARED TO THE ARRAY</p><br>'; $images = array_combine($numbers, array_map(function($i) { return sprintf('%02d.png', $i); }, $numbers) ); echo '<br> <body bgcolor="#000000" text="#FFFFFF" link="#FF0000"> <p style="text-align: center; font-family: Courier, monospace; font-size: 24px; color: #FFF;">ARRAY WAS COMBINED</p><br>'; echo '<body bgcolor="#000000" text="#FFFFFF" link="#FF0000"> <p style="text-align: center; font-family: Courier; font-size: 24px; color: #FFF;"><a href="?verify=1"></p>VERIFY THIS SEQUENCE IS CORRECT</a>'; if ($images == $sequence) { echo '<body bgcolor="#000000" text="#FFFFFF" link="#FF0000"> <p style="text-align: center; font-family: Courier; font-size: 24px; color: #FFF;">ACCESS IS GRANTED</p>'; } else { echo '<body bgcolor="#000000" text="#FFFFFF" link="#FF0000"> <p style="text-align: center; font-family: Courier; font-size: 24px; color: #FFF;">ACCESS IS DENIED</p>'; } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>THE IMPENETRABLE PUZZLE</title> <style type="text/css"> body { background-color: #000000; } </style> </head> <body link="#FF0000"> <div align="center"> <table width="48%" height="358" border="0" cellpadding="10" cellspacing="10"> <tr bgcolor="#333333" style="text-align: center"> <td><a href="?code=22"><img src="22.png" width="100" height="100" /></a></td> <td><a href="?code=8"><img src="08.png" width="100" height="100" /></a></td> <td><a href="?code=21"><img src="21.png" width="100" height="100" /></a></td> <td><a href="?code=13"><img src="13.png" width="100" height="100" /></a></td> <td><a href="?code=5"><img src="05.png" width="100" height="100" /></a></td> </tr> <tr bgcolor="#333333" style="text-align: center"> <td><a href="?code=3"><img src="03.png" width="100" height="100" /></a></td> <td><a href="?code=24"><img src="24.png" width="100" height="100" /></a></td> <td><a href="?code=2"><img src="02.png" width="100" height="100" /></a></td> <td><a href="?code=6"><img src="06.png" width="100" height="100" /></a></td> <td><a href="?code=10"><img src="10.png" width="100" height="100" /></a></td> </tr> <tr bgcolor="#333333" style="text-align: center"> <td><a href="?code=11"><img src="11.png" width="100" height="100" /></a></td> <td><a href="?code=12"><img src="12.png" width="100" height="100" /></a></td> <td><a href="?code=19"><img src="19.png" width="100" height="100" /></a></td> <td><a href="?code=14"><img src="14.png" width="100" height="100" /></a></td> <td><a href="?code=1"><img src="01.png" width="100" height="100" /></a></td> </tr> <tr bgcolor="#333333" style="text-align: center"> <td><a href="?code=20"><img src="20.png" width="100" height="100" /></a></td> <td><a href="?code=7"><img src="07.png" width="100" height="100" /></a></td> <td><a href="?code=18"><img src="18.png" width="100" height="100" /></a></td> <td><a href="?code=4"><img src="04.png" width="100" height="100" /></a></td> <td><a href="?code=16"><img src="16.png" width="100" height="100" /></a></td> </tr> <tr bgcolor="#333333" style="text-align: center"> <td><a href="?code=23"><img src="23.png" width="100" height="100" /></a></td> <td><a href="?code=15"><img src="15.png" width="100" height="100" /></a></td> <td><a href="?code=9"><img src="09.png" width="100" height="100" /></a></td> <td><a href="?code=17"><img src="17.png" width="100" height="100" /></a></td> <td><a href="?code=25"><img src="25.png" width="100" height="100" /></a></td> </tr> </table> </div> </body> </html> for anyone who wants to look at it, here is the link. http://www.zebradatasolutions.com/cipher.php Link to comment https://forums.phpfreaks.com/topic/283866-php-cipher/ Share on other sites More sharing options...
blackenedheart Posted November 13, 2013 Author Share Posted November 13, 2013 Also, the solutions offered on the original thread were absolutely brilliant. I realize that now that I have more experience with PHP. I just can't figure out why the actual cipher is not working. I have yet to see ACCESS GRANTED. Link to comment https://forums.phpfreaks.com/topic/283866-php-cipher/#findComment-1458123 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.