» » » Случайные Аркадные Игры в home.php

Случайные Аркадные Игры в home.php

Arcade Random Games in Home.php


Случайные Аркадные Игры в home.php


1. В home.php находим ASSIGN SMARTY VARIABLES AND INCLUDE FOOTER
после вставляем код:



////////GET LANG IDS
$aValues = array();
$sSql = " SELECT
`languagevar_id`,
REPLACE(`defVarName`, 'gamelist.', '') AS `key`
FROM `arcade_settings` WHERE `defVarName` LIKE '%gamelist.%' ";
$rResult = mysql_query($sSql);
while( ($aRow=mysql_fetch_assoc($rResult)) )
$aValues[ $aRow['key'] ] = $aRow['languagevar_id'];
$smarty->assign('aCusLang', $aValues);
$aArcdSttng = array();
$sSql = " SELECT
*
FROM `arcade_options` ";
$rResult = mysql_query($sSql);
while( ($aRow=mysql_fetch_assoc($rResult)) )
$aArcdSttng[ $aRow['var'] ] = stripslashes($aRow['value']);
$smarty->assign('aArcadeSetting', $aArcdSttng);
//////////////////////////////////////////////////////////////////////////////////////////////////////
/////////GET CATEGORY
$sCat = isset($_GET['cat']) ? $_GET['cat'] : "";
$smarty->assign('sCat', $sCat);

$sql="SELECT `catname`, `catid` FROM `arcade_categories` ORDER BY `displayorder`";
$result=mysql_query($sql);
$aCate = array();
while($row = mysql_fetch_assoc($result))
$aCate[$row['catid']] = stripslashes($row['catname']);

$smarty->assign('aCate', $aCate);

//////////////////////////////////////////////////////////////////////////
/////////GET NEWS
$sql ="SELECT `setting_username` FROM `se_settings` LIMIT 1";
$result = mysql_query($sql);
$aRow = mysql_fetch_assoc($result);
$bUserNames = $aRow['setting_username'] == 1 ? TRUE : FALSE;

$sql = " SELECT
`n`.`winnerid`,
`n`.`loserid`,
`n`.`time`,
`n`.`gameid`,
`n`.`score`,
`n`.`type`,
`g`.`title`,
".($bUserNames ? "
`u1`.`user_username` AS `winnerName`,
`u2`.`user_username` AS `loserName`":
"`u1`.`user_displayname` AS `winnerName`,
`u2`.`user_displayname` AS `loserName`")."
FROM
`arcade_news` AS `n`
INNER JOIN `arcade_games` AS `g` ON `g`.`gameid` = `n`.`gameid`
LEFT JOIN `se_users` AS `u1` ON `u1`.`user_id` = `n`.`winnerid`
LEFT JOIN `se_users` AS `u2` ON `u2`.`user_id` = `n`.`loserid`
ORDER BY `n`.`time` DESC LIMIT 1";
$result = mysql_query($sql);
if( ($row = mysql_fetch_assoc($result)) )
{
$row['time'] = date('F j, Y', $row['time']);
$row['title'] = stripslashes($row['title']);

if($row['winnerid'] != $row['loserid'] && $row['loserid'] != 0 && $row['type'] == 2)
$smarty->assign('iNewsType', 1);
elseif($row['winnerid'] == $row['loserid'] && $row['type'] == 1)
$smarty->assign('iNewsType', 2);
elseif($row['winnerid'] != $row['loserid'] && $row['loserid'] != 0 && $row['type'] == 1)
$smarty->assign('iNewsType', 3);
elseif($row['loserid'] == 0 && $row['type'] == 1)
$smarty->assign('iNewsType', 4);

$smarty->assign('aNewsData', $row);
}else
$smarty->assign('iNewsType', 5);
///////////////////////////////////////////////////////////////////////////////////////
$sql = " SELECT
`u`.`user_displayname`,
`i`.`userid`,
`i`.`arcade_champs`
FROM `arcade_info` AS `i`
INNER JOIN `se_users` AS `u` ON `u`.`user_id` = `i`.`userid`
ORDER BY `arcade_champs` DESC LIMIT 1";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$smarty->assign('aGameChamp', $row);

$sql = " SELECT
`gameid`,
`timesplayed`,
`stdimage`,
`title`
FROM `arcade_games`
ORDER BY `timesplayed` DESC LIMIT 1";
$result = mysql_query($sql);
$row = mysql_fetch_assoc($result);
$smarty->assign('sMostPlayedTitle', stripslashes($row['title']));
$smarty->assign('aMostPlayed', $row);
/////////////////////////////////////////////////////////////////////////////////////////////
////////////////////GAME LIST
$iUserId = isset($user->user_info['user_id']) ? $user->user_info['user_id'] : FALSE;
$smarty->assign('iUserId', $iUserId);

if(isset($_REQUEST['searchType']))
$smarty->assign('sSearchType', $_REQUEST['searchType']);
else
$smarty->assign('sSearchType', false);

$smarty->assign('sSearchWords', '');
if( isset($_REQUEST['searchWords']) )
$smarty->assign('sSearchWords', htmlentities($_REQUEST['searchWords']));

//Build Query
if(
isset($_REQUEST['searchWords'], $_REQUEST['searchType']) &&
!empty($_REQUEST['searchType']) && !empty($_REQUEST['searchWords'])
)
$bSearch = true;
else
$bSearch = false;
$sOrder = "";
$sWhere = "";
$aWhere = array();
if($sCat != "")
$aWhere[] = " `ag`.`categoryid` = '".mysql_real_escape_string($sCat)."' ";
elseif(!$bSearch)
$sOrder = " ORDER BY RAND()";
if($bSearch)
{
if($_REQUEST['searchType'] == 'title')
$aWhere[] = " `ag`.`title` LIKE '%".mysql_real_escape_string($_REQUEST['searchWords'])."%' ";
else
$aWhere[] = " `ag`.`description` LIKE '%".mysql_real_escape_string($_REQUEST['searchWords'])."%' ";
}
if(count($aWhere) > 0)
$sWhere = " WHERE ".implode(" && ", $aWhere);


$iPage = isset($_REQUEST['page']) ? $_REQUEST['page']*1 : 0;
$iLimit = ($iPage == "" ? 0 : ($iPage-1)*5);
$iLimit2 = 5;
$sLimit = " LIMIT ".$iLimit.', '.$iLimit2;

$sql1 = " SELECT
`ag`.`gameid`,
`ag`.`categoryid`,
`ag`.`isreverse`,
".($bUserNames ? "
`u1`.`user_username` AS `highScoreName`,":"
`u1`.`user_displayname` AS `highScoreName`,")."
`u1`.`user_username` AS `highScoreLink`,
`ah`.`score` AS `highScore`,
".( is_numeric($iUserId) ? "
`auh`.`score` AS `userScore`,
`af`.`id` AS `favorites`,
": "")."
`ag`.`stdimage`,
`ag`.`description`,
`ag`.`title`
FROM `arcade_games` AS `ag`
LEFT JOIN `arcade_highscores` AS `ah`
ON `ah`.`gameid` = `ag`.`gameid`
LEFT JOIN `se_users` AS `u1` ON `u1`.`user_id` = `ah`.`userid`
".( is_numeric($iUserId) ? "
LEFT JOIN (
SELECT
MAX(`score`) AS `score`,
`gameid`
FROM `arcade_userhighscores`
WHERE `userid` = '".$iUserId."' GROUP BY `gameid`
) AS `auh`
ON `auh`.`gameid` = `ag`.`gameid`
LEFT JOIN `arcade_favorite` AS `af`
ON (`af`.`gameid` = `ag`.`gameid` && `af`.`userid` = '".$iUserId."' )
" : "")."
".$sWhere." GROUP BY `ag`.`gameid` ".$sOrder.$sLimit;
// Get Query
$game_array = array();
$result1 = mysql_query($sql1);
if (mysql_num_rows($result1) > 0)
{
$bAdmin = false;
if( isset($admin->admin_exists) )
$bAdmin = true;
$smarty->assign('bAdmin', $bAdmin);

$aGames = array();
while( $row = mysql_fetch_assoc($result1) )
{
// get catname
$sTempCat = array_key_exists($row['categoryid'], $aCate) ? $aCate[$row['categoryid']] : "Uncategorized";
if( isset($row['highScore']) && $row['highScore'] > 0 )
{
$sTempName = $row['highScoreName'];
$sTempScore = $row['highScore'];
$sHighScoreLink = $row['highScoreLink'];
$bChamp = true;
}
else
{
$sTempName = "None";
$sHighScoreLink = '';
$sTempScore = 0;
$bChamp = false;
}
// get users highscore
if(isset($User))
{
$bTempScore2 = true;
if( isset($row['userScore']) && $row['userScore'] > 0)
$sTempScore2 = $row['userScore'];
else
$sTempScore2 = "None";
}
else
{
$bTempScore2 = false;
$sTempScore2 = 'None';
}
$aGames[] = array( 'gameid'=> $row['gameid'],
'stdimage'=> $row['stdimage'],
'description'=> stripslashes($row['description']),
'title'=> stripslashes($row['title']),
'categoryid'=> $row['categoryid'],
'favorites'=> $row['favorites'],
'sTempCat'=> $sTempCat,
'sTempName'=> $sTempName,
'sHighScoreLink'=> $sHighScoreLink,
'sTempScore'=> $sTempScore,
'sTempScore2'=> $sTempScore2,
'bTempScore2' => $bTempScore2);
}
}
$smarty->assign('aGames', $aGames);
/////////////////////////////////////////////////////////////////////
// generate links for the bottom
$smarty->assign('sCat', '');
if($sCat != "")
$sCat = "&cat=".$sCat;
if($bSearch)
$sCat = "&searchType=".$_REQUEST['searchType']."&searchWords=".$_REQUEST['searchWords'];
$smarty->assign('sCat', $sCat);


$sql1 = " SELECT
COUNT(*) AS `cnt`
FROM `arcade_games` AS `ag`
".$sWhere;
$result1 = mysql_query($sql1);
$aRow = mysql_fetch_assoc($result1);
$iNum = $aRow['cnt'];
$iPgMax = ceil($iNum/$iLimit2);
$smarty->assign('iNum', $iNum);
$smarty->assign('iPgMax', $iPgMax);
$smarty->assign('iPage', $iPage==0 ? 1 : $iPage );




2. В home.tpl находим BEGIN MIDDLE COLUMN
после вставляем код:



<div class='header'>Random Arcade Games</div>
<div class='portal_content'>

<table class="list" style="width:100%">
<tr>
<td class="list_header" style="width:15%;"></td>
<td class="list_header" style="width:30%;"><strong>{lang_print id=$aCusLang.game}</strong> </td>
<td class="list_header" style="width:15%;text-align:center;"><strong>{lang_print id=$aCusLang.category}</strong></td>

</tr>
{foreach from=$aGames item=v}
<tr {cycle values="list_item1,list_item2"}>
<td style="width:15%;text-align:center;">
<a class="link" href="game.php?play={$v.gameid}"><img src="file/arcade/images/{$v.stdimage}" alt="" /></a>
</td>
<td style="width:30%;vertical-align:top;">
<strong><a class="link" href="game.php?play={$v.gameid}">{$v.title}</a></strong>
<br />
<span>{$v.description}</span>
</td>
<td style="width:15%;text-align:center;">
<strong>{$v.sTempCat}</strong>
<br />
<span>(<a class="link" href="gamelist.php{if $v.sTempCat != "Uncategorized"}?cat={$v.categoryid}{/if}">{lang_print id=$aCusLang.more}</a>)</span>
</td>

</td>
</tr>
{foreachelse}
<tr>
</tr>
{/foreach}

</table>






<table>
<tr>
<td style="width: 300px;vertical-align: top;">
<div class="header">{lang_print id=$aCusLang.arcade_news}</div>
<div class="portal_content" style="height: 60px">
{if $iNewsType != 5}<strong>{$sTime}:</strong>{/if}
{if $iNewsType == 1}
{lang_sprintf id=$aCusLang.news_msg1 1=$aNewsData.winnerid 2=$aNewsData.winnerName 3=$aNewsData.loserid 4=$aNewsData.loserName 5=$aNewsData.gameid 6=$aNewsData.title 7=$aNewsData.score}
{elseif $iNewsType == 2}
{lang_sprintf id=$aCusLang.news_msg2 1=$aNewsData.winnerid 2=$aNewsData.winnerName 3=$aNewsData.gameid 4=$aNewsData.title 5=$aNewsData.score}
{elseif $iNewsType == 3}
{lang_sprintf id=$aCusLang.news_msg3 1=$aNewsData.winnerid 2=$aNewsData.winnerName 3=$aNewsData.loserid 4=$aNewsData.loserName 5=$aNewsData.gameid 6=$aNewsData.title 7=$aNewsData.score}
{elseif $iNewsType == 4}
{lang_sprintf id=$aCusLang.news_msg4 1=$aNewsData.winnerid 2=$aNewsData.winnerName 3=$aNewsData.gameid 4=$aNewsData.title 5=$aNewsData.score}
{elseif $iNewsType == 5}
<img src="./images/icons/bulb22.gif" alt="{lang_print id=$aCusLang.notice}" /> {lang_print id=$aCusLang.no_news}
{/if}
</div>
</td>
{if $aGameChamp}
<td style="vertical-align: top;">
<div class="header">{lang_print id=$aCusLang.arcade_champion}</div>
<div class="portal_content" style="height: 60px">
<img src="./images/icons/gold.png" alt="*" /><strong><a class="link" href='profile.php?user_id={$aGameChamp.userid}'>{$aGameChamp.user}</a></strong>
<div style="padding-left: 25px;">
{lang_sprintf id=$aCusLang.arcade_champ_records 1=$aGameChamp.arcade_champs}
<br />
<a class="link" href="toparcade.php">{lang_print id=$aCusLang.view_all}</a>
</div>
</div>
</td>
{/if}
<td style="vertical-align: top;">
<div class="header">{lang_print id=$aCusLang.most_played_game}</div>
<div class="portal_content" style="height: 60px">
{if $aMostPlayed.gameid}
<table>
<tr>
<td>
<a class="link" href="game.php?play={$aMostPlayed.gameid}"><img src="file/arcade/images/{$aMostPlayed.stdimage}" alt="" /></a>
</td>
<td style="padding-left: 5px;" >
<a class="link" href="game.php?play={$aMostPlayed.gameid}">{$sMostPlayedTitle}</a>
<br/>{lang_sprintf id=$aCusLang.total_plays 1=$aMostPlayed.timesplayed}
<br /><a class="link" href="toparcade.php">{lang_print id=$aCusLang.view_all}</a>
</td>
</tr>
</table>
{else}
<p>{lang_print id=$aCusLang.you_do_not_have_any_game_plays}</p>
{/if}
</div>
</td>
</tr>
</table>

</div>

Другие публикации по теме:

Комментарии