[insert_php] $yearly_rate = 25; //Member will be charged this for each extra year.
$years = $_GET['years'];
$price = doubleval($years) * $yearly_rate;
$desc = "Extend membership by $years years for $price CAD.";

$eot = s2member_eot();
$type = $eot['type']; //fixed, next, or blank. Only members with fixed expiration dates can extend membership.
$eot = $eot['time'];//unix timestamp. 0 if s2member doesn't have a fixed eot (happens if member paid by subscription)
$exptime = date_create( "@$eot" );
$today = date_create( date("Y-m-d") );
$diff = date_diff($exptime, $today);
$days = $diff->format("%a");
$enable = false;

if($type !== "fixed") {
echo 'You seem to have automatic membership renewal turned on with PayPal. If you want to switch to a fixed-length membership, please return to the Edit Profile page and turn off automatic renewals.';
else if($days / 365 + $years > 7) {
echo $days / 365 . " years + $years.\n";
echo "Unable to extend membership by $years years: membership cannot be extended over 5 years in the future.";
else {
echo 'Click the button below to complete your purchase of '. $years .' extra years of membership for '.$price.' CAD. Paypal will handle the transaction, but a Paypal account is not required. Purchase is non-refundable.';
$enable = true;