PK œqhYî¶J‚ßF ßF ) nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/
Dir : /home/trave494/productjuly1video/champdoms.click/admin-panel/pages/import-from-twitch/ |
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 IP: 209.182.202.254 |
Dir : //home/trave494/productjuly1video/champdoms.click/admin-panel/pages/import-from-twitch/content.html |
<?php $pt->sub_categories_array = array(); foreach ($pt->sub_categories as $cat_key => $subs) { $pt->sub_categories_array["'".$cat_key."'"] = '<option value="0">Sub Category</option>'; foreach ($subs as $sub_key => $sub_value) { $selected = ''; if (!empty($_GET['sub_category_id'])) { $selected = ($_GET['sub_category_id'] == $sub_key) ? 'selected' : ''; } $pt->sub_categories_array["'".$cat_key."'"] .= '<option value="'.array_keys($sub_value)[0].'" '.$selected.'>'.$sub_value[array_keys($sub_value)[0]].'</option>'; } } $query = ''; $multi_query = ''; $limit = 50; $respond_error = 0; $search_made = 0; $page_id = 1; if (empty($pt->config->twitch_api)) { $respond_error = 1; $error_text = 'please put your Twitch Client Id in Settings > General Settings to start import videos from Twitch.'; } if (!empty($_GET['query']) || !empty($_GET['multi-query'])) { if (!empty($_GET['query'])) { $query = PT_Secure($_GET['query']); } if (!empty($_GET['limit']) && $limit < 101) { $limit = (int) PT_Secure($_GET['limit']); } $search_made = 1; $offset = $limit; if (!empty($_GET['page-query'])) { if (is_numeric($_GET['page-query'])) { $page_id = PT_Secure($_GET['page-query']); $offset = ($page_id * $limit); } } $query = urlencode($query); for ($i=$page_id; $i <= 10 ; $i++) { $offset = ($i * $limit); $channelsApi = 'https://api.twitch.tv/kraken/channels/'.$query.'/videos?limit='.$limit; if (!empty($offset) && $page_id > 1) { $channelsApi = 'https://api.twitch.tv/kraken/channels/'.$query.'/videos?limit='.$limit.'&offset='.$offset; } $clientId = $pt->config->twitch_api; $ch = curl_init(); curl_setopt_array($ch, array( CURLOPT_HTTPHEADER => array( 'Client-ID: ' . $clientId, 'Accept: application/vnd.twitchtv.v4+json' ), CURLOPT_RETURNTRANSFER => true, CURLOPT_URL => $channelsApi )); $response = curl_exec($ch); curl_close($ch); $get_videos = json_decode($response); if (!empty($get_videos->videos) && $get_videos->status != 400) { if (!empty($get_videos->_total)) { $ids = array(); foreach ($get_videos->videos as $key => $video) { $check_if_exists = $db->where('twitch', substr($video->_id, 1) )->getValue(T_VIDEOS, 'count(*)'); if ($check_if_exists == 0) { $ids[] = substr($video->_id, 1); } } if (!empty($ids)) { break; } else{ } } } else if($get_videos->status == 400){ $respond_error = 1; $error_text = $get_videos->message; break; } else { $respond_error = 1; $error_text = 'No video found.'; break; } $page_id = $page_id + 1; } } $user_id = 0; $username = ''; if (!empty($_GET['username']) && isset($_GET['username'])) { $username = PT_Secure($_GET['username']); $user = $db->where('username', $username)->getOne(T_USERS); if (!empty($user)) { $user_id = $user->id; } else{ $respond_error = 1; $error_text = 'user not found'; } } $category_filter = array_keys(ToArray($pt->categories))[0]; if (!empty($_GET['category_id'])) { if (in_array($_GET['category_id'], array_keys(ToArray($pt->categories)))) { $category_filter = $_GET['category_id']; } } $get_ini = ini_get('max_input_vars'); $auto_import = 0; if (!empty($_GET['auto_import'])) { $auto_import = 1; } ?> <div class="container-fluid"> <?php if ($get_ini <= 1000) { ?> <div class="alert alert-warning"> If you want to import more than 180 videos by one click, you need to increase <b>max_input_vars</b> in your php.ini file. </div> <?php } ?> <div class="block-header"> <h2>Videos > Import Videos > Import From Twitch</h2> </div> <!-- Vertical Layout --> <div class="row"> <div class="col-lg-12 col-md-12"> <div class="card"> <div class="header"> <h2>Import Videos From Twitch</h2> </div> <div class="body"> <div class="row"> <div class="col-md-12" style="margin-bottom:0;"> <form method="get" action="<?php echo PT_LoadAdminLinkSettings('import-from-twitch'); ?>"> <div class="row"> <div class="col-md-2" id="normal-query-form"> <div class="form-group form-float"> <div class="form-line"> <input type="text" name="query" id="query" class="form-control" value="<?php echo (empty($multi_query)) ? urldecode($query) : ''; ?>"> <label class="form-label search-form">Channel name To Import from</label> </div> </div> </div> <div class="col-lg-2 col-md-2"> <select class="form-control show-tick" id="limit" name="limit"> <option value="all" selected disabled>Limit Per Page</option> <option value="5" <?php echo ($limit == 5) ? 'selected' : '' ?>>5</option> <option value="10" <?php echo ($limit == 10) ? 'selected' : '' ?>>10</option> <option value="25" <?php echo ($limit == 25) ? 'selected' : '' ?>>25</option> <option value="50" <?php echo ($limit == 50) ? 'selected' : '' ?>>50 (Default)</option> <option value="100" <?php echo ($limit == 100) ? 'selected' : '' ?>>100 (Default)</option> </select> </div> <div class="col-lg-2 col-md-2"> <select class="form-control show-tick" id="page-query" name="page-query"> <option value="1" selected disabled>Page</option> <?php for ($i=1; $i < 100; $i++) { ?> <option value="<?php echo $i ?>" <?php echo ($page_id == $i) ? 'selected' : '' ?>><?php echo $i ?></option> <?php } ?> </select> </div> <div class="col-lg-2 col-md-2"> <select class="form-control show-tick" id="category_id" name="category_id"> <?php foreach($pt->categories as $key => $category) { $selected = ($key == $category_filter) ? 'selected' : ''; ?> <option value="<?php echo $key?>" <?php echo $selected?>><?php echo $category?></option> <?php } ?> </select> </div> <div class="col-lg-2 col-md-2" <?php if (empty($pt->sub_categories_array["'1'"])) { ?> style="display: none;"<?php } ?> id="sub_category_div"> <select name="sub_category_id" id="sub_category_id" class="form-control"> <?php echo $pt->sub_categories_array["'1'"]; ?> </select> </div> <div class="clearfix"></div> <div class="col-lg-4 col-md-4"> <select class="form-control show-tick" id="auto_import" name="auto_import"> <option value="0" <?php echo ($auto_import == 0) ? 'selected' : '';?>>Manual Import</option> <option value="1" <?php echo ($auto_import == 1) ? 'selected' : '';?>>Auto Import (Auto Import After Loading)</option> </select> </div> <div class="col-md-2" id="normal-query-form"> <div class="form-group form-float"> <div class="form-line"> <input type="text" name="username" id="username" class="form-control" value="<?php echo ($username); ?>"> <label class="form-label search-form">Import as (Username)</label> </div> </div> </div> <!-- <div class="col-md-12 <?php echo (!empty($multi_query)) ? '' : 'hidden' ?>" id="multi-query-form"> <div class="form-group form-float"> <div class="form-line"> <textarea name="multi-query" id="multi-query" class="form-control" rows="5"><?php echo $multi_query ?></textarea> <label class="form-label search-form">Keywords separated by comma (This will import the next word automatically after the previous one is finished, 100 pages will be imported for each keyword)</label> </div> </div> </div> --> <div class="col-md-2"> <button class="btn btn-info">Search</button> </div> </div> <div class="clearfix"></div> </form> </div> </div> <div class="clearfix"></div> </div> </div> <?php if ((isset($_GET['query']) || isset($_GET['multi-query'])) && $respond_error == 0) { ?> <div class="card"> <div class="header"> <h2>Videos</h2> </div> <div class="body"> <div class="row" id="videos-layout"> <?php if (!empty($ids)) { foreach ($get_videos->videos as $key => $video) { $thumb = PT_GetMedia('upload/photos/thumbnail.jpg'); if (!empty($video->thumbnails->medium[0]->url)) { $thumb = $video->thumbnails->medium[0]->url; } else if (!empty($video->thumbnails->large[0]->url)) { $thumb = $video->thumbnails->large[0]->url; } $thumb = str_replace('http://', 'https://', $thumb); $tags = ''; // if (is_array($video->tags)) { // $tags_array = array(); // $tag_count = 0; // foreach ($video->tags as $key => $tag) { // if ($tag_count < 11) { // $tags_array[] = $tag; // } // $tag_count++; // } // $tags = implode(',', $tags_array); // } $duration = '00:00'; if (!empty($video->duration)) { $duration = gmdate("i:s", $video->duration); } $title = ''; if (!empty($video->title)) { $title = $video->title; } $description = ''; if (!empty($video->description)) { $description = $video->description; } $array_data = array( 'ID' => substr($video->_id, 1), 'TITLE' => $title, 'DESC' => $description, 'THUMB' => $thumb, 'TAGS' => $tags, 'DURATION' => $duration ); echo PT_LoadAdminPage('import-from-twitch/list', $array_data); } } else { echo '<div class="no-data-found">No videos found, try another page.</div>'; } ?> </div> <input type="hidden" name="user_id_" id="user_id_" value="<?php echo($user_id); ?>" > <div class="clearfix"></div> <?php if (!empty($ids)) { ?> <div class="text-center"> <button class="btn btn-info waves-effect waves-light btn-lg btn-load-more-videos" data-token="<?php echo $page_id?>" data-token-="<?php echo $offset?>">LOAD <?php echo $limit ?> MORE VIDEOS</button> <button class="btn btn-success waves-effect waves-light btn-lg btn-import">IMPORT SELECTED <span></span></button> </div> <?php } ?> </div> </div> <?php } ?> <?php if (isset($_GET['finished']) && !empty($_SESSION['imported-videos'])) { ?> <div class="card"> <div class="header bg-light-green"> <h2><i class="fa fa-check"></i> Auto Import Successfully Completed!</h2> </div> <div class="body"> <?php echo (!empty($_SESSION['imported-videos'])) ? number_format($_SESSION['imported-videos']) : ''; ?> videos successfully imported. </div> </div> <?php unset($_SESSION['imported-videos']); } ?> <?php if ($respond_error == 1 && !empty($error_text)) { ?> <div class="card"> <div class="header bg-red"> <h2><i class="fa fa-times"></i> Error found while fetching the videos!</h2> </div> <div class="body"> <?php echo $error_text?> </div> </div> <?php } ?> </div> <div class="clearfix"></div> </div> <!-- #END# Vertical Layout --> <div id="import-modal" class="modal fade" role="dialog" data-backdrop="static" data-keyboard="false"> <div class="modal-dialog"> <div class="modal-content modal-col-teal"> <div class="modal-body text-center"> <h4><p class="loading">Importing <?php if (isset($_SESSION['keyword-id'])) { echo (!empty($explode[$_SESSION['keyword-id']])) ? '"' . $explode[$_SESSION['keyword-id']] . '"' : '';} ?></p></h4> </div> </div> </div> </div> <script> <?php $js_array = json_encode($pt->sub_categories_array); echo "var sub_categories_array = ". $js_array . ";\n"; ?> $(window).load(function () { <?php if (!empty($_GET['category_id'])) { ?> if (typeof(sub_categories_array["'<?php echo($_GET['category_id']) ?>'"]) == 'undefined') { $('#sub_category_div').hide(); //$('#sub_category_id').html(''); $('#sub_category_div').html('<select name="sub_category_id" id="sub_category_id" class="form-control"></select>'); } else{ $('#sub_category_div').show(); //$('#sub_category_id').html(sub_categories_array["'<?php echo($_GET['category_id']) ?>'"]); $('#sub_category_div').html('<select name="sub_category_id" id="sub_category_id" class="form-control">'+sub_categories_array["'<?php echo($_GET['category_id']) ?>'"]+'</select>'); } <?php }else{ ?> $('#sub_category_div').html('<select name="sub_category_id" id="sub_category_id" class="form-control"><?php echo $pt->sub_categories_array["'1'"]; ?></select>'); <?php } ?> }); $(document).on('change', '#category_id', function(event) { event.preventDefault(); id = $(this).val(); if (typeof(sub_categories_array["'"+id+"'"]) == 'undefined') { $('#sub_category_div').hide(); $('#sub_category_id').html(''); } else{ $('#sub_category_div').show(); $('#sub_category_id').html(sub_categories_array["'"+id+"'"]); } }); $('#auto_import').change(function(event) { if ($(this).val() == 1) { $('#multi-query-form').removeClass('hidden'); $('#normal-query-form').addClass('hidden'); $('#query').val(''); } else { $('#multi-query-form').addClass('hidden'); $('#multi-query').val(''); $('#normal-query-form').removeClass('hidden'); } }); $('.btn-load-more-videos').on('click' , function(event) { event.preventDefault(); var token = $(this).attr('data-token-'); $('.btn-load-more-videos').text('Loading..'); $.post('{{LINK aj/ap/load-more-twitch}}', {pageToken: token, query: $('#query').val(), limit: $('#limit').val() }, function(data, textStatus, xhr) { if (data.status == 200) { $('#videos-layout').append(data.html); $('.btn-load-more-videos').attr('data-token-', data.token); $('.btn-load-more-videos').text('LOAD <?php echo $limit ?> MORE VIDEOS'); $(".form-line").addClass("focused"); $('.btn-import').find('span').text(' (' + $('.import-checkbox-input:checked').size() + ')'); } else { $('.btn-load-more-videos').text('No more videos found'); } }); }); $('.import-checkbox-input, .check-all').change(function(event) { $('.btn-import').find('span').text(' (' + $('.import-checkbox-input:checked').size() + ')'); }); $(function () { $('.btn-import').find('span').text(' (' + $('.import-checkbox-input:checked').size() + ')'); <?php if ($auto_import == 1 && !empty($ids)) {?> setTimeout(function () { $('.btn-import').trigger('click'); }, 3000); <?php } ?> <?php if (empty($ids) && !empty($_SESSION['keyword-id'])) {?> $('#page-query').val(1); $('form').submit(); <?php } ?> }); $('.btn-import').on('click', function(event) { data = new Array(); $('.btn-import').attr('disabled', true); $('.btn-import').text('Please wait..'); $('#import-modal').modal('show'); user_id = $('#user_id_').val(); $('.youtube-video').each(function(index, el) { var video_id = $(this).attr('data-id'); var is_checked = $(this).find('.import-checkbox-input').is(":checked"); if (is_checked) { object_video = { video_id: video_id, title: $(this).find('#title').val(), description: $(this).find('#description').val(), duration: $(this).find('#duration').val(), tags: $(this).find('#tags').val(), thumb: $(this).find('#thumb').val(), } data.push(object_video); } }); $.post('{{LINK aj/ap/import-twitch-videos}}', {videos: data, category_id: $('#category_id').val(),sub_category_id: $('#sub_category_id').val(),user_id:user_id}, function () { $('#import-modal').find('.modal-content').removeClass('modal-col-teal').addClass('modal-col-light-green'); $('#import-modal').find('.loading').html('<i class="fa fa-check"></i> Videos successfully imported, redirecting to next page'); var val = Number($('#page-query').val()); if (val < 100) { $('#page-query').val(val + 1); $('form').submit(); } else { $('#page-query').val(1); $('form').submit(); } }); }); </script> <style> p { color: white; font: 30px; text-align: center;} /* loading dots */ .loading:after { content: ' .'; animation: dots 1s steps(5, end) infinite;} @keyframes dots { 0%, 20% { color: rgba(0,0,0,0); text-shadow: .25em 0 0 rgba(0,0,0,0), .5em 0 0 rgba(0,0,0,0);} 40% { color: white; text-shadow: .25em 0 0 rgba(0,0,0,0), .5em 0 0 rgba(0,0,0,0);} 60% { text-shadow: .25em 0 0 white, .5em 0 0 rgba(0,0,0,0);} 80%, 100% { text-shadow: .25em 0 0 white, .5em 0 0 white;}} </style>