Subversion Repositories svnkaklik

Compare Revisions

Ignore whitespace Rev 5 → Rev 6

/web/test/gallery/cpg133/include/_vti_cnf/archive.php
0,0 → 1,14
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|19 Apr 2005 03:17:12 -0000
vti_extenderversion:SR|6.0.2.5516
vti_author:SR|KAKLIK\\Jakub
vti_modifiedby:SR|KAKLIK\\Jakub
vti_timecreated:TR|19 Apr 2005 03:17:12 -0000
vti_cacheddtm:TX|19 Apr 2005 03:17:12 -0000
vti_filesize:IR|25163
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|windows-1250
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/_vti_cnf/config.inc.php.sample
0,0 → 1,6
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|30 Jul 2004 08:25:44 -0000
vti_extenderversion:SR|6.0.2.5516
vti_cacheddtm:TX|30 Jul 2004 08:25:44 -0000
vti_filesize:IR|509
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/_vti_cnf/crop.inc.php
0,0 → 1,14
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|19 Apr 2005 03:17:12 -0000
vti_extenderversion:SR|6.0.2.5516
vti_author:SR|KAKLIK\\Jakub
vti_modifiedby:SR|KAKLIK\\Jakub
vti_timecreated:TR|19 Apr 2005 03:17:12 -0000
vti_cacheddtm:TX|19 Apr 2005 03:17:12 -0000
vti_filesize:IR|5680
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|windows-1250
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/_vti_cnf/exifReader.inc.php
0,0 → 1,14
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|19 Apr 2005 03:17:12 -0000
vti_extenderversion:SR|6.0.2.5516
vti_author:SR|KAKLIK\\Jakub
vti_modifiedby:SR|KAKLIK\\Jakub
vti_timecreated:TR|19 Apr 2005 03:17:12 -0000
vti_cacheddtm:TX|19 Apr 2005 03:17:12 -0000
vti_filesize:IR|64072
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|windows-1250
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/_vti_cnf/exif_php.inc.php
0,0 → 1,14
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|19 Apr 2005 03:17:12 -0000
vti_extenderversion:SR|6.0.2.5516
vti_author:SR|KAKLIK\\Jakub
vti_modifiedby:SR|KAKLIK\\Jakub
vti_timecreated:TR|19 Apr 2005 03:17:12 -0000
vti_cacheddtm:TX|19 Apr 2005 03:17:12 -0000
vti_filesize:IR|2965
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|windows-1250
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/_vti_cnf/functions.inc.php
0,0 → 1,14
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|19 Apr 2005 03:17:12 -0000
vti_extenderversion:SR|6.0.2.5516
vti_author:SR|KAKLIK\\Jakub
vti_modifiedby:SR|KAKLIK\\Jakub
vti_timecreated:TR|19 Apr 2005 03:17:12 -0000
vti_cacheddtm:TX|19 Apr 2005 03:17:12 -0000
vti_filesize:IR|80377
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|windows-1250
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/_vti_cnf/imageObjectGD.class.php
0,0 → 1,14
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|19 Apr 2005 03:17:12 -0000
vti_extenderversion:SR|6.0.2.5516
vti_author:SR|KAKLIK\\Jakub
vti_modifiedby:SR|KAKLIK\\Jakub
vti_timecreated:TR|19 Apr 2005 03:17:12 -0000
vti_cacheddtm:TX|19 Apr 2005 03:17:12 -0000
vti_filesize:IR|6218
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|windows-1250
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/_vti_cnf/imageObjectIM.class.php
0,0 → 1,14
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|19 Apr 2005 03:17:12 -0000
vti_extenderversion:SR|6.0.2.5516
vti_author:SR|KAKLIK\\Jakub
vti_modifiedby:SR|KAKLIK\\Jakub
vti_timecreated:TR|19 Apr 2005 03:17:12 -0000
vti_cacheddtm:TX|19 Apr 2005 03:17:12 -0000
vti_filesize:IR|7872
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|windows-1250
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/_vti_cnf/index.html
0,0 → 1,14
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|15 Oct 2003 12:24:14 -0000
vti_extenderversion:SR|6.0.2.5516
vti_author:SR|KAKLIK\\Jakub
vti_modifiedby:SR|KAKLIK\\Jakub
vti_timecreated:TR|15 Oct 2003 12:24:14 -0000
vti_cacheddtm:TX|15 Oct 2003 12:24:14 -0000
vti_filesize:IR|0
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|windows-1250
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/_vti_cnf/init.inc.php
0,0 → 1,14
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|19 Apr 2005 21:54:32 -0000
vti_extenderversion:SR|6.0.2.5516
vti_author:SR|KAKLIK\\Jakub
vti_modifiedby:SR|KAKLIK\\Jakub
vti_timecreated:TR|19 Apr 2005 21:54:32 -0000
vti_cacheddtm:TX|19 Apr 2005 21:54:32 -0000
vti_filesize:IR|18029
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|windows-1250
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/_vti_cnf/iptc.inc.php
0,0 → 1,14
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|19 Apr 2005 03:17:12 -0000
vti_extenderversion:SR|6.0.2.5516
vti_author:SR|KAKLIK\\Jakub
vti_modifiedby:SR|KAKLIK\\Jakub
vti_timecreated:TR|19 Apr 2005 03:17:12 -0000
vti_cacheddtm:TX|19 Apr 2005 03:17:12 -0000
vti_filesize:IR|4219
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|windows-1250
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/_vti_cnf/mailer.inc.php
0,0 → 1,14
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|19 Apr 2005 03:17:12 -0000
vti_extenderversion:SR|6.0.2.5516
vti_author:SR|KAKLIK\\Jakub
vti_modifiedby:SR|KAKLIK\\Jakub
vti_timecreated:TR|19 Apr 2005 03:17:12 -0000
vti_cacheddtm:TX|19 Apr 2005 03:17:12 -0000
vti_filesize:IR|9086
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|windows-1250
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/_vti_cnf/media.functions.inc.php
0,0 → 1,14
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|19 Apr 2005 03:17:12 -0000
vti_extenderversion:SR|6.0.2.5516
vti_author:SR|KAKLIK\\Jakub
vti_modifiedby:SR|KAKLIK\\Jakub
vti_timecreated:TR|19 Apr 2005 03:17:12 -0000
vti_cacheddtm:TX|19 Apr 2005 03:17:12 -0000
vti_filesize:IR|5102
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|windows-1250
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/_vti_cnf/picmgmt.inc.php
0,0 → 1,14
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|19 Apr 2005 03:17:12 -0000
vti_extenderversion:SR|6.0.2.5516
vti_author:SR|KAKLIK\\Jakub
vti_modifiedby:SR|KAKLIK\\Jakub
vti_timecreated:TR|19 Apr 2005 03:17:12 -0000
vti_cacheddtm:TX|19 Apr 2005 03:17:12 -0000
vti_filesize:IR|10669
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|windows-1250
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/_vti_cnf/search.inc.php
0,0 → 1,14
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|19 Apr 2005 03:17:12 -0000
vti_extenderversion:SR|6.0.2.5516
vti_author:SR|KAKLIK\\Jakub
vti_modifiedby:SR|KAKLIK\\Jakub
vti_timecreated:TR|19 Apr 2005 03:17:12 -0000
vti_cacheddtm:TX|19 Apr 2005 03:17:12 -0000
vti_filesize:IR|7518
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|windows-1250
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/_vti_cnf/select_lang.inc.php
0,0 → 1,14
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|19 Apr 2005 03:17:12 -0000
vti_extenderversion:SR|6.0.2.5516
vti_author:SR|KAKLIK\\Jakub
vti_modifiedby:SR|KAKLIK\\Jakub
vti_timecreated:TR|19 Apr 2005 03:17:12 -0000
vti_cacheddtm:TX|19 Apr 2005 03:17:12 -0000
vti_filesize:IR|6962
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|windows-1250
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/_vti_cnf/slideshow.inc.php
0,0 → 1,14
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|19 Apr 2005 03:17:12 -0000
vti_extenderversion:SR|6.0.2.5516
vti_author:SR|KAKLIK\\Jakub
vti_modifiedby:SR|KAKLIK\\Jakub
vti_timecreated:TR|19 Apr 2005 03:17:12 -0000
vti_cacheddtm:TX|19 Apr 2005 03:17:12 -0000
vti_filesize:IR|4369
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|windows-1250
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/_vti_cnf/smilies.inc.php
0,0 → 1,14
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|19 Apr 2005 03:17:12 -0000
vti_extenderversion:SR|6.0.2.5516
vti_author:SR|KAKLIK\\Jakub
vti_modifiedby:SR|KAKLIK\\Jakub
vti_timecreated:TR|19 Apr 2005 03:17:12 -0000
vti_cacheddtm:TX|19 Apr 2005 03:17:12 -0000
vti_filesize:IR|8208
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|windows-1250
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/_vti_cnf/sql_parse.php
0,0 → 1,14
vti_encoding:SR|utf8-nl
vti_timelastmodified:TR|19 Apr 2005 03:17:12 -0000
vti_extenderversion:SR|6.0.2.5516
vti_author:SR|KAKLIK\\Jakub
vti_modifiedby:SR|KAKLIK\\Jakub
vti_timecreated:TR|19 Apr 2005 03:17:12 -0000
vti_cacheddtm:TX|19 Apr 2005 03:17:12 -0000
vti_filesize:IR|6713
vti_cachedneedsrewrite:BR|false
vti_cachedhasbots:BR|false
vti_cachedhastheme:BR|false
vti_cachedhasborder:BR|false
vti_charset:SR|windows-1250
vti_backlinkinfo:VX|
/web/test/gallery/cpg133/include/archive.php
0,0 → 1,574
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2005 Coppermine Dev Team
v1.1 originaly written by Gregory DEMAR
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.3.3
$Source: /cvsroot/coppermine/stable/include/archive.php,v $
$Revision: 1.4 $
$Author: gaugau $
$Date: 2005/04/19 03:17:11 $
**********************************************/
 
/*--------------------------------------------------
| TAR/GZIP/ZIP ARCHIVE CLASSES
| By Devin Doucette
| Copyright (c) 2003 Devin Doucette
| Email: darksnoopy@shaw.ca
+--------------------------------------------------
| Email bugs/suggestions to darksnoopy@shaw.ca
+--------------------------------------------------
| This script has been created and released under
| the GNU GPL and is free to use and redistribute
| only if this copyright statement is not removed
+--------------------------------------------------*/
 
/*------------------------------------------------------------
| To create tar files:
| $example = new tarfile($cwd,$flags); // args optional
| -current working directory
| -flags (array):
| -overwrite - whether to overwrite existing files or return
| an error message
| -defaultperms - default file permissions (like chmod(),
| must include 0 in front of value [eg. 0777, 0644])
| -recursesd[1,0] - whether or not to include subdirs
| -storepath[1,0] - whether or not to store relative paths
| -replacestats[array] - values to replace those from files
| -mode - same as the result of a fileperms() call
| -uid/gid - user/group id
| -time - timestamp
| -type - file type (5=dir,1=link,0=file)
| -link - the file that is linked to
| -path - only supported in USTAR, not recommended
+------------------------------------------------------------*/
 
/*------------------------------------------------------------
| To create gzip files:
| $example = new gzfile($cwd,$flags); // args optional
| -current working directory
| -flags (array):
| -overwrite - whether to overwrite existing files or return
| an error message
| -defaultperms - default file permissions (like chmod(),
| must include 0 in front of value [eg. 0777, 0644])
+------------------------------------------------------------*/
 
/*------------------------------------------------------------
| To create zip files:
| $example = new zipfile($cwd,$flags); // args optional
| -current working directory
| -flags (array):
| -overwrite - whether to overwrite existing files or return
| an error message
| -defaultperms - default file permissions (like chmod(),
| must include 0 in front of value [eg. 0777, 0644])
| -time - timestamp to use to replace the mtime from files
| -recursesd[1,0] - whether or not to include subdirs
| -storepath[1,0] - whether or not to store relative paths
| -level[0-9] - compression level (0 = none, 9 = max)
| -comment - comment to add to the archive
+------------------------------------------------------------*/
 
/*------------------------------------------------------------
| To add files:
| $example->addfile($data,$filename,$flags);
| -data - file contents
| -filename - name of file to be put in archive
| -flags (all flags are optional)
| -flags (tar) [array]: -same flags as tarfile()
| -flags (gzip) [string]: -comment to add to archive
| -flags (zip) [array] -time - last modification time
|
| $example->addfiles($filelist); // tar and zip only
| -filelist - array of file names relative to CWD
|
| $example->adddirectories($dirlist); // tar and zip only
| -dirlist - array of directory names relative to CWD
+------------------------------------------------------------*/
 
/*------------------------------------------------------------
| To output files:
| $example->getdata();
| -returns file contents
|
| $example->filedownload($filename);
| -filename - the name to give the file that is being sent
|
| $example->filewrite($filename,$perms); // perms optional
| -filename - the name (including path) of the file to write
| -perms - permissions to give the file after it is written
+------------------------------------------------------------*/
 
/*------------------------------------------------------------
| To extract files (tar and gzip)
| $example->extract($data);
| -data - data to extract files from
| -returns an array containing file attributes and contents
|
| $example->extractfile($filename);
| -filename - the name (including path) of the file to use
| -returns an array containing file attributes and contents
|
| Both functions will return a string containing any errors
+------------------------------------------------------------*/
 
class tarfile extends archive {
var $cwd = "./";
var $tardata = "";
var $defaultflags = array(
'mode' => 0,
'uid' => 0,
'gid' => 0,
'time' => 0,
'type' => 0,
'link' => "",
'path' => "",
);
var $replacestats = array();
var $recursesd = 1;
var $storepath = 1;
 
function tarfile($cwd="./",$flags=array()) {
$this->cwd = $cwd;
$this->defaultflags['mode'] = decoct(0x8000 | 0x0100 | 0x0080 | 0x0020 | 0x0004);
$this->defaultflags['time'] = time();
if(isset($flags['recursesd']))
$this->recursesd = $flags['recursesd'];
if(isset($flags['storepath']))
$this->storepath = $flags['storepath'];
if(isset($flags['replacestats'])) {
if(is_array($flags['replacestats'])) {
if(isset($flags['replacestats']['mode']))
$this->replacestats['mode'] = $flags['replacestats']['mode'];
if(isset($flags['replacestats']['time']))
$this->replacestats['time'] = $flags['replacestats']['time'];
}
else if($flags['replacestats'] == 1) {
$this->replacestats['mode'] = $this->defaultflags['mode'];
$this->replacestats['time'] = $this->defaultflags['time'];
}
}
 
$this->archive($flags);
}
 
function addfile($data,$filename,$flags=array()) {
if(strlen($filename) > 99)
return $this->error("The file name $filename is too long to archive.");
 
$flags['mode'] = isset($this->replacestats['mode'])? $this->replacestats['mode'] : (isset($flags['mode'])? $flags['mode'] : $this->defaultflags['mode']);
$flags['uid'] = isset($flags['uid'])? $flags['uid'] : $this->defaultflags['uid'];
$flags['gid'] = isset($flags['gid'])? $flags['gid'] : $this->defaultflags['gid'];
$flags['time'] = isset($this->replacestats['time'])? $this->replacestats['time'] : (isset($flags['time'])? $flags['time'] : $this->defaultflags['time']);
$flags['type'] = isset($flags['type'])? $flags['type'] : $this->defaultflags['type'];
$flags['link'] = isset($flags['link'])? $flags['link'] : $this->defaultflags['link'];
$flags['path'] = isset($flags['path'])? $flags['path'] : $this->defaultflags['path'];
$flags['size'] = isset($flags['size'])? $flags['size'] : strlen($data);
 
if($this->storepath != 1) {
$filename = strstr($filename,"/")? substr($filename,strrpos($filename,"/")+1) : $filename;
$flags['path'] = "";
}
else
$filename = preg_replace("/^(\.{1,2}(\/|\\\))+/","",$filename);
 
$blockbeg = pack("a100a8a8a8a12a12",$filename,$flags['mode'],sprintf("%6s ",decoct($flags['uid'])),sprintf("%6s ",decoct($flags['gid'])),sprintf("%11s ",decoct($flags['size'])),sprintf("%11s ",decoct($flags['time'])));
$blockend = pack("a1a100a6a2a32a32a8a8a155",$flags['type'],$flags['link'],"ustar","00","Unknown","Unknown","","",$flags['path']);
 
$checksum = 0;
for($i = 0; $i < 148; $i++)
$checksum += ord(substr($blockbeg,$i,1));
for($i = 148; $i < 156; $i++)
$checksum += ord(" ");
for($i = 156; $i < 512; $i++)
$checksum += ord(substr($blockend,$i-156,1));
$checksum = pack("a8",sprintf("%6s ",decoct($checksum)));
 
if($flags['size'] % 512 > 0)
$data .= $this->nullpad(512 - $flags['size'] % 512);
 
$this->tardata .= $blockbeg . $checksum . $blockend . pack("a12","") . $data;
}
 
function addfiles($filelist) {
$pwd = getcwd();
@chdir($this->cwd);
 
foreach($filelist as $current) {
$file = array();
 
if($this->storepath != 1)
$file['name'] = strstr($current,"/")? substr($current,strrpos($current,"/")+1) : $current;
else
$file['name'] = preg_replace("/^(\.{1,2}(\/|\\\))+/","",$current);
 
$file['mode'] = @fileperms($current);
if($file['mode'] & 0x4000)
$file['type'] = 5; // Directory
else if($file['mode'] & 0x8000)
$file['type'] = 0; // Regular
else if($file['mode'] & 0xA000)
$file['type'] = 1; // Link
else
$file['type'] = 9; // Unknown
$file['mode'] = decoct($file['mode']);
 
if($file['type'] == 0 && !@file_exists($current))
return $this->error("$current does not exist");
else if(strlen($file['name']) > 99) {
$offset = strrpos($file['name'],"/") + 1;
$file['path'] = substr($file['name'],0,$offset);
$file['name'] = substr($file['name'],$offset);
if(strlen($file['name']) > 99 || strlen($file['path']) > 154)
return $this->error("The file name {$file['name']} is too long to archive.");
}
else
$file['path'] = "";
 
$stat = stat($current);
 
if(($file['type'] == 0 || $file['type'] == 1) && $fp = @fopen($current,"rb")) {
$data = fread($fp,$stat[7]);
fclose($fp);
}
else
$data = "";
 
$flags = array(
'mode' => $file['mode'],
'uid' => $stat[4],
'gid' => $stat[5],
'size' => $stat[7],
'time' => $stat[9],
'type' => $file['type'],
'link' => $file['type'] == 1? @readlink($current) : "",
'path' => $file['path'],
);
 
$this->addfile($data,$file['name'],$flags);
}
 
@chdir($pwd);
}
 
function extract($data) {
$return = array();
$blocks = strlen($data)/512 - 1;
$offset = 0;
 
while($offset < $blocks) {
$header = substr($data,512*$offset,512);
$current = unpack("a100filename/a8mode/a8uid/a8gid/a12size/a12mtime/a8checksum/a1type/a100linkname/a6magic/a2version/a32uname/a32gname/a8devmajor/a8devminor/a155path",$header);
foreach($current as $k => $v)
$current[$k] = trim($v);
$current['mode'] = octdec($current['mode']);
$current['uid'] = octdec($current['uid']);
$current['gid'] = octdec($current['gid']);
$current['size'] = octdec($current['size']);
$current['mtime'] = octdec($current['mtime']);
$current['checksum'] = octdec($current['checksum']);
$current['type'] = octdec($current['type']);
 
if($this->storepath != 1)
$current['filename'] = substr($current['filename'],strrpos($current['filename'],"/")+1);
 
$checksum = 0;
for($i = 0; $i < 148; $i++)
$checksum += ord(substr($header,$i,1));
for($i = 148; $i < 156; $i++)
$checksum += ord(" ");
for($i = 156; $i < 512; $i++)
$checksum += ord(substr($header,$i,1));
if($current['checksum'] != $checksum)
return $this->error("Checksum error.");
 
$size = ceil($current['size']/512);
$current['data'] = substr($data,512*(++$offset),$current['size']);
$offset += $size;
$return[] = $current;
}
 
return $return;
}
 
function getdata() {
return $this->tardata . pack("a512","");
}
 
function filedownload($filename) {
@header("Content-type: application/x-tar");
@header("Content-disposition: attachment; filename=$filename");
 
print($this->getdata());
}
 
function nullpad($bytes) {
$return = "";
for($i = 0; $i < $bytes; ++$i)
$return .= "\0";
return $return;
}
}
 
class gzfile extends archive {
var $gzdata = "";
 
function addfile($data,$filename=null,$comment=null) {
$flags = bindec("000".(!empty($comment)? "1" : "0").(!empty($filename)? "1" : "0")."000");
$this->gzdata .= pack("C1C1C1C1VC1C1",0x1f,0x8b,8,$flags,time(),2,0xFF);
 
if(!empty($filename))
$this->gzdata .= "$filename\0";
 
if(!empty($comment))
$this->gzdata .= "$comment\0";
 
$this->gzdata .= gzdeflate($data);
 
$this->gzdata .= pack("VV",crc32($data),strlen($data));
}
 
function extract($data) {
$id = unpack("H2id1/H2id2",substr($data,0,2));
if($id['id1'] != "1f" || $id['id2'] != "8b")
return $this->error("Not valid gzip data.");
 
$temp = unpack("Cflags",substr($data,2,1));
$temp = decbin($temp['flags']);
if($temp & 0x8)
$flags['name'] = 1;
if($temp & 0x4)
$flags['comment'] = 1;
 
$offset = 10;
 
$filename = "";
while(!empty($flags['name'])) {
$char = substr($data,$offset,1);
$offset++;
if($char == "\0")
break;
$filename .= $char;
}
if($filename == "")
$filename = "file";
 
$comment = "";
while(!empty($flags['comment'])) {
$char = substr($data,$offset,1);
$offset++;
if($char == "\0")
break;
$comment .= $char;
}
 
$temp = unpack("Vcrc32/Visize",substr($data,strlen($data)-8,8));
$crc32 = $temp['crc32'];
$isize = $temp['isize'];
 
$data = gzinflate(substr($data,$offset,strlen($data)-8-$offset));
 
if($crc32 != crc32($data))
return $this->error("Checksum error");
 
return array('filename'=>$filename,'comment'=>$comment,'size'=>$isize,'data'=>$data);
}
 
function getdata() {
return $this->gzdata;
}
 
function filedownload($filename) {
@header("Content-type: application/x-gzip");
@header("Content-disposition: attachment; filename=$filename");
 
print($this->getdata());
}
}
 
class zipfile extends archive {
var $cwd = "./";
var $comment = "";
var $level = 9;
var $offset = 0;
var $recursesd = 1;
var $storepath = 1;
var $replacetime = 0;
var $central = array();
var $zipdata = array();
 
function zipfile($cwd="./",$flags=array()) {
$this->cwd = $cwd;
if(isset($flags['time']))
$this->replacetime = $flags['time'];
if(isset($flags['recursesd']))
$this->recursesd = $flags['recursesd'];
if(isset($flags['storepath']))
$this->storepath = $flags['storepath'];
if(isset($flags['level']))
$this->level = $flags['level'];
if(isset($flags['comment']))
$this->comment = $flags['comment'];
 
$this->archive($flags);
}
 
function addfile($data,$filename,$flags=array()) {
if($this->storepath != 1)
$filename = strstr($filename,"/")? substr($filename,strrpos($filename,"/")+1) : $filename;
else
$filename = preg_replace("/^(\.{1,2}(\/|\\\))+/","",$filename);
 
$mtime = !empty($this->replacetime)? getdate($this->replacetime) : (isset($flags['time'])? getdate($flags['time']) : getdate());
$mtime = preg_replace("/(..){1}(..){1}(..){1}(..){1}/","\\x\\4\\x\\3\\x\\2\\x\\1",dechex(($mtime['year']-1980<<25)|($mtime['mon']<<21)|($mtime['mday']<<16)|($mtime['hours']<<11)|($mtime['minutes']<<5)|($mtime['seconds']>>1)));
eval('$mtime = "'.$mtime.'";');
 
$crc32 = crc32($data);
$normlength = strlen($data);
if(function_exists('gzcompress') ){
$data = gzcompress($data,$this->level);
}
$data = substr($data,2,strlen($data)-6);
$complength = strlen($data);
 
$this->zipdata[] = "\x50\x4b\x03\x04\x14\x00\x00\x00\x08\x00".$mtime.pack("VVVvv",$crc32,$complength,$normlength,strlen($filename),0x00).$filename.$data.pack("VVV",$crc32,$complength,$normlength);
$this->central[] = "\x50\x4b\x01\x02\x00\x00\x14\x00\x00\x00\x08\x00".$mtime.pack("VVVvvvvvVV",$crc32,$complength,$normlength,strlen($filename),0x00,0x00,0x00,0x00,0x0000,$this->offset).$filename;
 
$this->offset = strlen(implode("",$this->zipdata));
}
 
function addfiles($filelist) {
$pwd = getcwd();
@chdir($this->cwd);
 
foreach($filelist as $current) {
if(!@file_exists($current))
continue;
 
$stat = stat($current);
 
if($fp = @fopen($current,"rb")) {
$data = fread($fp,$stat[7]);
fclose($fp);
}
else
$data = "";
 
$flags = array('time'=>$stat[9]);
 
$this->addfile($data,$current,$flags);
}
 
@chdir($pwd);
}
 
function getdata() {
$central = implode("",$this->central);
$zipdata = implode("",$this->zipdata);
return $zipdata.$central."\x50\x4b\x05\x06\x00\x00\x00\x00".pack("vvVVv",sizeof($this->central),sizeof($this->central),strlen($central),strlen($zipdata),strlen($this->comment)).$this->comment;
}
 
function filedownload($filename) {
@header("Content-type: application/zip");
@header("Content-disposition: attachment; filename=$filename");
 
print($this->getdata());
}
}
 
class archive {
var $overwrite = 0;
var $defaultperms = 0644;
 
function archive($flags=array()) {
if(isset($flags['overwrite']))
$this->overwrite = $flags['overwrite'];
if(isset($flags['defaultperms']))
$this->defaultperms = $flags['defaultperms'];
}
 
function adddirectories($dirlist) {
$pwd = getcwd();
@chdir($this->cwd);
 
$filelist = array();
 
foreach($dirlist as $current) {
if(@is_dir($current)) {
$temp = $this->parsedirectories($current);
foreach($temp as $filename)
$filelist[] = $filename;
}
else if(@file_exists($current))
$filelist[] = $current;
}
 
@chdir($pwd);
$this->addfiles($filelist);
}
 
function parsedirectories($dirname) {
$filelist = array();
$dir = @opendir($dirname);
 
while($file = @readdir($dir)) {
if($file == "." || $file == "..")
continue;
else if(@is_dir($dirname."/".$file)) {
if($this->recursesd != 1)
continue;
$temp = $this->parsedirectories($dirname."/".$file);
foreach($temp as $file2)
$filelist[] = $file2;
}
else if(@file_exists($dirname."/".$file))
$filelist[] = $dirname."/".$file;
}
 
@closedir($dir);
 
return $filelist;
}
 
function filewrite($filename,$perms=null) {
if($this->overwrite != 1 && @file_exists($filename))
return $this->error("File $filename already exists.");
 
if(@file_exists($filename))
@unlink($filename);
 
$fp = @fopen($filename,"wb");
 
if(!fwrite($fp,$this->getdata()))
return $this->error("Could not write data to $filename.");
 
@fclose($fp);
 
if(!isset($perms))
$perms = $this->defaultperms;
 
@chmod($filename,$perms);
}
 
function extractfile($filename) {
if($fp = @fopen($filename,"rb")) {
return $this->extract(fread($fp,filesize($filename)));
@fclose($fp);
}
else
return $this->error("Could not open $filename.");
}
 
function error($error) {
$this->errors[] = $error;
return 0;
}
} ?>
/web/test/gallery/cpg133/include/config.inc.php.sample
0,0 → 1,13
<?php
// Coppermine configuration file
 
// MySQL configuration
$CONFIG['dbserver'] = 'localhost'; // Your databaseserver
$CONFIG['dbuser'] = 'root'; // Your mysql username
$CONFIG['dbpass'] = ''; // Your mysql password
$CONFIG['dbname'] = 'coppermine'; // Your mysql database name
 
 
// MySQL TABLE NAMES PREFIX
$CONFIG['TABLE_PREFIX'] = 'cpg132_';
?>
/web/test/gallery/cpg133/include/crop.inc.php
0,0 → 1,182
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2005 Coppermine Dev Team
v1.1 originaly written by Gregory DEMAR
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.3.3
$Source: /cvsroot/coppermine/stable/include/crop.inc.php,v $
$Revision: 1.5 $
$Author: gaugau $
$Date: 2005/04/19 03:17:11 $
**********************************************/
 
if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');
//////////////////// Variables //////////////////////////////
// used texts
$txt['bigger'] = ">";
$txt['smaller'] = "<";
$txt['up'] = "^";
$txt['down'] = "v";
$txt['closewindow'] = "Close window";
 
 
$result = db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} WHERE pid = '$pid'");
$CURRENT_PIC = mysql_fetch_array($result);
mysql_free_result($result);
$pic_url = get_pic_url($CURRENT_PIC,'fullsize');
 
 
 
echo <<<cropUIjs
<script language="JavaScript" src="dhtmlLib.js"></script>
<script language="JavaScript">
<!--
 
function libinit(){
obj=new lib_obj('cropDiv')
obj.dragdrop()
objImg =new lib_obj('imgDiv')
//alert (objImg.x + "-" + objImg.y);
obj.moveIt(objImg.x,objImg.y)
}
 
function cropCheck(crA){
//alert (obj.x + "-" + obj.y);
if (((obj.x + obj.cr) <= ({$CURRENT_PIC['pwidth']}+objImg.x))&&((obj.y + obj.cb) <= ({$CURRENT_PIC['pheight']}+objImg.y))&&(obj.x > objImg.x)&&(obj.y > objImg.y)){
cropX = obj.x - objImg.x;
cropY = obj.y - objImg.y;
var url = 'cropAction.php?pop=1&x='+cropX+'&y='+cropY+'&h='+obj.cb+'&w='+obj.cr+'&id={$pid}' ;
if (crA == 'pre'){
window.open(url,'prevWin','width='+obj.cr+',height='+obj.cb);
}else if(crA == 'final') {
url = url+'&final=1';
window.open(url,'prevWin','width='+obj.cr+',height='+(obj.cb));
}else if(crA == 'asThumb') {
 
thumb_use = "{$CONFIG['thumb_use']}"
thumb_width = {$CONFIG['thumb_width']}
 
if ( thumb_use== "ht") {
ratio = obj.cb / thumb_width ;
} else if (thumb_use == "wd") {
ratio = obj.cr / thumb_width ;
} else {
ratio = Math.max(obj.cb, obj.cr) / thumb_width ;
}
 
ratio = Math.max(ratio, 1.0);
destWidth = (obj.cr / ratio);
destHeight = (obj.cb / ratio);
 
url = url+'&asThumb=1';
window.open(url,'prevWin','width='+destWidth+',height='+destHeight);
}
} else {
alert('{$lang_editpics_php['sel_on_img']}');
}
}
 
 
function stopZoom() {
loop = false;
clearTimeout(zoomtimer);
}
 
