Projet

Général

Profil

Révision 67466a8d

Voir les différences:

www/.htaccess
1
<Files info.txt>
2
        deny from all
3
</Files>
www/VERSION
1
20120608
www/inc/comment_form.inc.php
1
<?php 
2
/* 
3
 * The HTML contained in this file is valid XHTML 1.0 Strict 
4
 */
5

  
6
echo "<div id=\"comment_block\">\n";
7

  
8
?>
9
	<?php echo"<div id=\"showhideform\"><strong> " . __('Post a Comment') . "</strong>:"; ?>
10
	<span class="comment_toggle"> 
11
	[&nbsp;
12
	<?php echo"<a href=\"javascript:toggle_comment()\"><span id=\"showlink\">" . __('Show Form') . "</span><span id=\"hidelink\" style=\"display:none;\">" . __('Hide Form') . "</span></a>"; ?>
13
	&nbsp;]
14
	</span>
15
	</div>
16
	
17
	<div id="comment_form" style="display: none;">
18
<?php
19
$this->form_start($ThisUrl, "post", NULL);
20
$this->input("text", "commentname", $username, __('Name:'), NULL, __('Enter your name.') );
21
$this->input("checkbox", "savecommentname", "1", __('Remember Name:'), "yes", 
22
             __('Should the browser remember your name?'));
23
$magic_number = random_digits(4);
24
//temporary. should generate an image instead
25
echo "<div class=\"row\"><div class=\"control\">$magic_number</div></div>\n";
26
$this->input("hidden", "commentkolacek", md5($magic_number), NULL, NULL, NULL);
27
$this->input("text", "commentspamcheck", "", __('Retype PIN Above:'), NULL, __('Enter the number shown above.'));
28
$this->input("textarea", "commentdata", "", __('Comment') . " :" , NULL, __('Allowed HTML tags: a,b,i,ul,li,blockquote,br.') );
29
$this->input("submit", "", __('Send') , NULL, NULL, NULL);
30
$this->form_end();
31
?>
32
	</div>
33
</div>
www/inc/config.inc.php
1
<?php
2
#base dirname
3
  $root = dirname(dirname(__FILE__) . "../");
4
# ===========================================================================
5
# dir index
6
	 $sortinmonth = 0;// 1 - alphabetically
7
	 								  // 0 - by date (reverse)
8

  
9
# ===========================================================================
10
# default languages
11
# use UA's accept language
12
require_once("$root/inc/l10nget.inc.php"); //get from UA
13
if (isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
14
	$sclang = get_lang_from_agent($_SERVER["HTTP_ACCEPT_LANGUAGE"]);
15
} else {
16
	$sclang = "en";
17
}
18
l10n::set("$root/l10n/".$GLOBALS['sclang']."/exif.lang");
19

  
20
# ===========================================================================
21
#Name to dsplay on the gallery
22
$scnamegallery = "Photo Gallery Index";
23

  
24

  
25
# ===========================================================================
26
# albums to show
27
   $yearsince = 1999;
28
#images FIXME - this is stylesheet's job
29
   $img["left"] = "left.png";
30
   $img["right"] = "right.png";
31
   $img["top"] = "top.png";
32
# ===========================================================================
33
#thumbnail behaviour
34
   //keep this unset for dynamic thumbnail size
35
   //$thumbsize = "fixed";
36
   //How the previous and Next thumbnails should be scaled
37
   // 1 is 1:1, >1 is smaller, <1 is bigger
38
   $PNthumbScale = 1.5;
39
# Photos Copyright
40
#	CHANGE THIS! I am not trying to take over the world ;)
41
	 $copy = "Software : GNU/GPL <a href=\"http://jimmac.musichall.cz/original.php\">Original</a> Copyright &copy; 1999-2005 Jakub Steiner - End user interface <a href=\"http://www.ryxeo.com/WebPhotoAlbum.html\">RyXeo WebPhotoAlbum</a> &copy; 2012 Eric Seigne";
42
#app info
43
   $app["name"] = "RyXeo WebPhotoAlbum"; // opensource remote image gallery,
44
                              // initialy not as lovely 
45
   $app["url"] = "http://www.ryxeo.com/WebPhotoAlbum.html";
46
   $app["version"] = "1.0";
47
   $exif_show = array("DateTime"=>__("Time Taken"), 
48
		      "Make"=>__("Camera Manufacturer"), 
49
		      "Model"=>__("Camera Model"), 
50
		      "FocalLength"=>__("Real Focal Length"), 
51
		      "FocalLengthIn35mmFilm"=>__("Focal Length Relative to 35mm Film"),
52
		      "FNumber"=>__("F Stop"), 
53
		      "Copyright"=>__("Copyright"), 
54
		      "Artist"=>__("Artist"), 
55
		      "ExposureTime"=>__("Time of Exposure"), 
56
		      "ISOSpeedRatings"=>__("Film/Chip Sensitivity"),
57
		      "Flash"=>__("Flash"));
58
# ===========================================================================
59
## Gallery Directory
60
# This is a path relative to the directory where original is installed
61
# eg. it can be "../galleries" to use a galleries dir above the original dir.
62
  $gallery_dir="galleries";
63

  
64
#Enable this to access extended tracking functionality
65
#depends on sqlite
66
$have_sqlite = 0;
67

  
68
# This controls wheather web visitors will be able to post
69
# comments to images
70
$comments = 1;
71

  
72
# Access Log/Counter
73
# $log_access = 0; // no access logging
74
$log_access = 1; 
75

  
76
#css styles
77
   $themes = array(
78
               "dark" => "inc/styles/dark/dark.css",
79
               "classic" => "inc/styles/classic/classic.css",
80
               "gorilla" => "inc/styles/gorilla/gorilla.css"
81
   );
82

  
83
?>
www/inc/db.class.inc.php
1
<?php
2
/* SQLite DB class for storing
3
   - image views,
4
	 - user comments
5
*/
6

  
7
$dbfile = "$root/$gallery_dir/photos.db";
8

  
9
//unfortunately in php4, the SQLiteDatabse class isn't created so we have to
10

  
11
class SQLiteDatabase {
12
	var $dbfile;
13

  
14
	function SQLiteDatabase ($dbfile) {
15
		
16
		$this->dbfile = $dbfile;
17
		//if db file doesn't exist, fill with skeleton
18
		if (file_exists($this->dbfile)) {
19
			$this->dbres = sqlite_open($this->dbfile, 0666, $sqliteerror);
20
		} else {
21
			//fill with skeleton
22
			$folder = dirname($this->dbfile);
23
			if (!is_writable($folder)) { //we need write permission to create database
24
				die("<p style=\"color:red;\">cannot create dabase. check permissions.</p>\n");
25
			} else {
26
				$this->dbres = sqlite_open($this->dbfile, 0666, $sqliteerror);
27
				//photo table
28
				$sql = "create table photo (id INTEGER PRIMARY KEY, caption TEXT, ";
29
				$sql .= "counter INTEGER, number INTEGER, album TEXT, name TEXT)";
30
				$this->query($sql);
31
				//comment table
32
				$sql = "create table comment (id INTEGER PRIMARY KEY, user TEXT, ";
33
				$sql .= "comment_body TEXT, photo_id INT, date DATETIME)";
34
				$this->query($sql);
35
			}
36
		}
37
	}
38

  
39
	function query($sql) {
40
		global $page;
41

  
42
		if (!$this->result = sqlite_query($this->dbres, $sql)) {
43
				print "Query failed, <span style=\"color: blue;\"><pre>$sql</pre></style>\n";
44
				print sqlite_error_string (sqlite_last_error($this->dbres));
45
				$page->footer();
46
				exit;
47
		}
48
	}
49

  
50
	function count() {
51
		return sqlite_num_rows($this->result);
52
	}
53

  
54
	function rewind() { //just to abstract from sqlite
55
		sqlite_rewind($this->result);
56
	}
57
	
58
}
59

  
60

  
61
$db = new SQLiteDatabase("$dbfile");
62

  
63
?>
www/inc/exif.inc.php
1
<?php
2

  
3

  
4
function formatEXIF ($k,$v) {
5
	// format some special cases
6
	// dunno if EXIF support formats it so weirdly everywhere.
7
	// Sure does in my php4
8

  
9
	switch ($k) {
10
		case "FocalLength":
11
			$out = eval("return $v;"); 
12
			$out .= "mm";
13
			return $out;
14
			break;
15
		case "FNumber":
16
			$out = "f/";
17
			$out .= eval("return $v;");
18
			return $out;
19
			break;
20
		case "ExposureTime":
21
			// numerator = cistatel; jmenovatel = denominator :)
22
			$x = explode("/",$v,2);
23
			if ($x[0]>=100) {
24
				$out = eval("return ${x[0]}/${x[1]};");
25
				$out .= "s";
26
				return $out;
27
			} else {
28
				return "1/".(1.0/($x[0]/$x[1]))."s";
29
			}
30
			break;
31
		case "Flash";
32
			if ($v=="0") {
33
				return "No Flash";
34
			} else {
35
				return $v;
36
			}
37
			break;
38
		case "ISOSpeedRatings":
39
			return "ISO" . $v;
40
			break;
41
		case "GainControl";
42
			return "EV" . $v;
43
			break;
44
		case "FocalLengthIn35mmFilm":
45
			return $v . "mm";
46
			break;
47
		case "DateTime":
48
			//return date("M d Y H:i:s", $v);
49
			ereg("^([0-9]{4}):([0-9]{1,2}):([0-9]{1,2}) (.*)",$v,$x);
50
			return $x[1] . "/" . $x[2] . "/" . $x[3] . " " . $x[4];
51
			break;
52
		default:
53
			return $v;
54
	}
55
}
56

  
57

  
58
// Only use php4 internal handling now.
59
// $file is LQ image
60
$exif_array = exif_read_data("$file");
61
reset($exif_array);
62
if ($exif_show) reset($exif_show);
63

  
64
if ($exif_array["Make"]) { // only render all this 
65
													// if there is EXIF header
66
	// fancy table look
67
	echo "<div id=\"exif_table\" style=\"display: none;\">\n";
68
	echo "<table class=\"exif\" border=\"0\">\n";
69
	//co ukazat (podle exif_show)
70
	if ($exif_show) {
71
		 while (list($kx,$x) = each($exif_show)) {
72
			 while(list($k,$v)=each($exif_array)) {
73
			 if ($kx==$k) {
74
				 echo "<tr>";
75
				 echo "<td align=\"right\">";
76
				 echo $x;
77
				 echo ": </td>";
78
				 echo "<td><b>";
79
				 echo formatEXIF($k,$v);
80
				 echo "</b></td>";
81
				 echo "</tr>\n";
82
			 }
83
			 }
84
			 reset($exif_array);
85
		 }
86
	} else {
87
		 //ukaze vsechno v tabulce
88
		 while(list($k,$v)=each($exif_array)) {
89
				echo "<tr>";
90
				echo "<td align=\"right\">";
91
				echo $k;
92
				echo ": </td>";
93
				echo "<td><b>";
94
				echo formatEXIF($k,$v);
95
				echo "</b></td>";
96
				echo "</tr>\n";
97
		 }
98
	}
99
	echo "<tr>\n";
100
	echo "<td></td>";
101
	echo "<td><a href=\"javascript:toggle_div('exif_table');toggle_div('exif_line');\">" . __("Less info");
102
	echo "</a></td>";
103
	echo "</tr>\n";
104
	echo "</table>\n";
105
	echo "</div>\n";
106

  
107

  
108

  
109

  
110

  
111
	// selected EXIF header on one line
112
	echo "<div id=\"exif_line\">\n";
113
	echo "<p class=\"exif\">";
114
	reset($exif_array);
115
	if ($exif_show) reset($exif_show);
116
	if ($exif_show) {
117
		 while (list($kx,$x) = each($exif_show)) {
118
			 while(list($k,$v)=each($exif_array)) {
119
					 if ($kx==$k) {
120
							echo "<span title=\"$x\">";
121
							echo formatEXIF($k,$v);
122
							echo "</span> | ";
123
					 }
124
				}
125
		 reset($exif_array);
126
		 }
127
	} else {
128
		/* vsechny exif headers inline */
129
		 while(list($k,$v)=each($exif_array)) {
130
				echo "<span title=\"";
131
				echo $k;
132
				echo "\">";
133
				echo formatEXIF($k,$v);
134
				echo "</span> | ";
135
		 }
136
	}
137

  
138
	echo "<a href=\"javascript:toggle_div('exif_table');toggle_div('exif_line');\">" . __("More info");
139
	echo "</a></p>\n";
140
	echo "</div>\n";
141
}
142

  
143
?>
www/inc/footer.inc.php
1
<?php
2

  
3
/*
4
echo "<p class=\"copyright\">\n";
5
echo "<a href=\"http://jigsaw.w3.org/css-validator/validator?uri=";
6
echo "http://$HostName$ThisScript\">";
7
echo "<img align=\"top\" style=\"border:0;width:88px;height:31px\"";
8
echo " src=\"http://jigsaw.w3.org/css-validator/images/vcss\""; 
9
echo " alt=\"Valid CSS!\">";
10
echo "</a>\n";
11

  
12
echo "<a href=\"http://validator.w3.org/check?uri=";
13
echo "http://$HostName$ThisScript\">";
14
echo "<img align=\"top\" style=\"border:0;width:88px;height:31px\"";
15
echo " src=\"http://www.w3.org/Icons/valid-html401\""; 
16
echo " alt=\"Valid HTML 4.01!\">";
17
echo "</a>\n";
18
*/
19

  
20
echo "\n\n<div class=\"footer\">";
21
echo "$copy";
22
echo "<br />" . __('Generated by') . "\n   <em>";
23
echo "<a href=\"" . $app["url"] . "\">";
24
echo $app["name"];
25
echo "</a>";
26
echo " ver. " . $app["version"];
27
echo "</em>\n";
28
echo "</div>\n";
29
?>
www/inc/funkce.inc.php
1
<?php
2

  
3
function check($file) {
4
   global $gallery_dir, $page;
5
   
6
#   if (eregi("[^0-9a-z\_\-\ ]",$file) || !file_exists("$gallery_dir/$file")) {
7
#   if (eregi("CVS",$file) || !file_exists("$gallery_dir/$file")) {
8
   if (!file_exists("$gallery_dir/$file")) {
9
      echo "funkce.inc.php/check(): Bad input";
10
      $page->footer();
11
      exit;
12
   }
13
}
14

  
15
function browserCheck() {
16
   global $HTTP_USER_AGENT;
17
   
18
	 $HTTP_USER_AGENT=$_SERVER["HTTP_USER_AGENT"];
19
   if (eregi("(MSIE.[456789]).*Mac.*",$HTTP_USER_AGENT)) {
20
        return("macie4+");
21
   } elseif (eregi("(MSIE.[678])",$HTTP_USER_AGENT)) {
22
        return("ie6+");
23
   } elseif (eregi("(MSIE.[45])",$HTTP_USER_AGENT)) {
24
        return("ie4+");
25
   } elseif (eregi("Opera",$HTTP_USER_AGENT)) {
26
        return("opera");
27
   } elseif (eregi("(Mozilla.4)",$HTTP_USER_AGENT)) {
28
        return("netscape4");
29
   } elseif (eregi("(Mozilla.[5-9])",$HTTP_USER_AGENT)) {
30
        return("mozilla");
31
   } elseif (eregi("KMeleon",$HTTP_USER_AGENT)) {
32
        return("mozilla");
33
   } else {
34
        return("Netscape3");
35
   }
36
}
37

  
38
function infoParse ($infofile) {
39
	
40
	$info_array = file($infofile);
41
	foreach ($info_array as $line) {
42
		list($key,$value) = split("\|",$line);
43
		$result[$key]=$value;
44
	}
45
	return $result;
46
}
47

  
48
function readInfo ($infofile, $file) {
49
	global $galerieyear, $galeriemonth, $galerieday, $galeriedesc, $galerieauthor,
50
	       $galeriename, $galerielogin, $galeriepw, $gallery_dir;
51
	
52
	if (file_exists($infofile)) {
53
		//read from info.txt
54
		$info_array = infoParse($infofile);
55
		if ($info_array["date"]) {
56
			// try to be a little smarter about format
57
			if (ereg("([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})",
58
				$info_array["date"])) {
59
				// remain compatible - DD.MM.YYYY
60
				list($day,$month,$year) = split("\.", $info_array["date"]);
61
				$year = rtrim($year);
62
				$month = rtrim($month);
63
				$day = rtrim($day);
64
				$info_array["date"] = "$year-$month-$day"; //make it US date
65
			}
66
			// US date format at this point
67
			$tstamp = strtotime($info_array["date"]);
68
		} else {
69
			$tstamp = filemtime("$gallery_dir/$file");// Get from filesystem
70
		}
71
		$galerieyear["$file"] = date("Y", $tstamp);
72
		$galeriemonth["$file"] = date("m", $tstamp);
73
		$galerieday["$file"] = date("d", $tstamp);
74
		
75
		if (@$info_array["description"]) {
76
			$galeriedesc["$file"] = rtrim($info_array["description"]);
77
		}
78
		
79
		if (@$info_array["author"]) {
80
			$galerieauthor["$file"] = rtrim($info_array["author"]);
81
		}
82
		
83
		if (@$info_array["name"]) {
84
			$galeriename["$file"] = rtrim($info_array["name"]);
85
		}
86
		
87
		if (@$info_array["restricted_user"]) {
88
			$galerielogin["$file"] = rtrim($info_array["restricted_user"]);
89
			$galeriepw["$file"] = rtrim($info_array["restricted_password"]);
90
		}
91
 } else { // Get Dates from modification stamp
92
		$mtime = filemtime("$gallery_dir/$file");
93
		$galerieyear["$file"] = date("Y", $mtime);
94
		$galeriemonth["$file"] = date("m", $mtime); //F
95
		$galerieday["$file"] = date("d", $mtime);
96
 }
97
}
98

  
99
function access_check($login, $password,$realm) {
100
   if (!($_SERVER['PHP_AUTH_USER']=="$login" && $_SERVER['PHP_AUTH_PW']=="$password")) {
101
      header("WWW-authenticate: Basic Realm=$realm");
102
      Header("HTTP/1.0 401 Unauthorized");
103
			$err = new C_www;
104
      $err->header("Access Denied");
105
			echo "<div class=\"error\">\n";
106
			echo "<h1>Access Denied</h1>\n";
107
			echo "<p>Sorry, this gallery is restricted</p>\n";
108
			echo "<p><a href=\"index.php\">Return to index</a></p>\n";
109
			echo "</div>\n";
110
			$err->footer();
111
      exit;
112
   }
113

  
114
}
115

  
116
function random_digits($times) {
117
	$random="";
118
	for ($i=0;$i<$times;$i++) {
119
		$random .= rand(0,9);
120
	}
121
	return $random;
122
}
123

  
124
function get_photo_title($galerie, $id) {
125
  global $gallery_dir;
126
  if ($title = @file_get_contents("$gallery_dir/$galerie/comments/${id}.txt")) {
127
    $title = trim(preg_replace('/[\s\n\r]+/', ' ', strip_tags($title)));
128
    if (strlen($title) > 80)
129
      $title = trim(substr($title, 0, 77)) . "...";
130
  } else 
131
    $title = "Photo ${id}";
132
  return $title;
133
}
134

  
135
?>
www/inc/global.js
1
function setActiveStyleSheet(title) {
2
   var i, a, main;
3
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
4
     if(a.getAttribute("rel").indexOf("style") != -1
5
        && a.getAttribute("title")) {
6
       a.disabled = true;
7
       if(a.getAttribute("title") == title) a.disabled = false;
8
     }
9
   }
10
   if (title!="") {
11
      writeCookie(title);
12
   }
13
}
14

  
15
function getInactiveStyleSheet() {
16
  var i, a;
17
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
18
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && a.disabled) return a.getAttribute("title");
19
  }
20
  return null;
21
}
22

  
23
function readCookie() {
24
    var theme = document.cookie;
25
    var theme = unescape(theme);
26

  
27
    return theme;
28
}
29

  
30
function writeCookie(theme) {
31
   //FIXME - set expires
32
   var original_cookie = "theme=" + escape(theme);
33
   document.cookie = original_cookie;
34
}
35

  
36
function checkForTheme() {
37
   var theme = readCookie();
38
   //alert(theme);
39
   if (theme=="undefined") {
40
      var theme = "none";
41
   }
42
}
43

  
44
// what a kludge. Luckily I found a clean way
45
function alignForGorilla() {
46
var image_preview = document.getElementById('preview');
47
image_preview.style.marginLeft = "-" + (image_preview.width/2 + 16) + "px";
48
}
49

  
50
// to hide and show the comment block
51
// inspired by www.wikipedia.org
52
function toggle_comment() {
53
    var comment_form = document.getElementById('comment_form');
54
    var showlink=document.getElementById('showlink');
55
    var hidelink=document.getElementById('hidelink');
56
    if(comment_form.style.display == 'none') {
57
	comment_was = comment_form.style.display; 
58
	comment_form.style.display = '';
59
	hidelink.style.display='';
60
	showlink.style.display='none';
61
    } else {
62
	comment_form.style.display = comment_was;
63
	hidelink.style.display='none';
64
	showlink.style.display='';
65
    }
66
}
67

  
68
function toggle_div(classname) {
69
	var div = document.getElementById(classname);
70
    if(div.style.display == 'none') {
71
			div.style.display = 'block';
72
		} else {
73
			div.style.display = 'none';
74
		}
75
}
76

  
www/inc/header.inc.php
1
<div class="stylenavbar">
2
	<div id="styleshiden" style="display: block;">
