help me expert php about little bit php script of just 2 files and 3 or 4 lines code

Discussion in 'PHP' started by waqarrr, Apr 7, 2012.

  1. #1
    i wana little bit help about url encryption(md5) or any other ecryption i have two files

    1: index.php
    2: premium.php

    i want to access premium.php with url encryption like md5 or any other encryption with in index.php via iframe or any other method. if user directly access the premium.php file the message will show to user "Access Denied!". user can access premium.php via index.php directly without username and password . mean index.php show the data of premium.php in encryption format and url of premium.php in the index.php file also encrypted user cannot copy my link hope you understand and help me thank you so much

     
    waqarrr, Apr 7, 2012 IP
  2. geforce

    geforce Active Member

    Messages:
    173
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #2
    I would advise the following method.

    In your index.php file use the following code:

    
    $salt = "38149";
    $hash = md5( $salt );
    
    include "premium.php";
    
    PHP:
    In your premium.php use this code:

    
    if( $hash != md5( $salt ) )
    {
       echo "Access Denied";
    }
    else
    {
       echo "put your premium content here.";
    }
    
    PHP:
    That way if anyone goes to url.com/premium.php it will deny access. If they go to index.php they will be allowed to view premium.php.
    Hope it helps.
     
    geforce, Apr 10, 2012 IP
  3. waqarrr

    waqarrr Greenhorn

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #3
    Thank you so much for reply may you live long.... well dear respected sir is there possible my premium content also in encryption format if user check the page source there is show only encrypted format content. in actual i have a flash player with my ads i want user cannot access my video file without ads or cannot get actual video file link to post in their website and paste his own ad on it. i want user cannot access the original video link. user only iframe the video link and my ads on flash also going with that link. sorry my english is too bad hope you understand my logic
     
    waqarrr, Apr 10, 2012 IP
  4. geforce

    geforce Active Member

    Messages:
    173
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #4
    In your premium.php, the code I posted, if you put your content in the bit that says:


    echo "put your premium content here.";

    Example:


    
    if( $hash != md5( $salt ) )
    {
       echo "Access Denied";
    }
    else
    {
       // Here you can put your premium content.
    }
    
    
    PHP:
    Then if anyone tries and accesses your page without index.php they will get an access deined message.
     
    geforce, Apr 16, 2012 IP
  5. Arttu

    Arttu Member

    Messages:
    139
    Likes Received:
    2
    Best Answers:
    8
    Trophy Points:
    40
    #5
    Here's an example of how to make the url to work only once.

    index.php:
    
    <?php
    session_start();
    $secret = md5(rand(0,9999999));
    
    
    $_SESSION['secret'] = $secret;
    $premiumUrl = 'premium.php?s=' .$secret;
    
    echo '<iframe src="' .$premiumUrl. '"></iframe>';
    
    ?>
    
    PHP:
    premium.php:
    
    <?php
    session_start();
    $secret = $_GET['s'];
    
    if($_SESSION['secret']!=$secret)
    	die("access denied");
    session_destroy();
    ?>
    premium content here
    
    PHP:
     
    Arttu, Apr 16, 2012 IP
  6. waqarrr

    waqarrr Greenhorn

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #6
    Thank you so much respected Geforce & Arttu. Dear Arttu when i run index.php url show in iframe like this "http://localhost/premium/premium.php?" this link work only one time that's good thank you but there is a big problem when i use only link "http://localhost/premium/premium.php" without session id it shows the premium content directly. how can i fix it??
     
    waqarrr, Apr 17, 2012 IP
  7. Arttu

    Arttu Member

    Messages:
    139
    Likes Received:
    2
    Best Answers:
    8
    Trophy Points:
    40
    #7
    Sorry about that, this should work:
    
    <?php
    session_start();
    $secret = $_GET['s'];
    
    if($_SESSION['secret']!=$secret||empty($_SESSION['secret']))
    	die("access denied");
    session_destroy();
    ?>
    premium content
    
    Code (markup):
     
    Arttu, Apr 17, 2012 IP
  8. waqarrr

    waqarrr Greenhorn

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #8
    Thank you so much salute to you now its work fine


    "May you and your family live long"
     
    waqarrr, Apr 19, 2012 IP