示例#1
0
function check_comment(&$str)
{
    global $CONFIG, $lang_bad_words, $queries;
    // Added according to Andi's proposal: optimization of strip-Tags and max. comment length
    // convert some entities
    $str = str_replace(array('&amp;', '&quot;', '&lt;', '&gt;', '&nbsp;', '&#39;'), array('&', '"', '<', '>', ' ', "'"), $str);
    // strip tags and cut to max allowed length
    $str = trim(substr(strip_tags($str), 0, $CONFIG['max_com_size']));
    // re convert some entities
    $str = str_replace(array('"', '<', '>', "'"), array('&quot;', '&lt;', '&gt;', '&#39;'), $str);
    if ($CONFIG['filter_bad_words']) {
        $ercp = array();
        foreach ($lang_bad_words as $word) {
            $ercp[] = '/' . ($word[0] == '*' ? '' : '\\b') . str_replace('*', '', $word) . ($word[strlen($word) - 1] == '*' ? '' : '\\b') . '/i';
        }
        $str = preg_replace($ercp, '(...)', $str);
    }
    $com_words = explode(' ', strip_tags(bb_decode($str)));
    $replacements = array();
    foreach ($com_words as $key => $word) {
        if (utf_strlen($word) > $CONFIG['max_com_wlength']) {
            $replacements[] = $word;
        }
    }
    $str = str_replace($replacements, '(...)', $str);
}
示例#2
0
function check_comment(&$str)
{
    global $CONFIG, $lang_bad_words;
    // convert some entities
    $str = str_replace(array('&amp;', '&quot;', '&lt;', '&gt;', '&nbsp;', '&#39;'), array('&', '"', '<', '>', ' ', "'"), $str);
    // if '<' is no start of a tag (e.g. a lower than + equal), convert it to entity to prevent strip_tags() to clip the comment wrongly
    $str = preg_replace("/<([0-9<>=])/", '&lt;\\1', $str);
    // strip tags and cut to max allowed length
    $str = trim(substr(strip_tags($str), 0, $CONFIG['max_com_size']));
    // re convert some entities
    $str = str_replace(array('"', '<', '>', "'"), array('&quot;', '&lt;', '&gt;', '&#39;'), $str);
    if ($CONFIG['filter_bad_words']) {
        $ercp = array();
        foreach ($lang_bad_words as $word) {
            $ercp[] = '/' . ($word[0] == '*' ? '' : '\\b') . str_replace('*', '', $word) . ($word[strlen($word) - 1] == '*' ? '' : '\\b') . '/i';
        }
        $str = preg_replace($ercp, '(...)', $str);
    }
    $com_words = explode(' ', strip_tags(bb_decode($str)));
    $replacements = array();
    foreach ($com_words as $key => $word) {
        if (utf_strlen($word) > $CONFIG['max_com_wlength']) {
            $replacements[] = $word;
        }
    }
    $str = str_replace($replacements, '(...)', $str);
}
示例#3
0
 function format_message($message)
 {
     if (!function_exists('process_smilies')) {
         include BASE_DIR . 'include' . DS . 'smilies.inc.php';
     }
     return make_clickable(process_smilies(bb_decode($message)));
 }
示例#4
0
function check_comment(&$str)
{
    global $CONFIG, $lang_bad_words, $queries;
    if ($CONFIG['filter_bad_words']) {
        $ercp = array();
        foreach ($lang_bad_words as $word) {
            $ercp[] = '/' . ($word[0] == '*' ? '' : '\\b') . str_replace('*', '', $word) . ($word[strlen($word) - 1] == '*' ? '' : '\\b') . '/i';
        }
        $str = preg_replace($ercp, '(...)', $str);
    }
    $com_words = explode(' ', strip_tags(bb_decode($str)));
    $replacements = array();
    foreach ($com_words as $key => $word) {
        if (utf_strlen($word) > $CONFIG['max_com_wlength']) {
            $replacements[] = $word;
        }
    }
    $str = str_replace($replacements, '(...)', $str);
}
示例#5
0
function fix_displayimage()
{
    // no specifics for Thumbnail page today.
    if (!defined("DISPLAYIMAGE_PHP")) {
        return;
    }
    global $CONFIG, $film_strip;
    global $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $comments, $picture, $votes, $pic_info, $template_display_media, $THEME_DIR;
    global $saved_template_image_comments, $saved_template_add_your_comment, $lang_display_comments, $lang_contest, $template_image_rating;
    if (!array_key_exists('aid', $CURRENT_ALBUM_DATA)) {
        return;
    }
    //checks if current album is a contest - not extracted in displayimage.php
    $result = cpg_db_query("SELECT contest FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid='{$CURRENT_ALBUM_DATA['aid']}'");
    if ($row = mysql_fetch_row($result)) {
        $CURRENT_ALBUM_DATA['contest'] = $row[0];
    } else {
        return;
    }
    // display the votes as a voting page.
    if ($CURRENT_ALBUM_DATA['votes'] != 'YES' && $CURRENT_ALBUM_DATA['contest'] == 'YES') {
        if (!defined('MAX_RATING')) {
            define('MAX_RATING', 5);
        }
        $title = $lang_contest['result'];
        $votetext = $CURRENT_PIC_DATA['votes'] ? sprintf($lang_contest['evaluation'], round($CURRENT_PIC_DATA['pic_rating'] / 2000, 1), MAX_RATING, $CURRENT_PIC_DATA['votes']) : $lang_rate_pic['no_votes'];
        $votes = $template_image_rating;
        $pattern = "#(<a href)(.*?)(</a>)#s";
        if (preg_match_all($pattern, $votes, $matches)) {
            foreach ($matches[0] as $key => $match) {
                if (preg_match("rating", $match)) {
                    $votes = ereg_replace(preg_quote($match), "", $votes);
                }
            }
        }
        $votes = ereg_replace("{VOTES}", $votetext, $votes);
        $votes = ereg_replace("{TITLE}", $title, $votes);
        $votes = ereg_replace("{LOCATION}", $THEME_DIR, $votes);
        if (preg_match("<!-- BEGIN rating_boxes -->", $votes)) {
            template_extract_block($votes, 'rating_boxes', '');
        }
    }
    //to be used only for contests in progress
    if ($CURRENT_ALBUM_DATA['votes'] == 'YES' && $CURRENT_ALBUM_DATA['contest'] == 'YES') {
        // do not display pic infos,owner names, captions
        $pic_info = "";
        $pattern = "#(<!-- BEGIN img_desc -->)(.*?)(<!-- END img_desc -->)#s";
        if (preg_match($pattern, $picture, $matches)) {
            $picture = str_replace($matches[0], $matches[1] . $matches[3], $picture);
        }
        //findout which image has already been noted by user in the contest and show them with a square in the film strip
        $myvotes = array();
        $query = "SELECT concat(filepath,'{$CONFIG['thumb_pfx']}',filename) FROM `{$CONFIG['TABLE_PREFIX']}user_votes` AS T1, `{$CONFIG['TABLE_PREFIX']}pictures` AS T2 WHERE T1.pid=T2.pid AND user_id  = " . USER_ID;
        $result = cpg_db_query($query);
        while ($row = mysql_fetch_row($result)) {
            $myvotes[] = $row[0];
        }
        $pattern = "#(<img )(.*?albums.*?)(\" border=\"0\")(.*?)(/>)#s";
        if (preg_match_all($pattern, $film_strip, $matches)) {
            foreach ($matches[0] as $key => $match) {
                foreach ($myvotes as $v) {
                    if (strpos($match, $v) !== FALSE) {
                        $matches[3][$key] = " style=\"border:1pix;border-color:grey;\"";
                        break;
                    }
                }
                $film_strip = ereg_replace(preg_quote($match), $matches[1][$key] . $matches[2][$key] . $matches[3][$key] . $matches[4][$key] . $matches[5][$key], $film_strip);
            }
            $film_strip = ereg_replace("class=\"image\"", "", $film_strip);
        }
        //removes alt and title from film_strip
        $pattern = "#(alt=\")(.*?)(\")#s";
        if (preg_match_all($pattern, $film_strip, $matches)) {
            foreach ($matches[0] as $key => $match) {
                $film_strip = ereg_replace(preg_quote($match), "", $film_strip);
            }
        }
        $pattern = "#(title=\")(.*?)(\")#s";
        if (preg_match_all($pattern, $film_strip, $matches)) {
            foreach ($matches[0] as $key => $match) {
                $film_strip = ereg_replace(preg_quote($match), "", $film_strip);
            }
        }
        //and try to set a border on current vote
        $result = cpg_db_query("SELECT rating FROM `{$CONFIG['TABLE_PREFIX']}user_votes` WHERE pid = {$CURRENT_PIC_DATA['pid']} AND user_id  = " . USER_ID);
        if ($row = mysql_fetch_row($result)) {
            $pattern = "#(<img.*?rating{$row[0]}.*?)(border=\"0\")(.*?/>)#s";
            if (preg_match($pattern, $votes, $matches)) {
                $votes = ereg_replace(preg_quote($matches[0]), $matches[1] . "border=\"2\"" . $matches[3], $votes);
            }
        }
        // find if user can vote (not own image) and if can vote verifies that the voting block is not hidden
        if ($CURRENT_PIC_DATA['owner_id'] == USER_ID || !USER_CAN_RATE_PICTURES) {
            //<a href="javascript:location.href='./ratepic.php?pic=22&amp;rate=1'" title="Beurk"><img src="themes/alphadxd/images/rating1.gif" border="0" alt="Beurk" /></a>
            $pattern = "#(<a href.*?ratepic.*?\\>)(.*?)(</a>)#s";
            if (preg_match_all($pattern, $votes, $matches)) {
                foreach ($matches[0] as $key => $match) {
                    $votes = ereg_replace(preg_quote($match), $matches[2][$key], $votes);
                }
            }
        } else {
            $votes = ereg_replace(preg_quote("display: none;"), "", $votes);
        }
        // only display current user's comments in a contest
        if ($CURRENT_ALBUM_DATA['comments'] != 'YES') {
            return;
        }
        $comments = '';
        $pid = $CURRENT_PIC_DATA['pid'];
        if (!$CONFIG['enable_smilies']) {
            $tmpl_comment_edit_box = template_extract_block($saved_template_image_comments, 'edit_box_no_smilies', '{EDIT}');
            template_extract_block($saved_template_image_comments, 'edit_box_smilies');
            template_extract_block($saved_template_add_your_comment, 'input_box_smilies');
        } else {
            $tmpl_comment_edit_box = template_extract_block($saved_template_image_comments, 'edit_box_smilies', '{EDIT}');
            template_extract_block($saved_template_image_comments, 'edit_box_no_smilies');
            template_extract_block($saved_template_add_your_comment, 'input_box_no_smilies');
        }
        $tmpl_comments_buttons = template_extract_block($saved_template_image_comments, 'buttons', '{BUTTONS}');
        template_extract_block($saved_template_image_comments, 'ipinfo', '');
        //suppressed by PL
        template_extract_block($saved_template_image_comments, 'report_comment_button');
        // won't report on own comment, would we?
        $newpostok = true;
        $query = "SELECT msg_id, msg_author, msg_body, UNIX_TIMESTAMP(msg_date) AS msg_date, author_id, author_md5_id, msg_raw_ip, msg_hdr_ip, pid FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid='{$pid}' AND msg_author='" . USER_NAME . "' ORDER BY msg_id DESC LIMIT 1";
        $result = cpg_db_query($query);
        if ($row = mysql_fetch_array($result)) {
            $user_can_edit = true;
            $comment_buttons = $tmpl_comments_buttons;
            $comment_edit_box = $tmpl_comment_edit_box;
            if ($CONFIG['enable_smilies']) {
                $comment_body = process_smilies(make_clickable($row['msg_body']));
                $smilies = generate_smilies("f{$row['msg_id']}", 'msg_body');
            } else {
                $comment_body = make_clickable($row['msg_body']);
                $smilies = '';
            }
            $params = array('{EDIT}' => &$tmpl_comment_edit_box, '{BUTTONS}' => &$tmpl_comments_buttons);
            $template = template_eval($saved_template_image_comments, $params);
            $params = array('{MSG_AUTHOR}' => stripslashes($row['msg_author']), '{MSG_ID}' => $row['msg_id'], '{PID}' => $row['pid'], '{EDIT_TITLE}' => &$lang_display_comments['edit_title'], '{CONFIRM_DELETE}' => &$lang_display_comments['confirm_delete'], '{MSG_DATE}' => localised_date($row['msg_date'], '%d %B %Y'), '{MSG_BODY}' => bb_decode($comment_body), '{MSG_BODY_RAW}' => $row['msg_body'], '{OK}' => &$lang_display_comments['OK'], '{SMILIES}' => $smilies, '{REPORT_COMMENT_TITLE}' => &$lang_display_comments['report_comment_title'], '{WIDTH}' => $CONFIG['picture_table_width']);
            $comments .= template_eval($template, $params);
            $newpostok = false;
            // only 1 comment per author
        }
        if (USER_ID == $CURRENT_PIC_DATA['owner_id'] || USER_ID == 0) {
            $newpostok = false;
        }
        if ($newpostok) {
            $user_name_input = '<tr><td><input type="hidden" name="msg_author" value="' . stripslashes(USER_NAME) . '" /></td>';
            template_extract_block($saved_template_add_your_comment, 'user_name_input', $user_name_input);
            $user_name = '';
            $params = array('{ADD_YOUR_COMMENT}' => $lang_display_comments['add_your_comment'], '{NAME}' => $lang_display_comments['name'], '{COMMENT}' => "", '{PIC_ID}' => $pid, '{USER_NAME}' => $user_name, '{MAX_COM_LENGTH}' => $CONFIG['max_com_size'], '{OK}' => $lang_display_comments['OK'], '{SMILIES}' => '', '{WIDTH}' => $CONFIG['picture_table_width']);
            if ($CONFIG['enable_smilies']) {
                $params['{SMILIES}'] = generate_smilies();
            } else {
                template_extract_block($saved_template_add_your_comment, 'smilies');
            }
            $comments .= template_eval($saved_template_add_your_comment, $params);
        }
    }
}
示例#6
0
  $Date: 2008-04-12 12:00:19 +0200 (Sa, 12 Apr 2008) $
