Last active
July 22, 2017 09:50
-
-
Save roamn/bc4b64d811aeed2f327b0b9195688844 to your computer and use it in GitHub Desktop.
Поздравлялка
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$json = file_get_contents ( 'http://rdesign-studio.ru/congratulation.json' ); | |
$obj = json_decode ( $json ); | |
$data = new stdClass(); | |
$data->date = explode( '.', date('d.m.Y') ); | |
$data->birthday = explode( '.', $obj->date ); | |
$data->user_name = $obj->name; | |
$data->age = 0; | |
$data->is_birthday = false; | |
$data->congratulation = ''; | |
if ( $data->date[0] === $data->birthday[0] | |
&& $data->date[1] === $data->birthday[1] ) { | |
$data->age = $data->date[2] - $data->birthday[2]; | |
$data->is_birthday = true; | |
} | |
if ( $data->is_birthday ) { | |
$data->congratulation_page_title = str_replace( '%age%', $data->age, $obj->page_title ); | |
$data->congratulation_title = str_replace( '%age%', $data->age, $obj->title ); | |
$data->congratulation_body = $obj->congratulation; | |
$data->img = $obj->img_url; | |
} | |
?> | |
<?php if ( $data->is_birthday ) : ?> | |
<!DOCTYPE html> | |
<html lang="ru"> | |
<head> | |
<meta charset="UTF-8"> | |
<title><?= $data->congratulation_page_title ?></title> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | |
<style> | |
p { | |
font-size: 24px; | |
text-align: center; | |
} | |
h2 { | |
text-align: center; | |
font-size: 48px; | |
} | |
img { | |
margin-left: auto; | |
margin-right: auto; | |
} | |
.row {margin-top: 30px;} | |
.row:first-child {margin-top: 0;} | |
[class*="col-"] {margin-top: 15px;} | |
[class*="col-"]:first-child {margin-top: 0;} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-xs-12"> | |
<h2><?= $data->congratulation_title ?></h2> | |
</div> | |
</div> | |
<div class="row"> | |
<div class="col-xs-12"> | |
<img src="<?= $data->img ?>" alt="" class="img-responsive"> | |
</div> | |
<div class="col-xs-12"> | |
<p><i><?= $data->congratulation_body ?></i></p> | |
</div> | |
</div> | |
</div> | |
</body> | |
</html> | |
<?php endif; ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"img_url": "http://s018.radikal.ru/i517/1309/16/1b45c84bca00.jpg", | |
"page_title": "С %age% днем рождения!", | |
"title": "С %age% днем рождения!", | |
"congratulation": "Желаю построить свое казино, с блэкджеком и шлюхами!!!", | |
"date" : "22.07.1986", | |
"name" : "Костя" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment