Файл: RootPanel 1.7.0 FreeCode/RootPanel 1.7.0 FreeCode/_rootbill/_changetarif.inc.php
Строк: 141
<?
$newTarif=@intval($newTarif);
$host_id=@intval($host_id);
if ($sub == "change") {
if (!$newTarif) { $error = $_lang[ChangeErrorNoNewTarif]; }
else if (!$host_id) { $error = $_lang[ErrorBadId]; }
else if (!IsAccessibleChangeTarifForHostingOrder($host_id,$newTarif)) { $error = $_lang[ChangeErrorNoAccessTarif]; }
else {
$order = @mysql_query("select *,TO_DAYS(todate)-TO_DAYS(NOW()) as leftdays from orders where id='$host_id' and uid='".$_SESSION["userId"]."'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
if (mysql_num_rows($order) > 0) {
$order = mysql_fetch_object($order);
$oldTarif = GetTarifById($order->tarif);
$newTarif = GetTarifById($newTarif);
if ($oldTarif->id and $newTarif->id) {
if ($order->leftdays <= 0) {$order->leftdays = 0;}
$money = $order->leftdays * ($newTarif->cost - $oldTarif->cost)/30;
$money = round($money, 2);
if ($money > 0) {
@mysql_query("insert into bills (uid,host_id,money_host,created,newtarif) values('$order->uid','$order->id','$money',NOW(),'$newTarif->id')") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
$billId = mysql_insert_id();
mclose();
Header("Location: billing.php?do=pay&fromchange=1&id=$billId");
exit;
} else {
if ($money < 0) {
$money = -1 * $money;
@mysql_query("update users set money=money+$money where id='".$_SESSION["userId"]."'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
}
if (changePackage($host_id, $newTarif->id)) {
@mysql_query("update orders set tarif='$newTarif->id' where id='$host_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
addUserLog($_SESSION["userId"],'changetarif',"Для заказа ID #$order->id, $order->domain, с $oldTarif->name на $newTarif->name");
_head('utf-8',$_lang[ChangeTitle]);
print $_lang[ChangeChangeTarifSuccess];
_foot('utf-8');
mclose();
exit;
} else {
@mysql_query("update orders set tarif='$newTarif->id' where id='$host_id'") or die("File: ".__FILE__."<BR>Line: ".__LINE__."<BR>MySQL Error: ".mysql_error());
addUserLog($_SESSION["userId"],'changetarif',"Для заказа ID #$order->id, $order->domain, с $oldTarif->name на $newTarif->name");
$error = $_lang[ChangeErrorChange];
}
}
}
} else { $error = $_lang[ChangeErrorNoOrder]; }
}
}
_head('utf-8',$_lang[ChangeTitle]);
if ($error) {print "<font color=red>".$_lang[Error].": $error</font><BR><BR>";}
if (!$host_id) { print "<font color=red>".$_lang[ErrorBadId]."</font><br><br>";}
else {
$accessibleTarifs = GetAccessibleChangeTarifsForHostingOrder($host_id);
if ($accessibleTarifs) {
$order = GetOrderById($host_id,$_SESSION["userId"]);
$tarif = GetTarifById($order->tarif);
print "<center>";
print "<B>".$_lang[ChangeDomain].":</b> $order->domain<Br>";
print "<b>".$_lang[ChangeTarif].":</b> $tarif->name<Br><br>";
print "<form method=post>";
print "<input type=hidden name=do value=changetarif>";
print "<input type=hidden name=sub value=change>";
print "<input type=hidden name=host_id value=$host_id>";
print "<b>".$_lang[ChangeNewTarif].":</b> <select class=input name=newTarif><option></option>";
while ($rr = mysql_fetch_object($accessibleTarifs)) {
# if ($rr->cost_setup) {$addon_cost=" + ".round($rr->cost_setup*CURK,2)." ".CURS." ".$_lang[OrderRazovoZaUstanovku];} else {$addon_cost="";}
print "<option value=$rr->id>$rr->name (".round($rr->cost*CURK,2)." ".CURS."/".$_lang[OrderSokraschenieMonth].$addon_cost.")"."</option>";
}
print "</select>";
print " <input class=button type=submit value='".$_lang[Save]."'>";
print "</form>";
print "</center>";
}
}
_foot('utf-8');
?>