function cropZoom(dir) {
loop = true;
zoomtimer = null;
direction = dir;
if (loop == true) {
if (direction == "in") {
if ((obj.cr > 60 )){
cW = obj.cr - 1;
cH = obj.cb ;
obj.clipTo(0,cW,cH,0,1);
}
} else if (direction == "out") {
if ((obj.cr < ({$CURRENT_PIC['pwidth']}-5))){
cW = obj.cr + 1;
cH = obj.cb ;
obj.clipTo(0,cW,cH,0,1);
}
} else if (direction == "down") {
if ((obj.cb < ({$CURRENT_PIC['pheight']}-5) )){
cW = obj.cr ;
cH = obj.cb + 1;
obj.clipTo(0,cW,cH,0,1);
}
} else if (direction == "up") {
if ((obj.cb > 60 )){
cW = obj.cr ;
cH = obj.cb - 1;
obj.clipTo(0,cW,cH,0,1);
}
}
zoomtimer = setTimeout("cropZoom(direction)", 10);
}
}
 
onload=libinit;
// -->
</script>
<style>
 
#cropDiv{
position:absolute;
left:10px;
top:10px;
width:60px;
height:60px;
z-index:2;
background-image: url(images/spacer.gif);
}
 
#imgDiv{
position:relative;
}
</style>
cropUIjs;
 
starttable("100%",$lang_editpics_php['crop_title'], 3);
echo <<<EOT
<tr><td>
<table cellspacing="0" cellpadding="5" border="0" align="center">
<tr><td>
<table cellspacing="0" cellpadding="5" border="0" align="center">
<tr><td align="center" valign="top"><div ID="imgDiv"><img src="$pic_url"></div></td></tr>
</table>
<table border="0">
<tr>
<td align="right">
<input type="button" name="Submit2" value="{$lang_editpics_php['save_thumb']}" onclick="cropCheck('asThumb');" class="button" />
<input type="button" name="Submit2" value="{$lang_editpics_php['save']}" onclick="cropCheck('final');" class="button" />
<input type="button" name="Submit2" value="{$lang_editpics_php['preview']}" onclick="cropCheck('pre');" class="button" />
<input type="button" name="Submit3" value="{$txt['smaller']}" onMouseDown="cropZoom('in');" onMouseUp="stopZoom();" class="button" />
<input type="button" name="Submit3" value="{$txt['up']}" onMouseDown="cropZoom('up');" onMouseUp="stopZoom();" class="button" />
<input type="button" name="Submit3" value="{$txt['down']}" onMouseDown="cropZoom('down');" onMouseUp="stopZoom();" class="button" />
<input type="button" name="Submit4" value="{$txt['bigger']}" onMouseDown="cropZoom('out');" onMouseUp="stopZoom();" class="button" />
</td>
</tr>
</form>
</table>
</td></tr>
</table>
</td></tr>
</table>
 
<div id="cropDiv">
<table width="100%" height="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
<tr>
<td><img src="images/spacer.gif"></td>
</tr>
</table>
</div>
EOT;
?>
/web/test/gallery/cpg133/include/exifReader.inc.php
0,0 → 1,1507
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2005 Coppermine Dev Team
v1.1 originaly written by Gregory DEMAR
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.3.3
$Source: /cvsroot/coppermine/stable/include/exifReader.inc.php,v $
$Revision: 1.4 $
$Author: gaugau $
$Date: 2005/04/19 03:17:11 $
**********************************************/
 
/**
* PHP Class to read EXIF information
* that most of the digital camera produce
*
* This class is based on jhead (in C) by Matthias Wandel
*
* Vinay Yadav (vinayRas) < vinay@sanisoft.com >
* http://www.sanisoft.com/phpexifrw/
*
* For more information on EXIF
* http://www.exif.org/
*
* Features:
* - Read Exif Information
* - Extract and display emdedded thumbnails
*
* Tested With
 
- Sony
- Cybershot (Sony)
- DSC-D700
- PowerShotA5
- SANYO Electric Co.,Ltd
- SR6
- SX113
- OLYMPUS OPTICAL CO.,LTD
- C960Z,D460Z
- Canon
PowerShot A40 (Canon)
Canon DIGITAL IXUS
- RICOH
- Caplio RR30
- RDC-5300
- NIKON
- D100 (NIKON CORPORATION)
- E5700 (NIKON)
- E950
- CASIO QV-8000SX
- KODAK
- DC290 Zoom Digital Camera (V01.00) [Eastman Kodak Company]
- DC210 Zoom (V05.00) [Eastman Kodak Company]
- KODAK DC240 ZOOM DIGITAL CAMERA
- FujiFilm
DX10
FinePix40i
MX-1700ZOOM
*
*
*/
 
/** * Start Of Frame N */
define("M_SOF0",0xC0);
/** * N indicates which compression process */
define("M_SOF1",0xC1);
/** * Only SOF0-SOF2 are now in common use */
define("M_SOF2",0xC2);
/** * */
define("M_SOF3",0xC3);
/** * NB: codes C4 and CC are NOT SOF markers */
define("M_SOF5",0xC5);
/** * */
define("M_SOF6",0xC6);
/** * */
define("M_SOF7",0xC7);
/** * */
define("M_SOF9",0xC9);
/** * */
define("M_SOF10",0xCA);
/** * */
define("M_SOF11",0xCB);
/** * */
define("M_SOF13",0xCD);
/** * */
define("M_SOF14",0xCE);
/** * */
define("M_SOF15",0xCF);
/** * Start Of Image (beginning of datastream) */
define("M_SOI",0xD8);
/** * End Of Image (end of datastream) */
define("M_EOI",0xD9);
/** * Start Of Scan (begins compressed data) */
define("M_SOS",0xDA);
/** * Jfif marker */
define("M_JFIF",0xE0);
/** * Exif marker */
define("M_EXIF",0xE1);
/** * Image Title -- */
define("M_COM",0xFE);
 
define("NUM_FORMATS","12");
 
/** * Tag Data Format */
define("FMT_BYTE","1");
/** * ASCII */
define("FMT_STRING","2");
/** * Short */
define("FMT_USHORT","3");
/** * Long */
define("FMT_ULONG","4");
/** * Rational */
define("FMT_URATIONAL","5");
/** * Byte */
define("FMT_SBYTE","6");
/** * Undefined */
define("FMT_UNDEFINED","7");
/** * Short */
define("FMT_SSHORT","8");
/** * Long */
define("FMT_SLONG","9");
/** * Rational */
define("FMT_SRATIONAL","10");
/** * Single */
define("FMT_SINGLE","11");
/** * Double */
define("FMT_DOUBLE","12");
 
/** * Exif IFD */
define("TAG_EXIF_OFFSET","0x8769");
/** * Interoperability tag */
define("TAG_INTEROP_OFFSET","0xa005");
/** * Image input equipment manufacturer */
define("TAG_MAKE","0x010F");
/** * Image input equipment model */
define("TAG_MODEL","0x0110");
/** * Orientation of image */
define("TAG_ORIENTATION","0x0112");
/** * Exposure Time */
define("TAG_EXPOSURETIME","0x829A");
/** * F Number */
define("TAG_FNUMBER","0x829D");
/** * Shutter Speed */
define("TAG_SHUTTERSPEED","0x9201");
/** * Aperture */
define("TAG_APERTURE","0x9202");
/** * Aperture */
define("TAG_MAXAPERTURE","0x9205");
/** * Lens Focal Length */
define("TAG_FOCALLENGTH","0x920A");
/** * The date and time when the original image data was generated. */
define("TAG_DATETIME_ORIGINAL","0x9003");
/** * User Comments */
define("TAG_USERCOMMENT","0x9286");
/** * subject Location */
define("TAG_SUBJECT_DISTANCE","0x9206");
/** * Flash */
define("TAG_FLASH","0x9209");
/** * Focal Plane X Resolution */
define("TAG_FOCALPLANEXRES","0xa20E");
/** * Focal Plane Resolution Units */
define("TAG_FOCALPLANEUNITS","0xa210");
/** * Image Width */
define("TAG_EXIF_IMAGEWIDTH","0xA002");
/** * Image Height */
define("TAG_EXIF_IMAGELENGTH","0xA003");
/** * Exposure Bias */
define("TAG_EXPOSURE_BIAS","0x9204");
/** * Light Source */
define("TAG_WHITEBALANCE","0x9208");
/** * Metering Mode */
define("TAG_METERING_MODE","0x9207");
/** * Exposure Program */
define("TAG_EXPOSURE_PROGRAM","0x8822");
/** * ISO Equivalent Speed Rating */
define("TAG_ISO_EQUIVALENT","0x8827");
/** * Compressed Bits Per Pixel */
define("TAG_COMPRESSION_LEVEL","0x9102");
/** * Thumbnail Start Offset */
define("TAG_THUMBNAIL_OFFSET","0x0201");
/** * Thumbnail Length */
define("TAG_THUMBNAIL_LENGTH","0x0202");
/** * Image Marker */
define("PSEUDO_IMAGE_MARKER",0x123);
/** * Max Image Title Length */
define("MAX_COMMENT",2000);
 
define("TAG_ARTIST","0x013B");
define("TAG_COPYRIGHT","0x8298");
 
//--------------------------------
 
define("TAG_IMAGE_WD","0x0100"); // image width
define("TAG_IMAGE_HT","0x0101"); // image height
define("TAG_IMAGE_BPS","0x0102"); // Bits Per sample
 
define("TAG_IMAGE_PHOTO_INT","0x0106"); // photometricinterpretation
define("TAG_IMAGE_SOFFSET","0x0111"); // stripoffsets
 
define("TAG_IMAGE_SPP","0x0115"); // Samples per pixel - 277
define("TAG_IMAGE_RPS","0x0116"); // RowsPerStrip - 278
define("TAG_IMAGE_SBC","0x0117"); // StripByteCounts - 279
 
define("TAG_IMAGE_P_CONFIG","0x011C"); // Planar Configuration - 284
 
define("TAG_IMAGE_DESC","0x010E"); // image title
define("TAG_X_RESOLUTION","0x011A"); // Image resolution in width direction
define("TAG_Y_RESOLUTION","0x011B"); // Image resolution in height direction
define("TAG_RESOLUTION_UNIT","0x0128"); // Unit of X and Y resolution
define("TAG_SOFTWARE","0x0131"); // Software used
define("TAG_FILE_MODDATE","0x0132"); // DateTime File change date and time
define("TAG_YCBCR_POSITIONING","0x0213"); // Y and C positioning
define("TAG_EXIF_VERSION","0x9000"); // Exif version
define("TAG_DATE_TIME_DIGITIZED","0x9004"); // Date and time of digital data
define("TAG_COMPONENT_CONFIG","0x9101"); // Component configuration
define("TAG_MAKER_NOTE","0x927C");
define("TAG_SUB_SEC_TIME","0x9290");
define("TAG_SUB_SEC_TIME_ORIG","0x9291");
define("TAG_SUB_SEC_TIME_DIGITIZED","0x9292");
define("TAG_FLASHPIX_VER","0xA000"); //FlashPixVersion
define("TAG_COLOR_SPACE","0xA001"); //ColorSpace
define("TAG_RELATED_SOUND_FILE","0xA004"); //Related audio file
 
define("TAG_GPS_LATITUDE_REF","0x0001"); //
define("TAG_GPS_LATITUDE","0x0002"); //
 
define("TAG_SENSING_METHOD","0xA217"); // SensingMethod
 
define("TAG_SOUCE_TYPE","0xA300"); // FileSource
define("TAG_SCENE_TYPE","0xA301"); // SceneType
 
define("TAG_CFA_PATTERN","0xA302"); // CFA Pattern
 
/** Tags in EXIF 2.2 Only */
define("TAG_COMPRESS_SCHEME","0x0103"); //
define("TAG_CUSTOM_RENDERED","0xA401"); // CustomRendered
define("TAG_EXPOSURE_MODE","0xA402"); // Exposure mode ExposureMode
define("TAG_WHITE_BALANCE","0xA403"); // White balance WhiteBalance
define("TAG_DIGITAL_ZOOM_RATIO","0xA404"); // Digital zoom ratio DigitalZoomRatio
define("TAG_FLENGTH_IN35MM","0xA405"); // Focal length in 35 mm film FocalLengthIn35mmFilm
define("TAG_SCREEN_CAP_TYPE","0xA406"); // Scene capture type SceneCaptureType
define("TAG_GAIN_CONTROL","0xA407"); //Gain control
define("TAG_CONTRAST","0xA408"); // Contrast
define("TAG_SATURATION","0xA409"); // Saturation
define("TAG_SHARPNESS","0xA40A"); // Sharpness
define("TAG_DEVICE_SETTING_DESC","0xA40B"); // SDevice settings description DeviceSettingDescription
define("TAG_DIST_RANGE","0xA40C"); //Subject distance range SubjectDistanceRange
 
define("TAG_FOCALPLANE_YRESOL","0xA20F");; //FocalPlaneYResolution
define("TAG_BRIGHTNESS","0x9203");; //Brightness
//--------------------------------
/** error Description */
/**
1 - File does not exists!
2 -
3 - Filename not provided
 
10 - too many padding bytes
11 - "invalid marker"
12 - Premature end of file?
 
 
51 - "Illegal subdirectory link"
52 - "NOT EXIF FORMAT"
53 - "Invalid Exif alignment marker.\n"
54 - "Invalid Exif start (1)"
 
*/
 
 
/**
* PHP Class to read, write and transfer EXIF information
* that most of the digital camera produces
* Currenty it can only read JPEG file.
*/
/**
* @author Vinay Yadav (vinayRas) < vinay@sanisoft.com >
*
* @todo Writing exif information to the file.
* @todo Add EXIF audio reading methods (I think it exists!)
* @todo Support of additional tags.
* @todo Handling Unicode character in UserComment tag of EXif Information.
*
* @version 0.5
* @licence http://opensource.org/licenses/lgpl-license.php GNU LGPL
*/
class phpExifReader {
 
/***
* Array containg all Exif and JPEG image attributes
* into regular expressions for themselves.
* $ImageInfo[TAG] = TAG_VALUE;
*
* @var array
* @access private
*
*/
var $ImageInfo = array();
 
var $MotorolaOrder = 0;
var $ExifImageWidth = 0; //
var $FocalplaneXRes = 0; //
var $FocalplaneUnits = 0; //
var $sections = array();
var $currSection = 0; /** Stores total number fo Sections */
 
var $BytesPerFormat = array(0,1,1,2,4,8,1,1,2,4,8,4,8);
 
var $ReadMode = array(
"READ_EXIF" => 1,
"READ_IMAGE" => 2,
"READ_ALL" => 3
);
 
var $ImageReadMode = 3; /** related to $RealMode arrays values */
var $file = ""; /** JPEG file to parse for EXIF data */
var $newFile = 1; /** flag to check if the current file has been parsed or not. */
 
var $thumbnail = ""; /* Name of thumbnail */
var $thumbnailURL = ""; /* */
 
var $exifSection = -1; // mark the exif section index out of all sections
 
var $errno = 0;
var $errstr = "";
 
var $debug = false;
 
// Caching ralated variables
var $caching = false; /* Should cacheing of image thumnails be allowed? */
var $cacheDir = ""; /* Checkout constructor for default path. */
 
/**
* Constructor
* @param string File name to be parsed.
*
*/
function phpExifReader($file = "") {
$this->timeStart = $this->cpgGetMicroTime();
if(!empty($file)) {
$this->file = $file;
}
 
/**
* Initialize some variables. Avoid lots of errors with fulll error_reporting
*/
$this->ExifImageLength = 0;
$this->ImageInfo['h']["resolutionUnit"] = 0;
 
$this->ImageInfo[TAG_MAXAPERTURE] = 0;
$this->ImageInfo[TAG_ISO_EQUIVALENT] = 0;
$this->ImageInfo[TAG_ORIENTATION] = 0;
 
$this->ThumbnailSize = 0;
 
if($this->caching) {
$this->cacheDir = dirname(__FILE__)."/.cache_thumbs";
 
/**
* If Cache directory does not exists then attempt to create it.
*/
if(!is_dir($this->cacheDir)) {
mkdir($this->cacheDir);
}
 
// Prepare the ame of thumbnail
if(is_dir($this->cacheDir)) {
$this->thumbnail = $this->cacheDir."/".basename($this->file);
$this->thumbnailURL = ".cache_thumbs/".basename($this->file);
}
}
 
/** check if file exists! */
if(!file_exists($this->file)) {
$this->errno = 1;
$this->errstr = "File '".$this->file."' does not exists!";
}
$this->currSection = 0;
 
$this->processFile();
}
 
/**
* Show Debugging information
*
* @param string Debugging message to display
* @param int Type of error (0 - Warning, 1 - Error)
* @return void
*
*/
function debug($str,$TYPE = 0,$file="",$line=0) {
if($this->debug) {
echo "<br>[$file:$line:".($this->getDiffTime())."]$str";
flush();
if($TYPE == 1) {
exit;
}
}
}
 
/**
* Processes the whole file.
*
*/
function processFile() {
/** dont reparse the whole file. */
if(!$this->newFile) return true;
 
if(!file_exists($this->file)) {
echo "<br>Error: File ".($this->file)."does not exists!";
exit;
}
 
$this->debug("Stating Processing of ".$this->newFile,0,__FILE__,__LINE__);
 
$i = 0; $exitAll = 0;
/** Open the JPEG in binary safe reading mode */
$fp = fopen($this->file,"rb");
 
$this->ImageInfo["h"]["FileName"] = $this->file;
$this->ImageInfo["h"]["FileSize"] = filesize($this->file); /** Size of the File */
$this->ImageInfo["h"]["FileDateTime"] = filectime($this->file); /** File node change time */
 
/** check whether jped image or not */
$a = fgetc($fp);
if (ord($a) != 0xff || ord(fgetc($fp)) != M_SOI){
$this->debug("Not a JPEG FILE",1);
$this->errorno = 1;
$this->errorstr = "File '".$this->file."' is not a JPEG File!";
}
$tmpTestLevel = 0;
/** Examines each byte one-by-one */
while(!feof($fp)) {
$data = array();
for ($a=0;$a<7;$a++){
$marker = fgetc($fp);
if (ord($marker) != 0xff) break;
if ($a >= 6){
$this->errno = 10;
$this->errstr = "too many padding bytes!";
$this->debug($this->errstr,1);
return false;
}
}
 
if (ord($marker) == 0xff){
// 0xff is legal padding, but if we get that many, something's wrong.
$this->errno = 10;
$this->errstr = "too many padding bytes!";
$this->debug($this->errstr,1);
}
 
$marker = ord($marker);
$this->sections[$this->currSection]["type"] = $marker;
 
// Read the length of the section.
$lh = ord(fgetc($fp));
$ll = ord(fgetc($fp));
 
$itemlen = ($lh << 8) | $ll;
 
if ($itemlen < 2){
$this->errno = 11;
$this->errstr = "invalid marker";
$this->debug($this->errstr,1);
}
$this->sections[$this->currSection]["size"] = $itemlen;
 
$tmpDataArr = array(); /** Temporary Array */
 
$tmpStr = fread($fp,$itemlen-2);
/*
$tmpDataArr[] = chr($lh);
$tmpDataArr[] = chr($ll);
 
$chars = preg_split('//', $tmpStr, -1, PREG_SPLIT_NO_EMPTY);
$tmpDataArr = array_merge($tmpDataArr,$chars);
 
$data = $tmpDataArr;
*/
$data = chr($lh).chr($ll).$tmpStr;
 
//$this->sections[$this->currSection]["data"] = $data;
 
$this->debug("<hr><h1>".$this->currSection.":</h1>");
//print_r($data);
$this->debug("<hr>");
 
//if(count($data) != $itemlen) {
if(strlen($data) != $itemlen) {
$this->errno = 12;
$this->errstr = "Premature end of file?";
$this->debug($this->errstr,1);
}
 
$this->currSection++; /** */
 
switch($marker) {
case M_SOS:
$this->debug("<br>Found '".M_SOS."' Section, Prcessing it... <br>");;
// If reading entire image is requested, read the rest of the data.
if ($this->ImageReadMode & $this->ReadMode["READ_IMAGE"]){
// Determine how much file is left.
$cp = ftell($fp);
fseek($fp,0, SEEK_END);
$ep = ftell($fp);
fseek($fp, $cp, SEEK_SET);
 
$size = $ep-$cp;
$got = fread($fp, $size);
 
$this->sections[$this->currSection]["data"] = $got;
$this->sections[$this->currSection]["size"] = $size;
$this->sections[$this->currSection]["type"] = PSEUDO_IMAGE_MARKER;
$this->currSection++;
$HaveAll = 1;
$exitAll =1;
}
$this->debug("<br>'".M_SOS."' Section, PROCESSED<br>");
break;
case M_COM: // Comment section
$this->debug("<br>Found '".M_COM."'(Comment) Section, Processing<br>");
$this->process_COM($data, $itemlen);
$this->debug("<br>'".M_COM."'(Comment) Section, PROCESSED<br>");
 
$tmpTestLevel++;
break;
case M_SOI:
$this->debug(" <br> === START OF IMAGE =====<br>");
break;
case M_EOI:
$this->debug(" <br>=== END OF IMAGE =====<br> ");
break;
case M_JFIF:
// Regular jpegs always have this tag, exif images have the exif
// marker instead, althogh ACDsee will write images with both markers.
// this program will re-create this marker on absence of exif marker.
// hence no need to keep the copy from the file.
//echo " <br> === M_JFIF =====<br>";
$this->sections[--$this->currSection]["data"] = "";
break;
case M_EXIF:
// Seen files from some 'U-lead' software with Vivitar scanner
// that uses marker 31 for non exif stuff. Thus make sure
// it says 'Exif' in the section before treating it as exif.
$this->debug("<br>Found '".M_EXIF."'(Exif) Section, Proccessing<br>");
$this->exifSection = $this->currSection-1;
if (($this->ImageReadMode & $this->ReadMode["READ_EXIF"]) && ($data[2].$data[3].$data[4].$data[5]) == "Exif"){
$this->process_EXIF($data, $itemlen);
}else{
// Discard this section.
$this->sections[--$this->currSection]["data"] = "";
}
$this->debug("<br>'".M_EXIF."'(Exif) Section, PROCESSED<br>");
$tmpTestLevel++;
break;
case M_SOF0:
case M_SOF1:
case M_SOF2:
case M_SOF3:
case M_SOF5:
case M_SOF6:
case M_SOF7:
case M_SOF9:
case M_SOF10:
case M_SOF11:
case M_SOF13:
case M_SOF14:
case M_SOF15:
$this->debug("<br>Found M_SOFn Section, Processing<br>");
$this->process_SOFn($data,$marker);
$this->debug("<br>M_SOFn Section, PROCESSED<br>");
break;
default:
$this->debug("DEFAULT: Jpeg section marker 0x$marker x size $itemlen\n");
}
$i++;
if($exitAll == 1) break;
//if($tmpTestLevel == 2) break;
}
fclose($fp);
$this->newFile = 0;
}
 
/**
* Changing / Assiging new file
* @param string JPEG file to process
*
*/
function assign($file) {
 
if(!empty($file)) {
$this->file = $file;
}
 
/** check for existance of file! */
if(!file_exists($this->file)) {
$this->errorno = 1;
$this->errorstr = "File '".$this->file."' does not exists!";
}
$this->newFile = 1;
}
 
/**
* Process SOFn section of Image
* @param array An array containing whole section.
* @param hex Marker to specify the type of section.
*
*/
function process_SOFn($data,$marker) {
$data_precision = 0;
$num_components = 0;
 
$data_precision = ord($data[2]);
 
if($this->debug) {
print("Image Dimension Calculation:");
print("((ord($data[3]) << 8) | ord($data[4]));");
}
$this->ImageInfo["h"]["Height"] = ((ord($data[3]) << 8) | ord($data[4]));
$this->ImageInfo["h"]["Width"] = ((ord($data[5]) << 8) | ord($data[6]));
 
$num_components = ord($data[7]);
 
if ($num_components == 3){
$this->ImageInfo["h"]["IsColor"] = 1;
}else{
$this->ImageInfo["h"]["IsColor"] = 0;
}
 
$this->ImageInfo["h"]["Process"] = $marker;
$this->debug("JPEG image is ".$this->ImageInfo["h"]["Width"]." * ".$this->ImageInfo["h"]["Height"].", $num_components color components, $data_precision bits per sample\n");
}
 
/**
* Process Comments
* @param array Section data
* @param int Length of the section
*
*/
function process_COM($data,$length) {
if ($length > MAX_COMMENT) $length = MAX_COMMENT;
/** Truncate if it won't fit in our structure. */
 
$nch = 0; $Comment = "";
for ($a=2;$a<$length;$a++){
$ch = $data[$a];
if ($ch == '\r' && $data[$a+1] == '\n') continue; // Remove cr followed by lf.
 
$Comment .= $ch;
}
//$this->ImageInfo[M_COM] = $Comment;
$this->ImageInfo["h"]["imageComment"] = $Comment;
$this->debug("COM marker comment: $Comment\n");
}
/**
* Process one of the nested EXIF directories.
* @param string All directory information
* @param string whole Section
* @param int Length of exif section
*
*/
function ProcessExifDir($DirStart, $OffsetBase, $ExifLength) {
 
$NumDirEntries = 0;
$ValuePtr = array();
 
$NumDirEntries = $this->Get16u($DirStart[0],$DirStart[1]);
 
 
$this->debug("<br>Directory with $NumDirEntries entries\n");
 
for ($de=0;$de<$NumDirEntries;$de++){
//$DirEntry = array_slice($DirStart,2+12*$de);
$DirEntry = substr($DirStart,2+12*$de);
 
$Tag = $this->Get16u($DirEntry[0],$DirEntry[1]);
$Format = $this->Get16u($DirEntry[2],$DirEntry[3]);
$Components = $this->Get32u($DirEntry[4],$DirEntry[5],$DirEntry[6],$DirEntry[7]);
 
/**
if ((Format-1) >= NUM_FORMATS) {
// (-1) catches illegal zero case as unsigned underflows to positive large.
ErrNonfatal("Illegal number format %d for tag %04x", Format, Tag);
continue;
}
*/
 
$ByteCount = $Components * $this->BytesPerFormat[$Format];
 
if ($ByteCount > 4){
$OffsetVal = $this->Get32u($DirEntry[8],$DirEntry[9],$DirEntry[10],$DirEntry[11]);
if ($OffsetVal+$ByteCount > $ExifLength){
$this->debug("Illegal value pointer($OffsetVal) for tag $Tag",1);
}
//$ValuePtr = array_slice($OffsetBase,$OffsetVal);
$ValuePtr = substr($OffsetBase,$OffsetVal);
} else {
//$ValuePtr = array_slice($DirEntry,8);
$ValuePtr = substr($DirEntry,8);
}
 
switch($Tag){
 
case TAG_MAKE:
$this->ImageInfo["h"]["make"] = substr($ValuePtr,0,$ByteCount);
break;
 
case TAG_MODEL:
$this->ImageInfo["h"]["model"] = substr($ValuePtr,0,$ByteCount);
break;
 
case TAG_DATETIME_ORIGINAL:
$this->ImageInfo[TAG_DATETIME_ORIGINAL] = substr($ValuePtr,0,$ByteCount);
$this->ImageInfo["h"]["DateTime"] = substr($ValuePtr,0,$ByteCount);
break;
 
case TAG_USERCOMMENT:
// Olympus has this padded with trailing spaces. Remove these first.
for ($a=$ByteCount;;){
$a--;
if ($ValuePtr[$a] == ' '){
//$ValuePtr[$a] = '\0';
} else {
break;
}
if ($a == 0) break;
}
 
// Copy the comment
if (($ValuePtr[0].$ValuePtr[1].$ValuePtr[2].$ValuePtr[3].$ValuePtr[4]) == "ASCII"){
for ($a=5;$a<10;$a++){
$c = $ValuePtr[$a];
if ($c != '\0' && $c != ' '){
$tmp = substr($ValuePtr,0,$ByteCount);
break;
}
}
} else if (($ValuePtr[0].$ValuePtr[1].$ValuePtr[2].$ValuePtr[3].$ValuePtr[4].$ValuePtr[5].$ValuePtr[6]) == "Unicode"){
$tmp = substr($ValuePtr,0,$ByteCount);
// * Handle Unicode characters here...
} else {
//$this->ImageInfo[TAG_USERCOMMENT] = implode("",array_slice($ValuePtr,0,$ByteCount));
$tmp = substr($ValuePtr,0,$ByteCount);
}
$this->ImageInfo['h']["exifComment"] = $tmp;
break;
 
case TAG_ARTIST:
$this->ImageInfo['h']["artist"] = substr($ValuePtr,0,$ByteCount);
break;
 
case TAG_COPYRIGHT:
$this->ImageInfo['h']["copyright"] = htmlentities(substr($ValuePtr,0,$ByteCount));
break;
 
case TAG_FNUMBER:
// Simplest way of expressing aperture, so I trust it the most.
// (overwrite previously computd value if there is one)
$tmp = $this->ConvertAnyFormat(substr($ValuePtr,0), $Format);
$this->ImageInfo['h']["fnumber"] = sprintf("f/%3.1f",(double)$tmp[0]);
break;
 
case TAG_APERTURE:
case TAG_MAXAPERTURE:
// More relevant info always comes earlier, so only use this field if we don't
// have appropriate aperture information yet.
if (!isset($this->ImageInfo['h']["aperture"])){
$tmpArr = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["aperture"] = exp($tmpArr[0]*log(2)*0.5);
}
break;
 
case TAG_FOCALLENGTH:
// Nice digital cameras actually save the focal length as a function
// of how farthey are zoomed in.
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["focalLength"] = sprintf("%4.2f (%d/%d)",(double)$tmp[0],$tmp[1][0],$tmp[1][1]);
if (isset($this->ImageInfo['h']["CCDWidth"])){
$this->ImageInfo['h']["focalLength"] .= sprintf("(35mm equivalent: %dmm)",(int)($tmp[0]/$this->ImageInfo['h']["CCDWidth"]*36 + 0.5));
}
break;
 
case TAG_SUBJECT_DISTANCE:
// Inidcates the distacne the autofocus camera is focused to.
// Tends to be less accurate as distance increases.
//$this->ImageInfo["h"]["Distance"] = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["Distance"] = sprintf("%4.2f (%d/%d)",(double)$tmp[0],$tmp[1][0],$tmp[1][1]);
if ($this->ImageInfo['h']["Distance"] < 0){
$this->ImageInfo['h']["focusDistance"] = "Infinite";
} else {
$this->ImageInfo['h']["focusDistance"] = sprintf("%4.2fm",(double)$this->ImageInfo['h']["Distance"]);
}
 
 
break;
 
case TAG_EXPOSURETIME:
// Simplest way of expressing exposure time, so I trust it most.
// (overwrite previously computd value if there is one)
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["exposureTime"] = sprintf("%6.3f s (%d/%d)",(double)$tmp[0],$tmp[1][0],$tmp[1][1]);
if ($tmp[0] <= 0.5 && $tmp[1][0] != 1){
$this->ImageInfo['h']["exposureTime"] .= sprintf(" (1/%d)",(int)(0.5 + 1/$tmp[0]));
}
break;
 
case TAG_SHUTTERSPEED:
// More complicated way of expressing exposure time, so only use
// this value if we don't already have it from somewhere else.
if ($this->ImageInfo[TAG_EXPOSURETIME] == 0){
$sp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo[TAG_SHUTTERSPEED] = (1/exp($sp[0]*log(2)));
}
break;
 
case TAG_FLASH:
$this->ImageInfo["h"]["flashUsed"] = "No";
if ($this->ConvertAnyFormat($ValuePtr, $Format) & 7){
$this->ImageInfo["h"]["flashUsed"] = "Yes";
}
break;
 
case TAG_ORIENTATION:
$this->ImageInfo[TAG_ORIENTATION] = $this->ConvertAnyFormat($ValuePtr, $Format);
if ($this->ImageInfo[TAG_ORIENTATION] < 1 || $this->ImageInfo[TAG_ORIENTATION] > 8){
$this->debug(sprintf("Undefined rotation value %d", $this->ImageInfo[TAG_ORIENTATION], 0),1);
$this->ImageInfo[TAG_ORIENTATION] = 0;
}
break;
 
case TAG_EXIF_IMAGELENGTH:
// * Image height
$a = (int) $this->ConvertAnyFormat($ValuePtr, $Format);
if ($this->ExifImageLength < $a) $this->ExifImageLength = $a;
$this->ImageInfo[TAG_EXIF_IMAGELENGTH] = $this->ExifImageLength;
$this->ImageInfo["h"]["Height"] = $this->ExifImageLength;
break;
case TAG_EXIF_IMAGEWIDTH:
// Use largest of height and width to deal with images that have been
// rotated to portrait format.
$a = (int) $this->ConvertAnyFormat($ValuePtr, $Format);
if ($this->ExifImageWidth < $a) $this->ExifImageWidth = $a;
$this->ImageInfo[TAG_EXIF_IMAGEWIDTH] = $this->ExifImageWidth;
$this->ImageInfo["h"]["Width"] = $this->ExifImageWidth;
 
break;
 
case TAG_FOCALPLANEXRES:
$this->FocalplaneXRes = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->FocalplaneXRes = $this->FocalplaneXRes[0];
$this->ImageInfo[TAG_FOCALPLANEXRES] = $this->FocalplaneXRes[0];
break;
 
case TAG_FOCALPLANEUNITS:
switch($this->ConvertAnyFormat($ValuePtr, $Format)){
case 1: $this->FocalplaneUnits = 25.4; break; // inch
case 2:
// According to the information I was using, 2 means meters.
// But looking at the Cannon powershot's files, inches is the only
// sensible value.
$this->FocalplaneUnits = 25.4;
break;
 
case 3: $this->FocalplaneUnits = 10; break; // centimeter
case 4: $this->FocalplaneUnits = 1; break; // milimeter
case 5: $this->FocalplaneUnits = .001; break; // micrometer
}
$this->ImageInfo[TAG_FOCALPLANEUNITS] = $this->FocalplaneUnits;
break;
 
// Remaining cases contributed by: Volker C. Schoech (schoech@gmx.de)
 
case TAG_EXPOSURE_BIAS:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["exposureBias"] = sprintf("%4.2f (%d/%d)",(double)$tmp[0],$tmp[1][0],$tmp[1][1]);
break;
 
case TAG_WHITEBALANCE:
$tmp = (int) $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("1"=>"Sunny","2"=>"fluorescent","3"=>"incandescent");
$this->ImageInfo['h']["whiteBalance"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Cloudy");
break;
 
case TAG_METERING_MODE:
$tmp = (int) $this->ConvertAnyFormat($ValuePtr, $Format);
 
$tmpArr = array("2"=>"center weight","3"=>"spot","5"=>"matrix");
$this->ImageInfo['h']["meteringMode"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
 
case TAG_EXPOSURE_PROGRAM:
$tmp = (int) $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("2"=>"program (auto)","3"=>"aperture priority (semi-auto)","4"=>"shutter priority (semi-auto)");
$this->ImageInfo['h']["exposure"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
 
break;
 
case TAG_ISO_EQUIVALENT:
$tmp = (int) $this->ConvertAnyFormat($ValuePtr, $Format);
if ( $tmp < 50 ) $tmp *= 200;
$this->ImageInfo['h']["isoEquiv"] = sprintf("%2d",(int)$tmp);
break;
 
case TAG_COMPRESSION_LEVEL:
$tmp = (int) $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("1"=>"Basic","2"=>"Normal","4"=>"Fine");
$this->ImageInfo['h']["jpegQuality"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
 
case TAG_THUMBNAIL_OFFSET:
$this->ThumbnailOffset = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->DirWithThumbnailPtrs = $DirStart;
break;
 
case TAG_THUMBNAIL_LENGTH:
$this->ThumbnailSize = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo[TAG_THUMBNAIL_LENGTH] = $this->ThumbnailSize;
break;
 
//----------------------------------------------
case TAG_IMAGE_DESC:
$this->ImageInfo['h']["imageDesc"] = substr($ValuePtr,0,$ByteCount);
break;
case TAG_X_RESOLUTION:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["xResolution"] = sprintf("%4.2f (%d/%d) %s",(double)$tmp[0],$tmp[1][0],$tmp[1][1],$this->ImageInfo['h']["resolutionUnit"]);
break;
case TAG_Y_RESOLUTION:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["yResolution"] = sprintf("%4.2f (%d/%d) %s",(double)$tmp[0],$tmp[1][0],$tmp[1][1],$this->ImageInfo['h']["resolutionUnit"]);
break;
case TAG_RESOLUTION_UNIT:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("2"=>"Inches","3"=>"Centimeters");
 
$this->ImageInfo['h']["resolutionUnit"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_SOFTWARE:
$this->ImageInfo['h']["software"] = substr($ValuePtr,0,$ByteCount);
break;
case TAG_FILE_MODDATE;
$this->ImageInfo['h']["fileModifiedDate"] = substr($ValuePtr,0,$ByteCount);
break;
case TAG_YCBCR_POSITIONING:
$this->ImageInfo['h']["YCbCrPositioning"] = $this->ConvertAnyFormat($ValuePtr, $Format);
break;
case TAG_EXIF_VERSION:
$this->ImageInfo['h']["exifVersion"] = substr($ValuePtr,0,$ByteCount);
break;
case TAG_DATE_TIME_DIGITIZED:
$this->ImageInfo['h']["dateTimeDigitized"] = substr($ValuePtr,0,$ByteCount);
break;
case TAG_COMPONENT_CONFIG: // need more tests for this
$tmp = (int)$this->ConvertAnyFormat($ValuePtr, $Format);
 
$tmpArr = array("0"=>"Does Not Exists","1"=>"Y","2"=>"Cb","3"=>"Cr","4"=>"R","5"=>"G","6"=>"B");
 
if(strlen($tmp) < 4 ) {
$this->ImageInfo['h']["componentConfig"] = $tmpArr["0"];
} else {
for($i=0;$i<strlen($tmp);$i++) {
if($tmp["$i"] != 0) {
$this->ImageInfo['h']["componentConfig"] .= $tmpArr[$tmp["$i"]];
}
}
}
break;
case TAG_MAKER_NOTE:
//$this->ImageInfo['h']["makerNote"] = substr($ValuePtr,0,$ByteCount);
$this->ImageInfo['h']["makerNote"] = "NOT IMPLEMENTED";
break;
case TAG_SUB_SEC_TIME:
$this->ImageInfo['h']["subSectionTime"] = substr($ValuePtr,0,$ByteCount);
break;
case TAG_SUB_SEC_TIME_ORIG:
$this->ImageInfo['h']["subSectionTimeOriginal"] = substr($ValuePtr,0,$ByteCount);
break;
case TAG_SUB_SEC_TIME_DIGITIZED:
$this->ImageInfo['h']["subSectionTimeDigtized"] = substr($ValuePtr,0,$ByteCount);
break;
case TAG_FLASHPIX_VER:
$this->ImageInfo['h']["flashpixVersion"] = substr($ValuePtr,0,$ByteCount);
break;
case TAG_COLOR_SPACE:
$this->ImageInfo['h']["colorSpace"] = substr($ValuePtr,0,$ByteCount);
break;
case TAG_RELATED_SOUND_FILE:
$this->ImageInfo['h']["relatedSoundFile"] = substr($ValuePtr,0,$ByteCount);
break;
case TAG_GPS_LATITUDE_REF:
$this->ImageInfo['h']["GPSLatitudeRef"] = substr($ValuePtr,0,$ByteCount);
break;
case TAG_GPS_LATITUDE:
$this->ImageInfo['h']["GPSLatitude"] = substr($ValuePtr,0,$ByteCount);
break;
case TAG_SENSING_METHOD:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("1"=>"Not Defined","2"=>"One-chip color area sensor","3"=>"Two-chip color area sensor",
"4"=>"Three -chip color area sensor","5"=>"Color sequential area sensor",
"6"=>"Trilinear sensor", "7"=>"Color sequential linear sensor"
);
 
$this->ImageInfo['h']["sensing"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_SOUCE_TYPE:
$this->ImageInfo['h']["sourceType"] = substr($ValuePtr,0,$ByteCount);
break;
case TAG_SCENE_TYPE:
$this->ImageInfo['h']["sceneType"] = substr($ValuePtr,0,$ByteCount);
break;
case TAG_CFA_PATTERN:
$this->ImageInfo['h']["CFAPattern"] = substr($ValuePtr,0,$ByteCount);
break;
case TAG_CUSTOM_RENDERED:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["customRendered"] = ($mp == 0) ? 'Normal Process' : ($mp == 1 ? 'Custom Process' : 'Reserved');
break;
case TAG_EXPOSURE_MODE:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array('Auto Exposure','Manual Exposure','Auto Bracket');
$this->ImageInfo['h']["exposureMode"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_WHITE_BALANCE:
$this->ImageInfo['h']["whiteBalance"] = $this->ConvertAnyFormat($ValuePtr, $Format);
break;
case TAG_DIGITAL_ZOOM_RATIO:
$tmp = $this->ImageInfo['h']["zoomRatio"] = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["zoomRatio"] = sprintf("%4.2f (%d/%d)",(double)$tmp[0],$tmp[1][0],$tmp[1][1]);
break;
case TAG_FLENGTH_IN35MM:
$this->ImageInfo['h']["flength35mm"] = $this->ConvertAnyFormat($ValuePtr, $Format);
break;
case TAG_SCREEN_CAP_TYPE:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("Standard","Landscape","Portrait","Night Scene");
$this->ImageInfo['h']["screenCaptureType"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_GAIN_CONTROL:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("None","Low Gain Up","High Gain Up","Low Gain Down","High Gain Down");
$this->ImageInfo['h']["gainControl"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_CONTRAST:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("Normal","Soft","Hard");
$this->ImageInfo['h']["contrast"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_SATURATION:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("Normal","Low Saturation","High Saturation");
$this->ImageInfo['h']["saturation"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_SHARPNESS:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("Normal","Soft","Hard");
$this->ImageInfo['h']["sharpness"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_DIST_RANGE:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("Unknown","Macro","Close View","Distant View");
$this->ImageInfo['h']["distanceRange"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_DEVICE_SETTING_DESC:
/*
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("Unknown","Macro","Close View","Distant View");
$this->ImageInfo['h']["distanceRange"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
*/
$this->ImageInfo['h']["deviceSettingDesc"] = "NOT IMPLEMENTED";
break;
case TAG_COMPRESS_SCHEME:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("1"=>"Uncompressed","6"=>"JPEG compression (thumbnails only)");
$this->ImageInfo['h']["compressScheme"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_IMAGE_WD:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegImageWidth"] = $tmp;
break;
case TAG_IMAGE_HT:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegImageHeight"] = $tmp;
break;
case TAG_IMAGE_BPS:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegBitsPerSample"] = $tmp;
break;
case TAG_IMAGE_PHOTO_INT:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegPhotometricInt"] = $tmp;
$tmpArr = array("2"=>"RGB","6"=>"YCbCr");
$this->ImageInfo['h']["jpegPhotometricInt"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
 
break;
case TAG_IMAGE_SOFFSET:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegStripOffsets"] = $tmp;
break;
case TAG_IMAGE_SPP:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegSamplesPerPixel"] = $tmp;
break;
case TAG_IMAGE_RPS:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegRowsPerStrip"] = $tmp;
break;
case TAG_IMAGE_SBC:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["jpegStripByteCounts"] = $tmp;
break;
case TAG_IMAGE_P_CONFIG:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$tmpArr = array("1"=>"Chunky Format","2"=>"Planar Format");
$this->ImageInfo['h']["jpegPlanarConfig"] =
(isset($tmpArr["$tmp"]) ? $tmpArr["$tmp"] : "Reserved");
break;
case TAG_FOCALPLANE_YRESOL:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["focalPlaneYResolution"] = sprintf("%4.2f (%d/%d)",(double)$tmp[0],$tmp[1][0],$tmp[1][1]);
break;
case TAG_BRIGHTNESS:
$tmp = $this->ConvertAnyFormat($ValuePtr, $Format);
$this->ImageInfo['h']["brightness"] = sprintf("%4.2f (%d/%d)",(double)$tmp[0],$tmp[1][0],$tmp[1][1]);
break;
//---------------------------------------------
case TAG_EXIF_OFFSET:
case TAG_INTEROP_OFFSET:
{
 
$SubdirStart = substr($OffsetBase,$this->Get32u($ValuePtr[0],$ValuePtr[1],$ValuePtr[2],$ValuePtr[3]));
//if ($SubdirStart < $OffsetBase || $SubdirStart > $OffsetBase+$ExifLength){
// debug("Illegal exif or interop ofset directory link",1);
//}else{
//echo "<h1>Calling sub-exif dir</h1>";
$this->ProcessExifDir($SubdirStart, $OffsetBase, $ExifLength);
//}
continue;
}
default: {
$this->debug("UNKNOWN TAG: $Tag");
}
}
}
 
{
// In addition to linking to subdirectories via exif tags,
// there's also a potential link to another directory at the end of each
// directory. this has got to be the result of a comitee!
$tmpDirStart = substr($DirStart,2+12*$NumDirEntries);
if (strlen($tmpDirStart) + 4 <= strlen($OffsetBase)+$ExifLength){
$Offset = $this->Get32u($tmpDirStart[0],$tmpDirStart[1],$tmpDirStart[2],$tmpDirStart[3]);
if ($Offset){
$SubdirStart = substr($OffsetBase,$Offset);
if (strlen($SubdirStart) > strlen($OffsetBase)+$ExifLength){
if (strlen($SubdirStart) < strlen($OffsetBase)+$ExifLength+20){
// Jhead 1.3 or earlier would crop the whole directory!
// As Jhead produces this form of format incorrectness,
// I'll just let it pass silently
} else {
$this->errno = 51;
$this->errstr = "Illegal subdirectory link";
$this->debug($this->errstr,1);
}
}else{
if (strlen($SubdirStart) <= strlen($OffsetBase)+$ExifLength){
$this->ProcessExifDir($SubdirStart, $OffsetBase, $ExifLength);
}
}
}
} else {
// The exif header ends before the last next directory pointer.
}
}
 
/**
* Check if thumbnail has been cached or not.
* If yes! then read the file.
*/
if(file_exists($this->thumbnail) && $this->caching && (filemtime($this->thumbnail) == filemtime($this->file) )) {
$this->ImageInfo["h"]["Thumbnail"] = $this->thumbnail;
$this->ImageInfo["h"]["ThumbnailSize"] = sprintf("%d bytes",filesize($this->thumbnail));
} else{
if ($this->ThumbnailSize && $this->ThumbnailOffset){
if ($this->ThumbnailSize + $this->ThumbnailOffset <= $ExifLength){
// The thumbnail pointer appears to be valid. Store it.
$this->ImageInfo["h"]["Thumbnail"] = substr($OffsetBase,$this->ThumbnailOffset);
 
// Save the thumbnail /
if($this->caching && is_dir($this->cacheDir)) {
$this->saveThumbnail($this->thumbnail);
$this->ImageInfo["h"]["Thumbnail"] = $this->thumbnail;
}
$this->ImageInfo["h"]["ThumbnailSize"] = sprintf("%d bytes",strlen($this->ImageInfo["h"]["Thumbnail"]));
}
}
}
}
 
/**
* Process Exif data
* @param array Section data as an array
* @param int Length of the section (length of data array)
*
*/
function process_EXIF($data,$length) {
 
$this->debug("Exif header $length bytes long\n");
if(($data[2].$data[3].$data[4].$data[5]) != "Exif") {
$this->errno = 52;
$this->errstr = "NOT EXIF FORMAT";
$this->debug($this->errstr,1);
}
 
$this->ImageInfo["h"]["FlashUsed"] = 0;
/** If it s from a digicam, and it used flash, it says so. */
 
$this->FocalplaneXRes = 0;
$this->FocalplaneUnits = 0;
$this->ExifImageWidth = 0;
 
if(($data[8].$data[9]) == "II") {
$this->debug("Exif section in Intel order\n");
$this->MotorolaOrder = 0;
} else if(($data[8].$data[9]) == "MM") {
$this->debug("Exif section in Motorola order\n");
$this->MotorolaOrder = 1;
} else {
$this->errno = 53;
$this->errstr = "Invalid Exif alignment marker.\n";
$this->debug($this->errstr,1);
return;
}
 
if($this->Get16u($data[10],$data[11]) != 0x2A || $this->Get32s($data[12],$data[13],$data[14],$data[15]) != 0x08) {
$this->errno = 54;
$this->errstr = "Invalid Exif start (1)";
$this->debug($this->errstr,1);
}
 
$DirWithThumbnailPtrs = NULL;
 
//$this->ProcessExifDir(array_slice($data,16),array_slice($data,8),$length);
$this->ProcessExifDir(substr($data,16),substr($data,8),$length);
 
// Compute the CCD width, in milimeters. 2
if ($this->FocalplaneXRes != 0){
$this->ImageInfo["h"]["CCDWidth"] = sprintf("%4.2fmm",(float)($this->ExifImageWidth * $this->FocalplaneUnits / $this->FocalplaneXRes));
}
 
$this->debug("Non settings part of Exif header: ".$length." bytes\n");
} // end of function process_EXIF
 
/**
* Converts two byte number into its equivalent int integer
* @param int
* @param int
*
*/
function Get16u($val,$by) {
if($this->MotorolaOrder){
return ((ord($val) << 8) | ord($by));
} else {
return ((ord($by) << 8) | ord($val));
}
}
 
/**
* Converts 4-byte number into its equivalent integer
*
* @param int
* @param int
* @param int
* @param int
*
* @return int
*/
function Get32s($val1,$val2,$val3,$val4)
{
$val1 = ord($val1);
$val2 = ord($val2);
$val3 = ord($val3);
$val4 = ord($val4);
 
if ($this->MotorolaOrder){
return (($val1 << 24) | ($val2 << 16) | ($val3 << 8 ) | ($val4 << 0 ));
}else{
return (($val4 << 24) | ($val3 << 16) | ($val2 << 8 ) | ($val1 << 0 ));
}
}
/**
* Converts 4-byte number into its equivalent integer with the help of Get32s
*
* @param int
* @param int
* @param int
* @param int
*
* @return int
*
*/
function get32u($val1,$val2,$val3,$val4) {
return ($this->Get32s($val1,$val2,$val3,$val4) & 0xffffffff);
}
 
//--------------------------------------------------------------------------
// Evaluate number, be it int, rational, or float from directory.
//--------------------------------------------------------------------------
function ConvertAnyFormat($ValuePtr, $Format)
{
$Value = 0;
 
switch($Format){
case FMT_SBYTE: $Value = $ValuePtr[0]; break;
case FMT_BYTE: $Value = $ValuePtr[0]; break;
 
case FMT_USHORT: $Value = $this->Get16u($ValuePtr[0],$ValuePtr[1]); break;
case FMT_ULONG: $Value = $this->Get32u($ValuePtr[0],$ValuePtr[1],$ValuePtr[2],$ValuePtr[3]); break;
 
case FMT_URATIONAL:
case FMT_SRATIONAL:
{
 
$Num = $this->Get32s($ValuePtr[0],$ValuePtr[1],$ValuePtr[2],$ValuePtr[3]);
$Den = $this->Get32s($ValuePtr[4],$ValuePtr[5],$ValuePtr[6],$ValuePtr[7]);
if ($Den == 0){
$Value = 0;
}else{
$Value = (double) ($Num/$Den);
}
return array($Value,array($Num,$Den));
break;
}
 
case FMT_SSHORT: $Value = $this->Get16u($ValuePtr[0],$ValuePtr[1]); break;
case FMT_SLONG: $Value = $this->Get32s($ValuePtr[0],$ValuePtr[1],$ValuePtr[2],$ValuePtr[3]); break;
 
// Not sure if this is correct (never seen float used in Exif format)
case FMT_SINGLE: $Value = $ValuePtr[0]; break;
case FMT_DOUBLE: $Value = $ValuePtr[0]; break;
}
return $Value;
}
 
/**
* Function to extract thumbnail from Exif data of the image.
* and store it in a filename given by $ThumbFile
*
* @param String Files name to store the thumbnail
*
*/
function saveThumbnail($ThumbFile) {
$ThumbFile = trim($ThumbFile);
$file = basename($this->file);
 
if(empty($ThumbFile)) $ThumbFile = "th_$file";
 
if (!empty($this->ImageInfo["h"]["Thumbnail"])){
$tp = fopen($ThumbFile,"wb");
if(!$tp) {
$this->errno = 2;
$this->errstr = "Cannot Open file '$ThumbFile'";
}
fwrite($tp,$this->ImageInfo["h"]["Thumbnail"]);
fclose($tp);
touch($ThumbFile,filemtime($this->file));
}
//$this->thumbnailURL = $ThumbFile;
$this->ImageInfo["h"]["Thumbnail"] = $ThumbFile;
}
 
/**
* Returns thumbnail url along with parameter supplied.
* Should be called in src attribute of image
*
* @return string File URL
*
*/
function showThumbnail() {
return "showThumbnail.php?file=".$this->file;
//$this->ImageInfo["h"]["Thumbnail"]
}
 
/**
* Function to give back thumbail image
* @return string full image
*
*/
function getThumbnail() {
return $this->ImageInfo["h"]["Thumbnail"];
}
 
/**
*
*/
function getImageInfo() {
 
$imgInfo = $this->ImageInfo["h"];
 
$retArr = $imgInfo;
$retArr["FileName"] = $imgInfo["FileName"];
$retArr["FileSize"] = $imgInfo["FileSize"]." bytes";
 
$retArr["FileDateTime"] = date("d-M-Y H:i:s",$imgInfo["FileDateTime"]);
 
$retArr["resolution"] = $imgInfo["Width"]."x".$imgInfo["Height"];
 
 
if ($this->ImageInfo[TAG_ORIENTATION] > 1){
// Only print orientation if one was supplied, and if its not 1 (normal orientation)
 
// 1 - "The 0th row is at the visual top of the image, and the 0th column is the visual left-hand side."
// 2 - "The 0th row is at the visual top of the image, and the 0th column is the visual right-hand side."
// 3 - "The 0th row is at the visual bottom of the image, and the 0th column is the visual right-hand side."
// 4 - "The 0th row is at the visual bottom of the image, and the 0th column is the visual left-hand side."
 
// 5 - "The 0th row is the visual left-hand side of of the image, and the 0th column is the visual top."
// 6 - "The 0th row is the visual right-hand side of of the image, and the 0th column is the visual top."
// 7 - "The 0th row is the visual right-hand side of of the image, and the 0th column is the visual bottom."
// 8 - "The 0th row is the visual left-hand side of of the image, and the 0th column is the visual bottom."
 
// Note: The descriptions here are the same as the name of the command line
// ption to pass to jpegtran to right the image
$OrientTab = array(
"Undefined",
"Normal", // 1
"flip horizontal", // left right reversed mirror
"rotate 180", // 3
"flip vertical", // upside down mirror
"transpose", // Flipped about top-left <--> bottom-right axis.
"rotate 90", // rotate 90 cw to right it.
"transverse", // flipped about top-right <--> bottom-left axis
"rotate 270", // rotate 270 to right it.
);
 
$retArr["orientation"] = $OrientTab[$this->ImageInfo[TAG_ORIENTATION]];
}
 
$retArr["color"] = ($imgInfo["IsColor"] == 0) ? "Black and white" : "Color";
 
if(isset($imgInfo["Process"])) {
switch($imgInfo["Process"]) {
case M_SOF0: $process = "Baseline";break;
case M_SOF1: $process = "Extended sequential";break;
case M_SOF2: $process = "Progressive";break;
case M_SOF3: $process = "Lossless";break;
case M_SOF5: $process = "Differential sequential";break;
case M_SOF6: $process = "Differential progressive";break;
case M_SOF7: $process = "Differential lossless";break;
case M_SOF9: $process = "Extended sequential, arithmetic coding";break;
case M_SOF10: $process = "Progressive, arithmetic coding";break;
case M_SOF11: $process = "Lossless, arithmetic coding";break;
case M_SOF13: $process = "Differential sequential, arithmetic coding";break;
case M_SOF14: $process = "Differential progressive, arithmetic coding";break;
case M_SOF15: $process = "Differential lossless, arithmetic coding";break;
default: $process = "Unknown";
}
$retArr["jpegProcess"] = $process;
}
 
if(file_exists($this->thumbnailURL)) {
$retArr["Thumbnail"] = "<a href='$this->thumbnailURL'>$this->thumbnailURL</a>";
}
 
return $retArr;
}
 
/**
* Returns time in microseconds
*/
function cpgGetMicroTime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
 
/**
* Get the time difference
*/
function getDiffTime() {
return ($this->cpgGetMicroTime() - $this->timeStart);
}
} // end of class
?>
/web/test/gallery/cpg133/include/exif_php.inc.php
0,0 → 1,88
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2005 Coppermine Dev Team
v1.1 originaly written by Gregory DEMAR
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.3.3
$Source: /cvsroot/coppermine/stable/include/exif_php.inc.php,v $
$Revision: 1.7 $
$Author: gaugau $
$Date: 2005/04/19 03:17:11 $
**********************************************/
 
define("EXIF_CACHE_FILE","exif.dat");
require("include/exifReader.inc.php");
 
function exif_parse_file($filename)
{ global $CONFIG;
if (!is_readable($filename)) return false;
$size = @getimagesize($filename);
if ($size[2] != 2) return false; // Not a JPEG file
 
//Check if we have the data of the said file in the table
$sql = "SELECT * FROM {$CONFIG['TABLE_EXIF']} ".
"WHERE filename = \"$filename\"";
 
$result = db_query($sql);
 
if (mysql_num_rows($result)){
$row = mysql_fetch_array($result);
mysql_free_result($result);
$exifParsed = unserialize($row["exifData"]);
return $exifParsed;
}
 
// No data in the table - read it from the image file
$exifObj = new phpExifReader($filename);
$exif = $exifObj->getImageInfo();
 
$exifParsed = array();
 
$Make = isset($exif['make']);
$Model = isset($exif['model']);
 
if (isset($exif['make']) && isset($exif['model'])){
$exifParsed['Camera'] = trim($exif['make'])." - ".trim($exif['model']);
}
 
if (isset($exif['DateTime'])){
$exifParsed['DateTaken'] = $exif['DateTime'];
}
 
if (isset($exif['fnumber'])){
$exifParsed['Aperture'] = $exif['fnumber'];
}
 
if (isset($exif['exposureTime'])){
$exifParsed['ExposureTime'] = $exif['exposureTime'];
}
 
if (isset($exif['focalLength'])){
$exifParsed['FocalLength'] = $exif['focalLength'];
}
 
if (isset($exif['isoEquiv'])){
$exifParsed['ISO'] = $exif['isoEquiv'];
}
 
if (isset($exif['exifComment'])){
$comment = $exif['exifComment'];
$exifParsed['Comment'] = $comment; // eregi_replace("ASCII"," ", $comment);
}
 
// Insert it into table for future reference
$sql = "INSERT INTO {$CONFIG['TABLE_EXIF']} ".
"VALUES ('$filename', '".addslashes(serialize($exifParsed))."')";
 
$result = db_query($sql);
 
return $exifParsed;
}
?>
/web/test/gallery/cpg133/include/functions.inc.php
0,0 → 1,1771
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2005 Coppermine Dev Team
v1.1 originaly written by Gregory DEMAR
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.3.3
$Source: /cvsroot/coppermine/stable/include/functions.inc.php,v $
$Revision: 1.24 $
$Author: gaugau $
$Date: 2005/04/19 03:17:11 $
**********************************************/
 
/**************************************************************************
Function for managing cookie saved user profile
**************************************************************************/
 
// Decode the user profile contained in a cookie
function user_get_profile()
{
global $CONFIG, $USER, $HTTP_COOKIE_VARS;
 
if (isset($HTTP_COOKIE_VARS[$CONFIG['cookie_name'].'_data'])) {
$USER = @unserialize(@base64_decode($HTTP_COOKIE_VARS[$CONFIG['cookie_name'].'_data']));
}
 
if (!isset($USER['ID']) || strlen($USER['ID']) != 32) {
list($usec, $sec) = explode(' ', microtime());
$seed = (float) $sec + ((float) $usec * 100000);
srand($seed);
$USER=array('ID' => md5(uniqid(rand(),1)));
} else {
$USER['ID'] = addslashes($USER['ID']);
}
 
if (!isset($USER['am'])) $USER['am'] = 1;
}
 
// Save the user profile in a cookie
function user_save_profile()
{
global $CONFIG, $USER, $HTTP_SERVER_VARS;
 
$data = base64_encode(serialize($USER));
setcookie($CONFIG['cookie_name'].'_data', $data, time()+86400*30, $CONFIG['cookie_path']);
}
 
/**************************************************************************
Database functions
**************************************************************************/
 
// Connect to the database
function cpg_db_connect()
{
global $CONFIG;
$result = @mysql_connect($CONFIG['dbserver'], $CONFIG['dbuser'], $CONFIG['dbpass']);
if (!$result)
return false;
if (!mysql_select_db($CONFIG['dbname']))
return false;
return $result;
}
 
// Perform a database query
function db_query($query, $link_id = 0)
{
global $CONFIG, $query_stats, $queries;
 
$query_start = cpgGetMicroTime();
if (($link_id)) {
$result = mysql_query($query, $link_id);
} else {
$result = mysql_query($query);
}
$query_end = cpgGetMicroTime();
if (isset($CONFIG['debug_mode']) && (($CONFIG['debug_mode']==1) || ($CONFIG['debug_mode']==2) )) {
$query_stats[] = $query_end - $query_start;
$queries[] = $query;
}
if (!$result) db_error("While executing query \"$query\" on $link_id");
 
return $result;
}
 
// Error message if a query failed
function db_error($the_error)
{
global $CONFIG;
 
if (!$CONFIG['debug_mode']) {
cpg_die(CRITICAL_ERROR, 'There was an error while processing a database query', __FILE__, __LINE__);
} else {
 
$the_error .= "\n\nmySQL error: ".mysql_error()."\n";
 
$out = "<br />There was an error while processing a database query.<br /><br/>
<form name='mysql'><textarea rows=\"8\" cols=\"60\">".htmlspecialchars($the_error)."</textarea></form>";
 
cpg_die(CRITICAL_ERROR, $out, __FILE__, __LINE__);
}
}
 
// Fetch all rows in an array
function db_fetch_rowset($result)
{
$rowset = array();
 
while ($row = mysql_fetch_array($result)) $rowset[] = $row;
 
return $rowset;
}
 
/**************************************************************************
Utilities functions
**************************************************************************/
 
//define ('LOC','YToyOntzOjE6ImwiO3M6OToie0dBTExFUll9IjtzOjE6InMiO3M6MTY5OiI8ZGl2IGNsYXNzPSJmb290ZXIiIGFsaWduPSJjZW50ZXIiIHN0eWxlPSJwYWRkaW5nLXRvcDogMTBweDsiPlBvd2VyZWQgYnkgPGEgaHJlZj0iaHR0cDovL3d3dy5jaGV6Z3JlZy5uZXQvY29wcGVybWluZS8iIHRhcmdldD0iX2JsYW5rIj5Db3BwZXJtaW5lIFBob3RvIEdhbGxlcnk8L2E+PC9kaXY+Ijt9');
define ('LOC','YToyOntzOjE6ImwiO3M6OToie0dBTExFUll9IjtzOjE6InMiO3M6MTU5OiI8ZGl2IGNsYXNzPSJmb290ZXIiIGFsaWduPSJjZW50ZXIiIHN0eWxlPSJwYWRkaW5nLXRvcDogMTBweDsiPlBvd2VyZWQgYnkgPGEgaHJlZj0iaHR0cDovL2NvcHBlcm1pbmUuc2YubmV0LyIgdGFyZ2V0PSJfYmxhbmsiPkNvcHBlcm1pbmUgUGhvdG8gR2FsbGVyeTwvYT48L2Rpdj4iO30=');
// Replacement for the die function
function cpg_die($msg_code, $msg_text, $error_file, $error_line, $output_buffer = false)
{
global $CONFIG, $lang_cpg_die, $template_cpg_die;
 
// Simple output if theme file is not loaded
if(!function_exists('pageheader')){
echo 'Fatal error :<br />'.$msg_text;
exit;
}
 
$ob = ob_get_contents();
if ($ob) ob_end_clean();
 
if(!$CONFIG['debug_mode']) template_extract_block($template_cpg_die, 'file_line');
if(!$output_buffer && !$CONFIG['debug_mode']) template_extract_block($template_cpg_die, 'output_buffer');
 
$params = array(
'{MESSAGE}' => $msg_text,
'{FILE_TXT}' => $lang_cpg_die['file'],
'{FILE}' => $error_file,
'{LINE_TXT}' => $lang_cpg_die['line'],
'{LINE}' => $error_line,
'{OUTPUT_BUFFER}' => $ob,
);
 
pageheader($lang_cpg_die[$msg_code]);
starttable(-1, $lang_cpg_die[$msg_code]);
echo template_eval($template_cpg_die, $params);
endtable();
pagefooter();
exit;
}
 
// Display a localised date
function localised_date($timestamp = -1, $datefmt)
{
global $lang_month, $lang_day_of_week;
 
if ($timestamp == -1) {
$timestamp = time();
}
 
$date = ereg_replace('%[aA]', $lang_day_of_week[(int)strftime('%w', $timestamp)], $datefmt);
$date = ereg_replace('%[bB]', $lang_month[(int)strftime('%m', $timestamp)-1], $date);
 
return strftime($date, $timestamp);
}
 
// Function to create correct URLs for image name with space or exotic characters
function path2url($path)
{
return str_replace("%2F","/",rawurlencode($path));
}
 
// Display a 'message box like' table
function msg_box($title, $msg_text, $button_text="", $button_link="", $width="-1")
{
global $template_msg_box;
 
if (!$button_text) {
template_extract_block($template_msg_box, 'button');
}
 
$params = array(
'{MESSAGE}' => $msg_text,
'{LINK}' => $button_link,
'{TEXT}' => $button_text
);
 
starttable($width, $title);
echo template_eval($template_msg_box, $params);
endtable();
}
 
function create_tabs($items, $curr_page, $total_pages, $template)
{
global $CONFIG;
 
if (function_exists('theme_create_tabs')) {
theme_create_tabs($items, $curr_page, $total_pages, $template);
return;
}
 
$maxTab = $CONFIG['max_tabs'];
 
$tabs = sprintf($template['left_text'], $items, $total_pages);
if (($total_pages == 1)) return $tabs;
 
$tabs .= $template['tab_header'];
if ($curr_page == 1) {
$tabs .= sprintf($template['active_tab'], 1);
} else {
$tabs .= sprintf($template['inactive_tab'], 1, 1);
}
if ($total_pages > $maxTab){
$start = max(2, $curr_page - floor(($maxTab -2)/2));
$start = min($start, $total_pages - $maxTab +2);
$end = $start + $maxTab -3;
} else {
$start = 2;
$end = $total_pages-1;
}
for ($page = $start ; $page <= $end; $page++) {
if ($page == $curr_page) {
$tabs .= sprintf($template['active_tab'], $page);
} else {
$tabs .= sprintf($template['inactive_tab'], $page, $page);
}
}
if ($total_pages > 1){
if ($curr_page == $total_pages) {
$tabs .= sprintf($template['active_tab'], $total_pages);
} else {
$tabs .= sprintf($template['inactive_tab'], $total_pages, $total_pages);
}
}
return $tabs.$template['tab_trailer'];
}
 
/**
* Rewritten by Nathan Codding - Feb 6, 2001. Taken from phpBB code
* - Goes through the given string, and replaces xxxx://yyyy with an HTML <a> tag linking
* to that URL
* - Goes through the given string, and replaces www.xxxx.yyyy[zzzz] with an HTML <a> tag linking
* to http://www.xxxx.yyyy[/zzzz]
* - Goes through the given string, and replaces xxxx@yyyy with an HTML mailto: tag linking
* to that email address
* - Only matches these 2 patterns either after a space, or at the beginning of a line
*
* Notes: the email one might get annoying - it's easy to make it more restrictive, though.. maybe
* have it require something like xxxx@yyyy.zzzz or such. We'll see.
*/
function make_clickable($text)
{
$ret = " " . $text;
$ret = preg_replace("#([\n ])([a-z]+?)://([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)#i", "\\1<a href=\"\\2://\\3\" target=\"_blank\">\\2://\\3</a>", $ret);
$ret = preg_replace("#([\n ])www\.([a-z0-9\-]+)\.([a-z0-9\-.\~]+)((?:/[a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]*)?)#i", "\\1<a href=\"http://www.\\2.\\3\\4\" target=\"_blank\">www.\\2.\\3\\4</a>", $ret);
$ret = preg_replace("#([\n ])([a-z0-9\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)?[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
$ret = substr($ret, 1);
 
return($ret);
}
 
// Allow the use of a limited set of phpBB bb codes in albums and image descriptions
// Taken from phpBB code
function bb_decode($text)
{
$text = nl2br($text);
 
static $bbcode_tpl = array();
static $patterns = array();
static $replacements = array();
 
// First: If there isn't a "[" and a "]" in the message, don't bother.
if ((strpos($text, "[") === false || strpos($text, "]") === false))
{
return $text;
}
 
// [b] and [/b] for bolding text.
$text = str_replace("[b]", '<b>', $text);
$text = str_replace("[/b]", '</b>', $text);
 
// [u] and [/u] for underlining text.
$text = str_replace("[u]", '<u>', $text);
$text = str_replace("[/u]", '</u>', $text);
 
// [i] and [/i] for italicizing text.
$text = str_replace("[i]", '<i>', $text);
$text = str_replace("[/i]", '</i>', $text);
 
// colours
$text = preg_replace("/\[color=(\#[0-9A-F]{6}|[a-z]+)\]/", '<span style="color:$1">', $text);
$text = str_replace("[/color]", '</span>', $text);
 
// [i] and [/i] for italicizing text.
//$text = str_replace("[i:$uid]", $bbcode_tpl['i_open'], $text);
//$text = str_replace("[/i:$uid]", $bbcode_tpl['i_close'], $text);
 
if (!count($bbcode_tpl)) {
// We do URLs in several different ways..
$bbcode_tpl['url'] = '<span class="bblink"><a href="{URL}" target="_blank">{DESCRIPTION}</a></span>';
$bbcode_tpl['email']= '<span class="bblink"><a href="mailto:{EMAIL}">{EMAIL}</a></span>';
 
$bbcode_tpl['url1'] = str_replace('{URL}', '\\1\\2', $bbcode_tpl['url']);
$bbcode_tpl['url1'] = str_replace('{DESCRIPTION}', '\\1\\2', $bbcode_tpl['url1']);
 
$bbcode_tpl['url2'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
$bbcode_tpl['url2'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url2']);
 
$bbcode_tpl['url3'] = str_replace('{URL}', '\\1\\2', $bbcode_tpl['url']);
$bbcode_tpl['url3'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url3']);
 
$bbcode_tpl['url4'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
$bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\2', $bbcode_tpl['url4']);
 
$bbcode_tpl['email'] = str_replace('{EMAIL}', '\\1', $bbcode_tpl['email']);
 
// [url]xxxx://www.phpbb.com[/url] code..
$patterns[1] = "#\[url\]([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/url\]#si";
$replacements[1] = $bbcode_tpl['url1'];
 
// [url]www.phpbb.com[/url] code.. (no xxxx:// prefix).
$patterns[2] = "#\[url\]([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/url\]#si";
$replacements[2] = $bbcode_tpl['url2'];
 
// [url=xxxx://www.phpbb.com]phpBB[/url] code..
$patterns[3] = "#\[url=([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/url\]#si";
$replacements[3] = $bbcode_tpl['url3'];
 
// [url=www.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix).
$patterns[4] = "#\[url=([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\](.*?)\[/url\]#si";
$replacements[4] = $bbcode_tpl['url4'];
 
// [email]user@domain.tld[/email] code..
$patterns[5] = "#\[email\]([a-z0-9\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si";
$replacements[5] = $bbcode_tpl['email'];
 
// [img]xxxx://www.phpbb.com[/img] code..
$bbcode_tpl['img'] = '<img src="{URL}" >';
$bbcode_tpl['img'] = str_replace('{URL}', '\\1\\2', $bbcode_tpl['img']);
 
$patterns[6] = "#\[img\]([a-z]+?://){1}([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+\(\)]+)\[/img\]#si";
$replacements[6] = $bbcode_tpl['img'];
 
}
 
$text = preg_replace($patterns, $replacements, $text);
 
return $text;
}
 
/**************************************************************************
Template functions
**************************************************************************/
 
// Load and parse the template.html file
function load_template()
{
global $THEME_DIR, $CONFIG, $template_header, $template_footer;
 
$tmpl_loc = array();
$tmpl_loc = unserialize(base64_decode(LOC));
 
if (file_exists(TEMPLATE_FILE)) {
$template_file = TEMPLATE_FILE;
} elseif (file_exists($THEME_DIR . TEMPLATE_FILE)) {
$template_file = $THEME_DIR . TEMPLATE_FILE;
} else die("<b>Coppermine critical error</b>:<br />Unable to load template file ".TEMPLATE_FILE."!</b>");
 
$template = fread(fopen($template_file, 'r'), filesize($template_file));
$gallery_pos = strpos($template, '{LANGUAGE_SELECT_FLAGS}');
$template = str_replace('{LANGUAGE_SELECT_FLAGS}', languageSelect('flags') ,$template);
$gallery_pos = strpos($template, '{LANGUAGE_SELECT_LIST}');
$template = str_replace('{LANGUAGE_SELECT_LIST}', languageSelect('list') ,$template);
$gallery_pos = strpos($template, '{THEME_DIR}');
$template = str_replace('{THEME_DIR}', $THEME_DIR ,$template);
$gallery_pos = strpos($template, '{THEME_SELECT_LIST}');
$template = str_replace('{THEME_SELECT_LIST}', themeSelect('list') ,$template);
$gallery_pos = strpos($template, $tmpl_loc['l']);
$template = str_replace($tmpl_loc['l'], $tmpl_loc['s'] ,$template);
 
$template_header = substr($template, 0, $gallery_pos);
$template_footer = substr($template, $gallery_pos);
$add_version_info = '<!--Coppermine Photo Gallery '.COPPERMINE_VERSION.'--></body>';
$template_footer = ereg_replace("</body[^>]*>",$add_version_info,$template_footer);
}
 
// Eval a template (substitute vars with values)
function template_eval(&$template, &$vars)
{
return strtr($template, $vars);
}
 
 
// Extract and return block '$block_name' from the template, the block is replaced by $subst
function template_extract_block(&$template, $block_name, $subst='')
{
$pattern = "#(<!-- BEGIN $block_name -->)(.*?)(<!-- END $block_name -->)#s";
if ( !preg_match($pattern, $template, $matches)){
die('<b>Template error<b><br />Failed to find block \''.$block_name.'\'('.htmlspecialchars($pattern).') in :<br /><pre>'.htmlspecialchars($template).'</pre>');
}
$template = str_replace($matches[1].$matches[2].$matches[3], $subst, $template);
return $matches[2];
}
 
/**************************************************************************
Functions for album/picture management
**************************************************************************/
 
// Get the list of albums that the current user can't see
function get_private_album_set()
{
if (GALLERY_ADMIN_MODE) return;
global $CONFIG, $ALBUM_SET, $USER_DATA, $FORBIDDEN_SET;
 
if ($USER_DATA['can_see_all_albums']) return;
 
$result = db_query("SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE visibility != '0' AND visibility !='".(FIRST_USER_CAT + USER_ID)."' AND visibility NOT IN ".USER_GROUP_SET);
if ((mysql_num_rows($result))) {
$set ='';
while($album=mysql_fetch_array($result)){
$set .= $album['aid'].',';
} // while
$FORBIDDEN_SET = "p.aid NOT IN (".substr($set, 0, -1).') ';
$ALBUM_SET .= 'AND aid NOT IN ('.substr($set, 0, -1).') ';
}
mysql_free_result($result);
}
 
// Retrieve the data for a picture or a set of picture
function get_pic_data($album, &$count, &$album_name, $limit1=-1, $limit2=-1, $set_caption = true)
{
global $USER, $CONFIG, $ALBUM_SET, $CURRENT_CAT_NAME, $CURRENT_ALBUM_KEYWORD, $HTTP_GET_VARS, $HTML_SUBST, $THEME_DIR, $FAVPICS;
global $album_date_fmt, $lastcom_date_fmt, $lastup_date_fmt, $lasthit_date_fmt;
global $lang_get_pic_data, $lang_meta_album_names, $lang_errors;
 
$sort_array = array('na' => 'filename ASC', 'nd' => 'filename DESC', 'ta'=>'title ASC', 'td'=>'title DESC', 'da' => 'pid ASC', 'dd' => 'pid DESC');
$sort_code = isset($USER['sort'])? $USER['sort'] : $CONFIG['default_sort_order'];
$sort_order = isset($sort_array[$sort_code]) ? $sort_array[$sort_code] : $sort_array[$CONFIG['default_sort_order']];
$limit = ($limit1 != -1) ? ' LIMIT '. $limit1 : '';
$limit .= ($limit2 != -1) ? ' ,'. $limit2 : '';
 
if ($limit2 == 1) {
$select_columns = '*';
} else {
$select_columns = 'pid, filepath, filename, url_prefix, filesize, pwidth, pheight, ctime, aid';
}
 
// Keyword
if (!empty($CURRENT_ALBUM_KEYWORD)){
$keyword = "OR keywords like '%$CURRENT_ALBUM_KEYWORD%'";
} else $keyword = '';
 
// Regular albums
if ((is_numeric($album))) {
$album_name_keyword = get_album_name($album);
$album_name = $album_name_keyword['title'];
$album_keyword = $album_name_keyword['keyword'];
 
if (!empty($album_keyword)){
$keyword = "OR keywords like '%$album_keyword%'";
}
 
$approved = GALLERY_ADMIN_MODE ? '' : 'AND approved=\'YES\'';
 
$result = db_query("SELECT COUNT(*) from {$CONFIG['TABLE_PICTURES']} WHERE aid='$album' $keyword $approved $ALBUM_SET");
$nbEnr = mysql_fetch_array($result);
$count = $nbEnr[0];
mysql_free_result($result);
 
if($select_columns != '*') $select_columns .= ', title, caption,hits,owner_id,owner_name';
 
$result = db_query("SELECT $select_columns from {$CONFIG['TABLE_PICTURES']} WHERE aid='$album' $keyword $approved $ALBUM_SET ORDER BY $sort_order $limit");
$rowset = db_fetch_rowset($result);
mysql_free_result($result);
// Set picture caption
if ($set_caption) foreach ($rowset as $key => $row){
 
$caption = "<span class=\"thumb_title\">";
$caption .= ($rowset[$key]['title']||$rowset[$key]['hits']) ? $rowset[$key]['title'] : '';
 
if ($CONFIG['views_in_thumbview']){
if ($rowset[$key]['title']){$caption .= "&nbsp;&ndash;&nbsp;";}
$caption .= sprintf($lang_get_pic_data['n_views'], $rowset[$key]['hits']);
}
$caption .= "</span>";
 
 
if ($CONFIG['caption_in_thumbview']){
$caption .= $rowset[$key]['caption'] ? "<span class=\"thumb_caption\">".bb_decode(($rowset[$key]['caption']))."</span>" : '';
}
if ($CONFIG['display_comment_count']) {
$comments_nr = count_pic_comments($row['pid']);
if ($comments_nr > 0) $caption .= "<span class=\"thumb_num_comments\">".sprintf($lang_get_pic_data['n_comments'], $comments_nr )."</span>";
}
 
if ($CONFIG['display_uploader']){
$caption .= '<span class="thumb_title"><a href ="profile.php?uid='.$rowset[$key]['owner_id'].'">'.$rowset[$key]['owner_name'].'</a></span>';
}
 
$rowset[$key]['caption_text'] = $caption;
 
}
 
return $rowset;
}
 
 
// Meta albums
switch($album){
case 'lastcom': // Last comments
if ($ALBUM_SET && $CURRENT_CAT_NAME) {
$album_name = $album_name = $lang_meta_album_names['lastcom'].' - '. $CURRENT_CAT_NAME;
} else {
$album_name = $lang_meta_album_names['lastcom'];
}
$query = "SELECT COUNT(*) from {$CONFIG['TABLE_COMMENTS']}, {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' AND {$CONFIG['TABLE_COMMENTS']}.pid = {$CONFIG['TABLE_PICTURES']}.pid $keyword $ALBUM_SET";
$result = db_query($query);
 
$nbEnr = mysql_fetch_array($result);
$count = $nbEnr[0];
mysql_free_result($result);
 
if($select_columns == '*'){
$select_columns = 'p.*';
} else {
$select_columns = str_replace('pid', 'c.pid', $select_columns).', msg_id, author_id, msg_author, UNIX_TIMESTAMP(msg_date) as msg_date, msg_body, aid';
}
 
$TMP_SET = str_replace($CONFIG['TABLE_PICTURES'],'p',$ALBUM_SET);
$result = db_query("SELECT $select_columns FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE approved = 'YES' AND c.pid = p.pid $keyword $TMP_SET ORDER by msg_id DESC $limit");
 
 
$rowset = db_fetch_rowset($result);
mysql_free_result($result);
 
if ($set_caption) foreach ($rowset as $key => $row){
if ($row['author_id']) {
$user_link = '<a href ="profile.php?uid='.$row['author_id'].'">'.$row['msg_author'].'</a>';
} else {
$user_link = $row['msg_author'];
}
$msg_body = strlen($row['msg_body']) > 50 ? @substr($row['msg_body'],0,50)."...": $row['msg_body'];
if ($CONFIG['enable_smilies']) $msg_body = process_smilies($msg_body);
$caption = '<span class="thumb_title">'.$user_link.'</span>'.'<span class="thumb_caption">'.localised_date($row['msg_date'], $lastcom_date_fmt).'</span>'.'<span class="thumb_caption">'.$msg_body.'</span>';
$rowset[$key]['caption_text'] = $caption;
}
return $rowset;
break;
 
case 'lastcomby': // Last comments by a specific user
if (isset($USER['uid'])) {
$uid = (int)$USER['uid'];
} else {
$uid = -1;
}
 
$user_name = get_username($uid);
if ($ALBUM_SET && $CURRENT_CAT_NAME) {
$album_name = $album_name = $lang_meta_album_names['lastcom'].' - '. $CURRENT_CAT_NAME .' - '. $user_name;
} else {
$album_name = $lang_meta_album_names['lastcom'].' - '. $user_name;
}
$result = db_query("SELECT COUNT(*) from {$CONFIG['TABLE_COMMENTS']}, {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' AND author_id = '$uid' AND {$CONFIG['TABLE_COMMENTS']}.pid = {$CONFIG['TABLE_PICTURES']}.pid $ALBUM_SET");
$nbEnr = mysql_fetch_array($result);
$count = $nbEnr[0];
mysql_free_result($result);
 
if($select_columns == '*'){
$select_columns = 'p.*';
} else {
$select_columns = str_replace('pid', 'c.pid', $select_columns).', msg_id, author_id, msg_author, UNIX_TIMESTAMP(msg_date) as msg_date, msg_body, aid';
}
 
$result = db_query("SELECT $select_columns FROM {$CONFIG['TABLE_COMMENTS']} as c, {$CONFIG['TABLE_PICTURES']} as p WHERE approved = 'YES' AND author_id = '$uid' AND c.pid = p.pid $ALBUM_SET ORDER by msg_id DESC $limit");
$rowset = db_fetch_rowset($result);
mysql_free_result($result);
 
if ($set_caption) foreach ($rowset as $key => $row){
if ($row['author_id']) {
$user_link = '<a href ="profile.php?uid='.$row['author_id'].'">'.$row['msg_author'].'</a>';
} else {
$user_link = $row['msg_author'];
}
 
$caption = '<span class="thumb_title">'.$user_link.'</span>'.'<span class="thumb_caption">'.localised_date($row['msg_date'], $lastcom_date_fmt).'</span>'.'<span class="thumb_caption">'.$row['msg_body'].'</span>';
$rowset[$key]['caption_text'] = $caption;
}
return $rowset;
break;
 
case 'lastup': // Last uploads
if ($ALBUM_SET && $CURRENT_CAT_NAME) {
$album_name = $lang_meta_album_names['lastup'].' - '. $CURRENT_CAT_NAME;
} else {
$album_name = $lang_meta_album_names['lastup'];
}
 
$result = db_query("SELECT COUNT(*) from {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' $ALBUM_SET");
$nbEnr = mysql_fetch_array($result);
$count = $nbEnr[0];
mysql_free_result($result);
 
if($select_columns != '*' ) $select_columns .= ',title, caption, owner_id, owner_name, aid';
 
$result = db_query("SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' $ALBUM_SET ORDER BY pid DESC $limit");
 
$rowset = db_fetch_rowset($result);
mysql_free_result($result);
 
if ($set_caption) foreach ($rowset as $key => $row){
$user_link = ($CONFIG['display_uploader'] && $row['owner_id'] && $row['owner_name']) ? '<span class="thumb_title"><a href ="profile.php?uid='.$row['owner_id'].'">'.$row['owner_name'].'</a></span>' : '';
$caption = $user_link.'<span class="thumb_caption">'.localised_date($row['ctime'], $lastup_date_fmt).'</span>';
$rowset[$key]['caption_text'] = $caption;
}
return $rowset;
break;
 
case 'lastupby': // Last uploads by a specific user
if (isset($USER['uid'])) {
$uid = (int)$USER['uid'];
} else {
$uid = -1;
}
 
$user_name = get_username($uid);
if ($ALBUM_SET && $CURRENT_CAT_NAME) {
$album_name = $lang_meta_album_names['lastup'].' - '. $CURRENT_CAT_NAME .' - '. $user_name;
} else {
$album_name = $lang_meta_album_names['lastup'] .' - '. $user_name;
}
 
$result = db_query("SELECT COUNT(*) from {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' AND owner_id = '$uid' $ALBUM_SET");
$nbEnr = mysql_fetch_array($result);
$count = $nbEnr[0];
mysql_free_result($result);
 
if($select_columns != '*' ) $select_columns .= ', owner_id, owner_name, aid';
 
$result = db_query("SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' AND owner_id = '$uid' $ALBUM_SET ORDER BY pid DESC $limit");
 
$rowset = db_fetch_rowset($result);
mysql_free_result($result);
 
if ($set_caption) foreach ($rowset as $key => $row){
if ($row['owner_id'] && $row['owner_name']) {
$user_link = '<span class="thumb_title"><a href ="profile.php?uid='.$row['owner_id'].'">'.$row['owner_name'].'</a></span>';
} else {
$user_link = '';
}
$caption = $user_link.'<span class="thumb_caption">'.localised_date($row['ctime'], $lastup_date_fmt).'</span>';
$rowset[$key]['caption_text'] = $caption;
}
return $rowset;
break;
 
case 'topn': // Most viewed pictures
if ($ALBUM_SET && $CURRENT_CAT_NAME) {
$album_name = $lang_meta_album_names['topn'].' - '. $CURRENT_CAT_NAME;
} else {
$album_name = $lang_meta_album_names['topn'];
}
$query ="SELECT COUNT(*) from {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' AND hits > 0 $ALBUM_SET $keyword";
 
$result = db_query($query);
$nbEnr = mysql_fetch_array($result);
$count = $nbEnr[0];
mysql_free_result($result);
 
if($select_columns != '*') $select_columns .= ', hits, aid, filename';
 
$result = db_query("SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES'AND hits > 0 $ALBUM_SET $keyword ORDER BY hits DESC, filename $limit");
 
$rowset = db_fetch_rowset($result);
mysql_free_result($result);
 
if ($set_caption) foreach ($rowset as $key => $row){
$caption = "<span class=\"thumb_caption\">".sprintf($lang_get_pic_data['n_views'], $row['hits']).'</span>';
$rowset[$key]['caption_text'] = $caption;
}
return $rowset;
break;
 
case 'toprated': // Top rated pictures
if ($ALBUM_SET && $CURRENT_CAT_NAME) {
$album_name = $lang_meta_album_names['toprated'].' - '. $CURRENT_CAT_NAME;
} else {
$album_name = $lang_meta_album_names['toprated'];
}
$result = db_query("SELECT COUNT(*) from {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' AND votes >= '{$CONFIG['min_votes_for_rating']}' $ALBUM_SET");
$nbEnr = mysql_fetch_array($result);
$count = $nbEnr[0];
mysql_free_result($result);
 
if($select_columns != '*') $select_columns .= ', pic_rating, votes, aid';
 
$result = db_query("SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' AND votes >= '{$CONFIG['min_votes_for_rating']}' $ALBUM_SET ORDER BY ROUND((pic_rating+1)/2000) DESC, votes DESC, filename $limit");
$rowset = db_fetch_rowset($result);
mysql_free_result($result);
 
if ($set_caption) foreach ($rowset as $key => $row){
if (defined('THEME_HAS_RATING_GRAPHICS')) {
$prefix= $THEME_DIR;
} else {
$prefix= '';
}
$caption = "<span class=\"thumb_caption\">".'<img src="'.$prefix.'images/rating'.round($row['pic_rating']/2000).'.gif" align="absmiddle"/>'.'<br />'.sprintf($lang_get_pic_data['n_votes'], $row['votes']).'</span>';
$rowset[$key]['caption_text'] = $caption;
}
return $rowset;
break;
 
case 'lasthits': // Last viewed pictures
if ($ALBUM_SET && $CURRENT_CAT_NAME) {
$album_name = $lang_meta_album_names['lasthits'].' - '. $CURRENT_CAT_NAME;
} else {
$album_name = $lang_meta_album_names['lasthits'];
}
$result = db_query("SELECT COUNT(*) from {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' $ALBUM_SET");
$nbEnr = mysql_fetch_array($result);
$count = $nbEnr[0];
mysql_free_result($result);
 
if($select_columns != '*') $select_columns .= ', UNIX_TIMESTAMP(mtime) as mtime, aid';
 
$result = db_query("SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' $ALBUM_SET ORDER BY mtime DESC $limit");
$rowset = db_fetch_rowset($result);
mysql_free_result($result);
 
if ($set_caption) foreach ($rowset as $key => $row){
$caption = "<span class=\"thumb_caption\">".localised_date($row['mtime'], $lasthit_date_fmt).'</span>';
$rowset[$key]['caption_text'] = $caption;
}
return $rowset;
break;
 
case 'random': // Random pictures
if ($ALBUM_SET && $CURRENT_CAT_NAME) {
$album_name = $lang_meta_album_names['random'].' - '. $CURRENT_CAT_NAME;
} else {
$album_name = $lang_meta_album_names['random'];
}
$result = db_query("SELECT COUNT(*) from {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' $ALBUM_SET");
$nbEnr = mysql_fetch_array($result);
$pic_count = $nbEnr[0];
mysql_free_result($result);
 
if($select_columns != '*') $select_columns .= ', aid';
 
// if we have more than 1000 pictures, we limit the number of picture returned
// by the SELECT statement as ORDER BY RAND() is time consuming
/* Commented out due to image not found bug
if ($pic_count > 1000) {
$result = db_query("SELECT COUNT(*) from {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES'");
$nbEnr = mysql_fetch_array($result);
$total_count = $nbEnr[0];
mysql_free_result($result);
 
$granularity = floor($total_count / RANDPOS_MAX_PIC);
$cor_gran = ceil($total_count / $pic_count);
srand(time());
for ($i=1; $i<= $cor_gran; $i++) $random_num_set =rand(0, $granularity).', ';
$random_num_set = substr($random_num_set,0, -2);
$result = db_query("SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE randpos IN ($random_num_set) AND approved = 'YES' $ALBUM_SET ORDER BY RAND() LIMIT $limit2");
} else {
*/
$sql = "SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' $ALBUM_SET ORDER BY RAND() LIMIT $limit2";
$result = db_query($sql);
 
$rowset = array();
while($row = mysql_fetch_array($result)){
$row['caption_text'] = '';
$rowset[-$row['pid']] = $row;
}
mysql_free_result($result);
 
return $rowset;
break;
 
case 'search': // Search results
if (isset($USER['search'])) {
$search_string = $USER['search'];
} else {
$search_string = '';
}
 
if (substr($search_string, 0, 3) == '###') {
$query_all = 1;
$search_string = substr($search_string, 3);
} else {
$query_all = 0;
}
 
if ($ALBUM_SET && $CURRENT_CAT_NAME) {
$album_name = $lang_meta_album_names['search'].' - '. $CURRENT_CAT_NAME;
} else {
$album_name = $lang_meta_album_names['search'].' - "'. strtr($search_string, $HTML_SUBST) . '"';
}
 
include 'include/search.inc.php';
return $rowset;
break;
 
case 'lastalb': // Last albums to which uploads
if ($ALBUM_SET && $CURRENT_CAT_NAME) {
$album_name = $lang_meta_album_names['lastalb'].' - '. $CURRENT_CAT_NAME;
} else {
$album_name = $lang_meta_album_names['lastalb'];
}
 
 
$ALBUM_SET = str_replace( "aid", $CONFIG['TABLE_PICTURES'].".aid" , $ALBUM_SET );
 
$result = db_query("SELECT COUNT(*) from {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' $ALBUM_SET");
$nbEnr = mysql_fetch_array($result);
$count = $nbEnr[0];
mysql_free_result($result);
 
$result = db_query("SELECT *,{$CONFIG['TABLE_ALBUMS']}.title AS title,{$CONFIG['TABLE_ALBUMS']}.aid AS aid FROM {$CONFIG['TABLE_PICTURES']},{$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND approved = 'YES' $ALBUM_SET GROUP BY {$CONFIG['TABLE_PICTURES']}.aid ORDER BY {$CONFIG['TABLE_PICTURES']}.ctime DESC $limit");
$rowset = db_fetch_rowset($result);
mysql_free_result($result);
 
if ($set_caption) foreach ($rowset as $key => $row){
$caption = "<span class=\"thumb_caption\">".$row['title']." - ".localised_date($row['ctime'], $lastup_date_fmt).'</span>';
$rowset[$key]['caption_text'] = $caption;
}
return $rowset;
break;
 
case 'favpics': // Favourite Pictures
 
$album_name = $lang_meta_album_names['favpics'];
$rowset = array();
if (count($FAVPICS)>0){
$favs = implode(",",$FAVPICS);
$result = db_query("SELECT COUNT(*) from {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES' AND pid IN ($favs)");
$nbEnr = mysql_fetch_array($result);
$count = $nbEnr[0];
mysql_free_result($result);
 
$select_columns = '*';
 
$result = db_query("SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE approved = 'YES'AND pid IN ($favs) $limit");
$rowset = db_fetch_rowset($result);
 
mysql_free_result($result);
 
if ($set_caption) foreach ($rowset as $key => $row){
$caption = $rowset[$key]['title'] ? "<span class=\"thumb_caption\">".($rowset[$key]['title'])."</span>" : '';
$rowset[$key]['caption_text'] = $caption;
}
}
return $rowset;
break;
 
default : // Invalid meta album
cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
}
} // End of get_pic_data
 
 
// Get the name of an album
function get_album_name($aid)
{
global $CONFIG;
global $lang_errors;
 
$result = db_query("SELECT title,keyword from {$CONFIG['TABLE_ALBUMS']} WHERE aid='$aid'");
$count = mysql_num_rows($result);
if ($count > 0) {
$row = mysql_fetch_array($result);
return $row;
} else {
cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
}
}
 
// Return the name of a user
function get_username($uid)
{
global $CONFIG;
 
$uid = (int)$uid;
 
if (!$uid) {
return 'Anonymous';
} elseif (defined('UDB_INTEGRATION')) {
return udb_get_user_name($uid);
} else {
$result = db_query("SELECT user_name FROM {$CONFIG['TABLE_USERS']} WHERE user_id = '".$uid."'");
if (mysql_num_rows($result) == 0) return '';
$row = mysql_fetch_array($result);
mysql_free_result($result);
return $row['user_name'];
}
}
 
// Return the ID of a user
function get_userid($username)
{
global $CONFIG;
 
$username = addslashes($username);
 
if (!$username) {
return 0;
} elseif (defined('UDB_INTEGRATION')) { // (Altered to fix banning w/ bb integration - Nibbler)
return udb_get_user_id($username);
} else {
$result = db_query("SELECT user_id FROM {$CONFIG['TABLE_USERS']} WHERE user_name = '".$username."'");
if (mysql_num_rows($result) == 0) return 0;
$row = mysql_fetch_array($result);
mysql_free_result($result);
return $row['user_id'];
}
}
 
// Return the total number of comments for a certain picture
function count_pic_comments($pid, $skip=0)
{
global $CONFIG;
$result = db_query("SELECT count(*) from {$CONFIG['TABLE_COMMENTS']} where pid=$pid and msg_id!=$skip");
$nbEnr = mysql_fetch_array($result);
$count = $nbEnr[0];
mysql_free_result($result);
 
return $count;
}
 
// Add 1 everytime a picture is viewed.
function add_hit($pid)
{
global $CONFIG;
 
db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET hits=hits+1 WHERE pid='$pid'");
}
 
 
// Build the breadcrumb
function breadcrumb($cat, &$breadcrumb, &$BREADCRUMB_TEXT)
{
global $album, $lang_errors, $lang_list_categories;
global $CONFIG,$CURRENT_ALBUM_DATA, $CURRENT_CAT_NAME;
if ($cat != 0) { //Categories other than 0 need to be selected
$breadcrumb_array = array();
if ($cat >= FIRST_USER_CAT) {
$user_name = get_username($cat - FIRST_USER_CAT);
if (!$user_name) $user_name = 'Mr. X';
 
$breadcrumb_array[] = array($cat, $user_name);
$CURRENT_CAT_NAME = sprintf($lang_list_categories['xx_s_gallery'], $user_name);
$row['parent'] = 1;
} else {
$result = db_query("SELECT name, parent FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '$cat'");
if (mysql_num_rows($result) == 0) cpg_die(CRITICAL_ERROR, $lang_errors['non_exist_cat'], __FILE__, __LINE__);
$row = mysql_fetch_array($result);
 
$breadcrumb_array[] = array($cat, $row['name']);
$CURRENT_CAT_NAME = $row['name'];
mysql_free_result($result);
}
 
while($row['parent'] != 0){
$result = db_query("SELECT cid, name, parent FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = '{$row['parent']}'");
if (mysql_num_rows($result) == 0) cpg_die(CRITICAL_ERROR, $lang_errors['orphan_cat'], __FILE__, __LINE__);
$row = mysql_fetch_array($result);
 
$breadcrumb_array[] = array($row['cid'], $row['name']);
mysql_free_result($result);
} // while
 
$breadcrumb_array = array_reverse($breadcrumb_array);
$breadcrumb = '<a href="index.php">'.$lang_list_categories['home'].'</a>';
$BREADCRUMB_TEXT = $lang_list_categories['home'];
 
foreach ($breadcrumb_array as $category){
$link = "<a href=\"index.php?cat={$category[0]}\">{$category[1]}</a>";
$breadcrumb .= ' > ' . $link;
$BREADCRUMB_TEXT .= ' > ' . $category[1];
}
 
}else{ //Dont bother just add the Home link to breadcrumb
$breadcrumb = '<a href="index.php">'.$lang_list_categories['home'].'</a>';
$BREADCRUMB_TEXT = $lang_list_categories['home'];
}
//Add Link for album if aid is set
if (isset($CURRENT_ALBUM_DATA['aid'])){
$link = "<a href=\"thumbnails.php?album=".$CURRENT_ALBUM_DATA['aid']."\">".$CURRENT_ALBUM_DATA['title']."</a>";
$breadcrumb .= ' > ' . $link;
$BREADCRUMB_TEXT .= ' > ' . $CURRENT_ALBUM_DATA['title'];
}
}
 
 
 
 
 
/**************************************************************************
 
**************************************************************************/
 
// Compute image geometry based on max width / height
function compute_img_size($width, $height, $max)
{
global $CONFIG;
$thumb_use=$CONFIG['thumb_use'];
if($thumb_use=='ht') {
$ratio = $height / $max;
} elseif($thumb_use=='wd') {
$ratio = $width / $max;
} else {
$ratio = max($width, $height) / $max;
}
if ($ratio > 1.0) {
$image_size['reduced'] = true;
}
$ratio = max($ratio, 1.0);
$image_size['width'] = ceil($width / $ratio);
$image_size['height'] = ceil($height / $ratio);
$image_size['whole'] = 'width="'.$image_size['width'].'" height="'.$image_size['height'].'"';
if($thumb_use=='ht') {
$image_size['geom'] = ' height="'.$image_size['height'].'"';
} elseif($thumb_use=='wd') {
$image_size['geom'] = 'width="'.$image_size['width'].'"';
} else {
$image_size['geom'] = 'width="'.$image_size['width'].'" height="'.$image_size['height'].'"';
}
 
 
 
return $image_size;
}
 
// Prints thumbnails of pictures in an album
function display_thumbnails($album, $cat, $page, $thumbcols, $thumbrows, $display_tabs)
{
global $CONFIG, $AUTHORIZED, $HTTP_GET_VARS;
global $album_date_fmt, $lang_display_thumbnails, $lang_errors, $lang_byte_units;
 
$thumb_per_page = $thumbcols * $thumbrows;
$lower_limit = ($page-1) * $thumb_per_page;
 
$pic_data = get_pic_data($album, $thumb_count, $album_name, $lower_limit, $thumb_per_page);
 
$total_pages = ceil($thumb_count / $thumb_per_page);
 
$i = 0;
if (count($pic_data) > 0) {
foreach ($pic_data as $key => $row) {
$i++;
 
$pic_title =$lang_display_thumbnails['filename'].$row['filename']."\n".
$lang_display_thumbnails['filesize'].($row['filesize'] >> 10).$lang_byte_units[1]."\n".
$lang_display_thumbnails['dimensions'].$row['pwidth']."x".$row['pheight']."\n".
$lang_display_thumbnails['date_added'].localised_date($row['ctime'], $album_date_fmt);
 
$pic_url = get_pic_url($row, 'thumb');
if (!is_image($row['filename'])) {
$image_info = getimagesize($pic_url);
$row['pwidth'] = $image_info[0];
$row['pheight'] = $image_info[1];
}
 
$image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width']);
 
$thumb_list[$i]['pos'] = $key < 0 ? $key : $i - 1 + $lower_limit;
$thumb_list[$i]['image'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$row['filename']}\" title=\"$pic_title\">";
$thumb_list[$i]['caption'] = $row['caption_text'];
$thumb_list[$i]['admin_menu'] = '';
$thumb_list[$i]['aid'] = $row['aid'];
}
theme_display_thumbnails($thumb_list, $thumb_count, $album_name, $album, $cat, $page, $total_pages, is_numeric($album), $display_tabs);
} else {
theme_no_img_to_display($album_name);
}
}
 
/**
* Return an array containing the system thumbs in a directory
*/
function cpg_get_system_thumb_list($search_folder = 'images/')
{
global $CONFIG;
static $thumbs = array();
 
$folder = 'images/';
 
$thumb_pfx =& $CONFIG['thumb_pfx'];
// If thumb array is empty get list from coppermine 'images' folder
if ((count($thumbs) == 0) && ($folder == $search_folder)) {
$dir = opendir($folder);
while (($file = readdir($dir))!==false) {
if (is_file($folder . $file) && strpos($file,$thumb_pfx) === 0) {
// Store filenames in an array
$thumbs[] = array('filename' => $file);
}
}
closedir($dir);
return $thumbs;
} elseif ($folder == $search_folder) {
// Search folder is the same as coppermine images folder; just return the array
return $thumbs;
} else {
// Search folder is the different; check for files in the given folder
$results = array();
foreach ($thumbs as $thumb) {
if (is_file($search_folder.$thumb['filename'])) {
$results[] = array('filename' => $thumb['filename']);
}
}
return $results;
}
}
 
// Prints thumbnails of pictures in an album
function display_film_strip($album, $cat, $pos)
{
global $CONFIG, $AUTHORIZED, $HTTP_GET_VARS;
global $album_date_fmt, $lang_display_thumbnails, $lang_errors, $lang_byte_units;
$max_item=$CONFIG['max_film_strip_items'];
//$thumb_per_page = $pos+$CONFIG['max_film_strip_items'];
$thumb_per_page = $max_item*2;
$l_limit = max(0,$pos-$CONFIG['max_film_strip_items']);
$new_pos=max(0,$pos-$l_limit);
 
$pic_data = get_pic_data($album, $thumb_count, $album_name, $l_limit, $thumb_per_page);
 
if (count($pic_data) < $max_item ){
$max_item = count($pic_data);
}
$lower_limit=3;
 
if(!isset($pic_data[$new_pos+1])) {
$lower_limit=$new_pos-$max_item+1;
} else if(!isset($pic_data[$new_pos+2])) {
$lower_limit=$new_pos-$max_item+2;
} else if(!isset($pic_data[$new_pos-1])) {
$lower_limit=$new_pos;
} else {
$hf=$max_item/2;
$ihf=(int)($max_item/2);
if($new_pos > $hf ) {
//if($max_item%2==0) {
//$lower_limit=
//} else {
{
$lower_limit=$new_pos-$ihf;
}
}
elseif($new_pos < $hf ) { $lower_limit=0; }
}
 
$pic_data=array_slice($pic_data,$lower_limit,$max_item);
$i=$l_limit;
if (count($pic_data) > 0) {
foreach ($pic_data as $key => $row) {
$hi =(($pos==($i + $lower_limit)) ? '1': '');
$i++;
 
$pic_title =$lang_display_thumbnails['filename'].$row['filename']."\n".
$lang_display_thumbnails['filesize'].($row['filesize'] >> 10).$lang_byte_units[1]."\n".
$lang_display_thumbnails['dimensions'].$row['pwidth']."x".$row['pheight']."\n".
$lang_display_thumbnails['date_added'].localised_date($row['ctime'], $album_date_fmt);
 
$pic_url = get_pic_url($row, 'thumb');
if (!is_image($row['filename'])) {
$image_info = getimagesize($pic_url);
$row['pwidth'] = $image_info[0];
$row['pheight'] = $image_info[1];
}
 
$image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width']);
 
$p=$i - 1 + $lower_limit;
$p=($p < 0 ? 0 : $p);
$thumb_list[$i]['pos'] = $key < 0 ? $key : $p;
$thumb_list[$i]['image'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$row['filename']}\" title=\"$pic_title\">";
$thumb_list[$i]['caption'] = $row['caption_text'];
$thumb_list[$i]['admin_menu'] = '';
 
}
return theme_display_film_strip($thumb_list, $thumb_count, $album_name, $album, $cat, $pos, is_numeric($album));
} else {
theme_no_img_to_display($album_name);
}
}
 
// Return the url for a picture, allows to have pictures spreaded over multiple servers
function get_pic_url(&$pic_row, $mode)
{
global $CONFIG,$THEME_DIR;
 
static $pic_prefix = array();
static $url_prefix = array();
 
if (!count($pic_prefix)) {
$pic_prefix = array(
'thumb' => $CONFIG['thumb_pfx'],
'normal' => $CONFIG['normal_pfx'],
'fullsize' => ''
);
 
$url_prefix = array(
0 => $CONFIG['fullpath'],
);
}
 
$mime_content = get_type($pic_row['filename']);
$filepathname = null;
 
// Code to handle custom thumbnails
// If fullsize or normal mode use regular file
if ($mime_content['content'] != 'image' && $mode!= 'thumb') {
$mode = 'fullsize';
} elseif ($mime_content['content'] != 'image' && $mode == 'thumb') {
$thumb_extensions = Array('.gif','.png','.jpg');
// Check for user-level custom thumbnails
// Create custom thumb path and erase extension using filename; Erase filename's extension
$custom_thumb_path = $url_prefix[$pic_row['url_prefix']].$pic_row['filepath'].$pic_prefix[$mode];
$file_base_name = str_replace('.'.$mime_content['extension'],'',basename($pic_row['filename']));
// Check for file-specific thumbs
foreach ($thumb_extensions as $extension) {
if (file_exists($custom_thumb_path.$file_base_name.$extension)) {
$filepathname = $custom_thumb_path.$file_base_name.$extension;
break;
}
}
// Check for extension-specific thumbs
if (is_null($filepathname)) {
foreach ($thumb_extensions as $extension) {
if (file_exists($custom_thumb_path.$mime_content['extension'].$extension)) {
$filepathname = $custom_thumb_path.$mime_content['extension'].$extension;
break;
}
}
}
// Check for content-specific thumbs
if (is_null($filepathname)) {
foreach ($thumb_extensions as $extension) {
if (file_exists($custom_thumb_path.$mime_content['content'].$extension)) {
$filepathname = $custom_thumb_path.$mime_content['content'].$extension;
break;
}
}
}
// Use default thumbs
if (is_null($filepathname)) {
// Check for default theme- and global-level thumbs
$thumb_paths[] = $THEME_DIR.'/images/'; // Used for custom theme thumbs
$thumb_paths[] = 'images/'; // Default Coppermine thumbs
foreach ($thumb_paths as $default_thumb_path) {
if (is_dir($default_thumb_path)) {
foreach ($thumb_extensions as $extension) {
// Check for extension-specific thumbs
if (file_exists($default_thumb_path.$CONFIG['thumb_pfx'].$mime_content['extension'].$extension)) {
$filepathname = $default_thumb_path.$CONFIG['thumb_pfx'].$mime_content['extension'].$extension;
break 2;
}
}
foreach ($thumb_extensions as $extension) {
// Check for media-specific thumbs (movie,document,audio)
if (file_exists($default_thumb_path.$CONFIG['thumb_pfx'].$mime_content['content'].$extension)) {
$filepathname = $default_thumb_path.$CONFIG['thumb_pfx'].$mime_content['content'].$extension;
break 2;
}
}
}
}
}
return path2url($filepathname);
}
 
return $url_prefix[$pic_row['url_prefix']]. path2url($pic_row['filepath']. $pic_prefix[$mode]. $pic_row['filename']);
}
 
// Return a variable from the default language file
function& cpg_get_default_lang_var($language_var_name,$overide_language = null) {
global $CONFIG;
if (is_null($overide_language)) {
if (isset($CONFIG['default_lang'])) {
$language = $CONFIG['default_lang'];
} else {
$language = $CONFIG['lang'];
}
} else {
$language = $overide_language;
}
include('lang/'.$language.'.php');
return $$language_var_name;
}
 
// Returns a variable from the current language file
// If variable doesn't exists gets value from english lang file
function& cpg_lang_var($varname,$index=null) {
global $$varname;
 
$lang_var =& $$varname;
 
if (isset($lang_var)) {
if (!is_null($index) && !isset($lang_var[$index])) {
include('lang/english.php');
return $lang_var[$index];
} elseif (is_null($index)) {
return $lang_var;
} else {
return $lang_var[$index];
}
} else {
include('lang/english.php');
return $lang_var;
}
}
 
//defined new debug_output function here in functions.inc.php instead of theme.php with different function names to avoid incompatibilities with users not updating their themes as required. Advanced info is only output if (GALLERY_ADMIN_MODE == TRUE) - GauGau 2003-11-23
 
function cpg_debug_output()
{
global $HTTP_GET_VARS, $HTTP_POST_VARS, $HTTP_SERVER_VARS;
global $USER, $USER_DATA, $ALBUM_SET, $CONFIG, $time_start, $query_stats, $queries, $lang_cpg_debug_output;
$time_end = cpgGetMicroTime();
$time = round($time_end - $time_start, 3);
 
$query_count = count($query_stats);
$query_times = '';
$total_query_time = 0;
foreach ($query_stats as $qtime) {
$query_times .= round($qtime, 3) . "s ";
$total_query_time += $qtime;
}
$total_query_time = round($total_query_time, 3);
$debug_underline = '&#0010;------------------&#0010;';
$debug_separate = '&#0010;==========================&#0010;';
echo '<form name="debug">';
starttable('100%', $lang_cpg_debug_output['debug_info'],2);
echo '<tr><td align="center" valign="middle" class="tableh2">';
echo '<script language="Javascript">
<!--
 
function HighlightAll(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
}
//-->
</script>';
echo '
<div class="admin_menu"><a href="javascript:HighlightAll(\'debug.debugtext\')" class="adm_menu">' . $lang_cpg_debug_output['select_all'] . '</a></div>';
echo '</td><td align="left" valign="middle" class="tableh2">';
if (GALLERY_ADMIN_MODE){echo '<span class="album_stat">('.$lang_cpg_debug_output['copy_and_paste_instructions'].')</span>';}
echo '</td></tr>';
echo '<tr><td class="tableb" colspan="2">';
echo '<textarea rows="10" class="debug_text" name="debugtext">';
echo "USER: ";
echo $debug_underline;
print_r($USER);
echo $debug_separate;
echo "USER DATA:";
echo $debug_underline;
print_r($USER_DATA);
echo $debug_separate;
echo "Queries:";
echo $debug_underline;
print_r($queries);
echo $debug_separate;
echo "GET :";
echo $debug_underline;
print_r($HTTP_GET_VARS);
echo $debug_separate;
echo "POST :";
echo $debug_underline;
print_r($HTTP_POST_VARS);
echo $debug_separate;
if (GALLERY_ADMIN_MODE){
echo "VERSION INFO :";
echo $debug_underline;
$version_comment = ' - OK';
if (strcmp('4.0.0', phpversion()) == 1) {$version_comment = ' - your PHP version isn\'t good enough! Minimum requirements: 4.x';}
echo 'PHP version: ' . phpversion().$version_comment;
echo $debug_underline;
$version_comment = '';
$mySqlVersion = cpg_phpinfo_mysql_version();
if (strcmp('3.23.23', $mySqlVersion) == 1) {$version_comment = ' - your mySQL version isn\'t good enough! Minimum requirements: 3.23.23';}
echo 'mySQL version: ' . $mySqlVersion . $version_comment;
echo $debug_underline;
echo 'Coppermine version: ';
echo COPPERMINE_VERSION;
echo $debug_separate;
error_reporting (E_ERROR | E_WARNING | E_PARSE);
echo cpg_phpinfo_mod_output('gd','text');
echo cpg_phpinfo_mod_output('mysql','text');
echo cpg_phpinfo_mod_output('zlib','text');
echo 'Server restrictions (safe mode)?';
echo $debug_underline;
echo 'Directive | Local Value | Master Value';
echo cpg_phpinfo_conf_output("safe_mode");
echo cpg_phpinfo_conf_output("safe_mode_exec_dir");
echo cpg_phpinfo_conf_output("safe_mode_gid");
echo cpg_phpinfo_conf_output("safe_mode_include_dir");
echo cpg_phpinfo_conf_output("safe_mode_exec_dir");
echo cpg_phpinfo_conf_output("sql.safe_mode");
echo cpg_phpinfo_conf_output("disable_functions");
echo cpg_phpinfo_conf_output("file_uploads");
echo cpg_phpinfo_conf_output("include_path");
echo cpg_phpinfo_conf_output("open_basedir");
echo $debug_separate;
echo 'email';
echo $debug_underline;
echo 'Directive | Local Value | Master Value';
echo cpg_phpinfo_conf_output("sendmail_from");
echo cpg_phpinfo_conf_output("sendmail_path");
echo cpg_phpinfo_conf_output("SMTP");
echo cpg_phpinfo_conf_output("smtp_port");
echo $debug_separate;
echo 'Size and Time';
echo $debug_underline;
echo 'Directive | Local Value | Master Value';
echo cpg_phpinfo_conf_output("max_execution_time");
echo cpg_phpinfo_conf_output("max_input_time");
echo cpg_phpinfo_conf_output("upload_max_filesize");
echo cpg_phpinfo_conf_output("post_max_size");
echo $debug_separate;
}
 
echo <<<EOT
Page generated in $time seconds - $query_count queries in $total_query_time seconds - Album set : $ALBUM_SET
EOT;
echo "</textarea>";
echo "</td>";
echo "</tr>";
if (GALLERY_ADMIN_MODE){
echo "<tr><td class=\"tableb\" colspan=\"2\">";
echo "<a href=\"phpinfo.php\">".$lang_cpg_debug_output['phpinfo']."</a>";
error_reporting (E_ERROR | E_WARNING | E_PARSE);
echo "</td></tr>";
}
endtable();
echo "</form>";
}
 
//phpinfo-related functions:
function cpg_phpinfo_mod($search)
{
// this could be done much better with regexpr - anyone who wants to change it: go ahead
ob_start();
phpinfo(INFO_MODULES);
$string = ob_get_contents();
$module = $string;
$delimiter = '#cpgdelimiter#';
ob_end_clean();
// find out the first occurence of "<h2" and throw the superfluos stuff away
$string = strstr($string, 'module_' . $search);
$string = eregi_replace('</table>(.*)', '', $string);
$string = strstr($string, '<tr>');
$string = str_replace('</td>', '|', $string);
$string = str_replace('</tr>', $delimiter, $string);
$string = chop(strip_tags($string));
$pieces = explode($delimiter, $string);
foreach($pieces as $key => $val) {
$bits[$key] = explode("|", $val);
}
return $bits;
}
 
function cpg_phpinfo_mod_output($search,$output_type)
{
// first parameter is the module name, second parameter is the way you want your output to look like: table or text
$pieces = cpg_phpinfo_mod($search);
$summ = '';
$return = '';
$debug_underline = '&#0010;------------------&#0010;';
$debug_separate = '&#0010;==========================&#0010;';
 
if ($output_type == 'table')
{
ob_start();
starttable('100%', 'Module: '.$search, 2);
$return.= ob_get_contents();
ob_end_clean();
}
else
{
$return.= 'Module: '.$search.$debug_underline;
}
foreach($pieces as $val) {
if ($output_type == 'table') {$return.= '<tr><td>';}
$return.= $val[0];
if ($output_type == 'table') {$return.= '</td><td>';}
$return.= $val[1];
if ($output_type == 'table') {$return.= '</td></tr>';}
$summ .= $val[0];
}
if (!$summ) {
if ($output_type == 'table') {$return.= '<tr><td colspan="2">';}
$return.= 'module doesn\'t exist';
if ($output_type == 'table') {$return.= '</td></tr>';}
}
if ($output_type == 'table')
{
ob_start();
endtable();
$return.= ob_get_contents();
ob_end_clean();
}
else
{
$return.= $debug_separate;
}
return $return;
}
 
function cpg_phpinfo_mysql_version()
{
$result = db_query("SELECT VERSION() as version");
$row = mysql_fetch_row($result);
return $row[0];
}
 
function cpg_phpinfo_conf($search)
{
// this could be done much better with regexpr - anyone who wants to change it: go ahead
$string ='';
$pieces = '';
$delimiter = '#cpgdelimiter#';
$bits = '';
 
ob_start();
phpinfo(INFO_CONFIGURATION);
$string = ob_get_contents();
ob_end_clean();
// find out the first occurence of "</tr" and throw the superfluos stuff in front of it away
$string = strchr($string, '</tr>');
$string = str_replace('</td>', '|', $string);
$string = str_replace('</tr>', $delimiter, $string);
$string = chop(strip_tags($string));
$pieces = explode($delimiter, $string);
foreach($pieces as $val) {
$bits = explode("|", $val);
if (strchr($bits[0], $search)) {
return $bits;
}
}
}
 
function cpg_phpinfo_conf_output($search)
{
$pieces = cpg_phpinfo_conf($search);
$return= $pieces[0] . ' | ' . $pieces[1] . ' | ' . $pieces[2];
return $return;
}
 
// theme and language selection
function languageSelect($parameter)
{
global $CONFIG,$lang_language_selection;
$return= '';
$lineBreak = "\n";
 
//check if language display is enabled
if ($CONFIG['language_list'] == 0 && $parameter == 'list'){
return;
}
if ($CONFIG['language_flags'] == 0 && $parameter == 'flags'){
return;
}
 
 
 
 
// get the current language
//use the default language of the gallery
$cpgCurrentLanguage = $CONFIG['lang'];
 
// is a user logged in?
//has the user already chosen another language for himself?
//if($USER['lang']!=""){
// $cpgCurrentLanguage = $USER['lang'];
// }
//has the language been set to something else on the previous page?
if (isset($_GET['lang'])){
$cpgCurrentLanguage = $_GET['lang'];
}
//get the url and all vars except $lang
$cpgChangeUrl = $_SERVER["SCRIPT_NAME"]."?";
foreach ($_GET as $key => $value) {
if ($key!="lang"){$cpgChangeUrl.= $key . "=" . $value . "&";}
}
$cpgChangeUrl.= 'lang=';
 
 
// get an array of english and native language names and flags
// for now, use a static array definition here - this could later be made into a true database query
$lang_language_data['arabic'] = array('Arabic','&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577;','sa');
$lang_language_data['basque'] = array('Basque','Euskera','baq');
$lang_language_data['bosnian'] = array('Bosnian','Bosanski','ba');
$lang_language_data['brazilian_portuguese'] = array('Portuguese [Brazilian]','Portugu&ecirc;s Brasileiro','br');
$lang_language_data['bulgarian'] = array('Bulgarian','&#1041;&#1098;&#1083;&#1075;&#1072;&#1088;&#1089;&#1082;&#1080;','bg');
$lang_language_data['catalan'] = array('Catalan','Catal&agrave;','ct');
$lang_language_data['chinese_big5'] = array('Chinese-Big5','&#21488;&#28771;','tw');
$lang_language_data['chinese_gb'] = array('Chinese-GB2312','&#20013;&#22269;','cn');
$lang_language_data['croatian'] = array('Croatian','Hrvatski','hr');
$lang_language_data['czech'] = array('Czech','&#x010C;esky','cz');
$lang_language_data['danish'] = array('Danish','Dansk','dk');
$lang_language_data['dutch'] = array('Dutch','Nederlands','nl');
$lang_language_data['english'] = array('English','English','gb');
$lang_language_data['estonian'] = array('Estonian','Eesti','ee');
$lang_language_data['finnish'] = array('Finnish','Suomea','fi');
$lang_language_data['french'] = array('French','Fran&ccedil;ais','fr');
$lang_language_data['german'] = array('German','Deutsch','de');
$lang_language_data['greek'] = array('Greek','&#917;&#955;&#955;&#951;&#957;&#953;&#954;&#940;','gr');
$lang_language_data['hebrew'] = array('Hebrew','&#1506;&#1489;&#1512;&#1497;&#1514;','il');
$lang_language_data['hungarian'] = array('Hungarian','Magyarul','hu');
$lang_language_data['indonesian'] = array('Indonesian','Bahasa Indonesia','id');
$lang_language_data['italian'] = array('Italian','Italiano','it');
$lang_language_data['japanese'] = array('Japanese','&#26085;&#26412;&#35486;','jp');
$lang_language_data['korean'] = array('Korean','&#54620;&#44397;&#50612;','kr');
$lang_language_data['kurdish'] = array('Kurdish','&#1603;&#1608;&#1585;&#1583;&#1740;','ku');
$lang_language_data['latvian'] = array('Latvian','Latvian','lv');
$lang_language_data['malay'] = array('Malay','Bahasa Melayu','my');
$lang_language_data['norwegian'] = array('Norwegian','Norsk','no');
$lang_language_data['polish'] = array('Polish','Polski','pl');
$lang_language_data['portuguese'] = array('Portuguese [Portugal]','Portugu&ecirc;s','pt');
$lang_language_data['romanian'] = array('Romanian','Rom&acirc;n&atilde;','ro');
$lang_language_data['russian'] = array('Russian','&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;','ru');
$lang_language_data['slovak'] = array('Slovak','Slovensky','sl');
$lang_language_data['slovenian'] = array('Slovenian','Slovensko','si');
$lang_language_data['spanish'] = array('Spanish','Espa&ntilde;ol','es');
$lang_language_data['swedish'] = array('Swedish','Svenska','se');
$lang_language_data['thai'] = array('Thai','&#3652;&#3607;&#3618;','th');
$lang_language_data['turkish'] = array('Turkish','T&uuml;rk&ccedil;e','tr');
$lang_language_data['uighur'] = array('Uighur','Uighur','cn-xj');
$lang_language_data['vietnamese'] = array('Vietnamese','Tieng Viet','vn');
$lang_language_data['welsh'] = array('Welsh','Cymraeg','gb-cm');
 
// get list of available languages
$value = strtolower($CONFIG['lang']);
// is utf-8 selected?
if ($CONFIG['charset'] == 'utf-8') {
$cpg_charset = 'utf-8';
} else {
$cpg_charset = '';
}
$lang_dir = 'lang/';
$dir = opendir($lang_dir);
while ($file = readdir($dir)) {
if (is_file($lang_dir . $file) && strtolower(substr($file, -4)) == '.php') {
if (($cpg_charset != 'utf-8' && strstr($file,'utf-8') == false) || ($cpg_charset == 'utf-8' && strstr($file,'utf-8') == true)) {
$lang_array[] = strtolower(substr($file, 0 , -4));
}
}
}
closedir($dir);
natcasesort($lang_array);
 
//start the output
switch ($parameter) {
case 'flags':
if ($CONFIG['language_flags'] == 2){
$return.= $lang_language_selection['choose_language'].': ';
}
foreach ($lang_array as $language) {
$cpg_language_name = str_replace('-utf-8','', $language);
if (array_key_exists($cpg_language_name, $lang_language_data)){
$return.= $lineBreak . '<a href="' .$cpgChangeUrl. $language . '"><img src="images/flags/' . $lang_language_data[$cpg_language_name][2] . '.gif" border="0" width="16" height="10" alt="" title="';
$return.= $lang_language_data[$language][0];
if ($lang_language_data[$language][1] != $lang_language_data[$language][0]){
$return.= ' (' . $lang_language_data[$language][1] . ')';
}
$return.= '" /></a>&nbsp;' . $lineBreak;
}
}
if ($CONFIG['language_reset'] == 1){
$return.= '<a href="' .$cpgChangeUrl. 'xxx"><img src="images/flags/reset.gif" border="0" width="16" height="11" alt="" title="';
$return.= $lang_language_selection['reset_language'] . '" /></a>' . $lineBreak;
}
break;
case 'table':
$return = 'not yet implemented';
break;
default:
$return.= $lineBreak . '<form name="cpgChooseLanguage" action="' . $cpgChangeUrl . '" method="get" style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;display:inline">' . $lineBreak;
$return.= '<select name="cpgLanguageSelect" class="listbox_lang" onchange="if (this.options[this.selectedIndex].value) window.location.href=\'' . $cpgChangeUrl . '\' + this.options[this.selectedIndex].value;">' . $lineBreak;
$return.='<option selected="selected">' . $lang_language_selection['choose_language'] . '</option>' . $lineBreak;
foreach ($lang_array as $language) {
$return.= '<option value="' . $language . '" >';
if (array_key_exists($language, $lang_language_data)){
$return.= $lang_language_data[$language][0];
if ($lang_language_data[$language][1] != $lang_language_data[$language][0]){
$return.= ' (' . $lang_language_data[$language][1] . ')';
}
}
else{
$return.= ucfirst($language);
}
$return.= ($value == $language ? '*' : '');
$return.= '</option>' . $lineBreak;
}
if ($CONFIG['language_reset'] == 1){
$return.= '<option value="xxx">' . $lang_language_selection['reset_language'] . '</option>' . $lineBreak;
}
$return.= '</select>' . $lineBreak;
$return.= '</form>' . $lineBreak;
}
 
return $return;
}
 
function themeSelect($parameter)
{
global $CONFIG,$lang_theme_selection;
$return= '';
$lineBreak = "\n";
 
if ($CONFIG['theme_list'] == 0){
return;
}
 
// get the current theme
//get the url and all vars except $theme
$cpgCurrentTheme = $_SERVER["SCRIPT_NAME"]."?";
foreach ($_GET as $key => $value) {
if ($key!="theme"){$cpgCurrentTheme.= $key . "=" . $value . "&";}
}
$cpgCurrentTheme.="theme=";
 
// get list of available languages
$value = $CONFIG['theme'];
$theme_dir = 'themes/';
 
$dir = opendir($theme_dir);
while ($file = readdir($dir)) {
if (is_dir($theme_dir . $file) && $file != "." && $file != "..") {
$theme_array[] = $file;
}
}
closedir($dir);
 
natcasesort($theme_array);
 
//start the output
switch ($parameter) {
case 'table':
$return = 'not yet implemented';
break;
default:
$return.= $lineBreak . '<form name="cpgChooseTheme" action="' . $cpgCurrentTheme . '" method="get" style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;display:inline">' . $lineBreak;
$return.= '<select name="cpgThemeSelect" class="listbox_lang" onchange="if (this.options[this.selectedIndex].value) window.location.href=\'' . $cpgCurrentTheme . '\' + this.options[this.selectedIndex].value;">' . $lineBreak;
$return.='<option selected="selected">' . $lang_theme_selection['choose_theme'] . '</option>';
foreach ($theme_array as $theme) {
$return.= '<option value="' . $theme . '">' . strtr(ucfirst($theme), '_', ' ') . ($value == $theme ? '*' : ''). '</option>' . $lineBreak;
}
if ($CONFIG['theme_reset'] == 1){
$return.= '<option value="xxx">' . $lang_theme_selection['reset_theme'] . '</option>' . $lineBreak;
}
$return.= '</select>' . $lineBreak;
$return.= '</form>' . $lineBreak;
}
 
return $return;
}
 
 
 
 
 
?>
/web/test/gallery/cpg133/include/imageObjectGD.class.php
0,0 → 1,172
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2005 Coppermine Dev Team
v1.1 originaly written by Gregory DEMAR
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.3.3
$Source: /cvsroot/coppermine/stable/include/imageObjectGD.class.php,v $
$Revision: 1.5 $
$Author: gaugau $
$Date: 2005/04/19 03:17:11 $
**********************************************/
 
class imageObject{
 
// image resource
var $imgRes;
// px
var $height=0;
var $width=0;
// for img height/width tags
var $string;
// output report or error message
var $message;
// file + dir
var $directory;
var $filename;
// output quality, 0 - 100
var $quality;
// truecolor available, boolean
var $truecolor;
 
//constructor
function imageObject($directory,$filename,$previous=null)
{
$this->directory = $directory;
$this->filename = $filename;
$this->previous = $previous;
$this->imgRes = $previous->imgRes;
if (file_exists($directory.$filename)){
$this->filesize = round(filesize($directory.$filename)/1000);
if($this->filesize>0){
$size = @GetImageSize($directory.$filename);
if ($size && !$this->imgRes) {
$this->imgRes = $this->getimgRes($directory.$filename,$size[2]);
}
if (function_exists("imagecreatetruecolor")){
$this->truecolor = true;
}
$this->width = $size[0];
$this->height = $size[1];
$this->string = $size[3];
}
}// if
}// constructor
 
// private methods
function getimgRes($name,&$type)
{
switch ($type){
case 1:
$im = imagecreatefromgif($name);
break;
case 2:
$im = imagecreatefromjpeg($name);
break;
case 3:
$im = imagecreatefrompng($name);
break;
}
return $im;
}
 
 
function createUnique(&$imgnew)
{
srand((double)microtime()*100000);
$unique_str = "temp_".md5(rand(0,999999)).".jpg";
@imagejpeg($imgnew,$this->directory.$unique_str,$this->quality);
@imagedestroy($this->imgRes);
//Don't clutter with old images
@unlink($this->directory.$this->filename);
//Create a new ImageObject
return new imageObject($this->directory,$unique_str,$imgnew);
}
 
function createImage($new_w,$new_h)
{
if (function_exists("imagecreatetruecolor")){
$retval = @imagecreatetruecolor($new_w,$new_h);
}
if (!$retval) $retval = imagecreate($new_w,$new_h);
return $retval;
}
 
function cropImage(&$clipval)
{
$cliparray = split(",",$clipval);
$clip_top = $cliparray[0];
$clip_right = $cliparray[1];
$clip_bottom = $cliparray[2];
$clip_left = $cliparray[3];
 
$new_w = $clip_right - $clip_left;
$new_h = $clip_bottom - $clip_top;
 
$dst_img = $this->createImage($new_w,$new_h);
 
$result = @imagecopyresampled($dst_img, $this->imgRes, 0,0,$clip_left, $clip_top,$new_w, $new_h, $new_w, $new_h);
if (!$result) $result = @imagecopyresized($dst_img, $this->imgRes, 0,0,$clip_left, $clip_top,$new_w, $new_h, $new_w, $new_h);
 
return $this->createUnique($dst_img);
 
}
 
function rotateImage(&$angle){
 
if ($angle == 180){
$dst_img = @imagerotate($this->imgRes, $angle, 0);
}else{
$width = imagesx($this->imgRes);
$height = imagesy($this->imgRes);
if ($width > $height){
$size = $width;
}else{
$size = $height;
}
 
$dst_img = $this->createImage($size, $size);
imagecopy($dst_img, $this->imgRes, 0, 0, 0, 0, $width, $height);
$dst_img = @imagerotate($dst_img, $angle, 0);
$this->imgRes = $dst_img;
$dst_img = $this->createImage($height, $width);
 
if ((($angle == 90) && ($width > $height)) || (($angle == 270) && ($width < $height))){
imagecopy($dst_img, $this->imgRes, 0, 0, 0, 0, $size, $size);
 
}
 
if ((($angle == 270) && ($width > $height)) || (($angle == 90) && ($width < $height))){
imagecopy($dst_img, $this->imgRes, 0, 0, $size - $height, $size - $width, $size, $size);
}
}
 
return $this->createUnique($dst_img);
}
 
 
 
function resizeImage($new_w=0,$new_h=0){
 
$dst_img = $this->createImage($new_w,$new_h);
 
$result = @imagecopyresampled($dst_img, $this->imgRes, 0, 0, 0, 0, $new_w, $new_h, $this->width,$this->height);
if (!$result) $result = @imagecopyresized($dst_img, $this->imgRes, 0, 0, 0, 0, $new_w, $new_h, $this->width,$this->height);
return $this->createUnique($dst_img);
 
}
 
 
function saveImage(){
 
}
 
}
?>
/web/test/gallery/cpg133/include/imageObjectIM.class.php
0,0 → 1,169
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2005 Coppermine Dev Team
v1.1 originaly written by Gregory DEMAR
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.3.3
$Source: /cvsroot/coppermine/stable/include/imageObjectIM.class.php,v $
$Revision: 1.4 $
$Author: gaugau $
$Date: 2005/04/19 03:17:11 $
**********************************************/
 
class imageObject{
 
// image resource
var $imgRes;
// px
var $height=0;
var $width=0;
// for img height/width tags
var $string;
// output report or error message
var $message;
// file + dir
var $directory;
var $filename;
// output quality, 0 - 100
var $quality;
 
//constructor
function imageObject($directory,$filename,$previous=null)
{
$this->directory = $directory;
$this->filename = $filename;
$this->previous = $previous;
$this->truecolor = true;
 
if (file_exists($directory.$filename)){
$this->filesize = round(filesize($directory.$filename)/1000);
if($this->filesize>0){
$size = @GetImageSize($directory.$filename);
// For IM we don't need an Image Resource (work directly on file :)
if ($size && !$this->imgRes) {
$this->imgRes = true;
}
 
$this->width = $size[0];
$this->height = $size[1];
$this->string = $size[3];
}
}// if
}// constructor
 
function cropImage(&$clipval)
{
global $CONFIG;
$cliparray = split(",",$clipval);
$clip_top = $cliparray[0];
$clip_right = $cliparray[1];
$clip_bottom = $cliparray[2];
$clip_left = $cliparray[3];
 
$new_w = $clip_right - $clip_left;
$new_h = $clip_bottom - $clip_top;
 
 
$imgFile = escapeshellarg("$this->directory$this->filename");
 
 
$output = array();
 
/*
* Hack for working with ImageMagick on WIndows even if IM is installed in C:\Program Files.
* Also the options for -crop should not have space in between them.
* By Aditya Mooley <aditya@sanisoft.com>
*/
if (eregi("win",$_ENV['OS'])) {
$imgFile = str_replace("'","\"" ,$imgFile );
$cmd = "\"".str_replace("\\","/", $CONFIG['impath'])."convert\" -quality {$this->quality} {$CONFIG['im_options']} -crop {$new_w}x{$new_h}+{$clip_left}+{$clip_top} ".str_replace("\\","/" ,$imgFile )." ".str_replace("\\","/" ,$imgFile );
exec ("\"$cmd\"", $output, $retval);
} else {
$cmd = "{$CONFIG['impath']}convert -quality {$this->quality} {$CONFIG['im_options']} -crop '{$new_w}x{$new_h} +{$clip_left} +{$clip_top}' $imgFile $imgFile";
exec ($cmd, $output, $retval);
}
//$cmd = "{$CONFIG['impath']}convert -quality {$this->quality} {$CONFIG['im_options']} -crop '{$new_w}x{$new_h} +{$clip_left} +{$clip_top}' $imgFile $imgFile";
//exec ($cmd, $output, $retval);
 
//To Do check for errors in execution etc
 
// Call the constructor again to repopulate the dimensions etc
$this->imageObject($this->directory,$this->filename);
 
return $this;
 
}
 
function rotateImage(&$angle){
 
global $CONFIG;
$imgFile = escapeshellarg("$this->directory$this->filename");
 
$output = array();
 
/*
* Hack for working with ImageMagick on WIndows even if IM is installed in C:\Program Files.
* By Aditya Mooley <aditya@sanisoft.com>
*/
 
if (eregi("win",$_ENV['OS'])) {
$imgFile = str_replace("'","\"" ,$imgFile );
$cmd = "\"".str_replace("\\","/", $CONFIG['impath'])."convert\" -quality {$this->quality} {$CONFIG['im_options']} -rotate $angle ".str_replace("\\","/" ,$imgFile )." ".str_replace("\\","/" ,$imgFile );
exec ("\"$cmd\"", $output, $retval);
} else {
$cmd = "{$CONFIG['impath']}convert -quality {$this->quality} {$CONFIG['im_options']} -rotate '$angle' $imgFile $imgFile";
exec ($cmd, $output, $retval);
}
//$cmd = "{$CONFIG['impath']}convert -quality {$this->quality} {$CONFIG['im_options']} -rotate '$angle' $imgFile $imgFile";
//exec ($cmd, $output, $retval);
 
//To Do check for errors in execution etc
 
// Call the constructor again to repopulate the dimensions etc
$this->imageObject($this->directory,$this->filename);
return $this;
 
}
 
 
function resizeImage($new_w=0,$new_h=0){
 
global $CONFIG;
$imgFile = escapeshellarg("$this->directory$this->filename");
 
$output = array();
 
/*
* Hack for working with ImageMagick on WIndows even if IM is installed in C:\Program Files.
* By Aditya Mooley <aditya@sanisoft.com>
*/
if (eregi("win",$_ENV['OS'])) {
$imgFile = str_replace("'","\"" ,$imgFile );
$cmd = "\"".str_replace("\\","/", $CONFIG['impath'])."convert\" -quality {$this->quality} {$CONFIG['im_options']} -geometry {$new_w}x{$new_h} ".str_replace("\\","/" ,$imgFile )." ".str_replace("\\","/" ,$imgFile );
exec ("\"$cmd\"", $output, $retval);
} else {
$cmd = "{$CONFIG['impath']}convert -quality {$this->quality} {$CONFIG['im_options']} -geometry '{$new_w}x{$new_h}' $imgFile $imgFile";
exec ($cmd, $output, $retval);
}
 
//$cmd = "{$CONFIG['impath']}convert -quality {$this->quality} {$CONFIG['im_options']} -geometry '{$new_w}x{$new_h}' $imgFile $imgFile";
//exec ($cmd, $output, $retval);
 
//To Do check for errors in execution etc
 
// Call the constructor again to repopulate the dimensions etc
$this->imageObject($this->directory,$this->filename);
return $this;
 
}
 
 
}
?>
/web/test/gallery/cpg133/include/index.html
--- init.inc.php (nonexistent)
+++ init.inc.php (revision 6)
@@ -0,0 +1,396 @@
+<?php
+/*************************
+ Coppermine Photo Gallery
+ ************************
+ Copyright (c) 2003-2005 Coppermine Dev Team
+ v1.1 originaly written by Gregory DEMAR
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+ ********************************************
+ Coppermine version: 1.3.3
+ $Source: /cvsroot/coppermine/stable/include/init.inc.php,v $
+ $Revision: 1.15 $
+ $Author: gaugau $
+ $Date: 2005/04/19 21:54:31 $
+**********************************************/
+
+define('COPPERMINE_VERSION', '1.3.3');
+// User database integration
+// Uncomment the applicable line if you want to use it
+// define('UDB_INTEGRATION', 'phpbb');
+// define('UDB_INTEGRATION', 'invisionboard');
+// define('UDB_INTEGRATION', 'vbulletin23');
+// define('UDB_INTEGRATION', 'vbulletin30');
+// define('UDB_INTEGRATION', 'yabbse');
+// define('UDB_INTEGRATION', 'smf');
+// define('UDB_INTEGRATION', 'woltlab21');
+// define('UDB_INTEGRATION', 'punbb');
+if (!defined('IN_COPPERMINE')) die('Not in Coppermine...');
+// Start output buffering
+ob_start();
+// Report all errors except E_NOTICE
+// This is the default value set in php.ini
+// error_reporting (E_ALL ^ E_NOTICE);
+error_reporting(E_ALL);
+
+set_magic_quotes_runtime(0);
+// used for timing purpose
+$query_stats = array();
+$queries = array();
+
+// Perform database queries to calculate user's privileges based on group membership
+function cpgGetUserData($pri_group, $groups, $default_group_id = 3)
+{
+
+ //Parameters :
+ // $pri_group (scalar) : Group ID number of the user's 'main' group. This is the group that will be
+ // the user's profile display. ($USER_DATA['group_id'])
+ //
+ // $groups (array) : List of group ids of all the groups that the user is a member of. IF this list
+ // does not include the $pri_group, it will be added.
+ //
+ // $default_group_id (scalar) : The group used as a fall-back if no valid group ids are specified.
+ // If this group also does not exist then CPG will abort with a critical
+ // error.
+ //
+ // Returns an array containing most of the data to put into in $USER_DATA.
+
+ global $CONFIG;
+
+ foreach ($groups as $key => $val)
+ if (!is_numeric($val))
+ unset ($groups[$key]);
+ if (!in_array($pri_group, $groups)) array_push($groups, $pri_group);
+
+ $result = db_query("SELECT MAX(group_quota) as disk_max, MIN(group_quota) as disk_min, " .
+ "MAX(can_rate_pictures) as can_rate_pictures, MAX(can_send_ecards) as can_send_ecards, " .
+ "MAX(upload_form_config) as ufc_max, MIN(upload_form_config) as ufc_min, " .
+ "MAX(custom_user_upload) as custom_user_upload, MAX(num_file_upload) as num_file_upload, " .
+ "MAX(num_URI_upload) as num_URI_upload, " .
+ "MAX(can_post_comments) as can_post_comments, MAX(can_upload_pictures) as can_upload_pictures, " .
+ "MAX(can_create_albums) as can_create_albums, " .
+ "MAX(has_admin_access) as has_admin_access, " .
+ "MIN(pub_upl_need_approval) as pub_upl_need_approval, MIN( priv_upl_need_approval) as priv_upl_need_approval ".
+ "FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id in (" . implode(",", $groups). ")");
+
+ if (mysql_num_rows($result)) {
+ $USER_DATA = mysql_fetch_assoc($result);
+ $result = db_query("SELECT group_name FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id= " . $pri_group);
+ $temp_arr = mysql_fetch_assoc($result);
+ $USER_DATA["group_name"] = $temp_arr["group_name"];
+ } else {
+ $result = db_query("SELECT * FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id = $default_group_id");
+ if (!mysql_num_rows($resultt)) die('<b>Coppermine critical error</b>:<br />The group table does not contain the Anonymous group !');
+ $USER_DATA = mysql_fetch_assoc($result);
+ }
+ mysql_free_result($result);
+
+ if ( $USER_DATA['ufc_max'] == $USER_DATA['ufc_min'] ) {
+ $USER_DATA["upload_form_config"] = $USER_DATA['ufc_min'];
+ } elseif ($USER_DATA['ufc_min'] == 0) {
+ $USER_DATA["upload_form_config"] = $USER_DATA['ufc_max'];
+ } elseif ((($USER_DATA['ufc_max'] == 2) or ($USER_DATA['ufc_max'] == 3)) and ($USER_DATA['ufc_min'] == 1)) {
+ $USER_DATA["upload_form_config"] = 3;
+ } elseif (($USER_DATA['ufc_max'] == 3) and ($USER_DATA['ufc_min'] == 2)) {
+ $USER_DATA["upload_form_config"] = 3;
+ } else {
+ $USER_DATA["upload_form_config"] = 0;
+ }
+ $USER_DATA["group_quota"] = ($USER_DATA["disk_min"])?$USER_DATA["disk_max"]:0;
+
+ $USER_DATA['can_see_all_albums'] = $USER_DATA['has_admin_access'];
+
+ $USER_DATA["group_id"] = $pri_group;
+ $USER_DATA['groups'] = $groups;
+
+ if (get_magic_quotes_gpc() == 0)
+ $USER_DATA['group_name'] = mysql_escape_string($USER_DATA['group_name']);
+
+ return($USER_DATA);
+}
+
+
+function cpgGetMicroTime()
+{
+ list($usec, $sec) = explode(" ", microtime());
+ return ((float)$usec + (float)$sec);
+}
+$time_start = cpgGetMicroTime();
+// Do some cleanup in GET, POST and cookie data and un-register global vars
+$HTML_SUBST = array('"' => '&quot;', '<' => '&lt;', '>' => '&gt;');
+if (get_magic_quotes_gpc()) {
+ if (is_array($HTTP_POST_VARS)) {
+ foreach ($HTTP_POST_VARS as $key => $value) {
+ if (!is_array($value))
+ $HTTP_POST_VARS[$key] = strtr(stripslashes($value), $HTML_SUBST);
+ if (isset($$key)) unset($$key);
+ }
+ }
+
+ if (is_array($HTTP_GET_VARS)) {
+ foreach ($HTTP_GET_VARS as $key => $value) {
+ $HTTP_GET_VARS[$key] = strtr(stripslashes($value), $HTML_SUBST);
+ if (isset($$key)) unset($$key);
+ }
+ }
+
+ if (is_array($HTTP_COOKIE_VARS)) {
+ foreach ($HTTP_COOKIE_VARS as $key => $value) {
+ if (!is_array($value))
+ $HTTP_COOKIE_VARS[$key] = stripslashes($value);
+ if (isset($$key)) unset($$key);
+ }
+ }
+} else {
+ if (is_array($HTTP_POST_VARS)) {
+ foreach ($HTTP_POST_VARS as $key => $value) {
+ if (!is_array($value))
+ $HTTP_POST_VARS[$key] = strtr($value, $HTML_SUBST);
+ if (isset($$key)) unset($$key);
+ }
+ }
+
+ if (is_array($HTTP_GET_VARS)) {
+ foreach ($HTTP_GET_VARS as $key => $value) {
+ $HTTP_GET_VARS[$key] = strtr($value, $HTML_SUBST);
+ if (isset($$key)) unset($$key);
+ }
+ }
+
+ if (is_array($HTTP_COOKIE_VARS)) {
+ foreach ($HTTP_COOKIE_VARS as $key => $value) {
+ if (isset($$key)) unset($$key);
+ }
+ }
+}
+// Initialise the $CONFIG array and some other variables
+$CONFIG = array();
+$PHP_SELF = isset($HTTP_SERVER_VARS['REDIRECT_URL']) ? $HTTP_SERVER_VARS['REDIRECT_URL'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
+$REFERER = urlencode($PHP_SELF . (isset($HTTP_SERVER_VARS['QUERY_STRING']) && $HTTP_SERVER_VARS['QUERY_STRING'] ? '?' . $HTTP_SERVER_VARS['QUERY_STRING'] : ''));
+$ALBUM_SET = '';
+$FORBIDDEN_SET = '';
+$CURRENT_CAT_NAME = '';
+$CAT_LIST = '';
+// Record User's IP address
+$raw_ip = stripslashes($HTTP_SERVER_VARS['REMOTE_ADDR']);
+
+if (isset($HTTP_SERVER_VARS['HTTP_CLIENT_IP'])) {
+ $hdr_ip = stripslashes($HTTP_SERVER_VARS['HTTP_CLIENT_IP']);
+} else {
+ if (isset($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR'])) {
+ $hdr_ip = stripslashes($HTTP_SERVER_VARS['HTTP_X_FORWARDED_FOR']);
+ } else {
+ $hdr_ip = $raw_ip;
+ }
+}
+
+if (!preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $raw_ip)) $raw_ip = '0.0.0.0';
+if (!preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $hdr_ip)) $hdr_ip = '0.0.0.0';
+
+// Define some constants
+define('USER_GAL_CAT', 1);
+define('FIRST_USER_CAT', 10000);
+define('RANDPOS_MAX_PIC', 200);
+define('TEMPLATE_FILE', 'template.html');
+// Constants used by the cpg_die function
+define('INFORMATION', 1);
+define('ERROR', 2);
+define('CRITICAL_ERROR', 3);
+
+// Include config and functions files
+if(file_exists('include/config.inc.php')){
+ require 'include/config.inc.php';
+} else {
+ // error handling: if the config file doesn't exist go to install
+ print <<< EOT
+<html>
+ <head>
+ <title>Coppermine not installed yet</title>
+ <meta http-equiv="refresh" content="10;url=install.php">
+ <style type="text/css">
+ <!--
+ body { font-size: 12px; background: #FFFFFF; margin: 20%; color: black; font-family: verdana, arial, helvetica, sans-serif;}
+ -->
+ </style>
+ </head>
+ <body>
+ <img src="images/coppermine_logo.png" alt="Coppermine Photo Gallery - Your Online Photo Gallery" /><br />
+ Coppermine Photo Gallery seems not to be installed correctly, or you're running coppermine for the first time. You'll be redirected to the installer. If your browser doesn't support redirect, click <a href="install.php">here</a>.
+ </body>
+</html>
+EOT;
+ die();
+}
+require 'include/functions.inc.php';
+
+$CONFIG['TABLE_PICTURES'] = $CONFIG['TABLE_PREFIX']."pictures";
+$CONFIG['TABLE_ALBUMS'] = $CONFIG['TABLE_PREFIX']."albums";
+$CONFIG['TABLE_COMMENTS'] = $CONFIG['TABLE_PREFIX']."comments";
+$CONFIG['TABLE_CATEGORIES'] = $CONFIG['TABLE_PREFIX']."categories";
+$CONFIG['TABLE_CONFIG'] = $CONFIG['TABLE_PREFIX']."config";
+$CONFIG['TABLE_USERGROUPS'] = $CONFIG['TABLE_PREFIX']."usergroups";
+$CONFIG['TABLE_VOTES'] = $CONFIG['TABLE_PREFIX']."votes";
+$CONFIG['TABLE_USERS'] = $CONFIG['TABLE_PREFIX']."users";
+$CONFIG['TABLE_BANNED'] = $CONFIG['TABLE_PREFIX']."banned";
+$CONFIG['TABLE_EXIF'] = $CONFIG['TABLE_PREFIX']."exif";
+$CONFIG['TABLE_FILETYPES'] = $CONFIG['TABLE_PREFIX']."filetypes";
+$CONFIG['TABLE_ECARDS'] = $CONFIG['TABLE_PREFIX']."ecards";
+$CONFIG['TABLE_TEMPDATA'] = $CONFIG['TABLE_PREFIX']."temp_data";
+
+// User DB system
+if (defined('UDB_INTEGRATION')) require 'bridge/' . UDB_INTEGRATION . '.inc.php';
+// Connect to database
+cpg_db_connect() || die("<b>Coppermine critical error</b>:<br />Unable to connect to database !<br /><br />MySQL said: <b>" . mysql_error() . "</b>");
+// Retrieve DB stored configuration
+$results = db_query("SELECT * FROM {$CONFIG['TABLE_CONFIG']}");
+while ($row = mysql_fetch_array($results)) {
+ $CONFIG[$row['name']] = $row['value'];
+} // while
+mysql_free_result($results);
+
+require 'include/media.functions.inc.php';
+
+// Parse cookie stored user profile
+user_get_profile();
+// Authenticate
+if (defined('UDB_INTEGRATION')) {
+ udb_authenticate();
+} else {
+ if (!isset($HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_uid']) || !isset($HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_pass'])) {
+ $cookie_uid = 0;
+ $cookie_pass = '*';
+ } else {
+ $cookie_uid = (int)$HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_uid'];
+ $cookie_pass = substr(addslashes($HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_pass']), 0, 32);
+ }
+
+ $sql = "SELECT * " . "FROM {$CONFIG['TABLE_USERS']} WHERE user_id='$cookie_uid'" . "AND user_active = 'YES' " . "AND user_password != '' " . "AND BINARY MD5(user_password) = '$cookie_pass'";
+ $results = db_query($sql);
+
+ if (mysql_num_rows($results)) {
+ $USER_DATA = mysql_fetch_assoc($results);
+ //unset($USER_DATA['user_password']);
+ $USER_DATA['user_password'] = '********';
+
+ $USER_DATA = $USER_DATA + cpgGetUserData($USER_DATA['user_group'], explode(',', $USER_DATA['user_group_list']));
+
+ define('USER_ID', (int)$USER_DATA['user_id']);
+ define('USER_NAME', $USER_DATA['user_name']);
+ define('USER_GROUP', $USER_DATA['group_name']);
+ define('USER_GROUP_SET', '(' . implode(',', $USER_DATA['groups']) . ')');
+ define('USER_IS_ADMIN', (int)$USER_DATA['has_admin_access']);
+ define('USER_CAN_SEND_ECARDS', (int)$USER_DATA['can_send_ecards']);
+ define('USER_CAN_RATE_PICTURES', (int)$USER_DATA['can_rate_pictures']);
+ define('USER_CAN_POST_COMMENTS', (int)$USER_DATA['can_post_comments']);
+ define('USER_CAN_UPLOAD_PICTURES', (int)$USER_DATA['can_upload_pictures']);
+ define('USER_CAN_CREATE_ALBUMS', (int)$USER_DATA['can_create_albums']);
+ define('USER_UPLOAD_FORM', (int)$USER_DATA['upload_form_config']);
+ define('CUSTOMIZE_UPLOAD_FORM', (int)$USER_DATA['custom_user_upload']);
+ define('NUM_FILE_BOXES', (int)$USER_DATA['num_file_upload']);
+ define('NUM_URI_BOXES', (int)$USER_DATA['num_URI_upload']);
+ mysql_free_result($results);
+ } else {
+ $USER_DATA = cpgGetUserData(3, array(3));
+ define('USER_ID', 0);
+ define('USER_NAME', 'Anonymous');
+ define('USER_GROUP', $USER_DATA['group_name']);
+ define('USER_GROUP_SET', '(' . $USER_DATA['group_id'] . ')');
+ define('USER_IS_ADMIN', 0);
+ define('USER_CAN_SEND_ECARDS', (int)$USER_DATA['can_send_ecards']);
+ define('USER_CAN_RATE_PICTURES', (int)$USER_DATA['can_rate_pictures']);
+ define('USER_CAN_POST_COMMENTS', (int)$USER_DATA['can_post_comments']);
+ define('USER_CAN_UPLOAD_PICTURES', (int)$USER_DATA['can_upload_pictures']);
+ define('USER_CAN_CREATE_ALBUMS', 0);
+ define('USER_UPLOAD_FORM', (int)$USER_DATA['upload_form_config']);
+ define('CUSTOMIZE_UPLOAD_FORM', (int)$USER_DATA['custom_user_upload']);
+ define('NUM_FILE_BOXES', (int)$USER_DATA['num_file_upload']);
+ define('NUM_URI_BOXES', (int)$USER_DATA['num_URI_upload']);
+ mysql_free_result($results);
+ }
+}
+// Test if admin mode
+$USER['am'] = isset($USER['am']) ? (int)$USER['am'] : 0;
+define('GALLERY_ADMIN_MODE', USER_IS_ADMIN && $USER['am']);
+define('USER_ADMIN_MODE', USER_ID && USER_CAN_CREATE_ALBUMS && $USER['am'] && !GALLERY_ADMIN_MODE);
+// Set error logging level
+if ($CONFIG['debug_notice']==1 && ($CONFIG['debug_mode']==1 || ($CONFIG['debug_mode']==2 && GALLERY_ADMIN_MODE ))) {
+ error_reporting (E_ALL);
+} else {
+ error_reporting (E_ALL ^ E_NOTICE);
+}
+
+
+// Process theme selection if present in URI or in user profile
+if (!empty($HTTP_GET_VARS['theme'])) {
+ $USER['theme'] = $HTTP_GET_VARS['theme'];
+}
+// Load theme file
+if (isset($USER['theme']) && !strstr($USER['theme'], '/') && is_dir('themes/' . $USER['theme'])) {
+ $CONFIG['theme'] = strtr($USER['theme'], '$/\\:*?"\'<>|`', '____________');
+} else {
+ unset($USER['theme']);
+}
+
+if (!file_exists("themes/{$CONFIG['theme']}/theme.php")) $CONFIG['theme'] = 'classic';
+require "themes/{$CONFIG['theme']}/theme.php";
+$THEME_DIR = "themes/{$CONFIG['theme']}/";
+// Process language selection if present in URI or in user profile or try
+// autodetection if default charset is utf-8
+if (!empty($HTTP_GET_VARS['lang'])) {
+ $USER['lang'] = $HTTP_GET_VARS['lang'];
+}
+
+if (isset($USER['lang']) && !strstr($USER['lang'], '/') && file_exists('lang/' . $USER['lang'] . '.php')) {
+ $CONFIG['default_lang'] = $CONFIG['lang']; // Save default language
+ $CONFIG['lang'] = strtr($USER['lang'], '$/\\:*?"\'<>|`', '____________');
+} elseif ($CONFIG['charset'] == 'utf-8') {
+ include('include/select_lang.inc.php');
+ if (file_exists('lang/' . $USER['lang'] . '.php')) {
+ $CONFIG['default_lang'] = $CONFIG['lang']; // Save default language
+ $CONFIG['lang'] = $USER['lang'];
+ }
+} else {
+ unset($USER['lang']);
+}
+
+if (!file_exists("lang/{$CONFIG['lang']}.php")) $CONFIG['lang'] = 'english';
+require "lang/{$CONFIG['lang']}.php";
+// See if the fav cookie is set else set it
+if (isset($HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_fav'])) {
+ $FAVPICS = @unserialize(@base64_decode($HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_fav']));
+ foreach ($FAVPICS as $key => $id ){
+ $FAVPICS[$key] = (int)$id; //protect against sql injection attacks
+ }
+} else {
+ $FAVPICS = array();
+}
+// load the main template
+load_template();
+// Remove expired bans
+$now = date('Y-m-d H:i:s');
+db_query("DELETE FROM {$CONFIG['TABLE_BANNED']} WHERE expiry < '$now'");
+// Check if the user is banned
+$user_id = USER_ID;
+$result = db_query("SELECT * FROM {$CONFIG['TABLE_BANNED']} WHERE ip_addr='$raw_ip' OR ip_addr='$hdr_ip' OR user_id=$user_id");
+if (mysql_num_rows($result)) {
+ pageheader($lang_error);
+ msg_box($lang_info, $lang_errors['banned']);
+ pagefooter();
+ exit;
+}
+mysql_free_result($result);
+// Retrieve the "private" album set
+if (!GALLERY_ADMIN_MODE && $CONFIG['allow_private_albums']) get_private_album_set();
+
+if (!USER_IS_ADMIN && $CONFIG['offline'] && !strstr($_SERVER["SCRIPT_NAME"],'login')) {
+pageheader($lang_errors['offline_title']);
+msg_box($lang_errors['offline_title'], $lang_errors['offline_text']);
+pagefooter();
+exit;
+}
+
+
+?>
\ No newline at end of file
/web/test/gallery/cpg133/include/iptc.inc.php
0,0 → 1,51
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2005 Coppermine Dev Team
v1.1 originaly written by Gregory DEMAR
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.3.3
$Source: /cvsroot/coppermine/stable/include/iptc.inc.php,v $
$Revision: 1.4 $
$Author: gaugau $
$Date: 2005/04/19 03:17:11 $
**********************************************/
 
function get_IPTC($filename) {
$size = GetImageSize ($filename, $info);
if (isset($info["APP13"])) {
$iptc = iptcparse($info["APP13"]);
if (is_array($iptc)) {
$IPTC_data=array( "Title" => $iptc["2#005"][0], # Max 65 octets, non-repeatable, alphanumeric
"Urgency" => $iptc["2#010"][0], # Max 1 octet, non-repeatable, numeric, 1 - High, 8 - Low
"Category" => $iptc["2#015"][0], # Max 3 octets, non-repeatable, alpha
"SubCategories" => $iptc["2#020"], # Max 32 octets, repeatable, alphanumeric
"Keywords" => $iptc["2#025"], # Max 64 octets, repeatable, alphanumeric
"Instructions" => $iptc["2#040"][0], # Max 256 octets, non-repeatable, alphanumeric
"CreationDate" => $iptc["2#055"][0], # Max 8 octets, non-repeatable, numeric, YYYYMMDD
"CreationTime" => $iptc["2#060"][0], # Max 11 octets, non-repeatable, numeric+-, HHMMSS(+|-)HHMM
"ProgramUsed" => $iptc["2#065"][0], # Max 32 octets, non-repeatable, alphanumeric
"Author" => $iptc["2#080"][0], #!Max 32 octets, repeatable, alphanumeric
"Position" => $iptc["2#085"][0], #!Max 32 octets, repeatable, alphanumeric
"City" => $iptc["2#090"][0], # Max 32 octets, non-repeatable, alphanumeric
"State" => $iptc["2#095"][0], # Max 32 octets, non-repeatable, alphanumeric
"Country" => $iptc["2#101"][0], # Max 64 octets, non-repeatable, alphanumeric
"TransmissionReference" => $iptc["2#103"][0], # Max 32 octets, non-repeatable, alphanumeric
"Headline" => $iptc["2#105"][0], # Max 256 octets, non-repeatable, alphanumeric
"Credit" => $iptc["2#110"][0], # Max 32 octets, non-repeatable, alphanumeric
"Source" => $iptc["2#115"][0], # Max 32 octets, non-repeatable, alphanumeric
"Copyright" => $iptc["2#116"][0], # Max 128 octets, non-repeatable, alphanumeric
"Caption" => $iptc["2#120"][0], # Max 2000 octets, non-repeatable, alphanumeric
"CaptionWriter" => $iptc["2#122"][0] # Max 32 octets, non-repeatable, alphanumeric
);
} else $IPTC_data=array();
}
return $IPTC_data;
}
?>
/web/test/gallery/cpg133/include/mailer.inc.php
0,0 → 1,233
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2005 Coppermine Dev Team
v1.1 originaly written by Gregory DEMAR
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.3.3
$Source: /cvsroot/coppermine/stable/include/mailer.inc.php,v $
$Revision: 1.6 $
$Author: gaugau $
$Date: 2005/04/19 03:17:11 $
**********************************************/
 
$CONFIG['smtp_host'] = '';
$CONFIG['smtp_username'] = '';
$CONFIG['smtp_password'] = '';
// Custom mail function
function cpg_mail($to, $subject, $msg_body, $type = 'text/plain', $sender_name = '', $sender_email = '')
{
global $CONFIG;
global $lang_charset;
 
if ($sender_name == '') $sender_name = $CONFIG['gallery_name'];
if ($sender_email == '') $sender_email = $CONFIG['gallery_admin_email'];
 
$charset = $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'];
 
$extra_headers = "From: $sender_name <$sender_email>\n" . "MIME-Version: 1.0\n" . "Content-type: $type; charset=" . $charset . "\n" . "Content-transfer-encoding: 8bit\n" . "Date: " . gmdate('D, d M Y H:i:s', time()) . " UT\n" ."X-Priority: 3 (Normal)\n" ."X-MSMail-Priority: Normal\n" . "X-Mailer: Coppermine Photo Gallery\n" ."Importance: Normal";
// Fix any bare linefeeds in the message to make it RFC821 Compliant.
 
$message = preg_replace("/(?<!\r)\n/si", "\r\n", $msg_body);
 
if (empty($CONFIG['smtp_host'])) {
return mail($to, $subject, $msg_body, $extra_headers);
} else {
return smtp_mail($to, $subject, $msg_body, $extra_headers);
}
}
 
/**
* smtp.php
* -------------------
* begin : Wed May 09 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id: mailer.inc.php,v 1.6 2005/04/19 03:17:11 gaugau Exp $
*/
 
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
 
// This function has been modified as provided
// by SirSir to allow multiline responses when
// using SMTP Extensions
 
function server_parse($socket, $response)
{
while (substr($server_response, 3, 1) != ' ') {
if (!($server_response = fgets($socket, 256))) {
cpg_die(ERROR, "Couldn't get mail server response codes", __FILE__, __LINE__);
}
}
 
if (!(substr($server_response, 0, 3) == $response)) {
cpg_die(ERROR, "Ran into problems sending Mail. Response: $server_response", "", __FILE__, __LINE__);
}
}
 
/**
* Function: smtpmail
* Description: This is a functional replacement for php's builtin mail
* function, that uses smtp.
* Usage: The usage for this function is identical to that of php's
* built in mail function.
*/
function smtp_mail($mail_to, $subject, $message, $headers = "")
{
// For now I'm using an array based $smtp_vars to hold the smtp server
// info, but it should probably change to $CONFIG...
// then the relevant info would be $CONFIG['smtp_host'] and
// $CONFIG['smtp_port'].
global $CONFIG;
 
// Fix any bare linefeeds in the message to make it RFC821 Compliant.
 
$message = preg_replace("/(?<!\r)\n/si", "\r\n", $message);
 
if ($headers != "") {
if (is_array($headers)) {
if (sizeof($headers) > 1) {
$headers = join("\n", $headers);
} else {
$headers = $headers[0];
}
}
$headers = chop($headers);
 
// Make sure there are no bare linefeeds in the headers
 
$headers = preg_replace("/(?<!\r)\n/si", "\r\n", $headers);
 
// Ok this is rather confusing all things considered,
// but we have to grab bcc and cc headers and treat them differently
// Something we really didn't take into consideration originally
 
$header_array = explode("\n", $headers);
@reset($header_array);
$headers = "";
while (list(, $header) = each($header_array)) {
if (preg_match("/^cc:/si", $header)) {
$cc = preg_replace("/^cc:(.*)/si", "\\1", $header);
} else if (preg_match("/^bcc:/si", $header)) {
$bcc = preg_replace("/^bcc:(.*)/si", "\\1", $header);
$header = "";
}
$headers .= $header . "\n";
}
$headers = chop($headers);
$cc = explode(",", $cc);
$bcc = explode(",", $bcc);
}
if (trim($mail_to) == "") {
cpg_die(ERROR, "No email address specified", __FILE__, __LINE__);
}
if (trim($subject) == "") {
cpg_die(ERROR, "No email Subject specified", __FILE__, __LINE__);
}
if (trim($message) == "") {
cpg_die(ERROR, "Email message was blank", __FILE__, __LINE__);
}
$mail_to_array = explode(",", $mail_to);
 
// Ok we have error checked as much as we can to this point let's get on
// it already.
 
if (!$socket = fsockopen($CONFIG['smtp_host'], 25, $errno, $errstr, 20)) {
cpg_die(ERROR, "Could not connect to smtp host : $errno : $errstr", __FILE__, __LINE__);
}
server_parse($socket, "220");
 
if (!empty($CONFIG['smtp_username']) && !empty($CONFIG['smtp_password'])) {
// Send the RFC2554 specified EHLO.
// This improved as provided by SirSir to accomodate
// both SMTP AND ESMTP capable servers
fputs($socket, "EHLO " . $CONFIG['smtp_host'] . "\r\n");
server_parse($socket, "250");
 
fputs($socket, "AUTH LOGIN\r\n");
server_parse($socket, "334");
fputs($socket, base64_encode($CONFIG['smtp_username']) . "\r\n");
server_parse($socket, "334");
fputs($socket, base64_encode($CONFIG['smtp_password']) . "\r\n");
server_parse($socket, "235");
} else {
// Send the RFC821 specified HELO.
fputs($socket, "HELO " . $CONFIG['smtp_host'] . "\r\n");
server_parse($socket, "250");
}
// From this point onward most server response codes should be 250
// Specify who the mail is from....
fputs($socket, "MAIL FROM: <" . $CONFIG['gallery_admin_email'] . ">\r\n");
server_parse($socket, "250");
// Specify each user to send to and build to header.
$to_header = "To: ";
@reset($mail_to_array);
while (list(, $mail_to_address) = each($mail_to_array)) {
 
// Add an additional bit of error checking to the To field.
 
$mail_to_address = trim($mail_to_address);
if (preg_match('/[^ ]+\@[^ ]+/', $mail_to_address)) {
fputs($socket, "RCPT TO: <$mail_to_address>\r\n");
server_parse($socket, "250");
}
$to_header .= (($mail_to_address != '') ? ', ' : '') . "<$mail_to_address>";
}
// Ok now do the CC and BCC fields...
@reset($bcc);
while (list(, $bcc_address) = each($bcc)) {
 
// Add an additional bit of error checking to bcc header...
 
$bcc_address = trim($bcc_address);
if (preg_match('/[^ ]+\@[^ ]+/', $bcc_address)) {
fputs($socket, "RCPT TO: <$bcc_address>\r\n");
server_parse($socket, "250");
}
}
@reset($cc);
while (list(, $cc_address) = each($cc)) {
 
// Add an additional bit of error checking to cc header
 
$cc_address = trim($cc_address);
if (preg_match('/[^ ]+\@[^ ]+/', $cc_address)) {
fputs($socket, "RCPT TO: <$cc_address>\r\n");
server_parse($socket, "250");
}
}
// Ok now we tell the server we are ready to start sending data
fputs($socket, "DATA\r\n");
// This is the last response code we look for until the end of the message.
server_parse($socket, "354");
// Send the Subject Line...
fputs($socket, "Subject: $subject\r\n");
// Now the To Header.
fputs($socket, "$to_header\r\n");
// Now any custom headers....
fputs($socket, "$headers\r\n\r\n");
// Ok now we are ready for the message...
fputs($socket, "$message\r\n");
// Ok the all the ingredients are mixed in let's cook this puppy...
fputs($socket, ".\r\n");
server_parse($socket, "250");
// Now tell the server we are done and close the socket...
fputs($socket, "QUIT\r\n");
fclose($socket);
 
return true;
}
 
?>
/web/test/gallery/cpg133/include/media.functions.inc.php
0,0 → 1,126
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2005 Coppermine Dev Team
v1.1 originaly written by Gregory DEMAR
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.3.3
$Source: /cvsroot/coppermine/stable/include/media.functions.inc.php,v $
$Revision: 1.4 $
$Author: gaugau $
$Date: 2005/04/19 03:17:11 $
**********************************************/
 
// REQUIRES GLOBAL VAR: CONFIG
// REQUIRES GLOBAL FUNCTION: db_query
 
global $FILE_TYPES;
 
// Map content types to corresponding user parameters
$content_types_to_vars = array('image'=>'allowed_img_types','audio'=>'allowed_snd_types','movie'=>'allowed_mov_types','document'=>'allowed_doc_types');
$CONFIG['allowed_file_extensions'] = '';
 
if (count($FILE_TYPES)==0) {
$result = db_query('SELECT extension, mime, content FROM '.$CONFIG['TABLE_FILETYPES'].';');
while ($row = mysql_fetch_array($result)) {
// Only add types that are in both the database and user defined parameter
if ($CONFIG[$content_types_to_vars[$row['content']]]=='ALL' || is_int(strpos('/'.$CONFIG[$content_types_to_vars[$row['content']]].'/','/'.$row['extension'].'/')))
{
$FILE_TYPES[$row['extension']] = $row;
$CONFIG['allowed_file_extensions'].= '/'.$row['extension'];
} }
mysql_free_result($result);
}
 
$CONFIG['allowed_file_extensions'] = substr($CONFIG['allowed_file_extensions'],1);
 
function get_type($filename,$filter=null)
{
global $FILE_TYPES;
if (!is_array($filename))
$filename = explode('.',$filename);
$EOA = count($filename)-1;
$filename[$EOA] = strtolower($filename[$EOA]);
 
if (!is_null($filter) && $FILE_TYPES[$filename[$EOA]]['content']==$filter)
return $FILE_TYPES[$filename[$EOA]];
elseif (is_null($filter))
return $FILE_TYPES[$filename[$EOA]];
else
return null;
}
 
function is_image(&$file)
{
return get_type($file,'image');
}
 
function is_movie(&$file)
{
return get_type($file,'movie');
}
 
function is_audio(&$file)
{
return get_type($file,'audio');
}
 
function is_document(&$file)
{
return get_type($file,'document');
}
 
function is_known_filetype($file)
{
return is_image($file) || is_movie($file) || is_audio($file) || is_document($file);
}
 
// Not implemented yet--will be implemented by Chris
/*
function cpg_file_html(&$file,$type='thumb',$file_title='')
{
global $CONFIG, $pic_title;
 
$mime_content = get_type($file['filename']);
$extension = file_exists("images/thumb_{$mime_content['extension']}.jpg") ? $mime_content['extension']:$mime_content['content'];
 
if ($mime_content['content']=='image' && $type=='thumb') {
$file['pwidth'] = 100;
$file['pheight'] = 100;
}
 
if ($type=='thumb')
$file_url = get_pic_url($file, 'thumb',$file_title='');
elseif ($CONFIG['make_intermediate'] && max($file['pwidth'], $file['pheight']) > $CONFIG['picture_width'])
$file_url = get_pic_url($file, 'normal');
else
$file_url = get_pic_url($file, 'fullsize');
 
$image_size = compute_img_size($file['pwidth'], $file['pheight'], $CONFIG['alb_list_thumb_size']);
if (($file['pwidth']==0 || $file['pheight']==0) && $type!='thumb')
$image_size['geom']='';
 
 
if ($mime_content['content']=='image') {
if (isset($image_size['reduced'])) {
$file_html = "<a href=\"javascript:;\" onClick=\"MM_openBrWindow('displayimage.php?pid=$pid&fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=yes,status=yes,resizable=yes,width=" . $file['pwidth']+16 . ",height=" . $file['pheight']+16 . "')\">"
$file_title = ""
}
return "<img src=\"" . $file_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$file['filename']}\" title=\"$pic_title\">";
}
elseif ($type=='thumb')
return "<img src=\"images/thumb_{$extension}.jpg\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$file['filename']}\" title=\"$pic_title\">";
elseif ($mime_content['content']=='movie')
return "<object {$image_size['geom']}><param name=\"movie\" value=\"". $file_url . "\"><embed {$image_size['geom']} src=\"". $file_url . "\"></embed></object>\n";
elseif ($mime_content['content']=='audio')
return "<object {$image_size['geom']}><param name=\"movie\" value=\"". $file_url . "\"><embed {$image_size['geom']} src=\"". $file_url . "\"></embed></object>\n";
elseif ($mime_content['content']=='document')
return "<a href=\"{$file_url}\" target=\"_blank\" class=\"document_link\"><img src=\"images/thumb_$extension.jpg\" border=\"0\" class=\"image\" /></a>\n";
}*/
?>
/web/test/gallery/cpg133/include/picmgmt.inc.php
0,0 → 1,235
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2005 Coppermine Dev Team
v1.1 originaly written by Gregory DEMAR
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.3.3
$Source: /cvsroot/coppermine/stable/include/picmgmt.inc.php,v $
$Revision: 1.10 $
$Author: gaugau $
$Date: 2005/04/19 03:17:11 $
**********************************************/
 
// Add a picture to an album
function add_picture($aid, $filepath, $filename, $title = '', $caption = '', $keywords = '', $user1 = '', $user2 = '', $user3 = '', $user4 = '', $category = 0, $raw_ip = '', $hdr_ip = '',$iwidth=0,$iheight=0)
{
global $CONFIG, $ERROR, $USER_DATA, $PIC_NEED_APPROVAL;
global $lang_errors;
 
$image = $CONFIG['fullpath'] . $filepath . $filename;
$normal = $CONFIG['fullpath'] . $filepath . $CONFIG['normal_pfx'] . $filename;
$thumb = $CONFIG['fullpath'] . $filepath . $CONFIG['thumb_pfx'] . $filename;
 
if (!is_known_filetype($image)) {
return false;
} elseif (is_image($filename)) {
if (!file_exists($thumb)) {
if (!resize_image($image, $thumb, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use']))
return false;
}
$imagesize = getimagesize($image);
if (max($imagesize[0], $imagesize[1]) > $CONFIG['picture_width'] && $CONFIG['make_intermediate'] && !file_exists($normal)) {
if (!resize_image($image, $normal, $CONFIG['picture_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use']))
return false;
}
} else {
$imagesize[0] = $iwidth;
$imagesize[1] = $iheight;
}
 
$image_filesize = filesize($image);
$total_filesize = is_image($filename) ? ($image_filesize + (file_exists($normal) ? filesize($normal) : 0) + filesize($thumb)) : ($image_filesize);
 
 
// Test if disk quota exceeded
if (!GALLERY_ADMIN_MODE && $USER_DATA['group_quota']) {
$result = db_query("SELECT sum(total_filesize) FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND category = '" . (FIRST_USER_CAT + USER_ID) . "'");
$record = mysql_fetch_array($result);
$total_space_used = $record[0];
mysql_free_result($result);
 
if ((($total_space_used + $total_filesize)>>10) > $USER_DATA['group_quota'] ) {
@unlink($image);
if (is_image($image)) {
@unlink($normal);
@unlink($thumb);
}
$msg = strtr($lang_errors['quota_exceeded'], array('[quota]' => ($USER_DATA['group_quota']),
'[space]' => ($total_space_used >> 10)));
cpg_die(ERROR, $msg, __FILE__, __LINE__);
}
}
// Test if picture requires approval
if (GALLERY_ADMIN_MODE) {
$approved = 'YES';
} elseif (!$USER_DATA['priv_upl_need_approval'] && $category == FIRST_USER_CAT + USER_ID) {
$approved = 'YES';
} elseif (!$USER_DATA['pub_upl_need_approval']) {
$approved = 'YES';
} else {
$approved = 'NO';
}
$PIC_NEED_APPROVAL = ($approved == 'NO');
// User ID is now recorded when in admin mode (casper)
$user_id = USER_ID;
$username= USER_NAME;
$query = "INSERT INTO {$CONFIG['TABLE_PICTURES']} (pid, aid, filepath, filename, filesize, total_filesize, pwidth, pheight, ctime, owner_id, owner_name, title, caption, keywords, approved, user1, user2, user3, user4, pic_raw_ip, pic_hdr_ip) VALUES ('', '$aid', '" . addslashes($filepath) . "', '" . addslashes($filename) . "', '$image_filesize', '$total_filesize', '{$imagesize[0]}', '{$imagesize[1]}', '" . time() . "', '$user_id', '$username','$title', '$caption', '$keywords', '$approved', '$user1', '$user2', '$user3', '$user4', '$raw_ip', '$hdr_ip')";
$result = db_query($query);
 
return $result;
}
 
define("GIS_GIF", 1);
define("GIS_JPG", 2);
define("GIS_PNG", 3);
 
// Add 'edit' directory if it doesn't exist
// Set access to read+write only
if (!is_dir($CONFIG['fullpath'].'edit')) {
$cpg_umask = umask(0);
@mkdir($CONFIG['fullpath'].'edit',0777);
umask($cpg_umask);
unset($cpg_umask);
}
 
/**
* resize_image()
*
* Create a file containing a resized image
*
* @param $src_file the source file
* @param $dest_file the destination file
* @param $new_size the size of the square within which the new image must fit
* @param $method the method used for image resizing
* @return 'true' in case of success
*/
function resize_image($src_file, $dest_file, $new_size, $method, $thumb_use)
{
global $CONFIG, $ERROR;
global $lang_errors;
 
$imginfo = getimagesize($src_file);
if ($imginfo == null)
return false;
// GD can only handle JPG & PNG images
if ($imginfo[2] != GIS_JPG && $imginfo[2] != GIS_PNG && ($method == 'gd1' || $method == 'gd2')) {
$ERROR = $lang_errors['gd_file_type_err'];
return false;
}
// height/width
$srcWidth = $imginfo[0];
$srcHeight = $imginfo[1];
if ($thumb_use == 'ht') {
$ratio = $srcHeight / $new_size;
} elseif ($thumb_use == 'wd') {
$ratio = $srcWidth / $new_size;
} else {
$ratio = max($srcWidth, $srcHeight) / $new_size;
}
$ratio = max($ratio, 1.0);
$destWidth = (int)($srcWidth / $ratio);
$destHeight = (int)($srcHeight / $ratio);
// Method for thumbnails creation
switch ($method) {
case "im" :
if (preg_match("#[A-Z]:|\\\\#Ai", __FILE__)) {
// get the basedir, remove '/include'
$cur_dir = substr(dirname(__FILE__), 0, -8);
$src_file = '"' . $cur_dir . '\\' . strtr($src_file, '/', '\\') . '"';
$im_dest_file = str_replace('%', '%%', ('"' . $cur_dir . '\\' . strtr($dest_file, '/', '\\') . '"'));
} else {
$src_file = escapeshellarg($src_file);
$im_dest_file = str_replace('%', '%%', escapeshellarg($dest_file));
}
 
$output = array();
/*
* Hack for working with ImageMagick on WIndows even if IM is installed in C:\Program Files.
* By Aditya Mooley <aditya@sanisoft.com>
*/
if (eregi("win",$_ENV['OS'])) {
$cmd = "\"".str_replace("\\","/", $CONFIG['impath'])."convert\" -quality {$CONFIG['jpeg_qual']} {$CONFIG['im_options']} -geometry {$destWidth}x{$destHeight} ".str_replace("\\","/" ,$src_file )." ".str_replace("\\","/" ,$im_dest_file );
exec ("\"$cmd\"", $output, $retval);
} else {
$cmd = "{$CONFIG['impath']}convert -quality {$CONFIG['jpeg_qual']} {$CONFIG['im_options']} -geometry {$destWidth}x{$destHeight} $src_file $im_dest_file";
exec ($cmd, $output, $retval);
}
 
 
if ($retval) {
$ERROR = "Error executing ImageMagick - Return value: $retval";
if ($CONFIG['debug_mode']) {
// Re-execute the command with the backtit operator in order to get all outputs
// will not work is safe mode is enabled
$output = `$cmd 2>&1`;
$ERROR .= "<br /><br /><div align=\"left\">Cmd line : <br /><font size=\"2\">" . nl2br(htmlspecialchars($cmd)) . "</font></div>";
$ERROR .= "<br /><br /><div align=\"left\">The convert program said:<br /><font size=\"2\">";
$ERROR .= nl2br(htmlspecialchars($output));
$ERROR .= "</font></div>";
}
@unlink($dest_file);
return false;
}
break;
 
case "gd1" :
if (!function_exists('imagecreatefromjpeg')) {
cpg_die(CRITICAL_ERROR, 'PHP running on your server does not support the GD image library, check with your webhost if ImageMagick is installed', __FILE__, __LINE__);
}
if ($imginfo[2] == GIS_JPG)
$src_img = imagecreatefromjpeg($src_file);
else
$src_img = imagecreatefrompng($src_file);
if (!$src_img) {
$ERROR = $lang_errors['invalid_image'];
return false;
}
$dst_img = imagecreate($destWidth, $destHeight);
imagecopyresized($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int)$destHeight, $srcWidth, $srcHeight);
imagejpeg($dst_img, $dest_file, $CONFIG['jpeg_qual']);
imagedestroy($src_img);
imagedestroy($dst_img);
break;
 
case "gd2" :
if (!function_exists('imagecreatefromjpeg')) {
cpg_die(CRITICAL_ERROR, 'PHP running on your server does not support the GD image library, check with your webhost if ImageMagick is installed', __FILE__, __LINE__);
}
if (!function_exists('imagecreatetruecolor')) {
cpg_die(CRITICAL_ERROR, 'PHP running on your server does not support GD version 2.x, please switch to GD version 1.x on the config page', __FILE__, __LINE__);
}
if ($imginfo[2] == GIS_JPG)
$src_img = imagecreatefromjpeg($src_file);
else
$src_img = imagecreatefrompng($src_file);
if (!$src_img) {
$ERROR = $lang_errors['invalid_image'];
return false;
}
$dst_img = imagecreatetruecolor($destWidth, $destHeight);
imagecopyresampled($dst_img, $src_img, 0, 0, 0, 0, $destWidth, (int)$destHeight, $srcWidth, $srcHeight);
imagejpeg($dst_img, $dest_file, $CONFIG['jpeg_qual']);
imagedestroy($src_img);
imagedestroy($dst_img);
break;
}
// Set mode of uploaded picture
chmod($dest_file, octdec($CONFIG['default_file_mode']));
// We check that the image is valid
$imginfo = getimagesize($dest_file);
if ($imginfo == null) {
$ERROR = $lang_errors['resize_failed'];
@unlink($dest_file);
return false;
} else {
return true;
}
}
?>
/web/test/gallery/cpg133/include/search.inc.php
0,0 → 1,218
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2005 Coppermine Dev Team
v1.1 originaly written by Gregory DEMAR
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.3.3
$Source: /cvsroot/coppermine/stable/include/search.inc.php,v $
$Revision: 1.6 $
$Author: gaugau $
$Date: 2005/04/19 03:17:11 $
**********************************************/
 
/**
* functions_search.php
*
* -------------------
*
* begin : Wed Sep 05 2001
*
* copyright : (C) 2001 The phpBB Group
*
* email : support@phpbb.com
*
*
*
* $Id: search.inc.php,v 1.6 2005/04/19 03:17:11 gaugau Exp $
*/
 
// encoding match for workaround
 
$multibyte_charset = 'utf-8, big5, shift_jis, euc-kr, gb2312';
 
$charset = $CONFIG['charset'] == 'language file' ? $GLOBALS['lang_charset'] : $CONFIG['charset'];
 
$mb_charset = stristr($multibyte_charset, $charset);
 
function clean_words(&$entry, $mb_charset)
{
global $charset, $multibyte_charset;
 
static $drop_char_match = array('^', '$', '&', '(', ')', '<', '>', '`', '\'', '"', '|', ',', '@', '_', '?', '%', '~', '.', '[', ']', '{', '}', ':', '\\', '/', '=', '#', '\'', ';', '!');
 
static $drop_char_replace = array(' ', ' ', ' ', ' ', ' ', ' ', ' ', '', '', ' ', ' ', ' ', ' ', '', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' , ' ', ' ', ' ', ' ', ' ', ' ');
 
$entry = ' ' . strtolower($entry) . ' ';
// Replace line endings by a space
$entry = preg_replace('/[\n\r]/is', ' ', $entry);
// + and - becomes and & not
$entry = str_replace(' +', ' and ', $entry);
 
$entry = str_replace(' -', ' not ', $entry);
 
// Filter out strange characters like ^, $, &, change "it's" to "its"
 
if (!$mb_charset) for($i = 0; $i < count($drop_char_match); $i++) {
$entry = str_replace($drop_char_match[$i], $drop_char_replace[$i], $entry);
}
// 'words' that consist of <3 or >20 characters are removed.
// $entry = preg_replace('/\b([a-z0-9]{1,2}|[a-z0-9]{21,})\b/',' ', $entry);
return $entry;
}
 
if (defined('USE_MYSQL_SEARCH') && $query_all) {
// If using MySQL 4 or above we use boolean search
$mysql_version = mysql_get_server_info();
 
if ($mysql_version >= '4') {
$boolean_mode = 'IN BOOLEAN MODE';
} else {
$boolean_mode = '';
}
 
$result = db_query("SELECT COUNT(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE MATCH(filename, title, caption, keywords) AGAINST ('$search_string' $boolean_mode) AND approved = 'YES' $ALBUM_SET");
 
$nbEnr = mysql_fetch_array($result);
 
$count = $nbEnr[0];
 
mysql_free_result($result);
 
if ($select_columns != '*') $select_columns .= ', title, caption';
 
$result = db_query("SELECT $select_columns FROM {$CONFIG['TABLE_PICTURES']} WHERE MATCH(filename, title, caption, keywords) AGAINST ('$search_string' $boolean_mode) AND approved = 'YES' $ALBUM_SET $limit");
 
$rowset = db_fetch_rowset($result);
 
mysql_free_result($result);
 
if ($set_caption) foreach ($rowset as $key => $row) {
$caption = $rowset[$key]['title'] ? "<span class=\"thumb_title\">" . $rowset[$key]['title'] . "</span>" : '';
 
if ($CONFIG['caption_in_thumbview']) {
$caption .= $rowset[$key]['caption'] ? "<span class=\"thumb_caption\">" . bb_decode($rowset[$key]['caption']) . "</span>" : '';
}
 
$rowset[$key]['caption_text'] = $caption;
}
} elseif ($search_string != '') {
$split_search = array();
 
$split_search = split(' ', clean_words($search_string, $mb_charset));
 
$current_match_type = 'and';
 
$pic_set = '';
 
for($i = 0; $i < count($split_search); $i++) {
switch ($split_search[$i]) {
case 'and':
 
$current_match_type = 'and';
 
break;
 
case 'or':
 
$current_match_type = 'or';
 
break;
 
case 'not':
 
$current_match_type = 'not';
 
break;
 
default:
 
if (empty($split_search[$i])) break;
 
$match_word = '%' . str_replace('*', '%', addslashes($split_search[$i])) . '%';
 
$match_keyword = '% ' . str_replace('*', '%', addslashes($split_search[$i])) . ' %';
 
$sql = "SELECT pid " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE CONCAT(' ', keywords, ' ') LIKE '$match_keyword' ";
 
if ($query_all) $sql .= "OR filename LIKE '$match_word' " . "OR title LIKE '$match_word' " . "OR caption LIKE '$match_word' " . "OR user1 LIKE '$match_word' " . "OR user2 LIKE '$match_word' " . "OR user3 LIKE '$match_word' " . "OR user4 LIKE '$match_word' ";
 
$result = db_query($sql);
 
$set = '';
 
while ($row = mysql_fetch_array($result)) {
$set .= $row['pid'] . ',';
} // while
if (empty($set)) {
$set = "'',";
}
 
if (empty($pic_set)) {
if ($current_match_type == 'not') {
$pic_set .= ' pid not in (' . substr($set, 0, -1) . ') ';
} else {
$pic_set .= ' pid in (' . substr($set, 0, -1) . ') ';
}
} else {
if ($current_match_type == 'not') {
$pic_set .= ' and pid not in (' . substr($set, 0, -1) . ') ';
} else {
$pic_set .= ' ' . $current_match_type . ' pid in (' . substr($set, 0, -1) . ') ';
}
}
 
mysql_free_result($result);
 
$current_match_type = 'and';
}
}
 
if (!empty($pic_set)) {
$sql = "SELECT COUNT(*) " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE ($pic_set) " . "AND approved = 'YES' " . "$ALBUM_SET";
 
$result = db_query($sql);
 
$nbEnr = mysql_fetch_array($result);
 
$count = $nbEnr[0];
 
mysql_free_result($result);
 
if ($select_columns != '*') $select_columns .= ', title, caption';
 
$sql = "SELECT $select_columns " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE ($pic_set) " . "AND approved = 'YES' " . "$ALBUM_SET $limit";
 
$result = db_query($sql);
 
$rowset = db_fetch_rowset($result);
 
mysql_free_result($result);
 
if ($set_caption) foreach ($rowset as $key => $row) {
$caption = $rowset[$key]['title'] ? "<span class=\"thumb_title\">" . $rowset[$key]['title'] . "</span>" : '';
 
if ($CONFIG['caption_in_thumbview']) {
$caption .= $rowset[$key]['caption'] ? "<span class=\"thumb_caption\">" . bb_decode($rowset[$key]['caption']) . "</span>" : '';
}
 
$rowset[$key]['caption_text'] = $caption;
}
} else {
$count = 0;
 
$rowset = array();
}
} else {
$count = 0;
 
$rowset = array();
}
 
?>
/web/test/gallery/cpg133/include/select_lang.inc.php
0,0 → 1,159
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2005 Coppermine Dev Team
v1.1 originaly written by Gregory DEMAR
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.3.3
$Source: /cvsroot/coppermine/stable/include/select_lang.inc.php,v $
$Revision: 1.7 $
$Author: gaugau $
$Date: 2005/04/19 03:17:11 $
**********************************************/
 
/**
* phpMyAdmin Language Loading File
*/
 
/**
* All the supported languages have to be listed in the array below.
* 1. The key must be the "official" ISO 639 language code and, if required,
* the dialect code. It can also contains some informations about the
* charset (see the Russian case).
* 2. The first of the values associated to the key is used in a regular
* expression to find some keywords corresponding to the language inside two
* environment variables.
* These values contains:
* - the "official" ISO language code and, if required, the dialect code
* also ('bu' for Bulgarian, 'fr([-_][[:alpha:]]{2})?' for all French
* dialects, 'zh[-_]tw' for Chinese traditional...);
* - the '|' character (it means 'OR');
* - the full language name.
* 3. The second values associated to the key is the name of the file to load
* without the '.php' extension.
* 4. The last values associated to the key is the language code as defined by
* the RFC1766.
*
* Beware that the sorting order (first values associated to keys by
* alphabetical reverse order in the array) is important: 'zh-tw' (chinese
* traditional) must be detected before 'zh' (chinese simplified) for
* example.
*
* When there are more than one charset for a language, we put the -utf-8
* first.
*/
$available_languages = array('ar' => array('ar([-_][[:alpha:]]{2})?|arabic', 'arabic-utf-8', 'ar'),
'bg' => array('bg|bulgarian', 'bulgarian-utf-8', 'bg'),
'ca' => array('ca|catalan', 'catalan-utf-8', 'ca'),
'cs' => array('cs|czech', 'czech-utf-8', 'cs'),
'da' => array('da|danish', 'danish-utf-8', 'da'),
'de' => array('de([-_][[:alpha:]]{2})?|german', 'german-utf-8', 'de'),
'el' => array('el|greek', 'greek-utf-8', 'el'),
'en' => array('en([-_][[:alpha:]]{2})?|english', 'english-utf-8', 'en'),
'es' => array('es([-_][[:alpha:]]{2})?|spanish', 'spanish-utf-8', 'es'),
'et' => array('et|estonian', 'estonian-utf-8', 'et'),
'fi' => array('fi|finnish', 'finnish-utf-8', 'fi'),
'fr' => array('fr([-_][[:alpha:]]{2})?|french', 'french-utf-8', 'fr'),
'gl' => array('gl|galician', 'galician-utf-8', 'gl'),
'he' => array('he|hebrew', 'hebrew-iso-8859-8-i', 'he'),
'hr' => array('hr|croatian', 'croatian-utf-8', 'hr'),
'hu' => array('hu|hungarian', 'hungarian-utf-8', 'hu'),
'id' => array('id|indonesian', 'indonesian-utf-8', 'id'),
'it' => array('it|italian', 'italian-utf-8', 'it'),
'ja' => array('ja|japanese', 'japanese-utf-8', 'ja'),
'ko' => array('ko|korean', 'korean-ks_c_5601-1987', 'ko'),
'ka' => array('ka|georgian', 'georgian-utf-8', 'ka'),
'lt' => array('lt|lithuanian', 'lithuanian-utf-8', 'lt'),
'lv' => array('lv|latvian', 'latvian-utf-8', 'lv'),
'nl' => array('nl([-_][[:alpha:]]{2})?|dutch', 'dutch-utf-8', 'nl'),
'no' => array('no|norwegian', 'norwegian-utf-8', 'no'),
'pl' => array('pl|polish', 'polish-utf-8', 'pl'),
'pt' => array('pt[-_]br|brazilian portuguese', 'brazilian_portuguese-utf-8', 'pt-BR'),
'pt' => array('pt([-_][[:alpha:]]{2})?|portuguese', 'portuguese-utf-8', 'pt'),
'ro' => array('ro|romanian', 'romanian-utf-8', 'ro'),
'ru' => array('ru|russian', 'russian-utf-8', 'ru'),
'sk' => array('sk|slovak', 'slovak-utf-8', 'sk'),
'sl' => array('sl|slovenian', 'slovenian-utf-8', 'sl'),
'sq' => array('sq|albanian', 'albanian-utf-8', 'sq'),
'sr' => array('sr|serbian', 'serbian-utf-8', 'sr'),
'sv' => array('sv|swedish', 'swedish-utf-8', 'sv'),
'th' => array('th|thai', 'thai-utf-8', 'th'),
'tr' => array('tr|turkish', 'turkish-utf-8', 'tr'),
'uk' => array('uk|ukrainian', 'ukrainian-utf-8', 'uk'),
'zh' => array('zh[-_]tw|chinese traditional', 'chinese_big5-utf-8', 'zh-TW'),
'zh' => array('zh|chinese simplified', 'chinese_gb-utf-8', 'zh'),
);
 
/**
* Analyzes some PHP environment variables to find the most probable language
* that should be used
*
* @param string $ string to analyze
* @param integer $ type of the PHP environment variable which value is $str
* @global array the list of available translations
* @global string the retained translation keyword
* @access private
*/
function lang_detect($str = '', $envType = '')
{
global $available_languages;
global $lang;
 
reset($available_languages);
while (list($key, $value) = each($available_languages)) {
// $envType = 1 for the 'HTTP_ACCEPT_LANGUAGE' environment variable,
// 2 for the 'HTTP_USER_AGENT' one
if (($envType == 1 && eregi('^(' . $value[0] . ')(;q=[0-9]\\.[0-9])?$', $str)) || ($envType == 2 && eregi('(\(|\[|;[[:space:]])(' . $value[0] . ')(;|\]|\))', $str))) {
$lang = $key;
break;
}
}
}
 
/**
* Get some global variables if 'register_globals' is set to 'off'
* loic1 - 2001/25/11: use the new globals arrays defined with php 4.1+
*/
if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$HTTP_ACCEPT_LANGUAGE = $_SERVER['HTTP_ACCEPT_LANGUAGE'];
} else if (!empty($HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'])) {
$HTTP_ACCEPT_LANGUAGE = $HTTP_SERVER_VARS['HTTP_ACCEPT_LANGUAGE'];
}
 
if (!empty($_SERVER['HTTP_USER_AGENT'])) {
$HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
} else if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) {
$HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
}
 
/**
* Do the work!
*/
 
$lang = '';
// 1. try to findout user's language by checking its HTTP_ACCEPT_LANGUAGE
// variable
if (empty($lang) && !empty($HTTP_ACCEPT_LANGUAGE)) {
$accepted = explode(',', $HTTP_ACCEPT_LANGUAGE);
$acceptedCnt = count($accepted);
reset($accepted);
for ($i = 0; $i < $acceptedCnt && empty($lang); $i++) {
lang_detect($accepted[$i], 1);
}
}
// 2. try to findout user's language by checking its HTTP_USER_AGENT variable
if (empty($lang) && !empty($HTTP_USER_AGENT)) {
lang_detect($HTTP_USER_AGENT, 2);
}
// 3. If we catch a valid language, configure it
if (!empty($lang)) {
$USER['lang'] = $available_languages[$lang][1];
}
// $__PMA_SELECT_LANG_LIB__
?>
/web/test/gallery/cpg133/include/slideshow.inc.php
0,0 → 1,131
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2005 Coppermine Dev Team
v1.1 originaly written by Gregory DEMAR
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.3.3
$Source: /cvsroot/coppermine/stable/include/slideshow.inc.php,v $
$Revision: 1.9 $
$Author: gaugau $
$Date: 2005/04/19 03:17:11 $
**********************************************/
?>
 
<script language="JavaScript" type="text/JavaScript">
// (C) 2000 www.CodeLifter.com
// http://www.codelifter.com
// Free for all users, but leave in this header
// NS4-6,IE4-6
// Fade effect only in IE; degrades gracefully
 
// $Id: slideshow.inc.php,v 1.9 2005/04/19 03:17:11 gaugau Exp $
 
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = <?php echo (int)$HTTP_GET_VARS['slideshow'] ?>
 
// Agent sniffer shamelessly 'stolen' from the excellent X library from cross-browser.com
var xOp7=false,xOp5or6=false,xIE4Up=false,xNN4=false,xUA=navigator.userAgent.toLowerCase();
if(window.opera){
xOp7=(xUA.indexOf('opera 7')!=-1 || xUA.indexOf('opera/7')!=-1);
if (!xOp7) xOp5or6=(xUA.indexOf('opera 5')!=-1 || xUA.indexOf('opera/5')!=-1 || xUA.indexOf('opera 6')!=-1 || xUA.indexOf('opera/6')!=-1);
}
else if(document.layers) xNN4=true;
else {xIE4Up=document.all && xUA.indexOf('msie')!=-1 && parseInt(navigator.appVersion)>=4;}
 
// Duration of crossfade (seconds)
var crossFadeDuration = 3
 
// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below
<?php
$i = 0;
$j = 0;
$pid = (int)$HTTP_GET_VARS['pid'];
$start_img = '';
$pic_data = get_pic_data($HTTP_GET_VARS['album'], $pic_count, $album_name, -1, -1, false);
foreach ($pic_data as $picture) {
 
if($CONFIG['thumb_use']=='ht' && $picture['pheight'] > $CONFIG['picture_width'] ){ // The wierd comparision is because only picture_width is stored
$condition = true;
}elseif($CONFIG['thumb_use']=='wd' && $picture['pwidth'] > $CONFIG['picture_width']){
$condition = true;
}elseif($CONFIG['thumb_use']=='any' && max($picture['pwidth'], $picture['pheight']) > $CONFIG['picture_width']){
$condition = true;
}else{
$condition = false;
}
 
if (is_image($picture['filename'])) {
if ($CONFIG['make_intermediate'] && $condition ) {
$picture_url = get_pic_url($picture, 'normal');
} else {
$picture_url = get_pic_url($picture, 'fullsize');
}
 
echo "Pic[$i] = '" . $picture_url . "'\n";
if ($picture['pid'] == $pid) {
$j = $i;
$start_img = $picture_url;
}
$i++;
}
}
if (!$i) {
echo "Pic[0] = 'images/thumb_document.jpg'\n";
}
?>
 
var t
var j = <?php echo "$j\n" ?>
var p = Pic.length
var pos = j
 
var preLoad = new Array()
 
function preLoadPic(index)
{
if (Pic[index] != ''){
window.status='Loading : '+Pic[index]
preLoad[index] = new Image()
preLoad[index].src = Pic[index]
Pic[index] = ''
window.status=''
}
}
 
function runSlideShow(){
if (xIE4Up){
document.images.SlideShow.style.filter="blendTrans(duration=2)"
document.images.SlideShow.style.filter= "blendTrans(duration=crossFadeDuration)"
document.images.SlideShow.filters.blendTrans.Apply()
}
document.images.SlideShow.src = preLoad[j].src
if (xIE4Up){
document.images.SlideShow.filters.blendTrans.Play()
}
 
pos = j
 
j = j + 1
if (j > (p-1)) j=0
t = setTimeout('runSlideShow()', slideShowSpeed)
preLoadPic(j)
}
 
function endSlideShow(){
self.document.location = 'displayimage.php?album=<?php echo isset($HTTP_GET_VARS['album']) ? $HTTP_GET_VARS['album'] : '';
echo isset($HTTP_GET_VARS['cat']) ? '&cat=' . $HTTP_GET_VARS['cat'] : '' ?>&pos='+pos
}
 
preLoadPic(j)
 
</script>
/web/test/gallery/cpg133/include/smilies.inc.php
0,0 → 1,168
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2005 Coppermine Dev Team
v1.1 originaly written by Gregory DEMAR
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.3.3
$Source: /cvsroot/coppermine/stable/include/smilies.inc.php,v $
$Revision: 1.6 $
$Author: gaugau $
$Date: 2005/04/19 03:17:11 $
**********************************************/
 
// ------------------------------------------------------------------------- //
// CODE IN THIS MODULE IS TAKEN FROM phpBB //
// ------------------------------------------------------------------------- //
 
define('SMILIES_PHP', true);
function get_smilies_table1()
{
global $lang_smilies_inc_php;
 
return array(
array(':!:', 'icon_exclaim.gif', $lang_smilies_inc_php['Exclamation']),
array(':?:', 'icon_question.gif', $lang_smilies_inc_php['Question']),
array(':D', 'icon_biggrin.gif', $lang_smilies_inc_php['Very Happy']),
array(':-D', 'icon_biggrin.gif', $lang_smilies_inc_php['Very Happy']),
array(':grin:', 'icon_biggrin.gif', $lang_smilies_inc_php['Very Happy']),
array(':)', 'icon_smile.gif', $lang_smilies_inc_php['Smile']),
array(':-)', 'icon_smile.gif', $lang_smilies_inc_php['Smile']),
array(':smile:', 'icon_smile.gif', $lang_smilies_inc_php['Smile']),
array(':(', 'icon_sad.gif', $lang_smilies_inc_php['Sad']),
array(':-(', 'icon_sad.gif', $lang_smilies_inc_php['Sad']),
array(':sad:', 'icon_sad.gif', $lang_smilies_inc_php['Sad']),
array(':o', 'icon_surprised.gif', $lang_smilies_inc_php['Surprised']),
array(':-o', 'icon_surprised.gif', $lang_smilies_inc_php['Surprised']),
array(':eek:', 'icon_surprised.gif', $lang_smilies_inc_php['Surprised']),
array(':shock:', 'icon_eek.gif', $lang_smilies_inc_php['Shocked']),
array(':?', 'icon_confused.gif', $lang_smilies_inc_php['Confused']),
array(':-?', 'icon_confused.gif', $lang_smilies_inc_php['Confused']),
array(':???:', 'icon_confused.gif', $lang_smilies_inc_php['Confused']),
array('8)', 'icon_cool.gif', $lang_smilies_inc_php['Cool']),
array('8-)', 'icon_cool.gif', $lang_smilies_inc_php['Cool']),
array(':cool:', 'icon_cool.gif', $lang_smilies_inc_php['Cool']),
array(':lol:', 'icon_lol.gif', $lang_smilies_inc_php['Laughing']),
array(':x', 'icon_mad.gif', $lang_smilies_inc_php['Mad']),
array(':-x', 'icon_mad.gif', $lang_smilies_inc_php['Mad']),
array(':mad:', 'icon_mad.gif', $lang_smilies_inc_php['Mad']),
array(':P', 'icon_razz.gif', $lang_smilies_inc_php['Razz']),
array(':-P', 'icon_razz.gif', $lang_smilies_inc_php['Razz']),
array(':razz:', 'icon_razz.gif', $lang_smilies_inc_php['Razz']),
array(':oops:', 'icon_redface.gif', $lang_smilies_inc_php['Embarassed']),
array(':cry:', 'icon_cry.gif', $lang_smilies_inc_php['Crying or Very sad']),
array(':evil:', 'icon_evil.gif', $lang_smilies_inc_php['Evil or Very Mad']),
array(':twisted:', 'icon_twisted.gif', $lang_smilies_inc_php['Twisted Evil']),
array(':roll:', 'icon_rolleyes.gif', $lang_smilies_inc_php['Rolling Eyes']),
array(':wink:', 'icon_wink.gif', $lang_smilies_inc_php['Wink']),
array(';)', 'icon_wink.gif', $lang_smilies_inc_php['Wink']),
array(';-)', 'icon_wink.gif', $lang_smilies_inc_php['Wink']),
array(':idea:', 'icon_idea.gif', $lang_smilies_inc_php['Idea']),
array(':arrow:', 'icon_arrow.gif', $lang_smilies_inc_php['Arrow']),
array(':|', 'icon_neutral.gif', $lang_smilies_inc_php['Neutral']),
array(':-|', 'icon_neutral.gif', $lang_smilies_inc_php['Neutral']),
array(':neutral:', 'icon_neutral.gif', $lang_smilies_inc_php['Neutral']),
array(':mrgreen:', 'icon_mrgreen.gif', $lang_smilies_inc_php['Mr. Green'])
);
}
 
function get_smilies_table2()
{
global $lang_smilies_inc_php;
 
return array(
array(':lol:', 'icon_lol.gif', $lang_smilies_inc_php['Laughing']),
array(':-P', 'icon_razz.gif', $lang_smilies_inc_php['Razz']),
array(':-D', 'icon_biggrin.gif', $lang_smilies_inc_php['Very Happy']),
array(':-)', 'icon_smile.gif', $lang_smilies_inc_php['Smile']),
array(':-|', 'icon_neutral.gif', $lang_smilies_inc_php['Neutral']),
array(':-(', 'icon_sad.gif', $lang_smilies_inc_php['Sad']),
array(':cry:', 'icon_cry.gif', $lang_smilies_inc_php['Crying or Very sad']),
array('8-)', 'icon_cool.gif', $lang_smilies_inc_php['Cool']),
array(':-o', 'icon_surprised.gif', $lang_smilies_inc_php['Surprised']),
array(':-?', 'icon_confused.gif', $lang_smilies_inc_php['Confused']),
array(':oops:', 'icon_redface.gif', $lang_smilies_inc_php['Embarassed']),
array(':shock:', 'icon_eek.gif', $lang_smilies_inc_php['Shocked']),
array(':-x', 'icon_mad.gif', $lang_smilies_inc_php['Mad']),
array(':roll:', 'icon_rolleyes.gif', $lang_smilies_inc_php['Rolling Eyes']),
array(';-)', 'icon_wink.gif', $lang_smilies_inc_php['Wink']),
array(':idea:', 'icon_idea.gif', $lang_smilies_inc_php['Idea']),
array(':!:', 'icon_exclaim.gif', $lang_smilies_inc_php['Exclamation']),
array(':?:', 'icon_question.gif', $lang_smilies_inc_php['Question'])
);
}
// Smilies code ... would this be better tagged on to the end of bbcode.php?
// Probably so and I'll move it before B2
 
function process_smilies($message, $url_prefix = '')
{
static $orig, $repl;
 
if (!isset($orig)) {
global $db, $board_config;
$orig = $repl = array();
 
$smilies = get_smilies_table1();
 
for($i = 0; $i < count($smilies); $i++) {
$orig[] = "/(?<=.\W|\W.|^\W)" . preg_quote($smilies[$i][0], "/") . "(?=.\W|\W.|\W$)/";
$repl[] = '<img src="' . $url_prefix . 'images/smiles' . '/' . ($smilies[$i][1]) . '" alt="' . ($smilies[$i][2]) . '" border="0" />';
}
}
 
if (count($orig)) {
$message = preg_replace($orig, $repl, ' ' . $message . ' ');
$message = substr($message, 1, -1);
}
return $message;
}
 
// Fill smiley templates (or just the variables) with smileys
// Either in a window or inline
 
function generate_smilies($form = 'post', $field = 'message')
{
$smilies = get_smilies_table2();
 
$html = '<table width="100%" border="0" cellspacing="0" cellpadding="0">' . "\n" . ' <tr align="center" valign="middle">' . "\n";
 
foreach($smilies as $smiley) {
$caption = $smiley[2] . " " . $smiley[0];
$html .= ' <td width="5%"><a href="javascript:emoticon_' . $form . '(\'' . $smiley[0] . '\')"><img src="images/smiles/' . $smiley[1] . '" alt="' . $caption . '" width="15" height="15" border="0" title="' . $caption . '"></a></td>' . "\n";
}
 
$html .= ' </tr>' . "\n" . '</table>' . "\n";
 
$html .= <<<EOT
 
<script language="JavaScript" type="text/javascript">
<!--
function emoticon_$form(text) {
text = ' ' + text + ' ';
if (document.$form.$field.createTextRange && document.post.message.caretPos) {
var caretPos = document.$form.$field.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
document.$form.$field.focus();
} else {
document.$form.$field.value += text;
document.$form.$field.focus();
}
}
 
function storeCaret_$form(textEl) {
if (textEl.createTextRange) textEl.caretPos = document.selection.createRange().duplicate();
}
//-->
 
EOT;
$html .= "</script>\n";
return $html;
}
 
?>
/web/test/gallery/cpg133/include/sql_parse.php
0,0 → 1,175
<?php
/*************************
Coppermine Photo Gallery
************************
Copyright (c) 2003-2005 Coppermine Dev Team
v1.1 originaly written by Gregory DEMAR
 
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
********************************************
Coppermine version: 1.3.3
$Source: /cvsroot/coppermine/stable/include/sql_parse.php,v $
$Revision: 1.6 $
$Author: gaugau $
$Date: 2005/04/19 03:17:11 $
**********************************************/
 
/**
* sql_parse.php
* -------------------
* begin : Thu May 31, 2001
* copyright : (C) 2001 The phpBB Group
* email : support@phpbb.com
*
* $Id: sql_parse.php,v 1.6 2005/04/19 03:17:11 gaugau Exp $
*/
 
/**
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
 
/**
* These functions are mainly for use in the db_utilities under the admin
* however in order to make these functions available elsewhere, specifically
* in the installation phase of phpBB I have seperated out a couple of
* functions into this file. JLH
*
* \**************************************************************************
*/
 
// remove_comments will strip the sql comment lines out of an uploaded sql file
// specifically for mssql and postgres type files in the install....
 
function remove_comments(&$output)
{
$lines = explode("\n", $output);
$output = "";
// try to keep mem. use down
$linecount = count($lines);
 
$in_comment = false;
for($i = 0; $i < $linecount; $i++) {
if (preg_match("/^\/\*/", preg_quote($lines[$i]))) {
$in_comment = true;
}
 
if (!$in_comment) {
$output .= $lines[$i] . "\n";
}
 
if (preg_match("/\*\/$/", preg_quote($lines[$i]))) {
$in_comment = false;
}
}
 
unset($lines);
return $output;
}
 
// remove_remarks will strip the sql comment lines out of an uploaded sql file
 
function remove_remarks($sql)
{
$lines = explode("\n", $sql);
// try to keep mem. use down
$sql = "";
 
$linecount = count($lines);
$output = "";
 
for ($i = 0; $i < $linecount; $i++) {
if (($i != ($linecount - 1)) || (strlen($lines[$i]) > 0)) {
if ($lines[$i][0] != "#") {
$output .= $lines[$i] . "\n";
} else {
$output .= "\n";
}
// Trading a bit of speed for lower mem. use here.
$lines[$i] = "";
}
}
 
return $output;
}
 
// split_sql_file will split an uploaded sql file into single sql statements.
// Note: expects trim() to have already been run on $sql.
 
function split_sql_file($sql, $delimiter)
{
// Split up our string into "possible" SQL statements.
$tokens = explode($delimiter, $sql);
// try to save mem.
$sql = "";
$output = array();
// we don't actually care about the matches preg gives us.
$matches = array();
// this is faster than calling count($oktens) every time thru the loop.
$token_count = count($tokens);
for ($i = 0; $i < $token_count; $i++) {
// Don't wanna add an empty string as the last thing in the array.
if (($i != ($token_count - 1)) || (strlen($tokens[$i] > 0))) {
// This is the total number of single quotes in the token.
$total_quotes = preg_match_all("/'/", $tokens[$i], $matches);
// Counts single quotes that are preceded by an odd number of backslashes,
// which means they're escaped quotes.
$escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$i], $matches);
 
$unescaped_quotes = $total_quotes - $escaped_quotes;
// If the number of unescaped quotes is even, then the delimiter did NOT occur inside a string literal.
if (($unescaped_quotes % 2) == 0) {
// It's a complete sql statement.
$output[] = $tokens[$i];
// save memory.
$tokens[$i] = "";
} else {
// incomplete sql statement. keep adding tokens until we have a complete one.
// $temp will hold what we have so far.
$temp = $tokens[$i] . $delimiter;
// save memory..
$tokens[$i] = "";
// Do we have a complete statement yet?
$complete_stmt = false;
 
for ($j = $i + 1; (!$complete_stmt && ($j < $token_count)); $j++) {
// This is the total number of single quotes in the token.
$total_quotes = preg_match_all("/'/", $tokens[$j], $matches);
// Counts single quotes that are preceded by an odd number of backslashes,
// which means they're escaped quotes.
$escaped_quotes = preg_match_all("/(?<!\\\\)(\\\\\\\\)*\\\\'/", $tokens[$j], $matches);
 
$unescaped_quotes = $total_quotes - $escaped_quotes;
 
if (($unescaped_quotes % 2) == 1) {
// odd number of unescaped quotes. In combination with the previous incomplete
// statement(s), we now have a complete statement. (2 odds always make an even)
$output[] = $temp . $tokens[$j];
// save memory.
$tokens[$j] = "";
$temp = "";
// exit the loop.
$complete_stmt = true;
// make sure the outer loop continues at the right point.
$i = $j;
} else {
// even number of unescaped quotes. We still don't have a complete statement.
// (1 odd and 1 even always make an odd)
$temp .= $tokens[$j] . $delimiter;
// save memory.
$tokens[$j] = "";
}
} // for..
} // else
}
}
 
return $output;
}
 
?>