<?php
require 'config.php'; 
/*===============================================================================================================================*/
/*==================================================== Statistics Functions =====================================================*/
/*===============================================================================================================================*/

function listCourseCount(){
	global $conection;
	$result = mysqli_query($conection,"SELECT COUNT(*) FROM categories;");
	$row = mysqli_fetch_array($result);

	$total = $row[0];
	echo $total;
}

function listAboutResort(){
	global $conection;
	$result = mysqli_query($conection,"SELECT COUNT(*) FROM about;");
	$row = mysqli_fetch_array($result);

	$total = $row[0];
	echo $total;
}
/*===============================================================================================================================*/
/*=============================================== ANTI SQL INJECTION Function ===================================================*/
/*===============================================================================================================================*/

function antiSQLInjection($texto){
	// Words for search
	$check[1] = chr(34); // simbol "
	$check[2] = chr(39); // simbol '
	$check[3] = chr(92); // simbol /
	$check[4] = chr(96); // simbol `
	$check[5] = "drop table";
	$check[6] = "update";
	$check[7] = "alter table";
	$check[8] = "drop database";
	$check[9] = "drop";
	$check[10] = "select";
	$check[11] = "delete";
	$check[12] = "insert";
	$check[13] = "alter";
	$check[14] = "destroy";
	$check[15] = "table";
	$check[16] = "database";
	$check[17] = "union";
	$check[18] = "TABLE_NAME";
	$check[19] = "1=1";
	$check[20] = 'or 1';
	$check[21] = 'exec';
	$check[22] = 'INFORMATION_SCHEMA';
	$check[23] = 'like';
	$check[24] = 'COLUMNS';
	$check[25] = 'into';
	$check[26] = 'VALUES';

	// Cria se as variáveis $y e $x para controle no WHILE que fará a busca e substituição
	$y = 1;
	$x = sizeof($check);
	// Faz-se o WHILE, procurando alguma das palavras especificadas acima, caso encontre alguma delas, este script substituirá por um espaço em branco " ".
	while($y <= $x){
		   $target = strpos($texto,$check[$y]);
			if($target !== false){
				$texto = str_replace($check[$y], "", $texto);
			}
		$y++;
	}
	// Retorna a variável limpa sem perigos de SQL Injection
	return $texto;
}

/*===============================================================================================================================*/
/*====================================================== Clients Functions ======================================================*/
/*===============================================================================================================================*/

// Display All clients over the Clients Dashboard
function listClientsBack()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM clients ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>
				  <th>ID</th>
                  <th>".lang('NAME')."</th>
                  <th>".lang('EMAIL')."</th>
					<th></th>				  
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";		
			echo $row['id'];
			echo "</td><td>";
			echo $row['name'];
			echo "</td><td>";			
			echo $row['email'];
			echo "</td>";
			echo "<td class='r'>
			<a href='edit_client.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i> ".lang('EDIT')."</a>
			<a href='javascript:EliminaCliente(". $row['id'] . ")'class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i> ".lang('DELETE')."</a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}

// Edit client function
function editClient($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from clients WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "
				

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='name'>".lang('NAME')."</label>  
					  <div class='col-md-6'>
					  <textarea rows ='1' cols='10' id='name' name='name' type='text' class='form-control input-md'>".$row['name']."</textarea>
						
					  </div>
					</div>

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='email'>".lang('EMAIL')."</label>  
					  <div class='col-md-6'>
					  <textarea rows ='1' cols='10' id='email' name='email' type='text' class='form-control input-md'>".$row['email']."</textarea>
						
					  </div>
					</div>

				";

}

// Update client Information
function updateClient($id,$name,$email)
{
	global $conection;
	$query = mysqli_query($conection,"UPDATE clients SET name = '$name', email = '$email' WHERE id = '$id'");
	if (!$query) {
		echo ("No data was inserted!: " . mysqli_error());
		return false;
	} else {
			echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('CLIENT_UPDATED')."', 'success');</script>";
					echo '<meta http-equiv="refresh" content="1; clients.php">'; 
					die();
			}				
			return true;
}


/*===============================================================================================================================*/
/*==================================================== Update User Info =========================================================*/
/*===============================================================================================================================*/

// Edit User Information
function editUser($username)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from users WHERE username='".$_SESSION['user']['username']."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "	
					
					<div class='col-md-6'>
						".lang('LANGUAGE').": <input disabled='disabled' class='form-control' name='lang' value='".$row['lang']."' />
					</div>
					<div class='col-md-6'>
						".lang('NEW_LANGUAGE')."
						<select class='form-control' name='lang'>
						  <option value='en'>English</option>
						  <option value='pt'>Portugues</option>
						  <option value='fr'>Francais</option>
						</select>
						<br/>
					</div>
					
					<div class='col-md-6'>
						".lang('LOGIN').":
						<textarea rows ='1' cols='40' class='form-control' name='username' >".$row['username']."</textarea><br />
					</div>
					<div class='col-md-6'>
						".lang('EMAIL').":
						<textarea rows ='1' cols='40' class='form-control' name='email' >".$row['email']."</textarea><br />
					</div>
					<div class='col-md-6'>	
						".lang('NEW_PASSWORD').":
						<input type='password' name='password' class='form-control' placeholder='".lang('NEW_PASSWORD')."' required value='' />
					</div>
					<div class='col-md-6'>	
						".lang('NEW_PASSWORD_REPEAT').":
						<input type='password' name='password1' class='form-control' placeholder='".lang('NEW_PASSWORD_REPEAT')."' required value='' />
					</div>
				<br/><br/><br/><br/>

				"

        ;

}

// Update User Information
function updateUser($id,$username,$password,$salt,$email,$lang)
{
	global $conection;
	 // Security measures
        $salt = dechex(mt_rand(0, 2147483647)) . dechex(mt_rand(0, 2147483647)); 
        $password = hash('sha256', $_POST['password'] . $salt);
		for($round = 0; $round < 65536; $round++){ $password = hash('sha256', $password . $salt); }		
	
	$query = mysqli_query($conection,"update users set username='$username', password='$password', salt='$salt', email='$email', lang='$lang' where username='$id';");
	
	if (!$query) {
		echo ("No data was inserted!: " . mysqli_error());
		return false;
	} else {
			echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('ACCOUNT')."', 'success');</script>";
					echo '<meta http-equiv="refresh" content="1; '.$_SERVER['PHP_SELF'].'">'; 
					die();
			}		
			return true;
}

// Select Language from Database for setting it as the default language relative to language settings
function language(){
	global $conection;
	$consulta = mysqli_query($conection,"select lang from users WHERE username='".$_SESSION['user']['username']."'");
    $row = mysqli_fetch_assoc($consulta);
    
	require("assets/languages/".$row['lang'].".php");
	
}

// Select Language from Database for setting it as the default language relative to language settings
function languageFront(){
	global $conection;
	$consulta = mysqli_query($conection,"select lang from users");
    $row = mysqli_fetch_assoc($consulta);
	
	$resp = $row['lang'];
    
	if($resp == ''){
		require("admin/assets/languages/en.php");
	}
	if($resp != ''){
		require("admin/assets/languages/".$row['lang'].".php");
	}
    
}

// Select Language from Database for setting it as the default language relative to language settings
function langName(){
	global $conection;
	$consulta = mysqli_query($conection,"select lang from users WHERE username='".$_SESSION['user']['username']."'");
    $row = mysqli_fetch_assoc($consulta);
    	
	echo $row['lang'];
}
	 
//Get Font Color under Settings area for the menu area 
function getMenu_Color()
{
	global $conection;
	$sql = mysqli_query($conection,"select * from dashboard WHERE id='1'");
    $row = mysqli_fetch_assoc($sql);
	$menu_color = $row['menu_color'];

	echo $menu_color;	
}

//Get Background Color under Settings area for the menu area 
function getMenu_BColor()
{
	global $conection;
	$sql = mysqli_query($conection,"select * from dashboard WHERE id='1'");
    $row = mysqli_fetch_assoc($sql);
	$menu_bcolor = $row['menu_bcolor'];
	
	echo $menu_bcolor;
	
}

//Get Font Color under Settings area for the menu area when hover
function getMenu_ColorHover()
{
	global $conection;
	$sql = mysqli_query($conection,"select * from dashboard WHERE id='1'");
    $row = mysqli_fetch_assoc($sql);
	$menu_colorhover = $row['menu_colorhover'];

	echo $menu_colorhover;	
}

//Get Background Color under Settings area for the menu area when hover
function getMenu_BColorHover()
{
	global $conection;
	$sql = mysqli_query($conection,"select * from dashboard WHERE id='1'");
    $row = mysqli_fetch_assoc($sql);
	$menu_bcolorhover = $row['menu_bcolorhover'];
	
	echo $menu_bcolorhover;
	
}

//Get Font Color under Settings area for the primary sections
function getBackgroundTColor()
{
	global $conection;
	$sql = mysqli_query($conection,"select * from dashboard WHERE id='1'");
    $row = mysqli_fetch_assoc($sql);
	$background_tcolor = $row['background_tcolor'];
	
	echo $background_tcolor;
	
}

//Get background Color under Settings area for the primary sections
function getBackgroundColor()
{
	global $conection;
	$sql = mysqli_query($conection,"select * from dashboard WHERE id='1'");
    $row = mysqli_fetch_assoc($sql);
	$background_color = $row['background_color'];
	
	echo $background_color;
	
}

//Get background Color under Settings area for the sidebar menu area
function getBackgroundMenuColor()
{
	global $conection;
	$sql = mysqli_query($conection,"select * from dashboard WHERE id='1'");
    $row = mysqli_fetch_assoc($sql);
	$background_menu_color = $row['background_menu_color'];
	
	echo $background_menu_color;
	
}

//Get Items Color under Settings area for the sidebar menu area
function getItemsColor()
{
	global $conection;
	$sql = mysqli_query($conection,"select * from dashboard WHERE id='1'");
    $row = mysqli_fetch_assoc($sql);
	$items_color = $row['items_color'];
	
	echo $items_color;
	
}

//Get Selected Font from Google Fonts
function getFont()
{
	global $conection;
	$sql = mysqli_query($conection,"select * from dashboard WHERE id='1'");
    $row = mysqli_fetch_assoc($sql);
	$font = $row['font'];
	
	echo $font;
	
}
  

//Function Update Theme Color Options From Settings page
function updateDashboard($font, $lcolor, $menu_color, $menu_bcolor, $menu_colorhover, $menu_bcolorhover, $background_color, $background_tcolor,$background_menu_color,$items_color,$image)
{
	global $conection;
	$query = mysqli_query($conection,"UPDATE dashboard SET font = '$font', lcolor = '$lcolor', menu_color = '$menu_color', menu_bcolor = '$menu_bcolor', menu_colorhover = '$menu_colorhover', menu_bcolorhover = '$menu_bcolorhover', background_color = '$background_color', background_tcolor = '$background_tcolor', background_menu_color = '$background_menu_color', items_color = '$items_color', image = '$image'");
	
	if (!$query) {
		echo ("No data was inserted!: " . mysqli_error());
		return false;
	} else {
			echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('LOADER_COLOR_UPDATED')."', 'success');</script>";
			echo '<meta http-equiv="refresh" content="1; settings.php">'; 
			die();
			}				
			return true;

}  
 
/*===============================================================================================================================*/
/*================================================= Background Text Functions ===================================================*/
/*===============================================================================================================================*/

// Display All Projects in the backoffice for the portfolio
function listResort()
{
	global $conection;

	$campos_query = "*";
	$final_query  = "FROM about ORDER BY id DESC";
	 
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>
                  <th>Latest Publications IMAGE 1</th>  
                  <th>Latest Publications IMAGE 2</th>
                  <th>Latest Publications IMAGE 3</th> 
                  <th>Latest Publications IMAGE 4</th>   
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr>";		
			echo "<td class='partner_img '>";
			echo "<img src='../assets/images/uploads/pub/".$row['image1']."' alt='' />";
			echo "</td><td class='partner_img '>";
			echo "<img src='../assets/images/uploads/pub/".$row['image2']."' alt='' />";
			echo "</td><td class='partner_img '>";
			echo "<img src='../assets/images/uploads/pub/".$row['image3']."' alt='' />";
			echo "</td><td class='partner_img '>";
			echo "<img src='../assets/images/uploads/pub/".$row['image4']."' alt='' />";
			echo "</td><td>"; 
			echo"
			<a href='edit_latestpub.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i> ".lang('EDIT')."</a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>"; 
       //	<a href='javascript:EliminaAbout(". $row['id'] . ")'class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i> ".lang('DELETE')."</a> 


	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}
 
