<?php
/**
* onArcade 2.0.1
* Copyright © 2006-2007 Hans Mäesalu & Eveterm OÜ, All Rights Reserved
**
* ONARCADE IS NOT FREE SOFTWARE!
*
onArcade - Tip of the day: Buy onArcade!
**/
// Get visitor IP
function userip() {
if (getenv('HTTP_CLIENT_IP')) {
$ip = getenv('HTTP_CLIENT_IP');
} elseif (getenv('HTTP_X_FORWARDED_FOR')) {
$ip = getenv('HTTP_X_FORWARDED_FOR');
} elseif (getenv('HTTP_X_FORWARDED')) {
$ip = getenv('HTTP_X_FORWARDED');
} elseif (getenv('HTTP_FORWARDED_FOR')) {
$ip = getenv('HTTP_FORWARDED_FOR');
} elseif (getenv('HTTP_FORWARDED')) {
$ip = getenv('HTTP_FORWARDED');
} else {
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
// Strip HTML dags
function nohtml($message) {
$message = preg_replace("#&(?!\#[0-9]+

#si", "&", $message);
$message = str_replace("<","<", $message);
$message = str_replace(">",">", $message);
$message = str_replace("\"",""", $message);
$message = str_replace(" ", " ", $message);
return $message;
}
// Generate file URL
function fileurl($fileId,$fileTitle) {
global $settings;
if ($settings['sefriendly'] == '1') {
$fileTitle = str_replace(" ","-",$fileTitle);
$fileTitle = str_replace("'","_",$fileTitle);
$fileTitle = str_replace(":","-",$fileTitle);
$fileTitle = str_replace("ä","a",$fileTitle);
$fileTitle = str_replace("ö","o",$fileTitle);
$fileTitle = str_replace("ü","y",$fileTitle);
$fileTitle = str_replace("&","and",$fileTitle);
$fileTitle = str_replace("(","8",$fileTitle);
$fileTitle = str_replace(")","9",$fileTitle);
$file_title = str_replace(" ","-",$file_title);
$file_title = str_replace("(","",$file_title);
$file_title = str_replace(")","",$file_title);
$file_title = str_replace("'","_",$file_title);
$file_title = str_replace(":","_",$file_title);
$file_title = str_replace("ä","a",$file_title);
$file_title = str_replace("ö","o",$file_title);
$file_title = str_replace("ü","u",$file_title);
$file_title = str_replace("ç","c",$file_title);
$file_title = str_replace("Ç","c",$file_title);
$file_title = str_replace("Ö","o",$file_title);
$file_title = str_replace("Ü","u",$file_title);
$file_title = str_replace("ı","i",$file_title);
$file_title = str_replace("İ","i",$file_title);
$file_title = str_replace("ğ","g",$file_title);
$file_title = str_replace("Ğ","g",$file_title);
$file_title = str_replace("ş","s",$file_title);
$file_title = str_replace("Ş","s",$file_title);
$fileurl = $settings['siteurl'] .'/'. $settings['fileurl'] .'/'. $fileId .'/'. $fileTitle .'.html';
} else {
$fileurl = $settings['siteurl'] .'/file.php?f='. $fileId;
}
return $fileurl;
}
// Generate category URL
function categoryurl($category_id, $category_name, $category_page = 1) {
global $settings;
if ($settings['sefriendly'] == '1') {
$category_name = str_replace(" ","-",$category_name);
$category_name = str_replace("'","_",$category_name);
$category_name = str_replace(":","-",$category_name);
$category_name = str_replace("ä","a",$category_name);
$category_name = str_replace("ö","o",$category_name);
$category_name = str_replace("ü","y",$category_name);
$category_name = str_replace("&","and",$category_name);
$file_title = str_replace(" ","-",$file_title);
$file_title = str_replace("(","",$file_title);
$file_title = str_replace(")","",$file_title);
$file_title = str_replace("'","_",$file_title);
$file_title = str_replace(":","_",$file_title);
$file_title = str_replace("ä","a",$file_title);
$file_title = str_replace("ö","o",$file_title);
$file_title = str_replace("ü","u",$file_title);
$file_title = str_replace("ç","c",$file_title);
$file_title = str_replace("Ç","c",$file_title);
$file_title = str_replace("Ö","o",$file_title);
$file_title = str_replace("Ü","u",$file_title);
$file_title = str_replace("ı","i",$file_title);
$file_title = str_replace("İ","i",$file_title);
$file_title = str_replace("ğ","g",$file_title);
$file_title = str_replace("Ğ","g",$file_title);
$file_title = str_replace("ş","s",$file_title);
$file_title = str_replace("Ş","s",$file_title);
$category_url = $settings['siteurl'] .'/'. $settings['categoryurl'] .'/'. $category_id .'/'. $category_name .'/'. $category_page .'.html';
} else {
$category_url = $settings['siteurl'] .'/browse.php?c='. $category_id .'&p='. $category_page;
}
return $category_url;
}
// Generate profile URL
function profileurl($userid,$username) {
global $settings;
if ($settings['sefriendly'] == '1') {
$username = str_replace(" ","-",$username);
$username = str_replace("'","_",$username);
$username = str_replace(":","-",$username);
$username = str_replace("ä","a",$username);
$username = str_replace("ö","o",$username);
$username = str_replace("ü","y",$username);
$username = str_replace("&","and",$username);
$file_title = str_replace(" ","-",$file_title);
$file_title = str_replace("(","",$file_title);
$file_title = str_replace(")","",$file_title);
$file_title = str_replace("'","_",$file_title);
$file_title = str_replace(":","_",$file_title);
$file_title = str_replace("ä","a",$file_title);
$file_title = str_replace("ö","o",$file_title);
$file_title = str_replace("ü","u",$file_title);
$file_title = str_replace("ç","c",$file_title);
$file_title = str_replace("Ç","c",$file_title);
$file_title = str_replace("Ö","o",$file_title);
$file_title = str_replace("Ü","u",$file_title);
$file_title = str_replace("ı","i",$file_title);
$file_title = str_replace("İ","i",$file_title);
$file_title = str_replace("ğ","g",$file_title);
$file_title = str_replace("Ğ","g",$file_title);
$file_title = str_replace("ş","s",$file_title);
$file_title = str_replace("Ş","s",$file_title);
$profileurl = $settings['siteurl'] .'/'. $settings['profileurl'] .'/'. $userid .'/'. $username .'.html';
} else {
$profileurl = $settings['siteurl'] .'/profile.php?u='. $userid;
}
return $profileurl;
}
// Generate score URL
function scoresurl($scores_id, $scores_page = 1) {
global $settings;
if ($settings['sefriendly'] == '1') {
$scores_url = $settings['siteurl'] .'/'. $settings['scoresurl'] .'/'. $scores_id .'/'. $scores_page .'.html';
} else {
$scores_url = $settings['siteurl'] .'/scores.php?f='. $scores_id .'&p='. $scores_page;
}
return $scores_url;
}
// BB Code
function bbcode($text) {
global $settings, $lang;
$text = str_replace('
','<b>',$text);
$text = str_replace('','</b>',$text);
$text = str_replace('
','<u>',$text);
$text = str_replace('','</u>',$text);
$text = str_replace('
','<i>',$text);
$text = str_replace('','</i>',$text);
$text = str_replace('
','<s>',$text);
$text = str_replace('','</s>',$text);
$text = str_replace('
Alıntı
','<div class="quote">',$text);
$text = str_replace('
','</div>',$text);
$text = str_replace('

','<img src="https://www.r10.net/php/'. $settings['siteurl'] .'/images/happy.gif" title="'. $lang['bb_happy'] .'" alt="'. $lang['bb_happy'] .'" />',$text);
$text = str_replace('

','<img src="https://www.r10.net/php/'. $settings['siteurl'] .'/images/sad.gif" title="'. $lang['bb_sad'] .'" alt="'. $lang['bb_sad'] .'" />',$text);
$text = str_replace('

','<img src="https://www.r10.net/php/'. $settings['siteurl'] .'/images/wink.gif" title="'. $lang['bb_wink'] .'" alt="'. $lang['bb_wink'] .'" />',$text);
$text = str_replace(':@:','<img src="https://www.r10.net/php/'. $settings['siteurl'] .'/images/@.gif" title="@" alt="@" />',$text);
$text = str_replace(':8','<img src="https://www.r10.net/php/'. $settings['siteurl'] .'/images/cool.gif" title="'. $lang['bb_cool'] .'" alt="'. $lang['bb_cool'] .'" />',$text);
$text = str_replace('

','<img src="https://www.r10.net/php/'. $settings['siteurl'] .'/images/wave.gif" title="'. $lang['bb_wave'] .'" alt="'. $lang['bb_wave'] .'" />',$text);
$text = str_replace(':think:','<img src="https://www.r10.net/php/'. $settings['siteurl'] .'/images/think.gif" title="'. $lang['bb_hmm'] .'" alt="'. $lang['bb_hmm'] .'" />',$text);
$text = str_replace('

','<img src="https://www.r10.net/php/'. $settings['siteurl'] .'/images/clap.gif" title="'. $lang['bb_clap_hands'] .'" alt="'. $lang['bb_clap_hands'] .'" />',$text);
return $text;
}
// Generate real date from UNIX timestamp
function mod_date($time) {
global $lang;
$day = date('j', $time);
$month = $lang['datetime'][date('F', $time)];
$year = date('Y', $time);
return $day .' '. $month .' '. $year;
}
// Get the number of stars
function stars($stars) {
if ($stars < 0.50) {
$stars = 0;
} elseif ($stars < 1.50) {
$stars = 1;
} elseif ($stars < 2.50) {
$stars = 2;
} elseif ($stars < 3.50) {
$stars = 3;
} elseif ($stars < 4.50) {
$stars = 4;
} else {
$stars = 5;
}
return $stars;
}
// Filter bad words
function word_filter($text) {
global $settings;
if ($settings['bad_word_filter'] == '1') {
$bad_words = explode(' ', $settings['bad_words']);
foreach ($bad_words as $bad_word) {
if (stristr(trim($text),$bad_word)) {
$word_length = strlen($bad_word);
for ($i = 1; $i <= $word_length; $i++) {
$stars .= '*';
}
$text = eregi_replace($bad_word,$stars,trim($text));
$stars = '';
}
}
}
return $text;
}
// Redirect page
function redirect_page($redirect_url, $redirect_message) {
global $settings, $lang;
$lang['if_not_redirected'] = str_replace('{$redirect_url}', $redirect_url, $lang['if_not_redirected']);
template_redirect($redirect_url, $redirect_message);
exit();
}
// onArcade 201 \\
// Load categories
function menu_categories() {
global $tbl_prefix, $settings, $user;
if ($user['status'] == '1') {
$categories_menu_query = mysql_query("SELECT name, catid FROM ". $tbl_prefix ."categories WHERE status = '1' && parentcategory = '0' ORDER BY catorder, name");
} else {
$categories_menu_query = mysql_query("SELECT name, catid FROM ". $tbl_prefix ."categories WHERE status = '1' && permissions = '1' && parentcategory = '0' ORDER BY catorder, name");
}
$menu_categories = array();
$break = FALSE;
while ($categories_menu_row = mysql_fetch_assoc($categories_menu_query)) {
$menu_categories[] = array (
'url' => categoryurl($categories_menu_row['catid'], $categories_menu_row['name'], 1),
'title' => $categories_menu_row['name'],
'break' => $break
);
$break = TRUE;
}
return $menu_categories;
}
// Get most popular files
function most_popular() {
global $tbl_prefix, $settings;
$most_popular_query = mysql_query("SELECT title, fileid, timesplayed FROM ". $tbl_prefix ."files WHERE status = '1' ORDER BY timesplayed DESC LIMIT ". $settings['max_most_popular']);
$position = '0';
$most_popular = array();
while ($most_popular_row = mysql_fetch_assoc($most_popular_query)) {
$position++;
$most_popular[] = array (
'id' => $most_popular_row['fileid'],
'title' => $most_popular_row['title'],
'played' => number_format($most_popular_row['timesplayed']),
'position' => $position
);
}
return $most_popular;
}
// Get newest files
function newest() {
global $tbl_prefix, $settings;
$newest_query = mysql_query("SELECT title, fileid, timesplayed FROM ". $tbl_prefix ."files WHERE status = '1' ORDER BY dateadded DESC, fileid DESC LIMIT ". $settings['max_newest']);
$position = '0';
$newest = array();
while ($newest_row = mysql_fetch_assoc($newest_query)) {
$position++;
$newest[] = array (
'id' => $newest_row['fileid'],
'title' => $newest_row['title'],
'played' => number_format($newest_row['timesplayed']),
'position' => $position
);
}
return $newest;
}
// Get top players
function top_players() {
global $tbl_prefix, $settings;
$top_players_query = mysql_query("SELECT userid, username, played FROM ". $tbl_prefix ."users WHERE status = '1' ORDER BY played DESC LIMIT ". $settings['max_top_players']);
$position = '0';
$top_players = array();
while ($top_players_row = mysql_fetch_assoc($top_players_query)) {
$position++;
$top_players[] = array (
'id' => $top_players_row['userid'],
'name' => $top_players_row['username'],
'plays' => number_format($top_players_row['played']),
'position' => $position
);
}
return $top_players;
}
// Get top links
function top_links() {
global $tbl_prefix, $settings;
$links_query = mysql_query("SELECT name, linkurl FROM ". $tbl_prefix ."links WHERE status = '1' ORDER BY hitsin DESC LIMIT ". $settings['max_links']);
$top_links = array();
while ($links_row = mysql_fetch_assoc($links_query)) {
$top_links[] = array (
'title' => nohtml($links_row['name']),
'url' => nohtml($links_row['linkurl'])
);
}
return $top_links;
}
?>