Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Volby 2016</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <link rel="stylesheet" href="style.css" />
- </head>
- <body>
- <table>
- <tr>
- <td style='width: 30%;'><img class = 'newappIcon' src='images/newapp-icon.png'>
- </td>
- <td>
- <h1 id = "message"><?php echo "Volby 2016"; ?>
- </h1>
- </td>
- </tr>
- </table>
- <table>
- <tr>
- <th>Názov strany</th>
- <th>Hlasy za prvé kolo</th>
- <th>Hlasy za druhé kolo</th>
- <th>Akcie</th>
- </tr>
- </table>
- <input type="button" onclick="window.open('init.php');" class="btn" value="Create table"></input>
- <input type="button" onclick="window.open('info.php');" class="btn" value="View PHP info"></input>
- </br>
- <?php
- echo '<h2>VCAP_SERVICE Environment variable</h2>';
- echo "----------------------------------" . "</br>";
- $key = "VCAP_SERVICES";
- $value = getenv ( $key );
- echo $key . ":" . $value . "</br>";
- echo "----------------------------------" . "</br>";
- $vcap_services = json_decode($_ENV["VCAP_SERVICES" ]);
- $db = $vcap_services->{'cleardb'}[0]->credentials;
- $mysql_database = $db->name;
- $mysql_port=$db->port;
- $mysql_server_name =$db->host . ':' . $db->port;
- $mysql_username = $db->username;
- $mysql_password = $db->password;
- $con = new mysqli($mysql_server_name, $mysql_username, $mysql_password, $mysql_database);
- if (!$con){
- die ('connection failed' . mysql_error());
- }
- mysql_select_db($mysql_database,$con);
- $strsq0 = "INSERT INTO ACCESS_HISTORY ( BROWSER, IP_ADDRESS) VALUES
- ('" . $_SERVER['HTTP_USER_AGENT'] . "', '" . $_SERVER['REMOTE_ADDR'] . "');";
- $result0 = mysql_query ( $strsq0 );
- if ($result0) {
- //echo "insert success!";
- } else {
- echo "Cannot insert into the data table; check whether the table is created, or the database is active.";
- }
- $strsql = "select * from ACCESS_HISTORY ORDER BY ID DESC limit 100";
- $result = mysql_db_query ( $mysql_database, $strsql, $con );
- $row = mysql_fetch_row ( $result );
- echo '<h2>Access history</h2>';
- echo '<table class="table">';
- echo "\n<tr>\n";
- for($i = 0; $i < mysql_num_fields ( $result ); $i ++) {
- echo '<th>' . mysql_field_name ( $result, $i );
- echo "</th>\n";
- }
- echo "</tr>\n";
- mysql_data_seek ( $result, 0 );
- while ( $row = mysql_fetch_row ( $result ) ) {
- echo "<tr>\n";
- for($i = 0; $i < mysql_num_fields ( $result ); $i ++) {
- echo '<td>';
- echo "$row[$i]";
- echo '</td>';
- }
- echo "</tr>\n";
- }
- echo "</table>\n";
- mysql_free_result ( $result );
- mysql_close();
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement