Login   Register  
PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Vincenzo Di Biaggio  >  PHP Digital Download Script  >  index.php  >  Download  
File: index.php
Role: Application script
Content type: text/plain
Description: Application script
Class: PHP Digital Download Script
Serve files for download with codes given to users
Author: By
Last change:
Date: 1 year ago
Size: 1,712 bytes
 

Contents

Class file image Download
<?php

include(__DIR__.'/digitalDownload.php');
use 
DigitalDownload\DigitalDownload;

$dd = new DigitalDownload();
$dd->install 0;
$dd->limitByHour 2;
$dd->limitNumDownload 5;

if (
== $dd->install)
{
    
$dd->installDigitalDownload();
}
else {
    
    
$random sha1(rand(1,64654654));
    
session_start();
    
$_SESSION['abracadabra'] = $random;
?>
<html>
    <head>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
        <link rel="stylesheet" type="text/css" href="htmlSrc/style.css">
        <title>Digital Download</title>
        
    </head>
    <body>
        <h2>Insert your code</h2>
        <form action="#" name="dd_form" id="dd_form">
            <input type="hidden" name="code" value="<?php echo $random;?>" />
            <input type="text" name="inputCode" value="...insert your code" />
            <input type="submit" value="Give me contents!" />    
        </form>
        <img id="loader" src="htmlSrc/ajax-loader.gif" alt="ajax loader" class="noDisplay"/>
        <div id="code_result"></div>
        <iframe id="frame" class="noDisplay"></iframe>
    </body>
    <script type="text/javascript">
        $('#dd_form').submit(function(e) {
            e.preventDefault();
            $('#loader').removeClass('noDisplay');
            $('#code_result').html('');
            $.ajax({
                data: $('#dd_form').serialize(),
                url: 'download.php',
                method:'post',
                success: function(data, msg, res){
                    var obj = $.parseJSON(data);
                    switch (res.status){
                        case 200:
                            $('#loader').addClass('noDisplay');
                            $('#code_result').html('Yeah :)');
                            $('#frame').attr('src', obj.message);
                            break;
                        default:
                            $('#loader').addClass('noDisplay');
                            $('#code_result').html(obj.message);
                            break;
                    }
                }
            });

        });
    </script>
</html>

<?php 
}
?>