#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (C) 2006 azurIt (azurit@pobox.sk, azurIt@IRCnet)
################################################################################
import sys, cgi, cgitb, _mysql, _mysql_exceptions, misc, config
from urllib import quote

cgitb.enable()

print "Content-Type: text/html"
print

form = cgi.FieldStorage()


def gen_cendom():
	db_conn = misc._db_connect("../../index.py")
	#db_conn.query("SELECT id, domena, cena, cenap FROM `cennikdom`")
	db_conn.query("SELECT dpl.id, st.tld AS domena, dpl.price_registration AS cena, dpl.price_renewal AS cenap FROM `domain_price_list` dpl LEFT JOIN `supported_tlds` st ON st.id=dpl.id_tld LEFT JOIN `interfaces` i ON i.id=dpl.id_interface WHERE dpl.id_service=(SELECT id FROM `services` WHERE type='SO' AND id_user=361) ORDER BY st.tld")
	mysql_result = db_conn.store_result().fetch_row(maxrows=0, how=1)
	db_conn.close()
	if mysql_result == ():
		tabulka = "Žiadne domény"
	else:
		lang_dom = "Doména"
		lang_cena = "Cena (registrácia) EUR/rok"
		lang_cenap = "Cena (predĺženie) EUR/rok"
		tabulka = """\
<table class="tab_kon">
	<tr>
		<td style="background: url(/images/tab_vlavo_hore2.jpg) bottom right no-repeat; width: 5px; height: 5px"><div style="width: 5px"></div></td>
		<td style="background: url(/images/tab_hore4.jpg) bottom repeat-x; height: 5px"></td>
		<td style="background: url(/images/tab_hore3.jpg) bottom repeat-x; height: 5px; width: 2px"><div style="width: 2px"></div></td>
		<td style="background: url(/images/tab_hore4.jpg) bottom repeat-x; height: 5px"></td>
		<td style="background: url(/images/tab_hore3.jpg) bottom repeat-x; height: 5px; width: 2px"><div style="width: 2px"></div></td>
		<td style="background: url(/images/tab_hore4.jpg) bottom repeat-x; height: 5px"></td>
		<td style="background: url(/images/tab_hore3.jpg) bottom repeat-x; height: 5px; width: 2px"><div style="width: 2px"></div></td>
		<td style="background: url(/images/tab_hore4.jpg) bottom repeat-x; height: 5px"></td>
		<td style="background: url(/images/tab_vpravo_hore2.jpg) bottom left no-repeat; width: 5px; height: 5px"><div style="width: 5px"></div></td>
	</tr>
<tr class="tb2" align="center" valign="middle">
	<td style="background: url(/images/tab_vlavo4.jpg) right repeat-y; width: 5px"></td>
	<td class="td3">#</td>
	<td style="background-color: white"><div style="width: 2px"></div></td>
	<td class="td3"><strong>%s</strong></td>
	<td style="background-color: white"><div style="width: 2px"></div></td>
	<td class="td3"><strong>%s</strong></td>
	<td style="background-color: white"><div style="width: 2px"></div></td>
	<td class="td3"><strong>%s</strong></td>
	<td style="background: url(/images/tab_vpravo4.jpg) left repeat-y; width: 5px"></td>
</tr>""" % (lang_dom, lang_cena, lang_cenap)
		farba = 1
		pocet = 1
		for i in mysql_result:
			cena1 = "%0.2f" % (config.mul_dph*float(i["cena"]))
			cena2 = "%0.2f" % (config.mul_dph*float(i["cenap"]))
			cena1 = cena1.split(".")
			cena2 = cena2.split(".")
			if farba != (farba/2)*2:
				tabulka = tabulka + """\
					<tr class="tb1" align="center" valign="middle">
						<td style="background: url(/images/tab_vlavo.jpg) right repeat-y; width: 5px"></td>
						<td class="td3">%s.</td>
						<td style="background-color: white"><div style="width: 2px"></div></td>
						<td class="td3">%s</td>
						<td style="background-color: white"><div style="width: 2px"></div></td>
						<td class="td3"><strong>%s</strong> (%s<small>,%s</small>)</td>
						<td style="background-color: white"><div style="width: 2px"></div></td>
						<td class="td3"><strong>%s</strong> (%s<small>,%s</small>)</td>
						<td style="background: url(/images/tab_vpravo.jpg) left repeat-y; width: 5px"></td>
					</tr>
					<tr>
						<td style="background: url(/images/tab_vlavo3.jpg) right repeat-y; width: 5px"></td>
						<td colspan="7" style="background-color: white"><div style="height: 2px"></div></td>
						<td style="background: url(/images/tab_vpravo3.jpg) left repeat-y; width: 5px"></td>
					</tr>""" % (pocet, i["domena"], i["cena"], cena1[0], cena1[1], i["cenap"], cena2[0], cena2[1])
			else:
				tabulka = tabulka + """\
					<tr class="tb2" align="center" valign="middle">
						<td style="background: url(/images/tab_vlavo4.jpg) right repeat-y; width: 5px"></td>
						<td class="td3">%s.</td>
						<td style="background-color: white"><div style="width: 2px"></div></td>
						<td class="td3">%s</td>
						<td style="background-color: white"><div style="width: 2px"></div></td>
						<td class="td3"><strong>%s</strong> (%s<small>,%s</small>)</td>
						<td style="background-color: white"><div style="width: 2px"></div></td>
						<td class="td3"><strong>%s</strong> (%s<small>,%s</small>)</td>
						<td style="background: url(/images/tab_vpravo4.jpg) left repeat-y; width: 5px"></td>
					</tr>
					<tr>
						<td style="background: url(/images/tab_vlavo3.jpg) right repeat-y; width: 5px"></td>
						<td colspan="7" style="background-color: white"><div style="height: 2px"></div></td>
						<td style="background: url(/images/tab_vpravo3.jpg) left repeat-y; width: 5px"></td>
					</tr>""" % (pocet, i["domena"], i["cena"], cena1[0], cena1[1], i["cenap"], cena2[0], cena2[1])
			farba += 1
			pocet += 1
		tabulka = tabulka + """\
			<tr>
				<td style="background: url(/images/tab_vlavo_dole.jpg) top right no-repeat; width: 5px; height: 5px"><div style="width: 5px"></div></td>
				<td colspan="7" style="background: url(/images/tab_dole.jpg) top repeat-x; height: 5px"></td>
				<td style="background: url(/images/tab_vpravo_dole.jpg) top left no-repeat; width: 5px; height: 5px"><div style="width: 5px"></div></td>
			</tr>
			</table>"""
	return tabulka

if form.getfirst("id", "").lower() == "cen1dom":
	if form.getfirst("dom", "") != "":
		db_conn = misc._db_connect("../../index.py")
		db_conn.query("SELECT cena, cenap FROM `cennikdom` WHERE domena='%s'" % (_mysql.escape_string(form.getfirst("dom", "").lower())))
		mysql_result = db_conn.store_result().fetch_row(maxrows=0, how=1)
		db_conn.close()
		if mysql_result != ():
			cena = "%0.2f" % (config.mul_dph*float(mysql_result[0]["cena"]))
			cena = cena.split(".")
			print "<strong>%s</strong> (%s<small>,%s</small>)" % (mysql_result[0]["cena"], cena[0], cena[1])
		else:
			print "? (?)"
	else:
		print "? (?)"
else:
	tabulka = gen_cendom()
	lang_overd = "Overiť doménu"
	lang_overit = "Overiť"
	lang_rod = "Rozšírené overenie domén"
	lang_zadd = "Zadajte doménu (bez www napr. elbia.sk)."
	lang_zna = "Nepovolené znaky v doméne."
	lang_nepd = "Doménu zadajte bez www a vrátane koncovky (napr. elbia.sk)."
	lang_nokon = "Doménu zadajte vrátane koncovky."
	lang_badkon = "Nepodporovaná koncovka."
	lang_prbkon = "Doménu v súčasnosti nie je možné overiť."
	lang_domob = "Doména je obsadená. Zvoľte si, prosím, inú."
	lang_domna = "Doménu nie je možné zaregistrovať."
	lang_domin = "Zadaná doména je neplatná."
	lang_domvol = "Doména je voľná."
	lang_chyba = "! CHYBA OVERENIA !"
	lang_over = "Overujem, prosím čakajte.."
	return_page = """<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="Content-Language" content="sk-SK" />
<meta name="Keywords" lang="sk" content="webhosting,multihosting,serverhousing,serverhosting,web,www,virtualhosting,server,elbia,domeny,domena,sk,registracia domen,mysql,ftp,mail,e-mail,email,najlepsi,najlacnejsi,najlepsie,najlacnejsie,registracia" />
<meta name="Description" content="Profesionálny webhosting, multihosting a serverhousing" />
<meta name="Author" content="ELBIA, s. r. o." />
<meta name="Distribution" content="Global" />
<meta name="Revisit-After" content="2 days" />
<meta name="Robots" content="all, index, follow" />
<meta name="Copyright" content="(c) 2009 ELBIA, s. r. o." />
<title>Profesionálny a neobmedzený MultiHosting</title>
<link href="/style.css" rel="stylesheet" type="text/css" />
<link href="/layout.css" rel="stylesheet" type="text/css" />
<script src="/rollover.js" type="text/javascript"></script>
</head>

<body  id="page6">
<div class="talling">
	<div class="site_center">
		<div class="site_space">
			<div class="site_color">
				<div class="bg_top">
					<div class="bg_left">
						<div class="bg_right">
							<div class="bg_bot">
								<div class="y_top_left">
									<div class="y_top_right">
										<div class="y_bot_left">
											<div class="y_bot_right">
												<div id="header">
													<div class="logo">
														<a href="/"><img alt="" class="indent" src="/images/logo.png" /></a><p><a href="https://webmail.elbiahosting.sk/" rel="external">WebMail</a> | <a href="https://webmysql.elbiahosting.sk/" rel="external">WebMySQL</a> | <a href="https://webftp.elbiahosting.sk/" rel="external">WebFTP</a></p>
													</div>
													<div class="tlacidla">
														<div class="but_1"><a href="/webhosting/" class="top">webhosting</a></div>
														<div class="but_2"><a href="/domeny/" class="top">domény</a></div>
														<div class="but_3"><a href="/servery/" class="top">servery</a></div>
														<div class="but_4"><a href="/referencie/" class="top">referencie</a></div>
														<div class="but_5"><a href="/kontakt/" class="top">kontakt</a></div>
													</div>
													<div class="m">
														<div class="text_top_hl">
															<div class="nadpis_top">neobmedzený MultiHosting !</div>
															<div class="clear"></div>
															<div class="text_top">NEOBMEDZENÝ počet <strong>domén</strong></div>
															<div class="clear"></div>
															<div class="text_top">NEOBMEDZENÝ počet subdomén</div>
															<div class="clear"></div>
															<div class="text_top">NEOBMEDZENÝ počet e-mailových schránok</div>
															<div class="clear"></div>
															<div class="text_top">NEOBMEDZENÝ počet MySQL databáz</div>
															<div class="clear"></div>
															<div class="text_top">NEOBMEDZENÝ počet FTP kont</div>
															<div class="clear"></div>
														</div>
														<div class="but_inf">
															<a href="/webhosting/" class="top">informácie</a>
														</div>
														<div class="but_obj">
															<a href="http://www.elbiahosting.sk/objednavka/28/" class="top">objednávka</a>
														</div>
													</div>
												</div>
												<div id="content">
													<div class="col1">
														<div class="indent2 text2">
		<script type="text/javascript">
		<!--
		function test(data) {
		  data = data.replace(/\\n/g, '');
		  if (data == "err nic") {
		    document.getElementById("dom_text").innerHTML = "%s";
		  } else if (data == "err zna") {
		    document.getElementById("dom_text").innerHTML = "<span style='color: red'>%s<\/span>";
		  } else if (data == "err dom") {
		    document.getElementById("dom_text").innerHTML = "<span style='color: red'>%s<\/span>";
		  } else if (data == "err no_kon") {
		    document.getElementById("dom_text").innerHTML = "<span style='color: red'>%s<\/span>";
		  } else if (data == "err bad_kon") {
		    document.getElementById("dom_text").innerHTML = "<span style='color: red'>%s<\/span>";
		  } else if (data == "err prb_kon") {
		    document.getElementById("dom_text").innerHTML = "<span style='color: red'>%s<\/span>";
		  } else if (data == "reg") {
		    document.getElementById("dom_text").innerHTML = "<span style='color: red'>%s<\/span>";
		  } else if (data == "na") {
		    document.getElementById("dom_text").innerHTML = "<span style='color: red'>%s<\/span>";
		  } else if (data == "in") {
		    document.getElementById("dom_text").innerHTML = "<span style='color: red'>%s<\/span>";
		  } else if (data == "ok") {
		    document.getElementById("dom_text").innerHTML = "<span style='color: green'>%s<\/span>";
		  } else {
		    document.getElementById("dom_text").innerHTML = "<span style='color: red'>%s<\/span>";
		  }
		}

		function check_dom() {
			var xmlhttp = null;
			var failed = false;
			try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e1) {
				try {
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e2) {
					xmlhttp = null;
				}
			}
			if (! xmlhttp) {
				if (typeof XMLHttpRequest != "undefined") {
					xmlhttp = new XMLHttpRequest();
				} else {
					failed = true;
				}
			}
			if (! failed) {
				document.getElementById("dom_text").innerHTML = "%s";
				xmlhttp.open("GET", "/check_dom.py?dom=" + document.getElementById("dom_over").value);
				xmlhttp.onreadystatechange = function() {
					handler(xmlhttp);
				};
				xmlhttp.send(null);
			}
		}

		function handler(xmlhttp) {
		  if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		    // so far so good
		    if(xmlhttp.responseText != null)
		      // success!
		      test(xmlhttp.responseText);
		    else
		      test(null);
		  } else if (xmlhttp.readyState == 4 && xmlhttp.status != 200) {
		    // fetched the wrong page or network error...
		    test(null);
		  }
		}
		//-->
		</script>
		<center>
		%s <input type="text" name="dom_over" value="" id="dom_over" onkeypress="if (event.which == 13) {check_dom()}" class="field1" /> <input type="button" value="%s" onclick="check_dom();" class="button1" /> <a href="/rod/">%s</a><br />
		<span id="dom_text">%s</span>
		<br />
		<br />
		%s<br />
<br />
<span class="text3">Všetky ceny sú uvedené bez DPH (s DPH).</span><br />
</center>
														</div>
													</div>
													<div class="clear"></div>
												</div>
												<div id="footer">
													<ul class="list2">
														<li><a class="bg_none" href="/webhosting/">Webhosting</a></li>
														<li><a href="/domeny/">Domény</a></li>
														<li><a href="/servery/">Servery</a></li>
														<li><a href="/referencie/">Referencie</a></li>
														<li><a href="/kontakt/">Kontakt</a></li>
													</ul>
													<p>Copyright © 2009, <a href="http://www.elbia.sk/" rel="external">ELBIA, s. r. o.</a> Všetky práva vyhradené.</p>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
</html>""" % (lang_zadd, lang_zna, lang_nepd, lang_nokon, lang_badkon, lang_prbkon, lang_domob, lang_domna, lang_domin, lang_domvol, lang_chyba, lang_over, lang_overd, lang_overit, lang_rod, lang_zadd, tabulka)
	print misc._remove_tabs(return_page)
