Arborescence des pages

Comparaison des versions

Légende

  • Ces lignes ont été ajoutées. Ce mot a été ajouté.
  • Ces lignes ont été supprimées. Ce mot a été supprimé.
  • La mise en forme a été modifiée.

...

Bloc de code
languagepy
themeRDark
#!/usr/bin/python
# -*- coding: utf-8 -*-

import cgi

args = cgi.parse()

print "Content-type: application/json"
print

if 'locations' in args.keys():
    if args['eppn'][0] in ('bonamvin@univ-rouen.fr', 'lemaida3@univ-rouen.fr', 'esupdem@univ-rouen.fr', 'galaxco3@univ-rouen.fr'):
        print '["Esup Goodies"]'
    else:
        print '[]'

elif 'isTagable' in args.keys():
    print 'OK'

elif 'validateTag' in args.keys():
    print 'OK'

elif 'tagIdCheck' in args.keys():
    csn = args['csn'][0]
    alreadyChecked = False
    suffix = ''
    file = open('/var/www/log/goodies.txt',"r")
    for line in file:
        if csn==line.rstrip('\r\n'):
            alreadyChecked = True
            suffix = '[RE]'
    file.close()

    csnAsInt = int(csn, 16)
    modCsn = csnAsInt%85
    if modCsn in range(0,1):
        print('{"csn":"-", "eppn":"parapluie", "firstname":"%s", "lastname":"Parapluie !", "locations":"esup-goodies"}' % (suffix))
    elif modCsn in range(1,5):
        print('{"csn":"-", "eppn":"couteau", "firstname":"%s", "lastname":"Couteau !", "locations":"esup-goodies"}' % (suffix))
    elif modCsn in range(5,15):
        print('{"csn":"-", "eppn":"porte-cartes", "firstname":"%s", "lastname":" Porte cartes !", "locations":"esup-goodies"}' % (suffix))
    elif modCsn in range(15,45):
        print('{"csn":"-", "eppn":"mystere", "firstname":"%s", "lastname":"Goodies 20 ans !", "locations":"esup-goodies"}' % (suffix))
    # range(2845,5184):
    else : 
        print('{"csn":"-", "eppn":"porte-carte-simple", "firstname":"%s", "lastname":"Porte carte simple", "locations":"esup-goodies"}' % (suffix))

    if not alreadyChecked:
        file = open('/var/www/log/goodies.txt',"a")
        file.write(csn + "\n")
        file.close()

else:
    print '[]'

...