<?

/*
// +--------------------------------------------------------------------------+
// | Project:    NVTracker - NetVision BitTorrent Tracker                     |
// +--------------------------------------------------------------------------+
// | This file is part of NVTracker. NVTracker is based on BTSource,          |
// | originally by RedBeard of TorrentBits, extensively modified by           |
// | Gartenzwerg.                                                             |
// |                                                                          |
// | NVTracker is free software; you can redistribute it and/or modify        |
// | it under the terms of the GNU General Public License as published by     |
// | the Free Software Foundation; either version 2 of the License, or        |
// | (at your option) any later version.                                      |
// |                                                                          |
// | NVTracker is distributed in the hope that it will be useful,             |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of           |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            |
// | GNU General Public License for more details.                             |
// |                                                                          |
// | You should have received a copy of the GNU General Public License        |
// | along with NVTracker; if not, write to the Free Software Foundation,     |
// | Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA            |
// +--------------------------------------------------------------------------+
// | Obige Zeilen dürfen nicht entfernt werden!    Do not remove above lines! |
// +--------------------------------------------------------------------------+
*/

ob_start("ob_gzhandler");

require "include/bittorrent.php";
hit_start();

dbconn(true);


// last disabled user by binnett69 abfrage
$res7 = mysql_query("SELECT id, username FROM users WHERE enabled = 'no' ORDER BY last_access LIMIT 15") or 

print(mysql_error());

while ($arr7 = mysql_fetch_assoc($res7))
{

    
if ($inactiv) $inactiv .= ",\n";
    //$ers["username"] = "<font class=".get_class_color($ers["class"]).">" . $ers["username"] . "</font>";
    if ($CURUSER)
        $inactiv .= "<a href=userdetails.php?id=" . $arr7["id"] . "><b>" . $arr7["username"] . "</b></a>";
    else
        $inactiv .= "<b>$arr7[username]</b>";
    
    }

if (!$inactiv)
    $inactiv = "Es sind keine gebannten User auf diesem Tracker.";
 // last disabled user by binnett69 abfrage end


if ($HTTP_SERVER_VARS["REQUEST_METHOD"] == "POST")
{
    $choice = $_POST["choice"];
    if ($CURUSER && $choice != "" && $choice < 256 && $choice == floor($choice))
    {
        $res = mysql_query("SELECT * FROM polls ORDER BY added DESC LIMIT 1") or sqlerr();
        $arr = mysql_fetch_assoc($res) or die("No poll");
        $pollid = $arr["id"];
        $userid = $CURUSER["id"];
        $res = mysql_query("SELECT * FROM pollanswers WHERE pollid=$pollid && userid=$userid") or sqlerr();
        $arr = mysql_fetch_assoc($res);
        if ($arr)
            die("Dupe vote");
        mysql_query("INSERT INTO pollanswers VALUES(0, $pollid, $userid, $choice)") or sqlerr();
        if (mysql_affected_rows() != 1)
            stderr("Error", "Ein Fehler ist passiert! Deine Stimme konnte nicht gez&auml;hlt werden.");
        header("Location: $BASEURL/?".SID);
        die;
    }
    else{
$user = $CURUSER['id'];
if($_GET["act"]=="Arcade")
{
if($_POST['gname'] == "asteroids")
{
$game = 1;
$level = 1;
$score = $_POST['score'];
}
if($_POST['gname'] == "breakout")
{
$game = 2;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "hexxagon")
{
$game = 3;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "invaders")
{
$game = 4;
$level = 1;
$score = $_POST['score'];
}
if($_POST['gname'] == "moonlander")
{
$game = 5;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "pacman")
{
$game = 6;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "psol")
{
$game = 7;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "simon")
{
$game = 8;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "snake")
{
$game = 32;
if($_POST['levelName'] == "LEVEL: SLUG")
{
$level = 1;
}
if($_POST['levelName'] == "LEVEL: WORM")
{
$level = 2;
}
if($_POST['levelName'] == "LEVEL: PYTHON")
{
$level = 3;
}
$score = $_POST['score'];
}
if($_POST['gname'] == "tetris")
{
$game = 33;
$level = $_POST['level'];
$score = $_POST['gscore'];
}
if($_POST['gname'] == "raiden")
{
$game = 11;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "donkeykong")
{
$game = 12;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "algarXec")
{
$game = 13;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "curveball2ibpg")
{
$game = 14;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "doomjs")
{
$game = 15;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "foosball")
{
$game = 16;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "froggster")
{
$game = 17;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "gta")
{
$game = 18;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "homersbeerrun2BH")
{
$game = 19;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "jungleescape")
{
$game = 20;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "marblemayhem")
{
$game = 21;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "pathfinder")
{
$game = 22;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "SuperFlashMarioBrosSte")
{
$game = 23;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "3d_Net_Blazer")
{
$game = 24;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "starwars")
{
$game = 25;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "bomberman")
{
$game = 26;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "theturtles")
{
$game = 27;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "fingerfooty")
{
$game = 28;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "BubbleShooterSte")
{
$game = 29;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "micromachines")
{
$game = 30;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "actiondrivinggameXec")
{
$game = 31;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "BreakfastBrawlSte")
{
$game = 9;
$level = 1;
$score = $_POST['gscore'];
}
if($_POST['gname'] == "xevious")
{
$game = 10;
$level = 1;
$score = $_POST['gscore'];
}
mysql_query("INSERT INTO `flashscores` ( `ID` , `game` , `user` , `level` , `score` ) VALUES ( '', '".$game."', '".$user."', '".$level."', '".$score."');") OR DIE(MySQL_ERROR());
$url="flashscores.php";
print("<html><head><meta http-equiv=refresh content='0;url=$url'></head>\n");

}else{
stderr("Error", "An error occured.");
}
}
}

$result8 = mysql_query("SELECT id, username FROM users WHERE status = 'confirmed' ORDER BY added DESC LIMIT 1") or 

print(mysql_error());

while ($array8 = mysql_fetch_assoc($result8))
{

    
if ($new) $new .= ",\n";
    $ers["username"] = "<font class=".get_class_color($ers["class"]).">" . $ers["username"] . "</font>";
    if ($CURUSER)
        $new .= "<a href=userdetails.php?id=" . $array8["id"] . "><b>" . $array8["username"] . "</b></a>";
    else
        $new .= "<b>$array8[username]</b>";
    
    }


$a = @mysql_fetch_assoc(@mysql_query("SELECT id,username FROM users WHERE status='confirmed' ORDER BY id DESC LIMIT 1")) or die(mysql_error());
if ($CURUSER)
    $latestuser = "<a href=userdetails.php?id=" . $a["id"] . ">" . $a["username"] . "</a>";
else
    $latestuser = $a['username'];



$registered = number_format(get_row_count("users"));
$unverified = number_format(get_row_count("users", "WHERE status='pending'"));
$inactive = number_format(get_row_count("users", "WHERE enabled='no'"));
$torrents = get_row_count("torrents");
$dead = get_row_count("torrents", "WHERE visible='no'");

$r = mysql_query("SELECT value_u FROM avps WHERE arg='seeders'") or sqlerr(__FILE__, __LINE__);
$a = mysql_fetch_row($r);
$seeders = 0 + $a[0];
$r = mysql_query("SELECT value_u FROM avps WHERE arg='leechers'") or sqlerr(__FILE__, __LINE__);
$a = mysql_fetch_row($r);
$leechers = 0 + $a[0];
$r = mysql_query("SELECT SUM(downloaded) FROM users WHERE enabled='yes'") or sqlerr(__FILE__, __LINE__);
$a = mysql_fetch_row($r);
$totaldown = mksize(0 + $a[0]);
$r = mysql_query("SELECT SUM(uploaded) FROM users WHERE enabled='yes'") or sqlerr(__FILE__, __LINE__);
$a = mysql_fetch_row($r);
$totalup = mksize(0 + $a[0]);

if ($leechers == 0)
    $ratio = 0;
else
    $ratio = round($seeders / $leechers * 100);

$peers = number_format($seeders + $leechers);
$seeders = number_format($seeders);
$leechers = number_format($leechers);

$dt = time() - 200;
$dt = sqlesc(get_date_time($dt));
$maxdt = get_date_time(time() - 21600*28);
$res = mysql_query("SELECT id, username, class, donor, warned, avatar, added, uploaded, downloaded, title, seedbonus, enabled FROM users WHERE last_access >= $dt AND last_access <= NOW() ORDER BY class DESC,username") or print(mysql_error());
$activeusers_no = mysql_num_rows($res);

while ($arr = mysql_fetch_assoc($res))
{
    if ($activeusers) $activeusers .= ",\n";
$res2 = mysql_query("SELECT COUNT(*) FROM peers WHERE userid=" . htmlspecialchars($arr["id"]) . " AND seeder='yes'") or print(mysql_error());

$row = mysql_fetch_row($res2);

$activeseed = $row[0];

$res2 = mysql_query("SELECT COUNT(*) FROM peers WHERE userid=" . htmlspecialchars($arr["id"]) . " AND seeder='no'") or print(mysql_error());

$row = mysql_fetch_row($res2);

$activeleech = $row[0];
//// end

if ($arr[added] == "0000-00-00 00:00:00")
$joindate = 'N/A';
else
$joindate = "User seit " . get_elapsed_time(sql_timestamp_to_unix_timestamp($arr["added"])) . "";

if ($arr["downloaded"] > 0)
{
$ratio = number_format($arr["uploaded"] / $arr["downloaded"], 3);
$ratio = "<font color=" . get_ratio_color($ratio) . ">$ratio</font>";
}
else
if ($arr["uploaded"] > 0)
$ratio = "Inf.";
else
$ratio = "---";

$uploaded = mksize($arr["uploaded"]);
$downloaded = mksize($arr["downloaded"]);
$username = $arr["username"];
$bonus = $arr["seedbonus"];
if ($arr["avatar"])
$avatarover = $arr["avatar"];
elseif (!$arr["avatar"])
$avatarover = $GLOBALS["PIC_BASE_URL"] . "default_avatarr.gif";

$res3 = mysql_query("SELECT webseed FROM users WHERE webseed = 'yes'") or print(mysql_error());
if (mysql_num_rows($res3)) {
$wbs="<b> WSEED </b>";
            }
else
{
$wbs="";
            }

$res4 = mysql_query("SELECT adsl FROM users WHERE adsl = 'yes'") or print(mysql_error());
if (mysql_num_rows($res4)) {
$adsl="<b> ADSL2 </b>";
            }
else
{
$adsl="";
            }

$res5 = mysql_query("SELECT * FROM users") or print(mysql_error());
if (isset($arr["vdsl"]) && $arr["vdsl"] == "yes"){
$vdsl="<b> VDSL </b>";
            }
else
{
$vdsl="";
            }
$arr["username"] = "<a href=userdetails.php?id=" . $arr["id"] . " onmouseover=\"return overlib('<img align=left src=$avatarover height=110 width=65><div align=top><font color=#EC0000>$arr[title]</font><br>$joindate<br> <font color=green>UP:$uploaded</font><br> <font color=darkred>DL:$downloaded</font><br>Bonus: <font color=green>$bonus</font><br><font color=black> R:$ratio</font><br><font color=black>$wbs $vdsl $adsl</font></div>', CAPTION, '<font class=".get_class_color($arr["class"]).">$username</font> <img src=pic/arrowupp1.gif> <font color=green>$activeseed</font> <img src=/pic/arrowdownn1.gif> <font color=darkred>$activeleech</font>');\" onmouseout=\"return nd();\"><font class=".get_class_color($arr["class"]).">" . htmlspecialchars($arr["username"]) . "</font></a>";

    /*$arr["username"] = "<font class=".get_class_color($arr["class"]).">" . $arr["username"] . "</font>";*/
    if ($CURUSER)
        $activeusers .= "<a href=userdetails.php?id=" . $arr["id"] . "><b>" . $arr["username"] . "</b></a>";
    else
        $activeusers .= "<b>$arr[username]</b>";

    $activeusers .= "&nbsp;".get_user_icons($arr);
}

if (!$activeusers)
    $activeusers = "Keine aktiven Mitglieder in den letzten 15 Minuten.";

stdhead();
signupreturn();


if ($CURUSER){
?>
<style type="text/css">
<!--
.Stil2 {color: #FF0000}
-->
</style>


<script type="text/javascript">

function expandCollapse(newsId)
{
    var plusMinusImg = document.getElementById("plusminus"+newsId);
    var detailRow = document.getElementById("details"+newsId);

    if (detailRow.style.display == "none") {
        plusMinusImg.src = "<?=$GLOBALS["PIC_BASE_URL"].$GLOBALS["ss_uri"]?>/minus.gif";
        detailRow.style.display = "table-row";
    } else {
        plusMinusImg.src = "<?=$GLOBALS["PIC_BASE_URL"].$GLOBALS["ss_uri"]?>/plus.gif";
        detailRow.style.display = "none";
    }
}

</script>
<table cellpadding="4" cellspacing="1" border="0" style="width:100%" class="tableinborder">
 <tr  class="tabletitle" width="100%">
        <td colspan="10" width="100%"><span class="normalfont"><center><img src="<?=$GLOBALS["PIC_BASE_URL"]?>newsticker.png" width="22" height="22" alt="" style="vertical-align: middle;"> <b>Neuigkeiten 
<?


if (get_user_class() >= UC_CO_ADMIN)
        print(" <a href=\"news.php\"><img src=\"".$GLOBALS["PIC_BASE_URL"]."news_add.png\" width=\"22\" height=\"22\" alt=\"News hinzufügen\" title=\"News hinzufügen\" style=\"vertical-align: middle;border:none\"></a>");
?>

</b></center></span></td>
 </tr><tr><td width="100%" class="tablea">
 <?
$res = mysql_query("SELECT * FROM news WHERE ADDDATE(added, INTERVAL 45 DAY) > NOW() ORDER BY added DESC LIMIT 10") or sqlerr(__FILE__, __LINE__);

if (mysql_num_rows($res) > 0)
{
    $first = TRUE;
    begin_table(TRUE);
    while($array = mysql_fetch_array($res))
    {
        $user_id=$array['userid'];
        $res_username=mysql_query("SELECT username FROM users WHERE id=$user_id") or sqlerr(__FILE__, __LINE__);
        $username=mysql_fetch_array($res_username);
    
        $news_date=date("Y-m-d",strtotime($array['added']));
        $news_year=substr($news_date,0,4);
        $news_month=substr($news_date,5,2);
        $news_day=substr($news_date,8,2);
    
        $news_date=$news_day . "." . $news_month . "." . $news_year;
        $news_day=date("l",mktime(0,0,0,$news_month,$news_day,$news_year));
    
        if ($news_day == "Monday")
            $news_day="Montag";
        if ($news_day == "Tuesday")
            $news_day="Dienstag";
            if ($news_day == "Wednesday")
            $news_day="Mittwoch";
        if ($news_day == "Thursday")
            $news_day="Donnerstag";
        if ($news_day == "Friday")
            $news_day="Freitag";
        if ($news_day == "Saturday")
            $news_day="Samstag";
        if ($news_day == "Sunday")
            $news_day="Sonntag";


        echo "<tr><td class=tablecat align=left>";
        if ($first)
        print("<a href=\"javascript:expandCollapse('" . $array['id'] . "');\"><img id=\"plusminus" . $array['id'] . "\" src=\"".$GLOBALS["PIC_BASE_URL"].$GLOBALS["ss_uri"]."/minus.gif\" alt=\"Auf-/Zuklappen\" border=\"0\"></a>\n");
        else
        print("<a href=\"javascript:expandCollapse('" . $array['id'] . "');\"><img id=\"plusminus" . $array['id'] . "\" src=\"".$GLOBALS["PIC_BASE_URL"].$GLOBALS["ss_uri"]."/plus.gif\" alt=\"Auf-/Zuklappen\" border=\"0\"></a>\n");
        print("<b>".htmlspecialchars($array["title"])."</b> ");
        print("(Von <a class=altlink href=userdetails.php?id=$user_id>" . $username['username'] . "</a>, " . $news_day . ", " . $news_date . ") ");
        if (get_user_class() >= UC_CO_ADMIN)
        {
    print(" <font class=middle><a class=altlink href=news.php?action=edit&newsid=" . $array['id'] . "&returnto=" . urlencode($_SERVER['PHP_SELF']) . "><img src=\"".$GLOBALS["PIC_BASE_URL"]."edit.png\" width=\"16\" height=\"16\" alt=\"Bearbeiten\" title=\"Bearbeiten\" border=\"0\" style=\"vertical-align:bottom\"></font>");
            print(" <font class=middle><a class=altlink href=news.php?action=delete&newsid=" . $array['id'] . "&returnto=" . urlencode($_SERVER['PHP_SELF']) . "><img src=\"".$GLOBALS["PIC_BASE_URL"]."editdelete.png\" width=\"16\" height=\"16\" alt=\"L&ouml;schen\" title=\"L&ouml;schen\" border=\"0\" style=\"vertical-align:bottom\"></a></font>");
        }
    
        if ($first)
            print("<tr id=\"details" . $array['id'] . "\" style=\"display:table-row;\">");
        else
        print("<tr id=\"details" . $array['id'] . "\" style=\"display:none;\">");
        print("<td class=\"tablea\" align=\"left\"><div align=\"justify\">" . format_comment($array['body']));
        print("</td></tr>");
        $first = FALSE;
    }
    end_table();
}
}

?>
</td></tr></table>

<br>




<br>
<?php


if ($CURUSER)
{

//Letzen 10 torrents mit bild
begin_frame("Die 20 neusten <a href=browse.php>Torrents</a>","true","100%");
if($CURUSER[xxx] =='yes'){
$query="SELECT * FROM torrents WHERE poster <> '' AND activated !='no' ORDER BY added DESC limit 20";
}
else
{
$query="SELECT * FROM torrents WHERE poster <> '' AND activated !='no' AND category !='38' ORDER BY added DESC limit 20";
}
$result=mysql_query($query);$num = mysql_num_rows($result);
// count rows
print'<marquee scrollAmount=2 onMouseover="this.scrollAmount=0" onMouseout="this.scrollAmount=2" scrolldelay="0"

direction="left">';
print '<center><table border=0 cellspacing=0 cellpadding=5><tr>';
$i=20;
while ($row = mysql_fetch_assoc($result)) { $id = $row['id'];
print'<td>';

$res7 = mysql_query("SELECT name FROM categories WHERE id=$row[category]");
$arr7 = mysql_fetch_assoc($res7);
$cat = $arr7["name"];



$free1 = mysql_query("SELECT * FROM torrents WHERE free = 'yes'") or sqlerr();
if  ($row[free]=="yes") {
$free1="<b><font color=yellow> [ONLY UPLOAD] </font></b>";
            }
else
{
$free1="";
            }

$free2 = mysql_query("SELECT * FROM torrents WHERE freeleech = 'yes'") or sqlerr();
if  ($row[freeleech]=="yes") {
$free2="<b><font color=#888800> [FREELEECH] </font></b>";
            }
else
{
$free2="";
            }

$highlight1 = mysql_query("SELECT * FROM torrents WHERE highlight = 'yes'") or sqlerr();
if  ($row[highlight]=="yes") {
$highlight1="<b><font color=#888800> [KINO HIGHLIGHT] </font></b>";
            }
else
{
$highlight1="";
            }

$multi1 = mysql_query("SELECT * FROM torrents WHERE multi > '0'") or sqlerr();
if  ($row[multi]>"0") {
$multi1="<b><font color=#888800> [MULTI TORRENT] </font></b>";
            }
else
{
$multi1="";
            }

$res8 = mysql_query("SELECT users.webseed FROM users JOIN peers ON users.id = peers.userid WHERE peers.torrent=$id AND users.webseed ='yes' AND peers.seeder = 'yes'") or sqlerr();
if (mysql_num_rows($res8) > 0) {
$wbs="<b><font color=blue> [WEBSEED] </font></b>";
            }
else
{
$wbs="";
            }

$res81 = mysql_query("SELECT users.adsl FROM users JOIN peers ON users.id = peers.userid WHERE peers.torrent=$id AND users.adsl ='yes' AND peers.seeder = 'yes'") or sqlerr();
if (mysql_num_rows($res81) > 0) {
$adsl="<b><font color=yellow> [ADSL2] </font></b>";
            }
else
{
$adsl="";
            }

$res91 = mysql_query("SELECT users.vdsl FROM users JOIN peers ON users.id = peers.userid WHERE peers.torrent=$id AND users.vdsl ='yes' AND peers.seeder = 'yes'") or sqlerr();
if (mysql_num_rows($res91) > 0) {
$vdsl="<b><font color=yellow> [VDSL] </font></b>";
            }
else
{
$vdsl="";
            }
$size = mksize($row["size"]);

$res9=mysql_query("SELECT * FROM peers WHERE torrent=$id AND seeder = 'yes'") or sqlerr();
$seeder=mysql_num_rows($res9);
$res91=mysql_query("SELECT * FROM peers WHERE torrent=$id AND seeder != 'yes'") or sqlerr();
$leecher=mysql_num_rows($res91);
$name = $row['name'];
  $poster = $row['poster'];
$name = str_replace('_', ' ' , $name);
$name = str_replace('.', ' ' , $name);
$name = substr($name, 0, 50);
echo "<a href=\"/details.php?id=$id&hit=1\" onMouseover=\"overlib('<table cellpadding=4 cellspacing=1 width=100% height=80><tr><td class=tablea align=center ><b><font color=white>$name</font></b><br><font color=green>$seeder Seeder</font><br><font color=red>$leecher Leecher</font><br><font color=black><b>$cat</b><br>$wbs<br> $vdsl<br> $adsl<br> $free1<br> $free2 <br>$highlight1<br> $multi1</font></td></tr></table>','blue')\"
 onMouseout=\"nd()\"><img src=$poster width=\"82\" height=\"100\" border=1></a>";
 $i++;
}
print'</td>';
echo "</center></table></marquee>";
 end_frame();



?>

<script type="text/javascript">
<!--
function bbshout(repdeb, repfin) {
  var input = document.forms['shbox'].elements['shbox_text'];
  input.focus();

  if(typeof document.selection != 'undefined') {

    var range = document.selection.createRange();
    var insText = range.text;
    range.text = repdeb + insText + repfin;

    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -repfin.length);
    } else {
      range.moveStart('character', repdeb.length + insText.length + repfin.length);
    }
    range.select();
  }

  else if(typeof input.selectionStart != 'undefined')
  {

    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + repdeb + insText + repfin + input.value.substr(end);

    var pos;
    if (insText.length == 0) {
      pos = start + repdeb.length;
    } else {
      pos = start + repdeb.length + insText.length + repfin.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }

  else
  {

    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos)) {
      pos = prompt("Insertion à la position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length) {
      pos = input.value.length;
    }

    var insText = prompt("Veuillez entrer le texte à formater:");
    input.value = input.value.substr(0, pos) + repdeb + insText + repfin + input.value.substr(pos);
  }
}

function bbcolor() {
   var colorvalue = document.forms['shbox'].elements['color'].value;
   bbshout("[color="+colorvalue+"]", "[/color]");
}

function bbfont() {
   var fontvalue = document.forms['shbox'].elements['font'].value;
   bbshout("[font="+fontvalue+"]", "[/font]");
}
function bbsize() {
    var sizevalue = document.forms['shbox'].elements['size'].value;
    bbshout("[size="+sizevalue+"]", "[/size]");
}
function bbimg() {
    var imgvalue = document.forms['shbox'].elements['img'].value;
    bbshout("[img="+sizevalue+"]", "[/img]");
}
//-->
</script>
<script language=javascript>
function SmileIT(smile,form,text){
   document.forms[form].elements[text].value = document.forms[form].elements[text].value+" "+smile+" ";
   document.forms[form].elements[text].focus();
}
</script>
<script LANGUAGE="JavaScript"><!--
function mySubmit() {
   setTimeout('document.shbox.reset()',100);
}
function winop1()
{
windop1 = window.open("smilies2.php?form=<?=$form?>&text=<?=$text?>","mywin","height=400,width=400,resizable=yes,scrollbars=yes");
}
//--></SCRIPT>
<?
function quickbbshout(){
echo "<center><table border=0 cellpadding=0 cellspacing=2><tr>";
echo "<tr>";
echo "<td width=22><a href=\"javascript:bbshout('[b]', '[/b]')\"><img src=./pic/bold.png border=0 alt='Bold'></a></td>";
echo "<td width=22><a href=\"javascript:bbshout('[i]', '[/i]')\"><img src=./pic/italic.png border=0 alt='Italic'></a></td>";
echo "<td width=22><a href=\"javascript:bbshout('[u]', '[/u]')\"><img src=./pic/underline.png border=0 alt='Underline'></a></td>";
echo "<td width=22><a href=\"javascript:bbshout('[url]', '[/url]')\"><img src=./pic/url.png border=0 alt='Url'></a></td>";
echo "<td width=22><a href=\"javascript:bbshout('[img]', '[/img]')\"><img src=./pic/image.png border=0 alt='Img'></a></td>";
echo "<td>
<select name='color' size='0.5' onChange=\"javascript:bbcolor()\">
<option selected='selected'>COLOR</option>
<option value=skyblue style=color:skyblue>sky blue</option>
<option value=royalblue style=color:royalblue>royal blue</option>
<option value=blue style=color:blue>blue</option>
<option value=darkblue style=color:darkblue>dark-blue</option>
<option value=orange style=color:orange>orange</option>
<option value=orangered style=color:orangered>orange-red</option>
<option value=crimson style=color:crimson>crimson</option>
<option value=red style=color:red>red</option>
<option value=firebrick style=color:firebrick>firebrick</option>
<option value=darkred style=color:darkred>dark red</option>
<option value=green style=color:green>green</option>
<option value=limegreen style=color:limegreen>limegreen</option>
<option value=seagreen style=color:seagreen>sea-green</option>
<option value=deeppink style=color:deeppink>deeppink</option>
<option value=tomato style=color:tomato>tomato</option>
<option value=coral style=color:coral>coral</option>
<option value=purple style=color:purple>purple</option>
<option value=indigo style=color:indigo>indigo</option>
<option value=burlywood style=color:burlywood>burlywood</option>
<option value=sandybrown style=color:sandybrown>sandy brown</option>
<option value=sienna style=color:sienna>sienna</option>
<option value=chocolate style=color:chocolate>chocolate</option>
<option value=teal style=color:teal>teal</option>
<option value=silver style=color:silver>silver</option>
</select></td>";
echo "<td>
<select name='font' size='0.5' onChange=\"javascript:bbfont()\">
<option selected='selected'>FONT</option>
<option value=arial>Arial</option>
<option value=comic sans ms>Comic</option>
<option value=courier new>Courier New</option>
<option value=tahoma>Tahoma</option>
<option value=times new roman>Times New Roman</option>
<option value=verdana>Verdana</option>
</select></td>";
echo "<td>
<select name='size' size='0.5' onChange=\"javascript:bbsize()\">
<option selected='selected'>Size</option>
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
<option value=5>5</option>
<option value=6>6</option>
<option value=7>7</option>
</select></td>";
echo "</tr></table></center>";
}
?>
<?begin_frame("Shoutbox",true,30);?>
<iframe src='./shoutbox.php' width='800%' height='300' align='center' frameborder='0' name='sbox' marginwidth='0' marginheight='0'></iframe><br><br>
<form action='./shoutbox.php' method='get' target='sbox' name='shbox' onSubmit="mySubmit()">
<p align="center">Message: <input type='text' name='shbox_text' size='110'> <input type='submit' class='btn' value=' Shout '>
<input type='hidden' name='sent' value='yes'><br>
<center><font size="1"><a href='./shoutbox.php' target='sbox'type="button" class='btn'>refresh</a><span class="smallfont">&nbsp;&nbsp;<a href='shoutbox2.php?history=1' target='_blank'type="button" class='btn'>History</a>&nbsp;&nbsp;<a href="javascript:winop1(); "type="button" class='btn' border: "1px solid gray" ><b>Mehr Smilies</b></a></center>



<?
quickbbshout();
?>
<br>
<center><a href="javascript: SmileIT(':axe:','shbox','shbox_text')"><img src=pic/smilies/outch.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':-(','shbox','shbox_text')"><img src=pic/smilies/sad.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':weep:','shbox','shbox_text')"><img src=pic/smilies/weep.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':-O','shbox','shbox_text')"><img src=pic/smilies/ohmy.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT('8-)','shbox','shbox_text')"><img src=pic/smilies/cool1.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':yawn:','shbox','shbox_text')"><img src=pic/smilies/yawn.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':sly:','shbox','shbox_text')"><img src=pic/smilies/sly.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':greedy:','shbox','shbox_text')"><img src=pic/smilies/greedy.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':weirdo:','shbox','shbox_text')"><img src=pic/smilies/weirdo.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':sneaky:','shbox','shbox_text')"><img src=pic/smilies/sneaky.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':geek:','shbox','shbox_text')"><img src=pic/smilies/geek.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':evil:','shbox','shbox_text')"><img src=pic/smilies/evil.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':yucky:','shbox','shbox_text')"><img src=pic/smilies/yucky.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':shit:','shbox','shbox_text')"><img src=pic/smilies/shit.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':?:','shbox','shbox_text')"><img src=pic/smilies/question.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':!:','shbox','shbox_text')"><img src=pic/smilies/idea.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':smile:','shbox','shbox_text')"><img border=0 src=pic/smilies/smile2.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':kiss:','shbox','shbox_text')"<img border=0 src=pic/smilies/kiss.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':evo:','shbox','shbox_text')"><img src=pic/smilies/evo.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':-|','shbox','shbox_text')"><img border=0 src=pic/smilies/noexpression.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':-/','shbox','shbox_text')"><img border=0 src=pic/smilies/confused.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':wavecry:','shbox','shbox_text')"><img border=0 src=pic/smilies/wavecry.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':nugget:','shbox','shbox_text')"><img border=0 src=pic/smilies/nugget.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':bigsmilie:','shbox','shbox_text')"><img border=0 src=pic/smilies/bigsmilie.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':smart:','shbox','shbox_text')"><img border=0 src=pic/smilies/smart.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':baby:','shbox','shbox_text')"><img src=pic/smilies/baby.gif width="28" height="28" border=0></a>
<a href="javascript: SmileIT(':snap:','shbox','shbox_text')"><img border=0 src=pic/smilies/snap.gif width="28" height="28" border=0></a><center>

</td></form>
<br>

<?end_frame();?>



<br>
<table cellpadding="4" cellspacing="1" border="0" style="width:100%" class="tableinborder">
 <tr class="tabletitle" width="100%">
<tr><td class="tabletitle" align="left" colspan="5">
      <span class="smallfont"><center><b>Neustes Mitglied : <b>(<?=$latestuser?>)</b></center></span>

 </tr><tr><td width="100%" class="tablea"><center><b><font class="small" color="#18DFDF">Owner</font> |
<font class="small" color="#FFFFFF">Coder</font> | 
<font class="small" color="#ff0000">Sysop</font> |


  
<font class="small" color="#39DF18">Teamleitung</font> | 
<font class="small" color="#CC0066">Administrator</font> | 
<font class="small" color="#18849C">Co-Administrator</font> |
<font class="small" color="#990033">Moderator</font> |
<br> 
<font class="small" color="#0066FF">Uploader</font> | 
<font class="small" color="#C37B7B">Partner Vip</font> | 
<font class="small" color="#9C5A9C">VIP</font> | 
<font class="small" color="#C3C318">ExtremeUser</font> |
<font class="small" color="#00ff99">PowerUser</font> | 
<font class="small" color="#9CDEDF">User</font> |</font></b>
<tr><td class="tablea"><?=$activeusers?></td>
<tr><td class=tablecat><center><b>Aktive Mitglieder : (<?=$activeusers_no?>) | 
 | Gebannte user: (<?=$inactive?>) | Verwarnte user : (<?=$warned?>)</b></center></td>
</tr></table>
<br>

<?





if (get_user_class() < UC_USER)
{
stdmsg("Sorry...", "you do not have access.");
stdfoot();
exit;
}

?>
<table width=200% border=0 class=tableoutborder cellspacing=1 cellpadding=5>



<tr><td class="tabletitle" align="left" colspan="5">
      <span class="smallfont"><center><b>DeinTracker TeamSpeak</b></center></span>
     </td>

    </tr>
    <tr>
     <td class="tableb" width="40%">
      <span class="smallfont">&nbsp;<b>Server:</b><br />
           &nbsp;Server Name<br /><br />
           &nbsp;<b>Ip</b><br />
           &nbsp;Ipoder.url:<br />

           &nbsp;(Ip)<br /><br />
           &nbsp;<b>Version:</b><br />
           &nbsp;2.0.20.1<br /><br />
          

           &nbsp;Welcome to DeinTracker TeamSpeak<br /><br />
           &nbsp;<b>Download:</b><br />
           &nbsp;<a href="http://www.goteamspeak.com/index.php?page=downloads" target="_blank"><img src="pic/teamspeak_link.gif" border="0" alt="Download" title="Download" /></a>
</span>
     </td></td>
<td class=tablea><iframe src="TeamSpeakViewer2.0/ts.php?user=<? $CURUSER["username"] ?>" width=100% height="250" scrolling="yes" marginheight="0" marginwidth="0" frameborder="0"></iframe></td></tr>

</td></tr>
</table>
</form>
<?




?>

<br>

<table cellpadding="4" cellspacing="1" border="0" style="width:100%" class="tableinborder">
 <tr class="tabletitle" width="100%">
 <td colspan="10" width="100%"><span class="normalfont"><center> <b>Lottery</b></center></span></td> 
 </tr>
<td align=center width=50% class=tablea valign=top>
<table cellpadding="4" cellspacing="1" border="0" style="width:100%" class="tableinborder">
<tr>


<html>
<body>
<table>
<tr>
<td>
<?php
// ANFANG LOTTO
$res = mysql_query("SELECT * FROM lottery_config") or sqlerr(__FILE__, __LINE__);
while ($arr = mysql_fetch_assoc($res))
$arr_config[$arr['name']] = $arr['value'];

$who_won = explode("|", $arr_config['lottery_winners']);
$who_won = array_unique($who_won);
$lottery_winners = '';
for ($x = 0; $x < count($who_won); $x++)
{
$username = '';
$res2 = mysql_query("SELECT id, username FROM users") or sqlerr(__FILE__, __LINE__);
while ($arr2 = mysql_fetch_assoc($res2))
{
if ($arr2['id'] == $who_won[$x])
{
$username = '<a href="userdetails.php?id='. $arr2['id'] .'">'. $arr2['username'] .'</a>';
$lottery_winners .= (!$lottery_winners) ? $username : ', '. $username;
break;
}
}
}

if (count($who_won) > 1)
$winners = 'Gewinner';
else
$winners = 'Gewinner';

if (count($who_won) > 1)
$each = ' (Pro)';
else
$each = '';

print'<table width=100% border=0 cellspacing=0 cellpadding=5>';
print'<tr>';
?>
<?
print'</tr>';
print '</table>';
?>
</td>
</tr>
</table>

</body>
</html>
<p><center><a href="tickets.php"><b><Font size=4><Font color=red>Hier gibts :</b></Font>
 <img src="pic/TICKETS.gif" width="128" height="43" ALT="Tickets" / ><a>
<br><br><br>



<?php
        if ($arr_config["enable"] == 1) {
        echo "<center><table><tr><td valign=\"middle\"><font color=green>Lottery Online</font> <img src=\"" . $GLOBALS["PIC_BASE_URL"] . "button_online.gif\" width=\"81\" height=\"20\" alt=\"Online\" style=\"vertical-align: middle;\"></td>";
        }
        ?>
        <?
            if ($arr_config["enable"] == 0) {
        echo "<center><table><tr><td valign=\"middle\"><img src=\"" . $GLOBALS["PIC_BASE_URL"] . "button_offline.gif\" width=\"81\" height=\"20\" alt=\"Online\" style=\"vertical-align: middle;\"></td>";
        }
    ?>
    </td>
  </tr>
  <tr>
    <td class="rowhead">Letzte Lotterie</td>
    <td class="rowhead" align="left"><?=count($who_won)?>
        <?=$winners?></td>
  </tr>
  <tr>
    <td class="rowhead2">Letzter Lotterie
        <?=$winners?></td>
    <td class="rowhead2" align="left"><?=$lottery_winners?></td>
  </tr>
  <tr>
    <td class="rowhead">Letzte gewonnene Menge
        <?=$each?></td>
    <td class="rowhead" align="left"><?=mksize($arr_config['lottery_winners_amount'])?></td>
  </tr>
  <tr>
    <td class="rowhead2">Datum der letzten Lotterie</td>
    <td class="rowhead2" align="left"><?=$arr_config['lottery_winners_time']?></td>
  </tr>
  <tr>
    <td class="rowhead3">Lotteriescheine</td>
    <td class="rowhead3" align="left"><a href="tickets.php">Tickets Kaufen</a></td>
  </tr>
</table>  

<?php
end_frame();
// Ende Lotto
?></tr>
</table></table>

<?php
}
if ($CURUSER)
{
    echo "<table cellspacing=\"5\" cellpadding=\"0\" border=\"0\" style=\"width:100%\"><tr>";
    // get current poll
    $res = mysql_query("SELECT * FROM polls ORDER BY added DESC LIMIT 1") or sqlerr();
    $arr = mysql_fetch_assoc($res);
    if (is_array($arr)) {
        $pollid = $arr["id"];
        $userid = $CURUSER["id"];
        $question = $arr["question"];
        $o = array($arr["option0"], $arr["option1"], $arr["option2"], $arr["option3"], $arr["option4"],
            $arr["option5"], $arr["option6"], $arr["option7"], $arr["option8"], $arr["option9"],
            $arr["option10"], $arr["option11"], $arr["option12"], $arr["option13"], $arr["option14"],
            $arr["option15"], $arr["option16"], $arr["option17"], $arr["option18"], $arr["option19"]);

        // check if user has already voted
        $res = mysql_query("SELECT * FROM pollanswers WHERE pollid=$pollid AND userid=$userid") or sqlerr();
        $arr2 = mysql_fetch_assoc($res);

?><td valign="top" width="50%">
<table cellpadding="4" cellspacing="1" border="0" style="width:100%" class="tableinborder">
 <tr class="tabletitle" width="100%">
  <td colspan="10" width="100%"><span class="normalfont"><center><b> Aktuelle Umfrage<?

    if (get_user_class() >= UC_MODERATOR)
    {
        print("<font class=middle>");
        print(" - [<a class=altlink href=makepoll.php?returnto=main><b>Neu</b></a>]\n");
        print(" - [<a class=altlink href=makepoll.php?action=edit&pollid=$arr[id]&returnto=main><b>&Auml;ndern</b></a>]\n");
        print(" - [<a class=altlink href=polls.php?action=delete&pollid=$arr[id]&returnto=main><b>L&ouml;schen</b></a>]");
        print("</font>");
    }
?> </b></center></span></td>
 </tr><tr><td width="100%" class="tablea">
 <?
    print("<p align=center><b>$question</b></p>\n");

    $voted = $arr2;

    if ($voted)
    {

        // display results
        if ($arr["selection"])
            $uservote = $arr["selection"];
        else
            $uservote = -1;
        // we reserve 255 for blank vote.
        $res = mysql_query("SELECT selection FROM pollanswers WHERE pollid=$pollid AND selection < 20") or sqlerr();
        $tvotes = mysql_num_rows($res);
        $vs = array();
        $os = array();

        // count votes
        while ($arr2 = mysql_fetch_row($res))
            $vs[$arr2[0]] += 1;

        reset($o);
        for ($i = 0; $i < count($o); ++$i)
            if ($o[$i])
                $os[$i] = array($vs[$i], $o[$i]);

        function srt($a,$b)
        {
            if ($a[0] > $b[0]) return -1;
            if ($a[0] < $b[0]) return 1;
            return 0;
        }

        // now os is an array like this: array(array(123, "Option 1"), array(45, "Option 2"))
        if ($arr["sort"] == "yes")
            usort($os, srt);

        print("<center><table border=0 cellspacing=0 cellpadding=2>\n");
        $i = 0;
        while ($a = $os[$i])
        {
            if ($i == $uservote)
                $a[1] .= "&nbsp;*";
            if ($tvotes == 0)
                $p = 0;
            else
                $p = round($a[0] / $tvotes * 100);

            print("<tr><td nowrap align=left>" . $a[1] . "&nbsp;&nbsp;</td><td align=left>" .
        "<img src=\"".$GLOBALS["PIC_BASE_URL"].$GLOBALS["ss_uri"]."/vote_left".(($i%5)+1).".gif\"><img src=\"".$GLOBALS["PIC_BASE_URL"].$GLOBALS["ss_uri"]."/vote_middle".(($i%5)+1).".gif\" height=9 width=" . ($p * 5) .
        "><img src=\"".$GLOBALS["PIC_BASE_URL"].$GLOBALS["ss_uri"]."/vote_right".(($i%5)+1).".gif\"> $p%</td></tr>\n");
            $i++;
        }
        print("</table></center>\n");
        $tvotes = number_format($tvotes);
        print("<p align=center>Abgebene Stimmen: $tvotes</p>\n");
    }
    else
    {
        print("<form method=post action=index.php>\n");
        $i = 0;
        while ($a = $o[$i])
        {
            print("<input type=radio name=choice value=$i>$a<br>\n");
            ++$i;
        }
    print("<br>");
    print("<input type=radio name=choice value=255>Ich will keine Stimme abgeben, ich m&ouml;chte nur das Ergebnis sehen!<br>\n");
    print("<p align=center><input type=submit value='Vote!' class=btn></p>");
    }

if ($voted)
    print("<p align=center><a href=polls.php>Ältere Umfragen</a></p>\n");

?>
</td></tr>
</td><br><br><table><p>
<?
    }

    if ($GLOBALS["ENABLESHOUTCAST"]) {
        echo "<td valign=\"top\" width=\"30%\">";
        sc_infobox();
        echo "</td>\n";
    }
    echo "</tr></table>";
}

?>


<br>
<table cellpadding="4" cellspacing="1" border="0" style="width:100%" class="tableinborder">
 <tr class="tabletitle" width="100%">
  <td colspan="10" width="200%"><span class="normalfont"><center><b>..:: Oldscool NV By Djbrocken© ::..</b></center></span></td> 
</td></tr></table>
<p>
  <?
stdfoot();

hit_end();
?>
<script src="http://layer-ads.de/la-16184.js" type="text/javascript"></script>
</p>
<p>