**********************************************/
define('IN_COPPERMINE', true);
define('DISPLAYECARD_PHP', true);
require 'include/init.inc.php';
require 'include/smilies.inc.php';
if (!isset($_GET['data'])) {
    cpg_die(CRITICAL_ERROR, $lang_errors['param_missing'], __FILE__, __LINE__);
}
$data = array();
$data = @unserialize(@base64_decode($_GET['data']));
// attempt to obtain full link from db if ecard logging enabled and min 12 chars of data is provided and only 1 match
if (!is_array($data) && $CONFIG['log_ecards'] && strlen($_GET['data']) > 12) {
    $result = cpg_db_query("SELECT link FROM {$CONFIG['TABLE_ECARDS']} WHERE link LIKE '{$_GET['data']}%'");
    if (mysql_num_rows($result) === 1) {
        $row = mysql_fetch_assoc($result);
        $data = @unserialize(@base64_decode($row['link']));
    }
}
if (is_array($data)) {
    // Remove HTML tags as we can't trust what we receive
    foreach ($data as $key => $value) {
        $data[$key] = strtr($value, $HTML_SUBST);
    }
    // Load template parameters
    $params = array('{LANG_DIR}' => $lang_text_dir, '{TITLE}' => sprintf($lang_ecard_php['ecard_title'], $data['sn']), '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'], '{VIEW_ECARD_TGT}' => '', '{VIEW_ECARD_LNK}' => '', '{PIC_URL}' => $data['p'], '{URL_PREFIX}' => '', '{GREETINGS}' => $data['g'], '{MESSAGE}' => bb_decode(process_smilies($data['m'])), '{SENDER_EMAIL}' => $data['se'], '{SENDER_NAME}' => $data['sn'], '{VIEW_MORE_TGT}' => $CONFIG['ecards_more_pic_target'], '{VIEW_MORE_LNK}' => $lang_ecard_php['view_more_pics'], '{PID}' => $data['pid'], '{PIC_TITLE}' => $data['pt'], '{PIC_CAPTION}' => $data['pc']);
    // Parse template
    echo template_eval($template_ecard, $params);
} else {
    cpg_die(CRITICAL_ERROR, $lang_displayecard_php['invalid_data'], __FILE__, __LINE__);
}
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 {$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__);
    }
}
示例#8
0
文件: rss.php 项目: phill104/branches
function make_pic_descr($pic, $row)
{
    global $CONFIG;
    $txt = "";
    $breadcrumb = " ";
    $ret = "<table><tr><td>";
    $pic_url = make_pic_url($pic, $size, FALSE);
    $size = isset($row['pic_size']) ? $row['pic_size'] : "Thumb";
    $comments = isset($row['item_comments']) ? $row['item_comments'] : "No";
    $content = isset($row['item_content']) ? $row['item_content'] : "&nbsp;";
    switch ($size) {
        case "Normal":
            $width = $CONFIG['picture_width'];
            break;
        case "Thumb":
            $width = $CONFIG['thumb_width'];
            break;
    }
    $ret .= "<a href =\"" . $CONFIG['ecards_more_pic_target'] . "displayimage.php?pos=-" . $pic['pid'] . "\">";
    $ret .= "<img src=\"" . $pic_url . "\" width=\"" . $width . "\" alt=\"RSS image\" /></a></td>";
    $n = 0;
    $content = "x" . $content;
    //x to avoid hitting anchor in first position (0= false)
    while ($pos = strpos($content, "{")) {
        $n++;
        $len = strpos($content, "}") - $pos + 1;
        $cmd = substr($content, $pos, $len);
        $exif = exif_parse_file("albums/" . $pic['file']);
        switch ($cmd) {
            case "{br}":
                $content = str_replace($cmd, "<br />", $content);
                break;
            case "{adate}":
                $content = str_replace($cmd, strftime("%x", $pic['ctime']), $content);
                break;
            case "{album}":
                $content = str_replace($cmd, $pic['atitle'], $content);
                break;
            case "{fname}":
                $content = str_replace($cmd, $pic['filename'], $content);
                break;
            case "{fsize}":
                $content = str_replace($cmd, intval($pic['filesize'] / 1024) . " kB", $content);
                break;
            case "{title}":
                $content = str_replace($cmd, $pic['title'], $content);
                break;
            case "{hits}":
                $content = str_replace($cmd, $pic['hits'], $content);
                break;
            case "{rating}":
                $content = str_replace($cmd, $pic['rating'], $content);
                break;
            case "{descr}":
                $content = str_replace($cmd, $pic['caption'], $content);
                break;
            case "{miniCMS}":
                if (isset($CONFIG['TABLE_CMS'])) {
                    $txt = getMiniCMS($pic['pid']);
                }
                $content = str_replace($cmd, $txt, $content);
                break;
            case "{owner}":
                $content = str_replace($cmd, $pic['owner_name'], $content);
                break;
            case "{cat}":
                $i = $pic['category'];
                if (!isset($alb_name[$i])) {
                    $query = "SELECT title FROM " . $CONFIG['TABLE_ALBUMS'] . " WHERE aid=" . $pic['category'];
                    if ($result = cpg_db_query($query)) {
                        $title = cpg_db_fetch_row($result);
                        $alb_name[$pic['category']] = $title['title'];
                    }
                }
                $name = $alb_name[$pic['category']];
                $content = str_replace($cmd, $name, $content);
                break;
            case "{bread}":
                $breadcrumb = " ";
                breadcrumb($pic['category'], $breadcrumb, $BREADCRUMB_TEXT);
                $content = str_replace($cmd, $breadcrumb, $content);
                break;
            case "{make}":
                $exif = exif_parse_file("albums/" . $pic['file']);
                $param = substr($exif['Make'], 0, -1);
                $content = str_replace($cmd, $param, $content);
                break;
            case "{model}":
                $param = substr($exif['Model'], 0, -1);
                $content = str_replace($cmd, $param, $content);
                break;
            case "{keyw}":
                $content = str_replace($cmd, $pic['keywords'], $content);
                break;
            case "{date}":
                $param = substr($exif['DateTime Original'], 0, -1);
                $content = str_replace($cmd, $param, $content);
                break;
            default:
                /*print_r ($exif);
                  die();*/
                $lookup = substr($cmd, 1, -1);
                if (isset($exif[$lookup])) {
                    $param = $exif[$lookup];
                    if (!ord(substr($param, -1))) {
                        $param = substr($param, 0, -1);
                        //some exif values ends with a ascii 0 character
                    }
                } else {
                    $param = substr($cmd, 1, -1) . " not valid anchor";
                    // $param = $cmd." not valid anchor";
                }
                $content = str_replace($cmd, $param, $content);
                break;
        }
        //  if ($n>5) die ("ut: ".$content);
    }
    $content = substr($content, 1);
    $ret .= "<td valign=\"top\">" . $content . "</td></tr>";
    if ($comments == "Yes") {
        $coms = get_pic_comments($pic['pid']);
        if (count($coms) > 0) {
            foreach ($coms as $com) {
                $ret .= "<tr><td>&nbsp</td><td><p>" . $com['msg_author'] . ": " . $com['msg_body'] . "</td></tr>";
            }
        }
    }
    $ret .= "</table>";
    return bb_decode($ret);
}
示例#9
0
文件: rss.php 项目: phill104/branches
foreach ($data as $picture) {
    $titlefield = $CONFIG[plugin_easyrss_titlefield];
    $caption_text = "<br>" . $picture[hits] . " " . $lang_plugin_easyrss['views'];
    $caption_text .= "<br>" . date('M d, Y', $picture[ctime]);
    $thumb_url = "{$image_url}{$picture['filepath']}{$CONFIG['thumb_pfx']}{$picture['filename']}";
    $keywords = explode(" ", trim($picture[keywords]));
    $category_string = "";
    foreach ($keywords as $keyword) {
        $category_string .= "<category>{$keyword}</category>";
    }
    $pubDate = gmdate("D, d M Y H:i:s", $picture[ctime]);
    $description = '<a href="' . $link_url . $picture['pid'] . '"><img src="' . $thumb_url . '" border="1" vspace="2" hspace="2"> <align="center" ></a><br>';
    if ($titlefield == "title") {
        $description .= bb_decode($picture[caption]);
    }
    $description .= bb_decode($caption_text);
    $description = htmlspecialchars($description);
    $item = '<item>
              <title>' . ($picture[$titlefield] ? $picture[$titlefield] : $lang_plugin_easyrss['no'] . $lang_plugin_easyrss['label_' . $titlefield]) . '</title>
              <link>' . $link_url . $picture[pid] . '</link>
              <pubDate>' . $pubDate . ' GMT</pubDate>                    
          ' . $category_string . '
              <description>' . $description . '</description>           
             </item>';
    echo $item;
}
$rssFooter = <<<EOT
</channel>
</rss>
EOT;
echo $rssFooter;
示例#10
0
function atom10()
{
    global $CONFIG, $result, $base, $gallery_name, $CURRENT_CAT_NAME, $album, $album_name, $pic_data;
    $superCage = Inspekt::makeSuperCage();
    // Decide what kind of title to be shown
    if ((int) $album) {
        $title = " | Album: {$album_name}";
    } elseif ($superCage->get->testInt('cat')) {
        $title = " | Category: {$CURRENT_CAT_NAME}";
    } elseif ($album) {
        $title = ' | ' . strip_tags($album_name);
    }
    print "<?xml version=\"1.0\" encoding=\"{$CONFIG['charset']}\"?>\n";
    print "<feed xmlns=\"http://www.w3.org/2005/Atom\">\n";
    print "<title>{$gallery_name}{$title}</title>\n";
    print "<link href=\"{$base}\" />\n";
    print "<updated>" . rfc3339date(time()) . "</updated>\n";
    print "<author><name>Admin</name></author>\n";
    print "<id>{$base}/</id>\n";
    print "<generator uri=\"http://coppermine-gallery.net/\" version=\"1.0\">Coppermine Atom Aggregator</generator>\n";
    print "<link rel=\"self\" type=\"application/atom+xml\" href=\"{$base}" . $_SERVER["PHP_SELF"] . "?type=atom\" />\n\n";
    foreach ($pic_data as $row) {
        print "\t<entry>\n";
        print "\t\t<title> {$row['title']} </title>\n";
        print "\t\t<link href=\"{$base}/displayimage.php?pid={$row['pid']}\" />\n";
        print "\t\t<id>{$base}/displayimage.php?pid={$row['pid']}</id>\n";
        print "\t\t<updated>" . rfc3339date($row['ctime']) . "</updated>\n";
        print "\t\t<content type=\"html\">\n";
        echo htmlspecialchars("<p><a href=\"{$base}/displayimage.php?pid={$row['pid']}\"><img src=\"{$base}/" . get_pic_url($row, 'thumb') . "\" alt=\"{$row['filename']}\" /></a></p>", ENT_COMPAT, $CONFIG['charset']);
        echo htmlspecialchars("<p>" . bb_decode($row['caption']) . "&nbsp;</p>", ENT_COMPAT, $CONFIG['charset']);
        echo htmlspecialchars("<p>" . bb_decode($row['keywords']) . "</p>", ENT_COMPAT, $CONFIG['charset']);
        if (isset($row['msg_body']) && !empty($row['msg_body'])) {
            // We have comment for the photo. Must be lastcom metaalbum feed. Display the comment
            echo htmlspecialchars("<p><b>Comment:</b> (<i>" . date('Y-m-d H:m:s', $row['msg_date']) . "</i>) - {$row['msg_author']}</p>", ENT_COMPAT, $CONFIG['charset']);
            if ($CONFIG['enable_smilies']) {
                include_once "include/smilies.inc.php";
                $row['msg_body'] = process_smilies($row['msg_body']);
            }
            echo htmlspecialchars("<p>" . bb_decode($row['msg_body']) . "&nbsp;</p>", ENT_COMPAT, $CONFIG['charset']);
        }
        print "\n\t\t</content>\n";
        print "\t</entry>\n";
        print "\n";
    }
    print "</feed>";
}
function html_picture()
{
    global $CONFIG, $CURRENT_PIC_DATA, $CURRENT_ALBUM_DATA, $USER, $HTTP_COOKIE_VARS;
    global $album, $comment_date_fmt, $template_display_picture;
    global $lang_display_image_php, $lang_picinfo;
    $pid = $CURRENT_PIC_DATA['pid'];
    if (!isset($USER['liv']) || !is_array($USER['liv'])) {
        $USER['liv'] = array();
    }
    // Add 1 to hit counter
    // if ($album != "lasthits" && !in_array($pid, $USER['liv']) && isset($HTTP_COOKIE_VARS[$CONFIG['cookie_name'] . '_data'])) {
    if ($album != "lasthits" && !in_array($pid, $USER['liv'])) {
        add_hit($pid);
        if (count($USER['liv']) > 4) {
            array_shift($USER['liv']);
        }
        array_push($USER['liv'], $pid);
    }
    if ($CONFIG['thumb_use'] == 'ht' && $CURRENT_PIC_DATA['pheight'] > $CONFIG['picture_width']) {
        // The wierd comparision is because only picture_width is stored
        $condition = true;
    } elseif ($CONFIG['thumb_use'] == 'wd' && $CURRENT_PIC_DATA['pwidth'] > $CONFIG['picture_width']) {
        $condition = true;
    } elseif ($CONFIG['thumb_use'] == 'any' && max($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight']) > $CONFIG['picture_width']) {
        $condition = true;
    } else {
        $condition = false;
    }
    if ($CONFIG['make_intermediate'] && $condition) {
        $picture_url = get_pic_url($CURRENT_PIC_DATA, 'normal');
    } else {
        $picture_url = get_pic_url($CURRENT_PIC_DATA, 'fullsize');
    }
    $pic_thumb_url = get_pic_url($CURRENT_PIC_DATA, 'thumb');
    $picture_menu = USER_ADMIN_MODE && $CURRENT_ALBUM_DATA['category'] == FIRST_USER_CAT + USER_ID || GALLERY_ADMIN_MODE ? html_picture_menu($pid) : '';
    $image_size = compute_img_size($CURRENT_PIC_DATA['pwidth'], $CURRENT_PIC_DATA['pheight'], $CONFIG['picture_width']);
    $pic_title = '';
    $mime_content = get_type($CURRENT_PIC_DATA['filename']);
    if ($CURRENT_PIC_DATA['title'] != '') {
        $pic_title .= $CURRENT_PIC_DATA['title'] . "\n";
    }
    if ($CURRENT_PIC_DATA['caption'] != '') {
        $pic_title .= $CURRENT_PIC_DATA['caption'] . "\n";
    }
    if ($CURRENT_PIC_DATA['keywords'] != '') {
        $pic_title .= $lang_picinfo['Keywords'] . ": " . $CURRENT_PIC_DATA['keywords'];
    }
    if ($CURRENT_PIC_DATA['pwidth'] == 0 || $CURRENT_PIC_DATA['pheight'] == 0) {
        $image_size['geom'] = '';
        $image_size['whole'] = '';
    } elseif ($mime_content['content'] == 'movie' || $mime_content['content'] == 'audio') {
        $ctrl_offset['mov'] = 15;
        $ctrl_offset['wmv'] = 45;
        $ctrl_offset['swf'] = 0;
        $ctrl_offset['rm'] = 0;
        $ctrl_offset_default = 45;
        $ctrl_height = isset($ctrl_offset[$mime_content['extension']]) ? $ctrl_offset[$mime_content['extension']] : $ctrl_offset_default;
        $image_size['whole'] = 'width="' . $CURRENT_PIC_DATA['pwidth'] . '" height="' . ($CURRENT_PIC_DATA['pheight'] + $ctrl_height) . '"';
    }
    if ($mime_content['content'] == 'image') {
        if (isset($image_size['reduced'])) {
            $winsizeX = $CURRENT_PIC_DATA['pwidth'] + 16;
            $winsizeY = $CURRENT_PIC_DATA['pheight'] + 16;
            $pic_html = "<a href=\"javascript:;\" onClick=\"MM_openBrWindow('displayimage.php?pid={$pid}&fullsize=1','" . uniqid(rand()) . "','scrollbars=yes,toolbar=yes,status=yes,resizable=yes,width={$winsizeX},height={$winsizeY}')\">";
            $pic_title = $lang_display_image_php['view_fs'] . "\n==============\n" . $pic_title;
            $pic_html .= "<img src=\"" . $picture_url . "\" class=\"image\" border=\"0\" alt=\"{$lang_display_image_php['view_fs']}\" /><br />";
            $pic_html .= "</a>\n";
        } else {
            $pic_html = "<img src=\"" . $picture_url . "\" {$image_size['geom']} class=\"image\" border=\"0\" /><br />\n";
        }
    } elseif ($mime_content['content'] == 'document') {
        $pic_html = "<a href=\"{$picture_url}\" target=\"_blank\" class=\"document_link\"><img src=\"" . $pic_thumb_url . "\" border=\"0\" class=\"image\" /></a>\n<br />";
    } else {
        $pic_html = "<object {$image_size['whole']}><param name=\"autostart\" value=\"true\"><param name=\"src\" value=\"" . $picture_url . "\"><embed {$image_size['whole']} src=\"" . $picture_url . "\" autostart=\"true\"></embed></object><br />\n";
    }
    if (!$CURRENT_PIC_DATA['title'] && !$CURRENT_PIC_DATA['caption']) {
        template_extract_block($template_display_picture, 'img_desc');
    } else {
        if (!$CURRENT_PIC_DATA['title']) {
            template_extract_block($template_display_picture, 'title');
        }
        if (!$CURRENT_PIC_DATA['caption']) {
            template_extract_block($template_display_picture, 'caption');
        }
    }
    $params = array('{CELL_HEIGHT}' => '100', '{IMAGE}' => $pic_html, '{ADMIN_MENU}' => $picture_menu, '{TITLE}' => $CURRENT_PIC_DATA['title'], '{CAPTION}' => bb_decode($CURRENT_PIC_DATA['caption']));
    return template_eval($template_display_picture, $params);
}
示例#12
0
function list_cat_albums($cat = 0)
{
    global $CONFIG, $USER, $lastup_date_fmt, $HTTP_GET_VARS, $USER_DATA, $FORBIDDEN_SET;
    global $lang_list_albums, $lang_errors, $cpg_show_private_album;
    $PAGE = 1;
    if ($cat == 0) {
        return '';
    }
    $alb_per_page = $CONFIG['albums_per_page'];
    $maxTab = $CONFIG['max_tabs'];
    $album_filter = '';
    $pic_filter = '';
    if (!empty($FORBIDDEN_SET) && !$cpg_show_private_album) {
        $album_filter = ' and ' . str_replace('p.', 'a.', $FORBIDDEN_SET);
        $pic_filter = ' and ' . $FORBIDDEN_SET;
    }
    $sql = "SELECT count(*) FROM {$CONFIG['TABLE_ALBUMS']} as a WHERE category = '{$cat}'" . $album_filter;
    $result = db_query($sql);
    $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 a.pos ".$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 a.thumb=p.pid ' . 'WHERE category=' . $cat . $album_filter . ' ORDER BY a.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 || in_array($visibility, $USER_DATA['groups']) || $USER_DATA['can_see_all_albums'] || $CONFIG['allow_private_albums'] == 0) {
            // 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);
                }
                $pic_url = get_pic_url($picture, 'thumb');
                if (!is_image($picture['filename'])) {
                    $image_info = getimagesize($pic_url);
                    $picture['pwidth'] = $image_info[0];
                    $picture['pheight'] = $image_info[1];
                }
                $image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['alb_list_thumb_size']);
                $alb_list[$alb_idx]['thumb_pic'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$picture['filename']}\">";
            } 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 || in_array($visibility, $USER_DATA['groups']) || $USER_DATA['can_see_all_albums']) {
            $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;
}
示例#13
0
文件: profile.php 项目: alencarmo/OCF
        }
        $user_thumb = '';
        if ($picture_count) {
            $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE pid='" . $thumb_pid . "'";
            $result = cpg_db_query($sql);
            if (mysql_num_rows($result)) {
                $picture = mysql_fetch_array($result);
                mysql_free_result($result);
                $pic_url = get_pic_url($picture, 'thumb');
                if (!is_image($picture['filename'])) {
                    $image_info = getimagesize(urldecode($pic_url));
                    $picture['pwidth'] = $image_info[0];
                    $picture['pheight'] = $image_info[1];
                }
                $image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['thumb_width']);
                $mime_content = cpg_get_type($picture['filename']);
                $user_thumb = '<img src="' . $pic_url . '" class="image"' . $image_size['geom'] . ' border="0" alt="" />';
                $user_thumb = '<td width="50%" valign="top" align="center">' . '<a href="thumbnails.php?album=lastupby&amp;uid=' . $uid . '">' . '<span class="thumb_title">' . $lang_register_php['last_uploads'] . ' ' . $user_data['user_name'] . '<br /></span>' . $user_thumb . '</a></td>';
            }
        }
        $quick_jump = $user_thumb . $lastcom ? '<table width="100%" border="0" cellspacing="5"><tr>' . $user_thumb . $lastcom . '</tr></table>' : '';
        $form_data = array('username' => $user_data['user_name'], 'reg_date' => localised_date($user_data['user_regdate'], $register_date_fmt), 'group' => $user_data['group_name'], 'user_profile1' => $user_data['user_profile1'], 'user_profile2' => $user_data['user_profile2'], 'user_profile3' => $user_data['user_profile3'], 'user_profile4' => $user_data['user_profile4'], 'user_profile5' => $user_data['user_profile5'], 'user_profile6' => bb_decode($user_data['user_profile6']), 'user_thumb' => $quick_jump, 'pic_count' => $pic_count);
        $title = sprintf($lang_register_php['x_s_profile'], $user_data['user_name']);
        pageheader($title);
        starttable(-1, $title, 2);
        make_form($display_profile_form_param, $form_data);
        endtable();
        pagefooter();
        ob_end_flush();
        break;
}
示例#14
0
/**
 * 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, $AUTHORIZED, $USER;
    global $album_date_fmt, $lang_display_thumbnails, $lang_errors, $lang_byte_units, $lang_common;
    $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 (count($pic_data) > 0) {
        foreach ($pic_data as $key => $row) {
            $i++;
            $pic_title = $lang_common['filename'] . '=' . $row['filename'] . "\n" . $lang_common['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 = 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 ($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'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$row['filename']}\" title=\"{$pic_title}\"/>";
            $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'];
            if (defined('API_CALL')) {
                $thumb_list[$i]['title'] = $row['title'];
                $thumb_list[$i]['filename'] = get_pic_url($row);
            }
        }
        // Print out XML photo list and exit
        if (defined('API_CALL')) {
            echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
            echo $superCage->post->getAlpha('album') ? "<" . $superCage->post->getAlpha('album') . ">\n" : "<api_search>\n";
            foreach ($thumb_list as $pic) {
                $file = preg_replace('/%7E/', '~', $pic['filename']);
                echo " <picture id=\"{$pic['pid']}\">\n";
                echo "  <title>{$pic['title']}</title>\n";
                echo "  <file>{$file}</file>\n";
                echo "  <width>{$pic['pwidth']}</width>\n";
                echo "  <height>{$pic['pheight']}</height>\n";
                echo " </picture>\n";
            }
            echo $superCage->post->getAlpha('album') ? "</" . $superCage->post->getAlpha('album') . ">" : "</api_search>";
            exit;
        }
        // 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 && !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);
    } else {
        if (defined('API_CALL')) {
            new OAuthException('No pictures found');
        } else {
            theme_no_img_to_display($album_name);
        }
    }
}
示例#15
0
$sender_email_warning = '';
$form_action = "{$CPG_PHP_SELF}?pid={$pid}";
// Get picture thumbnail url
$result = cpg_db_query("SELECT * FROM {$CONFIG['TABLE_PICTURES']} p WHERE pid='{$pid}' {$FORBIDDEN_SET}");
if (!$result->numRows()) {
    cpg_die(ERROR, $lang_errors['non_exist_ap'], __FILE__, __LINE__);
}
$row = $result->fetchArray(true);
$thumb_pic_url = get_pic_url($row, 'thumb');
if ($what == 'comment') {
    $result = cpg_db_query("SELECT msg_id, msg_author, msg_body, UNIX_TIMESTAMP(msg_date) AS msg_date, author_id, author_md5_id, msg_raw_ip, msg_hdr_ip, approval FROM {$CONFIG['TABLE_COMMENTS']} WHERE msg_id='{$cid}' AND approval = 'YES' AND pid='{$pid}'");
    if (!$result->numRows()) {
        cpg_die(ERROR, $lang_errors['non_exist_comment'], __FILE__, __LINE__);
    }
    $row = $result->fetchArray(true);
    $comment = bb_decode($row['msg_body']);
    if ($CONFIG['enable_smilies']) {
        $comment = process_smilies($comment);
    }
    $msg_author = $row['msg_author'];
    $comment_field_name = sprintf($lang_report_php['comment_field_name'], $msg_author);
    $type = $lang_report_php['type_comment'];
    $template = $template_report_comment_email;
    $form_action = "{$CPG_PHP_SELF}?pid={$pid}&amp;msg_id={$cid}&amp;what=comment";
    //template_extract_block($template_report_form, 'reason_missing'); //need help to toggle off reason(missing) since doesn't apply to comments
} else {
    //template_extract_block($template_report_form, 'display_comment'); //need help remove comment preview when reporting picture
}
// Check supplied email address
$valid_sender_email = Inspekt::isEmail($sender_email);
$invalid_email = '<div class="cpg_message_error">' . $lang_report_php['invalid_email'] . '</div>';
        } else {
            $user_status = '';
        }
        if ($user_thumb != '') {
            $user_thumb = '<td width="50%" valign="top" align="center">' . '<a href="thumbnails.php?album=lastupby&amp;uid=' . $uid . '">' . '<span class="thumb_title">' . $lang_register_php['last_uploads'] . '<br />' . sprintf($lang_register_php['last_uploads_detail'], $user_data['user_name']) . '<br /></span>' . $user_thumb . '</a></td>';
        }
        $lastComArray = cpgUserLastComment($uid);
        if ($lastComArray['count'] != 0) {
            $lastcom = '<td width="50%" valign="top" align="center">' . '<a href="thumbnails.php?album=lastcomby&amp;uid=' . $uid . '">' . '<span class="thumb_title">' . $lang_register_php['last_comments'] . '<br />' . sprintf($lang_register_php['last_comments_detail'], $user_data['user_name']) . '<br /></span>' . $lastComArray['thumb'] . '</a><br />';
            $lastcom .= "<span class=\"thumb_caption\">" . localised_date($lastComArray['msg_date'], $lang_date['lastcom']) . '</span>' . "<span class=\"thumb_caption\">" . bb_decode(process_smilies($lastComArray['comment'])) . '</span></td>';
        }
        $quick_jump = $user_thumb . $lastcom ? '<table width="100%" border="0" cellspacing="5"><tr>' . $user_thumb . $lastcom . '</tr></table>' : '';
        list($timestamp, $form_token) = getFormToken();
        if ($uid == USER_ID) {
            $adminLink = '<a href="profile.php?op=edit_profile" class="admin_menu">' . $lang_register_php['edit_my_profile'] . '</a>';
        } elseif (GALLERY_ADMIN_MODE) {
            $adminLink = '<a href="usermgr.php?op=edit&user_id=' . $uid . '&form_token=' . $form_token . '&timestamp=' . $timestamp . '" class="admin_menu">' . $icon_array['edit'] . sprintf($lang_register_php['edit_xs_profile'], $user_data['user_name']) . '</a>';
        } else {
            $adminLink = '';
        }
        $form_data = array('username' => $user_data['user_name'], 'status' => $user_status, 'reg_date' => localised_date($user_data['user_regdate'], $lang_date['register']), 'group' => $user_data['group_name'], 'user_profile1' => $user_data['user_profile1'], 'user_profile2' => $user_data['user_profile2'], 'user_profile3' => $user_data['user_profile3'], 'user_profile4' => $user_data['user_profile4'], 'user_profile5' => $user_data['user_profile5'], 'user_profile6' => bb_decode($user_data['user_profile6']), 'user_thumb' => $quick_jump, 'pic_count' => cpgUserPicCount($uid), 'admin_link' => $adminLink);
        $title = sprintf($lang_register_php['x_s_profile'], $user_data['user_name']);
        pageheader($title);
        // Displays the profile of any user
        starttable(-1, cpg_fetch_icon('my_profile', 2) . $title, 2);
        $profile_data = CPGPluginAPI::filter('profile_add_data', array(0 => $display_profile_form_param, 1 => $form_data));
        make_form($display_profile_form_param, $form_data);
        endtable();
        pagefooter();
        break;
}
    }
    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();
}
示例#18
0
            cpg_die(ERROR, $lang_ecard_php['send_failed'], __FILE__, __LINE__);
        }
    }
} elseif ($superCage->post->keyExists('preview')) {
    if ($CONFIG['make_intermediate'] && max($row['pwidth'], $row['pheight']) > $CONFIG['picture_width']) {
        $n_picname = get_pic_url($row, 'normal');
    } else {
        $n_picname = get_pic_url($row, 'fullsize');
    }
    if (!stristr($n_picname, 'http:')) {
        $n_picname = $gallery_url_prefix . $n_picname;
    }
    $msg_content = process_smilies($message, $gallery_url_prefix);
    $data = array('sn' => $superCage->post->noTags('sender_name'), 'se' => $sender_email, 'p' => $n_picname, 'g' => $greetings, 'm' => $message, 'pid' => $pid, 'pt' => $pic_title, 'pc' => $pic_caption);
    $encoded_data = urlencode(base64_encode(serialize($data)));
    $params = array('{LANG_DIR}' => $lang_text_dir, '{TITLE}' => sprintf($lang_ecard_php['ecard_title'], $sender_name), '{CHARSET}' => $CONFIG['charset'] == 'language file' ? $lang_charset : $CONFIG['charset'], '{VIEW_ECARD_TGT}' => "{$gallery_url_prefix}displayecard.php?data={$encoded_data}", '{VIEW_ECARD_LNK}' => $lang_ecard_php['preview_view_ecard'], '{PIC_URL}' => $n_picname, '{URL_PREFIX}' => $gallery_url_prefix, '{GREETINGS}' => $greetings, '{MESSAGE}' => bb_decode($msg_content), '{SENDER_EMAIL}' => $sender_email, '{SENDER_NAME}' => $sender_name, '{VIEW_MORE_TGT}' => $CONFIG['ecards_more_pic_target'], '{VIEW_MORE_LNK}' => $lang_ecard_php['view_more_pics'], '{PID}' => $pid, '{PIC_TITLE}' => $pic_title, '{PIC_CAPTION}' => bb_decode($pic_caption), '{PIC_MARKUP}' => $pic_markup);
    $eccontent = template_eval($template_ecard, $params);
    if (preg_match('#<body[^>]*>(.*)</body>#s', $eccontent, $matches)) {
        $eccontent = $matches[1];
    }
    starttable('100%', $icon_array['preview_table'] . $lang_ecard_php['preview']);
    echo '<tr><td>';
    echo $eccontent;
    echo '</td></tr>';
    endtable();
    echo '<br />';
}
if ($CONFIG['show_bbcode_help']) {
    $captionLabel = '&nbsp;' . cpg_display_help('f=empty.htm&amp;h=lang_bbcode_help_title&amp;t=lang_bbcode_help', 470, 245);
}
if ($row['pwidth'] == 0 || $row['pheight'] == 0) {
/**
 * 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 (count($pic_data) > 0) {
        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'] = '<img src="' . $pic_url . '" class="image thumbnail" ' . $image_size['geom'] . ' border="0" alt="' . $row['filename'] . '" title="' . $pic_title . '" />';
            $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);
    }
}
示例#20
0
function theme_page_title($section)
{
    global $CONFIG;
    $return = strip_tags(bb_decode($section)) . ' - ' . $CONFIG['gallery_name'];
    return $return;
}
示例#21
0
function displayfields_filter($info)
{
    global $CONFIG, $USER, $lang_picinfo, $lang_modifyalb_php, $CURRENT_PIC_DATA, $thisplugin;
    global $plugin_displayfields_params;
    require 'plugins/display_fields/include/init.inc.php';
    define('MODIFYALB_PHP', true);
    if (file_exists("lang/{$CONFIG['lang']}.php")) {
        require "lang/{$CONFIG['lang']}.php";
    } else {
        require 'lang/english.php';
    }
    // Add Album Description to display fields if requested
    $alb_desc = str_replace(' ', '_', $lang_modifyalb_php['alb_desc']);
    if ($plugin_displayfields_params["plugin_displayfields_{$alb_desc}"] == '1') {
        $result = cpg_db_query("SELECT description FROM {$CONFIG['TABLE_ALBUMS']} WHERE aid='{$CURRENT_PIC_DATA['aid']}' LIMIT 1");
        $row = mysql_fetch_array($result);
        mysql_free_result($result);
        // Adds album description at end; commented out so can add after Album Title
        // $info[str_replace('_',' ',$alb_desc)] = $row['description'];
        if ($row['description']) {
            $newinfo = array();
            foreach ($info as $key => $value) {
                $newinfo[$key] = $value;
                if ($key == $lang_picinfo['Album name']) {
                    $newinfo[str_replace('_', ' ', $alb_desc)] = bb_decode($row['description']);
                }
            }
            $info = $newinfo;
            // replace $info with new "sorted" info (only albdesc sorted now)
        }
    }
    if (!GALLERY_ADMIN_MODE || !$CONFIG['plugin_displayfields_adminshowall']) {
        foreach ($plugin_displayfields_params as $name => $value) {
            if ($value == '0') {
                $name = str_replace('plugin_displayfields_', '', $name);
                $name = str_replace('_', ' ', $name);
                unset($info[$name]);
            }
        }
        if (USE_SORTLIST) {
            $newinfo = array();
            foreach ($thisplugin->sort_fieldlist as $name) {
                $field = $lang_picinfo[$name] ? $lang_picinfo[$name] : $name;
                if ($info[$field]) {
                    $newinfo[$field] = $info[$field];
                }
            }
            $info = array_unique($newinfo + $info);
        }
    }
    return $info;
}
示例#22
0
function enlargeit_html_comments($pid)
{
    global $CONFIG, $USER, $CURRENT_ALBUM_DATA, $comment_date_fmt, $HTML_SUBST;
    global $enlargeit_image_comments, $enlargeit_add_your_comment, $lang_display_comments;
    $html = '';
    // report to moderator buttons
    $tmpl_comment_edit_box = template_extract_block($enlargeit_image_comments, 'edit_box_smilies', '{EDIT}');
    template_extract_block($enlargeit_image_comments, 'edit_box_no_smilies');
    template_extract_block($enlargeit_add_your_comment, 'input_box_no_smilies');
    $tmpl_comments_buttons = template_extract_block($enlargeit_image_comments, 'buttons', '{BUTTONS}');
    $tmpl_comments_ipinfo = template_extract_block($enlargeit_image_comments, 'ipinfo', '{IPINFO}');
    if ($CONFIG['comments_sort_descending'] == 1) {
        $comment_sort_order = 'DESC';
    } else {
        $comment_sort_order = 'ASC';
    }
    $result = cpg_db_query("SELECT msg_id, msg_author, msg_body, UNIX_TIMESTAMP(msg_date) AS msg_date, author_id, author_md5_id, msg_raw_ip, msg_hdr_ip, pid FROM {$CONFIG['TABLE_COMMENTS']} WHERE pid='{$pid}' ORDER BY msg_id {$comment_sort_order}");
    while ($row = mysql_fetch_array($result)) {
        $user_can_edit = GALLERY_ADMIN_MODE || USER_ID && USER_ID == $row['author_id'] && USER_CAN_POST_COMMENTS || !USER_ID && USER_CAN_POST_COMMENTS && $USER['ID'] == $row['author_md5_id'];
        $comment_buttons = $user_can_edit ? $tmpl_comments_buttons : '';
        $comment_edit_box = '';
        $comment_ipinfo = $row['msg_raw_ip'] && GALLERY_ADMIN_MODE ? $tmpl_comments_ipinfo : '';
        $comment_body = make_clickable($row['msg_body']);
        $smilies = '';
        $ip = $row['msg_hdr_ip'];
        if ($row['msg_hdr_ip'] != $row['msg_raw_ip']) {
            $ip .= ' [' . $row['msg_raw_ip'] . ']';
        }
        $params = array('{EDIT}' => &$comment_edit_box, '{BUTTONS}' => &$comment_buttons, '{IPINFO}' => &$comment_ipinfo);
        $template = template_eval($enlargeit_image_comments, $params);
        $params = array('{MSG_AUTHOR}' => stripslashes($row['msg_author']), '{MSG_ID}' => $row['msg_id'], '{PID}' => $row['pid'], '{EDIT_TITLE}' => &$lang_display_comments['edit_title'], '{CONFIRM_DELETE}' => &$lang_display_comments['confirm_delete'], '{MSG_DATE}' => localised_date($row['msg_date'], $comment_date_fmt), '{MSG_BODY}' => bb_decode($comment_body), '{MSG_BODY_RAW}' => $row['msg_body'], '{OK}' => &$lang_display_comments['OK'], '{SMILIES}' => '', '{IP}' => $ip, '{REPORT_COMMENT_TITLE}' => &$lang_display_comments['report_comment_title'], '{WIDTH}' => $CONFIG['picture_table_width']);
        $html .= template_eval($template, $params);
    }
    if (USER_CAN_POST_COMMENTS && $CURRENT_ALBUM_DATA['comments'] == 'YES') {
        if (USER_ID) {
            $user_name_input = '<tr><td><input type="hidden" name="msg_author" value="" /></td>';
            template_extract_block($enlargeit_add_your_comment, 'user_name_input', $user_name_input);
            $user_name = '';
        } else {
            if (isset($USER['name'])) {
                $user_name = strtr($USER['name'], $HTML_SUBST);
            } else {
                $user_name = $lang_display_comments['your_name'];
            }
        }
        $params = array('{ADD_YOUR_COMMENT}' => $lang_display_comments['add_your_comment'], '{NAME}' => $lang_display_comments['name'], '{COMMENT}' => $lang_display_comments['comment'], '{PIC_ID}' => $pid, '{USER_NAME}' => $user_name, '{MAX_COM_LENGTH}' => $CONFIG['max_com_size'], '{OK}' => $lang_display_comments['OK'], '{SMILIES}' => '', '{WIDTH}' => $CONFIG['picture_table_width']);
        template_extract_block($enlargeit_add_your_comment, 'smilies');
        $html .= template_eval($enlargeit_add_your_comment, $params);
    }
    return $html;
}
示例#23
0
/**
* list_cat_albums()
*
* This has been added to list the albums in a category, used for showing first level albumslargely a repetition of code elsewhere
* Redone for a cleaner approach
* @param integer $cat Category id for which albums are needed
*/
function list_cat_albums($cat = 0)
{
    global $CONFIG, $USER, $lastup_date_fmt, $USER_DATA, $FORBIDDEN_SET, $FORBIDDEN_SET_DATA, $cpg_show_private_album;
    global $lang_list_albums, $lang_errors;
    $PAGE = 1;
    if ($cat == 0) {
        return '';
    }
    $cat_owner_id = $cat > 10000 ? 10000 - $cat : 10001;
    $cpg_nopic_data = cpg_get_system_thumb('nopic.jpg', $cat_owner_id);
    $cpg_privatepic_data = cpg_get_system_thumb('private.jpg', $cat_owner_id);
    $alb_per_page = $CONFIG['albums_per_page'];
    $maxTab = $CONFIG['max_tabs'];
    $album_filter = '';
    $pic_filter = '';
    if (!empty($FORBIDDEN_SET) && !$cpg_show_private_album) {
        $album_filter = ' and ' . str_replace('p.', 'a.', $FORBIDDEN_SET);
        $pic_filter = ' and ' . $FORBIDDEN_SET;
    }
    $sql = "SELECT count(aid) FROM {$CONFIG['TABLE_ALBUMS']} as a WHERE category = '{$cat}'" . $album_filter;
    $result = cpg_db_query($sql);
    $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, a.thumb, visibility, filepath, ' . 'filename, url_prefix, pwidth, pheight ' . 'FROM ' . $CONFIG['TABLE_ALBUMS'] . ' as a ' . 'LEFT JOIN ' . $CONFIG['TABLE_PICTURES'] . ' as p ' . 'ON a.thumb=p.pid ' . 'WHERE category=' . $cat . $album_filter . ' ORDER BY a.pos ' . $limit;
    $alb_thumbs_q = cpg_db_query($sql);
    $alb_thumbs = cpg_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 = cpg_db_query($sql);
      $alb_stats = cpg_db_fetch_rowset($alb_stats_q);
      mysql_free_result($alb_stats_q);*/
    //This query will fetch album stats and keyword for the albums
    $sql = "SELECT a.aid, count( p.pid )  AS pic_count, max( p.pid )  AS last_pid, max( p.ctime )  AS last_upload, a.keyword, a.alb_hits" . " FROM {$CONFIG['TABLE_ALBUMS']} AS a " . " LEFT JOIN {$CONFIG['TABLE_PICTURES']} AS p ON a.aid = p.aid AND p.approved =  'YES' " . "WHERE a.aid IN {$album_set}" . "GROUP BY a.aid";
    $alb_stats_q = cpg_db_query($sql);
    $alb_stats = cpg_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];
        if ($CONFIG['link_pic_count'] == 1) {
            if (!empty($value['keyword'])) {
                $query = "SELECT count(pid) AS link_pic_count\n                      FROM {$CONFIG['TABLE_PICTURES']}\n                        WHERE aid != {$value['aid']} AND\n                        keywords LIKE '%{$value['keyword']}%' AND\n                        approved = 'YES'";
                $result = cpg_db_query($query);
                $link_stat = mysql_fetch_array($result);
                mysql_free_result($result);
                $alb_stats[$key]['link_pic_count'] = $link_stat['link_pic_count'];
            }
        }
    }
    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'];
            $alb_hits = $alb_stat['alb_hits'];
        } else {
            $alb_stat = array();
            $count = 0;
            $alb_hits = 0;
        }
        // Inserts a thumbnail if the album contains 1 or more images
        $visibility = $alb_thumb['visibility'];
        if (!in_array($aid, $FORBIDDEN_SET_DATA) || $CONFIG['allow_private_albums'] == 0) {
            //test for visibility
            if ($count > 0) {
                // Inserts a thumbnail if the album contains 1 or more images
                if ($alb_thumb['filename']) {
                    $picture =& $alb_thumb;
                } elseif ($alb_thumb['thumb'] < 0) {
                    $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_PICTURES']} WHERE aid = '{$alb_thumb['aid']}' ORDER BY RAND() LIMIT 0,1";
                    $result = cpg_db_query($sql);
                    $picture = mysql_fetch_array($result);
                    mysql_free_result($result);
                } else {
                    $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_PICTURES']} " . "WHERE pid='{$alb_stat['last_pid']}'";
                    $result = cpg_db_query($sql);
                    $picture = mysql_fetch_array($result);
                    mysql_free_result($result);
                }
                $pic_url = get_pic_url($picture, 'thumb');
                if (!is_image($picture['filename'])) {
                    $image_info = cpg_getimagesize(urldecode($pic_url));
                    $picture['pwidth'] = $image_info[0];
                    $picture['pheight'] = $image_info[1];
                }
                //thumb cropping
                if ($picture['system_icon'] == 'true') {
                    $image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['alb_list_thumb_size'], true, 'cat_thumb');
                } else {
                    $image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['alb_list_thumb_size'], false, 'cat_thumb');
                }
                $alb_list[$alb_idx]['thumb_pic'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$picture['filename']}\" />";
            } 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="' . $cpg_nopic_data['thumb'] . '" ' . $cpg_nopic_data['whole'] . ' class="image" border="0" alt="" />';
            }
        } elseif ($CONFIG['show_private']) {
            // $image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']);
            $alb_list[$alb_idx]['thumb_pic'] = '<img src="' . $cpg_privatepic_data['thumb'] . '" ' . $cpg_privatepic_data['whole'] . ' class="image" border="0" alt="" />';
        }
        // Prepare everything
        if (!in_array($aid, $FORBIDDEN_SET_DATA) || $CONFIG['allow_private_albums'] == 0) {
            $last_upload_date = $count ? localised_date($alb_stat['last_upload'], $lastup_date_fmt) : '';
            $link_pic_count = !empty($alb_stat['link_pic_count']) ? $alb_stat['link_pic_count'] : 0;
            $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]['alb_hits'] = sprintf($lang_list_albums['alb_hits'], $alb_hits);
            $alb_list[$alb_idx]['album_info'] = sprintf($lang_list_albums['n_pictures'], $count) . ($count ? sprintf($lang_list_albums['last_added'], $last_upload_date) : "") . ($CONFIG['link_pic_count'] && $link_pic_count > 0 ? sprintf(", {$lang_list_albums['n_link_pictures']}, {$lang_list_albums['total_pictures']}", $link_pic_count, $count + $link_pic_count) : "");
            $alb_list[$alb_idx]['album_adm_menu'] = album_adm_menu($alb_thumb['aid'], $cat);
        } 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) : '';
            $link_pic_count = !empty($alb_stat['link_pic_count']) ? $alb_stat['link_pic_count'] : 0;
            $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]['alb_hits'] = sprintf($lang_list_albums['alb_hits'], $alb_hits);
            $alb_list[$alb_idx]['album_info'] = sprintf($lang_list_albums['n_pictures'], $count) . ($count ? sprintf($lang_list_albums['last_added'], $last_upload_date) : "") . ($CONFIG['link_pic_count'] && $link_pic_count > 0 ? sprintf(", {$lang_list_albums['n_link_pictures']}, {$lang_list_albums['total_pictures']}", $link_pic_count, $count + $link_pic_count) : "");
            $alb_list[$alb_idx]['album_adm_menu'] = album_adm_menu($alb_thumb['aid'], $cat);
        }
    }
    ob_start();
    theme_display_album_list_cat($alb_list, $nbAlb, $cat, $PAGE, $totalPages);
    $cat_albums = ob_get_contents();
    ob_end_clean();
    return $cat_albums;
}
示例#24
0
/**
* list_cat_albums()
*
* This has been added to list the albums in a category, used for showing first level albums, largely a repetition of code elsewhere
* Redone for a cleaner approach
* @param integer $cat Category id for which albums are needed
*/
function list_cat_albums($cat, $catdata)
{
    global $CONFIG, $lang_date, $FORBIDDEN_SET_DATA;
    global $lang_list_albums;
    $PAGE = 1;
    if ($cat == 0) {
        return '';
    }
    $cat_owner_id = $cat > 10000 ? 10000 - $cat : 10001;
    $cpg_nopic_data = cpg_get_system_thumb('nopic.jpg', $cat_owner_id);
    $cpg_privatepic_data = cpg_get_system_thumb('private.jpg', $cat_owner_id);
    $alb_per_page = $CONFIG['albums_per_page'];
    //unused code {SaWey}
    /*$maxTab = $CONFIG['max_tabs'];
    
        $album_filter = '';
        $pic_filter = '';
    
        if (!empty($FORBIDDEN_SET) && !$cpg_show_private_album) {
            $album_filter = ' and ' . str_replace('p.', 'a.', $FORBIDDEN_SET);
            $pic_filter = ' and ' . $FORBIDDEN_SET;
        }*/
    $nbAlb = $catdata['details']['alb_count'];
    if ($nbAlb == 0) {
        return;
    }
    $totalPages = ceil($nbAlb / $alb_per_page);
    $alb_list = array();
    $approved = ' AND approved=\'YES\'';
    $forbidden_set_string = count($FORBIDDEN_SET_DATA) > 0 ? ' AND aid NOT IN (' . implode(', ', $FORBIDDEN_SET_DATA) . ')' : '';
    $last_pids = array();
    $last_pid_data = array();
    foreach ($catdata['subalbums'] as $aid => $album) {
        if ($CONFIG['link_pic_count'] == 1 || $album['pic_count'] == 0) {
            if (!empty($album['keyword'])) {
                $keyword = $album['keyword'] ? "AND (keywords like '%" . addslashes($album['keyword']) . "%' {$forbidden_set_string})" : '';
                $query = "SELECT count(pid) AS link_pic_count, max(pid) AS link_last_pid, max(ctime) AS link_last_upload " . " FROM {$CONFIG['TABLE_PICTURES']} " . " WHERE ((aid != '{$aid}' {$forbidden_set_string}) {$keyword}) {$approved}";
                $result = cpg_db_query($query);
                $link_stat = $result->fetchAssoc(true);
                $catdata['subalbums'][$aid]['link_pic_count'] = $link_stat['link_pic_count'];
                $catdata['subalbums'][$aid]['last_pid'] = !empty($album['last_pid']) && $album['last_pid'] > $link_stat['link_last_pid'] ? $album['last_pid'] : $link_stat['link_last_pid'];
                if ($CONFIG['link_last_upload'] && $link_stat['link_pic_count'] > 0) {
                    $catdata['subalbums'][$aid]['last_upload'] = $album['last_upload'] > $link_stat['link_last_upload'] ? $album['last_upload'] : $link_stat['link_last_upload'];
                }
            }
        }
        if ($catdata['subalbums'][$aid]['last_pid']) {
            $last_pids[] = $catdata['subalbums'][$aid]['last_pid'];
        }
        if ($album['thumb'] > 0) {
            $last_pids[] = $album['thumb'];
        }
    }
    if (count($last_pids)) {
        $result = cpg_db_query("SELECT pid, filepath, filename, url_prefix, pwidth, pheight FROM {$CONFIG['TABLE_PICTURES']} WHERE pid IN (" . implode(',', $last_pids) . ")");
        while ($row = $result->fetchAssoc()) {
            $last_pid_data[$row['pid']] = $row;
            unset($last_pid_data[$row['pid']]['pid']);
        }
        $result->free();
    }
    unset($last_pids);
    foreach ($catdata['subalbums'] as $aid => $album) {
        // Inserts a thumbnail if the album contains 1 or more images
        //unused code {SaWey}
        //$visibility = $album['visibility'];
        $keyword = $album['keyword'] ? "OR (keywords like '%" . addslashes($album['keyword']) . "%' {$forbidden_set_string})" : '';
        if (!in_array($aid, $FORBIDDEN_SET_DATA) || $CONFIG['allow_private_albums'] == 0) {
            //test for visibility
            if ($album['pic_count'] > 0 || !empty($album['link_pic_count'])) {
                if (!empty($last_pid_data[$album['thumb']]['filename'])) {
                    $picture = $last_pid_data[$album['thumb']];
                } elseif ($album['thumb'] < 0) {
                    $sql = "SELECT filepath, filename, url_prefix, pwidth, pheight " . "FROM {$CONFIG['TABLE_PICTURES']} WHERE ((aid = '{$aid}' {$forbidden_set_string}) {$keyword}) {$approved} " . "ORDER BY RAND() LIMIT 0,1";
                    $result = cpg_db_query($sql);
                    $picture = $result->fetchAssoc(true);
                } else {
                    $picture = $last_pid_data[$album['last_pid']];
                }
                $pic_url = get_pic_url($picture, 'thumb');
                if (!is_image($picture['filename'])) {
                    $image_info = cpg_getimagesize(urldecode($pic_url));
                    $picture['pwidth'] = $image_info[0];
                    $picture['pheight'] = $image_info[1];
                }
                //thumb cropping
                if (array_key_exists('system_icon', $picture) && $picture['system_icon'] == true) {
                    $image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['alb_list_thumb_size'], true, 'cat_thumb');
                } else {
                    $image_size = compute_img_size($picture['pwidth'], $picture['pheight'], $CONFIG['alb_list_thumb_size'], false, 'cat_thumb');
                }
                $alb_list[$aid]['thumb_pic'] = "<img src=\"" . $pic_url . "\" class=\"image thumbnail\" {$image_size['geom']} border=\"0\" alt=\"{$picture['filename']}\" />";
            } 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[$aid]['thumb_pic'] = '<img src="' . $cpg_nopic_data['thumb'] . '" ' . $cpg_nopic_data['whole'] . ' class="image thumbnail" border="0" alt="" />';
            }
        } elseif ($CONFIG['show_private']) {
            // $image_size = compute_img_size(100, 75, $CONFIG['alb_list_thumb_size']);
            $alb_list[$aid]['thumb_pic'] = '<img src="' . $cpg_privatepic_data['thumb'] . '" ' . $cpg_privatepic_data['whole'] . ' class="image thumbnail" border="0" alt="" />';
        }
        // Prepare everything
        if (!in_array($aid, $FORBIDDEN_SET_DATA) || $CONFIG['allow_private_albums'] == 0) {
            $link_pic_count = !empty($album['link_pic_count']) ? $album['link_pic_count'] : 0;
            $last_upload_date = $album['pic_count'] || $CONFIG['link_pic_count'] && $link_pic_count > 0 ? localised_date($album['last_upload'], $lang_date['lastup']) : '';
            $alb_list[$aid]['aid'] = $aid;
            $alb_list[$aid]['album_title'] = $album['title'];
            $alb_list[$aid]['album_desc'] = bb_decode($album['description']);
            $alb_list[$aid]['pic_count'] = $album['pic_count'];
            $alb_list[$aid]['last_upl'] = $last_upload_date;
            $alb_list[$aid]['alb_hits'] = sprintf($lang_list_albums['alb_hits'], $album['alb_hits']);
            $alb_list[$aid]['album_info'] = theme_album_info($album['pic_count'], $link_pic_count, $last_upload_date);
            $alb_list[$aid]['album_adm_menu'] = album_adm_menu($aid, $cat, $album['owner']);
        } elseif ($CONFIG['show_private']) {
            // show private album description
            $link_pic_count = !empty($album['link_pic_count']) ? $album['link_pic_count'] : 0;
            $last_upload_date = $album['pic_count'] || $CONFIG['link_pic_count'] && $link_pic_count > 0 ? localised_date($album['last_upload'], $lang_date['lastup']) : '';
            $alb_list[$aid]['aid'] = $aid;
            $alb_list[$aid]['album_title'] = $album['title'];
            $alb_list[$aid]['album_desc'] = bb_decode($album['description']);
            $alb_list[$aid]['pic_count'] = $album['pic_count'];
            $alb_list[$aid]['last_upl'] = $last_upload_date;
            $alb_list[$aid]['alb_hits'] = sprintf($lang_list_albums['alb_hits'], $album['alb_hits']);
            $alb_list[$aid]['album_info'] = theme_album_info($album['pic_count'], $link_pic_count, $last_upload_date);
            $alb_list[$aid]['album_adm_menu'] = album_adm_menu($aid, $cat, $album['owner']);
        }
    }
    ob_start();
    theme_display_album_list_cat($alb_list, $nbAlb, $cat, $PAGE, $totalPages);
    $cat_albums = ob_get_contents();
    ob_end_clean();
    return $cat_albums;
}
示例#25
0
/**
 * 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, $AUTHORIZED, $USER;
    global $album_date_fmt, $lang_display_thumbnails, $lang_errors, $lang_byte_units, $lang_common;
    $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_common['filename'] . '=' . $row['filename'] . "\n" . $lang_common['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(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 ($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'] = "<img src=\"" . $pic_url . "\" class=\"image\" {$image_size['geom']} border=\"0\" alt=\"{$row['filename']}\" title=\"{$pic_title}\"/>";
            $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'];
        }
        // 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 && !in_array($album, $USER['liv_a']) && isset($_COOKIE[$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();
            }
        }
        $date = isset($_GET['date']) ? cpgValidateDate($_GET['date']) : null;
        theme_display_thumbnails($thumb_list, $thumb_count, $album_name, $album, $cat, $page, $total_pages, is_numeric($album), $display_tabs, 'thumb', $date);
    } else {
        theme_no_img_to_display($album_name);
    }
}
示例#26
0
EOT;
$sort_codes = array('name_a' => 'msg_author ASC', 'name_d' => 'msg_author DESC', 'date_a' => 'msg_id ASC', 'date_d' => 'msg_id DESC', 'comment_a' => 'msg_body ASC', 'comment_d' => 'msg_body DESC', 'file_a' => 'pid ASC', 'file_d' => 'pid DESC');
$sort = !isset($_GET['sort']) || !isset($sort_codes[$_GET['sort']]) ? 'date_d' : $_GET['sort'];
$result = cpg_db_query("SELECT msg_id, msg_author, msg_body, UNIX_TIMESTAMP(msg_date) AS msg_date, author_id, {$CONFIG['TABLE_COMMENTS']}.pid as pid, aid, filepath, filename, url_prefix, pwidth, pheight FROM {$CONFIG['TABLE_COMMENTS']}, {$CONFIG['TABLE_PICTURES']} WHERE {$CONFIG['TABLE_COMMENTS']}.pid = {$CONFIG['TABLE_PICTURES']}.pid ORDER BY {$sort_codes[$sort]} LIMIT {$start}, {$count}");
$rowcounter = 0;
while ($row = mysql_fetch_array($result)) {
    $thumb_url = get_pic_url($row, 'thumb');
    if (!is_image($row['filename'])) {
        $image_info = getimagesize($thumb_url);
        $row['pwidth'] = $image_info[0];
        $row['pheight'] = $image_info[1];
    }
    $image_size = compute_img_size($row['pwidth'], $row['pheight'], $CONFIG['alb_list_thumb_size']);
    $thumb_link = 'displayimage.php?pos=' . -$row['pid'];
    $msg_date = localised_date($row['msg_date'], $comment_date_fmt);
    $msg_body = bb_decode(process_smilies($row['msg_body']));
    $rowcounter++;
    if ($rowcounter >= 2) {
        //let the row colors alternate, for now they are the same
        $rowcounter = 0;
        $tableclass = 'tableb';
        // change to "tableh2_compact" or similar for alternation
    } else {
        $tableclass = 'tableb';
    }
    // build a link to the author's profile if applicable
    if ($row['author_id'] != 0) {
        $profile_link_start = '<a href="profile.php?uid=' . $row['author_id'] . '">';
        $profile_link_end = '</a>';
    } else {
        $profile_link_start = '';
示例#27
0
/**
 * 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, $AUTHORIZED;
    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(urldecode($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]['pid'] = $row['pid'];
            $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'] = bb_decode($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);
    }
}