Example #1
0
function print_comments_content($display = true)
{
    global $links_text, $link_number, $max_link_number, $matched_links;
    if (!isset($matched_links)) {
        $matched_links = array();
    }
    $content = get_comment_text();
    $content = apply_filters('comment_text', $content);
    if (!print_can('images')) {
        $content = remove_image($content);
    }
    if (!print_can('videos')) {
        $content = remove_video($content);
    }
    if (print_can('links')) {
        preg_match_all('/<a(.+?)href=[\\"\'](.+?)[\\"\'](.*?)>(.+?)<\\/a>/', $content, $matches);
        for ($i = 0; $i < count($matches[0]); $i++) {
            $link_match = $matches[0][$i];
            $link_url = $matches[2][$i];
            if (stristr($link_url, 'https://')) {
                $link_url = strtolower(substr($link_url, 0, 8)) != 'https://' ? get_option('home') . $link_url : $link_url;
            } else {
                if (stristr($link_url, 'mailto:')) {
                    $link_url = strtolower(substr($link_url, 0, 7)) != 'mailto:' ? get_option('home') . $link_url : $link_url;
                } else {
                    if ($link_url[0] == '#') {
                        $link_url = $link_url;
                    } else {
                        $link_url = strtolower(substr($link_url, 0, 7)) != 'http://' ? get_option('home') . $link_url : $link_url;
                    }
                }
            }
            $new_link = true;
            $link_url_hash = md5($link_url);
            if (!isset($matched_links[$link_url_hash])) {
                $link_number = ++$max_link_number;
                $matched_links[$link_url_hash] = $link_number;
            } else {
                $new_link = false;
                $link_number = $matched_links[$link_url_hash];
            }
            $content = str_replace_one($link_match, "<a href=\"{$link_url}\" rel=\"external\">" . $link_text . '</a> <sup>[' . number_format_i18n($link_number) . ']</sup>', $content);
            if ($new_link) {
                if (preg_match('/<img(.+?)src=[\\"\'](.+?)[\\"\'](.*?)>/', $link_text)) {
                    $links_text .= '<p style="margin: 2px 0;">[' . number_format_i18n($link_number) . '] ' . __('Image', 'wp-print') . ': <b><span dir="ltr">' . $link_url . '</span></b></p>';
                } else {
                    $links_text .= '<p style="margin: 2px 0;">[' . number_format_i18n($link_number) . '] ' . $link_text . ': <b><span dir="ltr">' . $link_url . '</span></b></p>';
                }
            }
        }
    }
    if ($display) {
        echo $content;
    } else {
        return $content;
    }
}
function Spider_Video_Player_Videos()
{
    wp_enqueue_script('media-upload');
    wp_admin_css('thickbox');
    require_once "video_functions.php";
    // add functions for Spider_Video_Player
    require_once "video_function.html.php";
    // add functions for vive Spider_Video_Player
    /*
    	?>
       <form action="" method="post">
        <input type="text" value="asdgadsfg" id="narek" />
        <input type="button" onclick="alert(document.getElementById('narek').value);"  />
    	<a href="<?php echo plugins_url("video_function.html.php",__FILE__) ?>?TB_iframe=1&amp;width=640&amp;height=394" class="thickbox add_media" id="content-add_media" title="Add Video" onclick="return false;">Insert Video</a>
    	</form>
    	<?php
    */
    if (isset($_GET["task"])) {
        $task = htmlspecialchars($_GET["task"]);
    } else {
        $task = "default";
    }
    if (isset($_GET["id"])) {
        $id = htmlspecialchars($_GET["id"]);
    } else {
        $id = 0;
    }
    switch ($task) {
        case 'video':
            show_video();
            break;
        case 'add_video':
            add_video();
            break;
        case 'published':
            $nonce_sp_vid = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce_sp_vid, 'nonce_sp_vid')) {
                die("Are you sure you want to do this?");
            }
            published($id);
            show_video();
            break;
        case 'Save':
            if (!$id) {
                check_admin_referer('nonce_sp_vid', 'nonce_sp_vid');
                save_video();
            } else {
                check_admin_referer('nonce_sp_vid', 'nonce_sp_vid');
                apply_video($id);
            }
            show_video();
            break;
        case 'Apply':
            if (!$id) {
                check_admin_referer('nonce_sp_vid', 'nonce_sp_vid');
                save_video();
            } else {
                check_admin_referer('nonce_sp_vid', 'nonce_sp_vid');
                apply_video($id);
            }
            edit_video($id);
            break;
        case 'edit_video':
            edit_video($id);
            break;
        case 'remove_video':
            $nonce_sp_vid = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce_sp_vid, 'nonce_sp_vid')) {
                die("Are you sure you want to do this?");
            }
            remove_video($id);
            show_video();
            break;
        case 'publish_video':
            $nonce_sp_vid = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce_sp_vid, 'nonce_sp_vid')) {
                die("Are you sure you want to do this?");
            }
            change_video(1);
            break;
        case 'unpublish_video':
            $nonce_sp_vid = $_REQUEST['_wpnonce'];
            if (!wp_verify_nonce($nonce_sp_vid, 'nonce_sp_vid')) {
                die("Are you sure you want to do this?");
            }
            change_video(0);
            break;
        default:
            show_video();
            break;
    }
}