<?php
if ( ! defined( 'ABSPATH' ) ) exit; 
  
function fl_image() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>
<figure class="appicon">
  <img width="200" height="200" <?php if($opt_themes['lazy_img']){?>data-src<?php } else { ?>src<?php } ?>="<?php if ($opt_themes['hotlink']) { ?><?php echo get_post_meta( get_the_ID(), 'wp_poster_GP', true ); ?><?php } elseif (get_the_post_thumbnail( get_the_ID() )) { ?><?php   if($opt_themes['compress_img']){ echo wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'img_200' )[0];  } else { echo wp_get_attachment_image_src( get_post_thumbnail_id( get_the_ID() ), 'full' )[0];  } ?><?php } else { ?><?php echo $opt_themes['media_no_img']['url'];  } ?>" alt="<?php the_title(); ?>" fetchpriority="high">	
  <i class="mask star-mask"></i>
</figure>

<?php
}

function fl_tools() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  



<div class="md5">SHA-1: <?php if( $opt_themes['arab_number'] && is_rtl() ) { echo num_arab(substr(sha1($urlsx), 0, 32)); } else { echo substr(sha1($urlsx), 0, 32); } ?></div>
<h1 class="title"><?php _e($opt_themes['text_dw_1a'], TEXT_DOMAIN); ?> <?php if( $opt_themes['arab_number'] && is_rtl() ) { echo num_arab($_GET['names']); } else { echo $_GET['names']; } ?></h1>
<ul class="cdn-meta">
  <?php if(get_post_meta( get_the_ID(), 'wp_version_GP', true )){?><li class="cdn-meta-item">v<?php if( $opt_themes['arab_number'] && is_rtl() ) { echo num_arab(get_post_meta( get_the_ID(), 'wp_version_GP', true )); } else { echo get_post_meta( get_the_ID(), 'wp_version_GP', true ); } ?></li><?php } ?>
  <?php if(get_post_meta( get_the_ID(), 'wp_requires_GP', true )){?><li class="cdn-meta-item"><?php _e($opt_themes['o_text_3d'], TEXT_DOMAIN); ?> <?php if( $opt_themes['arab_number'] && is_rtl() ) { echo num_arab(get_post_meta( get_the_ID(), 'wp_requires_GP', true )); } else { echo get_post_meta( get_the_ID(), 'wp_requires_GP', true ); } ?></li><?php } ?>
</ul>

<?php
}

function fl_download() { 
global $wpdb, $post, $opt_themes, $wp_query; 

function mask_link( $string, $action = 'e' ){
$secret_key		= THEMES_NAMES;
$secret_iv		= EXTHEMES_AUTHOR;
$output			= false;
$encrypt_method	= "AES-256-CBC";
$key			= hash( 'sha256', $secret_key );
$iv				= substr( hash( 'sha256', $secret_iv ), 0, 16 );
if( $action == 'e' ){
	$output = base64_encode( openssl_encrypt( $string, $encrypt_method, $key, 0, $iv ) );
} else if( $action == 'd' ){
	$output = openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv );
}
return $output;
}

?>    

	<div id="countdown-timer" data-time="<?php echo $opt_themes['timer_dw']; ?>">
        <?php _e($opt_themes['text_dw_1d'], TEXT_DOMAIN); ?><span id="time-display"></span>
    </div>
 	
	<?php
	if( !function_exists('dynamic_sidebar') || !dynamic_sidebar('download_2') ) : endif;
	?>
	
<div id="page-cdn-btns" class="btn-group">
  <a class="btn btn-fill btn-blue" href="<?php echo $opt_themes['hd_tele_url']; ?>" target="_blank" rel="nofollow noopener">
    <span class="btn-cont"><?php _e($opt_themes['text_dw_1b'], TEXT_DOMAIN); ?></span>
  </a>
  <a class="btn btn-fill offcounter sr-only" id="btn-download-cdn" download_link="<?php if($opt_themes['masking_link']){ echo base64_encode(mask_link($_GET['urls'], 'd')); } else { echo base64_encode($_GET['urls']); } ?>" data-title="Loading...">
    <span class="btn-cont"><?php _e($opt_themes['text_dw_1a'], TEXT_DOMAIN); ?> <?php if($_GET['sizes']){?>(<?php if( $opt_themes['arab_number'] && is_rtl() ) { echo num_arab($_GET['sizes']); } else { echo $_GET['sizes']; } ?>)<?php } ?></span>
  </a>
  <a href="<?php the_permalink(); ?>" class="btn btn-line offcounter">
    <span class="btn-cont"><?php _e($opt_themes['text_dw_1c'], TEXT_DOMAIN); ?></span>
  </a> 
</div>

	
<?php
}

function fl_help() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  
	<div class="faq-list">
	<?php sp_help(); ?>
	</div>
	
<?php
}

function fl_related() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

<?php 
global $wpdb, $post, $opt_themes, $wp_query; 
if($opt_themes['rp_on']){
$the_query = themes_related_posts( get_the_ID(), 'post', 'category', $opt_themes['rp_num'] );
global $cl_from_element;
$cl_from_element['is_related'] = true;			
// Display posts
if ( $the_query->have_posts() ) : 
?>
<section class="wrp sect">
	<h2 class="sect-head title"><?php _e($opt_themes['rp_title2'], TEXT_DOMAIN); ?></h2>
	<div class="glist cards-sw g4 hscroll">
	<?php 
	while ( $the_query->have_posts() ) : $the_query->the_post(); 
	get_template_part('loop/item.useful');		
	endwhile;
	?>	  
	</div>
</section>
<?php 
endif; 
wp_reset_query();
$cl_from_element['is_related'] = false; 
}
?>  

<?php
}

function fl_js() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js" integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>

<script src="<?php echo get_template_directory_uri(); ?>/assets/js/dw_link.js"></script>
<script src="<?php echo get_template_directory_uri(); ?>/assets/js/encode_link.js"></script>

<!--<script src="<?php echo get_template_directory_uri(); ?>/assets/js/download.js"></script>-->
<?php if($opt_themes['masking_link']){?>
<script>
//<![CDATA[
var uri=window.location.toString();if(uri.indexOf("/file/","/file/")>0){var clean_uri=uri.substring(0,uri.indexOf("/file/"));window.history.replaceState({},document.title,clean_uri)}
//]]>
</script>
<?php } ?>

<?php 
}

function fl_() { 
global $wpdb, $post, $opt_themes, $wp_query; 
?>  

<?php
}
