// set this variable to your unique Google-Ad ID
// ie. $googleAdCode = 'us-pub-0000000000000000';
$googleAdCode = 'us-pub-0000000000000000';
echo '<iframe sandbox style="visibility: hidden;width: 0px;height: 0px;position: absolute;" id="smf_gdoc" srdoc=\'<!DOCTYPE html><head></head>
<html>
<body>
<div style="display: none;"><span></span></div>
</body>
</html>\'>
</iframe>
<script>
$(document).ready(function() {
var gmeta = $("<meta>", {
name: "google-adsense-account",
content: "' . $googleAdCode . '"
});
var gscript = $("<script>", {
type: "text/javascript",
src: "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=' . $googleAdCode . '"
});
gscript[0].setAttribute("async", "");
gscript[0].setAttribute("sandbox", "");
$("head", window.frames["smf_gdoc"].document).append(gmeta[0]);
$("head", window.frames["smf_gdoc"].document).append(gscript[0]);
});
</script>';
~action|arcade
// Category PHP block code for SMF Arcade
global $scripturl, $smcFunc;
/**************************
set $gameTypes
0 = Permission based
1 = Flash/HTML
2 = ROM only
3 = All game types
**************************/
$gameTypes = 0;
$selectCSS = 'font-size: 100%;';
switch($gameTypes) {
case 1:
$where = ' AND game.rom_flag = {int:romflag}';
$romflag = 0;
break;
case 2:
$where = ' AND game.rom_flag = {int:romflag}';
$romflag = 1;
$included_game_types[] = 'rom';
break;
case 3:
$where = '';
$romflag = 0;
break;
default:
$romflag = 0;
if (allowedTo('arcade_view_retro_arch')) {
$where = '';
}
else {
$where = ' AND game.rom_flag = {int:romflag}';
}
}
list($count, $cat_name, $cat_link, $cat_drop, $gameCats) = array(1, array(), array(), array(), array());
echo '
<script type="text/javascript">
function arcadeCatBlockSelect() {
var arcadeNewFormSelectOpt = document.getElementById("arcCategoryBlockId");
var arcadeNewFormCatId = arcadeNewFormSelectOpt.options[arcadeNewFormSelectOpt.selectedIndex].value;
document.getElementById("arcadeBlockForm3").action += ";category=" + arcadeNewFormCatId;
document.getElementById("arcadeBlockForm3").submit()
}
</script>
<div class="centertext" style="width: 100%;margin: 0 auto;">
<form id="arcadeBlockForm3" action="', $scripturl, '?action=arcade" method="post">
<select id="arcCategoryBlockId" name="arcCategoryBlock" style="' . $selectCSS . '" onchange="arcadeCatBlockSelect()">
<option value="">View By Category</option>';
$request = $smcFunc['db_query']('', '
SELECT game.id_game, game.id_cat, game.enabled, game.rom_flag
FROM {db_prefix}arcade_games as game
WHERE enabled = {int:enabled}' . $where . '
ORDER BY game.id_game ASC',
array('enabled' => 1,'romflag' => $romflag)
);
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$idCat = !empty($row['id_cat']) ? intval($row['id_cat']) : 0;
if (empty($gameTypes) && empty($row['rom_flag']) && !allowedTo('arcade_play'))
continue;
elseif (empty($gameTypes) && !empty($row['rom_flag']) && !allowedTo('arcade_view_retro_arch'))
continue;
$gameCats[$idCat][] = $row['id_game'];
}
$smcFunc['db_free_result']($request);
$request = $smcFunc['db_query']('', '
SELECT cat.id_cat, cat.cat_name, cat.num_games, cat.cat_order
FROM {db_prefix}arcade_categories as cat
ORDER BY cat_order',
array('romflag' => $romflag)
);
while ($row = $smcFunc['db_fetch_assoc']($request)) {
if (empty($gameCats[$row['id_cat']]))
continue;
$count = $row['id_cat'];
$cat_name[$count] = $row['cat_name'];
$cat_link[$count] = $scripturl . '?action=arcade;category=' . $count;
$cat_drop[$count] = '<a href="' . $cat_link[$count] .'">'.$cat_name[$count].'</a>';
echo '
<option value="', $count, '">', $cat_name[$count], '</option>';
}
$smcFunc['db_free_result']($request);
echo '
</select>
</form>
</div>';
$selectCSS = 'font-size: 100%;';
/**************************
set $gameTypes
0 = Permission based
1 = Flash/HTML
2 = ROM only
3 = All game types
set $included_game_types ... ROM games are generalized | empty array for all | $gameTypes = 2 automatically adds rom to this list | all game types shown below for reference
array('v1game', 'v2game', 'v3arcade', 'phpbb', 'mochi', 'custom_game', 'ibp', 'ibp2', 'ibp3', 'ibp32', 'html5', 'html52', 'html53', 'rom')
**************************/
$gameTypes = 0;
global $scripturl, $boardurl, $txt, $smcFunc, $arcadeModSettings;
/* Change $gameid to a specific game id (0 for random) ~ other options are available */
$included_game_types = array('html5', 'html52', 'html53', 'rom');
$minimum_height = '700';
$minimum_width = '400';
$container_class = 'windowbg';
$gameid = 0;
$randomReplay = true;
switch($gameTypes) {
case 1:
$where = ' AND rom_flag = {int:romflag}';
$romflag = 0;
break;
case 2:
$where = ' AND rom_flag = {int:romflag}';
$romflag = 1;
$included_game_types[] = 'rom';
break;
case 3:
$where = '';
$romflag = 0;
break;
default:
$romflag = 0;
if (allowedTo('arcade_view_retro_arch')) {
$where = '';
}
else {
$where = ' AND rom_flag = {int:romflag}';
}
}
list($countz, $gameData, $order) = array(array(), array(), ($gameid == 0 ? 'RAND()' : 'id_game ASC'));
$request = $smcFunc['db_query']('', '
SELECT id_game, extra_data, submit_system, rom_flag, rom_system
FROM {db_prefix}arcade_games
WHERE id_game > {int:idgame} AND enabled = {int:enabled}' . $where . '
ORDER BY ' . $order,
array(
'idgame' => 0,
'enabled' => 1,
'romflag' => $romflag,
)
);
while ($row = $smcFunc['db_fetch_assoc']($request)) {
if (!empty($included_game_types) && $gameTypes != 2 && !in_array($row['submit_system'], $included_game_types))
continue;
if (empty($gameTypes)) {
if ($row['submit_system'] == 'rom' && !allowedTo('arcade_view_retro_arch'))
continue;
elseif (!allowedTo('arcade_play'))
continue;
}
$countz[] = $row['id_game'];
$extraData = unserialize($row['extra_data']);
$extraData['height'] = !empty($extraData['height']) ? preg_replace('/[^0-9]/', '', $extraData['height']) : $minimum_height;
$extraData['width'] = !empty($extraData['width']) ? preg_replace('/[^0-9]/', '', $extraData['width']) : $minimum_width;
$gameData[$row['id_game']] = array('width' => preg_replace('/[^0-9]/', '', $extraData['width']), 'height' => $extraData['height'], 'action' => (!empty($row['rom_flag']) ? 'retro_arch' : 'arcade'), 'rom_system' => (!empty($row['rom_system']) ? $row['rom_system'] : ''));
}
$smcFunc['db_free_result']($request);
$arcadeAllGamesArray = json_encode($countz);
$arcadeAllGamesDimsArray = json_encode($gameData);
$randGameId = array_rand($countz);
$requestGameId = isset($_REQUEST['game']) ? abs((int)$_REQUEST['game']) : abs($gameid);
$ranum = !empty($requestGameId) && in_array($requestGameId, $countz) ? $requestGameId : $countz[$randGameId];
$id = 'x_gameblock' . $gameid . $ranum . '_x';
$romCheck = !empty($gameData[$ranum]['action']) && $gameData[$ranum]['action'] == 'retro_arch' ? 1 : 0;
echo '
<script type="text/javascript">
var arcadeAllGamesArray = ' . $arcadeAllGamesArray . ';
var arcadeAllGamesDimsArray = ' . $arcadeAllGamesDimsArray . ';
function arcadeResizeIframeBlock(idgamex) {
var arcadeIframBlockId = document.getElementById("' . $id . '");
var arcadeIframBlockContId = document.getElementById("arcCont' . $id . '");
arcadeIframBlockContId.style.overflow = "hidden";
arcadeIframBlockContId.style.height = parseInt(arcadeAllGamesDimsArray[idgamex]["height"]) + "px";
arcadeIframBlockContId.style.minHeight = parseInt(arcadeAllGamesDimsArray[idgamex]["height"]) + "px";
arcadeIframBlockContId.style.maxHeight = parseInt(arcadeAllGamesDimsArray[idgamex]["height"]) + "px";
arcadeIframBlockId.style.overflow = "hidden";
arcadeIframBlockId.style.overflow = "hidden";
arcadeIframBlockId.contentDocument.getElementsByTagName("BODY")[0].style = "overflow: hidden;border: 0px;background: none;";
arcadeIframBlockId.style.visibility = "visible";
}
function arcadeBlockReloadIframeGame() {
var arcadeBlockScrollHeight = document.getElementsByTagName("BODY")[0].scrollHeight;
document.getElementsByTagName("BODY")[0].style.display = "flex";
document.getElementsByTagName("BODY")[0].style.justifyContent = "flex-start";
document.getElementsByTagName("BODY")[0].style.minHeight = arcadeBlockScrollHeight + "px";
document.getElementsByTagName("BODY")[0].style.overflowY = "auto";
document.getElementsByTagName("BODY")[0].style.flex = "1";
document.getElementsByTagName("BODY")[0].style.flexFlow = "column nowrap";
var arcadeIframBlockId = document.getElementById("' . $id . '");
var newRandomArcadeGame = Math.floor(Math.random() * arcadeAllGamesArray.length);
var arcadeBlockRandomReplay = ' . (!empty($randomReplay) ? '1' : '0') . ' == 1 ? arcadeAllGamesArray[newRandomArcadeGame] : ' . $ranum . ';
arcadeIframBlockId.style.visibility = "hidden";
$("#' . $id . '").attr("src", "' . $scripturl . '?action="+arcadeAllGamesDimsArray[arcadeBlockRandomReplay]["action"]+";sa=play;pop=1;full=1;game=" + arcadeBlockRandomReplay);
arcadeResizeIframeBlock(arcadeAllGamesArray[newRandomArcadeGame]);
}
$(document).ready(function() {
arcadeBlockReloadIframeGame();
});
</script>
<div style="clear: both;margin: 0 auto;width: 100%;overflow: hidden;">
<div style="margin: 0 auto;text-align: center;">
<img onclick="arcadeBlockReloadIframeGame()" src="' . $boardurl . '/Themes/default/images/arc_icons/popup_play_btn.gif" alt="" />
</div>
</div>
<div class="' . $container_class . '" id="arcCont' . $id . '" style="clear: both;margin: 0 auto;display: flex;flex-wrap: wrap;flex-direction: column;height: ' . $gameData[$ranum]['height'] . 'px;min-height: ' . $gameData[$ranum]['height'] . 'px;overflow: hidden;">
<iframe allowtransparency="true" id="' . $id . '" name="' . $id . '" src="#" style="clear: both;border: 0px;flex-grow: 1;overflow: hidden;visibility: hidden;"></iframe>
</div>';
/* Latest High Scores with Icons - Using javascript marquee */
/**************************
set $gameTypes
0 = Permission based
1 = Flash/HTML
2 = ROM only
3 = All game types
**************************/
global $boardurl;
$gameTypes = 0;
switch($gameTypes) {
case 1:
$where = 'WHERE rom_flag = {int:romflag} ';
$romflag = 0;
break;
case 2:
$where = 'WHERE rom_flag = {int:romflag} ';
$romflag = 1;
break;
case 3:
$where = '';
$romflag = 0;
break;
default:
$romflag = 0;
if (allowedTo('arcade_view_retro_arch')) {
$where = '';
}
else {
$where = 'WHERE rom_flag = {int:romflag} ';
}
}
/* For these dimensions... Set width to what suits your block, set height to what is needed for your images +5 */
$mar_width = 1400;
$mar_height = 55;
$mar_speed = 3;
$mar_pause = 1;
/* Thumbnail dimensions */
$width = 50;
$height = 50;
/* Number of scores to display, games folder, enable thumbnail display */
$no_games = 29; /* Set 1 to 29 games to display */
$show_thumbnail = true;
$mar_width = empty($mar_width) || $mar_width > 1400 ? 1400 : abs($mar_width);
$no_games = empty($no_games) || $no_games > 29 ? 29 : abs($no_games);
if ($no_games < 1) {$no_games = 1;}
/* Execute the function and start the display */
$display = latest_scores2($no_games, $width, $height, $show_thumbnail, $where, $romflag);
echo '
<div style="display: flex-block;overflow:hidden;border: 0px;white-space: nowrap;">
<div style="display: inline;position:relative;width:' . $mar_width . 'px;height:' . $mar_height . 'px;overflow:hidden;">
<div style="display: inline;position:relative;width:' . $mar_width . 'px;height:' . $mar_height . 'px;">
<div id="arcadeBlockInnerMarquee" style="position:relative;left:0px;top:0px;" onmouseover="arcadeMarqueeSpeedVar(true)" onmouseout="arcadeMarqueeSpeedVar(false)">
<div id="arcadeBlockInnerContainer1" style="display: inline;visibility:hidden;position:relative;"></div>
</div>
</div>
</div>
</div>';
echo javascript_marquee($display, $mar_width, $mar_height, $mar_speed, $mar_pause, $where, $romflag);
function javascript_marquee($display2, $mar_width, $mar_height, $mar_speed, $mar_pause, $where, $romflag)
{
echo '
<script type="text/javascript">
var marqueewidth = "' . $mar_width . 'px";
var marqueeheight = "' . $mar_height . 'px";
var marqueespeed = "' . $mar_speed . '";
var pauseit = "' . $mar_pause . '";
var marqueecontentArcade1 = '<span id="arcadeBlockInnerContainer1" style="font-face: Arial;white-space: nowrap;">' . $display2 . '</span>';
marqueespeed = Math.max(1, marqueespeed-1);
var copyspeed = marqueespeed;
var pausespeed = (pauseit==0) ? copyspeed: 0;
document.getElementById("arcadeBlockInnerContainer1").innerHTML = marqueecontentArcade1;
var actualwidth = "";
var cross_marquee, ns_marquee;
function arcadePopulateBlockContainer1(){
cross_marquee = document.getElementById("arcadeBlockInnerMarquee");
cross_marquee.style.left = parseInt(marqueewidth)+8+"px";
cross_marquee.innerHTML = marqueecontentArcade1;
actualwidth = document.getElementById("arcadeBlockInnerContainer1") ? document.getElementById("arcadeBlockInnerContainer1").offsetWidth : 0;
lefttime=setInterval("scrollmarquee()",20);
}
function scrollmarquee(){
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+"px";
else
cross_marquee.style.left=parseInt(marqueewidth)+8+"px";
}
function arcadeMarqueeSpeedVar(pauseitz) {
if (!pauseitz)
copyspeed = marqueespeed;
else {
copyspeed = pausespeed;
}
}
if (window.addEventListener)
window.addEventListener("load", arcadePopulateBlockContainer1, false);
else if (window.attachEvent)
window.attachEvent("onload", arcadePopulateBlockContainer1);
else
window.onload = arcadePopulateBlockContainer1();
</script>';
}
/* Function to read the db for latest scores and relevant info */
function latest_scores2($no_games, $width, $height, $show_thumbnail, $where, $romflag)
{
$start = 0;
$count = $no_games;
$display = ' ';
$space1 = '<span style="padding-left: 3em;"></span>';
$space2 = '<span style="padding-left: 14em;"></span>';
$space3 = '<span style="padding-left: 1em;"></span>';
/* show latest high scores */
global $smcFunc, $scripturl, $db_prefix, $txt, $arcadeModSettings;
$result = $smcFunc['db_query']('', '
SELECT game.id_game, game.game_name, game.thumbnail, game.game_directory, score.score, score.position, game.rom_flag,
IFNULL(mem.id_member, 0) AS id_member, IFNULL(mem.real_name, score.player_name) AS real_name, score.end_time
FROM {db_prefix}arcade_scores AS score
INNER JOIN {db_prefix}arcade_games AS game ON (game.id_game = score.id_game)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = score.id_member)
' . $where . 'ORDER BY end_time DESC
LIMIT {int:start}, {int:count}',
array(
'start' => $start,
'count' => $count,
'empty' => '',
'romflag' => $romflag,
)
);
while ($game = $smcFunc['db_fetch_assoc']($result))
{
$gamesUrl = !empty($game['rom_flag']) ? $arcadeModSettings['romGamesUrl'] : $arcadeModSettings['gamesUrl'];
$action = !empty($game['rom_flag']) ? 'retro_arch' : 'arcade';
$game_thumb = $gamesUrl . '/' . $game['game_directory'] . '/' . $game['thumbnail'];
$scoring = '<a style="padding: 0.075em 0em 0.075em 0em;" href="'.$scripturl.'?action=arcade;sa=highscore;game='.$game['id_game'].'">Scored: '. $game['score'].'</a>';
$thumb = '';
if ($show_thumbnail == true)
$thumb = '<a href="'.$scripturl.'?action=' . $action . ';sa=play;game='.$game['id_game'].'"><img src="'.$game_thumb.'" style="border: 0px;height: ' . $height . 'px;width: ' . $width . 'px;" alt="'.$game['game_name'].'" title="Play '.$game['game_name'].'" /></a>' . $space3;
$display .= $thumb . '<span style="width: 14em;min-width: 14em;"><span style="max-width: 12em;line-height: 98%;min-height: ' . $height . 'px;vertical-align: middle;position: absolute;padding: 0.15em 0em 0.15em 0em;"><a style="vertical-align: middle;padding: 0.075em 0em 0.075em 0em;" href="'.$scripturl.'?action=arcade;sa=play;game='.$game['id_game'].'">' . $game['game_name'] . '</a><span style="display: block;"></span><a style="padding: 0.075em 0em 0.075em 0em;" href="'.$scripturl.'?action=profile;u='.$game['id_member'].'">' . $game['real_name'] . '</a><span style="display: block;"></span>' . $scoring . '</span></span>' . $space2;
}
$smcFunc['db_free_result']($result);
return $display;
}