uid == 1 || $user->uid == 36 || $user->uid == 357325) { print "
\n";
    foreach(func_get_args() as $a) {
      print_r($a);
      print ', ';
    }
    print "\n";
    debug_print_backtrace();  
	die;
  } else {
    liblogtrace('stop');
  }
}

// выдаёт, новый пользователь или давно зарегистрировался (сейчас 2 дня)
function IsNewUser() {
  Global $user; 
  if (!$user->uid) return 1;
  if (libprofit() > 10) return 0;
  return REQUEST_TIME - $user->created < 24*60*60*42;
}

function uid() { return $GLOBALS['user']->uid ?? 0;}
function SuperUser() { return uid() == 1; }
function notheme() {return 0;}
function liblog(...$args) {
  $s = array_reduce($args, function($r, $v) { return $r.' '.print_r($v, 1);});
  if (strpos($s, "::loadHTML():")) return;
  if (strlen($s) > 49999) $s = "VERY LONG STRING: ".substr($s, 0, 9999);
  $sub = substr($s, 0, 50);	
  if ($sub == apc_fetch("LibLogLastLine")) return;	
  apc_store("LibLogLastLine", $sub);
  if (!$space = apc_fetch("FreeLogSpace")) {
	$space = disk_free_space("/log")/1024/1024/1024;
    apc_store("FreeLogSpace", $space, 50);
	file_put_contents("/log/lib.log", $space."G\n", FILE_APPEND);
	if ($space < 0.1) file_put_contents("Файл переполнен и обновлён\n");
  }	  
  file_put_contents("/log/lib.log", $_SERVER['REQUEST_URI']." $s\n", FILE_APPEND);
}
function liblogtrace($s) {	  
  liblog($s);
//  if (SuperUser()) 
    if (apc_fetch("FreeLogSpace") > 1)	  
	  liblog(debug_backtrace(FALSE, 10));
}

// Относительный уровень нагрузки: до 1 - сервер свободен, 1-2 - загружен, больше 2 - сильно загружен.
function LA() {
  static $LoadAvg;
  if ($LoadAvg || ($LoadAvg = apc_fetch('LoadAvg'))) return $LoadAvg;
  list($la1) = explode(' ', file_get_contents("/proc/loadavg"));
  $LoadAvg = $la1/5;
  apc_store('LoadAvg', $LoadAvg, 50);
  return $LoadAvg;
}

function libramka($t, $r, $c = 'collapsed') {
  drupal_add_js('misc/form.js');
  drupal_add_js('misc/collapse.js'); 
  if ($c) $c = 'collapsed';  
  else $c = '';  
  if ($r) return <<
$t
$r
END; } function time_log() { $tm = time() - REQUEST_TIME; if ($tm > 1) { db_insert('time_log')->fields(['delay' => $tm, 'ip' => ip2long(ip_address()), 'uid'=>uid(), 'arg' => arg(0), 'uri' => substr($_SERVER['REQUEST_URI'], 0, 32), 'host' => $_SERVER['HTTP_HOST']])->execute(); } } define('DRUPAL_ROOT', '/www'); require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; //require_once DRUPAL_ROOT . '/modules/librusec/librusec.module'; drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); if (isset($_GET['flush'])) drupal_flush_all_caches(); libxml_use_internal_errors(); if (isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) user_authenticate(array('name' => $_SERVER['PHP_AUTH_USER'], 'pass' => $_SERVER['PHP_AUTH_PW'])); module_load_include('inc', 'librusec'); if ($PROXY) { if (!user_has_role(3) && !user_has_role(6)) if (arg(0) != 'user') $_GET['q'] = 'user'; } elseif ($_SERVER['HTTP_HOST'] == 'librusec.online') { if (!uid() && arg(0) != 'user') $_GET['q'] = 'user'; } /*elseif (strpos($_SERVER['HTTP_HOST'], 'lib.rus.ec')) { if (libprofit() < 100) { if (isset($_COOKIE['SESS037adc0cfbafeba07501b8f84d67450l'])) setcookie('SESS037adc0cfbafeba07501b8f84d67450l', '', 1); } else { setcookie('SESS037adc0cfbafeba07501b8f84d67450l', 'TcwDhcqkdUAkIoGdZbuNCeEL0g9gpEFu', REQUEST_TIME + 99999); } } */ register_shutdown_function('time_log'); menu_execute_active_handler();