// Display All partners created in the backoffice
function listPartnersBack()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM partners ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	
                  <th>ID</th>
				  <th>".lang('IMAGE')."</th>
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";		
			echo $row['id'];
			echo "</td><td class='partner_img'>"; 
			echo "<img src='../assets/img/uploads/partners/".$row['image']."' alt='' />";
			echo "</td><td>";
			echo"
			<a href='edit_partner.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i> ".lang('EDIT')."</a>
			<a href='javascript:EliminaPartner(". $row['id'] . ")'class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i> ".lang('DELETE')."</a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}

// Edit partner function
function editPartner($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from partners WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "

								
					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image' id='image'>
									<img src='../assets/img/uploads/partners/".$row['image']."' width='150px' hieght='150px' alt='' />
								</div>
						</div>
				";

}

// Update partner Information
function updatePartner($id,$image1)
{
	global $conection;
	$image = $_FILES['image'];

										
											// Se a foto estiver sido selecionada
											if (!empty($image["name"])) {
										 
												// Largura máxima em pixels
												$largura = 1000000;
												// Altura máxima em pixels
												$altura = 1000000;
												// Tamanho máximo do arquivo em bytes
												$tamanho = 500000000000;
										 
												// Verifica se o arquivo é uma imagem
												if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image["type"])){
												   $error[1] = "Isso não é uma imagem.";
												} 
										 
												// Pega as dimensões da imagem
												$dimensoes = getimagesize($image["tmp_name"]);
										 
												// Verifica se a largura da imagem é maior que a largura permitida
												if($dimensoes[0] > $largura) {
													$error[2] = "Image width should not exceed".$largura." pixels";
												}
										 
												// Verifica se a altura da imagem é maior que a altura permitida
												if($dimensoes[1] > $altura) {
													$error[3] = "Image height should not exceed ".$altura." pixels";
												}
										 
												// Verifica se o tamanho da imagem é maior que o tamanho permitido
												if($image["size"] > $tamanho) {
													$error[4] = "Image must be at most ".$tamanho." bytes";
												}
										 
													// Pega extensão da imagem
													preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image["name"], $ext);
										 
													// Gera um nome único para a imagem
													$nome_imagem = $image["name"];
										 
													// Caminho de onde ficará a imagem
													$caminho_imagem = "../assets/img/uploads/partners/" . $nome_imagem;
										 
													// Faz o upload da imagem para seu respectivo caminho
													move_uploaded_file($image["tmp_name"], $caminho_imagem);
										 
												
													$query = mysqli_query($conection,"UPDATE partners SET image='$nome_imagem' WHERE id = '$id'");
													if (!$query) {
														echo ("No data was inserted!: " . mysqli_error());
														return false;
													} else {
															echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
																	echo '<meta http-equiv="refresh" content="1; partners.php">'; 
																	die();
															}				
															return true;

												// Se houver mensagens de erro, exibe-as
												if (count($error) != 0) {
													foreach ($error as $erro) {
														echo $erro . "<br />";
													}
												}

										}

}

// Accomodations 
 // Edit About Resort function
function editAbout($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from about WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "
  
					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')." 1</label>
								<div class='col-md-6'>
									<input type='file' name='image1' id='image'>
									<img src='../assets/images/uploads/pub/".$row['image1']."' width='150px' hieght='150px' alt='' />
								</div>
						</div>

					<div class='form-group'>
					  <label class='col-md-2 control-label' for='description'> Title </label>  
					  <div class='col-md-6'>
					  <textarea rows ='2' cols='1'  name='name' type='text' class='form-control input-md'>".$row['name']."</textarea>
						
					  </div>
					</div>

					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')." 2 </label>
								<div class='col-md-6'>
									<input type='file' name='image2' id='image'>
									<img src='../assets/images/uploads/pub/".$row['image2']."' width='150px' hieght='150px' alt='' />
								</div>
						</div>

			 		<div class='form-group'>
					  <label class='col-md-2 control-label' for='description'>Title </label>  
					  <div class='col-md-6'>
					  <textarea rows ='2' cols='1' name='descript' type='text' class='form-control input-md'>".$row['descript']."</textarea>
						
					  </div>
					</div>

					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')." 3</label>
								<div class='col-md-6'>
									<input type='file' name='image3' id='image'>
									<img src='../assets/images/uploads/pub/".$row['image3']."' width='150px' hieght='150px' alt='' />
								</div>
						</div>

			 		<div class='form-group'>
					  <label class='col-md-2 control-label' for='description'>Title</label>  
					  <div class='col-md-6'>
					  <textarea rows ='2' cols='1' name='descript1' type='text' class='form-control input-md'>".$row['descript1']."</textarea>
						
					  </div>
					</div>

					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')." 4</label>
								<div class='col-md-6'>
									<input type='file' name='image4' id='image'>
									<img src='../assets/images/uploads/pub/".$row['image4']."' width='150px' hieght='150px' alt='' />
								</div>
						</div> 

			 		<div class='form-group'>
					  <label class='col-md-2 control-label' for='description'>Title</label>  
					  <div class='col-md-6'>
					  <textarea rows ='2' cols='1'  name='descript2' type='text' class='form-control input-md'>".$row['descript2']."</textarea>
						
					  </div>
					</div>
 
 
				";

}

 // Update about Information
function updateAbout($id,$name,$descript,$image1,$image2,$image3,$image4,$descript1,$descript2)
{
	global $conection;
	$image1 = $_FILES['image1'];
	$image2 = $_FILES['image2'];
	$image3 = $_FILES['image3'];
	$image4 = $_FILES['image4']; 
  $name = $_POST['name'];  
	$descript = $_POST['descript']; 
	$descript1 = $_POST['descript1']; 
	$descript2 = $_POST['descript2']; 

	 if(!empty($image1["name"])) {
										 
		$largura = 1000000;
		$altura = 1000000;
		$tamanho = 500000000000;
										 
		if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image1["type"])){
		$error[1] = "Isso não é uma imagem.";
		} 
										 
		$dimensoes = getimagesize($image1["tmp_name"]);
 
										 
		if($dimensoes[0] > $largura) {
			$error[2] = "A largura da imagem não deve ultrapassar ".$largura." pixels";
		}
										 
		if($dimensoes[1] > $altura) {
			$error[3] = "Image height should not exceed ".$altura." pixels";
		}
										 

		if($image1["size"] > $tamanho) {
			$error[4] = "Image must be at most ".$tamanho." bytes";
		}
										 
		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image1["name"], $ext);						 

		$nome_imagem = $image1["name"];
										 
		$caminho_imagem = "../assets/images/uploads/pub/" . $nome_imagem;
 							 
		move_uploaded_file($image1["tmp_name"], $caminho_imagem);							
								
		$query = mysqli_query($conection,"UPDATE about SET image1='$nome_imagem',image2='$nome_imagem1', image3='$nome_imagem2', image4='$nome_imagem3', name ='$name', descript = '$descript', descript1 = '$descript1', descript2 = '$descript2' WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; latestpub.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}
		}
		elseif (!empty($image2["name"])) {
										 
		$largura = 1000000;
		$altura = 1000000;
		$tamanho = 500000000000;
										 
		if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image2["type"])){
		$error[1] = "Isso não é uma imagem.";
		} 
										 
		$dimensoes1 = getimagesize($image2["tmp_name"]);
										 
		if ($dimensoes1[0] > $largura)  {
			$error[2] = "A largura da imagem não deve ultrapassar ".$largura." pixels";
		}
										 
		if($dimensoes1[1] > $altura) {
			$error[3] = "Image height should not exceed ".$altura." pixels";
		}
										 

		if($image2["size"] > $tamanho) {
			$error[4] = "Image must be at most ".$tamanho." bytes";
		}
										 
		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image2["name"], $ext);						 

		$nome_imagem1 = $image2["name"];
										 
		$caminho_imagem1 = "../assets/images/uploads/pub/" . $nome_imagem1;
 							 
		move_uploaded_file($image2["tmp_name"], $caminho_imagem1); 									
								
		$query = mysqli_query($conection,"UPDATE about SET image2='$nome_imagem1',image3='$nome_imagem2', image4='$nome_imagem3', name ='$name', descript = '$descript', descript1 = '$descript1', descript2 = '$descript2'  WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; latestpub.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}
		}
		elseif (!empty($image3["name"])) {
										 
		$largura = 1000000;
		$altura = 1000000;
		$tamanho = 500000000000;
										 
		if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image3["type"])){
		$error[1] = "Isso não é uma imagem.";
		} 
										 
		$dimensoes2 = getimagesize($image3["tmp_name"]);
										 
		if ($dimensoes2[0] > $largura)  {
			$error[2] = "A largura da imagem não deve ultrapassar ".$largura." pixels"; 
		}
										 
		if($dimensoes2[1] > $altura) {
			$error[3] = "Image height should not exceed ".$altura." pixels";
		}
										 

		if($image3["size"] > $tamanho) {
			$error[4] = "Image must be at most ".$tamanho." bytes";
		}	 
		
		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image3["name"], $ext);	

		$nome_imagem2 = $image3["name"];

		$caminho_imagem2 = "../assets/images/uploads/pub/" . $nome_imagem2;

		move_uploaded_file($image3["tmp_name"], $caminho_imagem2);	
										    								
		$query = mysqli_query($conection,"UPDATE about SET image3='$nome_imagem2', image4='$nome_imagem3', name ='$name', descript = '$descript', descript1 = '$descript1', descript2 = '$descript2'  WHERE id = '$id' ");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; latestpub.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}
		}
		elseif (!empty($image4["name"])) {
										 
		$largura = 1000000;
		$altura = 1000000;
		$tamanho = 500000000000;
										 
		if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image4["type"])){
		$error[1] = "Isso não é uma imagem.";
		} 
										 
		$dimensoes3 = getimagesize($image4["tmp_name"]);
										 
		if ($dimensoes3[0] > $largura)  {
			$error[2] = "A largura da imagem não deve ultrapassar ".$largura." pixels"; 
		}
										 
		if($dimensoes3[1] > $altura) {
			$error[3] = "Image height should not exceed ".$altura." pixels";
		}
										 

		if($image4["size"] > $tamanho) {
			$error[4] = "Image must be at most ".$tamanho." bytes";
		}
		
		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image4["name"], $ext);

		$nome_imagem3 = $image4["name"];

		$caminho_imagem3 = "../assets/images/uploads/pub/" . $nome_imagem3;
 							 
		move_uploaded_file($image4["tmp_name"], $caminho_imagem3);
								
		$query = mysqli_query($conection,"UPDATE about SET image4='$nome_imagem3', name ='$name', descript = '$descript', descript1 = '$descript1', descript2 = '$descript2'  WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; latestpub.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}
		}
		else{
		$query = mysqli_query($conection,"UPDATE about SET name ='$name', descript = '$descript', descript1 = '$descript1', descript2 = '$descript2'  WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; latestpub.php">'; 
				die();
			}				
		return true;
		}	
}


/*===============================================================================================================================*/
/*================================================== Photos Functions =====================================================*/
/*===============================================================================================================================*/

// Display All Projects on the backoffice
function listPhotos()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM publication ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	
                  <th>ID</th>
				  <th>Publication Title</th>
				  <th>Authors</th>
          <th>Year</th>
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";		
			echo $row['id'];
			echo "</td><td>"; 
			echo $row['booktitle'];
			echo "</td><td>";			
			echo $row['authors'];
			echo "</td><td>";
			echo $row['yearpub'];
			echo "</td><td>";
			echo"
			<a href='edit_publication.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i> ".lang('EDIT')."</a>
			<a href='javascript:EliminaPublication(". $row['id'] . ")'class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i> ".lang('DELETE')."</a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}


// Edit project function
function editPublication($id)
{
	global $conection;
}

// Update project Information
function updatePublication($id,$authors,$yearpub,$article,$pub,$publink,$booktitle) 
{
	global $conection; 
 	$checkbox1=$authors;  
$chk="";  
foreach($checkbox1 as $chk1)  
   {  
      $chk .= $chk1.",";  
   }   
 
		$query = mysqli_query($conection,"UPDATE publication SET booktitle = '$booktitle',  authors = '$chk', yearpub= '$yearpub',
		      article = '$article', pub='$pub', publink='$publink' WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; publication.php">'; 
				die();
			}				
		return true;
	
}

