# Path: lambdainst/models.py
# def random_gift_code():
#     def is_paid(self):
#     def time_left(self):
#     def add_paid_time(self, time):
#     def give_trial_period(self):
#     def can_have_trial(self):
#     def remaining_trial_periods(self):
#     def on_payment_confirmed(self, payment):
#     def get_subscription(self, include_unconfirmed=False):
#     def __str__(self):
# def create_vpnuser(sender, instance, created, **kwargs):
#     def use_on(self, user):
#     def comment_head(self):
#     def __str__(self):
#     def __str__(self):
# class VPNUser(models.Model):
#     class Meta:
# class GiftCode(models.Model):
#     class Meta:
# class GiftCodeUser(models.Model):
#     class Meta:


from datetime import datetime, timedelta
from django.conf import settings
from .models import User
import re



class ReferrerMiddleware():
    def process_request(self, request):
        if 'ref' in request.GET:
            id = request.GET['ref']
        elif 'referrer' in request.COOKIES:
            id = request.COOKIES['referrer']
        else:
            return

        try:
            id = int(id.strip())
        except (ValueError, TypeError):
            return

        try:

# Path: lambdainst/models.py
# def random_gift_code():
#     def is_paid(self):
#     def time_left(self):
#     def add_paid_time(self, time):
#     def give_trial_period(self):
#     def can_have_trial(self):
#     def remaining_trial_periods(self):
#     def on_payment_confirmed(self, payment):
#     def get_subscription(self, include_unconfirmed=False):
#     def __str__(self):
# def create_vpnuser(sender, instance, created, **kwargs):
#     def use_on(self, user):
#     def comment_head(self):
#     def __str__(self):
#     def __str__(self):
# class VPNUser(models.Model):
#     class Meta:
# class GiftCode(models.Model):
#     class Meta:
# class GiftCodeUser(models.Model):
#     class Meta:


# Path: lambdainst/middleware.py
from datetime import datetime, timedelta
from django.conf import settings
from .models import User
import re




class ReferrerMiddleware():
    def process_request(self, request):
        if 'ref' in request.GET:
            id = request.GET['ref']
        elif 'referrer' in request.COOKIES:
            id = request.COOKIES['referrer']
        else:
            return

        try:
            id = int(id.strip())
        except (ValueError, TypeError):
            return

        try:

            u = User.objects.get(id=id)