<?php
/*
  /$$$$$$  /$$   /$$  /$$$$$$  /$$   /$$  /$$$$$$  /$$   /$$                     /$$   /$$  /$$$$$$  /$$$$$$$$
 /$$__  $$| $$$ | $$ /$$__  $$| $$$ | $$ /$$__  $$| $$  | $$                    | $$$ | $$ /$$__  $$|__  $$__/  D
| $$  \__/| $$$$| $$| $$  \ $$| $$$$| $$| $$  \__/| $$  | $$  /$$$$$$   /$$$$$$ | $$$$| $$| $$  \ $$   | $$     O
|  $$$$$$ | $$ $$ $$| $$  | $$| $$ $$ $$| $$      | $$$$$$$$ /$$__  $$ /$$__  $$| $$ $$ $$| $$  | $$   | $$     T
 \____  $$| $$  $$$$| $$  | $$| $$  $$$$| $$      | $$__  $$| $$  \ $$| $$  \__/| $$  $$$$| $$  | $$   | $$     
 /$$  \ $$| $$\  $$$| $$  | $$| $$\  $$$| $$    $$| $$  | $$| $$  | $$| $$      | $$\  $$$| $$  | $$   | $$     C
|  $$$$$$/| $$ \  $$|  $$$$$$/| $$ \  $$|  $$$$$$/| $$  | $$|  $$$$$$/| $$      | $$ \  $$|  $$$$$$/   | $$     O
 \______/ |__/  \__/ \______/ |__/  \__/ \______/ |__/  |__/ \______/ |__/      |__/  \__/ \______/    |__/     M

                  [ A stupid website by a silly person ]
                    yo at joeltron dot com
 
# run this off server and upload contents to /content folder
# instaloader.py --no-profile-pic --no-compress-json --no-videos --login [yourusername] '#snonch'
 
*/

/* server settings */
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);

/* site settings */
$settings=array(
    'directory'        => 'content/',
    'site_name'        => 'Snonch or Not',
    'site_url'        => 'https://www.snonchornot.com/',
    'site_copy'        => '©&nbsp;'.date('Y').'&nbsp;// <a href="https://www.joeltron.com/">joeltron dot com</a>&nbsp;//&nbsp;Joeltron Trading Trust<div>If you can\'t tell, this page is sartorius and meant just for some fun.</div>

    <div class="admin">[&nbsp;<a href="/admin">admin</a>&nbsp;]</div>
    <div class="source">[&nbsp;<a href="/source">source</a>&nbsp;]</div>',
'top'            => '<span class="how">How it works:</span><ol>
    <li>Decide how SNONCHY a <a target="_BLANK" href="https://www.instagram.com/explore/search/keyword/?q=%23snonch">#snonch</a> piercing is</li>
    <li>In the pink box, click to rate the picture</li>
    <li>See what others thought on the left. Repeat</li>
    </ol>',
    'header'        => '<a href="/"><img src="/layout/SNONCH or NOT.png" alt="SNONCH or NOT"/></a>',
    'sub_header'        => 'As seen on that one weird APP class that nobody went to',
    'learn'            => '[ <a target="_BLANK" href="snonch.pdf">CLICK HERE TO LEARN WHAT A SNONCH IS</a> ]',
    'vote'            => 'Select how snonchy this #snonch is to see the next picture.',
    'onchange'        => 'this.form.submit();',
);

// connect to DB
include_once('db_connect.inc.php');

// download PDF
if(isset($_GET['class'])) {
    $_SESSION['downloaded']=true;

    $filename='snonch.pdf';
    header("Content-type:application/pdf");
    header("Content-Disposition:attachment;filename='$filename");
    header('Set-Cookie: fileLoading=true'); 
    readfile("snonch.pdf");
}

// download PDF upon 3 votes
if(isset($_SESSION['votes']) && $_SESSION['votes']>=2 && !isset($_SESSION['downloaded']))
    $settings['onchange']='pdf(); '.$settings['onchange'];
    
// restart
if(isset($_GET['restart']))
    session_regenerate_id(true);

// source
if(isset($_GET['source'])) {
    show_source('index.php');
    echo '<hr />';
    show_source('layout.inc.php');
    die;
}

// admin
if(isset($_GET['admin']))
    include_once('admin.inc.php');

