I just added a ton of pictures to my gallery (which can be found here (http://gallery.ultimatelykeithurban.com)) last night and it was working fine. Today, when I go to check it out, my gallery will not show, and I see the following error messages:
QuoteParse error: parse error in /home/ultimate/public_html/gallery/include/init.inc.php on line 49
Fatal error: Call to undefined function: breadcrumb() in /home/ultimate/public_html/gallery/index.php on line 118
I looked at both the init.inc.php and index.php files and have no idea what is wrong with them.
Here is what the init.inc.php file looks like:
<?php
// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery 1.2.1 //
// ------------------------------------------------------------------------- //
// Copyright (C) 2002,2003 Gregory DEMAR //
// http://www.chezgreg.net/coppermine/ //
// ------------------------------------------------------------------------- //
// Updated by the Coppermine Dev Team //
// (http://coppermine.sf.net/team/) //
// see /docs/credits.html for details //
// ------------------------------------------------------------------------- //
// 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. //
// ------------------------------------------------------------------------- //
define('COPPERMINE_VERSION', '1.2.1');
// User database integration
// Uncomment the applicable line if you want to use it
// define('UDB_INTEGRATION', 'phpbb');
// define('UDB_INTEGRATION', 'invisionboard');
// define('UDB_INTEGRATION', 'vbulletin');
// define('UDB_INTEGRATION', 'yabbse');
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();
function getmicrotime()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$time_start = getmicrotime();
// Do some cleanup in GET, POST and cookie data and un-register global vars
$HTML_SUBST = array('"' => '"', '<' => '<', '>' => '>');
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;
}
}
// 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);
$IMG_TYPES = array(1 => 'GIF',
2 => 'JPG',
3 => 'PNG',
4 => 'SWF',
5 => 'PSD',
6 => 'BMP',
7 => 'TIFF',
8 => 'TIFF',
9 => 'JPC',
10 => 'JP2',
11 => 'JPX',
12 => 'JB2',
13 => 'SWC',
14 => 'IFF'
);
// Include config and functions files
require 'include/config.inc.php';
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";
// 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);
// Set error logging level
if ($CONFIG['debug_mode']) {
error_reporting (E_ALL);
} else {
error_reporting (E_ALL ^ E_NOTICE);
}
// 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']}, {$CONFIG['TABLE_USERGROUPS']} " . "WHERE user_group = group_id " . "AND 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_array($results);
unset($USER_DATA['user_password']);
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', '(' . $USER_DATA['group_id'] . ($USER_DATA['user_lang'] != '' ? ',' . $USER_DATA['user_lang'] : '') . ')');
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']);
mysql_free_result($results);
} else {
$results = db_query("SELECT * FROM {$CONFIG['TABLE_USERGROUPS']} WHERE group_id = 3");
if (!mysql_num_rows($results)) die('<b>Coppermine critical error</b>:<br />The group table does not contain the Anonymous group !');
$USER_DATA = mysql_fetch_array($results);
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);
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);
// 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'] = 'default';
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['lang'] = strtr($USER['lang'], '$/\\:*?"\'<>|`', '____________');
} elseif ($CONFIG['charset'] == 'utf-8') {
include('include/select_lang.inc.php');
if (file_exists('lang/' . $USER['lang'] . '.php')) $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']));
} else {
$FAVPICS = array();
}
// load the main template
load_template();
// Remove expired bans
$now = time();
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();
?>
Here is what the index.php file looks like:
<?php
// ------------------------------------------------------------------------- //
// Coppermine Photo Gallery 1.2.1 //
// ------------------------------------------------------------------------- //
// Copyright (C) 2002,2003 Gregory DEMAR //
// http://www.chezgreg.net/coppermine/ //
// ------------------------------------------------------------------------- //
// Updated by the Coppermine Dev Team //
// (http://coppermine.sf.net/team/) //
// see /docs/credits.html for details //
// ------------------------------------------------------------------------- //
// 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. //
// ------------------------------------------------------------------------- //
define('IN_COPPERMINE', true);
define('INDEX_PHP', true);
require('include/init.inc.php');
/**
* Local functions definition
*/
function html_albummenu($id)
{
global $template_album_admin_menu, $lang_album_admin_menu;
static $template = '';
if ($template == '') {
$params = array('{CONFIRM_DELETE}' => $lang_album_admin_menu['confirm_delete'],
'{DELETE}' => $lang_album_admin_menu['delete'],
'{MODIFY}' => $lang_album_admin_menu['modify'],
'{EDIT_PICS}' => $lang_album_admin_menu['edit_pics'],
);
$template = template_eval($template_album_admin_menu, $params);
}
$params = array('{ALBUM_ID}' => $id,
);
return template_eval($template, $params);
}
function get_subcat_data($parent, &$cat_data, &$album_set_array, $level, $ident = '')
{
global $CONFIG, $HIDE_USER_CAT;
$result = db_query("SELECT cid, name, description FROM {$CONFIG['TABLE_CATEGORIES']} WHERE parent = '$parent' ORDER BY pos");
if (mysql_num_rows($result) > 0) {
$rowset = db_fetch_rowset($result);
foreach ($rowset as $subcat) {
if ($subcat['cid'] == USER_GAL_CAT) {
$result = db_query("SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category >= " . FIRST_USER_CAT);
$album_count = mysql_num_rows($result);
while ($row = mysql_fetch_array($result)) {
$album_set_array[] = $row['aid'];
} // while
mysql_free_result($result);
$result = db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND category >= " . FIRST_USER_CAT);
$nbEnr = mysql_fetch_array($result);
$pic_count = $nbEnr[0];
$subcat['description'] = preg_replace("/<br.*?>[\r\n]*/i", '<br />' . $ident , bb_decode($subcat['description']));
$link = $ident . "<a href=index.php?cat={$subcat['cid']}>{$subcat['name']}</a>";
if ($album_count) {
$cat_data[] = array($link, $ident . $subcat['description'], $album_count, $pic_count);
$HIDE_USER_CAT = 0;
} else {
$HIDE_USER_CAT = 1;
}
} else {
$result = db_query("SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = {$subcat['cid']}");
$album_count = mysql_num_rows($result);
while ($row = mysql_fetch_array($result)) {
$album_set_array[] = $row['aid'];
} // while
mysql_free_result($result);
$result = db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND category = {$subcat['cid']}");
$nbEnr = mysql_fetch_array($result);
mysql_free_result($result);
$pic_count = $nbEnr[0];
$subcat['name'] = $subcat['name'];
$subcat['description'] = preg_replace("/<br.*?>[\r\n]*/i", '<br />' . $ident , bb_decode($subcat['description']));
$link = $ident . "<a href=\"index.php?cat={$subcat['cid']}\">{$subcat['name']}</a>";
if ($pic_count == 0 && $album_count == 0) {
$cat_data[] = array($link, $ident . $subcat['description']);
} else {
// Check if you need to show subcat_level
if ($level == $CONFIG['subcat_level']) {
$cat_albums = list_cat_albums($subcat['cid']);
} else {
$cat_albums = '';
}
$cat_data[] = array($link, $ident . $subcat['description'], $album_count, $pic_count, 'cat_albums' => $cat_albums);
}
}
if ($level > 1) get_subcat_data($subcat['cid'], $cat_data, $album_set_array, $level -1, $ident . "<img src=\"images/spacer.gif\" width=\"20\" height=\"1\">");
}
}
}
// List all categories
function get_cat_list(&$breadcrumb, &$cat_data, &$statistics)
{
global $HTTP_GET_VARS, $CONFIG, $ALBUM_SET, $CURRENT_CAT_NAME, $BREADCRUMB_TEXT, $STATS_IN_ALB_LIST;
global $HIDE_USER_CAT;
global $cat;
global $lang_list_categories, $lang_errors;
// Build the breadcrumb
breadcrumb($cat, $breadcrumb, $BREADCRUMB_TEXT);
// Build the category list
$cat_data = array();
$album_set_array = array();
get_subcat_data($cat, $cat_data, $album_set_array, $CONFIG['subcat_level']);
// Add the albums in the current category to the album set
if ($cat) {
if ($cat == USER_GAL_CAT) {
$result = db_query("SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category >= " . FIRST_USER_CAT);
} else {
$result = db_query("SELECT aid FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = '$cat'");
} while ($row = mysql_fetch_array($result)) {
$album_set_array[] = $row['aid'];
} // while
mysql_free_result($result);
}
if (count($album_set_array) && $cat) {
$set = '';
foreach ($album_set_array as $album) $set .= $album . ',';
$set = substr($set, 0, -1);
$current_album_set = "AND aid IN ($set) ";
$ALBUM_SET .= $current_album_set;
} elseif ($cat) {
$current_album_set = "AND aid IN (-1) ";
$ALBUM_SET .= $current_album_set;
}
// Gather gallery statistics
if ($cat == 0) {
$result = db_query("SELECT count(*) FROM {$CONFIG['TABLE_ALBUMS']} WHERE 1");
$nbEnr = mysql_fetch_array($result);
$album_count = $nbEnr[0];
mysql_free_result($result);
$result = db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1");
$nbEnr = mysql_fetch_array($result);
$picture_count = $nbEnr[0];
mysql_free_result($result);
$result = db_query("SELECT count(*) FROM {$CONFIG['TABLE_COMMENTS']} WHERE 1");
$nbEnr = mysql_fetch_array($result);
$comment_count = $nbEnr[0];
mysql_free_result($result);
$result = db_query("SELECT count(*) FROM {$CONFIG['TABLE_CATEGORIES']} WHERE 1");
$nbEnr = mysql_fetch_array($result);
$cat_count = $nbEnr[0] - $HIDE_USER_CAT;
mysql_free_result($result);
$result = db_query("SELECT sum(hits) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1");
$nbEnr = mysql_fetch_array($result);
$hit_count = (int)$nbEnr[0];
mysql_free_result($result);
if (count($cat_data)) {
$statistics = strtr($lang_list_categories['stat1'], array('[pictures]' => $picture_count,
'[albums]' => $album_count,
'[cat]' => $cat_count,
'[comments]' => $comment_count,
'[views]' => $hit_count));
} else {
$STATS_IN_ALB_LIST = true;
$statistics = strtr($lang_list_categories['stat3'], array('[pictures]' => $picture_count,
'[albums]' => $album_count,
'[comments]' => $comment_count,
'[views]' => $hit_count));
}
} elseif ($cat >= FIRST_USER_CAT && $ALBUM_SET) {
$result = db_query("SELECT count(*) FROM {$CONFIG['TABLE_ALBUMS']} WHERE 1 $current_album_set");
$nbEnr = mysql_fetch_array($result);
$album_count = $nbEnr[0];
mysql_free_result($result);
$result = db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1 $current_album_set");
$nbEnr = mysql_fetch_array($result);
$picture_count = $nbEnr[0];
mysql_free_result($result);
$result = db_query("SELECT sum(hits) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1 $current_album_set");
$nbEnr = mysql_fetch_array($result);
$hit_count = (int)$nbEnr[0];
mysql_free_result($result);
$statistics = strtr($lang_list_categories['stat2'], array('[pictures]' => $picture_count,
'[albums]' => $album_count,
'[views]' => $hit_count));
} else {
$statistics = '';
}
}
function list_users()
{
global $CONFIG, $PAGE, $FORBIDDEN_SET;
global $lang_list_users, $lang_errors, $template_user_list_info_box;
if (defined('UDB_INTEGRATION')) {
$result = udb_list_users_query($user_count);
} else {
$sql = "SELECT user_id," . " user_name," . " COUNT(DISTINCT a.aid) as alb_count," . " COUNT(DISTINCT pid) as pic_count," . " MAX(pid) as thumb_pid " . "FROM {$CONFIG['TABLE_USERS']} AS u " . "INNER JOIN {$CONFIG['TABLE_ALBUMS']} AS a ON category = " . FIRST_USER_CAT . " + user_id " . "INNER JOIN {$CONFIG['TABLE_PICTURES']} AS p ON p.aid = a.aid " . "WHERE approved = 'YES' " . "$FORBIDDEN_SET " . "GROUP BY user_id " . "ORDER BY user_name ";
$result = db_query($sql);
$user_count = mysql_num_rows($result);
}
if (!$user_count) {
msg_box($lang_list_users['user_list'], $lang_list_users['no_user_gal'], '', '', '100%');
mysql_free_result($result);
return;
}
$user_per_page = $CONFIG['thumbcols'] * $CONFIG['thumbrows'];
$totalPages = ceil($user_count / $user_per_page);
if ($PAGE > $totalPages) $PAGE = 1;
$lower_limit = ($PAGE-1) * $user_per_page;
$upper_limit = min($user_count, $PAGE * $user_per_page);
$row_count = $upper_limit - $lower_limit;
if (defined('UDB_INTEGRATION')) {
$rowset = udb_list_users_retrieve_data($result, $lower_limit, $row_count);
} else {
$rowset = array();
$i = 0;
mysql_data_seek($result, $lower_limit);
while (($row = mysql_fetch_array($result)) && ($i++ < $row_count)) $rowset[] = $row;
mysql_free_result($result);
}
$user_list = array();
foreach ($rowset as $user) {
$user_thumb = '<img src="images/nopic.jpg" class="image" border="0" />';
$user_pic_count = $user['pic_count'];
$user_thumb_pid = $user['thumb_pid'];
$user_album_count = $user['alb_count'];
if ($user_pic_count) {
$sql = "SELECT filepath, filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE pid='$user_thumb_pid'";
$result = db_query($sql);
if (mysql_num_rows($result)) {
$picture = mysql_fetch_array($result);
mysql_free_result($result);
$image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['thumb_width']);
$user_thumb = "<img src=\"" . get_pic_url($picture, 'thumb') . "\" {$image_size['geom']} alt=\"\" border=\"0\" class=\"image\" />";
}
}
$albums_txt = sprintf($lang_list_users['n_albums'], $user_album_count);
$pictures_txt = sprintf($lang_list_users['n_pics'], $user_pic_count);
$params = array('{USER_NAME}' => $user['user_name'],
'{USER_ID}' => $user['user_id'],
'{ALBUMS}' => $albums_txt,
'{PICTURES}' => $pictures_txt,
);
$caption = template_eval($template_user_list_info_box, $params);
$user_list[] = array('cat' => FIRST_USER_CAT + $user['user_id'],
'image' => $user_thumb,
'caption' => $caption,
);
}
theme_display_thumbnails($user_list, $user_count, '', '', 1, $PAGE, $totalPages, false, true, 'user');
}
// List all albums
function list_albums()
{
global $CONFIG, $USER, $USER_DATA, $PAGE, $lastup_date_fmt;
global $cat;
global $lang_list_albums, $lang_errors;
$alb_per_page = $CONFIG['albums_per_page'];
$maxTab = $CONFIG['max_tabs'];
$result = db_query("SELECT count(*) FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = '$cat'");
$nbEnr = mysql_fetch_array($result);
$nbAlb = $nbEnr[0];
mysql_free_result($result);
if (!$nbAlb) return;
$totalPages = ceil($nbAlb / $alb_per_page);
if ($PAGE > $totalPages) $PAGE = 1;
$lower_limit = ($PAGE-1) * $alb_per_page;
$upper_limit = min($nbAlb, $PAGE * $alb_per_page);
$limit = "LIMIT " . $lower_limit . "," . ($upper_limit - $lower_limit);
$sql = "SELECT a.aid, a.title, a.description, visibility, filepath, " . " filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_ALBUMS']} as a " . "LEFT JOIN {$CONFIG['TABLE_PICTURES']} as p ON thumb=pid " . "WHERE category = '$cat' ORDER BY pos " . "$limit";
$alb_thumbs_q = db_query($sql);
$alb_thumbs = db_fetch_rowset($alb_thumbs_q);
mysql_free_result($alb_thumbs_q);
$disp_album_count = count($alb_thumbs);
$album_set = '';
foreach($alb_thumbs as $value) {
$album_set .= $value['aid'] . ', ';
}
$album_set = '(' . substr($album_set, 0, -2) . ')';
$sql = "SELECT aid, count(pid) as pic_count, max(pid) as last_pid, max(ctime) as last_upload " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE aid IN $album_set AND approved = 'YES' " . "GROUP BY aid";
$alb_stats_q = db_query($sql);
$alb_stats = db_fetch_rowset($alb_stats_q);
mysql_free_result($alb_stats_q);
foreach($alb_stats as $key => $value) {
$cross_ref[$value['aid']] = &$alb_stats[$key];
}
for ($alb_idx = 0; $alb_idx < $disp_album_count; $alb_idx++) {
$alb_thumb = &$alb_thumbs[$alb_idx];
$aid = $alb_thumb['aid'];
if (isset($cross_ref[$aid])) {
$alb_stat = $cross_ref[$aid];
$count = $alb_stat['pic_count'];
} else {
$alb_stat = array();
$count = 0;
}
// Inserts a thumbnail if the album contains 1 or more images
if ($count > 0) {
$visibility = $alb_thumb['visibility'];
if ($visibility == '0' || $visibility == (FIRST_USER_CAT + USER_ID) || strstr(USER_GROUP_SET, $visibility)) {
if ($alb_thumb['filename']) {
$picture = &$alb_thumb;
} else {
$sql = "SELECT filepath, filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE pid='{$alb_stat['last_pid']}'";
$result = db_query($sql);
$picture = mysql_fetch_array($result);
mysql_free_result($result);
}
$image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['alb_list_thumb_size']);
$alb_list[$alb_idx]['thumb_pic'] = "<img src=\"" . get_pic_url($picture, 'thumb') . "\" {$image_size['geom']} alt=\"\" border=\"0\" class=\"image\" />";
} elseif ($CONFIG['show_private']) {
$image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']);
$alb_list[$alb_idx]['thumb_pic'] = "<img src=\"images/private.jpg\" {$image_size['geom']} alt=\"\" border=\"0\" class=\"image\" />";
}
} else {
$image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']);
$alb_list[$alb_idx]['thumb_pic'] = "<img src=\"images/nopic.jpg\" {$image_size['geom']} alt=\"\" border=\"0\" class=\"image\" />";
}
// Prepare everything
if ($visibility == '0' || $visibility == (FIRST_USER_CAT + USER_ID) || $visibility == $USER_DATA['group_id']) {
$last_upload_date = $count ? localised_date($alb_stat['last_upload'], $lastup_date_fmt) : '';
$alb_list[$alb_idx]['aid'] = $alb_thumb['aid'];
$alb_list[$alb_idx]['album_title'] = $alb_thumb['title'];
$alb_list[$alb_idx]['album_desc'] = bb_decode($alb_thumb['description']);
$alb_list[$alb_idx]['pic_count'] = $count;
$alb_list[$alb_idx]['last_upl'] = $last_upload_date;
$alb_list[$alb_idx]['album_info'] = sprintf($lang_list_albums['n_pictures'], $count) . ($count ? sprintf($lang_list_albums['last_added'], $last_upload_date) : "");
$alb_list[$alb_idx]['album_adm_menu'] = (GALLERY_ADMIN_MODE || (USER_ADMIN_MODE && $cat == USER_ID + FIRST_USER_CAT)) ? html_albummenu($alb_thumb['aid']) : ' ';
} elseif ($CONFIG['show_private']) { // uncomment this else block to show private album description
$last_upload_date = $count ? localised_date($alb_stat['last_upload'], $lastup_date_fmt) : '';
$alb_list[$alb_idx]['aid'] = $alb_thumb['aid'];
$alb_list[$alb_idx]['album_title'] = $alb_thumb['title'];
$alb_list[$alb_idx]['album_desc'] = bb_decode($alb_thumb['description']);
$alb_list[$alb_idx]['pic_count'] = $count;
$alb_list[$alb_idx]['last_upl'] = $last_upload_date;
$alb_list[$alb_idx]['album_info'] = sprintf($lang_list_albums['n_pictures'], $count) . ($count ? sprintf($lang_list_albums['last_added'], $last_upload_date) : "");
$alb_list[$alb_idx]['album_adm_menu'] = (GALLERY_ADMIN_MODE || (USER_ADMIN_MODE && $cat == USER_ID + FIRST_USER_CAT)) ? html_albummenu($alb_thumb['aid']) : ' ';
}
}
theme_display_album_list($alb_list, $nbAlb, $cat, $PAGE, $totalPages);
}
/**
*/
// List category albums
// This has been added to list the category albums largely a repetition of code elsewhere
// Redone for a cleaner approach
function list_cat_albums($cat = 0)
{
global $CONFIG, $USER, $PAGE, $lastup_date_fmt, $HTTP_GET_VARS, $USER_DATA;
global $lang_list_albums, $lang_errors;
if ($cat == 0) {
return '';
}
$alb_per_page = $CONFIG['albums_per_page'];
$maxTab = $CONFIG['max_tabs'];
$result = db_query("SELECT count(*) FROM {$CONFIG['TABLE_ALBUMS']} WHERE category = '$cat'");
$nbEnr = mysql_fetch_array($result);
$nbAlb = $nbEnr[0];
mysql_free_result($result);
if ($nbAlb == 0) {
return;
}
$totalPages = ceil($nbAlb / $alb_per_page);
if ($PAGE > $totalPages) $PAGE = 1;
$lower_limit = ($PAGE-1) * $alb_per_page;
$upper_limit = min($nbAlb, $PAGE * $alb_per_page);
$limit = "LIMIT " . $lower_limit . "," . ($upper_limit - $lower_limit);
$sql = "SELECT a.aid, a.title, a.description, visibility, filepath, " . " filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_ALBUMS']} as a " . "LEFT JOIN {$CONFIG['TABLE_PICTURES']} as p ON thumb=pid " . "WHERE category = '$cat' ORDER BY pos " . "$limit";
$alb_thumbs_q = db_query($sql);
$alb_thumbs = db_fetch_rowset($alb_thumbs_q);
mysql_free_result($alb_thumbs_q);
$disp_album_count = count($alb_thumbs);
$album_set = '';
foreach($alb_thumbs as $value) {
$album_set .= $value['aid'] . ', ';
}
$album_set = '(' . substr($album_set, 0, -2) . ')';
$sql = "SELECT aid, count(pid) as pic_count, max(pid) as last_pid, max(ctime) as last_upload " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE aid IN $album_set AND approved = 'YES' " . "GROUP BY aid";
$alb_stats_q = db_query($sql);
$alb_stats = db_fetch_rowset($alb_stats_q);
mysql_free_result($alb_stats_q);
foreach($alb_stats as $key => $value) {
$cross_ref[$value['aid']] = &$alb_stats[$key];
}
for ($alb_idx = 0; $alb_idx < $disp_album_count; $alb_idx++) {
$alb_thumb = &$alb_thumbs[$alb_idx];
$aid = $alb_thumb['aid'];
if (isset($cross_ref[$aid])) {
$alb_stat = $cross_ref[$aid];
$count = $alb_stat['pic_count'];
} else {
$alb_stat = array();
$count = 0;
}
// Inserts a thumbnail if the album contains 1 or more images
$visibility = $alb_thumb['visibility'];
if ($visibility == '0' || $visibility == (FIRST_USER_CAT + USER_ID) || $visibility == $USER_DATA['group_id']) { // test for visibility
if ($count > 0) { // Inserts a thumbnail if the album contains 1 or more images
if ($alb_thumb['filename']) {
$picture = &$alb_thumb;
} else {
$sql = "SELECT filepath, filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE pid='{$alb_stat['last_pid']}'";
$result = db_query($sql);
$picture = mysql_fetch_array($result);
mysql_free_result($result);
}
$image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['alb_list_thumb_size']);
$alb_list[$alb_idx]['thumb_pic'] = "<img src=\"" . get_pic_url($picture, 'thumb') . "\" {$image_size['geom']} alt=\"\" border=\"0\" class=\"image\" />";
} else { // Inserts an empty thumbnail if the album contains 0 images
$image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']);
$alb_list[$alb_idx]['thumb_pic'] = "<img src=\"images/nopic.jpg\" {$image_size['geom']} alt=\"\" border=\"0\" class=\"image\" />";
}
} elseif ($CONFIG['show_private']) {
$image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']);
$alb_list[$alb_idx]['thumb_pic'] = "<img src=\"images/private.jpg\" {$image_size['geom']} alt=\"\" border=\"0\" class=\"image\" />";
}
// Prepare everything
if ($visibility == '0' || $visibility == (FIRST_USER_CAT + USER_ID) || $visibility == $USER_DATA['group_id']) {
$last_upload_date = $count ? localised_date($alb_stat['last_upload'], $lastup_date_fmt) : '';
$alb_list[$alb_idx]['aid'] = $alb_thumb['aid'];
$alb_list[$alb_idx]['album_title'] = $alb_thumb['title'];
$alb_list[$alb_idx]['album_desc'] = bb_decode($alb_thumb['description']);
$alb_list[$alb_idx]['pic_count'] = $count;
$alb_list[$alb_idx]['last_upl'] = $last_upload_date;
$alb_list[$alb_idx]['album_info'] = sprintf($lang_list_albums['n_pictures'], $count) . ($count ? sprintf($lang_list_albums['last_added'], $last_upload_date) : "");
$alb_list[$alb_idx]['album_adm_menu'] = (GALLERY_ADMIN_MODE || (USER_ADMIN_MODE && $cat == USER_ID + FIRST_USER_CAT)) ? html_albummenu($alb_thumb['aid']) : '';
} elseif ($CONFIG['show_private']) { // uncomment this else block to show private album description
$last_upload_date = $count ? localised_date($alb_stat['last_upload'], $lastup_date_fmt) : '';
$alb_list[$alb_idx]['aid'] = $alb_thumb['aid'];
$alb_list[$alb_idx]['album_title'] = $alb_thumb['title'];
$alb_list[$alb_idx]['album_desc'] = bb_decode($alb_thumb['description']);
$alb_list[$alb_idx]['pic_count'] = $count;
$alb_list[$alb_idx]['last_upl'] = $last_upload_date;
$alb_list[$alb_idx]['album_info'] = sprintf($lang_list_albums['n_pictures'], $count) . ($count ? sprintf($lang_list_albums['last_added'], $last_upload_date) : "");
$alb_list[$alb_idx]['album_adm_menu'] = (GALLERY_ADMIN_MODE || (USER_ADMIN_MODE && $cat == USER_ID + FIRST_USER_CAT)) ? html_albummenu($alb_thumb['aid']) : '';
}
}
ob_start();
theme_display_album_list_cat($alb_list, $nbAlb, $cat, $PAGE, $totalPages);
$cat_albums = ob_get_contents();
ob_end_clean();
return $cat_albums;
}
/**
*/
/**
* Main code
*/
if (isset($HTTP_GET_VARS['page'])) {
$PAGE = max((int)$HTTP_GET_VARS['page'], 1);
$USER['lap'] = $PAGE;
} elseif (isset($USER['lap'])) {
$PAGE = max((int)$USER['lap'], 1);
} else {
$PAGE = 1;
}
if (isset($HTTP_GET_VARS['cat'])) {
$cat = (int)$HTTP_GET_VARS['cat'];
}
// Gather data for categories
$breadcrumb = '';
$cat_data = array();
$statistics = '';
$STATS_IN_ALB_LIST = false;
get_cat_list($breadcrumb, $cat_data, $statistics);
pageheader($BREADCRUMB_TEXT ? $BREADCRUMB_TEXT : $lang_index_php['welcome']);
$elements = preg_split("|/|", $CONFIG['main_page_layout'], -1, PREG_SPLIT_NO_EMPTY);
foreach ($elements as $element) {
if (preg_match("/(\w+),*(\d+)*/", $element, $matches)) switch ($matches[1]) {
case 'breadcrumb':
// Added breadcrumb as a separate listable blcok from config
if ($breadcrumb != '' || count($cat_data) > 0) theme_display_breadcrumb($breadcrumb, $cat_data);
break;
case 'catlist':
if ($breadcrumb != '' || count($cat_data) > 0) theme_display_cat_list($breadcrumb, $cat_data, $statistics);
if (isset($cat) && $cat == USER_GAL_CAT) list_users();
flush();
break;
case 'alblist':
list_albums();
flush();
break;
case 'random':
display_thumbnails('random', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
flush();
break;
case 'lastup':
display_thumbnails('lastup', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
flush();
break;
case 'lastalb':
display_thumbnails('lastalb', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
break;
case 'topn':
display_thumbnails('topn', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
flush();
break;
case 'toprated':
display_thumbnails('toprated', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
flush();
break;
case 'lastcom':
display_thumbnails('lastcom', $cat, 1, $CONFIG['thumbcols'], max(1, $matches[2]), false);
flush();
break;
case 'anycontent':
if ($cat == 0) {
include('anycontent.php');
}
flush();
break;
}
}
pagefooter();
ob_end_flush();
// Speed-up the random image query by 'keying' the image table
if (time() - $CONFIG['randpos_interval'] > 86400) {
$result = db_query("SELECT count(*) FROM {$CONFIG['TABLE_PICTURES']} WHERE 1");
$nbEnr = mysql_fetch_array($result);
mysql_free_result($result);
$pic_count = $nbEnr[0];
$granularity = floor($pic_count / RANDPOS_MAX_PIC);
$result = db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET randpos = ROUND(RAND()*$granularity) WHERE 1");
$result = db_query("UPDATE {$CONFIG['TABLE_CONFIG']} SET value = '" . time() . "' WHERE name = 'randpos_interval'");
}
?>
If someone knows what I can do to solve this problem, please reply. I would really appreciate the help.
Thanks,
Sara
did you modify include/init.inc.php?
Try replacing it with the file from the package, maybe the file is corrupt (re-download the package just to make sure everything is working correctly).
GauGau
Hi, thanks for helping me.
As far as I know, the file hasn't been modified. If I redownload the package, should I just reupload the one file init.inc.php or the entire package? I tried just uploading the one file and it still gives me the same error messages.
Thanks again.
--Sara
your server os and php version, please?
GauGau
Linux and PHP Version 4.3.3
--Sara
PHP version should be OK then - I'm still convinced you have a faulty version of init.inc.php. If swapping it with a fresh file from the package won't help, please post your version of the file around line 49 (and specify which line is line 49).
GauGau
Well, I redownloaded the package again from a different mirror, then reuploaded the package's index.php and init.inc.php files to my directory. I don't know what the deal was, but now everything's working again! Thanks for your help, it is very much appreciated! :D