Advertisement
Guest User

Untitled

a guest
Apr 9th, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Volby 2016</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <link rel="stylesheet" href="style.css" />
  7. </head>
  8. <body>
  9.  
  10.  
  11. <table>
  12. <tr>
  13. <td style='width: 30%;'><img class = 'newappIcon' src='images/newapp-icon.png'>
  14. </td>
  15. <td>
  16. <h1 id = "message"><?php echo "Volby 2016"; ?>
  17. </h1>
  18.  
  19. </td>
  20. </tr>
  21. </table>
  22.  
  23. <table>
  24. <tr>
  25. <th>Názov strany</th>
  26. <th>Hlasy za prvé kolo</th>
  27. <th>Hlasy za druhé kolo</th>
  28. <th>Akcie</th>
  29. </tr>
  30. </table>
  31.  
  32. <input type="button" onclick="window.open('init.php');" class="btn" value="Create table"></input>
  33. <input type="button" onclick="window.open('info.php');" class="btn" value="View PHP info"></input>
  34. </br>
  35.  
  36. <?php
  37. echo '<h2>VCAP_SERVICE Environment variable</h2>';
  38. echo "----------------------------------" . "</br>";
  39. $key = "VCAP_SERVICES";
  40. $value = getenv ( $key );
  41. echo $key . ":" . $value . "</br>";
  42. echo "----------------------------------" . "</br>";
  43. $vcap_services = json_decode($_ENV["VCAP_SERVICES" ]);
  44. $db = $vcap_services->{'cleardb'}[0]->credentials;
  45. $mysql_database = $db->name;
  46. $mysql_port=$db->port;
  47. $mysql_server_name =$db->host . ':' . $db->port;
  48. $mysql_username = $db->username;
  49. $mysql_password = $db->password;
  50.  
  51. $con = new mysqli($mysql_server_name, $mysql_username, $mysql_password, $mysql_database);
  52. if (!$con){
  53. die ('connection failed' . mysql_error());
  54. }
  55. mysql_select_db($mysql_database,$con);
  56.  
  57. $strsq0 = "INSERT INTO ACCESS_HISTORY ( BROWSER, IP_ADDRESS) VALUES
  58. ('" . $_SERVER['HTTP_USER_AGENT'] . "', '" . $_SERVER['REMOTE_ADDR'] . "');";
  59. $result0 = mysql_query ( $strsq0 );
  60. if ($result0) {
  61. //echo "insert success!";
  62. } else {
  63. echo "Cannot insert into the data table; check whether the table is created, or the database is active.";
  64. }
  65. $strsql = "select * from ACCESS_HISTORY ORDER BY ID DESC limit 100";
  66.  
  67. $result = mysql_db_query ( $mysql_database, $strsql, $con );
  68.  
  69. $row = mysql_fetch_row ( $result );
  70.  
  71. echo '<h2>Access history</h2>';
  72. echo '<table class="table">';
  73. echo "\n<tr>\n";
  74. for($i = 0; $i < mysql_num_fields ( $result ); $i ++) {
  75. echo '<th>' . mysql_field_name ( $result, $i );
  76. echo "</th>\n";
  77. }
  78. echo "</tr>\n";
  79.  
  80. mysql_data_seek ( $result, 0 );
  81.  
  82. while ( $row = mysql_fetch_row ( $result ) ) {
  83. echo "<tr>\n";
  84. for($i = 0; $i < mysql_num_fields ( $result ); $i ++) {
  85. echo '<td>';
  86. echo "$row[$i]";
  87. echo '</td>';
  88.  
  89. }
  90. echo "</tr>\n";
  91. }
  92. echo "</table>\n";
  93.  
  94. mysql_free_result ( $result );
  95. mysql_close();
  96. ?>
  97.  
  98. </body>
  99. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement