403Webshell
Server IP : 23.111.136.34  /  Your IP : 216.73.216.136
Web Server : Apache
System : Linux servidor.eurohost.com.br 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : meusitei ( 1072)
PHP Version : 5.6.40
Disable Function : show_source, system, shell_exec, passthru, proc_open
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/meusitei/public_html/central/ajuda/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/meusitei/public_html/central/ajuda/administration_user_edit.php
<?php

/******************************************************************************
* Administration User Edit <administration_user_edit.php>
*
* Author: Michael McMullen <michael.mcmullen@tutelagesystems.com>
******************************************************************************/

require_once '../System/configuration.php';

class AdministrationUserEditPage extends MasterTemplate
{
	
	var $template					= 'admin_user_edit.html';
	var $output 					= array();
	
	function AdministrationUserEditPage()
	{
		// Call the Master Template Constructor
		parent::__construct();
		
		// Validate for Administrator
		if(! isset($_SESSION['administration']))
		{
			$this->redirect('login.php');
		}
		
		// Check for Post
		$this->SaveUser();
		// Check for Edit
		$this->LoadUser();
		
		// Add a Crumb
		$this->AddBreadCrumb('Welcome', $this->output['webRoot']);
		$this->AddBreadCrumb('Administration', 'administration.php');
		$this->AddBreadCrumb('User Management', 'administration_user.php');
		$this->AddBreadCrumb('Add / Edit User', null);
		
			
		// Render the Template
		$this->RenderTemplate();
	}
	
	// Renders the index template (called from master)
	function outputBody()
	{
		$body = new HTML_Template_Flexy($this->config['flexy']);
		$body->compile($this->template);
		$body->outputObject($this);
	}
	
	function LoadUser()
	{
		$user_id = intval($_GET['user_id']);
		
		if($user_id > 0)
		{
			$user_db = DB_DataObject::factory('users');
			$user_db->user_id = $user_id;
			if($user_db->find(true))
			{
				$this->output['user'] = $user_db->toArray();
			}
		}
		
		// Check for form data (from previous POST)
		$form_data = $this->GetFormData();
		if(! empty($form_data))
		{
			$this->output['user'] = $form_data;
			
			// Set category as active by default
			if(empty($this->output['user']['user_active']))
			{
				$this->output['user']['user_active'] = 1;
			}
		}
	}
	
	function SaveUser()
	{
		if(isset($_POST['user']))
		{
			$user_id					= 0;
			$user_name 				= $_POST['user']['user_name'];
			$user_password		= trim($_POST['user']['user_password']);
			$user_active			= isset($_POST['user']['user_active']) ? intval($_POST['user']['user_active']) : 1;
			
			if(! empty($_POST['user']['user_id']))
			{
				$user_id = intval($_POST['user']['user_id']);
			}
			
			if(empty($user_name))
			{
				// Save Form Input
				$this->SaveFormInput($_POST['user']);
				// Show Error
				$this->output['errors'] = 'The Username cannot be empty.';
				return;
			}
			
			if(empty($user_password) && $user_id <= 0)
			{
				// Save Form Input
				$this->SaveFormInput($_POST['user']);
				// Show Error
				$this->output['errors'] = 'The Password cannot be empty.';
				return;
			}
			
			// Are we updating or inserting
			if($user_id <= 0)
			{
				$user_db = DB_DataObject::factory('users');
				$user_db->user_name 		= $user_name;
				$user_db->user_password	= md5($user_password);
				$user_db->insert();
			}
			else
			{
				$user_db = DB_DataObject::factory('users');
				$user_db->user_id = $user_id;
				if(! $user_db->find(true))
				{
					// Save Form Input
					$this->SaveFormInput($_POST['category']);
					// Show Error
					$this->output['errors'] = 'The User you are trying to edit could not be found.';
					return;
				}
				
				$user_db->user_name 			= $user_name;
				
				// Only change password if requested
				if(! empty($user_password))
				{
					$user_db->user_password 	= md5($user_password);
				}
				$user_db->user_active 		= $user_active;
				$user_db->update();
			}
			
			// We have inserted or updated successfully
			$this->redirect('administration_user.php');
		}
	}
	
}

new AdministrationUserEditPage();

Youez - 2016 - github.com/yon3zu
LinuXploit