Bravo List
Register
Go Back   > Bravo List > Source Code > Archived Trackers > Template Shares
Reply
  #1  
Old 26th December 2019, 16:11
Floky123 Floky123 is offline
Senior Member
 
Join Date: Nov 2013
Slovenia
Posts: 55
Default Time problem TS 1.3.9 by xam
Hi,

Im here again with some other problem...when i have display_errors on Off site works normal but time on site is problem that is not currect.

Errors are like:

Quote:
Warning: strtotime(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in /var/www/html/include/functions.php on line 1429 Warning: date(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in /var/www/html/include/globalfunctions.php on line 73
Quote:
Warning: getdate(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/Berlin' for 'CET/1.0/no DST' instead in /var/www/html/include/functions.php on line 899
Reply With Quote
  #2  
Old 26th December 2019, 18:12
smoky28's Avatar
smoky28 smoky28 is offline
Senior Member
 
Join Date: Aug 2010
Hungary
Posts: 82
Default
PHP Code:
function get_date_time($timestamp 0){  if ($timestamp)    return date("Y-m-d H:i:s"$timestamp);  else    return gmdate("Y-m-d H:i:s");} 
replace globalfuntcions php.
__________________
Sky-Tech Developer Team Hungary

Reply With Quote
  #3  
Old 26th December 2019, 19:37
firefly007's Avatar
firefly007 firefly007 is offline
SUPPORT GURU
 
Join Date: Jun 2010
P2P
Posts: 721
Default
Bump:
Quote:
Originally Posted by smoky28 View Post
PHP Code:
function get_date_time($timestamp 0){  if ($timestamp)    return date("Y-m-d H:i:s"$timestamp);  else    return gmdate("Y-m-d H:i:s");} 
replace globalfuntcions php.

If your fix prevents the warning from occurring and the person is happy with the fix than good BUT one has to wonder if the fix will also fix the security issue in the warning :(

If u need to get the correct time no matter where u are in the world and u wana do so without PHP complaining then this could work BUT! like I said u will need to edit a few things.


Just an example.

PHP Code:
function get_date_time(){

global 
$CURUSER;

date_default_timezone_set($CURUSER["timezone"]); 
return 
date("Y-m-d H:i:s");

I suppose u could just add
PHP Code:
date_default_timezone_set($CURUSER["timezone"]); 
at or near the top of globalfuntions.php too, if u want but maybe best practice to only trigger this when been used.
__________________




Please Support Majority Report


You can contact me on Skype live:phesadent.elect but please let me know first.


If you are ever need me desperately then please email me at dan.oak44@gmail.com and I will contact u within a week.


Due to free time I'm able to help interested member's with their tracker.

Please Note!
Depending on your requests I will charge you for my assistance for Tracker installs and mods.
All my mods are custom and prices will very depending on the request.
I'm able to install any tracker and mods including themes.

Please PM me

Reply With Quote
  #4  
Old 26th December 2019, 20:58
Floky123 Floky123 is offline
Senior Member
 
Join Date: Nov 2013
Slovenia
Posts: 55
Default
Quote:
Originally Posted by firefly007 View Post
Bump:


If your fix prevents the warning from occurring and the person is happy with the fix than good BUT one has to wonder if the fix will also fix the security issue in the warning :(

If u need to get the correct time no matter where u are in the world and u wana do so without PHP complaining then this could work BUT! like I said u will need to edit a few things.


Just an example.

PHP Code:
function get_date_time(){

global 
$CURUSER;

date_default_timezone_set($CURUSER["timezone"]); 
return 
date("Y-m-d H:i:s");

I suppose u could just add
PHP Code:
date_default_timezone_set($CURUSER["timezone"]); 
at or near the top of globalfuntions.php too, if u want but maybe best practice to only trigger this when been used.
There is my globalfunctions.php

PHP Code:
<?php
# IMPORTANT: Do not edit below unless you know what you are doing!
if(!defined('IN_TRACKER'))
  die(
'Hacking attempt!');

function 
display_date_time($timestamp 0)
{
if (
$timestamp)
   return 
date("Y-m-d H:i:s"$timestamp);
else
   return 
gmdate("Y-m-d H:i:s");
}

function 
get_user_timezone($id '') {    

if(!isset(
$id) || empty($id) || !is_valid_id($id))
    return 
"2"//Default timezone
    
$query mysql_query("SELECT * FROM users WHERE id=".sqlesc($id)." LIMIT 1");
if (
mysql_num_rows($query) != "0")
    {
        
$kasutaja mysql_fetch_array($query);
        return 
"$kasutaja[tzoffset]";
    }else
        return 
"2"//Default timezone
}

function 
get_row_count($table$suffix "")
{
  if (
$suffix)
    
$suffix $suffix";
  (
$r mysql_query("SELECT COUNT(*) FROM $table$suffix")) or die(mysql_error());
  (
$a mysql_fetch_row($r)) or die(mysql_error());
  return 
$a[0];
}
function 
stdmsg($heading$text$htmlstrip TRUE)
{
    if (
$htmlstrip) {
        
$heading htmlspecialchars(trim($heading));
        
$text htmlspecialchars(trim($text));
    }
    print(
"<table class=main width=737 border=0 cellpadding=0 cellspacing=0><tr><td class=embedded>\n");
        if (
$heading)
            print(
"<h2>$heading</h2>\n");
    print(
"<table width=100% border=1 cellspacing=0 cellpadding=10><tr><td class=text>\n");
    print(
$text "</td></tr></table></td></tr></table>\n");
}

function 
stderr($heading$text$htmlstrip TRUE$head true$foot true$die true)
{
    if (
$headstdhead();
    
    
stdmsg($heading$text$htmlstrip);
    
    if (
$footstdfoot();
    
    if (
$die) die;
}

function 
sqlerr($file ''$line '')
{
  print(
"<table border=0 bgcolor=blue align=left cellspacing=0 cellpadding=10 style='background: blue'>" .
    
"<tr><td class=embedded><font color=white><h1>SQL Error</h1>\n" .
  
"<b>" mysql_error() . ($file != '' && $line != '' "<p>in $file, line $line</p>" "") . "</b></font></td></tr></table>");
  die;
}

// Returns the current time in GMT in MySQL compatible format.
function get_date_time($timestamp 0)
{
    global 
$_COOKIE,$_SESSION;
if (
$timestamp)
    return 
date("Y-m-d H:i:s"$timestamp);
else {
   
$idcookie base64($_COOKIE["c_secure_uid"],false);
   if (!
$idcookie)
       
$idcookie base64($_SESSION["s_secure_uid"],false);
   return 
gmdate("Y-m-d H:i:s"time() + (60 get_user_timezone($idcookie)));
    }
}

function 
encodehtml($s$linebreaks true)
{
  
$s str_replace("<""&lt;"str_replace("&""&"$s));
  if (
$linebreaks)
    
$s nl2br($s);
  return 
$s;
}

function 
get_dt_num()
{
  return 
gmdate("YmdHis");
}

function 
format_urls($s)
{
    return 
preg_replace(
        
"/(\A|[^=\]'\"a-zA-Z0-9])((http|ftp|https|ftps|irc):\/\/[^()<>\s]+)/i",
        
"\\1<a href=\"\\2\">\\2</a>"$s);
}

/*

// Removed this fn, I've decided we should drop the redir script...
// it's pretty useless since ppl can still link to pics...
// -Rb

function format_local_urls($s)
{
    return preg_replace(
    "/(<a href=redir\.php\?url=)((http|ftp|https|ftps|irc):\/\/(www\.)?sitename\.(net|org|com)(:8[0-3])?([^<>\s]*))>([^<]+)<\/a>/i",
    "<a href=\\2>\\8</a>", $s);
}
*/

//Finds last occurrence of needle in haystack
//in PHP5 use strripos() instead of this
function _strlastpos ($haystack$needle$offset 0)
{
    
$addLen strlen ($needle);
    
$endPos $offset $addLen;
    while (
true)
    {
        if ((
$newPos strpos ($haystack$needle$endPos $addLen)) === false) break;
        
$endPos $newPos;
    }
    return (
$endPos >= 0) ? $endPos false;
}

function 
format_quotes($s)
{
    
preg_match_all('/\\<<<@!2!@>>>","</fieldset><br>",$s);
   return $s;
}

function format_comment($text, $strip_html = false, $xssclean = false)
{
    global $smilies, $privatesmilies, $CURUSER;

    $s = $text;

  // This fixes the extraneous ;) smilies problem. When there was an html escaped
  // char before a closing bracket - like >), "), ... - this would be encoded
  // to &xxx;), hence all the extra smilies. I created a new :wink: label, removed
  // the ;) one, and replace all genuine ;) by :wink: before escaping the body.
  // (What took us so long? :blush:)- wyz

    $s = str_replace(";)", ":wink:", $s);
    $s = str_replace("<3", ":love:", $s);

    if ($strip_html)
        $s = htmlspecialchars($s);

    if ($xssclean)
    $s = xss_clean($s);
    
    //[*]
    $s = preg_replace("/\[\*\]/", "<img src=\"".$GLOBALS['
pic_base_url']."/list.gif\" class=\"listitem\" />", $s);

    // [b]Bold[/b]
    $s = preg_replace("/\[b\]((\s|.)+?)\[\/b\]/", "<b>\\1</b>", $s);

    // [i]Italic[/i]
    $s = preg_replace("/\[i\]((\s|.)+?)\[\/i\]/", "<i>\\1</i>", $s);

    // [u]Underline[/u]
    $s = preg_replace("/\[u\]((\s|.)+?)\[\/u\]/", "<u>\\1</u>", $s);



    $s = str_replace("<p>", "", $s);
    
    $s = str_replace("</p>", "", $s);
    

//---------------------------------
//---- Image Resizer v0.1 by xam
//---------------------------------

    // [img]http://www/image.gif[/img]
    $s = preg_replace("/\[img\](http:\/\/[^\s'
\"<>]+(\.(jpg|gif|png)))\[\/img\]/i",
        
"<a href=\"\\1\" rel=\"lightbox\"><img border=\"0\" src=\"\\1\" alt=\"\" onload=\"NcodeImageResizer.createOn(this);\"></a>"$s);

    
// [img=http://www/image.gif]
    
$s preg_replace("/\[img=(http:\/\/[^\s'\"<>]+(\.(gif|jpg|png)))\]/i",
        
"<a href=\"\\1\" rel=\"lightbox\"><img border=\"0\" src=\"\\1\" alt=\"\"  onload=\"NcodeImageResizer.createOn(this);\"></a>"$s);

//---------------------------------
//---- Image Resizer v0.1 by xam
//---------------------------------

    // [color=blue]Text[/color]
    
$s preg_replace(
        
"/\[color=([a-zA-Z]+)\]((\s|.)+?)\[\/color\]/i",
        
"<font color=\\1>\\2</font>"$s);

    
// [color=#ffcc99]Text[/color]
    
$s preg_replace(
        
"/\[color=(#[a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9])\]((\s|.)+?)\[\/color\]/i",
        
"<font color=\\1>\\2</font>"$s);

    
// [url=http://www.example.com]Text[/url]
    
$s preg_replace(
        
"/\[url=([^()<>\s]+?)\]((\s|.)+?)\[\/url\]/i",
        
"<a href="\\1">\\2</a>"$s);

    
// [url]http://www.example.com[/url]
    
$s preg_replace(
        
"/\[url\]([^()<>\s]+?)\[\/url\]/i",
        
"<a href="\\1">\\1</a>"$s);

    
$s preg_replace(
        
"/\[center\](.*)\[\/center\]/i",
        
"<center>\\1</center>"$s);

    
$s preg_replace(
        
"/\[youtube\]([^()<>\s]+?)\[\/youtube\]/i",
        
'<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/\1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/\1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="400" height="250"></embed></object>'$s);
         
 

    
// [code]php code[/code]
    
$s preg_replace(
    
"/\[code\]\s*((\s|.)+?)\s*\[\/code\]\s*/i",
    
"<br><div class="codetop">CODE</div><div class="codemain">\\1</div><br>"$s);

    
// [size=4]Text[/size]
    
$s preg_replace(
        
"/\[size=([1-7])\]((\s|.)+?)\[\/size\]/i",
        
"<font size=\\1>\\2</font>"$s);

    
// [font=Arial]Text[/font]
    
$s preg_replace(
        
"/\[font=([a-zA-Z ,]+)\]((\s|.)+?)\[\/font\]/i",
        
"<font face="\\1">\\2</font>"$s);

//  //<<<@!3!@>>>
//  $s = preg_replace(
//    "/\<<<@!4!@>>>
//  $s = preg_replace(
//    "/\<<<@!5!@>>>
//  $s = preg_replace(
//    "/\<<<@!6!@>>>
//  $s = preg_replace(
//    "/\[quote=(.+?)\]\s*((\s|.)+?)\s*\[\/quote\]\s*/i",
//    "<p class=sub><b>\\1 wrote:</b></p><table class=main border=1 cellspacing=0 cellpadding=10><tr><td style='border: 1px black dotted'>\\2</td></tr></table><br>", $s);


    // Linebreaks
    
$s nl2br($s);

    
// [pre]Preformatted[/pre]    
    
$s preg_replace("/\[pre\](.*?)\[\/pre\]/is""<pre>".htmlentities('\\1')."</pre>"$s);
    
    
// [nfo]NFO-preformatted[/nfo]
    
$s preg_replace("/\[nfo\]((\s|.)+?)\[\/nfo\]/i""\\1"$s);
        
    
// [you]
    
$s str_replace ("[you]"""$s);

    
// Maintain spacing
    
$s str_replace("  "" &nbsp;"$s);


    return 
$s;
}

//---------------------------------
//---- Search Highlight v0.1 by xam
//---------------------------------

function highlight($search,$subject,$hlstart="<b><font color=red>",$hlend="</font></b>"
) {
    
    
$srchlen=strlen($search);    // lenght of searched string
    
if ($srchlen==0) return $subject;
    
$find $subject;
    while (
$find stristr($find,$search)) {    // find $search text in $subject -case insensitiv
        
$srchtxt substr($find,0,$srchlen);    // get new search text
        
$find=substr($find,$srchlen);
        
$subject str_replace($srchtxt,"$hlstart$srchtxt$hlend",$subject);    // highlight founded case insensitive search text
    
}
    return 
$subject;
}

//---------------------------------
//---- Search Highlight v0.1 by xam
//---------------------------------

function get_user_class()
{
  global 
$CURUSER;
  return 
$CURUSER["class"];
}

function 
get_user_class_name($class)
{
  switch (
$class)
  {
    case 
UC_USER: return "Uporabnik";

    case 
UC_POWER_USER: return "Super uporabnik";

    case 
UC_VIP: return "Vip";

    case 
UC_UPLOADER: return "Nalagalec";

    case 
UC_MODERATOR: return "Moderator";

    case 
UC_ADMINISTRATOR: return "Administrator";

    case 
UC_SYSOP: return "SysOp";
    
    case 
UC_STAFFLEADER: return "Vodja osebja";
    
    case 
UC_OWNER: return "Vip";
    
  }
  return 
"";
}

function 
is_valid_user_class($class)
{
  return 
is_numeric($class) && floor($class) == $class && $class >= UC_USER && $class <= UC_OWNER;
}

//----------------------------------
//---- Security function v0.1 by xam
//----------------------------------
function int_check($value,$stdhead false$stdfood true$die true$log true) {
    global 
$CURUSER;
    
$msg "Invalid ID Attempt: Username: ".$CURUSER["username"]." - UserID: ".$CURUSER["id"]." - UserIP : ".getip();
    if ( 
is_array($value) ) {
        foreach (
$value as $valint_check ($val);
    } else {
        if (!
is_valid_id($value)) {
            if (
$stdhead) {
                if (
$log)
                    
write_log($msg);
                
stderr("ERROR","Invalid ID! For security reason, we have been logged this action.");
        }else {
                Print (
"<h2>Error</h2><table width=100% border=1 cellspacing=0 cellpadding=10><tr><td class=text>");
                Print (
"Invalid ID! For security reason, we have been logged this action.</td></tr></table>");
                if (
$log)
                    
write_log($msg);
            }            
            
            if (
$stdfood)
                
stdfoot();
            if (
$die)
                die;
        }            
        else
            return 
true;
    }
}
//----------------------------------
//---- Security function v0.1 by xam
//----------------------------------

function is_valid_id($id)
{
  return 
is_numeric($id) && ($id 0) && (floor($id) == $id);
}


  
//-------- Begins a main frame

  
function begin_main_frame()
  {
    print(
"<table class=white width=737 border=0 cellspacing=0 cellpadding=0>" .
      
"<tr><td class=embedded>\n");
  }

  
//-------- Ends a main frame

  
function end_main_frame()
  {
    print(
"</td></tr></table>\n");
  }

  function 
begin_frame($caption ""$center false$padding 10)
  {
    
$tdextra "";
    
    if (
$caption)
      print(
"<h2>$caption</h2>\n");

    if (
$center)
      
$tdextra .= " align=center";

    print(
"<table width=737 border=1 cellspacing=0 cellpadding=$padding><tr><td$tdextra>\n");

  }

  function 
attach_frame($padding 10)
  {
    print(
"</td></tr><tr><td style='border-top: 0px'>\n");
  }

  function 
end_frame()
  {
    print(
"</td></tr></table>\n");
  }

  function 
begin_table($fullwidth false$padding 5)
  {
    
$width "";
    
    if (
$fullwidth)
      
$width .= " width=100%";
    print(
"<table class=main$width border=1 cellspacing=0 cellpadding=$padding>\n");
  }

  function 
end_table()
  {
    print(
"</td></tr></table>\n");
  }

  
//-------- Inserts a smilies frame
  //         (move to globals)

  
function insert_smilies_frame()
  {
    global 
$smilies$BASEURL;

    
begin_frame("Smilies"true);

    
begin_table(false5);

    print(
"<tr><td class=colhead>Type...</td><td class=colhead>To make a...</td></tr>\n");

    while (list(
$code$url) = each($smilies))
      print(
"<tr><td>$code</td><td><img src=$BASEURL/pic/smilies/$url></td>\n");

    
end_table();

    
end_frame();
  }


function 
sql_timestamp_to_unix_timestamp($s)
{
  return 
mktime(substr($s112), substr($s142), substr($s172), substr($s52), substr($s82), substr($s04));
}

  function 
get_ratio_color($ratio)
  {
    if (
$ratio 0.1) return "#ff0000";
    if (
$ratio 0.2) return "#ee0000";
    if (
$ratio 0.3) return "#dd0000";
    if (
$ratio 0.4) return "#cc0000";
    if (
$ratio 0.5) return "#bb0000";
    if (
$ratio 0.6) return "#aa0000";
    if (
$ratio 0.7) return "#990000";
    if (
$ratio 0.8) return "#880000";
    if (
$ratio 0.9) return "#770000";
    if (
$ratio 1) return "#660000";
    return 
"#000000";
  }

  function 
get_slr_color($ratio)
  {
    if (
$ratio 0.025) return "#ff0000";
    if (
$ratio 0.05) return "#ee0000";
    if (
$ratio 0.075) return "#dd0000";
    if (
$ratio 0.1) return "#cc0000";
    if (
$ratio 0.125) return "#bb0000";
    if (
$ratio 0.15) return "#aa0000";
    if (
$ratio 0.175) return "#990000";
    if (
$ratio 0.2) return "#880000";
    if (
$ratio 0.225) return "#770000";
    if (
$ratio 0.25) return "#660000";
    if (
$ratio 0.275) return "#550000";
    if (
$ratio 0.3) return "#440000";
    if (
$ratio 0.325) return "#330000";
    if (
$ratio 0.35) return "#220000";
    if (
$ratio 0.375) return "#110000";
    return 
"#000000";
  }

function 
write_log($text)
{
  
$text sqlesc($text);
  
$added sqlesc(get_date_time());
  
mysql_query("INSERT INTO sitelog (added, txt) VALUES($added$text)") or sqlerr(__FILE____LINE__);
}

function 
get_elapsed_time($ts)
{
  
$mins floor((gmtime() - $ts) / 60);
  
$hours floor($mins 60);
  
$mins -= $hours 60;
  
$days floor($hours 24);
  
$hours -= $days 24;
  
$weeks floor($days 7);
  
$days -= $weeks 7;
  
$t "";
  if (
$weeks 0) {
  if (
$weeks == 1)
    return 
"$weeks teden";
    elseif (
$weeks == 2)
    return 
"$weeks tedna";
    elseif ((
$weeks == 3) || ($weeks == 4))
    return 
"$weeks tedne";
    elseif (
$weeks 4)
    return 
"$weeks tednov";
    }
  if (
$days 0) {
    if (
$days == 1)
    return 
"$days dan";
    elseif (
$days 1)
    return 
"$days dni";
  }
  if (
$hours 0) {
    if (
$hours == 1)
    return 
"$hours uro";
    elseif (
$hours == 2)
    return 
"$hours uri";
    elseif ((
$hours == 3) || ($hours == 4))
    return 
"$hours ure";
    elseif (
$hours 4)
    return 
"$hours ur";
    }
  if (
$mins 0)
    return 
"$mins min";
  return 
"< 1 min";
}

function 
textbbcode($form$text$content "",$message=false) {
    global 
$subject;
    
//print("<pre>" . print_r($_SERVER, true) . "</pre>");

        
?>
        <script language=javascript>
        var b_open = 0;
        var i_open = 0;
        var u_open = 0;
        var color_open = 0;
        var list_open = 0;
        var quote_open = 0;
        var html_open = 0;
        
        var myAgent = navigator.userAgent.toLowerCase();
        var myVersion = parseInt(navigator.appVersion);
        
        var is_ie = ((myAgent.indexOf("msie") != -1) && (myAgent.indexOf("opera") == -1));
        var is_nav = ((myAgent.indexOf('mozilla')!=-1) && (myAgent.indexOf('spoofer')==-1)
        && (myAgent.indexOf('compatible') == -1) && (myAgent.indexOf('opera')==-1)
        && (myAgent.indexOf('webtv') ==-1) && (myAgent.indexOf('hotjava')==-1));
        
        var is_win = ((myAgent.indexOf("win")!=-1) || (myAgent.indexOf("16bit")!=-1));
        var is_mac = (myAgent.indexOf("mac")!=-1);
        var bbtags = new Array();
        function cstat() {
        var c = stacksize(bbtags);
        if ( (c < 1) || (c == null) ) {c = 0;}
        if ( ! bbtags[0] ) {c = 0;}
        document.<?=$form?>.tagcount.value = "Close last, Open tags "+c;
        }
        function stacksize(thearray) {
        for (i = 0; i < thearray.length; i++ ) {
        if ( (thearray[i] == "") || (thearray[i] == null) || (thearray == 'undefined') ) {return i;}
        }
        return thearray.length;
        }
        function pushstack(thearray, newval) {
        arraysize = stacksize(thearray);
        thearray[arraysize] = newval;
        }
        function popstackd(thearray) {
        arraysize = stacksize(thearray);
        theval = thearray[arraysize - 1];
        return theval;
        }
        function popstack(thearray) {
        arraysize = stacksize(thearray);
        theval = thearray[arraysize - 1];
        delete thearray[arraysize - 1];
        return theval;
        }
        function closeall() {
        if (bbtags[0]) {
        while (bbtags[0]) {
        tagRemove = popstack(bbtags)
        if ( (tagRemove != 'color') ) {
        doInsert("[/"+tagRemove+"]", "", false);
        eval("document.<?=$form?>." + tagRemove + ".value = ' " + tagRemove + " '");
        eval(tagRemove + "_open = 0");
        } else {
        doInsert("[/"+tagRemove+"]", "", false);
        }
        cstat();
        return;
        }
        }
        document.<?=$form?>.tagcount.value = "Close last, Open tags 0";
        bbtags = new Array();
        document.<?=$form?>.<?=$text?>.focus();
        }
        function add_code(NewCode) {
        document.<?=$form?>.<?=$text?>.value += NewCode;
        document.<?=$form?>.<?=$text?>.focus();
        }
        function alterfont(theval, thetag) {
        if (theval == 0) return;
        if(doInsert("[" + thetag + "=" + theval + "]", "[/" + thetag + "]", true)) pushstack(bbtags, thetag);
        document.<?=$form?>.color.selectedIndex = 0;
        cstat();
        }
        function tag_url() {
        var FoundErrors = '';
        var enterURL = prompt("You must enter a URL", "http://");
        var enterTITLE = prompt("You must enter a title", "");
        if (!enterURL || enterURL=="") {FoundErrors += " " + "You must enter a URL,";}
        if (!enterTITLE) {FoundErrors += " " + "You must enter a title";}
        if (FoundErrors) {alert("Error!"+FoundErrors);return;}
        doInsert("[url="+enterURL+"]"+enterTITLE+"[/url]", "", false);
        }
        function tag_list() {
        var FoundErrors = '';
        var enterTITLE = prompt("Enter item of the list. For end of the list, press 'cancel' or leave the next field empty ", "");
        if (!enterTITLE) {FoundErrors += " " + "Enter item of the list. For end of the list, press 'cancel' or leave the next field empty";}
        if (FoundErrors) {alert("Error!"+FoundErrors);return;}
        doInsert("[*]"+enterTITLE+"", "", false);
        
        }
        function tag_image() {
        var FoundErrors = '';
        var enterURL = prompt("You must enter a full image URL", "http://");
        if (!enterURL || enterURL=="http://") {
        alert("Error!"+"You must enter a full image URL");
        return;
        }
        doInsert("[img]"+enterURL+"[/img]", "", false);
        }
        function tag_email() {
        var emailAddress = prompt("You must enter a E-mail", "");
        if (!emailAddress) {
        alert("Error!"+"You must enter a E-mail");
        return;
        }
        doInsert("[email]"+emailAddress+"[/email]", "", false);
        }
        function doInsert(ibTag, ibClsTag, isSingle)
        {
        var isClose = false;
        var obj_ta = document.<?=$form?>.<?=$text?>;
        if ( (myVersion >= 4) && is_ie && is_win) {
        if(obj_ta.isTextEdit){
        obj_ta.focus();
        var sel = document.selection;
        var rng = sel.createRange();
        rng.colapse;
        if((sel.type == "Text" || sel.type == "None") && rng != null){
        if(ibClsTag != "" && rng.text.length > 0)
        ibTag += rng.text + ibClsTag;
        else if(isSingle) isClose = true;
        rng.text = ibTag;
        }
        }
        else{
        if(isSingle) isClose = true;
        obj_ta.value += ibTag;
        }
        } else {
        if(isSingle) isClose = true;
        obj_ta.value += ibTag;
        }
        obj_ta.focus();
        // obj_ta.value = obj_ta.value.replace(/ /, " ");
        return isClose;
        }
        function em(theSmilie)
        {
        doInsert(" " + theSmilie + " ", "", false);
        }
        
        function winop()
        {
        windop = window.open("moresmiles.php?form=<?=$form?>&text=<?=$text?>","mywin","height=500,width=450,resizable=no,scrollbars=yes");
        }
        
        function simpletag(thetag)
        {
        var tagOpen = eval(thetag + "_open");
        if (tagOpen == 0) {
        if(doInsert("[" + thetag + "]", "[/" + thetag + "]", true))
        {
        eval(thetag + "_open = 1");
        eval("document.<?=$form?>." + thetag + ".value += '*'");
        pushstack(bbtags, thetag);
        cstat();
        }
        }
        else {
        lastindex = 0;
        for (i = 0; i < bbtags.length; i++ ) {
        if ( bbtags[i] == thetag ) {
        lastindex = i;
        }
        }
        
        while (bbtags[lastindex]) {
        tagRemove = popstack(bbtags);
        doInsert("[/" + tagRemove + "]", "", false)
        if ((tagRemove != 'COLOR') ){
        eval("document.<?=$form?>." + tagRemove + ".value = ' " + tagRemove + " '");
        eval(tagRemove + "_open = 0");
        }
        }
        cstat();
        }
        }
        </script>
        <?
        
print("<table width=737 cellspacing=0 cellpadding=5 border=0>\n");
        
?>
        <td align="left" colspan="2">
        <table cellspacing="1" cellpadding="2" border="0" style="width: 740px !important;">
        <tr>
            <td class="embedded" align="left">
                <input style="font-weight: bold;font-size:9px;" type=button name="b" value="B" onclick="javascript: simpletag('b')" />
                <input class="codebuttons" style="font-style: italic;font-size:10px;" type=button name="i" value="I" onclick="javascript: simpletag('i')" />
                <input class="codebuttons" style="text-decoration: underline;font-size:9px;" type=button name="u" value="U" onclick="javascript: simpletag('u')" />
                <input class="codebuttons" style="font-size:10px;" type=button name='url' value='URL' onclick='tag_url()' />
                <input class="codebuttons" style="font-size:10px;" type=button name="IMG" value="IMG" onclick="javascript: tag_image()" />
                <input type=button style="font-size:9px;" name="list" value="List" onclick="tag_list()" />
                <input class="codebuttons" style="font-size:10px;" type=button name="quote" value="Quote" onclick="javascript: simpletag('quote')" />
                <input style="width:180" style="font-size:9px;" type=button onclick='javascript:closeall();' name='tagcount' value="Close all tags" />
            </td>
        </tr>
        <tr>
            <td class="embedded" align="left">
                <select name='color' class='codebuttons' onchange="alterfont(this.options[this.selectedIndex].value, 'color')">
                    <option value='0'>-------- Color --------</option>
                    <option style="BACKGROUND-COLOR: black" value="Black">Black
                    </option>
                    <option style="BACKGROUND-COLOR: sienna" value="Sienna">
                    Sienna</option>
                    <option style="BACKGROUND-COLOR: darkolivegreen" value="DarkOliveGreen">
                    Dark Olive Green</option>
                    <option style="BACKGROUND-COLOR: darkgreen" value="DarkGreen">
                    Dark Green</option>
                    <option style="BACKGROUND-COLOR: darkslateblue" value="DarkSlateBlue">
                    Dark Slate Blue</option>
                    <option style="BACKGROUND-COLOR: navy" value="Navy">Navy
                    </option>
                    <option style="BACKGROUND-COLOR: indigo" value="Indigo">
                    Indigo</option>
                    <option style="BACKGROUND-COLOR: darkslategray" value="DarkSlateGray">
                    Dark Slate Gray</option>
                    <option style="BACKGROUND-COLOR: darkred" value="DarkRed">
                    Dark Red</option>
                    <option style="BACKGROUND-COLOR: darkorange" value="DarkOrange">
                    Dark Orange</option>
                    <option style="BACKGROUND-COLOR: olive" value="Olive">Olive
                    </option>
                    <option style="BACKGROUND-COLOR: green" value="Green">Green
                    </option>
                    <option style="BACKGROUND-COLOR: teal" value="Teal">Teal
                    </option>
                    <option style="BACKGROUND-COLOR: blue" value="Blue">Blue
                    </option>
                    <option style="BACKGROUND-COLOR: slategray" value="SlateGray">
                    Slate Gray</option>
                    <option style="BACKGROUND-COLOR: dimgray" value="DimGray">
                    Dim Gray</option>
                    <option style="BACKGROUND-COLOR: red" value="Red">Red
                    </option>
                    <option style="BACKGROUND-COLOR: sandybrown" value="SandyBrown">
                    Sandy Brown</option>
                    <option style="BACKGROUND-COLOR: yellowgreen" value="YellowGreen">
                    Yellow Green</option>
                    <option style="BACKGROUND-COLOR: seagreen" value="SeaGreen">
                    Sea Green</option>
                    <option style="BACKGROUND-COLOR: mediumturquoise" value="MediumTurquoise">
                    Medium Turquoise</option>
                    <option style="BACKGROUND-COLOR: royalblue" value="RoyalBlue">
                    Royal Blue</option>
                    <option style="BACKGROUND-COLOR: purple" value="Purple">
                    Purple</option>
                    <option style="BACKGROUND-COLOR: gray" value="Gray">Gray
                    </option>
                    <option style="BACKGROUND-COLOR: magenta" value="Magenta">
                    Magenta</option>
                    <option style="BACKGROUND-COLOR: orange" value="Orange">
                    Orange</option>
                    <option style="BACKGROUND-COLOR: yellow" value="Yellow">
                    Yellow</option>
                    <option style="BACKGROUND-COLOR: lime" value="Lime">Lime
                    </option>
                    <option style="BACKGROUND-COLOR: cyan" value="Cyan">Cyan
                    </option>
                    <option style="BACKGROUND-COLOR: deepskyblue" value="DeepSkyBlue">
                    Deep Sky Blue</option>
                    <option style="BACKGROUND-COLOR: darkorchid" value="DarkOrchid">
                    Dark Orchid</option>
                    <option style="BACKGROUND-COLOR: silver" value="Silver">
                    Silver</option>
                    <option style="BACKGROUND-COLOR: pink" value="Pink">Pink
                    </option>
                    <option style="BACKGROUND-COLOR: wheat" value="Wheat">Wheat
                    </option>
                    <option style="BACKGROUND-COLOR: lemonchiffon" value="LemonChiffon">
                    Lemon Chiffon</option>
                    <option style="BACKGROUND-COLOR: palegreen" value="PaleGreen">
                    Pale Green</option>
                    <option style="BACKGROUND-COLOR: paleturquoise" value="PaleTurquoise">
                    Pale Turquoise</option>
                    <option style="BACKGROUND-COLOR: lightblue" value="LightBlue">
                    Light Blue</option>
                    <option style="BACKGROUND-COLOR: plum" value="Plum">Plum
                    </option>
                    <option style="BACKGROUND-COLOR: white" value="White">White
                    </option>
                </select>
                <select name='font' class='codebuttons' onchange="alterfont(this.options[this.selectedIndex].value, 'font')">
                    <option value='0'>-------- Font --------</option>
                    <option value="Arial">Arial</option>
                    <option value="Arial Black">Arial Black</option>
                    <option value="Arial Narrow">Arial Narrow</option>
                    <option value="Book Antiqua">Book Antiqua</option>
                    <option value="Century Gothic">Century Gothic</option>
                    <option value="Comic Sans MS">Comic Sans MS</option>
                    <option value="Courier New">Courier New</option>
                    <option value="Fixedsys">Fixedsys</option>
                    <option value="Franklin Gothic Medium">Franklin Gothic
                    Medium</option>
                    <option value="Garamond">Garamond</option>
                    <option value="[youtube] [/youtube]">[youtube] [/youtube]</option>
                    <option value="Georgia">Georgia</option>
                    <option value="Impact">Impact</option>
                    <option value="Lucida Console">Lucida Console</option>
                    <option value="Lucida Sans Unicode">Lucida Sans Unicode
                    </option>
                    <option value="Microsoft Sans Serif">Microsoft Sans Serif
                    </option>
                    <option value="Palatino Linotype">Palatino Linotype</option>
                    <option value="System">System</option>
                    <option value="Tahoma">Tahoma</option>
                    <option value="Times New Roman">Times New Roman</option>
                    <option value="Trebuchet MS">Trebuchet MS</option>
                    <option value="Verdana">Verdana</option>
                </select>
                    <select name='size' class='codebuttons' onchange="alterfont(this.options[this.selectedIndex].value, 'size')">
                    <option value='0'>-------- 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>
        </tr>
        </table>
        </td>
        <?
        
if ($message) {
            
?>
            <TR>
        <TD align=left colspan=2><B>Subject:&nbsp;&nbsp;</B>
          <INPUT name="subject" type="text" size="102" value="<?=$subject?>"></TD>
        </TR>
        <?
        
}
        
?>
        <tr>
        <td align=left><textarea name="<?=$text?>" id="<?=$text?>" rows="" cols="" style="width: 600px; height: 300px;"><? echo $content?></textarea>
        </td>
        <td>
        <table cellSpacing="1" cellPadding="3">
        <tr>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':-)')">
        <img border=0 src=pic/smilies/smile1.gif width="18" height="18"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':smile:')">
        <img border=0 src=pic/smilies/smile2.gif width="18" height="18"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':-D')">
        <img border=0 src=pic/smilies/grin.gif width="18" height="18"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':w00t:')">
        <img border=0 src=pic/smilies/w00t.gif width="18" height="20"></a></td></tr><tr>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':-P')">
        <img border=0 src=pic/smilies/tongue.gif width="20" height="20"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(';-)')">
        <img border=0 src=pic/smilies/wink.gif width="20" height="20"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':-|')">
        <img border=0 src=pic/smilies/noexpression.gif width="18" height="18"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':-/')">
        <img border=0 src=pic/smilies/confused.gif width="18" height="18"></a></td></tr><tr>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':-(')">
        <img border=0 src=pic/smilies/sad.gif width="18" height="18"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':\'-(')">
        <img border=0 src=pic/smilies/cry.gif width="20" height="20"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':-O')">
        <img border=0 src=pic/smilies/ohmy.gif width="18" height="18"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em('|-)')">
        <img border=0 src=pic/smilies/sleeping.gif width="20" height="27"></a></td></tr><tr>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':innocent:')">
        <img border=0 src=pic/smilies/innocent.gif width="18" height="22"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':unsure:')">
        <img border=0 src=pic/smilies/unsure.gif width="20" height="20"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':closedeyes:')">
        <img border=0 src=pic/smilies/closedeyes.gif width="20" height="20"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':cool:')">
        <img border=0 src=pic/smilies/cool2.gif width="20" height="20"></a></td></tr><tr>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':thumbsdown:')">
        <img border=0 src=pic/smilies/thumbsdown.gif width="27" height="18"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':blush:')">
        <img border=0 src=pic/smilies/blush.gif width="20" height="20"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':yes:')">
        <img border=0 src=pic/smilies/yes.gif width="20" height="20"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':no:')">
        <img border=0 src=pic/smilies/no.gif width="20" height="20"></a></td></tr><tr>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':love:')">
        <img border=0 src=pic/smilies/love.gif width="19" height="19"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':?:')">
        <img border=0 src=pic/smilies/question.gif width="19" height="19"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':!:')">
        <img border=0 src=pic/smilies/excl.gif width="20" height="20"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':idea:')">
        <img border=0 src=pic/smilies/idea.gif width="19" height="19"></a></td></tr><tr>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':arrow:')">
        <img border=0 src=pic/smilies/arrow.gif width="20" height="20"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':arrow2:')">
        <img border=0 src=pic/smilies/arrow2.gif width="20" height="20"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':hmm:')">
        <img border=0 src=pic/smilies/hmm.gif width="20" height="20"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':hmmm:')">
        <img border=0 src=pic/smilies/hmmm.gif width="25" height="23"></a></td></tr><tr>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':huh:')">
        <img border=0 src=pic/smilies/huh.gif width="20" height="20"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':rolleyes:')">
        <img border=0 src=pic/smilies/rolleyes.gif width="20" height="20"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':kiss:')">
        <img border=0 src=pic/smilies/kiss.gif width="18" height="18"></a></td>
        <td class=embedded style='padding: 2px; margin: 1px'><a href="javascript: em(':shifty:')">
        <img border=0 src=pic/smilies/shifty.gif width="20" height="20"></a></td></tr>
        <td class=embedded style='padding: 2px; margin: 1px' colspan="4" align="center">
        </head>
        </table>
        <center>
        <a href="javascript:winop();">More Smiles</a>
        </td></tr></table>
        </td>
        <?
    
}
    

