uNknownMark
Постоялец
- Регистрация
- 22 Сен 2007
- Сообщения
- 393
- Реакции
- 170
Как то так:
PHP:
<?php
$root = $_ENV['DOCUMENT_ROOT'] . '/';
define('ROOT', $root);
$sk = new skclass();
$tpl = new template();
$skinscript = $_ENV["SCRIPT_NAME"];
$datecheck = 'MS_89475' . date('n') . '8973434254080808880077700134' . date('y') . '300344' . date('m') . '3204983240000234';
$datecheckMes = 'MS_4566' . date('W') . '456077700768880077700134' . date('y') . '300344' . date('nm') . '328808820082978434';
if ($configPath = $sk->getconfigpath()) {
if ($checkkey = $sk->openfile($configPath . "lichash")) {
list($lastcheck, $lastfail) = explode('__', $checkkey);
if ($lastcheck != $datecheck) {
$mustcheck = true;
}
} else {
$mustcheck = true;
}
} else {
$mustcheck = true;
}
$configPath = $sk->getconfigpath();
$key_path = $configPath . "key.php";
if (strstr($skinscript, "CMD_PLUGIN") || ($skinscript == "/CMD_SKINS") || ($skinscript == "/HTM_MSDEBUG") || strstr($skinscript, "HTM_INVALID_LICENCE") || ($_ENV["USER"] == "admin" && $skinscript == "/")) {
$dontcheck = 1;
} else {
if ($mustcheck == true) {
$key = $sk->openfile($configPath . "license");
$lic_status = checkLicence($key);
if ($lic_status['status'] != "active") {
$urlStatus = $lic_status['status'] . "|||" . $lic_status['message'] . "|||" . $lic_status['adminmsg'];
$urlStatus = urlencode(base64_encode($urlStatus));
echo '<script language="JavaScript" type="text/javascript">window.location=\'/HTM_INVALID_LICENCE?status=' . $urlStatus . '\';</script>';
echo '<META HTTP-EQUIV="refresh" CONTENT="0; url=/HTM_INVALID_LICENCE?status=' . $urlStatus . '">';
} else {
$sk->whitefile($datecheck, $configPath . "lichash");
@chmod($path . "lichash", 0777);
$checklocalkey = $sk->openfile($configPath . "lklichash");
if ($checklocalkey != $datecheckMes) {
if ($keyphp = getLocalKey($key)) {
$sk->whitefile($datecheckMes, $configPath . "lklichash");
@chmod($path . "lklichash", 0777);
$sk->whitefile($keyphp, $configPath . "key.php");
@chmod($path . "key.php", 0777);
}
}
}
}
}
function checkLicence($license)
{
$servers = array();
$servers[] = 'http://licencias.outservicesa.net/license_server';
$servers[] = 'http://us.licencias.outservices.net/license_server';
$installed_directory = "/license_server";
$installed_host = "http://licencias.outservices.net";
list($license_type, $xx) = explode('_', $license);
$product_id = 9999;
if ($license_type == "MSA")
$product_id = 15;
if ($license_type == "MSF")
$product_id = 16;
if ($license_type == "MS2A")
$product_id = 17;
if ($license_type == "MSLT")
$product_id = 27;
$enable_dns_spoof = 'yes';
$query_string = "license=" . $license . "&product_id=" . $product_id . "&access_ip=" . server_addr() . "&access_host=" . $_SERVER['HTTP_HOST'] . '&access_token=' . $token = make_token();
foreach ($servers as $server) {
$sinfo = @parse_url($server);
$data = phpaudit_exec_socket($sinfo['host'], $sinfo['path'], '/validate_internal.php', $query_string);
if (!$data)
$data = @file_get_contents($installed_host . $installed_directory . "/validate_internal.php?" . $query_string);
if ($data) {
$parser = xml_parser_create('');
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
xml_parse_into_struct($parser, $data, $values, $tags);
xml_parser_free($parser);
$returned = $values[0]['attributes'];
if ($returned['status']) {
break;
}
}
}
$skip_dns_spoof = false;
if (!$data) {
$array['per_server'] = $per_server;
$array['per_install'] = $per_install;
$array['per_site'] = $per_site;
$data = validate_local_key($array);
$skip_dns_spoof = true;
}
$parser = @xml_parser_create('');
@xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
@xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
@xml_parse_into_struct($parser, $data, $values, $tags);
@xml_parser_free($parser);
$returned = $values[0]['attributes'];
if (empty($returned)) {
$returned['status'] = "invalid";
}
if ($returned['status'] != "active") {
$sinfo = @parse_url($servers[0]);
}
unset($query_string);
unset($per_server);
unset($per_install);
unset($per_site);
unset($server);
unset($data);
unset($parser);
unset($values);
unset($tags);
unset($sinfo);
unset($token);
return $returned;
}
function make_token()
{
return md5('fde6c53b6ffd106d7aba038a349b5575' . time());
}
function get_key()
{
global $localKeyPath;
$data = @file($localKeyPath);
if (!$data) {
return false;
}
$buffer = false;
foreach ($data as $line) {
$buffer .= $line;
}
if (!$buffer) {
return false;
}
$buffer = @str_replace("<?PHP", "", $buffer);
$buffer = @str_replace("?>", "", $buffer);
$buffer = @str_replace("/*--", "", $buffer);
$buffer = @str_replace("--*/", "", $buffer);
return @str_replace("\n", "", $buffer);
}
function parse_local_key()
{
global $localKeyPath;
if (!@file_exists($localKeyPath)) {
return false;
}
$raw_data = @base64_decode(get_key());
$raw_array = @explode("|", $raw_data);
if (@is_array($raw_array) && @count($raw_array) < 8) {
return false;
}
return $raw_array;
}
function validate_local_key($array)
{
$raw_array = parse_local_key();
if (!@is_array($raw_array) || $raw_array === false)
return "<verify status='invalid_key' message='Please contact support for a new license key.' />";
if ($raw_array[9] && @strcmp(@md5("fde6c53b6ffd106d7aba038a349b5575" . $raw_array[9]), $raw_array[10]) != 0)
return "<verify status='invalid_key' message='Please contact support for a new license key.' />";
if (@strcmp(@md5("fde6c53b6ffd106d7aba038a349b5575" . $raw_array[1]), $raw_array[2]) != 0)
return "<verify status='invalid_key' message='Please contact support for a new license key.' " . $raw_array[9] . " />";
if ($raw_array[1] < time() && $raw_array[1] != "never")
return "<verify status='invalid_key' message='Please contact support for a new license key.' " . $raw_array[9] . " />";
return "<verify status='active' message='The license key is valid.' " . $raw_array[9] . " />";
}
function phpaudit_exec_socket($http_host, $http_dir, $http_file, $querystring)
{
$fp = @fsockopen($http_host, 80, $errno, $errstr, 10);
if (!$fp) {
return false;
} else {
$header = "POST " . ($http_dir . $http_file) . " HTTP/1.0\r\n";
$header .= "Host: " . $http_host . "\r\n";
$header .= "Content-type: application/x-www-form-urlencoded\r\n";
$header .= "User-Agent: PHPAudit v2 (http://www.phpaudit.com)\r\n";
$header .= "Content-length: " . @strlen($querystring) . "\r\n";
$header .= "Connection: close\r\n\r\n";
$header .= $querystring;
$data = false;
if (@function_exists('stream_set_timeout')) {
stream_set_timeout($fp, 20);
}
@fputs($fp, $header);
if (@function_exists('socket_get_status')) {
$status = @socket_get_status($fp);
} else {
$status = true;
}
while (!@feof($fp) && $status) {
$data .= @fgets($fp, 1024);
if (@function_exists('socket_get_status')) {
$status = @socket_get_status($fp);
} else {
if (@feof($fp) == true) {
$status = false;
} else {
$status = true;
}
}
}
@fclose($fp);
if (!strpos($data, '200')) {
return false;
}
if (!$data) {
return false;
}
$data = @explode("\r\n\r\n", $data, 2);
if (!$data[1]) {
return false;
}
if (@strpos($data[1], "verify") === false) {
return false;
}
return $data[1];
}
}
function server_addr()
{
return ($_SERVER['SERVER_ADDR']) ? $_SERVER['SERVER_ADDR'] : $_SERVER['LOCAL_ADDR'];
}
function getLocalKey($license)
{
global $licapi;
include realpath(dirname(__FILE__)) . "/license.php";
$licapi = new IXR_Client('http://licencias.outservices.net/admin/rpc.php');
$data = array();
$data['api_key'] = '2425f27c6bf1f8821c3283e3b3037085';
$data['license_key'] = $license;
$licapi->query('license.get_local_key', $data);
$returned = $licapi->getResponse();
if ($returned != '' && $returned['faultCode'] != -1 && $returned['faultCode'] != -2 && $returned['faultCode'] != -3) {
return $returned;
} else {
return false;
}
}
function getLCs()
{
return 'MS_89475' . date('n') . '8973434254080808880077700134' . date('y') . '300344' . date('m') . '3204983240000234';
}
function getLCm()
{
return 'MS_4566' . date('W') . '456077700768880077700134' . date('y') . '300344' . date('nm') . '328808820082978434';
}
class template
{
function footer($cp, $dav)
{
echo '</td></tr><tr>';
echo '<td height="30" class="td_footer" id="footer" colspan="2">DirectAdmin ' . $cp . ' v' . $dva . ' ? 2006 JBMC Software</td>';
echo '</tr></table></body></html>';
}
function start_table($width = '100%', $cellspacing = '0', $cellpadding = '0')
{
echo '<table width="' . $width . '" border="0" cellspacing="' . $cellspacing . '" cellpadding="' . $cellpadding . '"><tr><td>';
}
function split_table()
{
echo '</td></tr><tr><td>';
}
function end_table()
{
echo '</td></tr></table>';
}
}
class skclass
{
function make_html($html, $search = '', $replace = '')
{
if ($search == '' || $replace == '') {
$search = array(
'class=inputclass ',
' type=submit',
' type=\'submit\'',
'<input type=button',
'<input type=reset',
'<input type=text',
'<input type=password',
'<input type=file',
'<table class=list cellpadding=3 cellspacing=1>',
'<table class=list cellpadding=3 cellspacing=1>',
'<table style="width: 75%" class=list cellpadding=3 cellspacing=1>',
'<br>'
);
$replace = array(
'',
' type=submit class=boton',
' type=submit class=boton',
'<input type=button class=boton',
'<input type=reset class=boton',
'<input type=text class=combo',
'<input type=password class=combo',
'<input type=file class=archivo',
'<table class=list cellpadding=3 cellspacing=0>',
'<table class=list cellpadding=3 cellspacing=0>',
'<table style="width: 75%" class=list cellpadding=3 cellspacing=0>',
'<br />'
);
}
$newhtml = str_replace($search, $replace, $html);
return $newhtml;
}
function api_get($cmd, $post = false)
{
if (is_array($post)) {
$is_post = true;
$str = '';
foreach ($post as $var => $value) {
if (strlen($str) > 0)
$str .= '&';
$str .= $var . '=' . urlencode($value);
}
$post = $str;
} else {
$is_post = false;
}
$headers = array();
$headers['Host'] = '127.0.0.1:' . $_ENV['SERVER_PORT'];
$headers['Cookie'] = 'session=' . $_ENV['SESSION_ID'] . '; key=' . $_ENV['SESSION_KEY'];
if ($is_post) {
$headers['Content-type'] = 'application/x-www-form-urlencoded';
$headers['Content-length'] = strlen($post);
}
$send = ($is_post ? 'POST ' : 'GET ') . $cmd . " HTTP/1.1\r\n";
foreach ($headers as $var => $value)
$send .= $var . ': ' . $value . "\r\n";
$send .= "\r\n";
if ($is_post && strlen($post) > 0)
$send .= $post . "\r\n\r\n";
if ($_ENV["SSL"] == 1) {
$sIP = 'ssl://127.0.0.1';
} else {
$sIP = '127.0.0.1';
}
$res = @fsockopen($sIP, $_SERVER['SERVER_PORT'], &$sock_errno, &$sock_errstr, 2);
if ($sock_errno || $sock_errstr)
return false;
fputs($res, $send, strlen($send));
$result = '';
while (!feof($res))
$result .= fgets($res, 32768);
@fclose($res);
$data = explode("\r\n\r\n", $result, 2);
return $data[1];
}
function user_mainmenu($title, $items, $type = "item")
{
$output = '';
for ($i = 0; $i < count($items); $i++) {
if ($items[$i]['plugin']) {
$itemimg = "/IMG_IC_PLUGIN";
$plugintxt = $items[$i]['plugin'];
if (strstr($plugintxt, "stat"))
$itemimg = "/IMG_IC_STATS";
if (strstr($plugintxt, "Stat"))
$itemimg = "/IMG_IC_STATS";
if (strstr($plugintxt, "awstats"))
$itemimg = "/IMG_IC_AWSTATS";
if (strstr($plugintxt, "Awstats"))
$itemimg = "/IMG_IC_AWSTATS";
if (strstr($plugintxt, "AwStats"))
$itemimg = "/IMG_IC_AWSTATS";
if (strstr($plugintxt, "smtp"))
$itemimg = "/IMG_IC_STATS";
if (strstr($plugintxt, "Ruby"))
$itemimg = "/IMG_IC_RUBY";
if (strstr($plugintxt, "ruby"))
$itemimg = "/IMG_IC_RUBY";
if (strstr($plugintxt, "rails"))
$itemimg = "/IMG_IC_RUBY";
if (strstr($plugintxt, "Rails"))
$itemimg = "/IMG_IC_RUBY";
if (strstr($plugintxt, "SMTP"))
$itemimg = "/IMG_IC_SMTP_CONTROL";
if (strstr($plugintxt, "smtp"))
$itemimg = "/IMG_IC_SMTP_CONTROL";
if (strstr($plugintxt, "Billing"))
$itemimg = "/IMG_IC_BILLING";
if (strstr($plugintxt, "billing"))
$itemimg = "/IMG_IC_BILLING";
if (strstr($plugintxt, "bill"))
$itemimg = "/IMG_IC_BILLING";
if (strstr($plugintxt, "payment"))
$itemimg = "/IMG_IC_BILLING";
if (strstr($plugintxt, "hotlink"))
$itemimg = "/IMG_IC_HOTLINK";
if (strstr($plugintxt, "iTron"))
$itemimg = "/IMG_IC_ITRON";
if (strstr($plugintxt, "installatron"))
$itemimg = "/IMG_IC_ITRON";
if (strstr($plugintxt, "tomcat"))
$itemimg = "/IMG_IC_TOMCAT";
if (strstr($plugintxt, "Tomcat"))
$itemimg = "/IMG_IC_TOMCAT";
if (strstr($plugintxt, "marina"))
$itemimg = "/IMG_IC_LICENSE";
if (strstr(strtolower($plugintxt), "pear"))
$itemimg = "/IMG_IC_PEAR";
if (strstr(strtolower($plugintxt), "pgsql"))
$itemimg = "/IMG_IC_PGSQL";
if (strstr($plugintxt, "PostgreSQL"))
$itemimg = "/IMG_IC_PGSQL";
if (strstr($plugintxt, "Postgre"))
$itemimg = "/IMG_IC_PGSQL";
if (strstr(strtolower($plugintxt), "postgre"))
$itemimg = "/IMG_IC_PGSQL";
if (strstr(strtolower($plugintxt), "softaculous"))
$itemimg = "/IMG_IC_SOFTAC";
if (strstr(strtolower($plugintxt), "phpvs"))
$itemimg = "/IMG_IC_PHPVS";
if (strstr(strtolower($plugintxt), "php version selector"))
$itemimg = "/IMG_IC_PHPVS";
$pluglink = preg_replace("/<a(.*?)href=\"(.*?)\"(.*?)>(.*?)<\/a>/", "<a href=\"\\2\"><img src=\"$itemimg\"><br>\\4</a>", $items[$i]['plugin']);
$output .= $pluglink;
} else {
$output .= '<a href="' . $items[$i]['link'] . '"><img src="' . $items[$i]['img'] . '"><br>' . $items[$i]['txt'] . '</a>';
}
}
$start_menu = '<fieldset class="buttons-box"><legend>' . $title . '</legend>';
$end_menu = '</fieldset><br><br>';
echo $start_menu . $output . $end_menu;
}
function submenu($title, $items, $footer = false)
{
$output = '<table border="0" cellspacing="0" cellpadding="0" align="center"><tr>';
$div = 1;
for ($i = 0; $i < count($items); $i++) {
$output .= '<td width="20%" align="center"><a href="' . $items[$i]['link'] . '" class="subitem" ' . $items[$i]['js'] . '><img src="' . $items[$i]['img'] . '" width="32" height="32" border="0"><br>' . $items[$i]['txt'] . '</a></td>';
if ($div == 5) {
$output .= '</tr><tr>';
$div = 0;
}
$div++;
}
$output .= '</tr></table>';
$start_menu = '<table width="100%" border="0" cellspacing="0" cellpadding="0" class=list><tr><td class=listtitle height="22" style="padding-left:3px;"><b>' . $title . '</b></td></tr><tr><td class=list>';
$end_menu = '</td></tr>';
if ($footer)
$end_menu .= '<tr><td class="listend">' . $footer . '</td></tr>';
$end_menu .= '</table>';
echo $start_menu . $output . $end_menu;
}
function box_tit($tit)
{
$output = '<div><table width="100%" border="0" cellspacing="0" cellpadding="0">';
$output .= '<tr><td background="/IMG_BOX_L"><img src="/IMG_SPACER" width="3" height="22"></td>';
$output .= '<td width="100%" class="box_tit" background="/IMG_BG_BOX_TIT">' . $tit . '</td>';
$output .= '<td background="/IMG_BOX_R"><img src="/IMG_SPACER" width="3" height="22"></td></tr>';
$output .= '</table></div>';
return $output;
}
function uptime($color = false)
{
if ($uptime = @exec("uptime")) {
list($uptime, $load) = explode('load', $uptime);
list($a, $load) = explode(':', $load);
$load = trim($load);
list($load1, $load5, $load15) = explode(',', $load);
$load1 = trim($load1) * 1;
$load5 = trim($load5) * 1;
$load15 = trim($load15) * 1;
list($a, $uptime) = explode('up', $uptime);
list($up1, $up2, $a) = explode(',', $uptime);
$up1 = trim($up1);
$up2 = trim($up2);
$uptime = $up1 . ", " . $up2;
$ret['uptime'] = $uptime;
} else {
$loads = urldecode($this->api_get("/CMD_API_LOAD_AVERAGE"));
parse_str($loads);
$load1 = $one;
$load5 = $five;
$load15 = $fifteen;
}
if ($color) {
if ($load1 >= 5)
$load1 = "<span style='color:red;'><b>$load1</b></span>";
if ($load5 >= 5)
$load5 = "<span style='color:red;'><b>$load5</b></span>";
if ($load15 >= 5)
$load15 = "<span style='color:red;'><b>$load15</b></span>";
}
$load = $load1 . ", " . $load5 . ", " . $load15;
$ret['load'] = $load;
return $ret;
}
function openfile($file)
{
if (file_exists($file)) {
if ($data = @file_get_contents($file)) {
return $data;
} else {
return false;
}
} else {
return false;
}
}
function whitefile($str, $file)
{
if ($al = @fopen($file, "w")) {
if (is_writable($file)) {
@fwrite($al, $str);
return true;
} else {
return false;
}
@fclose($al);
} else {
return false;
}
}
function getpath()
{
$skinpath = $_ENV["DOCUMENT_ROOT"];
if (preg_match("/\/home\/(.+)\/skins\/(.+)/", $skinpath)) {
$return['skinlocate'] = "reseller";
$return['path'] = $skinpath . "/inc/";
} elseif (preg_match("/\/usr\/local\/directadmin\/data\/skins\/(.+)/", $skinpath)) {
$return['skinlocate'] = "admin";
$return['path'] = $skinpath . "/inc/";
} else {
if (file_exists("/usr/local/directadmin/data/skin_data/marina")) {
$return['skinlocate'] = "admin";
$return['path'] = "/usr/local/directadmin/data/skin_data/marina/";
return $return;
} else {
return false;
}
}
return $return;
}
function getconfigpath()
{
$arrPath = $this->getpath();
if ($arrPath['skinlocate'] == "reseller") {
return $arrPath['path'];
} else {
if (file_exists("/usr/local/directadmin/data/skin_data/marina")) {
return "/usr/local/directadmin/data/skin_data/marina/";
} else {
return $arrPath['path'];
}
}
}
function getUserConf()
{
$file = $this->getconfigpath() . "userconf";
if (!file_exists($file)) {
$this->whitefile(serialize(array(
"x" => "x"
)), $file);
@chmod($file, 0777);
}
$cont = $this->openfile($file);
if ($cont) {
$_Config = unserialize($cont);
return $_Config;
} else {
return false;
}
}
function saveConfig($_Config)
{
$file = $this->getconfigpath() . "userconf";
$cont = serialize($_Config);
if ($this->whitefile($cont, $file))
return true;
else
return false;
}
}
function _d6($_s)
{
return base64_decode(str_replace('_', '=', $_s));
}
function _d2_ev($_s)
{
return eval(base64_decode(str_replace('_', '=', $_s)));
}
function _dl3($_l1)
{
return checkLicence($_l1);
}
?>