3
	<p><a href="javascript:toggle_div('styleshiden');toggle_div('stylesshown');">show styles</a></p>
4
	</div>
5
	<div id="stylesshown" style="display: none;">
6
	<ul>
7
	<?php
8
	foreach ($themes as $skin => $url) {
9
				echo "<li><a href=\"javascript:setActiveStyleSheet('$skin')\" title=\"$skin\">";
10
				echo "$skin</a></li> \n";
11
	}
12
	?>
13
	</ul>
14
	<p><a href="javascript:toggle_div('styleshiden');toggle_div('stylesshown');">hide styles</a></p>
15
	</div>
16
</div>
17

  
18
<?php
19
echo "<h1 class=\"title\"><a href=\"http://$HostName$ThisScript\">Photo Gallery<span /></a></h1>\n\n";
20
?>
www/inc/l10nget.inc.php
1
<?php
2

  
3
function get_lang_from_agent($accept) {
4

  
5
	$acceptarr = explode("," , $accept);
6
	foreach ($acceptarr as $lang) {
7
		//get rid of trailing garbage
8
		$lang = ereg_replace("^(.*)\;.*","\\1", $lang);
9
		if (is_dir("l10n/$lang")) {
10
			return $lang;
11
			exit;
12
		}
13
		//no translation for accept language
14
		return "en";
15
	}
16
}
17
?>
www/inc/photo.class.inc.php
1
<?php
2
/* Photo class for dealing with individual images
3

  
4
*/
5

  
6
class C_photo {
7
	var $id;
8
	var $preview;
9
	var $previewsize;
10
	var $mq;
11
	var $hq;
12
	var $name;
13
	var $caption;
14
	var $file;
15
	var $number;
16
	var $counter;
17
	var $album;
18
	var $comments; //rendered string
19

  
20
	function C_photo($file, $number) {
21
		global $root, $gallery_dir, $galerie, $db;
22
		
23
		$this->file = $file;
24
		$this->number = $number;
25
		$this->album = $galerie;
26
		//init from filesystem
27
		//preview
28
		$this->preview = "$gallery_dir/$galerie/lq/img-" . $this->number . ".jpg";
29
		$this->previewsize = getimagesize($this->preview);
30
		//MQ
31
		if (file_exists("$root/$gallery_dir/$galerie/mq/img-" . $this->number . ".jpg")) {
32
			$this->mq = "$gallery_dir/$galerie/mq/img-" . $this->number . ".jpg";
33
		}
34
		//HQ
35
		if (file_exists("$root/$gallery_dir/$galerie/hq/img-" . $this->number . ".jpg")) {
36
			$this->hq = "$gallery_dir/$galerie/hq/img-" . $this->number . ".jpg";
37
		}
38
		if ($GLOBALS['have_sqlite']) { //query just once
39
			require_once("$root/inc/db.class.inc.php");
40
			$sql = "select * from photo where ";
41
			$sql .= "number=" . $this->number . " and ";
42
			$sql .= "album='" . $this->album . "'";
43
			$db->query($sql);
44
		}
45
		$this->readCaption();
46
		$this->readCounter(); //reads access log number
47
		if ($GLOBALS['have_sqlite']) { //need to get photo id first
48
			if (!$db->count()) {//no record for this photo, let's update the record
49
				//FIXME - if no photo data in db, create a unique index for it
50
				//and add number, album, caption and views.
51
				$sql = "insert into photo (name, caption, counter, number, album)";
52
				$sql .= " values (";
53
				$sql .= "\"" . sqlite_escape_string($this->name) . "\", ";
54
				$sql .= "\"" . sqlite_escape_string(strtr($this->caption,"\"","'")) . "\", ";
55
				$sql .= $this->counter . ", ";
56
				$sql .= $this->number . ", ";
57
				$sql .= "\"" . $this->album . "\"";
58
				$sql .= ")";
59
				$db->query($sql);
60
				print "\n\n<!-- We've moved the data to the database.-->";
61
				//now we still need to query for the id
62
				$sql = "select id from photo where ";
63
				$sql .= "number=" . $this->number . " and ";
64
				$sql .= "album='" . $this->album . "'";
65
				$db->query($sql);
66
			}
67
			$db->rewind();
68
			$resultarray = sqlite_fetch_array($db->result);
69
			$this->id = $resultarray["id"];
70
			print "\n\n<!-- image id: " . $this->id . " -->\n";
71
		}
72
		$this->readComments();
73
	}
74

  
75
	function readCaption() {
76
		global $have_sqlite, $root, $gallery_dir, $galerie, $db;
77
		
78
		/* reads name and caption of a photo
79
		   - either from sqlite database or filesystem
80
		 */
81
		 if ($have_sqlite) {
82
				//try reading from sqlite
83
				if ($db->count()) {
84
					$result = sqlite_fetch_array($db->result);
85
					$this->name = $result["name"];
86
					$this->caption = $result["caption"];
87
					return; //no need to fallback anymore
88
				}
89
		 } 
90
		 
91
		 //we falback to filesystem
92
		  $buffer = "";
93
			$captionfile = "$root/$gallery_dir/$galerie/comments/" . $this->number . ".txt";
94
			$fh = @fopen($captionfile, "r");
95
			if ($fh) {
96
				 while (!feof($fh)) {
97
						 $buffer .= fgets($fh, 4096);
98
				 }
99
				 fclose($fh);
100
			} else { // no caption file
101
				$this->name = __("Photo ") . $this->number;
102
				return;
103
			}
104
			//parse buffer
105
			if(eregi("^<span>(.*)</span>( - )?(.*)", $buffer, $x)) {
106
				$this->name = $x[1]; //mostly "Photo"
107
				$this->caption = chop($x[3]);
108
			} else {
109
				$this->caption = $buffer;
110
			}
111
	}
112
	
113
	function readCounter() {
114
		global $log_access, $root, $gallery_dir, $galerie, $db;
115

  
116
		if ($GLOBALS['have_sqlite']) {
117
			//try reading from sqlite
118
			if ($db->count()) {
119
				$db->rewind();
120
				$result = sqlite_fetch_array($db->result);
121
				$this->counter = $result["counter"];
122
				return; //no need to fallback anymore
123
			}
124
		} 
125
		//we fallback to filesystem :/
126
		 if (is_writable("$root/$gallery_dir/$galerie/comments")) { // needs perms
127
			 $log = "$root/$gallery_dir/$galerie/comments/log_" . $this->number . ".txt";
128
			 if (file_exists($log)){
129
				 $fh = @fopen($log, "r");
130
				 $this->counter = rtrim(fgets($fh));
131
				 fclose($fh);
132
			 } else {
133
				 $this->counter = 0;
134
			 }
135
		 } else {
136
			 //doesn't do anything if no perms
137
			 print "<!-- ". __('WARNING: comment dir not writable') . "-->\n";
138
			 return 0; //failure
139
		 }
140
		 return 1; //success
141
	}
142

  
143
	function readComments() {
144
		global $root, $gallery_dir, $galerie, $db;
145
		
146
		if ($GLOBALS['have_sqlite']) {
147
			//we have and will use SQLite
148
			//FIXME
149
			print "\n<!--SQLITE comments FIXME-->\n\n";
150
			return 1;
151
		} else {
152
			//filesystem
153
		 	$comments = "$root/$gallery_dir/$galerie/comments/user_" . $this->number . ".txt";
154
			if (file_exists($comments)){
155
				$buffer = "";
156
				$fh = @fopen($comments, "r");
157
				if ($fh) {
158
					 while (!feof($fh)) {
159
							 $buffer .= fgets($fh, 4096);
160
					 }
161
					 $this->comments = $buffer;
162
					 fclose($fh);
163
				}
164
			}
165
		}
166
	}
167
	
168
	function renderCounter() {
169
		
170
		 print "\n<div id=\"log\">\n";
171
		 print __('This image has been viewed') . " ";
172
		 print "<strong>" . $this->counter . "</strong>". " " . __('times') . ".";
173
		 print "</div>\n\n";
174
		 $this->writeCounter(); //save state
175

  
176
	}
177

  
178
	function writeCounter() {
179
		global $log_access, $root, $gallery_dir, $galerie, $page, $db;
180

  
181
		$this->counter++; //we add to counter
182
		if ($GLOBALS['have_sqlite']) {
183
			//we have SQLite
184
			$sql = "update photo set counter=" . $this->counter;
185
			$sql .= " where id=" . $this->id;
186
			$db->query($sql);
187
			return; //no need to fallback anymore
188
		} 
189
		 //fallback to filesystem
190
		 if (is_writable("$root/$gallery_dir/$galerie/comments")) { // needs perms
191
			 $log = "$root/$gallery_dir/$galerie/comments/log_". $this->number .".txt";
192
			 if (file_exists($log) && !is_writable($log)) {
193
				 print "\n\n\n<!-- cannot open $log. Check permissions.";
194
				 print "\nAborting counter write -->\n";
195
				 return 0;
196
			 }
197
			 $fh = fopen($log,"w");
198
			 if (!fwrite($fh, $this->counter . "\n")) {
199
					$page->error( __('Could not write to') . $log . "!");
200
					$page->footer();
201
					exit; //stop everything
202
			 }
203
			 fclose($fh);
204
		 }
205
	}
206

  
207
	function renderBigSize() {
208

  
209
   if ($this->mq || $this->hq) {
210
		 print "<div id=\"mqhq\">";
211
		 if ($this->mq) {
212
				print "<a href=\"" . $this->mq . "\">". __('MQ') . "</a> ";
213
		 }
214
		 if ($this->hq) {
215
				print "<a href=\"" . $this->hq . "\">" . __('HQ') . "</a>";
216
		 }
217
		 print "</div>\n";
218
	 }
219
	}
220

  
221
	function renderPreview() {
222

  
223
   $divheight = $this->previewsize[1] + 10;
224
   print "<div id=\"image\" style=\"height: ${divheight}px\">\n"; // extra kludge 
225
                                                                 // because of tall 
226
                                                                 // images
227

  
228
   print "<img id=\"preview\" " . $this->previewsize[3] . " src=\"". $this->file;
229
	 print "\" alt=\"$snimek\" />\n";
230
	}
231

  
232
	function renderCaption() {
233
	
234
		print "<div class=\"comment\">";
235
		print "<span>" . $this->name . "</span>";
236
		if ($this->caption) {
237
			print " &ndash; ";
238
			print $this->caption;
239
			print "</div>";
240
		}
241
	}
242

  
243
	function addComment($comment_name, $comment_data) { //adds comment to file or database
244
		global $log_access, $root, $gallery_dir, $galerie, $page;
245

  
246
		if ($GLOBALS['have_sqlite']) {
247
			//sqlite
248
			print "\n<!--SQLITE comments addition FIXME-->\n\n";
249
		} else {
250
				//filesystem
251
				if (is_writable("$root/$gallery_dir/$galerie/comments")) { // needs perms
252
					$comment = "$root/$gallery_dir/$galerie/comments/user_";
253
					$comment .= $this->number . ".txt";
254
					if (file_exists($comment) && !is_writable($comment)) {
255
							$page->error("Permission Denied", __('Could not write to')  . $comment . 
256
								"!\n Check permissions.\n");
257
							$page->footer();
258
							exit; //stop everything
259
					}
260

  
261
					$fh = fopen("$comment", "a");
262
					if (!$comment_name) {
263
							$comment_name = __('Anonymous');
264
					}
265
					if (!fwrite($fh, "<div class=\"commententry\">\n")) {
266
							$page->error("Write Failed",  __('Could not write to')  . $comment . "!" );
267
							$page->footer();
268
							exit; //stop everything
269
					}
270
					fwrite($fh, "   <div class=\"name\">" . __('Comment from') . "<em>$comment_name</em></div>\n",90);
271
					fwrite($fh, "   <div class=\"commentdata\">$comment_data</div>\n",280);
272
					fwrite($fh, "</div>\n");
273
					
274
					fclose($fh);
275
				}
276
		}
277
	}
278
}
279
?>
www/inc/styles/classic/classic.css
1
/* Default stylesheet
2
   ==================
3

  
4
   stylesheet & artwork
5
   (c) 2003 Jakub 'jimmac' Steiner
6

  
7
*/
8

  
9
body {
10
   background-color: #f6f6f6;
11
   background: url("bcg.png") top left repeat;
12
   /*
13
   margin: 0px 50px 0px 50px;
14
   width: auto;
15
   */
16
   margin: auto;
17
   width: 770px;
18
   font-family: "Bitstream Vera Sans", sans-serif;
19
   font-size: 10pt;
20
}
21

  
22
img {
23
   border: 0px;
24
}
25

  
26
.bigthumbnails img {
27
	width: 120px;
28
	height: 80px;
29
}
30

  
31
.bigthumbnails a.portrait img {
32
	width: 52px;
33
}
34

  
35
a:link {
36
   color: #909090;
37
}
38

  
39
a:visited {
40
   color: #808080;
41
}
42

  
43
a:hover {
44
   color: #f0f0f0;
45
   background-color: #707070;
46
}
47

  
48

  
49
h1.title {
50
   background-color: #a7a9a6;
51
   font-size: 16pt;
52
   color: #808080;
53
   width: 100%;
54
   margin-bottom: 0px;
55
   padding: 5px;
56
   
57
}
58

  
59
.title a {
60
   display: block;
61
	position:relative;
62
	width:100%; 
63
   height:48px;
64
	margin:0; padding:0;
65
}
66

  
67
.title a:hover {
68
   border: 0px;
69
   background-color: #a7a9a6;
70
}
71

  
72
.title a span {
73
   /* this overlays text below with an image */
74
	display: block;
75
	position:absolute; left:0; top:0; z-index:1; 
76
	width:338px; height:48px;
77
   margin:0; padding:0;
78
	background-image: url("title.png");
79
   background-attachment: top left;
80
   background-repeat: no-repeat;
81
}
82

  
83
div.thumbroll {
84
   margin: 10px 0px 4px 0px;
85
   min-height: 29px;
86
}
87

  
88
p.bigthumbnails {
89
   text-align: center;
90
}
91

  
92
p.bigthumbnails a {
93
    padding: 0px;
94
    margin: 0px;
95
    border: 0px;
96
      
97
}
98
/*
99
p.bigthumbnails a:link img {
100
   border: 1px solid white;
101
}
102

  
103
p.bigthumbnails a:hover img {
104
   border: 1px solid #909090;
105
   
106
}
107
*/
108

  
109
a#minus,a#plus {
110
   display: block;
