<?php
$area = "public";
include("./_include/core/main_start.php");
class CIndex extends CHtmlBlock
{
var $message = "";
function action()
{
global $g;
global $l;
$cmd = get_param("cmd", "");
if ($cmd == "please_login")
{
$this->message = $l['join.php']['please_login'] . "<br>";
}
if ($cmd == "sent")
{
$this->message = $l['join.php']['was_sent'] . "<br>";
}
elseif ($cmd == "login")
{
$name = get_param("user", "");
$password = get_param("password", "");
$this->message = "";
$id = DB::result("SELECT **** FROM **** WHERE ****=" . to_sql($name, "Text") . " and (password=" . to_sql($password, "Text") . " OR password=" . to_sql(md5($password), "Text") . ");");
if ($id == 0)
{
$this->message .= $l['join.php']['incorrect_username'] . "<br>";
}
if ($this->message == "")
{
set_session("****", $id);
set_session("****_verify", $id);
#print_r($_SESSION);
if (get_param("remember", "") != "")
{
set_cookie("*****", $name, -1);
set_cookie("*****", $password, -1);
}
else
{
set_cookie("c_user", "", -1);
set_cookie("c_password", "", -1);
}
DB::execute("UPDATE**** SET last_ip=" . to_sql($_SERVER['REMOTE_ADDR'], "Text") . " WHERE *****=" . $id . "");
redirect("home.php");
}
}
elseif (get_cookie("****") != "" and get_cookie("******") != "")
{
if (get_session("*****") != "")
{
redirect("invite.php");
}
$name = get_cookie("*****");
$password = get_cookie("*****");
$this->message = "";
$id = DB::result("SELECT ***** FROM**** WHERE ****=" . to_sql($name, "Text") . " and (password=" . to_sql($password, "****") . " OR password=" . to_sql(md5($password), "*****") . ");");
if ($id == "")
{
$this->message .= $l['join.php']['incorrect_username'] . "<br>";
}
if ($this->message == "")
{
set_session("*****", $id);
set_session("******", $id);
DB::execute("UPDATE **** SET last_ip='" . $_SERVER['REMOTE_ADDR'] . "' WHERE ****_id=" . $id . "");
redirect("home.php");
}
}
if (get_session("****") != "")
{
redirect("home.php");
}
global $m;
$m = $this->message;
}
function parseBlock(&$html)
{
global $g_info;
foreach ($g_info as $k => $v) $html->setvar($k, $v);
$html->setvar("login_message", $this->message);
parent::parseBlock($html);
}
}
class CJoinForm extends CHtmlBlock
{
var $message = "";
var $login = "";
function init()
{
global $g;
global $l;
global $gc;
* *
* *
* *
* *
$this->message = "";
if (strlen($name) < 4 or strlen($name) > 20 or strpos($name, "'") !== false)
{
$this->message .= $l['join.php']['another_username'] . "<br>";
}
*******
*******
*******
*******
$month = (int) get_param("month", 1);
$day = (int) get_param("day", 1);
$year = (int) get_param("year", 1980);
#$a = date("Y") - $year - 1;
#if ($month < date("m")) $a = $a + 1;
#elseif ($month == date("m") and $day < date("d")) $a = $a + 1;
#p($a);
#p(DB::result("SELECT YEAR(FROM_DAYS(TO_DAYS('" . date('Y-m-d H:i:s') . "')-TO_DAYS('" . date('Y-m-d H:i:s', mktime(0, 0, 0, $month, $day, $year)) . "')))"));
if ($month < 1 or $month > 12 or $day < 1 or $day > 31 or $year < (date('Y') - $g['options']['users_age_max']) or $year > date("Y") - $g['options']['users_age']) {
$this->message .= $l['join.php']['incorrect_date'] . "<br>";
}
if ($year == date("Y") - $g['options']['users_age'] and ($month > date('m') or ($month == date('m') and $day > date('d')))) {
$this->message .= $l['join.php']['incorrect_date'] . "<br>";
}
if ($this->message == "")
{
set_session("j_name", $name);
set_session("j_password", $pass);
set_session("j_mail", $mail);
set_session("j_month", $month);
set_session("j_day", $day);
set_session("j_year", $year);
set_session("j_country", get_param("country", 99));
set_session("j_orientation", get_param("orientation", 1));
if ($g['options']['fast_join'] == "N" and isset($gc) and $gc) redirect("join2.php");
elseif ($g['options']['fast_join'] == "N") redirect("join2.php");
else
{
$this->add_user();
#echo get_session("user_id");
redirect("home.php");
}
}
}
function add_user()
{
$partner = (int) get_session("partner");
global $g;
DB::execute("
UPDATE partner SET
account=(account+" . to_sql($g['options']['partner_price_user'], "Number") . "),
summary=(summary+" . to_sql($g['options']['partner_price_user'], "Number") . "),
count_users=(count_users+1)
WHERE partner_id=" . $partner . "
");
$p_partner = DB::result("SELECT **** FROM**** WHERE *****=" . $partner . "");
$plus = ($g['options']['partner_percent_ref'] / 100) * $g['options']['partner_price_user'];
DB::execute("
UPDATE ***** SET
account=(account+" . $plus . "),
summary=(summary+" . $plus . ")
WHERE partner_id='" . $p_partner . "'
");
$country = DB::result("SELECT **** FROM **** WHERE ****=" . to_sql(get_session("*****"), "*****") . "");
DB::execute("INSERT INTO **** SET ****=" . to_sql(get_session("j_mail"), "Text") . "");
DB::execute("
INSERT INTO ****
SET
partner=" . $partner . ",
gold_days=0,
name=" . to_sql(get_session("j_name"), "Text") . ",
orientation=" . to_sql(get_session("***"), "Number") . ",
p_orientation=" . to_sql(DB::result("SELECT *** FROM *** WHERE id=" . to_sql(get_session("***"), "Number")), "Number") . ",
gender=" . to_sql(DB::result("SELECT *** FROM *** WHERE **=" . to_sql(get_session("***"), "Number")), "Text") . ",
mail=" . to_sql(get_session("j_mail"), "Text") . ",
password=" . to_sql($g['options']['md5'] == "Y" ? md5(get_session("****")) : get_session("***"), "Text") . ",
country_id=" . to_sql(get_session("***"), "Number") . ",
country=" . to_sql($country, "Text") . ",
birth=" . to_sql(get_session("j_year") . "-" . get_session("j_month") . "-" . get_session("j_day"), "Text") . ",
horoscope=" . to_sql(zodiac(get_session("j_year") . "-" . get_session("j_month") . "-" . get_session("j_day")), "Number") . ",
p_horoscope=0,
active='Y',
active_code='',
hide_time='0',
register='" . date('Y-m-d H:i:s') . "',
last_visit='" . date('Y-m-d H:i:s') . "',
last_ip='',
set_email_mail='2',
set_email_interest='2'
");
global $user_id;
$user_id = DB::insert_id();
$tosql3 = "";
foreach ($g['user_var'] as $k => $v) {
if (substr($k, 0, 2) != "p_") {
if ($v[0] == "text") {
$tosql3 .= $k . "='', ";
} elseif ($v[0] == "textarea") {
$tosql3 .= $k . "='', ";
}
}
}
if ($tosql3 != '') $tosql3 = substr($tosql3, 0, strlen($tosql3) - 2);
if ($tosql3 != '') {
DB::execute("INSERT INTO **** SET user_id=" . $user_id . ", " . $tosql3 . "");
} else {
DB::execute("INSERT INTO **** SET user_id=" . $user_id . "");
}
DB::execute(" INSERT INTO ***** SET user_id=" . $user_id . " ");
DB::execute("DELETE FROM **** WHERE id=".$user_id.";");
DB::execute("
INSERT INTO ****
(*,*,*,*,*,*,*)
VALUES(".
$user_id.",".
to_sql(get_session("*"), "Text").
", 4, ".
to_sql(get_session("*"), "Text").
", ".
to_sql(get_session("*"), "Text").
", 1 , 1 ,1".
");"
);
$subject = DB::result("SELECT * FROM * WHERE note='join'");
$text = DB::result("SELECT * FROM * WHERE note='join'");
$subject = str_replace("{title}", $g['main']['title'], $subject);
$text = str_replace("{title}", $g['main']['title'], $text);
$text = str_replace("{name}", get_session("j_name"), $text);
$text = str_replace("{password}", get_session("j_password"), $text);
send_mail(
get_session("j_mail"),
$g['main']['info_mail'],
$subject,
$text
);
#session_unset();
set_session("*", $user_id);
set_session("*", $user_id);
}
function parseBlock(&$html)
{
global $g;
global $g_info;
global $l;
foreach ($g_info as $k => $v) $html->setvar($k, $v);
$name = get_param("*", "");
$pass = get_param("*", "");
$pass2 = get_param("*", "");
$mail = get_param("email", "");
$mail2 = get_param("*", "");
$html->setvar("*", $name);
$html->setvar("*", $pass);
$html->setvar("*", $pass2);
$html->setvar("email", $mail);
$html->setvar("*", $mail2);
if ($name != "") $html->setvar("join_message", $this->message);
$m = array(
1 => isset($l['all']['january']) ? $l['all']['january'] : 'January',
2 => isset($l['all']['february']) ? $l['all']['february'] : 'February',
3 => isset($l['all']['march']) ? $l['all']['march'] : 'March',
4 => isset($l['all']['april']) ? $l['all']['april'] : 'April',
5 => isset($l['all']['may']) ? $l['all']['may'] : 'May',
6 => isset($l['all']['june']) ? $l['all']['june'] : 'June',
7 => isset($l['all']['july']) ? $l['all']['july'] : 'July',
8 => isset($l['all']['august']) ? $l['all']['august'] : 'August',
9 => isset($l['all']['september']) ? $l['all']['september'] : 'September',
10 => isset($l['all']['october']) ? $l['all']['october'] : 'October',
11 => isset($l['all']['november']) ? $l['all']['november'] : 'November',
12 => isset($l['all']['december']) ? $l['all']['december'] : 'December',
);
$html->setvar("month_options", h_options($m, get_param("month", 1)));
$html->setvar("day_options", n_options(1, 31, get_param("day", 1)));
$html->setvar("year_options", n_options(date("Y") - $g['options']['users_age_max'], date("Y") - $g['options']['users_age'] + 1, get_param("year", date("Y") - $g['options']['users_age_max'])));
$html->setvar("country_options", DB::db_options("SELECT *, * FROM * WHERE* in (99)" , 99) . DB::db_options("SELECT *, * FROM * ORDER BY *" , ""));
$html->setvar("*", DB::db_options("SELECT id, title FROM const_orientation", get_param("orientation", "")));
parent::parseBlock($html);
}
}
$page = new CIndex("", $g['tmpl']['dir_tmpl_main'] . "join.html");
$header = new CHeader("header", $g['tmpl']['dir_tmpl_main'] . "_header.html");
$page->add($header);
$footer = new CFooter("footer", $g['tmpl']['dir_tmpl_main'] . "_footer.html");
$page->add($footer);
$register = new CJoinForm("join", null);
$page->add($register);
include("./_include/core/main_close.php");
?>