Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*****esetleges hibak(?) kijelzese*****///hozzaadott kezdete
- error_reporting(E_NOTICE);
- /*****forras megjelenitese, ekkor: ?forras*****/
- if(isset($_GET['forras'])){highlight_file(__FILE__);exit;}
- /***********************************************///hozzaadott vege
- function getItems() {
- $db = file('db.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); //allomany tombbe olvasasa, ures sorok kihagyasaval
- $entries = array(); //tombbe rendezes?
- foreach ($db as $line) { //sorokra bontas?
- $entry = new stdClass();
- list($entry->azonosito, $entry->cim, $entry->tartalom, $entry->kulcsszavak, $entry->cimkek, $entry->bekuldo, $entry->idopont) =
- explode('||', $line); //sorbol az elkulonitett reszek valtozova alakitasa //bekuldo es idopont hozzaadott
- $entry->cimkek = array_map('trim', explode(', ', $entry->cimkek)); //cimkék szetvalogatasa vesszo utani szokoz szerint
- $entries[] = $entry;
- }
- return $entries;
- }
- function showAll() {
- $teasers = array();
- $entries = getItems();
- foreach ($entries as $entry) {
- $teasers[] = showTeaser($entry);
- }
- return showTeasers($teasers);
- }
- function showTeasers($teasers) {
- $teasers = implode("\n", $teasers);
- return <<<__HTML__
- <div class="hfeed">
- $teasers
- </div>
- __HTML__;
- }
- function showTag($tag) {
- $teasers = array();
- $entries = getItems();
- foreach ($entries as $entry) {
- if (in_array($tag, $entry->cimkek)) {
- $teasers[] = showTeaser($entry);
- }
- }
- return showTeasers($teasers);
- }
- function showItem($entry) {
- $cimkek = array_map('checkPlain', $entry->cimkek);
- $felho = '';
- foreach ($cimkek as $cimke) {
- $ecimke = urlencode($cimke);
- $felho .= <<<__HTML__
- <li>
- <a href="?tag=$ecimke" rel="tag">$cimke</a>
- </li>
- __HTML__;
- }
- $cim = checkPlain($entry->cim);
- return <<<__HTML__
- <div class="hentry">
- <h2 class="entry-title">
- <a href="?view={$entry->azonosito}">$cim</a>
- </h2>
- <div class="entry-content">
- {$entry->tartalom}
- </div>
- <ul class="tags">
- $felho
- </ul>
- </div>
- __HTML__;
- }
- function getItem($azonosito) {
- $teasers = array();
- $entries = getItems();
- foreach ($entries as $entry) {
- $teasers[] = showTeaser($entry);
- if ($entry->azonosito == $azonosito) {
- return $entry;
- }
- }
- }
- function showTeaser($entry) {
- $cimkek = array_map('checkPlain', $entry->cimkek);
- $felho = array();
- foreach ($cimkek as $cimke) {
- $ecimke = urlencode($cimke);
- $felho[] = <<<__HTML__
- <li>
- <a href="?tag=$ecimke" rel="tag">$cimke</a>
- </li>
- __HTML__;
- }
- $felho = "\n" . implode("\n", $felho);
- $cim = checkPlain($entry->cim);
- $tartalom = nl2br(checkPlain(truncate(strip_tags($entry->tartalom), 240, TRUE, TRUE)), TRUE);
- return <<<__HTML__
- <div class="hentry">
- <h2 class="entry-title">
- <a href="?view={$entry->azonosito}">$cim</a>
- </h2>
- <div class="entry-summary">
- <p>$tartalom</p>
- </div>
- <ul class="tags">$felho
- </ul>
- </div>
- __HTML__;
- }
- function truncate($text, $len, $wordSafe, $dots) {
- if (mb_strlen($text) < $len) {
- return $text;
- }
- if ($dots) {
- $len -= 1;
- }
- if ($wordSafe) {
- $text = mb_substr($text, 0, $len + 1);
- if ($lastSpace = strrpos($text, ' ')) {
- $text = substr($text, 0, $lastSpace);
- }
- else {
- $text = mb_substr($text, 0, $len);
- }
- }
- else {
- $text = mb_substr($text, 0, $len);
- }
- if ($dots) {
- $text .= '…';
- }
- return $text;
- }
- function checkPlain($text) {
- return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
- }
- $meta = array(
- 'title' => 'Oldalam címe',
- 'description' => 'Oldalam leírása',
- 'keywords' => 'kulcsszó',
- 'tags' => 'tagok',
- 'author' => 'Mórocz Tamás',
- 'copyright' => 'Mórocz Tamás, Poetro',
- );
- if (isset($_GET['view'])) { //ha a $_GET['view'] valtozo van
- $entry = getItem($_GET['view']); //akkor az ertekevel megegyezo azonositoju bejegyzes megjelenitese
- $meta = array(
- 'title' => $entry->cim,
- 'description' => truncate($entry->tartalom, 240, TRUE, TRUE),
- 'keywords' => $entry->kulcsszavak,
- 'tags' => implode(', ', $entry->cimkek),
- 'author' => 'Mórocz Tamás' . ($entry->bekuldo != 'Mórocz Tamás' ? ', ' . $entry->bekuldo : ''),
- 'copyright' => 'Mórocz Tamás, Poetro',
- );
- $title = $entry->cim;
- $output = showItem($entry);
- }
- else if (isset($_GET['tag'])) { //ha a $_GET['tag'] valtozo van
- $title = $_GET['tag'];
- $output = showTag($_GET['tag']); //akkor az ertekevel megegyezo cimkeju bejegyzesek felsorolodnak
- }
- else {
- $title = 'Címlap';
- $output = showAll(); //osszes felsorolasa
- }
- ?>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
- <html xmlns='http://www.w3.org/1999/xhtml' lang='hu'>
- <head>
- <title><?php echo checkPlain($title)?> | Valós játékleírások blog</title>
- <meta http-equiv="content-type" content="text/html;charset=utf-8" />
- <?php foreach ($meta as $name => $content): ?>
- <meta name="<?php echo checkPlain($name); ?>" content="<?php echo checkPlain($content); ?>" />
- <?php endforeach; ?>
- <link rel="stylesheet" href="http://blog.realgameguides.com/style.css" type="text/css" />
- <link rel="shortcut icon" href="http://blog.realgameguides.com/favicon.ico" type="image/x-icon" />
- </head>
- <body>
- <div id="container">
- <div id="header">
- <div id="mainnav">
- <a href="http://blog.realgameguides.com/">Főoldal</a>
- <a href="http://blog.realgameguides.com/?view=kapcsolat">Kapcsolat</a>
- </div>
- </div>
- <div id="content">
- <?php echo $output; ?>
- <div class="ad468x60">
- <script type="text/javascript">
- document.write('<a href="http:\/\/ubuntu.hu\/ismerteto\/"><img src="http:\/\/ad.realgameguides.com\/ubuntuhu.png" alt="Ubuntu" \/><\/a>');
- </script>
- <noscript>
- <div>
- <a href="http://realgameguides.com/" title="Valós Játék Leírások">
- <img class="banner468x60" src="http://realgameguides.com/img/banner.png" alt="Valós Játék Leírások" />
- </a>
- </div>
- </noscript>
- </div>
- <?php if(isset($_GET['view'])): ?>
- <iframe id="fbb" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.realgameguides.com%2F%3Fview%3D<?php echo $_GET['view']; ?>&layout=standard&show_faces=true&width=450&action=like&font&colorscheme=light&height=80"></iframe>
- <?php endif; ?>
- </div>
- <div id="footer">
- <a href="http://blog.realgameguides.com/">Nyitólap</a> |
- <a href="http://blog.realgameguides.com/?view=kapcsolat">Kapcsolat</a> |
- <a href="http://realgameguides.com/">Valós Játék Leírások</a> |
- <a href="http://validator.w3.org/check?uri=referer">
- Érvényes
- <abbr title="eXtensible HyperText Markup Language">XHTML</abbr>
- </a> |
- <a href="http://jigsaw.w3.org/css-validator/check/referer">
- Érvényes <abbr title="Cascading Style Sheets">CSS</abbr>
- </a>
- | © 2011 Mórocz Tamás, Poetro - Minden jog fenntartva!
- </div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement