<?
/*
=====================================================
 Volkov NET!! - by SaNcHeS Group 
-----------------------------------------------------
 http://AllForCS.RU/
-----------------------------------------------------
 Copyright (c) 2009 SaNcHeS Group
=====================================================
 Данный код защищен авторскими правами
=====================================================
 Файл: test.php
-----------------------------------------------------
 Назначение: Тестирование
=====================================================
*/

  function get_dir ($mp3_number)
  {
    $mp3_number = $mp3_number / 100;
    list ($mp3_number, $dr) = explode ('.', $mp3_number);
    return $mp3_number;
  }

  function unsafe_str ($string)
  {
    $string = ereg_replace ('&quot_;', '\'', $string);
    return $string;
  }

  function get2tag ($number)
  {
    global $ARTIST;
    global $TRACK;
    global $SIZE;
    global $UPLOADER;
    global $DATE;
    global $ACTIVE;
    global $NOTICE;
    global $WWW;
    global $MP3_DOWNLOAD_LINK;
    global $RAR_DOWNLOAD_LINK;
    global $ZIP_DOWNLOAD_LINK;
    global $EXE_DOWNLOAD_LINK;
    global $KBPS_8_DOWNLOAD_LINK;
    global $MP3_VIEWER_LINK;
    global $MP3_COMMENTS;
    global $KEYWORDS;
    global $ID;
    $sql = @mysql_query ('SELECT * FROM `m3_mp3` WHERE `id` = \'' . $number . '\'');
    if (($sql AND 0 < @mysql_num_rows ($sql)))
    {
      while ($row = @mysql_fetch_array ($sql, MYSQL_ASSOC))
      {
        $MP3_VIEWER_LINK = $WWW . 'pages/' . get_dir ($number) . '/' . $number . '.shtml';
        $MP3_DOWNLOAD_LINK = unsafe_str ($WWW . 'download.php?id=' . $number . '&ass=' . trancelit ($row['artist'] . '_-_' . $row['track']) . '.mp3');
        $RAR_DOWNLOAD_LINK = unsafe_str ($WWW . 'download.php?id=' . $number . '&ass=' . trancelit ($row['artist'] . '_-_' . $row['track']) . '.rar');
        $ZIP_DOWNLOAD_LINK = unsafe_str ($WWW . 'download.php?id=' . $number . '&ass=' . trancelit ($row['artist'] . '_-_' . $row['track']) . '.zip');
        $EXE_DOWNLOAD_LINK = unsafe_str ($WWW . 'download.php?id=' . $number . '&ass=' . trancelit ($row['artist'] . '_-_' . $row['track']) . '.exe');
        $KBPS_8_DOWNLOAD_LINK = unsafe_str ($WWW . 'download.php?id=' . $number . '&kbps=8');
        $MP3_COMMENTS = 'javascript:na_open_window(\'comments\', \'' . $WWW . 'comments.php?id=' . $number . '\', 100, 100, 500, 400, 0, 0, 0, 0, 0)';
        $ARTIST = unsafe_str ($row['artist']);
        $TRACK = unsafe_str ($row['track']);
        $SIZE = $row['size'];
        $UPLOADER = $row['uploader'];
        $DATE = $row['date'];
        $ACTIVE = $row['active'];
        $NOTICE = $row['notice'];
        $ID = $row['id'];
      }
    }

    return $ACTIVE;
  }

  function tag2html ($content, $param)
  {
    global $ARTIST;
    global $TRACK;
    global $SIZE;
    global $UPLOADER;
    global $DATE;
    global $ACTIVE;
    global $NOTICE;
    global $WWW;
    global $NEW_MP3;
    global $TOP_MP3;
    global $NAV;
    global $B100X100;
    global $VOITE;
    global $COUNTER;
    global $TXTBANNER;
    global $B468X60;
    global $ADMIN_MAIL;
    global $ADMIN_ICQ;
    global $GUEST_DATA;
    global $ABOUT_DATA;
    global $TITLE;
    global $KBPS_8_DOWNLOAD_LINK;
    global $MP3_COMMENTS;
    global $MP3_VIEWER_LINK;
    global $MP3_DOWNLOAD_LINK;
    global $RAR_DOWNLOAD_LINK;
    global $ZIP_DOWNLOAD_LINK;
    global $EXE_DOWNLOAD_LINK;
    global $WWW_TEMPLATE;
    global $ADMIN_ICQ;
    global $ADMIN_MAIL;
    global $KEYWORDS;
    global $JS_POPUP;
    global $LIST_DATA;
    global $WWW_TITLE;
    global $THIS_GUEST;
    global $THIS_ABOUT;
    global $SEARCH_DATA;
    global $ID;
    if ($param == 'search')
    {
      $NEW_MP3 = '<? include("./html/new.html"); ?>';
      $TOP_MP3 = '<? include("./html/top.html"); ?>';
      $NAV = '<? include("./html/nav.html"); ?>';
      $B100X100 = '<? include("./html/100x100.html"); ?>';
      $VOITE = '<? include("./html/voite.html"); ?>';
      $COUNTER = '<? include("./html/count.html"); ?>';
      $SEARCH_DATA = '<? include("./inc/search.php"); ?>';
      $GUEST_DATA = '<? include("./inc/guest.php"); ?>';
    }
    else
    {
      $NEW_MP3 = '<!--#include virtual="' . $param . 'html/new.html" -->';
      $TOP_MP3 = '<!--#include virtual="' . $param . 'html/top.html" -->';
      $NAV = '<!--#include virtual="' . $param . 'html/nav.html" -->';
      $B100X100 = '<!--#include virtual="' . $param . 'html/100x100.html" -->';
      $VOITE = '<!--#include virtual="' . $param . 'html/voite.html" -->';
      $COUNTER = '<!--#include virtual="' . $param . 'html/count.html" -->';
      $TXTBANNER = '<!--#include virtual="' . $param . 'html/txtbanner.html" -->';
      $B468X60 = '<!--#include virtual="' . $param . 'html/468x60.html" -->';
      $ABOUT_DATA = '<!--#include virtual="' . $param . 'html/about.html" -->';
    }

    $WWW_TEMPLATE = $WWW . 'template/';
    $content = str_replace ('[ARTIST]', $ARTIST, $content);
    $content = str_replace ('[ICQ]', $ADMIN_ICQ, $content);
    $content = str_replace ('[ADMIN_MAIL]', $ADMIN_MAIL, $content);
    $content = str_replace ('[TRACK]', $TRACK, $content);
    $content = str_replace ('[UPLOADER]', $UPLOADER, $content);
    $content = str_replace ('[DATE]', $DATE, $content);
    $content = str_replace ('[ID]', $ID, $content);
    $content = str_replace ('[ACTIVE]', $ACTIVE, $content);
    $content = str_replace ('[NOTICE]', $NOTICE, $content);
    $content = str_replace ('[WWW]', $WWW, $content);
    $content = str_replace ('[WWW_TEMPLATE]', $WWW_TEMPLATE, $content);
    $content = str_replace ('[WWW_TITLE]', $WWW_TITLE, $content);
    $content = str_replace ('[NEW_MP3]', $NEW_MP3, $content);
    $content = str_replace ('[TOP_MP3]', $TOP_MP3, $content);
    $content = str_replace ('[NAV]', $NAV, $content);
    $content = str_replace ('[100X100]', $B100X100, $content);
    $content = str_replace ('[VOITE]', $VOITE, $content);
    $content = str_replace ('[COUNTER]', $COUNTER, $content);
    $content = str_replace ('[TXTBANNER]', $TXTBANNER, $content);
    $content = str_replace ('[468X60]', $B468X60, $content);
    $content = str_replace ('[ADMIN_MAIL]', $ADMIN_MAIL, $content);
    $content = str_replace ('[ADMIN_ICQ]', $ADMIN_ICQ, $content);
    if (($THIS_GUEST == 1 OR $THIS_GUEST == 2))
    {
      $content = str_replace ('[DATA]', $GUEST_DATA, $content);
    }

    if ($THIS_ABOUT == 1)
    {
      $content = str_replace ('[DATA]', $ABOUT_DATA, $content);
    }

    if ($param == 'search')
    {
      $content = str_replace ('[DATA]', $SEARCH_DATA, $content);
      $SEARCH_DATA = '';
    }

    $content = str_replace ('[LIST_DATA]', $LIST_DATA, $content);
    $content = str_replace ('[TITLE]', $TITLE, $content);
    $content = str_replace ('[8KBPS_LINK]', $KBPS_8_DOWNLOAD_LINK, $content);
    $content = str_replace ('[MP3_COMMENTS]', $MP3_COMMENTS, $content);
    $content = str_replace ('[MP3_VIEWER_LINK]', $MP3_VIEWER_LINK, $content);
    if ($NOTICE != '')
    {
      $content = str_replace ('[MP3_DOWNLOAD_LINK]', $NOTICE, $content);
      $fp = fopen ($NOTICE, 'r');
      $inf = stream_get_meta_data ($fp);
      fclose ($fp);
      foreach ($inf['wrapper_data'] as $v)
      {
        if (stristr ($v, 'content-length'))
        {
          $v = explode (':', $v);
          break;
        }
      }

      $blya = (int)@trim ($v[1]) / 1024;
      $blya = $blya / 1024;
      list ($mb, $kb) = @explode ('.', $blya);
      $kb = @substr ($kb, 0, 2);
      if ($kb == '')
      {
        $kb = '00';
      }

      $blyxa = $mb . '.' . $kb . ' Mb';
      $SIZE = $blyxa;
    }
    else
    {
      $content = str_replace ('[MP3_DOWNLOAD_LINK]', $MP3_DOWNLOAD_LINK, $content);
    }

    $content = str_replace ('[SIZE]', $SIZE, $content);
    $content = str_replace ('[RAR_DOWNLOAD_LINK]', $RAR_DOWNLOAD_LINK, $content);
    $content = str_replace ('[ZIP_DOWNLOAD_LINK]', $ZIP_DOWNLOAD_LINK, $content);
    $content = str_replace ('[EXE_DOWNLOAD_LINK]', $EXE_DOWNLOAD_LINK, $content);
    $K_TMP = $KEYWORDS;
    $KEYWORDS = $KEYWORDS . ', ' . $ARTIST . ' - ' . $TRACK . ' mp3';
    $content = str_replace ('[KEYWORDS]', $KEYWORDS, $content);
    $KEYWORDS = $K_TMP;
    $content = str_replace ('[JS_POPUP]', $JS_POPUP, $content);
    return $content;
  }

  function safe_str ($string)
  {
    $string = str_replace ('


', '', $string);
    $string = str_replace ('<', '&lt;', $string);
    $string = str_replace ('>', '&gt;', $string);
    $string = str_replace ('"', '&quot;', $string);
    $string = str_replace ('\'', '&quot_;', $string);
    $string = str_replace ('
', '', $string);
    $string = str_replace ('
', '<br>', $string);
    $string = str_replace ('%', '&#37;', $string);
    $string = str_replace ('!', '&#33;', $string);
    $string = str_replace ('^ +', '', $string);
    $string = str_replace ('' . ' +$', '', $string);
    $string = str_replace (' +', ' ', $string);
    $string = str_replace ('|', 'l', $string);
    return $string;
  }

  function safe_login ($string)
  {
    $safe = 1;
    if (strstr ($string, '
'))
    {
      $safe = 0;
    }

    if (strstr ($string, '
'))
    {
      $safe = 0;
    }

    if (strstr ($string, '<'))
    {
      $safe = 0;
    }

    if (strstr ($string, '>'))
    {
      $safe = 0;
    }

    if (strstr ($string, '"'))
    {
      $safe = 0;
    }

    if (strstr ($string, '\''))
    {
      $safe = 0;
    }

    if (strstr ($string, '%'))
    {
      $safe = 0;
    }

    if (strstr ($string, '^ +'))
    {
      $safe = 0;
    }

    if (strstr ($string, '' . ' +$'))
    {
      $safe = 0;
    }

    if (strstr ($string, ' +'))
    {
      $safe = 0;
    }

    if (strstr ($string, '|'))
    {
      $safe = 0;
    }

    return $safe;
  }

  function long_detector ($my_text, $max_len)
  {
    $res = explode (' ', $my_text);
    for ($i = 0; $i < count ($res); ++$i)
    {
      $all_ok .= wordwrap (pos ($res), $max_len, ' ', 1) . ' ';
      next ($res);
    }

    return $all_ok;
  }

  function remove_all ($dir)
  {
    if (!$dir)
    {
      return null;
    }

    $d = @opendir ($dir);
    while ($e = readdir ($d) !== false)
    {
      if ((($e == '.' OR $e == '..') OR !$e))
      {
        continue;
      }
      else
      {
        unlink ($dir . '/' . $e);
        continue;
      }
    }

    @rmdir ($dir);
    @closedir ($dir);
    @opendir ('./');
  }

  function makepass ($length)
  {
    $possible = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $str = '';
    while (strlen ($str) < $length)
    {
      $str .= $possible[rand (0, 61)];
    }

    return $str;
  }

  function trancelit ($rus2eng)
  {
    $rus2eng = strtolower ($rus2eng);
    $rus2eng = str_replace ('&quot;', '', $rus2eng);
    $rus2eng = str_replace ('&bdquo;', '', $rus2eng);
    $rus2eng = str_replace ('&ldquo;', '', $rus2eng);
    $rus2eng = str_replace ('&laquo;', '', $rus2eng);
    $rus2eng = str_replace ('&raquo;', '', $rus2eng);
    $rus2eng = str_replace ('&gt;', '', $rus2eng);
    $rus2eng = str_replace ('&lt;', '', $rus2eng);
    $rus2eng = str_replace ('&amp;', 'and', $rus2eng);
    $rus2eng = str_replace ('&', 'and', $rus2eng);
    $rus2eng = str_replace ('%', '', $rus2eng);
    $rus2eng = str_replace ('^', '', $rus2eng);
    $rus2eng = str_replace (('' . '$'), '', $rus2eng);
    $rus2eng = str_replace ('#', '', $rus2eng);
    $rus2eng = str_replace ('@', '', $rus2eng);
    $rus2eng = str_replace ('~', '', $rus2eng);
    $rus2eng = str_replace ('/', '', $rus2eng);
    $rus2eng = str_replace ('\\', '', $rus2eng);
    $rus2eng = str_replace (' ', '_', $rus2eng);
    $rus2eng = str_replace ('*', '', $rus2eng);
    $rus2eng = str_replace ('?', '', $rus2eng);
    $rus2eng = str_replace ('|', '', $rus2eng);
    $rus2eng = str_replace (':', '', $rus2eng);
    $rus2eng = str_replace ('\\\'', '', $rus2eng);
    $rus2eng = str_replace ('"', '', $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?', $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, '?, $rus2eng);
    $rus2eng = str_replace ('?, 'y', $rus2eng);
    $rus2eng = str_replace ('?, 'c', $rus2eng);
    $rus2eng = str_replace ('?, 'u', $rus2eng);
    $rus2eng = str_replace ('?, 'k', $rus2eng);
    $rus2eng = str_replace ('?, 'e', $rus2eng);
    $rus2eng = str_replace ('?, 'n', $rus2eng);
    $rus2eng = str_replace ('?, 'g', $rus2eng);
    $rus2eng = str_replace ('?, 'sh', $rus2eng);
    $rus2eng = str_replace ('?, 'sh', $rus2eng);
    $rus2eng = str_replace ('?, 'z', $rus2eng);
    $rus2eng = str_replace ('?, 'h', $rus2eng);
    $rus2eng = str_replace ('?, '', $rus2eng);
    $rus2eng = str_replace ('?, '', $rus2eng);
    $rus2eng = str_replace ('?, 'f', $rus2eng);
    $rus2eng = str_replace ('?, 'i', $rus2eng);
    $rus2eng = str_replace ('?, 'i', $rus2eng);
    $rus2eng = str_replace ('?', 'ya', $rus2eng);
    $rus2eng = str_replace ('?, 'v', $rus2eng);
    $rus2eng = str_replace ('?, 'a', $rus2eng);
    $rus2eng = str_replace ('?, 'p', $rus2eng);
    $rus2eng = str_replace ('?, 'r', $rus2eng);
    $rus2eng = str_replace ('?, 'o', $rus2eng);
    $rus2eng = str_replace ('?, 'l', $rus2eng);
    $rus2eng = str_replace ('?, 'd', $rus2eng);
    $rus2eng = str_replace ('?, 'zh', $rus2eng);
    $rus2eng = str_replace ('?, 'e', $rus2eng);
    $rus2eng = str_replace ('?, 'e', $rus2eng);
    $rus2eng = str_replace ('?, 'ch', $rus2eng);
    $rus2eng = str_replace ('?, 's', $rus2eng);
    $rus2eng = str_replace ('?, 'm', $rus2eng);
    $rus2eng = str_replace ('?, 't', $rus2eng);
    $rus2eng = str_replace ('?, 'b', $rus2eng);
    $rus2eng = str_replace ('?, 'iu', $rus2eng);
    return $rus2eng;
  }


  $LICENCED = 'macromusic.net';
  $nvv = strtolower ($_SERVER['HTTP_HOST']);
  if (!strstr ($nvv, $LICENCED))
  {
    print 'Error key file. Unregistred copy.';
    exit ();
  }

  $JS_POPUP = '<script language="JavaScript">
<!--
function na_open_window(name, url, left, top, width, height, toolbar, menubar, statusbar, scrollbar, resizable)
{
  toolbar_str = toolbar ? \'yes\' : \'no\';
  menubar_str = menubar ? \'yes\' : \'no\';
  statusbar_str = statusbar ? \'yes\' : \'no\';
  scrollbar_str = scrollbar ? \'yes\' : \'no\';
  resizable_str = resizable ? \'yes\' : \'no\';
  window.open(url, name, \'left=\'+left+\',top=\'+top+\',width=\'+width+\',height=\'+height+\',toolbar=\'+toolbar_str+\',menubar=\'+menubar_str+\',status=\'+statusbar_str+\',scrollbars=\'+scrollbar_str+\',resizable=\'+resizable_str);
}
// -->
</script>';
?>