Browse Source

Improved gallery upload system and album view.

seavenois 10 năm trước cách đây
mục cha
commit
2b521e6700

+ 5 - 4
sql/setup.sql

@@ -114,10 +114,11 @@ CREATE TABLE sponsor (
 	lon				DOUBLE,
 	ammount			INT,
 	print 			INT				DEFAULT 0,
-	print_static	INT				DEFAULT 0
+	print_static	INT				DEFAULT 0,
+	click			INT				DEFAULT 0
 );
 
-DROP TABLE IF EXISTS stat_visit;
+--DROP TABLE IF EXISTS stat_visit;
 CREATE TABLE stat_visit (
 	id		INT				NOT NULL	AUTO_INCREMENT	PRIMARY KEY,
 	ip		VARCHAR(50),
@@ -126,7 +127,7 @@ CREATE TABLE stat_visit (
 	browser	VARCHAR(150)
 );
 
-DROP TABLE IF EXISTS stat_view;
+--DROP TABLE IF EXISTS stat_view;
 CREATE TABLE stat_view (
 	id		INT				NOT NULL	AUTO_INCREMENT	PRIMARY KEY,
 	visit	INT				NOT NULL	REFERENCES stat_visit.id,
@@ -135,7 +136,7 @@ CREATE TABLE stat_view (
 	dtime	TIMESTAMP		NOT NULL	DEFAULT now()
 );
 
-DROP TABLE IF EXISTS stat_sync;
+--DROP TABLE IF EXISTS stat_sync;
 CREATE TABLE stat_sync (
 	id		INT			NOT NULL	AUTO_INCREMENT	PRIMARY KEY,
 	dtime	TIMESTAMP	NOT NULL	DEFAULT now(),

BIN
www-admin/.functions.php.kate-swp


+ 20 - 0
www-admin/functions.php

@@ -243,6 +243,26 @@
 			return false;
 	}
 	
+	/****************************************************
+	* Generates a URL-valid string from a regular one.  *
+	*                                                   *
+	* @params:                                          *
+	*    text: (string): Original string.               *
+	* @return: (string): URL-valid string.              *
+	****************************************************/
+	function permalink($text){
+		$unwanted_array = array('Š'=>'S', 'š'=>'s', 'Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
+							'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U',
+							'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss', 'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c',
+							'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o',
+							'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y' );
+		$str = strtr( $text, $unwanted_array );
+		$str = preg_replace('/[^\da-zA-Z ]/i', '', $str);
+		$str = str_replace(' ', '-', $str);
+		return $str;
+	}
+	
+	
 	/****************************************************
 	* Increases version value in table settings by one. *
 	* Helpfull for the app to know when to perform a    * 

+ 1 - 1
www/actividades/index.php

@@ -16,7 +16,7 @@
 		<meta content="text/html; charset=utf-8" http-equiv="content-type"/>
 		<meta charset="utf-8"/>
 		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
-		<title><?php echo $lng['actividades_title'];?></title>
+		<title><?php echo $lng['activities_title'];?></title>
 		<link rel="shortcut icon" href="<?php echo "http://$http_host/img/logo/favicon.ico";?>">
 		<!-- CSS files -->
 		<style>

+ 8 - 0
www/css/galeria.css

@@ -230,6 +230,14 @@ div#photo_data span#photo_date{
 	font-size:	80%;
 	font-style:	italic;
 }
+div#photo_data span#photo_user{
+	display:	block;
+	margin:		0.3em;
+	width:		90%;
+	text-align:	right;
+	font-size:	80%;
+	font-style:	italic;
+}
 
 
 div#photo_viewer_comments{

+ 1 - 1
www/css/index.css

@@ -20,7 +20,7 @@ table.festival_section_table tr td div.entry{
 }
 
 table.festival_section_table tr td div#festivals_summary{
-	min-height:		15em;
+/* 	min-height:		15em; */
 }
 
 table.festival_section_table tr td div#festivals_summary img{

+ 19 - 0
www/functions.php

@@ -221,6 +221,25 @@
 		return $str;
 	}
 	
