$browser = 'NetPositive'; } elseif (preg_match('#Shiira#i', $server_agent)) { $browser = 'Shiira'; } elseif (preg_match('#Shiretoko#i', $server_agent)) { $browser = 'Firefox'; } elseif (preg_match('#Sleipnir#i', $server_agent)) { $browser = 'Sleipnir'; } elseif (preg_match('#Stainless#i', $server_agent)) { $browser = 'Stainless'; } elseif (preg_match('#Sunrise#i', $server_agent)) { $browser = 'Sunrise'; } // Information partially taken from http://www.useragentstring.com/ //Code to get the search string if the referrer is any of the following $search_engines = array( 'google', 'lycos', 'yahoo' ); $query_array = array(); foreach ($search_engines as $engine) { if (is_referer_search_engine($engine)) { $query_array = get_search_query_terms($engine); break; } } $query_terms = is_array($query_array) ? implode(',', $query_array) : ''; $return_array = array( 'os' => $os, 'browser' => $browser, 'query_terms' => $query_terms ); return $return_array; } // Add 1 everytime a picture is viewed. /** * add_hit() * * @param $pid * @return **/ function add_hit($pid) { global $CONFIG, $raw_ip; if ($CONFIG['count_file_hits']) { cpg_db_query("UPDATE {$CONFIG['TABLE_PICTURES']} SET hits = hits + 1, lasthit_ip = '$raw_ip', mtime = CURRENT_TIMESTAMP WHERE pid = $pid"); } /** * Code to record the details of hits for the picture, if the option is set in CONFIG */ if ($CONFIG['hit_details']) { // Get the details of user browser, IP, OS, etc $client_details = cpg_determine_client(); $search_phrase = addslashes($client_details['query_terms']); //Making Cage $superCage = Inspekt::makeSuperCage(); $time = time(); //Sanitize the referer if ($superCage->server->keyExists('HTTP_REFERER')) { $referer = $superCage->server->getEscaped('HTTP_REFERER'); } else { $referer = ''; } $hitUserId = USER_ID; // Insert the record in database $query = "INSERT INTO {$CONFIG['TABLE_HIT_STATS']} SET" ." pid = $pid," ." search_phrase = '$search_phrase'," ." Ip = '$raw_ip'," ." sdate = '$time'," ." referer='$referer'," ." browser = '{$client_details['browser']}'," ." os = '{$client_details['os']}'," ." uid ='$hitUserId'"; cpg_db_query($query); } } /** * add_album_hit() * Add a hit to the album. * @param $pid * @return **/ function add_album_hit($aid) { global $CONFIG; if ($CONFIG['count_album_hits']) { $aid = (int) $aid; cpg_db_query("UPDATE {$CONFIG['TABLE_ALBUMS']} SET alb_hits = alb_hits + 1 WHERE aid = $aid"); } } /** * breadcrumb() * * Build the breadcrumb navigation * * @param integer $cat * @param string $breadcrumb * @param string $BREADCRUMB_TEXT * @return **/ function breadcrumb($cat, &$breadcrumb, &$BREADCRUMB_TEXT) { global $lang_list_categories, $lang_common; global $CONFIG,$CURRENT_ALBUM_DATA, $CURRENT_CAT_NAME; $category_array = array(); // first we build the category path: names and id if ($cat != 0) { //Categories other than 0 need to be selected if ($cat >= FIRST_USER_CAT) { $result = cpg_db_query("SELECT name FROM {$CONFIG['TABLE_CATEGORIES']} WHERE cid = " . USER_GAL_CAT); $row = $result->fetchAssoc(true); $category_array[] = array(USER_GAL_CAT, $row['name']); $user_name = get_username($cat - FIRST_USER_CAT); if (!$user_name) { $user_name = $lang_common['username_if_blank']; } $category_array[] = array($cat, $user_name); $CURRENT_CAT_NAME = sprintf($lang_list_categories['xx_s_gallery'], $user_name); $row['parent'] = 1; } else { $result = cpg_db_query("SELECT p.cid, p.name FROM {$CONFIG['TABLE_CATEGORIES']} AS c, {$CONFIG['TABLE_CATEGORIES']} AS p WHERE c.lft BETWEEN p.lft AND p.rgt AND c.cid = $cat ORDER BY p.lft"); while ( ($row = $result->fetchAssoc()) ) { $category_array[] = array($row['cid'], $row['name']); $CURRENT_CAT_NAME = $row['name']; } $result->free(); } } $breadcrumb_links = array(); $BREADCRUMB_TEXTS = array(); // Add the Home link to breadcrumb $breadcrumb_links[0] = ''.$lang_list_categories['home'].''; $BREADCRUMB_TEXTS[0] = $lang_list_categories['home']; $cat_order = 1; foreach ($category_array as $category) { $breadcrumb_links[$cat_order] = "{$category[1]}"; $BREADCRUMB_TEXTS[$cat_order] = $category[1]; $cat_order += 1; } //Add Link for album if aid is set if (isset($CURRENT_ALBUM_DATA['aid'])) { $breadcrumb_links[$cat_order] = "".$CURRENT_ALBUM_DATA['title'].""; $BREADCRUMB_TEXTS[$cat_order] = $CURRENT_ALBUM_DATA['title']; } // Build $breadcrumb,$BREADCRUMB_TEXT from _links and _TEXTS theme_breadcrumb($breadcrumb_links, $BREADCRUMB_TEXTS, $breadcrumb, $BREADCRUMB_TEXT); } // function breadcrumb /************************************************************************** **************************************************************************/ // Get the configured/available image tool class function getImageTool () { global $CONFIG; if ($CONFIG['thumb_method'] == 'imx') { require_once 'include/imageobject_imx.class.php'; } elseif ($CONFIG['thumb_method'] == 'im') { require_once 'include/imageobject_im.class.php'; } else { require_once 'include/imageobject_gd.class.php'; } } // Compute image geometry based on max width / height /** * compute_img_size() * * Compute image geometry based on max, width / height * * @param integer $width * @param integer $height * @param integer $max * @return array **/ function compute_img_size($width, $height, $max, $system_icon = false, $normal = false) { 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) { $image_size['reduced'] = true; } $ratio = max($ratio, 1); $image_size['width'] = (int) ($width / $ratio); $image_size['height'] = (int) ($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'] . '"'; //thumb cropping } elseif ($thumb_use == 'ex') { if ($normal == 'normal') { $image_size['geom'] = 'width="' . $image_size['width'] . '" height="' . $image_size['height'] . '"'; } elseif ($normal == 'cat_thumb') { $image_size['geom'] = 'width="' . $max . '" height="' . ($CONFIG['thumb_height'] * $max / $CONFIG['thumb_width']) . '"'; } else { $image_size['geom'] = 'width="' . $CONFIG['thumb_width'] . '" height="' . $CONFIG['thumb_height'] . '"'; } //if we have a system icon we override the previous calculation and take 'any' as base for the calc if ($system_icon) { $image_size['geom'] = 'width="' . $image_size['width'] . '" height="' . $image_size['height'] . '"'; } } else { $image_size['geom'] = 'width="' . $image_size['width'] . '" height="' . $image_size['height'] . '"'; } return $image_size; } // function compute_img_size // Prints thumbnails of pictures in an album /** * display_thumbnails() * * Generates data to display thumbnails of pictures in an album * * @param mixed $album Either the album ID or the meta album name * @param integer $cat Either the category ID or album ID if negative * @param integer $page Page number to display * @param integer $thumbcols * @param integer $thumbrows * @param boolean $display_tabs **/ function display_thumbnails($album, $cat, $page, $thumbcols, $thumbrows, $display_tabs) { global $CONFIG, $USER, $LINEBREAK; global $lang_date, $lang_display_thumbnails, $lang_byte_units, $lang_common, $valid_meta_albums; $superCage = Inspekt::makeSuperCage(); $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 (is_array($pic_data) && $pic_data) { foreach ($pic_data as $key => $row) { $i++; $pic_title = $lang_common['filename'] . '=' . $row['filename'] . $LINEBREAK . $lang_common['filesize'] . '=' . ($row['filesize'] >> 10) . $lang_byte_units[1] . $LINEBREAK . $lang_display_thumbnails['dimensions'] . $row['pwidth'] . "x" . $row['pheight'] . $LINEBREAK . $lang_display_thumbnails['date_added'] . localised_date($row['ctime'], $lang_date['album']); list($pic_title) = CPGPluginAPI::filter('thumb_html_title', array($pic_title, $row)); $pic_url = get_pic_url($row, 'thumb'); if (!is_image($row['filename'])) { $image_info = cpg_getimagesize(urldecode($pic_url)); $row['pwidth'] = $image_info[0]; $row['pheight'] = $image_info[1]; } // thumb cropping - if we display a system thumb we calculate the dimension by any and not ex if (array_key_exists('system_icon', $row) && ($row['system_icon'] == true)) { $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width'], true); } else { $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]['pid'] = $row['pid']; $thumb_list[$i]['image'] = '' . $row['filename'] . ''; $thumb_list[$i]['caption'] = bb_decode($row['caption_text']); $thumb_list[$i]['admin_menu'] = ''; $thumb_list[$i]['aid'] = $row['aid']; $thumb_list[$i]['pwidth'] = $row['pwidth']; $thumb_list[$i]['pheight'] = $row['pheight']; // cpg1.5: new thumb fields below $thumb_list[$i]['title'] = $row['title']; $thumb_list[$i]['description'] = $row['caption']; $thumb_list[$i]['filepath'] = $row['filepath']; $thumb_list[$i]['filename'] = $row['filename']; $thumb_list[$i]['filesize'] = $row['filesize']; $thumb_list[$i]['msg_id'] = isset($row['msg_id']) ? $row['msg_id'] : ''; // needed for get_pic_pos() } // Add a hit to album counter if it is a numeric album if (is_numeric($album)) { // Create an array to hold the album id for hits (if not created) if (!isset($USER['liv_a']) || !is_array($USER['liv_a'])) { $USER['liv_a'] = array(); } // Add 1 to album hit counter if ((!USER_IS_ADMIN && $CONFIG['count_admin_hits'] == 0 || $CONFIG['count_admin_hits'] == 1) && !in_array($album, $USER['liv_a']) && $superCage->cookie->keyExists($CONFIG['cookie_name'] . '_data')) { add_album_hit($album); if (count($USER['liv_a']) > 4) { array_shift($USER['liv_a']); } array_push($USER['liv_a'], $album); user_save_profile(); } } //Using getRaw(). The date is sanitized in the called function. $date = $superCage->get->keyExists('date') ? cpgValidateDate($superCage->get->getRaw('date')) : null; theme_display_thumbnails($thumb_list, $thumb_count, $album_name, $album, $cat, $page, $total_pages, is_numeric($album), $display_tabs, 'thumb', $date); } elseif (is_numeric($album) || in_array($album, $valid_meta_albums)) { theme_no_img_to_display($album_name); } } /** * cpg_get_system_thumb_list() * * Return an array containing the system thumbs in a directory * @param string $search_folder * @return array **/ function cpg_get_system_thumb_list($search_folder = 'images/') { global $CONFIG; static $thumbs = array(); $folder = 'images/thumbs/'; $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 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; } } /** * cpg_get_system_thumb() * * Gets data for system thumbs * * @param string $filename * @param integer $user * @return array **/ function& cpg_get_system_thumb($filename, $user = FIRST_USER_CAT) { global $CONFIG; // Correct user_id if ($user < FIRST_USER_CAT) { $user += FIRST_USER_CAT; } if ($user == FIRST_USER_CAT) { $user = FIRST_USER_CAT + 1; } // Get image data for thumb $picdata = array( 'filename' => $filename, 'filepath' => $CONFIG['userpics'] . $user . '/', 'url_prefix' => 0, ); $pic_url = get_pic_url($picdata, 'thumb', true); $picdata['thumb'] = $pic_url; $image_info = cpg_getimagesize(urldecode($pic_url)); $picdata['pwidth'] = $image_info[0]; $picdata['pheight'] = $image_info[1]; $image_size = compute_img_size($picdata['pwidth'], $picdata['pheight'], $CONFIG['alb_list_thumb_size']); $picdata['whole'] = $image_size['whole']; $picdata['reduced'] = (isset($image_size['reduced']) && $image_size['reduced']); return $picdata; } // function cpg_get_system_thumb /** * display_film_strip() * * gets data for thumbnails in an album for the film strip * * @param integer $album * @param integer $cat * @param integer $pos **/ function display_film_strip($album, $cat, $pos,$ajax_call) { global $CONFIG, $LINEBREAK; global $lang_date, $lang_display_thumbnails, $lang_byte_units, $lang_common, $pic_count,$ajax_call,$pos; $superCage = Inspekt::makeSuperCage(); $max_item = $CONFIG['max_film_strip_items']; $thumb_width = $CONFIG['thumb_width']; /** set to variable with to javascript*/ set_js_var('thumb_width', $thumb_width); set_js_var('thumb_use', $CONFIG['thumb_use']); if ($CONFIG['max_film_strip_items'] % 2 == 0) { $max_item = $CONFIG['max_film_strip_items'] + 1; $pic_count = $pic_count + 1; } $max_item_real = $max_item; /** check the thumb_per_page variable valid to query database*/ if ($pic_count < $max_item_real) { $max_item_real = $pic_count; } /** pass the max_items to the dispalyimage.js file */ set_js_var('max_item', $max_item_real); $max_block_items = $CONFIG['max_film_strip_items']; $thumb_per_page = $max_item_real; /** assign the varible $l_limit diffen */ $l_limit = (int) ($max_item_real / 2); $l_limit = max(0, $pos - $l_limit); /** set $l_limit to last images */ if ($l_limit > ($pic_count - $max_item_real)) { $l_limit = $pic_count - $max_item_real; } $pic_data = get_pic_data($album, $thumb_count, $album_name, $l_limit, $thumb_per_page, false, 'filmstrip'); if (count($pic_data) < $max_item) { $max_item = count($pic_data); } $lower_limit = 0; if ($ajax_call == 2) { $lower_limit = $max_item_real -1; $max_item = 1; } elseif ($ajax_call == 1) { $lower_limit = 0; $max_item = 1; } $pic_data = array_slice($pic_data, $lower_limit, $max_item); $i = $l_limit; set_js_var('count', $pic_count); $cat_link = is_numeric($album) ? '' : '&cat=' . $cat; //FIXME: Where does this '$date' come from? if (isset($date) && $date != '') { $date_link = '&date=' . $date; } else { $date_link = ''; } if ($superCage->get->getInt('uid')) { $uid_link = '&uid=' . $superCage->get->getInt('uid'); } else { $uid_link = ''; } if (count($pic_data) > 0) { foreach ($pic_data as $key => $row) { //$hi is never used //$hi = (($pos == ($i + $lower_limit)) ? '1': ''); $i++; $pic_alt = $row['filename']; $pic_title = $lang_common['filename'] . '=' . $row['filename'] . $LINEBREAK . $lang_common['filesize'] . '=' . ($row['filesize'] >> 10) . $lang_byte_units[1] . $LINEBREAK . $lang_display_thumbnails['dimensions'] . $row['pwidth'] . "x" . $row['pheight'] . $LINEBREAK . $lang_display_thumbnails['date_added'] . localised_date($row['ctime'], $lang_date['album']); list($pic_title) = CPGPluginAPI::filter('thumb_strip_html_title', array($pic_title, $row)); $pic_url = get_pic_url($row, 'thumb'); /*if (!is_image($row['filename'])) { $image_info = cpg_getimagesize(urldecode($pic_url)); $row['pwidth'] = $image_info[0]; $row['pheight'] = $image_info[1]; } //thumb cropping /*if (array_key_exists('system_icon', $row) && ($row['system_icon'] == true)) { $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width'], true); } else { $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['thumb_width']); }*/ // values never used $p = $i - 1 + $lower_limit; $p = ($p < 0 ? 0 : $p); $thumb_list[$i]['pos'] = $key < 0 ? $key : $p; $thumb_list[$i]['image'] = '' . $row['filename'] . ''; $thumb_list[$i]['admin_menu'] = ''; $thumb_list[$i]['pid'] = $row['pid']; $thumb_list[$i]['msg_id'] = isset($row['msg_id']) ? $row['msg_id'] : ''; // needed for get_pic_pos() $msg_id = isset($row['msg_id']) ? '&msg_id='.$row['msg_id'] : ''; $page = isset($row['msg_id']) ? '&page='.cpg_get_comment_page_number($row['msg_id']) : ''; $hash = isset($row['msg_id']) ? '#comment'.$row['msg_id'] : '#top_display_media'; $target = "displayimage.php?album=$album$cat_link$date_link&pid={$row['pid']}$msg_id$page$uid_link$hash"; } // Get the pos for next and prev links in filmstrip navigation $filmstrip_next_pos = $pos + 1; $filmstrip_prev_pos = $pos - 1; // If next pos is greater then total pics then make it pic_count - 1 $filmstrip_next_pos = $filmstrip_next_pos >= $pic_count ? $pic_count - 1 : $filmstrip_next_pos; // If prev pos is less than 0 then make it 0 $filmstrip_prev_pos = $filmstrip_prev_pos < 0 ? 0 : $filmstrip_prev_pos; //Using getRaw(). The date is sanitized in the called function. $date = $superCage->get->keyExists('date') ? cpgValidateDate($superCage->get->getRaw('date')) : null; if ($ajax_call == 2 || $ajax_call == 1) { $setArray = array( 'url' => $pic_url, 'target' => $target, 'alt' => $pic_alt, 'title' => $pic_title, ); header("Content-Type: text/plain"); echo json_encode($setArray); } else { return theme_display_film_strip($thumb_list, $thumb_count, $album_name, $album, $cat, $pos, is_numeric($album), 'thumb', $date, $filmstrip_prev_pos, $filmstrip_next_pos, $max_block_items, $thumb_width); } } else { if ($ajax_call == 2 || $ajax_call == 1) { $setArray = array( 'url' => 'images/stamp.png', 'target' => 'images/stamp.png', 'alt' => 'stamp.png', 'title' => '', ); header("Content-Type: text/plain"); echo json_encode($setArray); } else { theme_no_img_to_display($album_name); } } } /** * display_slideshow() * * gets data for thumbnails in an album for the film stript using Ajax call * * this added by Nuwan Sameera Hettiarachchi * * @param integer $album * @param integer $cat * @param integer $pos **/ function display_slideshow($pos, $ajax_show = 0) { global $CONFIG, $album, $pid, $slideshow, $USER; $superCage = Inspekt::makeSuperCage(); $Pic = array(); $Pid = array(); $Title = array(); $i = 0; $j = 0; /** get the pic details by querying database*/ $pic_data = get_pic_data($album, $pic_count, $album_name, $pos, 1, false); /** calculate total amount of pic a perticular album */ if ($ajax_show == 0) { set_js_var('Pic_count', $pic_count); } foreach ($pic_data as $picture) { if (is_image($picture['filename'])) { if ($CONFIG['make_intermediate'] && cpg_picture_dimension_exceeds_intermediate_limit($picture['pwidth'], $picture['pheight'])) { $picture_url = get_pic_url($picture, 'normal'); } else { $picture_url = get_pic_url($picture, 'fullsize'); } $Pic[$i] = htmlspecialchars($picture_url, ENT_QUOTES); /*if ($picture['pid'] == $pid) { $j = $i; $start_img = $picture_url; }*/ //$j and $start_img are never used } else { $pic_url = get_pic_url($picture, 'thumb'); $Pic[$i] = htmlspecialchars($pic_url); } $Pid[$i] = $picture['pid']; $Title[$i] = $picture['title'] ? $picture['title'] : $picture['filename']; $i++; } /** set variables to jquery.slideshow.js */ set_js_var('Time', $slideshow); set_js_var('Pid', $pid); /*if (!$i) { $Pic[0] = 'images/thumb_document.jpg'; }*/ // Add the hit if slideshow hits are enabled in config if ((!USER_IS_ADMIN && $CONFIG['count_admin_hits'] == 0 || $CONFIG['count_admin_hits'] == 1) && $CONFIG['slideshow_hits'] != 0) { // Add 1 to hit counter if (!in_array($Pid['0'], $USER['liv']) && $superCage->cookie->keyExists($CONFIG['cookie_name'] . '_data')) { add_hit($Pid['0']); if (count($USER['liv']) > 4) { array_shift($USER['liv']); } array_push($USER['liv'], $Pid['0']); user_save_profile(); } } /** show slide show on first time*/ if ($ajax_show == 0) { theme_slideshow($Pic['0'], $Title['0']); } /** now we make a array to encode*/ $dataArray = array( 'url' => $Pic['0'], 'title' => $Title['0'], 'pid' => $Pid['0'], ); $dataJson = json_encode($dataArray); /** send variable to javascript script*/ if ($ajax_show == 1) { header("Content-Type: text/plain"); echo $dataJson; } } // Return the url for a picture, allows to have pictures spreaded over multiple servers /** * get_pic_url() * * Return the url for a picture * * @param array $pic_row * @param string $mode * @param boolean $system_pic * @return string **/ function& get_pic_url(&$pic_row, $mode, $system_pic = false) { 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'], 'orig' => $CONFIG['orig_pfx'], 'fullsize' => '', ); $url_prefix = array( 0 => $CONFIG['fullpath'], ); } $mime_content = cpg_get_type($pic_row['filename']); // If $mime_content is empty there will be errors, so only perform the array_merge if $mime_content is actually an array if (is_array($mime_content)) { $pic_row = array_merge($pic_row, $mime_content); } $filepathname = null; // Code to handle custom thumbnails // If fullsize or normal mode use regular file if ($mime_content['content'] != 'image' && $mode == 'normal') { $mode = 'fullsize'; } elseif (($mime_content['content'] != 'image' && $mode == 'thumb') || $system_pic) { $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 if (array_key_exists('url_prefix', $pic_row)) { $custom_thumb_path = $url_prefix[$pic_row['url_prefix']]; } else { $custom_thumb_path = ''; } $custom_thumb_path .= $pic_row['filepath'] . (array_key_exists($mode, $pic_prefix) ? $pic_prefix[$mode] : ''); $file_base_name = str_ireplace('.' . $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; } } if (!$system_pic) { // 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/thumbs/'; // Default Coppermine thumbs foreach ($thumb_paths as $default_thumb_path) { if (is_dir($default_thumb_path)) { if (!$system_pic) { 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; //thumb cropping - if we display a system thumb we calculate the dimension by any and not ex $pic_row['system_icon'] = true; 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; //thumb cropping $pic_row['system_icon'] = true; break 2; } } } else { // Check for file-specific thumbs for system files foreach ($thumb_extensions as $extension) { if (file_exists($default_thumb_path . $CONFIG['thumb_pfx'] . $file_base_name . $extension)) { $filepathname = $default_thumb_path . $CONFIG['thumb_pfx'] . $file_base_name . $extension; //thumb cropping $pic_row['system_icon'] = true; break 2; } } // foreach $thumb_extensions } // else $system_pic } // if is_dir($default_thumb_path) } // foreach $thumbpaths } // if is_null($filepathname) if ($filepathname) { $filepathname = path2url($filepathname); } } if (is_null($filepathname)) { $localpath = $pic_row['filepath'] . $pic_prefix[$mode] . $pic_row['filename']; // Check here that the filename we are going to return exists // If it doesn't exist we return a placeholder image // We then log the missing file for the admin's attention if (file_exists($url_prefix[$pic_row['url_prefix']] . $localpath)) { $filepathname = $url_prefix[$pic_row['url_prefix']] . path2url($localpath); } else { $filepathname = 'images/thumbs/thumb_nopic.png'; $pic_row['system_icon'] = true; if ($CONFIG['log_mode'] != 0) { log_write("File {$url_prefix[$pic_row['url_prefix']]}$localpath is missing."); } } } // Added hack: "&& !isset($pic_row['mode'])" thumb_data filter isn't executed for the fullsize image if ($mode == 'thumb' && !isset($pic_row['mode'])) { $pic_row['url'] = $filepathname; $pic_row['mode'] = $mode; $pic_row = CPGPluginAPI::filter('thumb_data', $pic_row); } elseif ($mode != 'thumb') { $pic_row['url'] = $filepathname; $pic_row['mode'] = $mode; } else { $pic_row['url'] = $filepathname; } $pic_row = CPGPluginAPI::filter('picture_url', $pic_row); return $pic_row['url']; } // function get_pic_url /** * cpg_get_default_lang_var() * * Return a variable from the default language file * * @param $language_var_name * @param unknown $override_language * @return **/ function& cpg_get_default_lang_var($language_var_name, $override_language = null) { global $CONFIG; if (is_null($override_language)) { if (isset($CONFIG['default_lang'])) { $language = $CONFIG['default_lang']; } else { global $$language_var_name; return $$language_var_name; } } else { $language = $override_language; } include 'lang/english.php'; include 'lang/'.$language.'.php'; return $$language_var_name; } // function cpg_get_default_lang_var // Returns a variable from the current language file // If variable doesn't exists gets value from english_us lang file /** * cpg_lang_var() * * @param $varname * @param unknown $index * @return **/ 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; } } // function cpg_lang_var /** * cpg_debug_output() * * 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) * **/ function cpg_debug_output() { global $USER, $USER_DATA, $CONFIG, $cpg_time_start, $query_stats, $queries, $lang_cpg_debug_output, $CPG_PHP_SELF, $superCage, $CPG_PLUGINS, $LINEBREAK; if ($CONFIG['performance_timestamp'] == 0 || (date('Y-m-d', $CONFIG['performance_timestamp']) < date('Y-m-d'))) { // The metering data in the config table are outdated, let's write fresh values. // Currently happens each day. To extend the metering period to a whole week, // use 'Y-m-W' for both date functions above. Use 'Y-m' to extend the period over // one month and subsequently 'Y' for an entire year. $CONFIG['performance_timestamp'] = time(); cpg_config_set('performance_timestamp', $CONFIG['performance_timestamp']); $CONFIG['performance_page_generation_time'] = 0; $CONFIG['performance_page_query_time'] = 0; $CONFIG['performance_page_query_count'] = 0; } $time_end = cpgGetMicroTime(); $time = round(($time_end - $cpg_time_start) * 1000, 2); if ($CONFIG['performance_page_generation_time'] < $time) { $CONFIG['performance_page_generation_time'] = $time; cpg_config_set('performance_page_generation_time', $CONFIG['performance_page_generation_time']); } $query_count = count($query_stats); $total_query_time = round(array_sum($query_stats), 2); if ($CONFIG['performance_page_query_time'] < $total_query_time) { $CONFIG['performance_page_query_time'] = $total_query_time; cpg_config_set('performance_page_query_time', $CONFIG['performance_page_query_time']); } if ($CONFIG['performance_page_query_count'] < $query_count) { $CONFIG['performance_page_query_count'] = $query_count; cpg_config_set('performance_page_query_count', $CONFIG['performance_page_query_count']); } $debug_underline = ' ------------------ '; $debug_separate = ' ========================== '; $debug_toggle_link = $lang_cpg_debug_output['debug_output'] . ': '. $lang_cpg_debug_output['show_hide'].''; $debug_help = ' '. cpg_display_help('f=empty.htm&h=lang_cpg_debug_output%5Bdebug_output_explain%5D&t=lang_cpg_debug_output%5Bcopy_and_paste_instructions%5D', 470, 245); $debug_phpinfo_link = GALLERY_ADMIN_MODE ? '' . cpg_fetch_icon('phpinfo', 1) . $lang_cpg_debug_output['phpinfo'] . ' ' : ''; echo <<< EOT
EOT; starttable('100%', cpg_fetch_icon('bug', 2) . $lang_cpg_debug_output['debug_info'] . $debug_help, 2); echo <<< EOT {$debug_phpinfo_link}{$debug_toggle_link}
EOT; if ($CONFIG['debug_notice'] != 0) { // Maze's error report system global $cpgdebugger; $report = $cpgdebugger->stop(); //$debug_notices_icon = cpg_fetch_icon('text_left', 2); if (GALLERY_ADMIN_MODE) { $notices_help = 'notices_help_admin'; } else { $notices_help = 'notices_help_non_admin'; } $notices_help = ' ' . cpg_display_help('f=empty.htm&h=lang_cpg_debug_output[notices]&t=lang_cpg_debug_output['.$notices_help.']', 470, 245); if (is_array($report)) { echo <<< EOT {$lang_cpg_debug_output['notices']}{$notices_help} EOT; $noticesLoopCounter = 0; foreach ($report as $file => $errors) { if ($noticesLoopCounter/2 == floor($noticesLoopCounter/2)) { $cellstyle = 'tableb tableb_alternate'; } else { $cellstyle = 'tableb'; } echo <<< EOT EOT; //echo '' . substr($file, $strstart) . '