Example #1
0
/**
 * Private function, returns parsed cast shownotes
 * @param array $lines shownote lines taken from current cast file
 * @return string HTML-formatted shownotes!
 */
function _castBody($lines)
{
    if ($lines === false) {
        return false;
    }
    $text = '';
    foreach ($lines as $line) {
        $line = preg_replace_callback('/\\d+:\\d+:\\d+\\s+\\*(.*)\\*/', function ($matches) {
            return "\n<h4>" . slenc($matches[1]) . "</h4>\n<dl class=\"dl-horizontal\">";
        }, $line);
        $line = preg_replace_callback('/(\\d+:\\d+:\\d+)\\s+(.*)$/', function ($matches) {
            return '<dt>' . slenc($matches[1]) . "</dt>\n\t<dd>" . slenc($matches[2]) . "</dd>";
        }, $line);
        $line = preg_replace_callback('/(\\d+:\\d+:\\d{2})(?!])/', function ($matches) {
            return '<time id="ts-' . slenc($matches[1]) . '" datetime="' . slenc($matches[1]) . '">' . slenc($matches[1]) . '</time>';
        }, $line);
        $line = preg_replace_callback('/(?i)\\b((?:(https?|irc):\\/\\/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'".,<>?«]))/', function ($matches) {
            return "[<a href='" . slenc($matches[0]) . "' class='text-info'>source</a>]";
        }, $line);
        $line = preg_replace_callback('/(?i)\\b((?:(steam):\\/\\/[^ \\n<]*))/', function ($matches) {
            return "<a href='" . slenc($matches[0]) . "' class=\"steam-link\">" . slenc($matches[0]) . "</a>";
        }, $line);
        $line = preg_replace_callback('/\\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}\\b/', function ($matches) {
            return "<a href='mailto:" . slenc($matches[0]) . "' class=\"mail-link\">" . slenc($matches[0]) . '</a>';
        }, $line);
        $line = preg_replace_callback('/((?<=^|\\s|\\(|>))@([A-Za-z0-9_]+)/i', function ($matches) {
            return $matches[1] . '<a href="https://twitter.com/' . slenc($matches[2]) . '" class="twitter-link">' . slenc($matches[2]) . '</a>';
        }, $line);
        $line = preg_replace_callback('/^\\n$/', function ($matches) {
            return "</dl>\n";
        }, $line);
        $line = preg_replace_callback('/\\t\\[(\\w+)\\](.*)/', function ($matches) {
            return "\t<dd>&lt;<span class=\"nickname\">" . $matches[1] . "</span>&gt; " . $matches[2] . "</dd>";
        }, $line);
        $line = preg_replace_callback('/\\t((?!<dd).*)$/', function ($matches) {
            return "\t<dd>" . $matches[1] . "</dd>";
        }, $line);
        $line = preg_replace_callback('/  (.*)/', function ($matches) {
            return '<p>' . $matches[1] . "</p>\n";
        }, $line);
        $line = preg_replace_callback('/\\[(\\w\\d+\\w\\d+)#([0-9:]*)\\]/', function ($matches) {
            return '<a href="/cast/' . $matches[1] . '#ts-' . $matches[2] . '">' . $matches[1] . " @ " . $matches[2] . "</a>";
        }, $line);
        $line = preg_replace_callback('/\\[(\\w\\d+\\w\\d+)\\]/', function ($matches) {
            return '<a href="/cast/' . $matches[1] . '">' . $matches[1] . "</a>";
        }, $line);
        $text .= $line;
    }
    return $text;
}
Example #2
0
\t\t\t\t\t\t<th class="col-xs-1">Rating
\t\t\t\t\t\t<th class="col-sm-2">Hosts
\t\t\t\t\t\t<th>Guests
\t\t\t\t\t</tr>
\t\t\t\t</thead>
\t\t\t\t<tbody>
CASTTABLE;
    foreach (getCasts() as $castdir) {
        $meta = getCastHeader($castdir);
        /* if published unset, skip this entry */
        $wip = "";
        if ($meta['PUBLISHED'] === '') {
            $meta['TITLE'] = 'Edit In Progress';
            $wip = "class=\"in-progress\" ";
        }
        $meta['TITLE'] = slenc($meta['TITLE']);
        // we add a zero width space to allow this to wrap better on mobile
        $meta['RECORDED'] = preg_replace('/-/', '-​', $meta['RECORDED'], 1);
        $rating = $meta['RATING'] == 'Explicit' ? '<i class="text-danger"> <abbr title="Explicit">E</abbr></i>' : ($meta['RATING'] == 'Clean' ? '<i class="text-success"> <abbr title="Clean">C</abbr></i>' : ($meta['RATING'] != '' ? '<i><abbr title="Tolerable">T</abbr></i>' : ''));
        $listHosts = "";
        $listGuests = "";
        foreach ($meta['HOSTS'] as $Host) {
            $listHosts .= nameplate($Host, 22);
        }
        foreach ($meta['GUESTS'] as $Guest) {
            $listGuests .= nameplate($Guest, 22);
        }
        echo <<<CASTENTRY
\t\t\t<tr {$wip}>
\t\t\t\t<td><a href="/cast/{$meta['SLUG']}">{$meta['SLUG']}</a></td>
\t\t\t\t<td class="hidden-xxs"><time datetime="{$meta['RECORDED']}">{$meta['RECORDED']}</time></td>
Example #3
0
     return "<time datetime=\"" . slenc($matches[1]) . '">' . slenc($matches[1]) . "</time>";
 }, $note);
 $note = preg_replace_callback('/^<time.*$/', function ($matches) {
     return "<li>" . $matches[0] . "</li>";
 }, $note);
 $note = preg_replace_callback('/(?i)\\b((?:(https?|irc):\\/\\/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'".,<>?«]))/', function ($matches) {
     return "[<a href=\"" . slenc($matches[0]) . '">' . slenc($matches[0]) . "</a>]";
 }, $note);
 $note = preg_replace_callback('/(?i)\\b((?:(steam):\\/\\/[^ \\n<]*))/', function ($matches) {
     return '<a href="' . slenc($matches[0]) . '">' . slenc($matches[0]) . "</a>";
 }, $note);
 $note = preg_replace_callback('/\\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}\\b/', function ($matches) {
     return "<a href=\"mailto:" . slenc($matches[0]) . '">' . slenc($matches[0]) . "</a>";
 }, $note);
 $note = preg_replace_callback('/((?<=^|\\s|\\(|>))@([A-Za-z0-9_]+)/i', function ($matches) {
     return $matches[1] . '<a href="https://twitter.com/' . slenc($matches[2]) . '">@' . slenc($matches[2]) . '</a>';
 }, $note);
 $note = preg_replace_callback('/^\\n$/', function ($matches) {
     return "</ul>\n";
 }, $note);
 $note = preg_replace_callback('/\\t\\[(\\w+)\\](.*)/', function ($matches) {
     return "<li>&lt;" . $matches[1] . "&gt; " . $matches[2] . "</li>";
 }, $note);
 $note = preg_replace_callback('/\\t(.*)/', function ($matches) {
     return "<li>" . $matches[1] . "</li>";
 }, $note);
 $note = preg_replace_callback('/  (.*)/', function ($matches) {
     return "\t\t\t<p>" . $matches[1] . "</p>";
 }, $note);
 $note = preg_replace_callback('/\\[(\\w\\d+\\w\\d+)#([0-9:]*)\\]/', function ($matches) {
     return "\t\t\t<a href=\"https://steamlug.org/cast/" . $matches[1] . '#ts-' . $matches[2] . '">' . $matches[1] . " @ " . $matches[2] . "</a>";
<?php

header('Content-Type: text/html; charset=UTF-8');
include_once 'includes/functions_cast.php';
function slenc($u)
{
    return htmlentities($u, ENT_QUOTES, "UTF-8");
}
/* User wanting to see a specific cast, and shownotes file exists */
if ($season !== "00" && $episode !== "00" && ($meta = getCastHeader($slug))) {
    $shownotes = getCastBody($slug);
    $meta['RECORDED'] = $meta['RECORDED'] === '' ? "N/A" : $meta['RECORDED'];
    echo "{$meta['DESCRIPTION']}<br>\n<br>\n";
    echo "Shownotes featuring full descriptions and links can be found at https://steamlug.org/cast/{$meta['SLUG']}<br>\n";
    echo "This cast was recorded on {$meta['RECORDED']}<br>\n<br>\n";
    foreach ($shownotes as $note) {
        preg_replace_callback('/(\\d+:\\d+:\\d+)\\s+\\*(.*)\\*/', function ($matches) {
            print slenc($matches[1]) . " " . slenc($matches[2]) . "<br>";
        }, $note);
    }
    echo "<br>\nSteamLUG Cast is a casual, fortnightly audiocast which aims to provide interesting news and discussion for the SteamLUG and broader Linux gaming communities.<br>\n";
    echo "Visit our site http://steamlug.org/ and the cast homepage http://steamlug.org/cast<br>\n";
    echo "Email us feedback, questions, tips and suggestions to cast@steamlug.org<br>\n";
    echo "We can be followed on Twitter http://twitter.com/steamlug\n";
}
/**
 * Private function, returns parsed cast shownotes
 * @param array $lines shownote lines taken from current cast file
 * @param bool $feed produce feed (XML) friendly markup
 * @return string HTML-formatted shownotes!
 */
function _castBody($lines, $feed = false)
{
    if ($lines === false) {
        return false;
    }
    $text = "";
    foreach ($lines as $line) {
        $line = preg_replace_callback('/\\d+:\\d+:\\d+\\s+\\*(.*)\\*/', function ($matches) {
            return "\n<h4>" . slenc($matches[1]) . "</h4>\n<dl class=\"dl-horizontal\">";
        }, $line);
        if ($feed) {
            $line = preg_replace_callback('/(\\d+:\\d+:\\d{2})(?!])/', function ($matches) {
                return "<time datetime=\"" . slenc($matches[1]) . '">' . slenc($matches[1]) . "</time>";
            }, $line);
            $line = preg_replace_callback('/^<time.*$/', function ($matches) {
                return "<li>" . $matches[0] . "</li>";
            }, $line);
            $line = preg_replace_callback('/(?i)\\b((?:(https?|irc):\\/\\/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'".,<>?«]))/', function ($matches) {
                return "[<a href=\"" . slenc($matches[0]) . "\" class=\"text-info\">" . slenc($matches[0]) . "</a>]";
            }, $line);
        } else {
            $line = preg_replace_callback('/(\\d+:\\d+:\\d+)\\s+(.*)$/', function ($matches) {
                return "<dt>" . slenc($matches[1]) . "</dt>\n\t<dd>" . slenc($matches[2]) . "</dd>";
            }, $line);
            $line = preg_replace_callback('/(\\d+:\\d+:\\d{2})(?!])/', function ($matches) {
                return "<time id=\"ts-" . slenc($matches[1]) . "\" datetime=\"" . slenc($matches[1]) . "\">" . slenc($matches[1]) . "</time>";
            }, $line);
            $line = preg_replace_callback('/(?i)\\b((?:(https?|irc):\\/\\/)(?:[^\\s()<>]+|\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\))+(?:\\(([^\\s()<>]+|(\\([^\\s()<>]+\\)))*\\)|[^\\s`!()\\[\\]{};:\'".,<>?«]))/', function ($matches) {
                return "[<a href=\"" . slenc($matches[0]) . "\" class=\"text-info\">source</a>]";
            }, $line);
        }
        $line = preg_replace_callback('/`([^`]*)`/', function ($matches) {
            return "<code>" . $matches[1] . "</code>";
        }, $line);
        $line = preg_replace_callback('/(?i)\\b((?:(steam):\\/\\/[^ \\n<]*))/', function ($matches) {
            return "<a href=\"" . slenc($matches[0]) . "\" class=\"steam-link\">" . slenc($matches[0]) . "</a>";
        }, $line);
        $line = preg_replace_callback('/\\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}\\b/', function ($matches) {
            return "<a href=\"mailto:" . slenc($matches[0]) . "\" class=\"mail-link\">" . slenc($matches[0]) . "</a>";
        }, $line);
        $line = preg_replace_callback('/((?<=^|\\s|\\(|>))@([A-Za-z0-9_]+)/i', function ($matches) {
            return $matches[1] . "<a href=\"https://twitter.com/" . slenc($matches[2]) . "\" class=\"twitter-link\">" . slenc($matches[2]) . "</a>";
        }, $line);
        $line = preg_replace_callback('/^\\n$/', function ($matches) {
            return "</dl>\n";
        }, $line);
        $line = preg_replace_callback('/\\t\\[(\\w+)\\](.*)/', function ($matches) {
            return "\t<dd>&lt;<span class=\"nickname\">" . $matches[1] . "</span>&gt; " . $matches[2] . "</dd>";
        }, $line);
        $line = preg_replace_callback('/\\t((?!<dd).*)$/', function ($matches) {
            return "\t<dd>" . $matches[1] . "</dd>";
        }, $line);
        $line = preg_replace_callback('/  (.*)/', function ($matches) {
            return "<p>" . $matches[1] . "</p>\n";
        }, $line);
        $line = preg_replace_callback('/\\[(\\w\\d+\\w\\d+)#([0-9:]*)\\]/', function ($matches) {
            return "<a href=\"/cast/" . $matches[1] . "#ts-" . $matches[2] . "\">" . $matches[1] . " @ " . $matches[2] . "</a>";
        }, $line);
        $line = preg_replace_callback('/\\[(\\w\\d+\\w\\d+)\\]/', function ($matches) {
            return "<a href=\"/cast/" . $matches[1] . "\">" . $matches[1] . "</a>";
        }, $line);
        if ($feed) {
            /* Misc tidy up to match our current output (so we don’t trigger a bunch of new episode downloads */
            $line = preg_replace('/ter-link\\">/', "ter-link\">@", $line);
            $line = preg_replace('/ class="[^"]*"/', "", $line);
            $line = preg_replace('/dl>/', "ul>", $line);
            $line = preg_replace('/dd>/', "li>", $line);
            $line = preg_replace('/h4>/', "p>", $line);
            $line = preg_replace('/"\\/cast\\//', "\"https://steamlug.org/cast/", $line);
            $line = preg_replace('/\\t/', "", $line);
        }
        $text .= $line;
    }
    return $text;
}