Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $userIP = $_SERVER['REMOTE_ADDR'];
- $longIP = ip2long($userIP);
- $content = $_POST["txtSuggestion"];
- $con = mysql_connect( "localhost","lolerman","root" );
- $postcount = 0;
- $duplicate = 0;
- if ( !$con ){
- die( 'Could not connect: ' . mysql_error() );
- } else {
- mysql_select_db( "lolerman_lolerstream", $con );
- $query = "SELECT * FROM suggestions WHERE IP = $longIP";
- $result1 = mysql_query( $query,$con ) or die( 'Could not execute query: ' . mysql_error() );
- if ( mysql_num_rows( $result1 ) ) {
- while ($row1 = mysql_fetch_array($result1, MYSQL_ASSOC)) {
- if (preg_replace('/\s+/', '', $content) != preg_replace('/\s+/', '', $row1['content'])) {
- if (strtotime($row1['submitdate']) == strtotime(date("m/d/Y"))){
- $postcount += 1;
- }
- } else {
- $duplicate = 1;
- break;
- }
- }
- }
- if ($postcount < 3) {
- if ($duplicate == 0){
- $today = date("m/d/Y");
- $query = "INSERT INTO suggestions (content, submitdate, IP) VALUES ('$content', '$today', $longIP)";
- $result = mysql_query( $query,$con ) or die( 'Could not execute query: ' . mysql_error() );
- //echo "<script type='text/javascript'>refreshsuggestions();</script>";
- } else {
- echo "<script type='text/javascript'>alert('You already suggested that.');</script>";
- }
- } else {
- echo "<script type='text/javascript'>alert('You have exceeded your suggestion limit for the day.');</script>";
- }
- }
- mysql_close($con);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment