Вход Регистрация
Файл: billing/calc.php
Строк: 443
<?php
 
require_once( "./_rootconfig.php" );
session_start( );
mconnect( );
head( );
print 
"<table width=100% border=0 cellspacing=0 cellpadding=0><tr><td><font size=5><b><font size=3>Калькулятор тарифов</font></b></font><hr size=1></td></tr></table>";
if ( 
$do == "order" )
{
    if ( 
$domain_reg == "" )
    {
        
$error = "Не указано будет домен переноситься или нужно его зарегистрировать.";
        
$do = "";
    }
    else if ( ( !
$domain || !$zone ) && $domain_reg )
    {
        
$error = "Не указано доменное имя.";
        
$do = "";
    }
    else if ( !
$tarif_id )
    {
        
$error = "Не выбран тарифный план.";
        
$do = "";
    }
    else
    {
        if ( !
$months[$tarif_id] )
        {
            
$error = "Не выбран срок заказа.";
            
$do = "";
        }
        else
        {
            if ( 
$domain && $zone )
            {
                
$fulldomain = $domain.".".$zone;
            }
            
$hostmonths = $months[$tarif_id];
            
$addonsCost = 0;
            
$selectedAddons = $addons[$tarif_id];
            
$addonsToSave = "";
            
$addonsToSaveText = "";
            
$v = each( @$selectedAddons )[1];
            
$k = each( @$selectedAddons )[0];
            while ( @
each( @$selectedAddons ) )
            {
                if ( 
$v )
                {
                    
$selectedAddon = getaddonbyid( $v );
                    if ( 
$addonsToSaveText )
                    {
                        
$addonsToSaveText = $addonsToSaveText.", ".$selectedAddon->textid;
                    }
                    else
                    {
                        
$addonsToSaveText = $selectedAddon->textid;
                    }
                    
$addonsToSave = $addonsToSave.":x:{$selectedAddon->id}";
                    
$addonsCost += $selectedAddon->cost_start;
                    
$addonsCost += $selectedAddon->cost_monthly * $hostmonths;
                }
            }
            if ( !
$addonsToSaveText )
            {
                
$addonsToSaveText = "нет";
            }
            if ( !( 
$t = @mysql_query( @"select cost,cost_setup,name from tarifs where id={$tarif_id}" ) ) )
            {
                exit( 
mysql_error( ) );
            }
            
$t = mysql_fetch_object( $t );
            
$hostcost = $t->cost;
            
$host_setup = $t->cost_setup;
            if ( !( 
$tsroki = @mysql_query( @"select discount from tarifs_sroki where tarif_id={$tarif_id} and months='{$hostmonths}'" ) ) )
            {
                exit( 
mysql_error( ) );
            }
            
$tsroki = mysql_fetch_object( $tsroki );
            
$srokDiscount = $tsroki->discount;
            
$host = $hostcost * $hostmonths + $host_setup;
            
$host = $host - $host / 100 * $srokDiscount;
            
$dom = 0;
            if ( 
$domain_reg )
            {
                if ( !( 
$tzones = @mysql_query( @"select cost_if_host,minsrok from zones where zone='{$zone}'" ) ) )
                {
                    exit( 
mysql_error( ) );
                }
                
$tzones = mysql_fetch_object( $tzones );
                
$domaincost = $tzones->cost_if_host;
                
$domainminsrok = $tzones->minsrok;
                if ( !( 
$tfreedomains = @mysql_query( @"select * from tarifs_freedomains where tarif_id='{$tarif_id}' and zone='{$zone}' and hostmonths='{$hostmonths}'" ) ) )
                {
                    exit( 
mysql_error( ) );
                }
                if ( 
0 < mysql_num_rows( $tfreedomains ) )
                {
                    
$domainfree = 1;
                }
                else
                {
                    
$domainfree = 0;
                }
                
$dom = $domaincost * ( $domainminsrok / 12 );
                if ( 
$domainfree )
                {
                    
$dom = 0;
                }
            }
            
$template = str_replace( "{tarif}", $t->name, $template );
            
$template = str_replace( "{srok}", $hostmonths, $template );
            
$template = str_replace( "{domain}", $fulldomain, $template );
            
$template = str_replace( "{addons}", $addonsToSaveText, $template );
            
$template = str_replace( "{newreg}", $_newreg[$domain_reg], $template );
            
$template = str_replace( "{hostcost}", $host, $template );
            
$template = str_replace( "{domaincost}", $dom, $template );
            
$template = str_replace( "{addonscost}", $addonsCost, $template );
            
$template = str_replace( "{cost}", $host + $dom + $addonsCost, $template );
            print 
"rn<BR><B>Параметры Вашего заказа:</b><BR>rnТарифный план: {$t->name}<BR>rnСрок контракта: {$hostmonths} мес.<BR>rnДомен: {$fulldomain} [ {$_newreg[$domain_reg]} ]<BR>rnДополн. услуги: {$addonsToSaveText}<BR><BR>rnrn<B>Это будет стоить:</b><BR>rnЗа хостинг: {$host}$<BR>rnЗа домен: {$dom}$<BR>rnДополн. услуги: {$addonsCost}$<BR><BR>rnrn<B>ИТОГО К ОПЛАТЕ:</b> ".( $host + $dom + $addonsCost )."$<BR><BR>rnrn<A href=?>... посчитать ещё</a>rn";
        }
    }
}
if ( !
$do )
{
    if ( 
$error )
    {
        print 
"<font color=red>Ошибка: {$error}</font><BR><BR>";
    }
    if ( 
$domain_reg == "0" )
    {
        
$check1 = "checked";
        
$disabled = "";
    }
    else
    {
        
$check2 = "checked";
        
$disabled = "disabled";
    }
    if ( !
$vid )
    {
        
$vid = "hosting";
    }
    if ( 
$tarif )
    {
        if ( !( 
$r = @mysql_query( @"select * from tarifs where name='{$tarif}'" ) ) )
        {
            exit( 
mysql_error( ) );
        }
        if ( 
0 < mysql_num_rows( $r ) )
        {
            
$r = mysql_fetch_object( $r );
            
$tarif_id = $r->id;
        }
    }
    echo 
"rnt";
    echo 
"<s";
    echo 
"cript language=javascript type='text/javascript'>rnrntfunction showdiv(divid) {rntt";
    if ( 
$tarif_id )
    {
        print 
"parent.flast='{$tarif_id}';";
    }
    echo 
"rnttif (parent.last) {hidediv(parent.last);} else { if (parent.flast) {hidediv(parent.flast);}}rnrnttparent.last=divid;rnttif (document.getElementById) { // DOM3 = IE5, NS6rntttdocument.getElementById('d'+divid).style.display = 'block';rntttdocument.getElementById('a'+divid).style.display = 'block';rntt}rnttelse {rntttif (document.layers) { // Netscape 4rnttttdivid = 'd'+divid; document.divid.disp";
    echo 
"lay = 'block';rnttttdivid = 'a'+divid; document.divid.display = 'block';rnttt}rntttelse { // IE 4rnttttdivid = 'd'+divid; document.all.divid.style.display = 'block';rnttttdivid = 'a'+divid; document.all.divid.style.display = 'block';rnttt}rntt}rnt}rnrntfunction hidediv(divid) {rnttif (document.getElementById) { // DOM3 = IE5, NS6rntttdocument.getElementById('d'+divid).style.display = 'none';rntttd";
    echo 
"ocument.getElementById('a'+divid).style.display = 'none';rntt}rnttelse {rntttif (document.layers) { // Netscape 4rnttttdivid = 'd'+divid; document.divid.display = 'none';rnttttdivid = 'a'+divid; document.divid.display = 'none';rnttt}rntttelse { // IE 4rnttttdivid = 'd'+divid; document.all.divid.style.display = 'none';rnttttdivid = 'a'+divid; document.all.divid.style.display = 'none';rnttt}rntt}rnt";
    echo 
"}rnrntfunction showblankdiv(divid) {rnttif (document.getElementById) { // DOM3 = IE5, NS6rntttdocument.getElementById(divid).style.display = 'block';rntt}rnttelse {rntttif (document.layers) { // Netscape 4rnttttdocument.divid.display = 'block';rnttt}rntttelse { // IE 4rnttttdocument.all.divid.style.display = 'block';rnttt}rntt}rnt}rntrntfunction hideblankdiv(divid) {rnttif (document.getElementById";
    echo 
") { // DOM3 = IE5, NS6rntttdocument.getElementById(divid).style.display = 'none';rntt}rnttelse {rntttif (document.layers) { // Netscape 4rnttttdocument.divid.display = 'none';rnttt}rntttelse { // IE 4rnttttdocument.all.divid.style.display = 'none';rnttt}rntt}rnt}rnt</script>rnrnt<form method=post name=order>rnt<input type=hidden name=do value=order>rnt<input type=hidden name=vid value=";
    echo 
$vid;
    echo 
">rnrnt<table border=0>rnt<tr><td colspan=3><B>Выбор тарифного плана:</b><br><br></td></tr>rnt<tr><td align=right valign=top> * Хостинг:</td><td colspan="2"><input type=radio onclick="javascript: this.form.domain.disabled=1; this.form.zone.disabled=1;" name=domain_reg value=0 ";
    echo 
$check1;
    echo 
">с переносом домена<BR><input type=radio onclick="javascript: this.form.domain.disabled=0; this.form.zone.disabled=0;" name=domain_reg value=1 ";
    echo 
$check2;
    echo 
">с регистрацией нового</td></tr>rnt<tr><td align=right>* Домен:</td><td><input type="text" name="domain" value="";
    echo 
$domain;
    echo ""> "
;
    echo 
"<s";
    echo 
"elect name="zone"><option>rnt";
    if ( !( 
$r = @mysql_query( "select * from zones where active=1 order by zone" ) ) )
    {
        exit( 
mysql_error( ) );
    }
    while ( 
$rr = mysql_fetch_object( $r ) )
    {
        if ( 
$rr->zone == $zone )
        {
            
$addon = "selected";
        }
        else
        {
            
$addon = "";
        }
        print 
"<option value={$rr->zone} {$addon}>.{$rr->zone}";
    }
    echo 
"t</select></td></tr>rnt<tr><td align=right valign=top>* Тарифный план:</td><td colspan="2">rnt";
    if ( !( 
$r = @mysql_query( @"select * from tarifs where active=1 and vid='{$vid}' order by id" ) ) )
    {
        exit( 
mysql_error( ) );
    }
    while ( 
$rr = mysql_fetch_object( $r ) )
    {
        if ( 
$rr->id == $tarif_id || $tarif == $rr->name )
        {
            
$addon = "checked";
            
$tarif_id = $rr->id;
        }
        else
        {
            
$addon = "";
        }
        if ( 
$rr->cost_setup )
        {
            
$addon_cost = " + {$rr->cost_setup} $ разово за установку";
        }
        else
        {
            
$addon_cost = "";
        }
        print 
"<input type=radio name=tarif_id value={$rr->id} {$addon} onclick='showdiv(this.value);'>{$rr->name} ({$rr->cost} $/мес".$addon_cost.")<BR>";
    }
    echo 
"t</select></td></tr>rnt<tr><td align=right>* На срок:</td><td colspan="2">rnt";
    
$r = @mysql_query( "select * from tarifs_sroki order by tarif_id,months" );
    while ( 
$rr = mysql_fetch_object( $r ) )
    {
        if ( 
$rr->tarif_id == $tarif_id )
        {
            
$style = "style='display: block;'";
        }
        else
        {
            
$style = "style='display: none;'";
        }
        if ( !
$last_tarif_id )
        {
            print 
"<div id=d{$rr->tarif_id} {$style}><select name=months[{$rr->tarif_id}]><option>";
        }
        else if ( 
$last_tarif_id != $rr->tarif_id )
        {
            print 
"</select></div><div id=d{$rr->tarif_id} {$style}><select name=months[{$rr->tarif_id}]><option>";
        }
        if ( 
$months[$rr->tarif_id] == $rr->months )
        {
            
$addon = "selected";
        }
        else
        {
            
$addon = "";
        }
        print 
"<option value={$rr->months} {$addon}>{$rr->months} мес (скидка {$rr->discount}%)";
        
$last_tarif_id = $rr->tarif_id;
    }
    print 
"</div>";
    echo 
"t</td></tr>rnt<tr><td align=right valign=top>Доп. услуги:</td><td colspan="2">rnt";
    
$r = @mysql_query( @"select * from tarifs where active=1 and vid='{$vid}' order by cost" );
    while ( 
$rr = mysql_fetch_object( $r ) )
    {
        
$addonsForTarif = split( ":x:", $rr->addons );
        if ( 
$rr->id == $tarif_id )
        {
            
$style = "style='display: block;'";
        }
        else
        {
            
$style = "style='display: none;'";
        }
        print 
"<div id=a{$rr->id} {$style}>";
        
$v = each( @$addonsForTarif )[1];
        
$k = each( @$addonsForTarif )[0];
        while ( @
each( @$addonsForTarif ) )
        {
            if ( 
$v )
            {
                
$oneAddon = getaddonbyid( $v );
                if ( 
$oneAddon->active )
                {
                    
$addonMoney = "";
                    if ( 
$oneAddon->cost_start )
                    {
                        
$addonMoney = "{$oneAddon->cost_start}$ разово";
                        if ( 
$oneAddon->cost_monthly )
                        {
                            
$addonMoney = $addonMoney." + ";
                        }
                    }
                    if ( 
$oneAddon->cost_monthly )
                    {
                        
$addonMoney = $addonMoney."{$oneAddon->cost_monthly} $/мес";
                    }
                    if ( !
$addonMoney )
                    {
                        
$addonMoney = "бесплатно";
                    }
                    print 
"<input type=checkbox name=addons[{$rr->id}][] value={$oneAddon->id}>{$oneAddon->name} ({$addonMoney})<BR>";
                }
            }
        }
        print 
"</div>";
    }
    print 
"</div>";
    echo 
"t</td></tr>rnt<tr><td>&nbsp;</td><td colspan="2"><BR><input type="submit" name="Submit" value="Посчитать"></td></tr>rnt</table>rnt</form>rnrntПоля, отмеченные знаком *, обязательны для заполнения.rnrnt";
}
mclose( );
foot( );
?>
Онлайн: 3
Реклама