+	/****************************************************
+	* Generates a URL-valid string from a regular one.  *
+	*                                                   *
+	* @params:                                          *
+	*    text: (string): Original string.               *
+	* @return: (string): URL-valid string.              *
+	****************************************************/
+	function permalink($text){
+		$unwanted_array = array('Š'=>'S', 'š'=>'s', 'Ž'=>'Z', 'ž'=>'z', 'À'=>'A', 'Á'=>'A', 'Â'=>'A', 'Ã'=>'A', 'Ä'=>'A', 'Å'=>'A', 'Æ'=>'A', 'Ç'=>'C', 'È'=>'E', 'É'=>'E',
+							'Ê'=>'E', 'Ë'=>'E', 'Ì'=>'I', 'Í'=>'I', 'Î'=>'I', 'Ï'=>'I', 'Ñ'=>'N', 'Ò'=>'O', 'Ó'=>'O', 'Ô'=>'O', 'Õ'=>'O', 'Ö'=>'O', 'Ø'=>'O', 'Ù'=>'U',
+							'Ú'=>'U', 'Û'=>'U', 'Ü'=>'U', 'Ý'=>'Y', 'Þ'=>'B', 'ß'=>'Ss', 'à'=>'a', 'á'=>'a', 'â'=>'a', 'ã'=>'a', 'ä'=>'a', 'å'=>'a', 'æ'=>'a', 'ç'=>'c',
+							'è'=>'e', 'é'=>'e', 'ê'=>'e', 'ë'=>'e', 'ì'=>'i', 'í'=>'i', 'î'=>'i', 'ï'=>'i', 'ð'=>'o', 'ñ'=>'n', 'ò'=>'o', 'ó'=>'o', 'ô'=>'o', 'õ'=>'o',
+							'ö'=>'o', 'ø'=>'o', 'ù'=>'u', 'ú'=>'u', 'û'=>'u', 'ý'=>'y', 'þ'=>'b', 'ÿ'=>'y' );
+		$str = strtr( $text, $unwanted_array );
+		$str = preg_replace('/[^\da-zA-Z ]/i', '', $str);
+		$str = str_replace(' ', '-', $str);
+		return $str;
+	}
+	
 	/****************************************************
 	* This function closes all the opened HTML tags in  *
 	* a given string.                                   * 

+ 5 - 2
www/galeria/load_photo.php

@@ -9,7 +9,7 @@
 	
 	//Get photo data
 	$path = mysqli_real_escape_string($con, $_GET['path']);
-	$q = mysqli_query($con, "SELECT id, file, permalink, title_$lang AS title, description_$lang AS description, dtime, size, user, username FROM photo WHERE file = '$path' AND approved = 1");
+	$q = mysqli_query($con, "SELECT id, file, permalink, title_$lang AS title, description_$lang AS description, uploaded, size, user, username FROM photo WHERE file = '$path' AND approved = 1");
 	if (mysqli_num_rows($q) == 0){
 		exit(0);
 	}
@@ -34,7 +34,10 @@
 		if (strlen($r['description']) > 0){
 			echo "<span id='photo_description'>$r[description]</span>\n";
 		}
-		echo "<span id='photo_date'>" . formatDate($r['dtime'], $lang) . "</span>\n";
+		echo "<span id='photo_date'>" . formatDate($r['uploaded'], $lang) . "</span>\n";
+		if (strlen($r['username']) > 0){
+			echo "<span id='photo_user'>$lng[gallery_user]$r[username]</span>\n";
+		}
 		echo "</div>\n";
 		$q_comment = mysqli_query($con, "SELECT * FROM photo_comment WHERE photo = $r[id];");
 		$comment_count = mysqli_num_rows($q_comment);

+ 16 - 5
www/galeria/save.php

@@ -19,17 +19,26 @@
 	while (strlen($_POST["file_$total"]) > 0){
 		//$files[$total] = $_POST["file_$total"];
 		$img = $_POST["file_$total"];
+		error_log("FILE: " . $img);
 		//The next line wont work
-		$img = str_replace('data:image/png;base64,', '', $img);
+		if (strpos($img, 'data:image/jpeg;base64,') < 10){
+			$ext = 'jpg';
+			$img = str_replace('data:image/jpeg;base64,', '', $img);
+		}
+		else if (strpos($img, 'data:image/png;base64,') < 10){
+			$ext = 'png';
+			$img = str_replace('data:image/png;base64,', '', $img);
+		}
 		$img = str_replace(' ', '+', $img);
 		//echo "IMG idx " . $total . ": " . $img . "<br/><br/><br/>br/><br/>";
 		$files[$total] = base64_decode($img);
+		
 		//$file = 'image.png';
 		//$success = file_put_contents($file, $data);
 		$titles[$total] = mysqli_real_escape_string($con, $_POST["title_$total"]);
 		$descriptions[$total] = mysqli_real_escape_string($con, $_POST["description_$total"]);
 		//Save image to file
-		$file = 'image.png';
+		$file = 'image.' . $ext;
 		$success = file_put_contents($file, $files[$total]);
 		$total ++;
 	}
@@ -49,12 +58,13 @@
 			$fname = "$id";
 		}
 		//Save image to file
-		$file = "../img/galeria/$fname.png";
+		$file = "../img/galeria/$fname.$ext";
 		$success = file_put_contents($file, $files[$i]);
+		error_log("SUCCESS" . $success);
 		//Convert to jpg and create miniature and preview_image
 		//$im = new imagick("../img/galeria/$fname.png");
 		//$handle = fopen("../img/galeria/$fname.png", 'rb');
-		$im = new Imagick("../img/galeria/$fname.png");
+		$im = new Imagick("../img/galeria/$fname.$ext");
 		//$im->readImageFile($handle);
 		$im->setImageBackgroundColor('white');
 		$im = $im->flattenImages();
@@ -71,7 +81,7 @@
 		$im->writeImage("../img/galeria/miniature/$fname.jpg");
 		$im->resizeImage(200, 0, Imagick::FILTER_POINT, true);
 		$im->resizeImage(0, 200, Imagick::FILTER_POINT, true);
-		$im->writeImage("../img/galeria/t/$fname.jpg");
+		$im->writeImage("../img/galeria/thumb/$fname.jpg");
 		$im->clear();
 		$im->destroy();
 		//Delete initial png
@@ -82,6 +92,7 @@
 		$h = getimagesize("../img/galeria/$fname.jpg")[1];
 		//Entry in database
 		mysqli_query($con, "INSERT INTO photo (id, file, permalink, title_es, title_en, title_eu, description_es, description_en, description_eu, width, height, size, approved, username) VALUES ($id, '$fname.jpg', '$fname', '$titles[$i]', '$titles[$i]', '$titles[$i]', '$descriptions[$i]', '$descriptions[$i]', '$descriptions[$i]', $w, $h, $s, 0, '$username')");
+		error_log("INSERT INTO photo (id, file, permalink, title_es, title_en, title_eu, description_es, description_en, description_eu, width, height, size, approved, username) VALUES ($id, '$fname.jpg', '$fname', '$titles[$i]', '$titles[$i]', '$titles[$i]', '$descriptions[$i]', '$descriptions[$i]', '$descriptions[$i]', $w, $h, $s, 0, '$username')");
 		mysqli_query($con, "INSERT INTO photo_album VALUES ($id, $album);");
 		version();
 		$id ++;

+ 1 - 0
www/lang/lang_en.php

@@ -168,6 +168,7 @@
 	$lng['gallery_new_comment_content'] = 'Comment...';
 	$lng['gallery_new_comment_user'] = 'A name...';
 	$lng['gallery_new_comment_submit'] = 'Post';
+	$lng['gallery_user'] = 'Sent by: ';
 	$lng['gallery_'] = '';
 	
 	// /galeria/upload.php

+ 2 - 1
www/lang/lang_es.php

@@ -157,7 +157,8 @@
 	$lng['gallery_albums'] = '&Aacute;lbums';
 	$lng['gallery_photos_singular'] = 'foto';
 	$lng['gallery_photos_plural'] = 'fotos';
-	$lng['gallery_read_more'] = 'Read more';
+	$lng['gallery_read_more'] = 'Seguir leyendo';
+	$lng['gallery_user'] = 'Enviada por: ';
 	$lng['gallery_'] = '';
 	
 	// /galeria/album.php

+ 1 - 0
www/lang/lang_eu.php

@@ -158,6 +158,7 @@
 	$lng['gallery_photos_singular'] = 'argazkia';
 	$lng['gallery_photos_plural'] = 'argazkiak';
 	$lng['gallery_read_more'] = 'Gehiago irakurri';
+	$lng['gallery_user'] = 'Arabera: ';
 	$lng['gallery_'] = '';
 	
 	// /galeria/album.php