?>
There is functions.php

PHP Code:
<?php
# IMPORTANT: Do not edit below unless you know what you are doing!
if(!defined('IN_TRACKER'))
  die(
'Hacking attempt!');

include_once(
$rootpath 'include/config.php');
require_once(
$rootpath 'include/cleanup.php');
include(
$rootpath 'include/globalfunctions.php');
include(
$rootpath 'include/all_torrents_free.php');
include(
$rootpath "include/class_lang.php");

if (!
defined("DS"))
{
    
define("DS"DIRECTORY_SEPARATOR);
}

if (!
defined("ROOT"))
{
    
define("ROOT"dirname(dirname(__FILE__)));
}

    if (isset(
$_COOKIE["language"]))
    {
        
$lang $_COOKIE["language"];
    }
    else if (isset(
$CURUSER))
    {
        
$lang $CURUSER["language"];
    }
    else if (isset(
$_GET["lang"]))
    {
        
$lang $_GET["lang"];
    }
    else
    {
        
$lang null;
    }
    
    try
    {
        
$jezik = new jezik($lang);
    }
    catch (
Exception $e)
    {
        print(
$e->getMessage());
    }




//---------------------------------
//---- Max. Sysops v0.2 by xam
//---------------------------------

function strip_magic_quotes($arr)
{
foreach (
$arr as $k => $v)
{
 if (
is_array($v))
  { 
$arr[$k] = strip_magic_quotes($v); }
 else
  { 
$arr[$k] = stripslashes($v); }
}

return 
$arr;
}
function 
htmlspecialchars_uni($text$entities true)
{
    return 
str_replace(
        
// replace special html characters
        
array('<''>''"'),
        array(
'&lt;''&gt;''&quot;'),
        
preg_replace(
            
// translates all non-unicode entities
            
'/&(?!' . ($entities '#[0-9]+' '(#[0-9]+|[a-z]+)') . ';)/si',
            
'&',
            
$text
        
)
    );
}
function 
xss_clean(&$var)
    {
        static
            
$preg_find    = array('#javascript#i''#vbscript#i'),
            
$preg_replace = array('java script',   'vb script');

        
$var preg_replace($preg_find$preg_replacehtmlspecialchars_uni($var));
        return 
$var;
    }
function 
local_user()
{
  return 
$_SERVER["SERVER_ADDR"] == $_SERVER["REMOTE_ADDR"];
}

function 
cur_user_check () {
    global 
$CURUSER;
    if (
$CURUSER)
    
stderr ("Pozor""Ste že prijavljeni na spletni portal.");
}
function 
sql_query($query)
{
     
$_SESSION['queries']++;
      return 
mysql_query($query);
}
function 
KPS($type "+"$point "1.0"$id "") {
    global 
$bonus;
    if (
$bonus == "enable" OR $bonus == "disablesave")
        
sql_query("UPDATE users SET seedbonus = seedbonus$type$point WHERE id = ".sqlesc($id)) or sqlerr(__FILE____LINE__);        
    else
        return;
}
//---------------------------------
//---- BANNED EMAILS v0.1 by xam
//---------------------------------
function EmailBanned($newEmail)
{
    
$newEmail trim(strtolower($newEmail));
    
$sql mysql_query("SELECT * FROM bannedemails") or sqlerr(__FILE____LINE__);
    
$list mysql_fetch_array($sql);
    
$addresses explode(' 'preg_replace("/[[:space:]]+/"" "trim($list[value])) );

    if(
count($addresses) > 0)
    {
        foreach ( 
$addresses as $email )
        {
            
$email trim(strtolower(ereg_replace('\.''\\.'$email)));
            if(
strstr($email"@"))
            {
                if(
ereg('^@'$email))
                {        
// Any user @host?
                    // Expand the match expression to catch hosts and
                    // sub-domains
                    
$email ereg_replace('^@''[@\\.]'$email);
                    if(
ereg("$email$"$newEmail))
                    return 
true;
                }
            }
            elseif(
ereg('@$'$email))
            {    
// User at any host?
                
if(ereg("^$email"$newEmail))
                return 
true;
            }
            else
            {                
// User@host
                
if(strtolower($email) == $newEmail)
                return 
true;
            }
        }
    }

    return 
false;
}
//---------------------------------
//---- BANNED EMAILS v0.1 by xam
//---------------------------------

//---------------------------------
//---- Redirect MOD v0.1 by xam
//---------------------------------
function redirect($url)
{
    if(!
headers_sent())
         
header("Location : $url");
    else
        echo 
"<script language=\"JavaScript\">window.location.href = '$url';</script>";
    exit;

//---------------------------------
//---- Redirect MOD v0.1 by xam
//---------------------------------

//---------------------------------
//---- CACHE MOD v0.1 by xam
//---------------------------------
function cache_check ($file 'cachefile') {
    global 
$rootpath,$cache;    
    
$cachefile $rootpath.$cache '/'.$file.'.html'
    
$cachetime 60 60// 60 minutes
     // Serve from the cache if it is younger than $cachetime
     
if (file_exists($cachefile) && (time() - $cachetime filemtime($cachefile))) 
         {
            include(
$cachefile);
            print(
"<p align=center><font class=small>Stran je bila nazadnje posodobljena ".date('d.m.Y H:i:s'filemtime($cachefile))."</font></p>");
            
end_main_frame();
            
stdfoot();    
            exit;
         }
     
ob_start();
}
  
function 
cache_save  ($file 'cachefile') {
    global 
$rootpath,$cache;    
    
$cachefile $rootpath.$cache '/'.$file.'.html'
    
$fp fopen($cachefile'w'); 
      
// save the contents of output buffer to the file     
      
fwrite($fpob_get_contents());
      
// close the file
       
fclose($fp); 
       
// Send the output to the browser
       
ob_end_flush(); 
}
//---------------------------------
//---- CACHE MOD v0.1 by xam
//---------------------------------

//---------------------------------
//---- Browser detection v0.1 by xam
//---------------------------------
function checkbrowser(){
    unset(
$browser);
    
    if ( 
strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') )
    {
        if ( 
strpos($_SERVER['HTTP_USER_AGENT'], 'Netscape') )
            {
                
$browser true;
            }
        else if ( 
strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') )
            {
                
$browser true;    
            }
        else
            {
                
$browser true;
            }
    }else    
$browser false;
    if (!
$browser)
        Print (
"<p class=codemain align=justify>Če ste omogočili piškotke (cookies) in se še vedno ne morete prijaviti je vrjetno problem v vašem prijavnem piškotku (cookie). Predlagamo da zbrišete piškotke in poskusite znova.Da pobrišete piškotke v Internet Explorerju ali drugemu brsklaniku pojdite po orodja in nato internetne opcije in kliknete na izbris piškotka. Pozor: To bo izbrisalo tudi ostale piškotke ki jih uporabljate za dostop do drugih internetnih strani.</b></p>");
}
//---------------------------------
//---- Browser detection v0.1 by xam
//---------------------------------

//------------------------------------
//---- Secure Mail System v0.4 by xam
//------------------------------------
function safe_email($email) {     
    
$email str_replace("<","",$email); 
    
$email str_replace(">","",$email); 
    
$email str_replace("\'","",$email); 
    
$email str_replace('\"',"",$email); 
    
$email str_replace("\\\\","",$email); 
    return 
$email
}

function 
check_email ($email) {
    
# Check EMail Function v.02 by xam!
    
if(@ereg("^([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$"$email)) 
        return 
true;
    else
        return 
false;
}

function 
sent_mail($to,$fromname,$fromemail,$subject,$body,$type "confirmation",$showmsg=true,$multiple=false,$multiplemail='') {
    global 
$rootpath,$SITENAME,$SITEEMAIL,$smtptype,$smtp,$smtp_host,$smtp_port,$smtp_from,$smtpaddress,$smtpport,$accountname,$accountpassword;
    
# Sent Mail Function v.05 by xam (This function to help avoid spam-filters.)
    
if ($smtptype == 'default') {
        @
mail($to$subject$body"From: $SITEEMAIL""-f$SITEEMAIL") or stderr("Napaka""Emaila ni bilo mogoče poslati. Prosimo Vas, da o tej napaki obvestite administratorja.");    
    }elseif (
$smtptype == 'advanced') {
    
# Is the OS Windows or Mac or Linux?
    
if (strtoupper(substr(PHP_OS,0,3)=='WIN')) {
        
$eol="\r\n";
        
$windows true;
    }
    elseif (
strtoupper(substr(PHP_OS,0,3)=='MAC'))
        
$eol="\r";
    else
        
$eol="\n"
    
$mid md5(getip() . $fromname);
    
$name $_SERVER["SERVER_NAME"];
    
$headers .= "From: $fromname <$fromemail>".$eol;    
    
$headers .= "Reply-To: $fromname <$fromemail>".$eol;
    
$headers .= "Return-Path: $fromname <$fromemail>".$eol;
    
$headers .= "Message-ID: <$mid thesystem@$name>".$eol;
    
$headers .= "X-Mailer: PHP v".phpversion().$eol
    
$headers .= "MIME-Version: 1.0".$eol
    
$headers .= "X-Sender: PHP".$eol;        
    if (
$multiple)
        
$headers .= "Bcc: $multiplemail.$eol";
    if (
$smtp == "yes") {        
        
ini_set('SMTP'$smtp_host);
        
ini_set('smtp_port'$smtp_port);
        if (
$windows)
            
ini_set('sendmail_from'$smtp_from);
        }
            
        @
mail($to,$subject,$body,$headers) or stderr("Napaka""Emaila ni bilo mogoče poslati. Prosimo Vas, da o tej napaki obvestite administratorja.");    
        
        
ini_restore(SMTP); 
        
ini_restore(smtp_port); 
        if (
$windows)
            
ini_restore(sendmail_from); 
    }elseif (
$smtptype == 'external') {
        require (
$rootpath 'include/smtp/smtp.lib.php');
        
$mail = new smtp;        
        
$mail->debug(false);
        
$mail->open($smtpaddress$smtpport);
        
$mail->auth($accountname$accountpassword);
        
$mail->from($SITEEMAIL);
        
$mail->to($to);
        
$mail->subject($subject);
        
$mail->body($body);
        
$mail->send();
        
$mail->close();        
    }        
    if (
$showmsg) {
        if (
$type == "confirmation")
            
stderr("Uspešno""Potrditveni email je bil poslan na naslov: <b>"htmlspecialchars($to) ."</b>.\n" .
        
"Počakajte nekaj minut, da email prispe.",false);
        else if (
$type == "details")
            
stderr("Uspešno""Novi podatki za prijavo na spletni portal so bili posredovani na: <b>"htmlspecialchars($to) ."</b>.\n" .
        
"Počakajte nekaj minut, da email prispe.",false);
    }else
        return 
true;    
}
//------------------------------------
//---- Secure Mail System v0.4 by xam
//------------------------------------

//---------------------------------
//---- Login Attempts v0.1 by xam
//---------------------------------
function failedloginscheck ($type 'Login') {
    global 
$maxloginattempts;    
    
$total 0;
    
$ip sqlesc(getip());
    
$Query mysql_query("SELECT SUM(attempts) FROM loginattempts WHERE ip=$ip") or sqlerr(__FILE____LINE__);
    list(
$total) = mysql_fetch_array($Query);
    if (
$total >= $maxloginattempts) {
            
mysql_query("UPDATE loginattempts SET banned = 'yes' WHERE ip=$ip") or sqlerr(__FILE____LINE__);            
            
stderr("$type Locked! (the maximum number of failed $type attempts is reached during reauthentication)""We come to believe you are trying to cheat our system, therefore we've banned your ip!");                
        }
}
function 
failedlogins ($type 'login'$recover false$head true) {    
    
$ip sqlesc(getip());
    
$added sqlesc(get_date_time());
    
$a = (@mysql_fetch_row(@mysql_query("select count(*) from loginattempts where ip=$ip"))) or sqlerr(__FILE____LINE__);
    if (
$a[0] == 0)
        
mysql_query("INSERT INTO loginattempts (ip, added, attempts) VALUES ($ip$added, 1)") or sqlerr(__FILE____LINE__);
    else
        
mysql_query("UPDATE loginattempts SET attempts = attempts + 1 where ip=$ip") or sqlerr(__FILE____LINE__);        
    if (
$recover)
            
mysql_query("UPDATE loginattempts SET type = 'recover' WHERE ip = $ip") or sqlerr(__FILE____LINE__);
    if (
$type == 'silent')
        return;                
    elseif (
$type == 'login')    
        
stderr("Prijava neuspešna","<b>Napaka</b>: Uporabniško ime ali geslo je napačno.<br><br>Ste pozabili vaše geslo?<b><a href=recover.php>Obnovite</a></b> vaše geslo.",false);    
    else
        
stderr("Obnovitev ni usepla!",$type,false$head);
    
}

function 
remaining ($type 'login') {
    global 
$maxloginattempts;    
    
$total 0;
    
$ip sqlesc(getip());
    
$Query mysql_query("SELECT SUM(attempts) FROM loginattempts WHERE ip=$ip") or sqlerr(__FILE____LINE__);
    list(
$total) = mysql_fetch_array($Query);
    
$remaining $maxloginattempts $total;
    if (
$remaining <= )
        
$remaining "<font color=red size=2>[".$remaining."]</font>";
    else 
        
$remaining "<font color=green size=2>[".$remaining."]</font>";
        
    return 
$remaining;
}
//---------------------------------
//---- Login Attempts v0.1 by xam
//---------------------------------


//---------------------------------
//---- Signup Check v0.1 by xam
//---------------------------------
function registration_check($type "invitesystem"$maxuserscheck true$ipcheck true) {
    global 
$invitesystem$registration$maxusers$SITENAME$maxip;
    if (
$type == "invitesystem") {
        if (
$invitesystem == "off") {
            
stderr("Pozor""Sistem za povabila je trenutno onemogočen!");
            }
        }
    
    if (
$type == "normal") {
        if (
$registration == "off") {
            
stderr("Pozor""Registracije na spletni portal so trenutno onemogočene.");
            }
        }
    
    if (
$maxuserscheck) {    
    
$res mysql_query("SELECT COUNT(*) FROM users") or sqlerr(__FILE____LINE__);
    
$arr mysql_fetch_row($res);
    if (
$arr[0] >= $maxusers)
        
stderr("Pozor""Limit registriranih uporabnikov je bil dosežen! Neaktivni uporabniki se brišejo, zato nas obiščite naslednjič in morda imate srečo ter se registrirate.");
    }
    
    if (
$ipcheck) {
        
$ip getip () ;
        
$a = (@mysql_fetch_row(@mysql_query("select count(*) from users where ip='" mysql_real_escape_string($ip) . "'"))) or sqlerr(__FILE____LINE__);
        if (
$a[0] > $maxip)
            
stderr("Pozor""Ta IP <b>" htmlspecialchars($ip) . "</b> je že uporabljen in registriran na naš spletni portal! Podvojeni uporabniški računi niso dovoljeni na <b>$SITENAME</b>.",false);
    }

}
//---------------------------------
//---- Signup Check v0.1 by xam
//---------------------------------

//-----------------------------------
//---- Image Verification v0.1 by xam
//-----------------------------------
function random_str($length="6")
{
    
$set = array("A","B","C","D","E","F","G","H","P","R","M","N","1","2","3","4","5","6","7","8","9");
    
$str;
    for(
$i=1;$i<=$length;$i++)
    {
        
$ch rand(0count($set)-1);
        
$str .= $set[$ch];
    }
    return 
$str;
}
function 
image_code () {
            
$randomstr random_str();
            
$imagehash md5($randomstr);
            
$dateline time();        
            
$sql 'INSERT INTO `regimages` (`imagehash`, `imagestring`, `dateline`) VALUES (\''.$imagehash.'\', \''.$randomstr.'\', \''.$dateline.'\');';
            
mysql_query($sql) or die(mysql_error());
            return 
$imagehash;
}

function 
check_code ($imagehash$imagestring$where 'signup.php',$maxattemptlog=false,$head=true) {
    
$query sprintf("SELECT * FROM regimages WHERE imagehash='%s' AND imagestring='%s'",
   
mysql_real_escape_string($imagehash),
   
mysql_real_escape_string($imagestring));
    
$sql mysql_query($query);
    
$imgcheck mysql_fetch_array($sql);
    if(!
$imgcheck['dateline']) {
        
$delete sprintf("DELETE FROM regimages WHERE imagehash='%s'",
        
mysql_real_escape_string($imagehash));    
        
mysql_query($delete);
        if (!
$maxattemptlog)
            
bark("Invalid Image Code! <br><b>Do not go back, The image code has been cleared!</b> <br><br>Please click <a href=".htmlspecialchars($where)."><b>here</b></a> to request a new image code.");
        else
            
failedlogins("Invalid Image Code! <br><b>Do not go back, The image code has been cleared!</b> <br><br>Please click <a href=".htmlspecialchars($where)."><b>here</b></a> to request a new image code.",true,$head);
    }else{
        
$delete sprintf("DELETE FROM regimages WHERE imagehash='%s'",
        
mysql_real_escape_string($imagehash));
        
mysql_query($delete);
        return 
true;
    }
}
function 
show_image_code () {
    global 
$iv;
    unset(
$imagehash);    
    
$imagehash image_code () ;
    if (
$iv == "yes") {
        print (
"<tr><td class=\"rowhead\">Security Image:</td>");
        Print (
"<td><img src=\"image.php?action=regimage&imagehash=$imagehash\" border=\"0\"></a></td></tr>");
        Print (
"<tr><td class=\"rowhead\">Security Code:</td><td>");
        Print(
"<input type=\"text\" size=\"26\" name=\"imagestring\" value=\"\" />");
        Print(
"<input type=\"hidden\" name=\"imagehash\" value=\"$imagehash\" />");
    }
}
//-----------------------------------
//---- Image Verification v0.1 by xam
//-----------------------------------

// IP Validation
function validip($ip)
{
    if (!empty(
$ip) && $ip == long2ip(ip2long($ip)))
    {
        
// reserved IANA IPv4 addresses
        // http://www.iana.org/assignments/ipv4-address-space
        
$reserved_ips = array (
                array(
'0.0.0.0','2.255.255.255'),
                array(
'10.0.0.0','10.255.255.255'),
                array(
'127.0.0.0','127.255.255.255'),
                array(
'169.254.0.0','169.254.255.255'),
                array(
'172.16.0.0','172.31.255.255'),
                array(
'192.0.2.0','192.0.2.255'),
                array(
'192.168.0.0','192.168.255.255'),
                array(
'255.255.255.0','255.255.255.255')
        );

        foreach (
$reserved_ips as $r)
        {
                
$min ip2long($r[0]);
                
$max ip2long($r[1]);
                if ((
ip2long($ip) >= $min) && (ip2long($ip) <= $max)) return false;
        }
        return 
true;
    }
    else return 
false;
}
function 
maxslots () {
    global 
$CURUSER$maxdlsystem;
    
$gigs $CURUSER["uploaded"] / (1024*1024*1024);
    
$ratio = (($CURUSER["downloaded"] > 0) ? ($CURUSER["uploaded"] / $CURUSER["downloaded"]) : 1);
    if (
$ratio 0.5 || $gigs 5$max 1;
        elseif (
$ratio 0.65 || $gigs 6.5$max 2;
            elseif (
$ratio 0.8 || $gigs 8$max 3;
                elseif (
$ratio 0.95 || $gigs 9.5$max 4;
                    else 
$max 0;
       if (
$maxdlsystem == "yes") {
           if (
$CURUSER["class"] < UC_VIP) {
        if (
$max 0)
            print (
"<font color=#1900D1>Slots: </font><font color=black><span class=smallfont>$max</span></font>");
        else
            print (
"<font color=#1900D1>Slots: </font><font color=black><span class=smallfont>Unlimited</span></font>");
        }else
            print (
"<font color=#1900D1>Slots: </font><font color=black><span class=smallfont>Unlimited</span></font>");
       }else
               print (
"<font color=#1900D1>Slots: </font><font color=black><span class=smallfont>Unlimited</span></font>");
}

function 
getip() {
   if (isset(
$_SERVER)) {
     if (isset(
$_SERVER['HTTP_X_FORWARDED_FOR']) && validip($_SERVER['HTTP_X_FORWARDED_FOR'])) {
       
$ip $_SERVER['HTTP_X_FORWARDED_FOR'];
     } elseif (isset(
$_SERVER['HTTP_CLIENT_IP']) && validip($_SERVER['HTTP_CLIENT_IP'])) {
       
$ip $_SERVER['HTTP_CLIENT_IP'];
     } else {
       
$ip $_SERVER['REMOTE_ADDR'];
     }
   } else {
     if (
getenv('HTTP_X_FORWARDED_FOR') && validip(getenv('HTTP_X_FORWARDED_FOR'))) {
       
$ip getenv('HTTP_X_FORWARDED_FOR');
     } elseif (
getenv('HTTP_CLIENT_IP') && validip(getenv('HTTP_CLIENT_IP'))) {
       
$ip getenv('HTTP_CLIENT_IP');
     } else {
       
$ip getenv('REMOTE_ADDR');
     }
   }

   return 
$ip;
 }
function 
dbconn($autoclean false)
{
    global 
$mysql_host$mysql_user$mysql_pass$mysql_db;

    if (!@
mysql_connect($mysql_host$mysql_user$mysql_pass))
    {
      switch (
mysql_errno())
      {
        case 
1040:
        case 
2002:
            if (
$_SERVER[REQUEST_METHOD] == "GET")
                die(
"<html><head><meta http-equiv=refresh content=\"5 $_SERVER[REQUEST_URI]\"></head><body><table border=0 width=100% height=100%><tr><td><h3 align=center>Pravkar poteka konfiguriranje strežnika zato je zelo obremenjen. V nedoločenem kratkem času bo vse ponovno delovalo normalno ! Prosimo za razumevanje in potrplenje!</h3></td></tr></table></body></html>");
            else
                die(
"Strežnik je preobremenjen. Prosimo Vas, počakajte, da naši tehniki zatevo uredijo.");
        default:
            die(
"[" mysql_errno() . "] dbconn: mysql_connect: " mysql_error());
      }
    }
    
mysql_select_db($mysql_db)
        or die(
'dbconn: mysql_select_db: ' mysql_error());

    
userlogin();
    
    
update_sledilniki_torrent(); //nastavi visible na on če je torrent z več sledilniki, tudi če torrent nima sejalca!
    
    
if ($autoclean)
        
register_shutdown_function("autoclean");
}

function 
userlogin() {
    global 
$SITE_ONLINE$iplog1;
    unset(
$GLOBALS["CURUSER"]);

    
$ip getip();
    
$nip ip2long($ip);
    
    
$res mysql_query("SELECT * FROM bans WHERE '$nip' >= first AND '$nip' <= last") or sqlerr(__FILE____LINE__);
    if (
mysql_num_rows($res) > 0)
    {
      
header("HTTP/1.0 403 Forbidden");
      print(
"<html><body><h1>403 Forbidden</h1>Unauthorized IP address.</body></html>\n");
      die;
    }
    
    if (empty(
$_COOKIE["c_secure_pass"]) || empty($_COOKIE["c_secure_uid"]) || empty($_COOKIE["c_secure_login"]))
        return;
    if (
$_COOKIE["c_secure_login"] == base64("yeah"))
        if (empty(
$_SESSION["s_secure_uid"]) || empty($_SESSION["s_secure_pass"]))
            return;
    
$b_id base64($_COOKIE["c_secure_uid"],false);
    
$id $b_id;
    if (!
$id || !is_valid_id($id) || strlen($_COOKIE["c_secure_pass"]) != 32)
        return;
        
    if (
$_COOKIE["c_secure_login"] == base64("yeah"))
        if (
strlen($_SESSION["s_secure_pass"]) != 32)
            return;
    
    
$res mysql_query("SELECT users.*, NOW() as ctime FROM users WHERE id = ".mysql_real_escape_string($id)." AND enabled='yes' AND status = 'confirmed' LIMIT 1");
    
$row mysql_fetch_array($res);
    if (!
$row)
        return;
        
    
$sec hash_pad($row["secret"]);
    
    if (
$_COOKIE["c_secure_pass"] !== md5($row["passhash"].$_SERVER["REMOTE_ADDR"]))
        return;
    
    if (
$_COOKIE["c_secure_login"] == base64("yeah"))
        if (
$_SESSION["s_secure_pass"] !== md5($row["passhash"].$_SERVER["REMOTE_ADDR"]))
            return;
            
    if (!
$row["passkey"]){
        
$passkey md5($row['username'].get_date_time().$row['passhash']);
        
mysql_query("UPDATE users SET passkey = ".sqlesc($passkey)." WHERE id=" mysql_real_escape_string($row["id"]));// or die(mysql_error());
    
}
    if (
$iplog1 == "yes") {
        if ((
$ip != $row["ip"]) && $row["ip"])
            
mysql_query("INSERT INTO iplog (ip, userid, access) VALUES (" sqlesc($row["ip"]) . ", " $row["id"] . ", '" $row["last_access"] . "')");
    }
    
    
mysql_query("UPDATE users SET last_access='" get_date_time() . "', ip=".sqlesc($ip)." WHERE id=" mysql_real_escape_string($row["id"]));// or die(mysql_error());
    
$row['ip'] = $ip;
    if (empty(
$row["avatar"]))
    {
        
$row["avatar"] = "design/avatar.png";
    }
    
$GLOBALS["CURUSER"] = $row;
}

function 
autoclean() {
    global 
$autoclean_interval;

    
$now time();
    
$docleanup 0;

    
$res mysql_query("SELECT value_u FROM avps WHERE arg = 'lastcleantime'");
    
$row mysql_fetch_array($res);
    if (!
$row) {
        
mysql_query("INSERT INTO avps (arg, value_u) VALUES ('lastcleantime',$now)");
        return;
    }
    
$ts $row[0];
    if (
$ts $autoclean_interval $now)
        return;
    
mysql_query("UPDATE avps SET value_u=$now WHERE arg='lastcleantime' AND value_u = $ts");
    if (!
mysql_affected_rows())
        return;

    
docleanup();
}
function 
unesc($x) {
    if (
get_magic_quotes_gpc())
        return 
stripslashes($x);
    return 
$x;
}

function 
mksize($bytes)
{
    if (
$bytes 1000 1024)
        return 
number_format($bytes 10242) . " KB";
    elseif (
$bytes 1000 1048576)
        return 
number_format($bytes 10485762) . " MB";
    elseif (
$bytes 1000 1073741824)
        return 
number_format($bytes 10737418242) . " GB";
    else
        return 
number_format($bytes 10995116277762) . " TB";
}

function 
mksizeint($bytes)
{
    
$bytes max(0$bytes);
    if (
$bytes 1000)
        return 
floor($bytes) . " B";
    elseif (
$bytes 1000 1024)
        return 
floor($bytes 1024) . " kB";
    elseif (
$bytes 1000 1048576)
        return 
floor($bytes 1048576) . " MB";
    elseif (
$bytes 1000 1073741824)
        return 
floor($bytes 1073741824) . " GB";
    else
        return 
floor($bytes 1099511627776) . " TB";
}

function 
deadtime() {
    global 
$announce_interval;
    return 
time() - floor($announce_interval 1.3);
}

function 
mkprettytime($s) {
    if (
$s 0)
        
$s 0;
    
$t = array();
    foreach (array(
"60:sec","60:min","24:hour","0:day") as $x) {
        
$y explode(":"$x);
        if (
$y[0] > 1) {
            
$v $s $y[0];
            
$s floor($s $y[0]);
        }
        else
            
$v $s;
        
$t[$y[1]] = $v;
    }

    if (
$t["day"])
        return 
$t["day"] . "d " sprintf("%02d:%02d:%02d"$t["hour"], $t["min"], $t["sec"]);
    if (
$t["hour"])
        return 
sprintf("%d:%02d:%02d"$t["hour"], $t["min"], $t["sec"]);
//    if ($t["min"])
        
return sprintf("%d:%02d"$t["min"], $t["sec"]);
//    return $t["sec"] . " secs";
}

function 
mkglobal($vars) {
    if (!
is_array($vars))
        
$vars explode(":"$vars);
    foreach (
$vars as $v) {
        if (isset(
$_GET[$v]))
            
$GLOBALS[$v] = unesc($_GET[$v]);
        elseif (isset(
$_POST[$v]))
            
$GLOBALS[$v] = unesc($_POST[$v]);
        else
            return 
0;
    }
    return 
1;
}

function 
tr($x$y$noesc 0$relation '') {
    if (
$noesc)
        
$a $y;
    else {
        
$a htmlspecialchars($y);
        
$a str_replace("\n""<br />\n"$a);
    }
    print(
"<tr".( $relation " relation = \"$relation\"" "")."><td valign=\"top\" align=\"left\">$x</td><td valign=\"top\" align=left>$a</td></tr>\n");
}

function 
validfilename($name) {
    return 
preg_match('/^[^\0-\x1f:\\\\\/?*\xff#<>|]+$/si'$name);
}

function 
validemail($email) {
    return 
preg_match('/^[\w.-]+@([\w.-]+\.)+[a-z]{2,6}$/is'$email);
}

function 
sqlesc($value) {
    
// Stripslashes
   
if (get_magic_quotes_gpc()) {
       
$value stripslashes($value);
   }
   
// Quote if not a number or a numeric string
   
if (!is_numeric($value)) {
       
$value "'" mysql_real_escape_string($value) . "'";
   }
   return 
$value;
}

function 
sqlwildcardesc($x) {
    return 
str_replace(array("%","_"), array("\\%","\\_"), mysql_real_escape_string($x));
}

function 
urlparse($m) {
    
$t $m[0];
    if (
preg_match(',^\w+://,'$t))
        return 
"<a href=\"$t\">$t</a>";
    return 
"<a href=\"http://$t\">$t</a>";
}

function 
parsedescr($d$html) {
    if (!
$html)
    {
      
$d htmlspecialchars($d);
      
$d str_replace("\n""\n<br>"$d);
    }
    return 
$d;
}

//-----------------------------------
//---- Where's User v0.1 by xam
//-----------------------------------
function where ($scriptname "index"$userid) {
    global 
$where;
    if (
$where == "yes") {
        if (!
is_valid_id($userid))
            die;
        if (
preg_match("/details/i"$scriptname))
            
$where "Browsing Torrents Details...";
        elseif (
preg_match("/browse/i"$scriptname))
            
$where "Browsing Torrent Lists...";
        elseif (
preg_match("/userdetails/i"$scriptname))
            
$where "Browsing Userdetails...";
        elseif (
preg_match("/upload/i"$scriptname))
            
$where "Uploading Torrent..";
        elseif (
preg_match("/usercp/i"$scriptname))
            
$where "Browsing User Control Panel...";
        elseif (
preg_match("/search/i"$scriptname))
            
$where "Searching...";
        elseif (
preg_match("/forum/i"$scriptname))
            
$where "Browsing Forums...";
        elseif (
preg_match("/index/i"$scriptname))
            
$where "Browsing Homepage...";
        else
            
$where "Unknown Location...";
        
$query sprintf("UPDATE users SET page=".sqlesc($where)." WHERE id ='%s'",
        
mysql_real_escape_string($userid));
        
$result mysql_query($query);
        if (!
$result)
            
sqlerr(__FILE__,__LINE__);
        else
            return 
$where;
    }
    return;
}
//-----------------------------------
//---- Where's User v0.1 by xam
//-----------------------------------

//-----------------------------------
//---- Menu System v0.1 by xam
//-----------------------------------
function menu ($selected "home") {
    global 
$BASEURL;
    
$script_name $_SERVER["SCRIPT_FILENAME"];
    if (
preg_match("/index/i"$script_name)) {
        
$selected "home";
    }elseif (
preg_match("/browse/i"$script_name)) {
        
$selected "browse";
    }elseif (
preg_match("/viewrequests/i"$script_name) OR preg_match("/viewoffers/i"$script_name) OR preg_match("/offcomment/i"$script_name) OR preg_match("/reqcomment/i"$script_name)) {
        
$selected "requests";
    }elseif (
preg_match("/upload/i"$script_name)) {
        
$selected "upload";
    }elseif (
preg_match("/usercp/i"$script_name)) {
        
$selected "usercp";
    }elseif (
preg_match("/forums/i"$script_name)) {
        
$selected "forums";
    }elseif (
preg_match("/topten/i"$script_name)) {
        
$selected "topten";
    }elseif (
preg_match("/rules/i"$script_name)) {
        
$selected "rules";
    }elseif (
preg_match("/faq/i"$script_name)) {
        
$selected "faq";
    }elseif (
preg_match("/links/i"$script_name)) {
        
$selected "links";
    }elseif (
preg_match("/staff/i"$script_name)) {
        
$selected "staff";
    }else
        
$selected "";
    print (
"<div class=\"shadetabs\"><ul>");
    print (
"<li" . ($selected == "home" " class=selected" "") . "><a href=\"index.php\" onMouseout=\"window.status=''; return true;\" onMouseOver=\"window.status='User CP Home'; return true;\">Home</a></li>");
    print (
"<li" . ($selected == "browse" " class=selected" "") . "><a href=\"browse.php\" onMouseout=\"window.status=''; return true;\" onMouseOver=\"window.status='Browse Torrents'; return true;\">Browse</a></li>");
    print (
"<li" . ($selected == "requests" " class=selected" "") . "><a href=\"viewrequests.php\" onMouseout=\"window.status=''; return true;\" onMouseOver=\"window.status='Search Torrents'; return true;\">Requests</a></li>");
    print (
"<li" . ($selected == "upload" " class=selected" "") . "><a href=\"upload.php\" onMouseout=\"window.status=''; return true;\" onMouseOver=\"window.status='Upload Torrents'; return true;\">Upload</a></li>");
    print (
"<li" . ($selected == "usercp" " class=selected" "") . "><a href=\"usercp.php\" onMouseout=\"window.status=''; return true;\" onMouseOver=\"window.status='User CP'; return true;\">User CP</a></li>");
    print (
"<li" . ($selected == "forums" " class=selected" "") . "><a href=\"forums.php\" onMouseout=\"window.status=''; return true;\" onMouseOver=\"window.status='Forums'; return true;\">Forums</a></li>");
    print (
"<li" . ($selected == "topten" " class=selected" "") . "><a href=\"topten.php\" onMouseout=\"window.status=''; return true;\" onMouseOver=\"window.status='TOP 10'; return true;\">Top 10</a></li>");
    print (
"<li" . ($selected == "rules" " class=selected" "") . "><a href=\"rules.php\" onMouseout=\"window.status=''; return true;\" onMouseOver=\"window.status='rules'; return true;\">Rules</a></li>");
    print (
"<li" . ($selected == "faq" " class=selected" "") . "><a href=\"faq.php\" onMouseout=\"window.status=''; return true;\" onMouseOver=\"window.status='FAQ'; return true;\">FAQ</a></li>");
    print (
"<li" . ($selected == "links" " class=selected" "") . "><a href=\"links.php\" onMouseout=\"window.status=''; return true;\" onMouseOver=\"window.status='Links'; return true;\">Links</a></li>");
    print (
"<li" . ($selected == "staff" " class=selected" "") . "><a href=\"staff.php\" onMouseout=\"window.status=''; return true;\" onMouseOver=\"window.status='Staff'; return true;\">Staff</a></li>");
}
//-----------------------------------
//---- Menu System v0.1 by xam
//-----------------------------------

function stdhead($title ""$msgalert true$script "") {
    global 
$CURUSER$SITE_ONLINE$FUNDS$SITENAME,$SITEEMAIL,$BASEURL,$offlinemsg,$disablerightclick,$showversion,$autorefreshtime,$autorefresh,$leftmenu,$jezik;

  if (
$SITE_ONLINE == "no") {  
      if (
get_user_class() < UC_ADMINISTRATOR) {
            die(
"Site is down for maintenance, please check back again later... thanks<br>");
        }else{
            
$offlinemsg true;
        }
    }

    
header("Content-Type: text/html; charset=windows-1250");
    
//header("Pragma: No-cache");
    
if ($title == "")
        
$title $SITENAME.$showversion;
    else
        
$title "$SITENAME :: " htmlspecialchars($title) . "$showversion";
  if (
$CURUSER)
  {
    
$ss_a = @mysql_fetch_array(@mysql_query("select uri from stylesheets where id=" $CURUSER["stylesheet"]));
    if (
$ss_a$ss_uri $ss_a["uri"];
  }
  if (!
$ss_uri)
  {
    (
$r mysql_query("SELECT uri FROM stylesheets WHERE id=1")) or die(mysql_error());
    (
$a mysql_fetch_array($r)) or die(mysql_error());
    
$ss_uri $a["uri"];
  }
  if (
$msgalert && $CURUSER)
  {
    
$res mysql_query("SELECT COUNT(*) FROM messages WHERE receiver=" $CURUSER["id"] . " && unread='yes'") or die("OopppsY!");
    
$arr mysql_fetch_row($res);
    
$unread $arr[0];
    }   

    if (
$CURUSER) {

    
$datum getdate();
    
$datum["hours"] = sprintf("%02.0f"$datum["hours"]);
    
$datum["minutes"] = sprintf("%02.0f"$datum["minutes"]);
    
$uped mksize($CURUSER['uploaded']);
    
$downed mksize($CURUSER['downloaded']);
    if (
$CURUSER["downloaded"] > 0)
    {
        
$ratio $CURUSER['uploaded'] / $CURUSER['downloaded'];
        
$ratio number_format($ratio3);
        
$color get_ratio_color($ratio);
        
        if (
$color)
         
$ratio "<font color=$color>$ratio</font>";

    }else

    if (
$CURUSER["uploaded"] > 0)
        
$ratio "Inf.";
    else
    
$ratio "---";

    if (
$CURUSER['donor'] == "yes")
        
$medaldon "<img src=pic/star.gif alt=donor title=donor>";
    if (
$CURUSER['warned'] == "yes")
        
$warn "<img src=pic/warned.gif alt=warned title=warned>";
//// check for messages //////////////////

    
$res1 mysql_query("SELECT COUNT(*) FROM messages WHERE receiver=" $CURUSER["id"] . " AND location<>0") or print(mysql_error());
    
$arr1 mysql_fetch_row($res1);
    
$messages $arr1[0];
    
    
$res1 mysql_query("SELECT COUNT(*) FROM messages WHERE receiver=" $CURUSER["id"] . " AND location=1 AND unread='yes'") or print(mysql_error());
    
$arr1 mysql_fetch_row($res1);
    
$unread $arr1[0];
    
    
$res1 mysql_query("SELECT COUNT(*) FROM messages WHERE sender=" $CURUSER["id"] . " AND saved='yes'") or print(mysql_error());
    
$arr1 mysql_fetch_row($res1);
    
$outmessages $arr1[0];
    
    
$res1 mysql_query("SELECT COUNT(*) FROM messages WHERE receiver=" $CURUSER["id"] . " && unread='yes'") or die("OopppsY!");
    
$arr1 mysql_fetch_row($res1);
    
$unread $arr1[0];

    if (
$unread)
        
$inboxpic "<img height=14px style=border:none alt=inbox title='inbox (new messages)' src=pic/pn_inboxnew.gif>";
    
    else
        
$inboxpic "<img height=14px style=border:none alt=inbox title='inbox (no new messages)' src=pic/pn_inbox.gif>";


    
$res2 mysql_query("SELECT COUNT(*) FROM peers WHERE userid=" $CURUSER["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=" $CURUSER["id"] . " AND seeder='no'") or print(mysql_error());
    
$row mysql_fetch_row($res2);
    
$activeleech $row[0];

    
$res3 mysql_query("SELECT connectable FROM peers WHERE userid=" sqlesc($CURUSER["id"]) . " LIMIT 1") or print(mysql_error());
    if(
$row mysql_fetch_row($res3)){
        
$connect $row[0];
    if(
$connect == "yes"){
      
$connectable "<b><font color=green><a title='Connectable = Yes'>Yes</a></font></b>";
    }else{
      
$connectable "<b><font color=red><a title='Connectable = No'>No</a></font></b>";
    }
    }else{
        
$connectable "waiting...";
    }
$UC = array("Owner" => "VIP",
 
"Vodja osebja" => "Vodja osebja",
 
"SysOp" => "SysOp",
 
"Administrator" => "Administrator",
 
"Moderator" => "Moderator",
 
"Nalagalec" => "Nalagalec",
 
"Vip" => "VIP",
 
"Super uporabnik" => "PowerUser",
 
"Uporabnik" => "Uporabnik");
 
$uclass $UC[get_user_class_name($CURUSER["class"])];  
 
}

$colors = array("red""green""blue""orange");

if (
in_array($CURUSER["stylesheet"], $colors))
{
    
$color_layout $CURUSER["stylesheet"];
}
else
{
    
$color_layout "blue";
}




?>
<!DOCTYPE html PUBLIC 
    "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="sl">
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
        <title><?=$title?></title>
        <link rel="stylesheet" href="design/design.css" type="text/css" />
        <link rel="stylesheet" href="design/layouts/<?=$color_layout?>.css" type="text/css" />
        
        <link rel="shortcut icon" href="/favicon.ico" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="author" content="Tvoj-Orion.Si - Julij 2009" />
        <meta name="copyrigth" content="Copyright (c) 2009 Tvoj-Orion.Si" />
        <meta name="keywords" content="tvoj, orion, tracker, portal, download, prenos, forum, torrent, xvid, film, podnapis, divx" />
        <meta name="google-site-verification" content="7eBzxKOaMh3Z5VQigQd3Ei4Ehri_VqXGPI-pe6q9Z2w" />
        <meta name="description" content="Spletni portal prostega pretoka podatkov" />
        
        
        <script type="text/javascript" src="zanri/jquery.js"></script>
        <script type="text/javascript" src="zanri/jquery.ajaxify.js"></script>
        <script type="text/javascript" src="zanri/modal.js"></script>
        
        <script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
        <script type="text/javascript" src="tinymce/jscripts/tiny_mce/jquery.tinymce.js"></script>
        
        <script type="text/javascript" src="popup/popup.js"></script>        

        <link rel="alternate" type="application/rss+xml" title="Latest Torrents" href="<?php print $DEFAULTBASEURL?>/rss.php" />
                
        <!-- LightBox -->
        <script type="text/javascript" src="lightbox/js/jquery.lightbox-0.5.js"></script>
        <link rel="stylesheet" type="text/css" href="lightbox/css/jquery.lightbox-0.5.css" media="screen" />
        <script type="text/javascript">
        
            $(document).ready(function(){
                $("a[rel=lightbox]").lightBox({
                    overlayBgColor: '#000000',
                    overlayOpacity: 0.6,
                    imageLoading: '<?php print $BASEURL?>/lightbox/images/lightbox-ico-loading.gif',
                    imageBtnClose: '<?php print $BASEURL?>/lightbox/images/lightbox-btn-close.gif',
                    imageBtnPrev: '<?php print $BASEURL?>/lightbox/images/lightbox-btn-prev.gif',
                    imageBtnNext: '<?php print $BASEURL?>/lightbox/images/lightbox-btn-next.gif',
                    containerResizeSpeed: 350,
                    txtImage: 'Slika',
                    txtOf: 'od'
                });
            });
        
        </script>
        
        <script type="text/javascript" src="java_klappe.js"></script>
        <script type="text/javascript" src="ncode_imageresizer.js"></script>
        
        <script type="text/javascript">
        <!--
        NcodeImageResizer.MODE = 'newwindow';
        NcodeImageResizer.MAXWIDTH = 740;
        NcodeImageResizer.MAXHEIGHT = 0;
        
        //-->
        <!--Image Resizer v0.1 by xam//-->
        </script>
        <script type="text/javascript">
        
        <!-- Begin
        var checkflag = "false";
        function check(field) {
        if (checkflag == "false") {
        for (i = 0; i < field.length; i++) {
        field[i].checked = true;}
        checkflag = "true";
        return "Odznači vse"; }
        else {
        for (i = 0; i < field.length; i++) {
        field[i].checked = false; }
        checkflag = "false";
        return "Označi vse"; }
        }
        //  End -->
        </script>
        
        <script type="text/javascript">
        <!--
        function SetSize(obj, x_size) {
              if (obj.offsetWidth > x_size) {
              obj.style.width = x_size;
          };
        };
        //-->
        </script>
        <?
        
if ($disablerightclick == "yes") {
        
?>
        <script language=JavaScript>
        <!-- Begin
        var message="<?=$SITENAME;?>";
        
        function clickIE4(){
        if (event.button==2){
        alert(message);
        return false;
        }
        }
        
        function clickNS4(e){
        if (document.layers||document.getElementById&&!document.all){
        if (e.which==2||e.which==3){
        alert(message);
        return false;
        }
        }
        }
        
        if (document.layers){
        document.captureEvents(Event.MOUSEDOWN);
        document.onmousedown=clickNS4;
        }
        else if (document.all&&!document.getElementById){
        document.onmousedown=clickIE4;
        }
        
        document.oncontextmenu = new Function("alert(message);return false")
        
        //  End -->
        </script>
        <?
        
}
        
?>
        <script type="text/javascript">
            
            function index_torrenti(id, target)
            {
                $.ajax({
                   url: "torrents_index_ajax.php?category=" + id,
                   success: function(data){
                        $("#" + target).html(data);
                   } 
                });
            }
            
        </script>
        
        




        
    </head>
    <body>
        <!--script type="text/javascript" src="/snow.js"></script>-->
        <a name="top"></a>
        <div id="layout">
            <div id="header-search-messages">
                <div id="header-search-div">
                    <form method="GET" action="browse.php">
                        <input type="text" name="search" onclick="this.value = '';" value="iskanje..." id="search-div-input-text" />
                        <input type="submit" value="" id="search-div-input-submit" title="Išči" />
                    </form>
                </div>
                <div id="header-separator"></div>
                <?php
                
if ($unread):
                
                print (
"<div id=\"header-messages-attention\"></div>
                <div id=\"header-messages\"><span onclick=\"window.location = 'messages.php';\" style=\"cursor: pointer;\">Imate novo zasebno sporočilo!</span></div>"
);
                else: 
                print (
"<div id=\"header-donacije\"><span onclick=\"window.location = 'donate.php';\" style=\"cursor: pointer;\"><marquee loop=\"-1\" scrollamount=\"2\" width=\"60%\">Zahvaljujemo se vsem donatorjem za podporo: solist, mcasia, kamnoseštvo padovac, pato33, ladu, Depra, BENSPORT, blackhawk71</marquee></span></div>"); 
                
                endif;
                
?>

<!--[if CHROME]>
<style type='text/css'>
#header-donacije
{
    position: absolute;
    top: 11px;
    left: 355px;
    font-weight: bold;
    color: #FFFFFF;
}

    </style>
<![endif]-->



                <div id="header-user-menu-div">
                    <ul id="header-user-menu">
                        <li class="usermenu-users" title="Prijatelji"><a href="friends.php"></a></li>
                        <li class="usermenu-messages" title="Sporočila"><a href="messages.php"></a></li>
                        <li class="usermenu-donate" title="Zaznamki"><a href="zaznamki.php"></a></li>
                        <li class="usermenu-logout" title="Odjava" ><a href="logout.php"></a></li>
                        <li class="last-separator"></li>
                    </ul>
                </div>
            </div>
            <div id="header-user-menu-adds" class="header-layout">
                <div id="header-user-img"><a href="<?=$CURUSER["avatar"]?>" rel="lightbox"><img src="<?=$CURUSER["avatar"]?>" alt="" /></a></div>
                <div id="header-user-stats">
                    <?=$jezik->jezik("pozdrav")?> <span class="bold"><a href="userdetails.php?id=<?=$CURUSER["id"]?>"><?=$CURUSER["username"]?></a></span><br />
                    <?=$jezik->jezik("status")?> <span class="bold"><?=get_user_class_name(get_user_class())?></span><br />
                    <img src="design/icons/ratio.png" alt="" /> <?=$jezik->jezik("ratio")?> <span class="bold"><?=@number_format($CURUSER["uploaded"] / $CURUSER["downloaded"], 2)?></span><br />
                    <img src="design/icons/upload.png" alt="" /> <?=$jezik->jezik("nalozeno")?> <span class="bold"><?=mksize($CURUSER["uploaded"])?></span><br />
                    <img src="design/icons/download.png" alt="" /> <?=$jezik->jezik("preneseno")?> <span class="bold"><?=mksize($CURUSER["downloaded"])?></span><br />
                </div>
                <a href="index.php"><div id="header-logo"></div></a>
                <div id="header-navigation-div">
                    <ul id="menu">
                        <li><a href="index.php"><?=$jezik->jezik("glavni_domov")?></a></li>
                        <li>
                            <a href="browse.php"><?=$jezik->jezik("glavni_torrenti")?></a>
                            <ul>
                                <li><a href="browse.php" title="Brskaj"><?=$jezik->jezik("brskaj")?></a></li>
                                <li><a href="xxx.php" title="XXX">XXX</a></li>
                                <li><a href="orsi.php" title="Skupina OrSi">Skupina OrSi</a></li>
                                <li><a href="mrsi.php" title="Skupina MrSi">Skupina MrSi</a></li>
                                <li><a href="zamalcke.php" title="Za malčke"><?=$jezik->jezik("za_malcke")?></a></li>
                                <li><a href="http://tvoj-orion.si/forums.php?action=viewtopic&topicid=339" title="Prošnje torrentov"><?=$jezik->jezik("prosnje")?></a></li>
                                <li><a href="upload.php" title="Naloži"><?=$jezik->jezik("nalozi")?></a></li>
                            </ul>
                        </li>
                        <li><a href="#"><?=$jezik->jezik("glavni_skupnost")?></a>
                            <ul>
                                <li><a href="chat.php" title="Klepet"><?=$jezik->jezik("klepet")?></a></li>
                                <li><a href="forums.php" title="Forum"><?=$jezik->jezik("forum")?></a></li>
                                <li><a href="novice.php" title="Novice"><?=$jezik->jezik("novice")?></a></li>
                                <!--<li><a href="topdeset">Top 10</a></li>-->
                                <!--<li><a href="users.php" title="Uporabniki"><?=$jezik->jezik("uporabniki")?></a></li>-->
                                <li><a href="shrani.php" title="Shrani sliko"><?=$jezik->jezik("shrani_sliko")?></a></li>
                                <li><a href="vici.php" title="Šale"><?=$jezik->jezik("sale")?></a></li>
                                <li><a href="subs.php" title="Podnapisi">Podnapisi</a></li>
                            </ul>
                        </li>
                        <li><a href="#"><?=$jezik->jezik("glavni_profil")?></a>
                            <ul>
                                <li><a href="profil.php" title="Osebna"><?=$jezik->jezik("osebna")?></a></li>
                                <li><a href="usercp.php" title="Urejanje"><?=$jezik->jezik("urejanje_profila")?></a></li>
                                <li><a href="messages.php" title="Sporočila"><?=$jezik->jezik("zasebna_sporocila")?></a></li>
                                <li><a href="friends.php" title="Prijatelji"><?=$jezik->jezik("prijatelji")?></a></li>
                                <li><a href="invite.php" title="Povabila"><?=$jezik->jezik("povabila")?></a></li>
                                <li><a href="dodajnovico.php" title="Objavi novico"><?=$jezik->jezik("objavi_novico")?></a></li>
                            </ul>
                        </li>
                        <li><a href="#"><?=$jezik->jezik("glavni_podpora")?></a>
                            <ul>
                                <li><a href="rules.php" title="Pravila"><?=$jezik->jezik("pravila")?></a></li>
                                <li><a href="faq.php" title="FAQ">FAQ</a></li>
                                <li><a href="pravni.php" title="Pravni pouk"><?=$jezik->jezik("pravni_pouk")?></a></li>
                                <li><a href="podpora.php" title="Pomoč osebja"><?=$jezik->jezik("pomoc_osebja")?></a></li>
                                <li><a href="pogoji.php" title="Pogoji uporabe">Pogoji uporabe</a></li>
                            </ul>
                        </li>
                        <li><a href="#">T-O.Si</a>                            
                            <ul>
                                <li><a href="staff.php" title="Osebje"><?=$jezik->jezik("osebje")?></a></li>
                                <li><a href="donate.php" title="Donacije"><?=$jezik->jezik("donacije")?></a></li>
                                <!--<li><a href="partnerji.php">Partnerji</a></li>-->
                                <li><a href="oglasevanje.php" title="Oglaševanje"><?=$jezik->jezik("oglasevanje")?></a></li>
                                <li><a href="radio.php">Radio</a></li>
                                <li><a href="aktivni.php" title="Aktivni uporabniki"><?=$jezik->jezik("aktivni_uporabniki")?></a></li>
                                <li><a href="shop.php" title="Majice"><?=$jezik->jezik("majice")?></a></li>
                            </ul>
                        </li>                    
                    </ul>
                </div>
                <div id="header-advertising">
                    
<?       
include 'include/oglasi.php';
?>
                
                </div>
            </div>
            <div id="prehod-top"></div>
            <div id="content-layout">
            
<?
if($CURUSER['downloaded'] > 0) { // Make sure there is a download value

// Set the ratio threshold based on user class
switch (get_user_class())
 {
   case 
UC_USER:
   case 
UC_POWER_USER$ratio 1.00;
   break;

   case 
UC_VIP$ratio 0.30;
   break;

   case 
UC_UPLOADER
   case 
UC_MODERATOR$ratio 0.70;
   break;

   case 
UC_ADMINISTRATOR:
   case 
UC_SYSOP
   case 
UC_STAFFLEADER$ratio 0.00;
   break;
 }

// Override ratio if donor, but only if existing ratio is higher than 0.70
if($CURSUSER['donor'] == 'yes' && $ratio 0.70$ratio 0.70;

// Do remember warned users they are warned and for how long... [by fedepeco]
if ($CURUSER['leechwarn'] == 'yes') {
$leechwarnuntil $CURUSER['leechwarnuntil'];
print(
"<p><table border=1 width=737 cellspacing=0 cellpadding=10 bgcolor=#8daff5 align=center><tr><td style='padding: 10px;'bgcolor=red align=center>\n");
print(
"<b><font color=white align=center>Zaradi slabega razmerja, vam je Sistem dodelil opozorilo. Opozorilo se odstrani, ko dosežete razmerje 0.6 ali več.<br>Če tega ne storite v danem času " mkprettytime(strtotime($leechwarnuntil) - gmtime()) . ", bo vaš uporabniški račun blokiran.</font></b>");
print(
"</td></tr></table></p>\n");
print(
"<br>\n");
}
// End MOD...
}

if (
$CURUSER) {
    
$rel sql_query("SELECT COUNT(*) FROM users WHERE status = 'pending' AND invited_by = ".mysql_real_escape_string($CURUSER[id])) or sqlerr(__FILE____LINE__);
    
$arro mysql_fetch_row($rel);
    
$number $arro[0];
    if (
$number 0)
    {
      print(
"<p><table border=0 cellspacing=0 cellpadding=10 bgcolor=blue><tr><td style='padding: 10px; background: blue'>\n");
      print(
"<b><a href=$BASEURL/invite.php?id=$CURUSER[id]><font color=white>Vaš prijatelj čaka na potrditev računa!</font></a></b>");
      print(
"</td></tr></table></p><br />\n");
    }
}
if (
$offlinemsg)
{
    
$settings_script_name substr($_SERVER[SCRIPT_FILENAME], -12 12);
    if (
$settings_script_name != "settings.php" AND $settings_script_name != "announce.php") {        
    print(
"<p><table width=737 border=1 cellspacing=0 cellpadding=10 bgcolor=red><tr><td style='padding: 10px; background: red' class=text>\n");
    print(
"<font color=white><center><b>WARNING</b>: The website is currently offline! Click <a href=settings.php>here</a> to change settings.</font></center>");
    print(
"</td></tr></table></p>\n");
    print(
"<br>\n");
    }
}
if (
get_user_class() > UC_MODERATOR)
{
$resa mysql_query("select count(id) as numreports from reports WHERE dealtwith=0");
$arra mysql_fetch_assoc($resa);
$numreports $arra[numreports];
if (
$numreports){
 print(
"<p><table border=0 cellspacing=0 cellpadding=10 bgcolor=red><tr><td style='padding: 10px; background: blue'>\n");
 print(
"<b><a href=reports.php><font color=white>Imamo $numreports novo prijavo." . ($numreports "s" "") . "!</font></a></b>");
 print(
"</td></tr></table></p>\n");}

    
$rese mysql_query("SELECT COUNT(id) as nummessages from staffmessages WHERE answered='no'");
    
$arre mysql_fetch_assoc($rese);
    
$nummessages $arre[nummessages];
    if (
$nummessages 0) {
     print(
"<p><table border=0 cellspacing=0 cellpadding=10 bgcolor=red><tr><td style='padding: 10px; background: blue'>\n");
    print(
"<b><a href=staffbox.php><font color=white>Imamo $nummessages novo sporočilo osebja." . ($nummessages "s" "") . "!</font></a></b>");
    print(
"</td></tr></table></p>\n");}    
}
// stdhead

function stdfoot() {
    global 
$SITENAME,$BASEURL;
    
?>
                <div style="clear: both;"></div>
            </div>
            <div id="prehod-bottom"></div>
            <div id="footer-layout">
                <div id="footer-buttons">
                
                    <a href="rules.php" title="Pravilnik" id="footer-button-1"></a>
                    <a class="footer-buttons-separator"></a>
                    <a href="faq.php" title="FAQ" id="footer-button-2"></a>
                    <a class="footer-buttons-separator"></a>
                    <a href="pravni.php" title="Pravni Pouk" id="footer-button-3"></a>
                    <a class="footer-buttons-separator"></a>
                    <a href="getrss.php" title="RSS Povezave" id="footer-button-4"></a>
                
                </div>
                <div id="footer-advertising">
                
<?       
include 'include/oglasi_noga.php';
?>
                    
                </div>
                <div id="footer-toUp">
                    <a href="#top" title="Na vrh">Na vrh</a>
                </div>
                <div id="footer-copyright">
                    Copyright &copy; Vse pravice pridržane.
                </div>
            </div>
        </div>
        <!--
        <script src="http://js.anonym.to/anonym/anonymize.js" type="text/javascript"></script>
        -->
        <script type="text/javascript"><!--
        protected_links = "";
        
        auto_anonymize();
        //--></script>
        
        <script type="text/javascript">
        var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
        document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
        </script>
        <script type="text/javascript">
        try {
        var pageTracker = _gat._getTracker("UA-10348397-1");
        pageTracker._trackPageview();
        } catch(err) {}</script>
    </body>
</html>
<?php
  
unset($_SESSION['queries']);
}

function 
genbark($x,$y) {
    
stdhead($y);
    print(
"<h2>" htmlspecialchars($y) . "</h2>\n");
    print(
"<p>" htmlspecialchars($x) . "</p>\n");
    
stdfoot();
    exit();
}

function 
mksecret($len 20) {
    
$ret "";
    for (
$i 0$i $len$i++)
        
$ret .= chr(mt_rand(0255));
    return 
$ret;
}

function 
httperr($code 404) {
    
header("HTTP/1.0 404 Not found");
    print(
"<h1>Not Found</h1>\n");
    print(
"<p>Sorry pal :(</p>\n");
    exit();
}

function 
gmtime()
{
    return 
strtotime(get_date_time());
}

//-------------------------------------
//---- Secure Login System v0.3 by xam
//-------------------------------------
function sessioncookie ($id$passhash$expires=false) {
    if (
$expires)
        
$GLOBALS[$sessioncacheexpire]  = true;
        
    
$_SESSION['s_secure_uid'] = base64($id);
    
$_SESSION['s_secure_pass'] = $passhash;
    
        return 
$sessioncacheexpire;
}

function 
logincookie($id$passhash$updatedb 1$expires 0x7fffffff$securelogin=true)
{
    if (
$expires != 0x7fffffff)
        
$expires time()+900;
    
    
setcookie("c_secure_uid"base64($id), $expires"/");
    
setcookie("c_secure_pass"$passhash$expires"/");
    if (
$securelogin)
        
setcookie("c_secure_login"base64("yeah"), $expires"/");
    else
        
setcookie("c_secure_login"base64("nope"), $expires"/");

  if (
$updatedb)
      
mysql_query("UPDATE users SET last_login = NOW() WHERE id = ".mysql_real_escape_string($id));
}

function 
logoutsession () {
    
session_unset();
    
session_destroy();    
}

function 
logoutcookie() {
    
setcookie("c_secure_uid"""0x7fffffff"/");
    
setcookie("c_secure_pass"""0x7fffffff"/");
    
setcookie("c_secure_login"""0x7fffffff"/");
}

function 
base64 ($string$encode=true) {
    if (
$encode)
        return 
base64_encode($string);
    else
        return 
base64_decode($string);
}
//-------------------------------------
//---- Secure Login System v0.3 by xam
//-------------------------------------

function loggedinorreturn($mainpage false) {
    global 
$CURUSER,$BASEURL;
    if (!
$CURUSER) {
        if (
$mainpage)
            
header("Location: $BASEURL/login.php");
        else {
            
$to $_SERVER["REQUEST_URI"];
            
$to basename($to);
            
header("Location: $BASEURL/login.php?returnto=" urlencode($to));
        }
        exit();
    }
}

function 
deletetorrent($id) {
    global 
$torrent_dir;
    
mysql_query("DELETE FROM torrents WHERE id = ".mysql_real_escape_string($id));
    
mysql_query("DELETE FROM snatched WHERE torrentid = ".mysql_real_escape_string($id));
    foreach(
explode(".","peers.files.comments.ratings") as $x)
        
mysql_query("DELETE FROM $x WHERE torrent = ".mysql_real_escape_string($id));
    
unlink("$torrent_dir/$id.torrent");
}

function 
pager($rpp$count$href$opts = array()) {
    
$pages ceil($count $rpp);

    if (!
$opts["lastpagedefault"])
        
$pagedefault 0;
    else {
        
$pagedefault floor(($count 1) / $rpp);
        if (
$pagedefault 0)
            
$pagedefault 0;
    }

    if (isset(
$_GET["page"])) {
        
$page $_GET["page"];
        if (
$page 0)
            
$page $pagedefault;
    }
    else
        
$page $pagedefault;

    
$pager "";

    
$mp $pages 1;
    
$as "<b>&lt;&lt;&nbsp;Nazaj</b>";
    if (
$page >= 1) {
        
$pager .= "<a href=\"{$href}page=" . ($page 1) . "\">";
        
$pager .= $as;
        
$pager .= "</a>";
    }
    else
        
$pager .= $as;
    
$pager .= "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
    
$as "<b>Naprej&nbsp;&gt;&gt;</b>";
    if (
$page $mp && $mp >= 0) {
        
$pager .= "<a href=\"{$href}page=" . ($page 1) . "\">";
        
$pager .= $as;
        
$pager .= "</a>";
    }
    else
        
$pager .= $as;

    if (
$count) {
        
$pagerarr = array();
        
$dotted 0;
        
$dotspace 3;
        
$dotend $pages $dotspace;
        
$curdotend $page $dotspace;
        
$curdotstart $page $dotspace;
        for (
$i 0$i $pages$i++) {
            if ((
$i >= $dotspace && $i <= $curdotend) || ($i >= $curdotstart && $i $dotend)) {
                if (!
$dotted)
                    
$pagerarr[] = "...";
                
$dotted 1;
                continue;
            }
            
$dotted 0;
            
$start $i $rpp 1;
            
$end $start $rpp 1;
            if (
$end $count)
                
$end $count;
            
$text "$start&nbsp;-&nbsp;$end";
            if (
$i != $page)
                
$pagerarr[] = "<a href=\"{$href}page=$i\"><b>$text</b></a>";
            else
                
$pagerarr[] = "<b>$text</b>";
        }
        
$pagerstr join(" | "$pagerarr);
        
$pagertop "<p align=\"center\">$pager<br />$pagerstr</p>\n";
        
$pagerbottom "<p align=\"center\">$pagerstr<br />$pager</p>\n";
    }
    else {
        
$pagertop "<p align=\"center\">$pager</p>\n";
        
$pagerbottom $pagertop;
    }

    
$start $page $rpp;

    return array(
$pagertop$pagerbottom"LIMIT $start,$rpp");
}

function 
downloaderdata($res) {
    
$rows = array();
    
$ids = array();
    
$peerdata = array();
    while (
$row mysql_fetch_assoc($res)) {
        
$rows[] = $row;
        
$id $row["id"];
        
$ids[] = $id;
        
$peerdata[$id] = array(downloaders => 0seeders => 0comments => 0);
    }

    if (
count($ids)) {
        
$allids implode(","$ids);
        
$res mysql_query("SELECT COUNT(*) AS c, torrent, seeder FROM peers WHERE torrent IN ($allids) GROUP BY torrent, seeder");
        while (
$row mysql_fetch_assoc($res)) {
            if (
$row["seeder"] == "yes")
                
$key "seeders";
            else
                
$key "downloaders";
            
$peerdata[$row["torrent"]][$key] = $row["c"];
        }
        
$res mysql_query("SELECT COUNT(*) AS c, torrent FROM comments WHERE torrent IN ($allids) GROUP BY torrent");
        while (
$row mysql_fetch_assoc($res)) {
            
$peerdata[$row["torrent"]]["comments"] = $row["c"];
        }
    }

    return array(
$rows$peerdata);
}

function 
commenttable($rows)
{
    global 
$CURUSER;
    
$count 0;
    
?>
     
    <div id="torrent_comments_div">
     
    <?php
    
foreach ($rows as $row)
    {
       if (empty(
$row))
       {
        continue;
       }
        
        
/*print("<table align=center class=main width=600><tr><td colspan=\"2\" class=colhead>Objavil ");
        if (isset($row["username"]))
        {
            print("<a name=comm". $row["id"] .
                " href=userdetails.php?id=" . $row["user"] . "><b>" .
                htmlspecialchars($row["username"]) . "</b></a>" . ($row["donor"] == "yes" ? "<img src=pic/star.gif alt='Donor'>" : "") . ($row["warned"] == "yes" ? "<img src=".
                    "pic/warned.gif alt=\"Warned\">" : "") . "\n");
        }
        else
           print("<a name=\"comm" . $row["id"] . "\"><i>(orphaned)</i></a>\n");

        print(" " . $row["added"] . " GMT" .
            ($row["user"] == $CURUSER["id"] || get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=edit&cid=$row[id]>Edit</a>]" : "") .
            (get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=delete&cid=$row[id]>Delete</a>]" : "") .
            ($row["editedby"] && get_user_class() >= UC_MODERATOR ? "- [<a href=comment.php?action=vieworiginal&cid=$row[id]>View original</a>]" : "") . "</td></tr>");
        $avatar = ($CURUSER["avatars"] == "yes" ? htmlspecialchars(trim($row["avatar"])) : "");
        if (!$avatar)
            $avatar = "pic/defaultavatar.png";
        $text = format_comment($row["text"]);
    //if ($row["editedby"])
        //$text .= "<p><font size=1 class=small>Last edited by <a href=userdetails.php?id=$row[editedby]><b>$row[username]</b></a> at $row[editedat] GMT</font></p>\n";
        $dt = gmtime() - 180;
        $dt = sqlesc(get_date_time($dt));
        print("<tr>");
        print("<td align=left border=0 width=70 height=70 style='padding: 0px'><img border=0 width=70 height=70 src=$avatar></td>");
        print("<td align=left border=0 class=text valign=top>$text</td>");        
        print("</tr>");
        print("<tr><td border=0 colspan=2> ".("'".$row['last_access']."'">$dt?"<img src=pic/user_online.gif border=0 alt=\"Online\">":"<img src=pic/user_offline.gif border=0 alt=\"Offline\">" )."<a href=\"sendmessage.php?receiver=".htmlspecialchars(trim($row["user"]))."\"><img src=\"pic/pm.gif\" border=\"0\" alt=\"Send message to ".htmlspecialchars($row["username"])."\"></a> <a href=\"report.php?commentid=".htmlspecialchars(trim($row["id"]))."\"><img src=\"pic/report.gif\" border=\"0\" alt=\"Report this comment\"></a></td>");        
        print("</table>");
     print ("<br>");
     
     
     */
    
?>
        <div class="torrent_comment">
            <div class="torrent_comment_image">
                <a href="userdetails.php?id=<?=$row["user"]?>">
                    <img src="<?=(!empty($row["avatar"]) ? $row["avatar"] : "pic/default_avatar.png"?>" alt="" title="Uporabnik <?=$row["username"]?>" />
                </a>
            </div>
            <div class="torrent_comment_text">
                <div class="torrent_comment_text_header"></div>
                <div class="torrent_comment_text_middle">
                    <div class="objavil">
                        <a href="userdetails.php?id=<?=$row["user"]?>"><?=$row["username"]?></a> ob <?=date("d.m.Y H:i:s"strtotime($row["added"]))?>
                        <?php
                            
                            
if (get_user_class() > UC_MODERATOR || $row["user"] == $CURUSER["id"])
                            {
                                print (
" <a href='comment.php?action=edit&cid=$row[id]'><img artribute style='border: none;'src='design/icons/commentedit.png' title='Uredi' alt='' /></a>");
                            }
                            
                            if (
get_user_class() > UC_MODERATOR)
                            {
                                print (
" <a href='comment.php?action=delete&cid=$row[id]'><img artribute style='border: none;'src='design/icons/commentdelete.png' title='Briši' alt='' /></a>");
                            }

                            if (
get_user_class() > UC_MODERATOR)
                            {
                                print (
" <a href='comment.php?action=vieworiginal&cid=$row[id]'><img artribute style='border: none;'src='design/icons/original.png' title='Poglej prvotnega' alt='' /></a>");
                            }

                        
?>
                    </div>
                    <?=format_comment($row["text"])?>
                </div>
                <div class="torrent_comment_text_bottom"></div>
            </div>
            <div style="clear: both;"></div>
        </div>
    <?php
    
}
    
?>
  
    </div>
     
    <?php
}

function 
searchfield($s) {
    return 
preg_replace(array('/[^a-z0-9]/si''/^\s*/s''/\s*$/s''/\s+/s'), array(" """""" "), $s);
}

function 
genrelist() {
    
$ret = array();
    
$res mysql_query("SELECT id, name FROM categories ORDER BY name");
    while (
$row mysql_fetch_array($res))
        
$ret[] = $row;
    return 
$ret;
}

function 
newscats_list() {
    
$ret = array();
    
$res mysql_query("SELECT id, name FROM newscats ORDER BY name");
    while (
$row mysql_fetch_array($res))
        
$ret[] = $row;
    return 
$ret;
}

function 
linkcolor($num) {
    if (!
$num)
        return 
"red";
//    if ($num == 1)
//        return "yellow";
    
return "green";
}

function 
ratingpic($num) {
    global 
$pic_base_url;
    
$r round($num 2) / 2;
    if (
$r || $r 5)
        return;
    return 
"<img src=\"$pic_base_url$r.gif\" border=\"0\" alt=\"rating: $num / 5\" />";
}
function 
writecomment($userid$comment) {
    
$res mysql_query("SELECT modcomment FROM users WHERE id = '$userid'") or sqlerr(__FILE____LINE__);
    
$arr mysql_fetch_assoc($res);
    
       
$modcomment gmdate("d.m.Y") . " - " $comment "" . ($arr[modcomment] != "" "\n\n" "") . "$arr[modcomment]";    
    
$modcom sqlesc($modcomment);
    
    return 
mysql_query("UPDATE users SET modcomment = $modcom WHERE id = '$userid'") or sqlerr(__FILE____LINE__);
}

function 
torrenttable ($res$variant "index") {
global 
$pic_base_url$CURUSER,$waitsystem$all_torrents_free;
unset(
$wait);
$browse_res mysql_query("SELECT last_browse FROM users WHERE id=".sqlesc($CURUSER[id]));

$browse_arr mysql_fetch_row($browse_res);
$last_browse $browse_arr[0];
$time_now gmtime();

if (
$last_browse $time_now) {
$last_browse=$time_now;
}

$sloSubQuery mysql_query('SELECT id FROM zanri AS Zanri WHERE Zanri.name LIKE \'%SloSubs%\' OR Zanri.name LIKE \'%Slosubs%\'') or sqlerr();
$sloSubsIds = array();
while (
$sub mysql_fetch_assoc($sloSubQuery))
{
    
$sloSubsIds[] = $sub['id'];
}

?>

<table width="717px">
    <tr>

    <?php

    
// sorting by MarkoStamcar

    
$count_get 0;

    foreach (
$_GET as $get_name => $get_value) {

    
$get_name mysql_escape_string(@strip_tags(str_replace(array("\"","'"),array("",""),$get_name)));

    
$get_value mysql_escape_string(@strip_tags(str_replace(array("\"","'"),array("",""),$get_value)));

    if (
$get_name != "sort" && $get_name != "type") {
    if (
$count_get 0) {
    
$oldlink $oldlink "&" $get_name "=" $get_value;
    } else {
    
$oldlink $oldlink $get_name "=" $get_value;
    }
    
$count_get++;
    }

    }

    if (
$count_get 0) {
    
$oldlink $oldlink "&";
    }


    if (
$_GET['sort'] == "1") {
    if (
$_GET['type'] == "desc") {
    
$link1 "asc";
    } else {
    
$link1 "desc";
    }
    }

    if (
$_GET['sort'] == "2") {
    if (
$_GET['type'] == "desc") {
    
$link2 "asc";
    } else {
    
$link2 "desc";
    }
    }

    if (
$_GET['sort'] == "3") {
    if (
$_GET['type'] == "desc") {
    
$link3 "asc";
    } else {
    
$link3 "desc";
    }
    }

    if (
$_GET['sort'] == "4") {
    if (
$_GET['type'] == "desc") {
    
$link4 "asc";
    } else {
    
$link4 "desc";
    }
    }

    if (
$_GET['sort'] == "5") {
    if (
$_GET['type'] == "desc") {
    
$link5 "asc";
    } else {
    
$link5 "desc";
    }
    }

    if (
$_GET['sort'] == "6") {
    if (
$_GET['type'] == "desc") {
    
$link6 "asc";
    } else {
    
$link6 "desc";
    }
    }

    if (
$_GET['sort'] == "7") {
    if (
$_GET['type'] == "desc") {
    
$link7 "asc";
    } else {
    
$link7 "desc";
    }
    }

    if (
$_GET['sort'] == "8") {
    if (
$_GET['type'] == "desc") {
    
$link8 "asc";
    } else {
    
$link8 "desc";
    }
    }

    if (
$_GET['sort'] == "9") {
    if (
$_GET['type'] == "desc") {
    
$link9 "asc";
    } else {
    
$link9 "desc";
    }
    }

    if (
$link1 == "") { $link1 "asc"; } // for torrent name
    
if ($link2 == "") { $link2 "desc"; }
    if (
$link3 == "") { $link3 "desc"; }
    if (
$link4 == "") { $link4 "desc"; }
    if (
$link5 == "") { $link5 "desc"; }
    if (
$link6 == "") { $link6 "desc"; }
    if (
$link7 == "") { $link7 "desc"; }
    if (
$link8 == "") { $link8 "desc"; }
    if (
$link9 == "") { $link9 "desc"; }

    
?>
        <td class="tabela_browse_naslov" align="center">Kategorija</td>
        <td class="tabela_browse_naslov" align="left"><a href="browse.php?<? print $oldlink?>sort=1&type=<? print $link1?>">Naslov</a><!-- / <a href="browse.php?<? print $oldlink?>sort=4&type=<? print $link4?>">Dodan</a> --></td>
            <?
            
if ($CURUSER["downloadpos"] != "no")
            print(
"<td class='tabela_browse_naslov' align=\"center\">Prenos</td>");

            if (
$wait)
            {
             print(
"<td class=\"colhead\" align=\"center\"><font color=black>Čakaj</font></td>\n");
            }

            if (
$variant == "mytorrents")
            {
             print(
"<td class=\"colhead\" align=\"center\">Edit</td>\n");
             print(
"<td class=\"colhead\" align=\"center\">Visible</td>\n");
            }


            
/*<td class="colhead" align="right"><a href="browse.php?<? print $oldlink; ?>sort=2&type=<? print $link2; ?>"><img src=pic/files.gif border=0 alt=files></a></td>

            <td class="colhead" align="right"><a href="browse.php?<? print $oldlink; ?>sort=3&type=<? print $link3; ?>"><img src=pic/comments.gif border=0 alt=comments></a></td>*/
            
?>
        <td class="tabela_browse_naslov" align="center"><a href="browse.php?<? print $oldlink?>sort=7&type=<? print $link7?>">Sejalci</a></td>
        <td class="tabela_browse_naslov" align="center"><a href="browse.php?<? print $oldlink?>sort=8&type=<? print $link8?>">Odjemalci</a></td>

        <td class="tabela_browse_naslov" align="center"><a href="browse.php?<? print $oldlink?>sort=5&type=<? print $link5?>">Velikost</a><!-- / <a href="browse.php?<? print $oldlink?>sort=6&type=<? print $link6?>">Prenešen</a> --></td>

<?

if ($variant == "index")
print(
"<td class='tabela_browse_naslov' align=center><a href=\"browse.php?{$oldlink}sort=9&type={$link9}\">Nalagalec</a></td>\n");

print(
"</tr>\n");

while (
$row mysql_fetch_assoc($res)) {
$id $row["id"];

print(
"<tr class=\"tabela_browse\">");

print(
"<td class=rowhead2 align=center width=16 height=16 style='padding: 0px'>");
if (isset(
$row["cat_name"])) {
print(
"<a href=\"browse.php?cat=" $row["category"] . "\">");
if (isset(
$row["cat_pic"]) && $row["cat_pic"] != "")
print(
"<img border=\"0\" src=\"$pic_base_url$row["cat_pic"] . "\" alt=\"" $row["cat_name"] . "\" />");
else
print(
$row["cat_name"]);
print(
"</a>");
}
else
print(
"-");
print(
"</td>\n");

$dispname htmlspecialchars(trim(substr($row["name"], 040)) . "...");
$count_dispname=strlen($dispname);
$max_lenght_of_torrent_name "60"// maximum lenght
if($count_dispname $max_lenght_of_torrent_name){
$short_torrent_name_alt="title=\"$dispname\"";
$dispname=substr($dispname0$max_lenght_of_torrent_name) . "...";
}else
$short_torrent_name_alt="title=\"$dispname\"";
print(
"<td align=left class=rowhead2><a class=\"preview\" rel=\"" $row['poster'] . "\" $short_torrent_name_alt href=\"details.php?");
if (
$variant == "mytorrents")
print(
"returnto=" urlencode($_SERVER["REQUEST_URI"]) . "&");
print(
"id=$id");
if (
$variant == "index")
print(
"&hit=1");


///Id of sloSubs genre...
$torrentSubsIds explode('|'$row['zanri']);

$sloSubs false;
foreach (
$torrentSubsIds as $torrentSubId)
{
    if (
in_array($torrentSubId$sloSubsIds))
    {
        
$sloSubs true;
        break;
    }
}

$sloSubs = ($sloSubs '<img src="pic/slo.gif" title="Torrent vsebuje Slovenske podnapise." rel="SloSubs" />' '');    


$thisisfree = (($row[suprise]=="no" && $row[free]=="yes" || $all_torrents_free == 1) ? "<img src='pic/freedownload.png' title='Torrent je FreeLeech. Razmerje se vam ne bo pokvarilo.' />" "");
$suprise = (($row[suprise]=="yes" && $row[free]=="yes") ? "<img src='pic/suprise.gif' title='Torrent presenečenja. Sejanje torrenta ni potrebno.' />" "");
$req = (($row[req]=="yes") ? "<img src='pic/req.png' title='Torrent je izpolnjena prošnja.' />" "");

$max 55;
$short_descr $row["short_descr"];
$short_descr strlen($short_descr) > $max substr($short_descr0$max) . "..." $short_descr;
$timezone $row["added"];
if (
sql_timestamp_to_unix_timestamp($row["added"]) >= $last_browse)
print(
"\">$req<b>$dispname</b></a> <img src=pic/new.gif border=0> <br>$short_descr $thisisfree $suprise $sloSubs </div>");
else
print(
"\">$req<b>$dispname</b></a><br>$short_descr $thisisfree $suprise $sloSubs </div>");


if (
$variant == "index")
if (
$CURUSER["downloadpos"] != "no")
print(
"<td class=rowhead2 align=\"center\"><a class=\"index\" href=\"download.php?id=$id&name=" rawurlencode($row["filename"]) . "\"><img src=pic/dl.png border=0 alt=Prenesi></a></td>\n");
if (
$wait)
{
$elapsed floor((gmtime() - strtotime($row["added"])) / 3600);
if (
$elapsed $wait)
{
$color dechex(floor(127*($wait $elapsed)/48 128)*65536);
print(
"<td class=rowhead2 align=center><nobr><a href=\"faq.php#46\"><font color=\"$color\">" number_format($wait $elapsed) . " h</font></a></nobr></td>\n");
}
else
print(
"<td class=rowhead2 align=center><nobr>None</nobr></td>\n");
}

if (
$variant == "mytorrents")
print(
"<td class=rowhead2 align=\"center\"><a href=\"edit.php?returnto=" urlencode($_SERVER["REQUEST_URI"]) . "&id=" $row["id"] . "\">edit</a>\n");
print(
"</td>\n");
if (
$variant == "mytorrents") {
print(
"<td class=rowhead2 align=\"right\">");
if (
$row["visible"] == "no")
print(
"<b>no</b>");
else
print(
"yes");
print(
"</td>\n");
}

if (
$row["seeders"]) 
{
    if (
$variant == "index")
    {
        if (
$row["leechers"]) $ratio $row["seeders"] / $row["leechers"]; else $ratio 1;
            print(
"<td class=rowhead2 align=center>" $row["seeders"] . "</td>\n");
    }
    else
        print(
"<td class=rowhead2 align=\"center\">" $row["seeders"] . "</td>\n");
}
else if (
$row["sledilniki"] == "yes" && $row["seeders"] == 0)
{
    print(
"<td class=rowhead2 align=\"center\">1</td>\n");
}
else

print(
"<td class=rowhead2 align=\"center\">" $row["seeders"] . "</td>\n");

if (
$row["leechers"]) {
if (
$variant == "index")
print(
"<td class=rowhead2 align=center>" number_format($row["leechers"]) . "</td>\n");
else
print(
"<td class=rowhead2 align=\"center\">" $row["leechers"] . "</td>\n");
}
else
print(
"<td class=rowhead2 align=\"center\">0</td>\n");

$_s "";
if (
$row["times_completed"] != 1)
$_s "s";
print(
"<td class=rowhead2 align=center>" str_replace(" ""&nbsp;"mksize($row["size"])));

if (
$variant == "index") {
if (
$row["anonymous"] == "yes") {
print(
"<td class=rowhead2 align=center><i>Anonimen</i></td>\n");
}
else {
print(
"<td class=rowhead2 align=center>" . (isset($row["username"]) ? ("<a href=userdetails.php?id=" $row["owner"] . "><b>" htmlspecialchars($row["username"]) . "</b></a>") : "<i>(unknown)</i>") . "</td>\n");
}
}

}

print(
"</tr></table>\n");

return 
$rows;
}

function 
torrenttablexxx ($res$variant "index") {
global 
$pic_base_url$CURUSER,$waitsystem;
unset(
$wait);
$browse_res mysql_query("SELECT last_browse FROM users WHERE id=".sqlesc($CURUSER[id]));

$browse_arr mysql_fetch_row($browse_res);
$last_browse $browse_arr[0];
$time_now gmtime();

if (
$last_browse $time_now) {
$last_browse=$time_now;
}
?>

<table width="720px">
    <tr>

    <?

    
// sorting by MarkoStamcar

    
$count_get 0;

    foreach (
$_GET as $get_name => $get_value) {

    
$get_name mysql_escape_string(strip_tags(str_replace(array("\"","'"),array("",""),$get_name)));

    
$get_value mysql_escape_string(strip_tags(str_replace(array("\"","'"),array("",""),$get_value)));

    if (
$get_name != "sort" && $get_name != "type") {
    if (
$count_get 0) {
    
$oldlink $oldlink "&" $get_name "=" $get_value;
    } else {
    
$oldlink $oldlink $get_name "=" $get_value;
    }
    
$count_get++;
    }

    }

    if (
$count_get 0) {
    
$oldlink $oldlink "&";
    }


    if (
$_GET['sort'] == "1") {
    if (
$_GET['type'] == "desc") {
    
$link1 "asc";
    } else {
    
$link1 "desc";
    }
    }

    if (
$_GET['sort'] == "2") {
    if (
$_GET['type'] == "desc") {
    
$link2 "asc";
    } else {
    
$link2 "desc";
    }
    }

    if (
$_GET['sort'] == "3") {
    if (
$_GET['type'] == "desc") {
    
$link3 "asc";
    } else {
    
$link3 "desc";
    }
    }

    if (
$_GET['sort'] == "4") {
    if (
$_GET['type'] == "desc") {
    
$link4 "asc";
    } else {
    
$link4 "desc";
    }
    }

    if (
$_GET['sort'] == "5") {
    if (
$_GET['type'] == "desc") {
    
$link5 "asc";
    } else {
    
$link5 "desc";
    }
    }

    if (
$_GET['sort'] == "6") {
    if (
$_GET['type'] == "desc") {
    
$link6 "asc";
    } else {
    
$link6 "desc";
    }
    }

    if (
$_GET['sort'] == "7") {
    if (
$_GET['type'] == "desc") {
    
$link7 "asc";
    } else {
    
$link7 "desc";
    }
    }

    if (
$_GET['sort'] == "8") {
    if (
$_GET['type'] == "desc") {
    
$link8 "asc";
    } else {
    
$link8 "desc";
    }
    }

    if (
$_GET['sort'] == "9") {
    if (
$_GET['type'] == "desc") {
    
$link9 "asc";
    } else {
    
$link9 "desc";
    }
    }

    if (
$link1 == "") { $link1 "asc"; } // for torrent name
    
if ($link2 == "") { $link2 "desc"; }
    if (
$link3 == "") { $link3 "desc"; }
    if (
$link4 == "") { $link4 "desc"; }
    if (
$link5 == "") { $link5 "desc"; }
    if (
$link6 == "") { $link6 "desc"; }
    if (
$link7 == "") { $link7 "desc"; }
    if (
$link8 == "") { $link8 "desc"; }
    if (
$link9 == "") { $link9 "desc"; }

    
?>
        <td class="tabela_browse_naslov" align="center">Kategorija</td>
        <td class="tabela_browse_naslov" align="left"><a    href="xxx.php?<? print $oldlink?>sort=1&type=<? print $link1?>">Naslov</a><!-- / <a href="xxx.php?<? print $oldlink?>sort=4&type=<? print $link4?>">Dodan</a> --></td>
            <?
            
if ($CURUSER["downloadpos"] != "no")
            print(
"<td class='tabela_browse_naslov' align=\"center\">Prenos</td>");

            if (
$wait)
            {
            print(
"<td class=\"colhead\" align=\"center\"><font color=black>Wait</font></td>\n");
            }

            if (
$variant == "mytorrents")
            {
            print(
"<td class=\"colhead\" align=\"center\">Edit</td>\n");
            print(
"<td class=\"colhead\" align=\"center\">Visible</td>\n");
            }


            
/*<td class="colhead" align="right"><a href="xxx.php?<? print $oldlink; ?>sort=2&type=<? print $link2; ?>"><img src=pic/files.gif border=0 alt=files></a></td>

            <td class="colhead" align="right"><a href="xxx.php?<? print $oldlink; ?>sort=3&type=<? print $link3; ?>"><img src=pic/comments.gif border=0 alt=comments></a></td>*/
            
?>
        <td class="tabela_browse_naslov" align="center"><a href="xxx.php?<? print $oldlink?>sort=7&type=<? print $link7?>">Sejalci</a></td>
        <td class="tabela_browse_naslov" align="center"><a href="xxx.php?<? print $oldlink?>sort=8&type=<? print $link8?>">Odjemalci</a></td>

        <td class="tabela_browse_naslov" align="center"><a href="xxx.php?<? print $oldlink?>sort=5&type=<? print $link5?>">Velikost</a><!-- / <a href="xxx.php?<? print $oldlink?>sort=6&type=<? print $link6?>">Prenešen</a> --></td>

<?

if ($variant == "index")
print(
"<td class='tabela_browse_naslov' align=center><a href=\"xxx.php?{$oldlink}sort=9&type={$link9}\">Nalagalec</a></td>\n");

print(
"</tr>\n");

while (
$row mysql_fetch_assoc($res)) {
$id $row["id"];

print(
"<tr class=\"tabela_browse\">");

print(
"<td class=rowhead2 align=center width=16 height=16 style='padding: 0px'>");
if (isset(
$row["cat_name"])) {
print(
"<a href=\"xxx.php?cat=" $row["category"] . "\">");
if (isset(
$row["cat_pic"]) && $row["cat_pic"] != "")
print(
"<img border=\"0\" src=\"$pic_base_url$row["cat_pic"] . "\" alt=\"" $row["cat_name"] . "\" />");
else
print(
$row["cat_name"]);
print(
"</a>");
}
else
print(
"-");
print(
"</td>\n");

$dispname htmlspecialchars(trim($row["name"]));
$count_dispname=strlen($dispname);
$max_lenght_of_torrent_name="65"// maximum lenght
if($count_dispname $max_lenght_of_torrent_name){
$short_torrent_name_alt="title=\"$dispname\"";
$dispname=substr($dispname0$max_lenght_of_torrent_name) . "...";
}else
$short_torrent_name_alt="title=\"$dispname\"";
print(
"<td align=left class=rowhead2><a $short_torrent_name_alt href=\"details.php?");
if (
$variant == "mytorrents")
print(
"returnto=" urlencode($_SERVER["REQUEST_URI"]) . "&");
print(
"id=$id");
if (
$variant == "index")
print(
"&hit=1");

$thisisfree = (($row[suprise]=="no" && $row[free]=="yes" || $all_torrents_free == 1) ? "<img src='pic/freedownload.png' title='Torrent je FreeLeech. Razmerje se vam ne bo pokvarilo.' />" "");
$suprise = (($row[suprise]=="yes" && $row[free]=="yes") ? "<img src='pic/suprise.gif' title='Torrent presenečenja. Sejanje torrenta ni potrebno.' />" "");

$max 55;
$short_descr $row["short_descr"];
$short_descr strlen($short_descr) > $max substr($short_descr0$max) . "..." $short_descr;
$timezone $row["added"];
if (
sql_timestamp_to_unix_timestamp($row["added"]) >= $last_browse)
print(
"\"><b>$dispname</b></a> <img src=pic/new.gif border=0> <br>$short_descr $thisisfree $suprise $sloSubs </div>");
else
print(
"\"><b>$dispname</b></a><br>$short_descr $thisisfree $suprise $sloSubs </div>");


if (
$variant == "index")
if (
$CURUSER["downloadpos"] != "no")
print(
"<td class=rowhead2 align=\"center\"><a class=\"index\" href=\"download.php?id=$id&name=" rawurlencode($row["filename"]) . "\"><img src=pic/dl.png border=0 alt=Prenesi></a></td>\n");
if (
$wait)
{
$elapsed floor((gmtime() - strtotime($row["added"])) / 3600);
if (
$elapsed $wait)
{
$color dechex(floor(127*($wait $elapsed)/48 128)*65536);
print(
"<td class=rowhead2 align=center><nobr><a href=\"faq.php#46\"><font color=\"$color\">" number_format($wait $elapsed) . " h</font></a></nobr></td>\n");
}
else
print(
"<td class=rowhead2 align=center><nobr>None</nobr></td>\n");
}

if (
$variant == "mytorrents")
print(
"<td class=rowhead2 align=\"center\"><a href=\"edit.php?returnto=" urlencode($_SERVER["REQUEST_URI"]) . "&id=" $row["id"] . "\">edit</a>\n");
print(
"</td>\n");
if (
$variant == "mytorrents") {
print(
"<td class=rowhead2 align=\"right\">");
if (
$row["visible"] == "no")
print(
"<b>no</b>");
else
print(
"yes");
print(
"</td>\n");
}

if (
$row["seeders"]) {
if (
$variant == "index")
{
if (
$row["leechers"]) $ratio $row["seeders"] / $row["leechers"]; else $ratio 1;
print(
"<td class=rowhead2 align=center>" $row["seeders"] . "</td>\n");
}
else
print(
"<td class=rowhead2 align=\"center\">" $row["seeders"] . "</td>\n");
}
else
print(
"<td class=rowhead2 align=\"center\">" $row["seeders"] . "</td>\n");

if (
$row["leechers"]) {
if (
$variant == "index")
print(
"<td class=rowhead2 align=center>" number_format($row["leechers"]) . "</td>\n");
else
print(
"<td class=rowhead2 align=\"center\">" $row["leechers"] . "</td>\n");
}
else
print(
"<td class=rowhead2 align=\"center\">0</td>\n");

$_s "";
if (
$row["times_completed"] != 1)
$_s "s";
print(
"<td class=rowhead2 align=center>" str_replace(" ""&nbsp;"mksize($row["size"])));

if (
$variant == "index") {
if (
$row["anonymous"] == "yes") {
print(
"<td class=rowhead2 align=center><i>Anonimen</i></td>\n");
}
else {
print(
"<td class=rowhead2 align=center>" . (isset($row["username"]) ? ("<a href=userdetails.php?id=" $row["owner"] . "><b>" htmlspecialchars($row["username"]) . "</b></a>") : "<i>(unknown)</i>") . "</td>\n");
}
}

}

print(
"</tr></table>\n");

return 
$rows;
}

// IPLogger

function iplogger() {
GLOBAL 
$HTTP_SERVER_VARS$CURUSER$iplog2;
if (
$iplog2 == "yes") {
    
$ip getip();
    
$res mysql_query("SELECT * FROM ips WHERE ip = '".mysql_real_escape_string($ip)."' AND userid = ".mysql_real_escape_string($CURUSER[id])) or die(mysql_error());
    if (
mysql_num_rows($res) == ) {
        
mysql_query("INSERT INTO ips(userid, ip) VALUES (".mysql_real_escape_string($CURUSER[id]).", '".mysql_real_escape_string($ip)."')") or die(mysql_error());
        }
        return;
    }
    return;
}


// END IPLogger

function hash_pad($hash) {
    return 
str_pad($hash20);
}

function 
hash_where($name$hash) {
    
$shhash preg_replace('/ *$/s'""$hash);
    return 
"($name = " sqlesc($hash) . " OR $name = " sqlesc($shhash) . ")";
}

function 
get_user_icons($arr$big false)
{
    if (
$big)
    {
        
$donorpic "starbig.gif";
        
$leechwarnpic "warnedbig.gif";
        
$warnedpic "warnedbig3.gif";
        
$disabledpic "disabledbig.gif";
        
$style "style='margin-left: 4pt'";
    }
    else
    {
        
$donorpic "star.gif";
        
$leechwarnpic "warned.gif";
        
$warnedpic "warned3.gif";
        
$disabledpic "disabled.gif";
        
$style "style=\"margin-left: 2pt\"";
    }
    
$pics $arr["donor"] == "yes" "<img src=pic/$donorpic alt='Donor' border=0 $style>" "";
    if (
$arr["enabled"] == "yes")
        
$pics .= ($arr["leechwarn"] == "yes" "<img src=pic/$leechwarnpic alt=\"Leechwarned\" border=0 $style>" "") . ($arr["warned"] == "yes" "<img src=pic/$warnedpic alt=\"Warned\" border=0 $style>" "");
    else
        
$pics .= "<img src=pic/$disabledpic alt=\"Disabled\" border=0 $style>\n";
    return 
$pics;
}
//----------
// Progress Bar Image Generator
//-----------------------------
// Dynamic image created by Dumpy Dooby
// Original code by johim
// ------------------------------------------------
function get_percent_completed_image($p) {
 
$maxpx "45"// Maximum amount of pixels for the progress bar

 
if ($p == 0$progress "<img src=\"pic/progbar-rest.gif\" height=9 width=" . ($maxpx) . " />";
 if (
$p == 100$progress "<img src=\"pic/progbar-green.gif\" height=9 width=" . ($maxpx) . " />";
 if (
$p >= && $p <= 30$progress "<img src=\"pic/progbar-red.gif\" height=9 width=" . ($p*($maxpx/100)) . " /><img src=\"pic/progbar-rest.gif\" height=9 width=" . ((100-$p)*($maxpx/100)) . " />";
 if (
$p >= 31 && $p <= 65$progress "<img src=\"pic/progbar-yellow.gif\" height=9 width=" . ($p*($maxpx/100)) . " /><img src=\"pic/progbar-rest.gif\" height=9 width=" . ((100-$p)*($maxpx/100)) . " />";
 if (
$p >= 66 && $p <= 99$progress "<img src=\"pic/progbar-green.gif\" height=9 width=" . ($p*($maxpx/100)) . " /><img src=\"pic/progbar-rest.gif\" height=9 width=" . ((100-$p)*($maxpx/100)) . " />";
 return 
"<img src=\"pic/bar_left.gif\" />" $progress ."<img src=\"pic/bar_right.gif\" />";
}

//----------
// END Progress Bar Image Generator
//---------------------------------

//---------------------------------
//---- Website Settings v0.2 by xam
//---------------------------------
function ReadConfig ($configname) {
    if (
strstr($configname',')) {
        
$configlist explode(','$configname);
        foreach (
$configlist as $key=>$configname) {
            
ReadConfig(trim($configname));
        }
    } else {
        
$configname basename($configname);
        
$path './config/'.$configname;
        if (!
file_exists($path)) {
            
stderr("ERROR""<font color=red>File [<b>".htmlspecialchars($configname)."</b>] doesn't exist!.</font><br><font color=blue>Before the setup starts, please ensure that you have properly configured file and directory access permissions. Please see below.</font><br><br>chmod 777 CONFIG (config directory).<br>chmod 777 CONFIG/main (the file which save the main settings).",false);
        }
        
$fp fopen($path'r');
        
$content '';
        while (!
feof($fp)) {
            
$content .= fread($fp102400);
        }
        
fclose($fp);
        if (empty(
$content)) {
            if (
$configname == 'XAM') {
                
Header("Location: index.php");                  
                die; 
            }
            return array();
        }
        
$tmp        = @unserialize($content);
        if (empty(
$tmp)) {
            if (
$configname == 'XAM') {
                
Header("Location: index.php");                  
                die;                
            }
            
stderr("ERROR""<font color=red>Cannot read file [<b>".htmlspecialchars($configname)."</b>]!.</font><br><font color=blue>Before the setup starts, please ensure that you have properly configured file and directory access permissions. Please see below.</font><br><br>chmod 777 CONFIG (config directory).<br>chmod 777 CONFIG/main (the file which save the main settings).",false);
        }
        
$GLOBALS[$configname] = $tmp;
        return 
true;
    }
}

function 
WriteConfig ($configname$config) {
    
$configname basename($configname);
    
$path './config/'.$configname;
    if (!
file_exists($path) || !is_writable ($path)) {
        
stdmsg("ERROR""<font color=red>Cannot read file [<b>".htmlspecialchars($configname)."</b>]!.</font><br><font color=blue>Before the setup starts, please ensure that you have properly configured file and directory access permissions. Please see below.</font><br><br>chmod 777 CONFIG (config directory).<br>chmod 777 CONFIG/main (the file which save the main settings).",false);
    }
    
$data = @serialize($config);
    if (empty(
$data)) {
        
stdmsg("ERROR""<font color=red>Cannot serialize file [<b>".htmlspecialchars($configname)."</b>]</font><br><font color=blue>Before the setup starts, please ensure that you have properly configured file and directory access permissions. Please see below.</font><br><br>chmod 777 CONFIG (config directory).<br>chmod 777 CONFIG/main (the file which save the main settings).",false);
    }
    
$fp = @fopen ($path'w');
    if (!
$fp) {
        
stdmsg("ERROR""<font color=red>Cannot open file [<b>".htmlspecialchars($configname)."</b>] to save info!.</font><br><font color=blue>Before the setup starts, please ensure that you have properly configured file and directory access permissions. Please see below.</font><br><br>chmod 777 CONFIG (config directory).<br>chmod 777 CONFIG/main (the file which save the main settings).",false);
    }
    
$Res = @fwrite($fp$data);
    if (empty(
$Res)) {
        
stdmsg("ERROR""<font color=red>Cannot save info in file (error in serialisation) [<b>".htmlspecialchars($configname)."</b>] to save info!.</font><br><font color=blue>Before the setup starts, please ensure that you have properly configured file and directory access permissions. Please see below.</font><br><br>chmod 777 CONFIG (config directory).<br>chmod 777 CONFIG/main (the file which save the main settings).",false);
    }
    
fclose($fp);
    return 
true;
}

function 
GetVar ($name) {
    if ( 
is_array($name) ) {
        foreach (
$name as $varGetVar ($var);
    } else {
        if ( !isset(
$_REQUEST[$name]) )
            return 
false;
        if ( 
get_magic_quotes_gpc() ) {
            
$_REQUEST[$name] = ssr($_REQUEST[$name]);
        }
        
$GLOBALS[$name] = $_REQUEST[$name];
        return 
$GLOBALS[$name];
    }
}

function 
ssr ($arg) {
    if (
is_array($arg)) {
        foreach (
$arg as $key=>$arg_bit) {
            
$arg[$key] = ssr($arg_bit);
        }
    } else {
        
$arg stripslashes($arg);
    }
    return 
$arg;
}
//---------------------------------
//---- Website Settings v0.2 by xam
//---------------------------------

function parked()
{
       global 
$CURUSER;
       if (
$CURUSER["parked"] == "yes")
stderr("Access Denied!""Your account is parked.");
}

function 
quote_smart($value)
{
   
// Stripslashes
   
if (get_magic_quotes_gpc()) {
       
$value stripslashes($value);
   }
   
// Quote if not a number or a numeric string
   
if (!is_numeric($value)) {
       
$value "'" mysql_real_escape_string($value) . "'";
   }
   return 
$value;
}



// MaJerle.Eu started

function tinymce_editor ($id$name$vsebina ""$style "style='width: 600px; height: 250px;'")
{
    
    global 
$CURUSER;
    
    return 
'<script type="text/javascript">
    // Default skin
    tinyMCE.init({
        // General options
        mode : "exact",
        elements : "' 
$id '",
        theme : "simple",
        language : "sl",
        plugins : "safari,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups",

        // Theme options
        theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
        theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
        theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
        theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak",
        theme_advanced_toolbar_location : "top",
        theme_advanced_toolbar_align : "center",
        theme_advanced_statusbar_location : "bottom",
        theme_advanced_resizing : false,

        // Example content CSS (should be your site CSS)
        content_css : "css/content.css",

        // Drop lists for link/image/media/template dialogs
        template_external_list_url : "lists/template_list.js",
        external_link_list_url : "lists/link_list.js",
        external_image_list_url : "lists/image_list.js",
        media_external_list_url : "lists/media_list.js",

        // Replace values for the template plugin
        template_replace_values : {
            username : "' 
$CURUSER["username"] . '",
            staffid : "' 
$CURUSER["id"] . '"
        }
    });
    </script>
    
    <textarea name="' 
$name '" id="' $id '" ' $style '>
    ' 
. (($vsebina != "" && !empty ($vsebina)) ? $vsebina "") . '
    </textarea>'
;

}

function 
userlink ($id$dodatno ""$a_href true)
{
    global 
$BASEURL;
    
$res mysql_query ("SELECT username, class, id FROM users WHERE id = '$id'") or sqlerr ();
    if (
mysql_num_rows ($res) != 1)
    {
        return;
    }
    
    
$row mysql_fetch_array ($res);
    
$return "";
    
    
$link "uporabnik/$id/" strtolower ($row["username"]);
    
    if (
$a_href)
    {
        
$return .= "<a href=\"$BASEURL/$link. (!empty ($dodatno) ? $dodatno "") . "\"><b>";
        
$return .= ($row["username"]);
        
$return .= "</b></a>";
    }
    else
    {
        
$return .= $link;
    }
    
    return 
$return;
}


function 
torrentlink ($id$dodatno "")
{
    global 
$BASEURL;
    
    
$res mysql_query ("SELECT name FROM torrents WHERE id = '$id'") or sqlerr ();
    if (
mysql_num_rows ($res) != 1)
    {
        return;
    }

    
$ime mysql_fetch_array ($res);
    
    
$array1 = array (" ""š""c""ž""Š""C""Ž"".""Đ""d""#"".""+""("")");
    
$array2 = array ("_""s""c""z""S""C""Z""_""DZ""dz""""_""_""""");
    
    
$predelano str_replace ($array1$array2$ime["name"]);
    
    return 
"$BASEURL/torrent/$id/" $predelano . (!empty ($dodatno) ? $dodatno "");
    
}


function 
zanri($category$array = array(), $stolpcev 4)
{
    
$res mysql_query("SELECT * FROM zanri WHERE category = '$category' ORDER BY name ASC") or sqlerr();
    if (
mysql_num_rows($res) > 0)
    {
        
        
$return '<table border="0" cellpadding="3" cellspacing="0" style="background: none; width: 500px;">
            <tr>'
;
        
            
$i 1;
            
$width round(100 $stolpcev);
            while (
$row mysql_fetch_assoc($res))
            {
                
$return .= ('<td style="width: ' $width '%; text-align: left;"><input' . ((in_array($row["id"], $array)) ? ' checked="checked"' "") . ' type="checkbox" name="zanr[]" value="' $row["id"] . '" /> ' sumniki_zamenjaj($row["name"]) . '</td>');
                if (
$i $stolpcev == 0)
                {
                    
$return .= ("</tr><tr>");
                }
                
$i++;
            }      
        
        
$return .= ' </tr>
        </table>'
;
        
    }
    else
    {
        
$return = ("Žanri za to kategorijo ne obstajajo");
    }
    return 
$return;
}

function 
sumniki_zamenjaj($text)
{
    return 
str_replace(array("č""Č""ž""Ž""š""Š"), array("č""Č""ž""Ž""š""Š"), $text);
}

/**
 * Funkcija nastavi visible na on, po možnosti tudi sejalce na 1 če jih torrent nima, ČE je torrent z več sledilniki
 * @param
 * @return true, če je vse vredi :D
 */

function update_sledilniki_torrent()
{
    
$res mysql_query("SELECT visible, id FROM torrents WHERE visible = 'no'") or sqlerr();
    if (
mysql_num_rows($res) == 0)
    {
        return;
    }
    while (
$row mysql_fetch_assoc($res))
    {
        
$updateset = array();
        
/*
        if ($row["visible"] == "no")
        {
            $updateset[] = "visible = 'yes'";
        }
        */
        /*$updateset[] = "visible = 'no'";  */
        
if ((int)$row["seeders"] == 0)
        {
            
$updateset[] = "seeders = 1";
            
$updateset[] = "visible = 'yes'";
        }
        
mysql_query("UPDATE torrents SET " implode(", "$updateset) . " WHERE id = '" $row["id"] . "'") or sqlerr();
    }
    return 
true;
}

function 
viciKategorije($selected false$selectName "kategorija")
{
    
$res mysql_query("SELECT * FROM vici_kategorije ORDER BY name ASC") or sqlerr();
    
$select '<select name="' $selectName '">';
    if (
mysql_num_rows($res) > 0)
    {
        while (
$row mysql_fetch_assoc($res))
        {
            
$select .= '<option value="' $row["id"] . '"' . ($selected == $row["id"] ? ' selected="selected"' '') . '>' $row["name"] . '</option>';
        }
    }
    else
    {
        
$select .= '<option value="">Ni kategorij</option>';
    }
    
$select .= '</select>';
    return 
$select;
}

function 
isAjax()
{
    return (isset(
$_SERVER['HTTP_X_REQUESTED_WITH']) && ($_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest'));
}

function 
pr($array)
{
    print 
'<pre>';
    
print_r($array);
    print 
'</pre>';
}

// MaJerle.Eu ended 

?>
What i is there wrong? i really don't know.. in any of you can view this little..it's will be great..
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 16:17. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.