Kod
<?php
/* (C) ABK-Soft Ltd., 2004-2006
IMPORTANT: This is a commercial software product
and any kind of using it must agree to the ABK-Soft
Ltd. license agreement.
It can be found at http://abk-soft.com/license.doc
This notice may not be removed from the source code. */
$area = "login";
include("./_include/core/main_start.php");
class CProfileSettings extends CHtmlBlock
{
function action()
{
global $g;
global $g_user;
$cmd = get_param("cmd", "");
if ($cmd == "mail")
{
DB::execute("
UPDATE user SET
set_email_mail=" . to_sql(get_param("set_mail_alert", 0), "Number") . ",
set_email_interest=" . to_sql(get_param("set_interest_alert", 0), "Number") . "
WHERE user_id=" . $g_user['user_id'] . "
");
$newsletter = get_param("set_newsletter", "");
if ($newsletter != "Y" and $newsletter != "N")
{
$newsletter = "Y";
}
if ($newsletter == "Y" and DB::result("SELECT id FROM email WHERE mail='" . $g_user['mail'] . "'") == 0)
{
DB::execute("INSERT INTO email SET mail='" . $g_user['mail'] . "'");
}
elseif ($newsletter == "N" and DB::result("SELECT id FROM email WHERE mail='" . $g_user['mail'] . "'") != 0)
{
DB::execute("DELETE FROM email WHERE mail='" . $g_user['mail'] . "'");
}
if (get_param("auto_login", "") == "Y")
{
set_cookie("c_user", $g_user['name'], -1);
set_cookie("c_password", $g_user['password'], -1);
}
else
{
set_cookie("c_user", "", -1);
set_cookie("c_password", "", -1);
}
}
if ($cmd == "chat")
{
DB::execute("
UPDATE user SET
avatar=" . to_sql(get_param("avatar", 0), "Number") . "
WHERE user_id=" . $g_user['user_id'] . "
");
if (to_sql(get_param("avatar", 0), "Number") != 0)
{
redirect("chat.php");
}
}
if ($cmd == "password")
{
$this->password_message = "";
if (md5(get_param("old_password", "")) != $g_user['password'] and get_param("old_password", "") != $g_user['password'])
{
$this->password_message .= "Old password is incorrect. Please try again.";
}
if (get_param("new_password", "") != get_param("verify_new_password", ""))
{
$this->password_message .= "New password and Verify new password are not same. Please try again.";
}
if (strlen(get_param("new_password", "")) > 15 or strlen(get_param("new_password", "")) < 6 or strpos(get_param("new_password", ""), "'") !== false)
{
$this->password_message .= "The New password incorrect. Please choose another.";
}
if (IS_DEMO and is_demo_user());
else
{
if ($this->password_message == "")
{
DB::execute("
UPDATE user SET
password=" . to_sql($g['options']['md5'] == "Y" ? md5(get_param("new_password", "")) : get_param("new_password", ""), "Text") . "
WHERE user_id=" . $g_user['user_id'] . "
");
}
}
}
if ($cmd == "hide")
{
DB::execute("UPDATE user SET hide_time=" . to_sql($g['options']['hide_time'], "Number") . " WHERE user_id=" . $g_user['user_id'] . "");
}
if ($cmd == "active")
{
DB::execute("UPDATE user SET hide_time=0 WHERE user_id=" . $g_user['user_id'] . "");
}
}
function parseBlock(&$html)
{
global $l;
global $g;
global $g_user;
if ($g['options']['blogs'] == "Y")
{
$html->parse("my_blog", true);
}
if ($g['options']['select_language'] == "Y")
{
$dir = $g['path']['dir_lang'] . "main/";
if (is_dir($dir))
{
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if (is_dir($dir . $file) and $file != "." and $file != "..")
{
$html->setvar("language_value", $file);
$html->setvar("language_title", ucfirst($file));
$html->parse("language", true);
}
}
closedir($dh);
}
}
$html->parse("set_language", true);
}
if ($g['options']['select_template'] == "Y")
{
$dir = $g['path']['dir_tmpl'] . "main/";
if (is_dir($dir))
{
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if (is_dir($dir . $file) and $file != "." and $file != "..")
{
$html->setvar("template_value", $file);
$html->setvar("template_title", ucfirst($file));
$html->parse("template", true);
}
}
closedir($dh);
}
}
$html->parse("set_template", true);
}
if (isset($this->password_message)) $html->setvar("password_message", $this->password_message);
$set_email_mail = array(1 => isset($l['all']['Açık']) ? $l['all']['Açık'] : "Açık", 2 => isset($l['all']['Kapalı']) ? $l['all']['Kapalı'] : "Kapalı");
$html->setvar("mail_alert_options", h_options($set_email_mail ,get_param("set_mail_alert", $g_user['set_email_mail'])));
$set_email_interest = array(1 => isset($l['all']['Açık']) ? $l['all']['Açık'] : "Açık", 2 => isset($l['all']['Kapalı']) ? $l['all']['Kapalı'] : "Kapalı");
$html->setvar("interest_alert_options", h_options($set_email_interest ,get_param("set_interest_alert", $g_user['set_email_interest'])));
if (DB::result("SELECT id FROM email WHERE mail='" . $g_user['mail'] . "'") == 0)
{
$html->setvar("newsletter_checked_off", " checked");
}
elseif (DB::result("SELECT id FROM email WHERE mail='" . $g_user['mail'] . "'") != 0)
{
$html->setvar("newsletter_checked_on", " checked");
}
if (get_param("cmd", "") == "mail" and get_param("auto_login", "") == "Y") $html->setvar("auto_login_checked_on", " checked");
elseif (get_param("cmd", "") == "mail" and get_param("auto_login", "") == "N") $html->setvar("auto_login_checked_off", " checked");
elseif (get_cookie("c_user") == $g_user['name'] and get_cookie("c_password") == $g_user['password']) $html->setvar("auto_login_checked_on", " checked");
else $html->setvar("auto_login_checked_off", " checked");
/*if (get_param("set_im_mail", $g_user['set_im_mail']) == 'Y') $html->setvar("im_mail_on", " checked");
else $html->setvar("im_mail_off", " checked");
if (get_param("set_im_popup", $g_user['set_im_popup']) == 'Y') $html->setvar("im_popup_on", " selected");
else $html->setvar("im_popup_off", " selected");*/
$hide = DB::result("SELECT hide_time FROM user WHERE user_id=" . $g_user['user_id'] . "");
if ($hide > 0)
{
$html->parse("active", true);
}
else
{
$html->parse("hide", true);
}
if (get_param("cmd", "") == "avatar")
{
$html->setvar("chat_message", "Please choose an avatar first.");
}
if ($g_user['orientation'] == 1) $avs = array(1 => 1, 2 => 2, 3 => 6, 4 =>7, 5 =>8, 6 =>14, 7 =>15);
elseif ($g_user['orientation'] == 2) $avs = array(1 => 3, 2 => 4, 3 => 5, 4 => 9, 5 => 10, 6 => 11, 7 => 12, 8 => 13);
else $avs = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14, 15 => 15);
for ($i = 1; $i <= (ceil(count($avs) / 2) * 2); $i++)
{
$html->setvar("numer", $i);
if (isset($avs[$i]) and file_exists($g['path']['dir_main'] . "_server/chat/avatar/portrait" . $i . ".jpg"))
{
$html->setvar("avatar", $avs[$i]);
if ($i % 2 == 1) $html->parse("photo_odd", true);
else $html->setblockvar("photo_odd", "");
if ($i % 2 == 0 and $i != (ceil(count($avs) / 2) * 2)) $html->parse("photo_even", true);
else $html->setblockvar("photo_even", "");
if ($i % 3 == 0 and $i != (ceil(count($avs) / 2) * 2) and $i != 0) $html->parse("photo_after3", true);
else $html->setblockvar("photo_after3", "");
$html->parse("photo_item", true);
$html->parse("photo", false);
}
else
{
if ($i == 1 or $i == 3) $html->parse("nophoto_odd", true);
else $html->setblockvar("nophoto_odd", "");
if ($i == 2) $html->parse("nophoto_even", true);
else $html->setblockvar("nophoto_even", "");
$html->parse("nophoto_item", true);
$html->parse("photo", false);
}
}
parent::parseBlock($html);
}
}
g_user_full();
$page = new CProfileSettings("", $g['tmpl']['dir_tmpl_main'] . "profile_settings.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);
$users_ims = new CIms("ims", $g['tmpl']['dir_tmpl_main'] . "_ims.html");
$page->add($users_ims);
$complite = new CComplite("complite", $g['tmpl']['dir_tmpl_main'] . "_complite.html");
$page->add($complite);
include("./_include/core/main_close.php");
?>