Premium Membership
Subscription graphics design php html youtube
Gold Subscription with Silver access
graphics design php html youtube
Live Support
Contact us by live help [photoshop, website design, tutorials]
Not available on weekends
Date expire for Subscribers


For those using the subscription module and would like to know how to calculate the time remaing for a user. The following codes will accomplish that.

Steps :
The first thing is to get the user id from cookies.
<?php
        
global $user$db$prefix;
        
cookiedecode($user);
        
$wsuserid$cookie[0]; 
        
?>

Now we have the userid inside the variable $wsuserid. We now need to query the subscription table to see if that user id exist and calculate the time. The following codes will accomplish that.

<?php
      $resultws_sub 
$db->sql_query("SELECT subscription_expire FROM ".$prefix."_subscriptions WHERE userid='$wsuserid'");
    while (
$row $db->sql_fetchrow($resultws_sub)) {
    
$wstime $row['subscription_expire'];//Places the expiration time within a variable
    
if($wstime ==""){//Checks if its blank
    
echo "you are not subscribed";//User will see this if they are not a subscriber.
    
}else{
    echo 
"Subscription expires<br>";//Text to let people know they are subscribed
    //Caculate expire date
$mydiff $wstime-time(); //we use the variable $wstime that contains the subscription period.
        
$myyearDiff floor($mydiff/60/60/24/365);
        
$mydiff -= $myyearDiff*60*60*24*365;
        if (
$myyearDiff 1) {
            
$mydiff $wstime-time();
        }
        
$mydaysDiff floor($mydiff/60/60/24);
        
$mydiff -= $mydaysDiff*60*60*24;
        
$myhrsDiff floor($mydiff/60/60);
        
$mydiff -= $myhrsDiff*60*60;
        
$myminsDiff floor($mydiff/60);
        
$mydiff -= $myminsDiff*60;
        
$mysecsDiff $mydiff;
        if (
$myyearDiff 1) {
            
$myrest "$mydaysDiff "._SBDAYS.", $myhrsDiff "._SBHOURS."";
        } elseif (
$myyearDiff == 1) {
            
$myrest "$myyearDiff "._SBYEAR.", $mydaysDiff "._SBDAYS."";
        } elseif (
$myyearDiff 1) {
            
$myrest "$myyearDiff "._SBYEARS.", $mydaysDiff "._SBDAYS."";
        }
        echo 
$myrest// after running all those codes we echo the result which is contained in $myrest
    
}
    }
      
?>
      

As you can see, it's pretty easy. The entire script should look like the following.

<?php
      
global $user$db$prefix;
      
cookiedecode($user);
      
$wsuserid$cookie[0];
      
$resultws_sub $db->sql_query("SELECT subscription_expire FROM ".$prefix."_subscriptions WHERE userid='$wsuserid'");
      while (
$row $db->sql_fetchrow($resultws_sub)) {
      
$wstime $row['subscription_expire'];//Places the expiration time within a variable
      
if($wstime ==""){//Checks if its blank
      
echo "you are not subscribed";//User will see this if they are not a subscriber.
      
}else{
      echo 
"Subscription expires<br>";//Text to let people know they are subscribed
      //Caculate expire date
      
$mydiff $wstime-time(); //we use the variable $wstime that contains the subscription period.
      
$myyearDiff floor($mydiff/60/60/24/365);
      
$mydiff -= $myyearDiff*60*60*24*365;
      if (
$myyearDiff 1) {
            
$mydiff $wstime-time();
        }
        
$mydaysDiff floor($mydiff/60/60/24);
        
$mydiff -= $mydaysDiff*60*60*24;
        
$myhrsDiff floor($mydiff/60/60);
        
$mydiff -= $myhrsDiff*60*60;
        
$myminsDiff floor($mydiff/60);
        
$mydiff -= $myminsDiff*60;
        
$mysecsDiff $mydiff;
        if (
$myyearDiff 1) {
            
$myrest "$mydaysDiff "._SBDAYS.", $myhrsDiff "._SBHOURS."";
        } elseif (
$myyearDiff == 1) {
            
$myrest "$myyearDiff "._SBYEAR.", $mydaysDiff "._SBDAYS."";
        } elseif (
$myyearDiff 1) {
            
$myrest "$myyearDiff "._SBYEARS.", $mydaysDiff "._SBDAYS."";
        }
    echo 
$myrest// after running all those codes we echo the result which is contained in $myrest
    //final results should say -->> Subscription expires 2 years, 35 days
    
}
    }
?>

That's all! You can now place those in any blocks or module that you want to display the expiration time for a nuke user.



Advertisement





New Subscribers



Subscriber

CubanoSiempre

Platinum Subscribers

#1
Subscriber

chefjustinh

Silver Subscribers

#2
Subscriber

ballistique

Silver Subscribers

#3
Subscriber

xplan

Silver Subscribers

#4
Subscriber

kenno

Ultimate Subscriber

#5




Our Sponsors



Advertise with Western Studios.net
Free e Cards of holidays, cute animals, nature and more
PHP Nuke themes, stock photos, icons, drupal themes and more.
Custom jobs at low cost, free lancers and service buyers.


Downloads



Latest in downloads

Most downloaded


Jobs





Community

Western Studios is an award winning website creating website disign and professional php scripts.

Associated Sites

Marketplace Themes, scripts, icons and images

Themes site PHP Nuke themes preview site.