Location: PHPKode > projects > Katyshop > katyshop_ro_0.3.2.1/web/admin/formparser/user.php
<?php

/**
 * Product: Katyshop
 * @version 0.3.2.1
 * @author Catalin Hulea - hide@address.com
 * @copyright Copyright (C) 2007 Catalin Hulea
 * @license GNU General Public License version 3
 * 			You can find a copy of GNU GPL v3 at this path: /docs/LICENSE
 * @link https://sourceforge.net/projects/katyshop
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

require_once(dirname(dirname(dirname(__FILE__))) . "/init.php");
require_once(WEB_DIR . "/includes/req_admin.php");


if(@$_GET["action"] == "activate")
{
	$db = Application::getDb();
	$db->tbUser->activate(@$_POST["id"]);
	$s = (@$_POST["detail"] == "true") ? "?action=detail&id=" . intval(@$_POST["id"]) : "";
	Tools::redirect("../user.php$s");
}
elseif(@$_GET["action"] == "deactivate")
{
	$db = Application::getDb();
	$db->tbUser->deactivate(@$_POST["id"]);
	$s = (@$_POST["detail"] == "true") ? "?action=detail&id=" . intval(@$_POST["id"]) : "";
	Tools::redirect("../user.php$s");
}
elseif (@$_GET["action"] == "create_admin")
{
	$user = Application::getUser();
	$registerAdmin = new Admin();

	$registerAdmin->copyFromArray(@$_POST);
	$registerAdmin->acc_type = "admin";
	$registerAdmin->active = 1;
	$registerAdmin->activation_code = "";
	$registerAdmin->login_code = "";
	$registerAdmin->is_admin = 1;
	if($registerAdmin->validateRegister(@$_POST["confirm_password"]))
	{
		$registerAdmin->password = md5($registerAdmin->password);
		$db = Application::getDb();
		$db->tbUser->insertObj($registerAdmin);

		Application::addMessage("Contul de admin a fost creat");
	}

	if(Application::hasErrors())
	{
		SessionHandler::set("registerAdmin", $registerAdmin);
		Tools::redirect("../user.php?action=create_admin");
	}
	else
	{
		SessionHandler::set("registerAdmin", "");
		Tools::redirect("../user.php");
	}
}

elseif (@$_GET["action"] == "delete")
{
	$db = Application::getDb();
	$u = $db->tbUser->getUserById(@$_POST["id"]);
	$u = Factory::instantiateUser($u);
	if($u->id == 0)
	{
		Application::addError("Nu a putut fi gasit utilizatorul care trebuie sters");
	}
	else
	{
		$db->tbUser->deleteObj($u);
		Application::addMessage("Utilizatorul a fost sters");
	}
	Tools::redirect("../user.php");
}

?>
Return current item: Katyshop