Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <?php
- $ip = $_SERVER['REMOTE_ADDR'];
- //$host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
- $host = $_SERVER['HTTP_HOST'];
- $agent = $_SERVER['HTTP_USER_AGENT'];
- $bgcolor = "";
- $color = "";
- require('/includes/php/cookie.php');
- $sql_host = 'localhost';
- $sql_user = '**********';
- $sql_pass = '******************';
- $sql_db = "info_test";
- $db = new mysqli($sql_host, $sql_user, $sql_pass, $sql_db);
- if (mysqli_connect_errno())
- {
- echo('Error: Could not connect to database. Please try again later.');
- exit;
- }
- if(isset($_POST['changeColor']))
- {
- ae_put_cookie('bgcolor', $_POST['bgcolor'], 'f');
- ae_put_cookie('color', $_POST['color'], 'f');
- header('Location: index.php');
- }
- if (!isset($_COOKIE['bgcolor']))
- {
- $bgcolor = '#FFFFFF';
- }
- else
- {
- $bgcolor = $_COOKIE['bgcolor'];
- }
- if (!isset($_COOKIE['color']))
- {
- $color = '#000000';
- }
- else
- {
- $color = $_COOKIE['color'];
- }
- echo("
- <style type=\"text/css\">
- body
- {
- background-color: $bgcolor;
- color: $color;
- }
- select
- {
- background-color: $bgcolor;
- color: $color;
- }
- }
- </style>
- ");
- ?>
- </head>
- <body>
- <fieldset style="width: 200px; float: left;">
- <legend>Poll</legend>
- <?php
- if (isset($_POST['submitVote']) and isset($_POST['progLang']))
- {
- if (!isset($_COOKIE['voteClosed']))
- {
- $query = "select * from poll_proglang";
- $result = $db->query($query);
- $row = $result->fetch_assoc();
- $phpVotes = stripslashes($row['phpVotes']);
- $pythonVotes = stripslashes($row['pythonVotes']);
- $aspVotes = stripslashes($row['aspVotes']);
- $csnetVotes = stripslashes($row['csnetVotes']);
- $value = $_POST['progLang'];
- switch($value)
- {
- default:
- echo('An error occurred while trying to process your vote, please go back and try again. (Errorcode 1)');
- break; case "PHP":
- $phpVotes += 1;
- if (!get_magic_quotes_gpc())
- {
- $phpVotes = addslashes($phpVotes);
- $pythonVotes = addslashes($pythonVotes);
- $aspVotes = addslashes($aspVotes);
- $csnetVotes = addslashes($csnetVotes);
- }
- $query = "insert into poll_proglang values ('" . $phpVotes . "', '" . $pythonVotes . "', '" . $aspVotes . "', '" . $csnetVotes . "')";
- $result = $db->query($query);
- if ($result)
- {
- echo('Vote successful!');
- setcookie('voteClosed', 'closed', 1);
- }
- else
- {
- echo('An error occurred while trying to process your vote, please go back and try again. (Errorcode 2)');
- }
- break; case "Python":
- $pythonVotes += 1;
- if (!get_magic_quotes_gpc())
- {
- $phpVotes = addslashes($phpVotes);
- $pythonVotes = addslashes($pythonVotes);
- $aspVotes = addslashes($aspVotes);
- $csnetVotes = addslashes($csnetVotes);
- }
- $query = "insert into poll_proglang values ('" . $phpVotes . "', '" . $pythonVotes . "', '" . $aspVotes . "', '" . $csnetVotes . "')";
- $result = $db->query($query);
- if ($result)
- {
- echo('Vote successful!');
- setcookie('voteClosed', 'closed', 1);
- }
- else
- {
- echo('An error occurred while trying to process your vote, please go back and try again.');
- }
- break; case "ASP":
- $aspVotes += 1;
- if (!get_magic_quotes_gpc())
- {
- $phpVotes = addslashes($phpVotes);
- $pythonVotes = addslashes($pythonVotes);
- $aspVotes = addslashes($aspVotes);
- $csnetVotes = addslashes($csnetVotes);
- }
- $query = "insert into poll_proglang values ('" . $phpVotes . "', '" . $pythonVotes . "', '" . $aspVotes . "', '" . $csnetVotes . "')";
- $result = $db->query($query);
- if ($result)
- {
- echo('Vote successful!');
- setcookie('voteClosed', 'closed', 1);
- }
- else
- {
- echo('An error occurred while trying to process your vote, please go back and try again.');
- }
- break; case "C#/.NET":
- $csnetVotes += 1;
- if (!get_magic_quotes_gpc())
- {
- $phpVotes = addslashes($phpVotes);
- $pythonVotes = addslashes($pythonVotes);
- $aspVotes = addslashes($aspVotes);
- $csnetVotes = addslashes($csnetVotes);
- }
- $query = "insert into poll_proglang values ('" . $phpVotes . "', '" . $pythonVotes . "', '" . $aspVotes . "', '" . $csnetVotes . "')";
- $result = $db->query($query);
- if ($result)
- {
- echo('Vote successful!');
- setcookie('voteClosed', 'closed', 1);
- }
- else
- {
- echo('An error occurred while trying to process your vote, please go back and try again.');
- }
- }
- }
- $query = "select * from poll_proglang";
- $result = $db->query($query);
- $row = $result->fetch_assoc();
- $phpVotes = stripslashes($row['phpVotes']);
- $pythonVotes = stripslashes($row['pythonVotes']);
- $aspVotes = stripslashes($row['aspVotes']);
- $csnetVotes = stripslashes($row['csnetVotes']);
- echo("<p>Results:<br />PHP:<br /> $phpVotes votes.<br />Python:<br /> $pythonVotes votes.<br />ASP:<br /> $aspVotes votes.<br />C#/.NET:<br /> $csnetVotes votes.</p>");
- }
- else
- {
- ?>
- <form action="index.php" method="post">
- <p>Today's question:<br />what programming language do you use for web development?<br /><b><i>(THIS DOES NOT WORK)</i></b></p>
- <input type="radio" name="progLang" value="PHP" checked="checked" /><label>PHP</label><br />
- <input type="radio" name="progLang" value="Python" /><label>Python</label><br />
- <input type="radio" name="progLang" value="ASP" /><label>ASP</label><br />
- <input type="radio" name="progLang" value="C#/.NET" /><label>C#/.NET</label><br />
- <input type="submit" name="submitVote" value="Vote!" style="margin-left: auto;" />
- </form>
- <?php
- }
- ?>
- </fieldset>
- <div id="content" style="float: left;">
- <?php echo('Server time: ' . date('H:i') . '.'); ?>
- <h1>Welcome!</h1>
- <p>This is a testing site for F16Gaming, feel free to play around with the tools here!</p>
- <fieldset style="width: 300px;">
- <legend>Order form</legend>
- <?php
- if (isset($_POST['order']))
- {
- $tireqty = $_POST['tireqty'];
- $oilqty = $_POST['oilqty'];
- $sparkplugsqty = $_POST['sparkplugsqty'];
- echo('Order processed at ' . date('H:i, jS F Y') . '.');
- echo('You ordered:<br />');
- echo("
- <table style=\"border: none;\">
- <tr>
- <td style=\"width: 50px;\">$tireqty</td>
- <td style=\"width: 250px;\">Tire(s)</td>
- </tr>
- <tr>
- <td>$oilqty</td>
- <td>Oil(s)</td>
- </tr>
- <tr>
- <td>$sparkplugsqty</td>
- <td>Spark Plug(s)</td>
- </tr>
- </table>
- <form action=\"index.php\" method=\"post\">
- <input type=\"submit\" value=\"Go Back\" style=\"width: 100%;\" />
- </form>
- ");
- }
- else
- {
- ?>
- <form action="index.php" method="post">
- <table style="border: none;">
- <tr style="background-color: #CCCCCC;">
- <td style="width: 250px; color: #000000;">Item</td>
- <td style="width: 50px; color: #000000;">Quantity</td>
- </tr>
- <tr>
- <td>Tires</td>
- <td><input type="text" name="tireqty" maxlength="3" value="0" style="width: 100%;" /></td>
- </tr>
- <tr>
- <td>Oil</td>
- <td<input type="text" name="oilqty" maxlength="3" value="0" style="width: 100%;" /></td>
- </tr>
- <tr>
- <td>Spark Plugs</td>
- <td<input type="text" name="sparkplugsqty" maxlength="3" value="0" style="width: 100%;" /></td>
- </tr>
- </table>
- <input type="submit" name="order" value="Order" style="width: 49%;" />
- <input type="reset" name="resetOrder" value="Reset Fields" style="width: 49%;" />
- </form>
- <?php
- }
- ?>
- </fieldset>
- </div>
- <fieldset style="width: 70px; float: right;">
- <legend>Color changer</legend>
- <form action="index.php" method="post">
- <select name="color" style="width: 70px;">
- <optgroup label="Foreground">
- <option value="#000000" selected="selected">Black</option>
- <option value="#FFFFFF">White</option>
- <option value="#FF0000">Red</option>
- <option value="#0000FF">Blue</option>
- </optgroup>
- </select><br />
- <select name="bgcolor" style="width: 70px;">
- <optgroup label="Background">
- <option value="#000000">Black</option>
- <option value="#FFFFFF" selected="selected">White</option>
- <option value="#FF0000">Red</option>
- <option value="#0000FF">Blue</option>
- </optgroup>
- </select><br />
- <input type="submit" name="changeColor" value="Change!" style="width: 70px;" />
- </form>
- </fieldset>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement