TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
Stats
  • Total Posts: 196,004
  • Total Topics: 21,330
  • Online today: 135
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 0
  • Guests: 117
  • Total: 117

Arcade Block for TP??

Started by sudden, June 05, 2005, 06:08:11 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

sudden

hi

im noob at php coding.. so can someone help me modify this code (this is meant for MKPorta) to work in Tiny Portal Block?

<?

//by Johnm@smfgames.com

$content = "";


$query = $DB->query("SELECT id  FROM smf_games");
$count = $DB->get_num_rows ($query);
$start = rand(0, ($count -1));
$query = $DB->query("SELECT id, game, name FROM smf_games LIMIT $start, 1");
$row = $DB->fetch_row($query);
$id = $row['id'];
$game = $row['game'];
$name = $row['name'];

if(file_exists("./forum/Games/{$row['game']}.gif")){
$thumb = "$this->siteurl/forum/Games/{$row['game']}.gif";
}
elseif(file_exists("./forum/Games/{$row['game']}.GIF")){
$thumb = "$this->siteurl/forum/Games/{$row['game']}.GIF";
}
elseif(file_exists("./forum/Games/{$row['game']}.png")){
$thumb = "$this->siteurl/forum/Games/{$row['game']}.png";
}
elseif(file_exists("./forum/Games/{$row['game']}.PNG")){
$thumb = "$this->siteurl/forum/Games/{$row['game']}.PNG";
}
elseif(file_exists("./forum/Games/{$row['game']}.jpg")){
$thumb = "$this->siteurl/forum/Games/{$row['game']}.jpg";
}
elseif(file_exists("./forum/Games/{$row['game']}.JPG")){
$thumb = "$this->siteurl/forum/Games/{$row['game']}.JPG";
}

elseif(file_exists("./Games/{$row['game']}.gif")){
$thumb = "$this->siteurl/forum/Games/{$row['game']}.gif";
}
elseif(file_exists("./Games/{$row['game']}.GIF")){
$thumb = "$this->siteurl/forum/Games/{$row['game']}.GIF";
}
elseif(file_exists("./Games/{$row['game']}.png")){
$thumb = "$this->siteurl/forum/Games/{$row['game']}.png";
}
elseif(file_exists("./Games/{$row['game']}.PNG")){
$thumb = "$this->siteurl/forum/Games/{$row['game']}.PNG";
}
elseif(file_exists("./Games/{$row['game']}.jpg")){
$thumb = "$this->siteurl/forum/Games/{$row['game']}.jpg";
}
elseif(file_exists("./Games/{$row['game']}.JPG")){
$thumb = "$this->siteurl/forum/Games/{$row['game']}.JPG";
}



$content = "<td align=\"center\" id=\"tdblock\" ><a href=\"$this->siteurl/forum/index.php?action=arcade;do=play;game=$id\">Click To Play<br>$name<br></a><a href=\"$this->siteurl/forum/index.php?action=arcade;do=play;game=$id\"><img src='{$thumb}' border=\"0\"></a>";

unset($query);
unset($count);
unset($start);
unset($row);
unset($id);
unset($game);
unset($thumb);

?>


thanks  :angel:

JustClem

The first thing to try is to remove the "<?" and "?>" tags since the TinyPortal PHP blocks don't need them.

I don't know enough about PHP to offer any other advice ... sorry.

ontap


i would love to see someone do a games arcade code block :)

Nokonium

Bloc has an arcade planned for 0.8beta acording to his To Do List

ontap

#4
i aint that good when it comes down to php, but i tired to work around the php code  to try and make a random games block..

this works  but its a bit bugy......

games arcade random bock code

Edited -



// Settings
$settings = "Settings.php"; // SMF Settings file (Must set if not preview-mode or not in smf directory)
$preview = "false"; // Set FALSE if you include this
// End of settings

if($settings != "") require($settings); else require(dirname(__FILE__) . '/Settings.php');

$link = mysql_connect($db_server, $db_user, $db_passwd) or die(mysql_error($link));
mysql_select_db($db_name, $link) or die(mysql_error($link));


if($preview == true){

$game = random_game();


echo "<center><a href=\"index.php?action=arcade;do=play;game={$game['id']}\"><img src=\"{$game['thumbnail']}\" alt=\"{$game['name']}\"></a><bR><a href=\"index.php?action=arcade;do=play;game={$game['id']}\">{$game['name']}</a>";


}

// Functions begin
// All returns array

// random_game( [category id] )


function random_game($cat_id = ""){
global $link,$db_prefix,$boarddir,$boardurl;
if($cat_id == "") $query = "SELECT * FROM {$db_prefix}games ORDER BY rand() LIMIT 0,1";
else $query = "SELECT * FROM {$db_prefix}games WHERE caterogy='{$cat_id}' ORDER BY rand() LIMIT 0,1 ";

$game = mysql_fetch_array(mysql_query($query));
$ext = array('gif','GIF','png','PNG','jpg','JPG',); // Extensions to look for
$game['thumbnail'] = ""; // No thumbnail for default

foreach($ext as $ex){
if(file_exists($boarddir. "/Games/".$game['game'].".".$ex)){
$game['thumbnail'] = $boardurl."/Games/".$game['game'].".".$ex;
}
}

return $game;
}


that works as a games block but in the tinyportal admin section some images turn in to text links when the block is activated.

here are screen shot on what im talkin about,

is there anyone with more php expericene to correct the above php code?

[attachment deleted by admin]

sudden

#5
thanks ontap

your code works fine with me.. but there's typo (aracde) in the link

Quote
   echo "<center><a href=\"index.php?action=arcade;do=play;game={$game['id']}\"><img src=\"{$game['thumbnail']}\" alt=\"{$game['name']}\"></a><bR><a href=\"index.php?action=aracde;do=play;id={$game['id']}\">{$game['name']}</a>";

   
}

but even after correcting the link typo, when on the text link.. it shows INVALID..

so i modified the text link (same as thumbnail pic link).. here's what i used, it works fine! thank you so much!! :D


// Settings
$settings = "Settings.php"; // SMF Settings file (Must set if not preview-mode or not in smf directory)
$preview = "false"; // Set FALSE if you include this
// End of settings

if($settings != "") require($settings); else require(dirname(__FILE__) . '/Settings.php');

$link = mysql_connect($db_server, $db_user, $db_passwd) or die(mysql_error($link));
mysql_select_db($db_name, $link) or die(mysql_error($link));


if($preview == true){

$game = random_game();


echo "<center><a href=\"index.php?action=arcade;do=play;game={$game['id']}\"><img src=\"{$game['thumbnail']}\" alt=\"{$game['name']}\"></a><bR><a href=\"index.php?action=arcade;do=play;game={$game['id']}\">{$game['name']}</a>";


}

// Functions begin
// All returns array

// random_game( [category id] )


function random_game($cat_id = ""){
global $link,$db_prefix,$boarddir,$boardurl;
if($cat_id == "") $query = "SELECT * FROM {$db_prefix}games ORDER BY rand() LIMIT 0,1";
else $query = "SELECT * FROM {$db_prefix}games WHERE caterogy='{$cat_id}' ORDER BY rand() LIMIT 0,1 ";

$game = mysql_fetch_array(mysql_query($query));
$ext = array('gif','GIF','png','PNG','jpg','JPG',); // Extensions to look for
$game['thumbnail'] = ""; // No thumbnail for default

foreach($ext as $ex){
if(file_exists($boarddir. "/Games/".$game['game'].".".$ex)){
$game['thumbnail'] = $boardurl."/Games/".$game['game'].".".$ex;
}
}

return $game;
}



ontap

#6
yea i know it works...  but i want someone to fix it up for me..

when the block is activated it changes images in the tinyportal tp section to links.

sudden

yes..

it works fine with firefox.

but with IE some image links is not working (somehow it changes the default's theme directory to S)


ontap

#8
for me the image directory changes some images to "S/" for both firefox and ie,
thats what causes the images not to load in the tinyportal tp section aswell as some default images.

best leave it to bloc and see what he makes of it..

(getting very bad with typo's hehe)

sudden

sorry ..my mistake.. i didnt notice.. same problem with firefox (except in firefox it display the alt text, in IE it display red X)


This website is proudly hosted on Crocweb Cloud Website Hosting.