Вход Регистрация
Файл: _rootfuncs.php
Строк: 3852
<?php
/**********************
* Nulled by Alex.Volk *
* Thanks for sidxx55  *
*     Nulled.CC       *
**********************/

function EnableLanguages($isAdmin = 0)
{
    global 
$full_home_path;
    global 
$lang;
    global 
$newlang;
    global 
$languages;
    
$_SESSION = &$_SESSION;
    global 
$_lang;
    global 
$login;
    global 
$pass;
    require_once (
$full_home_path . "/_rootlang/_langconfig.inc.php");
    require_once (
$full_home_path . "/_rootlang/russian.inc.php");
    @include_once (
$full_home_path . "/_rootlang/russian.local.inc.php");

    if (!
$isAdmin) {
        
$default_language = getsetting("lngDefault");
        
$lngUsersCanChange = getsetting("lngUsersCanChange");

        if (
$lngUsersCanChange) {
            
$lngEnableLangVariable = getsetting("lngEnableLangVariable");

            if (
$lngEnableLangVariable) {
                
$lang = strtolower($lang);
            }
            else {
                
$lang = "";
            }

            if (
$newlang) {
                
$lang = $newlang;
            }

            if (!
$lang && !$_SESSION["userLogin"] && $login && $pass) {
                
$user = getuserbylogin($login);

                if (
$user->lang) {
                    
$lang = $user->lang;
                }
            }

            if (
$lang && ($languages[$lang] != "")) {
                
$_SESSION["userLang"] = $lang;
            }
            else if (!
$_SESSION["userLang"]) {
                
$_SESSION["userLang"] = $default_language;
            }
            else if (
$_SESSION["userLang"]) {
                
$sess_lang = $_SESSION["userLang"];
                if (!
$sess_lang || ($sess_lang && !$languages[$sess_lang])) {
                    
$_SESSION["userLang"] = $default_language;
                }
            }
        }
        else {
            
$_SESSION["userLang"] = $default_language;
        }

        if (
$_SESSION["userLang"] && @file_exists($full_home_path . "/_rootlang/" . $_SESSION["userLang"] . ".inc.php")) {
            require_once (
$full_home_path . "/_rootlang/" . $_SESSION["userLang"] . ".inc.php");
            @include_once (
$full_home_path . "/_rootlang/" . $_SESSION["userLang"] . ".local.inc.php");
            
setlanguagevariables();
            return 
$_SESSION["userLang"];
        }
        else {
            return 
false;
        }
    }
    else {
        
setlanguagevariables();
    }
}

function 
LoadLanguageToVariable($lng = "")
{
    global 
$full_home_path;
    require (
$full_home_path . "/_rootlang/_langconfig.inc.php");
    require (
$full_home_path . "/_rootlang/russian.inc.php");
    @include (
$full_home_path . "/_rootlang/russian.local.inc.php");
    if (
$lng && $languages[$lng]) {
        require (
$full_home_path . "/_rootlang/" . $lng . ".inc.php");
        @include (
$full_home_path . "/_rootlang/" . $lng . ".local.inc.php");
    }
    else {
        
$default_language = getsetting("lngDefault");

        if (
$languages[$default_language]) {
            require (
$full_home_path . "/_rootlang/" . $default_language . ".inc.php");
            @include (
$full_home_path . "/_rootlang/" . $default_language . ".local.inc.php");
        }
    }

    return 
$_lang;
}

function 
SetLanguageVariables()
{
    global 
$_lang;
    global 
$_yes;
    global 
$_status;
    global 
$_statusBill;
    global 
$_newreg;
    global 
$_renew;
    global 
$_newregmin;
    global 
$_renewmin;
    global 
$_sort;
    global 
$_priority;
    global 
$_prioritysms;
    global 
$_statusTicket;
    
$_yes[0] = $_lang[No];
    
$_yes[1] = $_lang[Yes];
    
$_status[0] = $_lang[OrderStatusNeObrabotan];
    
$_status[1] = $_lang[OrderStatusObrabotan];
    
$_status[2] = $_lang[OrderStatusSuspended];
    
$_status[3] = $_lang[OrdersStatusObrab];
    
$_statusBill[0] = $_lang[BillNotPayed];
    
$_statusBill[1] = $_lang[BillPayed];
    
$_statusBill[2] = $_lang[BillPayedUslovno];
    
$_newreg["0"] = $_lang[DomainExists];
    
$_newreg["1"] = $_lang[DomainNew];
    
$_newreg["2"] = $_lang[DomainWithout];
    
$_newreg["3"] = $_lang[DomainTransfer];
    
$_renew[0] = $_lang[DomainWithoutRenew];
    
$_renew[1] = $_lang[DomainRenew];
    
$_newregmin[0] = $_lang[DomainExistsMin];
    
$_newregmin[1] = $_lang[DomainNewMin];
    
$_newregmin[2] = $_lang[DomainWithoutMin];
    
$_newregmin[3] = $_lang[DomainTransferMin];
    
$_renewmin[0] = $_lang[DomainWithoutRenewMin];
    
$_renewmin[1] = $_lang[DomainRenewMin];
    
$_sort[asc] = $_lang[SortAsc];
    
$_sort[desc] = $_lang[SortDesc];
    
$_priority[0] = $_lang[TicketPriority0];
    
$_priority[1] = $_lang[TicketPriority1];
    
$_priority[2] = $_lang[TicketPriority2];
    
$_prioritysms[0] = $_lang[TicketPrioritySMS0];
    
$_prioritysms[1] = $_lang[TicketPrioritySMS1];
    
$_prioritysms[2] = $_lang[TicketPrioritySMS2];
    
$_statusTicket[open] = $_lang[TicketStatusOpen];
    
$_statusTicket[closed] = $_lang[TicketStatusClose];
    
$_statusTicket[wait] = $_lang[TicketStatusWait];
}

function 
adminLogOn($log, $pas)
{
    
$_SESSION = &$_SESSION;
    global 
$ip;
    (
$admin = @mysql_query("select * from admin_users where login='{$log}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 284 . "<BR>Function: " . "adminLogOn" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($admin)) {
        
$admin = mysql_fetch_object($admin);

        if (
crypt($pas, $admin->password) == $admin->password) {
            
$_SESSION["adminId"] = $admin->id;
            
$_SESSION["adminLogin"] = $admin->login;
            
$_SESSION["adminName"] = $admin->name;
            
$_SESSION["adminHash"] = $admin->password;
            
$_SESSION["adminFullAccess"] = $admin->fullaccess;
            
$_SESSION["adminAccessto"] = $admin->accessto;
            
$_SESSION["adminAccesstoArray"] = @mb_split("::", $admin->accessto);
            
$_SESSION["adminIP"] = $ip;
            
$_SESSION["adminLastDate"] = $admin->curDate;
            
$_SESSION["adminLastIp"] = $admin->curIp;
            
$_SESSION["adminAvatar"] = $admin->avatar;
            
$_SESSION["disallowLastSeen"] = $admin->disallowLastSeen;
            
$_SESSION["disallowLicenseInfo"] = $admin->disallowLicenseInfo;
            
$_SESSION["billsShow"] = "";
            
$_SESSION["billsSort"] = "";
            
$_SESSION["billsDesc"] = "";
            
$_SESSION["billskvShow"] = "";
            
$_SESSION["billskvSort"] = "";
            
$_SESSION["billskvDesc"] = "";
            
$_SESSION["domainShow"] = "";
            
$_SESSION["domainSort"] = "";
            
$_SESSION["domainDesc"] = "";
            
$_SESSION["domainCertsShow"] = "";
            
$_SESSION["domainCertsSort"] = "";
            
$_SESSION["domainCertsDesc"] = "";
            
$_SESSION["orderShow"] = "";
            
$_SESSION["orderShowVid"] = "";
            
$_SESSION["orderSort"] = "";
            
$_SESSION["orderDesc"] = "";
            
$_SESSION["ticketsStatus"] = "";
            
$_SESSION["ticketsDepartment"] = "";
            
$_SESSION["whoisLogsShow"] = "";
            @
mysql_query("UPDATE admin_users set lastDate=curDate,lastIp=curIp where id='{$admin->id}'") || exit("File: " . __FILE__ . "<BR>Line: " . 322 . "<BR>Function: " . "adminLogOn" . "<BR>MySQL Error: " . mysql_error());
            @
mysql_query("UPDATE admin_users set curDate=NOW(),curIp='{$ip}' where id='{$admin->id}'") || exit("File: " . __FILE__ . "<BR>Line: " . 323 . "<BR>Function: " . "adminLogOn" . "<BR>MySQL Error: " . mysql_error());
            return 
1;
        }
    }

    return 
0;
}

function 
adminLogOut()
{
    
$_SESSION = &$_SESSION;
    unset(
$_SESSION["adminId"]);
    unset(
$_SESSION["adminLogin"]);
    unset(
$_SESSION["adminName"]);
    unset(
$_SESSION["adminHash"]);
    unset(
$_SESSION["adminFullAccess"]);
    unset(
$_SESSION["adminAccessto"]);
    unset(
$_SESSION["adminAccesstoArray"]);
    unset(
$_SESSION["adminIP"]);
    unset(
$_SESSION["adminLastDate"]);
    unset(
$_SESSION["adminLastIp"]);
    unset(
$_SESSION["adminAvatar"]);
    unset(
$_SESSION["disallowLastSeen"]);
    unset(
$_SESSION["disallowLicenseInfo"]);
    return 
1;
}

function 
validateAdmin()
{
    
$_SESSION = &$_SESSION;
    global 
$ip;

    if (
$_SESSION["adminId"]) {
        (
$r = @mysql_query("select * from admin_users where id='" . $_SESSION["adminId"] . "' and password='" . $_SESSION["adminHash"] . "' and fullaccess='" . $_SESSION["adminFullAccess"] . "' and accessto='" . $_SESSION["adminAccessto"] . "'")) || exit("File: " . __FILE__ . "<BR>Line: " . 356 . "<BR>Function: " . "validateAdmin" . "<BR>MySQL Error: " . mysql_error());
        if ((
mysql_num_rows($r) == 0) || ($_SESSION["adminIP"] != $ip)) {
            
adminlogout();
        }
        else {
            return 
1;
        }
    }

    return 
0;
}

function 
validateUser()
{
    
$_SESSION = &$_SESSION;
    global 
$ip;

    if (
$_SESSION["userId"]) {
        (
$r = @mysql_query("select * from users where id='" . $_SESSION["userId"] . "' and password='" . $_SESSION["userHash"] . "' and banned<>1")) || exit("File: " . __FILE__ . "<BR>Line: " . 371 . "<BR>Function: " . "validateUser" . "<BR>MySQL Error: " . mysql_error());
        if ((
mysql_num_rows($r) == 0) || ($_SESSION["userIP"] != $ip)) {
            
userlogout();
        }
        else {
            return 
1;
        }
    }
}

function 
userLogOn($u, $p)
{
    
$_SESSION = &$_SESSION;
    global 
$ip;
    
$u = strtolower($u);
    
mconnect();
    (
$r = @mysql_query("select * from users where login='{$u}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 385 . "<BR>Function: " . "userLogOn" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        
$r = mysql_fetch_object($r);
        if ((
$r->password && (crypt($p, $r->password) == $r->password)) || ($r->tempPassword && (crypt($p, $r->tempPassword) == $r->tempPassword))) {
            if (!
$r->banned) {
                
$_SESSION["userId"] = $r->id;
                
$_SESSION["userLogin"] = $r->login;
                
$_SESSION["userEmail"] = $r->email;
                
$_SESSION["userEmail2"] = $r->email2;
                
$_SESSION["userCurrency"] = $r->currency;
                
$_SESSION["userHash"] = $r->password;
                
$_SESSION["userIP"] = $ip;
                if (
$r->lang && !$_SESSION["userLang"]) {
                    
$_SESSION["userLang"] = $r->lang;
                }

                
$_SESSION["userAttachPDFtoBill"] = $r->attachPDFtoBill;

                if (
$r->tempPassword) {
                    @
mysql_query("update users set tempPassword='' where id='{$r->id}'") || exit("File: " . __FILE__ . "<BR>Line: " . 402 . "<BR>Function: " . "userLogOn" . "<BR>MySQL Error: " . mysql_error());
                }

                
adduserlog($r->id, "auth", "OK [{$ip}]");
                return 
1;
            }
            else {
                
adduserlog($r->id, "auth", "USER BANNED [{$ip}]");
                return -
2;
            }
        }
        else {
            
adduserlog($r->id, "auth", "BAD PASSWORD [{$ip}]");
            return 
0;
        }
    }
    else {
        return -
1;
    }
}

function 
userLogOut()
{
    
$_SESSION = &$_SESSION;
    unset(
$_SESSION["userId"]);
    unset(
$_SESSION["userLogin"]);
    unset(
$_SESSION["userEmail"]);
    unset(
$_SESSION["userEmail2"]);
    unset(
$_SESSION["userCurrency"]);
    unset(
$_SESSION["userHash"]);
    unset(
$_SESSION["userIP"]);
    unset(
$_SESSION["userAttachPDFtoBill"]);
    unset(
$_SESSION["disallowedMenus"]);
    return 
1;
}

function 
GetVersionNormal()
{
    global 
$version;
    
$my->cvkDefcz = $version;
    return 
$my->cvkDefcz;
}

function 
GetVersionInt()
{
    
$my->blFgess = mystrreplace(getdot(), "", getversionnormal());
    return 
$my->blFgess;
}

function 
GetStepen()
{
    return 
mysubstr(getversionnormal(), 0, 3);
}

function 
GetDot()
{
    return 
mychr(46);
}

function 
GetStartPos($i)
{
    
$my->vcEwpskfgd = mysplit("\" . getdot(), getversionnormal());
    return 
$my->vcEwpskfgd[$i];
}

function GetKeyPart1()
{
    
$key->lfEfxcve3Ws = getversionint();
    
$key2->vbRdfsplsdgf = mypow($key->lfEfxcve3Ws, getstepen());
    return mysubstr(mymd5(
$key2->vbRdfsplsdgf), getstartpos(2), 16);
}

function GetKeyPart2()
{
    
$key->poFdsfe342s = getversionint();
    return mysubstr(mymd5(
$key->poFdsfe342s * getstartpos(1)), getstartpos(2), 16);
}

function GetKeyPart3()
{
    
$key->zxcsadwerfsd = getversionint();
    return mysubstr(mymd5(
$key->zxcsadwerfsd * $key->zxcsadwerfsd), getstartpos(1), 16);
}

function GetKey()
{
    return getkeypart1() . getkeypart2() . getkeypart3();
}

function GetLicenseFileName()
{
    return mychr(108) . mychr(105) . mychr(99) . mychr(101) . mychr(110) . mychr(115) . mychr(101) . mychr(46) . mychr(114) . mychr(112) . mychr(108);
}

function GetLicenseError(
$l)
{
    return mychr(108) . mychr(105) . mychr(99) . mychr(101) . mychr(110) . mychr(115) . mychr(101) . mychr(32) . mychr(101) . mychr(114) . mychr(114) . mychr(111) . mychr(114) . " " . 
$l;
}

function GetEncodingType()
{
    return mychr(77) . mychr(67) . mychr(82) . mychr(89) . mychr(80) . mychr(84) . mychr(95) . mychr(82) . mychr(73) . mychr(74) . mychr(78) . mychr(68) . mychr(65) . mychr(69) . mychr(76) . mychr(95) . mychr(49) . mychr(50) . mychr(56);
}

function GetDecrypted(
$s, $k)
{
    return mytrim(mcrypt_cbc(MCRYPT_RIJNDAEL_128, mysubstr(
$k, 0, 32), $s, MCRYPT_DECRYPT, mysubstr($k, 20, 16)));
}

function checkLicenseFile()
{
    global 
$full_home_path;

    if (!myfileexists(
$full_home_path . "/" . getlicensefilename())) {
        myexit(getlicenseerror(0));
    }
}

function readLicenseEncryptedArray()
{
    global 
$full_home_path;
    
$lfbmktDvdvc = myfopen($full_home_path . "/" . getlicensefilename(), "rb");
    
$CcvsSw2esxc = myfread($lfbmktDvdvc, myfilesize($full_home_path . "/" . getlicensefilename()));
    myfclose(
$lfbmktDvdvc);
    
$CcvsSw2esxc = mysplit("&kd@3sa2", $CcvsSw2esxc);
    return 
$CcvsSw2esxc;
}

function checkRplBy(
$l, $k)
{
    if (!getdecrypted(
$l[0], $k)) {
        myexit(getlicenseerror(1));
    }
}

function checkRplId(
$l, $k)
{
    global 
$retfsff;
    
$my->XDFser45c = getdecrypted($l[1], $k);
    
$retfsff = $my->XDFser45c;

    if (!0 < 
$my->XDFser45c) {
        myexit(getlicenseerror(2));
    }
}

function checkRplDate(
$l, $k)
{
    global 
$vfdFDsdfg;
    
$my->vfdFDsdfg = getdecrypted($l[2], $k);
    
$vfdFDsdfg = $my->vfdFDsdfg;
    if (
$my->vfdFDsdfg && ($my->vfdFDsdfg < mytime())) {
        myexit(getlicenseerror(3));
    }
}

function checkRplDomain(
$l, $k)
{
    global 
$sfsdfewwc;
    
$my->sdWEfrvcx1 = getdecrypted($l[3], $k);
    
$my->sdWEfDSas2 = getdecrypted($l[4], $k);
    
$sfsdfewwc[0] = $my->sdWEfrvcx1;
    
$sfsdfewwc[1] = $my->sdWEfDSas2;
    if ((
$my->sdWEfrvcx1 != getnulltxt()) && !myeregi(mychr(99) . mychr(114) . mychr(111) . mychr(110), mygetscriptname()) && !myeregi(mychr(95) . mychr(114) . mychr(111) . mychr(111) . mychr(116) . mychr(115) . mychr(101) . mychr(110) . mychr(100) . mychr(101) . mychr(114), mygetscriptname())) {
        if (!myeregi(
$my->sdWEfrvcx1, mygethost())) {
            if (!
$my->sdWEfDSas2) {
                myexit(getlicenseerror(4));
            }
            else {
                
$sdjdsfSsdfccx = mysplit("::", $my->sdWEfDSas2);
                
$bzbzdvd = 0;

                while (list(
$ccvcv, $dfwewe) = @each($sdjdsfSsdfccx)) {
                    if (myeregi(
$dfwewe, mygethost())) {
                        
$bzbzdvd = 1;
                        break;
                    }
                }

                if (!
$bzbzdvd) {
                    myexit(getlicenseerror(5));
                }
            }
        }
    }
}

function checkRplIp(
$l, $k)
{
    global 
$ertdsfgsdf;
    
$my->sdWEfrvcx1 = getdecrypted($l[5], $k);
    
$ertdsfgsdf[0] = $my->sdWEfrvcx1;
    
$my->sdWEfDSas2 = getdecrypted($l[6], $k);
    
$ertdsfgsdf[1] = $my->sdWEfDSas2;
    if ((
$my->sdWEfrvcx1 != getnulltxt()) && !myeregi(mychr(99) . mychr(114) . mychr(111) . mychr(110), mygetscriptname()) && !myeregi(mychr(95) . mychr(114) . mychr(111) . mychr(111) . mychr(116) . mychr(115) . mychr(101) . mychr(110) . mychr(100) . mychr(101) . mychr(114), mygetscriptname())) {
        if (
$my->sdWEfrvcx1 != mygetserverip()) {
            if (!
$my->sdWEfDSas2) {
                myexit(getlicenseerror(6));
            }
            else {
                
$sdjdsfSsdfccx = mysplit("::", $my->sdWEfDSas2);

                if (!myinarray(mygetserverip(), 
$sdjdsfSsdfccx)) {
                    myexit(getlicenseerror(7));
                }
            }
        }
    }
}

function checkRplSc(
$s, $l, $k)
{
    if (getdecrypted(
$l[7], $k) != $s) {
        myexit(getlicenseerror(8));
    }
}

function checkNewInstall(
$d, $s)
{

    if (
$d == 'createadmin' && !$s) {
        
$my->CXsdfsdf = 'install';
    }
    else if (myeregi('update.php', mygetscriptname())) {
        
$my->CXsdfsdf = 'update to ' . getversionnormal();
    }

    if (
$my->CXsdfsdf) {
        mconnect();
        
$my->ooooqqqw = mychr(118) . getsetting("version") . mychr(32) . $my->CXsdfsdf . mychr(32) . mychr(58) . getbr() . getbr() . mygethost() . mychr(32) . mygetserverip() . getbr() . getbr() . $my->lfdgjfgh1 . getbr() . $my->ldfkfdgj2 . getbr() . $my->leotiuer3 . getbr() . $my->pooiuewr4 . getbr() . $my->powqdswe5 . getbr() . $my->bvdefedd6 . getbr() . $my->qwssdfdf7 . getbr();
    }
}

function mconnect(
$silent = 0)
{
    global 
$dbhost;
    global 
$dbuser;
    global 
$dbpass;
    global 
$dbname;
    global 
$GLOBALerror;

    if (
$silent) {
        
$dblink = @mysql_connect($dbhost, $dbuser, $dbpass);
        
$GLOBALerror = mysql_error();
    }
    else {
        (
$dblink = @mysql_connect($dbhost, $dbuser, $dbpass)) || exit("File: " . __FILE__ . "<BR>Line: " . 489 . "<BR>Function: " . "mconnect" . "<BR>MySQL Error: " . mysql_error());
    }

    if (
$dblink) {
        @mysql_query("
SET NAMES utf8");

        if (
$silent) {
            
$db = @mysql_select_db("{$dbname}");
            
$GLOBALerror = mysql_error();
        }
        else {
            (
$db = @mysql_select_db("{$dbname}")) || exit("File: " . __FILE__ . "<BR>Line: " . 499 . "<BR>Function: " . "mconnect" . "<BR>MySQL Error: " . mysql_error());
        }

        if (
$db) {
            return 
$dblink;
        }
        else {
            return false;
        }
    }
    else {
        return false;
    }
}

function mencoding(
$encoding)
{
    global 
$dbname;
    @mysql_query("
SET NAMES {$encoding}");
    @mysql_select_db("
{$dbname}") || exit("File: " . __FILE__ . "<BR>Line: " . 514 . "<BR>Function: " . "mencoding" . "<BR>MySQL Error: " . mysql_error());
}

function mclose()
{
    if (@mysql_ping()) {
        @mysql_close();
    }
}

function getfont()
{
    global 
$font_row;
    global 
$font_row1;
    global 
$font_row2;

    if (
$font_row == $font_row1) {
        
$font_row = $font_row2;
    }
    else {
        
$font_row = $font_row1;
    }
}

function htmlEncode(
$txt)
{
    return @htmlspecialchars(
$txt, ENT_QUOTES, "UTF-8");
}

function htmlDecode(
$txt)
{
    return @htmlspecialchars_decode(
$txt, ENT_QUOTES);
}

function mydate(
$date)
{
    
$date = mb_split("-", $date);
    return 
$date[2] . "." . $date[1] . "." . $date[0];
}

function fromMyDate(
$date)
{
    
$date = mb_split("\.", $date);
    return 
$date[2] . "-" . $date[1] . "-" . $date[0];
}

function dateNow()
{
    return date("
d.m.Y");
}

function head(
$enc = "windows-1251", $CUR_PAGE_TITLE = "")
{
    global 
$full_home_path;
    global 
$languages;
    global 
$_lang;
    
$PAGE_TITLE = parserpstrarray(getsetting("pageTitle"), ":xxx:", ":xx:");
    
$lngUser = $_SESSION["userLang"];
    
$lngDefault = getsetting("lngDefault");
    if (
$lngUser && $languages[$lngUser] && $PAGE_TITLE[$lngUser]) {
        
$PAGE_TITLE = $PAGE_TITLE[$lngUser];
    }
    else {
        if (
$lngDefault && $languages[$lngDefault] && $PAGE_TITLE[$lngDefault]) {
            
$PAGE_TITLE = $PAGE_TITLE[$lngDefault];
        }
        else {
            
$PAGE_TITLE = "";
        }
    }

    
$pageTitleAddPage = getsetting("pageTitleAddPage");
    if (
$PAGE_TITLE && $pageTitleAddPage && $CUR_PAGE_TITLE) {
        
$pageTitleDelimiter = getsetting("pageTitleDelimiter");
        
$PAGE_TITLE = $CUR_PAGE_TITLE . " " . $pageTitleDelimiter . " " . $PAGE_TITLE;
    }

    if (!
$PAGE_TITLE && $CUR_PAGE_TITLE) {
        
$PAGE_TITLE = $CUR_PAGE_TITLE;
    }

    if (
$enc == "utf-8") {
        require (
$full_home_path . "/_rootheader.utf8.php");
    }
    else if (
$enc == "koi8-r") {
        
$PAGE_TITLE = iconv("utf-8", "koi8-r", $PAGE_TITLE);
        require (
$full_home_path . "/_rootheader.koi8r.php");
    }
    else if (
$enc == "windows-1251") {
        
$PAGE_TITLE = iconv("utf-8", "windows-1251", $PAGE_TITLE);
        require (
$full_home_path . "/_rootheader.php");
    }

    print("
<script src="./_rootmenu/hint.js" type="text/javascript"></script>");
    print("
<script src="./_rootmenu/passwd.js" type="text/javascript"></script>");
    print("
<script src="./_rootmenu/smartstars.js" type="text/javascript"></script>");
    echo "
t<script language=javascript type='text/javascript'>nntfunction myShow(divid) {nttvar state;nnttif (document.getElementById) { // DOM3 = IE5, NS6ntttstate = document.getElementById(divid).style.display;ntt}nttelse {ntttif (document.layers) { // Netscape 4nttttstate = document.divid.display;nttt}ntttelse { // IE 4nttttstate = document.all.divid.style.display;nttt}ntt}nnttif (state == 'block') {nttthidediv(divid);nt        } else {ntttshowdiv(divid);n        t}nt}nntfunction showdiv(divid) {nttif (document.getElementById) { // DOM3 = IE5, NS6ntttdocument.getElementById(divid).style.display = 'block';ntt}nttelse {ntttif (document.layers) { // Netscape 4nttttdocument.divid.display = 'block';nttt}ntttelse { // IE 4nttttdocument.all.divid.style.display = 'block';nttt}ntt}nt}nntfunction hidediv(divid) {nttif (document.getElementById) { // DOM3 = IE5, NS6ntttdocument.getElementById(divid).style.display = 'none';ntt}nttelse {ntttif (document.layers) { // Netscape 4nttttdocument.divid.display = 'none';nttt}ntttelse { // IE 4nttttdocument.all.divid.style.display = 'none';nttt}ntt}nt}nnt</script>nnt";

    
if ($_SESSION["userId"]) {
        
menu($enc);
    }
}

function 
foot($enc = "windows-1251")
{
    global 
$version;
    global 
$full_home_path;
    global 
$_lang;

    if (
$enc == "utf-8") {
        require (
$full_home_path . "/_rootfooter.utf8.php");
    }
    else if (
$enc == "koi8-r") {
        require (
$full_home_path . "/_rootfooter.koi8r.php");
    }
    else if (
$enc == "windows-1251") {
        require (
$full_home_path . "/_rootfooter.php");
    }

    print(
"rnrn<!-- Copyright (c) 2006-" . date("Y") . ", RootPanel.ru -->rn<!-- Powered by RootPanel v{$version} [ www.rootpanel.ru ] -->");
}

function 
myChr($k)
{
    return 
chr($k);
}

function 
myStrReplace($a, $b, $c)
{
    return 
str_replace($a, $b, $c);
}

function 
mySplit($l, $m)
{
    return @
mb_split($l, $m);
}

function 
myJoin($l, $m)
{
    return @
join($l, $m);
}

function 
myPow($r, $s)
{
    return 
round(pow($r, $s), 2);
}

function 
myEregi($z, $x)
{
    return 
preg_match("/" . $z . "/ui", $x);
}

function 
mySubstr($k, $l, $m)
{
    return 
substr($k, $l, $m);
}

function 
myMd5($n)
{
    return 
md5($n);
}

function 
myExit($y)
{
    exit(
$y);
}

function 
myFileExists($e)
{
    return 
file_exists($e);
}

function 
myFopen($s, $d)
{
    return 
fopen($s, $d);
}

function 
myFread($h, $j)
{
    return 
fread($h, $j);
}

function 
myFileSize($q)
{
    return 
filesize($q);
}

function 
myFclose($s)
{
    return 
fclose($s);
}

function 
myTrim($e)
{
    return 
trim($e);
}

function 
myTime()
{
    return 
time();
}

function 
myGetHost()
{
    return 
getenv("HTTP_HOST");
}

function 
myGetServerIp()
{
    return 
getenv("SERVER_ADDR");
}

function 
myGetScriptName()
{
    
$_SERVER = &$_SERVER;
    global 
$argv;

    if (
$_SERVER["SCRIPT_NAME"]) {
        return 
$_SERVER["SCRIPT_NAME"];
    }
    else {
        return 
$argv["0"];
    }
}

function 
myInArray($u, $i)
{
    return @
in_array($u, $i);
}

function 
GetNullTxt()
{
    return 
mychr(110) . mychr(117) . mychr(108) . mychr(108);
}

function 
GetBR()
{
    return 
mychr(10);
}

function 
GotoTranslit($var)
{
    
$NpjLettersFrom = array("а", "б", "в", "г", "д", "е", "з", "и", "к", "л", "м", "н", "о", "п", "р", "с", "т", "у", "ф", "ц", "ы", "є", "ї", "і");
    
$NpjLettersTo = array("a", "b", "v", "g", "d", "e", "z", "i", "k", "l", "m", "n", "o", "p", "r", "s", "t", "u", "f", "c", "y", "e", "i", "i");
    
$NpjBiLettersF = array("й", "ё", "ж", "х", "ч", "ш", "щ", "э", "ю", "я", "ъ", "ь");
    
$NpjBiLettersT = array("y", "jo", "zh", "kh", "ch", "sh", "sch", "e", "yu", "ya", "", "");
    
$NpjBLettersFrom = array("А", "Б", "В", "Г", "Д", "Е", "З", "И", "К", "Л", "М", "Н", "О", "П", "Р", "С", "Т", "У", "Ф", "Ц", "Ы", "Є", "Ї", "І");
    
$NpjBLettersTo = array("A", "B", "V", "G", "D", "E", "Z", "I", "K", "L", "M", "N", "O", "P", "R", "S", "T", "U", "F", "C", "Y", "E", "I", "I");
    
$NpjBiGLettersF = array("Й", "Ё", "Ж", "Х", "Ч", "Ш", "Щ", "Э", "Ю", "Я", "Ъ", "Ь");
    
$NpjBiGLettersT = array("Y", "Jo", "Zh", "Kh", "Ch", "Sh", "Sch", "E", "Yu", "Ya", "", "");
    
$NpjCaps = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЪЫЭЮЯ";
    
$NpjSmall = "абвгдеёжзийклмнопрстуфхцчшщьъыэюя";
    
$var = str_replace(".php", "", $var);
    
$var = trim(strip_tags($var));
    
$var = preg_replace("/\s+/msu", "_", $var);
    
$var = str_replace($NpjBiGLettersF, $NpjBiGLettersT, $var);
    
$var = str_replace($NpjBLettersFrom, $NpjBLettersTo, $var);
    
$var = str_replace($NpjLettersFrom, $NpjLettersTo, $var);
    
$var = str_replace($NpjBiLettersF, $NpjBiLettersT, $var);
    
$var = preg_replace("#[\-]+#iu", "_", $var);
    
$var = str_replace("_", " ", $var);
    return 
$var;
}

function 
semantic($i, &$words, &$fem, $f, $lng)
{
    global 
$_1_2;
    global 
$_1_19;
    global 
$des;
    global 
$hang;
    global 
$namecur;
    global 
$nametho;
    global 
$namemil;
    global 
$namemrd;
    
$words = "";
    
$fl = 0;

    if (
100 <= $i) {
        
$jkl = intval($i / 100);
        
$words .= $hang[$jkl][$lng];
        
$i %= 100;
    }

    if (
20 <= $i) {
        
$jkl = intval($i / 10);
        
$words .= $des[$jkl][$lng];
        
$i %= 10;
        
$fl = 1;
    }

    switch (
$i) {
    case 
1:
        
$fem = 1;
        break;

    case 
2:
    case 
3:
    case 
4:
        
$fem = 2;
        break;

    default:
        
$fem = 3;
        break;
    }

    if (
$i) {
        if ((
$i < 3) && (0 < $f)) {
            if (
2 <= $f) {
                
$words .= $_1_19[$i][$lng];
            }
            else {
                
$words .= $_1_2[$i][$lng];
            }
        }
        else {
            
$words .= $_1_19[$i][$lng];
        }
    }
}

function 
num2str($L, $currency, $lng)
{
    global 
$_1_2;
    global 
$_1_19;
    global 
$des;
    global 
$hang;
    global 
$namecur;
    global 
$nametho;
    global 
$namemil;
    global 
$namemrd;
    global 
$kopeek;
    
$s = " ";
    
$s1 = " ";
    
$s2 = " ";
    
$kop = intval(($L * 100) - (intval($L) * 100));
    
$L = intval($L);

    if (
1000000000 <= $L) {
        
$many = 0;
        
semantic(intval($L / 1000000000), &$s1, &$many, 3, $lng);
        
$s .= $s1 . $namemrd[$many][$lng];
        
$L %= 1000000000;
    }

    if (
1000000 <= $L) {
        
$many = 0;
        
semantic(intval($L / 1000000), &$s1, &$many, 2, $lng);
        
$s .= $s1 . $namemil[$many][$lng];
        
$L %= 1000000;

        if (
$L == 0) {
            
$s .= $namecur[$currency][3][$lng] . " ";
        }
    }

    if (
1000 <= $L) {
        
$many = 0;
        
semantic(intval($L / 1000), &$s1, &$many, 1, $lng);
        
$s .= $s1 . $nametho[$many][$lng];
        
$L %= 1000;

        if (
$L == 0) {
            
$s .= $namecur[$currency][3][$lng] . " ";
        }
    }

    if (
$L != 0) {
        
$many = 0;
        
semantic($L, &$s1, &$many, 0, $lng);
        
$s .= $s1 . $namecur[$currency][$many][$lng];
    }

    if (
0 < $kop) {
        
$many = 0;
        
semantic($kop, &$s1, &$many, 1, $lng);
        
$s .= $s1 . $kopeek[$currency][$many][$lng];
    }
    else {
        
$s .= " 00 " . $kopeek[$currency][3][$lng];
    }

    return 
$s;
}

function 
GetTpl($tpl, $tlng = "russian", $isAdmin = "0")
{
    global 
$languages;

    if (!
$isAdmin) {
        (
$r = @mysql_query("select * from templates where param='{$tpl}' and byDefault='1'")) || exit("File: " . __FILE__ . "<BR>Line: " . 848 . "<BR>Function: " . "GetTpl" . "<BR>MySQL Error: " . mysql_error());

        if (
0 < mysql_num_rows($r)) {
            
$r = mysql_fetch_object($r);
            
$tlng = $r->language;
        }
    }

    if (!
$languages[$tlng]) {
        
$tlng = "russian";
    }

    if (
$languages[$tlng]) {
        (
$r = @mysql_query("select * from templates where param='{$tpl}' and language='{$tlng}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 859 . "<BR>Function: " . "GetTpl" . "<BR>MySQL Error: " . mysql_error());
        
$r = @mysql_fetch_object($r);
        if (
$isAdmin || $r->template) {
            
$result[subject] = $r->subject;
            
$result[template] = htmldecode($r->template);

            if (
$r->isHtml) {
                
$result[type] = "html";
            }
            else {
                
$result[type] = "text";
            }
        }
        else {
            (
$r = @mysql_query("select * from templates where param='{$tpl}' and language='russian'")) || exit("File: " . __FILE__ . "<BR>Line: " . 866 . "<BR>Function: " . "GetTpl" . "<BR>MySQL Error: " . mysql_error());
            
$r = @mysql_fetch_object($r);
            
$result[subject] = $r->subject;
            
$result[template] = htmldecode($r->template);

            if (
$r->isHtml) {
                
$result[type] = "html";
            }
            else {
                
$result[type] = "text";
            }
        }
    }

    return 
$result;
}

function 
GetSetting($set, $silent = 0)
{
    if (
$silent) {
        
$r = @mysql_query("select * from settings where param='{$set}'");
    }
    else {
        (
$r = @mysql_query("select * from settings where param='{$set}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 884 . "<BR>Function: " . "GetSetting" . "<BR>MySQL Error: " . mysql_error());
    }

    if (
0 < @mysql_num_rows($r)) {
        
$r = @mysql_fetch_object($r);
        return 
htmldecode($r->value);
    }
}

function 
SetSetting($param, $value)
{
    @
mysql_query("update settings set value='{$value}' where param='{$param}'") || exit("File: " . __FILE__ . "<BR>Line: " . 895 . "<BR>Function: " . "SetSetting" . "<BR>MySQL Error: " . mysql_error());
}

function 
GetAddons()
{
    (
$z = @mysql_query("select * from addons")) || exit("File: " . __FILE__ . "<BR>Line: " . 899 . "<BR>Function: " . "GetAddons" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
$z;
    }
}

function 
GetAddonById($id)
{
    (
$z = @mysql_query("select * from addons where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 903 . "<BR>Function: " . "GetAddonById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetAddonsIdsByTxt($txt)
{
    
$orderAddons = mb_split(":x:", $txt);

    if (
0 < getarraynotnullcount($orderAddons)) {
        
$resultArray = NULL;

        while (list(
$k, $v) = each($orderAddons)) {
            if (
$v) {
                
$resultArray[] = $v;
            }
        }
    }

    if (
is_array($resultArray)) {
        return 
$resultArray;
    }
    else {
        return 
false;
    }
}

function 
GetAddonsIdsForOrderId($id)
{
    
$order = getorderbyid($id);
    return 
getaddonsidsbytxt($order->addons);
}

function 
GetAccessibleAddonsIdsForTarifId($id)
{
    
$tarif = gettarifbyid($id);
    return 
getaddonsidsbytxt($tarif->addons);
}

function 
GetAccessibleAddonsIdsForOrderId($id)
{
    
$order = getorderbyid($id);

    if (
$order->id) {
        
$addonsForTarif = getaccessibleaddonsidsfortarifid($order->tarif);
        
$resultArray = NULL;

        while (list(
$k, $v) = @each($addonsForTarif)) {
            
$oneAddon = getaddonbyid($v);

            if (
$oneAddon->id) {
                if (!
$oneAddon->cntforoneorder) {
                    
$resultArray[] = $v;
                }
                else if (
getoneaddonscntfororderid($order->id, $oneAddon->id) < $oneAddon->cntforoneorder) {
                    
$resultArray[] = $v;
                }
            }
        }

        if (
is_array($resultArray)) {
            return 
$resultArray;
        }
    }
}

function 
GetArrayNotNullCount($arr)
{
    
$cnt = 0;

    while (list(
$k, $v) = each($arr)) {
        if (
$v) {
            
$cnt++;
        }
    }

    
reset($arr);
    return 
$cnt;
}

function 
GetCurrencys($withZero = "0")
{
    if (
$withZero) {
        
$where = "";
    }
    else {
        
$where = "where NOT(koeficient=0)";
    }

    (
$z = @mysql_query("select * from currency {$where}")) || exit("File: " . __FILE__ . "<BR>Line: " . 967 . "<BR>Function: " . "GetCurrencys" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
$z;
    }
}

function 
GetCurrencyByCode($code)
{
    
$code = strtoupper($code);
    (
$z = @mysql_query("select * from currency where code='{$code}' or id='" . intval($code) . "'")) || exit("File: " . __FILE__ . "<BR>Line: " . 975 . "<BR>Function: " . "GetCurrencyByCode" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
    else {
        return 
false;
    }
}

function 
GetCurrencyKoeficientByCode($code)
{
    
$code = strtoupper($code);
    (
$z = @mysql_query("select koeficient from currency where code='{$code}' or id='" . intval($code) . "'")) || exit("File: " . __FILE__ . "<BR>Line: " . 986 . "<BR>Function: " . "GetCurrencyKoeficientByCode" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z->koeficient;
    }
    else {
        return 
false;
    }
}

function 
GetCurrentAdminCurrency()
{
    (
$r = @mysql_query("select * from currency where koeficient='1'")) || exit("File: " . __FILE__ . "<BR>Line: " . 996 . "<BR>Function: " . "GetCurrentAdminCurrency" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        
$r = mysql_fetch_object($r);
        
define("CURAS", $r->symbol);
        
define("CURAC", $r->code);
        return 
true;
    }
    else {
        return 
false;
    }
}

function 
GetCurrentCurrency()
{
    
$_SESSION = &$_SESSION;
    global 
$valuta;
    if (
$valuta && getsetting("usersChangeCurrency")) {
        
$currency = getcurrencybycode(strtoupper($valuta));
        if (
$currency->symbol && $currency->koeficient && !$_SESSION["userId"]) {
            
$_SESSION["userCurrency"] = strtoupper($valuta);
        }
    }

    if (!
$currency && $_SESSION["userCurrency"] && getsetting("usersChangeCurrency")) {
        
$currency = getcurrencybycode($_SESSION["userCurrency"]);
    }

    if (!
$currency->symbol || !$currency->koeficient) {
        
$currency = getsetting("currency");
        
$currency = getcurrencybycode($currency);
    }

    if (
$currency->symbol && $currency->koeficient) {
        
define("CURC", $currency->code);
        
define("CURS", $currency->symbol);
        
define("CURK", $currency->koeficient);
        return 
true;
    }
    else {
        return 
false;
    }
}

function 
LoadCurrencyToVariable($userCurrency)
{
    if (
$userCurrency && getsetting("usersChangeCurrency")) {
        
$currency = getcurrencybycode($userCurrency);
    }

    if (!
$currency->symbol || !$currency->koeficient) {
        
$currency = getsetting("currency");
        
$currency = getcurrencybycode($currency);
    }

    if (
$currency->symbol && $currency->koeficient) {
        
$res["CURC"] = $currency->code;
        
$res["CURS"] = $currency->symbol;
        
$res["CURK"] = $currency->koeficient;
        return 
$res;
    }
    else {
        return 
false;
    }
}

function 
GetTarifById($id)
{
    (
$z = @mysql_query("select * from tarifs where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1060 . "<BR>Function: " . "GetTarifById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetTarifByOrderId($id)
{
    (
$z = @mysql_query("select t.* from tarifs as t, orders as o where t.id=o.tarif and o.id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1068 . "<BR>Function: " . "GetTarifByOrderId" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetTarifVidByOrderId($id)
{
    (
$z = @mysql_query("select t.vid from tarifs as t, orders as o where t.id=o.tarif and o.id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1076 . "<BR>Function: " . "GetTarifVidByOrderId" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z->vid;
    }
}

function 
GetTarifsCostById($id)
{
    (
$z = @mysql_query("select * from tarifs_costs where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1085 . "<BR>Function: " . "GetTarifsCostById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetTarifsCostsActive($id)
{
    (
$z = @mysql_query("select * from tarifs_costs where tarif_id='{$id}' and active='1' order by id")) || exit("File: " . __FILE__ . "<BR>Line: " . 1093 . "<BR>Function: " . "GetTarifsCostsActive" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
$z;
    }
}

function 
GetBillById($id)
{
    (
$z = @mysql_query("select * from bills where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1100 . "<BR>Function: " . "GetBillById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetBillByIdWithAttached($id)
{
    (
$z = @mysql_query("select * from bills where id='{$id}' or attachTo='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1108 . "<BR>Function: " . "GetBillByIdWithAttached" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
$z;
    }
}

function 
GetBillPayedCountByUserId($id)
{
    (
$z = @mysql_query("select COUNT(*) as cnt from bills where status='1' and archived=0 and uid='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1115 . "<BR>Function: " . "GetBillPayedCountByUserId" . "<BR>MySQL Error: " . mysql_error());
    
$z = mysql_fetch_object($z);
    return 
$z->cnt;
}

function 
GetZoneByZone($zone)
{
    (
$z = mysql_query("select * from zones where zone='{$zone}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1121 . "<BR>Function: " . "GetZoneByZone" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetActiveZoneByZone($zone)
{
    (
$z = mysql_query("select * from zones where zone='{$zone}' and active='1' order by isDefault desc")) || exit("File: " . __FILE__ . "<BR>Line: " . 1129 . "<BR>Function: " . "GetActiveZoneByZone" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetZoneById($id)
{
    (
$z = mysql_query("select * from zones where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1137 . "<BR>Function: " . "GetZoneById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetZoneByDomain($domain)
{
    (
$z = @mysql_query("select t1.* from zones as t1, orders_domains as t2 where t1.id=t2.zone_id and t2.domain='{$domain}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1145 . "<BR>Function: " . "GetZoneByDomain" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetZoneByDomainOrderId($id)
{
    (
$z = @mysql_query("select t1.* from zones as t1, orders_domains as t2 where t1.id=t2.zone_id and t2.id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1153 . "<BR>Function: " . "GetZoneByDomainOrderId" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetDomainByDomain($domain)
{
    (
$z = mysql_query("select *,TO_DAYS(todate)-TO_DAYS(NOW()) as leftdays,TO_DAYS(todateprivacy)-TO_DAYS(NOW()) as leftdaysprivacy from orders_domains where domain='{$domain}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1161 . "<BR>Function: " . "GetDomainByDomain" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetDomainById($id)
{
    (
$z = mysql_query("select *,TO_DAYS(todate)-TO_DAYS(NOW()) as leftdays,TO_DAYS(todateprivacy)-TO_DAYS(NOW()) as leftdaysprivacy from orders_domains where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1169 . "<BR>Function: " . "GetDomainById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetZonesNamesActive()
{
    (
$z = @mysql_query("select zone from zones where active='1' order by zone")) || exit("File: " . __FILE__ . "<BR>Line: " . 1177 . "<BR>Function: " . "GetZonesNamesActive" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        while (
$zz = mysql_fetch_object($z)) {
            
$result[] = $zz->zone;
        }

        return 
$result;
    }
}

function 
GetZonesNamesActiveWithTransferCount()
{
    (
$z = @mysql_query("select id from zones where active='1' and transferAllow='1'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1187 . "<BR>Function: " . "GetZonesNamesActiveWithTransferCount" . "<BR>MySQL Error: " . mysql_error());
    return @
mysql_num_rows($z);
}

function 
GetZonesNamesActiveCount()
{
    (
$z = @mysql_query("select id from zones where active='1'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1192 . "<BR>Function: " . "GetZonesNamesActiveCount" . "<BR>MySQL Error: " . mysql_error());
    return @
mysql_num_rows($z);
}

function 
GetZonesNamesForWhois()
{
    (
$z = @mysql_query("select zone from zones where active='1' and useinwhois='1' group by zone order by zone")) || exit("File: " . __FILE__ . "<BR>Line: " . 1197 . "<BR>Function: " . "GetZonesNamesForWhois" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        while (
$zz = mysql_fetch_object($z)) {
            
$result[] = $zz->zone;
        }

        return 
$result;
    }
}

function 
GetZonesNamesForWhoisFavorite()
{
    (
$z = @mysql_query("select zone from zones where active='1' and isFavorite='1' group by zone order by zone")) || exit("File: " . __FILE__ . "<BR>Line: " . 1207 . "<BR>Function: " . "GetZonesNamesForWhoisFavorite" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        while (
$zz = mysql_fetch_object($z)) {
            
$result[] = $zz->zone;
        }

        return 
$result;
    }
}

function 
GetZonesActive($group = "", $nogroupby = "0")
{
    if (
$group != "") {
        
$where = "and `group`='{$group}'";
    }

    if (!
$nogroupby) {
        
$groupby = "group by zone";
    }

    (
$z = @mysql_query("select * from zones where active='1' {$where} {$groupby} order by zone,cost_if_not_host,cost_if_not_hostCurrency desc")) || exit("File: " . __FILE__ . "<BR>Line: " . 1220 . "<BR>Function: " . "GetZonesActive" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
$z;
    }
}

function 
GetZonesForWhois()
{
    (
$z = @mysql_query("select * from zones where active='1' and useinwhois='1' group by zone order by zone")) || exit("File: " . __FILE__ . "<BR>Line: " . 1227 . "<BR>Function: " . "GetZonesForWhois" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
$z;
    }
}

function 
GetZonesAll()
{
    (
$z = @mysql_query("select * from zones order by zone")) || exit("File: " . __FILE__ . "<BR>Line: " . 1234 . "<BR>Function: " . "GetZonesAll" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
$z;
    }
}

function 
IsZoneInUse($id)
{
    (
$z = @mysql_query("select * from orders_domains where zone_id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1241 . "<BR>Function: " . "IsZoneInUse" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
true;
    }
    else {
        return 
false;
    }
}

function 
IsZoneActive($zone)
{
    (
$z = @mysql_query("select * from zones where zone='{$zone}' and active='1'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1250 . "<BR>Function: " . "IsZoneActive" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
true;
    }
    else {
        return 
false;
    }
}

function 
GetZoneByNonExistsDomain($domain)
{
    
$dom = mb_split("\.", $domain);
    
$zone = preg_replace("/{$dom[0]}\./ui", "", $domain);
    (
$z = mysql_query("select * from zones where zone='{$zone}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1263 . "<BR>Function: " . "GetZoneByNonExistsDomain" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
IsTarifInUse($id)
{
    (
$z = @mysql_query("select * from orders where tarif='{$id}' and archived=0")) || exit("File: " . __FILE__ . "<BR>Line: " . 1271 . "<BR>Function: " . "IsTarifInUse" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
true;
    }
    else {
        return 
false;
    }
}

function 
GetTarifsGroups()
{
    (
$z = @mysql_query("select * from tarifs_groups order by name")) || exit("File: " . __FILE__ . "<BR>Line: " . 1280 . "<BR>Function: " . "GetTarifsGroups" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
$z;
    }
}

function 
GetTarifsGroupById($id)
{
    (
$z = @mysql_query("select * from tarifs_groups where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1287 . "<BR>Function: " . "GetTarifsGroupById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
mysql_fetch_object($z);
    }
}

function 
GetAddonsGroups()
{
    (
$z = @mysql_query("select * from addons_groups order by name")) || exit("File: " . __FILE__ . "<BR>Line: " . 1294 . "<BR>Function: " . "GetAddonsGroups" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
$z;
    }
}

function 
GetAddonsGroupById($id)
{
    (
$z = @mysql_query("select * from addons_groups where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1301 . "<BR>Function: " . "GetAddonsGroupById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
mysql_fetch_object($z);
    }
}

function 
GetAboutUsFromAll()
{
    (
$z = @mysql_query("select * from aboutusfrom order by sort")) || exit("File: " . __FILE__ . "<BR>Line: " . 1308 . "<BR>Function: " . "GetAboutUsFromAll" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
$z;
    }
}

function 
GetAboutUsFromById($id)
{
    (
$z = @mysql_query("select * from aboutusfrom where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1315 . "<BR>Function: " . "GetAboutUsFromById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
mysql_fetch_object($z);
    }
}

function 
GetPayMethods()
{
    (
$r = @mysql_query("select * from pay_methods order by id")) || exit("File: " . __FILE__ . "<BR>Line: " . 1322 . "<BR>Function: " . "GetPayMethods" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
$r;
    }
}

function 
GetNews($num = 0)
{
    
mconnect();

    if (
$num) {
        (
$r = @mysql_query("select * from news order by data desc, id desc limit 0,{$num}")) || exit("File: " . __FILE__ . "<BR>Line: " . 1332 . "<BR>Function: " . "GetNews" . "<BR>MySQL Error: " . mysql_error());
    }
    else {
        (
$r = @mysql_query("select * from news order by data desc, id desc")) || exit("File: " . __FILE__ . "<BR>Line: " . 1334 . "<BR>Function: " . "GetNews" . "<BR>MySQL Error: " . mysql_error());
    }

    if (
0 < mysql_num_rows($r)) {
        return 
$r;
    }
}

function 
GetNewsById($id)
{
    if (
$id) {
        (
$r = @mysql_query("select * from news where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1344 . "<BR>Function: " . "GetNewsById" . "<BR>MySQL Error: " . mysql_error());

        if (
0 < mysql_num_rows($r)) {
            return 
mysql_fetch_object($r);
        }
    }
}

function 
GetServers($id = "", $type = "")
{
    if (
$id) {
        (
$r = @mysql_query("select * from servers where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1353 . "<BR>Function: " . "GetServers" . "<BR>MySQL Error: " . mysql_error());

        if (
0 < mysql_num_rows($r)) {
            return 
mysql_fetch_object($r);
        }
    }
    else {
        if (
$type) {
            
$where = "where `type`='{$type}'";
        }

        (
$r = @mysql_query("select * from servers {$where} order by parentid,id")) || exit("File: " . __FILE__ . "<BR>Line: " . 1360 . "<BR>Function: " . "GetServers" . "<BR>MySQL Error: " . mysql_error());

        if (
0 < mysql_num_rows($r)) {
            return 
$r;
        }
    }
}

function 
GetServerUserCount($id)
{
    if (
$id) {
        (
$r = @mysql_query("select COUNT(*) as cnt from orders where serverid='{$id}' and status<>0 and archived=0")) || exit("File: " . __FILE__ . "<BR>Line: " . 1370 . "<BR>Function: " . "GetServerUserCount" . "<BR>MySQL Error: " . mysql_error());
        
$r = @mysql_fetch_object($r);
        return 
$r->cnt;
    }
}

function 
IsLoginExists($login)
{
    (
$z = @mysql_query("select * from users where login='{$login}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1377 . "<BR>Function: " . "IsLoginExists" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
true;
    }
}

function 
GetUserById($id)
{
    (
$z = @mysql_query("select * from users where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1384 . "<BR>Function: " . "GetUserById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetUserProfileByUserId($id, $profileid = "")
{
    if (
$profileid) {
        
$sql = "uid='{$id}' and id='{$profileid}'";
    }
    else {
        
$user = getuserbyid($id);
        
$sql = "uid='{$id}' and id='{$user->defaultProfileId}'";
    }

    (
$z = @mysql_query("select * from users_profile where {$sql}")) || exit("File: " . __FILE__ . "<BR>Line: " . 1398 . "<BR>Function: " . "GetUserProfileByUserId" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetUserByLogin($login)
{
    (
$z = @mysql_query("select * from users where login='{$login}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1406 . "<BR>Function: " . "GetUserByLogin" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetUserByLoginOrId($ident)
{
    (
$z = @mysql_query("select * from users where login='{$ident}' or id='{$ident}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1414 . "<BR>Function: " . "GetUserByLoginOrId" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetUserByEmail($email)
{
    (
$z = @mysql_query("select * from users where email='{$email}' or email2='{$email}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1422 . "<BR>Function: " . "GetUserByEmail" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetUsersLogins()
{
    (
$z = @mysql_query("select login from users order by login")) || exit("File: " . __FILE__ . "<BR>Line: " . 1431 . "<BR>Function: " . "GetUsersLogins" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        while (
$zz = mysql_fetch_object($z)) {
            
$result[] = $zz->login;
        }

        return 
$result;
    }
}

function 
GetUsersAll()
{
    (
$r = @mysql_query("select * from users order by login")) || exit("File: " . __FILE__ . "<BR>Line: " . 1441 . "<BR>Function: " . "GetUsersAll" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
$r;
    }
}

function 
GetOrderById($id, $uid = "")
{
    if (
$uid) {
        
$sqladdon = "and uid='{$uid}'";
    }
    else {
        
$sqladdon = "";
    }

    (
$z = @mysql_query("select *,TO_DAYS(todate)-TO_DAYS(NOW()) as leftdays from orders where archived=0 and id='{$id}' {$sqladdon}")) || exit("File: " . __FILE__ . "<BR>Line: " . 1450 . "<BR>Function: " . "GetOrderById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetUserPartnerMoney($id)
{
    (
$z = @mysql_query("select partnerMoney from users where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1458 . "<BR>Function: " . "GetUserPartnerMoney" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
round($z->partnerMoney, 2);
    }
}

function 
GetUserReferalsCount($id)
{
    (
$z = @mysql_query("select * from users where referal='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1466 . "<BR>Function: " . "GetUserReferalsCount" . "<BR>MySQL Error: " . mysql_error());
    return 
mysql_num_rows($z);
}

function 
GetUserReferalsArray($id)
{
    (
$r = @mysql_query("select id,login,email from users where referal='{$id}' order by login")) || exit("File: " . __FILE__ . "<BR>Line: " . 1471 . "<BR>Function: " . "GetUserReferalsArray" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        while (
$rr = mysql_fetch_object($r)) {
            
$result[$rr->id][login] = $rr->login;
            
$result[$rr->id][email] = $rr->email;
        }

        return 
$result;
    }
    else {
        return 
false;
    }
}

function 
GetUserMoney($id)
{
    (
$r = @mysql_query("select money from users where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1483 . "<BR>Function: " . "GetUserMoney" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        
$r = mysql_fetch_object($r);
        return 
round($r->money, 2);
    }
    else {
        return 
false;
    }
}

function 
GetTicketById($id)
{
    (
$z = @mysql_query("select * from tickets where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1493 . "<BR>Function: " . "GetTicketById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
IsUserActiveReseller($uid)
{
    (
$r = @mysql_query("select t1.id from orders as t1, tarifs as t2 where t1.uid='{$uid}' and t1.archived=0 and t1.todate>NOW() and t1.tarif=t2.id and t2.vid='reseller'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1501 . "<BR>Function: " . "IsUserActiveReseller" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
true;
    }
    else {
        return 
false;
    }
}

function 
IsUserHaveActiveOrders($uid)
{
    (
$r = @mysql_query("select id from orders where uid='{$uid}' and todate>NOW() and archived=0")) || exit("File: " . __FILE__ . "<BR>Line: " . 1510 . "<BR>Function: " . "IsUserHaveActiveOrders" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
true;
    }
    else {
        return 
false;
    }
}

function 
IsUserHaveActiveDomainOrders($uid)
{
    (
$r = @mysql_query("select id from orders_domains where uid='{$uid}' and todate>NOW() and archived=0")) || exit("File: " . __FILE__ . "<BR>Line: " . 1519 . "<BR>Function: " . "IsUserHaveActiveDomainOrders" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
true;
    }
    else {
        return 
false;
    }
}

function 
IsUserHaveActiveShopOrders($uid)
{
    (
$r = @mysql_query("select id from orders_shop where uid='{$uid}' and (todate>NOW() or status='1')")) || exit("File: " . __FILE__ . "<BR>Line: " . 1528 . "<BR>Function: " . "IsUserHaveActiveShopOrders" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
true;
    }
    else {
        return 
false;
    }
}

function 
IsUserDomainReseller($uid)
{
    (
$r = @mysql_query("select * from users where id='{$uid}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1537 . "<BR>Function: " . "IsUserDomainReseller" . "<BR>MySQL Error: " . mysql_error());
    
$r = mysql_fetch_object($r);

    if (
$r->domainreseller) {
        return 
true;
    }
    else {
        return 
false;
    }
}

function 
GetAccessibleChangeTarifsForHostingOrder($orderId)
{
    
$order = getorderbyid($orderId);
    if (
$order->id && $order->status && ($order->status != "3")) {
        
$tarif = gettarifbyid($order->tarif);

        if (
$tarif->id) {
            
$changeUp = getsetting("changetarif_up");
            
$changeDown = getsetting("changetarif_down");
            
$userBalance = getsetting("userBalanceEnable");
            if (
$changeUp || ($changeDown && $userBalance)) {
                if (
$changeUp) {
                    
$sql1 = "cost > {$tarif->cost}";
                }

                if (
$changeDown && $userBalance) {
                    
$sql2 = "cost < {$tarif->cost}";
                }

                if (
$changeUp && $changeDown && $userBalance) {
                    
$sqlop = "OR";
                }

                (
$r = @mysql_query("select * from tarifs where active=1 and nochange=0 and vid='{$tarif->vid}' and NOT(id='{$order->tarif}') and ({$sql1} {$sqlop} {$sql2}) order by cost")) || exit("File: " . __FILE__ . "<BR>Line: " . 1561 . "<BR>Function: " . "GetAccessibleChangeTarifsForHostingOrder" . "<BR>MySQL Error: " . mysql_error());

                if (
0 < mysql_num_rows($r)) {
                    return 
$r;
                }
            }
        }
    }

    return 
false;
}

function 
IsAccessibleChangeTarifForHostingOrder($orderId, $newTarifId)
{
    
$tarifs = getaccessiblechangetarifsforhostingorder($orderId);
    
$newTarif = gettarifbyid($newTarifId);

    while (
$tarif = @mysql_fetch_object($tarifs)) {
        if (
$tarif->id = $newTarifId) {
            return 
true;
        }
    }
}

function 
GetAccessibleChangeServersForOrder($orderId)
{
    
$order = getorderbyid($orderId);
    if (
$order->id && $order->status && ($order->status != "3")) {
        
$server = getservers($order->serverid);

        if (
$server->id) {
            if (
$server->parentid) {
                
$mainServer = $server->parentid;
            }
            else {
                
$mainServer = $server->id;
            }

            (
$r = @mysql_query("select * from servers where NOT(id='{$server->id}') and (id='{$mainServer}' OR parentid='{$mainServer}')")) || exit("File: " . __FILE__ . "<BR>Line: " . 1588 . "<BR>Function: " . "GetAccessibleChangeServersForOrder" . "<BR>MySQL Error: " . mysql_error());

            if (
0 < mysql_num_rows($r)) {
                return 
$r;
            }
        }
    }

    return 
false;
}

function 
IsAccessibleChangeServerForOrder($orderId, $newServerId)
{
    
$servers = getaccessiblechangeserversfororder($orderId);
    
$newServer = getservers($newServerId);

    while (
$server = @mysql_fetch_object($servers)) {
        if (
$server->id = $newServerId) {
            return 
true;
        }
    }
}

function 
IsIPInIPs($ip, $catalog_ip)
{
    if (
$catalog_ip) {
        
$catalog_array = mb_split("rn", $catalog_ip);
        
$result = false;

        while (list(
$key, $value) = each($catalog_array)) {
            if (
preg_match("/\-/ui", $value)) {
                
$ips = mb_split("\-", $value);
                if ((
ip2long($ips[0]) <= ip2long($ip)) && (ip2long($ip) <= ip2long($ips[1]))) {
                    
$result = true;
                    break;
                }
            }
            else if (
ip2long($ip) == ip2long($value)) {
                
$result = true;
                break;
            }
        }

        return 
$result;
    }
    else {
        return 
true;
    }
}

function 
IsNewTicketsForAdmin()
{
    (
$r = @mysql_query("select id from tickets where parentid=0 and newforadmin='1' LIMIT 0,1")) || exit("File: " . __FILE__ . "<BR>Line: " . 1624 . "<BR>Function: " . "IsNewTicketsForAdmin" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
true;
    }
}

function 
IsNewTicketsForUser($uid)
{
    (
$r = @mysql_query("select * from tickets where parentid=0 and newforuser='1' and userid='{$uid}' LIMIT 0,1")) || exit("File: " . __FILE__ . "<BR>Line: " . 1629 . "<BR>Function: " . "IsNewTicketsForUser" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
true;
    }
    else {
        return 
false;
    }
}

function 
GetAdminEmailsWhereTrueParam($param, $department = "")
{
    (
$r = @mysql_query("select email,groups from admin_users where {$param}='1'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1638 . "<BR>Function: " . "GetAdminEmailsWhereTrueParam" . "<BR>MySQL Error: " . mysql_error());
    
$res = array();

    if (
0 < mysql_num_rows($r)) {
        while (
$rr = mysql_fetch_object($r)) {
            if (
$rr->groups) {
                
$gr = @mb_split("::", $rr->groups);
            }
            else {
                
$gr = array();
            }

            if ((@
count($gr) == 0) || !$department || ($department && @in_array("{$department}", $gr))) {
                
$res[] = $rr->email;
            }
        }
    }

    return 
$res;
}

function 
GetAdminIdsWhereTrueParam($param, $department = "")
{
    (
$r = @mysql_query("select id,groups from admin_users where {$param}='1'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1657 . "<BR>Function: " . "GetAdminIdsWhereTrueParam" . "<BR>MySQL Error: " . mysql_error());
    
$res = array();

    if (
0 < mysql_num_rows($r)) {
        while (
$rr = mysql_fetch_object($r)) {
            if (
$rr->groups) {
                
$gr = @mb_split("::", $rr->groups);
            }
            else {
                
$gr = array();
            }

            if ((@
count($gr) == 0) || !$department || ($department && @in_array("{$department}", $gr))) {
                
$res[] = $rr->id;
            }
        }
    }

    return 
$res;
}

function 
GetAboutUsFromDiscount($id, $type)
{
    (
$r = @mysql_query("select discount" . $type . " as discount from aboutusfrom where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1676 . "<BR>Function: " . "GetAboutUsFromDiscount" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        
$r = mysql_fetch_object($r);
        return 
$r->discount;
    }
    else {
        return 
0;
    }
}

function 
GetSpecialCost($uid, $type, $id)
{
    if (
$type == "tarif") {
        
$row = "tarif_id";
    }
    else if (
$type == "zone") {
        
$row = "zone_id";
    }
    else if (
$type == "addon") {
        
$row = "addon_id";
    }
    else if (
$type == "shop") {
        
$row = "item_id";
    }

    (
$r = @mysql_query("select cost1,cost2 from specialcosts where uid='{$uid}' and {$row}='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1691 . "<BR>Function: " . "GetSpecialCost" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        
$r = mysql_fetch_object($r);
        
$result["cost1"] = $r->cost1;
        
$result["cost2"] = $r->cost2;
        return 
$result;
    }
    else {
        return 
false;
    }
}

function 
GetDomainsCntByRegistratorId($id)
{
    if (
$id) {
        (
$r = @mysql_query("select COUNT(*) as cnt from orders_domains where autoregby='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1704 . "<BR>Function: " . "GetDomainsCntByRegistratorId" . "<BR>MySQL Error: " . mysql_error());
        
$r = @mysql_fetch_object($r);
        return 
$r->cnt;
    }

    return 
0;
}

function 
GetRegistratorNameById($id)
{
    if (
$id) {
        (
$r = @mysql_query("select name from registrators where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1713 . "<BR>Function: " . "GetRegistratorNameById" . "<BR>MySQL Error: " . mysql_error());

        if (
0 < mysql_num_rows($r)) {
            
$r = @mysql_fetch_object($r);
            return 
$r->name;
        }
    }

    return 
"";
}

function 
GetRegistrators()
{
    (
$r = @mysql_query("select * from registrators")) || exit("File: " . __FILE__ . "<BR>Line: " . 1723 . "<BR>Function: " . "GetRegistrators" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
$r;
    }
}

function 
GetRegistratorTypeById($id)
{
    if (
$id) {
        (
$r = @mysql_query("select type from registrators where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1731 . "<BR>Function: " . "GetRegistratorTypeById" . "<BR>MySQL Error: " . mysql_error());

        if (
0 < mysql_num_rows($r)) {
            
$r = @mysql_fetch_object($r);
            return 
$r->type;
        }
    }

    return 
"";
}

function 
GetRegistratorById($id)
{
    (
$r = @mysql_query("select * from registrators where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1741 . "<BR>Function: " . "GetRegistratorById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
mysql_fetch_object($r);
    }
}

function 
GetFirstActiveRegistratorByType($type)
{
    (
$r = @mysql_query("select * from registrators where active='1' and type='{$type}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1748 . "<BR>Function: " . "GetFirstActiveRegistratorByType" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
mysql_fetch_object($r);
    }
}

function 
GetDomainCostForUserByZoneId($uid = 0, $zid, $withhost = 0, $transfer = 0)
{
    
$tzones = getzonebyid($zid);

    if (
$tzones->id) {
        
$domSpecCost = getspecialcost($uid, "zone", $zid);

        if (
$domSpecCost) {
            if (
$transfer && ($tzones->transferRenew == "2")) {
                
$domainCost = $domSpecCost["cost2"];
            }
            else {
                
$domainCost = $domSpecCost["cost1"];
            }
        }
        else {
            if (
$transfer && ($tzones->transferRenew == "2")) {
                if (
isuserdomainreseller($uid)) {
                    
$domainCost = $tzones->renew_if_domainreseller / getcurrencykoeficientbycode($tzones->renew_if_domainresellerCurrency);
                }
                else if (
isuseractivereseller($uid)) {
                    
$domainCost = $tzones->renew_if_reseller / getcurrencykoeficientbycode($tzones->renew_if_resellerCurrency);
                }
                else {
                    
$domainCostType = getsetting("domainCostType");
                    if ((
$domainCostType && (isuserhaveactiveorders($uid) || $withhost)) || (!$domainCostType && $withhost)) {
                        
$domainCost = $tzones->renew_if_host / getcurrencykoeficientbycode($tzones->renew_if_hostCurrency);
                    }
                    else {
                        
$domainCost = $tzones->renew_if_not_host / getcurrencykoeficientbycode($tzones->renew_if_not_hostCurrency);
                    }
                }
            }
            else if (
isuserdomainreseller($uid)) {
                
$domainCost = $tzones->cost_if_domainreseller / getcurrencykoeficientbycode($tzones->cost_if_domainresellerCurrency);
            }
            else if (
isuseractivereseller($uid)) {
                
$domainCost = $tzones->cost_if_reseller / getcurrencykoeficientbycode($tzones->cost_if_resellerCurrency);
            }
            else {
                
$domainCostType = getsetting("domainCostType");
                if ((
$domainCostType && (isuserhaveactiveorders($uid) || $withhost)) || (!$domainCostType && $withhost)) {
                    
$domainCost = $tzones->cost_if_host / getcurrencykoeficientbycode($tzones->cost_if_hostCurrency);
                }
                else {
                    
$domainCost = $tzones->cost_if_not_host / getcurrencykoeficientbycode($tzones->cost_if_not_hostCurrency);
                }
            }
        }

        if (
$transfer && $tzones->transferCost) {
            
$domainCost += $tzones->transferCost / getcurrencykoeficientbycode($tzones->transferCostCurrency);
        }
    }
    else {
        
$domainCost = 0;
    }

    return 
$domainCost;
}

function 
GetDomainMinCostForUserByZone($uid = 0, $zone, $withhost = 0)
{
    (
$r = @mysql_query("select * from zones where zone='{$zone}' and active='1'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1804 . "<BR>Function: " . "GetDomainMinCostForUserByZone" . "<BR>MySQL Error: " . mysql_error());
    
$costArr = array();

    while (
$rr = @mysql_fetch_object($r)) {
        
$costArr[] = getdomaincostforuserbyzoneid($uid, $rr->id, $withhost);
    }

    return 
min($costArr);
}

function 
GetDomainCostRenewForUserByZoneId($uid = 0, $zid, $withhost = 0)
{
    
$tzones = getzonebyid($zid);

    if (
$tzones->id) {
        if (
isuserdomainreseller($uid)) {
            
$domainCost = $tzones->renew_if_domainreseller / getcurrencykoeficientbycode($tzones->renew_if_domainresellerCurrency);
        }
        else if (
isuseractivereseller($uid)) {
            
$domainCost = $tzones->renew_if_reseller / getcurrencykoeficientbycode($tzones->renew_if_resellerCurrency);
        }
        else {
            
$domainCostType = getsetting("domainCostType");
            if ((
$domainCostType && (isuserhaveactiveorders($uid) || $withhost)) || (!$domainCostType && $withhost)) {
                
$domainCost = $tzones->renew_if_host / getcurrencykoeficientbycode($tzones->renew_if_hostCurrency);
            }
            else {
                
$domainCost = $tzones->renew_if_not_host / getcurrencykoeficientbycode($tzones->renew_if_not_hostCurrency);
            }
        }

        
$domSpecCost = getspecialcost($uid, "zone", $zid);

        if (
$domSpecCost) {
            
$domainCost = $domSpecCost["cost2"];
        }
    }
    else {
        
$domainCost = 0;
    }

    return 
$domainCost;
}

function 
GetKvitancii($active = 0)
{
    if (
$active) {
        
$addon = "where active=1";
    }

    (
$r = @mysql_query("select * from kvitancii {$addon}")) || exit("File: " . __FILE__ . "<BR>Line: " . 1841 . "<BR>Function: " . "GetKvitancii" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
$r;
    }
}

function 
GetKvitanciiById($id)
{
    if (
$id) {
        (
$r = @mysql_query("select * from kvitancii where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1849 . "<BR>Function: " . "GetKvitanciiById" . "<BR>MySQL Error: " . mysql_error());

        if (
0 < mysql_num_rows($r)) {
            return 
mysql_fetch_object($r);
        }
    }
}

function 
GetFakturas($active = 0)
{
    if (
$active) {
        
$addon = "where active=1";
    }

    (
$r = @mysql_query("select * from kvitancii_faktura {$addon}")) || exit("File: " . __FILE__ . "<BR>Line: " . 1859 . "<BR>Function: " . "GetFakturas" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
$r;
    }
}

function 
GetFakturasById($id)
{
    if (
$id) {
        (
$r = @mysql_query("select * from kvitancii_faktura where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 1867 . "<BR>Function: " . "GetFakturasById" . "<BR>MySQL Error: " . mysql_error());

        if (
0 < mysql_num_rows($r)) {
            return 
mysql_fetch_object($r);
        }
    }
}

function 
GetMoneyBackByOrderId($id)
{
    if (
$id) {
        
$order = getorderbyid($id);
        if (
$order->id && (0 < $order->leftdays)) {
            (
$bill = @mysql_query("select id,uid,host_srok,money_host from bills where status=1 and newtarif='0' and NOT(host_srok='0') and newaddons='' and host_id='{$order->id}' order by id desc LIMIT 0,1")) || exit("File: " . __FILE__ . "<BR>Line: " . 1878 . "<BR>Function: " . "GetMoneyBackByOrderId" . "<BR>MySQL Error: " . mysql_error());

            if (
0 < mysql_num_rows($bill)) {
                
$bill = mysql_fetch_object($bill);

                if (
$bill->money_host != "0") {
                    
$moneyBack = round($order->leftdays * ($bill->money_host / ($bill->host_srok * 30)), 2);
                }
                else {
                    
$moneyBack = "-";
                }
            }
            else {
                
$tarifSpecCost = getspecialcost($order->uid, "tarif", $order->tarif);

                if (
$tarifSpecCost) {
                    
$cost = $tarifSpecCost["cost2"];
                }
                else {
                    
$tarif = gettarifbyid($order->tarif);
                    
$cost = $tarif->cost / getcurrencykoeficientbycode($tarif->costCurrency);
                }

                if (
$cost != 0) {
                    
$moneyBack = round($order->leftdays * ($cost / 30), 2);
                }
                else {
                    
$moneyBack = "-";
                }
            }

            return 
$moneyBack;
        }
        else {
            return 
"-";
        }
    }
}

function 
ftpDeleteDir($ftp_server, $ftp_login, $ftp_password, $dir)
{
    
$conn_id = ftp_connect($ftp_server);
    
$login_result = ftp_login($conn_id, $ftp_login, $ftp_password);
    if (!
$conn_id || !$login_result) {
        return 
false;
    }

    
ftp_pasv($conn_id, true);
    
ftprecursivedelete($conn_id, $dir);
    
ftp_close($conn_id);
}

function 
ftpRecursiveDelete($handle, $directory)
{
    if (!@
ftp_rmdir($handle, $directory) || @ftp_delete($handle, $directory)) {
        
$filelist = @ftp_nlist($handle, $directory);

        foreach (
$filelist as $file ) {
            
ftprecursivedelete($handle, $file);
        }

        
ftprecursivedelete($handle, $directory);
    }
}

function 
ftpUploadDir($conn_id, $dir, $ftp_root)
{
    if (!
preg_match("/\/$/ui", $dir) && !preg_match("/\$/ui", $dir)) {
        
$dir = $dir . "/";
    }

    if (!
preg_match("/\/$/ui", $ftp_root)) {
        
$ftp_root = $ftp_root . "/";
    }

    if (@
is_dir($dir)) {
        
$dh = @opendir($dir);

        while ((
$file = @readdir($dh)) !== false) {
            if ((
$file != ".") && ($file != "..")) {
                if (@
is_file($dir . "/" . $file)) {
                    
ftp_put($conn_id, $ftp_root . $file, $dir . $file, FTP_BINARY);
                }
                else if (@
is_dir($dir . "/" . $file)) {
                    @
ftp_mkdir($conn_id, $ftp_root . $file);
                    
ftpuploaddir($conn_id, $dir . $file . "/", $ftp_root . $file . "/");
                }
            }
        }

        @
closedir($dh);
    }
}

function 
rmdirr($dirname)
{
    if (!
file_exists($dirname)) {
        return 
false;
    }

    if (
is_file($dirname) || is_link($dirname)) {
        return 
unlink($dirname);
    }

    
$dir = dir($dirname);

    while (
false !== $entry = $dir->read()) {
        if ((
$entry == ".") || ($entry == "..")) {
            continue;
        }

        
rmdirr($dirname . DIRECTORY_SEPARATOR . $entry);
    }

    
$dir->close();
    return 
rmdir($dirname);
}

function 
checkAdminAccess($in, $printerror = 0)
{
    
$_SESSION = &$_SESSION;
    global 
$version;
    global 
$full_home_path;

    if (
$_SESSION["adminFullAccess"]) {
        return 
true;
    }
    else if (@
in_array($in, $_SESSION["adminAccesstoArray"])) {
        return 
true;
    }
    else {
        if (
$printerror) {
            print(
"<center><font color=red>Access denied!</font></center>");
            include (
$full_home_path . "/_rootinc/adminfoot.inc.php");
            
mclose();
            exit();
        }

        return 
false;
    }
}

function 
writeAdminLog($val, $aid = "")
{
    
$_SESSION = &$_SESSION;

    if (!
$aid) {
        
$aid = $_SESSION["adminId"];
    }

    @
mysql_query("INSERT INTO admin_logs (aid,dt,val) VALUES('{$aid}',NOW(),'{$val}')") || exit("File: " . __FILE__ . "<BR>Line: " . 2010 . "<BR>Function: " . "writeAdminLog" . "<BR>MySQL Error: " . mysql_error());
}

function 
GetAdminByLogin($login)
{
    if (
$login) {
        (
$r = @mysql_query("select * from admin_users where login='{$login}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2015 . "<BR>Function: " . "GetAdminByLogin" . "<BR>MySQL Error: " . mysql_error());

        if (
0 < mysql_num_rows($r)) {
            return 
mysql_fetch_object($r);
        }
    }
}

function 
GetAdminById($id)
{
    if (
$id) {
        (
$r = @mysql_query("select * from admin_users where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2024 . "<BR>Function: " . "GetAdminById" . "<BR>MySQL Error: " . mysql_error());

        if (
0 < mysql_num_rows($r)) {
            return 
mysql_fetch_object($r);
        }
    }
}

function 
WriteMailLog($subject, $message, $uid = "")
{
    if ((
$uid && getsetting("mailLogUserEnable")) || (!$uid && getsetting("mailLogAdminEnable"))) {
        if (
$subject && $message) {
            
$subject = htmlencode($subject);
            
$message = htmlencode($message);
            @
mysql_query("insert into mail_logs (uid,dt,subject,message) values('{$uid}',NOW(),'{$subject}','" . addslashes($message) . "')") || exit("File: " . __FILE__ . "<BR>Line: " . 2036 . "<BR>Function: " . "WriteMailLog" . "<BR>MySQL Error: " . mysql_error());
            return 
true;
        }
        else {
            return 
false;
        }
    }
    else {
        return 
false;
    }
}

function 
hmac($key, $data)
{
    
$b = 64;

    if (
$b < strlen($key)) {
        
$key = pack("H*", md5($key));
    }

    
$key = str_pad($key, $b, chr(0));
    
$ipad = str_pad("", $b, chr(54));
    
$opad = str_pad("", $b, chr(92));
    
$k_ipad = $key ^ $ipad;
    
$k_opad = $key ^ $opad;
    return 
md5($k_opad . pack("H*", md5($k_ipad . $data)));
}

function 
GetCoupon($type, $code, $isRenew, $oType, $id)
{
    if (
$type && $code) {
        (
$r = @mysql_query("select * from coupons where type='{$type}' and code='{$code}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2065 . "<BR>Function: " . "GetCoupon" . "<BR>MySQL Error: " . mysql_error());

        if (
$type == "coupon") {
            if (
0 < @mysql_num_rows($r)) {
                return @
mysql_fetch_object($r);
            }
            else {
                return 
false;
            }
        }
        else {
            while (
$rr = @mysql_fetch_object($r)) {
                if ((
$rr->ordersType == "new") && $isRenew) {
                    continue;
                }
                else {
                    if ((
$rr->ordersType == "renew") && !$isRenew) {
                        continue;
                    }
                    else {
                        if (
$oType == "tarif") {
                            
$oType = $rr->tarifsType;
                            
$oValue = @unserialize($rr->tarifsValue);
                        }
                        else if (
$oType == "addon") {
                            
$oType = $rr->addonsType;
                            
$oValue = @unserialize($rr->addonsValue);
                        }
                        else if (
$oType == "zone") {
                            
$oType = $rr->zonesType;
                            
$oValue = @unserialize($rr->zonesValue);
                        }
                        else if (
$oType == "shopitem") {
                            
$oType = $rr->shopItemsType;
                            
$oValue = @unserialize($rr->shopItemsValue);
                        }

                        if (
$oType == "all") {
                            return 
$rr;
                            break;
                        }
                        else {
                            if ((
$oType == "select") && @in_array("{$id}", $oValue)) {
                                return 
$rr;
                                break;
                            }
                            else {
                                continue;
                            }
                        }
                    }
                }
            }
        }
    }
}

function 
GetCouponActiveCount($type)
{
    (
$r = @mysql_query("select * from coupons where type='{$type}' and active='1'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2094 . "<BR>Function: " . "GetCouponActiveCount" . "<BR>MySQL Error: " . mysql_error());
    return 
mysql_num_rows($r);
}

function 
IsCanUseCoupon($id, $uid)
{
    if (
$id) {
        (
$r = @mysql_query("select *,TO_DAYS(toDate)-TO_DAYS(NOW()) as leftdays from coupons where id='{$id}' and active='1'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2100 . "<BR>Function: " . "IsCanUseCoupon" . "<BR>MySQL Error: " . mysql_error());

        if (
0 < mysql_num_rows($r)) {
            
$r = mysql_fetch_object($r);
            if ((
$r->leftdays == "") || (($r->leftdays != "") && (0 <= $r->leftdays))) {
                if (
$r->usedBy) {
                    
$usedBy = mb_split("\,", $r->usedBy);
                    
$usersArray = array();
                    
$usersBills = array();
                    
$cntUsersArray = array();

                    while (list(
$index, $value) = each($usedBy)) {
                        if (
preg_match("/\:/ui", $value)) {
                            
$sub = mb_split("\:", $value);
                            
$userId = $sub[0];
                            
$billId = $sub[1];
                            
$usersArray[] = $userId;
                            
$cntUsersArray[$userId] = $cntUsersArray[$userId] + 1;
                            
$usersBills[$userId][] = $billId;
                        }
                        else {
                            
$usersArray[] = $value;
                            
$cntUsersArray[$value] = $cntUsersArray[$value] + 1;
                        }
                    }

                    if (
$r->canUsed == "1") {
                        return 
false;
                    }
                    else if (
$r->canUsed == "2") {
                        if (
$uid) {
                            if (
in_array($uid, $usersArray)) {
                                return 
true;
                            }
                            else {
                                return 
false;
                            }
                        }
                        else {
                            return 
false;
                        }
                    }
                    else if (
$r->canUsed == "3") {
                        if (
$uid) {
                            if (
0 < $cntUsersArray[$uid]) {
                                return 
false;
                            }
                            else {
                                return 
true;
                            }
                        }
                        else {
                            return 
true;
                        }
                    }
                    else if (
$r->canUsed == "4") {
                        return 
true;
                    }
                }
                else {
                    return 
true;
                }
            }
            else {
                return 
false;
            }
        }
        else {
            return 
false;
        }
    }
    else {
        return 
false;
    }
}

function 
AddUsedByToCoupon($couponId, $uid, $billid = "")
{
    if (
$billid) {
        
$value = "{$uid}:{$billid}";
    }
    else {
        
$value = "{$uid}";
    }

    (
$r = @mysql_query("select usedBy from coupons where id='{$couponId}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2163 . "<BR>Function: " . "AddUsedByToCoupon" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        
$r = mysql_fetch_object($r);

        if (
$r->usedBy) {
            
$usedBy = mb_split("\,", $r->usedBy);
            
$usedBy[] = $value;
            
$toSQL = @join(",", $usedBy);
        }
        else {
            
$toSQL = $value;
        }

        @
mysql_query("update coupons set usedBy='{$toSQL}' where id='{$couponId}'") || exit("File: " . __FILE__ . "<BR>Line: " . 2176 . "<BR>Function: " . "AddUsedByToCoupon" . "<BR>MySQL Error: " . mysql_error());
    }
}

function 
xml2array($text)
{
    
$reg_exp = "/<(\S+)[^>]*>(.*?)<\/\1>/su";
    
$reg_exp2 = "/<([^\/]+)\/>/u";
    
preg_match_all($reg_exp, $text, $match);

    foreach (
$match[1] as $key => $val ) {
        if (
preg_match($reg_exp, $match[2][$key])) {
            
$array[$val][] = xml2array($match[2][$key]);
        }
        else if (
preg_match($reg_exp2, $match[2][$key], $m)) {
            
$nn = $m[1];
            
$array[$val][][$nn] = "";
        }
        else if (
$lastVal == $val) {
            
$i++;
            
$valN = $val . $i;
        }
        else {
            
$i = 0;
            
$valN = $val;
        }

        
$array[$valN] = html_entity_decode($match[2][$key]);
        
$lastVal = $val;
    }

    return 
$array;
}

function 
GetUsersMenu($id = "", $cat = "")
{
    if (
$id) {
        (
$r = @mysql_query("select * from users_menu where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2201 . "<BR>Function: " . "GetUsersMenu" . "<BR>MySQL Error: " . mysql_error());

        if (
0 < mysql_num_rows($r)) {
            return 
mysql_fetch_object($r);
        }
    }
    else {
        if (
$cat) {
            
$where = "WHERE cat='{$cat}'";
        }

        (
$z = @mysql_query("select * from users_menu {$where} order by cat,sort")) || exit("File: " . __FILE__ . "<BR>Line: " . 2208 . "<BR>Function: " . "GetUsersMenu" . "<BR>MySQL Error: " . mysql_error());

        if (
0 < mysql_num_rows($z)) {
            return 
$z;
        }
    }
}

function 
getFileType($file)
{
    
$handle = fopen($file, "r");
    
$contents = fread($handle, 2);
    
fclose($handle);
    
$firstTwoByte = bin2hex($contents[0] . $contents[1]);
    
$typesArray = array("ffd8" => "image/jpeg", "4749" => "image/gif", "8950" => "image/png", "424d" => "image/bmp", "2550" => "application/pdf");
    
$type = $typesArray[$firstTwoByte];
    return 
$type;
}

function 
uploadPassportFiles($field_name, $profileid, $filenameaddon)
{
    global 
$full_home_path;
    
$_FILES = &$_FILES;
    global 
$UploadError;

    if (
$_FILES[$field_name][name]) {
        if (
$_FILES[$field_name]["error"] == 0) {
            
$mimetype = getfiletype($_FILES[$field_name]["tmp_name"]);

            if (
$mimetype == "image/jpeg") {
                
$ext = "jpg";
            }
            else if (
$mimetype == "image/gif") {
                
$ext = "gif";
            }
            else if (
$mimetype == "image/png") {
                
$ext = "png";
            }
            else if (
$mimetype == "application/pdf") {
                
$ext = "pdf";
            }
            else {
                
$ext = "";
            }

            if (
$ext) {
                
$newfile = "passport_" . $profileid . "_" . $filenameaddon . "." . $ext;
                
$file = $full_home_path . "/_rootfiles/" . $newfile;

                if (!
file_exists($file)) {
                    if (
move_uploaded_file($_FILES[$field_name]["tmp_name"], $file)) {
                        @
chmod($file, 511);
                        return 
$newfile;
                    }
                    else {
                        
$UploadError = "cant move tmp file";
                        return 
false;
                    }
                }
                else {
                    
$UploadError = "file exists";
                    return 
false;
                }
            }
            else {
                
$UploadError = "bad mime type";
                return 
false;
            }
        }
        else {
            
$UploadError = "code: " . $_FILES[$field_name]["error"];
            return 
false;
        }
    }
}

function 
IsProfileUsed($profileId)
{
    (
$r = @mysql_query("select * from orders_domains where profileId='{$profileId}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2265 . "<BR>Function: " . "IsProfileUsed" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
true;
    }
    else {
        (
$r = @mysql_query("select * from users where defaultProfileId='{$profileId}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2269 . "<BR>Function: " . "IsProfileUsed" . "<BR>MySQL Error: " . mysql_error());

        if (
0 < mysql_num_rows($r)) {
            return 
true;
        }
        else {
            return 
false;
        }
    }
}

function 
IsEmailUsed($email)
{
    (
$r = @mysql_query("select * from users where (email='{$email}' OR email2='{$email}')")) || exit("File: " . __FILE__ . "<BR>Line: " . 2279 . "<BR>Function: " . "IsEmailUsed" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
true;
    }
    else {
        return 
false;
    }
}

function 
hexbin($temp)
{
    
$len = strlen($temp);
    
$i = 0;

    for (; 
$i < $len; $i += 2) {
        
$data .= chr(hexdec(substr($temp, $i, 2)));
    }

    return 
$data;
}

function 
GetServersIPs($server_id, $order_id = "")
{
    if (
$order_id) {
        
$addon = "and order_id='{$order_id}'";
    }

    (
$r = @mysql_query("select * from servers_ips where server_id='{$server_id}' {$addon} order by ip")) || exit("File: " . __FILE__ . "<BR>Line: " . 2296 . "<BR>Function: " . "GetServersIPs" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
$r;
    }
}

function 
GetFreeServerIP($server_id)
{
    (
$r = @mysql_query("select * from servers_ips where server_id='{$server_id}' and order_id='0' LIMIT 0,1")) || exit("File: " . __FILE__ . "<BR>Line: " . 2303 . "<BR>Function: " . "GetFreeServerIP" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        
$r = @mysql_fetch_object($r);
        return 
$r;
    }
}

function 
GetOrderIpByOrderId($order_id)
{
    
$order = getorderbyid($order_id);
    if (
$order->id && $order->serverid) {
        
$server = getservers($order->serverid);
        (
$r = @mysql_query("select * from servers_ips where server_id='{$server->id}' and order_id='{$order->id}' and isMain='1'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2315 . "<BR>Function: " . "GetOrderIpByOrderId" . "<BR>MySQL Error: " . mysql_error());

        if (
0 < mysql_num_rows($r)) {
            
$r = mysql_fetch_object($r);
            return 
$r->ip;
        }
        else {
            return 
$server->userip;
        }
    }
}

function 
printTarifCost($tarif_id, $valuta, $months, $enc = "windows-1251")
{
    
mconnect();
    
$tarif = gettarifbyid($tarif_id);

    if (
$tarif->id) {
        (
$srok = @mysql_query("select * from tarifs_sroki where tarif_id='{$tarif->id}' and months='{$months}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2329 . "<BR>Function: " . "printTarifCost" . "<BR>MySQL Error: " . mysql_error());

        if (
0 < mysql_num_rows($srok)) {
            
$srok = mysql_fetch_object($srok);
            
$currency = getcurrencybycode(strtoupper($valuta));

            if (
$currency->code) {
                
$cost = ($tarif->cost * $months) - ((($tarif->cost * $months) / 100) * $srok->discount);
                
$cost = $cost * $currency->koeficient;
                
$cost = round($cost, 2);

                if (
$enc == "utf-8") {
                }
                else if (
$enc == "koi8-r") {
                    
$currency->symbol = iconv("utf-8", "koi8-r", $currency->symbol);
                }
                else if (
$enc == "windows-1251") {
                    
$currency->symbol = iconv("utf-8", "windows-1251", $currency->symbol);
                }

                print(
$cost . " " . $currency->symbol);
            }
            else {
                print(
"no currency");
            }
        }
        else {
            print(
"no srok");
        }
    }
    else {
        print(
"no tarif");
    }
}

function 
GetShopItemGroups()
{
    (
$z = @mysql_query("select * from shop_groups order by name")) || exit("File: " . __FILE__ . "<BR>Line: " . 2358 . "<BR>Function: " . "GetShopItemGroups" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
$z;
    }
}

function 
GetShopItemGroupById($id)
{
    (
$z = @mysql_query("select * from shop_groups where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2365 . "<BR>Function: " . "GetShopItemGroupById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
mysql_fetch_object($z);
    }
}

function 
IsShopItemInUse($id)
{
    (
$z = @mysql_query("select * from orders_shop where item='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2372 . "<BR>Function: " . "IsShopItemInUse" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
true;
    }
    else {
        return 
false;
    }
}

function 
GetShopItemById($id)
{
    (
$z = @mysql_query("select * from shop_items where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2381 . "<BR>Function: " . "GetShopItemById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetOrderShopById($id, $uid = "")
{
    if (
$uid) {
        
$sqladdon = "and uid='{$uid}'";
    }
    else {
        
$sqladdon = "";
    }

    (
$z = @mysql_query("select *,TO_DAYS(todate)-TO_DAYS(NOW()) as leftdays,UNIX_TIMESTAMP(todate) as todateunixtimestamp from orders_shop where id='{$id}' {$sqladdon}")) || exit("File: " . __FILE__ . "<BR>Line: " . 2391 . "<BR>Function: " . "GetOrderShopById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);
        return 
$z;
    }
}

function 
GetShopItems()
{
    (
$z = @mysql_query("select * from shop_items order by name")) || exit("File: " . __FILE__ . "<BR>Line: " . 2399 . "<BR>Function: " . "GetShopItems" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
$z;
    }
}

function 
GetFaqGroups()
{
    (
$z = @mysql_query("select * from faq_groups order by sort,id")) || exit("File: " . __FILE__ . "<BR>Line: " . 2406 . "<BR>Function: " . "GetFaqGroups" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
$z;
    }
}

function 
GetFaqGroupById($id)
{
    (
$z = @mysql_query("select * from faq_groups where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2413 . "<BR>Function: " . "GetFaqGroupById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
mysql_fetch_object($z);
    }
}

function 
GetZonesGroups()
{
    (
$z = @mysql_query("select * from zones_groups order by sort,id")) || exit("File: " . __FILE__ . "<BR>Line: " . 2420 . "<BR>Function: " . "GetZonesGroups" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
$z;
    }
}

function 
GetZonesGroupById($id)
{
    (
$z = @mysql_query("select * from zones_groups where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2427 . "<BR>Function: " . "GetZonesGroupById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
mysql_fetch_object($z);
    }
}

function 
GetFaqs($group = "")
{
    if (
$group != "") {
        
$addon = "where `group`='{$group}'";
    }

    (
$z = @mysql_query("select * from faq {$addon} order by `group`,sort,id")) || exit("File: " . __FILE__ . "<BR>Line: " . 2436 . "<BR>Function: " . "GetFaqs" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
$z;
    }
}

function 
GetFaqById($id)
{
    (
$z = @mysql_query("select * from faq where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2443 . "<BR>Function: " . "GetFaqById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
mysql_fetch_object($z);
    }
}

function 
printDomainCost($zone_id, $costType, $isRenew, $valuta, $enc = "windows-1251")
{
    
mconnect();
    
$zone = getzonebyid($zone_id);

    if (
$zone->id) {
        if (
$costType == "cost1") {
            if (
$isRenew) {
                
$cost = $zone->renew_if_not_host / getcurrencykoeficientbycode($zone->renew_if_not_hostCurrency);
            }
            else {
                
$cost = $zone->cost_if_not_host / getcurrencykoeficientbycode($zone->cost_if_not_hostCurrency);
            }
        }
        else if (
$costType == "cost2") {
            if (
$isRenew) {
                
$cost = $zone->renew_if_host / getcurrencykoeficientbycode($zone->renew_if_hostCurrency);
            }
            else {
                
$cost = $zone->cost_if_host / getcurrencykoeficientbycode($zone->cost_if_hostCurrency);
            }
        }
        else if (
$costType == "reseller") {
            if (
$isRenew) {
                
$cost = $zone->renew_if_reseller / getcurrencykoeficientbycode($zone->renew_if_resellerCurrency);
            }
            else {
                
$cost = $zone->cost_if_reseller / getcurrencykoeficientbycode($zone->cost_if_resellerCurrency);
            }
        }
        else if (
$costType == "domainreseller") {
            if (
$isRenew) {
                
$cost = $zone->renew_if_domainreseller / getcurrencykoeficientbycode($zone->renew_if_domainresellerCurrency);
            }
            else {
                
$cost = $zone->cost_if_domainreseller / getcurrencykoeficientbycode($zone->cost_if_domainresellerCurrency);
            }
        }
        else {
            print(
"no costtype");
        }

        if (
$cost) {
            
$currency = getcurrencybycode(strtoupper($valuta));

            if (
$currency->code) {
                
$cost = $cost * $currency->koeficient;
                
$cost = round($cost, 2);

                if (
$enc == "utf-8") {
                }
                else if (
$enc == "koi8-r") {
                    
$currency->symbol = iconv("utf-8", "koi8-r", $currency->symbol);
                }
                else if (
$enc == "windows-1251") {
                    
$currency->symbol = iconv("utf-8", "windows-1251", $currency->symbol);
                }

                print(
$cost . " " . $currency->symbol);
            }
            else {
                print(
"no currency");
            }
        }
    }
    else {
        print(
"no zone");
    }
}

function 
parseRPStrArray($str, $d1, $d2)
{
    
$ss = @mb_split("{$d1}", $str);

    while (list(
$k, $v) = @each($ss)) {
        
$qq = @mb_split("{$d2}", $v);
        
$param = $qq[0];
        
$value = $qq[1];
        if (
$param && $value) {
            
$res_array[$param] = $value;
        }
    }

    return 
$res_array;
}

function 
parseRPArrayStr($arrayTo, $d1, $d2)
{
    while (list(
$k, $v) = @each($arrayTo)) {
        
$arrayToJoin[] = $k . "{$d2}" . $v;
    }

    
$resString = @join($d1, $arrayToJoin);
    return 
$resString;
}

function 
GetAdminGroups()
{
    (
$z = @mysql_query("select * from admin_groups order by name")) || exit("File: " . __FILE__ . "<BR>Line: " . 2527 . "<BR>Function: " . "GetAdminGroups" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
$z;
    }
}

function 
GetAdminGroupById($id)
{
    (
$z = @mysql_query("select * from admin_groups where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2534 . "<BR>Function: " . "GetAdminGroupById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        return 
mysql_fetch_object($z);
    }
}

function 
printCourses($code, $enc = "utf-8")
{
    @
mconnect();
    
$code = strtoupper($code);
    (
$z = @mysql_query("select * from currency where code='{$code}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2543 . "<BR>Function: " . "printCourses" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($z)) {
        
$z = mysql_fetch_object($z);

        if (
$enc == "utf-8") {
        }
        else if (
$enc == "koi8-r") {
            
$z->symbol = iconv("utf-8", "koi8-r", $z->symbol);
        }
        else if (
$enc == "windows-1251") {
            
$z->symbol = iconv("utf-8", "windows-1251", $z->symbol);
        }

        print(
$z->koeficient . " " . $z->symbol);
    }
    else {
        print(
"no currency");
    }
}

function 
IsNonCheckedTestimonials()
{
    (
$r = @mysql_query("select id from testimonials where checked=0 LIMIT 0,1")) || exit("File: " . __FILE__ . "<BR>Line: " . 2562 . "<BR>Function: " . "IsNonCheckedTestimonials" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
true;
    }
}

function 
GetSMSGateways($onlyActive = 0)
{
    if (
$onlyActive) {
        
$where = "where active=1";
    }

    (
$r = @mysql_query("select * from smsgateways {$where}")) || exit("File: " . __FILE__ . "<BR>Line: " . 2569 . "<BR>Function: " . "GetSMSGateways" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
$r;
    }
}

function 
GetSMSGatewayTypeById($id)
{
    if (
$id) {
        (
$r = @mysql_query("select type from smsgateways where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2577 . "<BR>Function: " . "GetSMSGatewayTypeById" . "<BR>MySQL Error: " . mysql_error());

        if (
0 < mysql_num_rows($r)) {
            
$r = @mysql_fetch_object($r);
            return 
$r->type;
        }
    }

    return 
"";
}

function 
GetSMSGatewayById($id)
{
    (
$r = @mysql_query("select * from smsgateways where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2587 . "<BR>Function: " . "GetSMSGatewayById" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        return 
mysql_fetch_object($r);
    }
}

function 
GetDomainsFreeCountTodayByUserId($userid)
{
    (
$r = @mysql_query("select freeDomainCount from users where id='{$userid}' and TO_DAYS(freeDomainDay)=TO_DAYS(NOW())")) || exit("File: " . __FILE__ . "<BR>Line: " . 2594 . "<BR>Function: " . "GetDomainsFreeCountTodayByUserId" . "<BR>MySQL Error: " . mysql_error());

    if (
0 < mysql_num_rows($r)) {
        
$r = mysql_fetch_object($r);
        return 
$r->freeDomainCount;
    }
    else {
        return 
0;
    }
}

function 
encodePwd($data, $decode = 0)
{
    
$pwd = "dfkDFG$#rdsf%^4dsfxdsf23534";

    if (!
$data) {
        return 
"";
    }

    
$pwd_length = strlen($pwd);
    
$i = 0;

    for (; 
$i < 255; $i++) {
        
$key[$i] = ord(substr($pwd, ($i % $pwd_length) + 1, 1));
        
$counter[$i] = $i;
    }

    
$i = 0;

    for (; 
$i < 255; $i++) {
        
$x = ($x + $counter[$i] + $key[$i]) % 256;
        
$temp_swap = $counter[$i];
        
$counter[$i] = $counter[$x];
        
$counter[$x] = $temp_swap;
    }

    
$i = 0;

    for (; 
$i < strlen($data); $i++) {
        
$a = ($a + 1) % 256;
        
$j = ($j + $counter[$a]) % 256;
        
$temp = $counter[$a];
        
$counter[$a] = $counter[$j];
        
$counter[$j] = $temp;
        
$k = $counter[($counter[$a] + $counter[$j]) % 256];
        
$Zcipher = ord(substr($data, $i, 1)) ^ $k;
        
$Zcrypt .= chr($Zcipher);
    }

    if (
$decode) {
        return 
$Zcrypt;
    }
    else {
        return 
bin2hex($Zcrypt);
    }
}

function 
decodePwd($data)
{
    return 
encodepwd(hex2binrp($data), 1);
}

function 
hex2binRP($hexdata)
{
    
$i = 0;

    for (; 
$i < strlen($hexdata); $i += 2) {
        
$bindata .= chr(hexdec(substr($hexdata, $i, 2)));
    }

    return 
$bindata;
}

function 
AddAPILog($login, $command, $status, $serializedData, $id = "", $querySeconds = "")
{
    global 
$ip;

    if (!
$id) {
        @
mysql_query("INSERT INTO api_logs (dtStart,ip,login,command,request) VALUES(NOW(),'{$ip}','{$login}','{$command}','{$serializedData}')") || exit(mysql_error());
        
$id = @mysql_insert_id();
        return 
$id;
    }
    else {
        @
mysql_query("UPDATE api_logs set dtEnd=NOW(),querySeconds='{$querySeconds}',response='{$serializedData}',status='{$status}' WHERE id='{$id}'") || exit(mysql_error());
        return 
true;
    }
}

function 
addWhoisLog($userid, $domain, $result)
{
    global 
$ip;
    
$whoisLogEnable = getsetting("whoisLogEnable");

    if (
$whoisLogEnable) {
        @
mysql_query("INSERT INTO whois_logs (uid,domain,dt,result,ip) VALUES('{$userid}','{$domain}',NOW(),'{$result}','{$ip}')") || exit(mysql_error());
        return 
true;
    }
    else {
        return 
false;
    }
}

function 
GetPaymentSystemById($id)
{
    if (
$id) {
        (
$r = @mysql_query("select * from pay_systems where id='{$id}'")) || exit("File: " . __FILE__ . "<BR>Line: " . 2678 . "<BR>Function: " . "GetPaymentSystemById" . "<BR>MySQL Error: " . mysql_error());

        if (
0 < mysql_num_rows($r)) {
            return @
mysql_fetch_object($r);
        }
    }
}

function 
xmlToArrayL($xml, $get_attributes = 1, $priority = "tag")
{
    if (!
$xml) {
        return array();
    }

    if (!
function_exists("xml_parser_create")) {
        return array();
    }

    
$xml = preg_replace("/<\w+:(\w+)/", "<$1", $xml);
    
$xml = preg_replace("/<\/\w+:(\w+)/", "</$1", $xml);
    
$parser = xml_parser_create("");
    
xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8");
    
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, trim($xml), $xml_values);
    
xml_parser_free($parser);

    if (!
$xml_values) {
        return 
NULL;
    }

    
$xml_array = array();
    
$parents = array();
    
$opened_tags = array();
    
$arr = array();
    
$current = &$xml_array;
    
$repeated_tag_index = array();

    foreach (
$xml_values as $data ) {
        unset(
$attributes);
        unset(
$value);
        
extract($data);
        
$result = array();
        
$attributes_data = array();

        if (isset(
$value)) {
            if (
$priority == "tag") {
                
$result = $value;
            }
            else {
                
$result["value"] = $value;
            }
        }

        if (isset(
$attributes) && $get_attributes) {
            foreach (
$attributes as $attr => $val ) {
                if (
$priority == "tag") {
                    
$attributes_data[$attr] = $val;
                }
                else {
                    
$result["attr"][$attr] = $val;
                }
            }
        }

        if (
$type == "open") {
            
$parent[$level - 1] = &$current;
            if (!
is_array($current) || !in_array($tag, array_keys($current))) {
                
$current[$tag] = $result;

                if (
$attributes_data) {
                    
$current[$tag . "_attr"] = $attributes_data;
                }

                
$repeated_tag_index[$tag . "_" . $level] = 1;
                
$current = &$current[$tag];
            }
            else {
                if (isset(
$current[$tag][0])) {
                    
$current[$tag][$repeated_tag_index[$tag . "_" . $level]] = $result;
                    
$repeated_tag_index[$tag . "_" . $level]++;
                }
                else {
                    
$current[$tag] = array($current[$tag], $result);
                    
$repeated_tag_index[$tag . "_" . $level] = 2;

                    if (isset(
$current[$tag . "_attr"])) {
                        
$current[$tag]["0_attr"] = $current[$tag . "_attr"];
                        unset(
$current[$tag . "_attr"]);
                    }
                }

                
$last_item_index = $repeated_tag_index[$tag . "_" . $level] - 1;
                
$current = &$current[$tag][$last_item_index];
            }
        }
        else if (
$type == "complete") {
            if (!isset(
$current[$tag])) {
                
$current[$tag] = $result;
                
$repeated_tag_index[$tag . "_" . $level] = 1;
                if ((
$priority == "tag") && $attributes_data) {
                    
$current[$tag . "_attr"] = $attributes_data;
                }
            }
            else {
                if (isset(
$current[$tag][0]) && is_array($current[$tag])) {
                    
$current[$tag][$repeated_tag_index[$tag . "_" . $level]] = $result;
                    if ((
$priority == "tag") && $get_attributes && $attributes_data) {
                        
$current[$tag][$repeated_tag_index[$tag . "_" . $level] . "_attr"] = $attributes_data;
                    }

                    
$repeated_tag_index[$tag . "_" . $level]++;
                }
                else {
                    
$current[$tag] = array($current[$tag], $result);
                    
$repeated_tag_index[$tag . "_" . $level] = 1;
                    if ((
$priority == "tag") && $get_attributes) {
                        if (isset(
$current[$tag . "_attr"])) {
                            
$current[$tag]["0_attr"] = $current[$tag . "_attr"];
                            unset(
$current[$tag . "_attr"]);
                        }

                        if (
$attributes_data) {
                            
$current[$tag][$repeated_tag_index[$tag . "_" . $level] . "_attr"] = $attributes_data;
                        }
                    }

                    
$repeated_tag_index[$tag . "_" . $level]++;
                }
            }
        }
        else if (
$type == "close") {
            
$current = &$parent[$level - 1];
        }
    }

    return 
$xml_array;
}

function 
calculatePromoDiscountWithMaxSrok($summ, $srok, $promoMaxSrok, $promoDiscount)
{
    if (
$promoMaxSrok && ($promoMaxSrok < $srok)) {
        
$oneMonthCost = $summ / $srok;
        
$summWithoutDiscount = $oneMonthCost * ($srok - $promoMaxSrok);
        
$summForDiscount = $oneMonthCost * $promoMaxSrok;
        
$summDiscount = ($summForDiscount / 100) * $promoDiscount;
        
$result[summDiscount] = $summDiscount;
        
$result[totalSummWithDiscount] = ($summForDiscount - $summDiscount) + $summWithoutDiscount;
    }
    else {
        
$result[summDiscount] = ($summ / 100) * $promoDiscount;
        
$result[totalSummWithDiscount] = $summ - (($summ / 100) * $promoDiscount);
    }

    return 
$result;
}

function 
GetUserActiveReferalsLevel1Count($userId)
{
    
$cnt = 0;
    
$referals = getuserreferalsarray($userId);

    while (list(
$id, $refArray) = @each($referals)) {
        if (
getbillpayedcountbyuserid($id) || isuserhaveactiveorders($id) || isuserhaveactivedomainorders($id) || isuserhaveactiveshoporders($id)) {
            
$cnt++;
        }
    }

    return 
$cnt;
}

function 
convertToLinks($text)
{
    
$text = preg_replace("/((ht|f)tp(s)?:\/\/[\w]+[^ "nrt<]*)/is", "<a href="$1" target="_blank">$1</a>", $text);
    
$text = preg_replace("/([a-z0-9&\-_\.]+?)@([\w\-]+\.([\w\-\.]+)+)/i", "<a href="mailto:$1@$2" target="_blank">$1@$2</a>", $text);
    return 
$text;
}

function GetOneAddonsCntForOrderId(
$orderid, $addonid)
{
    
$order = getorderbyid($orderid);
    
$addonsIdsArray = getaddonsidsbytxt($order->addons);
    
$cnt = 0;

    while (list(
$k, $v) = @each($addonsIdsArray)) {
        if (
$v == $addonid) {
            
$cnt++;
        }
    }

    return 
$cnt;
}

@ini_set("
magic_quotes_runtime", 0);
@set_time_limit(200);
@mb_internal_encoding("
UTF-8");
$sc = "1";

while (list(
$key, $val) = @each($_GET)) {
    if (!is_array(
$val)) {
        if (
$key != "message") {
            
$val = stripslashes($val);
        }

        $
$key = htmlencode($val);
        
$_GET["{$key}"] = $$key;
        
$queryParametersForLog["{$key}"] = $$key;
    }
    else {
        $
$key = array();
        
$tmp = array();

        while (list(
$kkey, $vval) = @each($val)) {
            if (!is_array(
$vval)) {
                if (
$kkey != "message") {
                    
$vval = stripslashes($vval);
                }

                
$tmp[$kkey] = htmlencode($vval);
            }
            else {
                
$tmp2 = array();

                while (list(
$kkkey, $vvval) = @each($vval)) {
                    if (
$kkkey != "message") {
                        
$vvval = stripslashes($vvval);
                    }

                    
$tmp2[$kkkey] = htmlencode($vvval);
                }

                
$tmp[$kkey] = $tmp2;
            }
        }

        $
$key = $tmp;
        
$_GET["{$key}"] = $tmp;
        
$queryParametersForLog["{$key}"] = $tmp;
    }
}

while (list(
$key, $val) = @each($_POST)) {
    if (!is_array(
$val)) {
        if (
$key != "message") {
            
$val = stripslashes($val);
        }

        $
$key = htmlencode($val);
        
$_POST["{$key}"] = $$key;
        
$queryParametersForLog["{$key}"] = $$key;
    }
    else {
        $
$key = array();
        
$tmp = array();

        while (list(
$kkey, $vval) = @each($val)) {
            if (!is_array(
$vval)) {
                if (
$kkey != "message") {
                    
$vval = stripslashes($vval);
                }

                
$tmp[$kkey] = htmlencode($vval);
            }
            else {
                
$tmp2 = array();

                while (list(
$kkkey, $vvval) = @each($vval)) {
                    if (
$kkkey != "message") {
                        
$vvval = stripslashes($vvval);
                    }

                    
$tmp2[$kkkey] = htmlencode($vvval);
                }

                
$tmp[$kkey] = $tmp2;
            }
        }

        $
$key = $tmp;
        
$_POST["{$key}"] = $tmp;
        
$queryParametersForLog["{$key}"] = $tmp;
    }
}

$do = @preg_replace("/(\W)/uis", "", $do);
$lang = @preg_replace("/(\W)/uis", "", $lang);
$newlang = @preg_replace("/(\W)/uis", "", $newlang);
$version = "1.9.2";
$font_head = "tableHead";
$font_row1 = "tableRow1";
$font_row2 = "tableRow2";
$font_row = $font_row2;
$ip = getenv("REMOTE_ADDR");
$server_host = getenv("HTTP_HOST");
$server_ip = getenv("SERVER_ADDR");

if (!
$admin_script) {
    
$admin_script = "admin.php";
}

if (!
$PHPPATH) {
    
$PHPPATH = "/usr/bin/php";
}

require_once (
$full_home_path . "/_rootinc/functions.inc.php");
require_once (
$full_home_path . "/_rootinc/domain.class.inc.php");
require_once (
$full_home_path . "/_rootinc/todaynic/xmlbase.inc.php");
require_once (
$full_home_path . "/_rootinc/todaynic/agentxmlclient.inc.php");
require_once (
$full_home_path . "/_rootinc/da.class.inc.php");
require_once (
$full_home_path . "/_rootinc/whm.inc.php");
require_once (
$full_home_path . "/_rootinc/isp.inc.php");
require_once (
$full_home_path . "/_rootinc/plesk.inc.php");
require_once (
$full_home_path . "/_rootinc/regru.inc.php");
require_once (
$full_home_path . "/_rootinc/webnames.inc.php");
require_once (
$full_home_path . "/_rootinc/freehost.inc.php");
require_once (
$full_home_path . "/_rootinc/naunet.inc.php");
require_once (
$full_home_path . "/_rootinc/nicru.inc.php");
require_once (
$full_home_path . "/_rootinc/todaynic.inc.php");
require_once (
$full_home_path . "/_rootinc/hostmaster.inc.php");
require_once (
$full_home_path . "/_rootinc/onlinenic.inc.php");
require_once (
$full_home_path . "/_rootinc/easypay.inc.php");
require_once (
$full_home_path . "/_rootinc/portmone.inc.php");
require_once (
$full_home_path . "/_rootinc/captcha.inc.php");
require_once (
$full_home_path . "/_rootinc/class.phpmailer.php");
require_once (
$full_home_path . "/_rootinc/class.pop3.php");
require_once (
$full_home_path . "/_rootinc/class.smtp.php");
require_once (
$full_home_path . "/_rootinc/started.inc.php");
require_once (
$full_home_path . "/_rootinc/ukrnames.inc.php");
require_once (
$full_home_path . "/_rootinc/r01.inc.php");
require_once (
$full_home_path . "/_rootinc/idna.class.inc.php");
require_once (
$full_home_path . "/_rootinc/avdesk.inc.php");
require_once (
$full_home_path . "/_rootinc/privatapi.inc.php");
require_once (
$full_home_path . "/_rootinc/ficora.inc.php");
require_once (
$full_home_path . "/_rootinc/pdf.inc.php");
require_once (
$full_home_path . "/_rootinc/ventrilo.inc.php");
require_once (
$full_home_path . "/_rootinc/internetx.inc.php");
require_once (
$full_home_path . "/_rootinc/teamspeak2.inc.php");
require_once (
$full_home_path . "/_rootinc/rrpproxy.inc.php");
require_once (
$full_home_path . "/_rootinc/epochtasms.inc.php");
require_once (
$full_home_path . "/_rootinc/rpimap.class.inc.php");
require_once (
$full_home_path . "/_rootinc/billmgr.inc.php");
require_once (
$full_home_path . "/_rootinc/ppua.inc.php");
require_once (
$full_home_path . "/_rootinc/hypervm.inc.php");
require_once (
$full_home_path . "/_rootinc/vdsmanager.inc.php");
require_once (
$full_home_path . "/_rootinc/cnic.inc.php");
require_once (
$full_home_path . "/_rootinc/cnic/Toolkit.php");
require_once (
$full_home_path . "/_rootinc/gfx.inc.php");
require_once (
$full_home_path . "/_rootinc/internetbs.inc.php");
require_once (
$full_home_path . "/_rootinc/rootpanelapi.inc.php");
require_once (
$full_home_path . "/_rootinc/smsplan.inc.php");
require_once (
$full_home_path . "/_rootinc/assist.inc.php");
require_once (
$full_home_path . "/_rootinc/kkbkz.inc.php");
require_once (
$full_home_path . "/_rootinc/gproxy.inc.php");
require_once (
$full_home_path . "/_rootinc/solusvm.inc.php");
require_once (
$full_home_path . "/_rootinc/websitews.inc.php");
require_once (
$full_home_path . "/_rootinc/epag.inc.php");
require_once (
$full_home_path . "/_rootinc/paylicenseru.inc.php");
require_once (
$full_home_path . "/_rootinc/dotfm.inc.php");
require_once (
$full_home_path . "/_rootinc/gamecp.inc.php");
require_once (
$full_home_path . "/_rootinc/rootpanelapih.inc.php");
require_once (
$full_home_path . "/_rootinc/niclv.inc.php");
require_once (
$full_home_path . "/_rootinc/plesk10.inc.php");
require_once (
$full_home_path . "/_rootinc/avdesk6.inc.php");
require_once (
$full_home_path . "/_rootinc/netcardaz.inc.php");
require_once (
$full_home_path . "/_rootinc/hostmasterepp.inc.php");
require_once (
$full_home_path . "/_rootinc/networking4all.inc.php");
require_once (
$full_home_path . "/_rootinc/subreg.inc.php");
require_once (
$full_home_path . "/_rootinc/directi.inc.php");
require_once (
$full_home_path . "/_rootinc/qtelecom.inc.php");
require_once (
$full_home_path . "/_rootinc/hosterby.inc.php");
require_once (
$full_home_path . "/_rootinc/pskz.inc.php");
require_once (
$full_home_path . "/_rootinc/activeby.inc.php");
require_once (
$full_home_path . "/_rootinc/nicdpua.inc.php");
require_once (
$full_home_path . "/_rootinc/netmoneyaz.inc.php");
require_once (
$full_home_path . "/_rootinc/namecheap.inc.php");
@include_once (
$full_home_path . "/_rootinc/vamshop.inc.php");
@include_once (
$full_home_path . "/_rootinc/wordpress.inc.php");
@include_once (
$full_home_path . "/_rootinc/modx.inc.php");
@include_once (
$full_home_path . "/_rootinc/modxevo.inc.php");
@include_once (
$full_home_path . "/_rootinc/joomla.inc.php");
@include_once (
$full_home_path . "/_rootinc/shopos.inc.php");
@include_once (
$full_home_path . "/_rootinc/teamspeak3.inc.php");
@include_once (
$full_home_path . "/_rootinc/ventrilols.inc.php");
@include_once (
$full_home_path . "/_rootinc/mumbleadmin0.4.2.inc.php");

if (
$_GET["test"] == "1") {
    print("
<BR><B>Kernel version:</B><BR><BR>{$version}");
    exit();
}

$_1_2[1][russian] = "одна ";
$_1_2[2][russian] = "две ";
$_1_2[1][ukrainian] = "одна ";
$_1_2[2][ukrainian] = "дві ";
$_1_19[1][russian] = "один ";
$_1_19[2][russian] = "два ";
$_1_19[3][russian] = "три ";
$_1_19[4][russian] = "четыре ";
$_1_19[5][russian] = "пять ";
$_1_19[6][russian] = "шесть ";
$_1_19[7][russian] = "семь ";
$_1_19[8][russian] = "восемь ";
$_1_19[9][russian] = "девять ";
$_1_19[10][russian] = "десять ";
$_1_19[11][russian] = "одиннацать ";
$_1_19[12][russian] = "двенадцать ";
$_1_19[13][russian] = "тринадцать ";
$_1_19[14][russian] = "четырнадцать ";
$_1_19[15][russian] = "пятнадцать ";
$_1_19[16][russian] = "шестнадцать ";
$_1_19[17][russian] = "семнадцать ";
$_1_19[18][russian] = "восемнадцать ";
$_1_19[19][russian] = "девятнадцать ";
$_1_19[1][ukrainian] = "одна ";
$_1_19[2][ukrainian] = "дві ";
$_1_19[3][ukrainian] = "три ";
$_1_19[4][ukrainian] = "чотири ";
$_1_19[5][ukrainian] = "п'ять ";
$_1_19[6][ukrainian] = "шість ";
$_1_19[7][ukrainian] = "сім ";
$_1_19[8][ukrainian] = "вісім ";
$_1_19[9][ukrainian] = "дев'
ять ";
$_1_19[10][ukrainian] = "десять ";
$_1_19[11][ukrainian] = "одинадцять ";
$_1_19[12][ukrainian] = "дванадцять ";
$_1_19[13][ukrainian] = "тринадцять ";
$_1_19[14][ukrainian] = "чотирнадцять ";
$_1_19[15][ukrainian] = "п'ятнадцять ";
$_1_19[16][ukrainian] = "шістнадцять ";
$_1_19[17][ukrainian] = "сімнадцять ";
$_1_19[18][ukrainian] = "вісімнадцять ";
$_1_19[19][ukrainian] = "дев'
ятнадцять ";
$des[2][russian] = "двадцать ";
$des[3][russian] = "тридцать ";
$des[4][russian] = "сорок ";
$des[5][russian] = "пятьдесят ";
$des[6][russian] = "шестьдесят ";
$des[7][russian] = "семьдесят ";
$des[8][russian] = "восемдесят ";
$des[9][russian] = "девяносто ";
$des[2][ukrainian] = "двадцять ";
$des[3][ukrainian] = "тридцять ";
$des[4][ukrainian] = "сорок ";
$des[5][ukrainian] = "п'ятдесят ";
$des[6][ukrainian] = "шістдесят ";
$des[7][ukrainian] = "сімдесят ";
$des[8][ukrainian] = "вісімдесят ";
$des[9][ukrainian] = "дев'
яносто ";
$hang[1][russian] = "сто ";
$hang[2][russian] = "двести ";
$hang[3][russian] = "триста ";
$hang[4][russian] = "четыреста ";
$hang[5][russian] = "пятьсот ";
$hang[6][russian] = "шестьсот ";
$hang[7][russian] = "семьсот ";
$hang[8][russian] = "восемьсот ";
$hang[9][russian] = "девятьсот ";
$hang[1][ukrainian] = "сто ";
$hang[2][ukrainian] = "двісті ";
$hang[3][ukrainian] = "триста ";
$hang[4][ukrainian] = "чотириста ";
$hang[5][ukrainian] = "п'ятсот ";
$hang[6][ukrainian] = "шістсот ";
$hang[7][ukrainian] = "сімсот ";
$hang[8][ukrainian] = "вісімсот ";
$hang[9][ukrainian] = "дев'
ятсот ";
$nametho[1][russian] = "тысяча ";
$nametho[2][russian] = "тысячи ";
$nametho[3][russian] = "тысяч ";
$nametho[1][ukrainian] = "тисяча ";
$nametho[2][ukrainian] = "тисячі ";
$nametho[3][ukrainian] = "тисяч ";
$namemil[1][russian] = "миллион ";
$namemil[2][russian] = "миллиона ";
$namemil[3][russian] = "миллионов ";
$namemil[1][ukrainian] = "мільйон ";
$namemil[2][ukrainian] = "мільйони ";
$namemil[3][ukrainian] = "мільйонів ";
$namemrd[1][russian] = "миллиард ";
$namemrd[2][russian] = "миллиарда ";
$namemrd[3][russian] = "миллиардов ";
$namemrd[1][ukrainian] = "мільярд ";
$namemrd[2][ukrainian] = "мільярди ";
$namemrd[3][ukrainian] = "мільярдів ";
$namecur[RUB][1][russian] = "рубль ";
$namecur[RUB][2][russian] = "рубля ";
$namecur[RUB][3][russian] = "рублей ";
$namecur[UAH][1][russian] = "гривна ";
$namecur[UAH][2][russian] = "гривны ";
$namecur[UAH][3][russian] = "гривен ";
$namecur[KZT][1][russian] = "тенге ";
$namecur[KZT][2][russian] = "тенге ";
$namecur[KZT][3][russian] = "тенге ";
$namecur[UZS][1][russian] = "сум ";
$namecur[UZS][2][russian] = "сума ";
$namecur[UZS][3][russian] = "сум ";
$namecur[RUB][1][ukrainian] = "рубль ";
$namecur[RUB][2][ukrainian] = "рубля ";
$namecur[RUB][3][ukrainian] = "рублів ";
$namecur[UAH][1][ukrainian] = "гривня ";
$namecur[UAH][2][ukrainian] = "гривні ";
$namecur[UAH][3][ukrainian] = "гривень ";
$namecur[KZT][1][ukrainian] = "тенге ";
$namecur[KZT][2][ukrainian] = "тенге ";
$namecur[KZT][3][ukrainian] = "тенге ";
$namecur[UZS][1][ukrainian] = "сум ";
$namecur[UZS][2][ukrainian] = "сума ";
$namecur[UZS][3][ukrainian] = "сум ";
$kopeek[RUB][1][russian] = "копейка ";
$kopeek[RUB][2][russian] = "копейки ";
$kopeek[RUB][3][russian] = "копеек ";
$kopeek[UAH][1][russian] = "копейка ";
$kopeek[UAH][2][russian] = "копейки ";
$kopeek[UAH][3][russian] = "копеек ";
$kopeek[KZT][1][russian] = "тиын ";
$kopeek[KZT][2][russian] = "тиын ";
$kopeek[KZT][3][russian] = "тиын ";
$kopeek[UZS][1][russian] = "тийин ";
$kopeek[UZS][2][russian] = "тийин ";
$kopeek[UZS][3][russian] = "тийин ";
$kopeek[RUB][1][ukrainian] = "копійка ";
$kopeek[RUB][2][ukrainian] = "копійки ";
$kopeek[RUB][3][ukrainian] = "копійок ";
$kopeek[UAH][1][ukrainian] = "копійка ";
$kopeek[UAH][2][ukrainian] = "копійки ";
$kopeek[UAH][3][ukrainian] = "копійок ";
$kopeek[KZT][1][ukrainian] = "тіин ";
$kopeek[KZT][2][ukrainian] = "тіин ";
$kopeek[KZT][3][ukrainian] = "тіин ";
$kopeek[UZS][1][ukrainian] = "тійін ";
$kopeek[UZS][2][ukrainian] = "тійін ";
$kopeek[UZS][3][ukrainian] = "тійін ";
/*checklicensefile();
$lknbsdfc->wweqwrexs = readlicenseencryptedarray();
$lsknhdsf->qwwdxz = getkey();
checkrplby(
$lknbsdfc->wweqwrexs, $lsknhdsf->qwwdxz);
checkrplid(
$lknbsdfc->wweqwrexs, $lsknhdsf->qwwdxz);
checkrpldate(
$lknbsdfc->wweqwrexs, $lsknhdsf->qwwdxz);
checkrpldomain(
$lknbsdfc->wweqwrexs, $lsknhdsf->qwwdxz);
checkrplip(
$lknbsdfc->wweqwrexs, $lsknhdsf->qwwdxz);
checkrplsc(
$sc, $lknbsdfc->wweqwrexs, $lsknhdsf->qwwdxz); */
checknewinstall(
$do, $_SESSION["adminId"]);
/* 
$lti = $retfsff;
$ltd = $vfdFDsdfg;
$ltr = $sfsdfewwc;
$ltq = $ertdsfgsdf; */

?>
Онлайн: 1
Реклама