Advertisement
Guest User

Untitled

a guest
May 1st, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.69 KB | None | 0 0
  1. <html>
  2. <head>
  3. <?php
  4.     $ip = $_SERVER['REMOTE_ADDR'];
  5.     //$host = gethostbyaddr($_SERVER['REMOTE_ADDR']);
  6.     $host = $_SERVER['HTTP_HOST'];
  7.     $agent = $_SERVER['HTTP_USER_AGENT'];
  8.     $bgcolor = "";
  9.     $color = "";
  10.    
  11.     require('/includes/php/cookie.php');
  12.    
  13.     $sql_host = 'localhost';
  14.     $sql_user = '**********';
  15.     $sql_pass = '******************';
  16.     $sql_db = "info_test";
  17.     $db = new mysqli($sql_host, $sql_user, $sql_pass, $sql_db);
  18.     if (mysqli_connect_errno())
  19.     {
  20.         echo('Error: Could not connect to database. Please try again later.');
  21.         exit;
  22.     }
  23.    
  24.     if(isset($_POST['changeColor']))
  25.     {
  26.         ae_put_cookie('bgcolor', $_POST['bgcolor'], 'f');
  27.         ae_put_cookie('color', $_POST['color'], 'f');
  28.         header('Location: index.php');
  29.     }
  30.    
  31.     if (!isset($_COOKIE['bgcolor']))
  32.     {
  33.         $bgcolor = '#FFFFFF';
  34.     }
  35.     else
  36.     {
  37.         $bgcolor = $_COOKIE['bgcolor'];
  38.     }
  39.     if (!isset($_COOKIE['color']))
  40.     {
  41.         $color = '#000000';
  42.     }
  43.     else
  44.     {
  45.         $color = $_COOKIE['color'];
  46.     }
  47.  
  48.     echo("
  49.     <style type=\"text/css\">
  50.         body
  51.         {
  52.             background-color: $bgcolor;
  53.             color: $color;
  54.         }
  55.         select
  56.         {
  57.             background-color: $bgcolor;
  58.             color: $color;
  59.         }
  60.     }
  61.     </style>
  62.     ");
  63. ?>
  64. </head>
  65. <body>
  66.         <fieldset style="width: 200px; float: left;">
  67.         <legend>Poll</legend>
  68.         <?php
  69.         if (isset($_POST['submitVote']) and isset($_POST['progLang']))
  70.         {  
  71.            
  72.             if (!isset($_COOKIE['voteClosed']))
  73.             {
  74.                 $query = "select * from poll_proglang";
  75.                 $result = $db->query($query);
  76.                 $row = $result->fetch_assoc();
  77.                 $phpVotes = stripslashes($row['phpVotes']);
  78.                 $pythonVotes = stripslashes($row['pythonVotes']);
  79.                 $aspVotes = stripslashes($row['aspVotes']);
  80.                 $csnetVotes = stripslashes($row['csnetVotes']);
  81.                 $value = $_POST['progLang'];
  82.                 switch($value)
  83.                 {
  84.                     default:
  85.                     echo('An error occurred while trying to process your vote, please go back and try again. (Errorcode 1)');
  86.                     break; case "PHP":
  87.                     $phpVotes += 1;
  88.                     if (!get_magic_quotes_gpc())
  89.                     {
  90.                     $phpVotes = addslashes($phpVotes);
  91.                     $pythonVotes = addslashes($pythonVotes);
  92.                     $aspVotes = addslashes($aspVotes);
  93.                     $csnetVotes = addslashes($csnetVotes);
  94.                     }
  95.                     $query = "insert into poll_proglang values ('" . $phpVotes . "', '" . $pythonVotes . "', '" . $aspVotes . "', '" . $csnetVotes . "')";
  96.                     $result = $db->query($query);
  97.                     if ($result)
  98.                     {
  99.                         echo('Vote successful!');
  100.                         setcookie('voteClosed', 'closed', 1);
  101.                     }
  102.                     else
  103.                     {
  104.                         echo('An error occurred while trying to process your vote, please go back and try again. (Errorcode 2)');
  105.                     }
  106.                     break; case "Python":
  107.                     $pythonVotes += 1;
  108.                     if (!get_magic_quotes_gpc())
  109.                     {
  110.                     $phpVotes = addslashes($phpVotes);
  111.                     $pythonVotes = addslashes($pythonVotes);
  112.                     $aspVotes = addslashes($aspVotes);
  113.                     $csnetVotes = addslashes($csnetVotes);
  114.                     }
  115.                     $query = "insert into poll_proglang values ('" . $phpVotes . "', '" . $pythonVotes . "', '" . $aspVotes . "', '" . $csnetVotes . "')";
  116.                     $result = $db->query($query);
  117.                     if ($result)
  118.                     {
  119.                         echo('Vote successful!');
  120.                         setcookie('voteClosed', 'closed', 1);
  121.                     }
  122.                     else
  123.                     {
  124.                         echo('An error occurred while trying to process your vote, please go back and try again.');
  125.                     }
  126.                     break; case "ASP":
  127.                     $aspVotes += 1;
  128.                     if (!get_magic_quotes_gpc())
  129.                     {
  130.                     $phpVotes = addslashes($phpVotes);
  131.                     $pythonVotes = addslashes($pythonVotes);
  132.                     $aspVotes = addslashes($aspVotes);
  133.                     $csnetVotes = addslashes($csnetVotes);
  134.                     }
  135.                     $query = "insert into poll_proglang values ('" . $phpVotes . "', '" . $pythonVotes . "', '" . $aspVotes . "', '" . $csnetVotes . "')";
  136.                     $result = $db->query($query);
  137.                     if ($result)
  138.                     {
  139.                         echo('Vote successful!');
  140.                         setcookie('voteClosed', 'closed', 1);
  141.                     }
  142.                     else
  143.                     {
  144.                         echo('An error occurred while trying to process your vote, please go back and try again.');
  145.                     }
  146.                     break; case "C#/.NET":
  147.                     $csnetVotes += 1;
  148.                     if (!get_magic_quotes_gpc())
  149.                     {
  150.                     $phpVotes = addslashes($phpVotes);
  151.                     $pythonVotes = addslashes($pythonVotes);
  152.                     $aspVotes = addslashes($aspVotes);
  153.                     $csnetVotes = addslashes($csnetVotes);
  154.                     }
  155.                     $query = "insert into poll_proglang values ('" . $phpVotes . "', '" . $pythonVotes . "', '" . $aspVotes . "', '" . $csnetVotes . "')";
  156.                     $result = $db->query($query);
  157.                     if ($result)
  158.                     {
  159.                         echo('Vote successful!');
  160.                         setcookie('voteClosed', 'closed', 1);
  161.                     }
  162.                     else
  163.                     {
  164.                         echo('An error occurred while trying to process your vote, please go back and try again.');
  165.                     }
  166.                 }
  167.             }
  168.             $query = "select * from poll_proglang";
  169.             $result = $db->query($query);
  170.             $row = $result->fetch_assoc();
  171.             $phpVotes = stripslashes($row['phpVotes']);
  172.             $pythonVotes = stripslashes($row['pythonVotes']);
  173.             $aspVotes = stripslashes($row['aspVotes']);
  174.             $csnetVotes = stripslashes($row['csnetVotes']);
  175.             echo("<p>Results:<br />PHP:<br />&nbsp;&nbsp;$phpVotes votes.<br />Python:<br />&nbsp;&nbsp;$pythonVotes votes.<br />ASP:<br />&nbsp;&nbsp;$aspVotes votes.<br />C#/.NET:<br />&nbsp;&nbsp;$csnetVotes votes.</p>");
  176.         }
  177.         else
  178.         {
  179.         ?>
  180.             <form action="index.php" method="post">
  181.                 <p>Today's question:<br />what programming language do you use for web development?<br /><b><i>(THIS DOES NOT  WORK)</i></b></p>
  182.                 <input type="radio" name="progLang" value="PHP" checked="checked" /><label>PHP</label><br />
  183.                 <input type="radio" name="progLang" value="Python" /><label>Python</label><br />
  184.                 <input type="radio" name="progLang" value="ASP" /><label>ASP</label><br />
  185.                 <input type="radio" name="progLang" value="C#/.NET" /><label>C#/.NET</label><br />
  186.                 <input type="submit" name="submitVote" value="Vote!" style="margin-left: auto;" />
  187.             </form>
  188.         <?php
  189.         }
  190.         ?>
  191.         </fieldset>
  192.         <div id="content" style="float: left;">
  193.             <?php echo('Server time: ' . date('H:i') . '.'); ?>
  194.             <h1>Welcome!</h1>
  195.             <p>This is a testing site for F16Gaming, feel free to play around with the tools here!</p>
  196.             <fieldset style="width: 300px;">
  197.                 <legend>Order form</legend>
  198.                 <?php
  199.                     if (isset($_POST['order']))
  200.                     {
  201.                     $tireqty = $_POST['tireqty'];
  202.                     $oilqty = $_POST['oilqty'];
  203.                     $sparkplugsqty = $_POST['sparkplugsqty'];
  204.                    
  205.                     echo('Order processed at ' . date('H:i, jS F Y') . '.');
  206.                     echo('You ordered:<br />');
  207.                     echo("
  208.                     <table style=\"border: none;\">
  209.                         <tr>
  210.                             <td style=\"width: 50px;\">$tireqty</td>
  211.                             <td style=\"width: 250px;\">Tire(s)</td>
  212.                         </tr>
  213.                         <tr>
  214.                             <td>$oilqty</td>
  215.                             <td>Oil(s)</td>
  216.                         </tr>
  217.                         <tr>
  218.                             <td>$sparkplugsqty</td>
  219.                             <td>Spark Plug(s)</td>
  220.                         </tr>
  221.                     </table>
  222.                     <form action=\"index.php\" method=\"post\">
  223.                         <input type=\"submit\" value=\"Go Back\" style=\"width: 100%;\" />
  224.                     </form>
  225.                     ");
  226.                     }
  227.                     else
  228.                     {
  229.                     ?>
  230.                     <form action="index.php" method="post">
  231.                         <table style="border: none;">
  232.                             <tr style="background-color: #CCCCCC;">
  233.                                 <td style="width: 250px; color: #000000;">Item</td>
  234.                                 <td style="width: 50px; color: #000000;">Quantity</td>
  235.                             </tr>
  236.                             <tr>
  237.                                 <td>Tires</td>
  238.                                 <td><input type="text" name="tireqty" maxlength="3" value="0" style="width: 100%;" /></td>
  239.                             </tr>
  240.                             <tr>
  241.                                 <td>Oil</td>
  242.                                 <td<input type="text" name="oilqty" maxlength="3" value="0" style="width: 100%;" /></td>
  243.                             </tr>
  244.                             <tr>
  245.                                 <td>Spark Plugs</td>
  246.                                 <td<input type="text" name="sparkplugsqty" maxlength="3" value="0" style="width: 100%;" /></td>
  247.                             </tr>
  248.                         </table>
  249.                         <input type="submit" name="order" value="Order" style="width: 49%;" />
  250.                         <input type="reset" name="resetOrder" value="Reset Fields" style="width: 49%;" />
  251.                     </form>
  252.                     <?php
  253.                     }
  254.                     ?>
  255.             </fieldset>
  256.         </div>
  257.         <fieldset style="width: 70px; float: right;">
  258.         <legend>Color changer</legend>
  259.             <form action="index.php" method="post">
  260.                 <select name="color" style="width: 70px;">
  261.                     <optgroup label="Foreground">
  262.                         <option value="#000000" selected="selected">Black</option>
  263.                         <option value="#FFFFFF">White</option>
  264.                         <option value="#FF0000">Red</option>
  265.                         <option value="#0000FF">Blue</option>
  266.                     </optgroup>
  267.                 </select><br />
  268.                 <select name="bgcolor" style="width: 70px;">
  269.                     <optgroup label="Background">
  270.                         <option value="#000000">Black</option>
  271.                         <option value="#FFFFFF" selected="selected">White</option>
  272.                         <option value="#FF0000">Red</option>
  273.                         <option value="#0000FF">Blue</option>
  274.                     </optgroup>
  275.                 </select><br />
  276.                 <input type="submit" name="changeColor" value="Change!" style="width: 70px;" />
  277.             </form>
  278.         </fieldset>
  279. </body>
  280. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement