<?
### Версия ПО (ДМ) 1.0.0.0 ( (c)2018 MISOFT Продукт защищен регистрацией патента и авторских прав! www.misoft.studio )
######################################################################################################################
  
  if ( $_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest' ) {
    define( 'ROOT_DIR', $_SERVER['DOCUMENT_ROOT'] );
    session_start();
    header( 'Content-type: text/html; charset=windows-1251' );
    include_once ROOT_DIR . '/engine/config.php';
    include_once ROOT_DIR . '/engine/function.php';
  } else {
    if ( !defined( 'MISOFT' ) ) { exit(); }
  }
  
  #Обявляем класс ксс активной/не активной кнопки  
  $url_page = $_SERVER['REQUEST_URI'];
  $page_active_e = 'class="content_bar_buttom1_act"';
  $page_pasive_e = 'class="content_bar_buttom"';
  
  #Определяем страну 
  $regcode = find_country();
  
  #Считаем количество серфинг ссылок
  $quantity_dyn = mysql_fetch_array( mysql_query( "SELECT COUNT(id) as count FROM dynlink t1  WHERE t1.paused = 1 and t1.plus = 0 and NOT EXISTS ( SELECT ident, iduser FROM dynlink_temp t2 WHERE t1.id = t2.ident and t2.iduser = '" . $_SESSION['iduser'] . "' ) and id IN (SELECT id FROM dynlink WHERE geo_ru = '".$regcode."' OR geo_ua = '".$regcode."' OR geo_by = '".$regcode."' OR geo_kz = '".$regcode."' OR geo_ge = '".$regcode."' OR geo_md = '".$regcode."' OR geo_am = '".$regcode."' OR geo_tj = '".$regcode."' OR geo_az = '".$regcode."' OR geo_uz = '".$regcode."' OR geo_pt = '".$regcode."' OR geo_es = '".$regcode."' OR geo_ee = '".$regcode."' OR geo_lv = '".$regcode."' OR geo_lt = '".$regcode."' OR geo_us = '".$regcode."' OR geo_gb = '".$regcode."' OR geo_fr = '".$regcode."' OR geo_de = '".$regcode."' OR geo_cn = '".$regcode."' OR geo_it = '".$regcode."' OR geo_all = '".$regcode."') ORDER BY t1.vip DESC, t1.timer DESC, t1.date DESC" ) );
  
  #Считаем количество авто-серфинг ссылок
  $quantity_autodyn = mysql_fetch_array( mysql_query( "SELECT COUNT(id) as count FROM autodynlink t1  WHERE t1.paused = 1 and NOT EXISTS ( SELECT ident FROM autodynlink_temp t2 WHERE t1.id = t2.ident and t2.iduser = '" . $_SESSION['iduser'] . "' ) and NOT EXISTS ( SELECT ident FROM autoserf_ban_url t3 WHERE t1.id = t3.ident and t3.iduser = '" . $_SESSION['iduser'] . "' ) and id IN (SELECT id FROM autodynlink WHERE geo_ru = '".$regcode."' OR geo_ua = '".$regcode."' OR geo_by = '".$regcode."' OR geo_kz = '".$regcode."' OR geo_ge = '".$regcode."' OR geo_md = '".$regcode."' OR geo_am = '".$regcode."' OR geo_tj = '".$regcode."' OR geo_az = '".$regcode."' OR geo_uz = '".$regcode."' OR geo_pt = '".$regcode."' OR geo_es = '".$regcode."' OR geo_ee = '".$regcode."' OR geo_lv = '".$regcode."' OR geo_lt = '".$regcode."' OR geo_us = '".$regcode."' OR geo_gb = '".$regcode."' OR geo_fr = '".$regcode."' OR geo_de = '".$regcode."' OR geo_cn = '".$regcode."' OR geo_it = '".$regcode."' OR geo_all = '".$regcode."') LIMIT 1" ) );
  
  #Считаем количество тестов
  $quantity_tests = mysql_fetch_array( mysql_query( "SELECT COUNT(id) as count FROM tests t1 WHERE t1.paused = 1 and t1.balance > '" . $config['tests'] . "' and NOT EXISTS ( SELECT ident, iduser FROM tests_temp t2 WHERE t1.id = t2.ident and t2.iduser = '" . $_SESSION['iduser'] . "') and id IN (SELECT id FROM tests WHERE geo_ru = '".$regcode."' OR geo_ua = '".$regcode."' OR geo_by = '".$regcode."' OR geo_kz = '".$regcode."' OR geo_ge = '".$regcode."' OR geo_md = '".$regcode."' OR geo_am = '".$regcode."' OR geo_tj = '".$regcode."' OR geo_az = '".$regcode."' OR geo_uz = '".$regcode."' OR geo_pt = '".$regcode."' OR geo_es = '".$regcode."' OR geo_ee = '".$regcode."' OR geo_lv = '".$regcode."' OR geo_lt = '".$regcode."' OR geo_us = '".$regcode."' OR geo_gb = '".$regcode."' OR geo_fr = '".$regcode."' OR geo_de = '".$regcode."' OR geo_cn = '".$regcode."' OR geo_it = '".$regcode."' OR geo_all = '".$regcode."') ORDER BY id DESC" ) );
  
  #Считаем количество оплачиваемых заданий
  $quantity_task = mysql_fetch_array( mysql_query( "SELECT COUNT(id) as count FROM tasks t1 WHERE t1.paused = 1 and t1.balance >= (t1.t_wait + t1.t_work ) * t1.price  / '" . $config['factor'] . "' + t1.price  / '" . $config['factor'] . "' - 0.02 and NOT EXISTS(SELECT ident, iduser, status, startdate FROM tasks_temp t2 WHERE (t2.ident = t1.id and t2.status in (1,4) and t1.many in (1) and t2.startdate + executionTime > '" . time() . "' and t2.iduser = '" . $_SESSION['iduser'] . "') or (t2.ident = t1.id and t2.status in (1) and t1.many in (0) and t2.iduser = '" . $_SESSION['iduser'] . "') ) and id IN (SELECT id FROM tasks WHERE geo_ru = '".$regcode."' OR geo_ua = '".$regcode."' OR geo_by = '".$regcode."' OR geo_kz = '".$regcode."' OR geo_ge = '".$regcode."' OR geo_md = '".$regcode."' OR geo_am = '".$regcode."' OR geo_tj = '".$regcode."' OR geo_az = '".$regcode."' OR geo_uz = '".$regcode."' OR geo_pt = '".$regcode."' OR geo_es = '".$regcode."' OR geo_ee = '".$regcode."' OR geo_lv = '".$regcode."' OR geo_lt = '".$regcode."' OR geo_us = '".$regcode."' OR geo_gb = '".$regcode."' OR geo_fr = '".$regcode."' OR geo_de = '".$regcode."' OR geo_cn = '".$regcode."' OR geo_it = '".$regcode."' OR geo_all = '".$regcode."') and id in (SELECT id FROM tasks WHERE (TimeoutInExecution = '0') or (TimeoutInExecution > '0' and TimeoutResidue > '0')) and id in (SELECT id FROM tasks WHERE (nextExecutionOn = '0') or (nextExecutionOn > '0' and nextExecution + nextExecutionOn < '".time()."')) and id in (SELECT id FROM tasks WHERE (openReyting = '0') or (openReyting > '0' and openReyting <= '".$config_user['reyting']."')) and id in (SELECT id FROM tasks WHERE (openWmid = '0') or (openWmid = '1' and openWmid < '".$config_user['wmid']."'))" ) );
  
  
?>

  <div style="margin-left: -10px; margin-bottom: -2px;">
    <a href="/serfing" <? if ($url_page == '/serfing' ) { echo $page_active_e; } else { echo $page_pasive_e; } ?> >СЕРФИНГ <font class="serf_border"><?=$quantity_dyn['count']?></font></a>
    <a href="/auto_serfing" <? if ( strpos( $url_page, 'auto_serfing' ) ) { echo $page_active_e; } else { echo $page_pasive_e; } ?> >АВТО СЕРФИНГ <span class="autoserf_border"><?=$quantity_autodyn['count']?></span></a>
    <a href="/tests" <? if ( strpos( $url_page, 'tests' ) ) { echo $page_active_e; } else { echo $page_pasive_e; } ?> >ТЕСТЫ <span class="test_border"><?=$quantity_tests['count']?></span></a>
    <a href="/tasks" <? if ( strpos( $url_page, 'tasks' ) ) { echo $page_active_e; } else { echo $page_pasive_e; } ?> >ЗАДАНИЯ <span class="task_border"><?=$quantity_task['count']?></span></a>
    <a href="/vkontakte" <? if ( strpos( $url_page, 'vkontakte' ) ) { echo $page_active_e; } else { echo $page_pasive_e; } ?> >VK <span class="vk_border">0</span></a>
    <a href="/youtube" <? if ( strpos( $url_page, 'youtube' ) ) { echo $page_active_e; } else { echo $page_pasive_e; } ?> >YOUTUBE <span class="youtube_border">0</span></a>
  </div>