if (!isOK($_GET['q']) && !isOK($_GET['game']) && !isOK($_GET['gametype'])) {
        $inPageTitle = 'Latest maps';
        $pageTitle = 'Map Factory - the game map database';
        $pageDescriptiom = 'Download custom Maps for your favorit FPS (First Person Shooters) games, and submit your own maps.';
    } else {
        $pageTitle = '';
        if (isOK($_GET['q'])) {
            $pageTitle .= 'Results for "' . utf8_encode(htmlspecialchars(rawurldecode(stripslashes($_GET['q'])))) . '"';
            $pageDescriptiom = 'Search results for ' . utf8_encode(htmlspecialchars(rawurldecode(stripslashes($_GET['q']))));
        } else {
            $pageDescriptiom = 'Download a large selection of the best';
        }
        if (isOK($_GET['game'])) {
            $rs = $db->select('SELECT name FROM game WHERE guid="' . $_GET['game'] . '"');
            $pageTitle .= (isOK($_GET['q']) ? ' in ' : '') . $rs['result'][0]['name'];
            $pageDescriptiom .= (isOK($_GET['q']) ? ' in ' : ' ') . $rs['result'][0]['name'];
            $pageKeyword = $rs['result'][0]['name'] . ', ' . $pageKeyword;
        }
        if (isOK($_GET['gametype'])) {
            $rs = $db->select('SELECT name FROM gametype WHERE guid="' . $_GET['gametype'] . '"');
            $pageTitle .= ' ' . $rs['result'][0]['name'];
            $pageDescriptiom .= ' ' . $rs['result'][0]['name'];
            $pageKeyword = $rs['result'][0]['name'] . ', ' . $pageKeyword;
        }
        $pageTitle .= ' maps';
        $pageDescriptiom .= ' maps';
        $inPageTitle = $pageTitle;
    }
}
$tpl->assignVar(array('page_title' => encodeCurly($inPageTitle), 'PAGE_TITLE' => encodeCurly($pageTitle), 'PAGE_DESCRIPTION' => encodeCurly($pageDescriptiom), 'PAGE_KEYWORDS' => encodeCurly($pageKeyword)));
<?php

/////////////////////////
// LATEST COMMENTS
/////////////////////////
$tpl->setCacheKey('cached/latest_comment.tpl', 'latest_comment');
if ($tpl->isCached('cached/latest_comment.tpl', 60) == false) {
    $rs = $db->select('SELECT
            c.date      AS date,
            c.name      AS name,
            c.message   AS message

            FROM  map_comment AS c
            JOIN  map         AS m ON c.map_id=m.id

            WHERE     c.status = 1
            AND       m.date < ' . time() . '
            AND       m.status = 1

            ORDER BY c.date DESC', 0, 14);
    foreach ($rs['result'] as $key => $item) {
        $tpl->assignLoopVar('comment', array('date' => timeWarp($item['date']), 'name' => $item['name'], 'message' => encodeCurly(cutText($item['message'], 120))));
    }
}
    $rs_response = $db->select('SELECT date, parent_id, name, message
    		FROM map_comment
    		WHERE parent_id IN (' . implode(',', $idList) . ') AND status = 1
    		ORDER BY date ASC');
    $n = 0;
    foreach ($rs['result'] as $comment) {
        $message = nl2br($comment['message']);
        $message = preg_replace('/([\\t\\r\\n\\v\\f]+)/is', '', $message);
        $message = preg_replace('/((?:<br \\/>){2,})/is', '<br /><br />', $message);
        $tpl->assignLoopVar('comment', array('time' => timeWarp($comment['date']), 'name' => encodeCurly($comment['name']), 'message' => encodeCurly($message), 'id' => $comment['id']));
        foreach ($rs_response['result'] as $response) {
            if ($response['parent_id'] == $comment['id']) {
                $message = nl2br($response['message']);
                $message = preg_replace('/([\\t\\r\\n\\v\\f]+)/is', '', $message);
                $message = preg_replace('/((?:<br \\/>){2,})/is', '<br /><br />', $message);
                $tpl->assignLoopVar('comment.response', array('time' => timeWarp($response['date']), 'name' => encodeCurly($response['name']), 'message' => encodeCurly($message)));
            }
        }
        $n++;
        if ($n > COMMENT_PER_PAGE) {
            break;
        }
    }
} else {
    $tpl->assignVar('commentDisplay', 'none');
    $tpl->assignVar('commentClass', 'off');
}
/////////////////////////
// PAGINATION
/////////////////////////
$pageTotal = ceil($rs['total'] / COMMENT_PER_PAGE);
Exemple #4
0
/////////////////////////
// STATS
/////////////////////////
$tpl->setCacheKey('cached/author_stat.tpl', 'author_stat_' . $_GET['author']);
if ($tpl->isCached('cached/author_stat.tpl', 60) == false) {
    $rs = $db->select('SELECT
            SUM(DISTINCT m.download)          AS download,
            COUNT(DISTINCT c.id)              AS comment,
            COUNT(m.id)                       AS map

            FROM              map             AS m
            JOIN              game            AS g    ON m.game_id = g.id
            JOIN              gametype        AS t    ON m.gametype_id = t.id
            JOIN              author          AS a    ON m.author_id = a.id
            LEFT OUTER JOIN   map_comment     AS c    ON c.map_id=m.id AND c.status=1

            WHERE     m.status = 1
            AND       a.id = ' . $_GET['author'] . '
            AND       m.date < ' . time() . '
            AND       g.status = 1
            AND       t.status = 1
            AND       a.status = 1

            GROUP BY a.id');
    $tpl->assignVar(array('downloadTotal' => $rs['result'][0]['download'], 'commentTotal' => $rs['result'][0]['comment'], 'mapTotal' => $rs['result'][0]['map']));
}
/////////////////////////
// PAGE INFOS
/////////////////////////
$tpl->assignVar(array('PAGE_TITLE' => encodeCurly($authorName . ' maps'), 'PAGE_DESCRIPTION' => encodeCurly('Download all the maps made by ' . $authorName . ' on Map Factory.'), 'PAGE_KEYWORDS' => encodeCurly($authorName . ', ' . implode(', ', $keywordList))));
            FROM              map             AS m
            JOIN              game            AS g    ON m.game_id = g.id
            JOIN              gametype        AS t    ON m.gametype_id = t.id
            JOIN              author          AS a    ON m.author_id = a.id
            LEFT OUTER JOIN   map_comment     AS c    ON c.map_id=m.id AND c.status=1

            WHERE     m.status = 1
            AND       m.game_id = ' . $gameId . '
            AND       m.date < ' . time() . '
            AND       g.status = 1
            AND       t.status = 1

            GROUP BY m.id
            ORDER BY m.date DESC', $paginationPage * 5, 5);
    foreach ($rs['result'] as $key => $item) {
        $tpl->assignLoopVar('moreMapGame', array('id' => $item['id'], 'title' => encodeCurly($item['title']), 'game' => encodeCurly($item['game']), 'gametype' => encodeCurly($item['gametype']), 'author' => encodeCurly($item['author']), 'author_id' => $item['author_id'], 'image' => $item['image'], 'comment' => $item['comment'], 'download' => $item['download'], 'comment_s' => $item['comment'] > 1 ? 's' : '', 'download_s' => $item['download'] > 1 ? 's' : '', 'ratting' => round($item['ratting'] / 5 * 80), 'rattingPercent' => round($item['ratting'] / 5 * 100), 'map_guid' => $item['guid'], 'game_guid' => $item['game_guid'], 'gametype_guid' => $item['gametype_guid'], 'author_guid' => $item['author_guid'], 'class' => $key % 2 == 0 ? 'pair' : 'odd'));
    }
    /////////////////////////
    // PAGINATION
    /////////////////////////
    $paginationPageTotal = ceil($rs['total'] / 5);
    if ($paginationPageTotal > 1) {
        $tpl->assignVar(array('pagination_game_id' => $gameId, 'pagination_game' => $game, 'pagination_total' => ceil($rs['total'] / 5), 'pagination_page' => $paginationPage + 1, 'pagination_next' => $paginationPage + 1, 'pagination_prev' => $paginationPage - 1));
        if ($paginationPage > 0) {
            $tpl->assignSection('pagination_prev');
        }
        if ($paginationPage < $paginationPageTotal - 1) {
            $tpl->assignSection('pagination_next');
        }
    }
}
Exemple #6
0
            m.image_id              AS image,
            g.name                  AS game,
            g.guid                  as game_guid,
            t.name                  AS gametype,
            t.guid                  AS gametype_guid

            FROM              map             AS m
            JOIN              game            AS g    ON m.game_id = g.id
            JOIN              gametype        AS t    ON m.gametype_id = t.id

            WHERE     m.status = 1
            AND       m.author_id = ' . $authorId . '
            AND       m.date < ' . time() . '
            AND       g.status = 1
            AND       t.status = 1

            GROUP BY m.id
            ORDER BY m.date DESC');
    foreach ($rs['result'] as $key => $item) {
        $tpl->assignLoopVar('moreMapFrom', array('id' => $item['id'], 'title' => encodeCurly($item['title']), 'game' => encodeCurly($item['game']), 'gametype' => encodeCurly($item['gametype']), 'image' => $item['image'], 'map_guid' => makeGUID($item['title']), 'game_guid' => $item['game_guid'], 'gametype_guid' => $item['gametype_guid'], 'class' => $key % 2 == 0 ? 'pair' : 'odd'));
    }
}
/////////////////////////
// MORE MAP GAME
/////////////////////////
require 'bloc/moreMapGame.php';
/////////////////////////
// PAGE INFOS
/////////////////////////
$tpl->assignVar(array('PAGE_TITLE' => encodeCurly($gameName . ' - ' . $mapTitle), 'PAGE_DESCRIPTION' => encodeCurly($mapTitle . ', a ' . $gametypeName . ' map for ' . $gameName . ', realised by ' . $authorName), 'PAGE_KEYWORDS' => encodeCurly($mapTitle . ', ' . $gameName . ', ' . $gametypeName . ', ' . $authorName . ', ' . implode(', ', $keywordList))));
            GROUP BY a.type, map_id
            ORDER BY a.total, a.type DESC');
    $total = 0;
    $activityList = array();
    $activityTotal = array();
    $factor = array('comment' => 10, 'vote' => 4, 'download' => 1);
    foreach ($rs['result'] as $key => $item) {
        if (array_key_exists($item['id'], $activityList) == false) {
            $activityList[$item['id']] = array();
        }
        $activityList[$item['id']][] = array('key' => $key, 'type' => $item['type'], 'total' => $item['total']);
        if (array_key_exists($item['id'], $activityTotal) == false) {
            $activityTotal[$item['id']] = 0;
        }
        $activityTotal[$item['id']] += $item['total'] * $factor[$item['type']];
        $total += $item['total'];
    }
    arsort($activityTotal);
    $i = 0;
    foreach ($activityTotal as $id => $total) {
        $item = $rs['result'][$activityList[$id][0]['key']];
        $tpl->assignLoopVar('activity', array('id' => $item['id'], 'title' => encodeCurly($item['title']), 'game' => encodeCurly($item['game']), 'gametype' => encodeCurly($item['gametype']), 'image' => $item['image'], 'map_guid' => $item['guid'], 'game_guid' => $item['game_guid'], 'gametype_guid' => $item['gametype_guid']));
        foreach ($activityList[$id] as $a) {
            $tpl->assignLoopVar('activity.type', array('class' => strtolower($a['type']), 'name' => $a['type'], 'n' => $a['total']));
        }
        $i++;
        if ($i == 12) {
            break;
        }
    }
}