// fire it up!
if (session_status() === PHP_SESSION_NONE)    session_start();
$user=session_id();
if(!isset($_SESSION['votes']))
    $_SESSION['votes']=0;

// did you just vote?
$voted=false;
if(isset($_POST['vote']) && isset($_POST['vote_for'])) {
    if(vote($link, $user, $_POST['vote_for'], $_POST['vote'])) {
        $_SESSION['votes']++;
        $ig=$_POST['vote_for'];
        $file=ig_to_file($link, $ig);
        $image=$settings['directory'].$file.'.jpg';
        if(file_exists($image)) {
            $voted=array(
                'image'        => '/'.$image,
                'vote'        => $_POST['vote'],
                'average'    => rating_av($link, $ig),
                'total'    => rating_count($link, $ig),
            );
        }
    }
}

$snonch = false;
$count=vote_count($link, $user);

// specified ID
if(isset($_GET['p']))
    $snonch=get_next($link, $settings['directory'], $user, $_GET['p']);

// non snonch yet
if(!$snonch)
    $snonch=get_next($link, $settings['directory'], $user);

// now display stuff
include_once('layout.inc.php');

/* Functions
 * ********* */
function ig_to_file($link, $ig) {
    $q="SELECT file FROM enabled WHERE instagram = '".mysqli_escape_string($link, $ig)."' AND status = true;";
    if($res=mysqli_query($link, $q))
        if($row=mysqli_fetch_assoc($res))
            return $row['file'];
    return false;
}

// change header after a few votes for lols
function dynamic_top($link, $count, $text) {
    if($count > 5) {
        $find=array(
            'SafePiercing.org',
            'SafePiercing.org.au',
            'UKAPP.org.uk',
        );

        $text='<span class="how">Find live snonches in your area!</span><ul>';
        foreach($find as $f)
            $text.='<li><a target="_BLANK" href="https://www.'.strtolower($f).'">'.$f.'</a></li>';
        $text.='</span>';
    }

    if($count > 10 ) {
        $text='<span class="how">OK... you can stop now and:</span><ol>
            <li>Go touch grass</li>
            <li>Flush and quit pooping</li>
            <li>Give joel a virtual <a href="mailto:yo@joeltron.com?subject=SNONCH4LYFE">high five</a></li>
            </ul>';
    }

    if($count > 10 ) {
        $text='<span class="how">Did you know....:</span><ol>
            <li>You can vote using your numpad?</li>
            <li>It\'ll vote 0-9 and + key is a 10</li>
            <li>(I bet you did... ya nerd)</li>
            </ul>';
    }
    if($count > 50 || isset($_GET['info']) || isset($_SESSION['stats'])) {
        // enable for this session
        $_SESSION['stats'] = true;

        // calculate
        $highest=stats_highest($link);
        $lowest=stats_lowest($link);
        $text='<span class="how">
                <span class="session_id">'.session_id().'</span><br />
                Stats stats stats!
            </span>
            <ul class="stats">
                <li><span>Total votes:</span>'.stats_votes($link).'</li>
                <li><span>Total snonches:</span>'.stats_total($link).'</li>
                <li><span>Highest average:</span><a href="/p/'.$highest['id'].'">'.$highest['vote'].'</a></li>
                <li><span>Lowest average:</span><a href="/p/'.$lowest['id'].'">'.$lowest['vote'].'</a></li>
            </ul>';
    }

    return $text;
}

function stats_votes($link) {
    $q="SELECT count(*) as count FROM votes";
    if($res=mysqli_query($link, $q))
        if($row=mysqli_fetch_assoc($res))
            return $row['count'];

    return 10;
}

function stats_total($link) {
    $q="SELECT count(*) as count FROM enabled WHERE status = true";
    if($res=mysqli_query($link, $q))
        if($row=mysqli_fetch_assoc($res))
            return $row['count'];
    return 0;
}

function stats_highest($link) {
    $q="SELECT instagram, round(AVG(vote),2) as avg FROM votes
        GROUP BY instagram
        ORDER BY avg DESC
    LIMIT 1;";
    if($res=mysqli_query($link, $q))
        if($row=mysqli_fetch_assoc($res))
            return array(
                'id'    =>    $row['instagram'],
                'vote'    =>    $row['avg'],
            );
    return false;
}

function stats_lowest($link) {
    $q="SELECT instagram, round(AVG(vote),2) as avg FROM votes
        GROUP BY instagram
        ORDER BY avg ASC
    LIMIT 1;";
    if($res=mysqli_query($link, $q))
        if($row=mysqli_fetch_assoc($res))
            return array(
                'id'    =>    $row['instagram'],
                'vote'    =>    $row['avg'],
            );
    return false;
}

function get_instagram($instagram) {
    return false;
    // settings
    $url_prefix='https://instagram.com/p/';
    $share_prefix='https://snonchornot.com/p/';

    $file=$directory.$instagram.'.json';
    if(file_exists($file)) {
        // load and decode
        $json=json_decode(file($file)[0]);

        // get what we ant out
        $content=array(
            'id'    => $json->node->id,
            'owner'    => $json->node->owner->id,
            'user'    => $json->node->owner->username,
            'url'    => $url_prefix.$json->node->shortcode,
            'share'    => $share_prefix.$json->node->shortcode,
            'text'    => $json->node->edge_media_to_caption->edges[0]->node->text,
            'image'    => $directory.$instagram.'.jpg',
        );

        if($content['user']==null) {
            //debug($content); die;
            //$conent['user']=instagram_userid_to_name($content['owner']);
        }

        return $content;
        //    debug($json);
    }
    return false;
}

function vote_count($link, $user) {
    $q="SELECT count(*) as count FROM votes WHERE user = '".mysqli_escape_string($link, $user)."' LIMIT 1";
    if($res=mysqli_query($link, $q))
        if($row=mysqli_fetch_assoc($res))
            return $row['count'];
    return 0;
}

function rating_count($link, $instagram) {
    $q="SELECT count(*) as votes FROM votes WHERE instagram = '".mysqli_escape_string($link, $instagram)."'";
    if($res=mysqli_query($link, $q))
        if($row=mysqli_fetch_assoc($res))
            return $row['votes'];
    return false;
}



function rating_av($link, $instagram) {
    $q="SELECT round(AVG(vote),0) as vote FROM votes WHERE instagram = '".mysqli_escape_string($link, $instagram)."'";
    if($res=mysqli_query($link, $q))
        if($row=mysqli_fetch_assoc($res))
            return $row['vote'];
    return false;
}

function vote($link, $user, $instagram, $vote) {
    // check for dupe
    $q="INSERT INTO `votes` (`id`, `user`, `instagram`, `vote`)
           SELECT NULL, '".mysqli_escape_string($link, $user)."', '".mysqli_escape_string($link, $instagram)."', '".mysqli_escape_string($link, floor($vote))."' FROM DUAL
           WHERE NOT EXISTS ( SELECT * FROM `votes` WHERE `user` = '".mysqli_escape_string($link, $user)."' AND `instagram` = '".mysqli_escape_string($link, $instagram)."' LIMIT 1);";

    // doesn't check for dupes (aka refresh bug)
    //$q="INSERT INTO `votes` (`id`, `user`, `instagram`, `vote`) VALUES (NULL, '".mysqli_escape_string($link, $user)."', '".mysqli_escape_string($link, $instagram)."', '".mysqli_escape_string($link, floor($vote))."');";

    $res=mysqli_query($link, $q);
    if(!mysqli_error($link))
        return true;
    return false;
}

function get_votes($link, $user) {
    $votes=array();
    $q="SELECT * from `votes` WHERE `user` = '".mysqli_escape_string($link, $user)."'";
    $res=mysqli_query($link, $q);
    while($row=mysqli_fetch_assoc($res))
        $votes[$row['instagram']]=$row['vote'];

    return $votes;
}

function get_next($link, $directory, $user, $ig=false) {
    if($ig)
        $q="SELECT * from `enabled` WHERE `instagram` = '".$ig."' AND `status` = '1' LIMIT 1";
    else
        $q="SELECT * from `enabled` WHERE `status` = '1' AND enabled.instagram NOT IN (SELECT instagram FROM votes WHERE user = '".mysqli_escape_string($link, $user)."') ORDER BY RAND() LIMIT 1;";
    $res=mysqli_query($link, $q);

    // none left!
    if(!mysqli_num_rows($res))
        return false;

    $row=mysqli_fetch_assoc($res);

    $row['image']='/'.$directory.$row['file'].'.jpg';
    $row['user']=$row['owner'];
    $row['url']='https://www.instagram.com/p/'.$row['instagram'];
    $row['share']='https://www.snonchornot.com/p/'.$row['instagram'];

//    if(is_numeric($row['user'])) {
//        debug(instagram_userid_to_name($row['user']));
//    }

    return $row;
}

function debug($input) {
    ?><pre style="color: #fff; background: #000;"><?php
    var_dump($input);
    ?></pre><?php
}

/* le fin */
?>

<?php
/*
  /$$$$$$  /$$   /$$  /$$$$$$  /$$   /$$  /$$$$$$  /$$   /$$                     /$$   /$$  /$$$$$$  /$$$$$$$$
 /$$__  $$| $$$ | $$ /$$__  $$| $$$ | $$ /$$__  $$| $$  | $$                    | $$$ | $$ /$$__  $$|__  $$__/  D
| $$  \__/| $$$$| $$| $$  \ $$| $$$$| $$| $$  \__/| $$  | $$  /$$$$$$   /$$$$$$ | $$$$| $$| $$  \ $$   | $$     O
|  $$$$$$ | $$ $$ $$| $$  | $$| $$ $$ $$| $$      | $$$$$$$$ /$$__  $$ /$$__  $$| $$ $$ $$| $$  | $$   | $$     T
 \____  $$| $$  $$$$| $$  | $$| $$  $$$$| $$      | $$__  $$| $$  \ $$| $$  \__/| $$  $$$$| $$  | $$   | $$     
 /$$  \ $$| $$\  $$$| $$  | $$| $$\  $$$| $$    $$| $$  | $$| $$  | $$| $$      | $$\  $$$| $$  | $$   | $$     C
|  $$$$$$/| $$ \  $$|  $$$$$$/| $$ \  $$|  $$$$$$/| $$  | $$|  $$$$$$/| $$      | $$ \  $$|  $$$$$$/   | $$     O
 \______/ |__/  \__/ \______/ |__/  \__/ \______/ |__/  |__/ \______/ |__/      |__/  \__/ \______/    |__/     M

                  [ A stupid website by a silly person ]
                    yo at joeltron dot com
 */

// vote html
if($snonch) {
    $settings['vote'].='<form id="vote" action="/index.php" method="POST">
        <input type="hidden" name="vote_for" value="'.$snonch['instagram'].'" />
        <ul>';
    for($a=0; $a<=10; $a++)
        $settings['vote'].='<li><input type="radio" name="vote" id="vote_'.$a.'" value="'.$a.'" onchange="'.$settings['onchange'].'"><label for="vote_'.$a.'">'.$a.'</label></li>';
    $settings['vote'].='
        </ul>
        </form>
        <div>NOT<span>&nbsp;</span>SNONCH</div>';
}

$settings['top']=dynamic_top($link, vote_count($link, $user), $settings['top']); 

// last vote
$last_content='';
if($voted) {
    $last_content.='
    <div class="last">
        <div>Last snonch</div>
        <img src="'.$voted['image'].'" />
        <table>
            <tr>
                <th>Your vote:</th>
                <td>'.$voted['vote'].'</td>
            </tr>
            <tr>
                <th>Average:</th>
                <td>'.$voted['average'].'</td>
            </tr>';
    $last_content.='<tr><th># of votes</th><td>'.$voted['total'].'</td></tr>';
    $last_content.='</table>
    </div>';
}

// main content
$main='';
if(!$snonch)
    $settings['vote']='<div class="finished">
    You somehow ran out of Snonches to vote on....<br /><br />
    I\'m not sure if I\'m impressed or embarassed for you, but in any event you can now<br/ >
    <a href="/restart">START OVER</a>
    </div>';

if($snonch)
    $main='
<table>
    <tr>
        <td class="last_td">'.$last_content.'</td>
        <td class="current" rowspan="2">
            <img src="'.$snonch['image'].'" />
            <a target="_BLANK" href="https://www.instagram.com/'.$snonch['user'].'">@'.$snonch['user'].'</a>
        </td>
    </tr>
    <tr>
        <td class="current_text_td"><div class="current_text">'.$snonch['text'].'</div></td>
    </tr>
</table>';

// links
$links='';
if($snonch)
    $links = '<div class="original"><span>Go to the original post now:</span> <a target="_BLANK" href="'.$snonch['url'].'">'.$snonch['url'].'</a></div>
    <div class="friend"><span>Share page with a friend:</span> <a target="_BLANK" href="'.$snonch['share'].'">'.$snonch['share'].'</a></div>
    <div class="remove">';
//$links .= '<span>Don\'t want your image on here?</span>That\'s ok - just <a href="mailto:yo@joeltron.com?subject=REMOVE ME FROM SNONCHorNOT!!!">hit me up</a>';
$links .= '</div>
';

?>
<html>
    <head>
        <title><?=$settings['site_name']?></title>
        <link rel="icon" type="image/png" href="/layout/favicon.png">
        <link rel='apple-touch-icon' type='image/png' href='/layout/favicon.57.png'>
        <link rel='apple-touch-icon' type='image/png' sizes='72x72' href='/layout/favicon.72.png'>
        <link rel='apple-touch-icon' type='image/png' sizes='114x114' href='/layout/favicon.114.png'>
    </head>
    <body>

<script language="javascript">
// download PDF
function pdf() {
    window.open("/class","_BLANK");
    return true;
}

// fucking nerds
addEvent(document, "keypress", function (e) {
    e = e || window.event;

    // get key input
    let vote = Number(e.key);

    // if +, then she's a 10
    if(e.keyCode == '43')
        vote="10";

    // if space, get outta here
    if(e.keyCode == '32')
        return false;

    // if voted, make the vote!
    if(vote >= 0) {
        document.getElementById('vote_'+vote).checked = true;
        document.getElementById('vote').submit();
    }
});

function addEvent(element, eventName, callback) {
    if (element.addEventListener)
        element.addEventListener(eventName, callback, false);
    else if (element.attachEvent)
        element.attachEvent("on" + eventName, callback);
    else
        element["on" + eventName] = callback;
}
</script>

<style>
    /* hax */
    .clearfix {
        clear: both !important;
        height: 0;
    }

    /* errywhere */
    body {
        width: 100%;
        position: absolute;
        font-family: 'Trebuchet MS', sans-serif;
        text-align: center;
        background: #e3d1d8 url('layout/son_bg.jpg') top left repeat;
    }
    * {
        margin: 0;
        padding: 0;
    }
    a {
        color: #5f2d50;
        font-weight: bold;    
    }

    /* purple bars */
    .admin,
    .source {
        position: absolute;
        bottom: 0.5em;
        color: #666 !important;
    }
    .admin a,
    .source a {
        color: #ccc !important;
        text-decoration: none;
    }
    .admin {
        right: 0.5em;
    }
    .source {
        left: 0.5em;
    }
    .top,
    .copy {
        background: #672952;
        color: white;
    }
    .top {
        padding: 0.5em 0 0.75em 0;
    }
    .copy {
        padding: 1em;
        position: absolute;
        left: 0px;
        bottom: 0px;
        padding: 0.5em 0;
        width: 100%;
    }
    .copy div {
        color: #ccc;
        margin-top: 0.25em;
    }
    .top a,
    .copy a {
        color: white;
    }

    /* how */
    .how {
        font-size: 2em;
        text-align: right;
        display: inline-block;
        vertical-align: top;
        font-weight: bold;
    }
    .top .session_id {
        color: #000;
        font-size: 0.5em;
    }
    .top .stats li {
        list-style: none;
        padding: 0;
    }
    .top .stats span {
        width: 8em;
        float: left;
        text-align: right;
        padding-right: 0.5em;
    }
    .top ol,
    .top ul {
        margin-left: 3em;
        display: inline-block;
    }
    .top ol,
    .top ul {
        text-align: left;
    }
    .top ol li,
    .top ul li {
        padding-left: 0.5em;
    }

    /* header */
    .header {
        margin-top: 1em;
    }
    .header img {
        max-width: 50%;
        min-width: 550px;
    }
    .sub_header {
        color: #000;
        margin-top: 0.5em;
        font-size: 1.2em;
        font-weight: bold;
    }
    .learn {
        color: #000;
        display: inline-block;
        font-size: 1.1em;
    }
    .learn a {
        color: #672952;
    }

    .learn_underline {
        height: 0;
        border-top: 2px solid #000;
        width: 95%;
        margin: auto;
        animation: blinker 1s linear infinite;
    }

    @keyframes blinker {
        50% {
            opacity: 0;
        }
    }

    /* vote */
    .vote {
        margin: 1.5em 0;
        background: #eecde7;
        border: 4px solid white;
        border-radius: 2em;
        display: inline-block;
        padding: 0.5em 1em 1em 0em;
        min-width: 550px;
    }
    .vote li {
        display: inline-block;
        margin: 0.5em 0em 0.25em 1em;
        font-size: 1.5em;
    }
    .vote input {    /* hide default */
        transform: scale(1.5);
    }
    .vote .finished {
        padding: 0.5em;
    }
    .vote a {
        display: block;
        margin-top: 0.5em;
        font-size: 2em;
        text-decoration-color: #000;
    }
    input[type='radio'] {
        -webkit-appearance: none;
        width: 1.5em;
        height: 1.5em;
        border-radius: 50%;
        outline: none;
        border: 3px solid #5f2d50;
        background: white;
    }
    input[type='radio']:before {
        content: '';
        display: block;
        width: 60%;
        height: 60%;
        margin: 20% auto;
        border-radius: 50%;
    }
    input[type="radio"]:checked:before {
        background: black;
    }
    input[type="radio"]:checked {
        border-color: #cf508b;
    }
    .vote span {
        font-size: 1.2em;
    }
    .vote label {
        font-size: 1.1em;
        padding-left: 0.5em;
        display: inline-block;
    }
    .vote div {
        font-weight: bold;
        font-size: 1.5em;
    }
    .vote div span {
        width: 60%;
        height: 0.75em;
        vertical-align: middle;
        background: linear-gradient(to right, #271721, #e74390);
        display: inline-block;
        margin: 0 0.5em;
    }

    /* main site */
    .main {
        display: inline-block;
        color: white;
    }
    .current {
        vertical-align: top;
    }
    .main .current_text_td {
        word-break: break-word;
        vertical-align: bottom;
    }
    .main .left,
    .main .current {
        font-size: 15px;
    }
    .main .last_td {
        padding: 0 1em 1em 0;
        width: 20em;
    }
    .main table {
        color: #fff;
        border-spacing: 0;
        border-collapse: none;
    }
    .main .last {
        padding: 0.5em;
        background: #672952;
        font-size: 1.5em;
        font-weight: bold;
        text-align: center;
    }
    .main .last img {
        margin: 0.5em 0;
        max-width: 100%;
    }
    .main .last table {
        font-size: 1em;
        margin: auto;
    }
    .main .last table th {
        text-align: right;
        padding-right: 1em;
    }
    .main .current {
        width: 40em;
        max-width: 25%;
        border: 1em solid #672952;
        background: #672952;
    }
    .main .current img {
        max-width: 100%;
        min-height: 20em;
        width: 100%;
    }
    .main .current a {
        color: white;
        display: block;
        text-align: center;
        font-size: 2.5em;
        padding: 0.3em 0 0.3em 0;
    }
    .main .current_text {
        background: #672952;
        font-size: 1.1em;
        padding: 1em;
        vertical-align: bottom;
        max-width: 100%;
    }

    /* links */
    .links {
        margin-bottom: 6em;    /* fix for copy */
    }
    .links div {
        text-align: left;
        padding-right: 1em;
        margin-top: 0.5em;
    }
    .links div span {
        text-align: right;
        float: left;
        width: 50%;
        padding-right: 1em;
    }
    .links div.original span,
    .links div.friend span {
        font-weight: bold;
    }
    .links .original,
    .links .friend {
        font-size: 1.25em;
    }
    .links .remove {
        margin-top: 1.5em;
        color: #333;
    }
    .links .remove a {
        color: #000;
    }
</style>
        <div class="top"><?=$settings['top']?></div>
        <div class="header"><?=$settings['header']?></div>
        <div class="sub_header"><?=$settings['sub_header']?></div>
        <div class="learn"><?=$settings['learn']?><div class="learn_underline">&nbsp;</div></div>
        <div class="clearfix">&nbsp;</div>
        <div class="vote"><?=$settings['vote']?></div>
        <div class="clearfix">&nbsp;</div>
        <div class="main"><?=$main?></div>
        <div class="links"><?=$links?></div>
        <div class="copy"><?=$settings['site_copy']?></div>
    </body>
</html>