Esempio n. 1
0
def get_check_code_image(request, image=APP_IMAGES + '/checkcode.gif'):
    import Image, ImageDraw, ImageFont, random
    logger2 = initlog()
    logger2.info("start get checkcode ..")
    font_file = APP_IMAGES + '/Arial.ttf'
    im = Image.open(image)
    draw = ImageDraw.Draw(im)
    mp = md5.new()
    mp_src = mp.update(str(datetime.now()))
    mp_src = mp.hexdigest()
    rand_str = mp_src[0:6]
    draw.text((10, 10),
              rand_str[0],
              font=ImageFont.truetype(font_file, random.randrange(25, 40)))
    draw.text((48, 10),
              rand_str[1],
              font=ImageFont.truetype(font_file, random.randrange(25, 40)))
    draw.text((85, 10),
              rand_str[2],
              font=ImageFont.truetype(font_file, random.randrange(25, 40)))
    draw.text((120, 10),
              rand_str[3],
              font=ImageFont.truetype(font_file, random.randrange(25, 40)))
    draw.text((150, 10),
              rand_str[4],
              font=ImageFont.truetype(font_file, random.randrange(25, 40)))
    draw.text((180, 10),
              rand_str[5],
              font=ImageFont.truetype(font_file, random.randrange(25, 40)))
    del draw
    request.session['checkcode'] = rand_str
    buf = cStringIO.StringIO()
    im.save(buf, 'gif')
    return HttpResponse(buf.getvalue(), 'image/gif')
Esempio n. 2
0
def get_check_code_image(request, image= APP_IMAGES+'/checkcode.gif'):
    import Image, ImageDraw, ImageFont, random
    logger2 = initlog()
    logger2.info("start get checkcode ..")
    font_file =  APP_IMAGES+'/Arial.ttf'
    im = Image.open(image)
    draw = ImageDraw.Draw(im)
    mp = md5.new()
    mp_src = mp.update(str(datetime.now()))
    mp_src = mp.hexdigest()
    rand_str = mp_src[0:6]
    draw.text((10,10), rand_str[0], font=ImageFont.truetype(font_file, random.randrange(25,40)))
    draw.text((48,10), rand_str[1], font=ImageFont.truetype(font_file, random.randrange(25,40)))
    draw.text((85,10), rand_str[2], font=ImageFont.truetype(font_file, random.randrange(25,40)))
    draw.text((120,10), rand_str[3], font=ImageFont.truetype(font_file, random.randrange(25,40)))
    draw.text((150,10), rand_str[4], font=ImageFont.truetype(font_file, random.randrange(25,40)))
    draw.text((180,10), rand_str[5], font=ImageFont.truetype(font_file, random.randrange(25,40)))
    del draw
    request.session['checkcode'] = rand_str
    buf = cStringIO.StringIO()
    im.save(buf, 'gif')
    return HttpResponse(buf.getvalue(),'image/gif')
Esempio n. 3
0
from django.db.models import Q
from django.core.urlresolvers import reverse
from django import forms
from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _
from django.forms.widgets import Select
from django.views.decorators.csrf import csrf_exempt

from proftpd.ftpadmin.lib.view_common import show_items, view_multiple_done, display_confirm_msg, get_model_html_output
from proftpd.ftpadmin.lib.ftp_info import proftpd_ctrls, proftpd_info
from proftpd.ftpadmin.settings import SITE_INTERFACE
from proftpd.ftpadmin.models.ftpusers import Ftpuser
from proftpd.ftpadmin.models.ftpgroups import Ftpgroup
from proftpd.ftpadmin.lib.common import initlog

logger2 = initlog()

FTP_SESSION_CLASS_CHOICES = (
    ('intranet', 'intranet'),
    ('eval', 'eval'),
)


def get_all_instance_name(model=None):
    all_name = []
    for instance in model.objects.all():
        all_name.append(instance.__unicode__())
    return all_name


def get_choices(v_array=[]):
Esempio n. 4
0
from django.core.urlresolvers import reverse
from django import forms
from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _
from django.forms.widgets import Select
from django.views.decorators.csrf import csrf_exempt

from proftpd.ftpadmin.lib.view_common import show_items, view_multiple_done, display_confirm_msg, get_model_html_output
from proftpd.ftpadmin.lib.ftp_info import proftpd_ctrls, proftpd_info
from proftpd.ftpadmin.settings import SITE_INTERFACE
from proftpd.ftpadmin.models.ftpusers import Ftpuser
from proftpd.ftpadmin.models.ftpgroups import  Ftpgroup
from proftpd.ftpadmin.lib.common import initlog


logger2 = initlog()

FTP_SESSION_CLASS_CHOICES = (
    ('intranet', 'intranet'),
    ('eval', 'eval'),
)

def get_all_instance_name(model=None):
    all_name = []
    for instance in model.objects.all():
        all_name.append( instance.__unicode__() )
    return all_name

def get_choices(v_array=[]):
    choices = []
    for v in v_array: