Exemplo n.º 1
0
function cmtx_notify_admin_new_comment_okay($poster, $comment, $comment_id)
{
    //notify admin of new comment
    global $cmtx_mysql_table_prefix, $cmtx_is_admin, $cmtx_path;
    //globalise variables
    if (file_exists($cmtx_path . 'includes/emails/' . cmtx_setting('language_frontend') . '/admin/custom/new_comment_okay.txt')) {
        $admin_new_comment_okay_email_file = $cmtx_path . 'includes/emails/' . cmtx_setting('language_frontend') . '/admin/custom/new_comment_okay.txt';
        //build path to custom admin new comment okay email file
    } else {
        $admin_new_comment_okay_email_file = $cmtx_path . 'includes/emails/' . cmtx_setting('language_frontend') . '/admin/new_comment_okay.txt';
        //build path to admin new comment okay email file
    }
    $body = file_get_contents($admin_new_comment_okay_email_file);
    //get the file's contents
    $page_reference = cmtx_decode(cmtx_get_page_reference());
    //get the reference of the current page
    $page_url = cmtx_decode(cmtx_get_page_url());
    //get the URL of the current page
    $comment_url = cmtx_decode(cmtx_get_permalink($comment_id, cmtx_get_page_url()));
    //get the permalink of the comment
    $poster = cmtx_prepare_name_for_email($poster);
    //prepare name for email
    $comment = cmtx_prepare_comment_for_email($comment);
    //prepare comment for email
    $admin_link = cmtx_url_encode_spaces(cmtx_setting('commentics_url') . cmtx_setting('admin_folder')) . '/';
    //build admin panel link
    //convert email variables with actual variables
    $body = str_ireplace('[page reference]', $page_reference, $body);
    $body = str_ireplace('[page url]', $page_url, $body);
    $body = str_ireplace('[comment url]', $comment_url, $body);
    $body = str_ireplace('[poster]', $poster, $body);
    $body = str_ireplace('[comment]', $comment, $body);
    $body = str_ireplace('[admin link]', $admin_link, $body);
    $body = str_ireplace('[signature]', cmtx_setting('signature'), $body);
    //select administrators from database
    $admins = cmtx_db_query("SELECT `email` FROM `" . $cmtx_mysql_table_prefix . "admins` WHERE `receive_email_new_comment_okay` = '1' AND `is_enabled` = '1'");
    while ($admin = cmtx_db_fetch_assoc($admins)) {
        //while there are administrators
        $email = $admin['email'];
        //get administrator email address
        if ($cmtx_is_admin && cmtx_is_admin_email($email)) {
        } else {
            //if not detected admin who submitted
            cmtx_email($email, null, cmtx_setting('admin_new_comment_okay_subject'), $body, cmtx_setting('admin_new_comment_okay_from_email'), cmtx_setting('admin_new_comment_okay_from_name'), cmtx_setting('admin_new_comment_okay_reply_to'));
        }
    }
}
Exemplo n.º 2
0
function cmtx_generate_comment($is_preview, $alternate, $id, $name, $email, $website, $town, $country, $rating, $reply_to, $comment, $reply, $is_admin, $likes, $dislikes, $is_sticky, $is_locked, $dated)
{
    //generate comment
    $cmtx_box = '';
    //initialise box
    for ($i = 1; $i <= cmtx_get_reply_depth($id); $i++) {
        if (cmtx_setting('reply_arrow') && $i == cmtx_get_reply_depth($id)) {
            $cmtx_box .= '<div class="cmtx_reply_arrow">';
            //add the reply arrow
        }
        $cmtx_box .= '<div class="cmtx_reply_indent">';
        //indent the reply
    }
    $perm = '';
    if (isset($_GET['cmtx_perm']) && ctype_digit($_GET['cmtx_perm'])) {
        $cmtx_perm = (int) $_GET['cmtx_perm'];
        if ($cmtx_perm == $id) {
            $perm = ' cmtx_permalink_box';
        }
    }
    if ($alternate == 1) {
        //if it's the first box
        if (!$reply_to && !$is_admin) {
            $cmtx_box .= '<div class="cmtx_comment_box_1' . $perm . '" id="cmtx_perm_' . $id . '">';
            //comment and not admin
        } else {
            if ($reply_to && !$is_admin) {
                $cmtx_box .= '<div class="cmtx_reply_box_1' . $perm . '" id="cmtx_perm_' . $id . '">';
                //reply and not admin
            } else {
                if (!$reply_to && $is_admin) {
                    $cmtx_box .= '<div class="cmtx_admin_comment_box_1' . $perm . '" id="cmtx_perm_' . $id . '">';
                    //comment and is admin
                } else {
                    if ($reply_to && $is_admin) {
                        $cmtx_box .= '<div class="cmtx_admin_reply_box_1' . $perm . '" id="cmtx_perm_' . $id . '">';
                        //reply and is admin
                    }
                }
            }
        }
    } else {
        //if it's the second box
        if (!$reply_to && !$is_admin) {
            $cmtx_box .= '<div class="cmtx_comment_box_2' . $perm . '" id="cmtx_perm_' . $id . '">';
            //comment and not admin
        } else {
            if ($reply_to && !$is_admin) {
                $cmtx_box .= '<div class="cmtx_reply_box_2' . $perm . '" id="cmtx_perm_' . $id . '">';
                //reply and not admin
            } else {
                if (!$reply_to && $is_admin) {
                    $cmtx_box .= '<div class="cmtx_admin_comment_box_2' . $perm . '" id="cmtx_perm_' . $id . '">';
                    //comment and is admin
                } else {
                    if ($reply_to && $is_admin) {
                        $cmtx_box .= '<div class="cmtx_admin_reply_box_2' . $perm . '" id="cmtx_perm_' . $id . '">';
                        //reply and is admin
                    }
                }
            }
        }
    }
    //Sticky (1/2)
    if ($is_sticky) {
        $cmtx_box .= '<div class="cmtx_sticky_image">';
    }
    //Gravatar (1/2)
    if (cmtx_setting('show_gravatar')) {
        $cmtx_box .= '<div class="cmtx_gravatar_block">';
        $gravatar_parameter = '&amp;r=' . cmtx_setting('gravatar_rating');
        if (cmtx_setting('gravatar_default') != 'default') {
            if (cmtx_setting('gravatar_default') == 'custom') {
                $gravatar_parameter .= '&amp;d=' . cmtx_url_encode(cmtx_setting('gravatar_custom'));
            } else {
                $gravatar_parameter .= '&amp;d=' . cmtx_setting('gravatar_default');
            }
        }
        $cmtx_box .= '<img src="http://www.gravatar.com/avatar/' . md5(strtolower(trim($email))) . '.png?s=' . cmtx_setting('gravatar_size') . $gravatar_parameter . '" alt="Gravatar" title="Gravatar"/>';
        $cmtx_box .= '</div>';
        $cmtx_box .= '<div style="clear: right;"></div>';
        $cmtx_box .= '<div style="margin-left:' . (cmtx_setting('gravatar_size') + 5) . 'px;">';
    }
    //Rating
    if (cmtx_setting('show_rating') && $rating != 0) {
        $cmtx_box .= '<div class="cmtx_rating_block">';
        if ($rating == 1) {
            $cmtx_box .= cmtx_star_full(1, CMTX_RATING_ONE);
            $cmtx_box .= cmtx_star_empty(4, CMTX_RATING_ONE);
        } else {
            if ($rating == 2) {
                $cmtx_box .= cmtx_star_full(2, CMTX_RATING_TWO);
                $cmtx_box .= cmtx_star_empty(3, CMTX_RATING_TWO);
            } else {
                if ($rating == 3) {
                    $cmtx_box .= cmtx_star_full(3, CMTX_RATING_THREE);
                    $cmtx_box .= cmtx_star_empty(2, CMTX_RATING_THREE);
                } else {
                    if ($rating == 4) {
                        $cmtx_box .= cmtx_star_full(4, CMTX_RATING_FOUR);
                        $cmtx_box .= cmtx_star_empty(1, CMTX_RATING_FOUR);
                    } else {
                        if ($rating == 5) {
                            $cmtx_box .= cmtx_star_full(5, CMTX_RATING_FIVE);
                        }
                    }
                }
            }
        }
        $cmtx_box .= '</div>';
    }
    //Name and Website
    if (cmtx_setting('show_website') && !empty($website) && $website != 'http://') {
        $cmtx_website_attribute = '';
        //initialize variable
        if (cmtx_setting('website_new_window')) {
            $cmtx_website_attribute = ' target="_blank"';
        }
        //if website should open in new window
        if (cmtx_setting('website_nofollow')) {
            $cmtx_website_attribute .= ' rel="nofollow"';
        }
        //if website should contain nofollow tag
        if ($is_admin) {
            $cmtx_box .= '<a class="cmtx_admin_name_with_website_text" href="' . $website . '"' . $cmtx_website_attribute . '>' . $name . '</a>';
        } else {
            $cmtx_box .= '<a class="cmtx_name_with_website_text" href="' . $website . '"' . $cmtx_website_attribute . '>' . $name . '</a>';
        }
    } else {
        if ($is_admin) {
            $cmtx_box .= '<span class="cmtx_admin_name_without_website_text">';
            $cmtx_box .= $name;
            $cmtx_box .= '</span>';
        } else {
            $cmtx_box .= '<span class="cmtx_name_without_website_text">';
            $cmtx_box .= $name;
            $cmtx_box .= '</span>';
        }
    }
    //Town and Country
    if (cmtx_setting('show_town') && !empty($town) && cmtx_setting('show_country') && !empty($country)) {
        $cmtx_box .= '<span class="cmtx_town_country_text">';
        $cmtx_box .= ' (' . $town . ', ' . $country . ')';
        $cmtx_box .= '</span>';
    } else {
        if (cmtx_setting('show_town') && !empty($town)) {
            $cmtx_box .= '<span class="cmtx_town_country_text">';
            $cmtx_box .= ' (' . $town . ')';
            $cmtx_box .= '</span>';
        } else {
            if (cmtx_setting('show_country') && !empty($country)) {
                $cmtx_box .= '<span class="cmtx_town_country_text">';
                $cmtx_box .= ' (' . $country . ')';
                $cmtx_box .= '</span>';
            }
        }
    }
    //Says...
    if (cmtx_setting('show_says')) {
        $cmtx_box .= '<span class="cmtx_says_text">';
        $cmtx_box .= ' ' . CMTX_SAYS;
        $cmtx_box .= '</span>';
    }
    $cmtx_box .= '<div class="cmtx_height_above_comment_text"></div>';
    //Comment
    $cmtx_box .= '<div class="cmtx_comment_text">';
    if (cmtx_setting('show_read_more') && !$is_preview && cmtx_strlen(strip_tags($comment)) > cmtx_setting('read_more_limit')) {
        $comment_less = str_ireplace('<br />', ' ', $comment);
        $comment_less = str_ireplace('<br/>', ' ', $comment_less);
        $comment_less = str_ireplace('<br>', ' ', $comment_less);
        $comment_less = str_ireplace('<p></p>', ' ', $comment_less);
        $comment_less = str_ireplace('<p />', ' ', $comment_less);
        $comment_less = str_ireplace('<p/>', ' ', $comment_less);
        $comment_less = strip_tags($comment_less);
        $comment_cut = substr($comment_less, 0, cmtx_setting('read_more_limit'));
        $comment_less = substr($comment_cut, 0, strrpos($comment_cut, ' '));
        $cmtx_box .= '<div id="cmtx_comment_less_' . $id . '">';
        $cmtx_box .= $comment_less;
        $cmtx_box .= ' <a href="' . cmtx_url_encode(cmtx_current_page()) . '" class="cmtx_read_more_link" title="' . CMTX_TITLE_READ_MORE . '" rel="nofollow" onclick="cmtx_read_more(' . $id . ');return false;">' . CMTX_READ_MORE . '</a>';
        $cmtx_box .= '</div>';
        $cmtx_box .= '<div id="cmtx_comment_more_' . $id . '" style="display:none;">';
        $cmtx_box .= $comment;
        $cmtx_box .= '</div>';
    } else {
        $cmtx_box .= $comment;
    }
    $cmtx_box .= '</div>';
    //Admin Reply
    if (!empty($reply)) {
        $cmtx_box .= '<div class="cmtx_height_above_reply_text"></div>';
        $cmtx_box .= '<div class="cmtx_reply_area">';
        $cmtx_box .= '<div class="cmtx_reply_intro">';
        $cmtx_box .= CMTX_REPLY_INTRO;
        $cmtx_box .= '</div>';
        $cmtx_box .= ' ';
        $cmtx_box .= '<div class="cmtx_reply_text">';
        $cmtx_box .= $reply;
        $cmtx_box .= '</div>';
        $cmtx_box .= '</div>';
    }
    $cmtx_box .= '<div class="cmtx_height_below_comment_text"></div>';
    //Preview Message
    if ($is_preview) {
        $cmtx_box .= '<div class="cmtx_preview_text">';
        $cmtx_box .= CMTX_PREVIEW_TEXT;
        $cmtx_box .= '</div>';
    }
    $cmtx_box .= '<div class="cmtx_buttons_block">';
    //Reply
    if (cmtx_setting('show_reply') && !$is_preview) {
        $cmtx_box .= '<div class="cmtx_reply_block">';
        $cmtx_box .= '<div class="cmtx_buttons">';
        if (cmtx_get_reply_depth($id) < cmtx_setting('reply_depth') && !$is_locked) {
            $cmtx_box .= '<a href="' . cmtx_url_encode(cmtx_current_page() . CMTX_ANCHOR_FORM) . '" id="cmtx_reply_' . $id . '" class="cmtx_reply_enabled" title="' . CMTX_TITLE_REPLY . '" rel="nofollow" onclick="';
            if (cmtx_setting('hide_form')) {
                $cmtx_box .= 'cmtx_open_form();';
            }
            $cmtx_box .= 'document.getElementById(\'cmtx_hide_reply\').style.display=\'block\';';
            $cmtx_box .= 'document.getElementById(\'cmtx_reply_id\').value=\'' . $id . '\';';
            $cmtx_box .= 'document.getElementById(\'cmtx_reply_message\').innerHTML=\'' . CMTX_REPLY_MESSAGE . ' ' . $name . '. ' . '\';';
            $cmtx_box .= 'document.getElementById(\'cmtx_reset_reply\').style.display=\'inline\'">';
            $cmtx_box .= '<img src="' . cmtx_commentics_url() . 'images/buttons/reply.png" alt="Reply" title="' . CMTX_TITLE_REPLY . '"/>' . CMTX_REPLY . '</a>';
        } else {
            $cmtx_box .= '<a href="' . cmtx_url_encode(cmtx_current_page()) . '" id="cmtx_reply_' . $id . '" class="cmtx_reply_disabled" title="" rel="nofollow" onclick="return false;">';
            $cmtx_box .= '<img src="' . cmtx_commentics_url() . 'images/buttons/reply.png" alt="Reply" title=""/>' . CMTX_REPLY . '</a>';
        }
        $cmtx_box .= '</div>';
        $cmtx_box .= '</div>';
    }
    //Permalink
    if (cmtx_setting('show_permalink') && !$is_preview) {
        $cmtx_box .= '<div class="cmtx_permalink_block">';
        $cmtx_box .= '<div class="cmtx_buttons">';
        $cmtx_box .= '<a class="cmtx_permalink" href="' . cmtx_get_permalink($id, cmtx_get_page_url()) . '" id="cmtx_permalink_' . $id . '" title="' . CMTX_TITLE_PERMALINK . '" rel="nofollow"><img src="' . cmtx_commentics_url() . 'images/buttons/permalink.png" alt="Permalink" title="' . CMTX_TITLE_PERMALINK . '"/>' . CMTX_PERMALINK . '</a>';
        $cmtx_box .= '</div>';
        $cmtx_box .= '</div>';
    }
    //Flag
    if (cmtx_setting('show_flag') && !$is_preview) {
        $cmtx_box .= '<div class="cmtx_flag_block">';
        $cmtx_box .= '<div class="cmtx_buttons">';
        $cmtx_box .= '<a class="cmtx_flag" href="' . cmtx_url_encode(cmtx_current_page()) . '" id="cmtx_flag_' . $id . '" title="' . CMTX_TITLE_FLAG . '" rel="nofollow"><img src="' . cmtx_commentics_url() . 'images/buttons/flag.png" alt="Flag" title="' . CMTX_TITLE_FLAG . '"/>' . CMTX_FLAG . '</a>';
        $cmtx_box .= '</div>';
        $cmtx_box .= '</div>';
    }
    //Like/Dislike
    if ((cmtx_setting('show_like') || cmtx_setting('show_dislike')) && !$is_preview) {
        $cmtx_box .= '<div class="cmtx_like_block">';
        $cmtx_box .= '<div class="cmtx_buttons">';
        if (cmtx_setting('show_like')) {
            $cmtx_box .= '<a class="cmtx_vote cmtx_like" href="' . cmtx_url_encode(cmtx_current_page()) . '" id="cmtx_like_' . $id . '" title="' . CMTX_TITLE_LIKE . '" rel="nofollow"><img src="' . cmtx_commentics_url() . 'images/buttons/like.png" alt="Like" title="' . CMTX_TITLE_LIKE . '"/>' . $likes . '</a>';
        }
        if (cmtx_setting('show_dislike')) {
            $cmtx_box .= '<a class="cmtx_vote cmtx_dislike" href="' . cmtx_url_encode(cmtx_current_page()) . '" id="cmtx_dislike_' . $id . '" title="' . CMTX_TITLE_DISLIKE . '" rel="nofollow"><img src="' . cmtx_commentics_url() . 'images/buttons/dislike.png" alt="Dislike" title="' . CMTX_TITLE_DISLIKE . '"/>' . $dislikes . '</a>';
        }
        $cmtx_box .= '</div>';
        $cmtx_box .= '</div>';
    }
    $cmtx_box .= '</div>';
    //Date
    if (cmtx_setting('show_date')) {
        $cmtx_box .= '<div class="cmtx_date_text">';
        if (date('Y-m-d', strtotime($dated)) == date('Y-m-d')) {
            //if comment's date is today
            $cmtx_box .= CMTX_TODAY . ' ' . cmtx_format_date(date(CMTX_TIME_FORMAT, strtotime($dated)));
        } else {
            if (date('Y-m-d', strtotime($dated)) == date('Y-m-d', mktime(date('H'), date('i'), date('s'), date('m'), date('d') - 1, date('Y')))) {
                //if comment's date is yesterday
                $cmtx_box .= CMTX_YESTERDAY . ' ' . cmtx_format_date(date(CMTX_TIME_FORMAT, strtotime($dated)));
            } else {
                $cmtx_box .= cmtx_format_date(date(CMTX_DATE_FORMAT, strtotime($dated))) . ' ' . cmtx_format_date(date(CMTX_TIME_FORMAT, strtotime($dated)));
            }
        }
        $cmtx_box .= '</div>';
    }
    //Sticky (2/2)
    if ($is_sticky) {
        $cmtx_box .= '</div>';
    }
    //Gravatar (2/2)
    if (cmtx_setting('show_gravatar')) {
        $cmtx_box .= '</div>';
    }
    $cmtx_box .= '</div>';
    //end div
    for ($i = 1; $i <= cmtx_get_reply_depth($id); $i++) {
        if (cmtx_setting('reply_arrow') && $i == cmtx_get_reply_depth($id)) {
            $cmtx_box .= '</div>';
        }
        $cmtx_box .= '</div>';
    }
    if ($is_preview) {
        $cmtx_box .= '<div class="cmtx_height_below_preview_box"></div>';
    }
    return $cmtx_box;
}
Exemplo n.º 3
0
         }
     } else {
         echo $cmtx_average_rating . '/5 (' . cmtx_number_of_ratings() . ')</span>';
     }
 }
 echo '</div>';
 /* *** Pagination (Top) *** */
 echo '<div class="cmtx_pagination_block_top">';
 if (cmtx_setting('enabled_pagination') && cmtx_setting('show_pagination_top') && $cmtx_total_pages > 1) {
     cmtx_paginate($cmtx_current_page, cmtx_setting('range_of_pages'), $cmtx_total_pages);
 }
 echo '</div>';
 /* *** Social *** */
 echo '<div class="cmtx_social_block">';
 if (cmtx_setting('show_social')) {
     $cmtx_social_url = cmtx_url_encode_spaces(cmtx_get_page_url());
     $cmtx_social_title = cmtx_url_encode_spaces(cmtx_get_page_reference());
     $cmtx_social_url = str_ireplace('&amp;', '%26', $cmtx_social_url);
     //convert &amp; to %26
     $cmtx_social_title = str_ireplace('&amp;', '%26', $cmtx_social_title);
     //convert &amp; to %26
     $cmtx_social_attribute = '';
     //initialize variable
     if (cmtx_setting('social_new_window')) {
         $cmtx_social_attribute = ' target="_blank"';
     }
     echo '<div class="cmtx_social_images">';
     if (cmtx_setting('show_social_facebook')) {
         echo '<a href="http://www.facebook.com/sharer.php?u=' . $cmtx_social_url . '&amp;t=' . $cmtx_social_title . '" rel="nofollow"' . $cmtx_social_attribute . '><img src="' . cmtx_commentics_url() . 'images/social/facebook.png" class="cmtx_social_image" title="Facebook" alt="Facebook"/></a>';
     }
     if (cmtx_setting('show_social_delicious')) {