Ver código fonte

Merge branch 'Internal'

Iñigo Valentin 9 anos atrás
pai
commit
4473bff4cc

+ 1 - 0
sql/setup.sql

@@ -135,6 +135,7 @@ CREATE TABLE stat_view (
 	entry	VARCHAR(100)	NOT NULL,
 	dtime	TIMESTAMP		NOT NULL	DEFAULT now()
 );
+CREATE INDEX visit_dtime ON stat_view(visit, dtime);
 
 DROP TABLE IF EXISTS sync;
 CREATE TABLE sync (

+ 58 - 1
www-admin/ajustes/index.php

@@ -1 +1,58 @@
- 
+<?php
+	$server = get_protocol() . $_SERVER['HTTP_HOST'];
+	$default_host = substr($http_host, 0, strpos($http_host, ':'));
+	include("../functions.php");
+	$con = startdb();
+	if (!checkSession($con)){
+		header("Location: /index.php");
+		exit (-1);
+	}
+	else{
+?>
+<html>
+	<head>
+		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
+		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
+		<title>Ajustes - Gasteizko Margolariak - Administracion</title>
+		<!-- CSS files -->
+		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
+		<link rel="stylesheet" type="text/css" href="/css/settings.css"/>
+		<!-- CSS for mobile version -->
+		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
+		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/settings.css"/>
+		<!-- Script files -->
+		<script type="text/javascript" src="/script/ui.js"></script>
+		<script type="text/javascript">
+			function saveSetting(name, value){
+				// TODO: Call guardar.php
+			}
+		</script>
+	</head>
+	<body>
+		<?php include('../toolbar.php'); ?>
+		<div id='content'>
+			<div class='section'>
+				<h3 class='section_title'>Ajustes</h3>
+				<div class='entry'>
+					Permitir que los visitantes comenten anonimamente...
+					<br/>&nbsp;&nbsp;&nbsp;&nbsp;
+					<label><input type="checkbox" name="comment_blog" value="value">... en el blog</label>
+					<br/>&nbsp;&nbsp;&nbsp;&nbsp;
+					<label><input type="checkbox" name="comment_activities" value="value">... en las actividades</label>
+					<br/>&nbsp;&nbsp;&nbsp;&nbsp;
+					<label><input type="checkbox" name="comment_gallery" value="value">... en la galer&iacute;a</label>
+					<br/><br/>
+					<label>
+						<input type="checkbox" name="upload_gallery" value="value">
+						Permitir que los usuarios contribuyan a los albums con sus fotos (puede restringirse por album)
+					</label>
+					<label>
+						<input type="checkbox" name="festivals" value="value">
+						Usar disseño para fiestas de Vitoria.
+					</label>
+				</div>
+			</div>
+		</div>
+	</body>
+</html>
+<?php } ?>

+ 0 - 1
www-admin/ajustes/settings.php

@@ -1 +0,0 @@
- 

+ 0 - 59
www-admin/estadisticas/web.php

@@ -1,59 +0,0 @@
-<?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	$default_host = substr($http_host, 0, strpos($http_host, ':'));
-	include("../functions.php");
-	$con = startdb();
-	if (!checkSession($con)){
-		header("Location: /index.php");
-		exit (-1);
-	}
-	else{
-?>
-<html>
-	<head>
-		<meta content="text/html; charset=windows-1252" http-equiv="content-type"/>
-		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title>Estadisticas Web - Administracion</title>
-		<!-- CSS files -->
-		<link rel="stylesheet" type="text/css" href="/css/ui.css"/>
-		<link rel="stylesheet" type="text/css" href="/css/estadisticas.css"/>
-		<!-- CSS for mobile version -->
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/ui.css"/>
-		<link rel="stylesheet" type="text/css" media="(max-width : 990px)" href="/css/m/estadisticas.css"/>
-		<!-- Script files -->
-		<script type="text/javascript" src="/script/ui.js"></script>
-	</head>
-	<body>
-		<?php include('toolbar.php'); ?>
-		<div id='content'>
-			<div id='section_table'>
-				<div class='section_row'>
-					<div class='section_cell'>
-						<div class='section'>
-							<h3 class='section_title'>Visitantes &Uacute;nicos</h3>
-							<?php
-								$q_total = mysqli_query($con, "SELECT LOW_PRIORITY COUNT(id) AS c FROM stat_visit;");
-								$q_week = mysqli_query($con, "SELECT LOW_PRIORITY COUNT(id) AS c FROM stat_visit WHERE id IN (SELECT visit FROM stat_view WHERE dtime > DATE_FORMAT(LAST_DAY(NOW()) - ((7 + WEEKDAY(LAST_DAY(NOW())) - 7) % 7), '%Y-%m-%d'));");
-								$q_month = mysqli_query($con, "SELECT LOW_PRIORITY COUNT(id) AS c FROM stat_visit WHERE id IN (SELECT visit FROM stat_view WHERE dtime > LAST_DAY(NOW() - INTERVAL 1 MONTH) + INTERVAL 1 DAY);");
-								$q_year =  mysqli_query($con, "SELECT LOW_PRIORITY COUNT(id) AS c FROM stat_visit WHERE id IN (SELECT visit FROM stat_view WHERE dtime > DATE_FORMAT(NOW() ,'%Y-01-01'));");
-								$r_total = mysqli_fetch_array($q_total);
-								$r_week = mysqli_fetch_array($q_week);
-								$r_month = mysqli_fetch_array($q_month);
-								$r_year = mysqli_fetch_array($q_year);
-							?>
-							<div class='entry'>
-								<ul>
-									<li>Totales: <?php echo($r_total['c']); ?> </li>
-									<li>Semana: <?php echo($r_week['c']); ?> </li>
-									<li>Mes: <?php echo($r_month['c']); ?> </li>
-									<li>A&ntilde;o: <?php echo($r_year['c']); ?> </li>
-								</ul>
-							</div>
-						</div>
-					</div>
-				</div>
-			</div>
-		</div>
-	</body>
-</html>
-<?php } ?>

+ 12 - 0
www-admin/functions.php

@@ -2,6 +2,18 @@
 
 	$IMG_SIZE_PREVIEW = 600;
 	$IMG_SIZE_MINIATURE = 200;
+	
+	
+	function getProtocol(){
+		if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
+				$protocol = 'https://';
+		}
+		else {
+				$protocol = 'http://';
+		}
+		return $protocol;
+	}
+
 
 	/****************************************************
 	* This function is called from almost everywhere at *

+ 22 - 23
www-admin/main.php

@@ -1,7 +1,7 @@
 <?php
-	$http_host = $_SERVER['HTTP_HOST'];
-	$default_host = substr($http_host, 0, strpos($http_host, ':'));
 	include("functions.php");
+	$server = getProtocol() . $_SERVER['HTTP_HOST'];
+	$default_host = substr($server, 0, strpos($http_host, ':'));
 	$con = startdb();
 	if (!checkSession($con)){
 		header("Location: /index.php");
@@ -33,8 +33,8 @@
 							<h3 class='section_title'>Blog</h3>
 							<div class='entry'>
 								<ul>
-									<li><a href='/blog/add/'>Nuevo post</a></li>
-									<li><a href='/blog/'>Gestionar posts</a></li>
+									<li><a href='<?=$server?>/blog/add/'>Nuevo post</a></li>
+									<li><a href='<?=$server?>/blog/'>Gestionar posts</a></li>
 								</ul>
 							</div>
 						</div>
@@ -44,8 +44,8 @@
 							<h3 class='section_title'>Actividades</h3>
 							<div class='entry'>
 								<ul>
-									<li><a href='/actividades/add/'>Nueva actividad</a></li>
-									<li><a href='/actividades/'>Gestionar actividades</a></li>
+									<li><a href='<?=$server?>/actividades/add/'>Nueva actividad</a></li>
+									<li><a href='<?=$server?>/actividades/'>Gestionar actividades</a></li>
 								</ul>
 							</div>
 						</div>
@@ -57,11 +57,11 @@
 							<h3 class='section_title'>Galeria</h3>
 							<div class='entry'>
 								<ul>
-									<li><a href='/galeria/add/'>Crear album</a></li>
-									<li><a href='/galeria/'>Gestionar albums</a></li>
-									<li><a href='/galeria/upload/'>Subir fotos</a></li>
-									<li><a href='/galeria/moderate/'>Moderar comentarios</a></li>
-									<li><a href='/galeria/translate/'>Traducir galeria</a></li>
+									<li><a href='<?=$server?>/galeria/add/'>Crear album</a></li>
+									<li><a href='<?=$server?>/galeria/'>Gestionar albums</a></li>
+									<li><a href='<?=$server?>/galeria/upload/'>Subir fotos</a></li>
+									<li><a href='<?=$server?>/galeria/moderate/'>Moderar comentarios</a></li>
+									<li><a href='<?=$server?>/galeria/translate/'>Traducir galeria</a></li>
 								</ul>
 							</div>
 						</div>
@@ -71,9 +71,9 @@
 							<h3 class='section_title'>Fiestas</h3>
 							<div class='entry'>
 								<ul>
-									<li><a href='/lablanca/'>Preparar las fiestas</a></li>
-									<li><a href='/lablanca/prices.php'>Gestionar precios</a></li>
-									<li><a href='/lablanca/schedule.php'>Gestionar programa</a></li>
+									<li><a href='<?=$server?>/lablanca/'>Preparar las fiestas</a></li>
+									<li><a href='<?=$server?>/lablanca/prices.php'>Gestionar precios</a></li>
+									<li><a href='<?=$server?>/lablanca/schedule.php'>Gestionar programa</a></li>
 								</ul>
 							</div>
 						</div>
@@ -85,9 +85,8 @@
 							<h3 class='section_title'>Miembros</h3>
 							<div class='entry'>
 								<ul>
-									<li><a href='/miembros/'>Consultar y buscar</a></li>
-									<li><a href='/miembros/add/'>Anadir miembros</a></li>
-									<li><a href='/miembros/editable.php'>Gestionar lista</a></li>
+									<li><a href='<?=$server?>/miembros/'>Consultar y buscar</a></li>
+									<li><a href='<?=$server?>/miembros/add/'>A&ntilde;adir miembros</a></li>
 								</ul>
 							</div>
 						</div>
@@ -97,9 +96,9 @@
 							<h3 class='section_title'>Estadisticas</h3>
 							<div class='entry'>
 								<ul>
-									<li><a href='/estadisticas/web.php'>Estadisticas Web</a></li>
-									<li><a href='/estadisticas/app.php'>Estadisticas Apps</a></li>
-									<li><a href='/estadisticas/miembros'>Estadisticas miembros</a></li>
+									<li><a href='<?=$server?>/estadisticas/web/'>Estadisticas Web</a></li>
+									<li><a href='<?=$server?>/estadisticas/app/'>Estadisticas Apps</a></li>
+									<li><a href='<?=$server?>/estadisticas/miembros/'>Estadisticas miembros</a></li>
 								</ul>
 							</div>
 						</div>
@@ -111,9 +110,9 @@
 							<h3 class='section_title'>Ajustes</h3>
 							<div class='entry'>
 								<ul>
-									<li><a href=''>Cambiar ajustes</a></li>
-									<li><a href=''>Gestionar usuarios</a></li>
-									<li><a href=''>Salir</a></li>
+									<li><a href='<?=$server?>/settings/'Ajustes</a></li>
+									<li><a href='<?=$server?>/users/'>Gestionar usuarios</a></li>
+									<li><a href='<?=$server?>/salir/'>Salir</a></li>
 								</ul>
 							</div>
 						</div>

+ 26 - 25
www-admin/toolbar.php

@@ -2,13 +2,14 @@
 	<table>
 		<tr>
 			<td>
-				<img src="/img/misc/logo.png"/><span style='font-weight:normal;font-style:italic;font-size:90%;'><?php echo $_SESSION['name']; ?></span>
+				<img src="<?=$server?>/img/misc/logo.png"/>
+				<span style='font-weight:normal;font-style:italic;font-size:90%;'><?=$_SESSION['name']?></span>
 			</td>
 			<td>
-				<a href="/" class="pointer toolbar_section">Inicio</a>
+				<a href="<?=$server?>/" class="pointer toolbar_section">Inicio</a>
 			</td>
 			<td class="pointer toolbar_section" onClick="showToolbar('blog', this);">
-				Blog
+				<span class="pointer">Blog</span>
 			</td>
 			<td class="pointer toolbar_section" onClick="showToolbar('actividades', this);">
 				<span class="pointer">Actividades</span>
@@ -35,10 +36,10 @@
 	<table>
 		<tr>
 			<td>
-				<a href="http://<?php echo $http_host; ?>/blog/add/">Nuevo post</a>
+				<a href="<?=$server?>/blog/add/">Nuevo post</a>
 			</td>
 			<td>
-				<a href="http://<?php echo $http_host; ?>/blog/">Gestionar posts</a>
+				<a href="<?=$server?>/blog/">Gestionar posts</a>
 			</td>
 		</tr>
 	</table>
@@ -47,10 +48,10 @@
 	<table>
 		<tr>
 			<td>
-				<a href="http://<?php echo $http_host; ?>/actividades/add/">Nueva actividad</a>
+				<a href="<?=$server?>/actividades/add/">Nueva actividad</a>
 			</td>
 			<td>
-				<a href="http://<?php echo $http_host; ?>/actividades/">Gestionar actividades</a>
+				<a href="<?=$server?>/actividades/">Gestionar actividades</a>
 			</td>
 		</tr>
 	</table>
@@ -59,19 +60,19 @@
 	<table>
 		<tr>
 			<td>
-				<a href="//">Crear album</a>
+				<a href="<?=$server?>/galeria/add/">Crear album</a>
 			</td>
 			<td>
-				<a href="//">Gestionar albums</a>
+				<a href="<?=$server?>/galeria/">Gestionar albums</a>
 			</td>
 			<td>
-				<a href="//">Subir fotos</a>
+				<a href="<?=$server?>/galeria/upload/">Subir fotos</a>
 			</td>
 			<td>
-				<a href="//">Moderar comentarios</a>
+				<a href="<?=$server?>/galeria/moderate/">Moderar comentarios</a>
 			</td>
 			<td>
-				<a href="//">Traducir galer&iacute;a</a>
+				<a href="<?=$server?>/galeria/translate/">Traducir galer&iacute;a</a>
 			</td>
 		</tr>
 	</table>
@@ -80,10 +81,13 @@
 	<table>
 		<tr>
 			<td>
-				<a href="//">Gestionar precios</a>
+				<a href='<?=$server?>/lablanca/'>Preparar las fiestas</a>
 			</td>
 			<td>
-				<a href="//">Gestionar programa</a>
+				<a href='<?=$server?>/lablanca/prices.php'>Gestionar precios</a>
+			</td>
+			<td>
+				<a href='<?=$server?>/lablanca/schedule.php'>Gestionar programa</a>
 			</td>
 		</tr>
 	</table>
@@ -92,13 +96,10 @@
 	<table>
 		<tr>
 			<td>
-				<a href="//">Consultar</a>
-			</td>
-			<td>
-				<a href="//">A&ntilde;adir miembro</a>
+				<a href='<?=$server?>/miembros/'>Consultar y buscar</a>
 			</td>
 			<td>
-				<a href="//">A&ntilde;adir miembros en lote</a>
+				<a href='<?=$server?>/miembros/add/'>A&ntilde;adir miembros</a>
 			</td>
 		</tr>
 	</table>
@@ -107,13 +108,13 @@
 	<table>
 		<tr>
 			<td>
-				<a href="//">Web</a>
+				<a href='<?=$server?>/estadisticas/web/'>Estadisticas Web</a>
 			</td>
 			<td>
-				<a href="//">Apps</a>
+				<a href='<?=$server?>/estadisticas/app/'>Estadisticas Apps</a>
 			</td>
 			<td>
-				<a href="//">Miembros</a>
+				<a href='<?=$server?>/estadisticas/miembros/'>Estadisticas miembros</a>
 			</td>
 		</tr>
 	</table>
@@ -122,13 +123,13 @@
 	<table>
 		<tr>
 			<td>
-				<a href="//">Cambiar ajustes</a>
+				<a href='<?=$server?>/settings/'Ajustes</a>
 			</td>
 			<td>
-				<a href="//">Gestionar usuarios</a>
+				<a href='<?=$server?>/usuarios/'>Gestionar usuarios</a>
 			</td>
 			<td>
-				<a href="//">Salir</a>
+				<a href='<?=$server?>/salir/'>Salir</a>
 			</td>
 		</tr>
 	</table>

+ 6 - 2
www/functions.php

@@ -433,9 +433,9 @@
 		$bot_kw[18] = 'fake';
 		$bot_kw[19] = 'library';
 		$bot_kw[20] = 'commerce';
-		$bot_kw[21] = 'html';
+		$bot_kw[21] = 'htmlbot';
 		$bot_kw[22] = 'fetch';
-		$bot_kw[23] = 'google';
+		$bot_kw[23] = 'googleb';
 		$bot_kw[24] = 'facebook';
 		$bot_kw[25] = 'whatsapp';
 		$bot_kw[26] = 'pinterest';
@@ -459,6 +459,10 @@
 			}
 			$i ++;
 		}
+		if (strlen($os) == 0 || strlen($browser) == 0){ // Certain chinese hosting provider makes a lot of requests...
+			mysqli_close($con);
+			return;
+		}
 		
 		//Look for a visit with the same IP in the last 30 mins.
 		$con = startdb('rw');