#!/usr/bin/python import cgi import cgitb cgitb.enable() import xml.dom.minidom as minidom import urllib import BeautifulSoup site = "http://crschmidt.net/yadis/minidom" form = cgi.FieldStorage() if form.has_key('source'): print "Content-Type:text/plain" print "" print "" f = open("minidom.cgi") print f.read() f.close() elif form.has_key('address'): add = form['address'].value if (not add.startswith("http://")): address = "http://" + add else: address = add u = urllib.urlopen(address) if (u.info().getheader("Content-Type").startswith("application/rdf+xml")): pass else: soup = BeautifulSoup.BeautifulSoup(u.read()) for i in soup('link'): if (i.get("title") == "FOAF"): address = i.get("href") u = urllib.urlopen(i.get("href")) data = u.read() doc = minidom.parseString(data) server = doc.getElementsByTagNameNS("http://danga.com/yadis/vocab/1.0/#", "identityServer") s = server[0].childNodes[0].nodeValue addressarg = urllib.quote("?a=%s" % add) if ("?" in s): print "Location: %s&post_grant=return&return_to=%s%s&is_foaf=%s" % (s, site, addressarg, address) else: print "Location: %s?post_grant=return&return_to=%s%s&is_foaf=%s" % (s, site, addressarg, address) print "" print elif form.has_key('user_setup_url'): print "Content-Type: text/html" print "" print u = form['user_setup_url'].value print "
Verify this site, and you will be sent back here." elif form.has_key('assert_foaf'): print "Content-Type: text/html" print "" print print """You are a verified user. Assertion: %s, timestamp: %s """ % (form['assert_foaf'].value, form['assert_timestamp'].value) else: print "Content-Type: text/html" print "" print """ """