Advertisement
Guest User

Untitled

a guest
May 4th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.77 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 (!$_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.');
  86.                     break; case "PHP":
  87.                     $phpVotes += 1;
  88.                     $query = "insert into poll_proglang values ('" . $phpVotes . "', '" . $pythonVotes . "', '" . $aspVotes . "', '" . $csnetVotes . "')";
  89.                     $result = $db->query($query);
  90.                     if ($result)
  91.                     {
  92.                         echo('Vote successful!');
  93.                         setcookie('voteClosed', 'closed', 1);
  94.                     }
  95.                     else
  96.                     {
  97.                         echo('An error occurred while trying to process your vote, please go back and try again.');
  98.                     }
  99.                     break; case "Python":
  100.                     $pythonVotes += 1;
  101.                     $query = "insert into poll_proglang values ('" . $phpVotes . "', '" . $pythonVotes . "', '" . $aspVotes . "', '" . $csnetVotes . "')";
  102.                     $result = $db->query($query);
  103.                     if ($result)
  104.                     {
  105.                         echo('Vote successful!');
  106.                         setcookie('voteClosed', 'closed', 1);
  107.                     }
  108.                     else
  109.                     {
  110.                         echo('An error occurred while trying to process your vote, please go back and try again.');
  111.                     }
  112.                     break; case "ASP":
  113.                     $aspVotes += 1;
  114.                     $query = "insert into poll_proglang values ('" . $phpVotes . "', '" . $pythonVotes . "', '" . $aspVotes . "', '" . $csnetVotes . "')";
  115.                     $result = $db->query($query);
  116.                     if ($result)
  117.                     {
  118.                         echo('Vote successful!');
  119.                         setcookie('voteClosed', 'closed', 1);
  120.                     }
  121.                     else
  122.                     {
  123.                         echo('An error occurred while trying to process your vote, please go back and try again.');
  124.                     }
  125.                     break; case "C#/.NET":
  126.                     $csnetVotes += 1;
  127.                     $query = "insert into poll_proglang values ('" . $phpVotes . "', '" . $pythonVotes . "', '" . $aspVotes . "', '" . $csnetVotes . "')";
  128.                     $result = $db->query($query);
  129.                     if ($result)
  130.                     {
  131.                         echo('Vote successful!');
  132.                         setcookie('voteClosed', 'closed', 1);
  133.                     }
  134.                     else
  135.                     {
  136.                         echo('An error occurred while trying to process your vote, please go back and try again.');
  137.                     }
  138.                 }
  139.             $query = "select * from poll_proglang";
  140.             $result = $db->query($query);
  141.             $row = $result->fetch_assoc();
  142.             $phpVotes = stripslashes($row['phpVotes']);
  143.             $pythonVotes = stripslashes($row['pythonVotes']);
  144.             $aspVotes = stripslashes($row['aspVotes']);
  145.             $csnetVotes = stripslashes($row['csnetVotes']);
  146.             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>");
  147.         }
  148.         else
  149.         {
  150.         ?>
  151.             <form action="index.php" method="post">
  152.                 <p>Today's question:<br />what programming language do you use for web development?<br /><b><i>(THIS DOES NOT  WORK)</i></b></p>
  153.                 <input type="radio" name="progLang" value="PHP" checked="checked" /><label>PHP</label><br />
  154.                 <input type="radio" name="progLang" value="Python" /><label>Python</label><br />
  155.                 <input type="radio" name="progLang" value="ASP" /><label>ASP</label><br />
  156.                 <input type="radio" name="progLang" value="C#/.NET" /><label>C#/.NET</label><br />
  157.                 <input type="submit" name="submitVote" value="Vote!" style="margin-left: auto;" />
  158.             </form>
  159.         <?php
  160.         }
  161.         ?>
  162.         </fieldset>
  163.         <div id="content" style="float: left;">
  164.             <?php echo('Server time: ' . date('H:i') . '.'); ?>
  165.             <h1>Welcome!</h1>
  166.             <p>This is a testing site for F16Gaming, feel free to play around with the tools here!</p>
  167.             <fieldset style="width: 300px;">
  168.                 <legend>Order form</legend>
  169.                 <?php
  170.                     if (isset($_POST['order']))
  171.                     {
  172.                     $tireqty = $_POST['tireqty'];
  173.                     $oilqty = $_POST['oilqty'];
  174.                     $sparkplugsqty = $_POST['sparkplugsqty'];
  175.                    
  176.                     echo('Order processed at ' . date('H:i, jS F Y') . '.');
  177.                     echo('You ordered:<br />');
  178.                     echo("
  179.                     <table style=\"border: none;\">
  180.                         <tr>
  181.                             <td style=\"width: 50px;\">$tireqty</td>
  182.                             <td style=\"width: 250px;\">Tire(s)</td>
  183.                         </tr>
  184.                         <tr>
  185.                             <td>$oilqty</td>
  186.                             <td>Oil(s)</td>
  187.                         </tr>
  188.                         <tr>
  189.                             <td>$sparkplugsqty</td>
  190.                             <td>Spark Plug(s)</td>
  191.                         </tr>
  192.                     </table>
  193.                     <form action=\"index.php\" method=\"post\">
  194.                         <input type=\"submit\" value=\"Go Back\" style=\"width: 100%;\" />
  195.                     </form>
  196.                     ");
  197.                     }
  198.                     else
  199.                     {
  200.                     ?>
  201.                     <form action="index.php" method="post">
  202.                         <table style="border: none;">
  203.                             <tr style="background-color: #CCCCCC;">
  204.                                 <td style="width: 250px; color: #000000;">Item</td>
  205.                                 <td style="width: 50px; color: #000000;">Quantity</td>
  206.                             </tr>
  207.                             <tr>
  208.                                 <td>Tires</td>
  209.                                 <td><input type="text" name="tireqty" maxlength="3" value="0" style="width: 100%;" /></td>
  210.                             </tr>
  211.                             <tr>
  212.                                 <td>Oil</td>
  213.                                 <td<input type="text" name="oilqty" maxlength="3" value="0" style="width: 100%;" /></td>
  214.                             </tr>
  215.                             <tr>
  216.                                 <td>Spark Plugs</td>
  217.                                 <td<input type="text" name="sparkplugsqty" maxlength="3" value="0" style="width: 100%;" /></td>
  218.                             </tr>
  219.                         </table>
  220.                         <input type="submit" name="order" value="Order" style="width: 49%;" />
  221.                         <input type="reset" name="resetOrder" value="Reset Fields" style="width: 49%;" />
  222.                     </form>
  223.                     <?php
  224.                     }
  225.                     ?>
  226.             </fieldset>
  227.         </div>
  228.         <fieldset style="width: 70px; float: right;">
  229.         <legend>Color changer</legend>
  230.             <form action="index.php" method="post">
  231.                 <select name="color" style="width: 70px;">
  232.                     <optgroup label="Foreground">
  233.                         <option value="#000000" selected="selected">Black</option>
  234.                         <option value="#FFFFFF">White</option>
  235.                         <option value="#FF0000">Red</option>
  236.                         <option value="#0000FF">Blue</option>
  237.                     </optgroup>
  238.                 </select><br />
  239.                 <select name="bgcolor" style="width: 70px;">
  240.                     <optgroup label="Background">
  241.                         <option value="#000000">Black</option>
  242.                         <option value="#FFFFFF" selected="selected">White</option>
  243.                         <option value="#FF0000">Red</option>
  244.                         <option value="#0000FF">Blue</option>
  245.                     </optgroup>
  246.                 </select><br />
  247.                 <input type="submit" name="changeColor" value="Change!" style="width: 70px;" />
  248.             </form>
  249.         </fieldset>
  250. </body>
  251. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement