HEX
Server: Apache
System: Linux 162-240-236-42.bluehost.com 3.10.0-1160.114.2.el7.x86_64 #1 SMP Wed Mar 20 15:54:52 UTC 2024 x86_64
User: bt667 (1004)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /home/bt667/public_html/wp-content/plugins/wp_mvplayer/settings/admin_manage_video.php
<?php
if ( ! defined( 'ABSPATH' ) ) exit;

if( isset($_GET['delete'] ) &&  ($_GET['delete']=='success'))
    echo '<div class="updated"><p><strong>'.__('Video(s) Deleted Successfully','mvp' ).'</strong></p></div>';

if( ! class_exists( 'WP_List_Table' ) ) {
    require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}

class video_List_Table extends WP_List_Table{
    function __construct(){
        global $status, $page;
        parent::__construct( array('items',));
    }

    function column_default($item, $column_name){
        switch($column_name){
            case 'id':
                echo '<div class="clipboard">
                    <input onclick="copyvideocode'.$item['id'].'()" class="copy-input" value="[MVP id='.$item['id'].']" id="copyClipboardVideo'.$item['id'].'" readonly>
                    <button class="copyButton" id="copyButton'.$item['id'].'">Copy</button>
                    </div>
                    <div id="copied-success" class="copied"><span>Copied!</span></div>
                    <script>
                        jQuery("document").ready(function(){
                            jQuery("#copyButton'.$item['id'].'").on("click",function(e){
                                e.preventDefault();
                                copyvideocode'.$item['id'].'();
                                jQuery("#copyButton'.$item['id'].'").text("Copied");
                            });    
                        });    
                    </script>
                    <script>
                        function copyvideocode'.$item['id'].'() {
                            var copyText = document.getElementById("copyClipboardVideo'.$item['id'].'");
                            copyText.select();
                            copyText.setSelectionRange(0, 99999);
                            document.execCommand("copy");
                            jQuery("#copied-success").fadeIn(800);
                            jQuery("#copied-success").fadeOut(800);
                        }
                    </script>';
                break;
            case 'Title':                
            case 'Video':
            case 'SocialEnable': 
            case 'OptinBox':
                return $item[$column_name];
            case 'VideoSource':
                if($item['VideoSource']=='mp4_video'){return 'mp4';}
                if($item['VideoSource']=='youtube_video'){return 'youtube';}
                if($item['VideoSource']=='vimeo_video'){return 'vimeo';}
                break;
            case 'PlayerSkin':
                if($item['PlayerSkin']=='none'){return "<img src='".MV_PLAYER_URL."/image/none.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin1'){return "<img src='".MV_PLAYER_URL."/image/skin6/skin6.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin2'){return "<img src='".MV_PLAYER_URL."/image/skin3/skin3.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin3'){return "<img src='".MV_PLAYER_URL."/image/skin15/skin15.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin4'){return "<img src='".MV_PLAYER_URL."/image/skin1/skin1.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin5'){return "<img src='".MV_PLAYER_URL."/image/skin23/skin23.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin6'){return "<img src='".MV_PLAYER_URL."/image/newskin1/demo.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin7'){return "<img src='".MV_PLAYER_URL."/image/newskin2/demo.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin8'){return "<img src='".MV_PLAYER_URL."/image/newskin3/demo.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin9'){return "<img src='".MV_PLAYER_URL."/image/newskin4/demo.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin10'){return "<img src='".MV_PLAYER_URL."/image/newskin5/demo.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin11'){return "<img src='".MV_PLAYER_URL."/image/newskin6/demo.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin12'){return "<img src='".MV_PLAYER_URL."/image/newskin7/demo.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin13'){return "<img src='".MV_PLAYER_URL."/image/newskin8/demo.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin14'){return "<img src='".MV_PLAYER_URL."/image/newskin9/demo.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin15'){return "<img src='".MV_PLAYER_URL."/image/newskin10/demo.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin16'){return "<img src='".MV_PLAYER_URL."/image/newskin11/demo.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin17'){return "<img src='".MV_PLAYER_URL."/image/newskin12/demo.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin18'){return "<img src='".MV_PLAYER_URL."/image/newskin13/demo.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin19'){return "<img src='".MV_PLAYER_URL."/image/newskin14/demo.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin20'){return "<img src='".MV_PLAYER_URL."/image/newskin15/demo.png' style='height:40px;width:40px;'>";}
                if($item['PlayerSkin']=='skin21'){ return "<img src='".MV_PLAYER_URL."/image/newskin16/demo.png' style='height:40px;width:40px;'>"; }
                if($item['PlayerSkin']=='skin22'){ return "<img src='".MV_PLAYER_URL."/image/newskin17/demo.png' style='height:40px;width:40px;'>"; }
                if($item['PlayerSkin']=='skin23'){ return "<img src='".MV_PLAYER_URL."/image/newskin18/demo.png' style='height:40px;width:40px;'>"; }
                if($item['PlayerSkin']=='skin24'){ return "<img src='".MV_PLAYER_URL."/image/newskin19/demo.png' style='height:40px;width:40px;'>"; }
                if($item['PlayerSkin']=='skin25'){ return "<img src='".MV_PLAYER_URL."/image/newskin20/demo.png' style='height:40px;width:40px;'>"; }                
            case 'ImageLogo':
                if( !empty( $item['ImageLogo'] )){
                    return "<img src='" . $item['ImageLogo'] . "' style='height:30px;width:30px;' alt='".__( 'No Icon', 'mvp' )."'>";
                }else{
                    return esc_html_e( 'Not Uploaded', 'mvp' );;
                }
            default:
            case 'datetime':echo date('j-M-Y',strtotime($item['datetime']));
                return false;
        }
    }

    function column_Title($item){ 
        $actions=array('edit'=>sprintf('<a href="?page=mv_player_add_video&view=update&id='.$item['id'].'">Edit</a>',$_REQUEST['page'],$item['id'],'edit'),
            'delete' => sprintf('<a href="?page=%s&action=%s&id=%s">Delete</a>',$_REQUEST['page'],'delete',$item['id']),);
            return sprintf('%1$s%3$s',$item['Title'],$item['id'],$this->row_actions($actions));
        }

        function column_cb($item){
            return sprintf('<input type="checkbox" name="check[]" value="%1$s" />', $item['id'] );
        }

        function get_columns(){
            $columns = array('cb'=>'<input type="checkbox"/>','Title'=>'Title','Video'=>'Video','VideoSource'=>'Video Tpye','SocialEnable'=>'Social Share','OptinBox'=>'OptinBox','ImageLogo'=>'Video Icon','PlayerSkin'=>'PlayerSkin','id'=>'Short Code');
            return $columns;
        }

        function get_sortable_columns(){
            $sortable_columns = array('Title'=> array('Title',false), 
                                    'Video'    => array('Video',false),
                                    'VideoSource'=> array('VideoSource',false),
                                    'SocialEnable'=> array('SocialEnable',false),
                                    'OptinBox'=> array('OptinBox',false),
                                    'ImageLogo'=> array('ImageLogo',false),
                                    'PlayerSkin'    => array('PlayerSkin',false),
                                );
            return $sortable_columns;
        }

        function get_bulk_actions() {
            $actions = array('trash' => 'Trash');
            return $actions;
        }

        function process_bulk_action() {
            global $wpdb;            
            $video_table = $wpdb->base_prefix . 'mvplayer_video';
            $videobuttons_table = $wpdb->base_prefix . 'mvplayer_videobuttons';

            if( 'delete'===$this->current_action() ) {
                if( isset($_REQUEST['id'])){
                    $id =  $_REQUEST['id'];
                    $screen = get_current_screen();
                    $query = "delete  FROM $video_table where id=$id";
                    $wpdb->query($query);

                    $query2 = "delete  FROM $videobuttons_table where VideoId=$id";
                    $wpdb->query($query2);

                    wp_mvplayer_redirect("?page=mv_player_manage_video&delete=success");
                }else{
                    wp_mvplayer_redirect("?page=mv_player_manage_video");
                }
            }

            if(isset($check)){
                if( 'trash'===$this->current_action() ) {
                    foreach($check as $trashid){
                        $query = "delete  FROM $video_table where id=$trashid ";
                        $wpdb->query($query);

                        $query2 = "delete  FROM $videobuttons_table where VideoId=$trashid ";
                        $wpdb->query($query2);
                    }                    
                    wp_mvplayer_redirect("?page=mv_player_manage_video&delete=success");
                }
            }
        }

        function prepare_items(){
            global $wpdb;
            $per_page =20;
            $screen = get_current_screen();
            $video_table = $wpdb->base_prefix . 'mvplayer_video';
            $query = "SELECT * FROM $video_table";

            if(!empty($_REQUEST['s'])){
                $query .= " Where Title LIKE '%".$_REQUEST['s']."%'";
            }

            $query .= " order by id desc";
            $example_data=$wpdb->get_results($query, ARRAY_A);
            $columns = $this->get_columns();
            $hidden = array();
            $sortable = $this->get_sortable_columns();
            $this->_column_headers = array($columns, $hidden, $sortable);       
            $this->process_bulk_action();
            $tdata = array();

            if(isset($item)){
                foreach($example_data as $k){
                    $actions = $this->column_Title($item) ;
                    $tdata[]=array();
                    echo $k->Title;
                }
            }

            if(isset($actions) && isset($k)){
                $data=array( $k, $actions );
            }      

            $data = $example_data;

            if(isset($_REQUEST['orderby'])){
                function usort_reorder($a,$b){
                    $orderby = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'date';
                    $order = (!empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'desc';
                    $result = strcmp($a[$orderby], $b[$orderby]);
                    return ($order==='asc') ? $result : -$result;
                }

                usort($data, 'usort_reorder');
            }

            $current_page = $this->get_pagenum();
            $total_items = count($data);
            $data = array_slice($data,(($current_page-1)*$per_page),$per_page);
            $this->items = $data;   
            $this->set_pagination_args(array('total_items'=>$total_items,'per_page'=> $per_page,'total_pages'=>ceil($total_items/$per_page)) );
        }
    }

    ?> 
    <div class="wrap">
        <div id="icon-edit" class="icon32"><br/></div>
        <h2><?php echo esc_html_e('Manage Video','mvp'); ?><a href="?page=mv_player_add_video" class="add-new-h2"><?php echo esc_html_e('Add New','mvp'); ?></a></h2> 
        <form id="movies-filter" method="post">
            <input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />
            <?php 
                $testListTable = new video_List_Table();
                $testListTable->prepare_items();
                $testListTable->search_box(__('Search','mvp'),'Title');
            ?>
            <div>  <?php $testListTable->display();?></div>
        </form>
    </div>