def __init__(this): this.dbconnection = dbconnection.dbconnection() data = cgi.FieldStorage() print "Content-type: text/html\n" if data.has_key("do"): if ( data.has_key("roleid") and data.has_key("itemid") and data["do"].value == "setrole" ): # set roleid of itemid to data['roleid'] this.dbconnection.setrole(data["itemid"].value, data["roleid"].value) elif ( data.has_key("roleid") and data["do"].value == "removerole" ): # remove role id and set all roles with that id to -1 (none) this.dbconnection.removerole(data["roleid"].value) elif data["do"].value == "addrole": # add role # get user id of currently logged in user try: cookies = Cookie.SimpleCookie(os.environ["HTTP_COOKIE"]) userid = cookies["userid"].value except: return # add role roleid = this.dbconnection.addrole(userid, data["rolename"].value, data["rolecolor"].value) # add attrroles attrdata = [] for counter in range(10): if data.has_key("attr" + str(counter)): # turn params into array if ( data["attr" + str(counter)].value == "title" or data["attr" + str(counter)].value == "body" or data["attr" + str(counter)].value == "author" ): if data["comp" + str(counter)].value == "includes": # value = "%"+data['val'+str(counter)].value+"%" f**k it value = data["val" + str(counter)].value elif data["comp" + str(counter)].value == "equals": value = data["val" + str(counter)].value print roleid, (data["attr" + str(counter)].value, value) this.dbconnection.addattrrole(roleid, (data["attr" + str(counter)].value, value)) else: break elif data["do"].value == "editpositions": # edit role positions (order) this.dbconnection.editroleposition(data["roleid"].value, data["roleposition"].value) elif data["do"].value == "removefeed": # remove feed this.dbconnection.removefeed(data["feedid"].value) elif data["do"].value == "addfeed": # add feed # userid,feedtype,url,roleid,secureuser,securepass secureuser = "" securepass = "" roleid = "" if data.has_key("secureuser"): secureuser = data["secureuser"].value if data.has_key("securepass"): securepass = data["securepass"].value if data.has_key("roleid"): roleid = data["roleid"].value this.dbconnection.addfeed( data["userid"].value, data["feedtype"].value, data["feedurl"].value, roleid, secureuser, securepass )
def __init__(this): this.dbconnection = dbconnection.dbconnection() this.analysis = analysis.analysis() print "Content-type: text/html\n" try: cookies = Cookie.SimpleCookie(os.environ["HTTP_COOKIE"]) userid = cookies['userid'].value print this.update(userid) except Exception, e: print "error getdata: %s" %(e)
def __init__(this): this.dbconnection = dbconnection.dbconnection() this.html = [] try: cookies = Cookie.SimpleCookie(os.environ["HTTP_COOKIE"]) #build header this.html += ["Content-type: text/html\n"] this.html += ['''<html> <head> <title>InfoCentral</title> <script type='text/javascript' src='../js/jquery-1.4.4.min.js'></script> <script type='text/javascript' src='../js/jquery-ui-1.8.6.custom.min.js'></script> <script type='text/javascript' src='../jq/farbtastic/farbtastic.js'></script> <script type='text/javascript' src='../js/main.js'></script> <link rel='stylesheet' type='text/css' href='../css/ui-lightness/jquery-ui-1.8.6.custom.css' > <link rel='stylesheet' type='text/css' href='../css/main.css' > <link rel='stylesheet' type='text/css' href='../jq/farbtastic/farbtastic.css' > </head> <body>'''] #build content #get roles data #userid = 1 #testing only userid = int(cookies['userid'].value) roles = this.dbconnection.getroles(userid) feeds = this.dbconnection.getfeeds(userid) #make logout link this.html += ["<a id='logout' href='../src/logout.py'>Log Out</a>"] #make new items notice this.html += ["<div id='newitems'>"] this.html += ["Updated [3]"] this.html += ["</div>"] #make role selection dropdown this.html += ["<div id='roleselect'>"] this.html += [" <select name='roleid'>"] this.html += [" <option selected='' value=''>All Roles</option>"] for role in roles: this.html += [" <option value='%s'>%s</option>" %(role[0],role[2])] this.html += [" <option value='-1'>None</option>"] this.html += [" </select>"] this.html += ["</div>"] #make feeds controllor dialog this.html += ["<div id='feedslink'><a href='#'>Feeds</a></div>"] this.html += ["<div id='feeds' title='Feeds'>"] this.html += [" <ul>"] for feed in feeds: this.html += [" <li><img id='typeicon' src='../img/feedtype%s.gif' /><span id='url'>%s</span><span class='hidden'>%s</span><a id='remove' href='#'>[remove]</a></li>" %(feed[2],feed[1],feed[0])] this.html += [" </ul>"] this.html += [" <div id='addupdatefeed'>"] this.html += [" <span class='hidden'>%s</span>" %(userid)] this.html += [" Type:<select id='type' name='type'>"] this.html += [" <option value='0'>RSS/ATOM</option>"] this.html += [" <option value='1'>GMail</option>"] this.html += [" <option value='2'>GCal</option>"] this.html += [" </select>"] this.html += [" </br><label for='url'>URL:<input id='url' name='url' type='text' /></label>"] this.html += [" </br>Role (if applicable):<select id='roleid' name='roleid'"] this.html += [" <option selected='' value=''>None</option>"] for role in roles: this.html += [" <option value='%s'>%s</option>" %(role[0],role[2])] this.html += [" </select>"] this.html += [" </br>Login Info (if necessary):"] this.html += [" </br><label for='secureuser'>User:<input id='secureuser' name='secureuser' type='text' /></label>"] this.html += [" </br><label for='securepass'>Pass:<input id='securepass' name='securepass' type='text' /></label>"] this.html += [" </br><a id='submit' href='#'>Create Feed</a>"] this.html += [" </div>"] this.html += ["</div>"] #make roles controllor dialog this.html += ["<div id='roleslink'><a href='#'>Roles</a></div>"] this.html += ["<div id='roles' title='Roles'>"] this.html += [" <ol>"] for role in roles: this.html += [" <li><span class='hidden'>%s|#%s</span><img id='handle' src='../img/handle.gif'></img>%s<a id='remove' href='#'>[remove]</a></li>" %(role[0],role[3],role[2])] this.html += [" </ol>"] this.html += [" <div id='addupdaterole'>"] this.html += [" <label for='name'>Name:<input name='name' id='name' type='text' /></label>"] this.html += [" <div id='colorchoose'></div><label for='color'>Color:<input id='color' type='text' name='color' /></label>"] this.html += [" <div id='attrs'>"] this.html += [" Attributes:"] this.html += [" <div id='attr-0'>"] this.html += [" <select id='attr' name='attr'>"] this.html += [" <option value='title'>Title</option>"] this.html += [" <option value='body'>Body</option>"] this.html += [" <option value='author'>Author</option>"] this.html += [" </select>"] this.html += [" <select id='comparison' name='comparison'>"] this.html += [" <option value='equals'>Equals</option>"] this.html += [" <option value='includes'>Includes</option>"] this.html += [" </select>"] this.html += [" <input id='value' name='value' type='text' />"] this.html += [" </br><a id='showattr-1' href='#'>(+ another attribute)</a>"] this.html += [" </div>"] for i in range(10): this.html += [" <div id='attr-%s'>" %(i+1)] this.html += [" <select id='attr' name='attr'>"] this.html += [" <option value='title'>Title</option>"] this.html += [" <option value='body'>Body</option>"] this.html += [" <option value='author'>Author</option>"] this.html += [" </select>"] this.html += [" <select id='comparison' name='comparison'>"] this.html += [" <option value='equals'>Equals</option>"] this.html += [" <option value='includes'>Includes</option>"] this.html += [" </select>"] this.html += [" <input id='value' name='value' type='text' />"] if i < 9: this.html += [" </br><a id='showattr-%s' href='#'>(+ another attribute)</a>" %(i+2)] this.html += [" </div>"] this.html += [" </div>"] this.html += [" <a href='#' id='submit'>Create Role</a>"] this.html += [" </div>"] this.html += ['</div>'] #make tab bar from each feed this.html += ['''<div id='tabs'> <ul> <li><a href="view.py?of=-1"><span>All</span></a></li> <li><a href='view.py?of=1'><span>Email</span></a></li> <li><a href='view.py?of=2'><span>Calendar</span></a></li> <li><a href='view.py?of=0'><span>Articles</span></a></li> </ul>'''] this.html += ["<div id='moreitems'>"] this.html += [" <a href='#'>Get More Old Items</a>"] this.html += ["</div>"] #build footer this.html += ["</body>\n</html>"] #output print "\n".join(this.html) except: print "Location: ../src/index.py\n"
def __init__(this): this.dbconnection = dbconnection.dbconnection() this.html = [] try: cookies = Cookie.SimpleCookie(os.environ["HTTP_COOKIE"]) userid = int(cookies['userid'].value) this.html += ["Content-type: text/html\n"] this.html += ['''<html> <head> <link rel='stylesheet' type='text/css' href='../css/items.css' /> <script type='text/javascript' src='../js/items.js'></script> </head> <body>'''] #get parameters from GET getdata = cgi.FieldStorage() #get desired items from database dof = None dfor = None drecent = None dorderby = None haskey = False currentattrs = "" if getdata.has_key('of'): dof = getdata['of'] haskey = True currentattrs = "of="+getdata['of'].value if getdata.has_key('for'): dfor = getdata['for'] haskey = True if currentattrs != '': currentattrs = currentattrs+"&for="+getdata['for'].value else: currentattrs = "for="+getdata['for'].value if getdata.has_key('orderby'): dorderby = getdata['orderby'] if currentattrs != '': currentattrs = currentattrs+"&orderby="+getdata['orderby'].value else: currentattrs = "orderby="+getdata['orderby'].value haskey = True if getdata.has_key('recent'): drecent = getdata['recent'].value if currentattrs != '': currentattrs = currentattrs+"&recent="+getdata['recent'].value else: currentattrs = "recent="+getdata['recent'].value if not haskey: return items = this.dbconnection.getitems(userid,dof,dfor,dorderby,drecent) feedtypes = this.dbconnection.getfeedtypes() #userid = 1 #for testing purposes only roles = this.dbconnection.getroles(userid) this.html += ["<div id='items'>"] #put current url in hidden span this.html += [" <span id='hiddenurl' class='hidden'>view.py?%s</span>" %(currentattrs)] for item in items: #encode data in proper form itemtime = time.strftime("%I:%M%p - %b %d '%y",time.gmtime(float(item[7]))) if item[5].strip() == "": itemauthor = "" else: itemauthor = "From %s" %(item[5]) #display item this.html += ["<div id='item-%s'>" %(item[0])] this.html += [" <div id='header'>"] this.html += [" <img id='typeicon' src='../img/feedtype%s.gif' />" %(feedtypes[item[1]][0])] this.html += [" <a id='permalink' href='#item-%s'>#</a><a id='title' href='%s'>%s</a>"%(item[0],item[6],item[3])] this.html += [" <form action='#' method='post'>"] this.html += [" <select name='roleid'>"] #display role options beenselected = False for role in roles: if int(role[0]) == int(item[2]): selected = "selected=''" beenselected = True else: selected = "" this.html += [" <option %s value='%s|#%s'>%s</option>" %(selected,role[0],role[3],role[2])] if not beenselected: selected = "selected=''" else: selected = "" this.html += [" <option %s value='none|white'>None</option>" %(selected)] this.html += [" </select>"] this.html += [" </form>"] this.html += [" <span id='time'>%s</span>" %(itemtime)] this.html += [" </div>"] this.html += [" <div id='content'>"] this.html += [" <p>%s @ %s,</p>" %(itemauthor,itemtime)] this.html += [" <p>%s</p>" %(item[4])] this.html += [" </div>"] this.html += ["</div>"] numitems = len(items) this.html += [" <span id='hiddenrecent' class='hidden'>%s</span>" %(numitems)] this.html += ["</div>"] #add footer this.html += ['''</body> </html>'''] #output print '\n'.join(this.html) except: print "Location: ../src/index.py"
def __init__(this): this.dbconnection = dbconnection.dbconnection()