Counter Click or Total of Downloads DLE English

Downloads DLE English
Counter Click or Total of Downloads
Counter clicks on the button or number of downloads.

1. At the root of the site to create a folder called click_counter ask her permission to write 777.

2. It create a PHP file with the contents of index.php:
<?PHP
@error_reporting ( E_ALL ^ E_WARNING ^ E_NOTICE );
@ini_set ( 'error_reporting', E_ALL ^ E_WARNING ^ E_NOTICE );
@ini_set ( 'display_errors', true );
@ini_set ( 'html_errors', false );
define ( 'ROOT_DIR', dirname ( __FILE__ ) );

if(!$_GET['href']) die('Undefinded href');
$href = md5($_GET['href']);
$stat = unserialize(file_get_contents(ROOT_DIR."/stats.txt"));
if(!$stat[$href]) $stat[$href] = 0;
if($_GET['type']=='set'){
    $stat[$href]++;
    file_put_contents(ROOT_DIR. "/stats.txt", serialize($stat), LOCK_EX);
}
echo $stat[$href];
?>

3. We now turn to the template and JS handler. As a trigger for the desired button adds the class name click_count.
For example it was:
<a href="[xfields_download]">Download</a>

And to do so:
<a href="[xfields_download]" class="click_count">Download</a>

4. Staying Connected js, for this purpose, in principle any pattern connected to the JS file, you can insert the following code:
$(function(){
    function get_counter(a,b){
        $.get(dle_root+'click_counter/index.php',{type:b,href:a.attr('href')},function(d){
            a.find('.click_counter').html(d);
        });
    }
    var click_trigger = ".click_count";
    $(click_trigger).each(function(){
        $(this).append(" <span class='click_counter' title='Click'><img src='/click_counter/loading.gif' alt=''/></span>");
        get_counter($(this),'');
    });
    $('body').on("click",click_trigger,function(){
        get_counter($(this),'set');
    });
})

Done!
We should also mention - where and how the number itself will appear counter. On the example of the same html code that I quoted above, we get:
<a href="[xfields_download]" class="click_count">Download<span class='click_counter' title='Click'>0</span></a>

You just need to customize the style for the most number of counters.
Well, still, as you can see in the code, as long as the script is not processed as a plug used image /click_counter/loading.gif, you can either fill in your picture download anything at all clear picture of the code to you.

Version DLE: 9.x-10.x
Author: Sander

About the Author

Saya bagian dari CKD (pesakit buah pinggang kronik) selama 8 thn. siapa-siapa nak bantu saya untuk biaya Injection.boleh email saya. Click Profile

إرسال تعليق

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.