<commit_before><?php 

class AdminController extends Controller{
	

	function __construct()
	{
		if( !isset($_SESSION["admin"] ) && $_SERVER["REQUEST_URI"] != "/panel/login"){
			header( "Location: http://{$_SERVER["HTTP_HOST"]}/panel/login");
		}

		global $_config;
		$this->pdo = new PDO($_config->db["dsn"], $_config->db["nombre_usuario"], $_config->db["password"], $_config->db["opciones"]);
	}


	public function login(){
		require $this->adminviews."login.php";
	}


	public function logout(){
		unset( $_SESSION[ "admin"] );
		header( "Location: http://{$_SERVER["HTTP_HOST"]}/panel/login");
	}

	public function saveLogin(){

		$user = $this->pdo->quote( $_POST["username"] );
 		$pass = $_POST["password"];
 			
		$sql =  "SELECT * FROM usuario WHERE username LIKE LOWER(".$user.") ";
		$query = $this->pdo->prepare($sql);
		if( $query->execute() ){
			$nr = $query->rowCount();
			if( $nr > 0 ){
				$user = $query->fetchAll(PDO::FETCH_ASSOC);
				if( isset( $user[0]["username"] ) ){
					if($user[0]["password"] == $pass){
						$_SESSION[ "admin"] = $user[0];	
						header( "Location: http://{$_SERVER["HTTP_HOST"]}/panel");
					}else{
						header( "Location: http://{$_SERVER["HTTP_HOST"]}/panel/login");<commit_msg>Se encripta la contraseña al logearse para entrar al panel de administracion de opemedios<commit_after><?php 

class AdminController extends Controller{
	

	function __construct()
	{
		if( !isset($_SESSION["admin"] ) && $_SERVER["REQUEST_URI"] != "/panel/login"){
			header( "Location: http://{$_SERVER["HTTP_HOST"]}/panel/login");
		}

		global $_config;
		$this->pdo = new PDO($_config->db["dsn"], $_config->db["nombre_usuario"], $_config->db["password"], $_config->db["opciones"]);
	}


	public function login(){
		require $this->adminviews."login.php";
	}


	public function logout(){
		unset( $_SESSION[ "admin"] );
		header( "Location: http://{$_SERVER["HTTP_HOST"]}/panel/login");
	}

	public function saveLogin(){

		$user = $this->pdo->quote( $_POST["username"] );
 		$pass = $_POST["password"];
 			
		$sql =  "SELECT * FROM usuario WHERE username LIKE LOWER(".$user.") ";
		$query = $this->pdo->prepare($sql);
		if( $query->execute() ){
			$nr = $query->rowCount();
			if( $nr > 0 ){
				$user = $query->fetchAll(PDO::FETCH_ASSOC);
				if( isset( $user[0]["username"] ) ){
					if($user[0]["password"] == <PASSWORD>( $pass ) ){
						$_SESSION[ "admin"] = $user[0];	
						header( "Location: http://{$_SERVER["HTTP_HOST"]}/panel");
					}else{
						header( "Location: http://{$_SERVER["HTTP_HOST"]}/panel/login");
{'fraction_non_alphanumeric': 0.22665103556076593, 'fraction_numerical': 0.0031262211801484957, 'mean_word_length': 4.278350515463917, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2070002', 'n_tokens_mistral': 995, 'n_tokens_neox': 874, 'n_words': 169}