Forráskód Böngészése

Implemented add functionality

seavenois 10 éve
szülő
commit
a1f094312b

+ 7 - 0
.gitignore

@@ -52,3 +52,10 @@ www/img/galeria/miniature/*.jpg
 www/img/galeria/preview/*.jpg
 www/img/galeria/thumb/*.jpg
 www/img/galeria/view/*.jpg
+www/img/sponsor/script
+www/img/sponsor/*.jpg
+www/img/sponsor/miniature/*.jpg
+www/img/sponsor/preview/*.jpg
+www/img/sponsor/thumb/*.jpg
+www/img/sponsor/view/*.jpg
+

+ 10 - 5
sql/setup.sql

@@ -100,12 +100,17 @@ CREATE TABLE sponsor (
 	name_es			VARCHAR(100)    NOT NULL,
 	name_en			VARCHAR(100),
 	name_eu			VARCHAR(100),
-	description_es	VARCHAR(1000),
-	description_en	VARCHAR(1000),
-	description_eu	VARCHAR(1000),
+	text_es			VARCHAR(1000),
+	text_en			VARCHAR(1000),
+	text_eu			VARCHAR(1000),
 	image			VARCHAR(100),
-	address			INT				REFERENCES place.id,
-	link			VARCHAR(300)
+	address_es		VARCHAR(200),
+	address_en		VARCHAR(200),
+	address_eu		VARCHAR(200),
+	link			VARCHAR(300),
+	lat				DOUBLE,
+	lon				DOUBLE,
+	ammount			INT
 );
 
 DROP TABLE IF EXISTS photo;

+ 2 - 2
www-admin/functions.php

@@ -246,8 +246,8 @@
 	/****************************************************
 	* Increases version value in table settings by one. *
 	* Helpfull for the app to know when to perform a    * 
-	* full sync. Must be called after every INSERT or   *
-	* UPDATE query to the database.                     *
+	* full sync. Must be called after every INSERT,     *
+	* UPDATE or DELETE query to the database.           *
  	****************************************************/
 	function version(){
 		$con = startdb('rw');

+ 2 - 1
www/actividades/actividad.php

@@ -1,4 +1,5 @@
 <?php
+	session_start();
 	$http_host = $_SERVER['HTTP_HOST'];
 	include("../functions.php");
 	$con = startdb();
@@ -221,6 +222,6 @@
 				</div>
 			</div>
 		</div>
-		<?php include("../footer.php"); ?>
+		<?php include("../footer.php"); ad($con, $lang, $lng); ?>
 	</body>
 </html>

+ 2 - 1
www/actividades/index.php

@@ -1,4 +1,5 @@
 <?php
+	session_start();
 	$http_host = $_SERVER['HTTP_HOST'];
 	include("../functions.php");
 	$con = startdb();
@@ -177,6 +178,6 @@
 			}
 		?>
 		</div>
-		<?php include("../footer.php"); ?>
+		<?php include("../footer.php"); ad($con, $lang, $lng); ?>
 	</body>
 </html>

+ 2 - 1
www/ayuda/index.php

@@ -1,4 +1,5 @@
 <?php
+	session_start();
 	$http_host = $_SERVER['HTTP_HOST'];
 	include("../functions.php");
 	$con = startdb();
@@ -137,6 +138,6 @@
 				</div>
 			</div>
 		</div>
-		<?php include("../footer.php"); ?>
+		<?php include("../footer.php"); ad($con, $lang, $lng); ?>
 	</body>
 </html>

+ 2 - 1
www/blog/buscar.php

@@ -1,4 +1,5 @@
 <?php
+	session_start();
 	$http_host = $_SERVER['HTTP_HOST'];
 	include("../functions.php");
 	$con = startdb();
@@ -153,6 +154,6 @@
 			</div>
 			<?php include("common/rightpanel.php"); ?>
 		</div>
-		<?php include("../footer.php"); ?>
+		<?php include("../footer.php"); ad($con, $lang, $lng); ?>
 	</body>
 </html>

+ 2 - 1
www/blog/index.php

@@ -1,4 +1,5 @@
 <?php
+	session_start();
 	$http_host = $_SERVER['HTTP_HOST'];
 	include("../functions.php");
 	$con = startdb();
@@ -156,6 +157,6 @@
 			</div>
 			<?php include("common/rightpanel.php"); ?>
 		</div>
-		<?php include("../footer.php"); ?>
+		<?php include("../footer.php"); ad($con, $lang, $lng); ?>
 	</body>
 </html>

+ 61 - 0
www/css/ui.css

@@ -461,3 +461,64 @@ div#comment_new input[type='text']{
 div#comment_new input[type='submit']{
 	width:	25%;
 }
+
+/******************************************
+* Styles for the ad window.               *
+******************************************/
+div#ad{
+	width:						25%;
+	max-width:					25em;
+	min-width:					12em;
+	max-height:					20em;
+	position:					fixed;
+	bottom:						-25em;
+	left:						3em;
+	margin-bottom:				0;
+	box-shadow:					0 0 2em #111122;
+	border-top-left-radius:		1em;
+	border-top-right-radius:	1em;
+	transition:					bottom .5s ease-in-out;
+}
+
+
+div#ad h3{
+	margin-top:	0.3em;
+}
+
+div#ad div#ad_details{
+	text-align:		right;
+	color:			#555555;
+	font-size:		80%;
+	font-weight:	bold;
+	margin:			0;
+}
+
+div#ad div#ad_details img{
+	height:			0.8em;
+	width:			0.8em;
+	vertical-align: middle;
+	margin: 		0 0.5em 0 0.5em;
+}
+
+div#ad div.entry div#ad_image_container{
+	max-height:	9.5em;
+	margin:		0.3em 0.5em 0.3em 0.5em;
+	text-align:	center;
+}
+
+div#ad div.entry div#ad_image_container img{
+	max-height:	9em;
+	border:	0.1em solid #111111;
+}
+
+div#ad div.entry a{
+	font-style:		italic;
+	font-size:		90%;
+	margin-left:	0.6em;
+	margin-right:	0.6em;
+}
+
+div#ad div.entry a img#ad_pinpoint{
+	vertical-align:	middle;
+	max-height:		0.8em;
+}

+ 0 - 1
www/footer.php

@@ -39,5 +39,4 @@
 </div>
 <?php
 }
-//else{echo "<div id='cookie_popup'></div>";}
 ?>

+ 53 - 1
www/functions.php

@@ -246,7 +246,7 @@
 			}
 		}
 		return $html;
-	} 
+	}
 	
 	/****************************************************
 	* Text shortener. Given a string, it trims in the   *
@@ -285,5 +285,57 @@
 		$con = startdb('rw');
 		mysqli_query($con, 'UPDATE settings SET value = value + 1 WHERE name = "version";');
 	}
+	
+	function ad($con, $lang, $lng){
+		//If the user hasn't still see an add on this session
+		if (isset($_SESSION['ad']) == false){
+			//25% chance of seeing an add
+			if (rand (0, 3) == 0){
+				//Create an array with weighted values
+				$q = mysqli_query($con, "SELECT id, round(ammount/10) AS value FROM sponsor;");
+				if (mysqli_num_rows($q) == 0){
+					return;
+				}
+				$total = 0;
+				$sponsors = array();
+				while ($r = mysqli_fetch_array($q)){
+					$times = $r['value'];
+					$id = $r['id'];
+					for ($i = 0; $i < $times; $i ++) {
+						array_push($sponsors, $id);
+						$total ++;
+					}
+				}
+				
+				//Get a random id from the array
+				$id = $sponsors[rand (0, $total - 1)];
+				
+				//Get sponsor data
+				$q = mysqli_query($con, "SELECT name_$lang AS name, text_$lang AS text, image, address_$lang AS address, link, lat, lon FROM sponsor WHERE id = $id;");
+				$r = mysqli_fetch_array($q);
+				echo("<div id='ad' class='section'>\n");
+				echo("<div id='ad_details'>\n");
+				echo($lng['ad_title']);
+				echo("<img class='pointer' src='/img/misc/slid-close.png' onClick='closeAd();' />\n");
+				echo("</div>\n");
+				echo("<h3><a target='_blank' href='$r[link]'>$r[name]</a></h3>\n");
+				echo("<div class='entry'>\n");
+				if (strlen($r['image']) > 0){
+					echo("<div id='ad_image_container'>\n");
+					echo("<img src='/img/sponsor/miniature/$r[image]'/>\n");
+					echo("</div>\n");
+				}
+				echo($r['text']);
+				echo("<br/><br/><a target='_blank' href='https://www.google.es/maps/@$r[lat],$r[lon],14z'><img id='ad_pinpoint' src='/img/misc/pinpoint.png'\>$r[address]</a>\n");
+				echo("</div>\n");
+				echo("</div>\n");
+				echo("<script type='text/javascript'>showAd();</script>\n");
+				
+				//Set ad as seen
+				$_SESSION['ad'] = 1;
+			}
+			
+		}
+	}
 ?>
 	

+ 2 - 1
www/galeria/album.php

@@ -1,4 +1,5 @@
 <?php
+	session_start();
 	$http_host = $_SERVER['HTTP_HOST'];
 	include("../functions.php");
 	$con = startdb();
@@ -104,7 +105,7 @@
 		</div>
 		<div id="photo_viewer" class="section">
 		</div>
-		<?php include("../footer.php"); ?>
+		<?php include("../footer.php"); ad($con, $lang, $lng); ?>
 	</body>
 </html>
 

+ 2 - 1
www/galeria/index.php

@@ -1,4 +1,5 @@
 <?php
+	session_start();
 	$http_host = $_SERVER['HTTP_HOST'];
 	include("../functions.php");
 	$con = startdb();
@@ -99,6 +100,6 @@
 				?>
 			</div>
 		</div>
-		<?php include("../footer.php"); ?>
+		<?php include("../footer.php"); ad($con, $lang, $lng); ?>
 	</body>
 </html>

+ 2 - 0
www/galeria/upload.php

@@ -1,4 +1,5 @@
 <?php
+	session_start();
 	$http_host = $_SERVER['HTTP_HOST'];
 	include("../functions.php");
 	$con = startdb();
@@ -110,5 +111,6 @@
 				</div>
 			</form>
 		</div>
+		<?php include("../footer.php"); ad($con, $lang, $lng); ?>
 	</body>
 </html>

+ 2 - 1
www/index.php

@@ -1,4 +1,5 @@
 <?php
+	session_start();
 	$http_host = $_SERVER['HTTP_HOST'];
 	include("functions.php");
 	$con = startdb();
@@ -399,6 +400,6 @@
 				}
 			?>
 		</div>
-		<?php include("footer.php"); ?>
+		<?php include("footer.php"); ad($con, $lang, $lng); ?>
 	</body>
 </html>

+ 2 - 2
www/lablanca/index.php

@@ -1,5 +1,5 @@
 <?php
-	
+	session_start();
 	include("../functions.php");
 	$con = startdb();
 	
@@ -143,6 +143,6 @@
 				}
 			?>
 		</div>
-		<?php include("../footer.php"); ?>
+		<?php include("../footer.php"); ad($con, $lang, $lng); ?>
 	</body>
 </html>

+ 3 - 0
www/lang/lang_en.php

@@ -210,6 +210,9 @@
 	$lng['help_cookie_title'] = 'Pol&iacute;tca de cookies';
 	$lng['help_cookie'] = '¡Cookies! Est&aacute;n por todas partes. Sabemos que nadie suele leerse estos avisos sobre ellas, as&iacute; que ya que estas leyendo este, vamos a intentar hacerlo f&aacute;cil.<br/><br/>Una cookie es un peque&ntilde;o archivo de texto que puede quedar guardado en tu ordenador cuando visitas una web. Estos archivos son benignos, en el sentido de que no afectan al funcionamiento de tu ordenador, pero pueden ser utiles para los desarrolladores de p&aacute;ginas web para diversas cosas, como recordar tus preferencias entre visitas (como en nuestro caso) o identificarte y trazar tus movimientos por Internet (no es nuestro caso).<br/><br/>Aprovechando que aqu&iacute; utilizamos verdaderamente pocas, te contamos para que.<br/><ul><li><span style="font-weight:bold;">Idioma</span>: Utilizamos una cookie para recordar el idioma en el que quieres ver la p&aacute;gina. Si la estas viendo en castellano, el &uacute;nico texto que contendr&aacute; sera &quot;es&quot;. Bastante inofensivo, ¿verdad?</li><li><span style="font-weight:bold;">Aviso de cookies</span>: Ir&oacute;nicamente, tenemos que usar una cookie para evitar que el aviso sobre cookies que estamos obligados a mostrarte cuando nos visitas por primera vez te moleste solo esa primera vez. Esta es mas simple aun que la anterior, y es una cookie vacia, sin ningun tipo de texto.</li><li><span style="font-weight:bold;">Cookies de Google</span>: Esto tiene m&aacute;s miga. Durante las fiestas de Vitoria, esta p&aacute;gina muestra mapas de Google. Es posible (y casi seguro) que estos mapas inserten cookies propias sobre las que no tenemos ning&uacute;n control. Sorry.</li></ul>';
 	
+	//Ads
+	$lng['ad_title'] = 'Advertisment';
+	
 	// /error/
 	$lng['error_title'] = 'Error';
 	$lng['error_error'] = 'ERROR';

+ 3 - 0
www/lang/lang_es.php

@@ -210,6 +210,9 @@
 	$lng['help_cookie_title'] = 'Pol&iacute;tica de cookies';
 	$lng['help_cookie'] = '¡Cookies! Est&aacute;n por todas partes. Sabemos que nadie suele leerse estos avisos sobre ellas, as&iacute; que ya que estas leyendo este, vamos a intentar hacerlo f&aacute;cil.<br/><br/>Una cookie es un peque&ntilde;o archivo de texto que puede quedar guardado en tu ordenador cuando visitas una web. Estos archivos son benignos, en el sentido de que no afectan al funcionamiento de tu ordenador, pero pueden ser utiles para los desarrolladores de p&aacute;ginas web para diversas cosas, como recordar tus preferencias entre visitas (como en nuestro caso) o identificarte y trazar tus movimientos por Internet (no es nuestro caso).<br/><br/>Aprovechando que aqu&iacute; utilizamos verdaderamente pocas, te contamos para qu&eacute;.<br/><ul><li><span style="font-weight:bold;">Idioma</span>: Utilizamos una cookie para recordar el idioma en el que quieres ver la p&aacute;gina. Si la estas viendo en castellano, el &uacute;nico texto que contendr&aacute; sera &quot;es&quot;. Bastante inofensivo, ¿verdad?</li><li><span style="font-weight:bold;">Aviso de cookies</span>: Ir&oacute;nicamente, tenemos que usar una cookie para evitar que el aviso sobre cookies que estamos obligados a mostrarte cuando nos visitas por primera vez te moleste solo esa primera vez. Esta es m&aacute;s simple a&uacute;n que la anterior: es una cookie vac&iacute;a, sin ning&uacute;n tipo de texto.</li><li><span style="font-weight:bold;">Cookies de Google</span>: Esto tiene m&aacute;s miga. Durante las fiestas de Vitoria, esta p&aacute;gina muestra mapas de Google. Es posible (y casi seguro) que estos mapas inserten cookies propias sobre las que no tenemos ning&uacute;n control. Sorry.</li></ul>';
 	
+	//Ads
+	$lng['ad_title'] = 'Publicidad';
+	
 	// /error/
 	$lng['error_title'] = 'Error';
 	$lng['error_error'] = 'ERROR';

+ 3 - 0
www/lang/lang_eu.php

@@ -210,6 +210,9 @@
 	$lng['help_cookie_title'] = 'Cookiek politika';
 	$lng['help_cookie'] = '¡Cookies! Est&aacute;n por todas partes. Sabemos que nadie suele leerse estos avisos sobre ellas, as&iacute; que ya que estas leyendo este, vamos a intentar hacerlo f&aacute;cil.<br/><br/>Una cookie es un peque&ntilde;o archivo de texto que puede quedar guardado en tu ordenador cuando visitas una web. Estos archivos son benignos, en el sentido de que no afectan al funcionamiento de tu ordenador, pero pueden ser utiles para los desarrolladores de p&aacute;ginas web para diversas cosas, como recordar tus preferencias entre visitas (como en nuestro caso) o identificarte y trazar tus movimientos por Internet (no es nuestro caso).<br/><br/>Aprovechando que aqu&iacute; utilizamos verdaderamente pocas, te contamos para que.<br/><ul><li><span style="font-weight:bold;">Idioma</span>: Utilizamos una cookie para recordar el idioma en el que quieres ver la p&aacute;gina. Si la estas viendo en castellano, el &uacute;nico texto que contendr&aacute; sera &quot;es&quot;. Bastante inofensivo, ¿verdad?</li><li><span style="font-weight:bold;">Aviso de cookies</span>: Ir&oacute;nicamente, tenemos que usar una cookie para evitar que el aviso sobre cookies que estamos obligados a mostrarte cuando nos visitas por primera vez te moleste solo esa primera vez. Esta es mas simple aun que la anterior, y es una cookie vacia, sin ningun tipo de texto.</li><li><span style="font-weight:bold;">Cookies de Google</span>: Esto tiene m&aacute;s miga. Durante las fiestas de Vitoria, esta p&aacute;gina muestra mapas de Google. Es posible (y casi seguro) que estos mapas inserten cookies propias sobre las que no tenemos ning&uacute;n control. Sorry.</li></ul>';
 	
+	//Ads
+	$lng['ad_title'] = 'Publizitatea';
+	
 	// /error/
 	$lng['error_title'] = 'Error';
 	$lng['error_error'] = 'ERROR';

+ 2 - 1
www/nosotros/index.php

@@ -1,4 +1,5 @@
 <?php
+	session_start();
 	$http_host = $_SERVER['HTTP_HOST'];
 	include("../functions.php");
 	$con = startdb();
@@ -104,6 +105,6 @@
 				</div>
 			</div>
 		</div>
-		<?php include("../footer.php"); ?>
+		<?php include("../footer.php"); ad($con, $lang, $lng); ?>
 	</body>
 </html>

+ 10 - 0
www/script/ui.js

@@ -62,3 +62,13 @@ function dismissCookiePopUp(host, open = false){
 		win.focus();
 	}
 }
+
+function showAd(){
+	console.log("SHOW");
+	setTimeout(function(){document.getElementById('ad').style.bottom = '0';}, 3000);
+}
+
+function closeAd(){
+	console.log("CLOSE");
+	document.getElementById('ad').style.bottom = '-25em';
+}

+ 7 - 11
www/sitemap.php

@@ -12,8 +12,7 @@
 		<?php
 			$res_date = mysqli_query($con, "(SELECT DATE_FORMAT(dtime, '%Y-%m-%d') AS cdate FROM post) UNION (SELECT DATE_FORMAT(dtime, '%Y-%m-%d') AS cdate FROM activity) UNION (SELECT DATE_FORMAT(uploaded, '%Y-%m-%d') AS cdate FROM photo) ORDER BY cdate DESC LIMIT 1;");
 			$row_date = mysqli_fetch_array($res_date);
-		?>
-		<lastmod><?php echo $row_date['cdate']; ?></lastmod>
+		?><lastmod><?php echo $row_date['cdate']; ?></lastmod>
 		<changefreq>weekly</changefreq>
 		<priority>0.8</priority>
 	</url>
@@ -32,8 +31,7 @@
 		<?php
 			$res_date = mysqli_query($con, "SELECT DATE_FORMAT(dtime, '%Y-%m-%d') AS cdate FROM post ORDER BY cdate DESC LIMIT 1;");
 			$row_date = mysqli_fetch_array($res_date);
-		?>
-		<lastmod><?php echo $row_date['cdate']; ?></lastmod>
+		?><lastmod><?php echo $row_date['cdate']; ?></lastmod>
 		<changefreq>weekly</changefreq>
 		<priority>0.8</priority>
 	</url>
@@ -57,8 +55,7 @@
 		<?php
 			$res_date = mysqli_query($con, "SELECT DATE_FORMAT(dtime, '%Y-%m-%d') AS cdate FROM activity ORDER BY cdate DESC LIMIT 1;");
 			$row_date = mysqli_fetch_array($res_date);
-		?>
-		<lastmod><?php echo $row_date['cdate']; ?></lastmod>
+		?><lastmod><?php echo $row_date['cdate']; ?></lastmod>
 		<changefreq>weekly</changefreq>
 		<priority>1</priority>
 	</url>
@@ -82,8 +79,7 @@
 		<?php
 			$res_date = mysqli_query($con, "SELECT DATE_FORMAT(uploaded, '%Y-%m-%d') AS cdate FROM photo ORDER BY cdate DESC LIMIT 1;");
 			$row_date = mysqli_fetch_array($res_date);
-		?>
-		<lastmod><?php echo $row_date['cdate']; ?></lastmod>
+		?><lastmod><?php echo $row_date['cdate']; ?></lastmod>
 		<changefreq>weekly</changefreq>
 		<priority>0.8</priority>
 	</url>
@@ -109,16 +105,16 @@
 			if (mysqli_num_rows($res_lb) > 0){
 				$r_lb = mysqli_fetch_array($res_lb);
 				if ($r_lb['value'] == 1){
-					echo "\t\t<changefreq>monthly</changefreq>\n";
+					echo "<changefreq>monthly</changefreq>\n";
 					echo "\t\t<priority>0.5</priority>\n";
 				}
 				else{
-					echo "\t\t<changefreq>monthly</changefreq>\n";
+					echo "<changefreq>monthly</changefreq>\n";
 					echo "\t\t<priority>0.5</priority>\n";
 				}
 			}
 			else{
-				echo "\t\t<changefreq>monthly</changefreq>\n";
+				echo "<changefreq>monthly</changefreq>\n";
 				echo "\t\t<priority>0.5</priority>\n";
 			}
 		?>