111
	position: relative;
112
   float: left;
113
	width:24px; 
114
   height:24px;
115
	margin:0px; padding:0px;
116
}
117

  
118
a#minus {
119
   background: url("minus.png") top left no-repeat;
120
}
121

  
122
a#plus {
123
   background: url("plus.png") top left no-repeat;
124
}
125

  
126
a#zip {
127
   /* display: block; */
128
	position: relative;
129
	width:16px; 
130
   height:16px;
131
	margin:0px; padding:0px;
132
   font-size: 9px;
133
}
134

  
135
a#zip span {
136
   background: url("zip.png") top left no-repeat;
137
	position:absolute; left:0; top:0; z-index:1; 
138
	width:16px; height:16px;
139
}
140

  
141
div.navigation {
142
   background-color: #f6f6f6;
143
   width: 100%;
144
   padding: 5px;
145
   font-size: 10px;
146
}
147

  
148
div.navigation a {
149
   color: #a0a0a0;
150
   font-weight: bold;
151
}
152

  
153
div.footer {
154
   font-size: 9px;
155
   width: 100%;
156
   margin-top: 40px;
157
   padding: 5px 5px 20px 5px;
158
   clear: both;
159
   border-top: 1px dotted #909090;
160
}
161

  
162
div.year {
163
   font-size: 11pt;
164
   float: left;
165
   margin: 10px;
166
}
167

  
168
div.month {
169
   margin: 0px 0px 0px 2em;
170
   padding: 2px;
171
}
172

  
173
div.month h4 {
174
   margin: 0px 0px 3px 0px;
175
}
176

  
177
.author, .date, .desc {
178
	display: block;
179
}
180

  
181
.date {
182
	color: gray;
183
}
184

  
185
.date:before {
186
	content: ">>";
187
}
188

  
189
/* ul won't work on safari with float: left */
190
div.month p {
191
   margin: 2px;
192
   padding: 0px 0px 0px 6px;
193
   list-style: none;
194
   font-size: 10px;
195
}
196

  
197
div.month p.restricted {
198
	background: transparent url("restricted.png") top left no-repeat;
199
  padding: 0px 0px 3px 16px;
200
}
201

  
202
div#image {
203
   /* width: 800px; */
204
   display: block;
205
   position: relative;
206
   clear: both;
207
   margin-left: auto;
208
   margin-right: auto;
209
   /* border: 1px solid black; */
210
   min-height: 480px; /* only works in gecko :/ */
211
}
212

  
213
img#preview {
214
   position: relative;
215
   float: left;
216
   margin-right: 8px;
217
}
218

  
219
div.comment {
220
   margin: 2em 0px;
221
   color: #808080;
222
   font-size: 9px;
223
}
224

  
225
div.comment span {
226
   color: black;
227
   font-weight: bold;
228
   font-size: 10px;
229
}
230

  
231
div.navbuttons {
232
   position: absolute;
233
   top: 580px; left: 50%;
234
   margin-left: 260px; /* 260px to the right of the center of the page */
235
   width: 64px; height: 32px;
236
   z-index: 1;
237
}
238

  
239
div.navbuttonsshell {
240
   position: relative;
241
   width: 100%;
242
   margin: 2px;
243
}
244

  
245
div.navbuttonsshell a#previcon {
246
   display: block;
247
   position: absolute;
248
   width: 24px; height: 24px;
249
   margin: 2px; padding: 0;
250
   top: 0px;
251
   left: 0px;
252
   color: #f6f6f6;
253
   font-size: 30px; /* make unreadable */
254
   text-indent: 2em; /* push it off screen, since khtml doesn't do 0px fonts */
255
   overflow: hidden; /* hide the oveflow text */
256
	background: url("left.png") top left no-repeat; /* have a pixmap */
257
}
258

  
259
div.navbuttonsshell a#nexticon {
260
   display: block;
261
   position: absolute;
262
   width: 24px; height: 24px;
263
   margin: 2px 4px 2px auto; padding: 0;
264
   right: 4px; top: 0px;
265
   color: #f6f6f6;
266
   font-size: 30px; /* make unreadable */
267
   text-indent: 2em; /* push it off screen, since khtml doesn't do 0px fonts */
268
   overflow: hidden; /* hide the overflow text */
269
	background: url("right.png") top left no-repeat; /* have a pixmap */
270
}
271

  
272

  
273
div.prevthumb,div.nextthumb {
274
   margin-bottom: 1em;
275
}
276

  
277
div.nextthumb a,div.prevthumb a {
278
   text-decoration: none;
279
}
280

  
281
div#mqhq {
282
   margin: 2px 2px 4px 0px;
283
   height: 32px;
284
}
285

  
286
div#mqhq a {
287
   display: block;
288
   border: 1px solid #909090;
289
   padding: 2px;
290
   font-size: 10px;
291
   background-color: #f6f6f6;
292
   color: black;
293
   float: left;
294
   width: 48px;
295
   text-align: center;
296
   margin: 2px;
297
   -moz-border-radius: 2px; 
298
}
299

  
300
div#mqhq a:hover {
301
   background-color: #909090;
302
   border: 1px solid black;
303
   color: white;
304
}
305

  
306
div.stylenavbar {
307
   position: fixed;
308
	 bottom: 0px;
309
	 right: 0px;
310
   font-size: 9px; 
311
   padding: 4px;
312
	 opacity: 0.4;
313
}
314

  
315
div.stylenavbar ul {
316
	list-style-type: none;
317
	margin-left: 0px;
318
	padding-left: 0px;
319
	
320
}
321

  
322

  
323

  
324
/* Formatting of the user comments */
325
/* 
326
div.commententry {
327
    border: 1px dotted pink; 
328
} 
329
*/
330

  
331
#comment_block .comment_toggle {  
332
    font-size: smaller;
333
}
334

  
335
div.commentdata {
336
    margin-bottom: 10px;
337
} 
338

  
339
div.name {
340
    border-bottom: 1px dotted grey;
341
    font-size: 10pt;
342
    margin-bottom: 2px;
343
}
344

  
345
textarea, input {
346
   font-family: "Bitstream Vera Sans", sans-serif;
347
   font-size: 10pt;
348
    -moz-border-radius: 3px; 
349
}
www/inc/styles/classic/classic.css.net
1
/* Default stylesheet
2
   ==================
3

  
4
   stylesheet & artwork
5
   (c) 2003 Jakub 'jimmac' Steiner
6

  
7
*/
8

  
9
body {
10
   background-color: #f6f6f6;
11
   background: url("bcg.png") top left repeat;
12
   /*
13
   margin: 0px 50px 0px 50px;
14
   width: auto;
15
   */
16
   margin: auto;
17
   width: 770px;
18
   font-family: "Bitstream Vera Sans", sans-serif;
19
   font-size: 10pt;
20
}
21

  
22
img {
23
   border: 0px;
24
	 width: 120px;
25
	 height: 80px;
26
}
27

  
28
img#preview {
29
	width: inherit;
30
	height: inherit;
31
}
32

  
33
a.portrait img {
34
	width: 58px;
35
}
36

  
37
a:link {
38
   color: #909090;
39
}
40

  
41
a:visited {
42
   color: #808080;
43
}
44

  
45
a:hover {
46
   color: #f0f0f0;
47
   background-color: #707070;
48
}
49

  
50
a.hascomments {
51
	background-image: url('hascomments.png');
52
	background-position: bottom right;
53
	background-repeat: no-repeat;
54
}
55

  
56
.month p>a {
57
	display: block;
58
}
59

  
60
.author, .description, .date {
61
	display: block;
62
	padding: 2px 0px 1em 4px;
63
}
64

  
65
.date {
66
	color: #666;
67
}
68

  
69
.date:before {
70
	content: ">> ";
71
}
72

  
73
h1.title {
74
   background-color: #a7a9a6;
75
   font-size: 16pt;
76
   color: #808080;
77
   width: 100%;
78
   margin-bottom: 0px;
79
   padding: 5px;
80
   
81
}
82

  
83
.title a {
84
   display: block;
85
	position:relative;
86
	width:100%; 
87
   height:48px;
88
	margin:0; padding:0;
89
}
90

  
91
.title a:hover {
92
   border: 0px;
93
   background-color: #a7a9a6;
94
}
95

  
96
.title a span {
97
   /* this overlays text below with an image */
98
	display: block;
99
	position:absolute; left:0; top:0; z-index:1; 
100
	width:338px; height:48px;
101
   margin:0; padding:0;
102
	background-image: url("title.png");
103
   background-position: top left;
104
   background-repeat: no-repeat;
105
}
106

  
107
div.thumbroll {
108
   margin: 10px 0px 4px 0px;
109
   min-height: 29px;
110
}
111

  
112
p.bigthumbnails {
113
   text-align: center;
114
}
115

  
116
p.bigthumbnails a {
117
		display: block;
118
		float: left;
119
    padding: 0px 0px 18px 0px;
120
    margin: 4px;
121
    border: 0px;
122
}
123

  
124
p {
125
	clear: both;
126
}
127
/*
128
p.bigthumbnails a:link img {
129
   border: 1px solid white;
130
}
131

  
132
p.bigthumbnails a:hover img {
133
   border: 1px solid #909090;
134
   
135
}
136
*/
137

  
138
a#minus,a#plus {
139
   display: block;
140
	position: relative;
141
   float: left;
142
	width:24px; 
143
   height:24px;
144
	margin:0px; padding:0px;
145
}
146

  
147
a#minus {
148
   background: url("minus.png") top left no-repeat;
149
}
150

  
151
a#plus {
152
   background: url("plus.png") top left no-repeat;
153
}
154

  
155
a#zip {
156
   /* display: block; */
157
	position: relative;
158
	width:16px; 
159
   height:16px;
160
	margin:0px; padding:0px;
161
   font-size: 9px;
162
}
163

  
164
a#zip span {
165
   background: url("zip.png") top left no-repeat;
166
	position:absolute; left:0; top:0; z-index:1; 
167
	width:16px; height:16px;
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff

Redmine Appliance - Powered by TurnKey Linux