/*===============================================================================================================================*/
/*================================================== Activities Functions =====================================================*/
/*===============================================================================================================================*/

// Display All Categories in the backoffice for the portfolio
function listActivities()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM activities ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	
                  <th>ID</th>
                  <th>".lang('IMAGE')."</th>
                  <th>".lang('IMAGE')."</th>
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";		
			echo $row['id'];
			echo "</td><td class='partner_img'>"; 
			echo "<img src='../assets/img/uploads/other/".$row['image1']."' alt='' />";
			echo "</td><td class='partner_img'>";
			echo "<img src='../assets/img/uploads/other/".$row['image2']."' alt='' />";
			echo "</td><td>";

			echo"
			<a href='edit_activities.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i> ".lang('EDIT')."</a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}

// Edit SERVICE CATEGORY function
function editActivities($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from activities WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='name'>".lang('NAME')."</label>  
					  <div class='col-md-6'>
					  <textarea rows ='1' cols='10' id='name' name='name' type='text' class='form-control input-md'>".$row['name']."</textarea>
						
					  </div>
					</div>
 

					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image1' id='image1'>
									<img src='../assets/img/uploads/other/".$row['image1']."' width='150px' hieght='150px' alt='' />
								</div>
						</div>

						<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image2' id='image2'>
									<img src='../assets/img/uploads/other/".$row['image2']."' width='150px' hieght='150px' alt='' />
								</div>
						</div>	

				";

}

// Update SERVICE CATEGORY Information
function updateActivities($id,$name,$image1,$image2)
{
	global $conection;
	$image1 = $_FILES['image1'];
	$image2 = $_FILES['image2'];

		if (!empty($image1["name"])) {
										 
		$largura = 1000000;
		$altura = 1000000;
		$tamanho = 500000000000;
										 
		if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image1["type"])){
		$error[1] = "Isso não é uma imagem.";
		} 
										 
		$dimensoes = getimagesize($image1["tmp_name"]); 
										 
		if($dimensoes[0] > $largura) {
			$error[2] = "A largura da imagem não deve ultrapassar ".$largura." pixels";
		}
										 
		if($dimensoes[1] > $altura) {
			$error[3] = "Image height should not exceed ".$altura." pixels";
		}
										 

		if($image1["size"] > $tamanho) {
			$error[4] = "Image must be at most ".$tamanho." bytes";
		}
										 

		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image1["name"], $ext); 
										 

		$nome_imagem = $image1["name"]; 
										 
		$caminho_imagem = "../assets/img/uploads/other/" . $nome_imagem; 
										 
		move_uploaded_file($image1["tmp_name"], $caminho_imagem); 
										
								
		$query = mysqli_query($conection,"UPDATE activities SET name = '$name', image1='$nome_imagem' WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; activities.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}
		}
		elseif (!empty($image2["name"])) {
										 
		$largura = 1000000;
		$altura = 1000000;
		$tamanho = 500000000000;
										 
		if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image2["type"])){
		$error[1] = "Isso não é uma imagem.";
		} 
										  
		$dimensoes1 = getimagesize($image2["tmp_name"]);
										 
		if($dimensoes1[0] > $largura) { 
			$error[2] = "A largura da imagem não deve ultrapassar ".$largura." pixels";
		}
										 
		if($dimensoes1[1] > $altura) {
			$error[3] = "Image height should not exceed ".$altura." pixels";
		}
										 

		if($image2["size"] > $tamanho) {
			$error[4] = "Image must be at most ".$tamanho." bytes";
		}
										 

		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image1["name"], $ext);
		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image2["name"], $ext);
										 

		$nome_imagem = $image1["name"];
		$nome_imagem1 = $image2["name"];
										 
		$caminho_imagem = "../assets/img/uploads/other/" . $nome_imagem;
		$caminho_imagem1 = "../assets/img/uploads/other/" . $nome_imagem1;
										 
		move_uploaded_file($image1["tmp_name"], $caminho_imagem);
		move_uploaded_file($image2["tmp_name"], $caminho_imagem1);
										
								
		$query = mysqli_query($conection,"UPDATE activities SET name = '$name', image2='$nome_imagem1' WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; activities.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}
		}
		else{
		$query = mysqli_query($conection,"UPDATE activities SET name = '$name'  WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; activities.php">'; 
				die();
			}				
		return true;
		}	
}
 
//end activities

/*===============================================================================================================================*/
/*================================================== Travel tourism Functions =====================================================*/
/*===============================================================================================================================*/

// Display All Categories in the backoffice for the portfolio
function listTravel()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM tours ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	
                  <th>ID</th>
                  <th>".lang('IMAGE1')."</th>
                  <th>".lang('IMAGE2')."</th>
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";		
			echo $row['id'];
			echo "</td><td class='resrt_img'>"; 
			echo "<img src='../assets/img/uploads/other/".$row['image1']."' alt='' />";
			echo "</td><td class='resrt_img'>";
			echo "<img src='../assets/img/uploads/other/".$row['image2']."' alt='' />";
			echo "</td><td>";

			echo"
			<a href='edit_travel.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i> ".lang('EDIT')."</a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}

// Edit SERVICE CATEGORY function
function editTravel($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from tours WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='name'>".lang('NAME')."</label>  
					  <div class='col-md-6'>
					  <textarea rows ='1' cols='10' id='name' name='name' type='text' class='form-control input-md'>".$row['name']."</textarea>
						
					  </div>
					</div>
 

					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image1' id='image1'>
									<img src='../assets/img/uploads/other/".$row['image1']."' width='150px' hieght='150px' alt='' />
								</div>
						</div>

						<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image2' id='image2'>
									<img src='../assets/img/uploads/other/".$row['image2']."' width='150px' hieght='150px' alt='' />
								</div>
						</div>	

				";

}

// Update SERVICE CATEGORY Information
function updateTravel($id,$name,$image1,$image2)
{
	global $conection;
	$image1 = $_FILES['image1'];
	$image2 = $_FILES['image2'];

		if (!empty($image1["name"])) {
										 
		$largura = 1000000;
		$altura = 1000000;
		$tamanho = 500000000000;
										 
		if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image1["type"])){
		$error[1] = "Isso não é uma imagem.";
		} 
										 
		$dimensoes = getimagesize($image1["tmp_name"]); 
										 
		if($dimensoes[0] > $largura) {
			$error[2] = "A largura da imagem não deve ultrapassar ".$largura." pixels";
		}
										 
		if($dimensoes[1] > $altura) {
			$error[3] = "Image height should not exceed ".$altura." pixels";
		}
										 

		if($image1["size"] > $tamanho) {
			$error[4] = "Image must be at most ".$tamanho." bytes";
		}
										 

		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image1["name"], $ext); 
										 

		$nome_imagem = $image1["name"]; 
										 
		$caminho_imagem = "../assets/img/uploads/other/" . $nome_imagem; 
										 
		move_uploaded_file($image1["tmp_name"], $caminho_imagem); 
										
								
		$query = mysqli_query($conection,"UPDATE tours SET name = '$name', image1='$nome_imagem' WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; travel.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}
		}
		elseif (!empty($image2["name"])) {
										 
		$largura = 1000000;
		$altura = 1000000;
		$tamanho = 500000000000;
										 
		if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image2["type"])){
		$error[1] = "Isso não é uma imagem.";
		} 
										  
		$dimensoes1 = getimagesize($image2["tmp_name"]);
										 
		if($dimensoes1[0] > $largura) { 
			$error[2] = "A largura da imagem não deve ultrapassar ".$largura." pixels";
		}
										 
		if($dimensoes1[1] > $altura) {
			$error[3] = "Image height should not exceed ".$altura." pixels";
		}
										 

		if($image2["size"] > $tamanho) {
			$error[4] = "Image must be at most ".$tamanho." bytes";
		}
										 

		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image1["name"], $ext);
		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image2["name"], $ext);
										 

		$nome_imagem = $image1["name"];
		$nome_imagem1 = $image2["name"];
										 
		$caminho_imagem = "../assets/img/uploads/other/" . $nome_imagem;
		$caminho_imagem1 = "../assets/img/uploads/other/" . $nome_imagem1;
										 
		move_uploaded_file($image1["tmp_name"], $caminho_imagem);
		move_uploaded_file($image2["tmp_name"], $caminho_imagem1);
										
								
		$query = mysqli_query($conection,"UPDATE tours SET name = '$name', image2='$nome_imagem1' WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; travel.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}
		}
		else{
		$query = mysqli_query($conection,"UPDATE tours SET name = '$name'  WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; travel.php">'; 
				die();
			}				
		return true;
		}	
}
//end ttourism

/*===============================================================================================================================*/
/*================================================== corporates Functions =====================================================*/
/*===============================================================================================================================*/

// Display All partners created in the backoffice
function listCorporates()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM facilities ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	
                  <th>ID</th>
				  <th>".lang('IMAGE')."</th>
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";		
			echo $row['id'];
			echo "</td><td class='partner_img'>"; 
			echo "<img src='../assets/img/uploads/partners/".$row['image']."' alt='' />";
			echo "</td><td>";
			echo"
			<a href='edit_slider1.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i> ".lang('EDIT')."</a>
			<a href='javascript:EliminaCorporates(". $row['id'] . ")'class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i> ".lang('DELETE')."</a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}

// Edit partner function
function editCorporates($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from facilities WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "

								
					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image' id='image'>
									<img src='../assets/img/uploads/partners/".$row['image']."' width='150px' hieght='150px' alt='' />
								</div>
						</div>
				";

}

// Update partner Information
function updateCorporates($id,$image1)
{
	global $conection;
	$image = $_FILES['image'];

										
											// Se a foto estiver sido selecionada
											if (!empty($image["name"])) {
										 
												// Largura máxima em pixels
												$largura = 1000000;
												// Altura máxima em pixels
												$altura = 1000000;
												// Tamanho máximo do arquivo em bytes
												$tamanho = 500000000000;
										 
												// Verifica se o arquivo é uma imagem
												if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image["type"])){
												   $error[1] = "Isso não é uma imagem.";
												} 
										 
												// Pega as dimensões da imagem
												$dimensoes = getimagesize($image["tmp_name"]);
										 
												// Verifica se a largura da imagem é maior que a largura permitida
												if($dimensoes[0] > $largura) {
													$error[2] = "Image width should not exceed".$largura." pixels";
												}
										 
												// Verifica se a altura da imagem é maior que a altura permitida
												if($dimensoes[1] > $altura) {
													$error[3] = "Image height should not exceed ".$altura." pixels";
												}
										 
												// Verifica se o tamanho da imagem é maior que o tamanho permitido
												if($image["size"] > $tamanho) {
													$error[4] = "Image must be at most ".$tamanho." bytes";
												}
										 
													// Pega extensão da imagem
													preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image["name"], $ext);
										 
													// Gera um nome único para a imagem
													$nome_imagem = $image["name"];
										 
													// Caminho de onde ficará a imagem
													$caminho_imagem = "../assets/img/uploads/partners/" . $nome_imagem;
										 
													// Faz o upload da imagem para seu respectivo caminho
													move_uploaded_file($image["tmp_name"], $caminho_imagem);
										 
												
													$query = mysqli_query($conection,"UPDATE facilities SET image='$nome_imagem' WHERE id = '$id'");
													if (!$query) {
														echo ("No data was inserted!: " . mysqli_error());
														return false;
													} else {
															echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
																	echo '<meta http-equiv="refresh" content="1; resortsliders.php">'; 
																	die();
															}				
															return true;

												// Se houver mensagens de erro, exibe-as
												if (count($error) != 0) {
													foreach ($error as $erro) {
														echo $erro . "<br />";
													}
												}

										}
									}



/*===============================================================================================================================*/
/*================================================== Local Tours Functions =====================================================*/
/*===============================================================================================================================*/

// Display All partners created in the backoffice
function listLocaltours()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM localtours ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	
                  <th>ID</th>
				  <th>".lang('IMAGE')."</th>
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";		
			echo $row['id'];
			echo "</td><td class='partner_img'>"; 
			echo "<img src='../assets/img/uploads/partners/".$row['image']."' alt='' />";
			echo "</td><td>";
			echo"
			<a href='edit_slider2.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i> ".lang('EDIT')."</a>
			<a href='javascript:EliminaLocaltours(". $row['id'] . ")'class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i> ".lang('DELETE')."</a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}

// Edit partner function
function editLocaltours($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from localtours WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "

								
					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image' id='image'>
									<img src='../assets/img/uploads/partners/".$row['image']."' width='150px' hieght='150px' alt='' />
								</div>
						</div>
				";

}

// Update partner Information
function updateLocaltours($id,$image1)
{
	global $conection;
	$image = $_FILES['image'];

										
											// Se a foto estiver sido selecionada
											if (!empty($image["name"])) {
										 
												// Largura máxima em pixels
												$largura = 1000000;
												// Altura máxima em pixels
												$altura = 1000000;
												// Tamanho máximo do arquivo em bytes
												$tamanho = 500000000000;
										 
												// Verifica se o arquivo é uma imagem
												if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image["type"])){
												   $error[1] = "Isso não é uma imagem.";
												} 
										 
												// Pega as dimensões da imagem
												$dimensoes = getimagesize($image["tmp_name"]);
										 
												// Verifica se a largura da imagem é maior que a largura permitida
												if($dimensoes[0] > $largura) {
													$error[2] = "Image width should not exceed".$largura." pixels";
												}
										 
												// Verifica se a altura da imagem é maior que a altura permitida
												if($dimensoes[1] > $altura) {
													$error[3] = "Image height should not exceed ".$altura." pixels";
												}
										 
												// Verifica se o tamanho da imagem é maior que o tamanho permitido
												if($image["size"] > $tamanho) {
													$error[4] = "Image must be at most ".$tamanho." bytes";
												}
										 
													// Pega extensão da imagem
													preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image["name"], $ext);
										 
													// Gera um nome único para a imagem
													$nome_imagem = $image["name"];
										 
													// Caminho de onde ficará a imagem
													$caminho_imagem = "../assets/img/uploads/partners/" . $nome_imagem;
										 
													// Faz o upload da imagem para seu respectivo caminho
													move_uploaded_file($image["tmp_name"], $caminho_imagem);
										 
												
													$query = mysqli_query($conection,"UPDATE localtours SET image='$nome_imagem' WHERE id = '$id'");
													if (!$query) {
														echo ("No data was inserted!: " . mysqli_error());
														return false;
													} else {
															echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
																	echo '<meta http-equiv="refresh" content="1; resortsliders.php">'; 
																	die();
															}				
															return true;

												// Se houver mensagens de erro, exibe-as
												if (count($error) != 0) {
													foreach ($error as $erro) {
														echo $erro . "<br />";
													}
												}

										}
									}

/*===============================================================================================================================*/
/*================================================== Piligrim Functions =====================================================*/
/*===============================================================================================================================*/

// Display All partners created in the backoffice
function listPiligrim()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM piligrim ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	
                  <th>ID</th>
				  <th>".lang('IMAGE')."</th>
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";		
			echo $row['id'];
			echo "</td><td class='partner_img'>"; 
			echo "<img src='../assets/img/uploads/partners/".$row['image']."' alt='' />";
			echo "</td><td>";
			echo"
			<a href='edit_slider3.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i> ".lang('EDIT')."</a>
			<a href='javascript:EliminaPiligrim(". $row['id'] . ")'class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i> ".lang('DELETE')."</a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}

// Edit partner function
function editPiligrim($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from piligrim WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "

								
					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image' id='image'>
									<img src='../assets/img/uploads/partners/".$row['image']."' width='150px' hieght='150px' alt='' />
								</div>
						</div>
				";

}

// Update partner Information
function updatePiligrim($id,$image1)
{
	global $conection;
	$image = $_FILES['image'];

										
											// Se a foto estiver sido selecionada
											if (!empty($image["name"])) {
										 
												// Largura máxima em pixels
												$largura = 1000000;
												// Altura máxima em pixels
												$altura = 1000000;
												// Tamanho máximo do arquivo em bytes
												$tamanho = 500000000000;
										 
												// Verifica se o arquivo é uma imagem
												if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image["type"])){
												   $error[1] = "Isso não é uma imagem.";
												} 
										 
												// Pega as dimensões da imagem
												$dimensoes = getimagesize($image["tmp_name"]);
										 
												// Verifica se a largura da imagem é maior que a largura permitida
												if($dimensoes[0] > $largura) {
													$error[2] = "Image width should not exceed".$largura." pixels";
												}
										 
												// Verifica se a altura da imagem é maior que a altura permitida
												if($dimensoes[1] > $altura) {
													$error[3] = "Image height should not exceed ".$altura." pixels";
												}
										 
												// Verifica se o tamanho da imagem é maior que o tamanho permitido
												if($image["size"] > $tamanho) {
													$error[4] = "Image must be at most ".$tamanho." bytes";
												}
										 
													// Pega extensão da imagem
													preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image["name"], $ext);
										 
													// Gera um nome único para a imagem
													$nome_imagem = $image["name"];
										 
													// Caminho de onde ficará a imagem
													$caminho_imagem = "../assets/img/uploads/partners/" . $nome_imagem;
										 
													// Faz o upload da imagem para seu respectivo caminho
													move_uploaded_file($image["tmp_name"], $caminho_imagem);
										 
												
													$query = mysqli_query($conection,"UPDATE piligrim SET image='$nome_imagem' WHERE id = '$id'");
													if (!$query) {
														echo ("No data was inserted!: " . mysqli_error());
														return false;
													} else {
															echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
																	echo '<meta http-equiv="refresh" content="1; resortsliders.php">'; 
																	die();
															}				
															return true;

												// Se houver mensagens de erro, exibe-as
												if (count($error) != 0) {
													foreach ($error as $erro) {
														echo $erro . "<br />";
													}
												}

										}
									}					
// end piligrim 


/*===============================================================================================================================*/
/*================================================== Reviews Functions =====================================================*/
/*===============================================================================================================================*/

// Display All Categories in the backoffice for the portfolio
function listReviews()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM reviews ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	
                  <th>ID</th>
                  <th>Author</th>
                  <th>Description</th> 
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";		
			echo $row['id'];
			echo "</td><td>";
			echo $row['name'];
			echo "</td><td>";
			echo $row['descript'];
			echo "</td><td>";
			echo"
			<a href='edit_reviews.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i> ".lang('EDIT')."</a>
			<a href='javascript:EliminaReviews(". $row['id'] . ")'class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i> ".lang('DELETE')."</a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}
 
// Edit SERVICE CATEGORY function
function editReviews($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from reviews WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='name'>Author Name</label>  
					  <div class='col-md-6'>
					  <textarea rows ='1' cols='10' id='name' name='name' type='text' class='form-control input-md'>".$row['name']."</textarea>
						
					  </div>
					</div>

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='descript'>Description</label>  
					  <div class='col-md-6'>
					  <textarea rows ='1' cols='10' id='descript' name='descript' type='text' class='form-control input-md'>".$row['descript']."</textarea>
						
					  </div>
					</div>
  
				";

}

// Update SERVICE CATEGORY Information
function updateReviews($id,$name,$descript)
{
	global $conection; 

		$query = mysqli_query($conection,"UPDATE reviews SET name = '$name', descript = '$descript' WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; reviews.php">'; 
				die();
			}				
		return true;
}
 
//end reviews


/*===============================================================================================================================*/
/*========================================= About Resort SLider Functions =====================================================*/
/*===============================================================================================================================*/

// Display All partners created in the backoffice
function listAbtresort()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM abtresort ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	
                  <th>ID</th>
				  <th>".lang('IMAGE')."</th>
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";		
			echo $row['id'];
			echo "</td><td class='partner_img'>"; 
			echo "<img src='../assets/img/uploads/partners/".$row['image']."' alt='' />";
			echo "</td><td>";
			echo"
			<a href='edit_abtresort.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i> ".lang('EDIT')."</a>
			<a href='javascript:EliminaAbtresort(". $row['id'] . ")'class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i> ".lang('DELETE')."</a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}

// Edit partner function
function editAbtresort($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from abtresort WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "

								
					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image' id='image'>
									<img src='../assets/img/uploads/partners/".$row['image']."' width='150px' hieght='150px' alt='' />
								</div>
						</div>
				";

}

// Update partner Information
function updateAbtresort($id,$image1)
{
	global $conection;
	$image = $_FILES['image'];

										
											// Se a foto estiver sido selecionada
											if (!empty($image["name"])) {
										 
												// Largura máxima em pixels
												$largura = 1000000;
												// Altura máxima em pixels
												$altura = 1000000;
												// Tamanho máximo do arquivo em bytes
												$tamanho = 500000000000;
										 
												// Verifica se o arquivo é uma imagem
												if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image["type"])){
												   $error[1] = "Isso não é uma imagem.";
												} 
										 
												// Pega as dimensões da imagem
												$dimensoes = getimagesize($image["tmp_name"]);
										 
												// Verifica se a largura da imagem é maior que a largura permitida
												if($dimensoes[0] > $largura) {
													$error[2] = "Image width should not exceed".$largura." pixels";
												}
										 
												// Verifica se a altura da imagem é maior que a altura permitida
												if($dimensoes[1] > $altura) {
													$error[3] = "Image height should not exceed ".$altura." pixels";
												}
										 
												// Verifica se o tamanho da imagem é maior que o tamanho permitido
												if($image["size"] > $tamanho) {
													$error[4] = "Image must be at most ".$tamanho." bytes";
												}
										 
													// Pega extensão da imagem
													preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image["name"], $ext);
										 
													// Gera um nome único para a imagem
													$nome_imagem = $image["name"];
										 
													// Caminho de onde ficará a imagem
													$caminho_imagem = "../assets/img/uploads/partners/" . $nome_imagem;
										 
													// Faz o upload da imagem para seu respectivo caminho
													move_uploaded_file($image["tmp_name"], $caminho_imagem);
										 
												
													$query = mysqli_query($conection,"UPDATE abtresort SET image='$nome_imagem' WHERE id = '$id'");
													if (!$query) {
														echo ("No data was inserted!: " . mysqli_error());
														return false;
													} else {
															echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
																	echo '<meta http-equiv="refresh" content="1; abtresort.php">'; 
																	die();
															}				
															return true;

												// Se houver mensagens de erro, exibe-as
												if (count($error) != 0) {
													foreach ($error as $erro) {
														echo $erro . "<br />";
													}
												}

										}
									}					
// end About Resort slider 

/*===============================================================================================================================*/
/*========================== Resort Accomodation SLider Functions =====================================================*/
/*===============================================================================================================================*/

// Display All partners created in the backoffice
function listAcmresort()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM acmresort ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	
                  <th>ID</th>
				  <th>".lang('IMAGE')."</th>
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";		
			echo $row['id'];
			echo "</td><td class='partner_img'>"; 
			echo "<img src='../assets/img/uploads/partners/".$row['image']."' alt='' />";
			echo "</td><td>";
			echo"
			<a href='edit_acmresort.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i> ".lang('EDIT')."</a>
			<a href='javascript:EliminaAcmresort(". $row['id'] . ")'class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i> ".lang('DELETE')."</a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}

// Edit partner function
function editAcmresort($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from acmresort WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "

								
					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image' id='image'>
									<img src='../assets/img/uploads/partners/".$row['image']."' width='150px' hieght='150px' alt='' />
								</div>
						</div>
				";

}

// Update partner Information
function updateAcmresort($id,$image1)
{
	global $conection;
	$image = $_FILES['image'];

										
											// Se a foto estiver sido selecionada
											if (!empty($image["name"])) {
										 
												// Largura máxima em pixels
												$largura = 1000000;
												// Altura máxima em pixels
												$altura = 1000000;
												// Tamanho máximo do arquivo em bytes
												$tamanho = 500000000000;
										 
												// Verifica se o arquivo é uma imagem
												if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image["type"])){
												   $error[1] = "Isso não é uma imagem.";
												} 
										 
												// Pega as dimensões da imagem
												$dimensoes = getimagesize($image["tmp_name"]);
										 
												// Verifica se a largura da imagem é maior que a largura permitida
												if($dimensoes[0] > $largura) {
													$error[2] = "Image width should not exceed".$largura." pixels";
												}
										 
												// Verifica se a altura da imagem é maior que a altura permitida
												if($dimensoes[1] > $altura) {
													$error[3] = "Image height should not exceed ".$altura." pixels";
												}
										 
												// Verifica se o tamanho da imagem é maior que o tamanho permitido
												if($image["size"] > $tamanho) {
													$error[4] = "Image must be at most ".$tamanho." bytes";
												}
										 
													// Pega extensão da imagem
													preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image["name"], $ext);
										 
													// Gera um nome único para a imagem
													$nome_imagem = $image["name"];
										 
													// Caminho de onde ficará a imagem
													$caminho_imagem = "../assets/img/uploads/partners/" . $nome_imagem;
										 
													// Faz o upload da imagem para seu respectivo caminho
													move_uploaded_file($image["tmp_name"], $caminho_imagem);
										 
												
													$query = mysqli_query($conection,"UPDATE acmresort SET image='$nome_imagem' WHERE id = '$id'");
													if (!$query) {
														echo ("No data was inserted!: " . mysqli_error());
														return false;
													} else {
															echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
																	echo '<meta http-equiv="refresh" content="1; abtresort.php">'; 
																	die();
															}				
															return true;

												// Se houver mensagens de erro, exibe-as
												if (count($error) != 0) {
													foreach ($error as $erro) {
														echo $erro . "<br />";
													}
												}

										}
									}					
// end   Resort  accomodation slider 

/*===============================================================================================================================*/
/*================================================== Team building Functions =====================================================*/
/*===============================================================================================================================*/

// Display All partners created in the backoffice
function listTeambuild()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM team ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	 
				  <th>Name</th> 
				  <th>Photo</th>
				  <th>Designation</th>
				  <th>Email</th>
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";		
			echo $row['name']." ".$row['qualification'];  
			echo "</td><td class='partner_img'>"; 
			echo "<img src='../assets/images/uploads/".$row['image']."' alt='' />";
			echo "</td><td>";
			echo $row['designation'];
			echo "</td><td>";
			echo $row['email'] ;
			echo "</td><td>";
			echo"
			<a  href='edit_team.php?id=". $row['id'] . "'  class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i> ".lang('EDIT')."</a>
			<a  href='javascript:EliminaTeambuild(". $row['id'] . ")' class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i> ".lang('DELETE')."</a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}

// Edit partner function
function editTeambuild($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from team WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    $dept = $row['dept'];
    if ( $dept  == 'Faculty' ) 
    {  
    echo " 
    			<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='name'>Name</label>  
					  <div class='col-md-6'>
					  	<input id='name' name='name' type='text' class='form-control input-md' value='".$row['name']."' />
					  </div>
					</div>
    			<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='qualification'>Qualification</label>  
					  <div class='col-md-6'>
					  	<input id='qualification' name='qualification' type='text' class='form-control input-md' value='".$row['qualification']."' />
					  </div>
					</div>
  			<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='designation'>Designation</label>  
					  <div class='col-md-6'>
					  	<input id='designation' name='designation' type='text' class='form-control input-md' value='".$row['designation']."' />
					  </div>
					</div>
    			<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='email'>Email</label>  
					  <div class='col-md-6'>
					  	<input id='email' name='email' type='text' class='form-control input-md' value='".$row['email']."' />
					  </div>
					</div> 
					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeAddress'> Biography </label>  
					  <div class='col-md-6'> 
					  		<textarea rows ='4' cols='10' id='editor' name='biography' type='text' class='form-control input-md'>".$row['biography']."</textarea>
					  </div>
					</div>  
					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeAddress'> Projects </label>  
					  <div class='col-md-6'> 
					  		<textarea rows ='4' cols='10' id='editor1' name='scientificdiscipline' type='text' class='form-control input-md'>
					  		".$row['scientificdiscipline']."</textarea>
					  </div>
					</div>  
					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeAddress'> Patents </label>  
					  <div class='col-md-6'> 
					  		<textarea rows ='4' cols='10' id='editor2' name='education' type='text' class='form-control input-md'>".$row['education']."</textarea>
					  </div>
					</div>   
    			<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='linkedin'>Linkedin</label>  
					  <div class='col-md-6'>
					  	<input id='linkedin' name='linkedin' type='text' class='form-control input-md' value='".$row['linkedin']."' />
					  </div>
					</div>
    			<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='googles'>Google Scholar</label>  
					  <div class='col-md-6'>
					  	<input id='googles' name='googles' type='text' class='form-control input-md' value='".$row['googles']."' />
					  </div>
					</div>  
										<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image' id='image'>
									<img src='../assets/images/uploads/".$row['image']."' width='150px' hieght='150px' alt='' />
								</div>
						</div> 
				";

} else {

    echo " 

<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='name'>Name</label>  
					  <div class='col-md-6'>
					  	<input id='name' name='name' type='text' class='form-control input-md' value='".$row['name']."' />
					  </div>
					</div>
    			<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='qualification'>Qualification</label>  
					  <div class='col-md-6'>
					  	<input id='qualification' name='qualification' type='text' class='form-control input-md' value='".$row['qualification']."' />
					  </div>
					</div>
  			<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='designation'>Designation</label>  
					  <div class='col-md-6'>
					  	<input id='designation' name='designation' type='text' class='form-control input-md' value='".$row['designation']."' />
					  </div>
					</div>
    			<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='email'>Email</label>  
					  <div class='col-md-6'>
					  	<input id='email' name='email' type='text' class='form-control input-md' value='".$row['email']."' />
					  </div>
					</div> 
					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeAddress'> Biography </label>  
					  <div class='col-md-6'> 
					  		<textarea rows ='4' cols='10' id='editor' name='biography' type='text' class='form-control input-md'>".$row['biography']."</textarea>
					  </div>
					</div>   
    			<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='linkedin'>Linkedin</label>  
					  <div class='col-md-6'>
					  	<input id='linkedin' name='linkedin' type='text' class='form-control input-md' value='".$row['linkedin']."' />
					  </div>
					</div>
    			<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='googles'>Google Scholar</label>  
					  <div class='col-md-6'>
					  	<input id='googles' name='googles' type='text' class='form-control input-md' value='".$row['googles']."' />
					  </div>
					</div>  
										<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image' id='image'>
									<img src='../assets/images/uploads/".$row['image']."' width='150px' hieght='150px' alt='' />
								</div>
						</div> 
				";

}
}

// Update partner Information
function updateTeambuild($id,$name,$qualification,$designation,$email,$biography,$scientificdiscipline,$education,$linkedin,$googles,$image)
{
	global $conection;
	echo $image = $_FILES['image']; 
  	echo $name = $_POST['name'];  
		echo $qualification = $_POST['qualification']; 
  	echo $designation = $_POST['designation'];  
		echo $email = $_POST['email']; 
  	echo $biography = $_POST['biography'];  
		echo $scientificdiscipline = $_POST['scientificdiscipline']; 
  	echo $education = $_POST['education'];   
		echo $linkedin = $_POST['linkedin']; 
  	echo $googles = $_POST['googles'];   
										
											// Se a foto estiver sido selecionada
											if (!empty($image["name"])) {
										 
												// Largura máxima em pixels
												$largura = 1000000;
												// Altura máxima em pixels
												$altura = 1000000;
												// Tamanho máximo do arquivo em bytes
												$tamanho = 500000000000;
										 
												// Verifica se o arquivo é uma imagem
												if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image["type"])){
												   $error[1] = "Isso não é uma imagem.";
												} 
										 
												// Pega as dimensões da imagem
												$dimensoes = getimagesize($image["tmp_name"]);
										 
												// Verifica se a largura da imagem é maior que a largura permitida
												if($dimensoes[0] > $largura) {
													$error[2] = "Image width should not exceed".$largura." pixels";
												}
										 
												// Verifica se a altura da imagem é maior que a altura permitida
												if($dimensoes[1] > $altura) {
													$error[3] = "Image height should not exceed ".$altura." pixels";
												}
										 
												// Verifica se o tamanho da imagem é maior que o tamanho permitido
												if($image["size"] > $tamanho) {
													$error[4] = "Image must be at most ".$tamanho." bytes";
												}
										 
													// Pega extensão da imagem
													preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image["name"], $ext);
										 
													// Gera um nome único para a imagem
													$nome_imagem = $image["name"];
										 
													// Caminho de onde ficará a imagem
													$caminho_imagem = "../assets/images/uploads/" . $nome_imagem;
										 
													// Faz o upload da imagem para seu respectivo caminho
													move_uploaded_file($image["tmp_name"], $caminho_imagem);
										 
												
													$query = mysqli_query($conection,"UPDATE team SET  name='$name', qualification='$qualification',
													 designation='$designation', email='$email', biography='$biography', scientificdiscipline='$scientificdiscipline', education='$education', linkedin='$linkedin', 
													 googles='$googles',image='$nome_imagem' WHERE id = '$id'");
													if (!$query) {
														echo ("No data was inserted!: " . mysqli_error());
														return false;
													} else {
															echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
																	echo '<meta http-equiv="refresh" content="1; team.php">'; 
																	die();
															}				
															return true;

												// Se houver mensagens de erro, exibe-as
												if (count($error) != 0) {
													foreach ($error as $erro) {
														echo $erro . "<br />";
													}
												}

										}
										else


													$query = mysqli_query($conection,"UPDATE team SET  name='$name', qualification='$qualification',
													 designation='$designation', email='$email', biography='$biography', scientificdiscipline='$scientificdiscipline', education='$education', linkedin='$linkedin', 
													 googles='$googles'  WHERE id = '$id'");
													if (!$query) {
														echo ("No data was inserted!: " . mysqli_error());
														return false;
													} else {
															echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
																	echo '<meta http-equiv="refresh" content="1; team.php">'; 
																	die();
															}				
															return true;

												// Se houver mensagens de erro, exibe-as
												if (count($error) != 0) {
													foreach ($error as $erro) {
														echo $erro . "<br />";
													}
												}

									}					
// end teambuilding 

/*===============================================================================================================================*/
/*================================================== Conference Functions =====================================================*/
/*===============================================================================================================================*/

// Display All partners created in the backoffice
function listConference()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM conference ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	
                  <th>ID</th>
				  <th>".lang('IMAGE')."</th>
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";		
			echo $row['id'];
			echo "</td><td class='partner_img'>"; 
			echo "<img src='../assets/img/uploads/partners/".$row['image']."' alt='' />";
			echo "</td><td>";
			echo"
			<a href='edit_conference.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i> ".lang('EDIT')."</a>
			<a href='javascript:EliminaConference(". $row['id'] . ")'class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i> ".lang('DELETE')."</a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}

// Edit partner function
function editConference($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from conference WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "

								
					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image' id='image'>
									<img src='../assets/img/uploads/partners/".$row['image']."' width='150px' hieght='150px' alt='' />
								</div>
						</div>
				";

}

// Update partner Information
function updateConference($id,$image1)
{
	global $conection;
	$image = $_FILES['image'];

										
											// Se a foto estiver sido selecionada
											if (!empty($image["name"])) {
										 
												// Largura máxima em pixels
												$largura = 1000000;
												// Altura máxima em pixels
												$altura = 1000000;
												// Tamanho máximo do arquivo em bytes
												$tamanho = 500000000000;
										 
												// Verifica se o arquivo é uma imagem
												if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image["type"])){
												   $error[1] = "Isso não é uma imagem.";
												} 
										 
												// Pega as dimensões da imagem
												$dimensoes = getimagesize($image["tmp_name"]);
										 
												// Verifica se a largura da imagem é maior que a largura permitida
												if($dimensoes[0] > $largura) {
													$error[2] = "Image width should not exceed".$largura." pixels";
												}
										 
												// Verifica se a altura da imagem é maior que a altura permitida
												if($dimensoes[1] > $altura) {
													$error[3] = "Image height should not exceed ".$altura." pixels";
												}
										 
												// Verifica se o tamanho da imagem é maior que o tamanho permitido
												if($image["size"] > $tamanho) {
													$error[4] = "Image must be at most ".$tamanho." bytes";
												}
										 
													// Pega extensão da imagem
													preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image["name"], $ext);
										 
													// Gera um nome único para a imagem
													$nome_imagem = $image["name"];
										 
													// Caminho de onde ficará a imagem
													$caminho_imagem = "../assets/img/uploads/partners/" . $nome_imagem;
										 
													// Faz o upload da imagem para seu respectivo caminho
													move_uploaded_file($image["tmp_name"], $caminho_imagem);
										 
												
													$query = mysqli_query($conection,"UPDATE conference SET image='$nome_imagem' WHERE id = '$id'");
													if (!$query) {
														echo ("No data was inserted!: " . mysqli_error());
														return false;
													} else {
															echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
																	echo '<meta http-equiv="refresh" content="1; conference.php">'; 
																	die();
															}				
															return true;

												// Se houver mensagens de erro, exibe-as
												if (count($error) != 0) {
													foreach ($error as $erro) {
														echo $erro . "<br />";
													}
												}

										}
									}					
// end conference

function listHomecontent()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM homecontent ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	                 
                  <th>Paragraph 1</th>                   
                  <th>Paragraph 2</th>  
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";	 
			echo $row['descript'];
			echo "</td><td>"; 
			echo $row['descript2'];
			echo "</td><td>";
			echo"
			<a href='edit_homecontent.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i></a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}


// Edit NURSE function
function editHomecontent($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from homecontent WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeAddress'>Paragraph 1 </label>  
					  <div class='col-md-6'>
					  	<textarea rows ='1' cols='10' id='editor' name='descript' type='text' class='form-control input-md'>".$row['descript']."</textarea>
					  </div>
					</div>
  

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeAddress'>Paragraph 2 </label>  
					  <div class='col-md-6'>
					  	<textarea rows ='12' cols='10' id='editor1' name='descript2' type='text' class='form-control input-md'>".$row['descript2']."</textarea>
					  </div>
					</div>

				";

}

// Update NURSE Information
function updateHomecontent($id,$descript,$descript2)
{
	global $conection;

    $title = $_POST['descript'];  
	$descript = $_POST['descript2']; 

 
		$query = mysqli_query($conection,"UPDATE homecontent SET  descript = '$title',   descript2 = '$descript' WHERE id = '$id'");

			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', 'Updated Sucessfully', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; abtresort.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}

		} 
 
/*************************************/

function listHomecontent1()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM homecontent1 ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	                 
                  <th>Best Resort in Chikmagalur</th>     
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";	 
			echo $row['descript'];
			echo "</td><td>";  
			echo"
			<a href='edit_resorttext.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i></a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}


// Edit NURSE function
function editHomecontent1($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from homecontent1 WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeAddress'> Best Resort in Chikmagalur </label>  
					  <div class='col-md-6'>
					  	<textarea rows ='1' cols='10' id='editor' name='descript' type='text' class='form-control input-md'>".$row['descript']."</textarea>
					  </div>
					</div> 

				";

}

// Update NURSE Information
function updateHomecontent1($id,$descript)
{
	global $conection;

    $title = $_POST['descript'];   

 
		$query = mysqli_query($conection,"UPDATE homecontent1 SET  descript = '$title'  WHERE id = '$id'");

			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', 'Updated Sucessfully', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; resorttext.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}

		} 

/***************** Programs **************/ 
function listPrograms()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM pinterest ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	
                  <th>Title</th> 
                  <th>Image</th>				   
                  <th>Description</th>
                  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";		
			echo $row['title']; 
			echo "</td><td class='partner_img'>"; 
			echo "<img src='assets/img/uploads/programs/".$row['image']."' alt='' />";
			echo "</td><td>";
			echo $row['descript'];
			echo "</td><td>";

			echo"
			<a href='edit_pinterest.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i></a>
			<a href='javascript:EliminaPrograms(". $row['id'] . ")'class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i></a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}
 


// Edit NURSE function
function editPrograms($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from pinterest WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeName'>Title</label>  
					  <div class='col-md-6'>
					  	<textarea rows ='1' cols='10' id='title' name='title' type='text' class='form-control input-md'>".$row['title']."</textarea>
					  </div>
					</div>
					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image' id='image' >
									<img src='../admin/assets/img/uploads/programs/".$row['image']."' name='image' width='150px' hieght='150px' alt='' />
								</div>
						</div>

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeAddress'> Description </label>  
					  <div class='col-md-6'>
					  	<textarea rows ='7' cols='10' id='descript' name='descript' type='text' class='form-control input-md'>".$row['descript']."</textarea>
					  </div>
					</div> 
				";

}

// Update NURSE Information
function updatePrograms($id,$title,$image,$descript)
{
	global $conection;

  $title = $_POST['title'];  
	$image = $_FILES['image']; 
	$descript = $_POST['descript'];  


		if (!empty($image["name"])) {
										 
		$largura = 1000000;
		$altura = 1000000;
		$tamanho = 500000000000;
										 
		if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image["type"])){
		$error[1] = "Isso não é uma imagem.";
		} 
										  
		$dimensoes = getimagesize($image["tmp_name"]); 
										 
		if(($dimensoes[0] > $largura))  {
			$error[2] = "Image width should not exceed".$largura." pixels";
		}
										 
		if($dimensoes[1] > $altura) {
			$error[3] = "Image height should not exceed ".$altura." pixels";
		}
										 
		if($image["size"] > $tamanho) {
			$error[4] = "A imagem deve ter no máximo ".$tamanho." bytes";
		}
 			 
		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image["name"], $ext); 

		$nome_imagem = $image["name"]; 
		$caminho_imagem = "assets/img/uploads/programs/" . $nome_imagem; 
										 
		move_uploaded_file($image["tmp_name"], $caminho_imagem); 
							
								
		$query = mysqli_query($conection,"UPDATE pinterest SET title = '$title', image = '$nome_imagem', descript = '$descript'  WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', 'Content Updated', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; pinterest.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}
		}else{

		$query = mysqli_query($conection,"UPDATE pinterest SET title = '$title', descript = '$descript'    WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', 'Updated', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; pinterest.php">'; 
				die();
			}				
		return true;
		}	
}
/******************* Places ********************/
function listPlaces()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM places ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	
                  <th>ID</th>
				  <th>".lang('IMAGE')."</th>
				  <th>".lang('TITLE')."</th> 
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";		
			echo $row['id'];
			echo "</td><td class='partner_img'>"; 
			echo "<img src='../assets/img/uploads/places/".$row['image']."' alt='' />";
			echo "</td><td>";			
			echo $row['title'];
			echo "</td><td>"; 
			echo"
			<a href='edit_places.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i> ".lang('EDIT')."</a>
			<a href='javascript:EliminaPlaces(". $row['id'] . ")'class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i> ".lang('DELETE')."</a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}

// Edit project function
function editPlaces($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from places WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo " 		 
					<!-- Image input-->
					<div class='form-group'>
						<label class='col-md-2 control-label' for='image'>".lang('UPLOAD_IMAGE')."</label>
							<div class='col-md-6'>
								<input type='file' name='image' id='image'>
								<img src='../assets/img/uploads/places/".$row['image']."' width='150px' height='150px' alt='' />
							</div>
					</div>			

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='title'>".lang('TITLE')."</label>  
					  <div class='col-md-6'>
					  <textarea rows ='1' cols='10' id='title' name='title' type='text' class='form-control input-md'>".$row['title']."</textarea>
					  </div>
					</div>
				";
}

// Update project Information
function updatePlaces($id,$image1,$title)
{
	global $conection;
	$image = $image1;

											if (!empty($image["name"])) {
										 
												$largura = 1000000;
												$altura = 1000000;
												$tamanho = 500000000000;
										 
												if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image["type"])){
												   $error[1] = "Isso não é uma imagem.";
												} 
										 
												$dimensoes = getimagesize($image["tmp_name"]);
										 
												if($dimensoes[0] > $largura) {
													$error[2] = "The width of the image should not exceed ".$largura." pixels";
												}
										 
												if($dimensoes[1] > $altura) {
													$error[3] = "Image height should not exceed".$altura." pixels";
												}
										 
												if($image["size"] > $tamanho) {
													$error[4] = "Image must be at most ".$tamanho." bytes";
												}
										 
													preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image["name"], $ext);
										 
													$nome_imagem = $image["name"];
										 
													$caminho_imagem = "../assets/img/uploads/places/" . $nome_imagem;
										 
													move_uploaded_file($image["tmp_name"], $caminho_imagem);
										 
													
													$query = mysqli_query($conection,"UPDATE places SET image='$nome_imagem', title = '$title' WHERE id = '$id'");
													if (!$query) {
														echo ("No data was inserted!: " . mysqli_error());
														return false;
													} else {
															echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
																	echo '<meta http-equiv="refresh" content="1; places.php">'; 
																	die();
															}				
															return true;

												if (count($error) != 0) {
													foreach ($error as $erro) {
														echo $erro . "<br />";
													}
												}

										}else{

	$query = mysqli_query($conection,"UPDATE places SET title = '$title' WHERE id = '$id'");
		if (!$query) {
			echo ("No data was inserted!: " . mysqli_error());
				return false;
			} else {
			echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
			echo '<meta http-equiv="refresh" content="1; places.php">';  
			die();
		}				
	return true;
	}
	
}
/************** Chikmagalur ***************/

function listChik()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM chikmagalur ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	                 
                  <th>Title</th>                   
                  <th>Description</th>  
                  <th>Image</th> 
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";	 
			echo $row['title'];
			echo "</td><td>"; 
			echo $row['ranks'];
			echo "</td><td class='partner_img'>"; 
			echo "<img src='../admin/assets/img/uploads/".$row['image']."' alt='' />"; 
			echo "</td><td>";
			echo"
			<a href='edit_chikmagalur.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i></a>
			<a href='javascript:EliminaChikmagalur(". $row['id'] . ")'class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i></a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}


// Edit NURSE function
function editChikmagalur($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from chikmagalur WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeAddress'>Title</label>  
					  <div class='col-md-6'>
					  	<input id='name' name='title' type='text' class='form-control input-md' value='".$row['title']."' />
					  </div>
					</div>

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeAddress'> Description </label>  
					  <div class='col-md-6'> 
					  		<textarea rows ='4' cols='10' id='editor' name='ranks' type='text' class='form-control input-md'>".$row['ranks']."</textarea>
					  </div>
					</div>  

					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image' id='image'>
									<img src='../admin/assets/img/uploads/".$row['image']."' width='150px' hieght='150px' alt='' />
								</div>
						</div>
				";
}

// Update message Information
function updateChikmagalur($id,$title,$ranks,$image)
{
	global $conection;

    $title = $_POST['title'];  
	$ranks = $_POST['ranks']; 
	$image = $_FILES['image'];

		if (!empty($image["name"])) {
										 
		$largura = 1000000;
		$altura = 1000000;
		$tamanho = 500000000000;
										 
		if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image["type"])){
		$error[1] = "Isso não é uma imagem.";
		} 
										 
		$dimensoes = getimagesize($image["tmp_name"]);
										 
		if($dimensoes[0] > $largura) {
			$error[2] = "Image width should not exceed".$largura." pixels";
		}
										 
		if($dimensoes[1] > $altura) {
			$error[3] = "Image height should not exceed ".$altura." pixels";
		}
										 
		if($image["size"] > $tamanho) {
			$error[4] = "Image must be at most ".$tamanho." bytes";
		}
										 
		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image["name"], $ext);
										 
		$nome_imagem = $image["name"];
										 
		$caminho_imagem = "../admin/assets/img/uploads/" . $nome_imagem;
										 
		move_uploaded_file($image["tmp_name"], $caminho_imagem);
										
								
		$query = mysqli_query($conection,"UPDATE chikmagalur SET  title = '$title', ranks = '$ranks', image = '$nome_imagem'  WHERE id = '$id'");

			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', 'Updated Sucessfully', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; chikmagalur.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}
		}else{

		$query = mysqli_query($conection,"UPDATE chikmagalur SET  title = '$title', ranks = '$ranks'  WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', 'Page Updated', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; chikmagalur.php">'; 
				die();
			}				
		return true;
		}  
}  

/************ end chikmagalur ****************/
/************** Blog ***************/

function listBlog()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM blog ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	                 
                  <th>Title</th>                   
                  <th>Description</th>  
                  <th>Image</th>  
                  <th>Blog page image</th> 
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";	 
			echo $row['title'];
			echo "</td><td>"; 
			echo $row['ranks'];
			echo "</td><td class='partner_img'>"; 
			echo "<img src='../admin/assets/img/uploads/".$row['image']."' alt='' />"; 
			echo "</td><td class='partner_img'>"; 
			echo "<img src='../admin/assets/img/uploads/".$row['image1']."' alt='' />"; 
			echo "</td><td>";
			echo"
			<a href='edit_blog.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i></a>
			<a href='javascript:EliminaBlog(". $row['id'] . ")'class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i></a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}


// Edit NURSE function
function editBlog($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from blog WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeAddress'>Title</label>  
					  <div class='col-md-6'>
					  	<input id='name' name='title' type='text' class='form-control input-md' value='".$row['title']."' />
					  </div>
					</div>

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeAddress'> Description </label>  
					  <div class='col-md-6'> 
					  		<textarea rows ='4' cols='10' id='editor' name='ranks' type='text' class='form-control input-md'>".$row['ranks']."</textarea>
					  </div>
					</div>  

					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image' id='image'>
									<img src='../admin/assets/img/uploads/".$row['image']."' width='150px' hieght='150px' alt='' />
								</div>
						</div>

					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image1' id='image'>
									<img src='../admin/assets/img/uploads/".$row['image1']."' width='150px' hieght='150px' alt='' />
								</div>
						</div>


				";
}

// Update message Information
function updateBlog($id,$title,$ranks,$image,$image1)
{
	global $conection;

    $title = $_POST['title'];  
	$ranks = $_POST['ranks']; 
	$image = $_FILES['image']; 
	$image2 = $_FILES['image1'];

		if (!empty($image["name"])) {
										 
		$largura = 1000000;
		$altura = 1000000;
		$tamanho = 500000000000;
										 
		if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image["type"])){
		$error[1] = "Isso não é uma imagem.";
		} 
										 
		$dimensoes = getimagesize($image["tmp_name"]);
										 
		if($dimensoes[0] > $largura) {
			$error[2] = "Image width should not exceed".$largura." pixels";
		}
										 
		if($dimensoes[1] > $altura) {
			$error[3] = "Image height should not exceed ".$altura." pixels";
		}
										 
		if($image["size"] > $tamanho) {
			$error[4] = "Image must be at most ".$tamanho." bytes";
		}
										 
		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image["name"], $ext);
										 
		$nome_imagem = $image["name"];
										 
		$caminho_imagem = "../admin/assets/img/uploads/" . $nome_imagem;
										 
		move_uploaded_file($image["tmp_name"], $caminho_imagem);
										
								
		$query = mysqli_query($conection,"UPDATE blog SET  title = '$title', ranks = '$ranks', image = '$nome_imagem'  WHERE id = '$id'");

			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', 'Updated Sucessfully', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; blog.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}
		} elseif (!empty($image2["name"])) {
										 
		$largura = 1000000;
		$altura = 1000000;
		$tamanho = 500000000000;
										 
		if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image2["type"])){
		$error[1] = "Isso não é uma imagem.";
		} 
										  
		$dimensoes1 = getimagesize($image2["tmp_name"]);
										 
		if($dimensoes1[0] > $largura) { 
			$error[2] = "A largura da imagem não deve ultrapassar ".$largura." pixels";
		}
										 
		if($dimensoes1[1] > $altura) {
			$error[3] = "Image height should not exceed ".$altura." pixels";
		}
										 

		if($image2["size"] > $tamanho) {
			$error[4] = "Image must be at most ".$tamanho." bytes";
		}
										 

		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image["name"], $ext);
		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image2["name"], $ext);
										 

		$nome_imagem = $image["name"];
		$nome_imagem1 = $image2["name"];
										 
		$caminho_imagem = "../admin/assets/img/uploads/" . $nome_imagem;
		$caminho_imagem1 = "../admin/assets/img/uploads/" . $nome_imagem1;
										 
		move_uploaded_file($image["tmp_name"], $caminho_imagem);
		move_uploaded_file($image2["tmp_name"], $caminho_imagem1);
										
										
								
		$query = mysqli_query($conection,"UPDATE blog SET  title = '$title', ranks = '$ranks', image1 = '$nome_imagem1'  WHERE id = '$id'");

			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', 'Updated Sucessfully', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; blog.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}
		}
 
 
		else{

		$query = mysqli_query($conection,"UPDATE blog SET  title = '$title', ranks = '$ranks'  WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', 'Page Updated', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; blog.php">'; 
				die();
			}				
		return true;
		}  
}  
/************ end BLog ****************/
/************** Celebrations ***************/
function listCelebrations()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM celebrations ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	                 
                  <th>Title</th>                   
                  <th>Description</th>  
                  <th>Image</th> 
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";	 
			echo $row['title'];
			echo "</td><td>"; 
			echo $row['ranks'];
			echo "</td><td class='partner_img'>"; 
			echo "<img src='../admin/assets/img/uploads/".$row['image']."' alt='' />"; 
			echo "</td><td>";
			echo"
			<a href='edit_celebrations.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i></a>
			<a href='javascript:EliminaCelebrations(". $row['id'] . ")'class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i></a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}


// Edit NURSE function
function editCelebrations($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from celebrations WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeAddress'>Title</label>  
					  <div class='col-md-6'>
					  	<input id='name' name='title' type='text' class='form-control input-md' value='".$row['title']."' />
					  </div>
					</div>

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeAddress'> Description </label>  
					  <div class='col-md-6'> 
					  		<textarea rows ='4' cols='10' id='editor' name='ranks' type='text' class='form-control input-md'>".$row['ranks']."</textarea>
					  </div>
					</div>  

					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image' id='image'>
									<img src='../admin/assets/img/uploads/".$row['image']."' width='150px' hieght='150px' alt='' />
								</div>
						</div>
				";
}

// Update message Information
function updateCelebrations($id,$title,$ranks,$image)
{
	global $conection;

    $title = $_POST['title'];  
	$ranks = $_POST['ranks']; 
	$image = $_FILES['image'];

		if (!empty($image["name"])) {
										 
		$largura = 1000000;
		$altura = 1000000;
		$tamanho = 500000000000;
										 
		if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image["type"])){
		$error[1] = "Isso não é uma imagem.";
		} 
										 
		$dimensoes = getimagesize($image["tmp_name"]);
										 
		if($dimensoes[0] > $largura) {
			$error[2] = "Image width should not exceed".$largura." pixels";
		}
										 
		if($dimensoes[1] > $altura) {
			$error[3] = "Image height should not exceed ".$altura." pixels";
		}
										 
		if($image["size"] > $tamanho) {
			$error[4] = "Image must be at most ".$tamanho." bytes";
		}
										 
		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image["name"], $ext);
										 
		$nome_imagem = $image["name"];
										 
		$caminho_imagem = "../admin/assets/img/uploads/" . $nome_imagem;
										 
		move_uploaded_file($image["tmp_name"], $caminho_imagem);
										
								
		$query = mysqli_query($conection,"UPDATE celebrations SET  title = '$title', ranks = '$ranks', image = '$nome_imagem'  WHERE id = '$id'");

			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', 'Updated Sucessfully', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; celebrations.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}
		}else{

		$query = mysqli_query($conection,"UPDATE celebrations SET  title = '$title', ranks = '$ranks'  WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', 'Page Updated', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; celebrations.php">'; 
				die();
			}				
		return true;
		}  
}  
/***************** Programs **************/ 
function listAbt()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM abt ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	
                  <th>Title</th> 
                  <th>Slider Image 1</th>  
                  <th>Slider Image 2</th>
                  <th>Slider Image 3</th> 
                  <th>Slider Image 4</th>   
                  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";		
			echo $row['title']; 
			echo "</td><td class='partner_img'>"; 
			echo "<img src='assets/img/uploads/programs/".$row['image']."' alt='' />";
			echo "</td><td class='partner_img'>"; 
			echo "<img src='assets/img/uploads/programs/".$row['image1']."' alt='' />";
			echo "</td><td class='partner_img'>"; 
			echo "<img src='assets/img/uploads/programs/".$row['image2']."' alt='' />";
			echo "</td><td class='partner_img'>"; 
			echo "<img src='assets/img/uploads/programs/".$row['image3']."' alt='' />"; 
			echo "</td><td>";

			echo"
			<a href='edit_about.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i></a>  
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}
 

// Edit NURSE function
function editAbt($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from abt WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeName'>Title</label>  
					  <div class='col-md-6'>
					  	<textarea rows ='1' cols='10' id='title' name='title' type='text' class='form-control input-md'>".$row['title']."</textarea>
					  </div>
					</div>
					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image' id='image' >
									<img src='../admin/assets/img/uploads/programs/".$row['image']."' name='image' width='150px' hieght='150px' alt='' />
								</div>
						</div>

					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image1' id='image1' >
									<img src='../admin/assets/img/uploads/programs/".$row['image1']."' name='image1' width='150px' hieght='150px' alt='' />
								</div>
						</div>

					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image2' id='image2' >
									<img src='../admin/assets/img/uploads/programs/".$row['image2']."' name='image2' width='150px' hieght='150px' alt='' />
								</div>
						</div>

					<!-- Image input-->
						<div class='form-group'>
							<label class='col-md-2 control-label' for='url'>".lang('UPLOAD_IMAGE')."</label>
								<div class='col-md-6'>
									<input type='file' name='image3' id='image3' >
									<img src='../admin/assets/img/uploads/programs/".$row['image3']."' name='image3' width='150px' hieght='150px' alt='' />
								</div>
						</div> 

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeAddress'> Description </label>  
					  <div class='col-md-6'>
					  	<textarea rows ='7' cols='10' id='editor' name='descript' type='text' class='form-control input-md'>".$row['descript']."</textarea>
					  </div>
					</div> 
				";

}

// Update NURSE Information
function updateAbt($id,$title,$image,$image1,$image2,$image3,$descript)
{
	global $conection;

  $title = $_POST['title'];  
	$image = $_FILES['image']; 
	$image1 = $_FILES['image1']; 
	$image2 = $_FILES['image2']; 
	$image3 = $_FILES['image3']; 
	$descript = $_POST['descript'];  


		if (!empty($image["name"])) {
										 
		$largura = 1000000;
		$altura = 1000000;
		$tamanho = 500000000000;
										 
		if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image["type"])){
		$error[1] = "Isso não é uma imagem.";
		} 
										  
		$dimensoes = getimagesize($image["tmp_name"]); 
										 
		if(($dimensoes[0] > $largura))  {
			$error[2] = "Image width should not exceed".$largura." pixels";
		}
										 
		if($dimensoes[1] > $altura) {
			$error[3] = "Image height should not exceed ".$altura." pixels";
		}
										 
		if($image["size"] > $tamanho) {
			$error[4] = "A imagem deve ter no máximo ".$tamanho." bytes";
		}
 			 
		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image["name"], $ext); 

		$nome_imagem = $image["name"]; 
		$nome_imagem1 = $image1["name"]; 
		$nome_imagem2 = $image2["name"]; 
		$nome_imagem3 = $image3["name"]; 
		$caminho_imagem = "assets/img/uploads/programs/" . $nome_imagem; 
		$caminho_imagem1 = "assets/img/uploads/programs/" . $nome_imagem1; 
		$caminho_imagem2 = "assets/img/uploads/programs/" . $nome_imagem2; 
		$caminho_imagem3 = "assets/img/uploads/programs/" . $nome_imagem3; 
										 
		move_uploaded_file($image["tmp_name"], $caminho_imagem); 
		move_uploaded_file($image1["tmp_name"], $caminho_imagem1); 
		move_uploaded_file($image2["tmp_name"], $caminho_imagem2); 
		move_uploaded_file($image3["tmp_name"], $caminho_imagem3); 
							
								
		$query = mysqli_query($conection,"UPDATE abt SET title = '$title', image = '$nome_imagem', image1 = '$nome_imagem1', image2 = '$nome_imagem2', image3 = '$nome_imagem3',  descript = '$descript'  WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', 'Content Updated', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; about.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}
		} elseif (!empty($image1["name"])) {
										 
		$largura = 1000000;
		$altura = 1000000;
		$tamanho = 500000000000;
										 
		if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image1["type"])){
		$error[1] = "Isso não é uma imagem.";
		} 
										  
		$dimensoes = getimagesize($image1["tmp_name"]); 
										 
		if(($dimensoes[0] > $largura))  {
			$error[2] = "Image width should not exceed".$largura." pixels";
		}
										 
		if($dimensoes[1] > $altura) {
			$error[3] = "Image height should not exceed ".$altura." pixels";
		}
										 
		if($image1["size"] > $tamanho) {
			$error[4] = "A imagem deve ter no máximo ".$tamanho." bytes";
		}
 			 
		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image1["name"], $ext); 
 
		$nome_imagem = $image["name"]; 
		$nome_imagem1 = $image1["name"]; 
		$nome_imagem2 = $image2["name"]; 
		$nome_imagem3 = $image3["name"]; 
		$caminho_imagem = "assets/img/uploads/programs/" . $nome_imagem; 
		$caminho_imagem1 = "assets/img/uploads/programs/" . $nome_imagem1; 
		$caminho_imagem2 = "assets/img/uploads/programs/" . $nome_imagem2; 
		$caminho_imagem3 = "assets/img/uploads/programs/" . $nome_imagem3; 
										 
		move_uploaded_file($image["tmp_name"], $caminho_imagem); 
		move_uploaded_file($image1["tmp_name"], $caminho_imagem1); 
		move_uploaded_file($image2["tmp_name"], $caminho_imagem2); 
		move_uploaded_file($image3["tmp_name"], $caminho_imagem3); 
							
								
		$query = mysqli_query($conection,"UPDATE abt SET title = '$title', image1 = '$nome_imagem1', image2 = '$nome_imagem2', image3 = '$nome_imagem3',  descript = '$descript'  WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', 'Content Updated', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; about.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}
		} elseif (!empty($image2["name"])) {
										 
		$largura = 1000000;
		$altura = 1000000;
		$tamanho = 500000000000;
										 
		if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image2["type"])){
		$error[1] = "Isso não é uma imagem.";
		} 
										  
		$dimensoes = getimagesize($image2["tmp_name"]); 
										 
		if(($dimensoes[0] > $largura))  {
			$error[2] = "Image width should not exceed".$largura." pixels";
		}
										 
		if($dimensoes[1] > $altura) {
			$error[3] = "Image height should not exceed ".$altura." pixels";
		}
										 
		if($image2["size"] > $tamanho) {
			$error[4] = "A imagem deve ter no máximo ".$tamanho." bytes";
		}
 			 
		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image2["name"], $ext); 

		$nome_imagem = $image["name"]; 
		$nome_imagem1 = $image1["name"]; 
		$nome_imagem2 = $image2["name"]; 
		$nome_imagem3 = $image3["name"]; 
		$caminho_imagem = "assets/img/uploads/programs/" . $nome_imagem; 
		$caminho_imagem1 = "assets/img/uploads/programs/" . $nome_imagem1; 
		$caminho_imagem2 = "assets/img/uploads/programs/" . $nome_imagem2; 
		$caminho_imagem3 = "assets/img/uploads/programs/" . $nome_imagem3; 
										 
		move_uploaded_file($image["tmp_name"], $caminho_imagem); 
		move_uploaded_file($image1["tmp_name"], $caminho_imagem1); 
		move_uploaded_file($image2["tmp_name"], $caminho_imagem2); 
		move_uploaded_file($image3["tmp_name"], $caminho_imagem3); 
							
								
		$query = mysqli_query($conection,"UPDATE abt SET title = '$title',  image2 = '$nome_imagem2', image3 = '$nome_imagem3', descript = '$descript'  WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', 'Content Updated', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; about.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}
		}
		elseif (!empty($image3["name"])) {
										 
		$largura = 1000000;
		$altura = 1000000;
		$tamanho = 500000000000;
										 
		if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image3["type"])){
		$error[1] = "Isso não é uma imagem.";
		} 
										  
		$dimensoes = getimagesize($image3["tmp_name"]); 
										 
		if(($dimensoes[0] > $largura))  {
			$error[2] = "Image width should not exceed".$largura." pixels";
		}
										 
		if($dimensoes[1] > $altura) {
			$error[3] = "Image height should not exceed ".$altura." pixels";
		}
										 
		if($image3["size"] > $tamanho) {
			$error[4] = "A imagem deve ter no máximo ".$tamanho." bytes";
		}
 			 
		preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image3["name"], $ext); 

		$nome_imagem = $image["name"]; 
		$nome_imagem1 = $image1["name"]; 
		$nome_imagem2 = $image2["name"]; 
		$nome_imagem3 = $image3["name"]; 
		$caminho_imagem  = "assets/img/uploads/programs/" . $nome_imagem; 
		$caminho_imagem1 = "assets/img/uploads/programs/" . $nome_imagem1; 
		$caminho_imagem2 = "assets/img/uploads/programs/" . $nome_imagem2; 
		$caminho_imagem3 = "assets/img/uploads/programs/" . $nome_imagem3; 
										 
		move_uploaded_file($image["tmp_name"], $caminho_imagem); 
		move_uploaded_file($image1["tmp_name"], $caminho_imagem1); 
		move_uploaded_file($image2["tmp_name"], $caminho_imagem2); 
		move_uploaded_file($image3["tmp_name"], $caminho_imagem3); 
							
								
		$query = mysqli_query($conection,"UPDATE abt SET title = '$title', image3 = '$nome_imagem3', image = '$nome_imagem', image1 = '$nome_imagem1', image2 = '$nome_imagem2', descript = '$descript'  WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', 'Content Updated', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; about.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}
		}
		else{

		$query = mysqli_query($conection,"UPDATE abt SET title = '$title', descript = '$descript'    WHERE id = '$id'");
			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', 'Updated', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; about.php">'; 
				die();
			}				
		return true;
		}	
}
/******************* Accom  ********************/
function listAccom()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM accom ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	
                  <th>ID</th>
				  <th>".lang('IMAGE')."</th>
				  <th>".lang('TITLE')."</th> 
				  <th>".lang('CATEGORY')."</th>
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";		
			echo $row['id'];
			echo "</td><td class='partner_img'>"; 
			echo "<img src='../assets/img/uploads/accom/".$row['image']."' alt='' />";
			echo "</td><td>";			
			echo $row['title'];
			echo "</td><td>"; 
			echo $row['category'];
			echo "</td><td>";
			echo"
			<a href='edit_accom.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i> ".lang('EDIT')."</a>
			<a href='javascript:EliminaAccom(". $row['id'] . ")'class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i> ".lang('DELETE')."</a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}

// Edit project function
function editAccom($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from accom WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo " 		 
					<!-- Image input-->
					<div class='form-group'>
						<label class='col-md-2 control-label' for='image'>".lang('UPLOAD_IMAGE')."</label>
							<div class='col-md-6'>
								<input type='file' name='image' id='image'>
								<img src='../assets/img/uploads/accom/".$row['image']."' width='150px' height='150px' alt='' />
							</div>
					</div>			

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='title'>".lang('TITLE')."</label>  
					  <div class='col-md-6'>
					  <textarea rows ='1' cols='10' id='title' name='title' type='text' class='form-control input-md'>".$row['title']."</textarea>
					  </div>
					</div>
				";
}

// Update project Information
function updateAccom($id,$category,$image1,$title)
{
	global $conection;
	$image = $image1;

											if (!empty($image["name"])) {
										 
												$largura = 1000000;
												$altura = 1000000;
												$tamanho = 500000000000;
										 
												if(!preg_match("/image\/(pjpeg|jpeg|png|gif|bmp)/", $image["type"])){
												   $error[1] = "Isso não é uma imagem.";
												} 
										 
												$dimensoes = getimagesize($image["tmp_name"]);
										 
												if($dimensoes[0] > $largura) {
													$error[2] = "The width of the image should not exceed ".$largura." pixels";
												}
										 
												if($dimensoes[1] > $altura) {
													$error[3] = "Image height should not exceed".$altura." pixels";
												}
										 
												if($image["size"] > $tamanho) {
													$error[4] = "Image must be at most ".$tamanho." bytes";
												}
										 
													preg_match("/\.(gif|bmp|png|jpg|jpeg){1}$/i", $image["name"], $ext);
										 
													$nome_imagem = $image["name"];
										 
													$caminho_imagem = "../assets/img/uploads/accom/" . $nome_imagem;
										 
													move_uploaded_file($image["tmp_name"], $caminho_imagem);
										 
													
													$query = mysqli_query($conection,"UPDATE accom SET image='$nome_imagem', category = '$category',  title = '$title' WHERE id = '$id'");
													if (!$query) {
														echo ("No data was inserted!: " . mysqli_error());
														return false;
													} else {
															echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
																	echo '<meta http-equiv="refresh" content="1; accommodation.php">'; 
																	die();
															}				
															return true;

												if (count($error) != 0) {
													foreach ($error as $erro) {
														echo $erro . "<br />";
													}
												}

										}else{

	$query = mysqli_query($conection,"UPDATE accom SET title = '$title', category = '$category' WHERE id = '$id'");
		if (!$query) {
			echo ("No data was inserted!: " . mysqli_error());
				return false;
			} else {
			echo "<script type='text/javascript'>swal('".lang('NICE')."', '".lang('UPDATED')."', 'success');</script>";
			echo '<meta http-equiv="refresh" content="1; accommodation.php">';  
			die();
		}				
	return true;
	}
	
}
/******************* videos ***************/

function listMessage()
{
	global $conection;
	// Informações da query
	$campos_query = "*";
	$final_query  = "FROM message ORDER BY id DESC";
	 
	// Maximo de registros por pagina
	$maximo = 10000000;
	
	$_GET["pagina"] = 0;
	// Declaração da pagina inicial
	$pagina = antiSQLInjection($_GET["pagina"]);
	if($pagina == "") {
		$pagina = "1";
	}
	 
	// Calculando o registro inicial
	$inicio = $pagina - 1;
	$inicio = $maximo * $inicio;
	 
	// Conta os resultados no total da query
	$strCount = "SELECT COUNT(*) AS 'num_registros' $final_query";
	$query = mysqli_query($conection,$strCount);
	$row = mysqli_fetch_array($query);
	$total = $row["num_registros"];
	 
	###################################################################################
	// INICIO DO CONTEÚDO
	 
	// Realizamos a query
	$sql = mysqli_query($conection,"SELECT $campos_query $final_query LIMIT $inicio,$maximo");
	
	
	echo "<table class='table table-striped table-bordered table-hover' id='dataTables-example'>";
		echo "  <thead>
                <tr>	                 
                  <th>Title</th>                   
                  <th>Video Link</th>  
				  <th></th>
                </tr>
              </thead>";
		while ($row = mysqli_fetch_array($sql)) {
			// Print out the contents of each row into a table
			echo "<tr><td>";	 
			echo $row['title'];
			echo "</td><td>"; 
			echo $row['descript'];
			echo "</td><td>";
			echo"
			<a href='edit_videos.php?id=". $row['id'] . "' class='btn btn-primary btn-sm' role='button'><i class='fa fa-fw fa-edit'></i></a>
			<a href='javascript:EliminaMessage(". $row['id'] . ")'class='btn btn-danger btn-sm' role='button'><i class='fa fa-fw fa-trash'></i></a>
			</td>";
			echo "</tr>"; 	
		} 

		echo "</table>";
	

	// FIM DO CONTEUDO
	###################################################################################

	$menos = $pagina - 1;
	$mais = $pagina + 1;
	 
	$pgs = ceil($total / $maximo);
	 
	if($pgs > 1 ) {
	 
		echo "<br />";
	 
		// Mostragem de pagina
		if($menos > 0) {
			//echo "<a href=".$_SERVER['PHP_SELF']."?pagina=$menos>anterior</a>&nbsp; ";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$menos'>< anterior</a>";
		}
	 
		// Listando as paginas
		for($i=1;$i <= $pgs;$i++) {
			if($i != $pagina) {
				echo " <".$_SERVER['PHP_SELF']."?pagina=".($i)."> [$i</a>] ";
			} else {
				echo "[<strong>".$i."</strong>] ";
			}
		}
	 
		if($mais <= $pgs) {
			//echo " <a href=".$_SERVER['PHP_SELF']."?pagina=$mais#tabela>próxima</a>";
			echo "<a class='paginas' href='{$_SERVER['PHP_SELF']}?pagina=$mais'>proxima ></a>";
		}
	}
}


// Edit NURSE function
function editMessage($id)
{
	global $conection;
    $consulta = mysqli_query($conection,"select * from message WHERE id='".$id."'");
    $row = mysqli_fetch_assoc($consulta);
    echo "

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeAddress'>Title</label>  
					  <div class='col-md-6'>
					  	<textarea rows ='1' cols='10' id='title' name='title' type='text' class='form-control input-md'>".$row['title']."</textarea>
					  </div>
					</div>
  

					<!-- Text input-->
					<div class='form-group'>
					  <label class='col-md-2 control-label' for='collegeAddress'>Video Link</label>  
					  <div class='col-md-6'>
					  	<textarea rows ='1' cols='10' id='descript' name='descript' type='text' class='form-control input-md'>".$row['descript']."</textarea>
					  </div>
					</div>

				";

}

// Update message Information
function updateMessage($id,$title,$descript)
{
	global $conection;

    $title = $_POST['title'];  
	$descript = $_POST['descript']; 

 
		$query = mysqli_query($conection,"UPDATE message SET  title = '$title',    descript = '$descript' WHERE id = '$id'");

			if (!$query) {
				echo ("No data was inserted!: " . mysqli_error());
					return false;
				} else {
				echo "<script type='text/javascript'>swal('".lang('NICE')."', 'Updated Sucessfully', 'success');</script>";
				echo '<meta http-equiv="refresh" content="1; message.php">'; 
				die();
			}				
		return true;

		// Se houver mensagens de erro, exibe-as
		if (count($error) != 0) {
			foreach ($error as $erro) {
				echo $erro . "<br />";
				}
			}

		} 

