update domain for redirection issues to 'somedomain.io' | create design
This commit is contained in:
parent
477285c775
commit
b9217121ed
|
@ -85,7 +85,7 @@ Containers between them will be connected through the `privnet` network which is
|
||||||
|
|
||||||
###### b) DNS
|
###### b) DNS
|
||||||
|
|
||||||
The `nginx` container is configured to only accept the host `mydomain.com`, it corresponds to the DNS record chosen for the production server. This domain must be added into the `/etc/hosts` file of each developer in order for them to access the web server at `mydomain.com:8080`.
|
The `nginx` container is configured to only accept the host `somedomain.io`, it corresponds to the DNS record chosen for the production server. This domain must be added into the `/etc/hosts` file of each developer in order for them to access the web server at `somedomain.io:8080`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -34,13 +34,13 @@ http {
|
||||||
listen 80 default_server;
|
listen 80 default_server;
|
||||||
listen [::]:80 default_server;
|
listen [::]:80 default_server;
|
||||||
|
|
||||||
server_name mydomain.com www.mydomain.com;
|
server_name somedomain.io www.somedomain.io;
|
||||||
|
|
||||||
root /vhost/public_html;
|
root /vhost/public_html;
|
||||||
index index.php;
|
index index.php;
|
||||||
|
|
||||||
error_log /var/log/nginx/mydomain.error.log;
|
error_log /var/log/nginx/somedomain.error.log;
|
||||||
access_log /var/log/nginx/mydomain.access.log main;
|
access_log /var/log/nginx/somedomain.access.log main;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
try_files $uri $uri/ /index.php?url=$uri;
|
try_files $uri $uri/ /index.php?url=$uri;
|
||||||
|
|
|
@ -1,60 +1,86 @@
|
||||||
<?php
|
<style type='text/css'>
|
||||||
|
.blink {
|
||||||
|
color: #ff0000;
|
||||||
|
|
||||||
try{
|
animation: blink-animation 1s steps(5, start) infinite;
|
||||||
|
-webkit-animation: blink-animation 1s steps(5, start) infinite;
|
||||||
|
}
|
||||||
|
.yay{ display: inline-block; color: #2AC940; font-size: 1.2em; margin: .5em; padding: 1em; border: 1px solid red; }
|
||||||
|
.faded{ opacity: .5; }
|
||||||
|
@keyframes blink-animation { to { visibility: hidden; } }
|
||||||
|
@-webkit-keyframes blink-animation { to { visibility: hidden; } }
|
||||||
|
a{ text-decoration: underline; color: inherit; }
|
||||||
|
h2 a { text-decoration: none; }
|
||||||
|
</style>
|
||||||
|
|
||||||
$pdo = new PDO('mysql:host=mariadb;dbname=vhost;charset=utf8', "php", "Ew1RmFFqeZOA1zwkJkocAjmepQA4JmnUW0nqDFh79jHY8aubtPO_12E9wgbNvScX0Uiv1GuUllb8YCJ00PAoh0fvNS");
|
<center>
|
||||||
|
|
||||||
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
<?php
|
||||||
$pdo->setAttribute(PDO::ATTR_TIMEOUT, 5);
|
|
||||||
$pdo->setAttribute(PDO::ERRMODE_EXCEPTION, true);
|
|
||||||
$pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
|
|
||||||
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
|
||||||
|
|
||||||
}catch(Exception $e){
|
|
||||||
printf("Cannot connect to database\n");
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 1. Create table
|
printf("<h2 class='blink'><a href=''>-- Refresh me --</a></h2>\n");
|
||||||
$create = "CREATE TABLE IF NOT EXISTS nonce (
|
|
||||||
id_nonce int NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
||||||
created_at int NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
||||||
);";
|
|
||||||
|
|
||||||
if( $errcode = $pdo->exec($create) > 0 ){
|
try{
|
||||||
printf("* [%d] cannot create table\n\n", $errcode);
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. Insert new line
|
$pdo = new PDO('mysql:host=mariadb;dbname=vhost;charset=utf8', "php", "Ew1RmFFqeZOA1zwkJkocAjmepQA4JmnUW0nqDFh79jHY8aubtPO_12E9wgbNvScX0Uiv1GuUllb8YCJ00PAoh0fvNS");
|
||||||
|
|
||||||
$pr = $pdo->prepare("INSERT INTO nonce(id_nonce, created_at) VALUES(DEFAULT, :tnow);");
|
$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
|
||||||
|
$pdo->setAttribute(PDO::ATTR_TIMEOUT, 5);
|
||||||
|
$pdo->setAttribute(PDO::ERRMODE_EXCEPTION, true);
|
||||||
|
$pdo->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
|
||||||
|
$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||||
|
|
||||||
if( $pr !== false ){
|
}catch(Exception $e){
|
||||||
$ok = $pr->execute([":tnow" => time()]);
|
printf("Cannot connect to database\n");
|
||||||
if( !$ok ){
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 1. Create table
|
||||||
|
$create = "CREATE TABLE IF NOT EXISTS nonce (
|
||||||
|
id_nonce int NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
created_at int NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);";
|
||||||
|
|
||||||
|
if( $errcode = $pdo->exec($create) > 0 ){
|
||||||
|
printf("* [%d] cannot create table\n\n", $errcode);
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. Insert new line
|
||||||
|
|
||||||
|
$pr = $pdo->prepare("INSERT INTO nonce(id_nonce, created_at) VALUES(DEFAULT, :tnow);");
|
||||||
|
|
||||||
|
if( $pr !== false ){
|
||||||
|
$ok = $pr->execute([":tnow" => time()]);
|
||||||
|
if( !$ok ){
|
||||||
|
printf("* cannot insert data\n\n");
|
||||||
|
}
|
||||||
|
}else{
|
||||||
printf("* cannot insert data\n\n");
|
printf("* cannot insert data\n\n");
|
||||||
}
|
}
|
||||||
}else{
|
|
||||||
printf("* cannot insert data\n\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. select all
|
// 3. select all
|
||||||
$st = $pdo->query("SELECT * FROM nonce ORDER BY id_nonce;");
|
$st = $pdo->query("SELECT * FROM nonce ORDER BY id_nonce DESC LIMIT 100;");
|
||||||
if( $st !== false ){
|
if( $st !== false ){
|
||||||
|
|
||||||
$nonces = $st->fetchAll();
|
$nonces = $st->fetchAll();
|
||||||
printf("<pre>\n");
|
printf("<pre>\n");
|
||||||
foreach( $nonces as $key=>$value ){
|
$max = count($nonces);
|
||||||
printf("[%d] nonce id %s created at %s\n", $key, $value['id_nonce'], date('H:i:s d/m/Y', $value['created_at']));
|
foreach( $nonces as $key=>$value ){
|
||||||
|
if( $key == 0 ){
|
||||||
|
printf("<span class='yay'>YOU ARE EXACTLY THE <strong>%d</strong>th VISITOR, CLICK <a href=''>HERE</a> TO WIN THE PRIZE !!</span>\n", $value['id_nonce']);
|
||||||
|
printf("\nWow ! Got lucky\n\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
printf("<span class='faded'>%s</span> | You are the <strong>%d</strong>th visitor, click <a href=''>here</a> to win the prize !!\n", date('H:i:s d/m/Y', $value['created_at']), $value['id_nonce']);
|
||||||
|
}
|
||||||
|
printf("</pre>\n");
|
||||||
|
|
||||||
|
}else{
|
||||||
|
printf("* cannot fetch data\n\n");
|
||||||
}
|
}
|
||||||
printf("</pre>\n");
|
|
||||||
|
|
||||||
}else{
|
?>
|
||||||
printf("* cannot fetch data\n\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
</center>
|
||||||
|
|
||||||
echo "my app";
|
|
Loading…
Reference in New Issue