Exemple #1
0
    def get(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" %
                            (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        elif not distributors.authorized(
                self.request.headers['X-SecondLife-Owner-Key']):
            self.error(403)
        else:
            #get the deliveries where giverkey = key provided (this way we can still have multiple givers)
            giverkey = self.request.headers['X-SecondLife-Object-Key']
            pop = cgi.escape(
                self.request.get('pop')
            )  #true or false.  if true, then remove items from db on returning them

            deliveries = FreebieDelivery.gql("WHERE giverkey = :1", giverkey)
            #write each out in form <objname>|receiverkey
            response = ""
            for delivery in deliveries:
                #make sure the response is shorter than 2048.  If longer, then stop looping and set last line to "more", so giver will know to request again
                if len(response) > 2000:
                    response += "\nmore"
                    break
                else:
                    response += "%s|%s\n" % (delivery.itemname,
                                             delivery.rcptkey)
                    #delete from datastore
                    if pop == 'true':
                        delivery.delete()
            self.response.out.write(response)
Exemple #2
0
    def get(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" %
                            (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        else:
            #self.request.headers
            #look for an item with the requested name
            name = cgi.escape(self.request.get('object'))
            version = cgi.escape(self.request.get('version'))
            creator = cgi.escape(self.request.get('creator'))

            items = FreebieItem2.gql("WHERE name = :1 AND creator = :2", name,
                                     creator)
            item = items.get()
            if item is None:
                self.error(404)  #not found
            elif creator is None:
                self.error(400)  #invalid request
            else:
                if float(version) < float(item.version):
                    #get recipient key from http headers or request
                    rcpt = self.request.headers['X-SecondLife-Owner-Key']

                    #enqueue delivery, if queue does not already contain this delivery
                    name_version = "%s - %s" % (name, item.version)
                    delivery = FreebieDelivery(giverkey=item.giver,
                                               rcptkey=rcpt,
                                               itemname=name_version)
                    delivery.put()
                    self.response.set_status(202)  #accepted
                else:
                    self.response.set_status(204)  #no content
Exemple #3
0
 def get(self):
     if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
         self.error(403)
     elif self.request.headers['X-SecondLife-Shard'] != 'Production':
         logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
         self.response.set_status(305)
     elif not distributors.authorized(self.request.headers['X-SecondLife-Owner-Key']):
         self.error(403)
     else:        
         #get the deliveries where giverkey = key provided (this way we can still have multiple givers)
         giverkey = self.request.headers['X-SecondLife-Object-Key']
         pop = cgi.escape(self.request.get('pop'))#true or false.  if true, then remove items from db on returning them
         
         
         deliveries = FreebieDelivery.gql("WHERE giverkey = :1", giverkey)
         #write each out in form <objname>|receiverkey
         response = ""
         for delivery in deliveries:
             #make sure the response is shorter than 2048.  If longer, then stop looping and set last line to "more", so giver will know to request again
             if len(response) > 2000:
                 response += "\nmore"
                 break
             else:
                 response += "%s|%s\n" % (delivery.itemname, delivery.rcptkey)
                 #delete from datastore
                 if pop == 'true':
                     delivery.delete()
         self.response.out.write(response)        
Exemple #4
0
    def get(self):
        #check the big secret key
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" %
                            (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        elif not distributors.authorized(
                self.request.headers['X-SecondLife-Owner-Key']):
            self.error(403)
        else:
            self.response.headers['Content-Type'] = 'text/plain'
            name = cgi.escape(self.request.get('object'))
            version = cgi.escape(self.request.get('version'))
            giverkey = self.request.headers['X-SecondLife-Object-Key']
            creator = self.request.headers['X-SecondLife-Owner-Key']

            #look for an existing item with that name
            items = FreebieItem2.gql("WHERE name = :1 AND creator = :2", name,
                                     creator)
            item = items.get()
            if item is None:
                newitem = FreebieItem2(name=name,
                                       version=version,
                                       giver=giverkey,
                                       creator=creator)
                newitem.put()
            else:
                item.version = version
                item.giver = giverkey
                item.creator = creator
                item.put()
            self.response.set_status(202)  #accepted
    def post(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        elif not self.request.headers['X-SecondLife-Owner-Key'] in model.adminkeys:
            self.error(403)
        else:
            done_str = self.request.get('done')
            serverkey= self.request.headers['X-SecondLife-Object-Key']
            logging.info('Finalizing texture update from texture server %s' % (serverkey))
            if not done_str:
                logging.info ('Done not confirmed, something is seriously wrong')
                self.error(402)
            else:
                starttime=int(done_str)
                t=int(time.time())
                ts="%d" % t
                logging.info ('Cleaning all textures for server %s with timestamp below %d' % (serverkey, starttime))

                query = FreebieItem.gql("WHERE freebie_texture_serverkey = :1", serverkey)
                for record in query:
                    if record.freebie_texture_update < starttime:
                        logging.info ('Cleaned info for %s' % record.freebie_name)
                        record.freebie_texture_serverkey = ''
                        record.freebie_texture_update = -1
                        record.freebie_texture_key = ''
                        record.put()

                logging.info ('Version info stored: %s' % ts)
                model.GenericStorage_Store('TextureTime', ts)
                self.response.out.write('Version updated: %s' % ts)
Exemple #6
0
 def post(self):
     if lindenip.inrange(os.environ["REMOTE_ADDR"]) != "Production":
         self.error(403)
     elif self.request.headers["X-SecondLife-Shard"] != "Production":
         logging.warning("Attempt while on beta grid %s" % (self.request.headers["X-SecondLife-Shard"]))
         self.response.set_status(305)
     else:
         av = self.request.headers["X-SecondLife-Owner-Key"]
         if not distributors.distributor_authorized(
             av
         ):  # function needs to be changed to distributors.authorized_designer as soon as the database for that is fully functioning
             self.error(402)
         else:
             objectkey = self.request.headers["X-SecondLife-Object-Key"]
             public = self.request.get("Public")
             version = self.request.get("tv")
             current_version = model.GenericStorage_GetOrPutDefault("TextureTime", "0")
             logging.info(
                 "Texture request from vendor with version %s, db at version %s" % (version, current_version)
             )
             if version:
                 if current_version != version:
                     self.response.out.write("UPDATE:%s" % current_version)
                 else:
                     self.response.out.write("CURRENT")
Exemple #7
0
    def get(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        else:
            groupKey = self.request.get('group')
            uplook_url = 'http://world.secondlife.com/group/%s' % groupKey
            answer = urlfetch.fetch(uplook_url,
                                    method="GET",
                                    follow_redirects=True)
            if answer.status_code == 200:
                body = answer.content
                if 'AccessDenied' in body:
                    logging.info('Group not found: %s' % groupKey)
                    self.response.out.write('X')
                else:
                    startpos = string.find(body, "<title>") + 7
                    endpos = string.find(body, "</title>")

                    groupname = body[startpos:endpos]
                    logging.info('Group name for %s resolved: %s' %
                                 (groupKey, groupname))
                    self.response.out.write(groupname)

            else:
                logging.info('Error on group lookup answer: %d' %
                             answer.status_code)
                self.response.out.write('X')
Exemple #8
0
    def post(self):
        if lindenip.inrange(os.environ["REMOTE_ADDR"]) != "Production":
            self.error(403)
        elif self.request.headers["X-SecondLife-Shard"] != "Production":
            logging.warning("Attempt while on beta grid %s" % (self.request.headers["X-SecondLife-Shard"]))
            self.response.set_status(305)
        elif not self.request.headers["X-SecondLife-Owner-Key"] in model.adminkeys:
            self.error(403)
        else:
            done_str = self.request.get("done")
            serverkey = self.request.headers["X-SecondLife-Object-Key"]
            logging.info("Finalizing texture update from texture server %s" % (serverkey))
            if not done_str:
                logging.info("Done not confirmed, something is seriously wrong")
                self.error(402)
            else:
                starttime = int(done_str)
                t = int(time.time())
                ts = "%d" % t
                logging.info("Cleaning all textures for server %s with timestamp below %d" % (serverkey, starttime))

                query = FreebieItem.gql("WHERE freebie_texture_serverkey = :1", serverkey)
                for record in query:
                    if record.freebie_texture_update < starttime:
                        logging.info("Cleaned info for %s" % record.freebie_name)
                        record.freebie_texture_serverkey = ""
                        record.freebie_texture_update = -1
                        record.freebie_texture_key = ""
                        record.put()

                logging.info("Version info stored: %s" % ts)
                model.GenericStorage_Store("TextureTime", ts)
                self.response.out.write("Version updated: %s" % ts)
Exemple #9
0
 def post(self):
     #check linden IP  and allowed avs
     logging.info('Alarm URL')
     if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
         self.error(403)
     elif self.request.headers['X-SecondLife-Shard'] != 'Production':
         logging.warning("Attempt while on beta grid %s" %
                         (self.request.headers['X-SecondLife-Shard']))
         self.response.set_status(305)
     elif not self.request.headers[
             'X-SecondLife-Owner-Key'] in model.adminkeys:
         logging.warning(
             "Illegal attempt to set alarm URL from %s, box %s located in %s at %s"
             % (self.request.headers['X-SecondLife-Owner-Name'],
                self.request.headers['X-SecondLife-Object-Name'],
                self.request.headers['X-SecondLife-Region'],
                self.request.headers['X-SecondLife-Local-Position']))
         self.error(403)
     else:
         alarmurl = self.request.body
         alarm = AppSettings(key_name="alarmurl", value=alarmurl)
         alarm.put()
         memcache.set('alarmurl', alarmurl)
         logging.info('Alarm URL set to %s' % alarmurl)
         self.response.out.write('Added')
Exemple #10
0
 def get(self):
     if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
         self.error(403)
     elif self.request.headers['X-SecondLife-Shard'] != 'Production':
         logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
         self.response.set_status(305)
     else:        
         #self.request.headers
         #look for an item with the requested name
         name = cgi.escape(self.request.get('object'))    
         version = cgi.escape(self.request.get('version'))
         creator = cgi.escape(self.request.get('creator'))
                      
         items = FreebieItem2.gql("WHERE name = :1 AND creator = :2", name, creator)
         item = items.get()   
         if item is None:
             self.error(404)#not found
         elif creator is None:
             self.error(400)#invalid request
         else:
             if float(version) < float(item.version):
                 #get recipient key from http headers or request
                 rcpt = self.request.headers['X-SecondLife-Owner-Key']
                 
                 #enqueue delivery, if queue does not already contain this delivery
                 name_version = "%s - %s" % (name, item.version)
                 delivery = FreebieDelivery(giverkey = item.giver, rcptkey = rcpt, itemname = name_version)
                 delivery.put()
                 self.response.set_status(202)#accepted
             else:
                 self.response.set_status(204)#no content  
Exemple #11
0
    def get(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" %
                            (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        else:
            self.response.headers['Content-Type'] = 'text/plain'
            #look for an item with the requested name
            name = cgi.escape(self.request.get('object'))
            version = cgi.escape(self.request.get('version'))
            update = cgi.escape(self.request.get('update'))

            #logging.info('%s checked %s version %s' % (self.request.headers['X-SecondLife-Owner-Name'], name, version))

            item = tools.get_item(name, True)
            if item is None:
                self.response.out.write("NSO %s" % (name))
                return
            if item['baseprice'] > 0:
                self.response.out.write("NSO %s" % (name))
                logging.error(
                    'Rejecting request: Regquesting a paid item using the update check url by %s, vendor %s located in %s at %s. Item:%s'
                    % (self.request.headers['X-SecondLife-Owner-Name'],
                       self.request.headers['X-SecondLife-Object-Name'],
                       self.request.headers['X-SecondLife-Region'],
                       self.request.headers['X-SecondLife-Local-Position'],
                       name))
                return
            logging.debug('baseprice:%s' % item['baseprice'])
            thisversion = 0.0
            try:
                thisversion = float(version)
            except ValueError:
                avname = self.request.headers['X-SecondLife-Owner-Name']
                logging.error(
                    '%s is using %s with bad version "%s" and will be sent an update'
                    % (avname, name, version))

            if thisversion < float(item['version']):
                #get recipient key from http headers or request
                rcpt = self.request.headers['X-SecondLife-Owner-Key']

                #enqueue delivery, if queue does not already contain this delivery
                name_version = "%s - %s" % (name, item['version'])
                if update != "no":
                    if tools.enqueue_delivery(item['giver'], rcpt,
                                              name_version,
                                              self.request.host_url) == False:
                        self.error(403)
                #queue = FreebieDelivery.gql("WHERE rcptkey = :1 AND itemname = :2", rcpt, name_version)
                #if queue.count() == 0:
                #    delivery = FreebieDelivery(giverkey = item.freebie_giver, rcptkey = rcpt, itemname = name_version)
                #    delivery.put()
                #in the future return null key instead of giver's key
                self.response.out.write("%s|%s - %s" %
                                        (null_key, name, item['version']))
            else:
                self.response.out.write('current')
Exemple #12
0
    def get(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
#        elif not distributors.Distributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
#            logging.info("Illegal attempt to request an item from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
#            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        else:
            #should be newline-delimited, token=value
#            lines = self.request.body.split('\n')
#            params = {}
#            for line in lines:
#                params[line.split('=')[0]] = line.split('=')[1]
            try:
                recordID = int(self.request.get('id'))
                record = Purchases.get_by_id(recordID)
                if record is None:
                    #could not find item to look up its deliverer.  return an error
                    logging.error('Error, Paid record %s not found. Requested by %s using %s.' % (recordID, self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name']))
                    self.error(404)
                    return
                elif record.item_reciver == self.request.headers['X-SecondLife-Owner-Key']:
                    rcpt = record.item_reciver
                    name = record.item
                    self.response.out.write(tools.httpin_delivery(self, rcpt, name, record.key().id()))
                else:
                    logging.error('Error, Paid record %s found but requested by %s using %s and it is set for %s.' % (recordID, self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], record.item_reciver))
                    self.error(403)
            except KeyError:
                logging.error('Key error for paid PUT gift receive vendor %s, queue entry: %s|%s   %s' % (self.request.headers['X-SecondLife-Object-Key'], rcpt, name, sys.exc_info()))
                self.error(403)        
Exemple #13
0
 def get(self):
     #check that we're coming from an LL ip
     if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
         self.error(403)
     elif self.request.headers['X-SecondLife-Shard'] != 'Production':
         logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
         self.response.set_status(305)
     else:
         av = self.request.headers['X-SecondLife-Owner-Key']
         avname = self.request.headers['X-SecondLife-Owner-Name']
         if avname != "(Loading...)":
             relations.update_av(av, avname)            
         #get all relations for which av is owner or secowner
         subdict = {}
         ownersubs = relations.getby_subj_type(av, 'owns')
         for sub in ownersubs:
             id = sub.obj_id
             if id not in subdict:
                 subdict[id] = relations.key2name(id)
             else:
                 #delete duplicates
                 sub.delete()
             
         secownersubs = relations.getby_subj_type(av, 'secowns')
         for sub in secownersubs:
             id = sub.obj_id
             if id not in subdict:#since you can be both an owner and a secowner, ignore those here already in the owner list
                 subdict[id] = relations.key2name(id)
                 
         out = ''
         for sub in subdict:
             out += '%s,%s,' % (sub, subdict[sub])
         self.response.out.write(out.rstrip(','))
Exemple #14
0
 def post(self):
     if lindenip.inrange(os.environ["REMOTE_ADDR"]) != "Production":
         self.error(403)
     elif self.request.headers["X-SecondLife-Shard"] != "Production":
         logging.warning("Attempt while on beta grid %s" % (self.request.headers["X-SecondLife-Shard"]))
         self.response.set_status(305)
     elif not self.request.headers["X-SecondLife-Owner-Key"] in model.adminkeys:
         self.error(403)
     else:
         t = int(time.time())
         serverkey = self.request.headers["X-SecondLife-Object-Key"]
         logging.info("Texture update started from texture server %s at %d" % (serverkey, t))
         # Setting texture time to negative time to signalize texure update is in progress
         currentVersion = int(model.GenericStorage_GetOrPutDefault("TextureTime", "0"))
         if currentVersion < 0:
             if -currentVersion + updateTimeout < t:
                 logging.warning(
                     "Texture update timestamp was outdated, allowing texture update (Old timestamp: %d)"
                     % currentVersion
                 )
             else:
                 logging.warning(
                     "Texture update requested from texture server %s at %d, but already in progress"
                     % (serverkey, t)
                 )
                 self.response.out.write("Update already in progress, try again later")
                 return
         logging.info("Texture update started from texture server %s at %d" % (serverkey, t))
         model.GenericStorage_Store("TextureTime", "-%d" % t)
         self.response.out.write("Timestamp:%d" % t)
Exemple #15
0
 def get(self):
     #check the big secret key    
     if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
         self.error(403)
     elif self.request.headers['X-SecondLife-Shard'] != 'Production':
         logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
         self.response.set_status(305)
     elif not distributors.authorized(self.request.headers['X-SecondLife-Owner-Key']):
         self.error(403)
     else:
         self.response.headers['Content-Type'] = 'text/plain'            
         name = cgi.escape(self.request.get('object'))    
         version = cgi.escape(self.request.get('version'))
         giverkey = self.request.headers['X-SecondLife-Object-Key']
         creator = self.request.headers['X-SecondLife-Owner-Key']
         
         #look for an existing item with that name
         items = FreebieItem2.gql("WHERE name = :1 AND creator = :2", name, creator)
         item = items.get()
         if item is None:            
             newitem = FreebieItem2(name = name, version = version, giver = giverkey, creator = creator)
             newitem.put()
         else:
             item.version = version
             item.giver = giverkey
             item.creator = creator
             item.put()
         self.response.set_status(202)#accepted
Exemple #16
0
    def get(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" %
                            (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        elif not distributors.Contributor_authorized(
                self.request.headers['X-SecondLife-Owner-Key']):
            logging.warning(
                "Illegal attempt to check for item from %s, box %s located in %s at %s"
                % (self.request.headers['X-SecondLife-Owner-Name'],
                   self.request.headers['X-SecondLife-Object-Name'],
                   self.request.headers['X-SecondLife-Region'],
                   self.request.headers['X-SecondLife-Local-Position']))
            self.error(403)
        else:
            # get the deliveries where giverkey = key provided (this way we can
            # still have multiple givers)
            giverkey = self.request.headers['X-SecondLife-Object-Key']
            givername = self.request.headers['X-SecondLife-Object-Name']

            # true or false.  if true, then remove items from db on returning them
            pop = cgi.escape(self.request.get('pop'))

            avname = self.request.headers['X-SecondLife-Owner-Name']
            logging.info('%s (%s) from %s checked' %
                         (givername, giverkey, avname))

            # to enable/disable the update routine fast, only need to update old records
            if (False):
                timestring = datetime.datetime.utcnow()
                location = '%s @ %s' % (
                    self.request.headers['X-SecondLife-Region'],
                    self.request.headers['X-SecondLife-Local-Position'])

                query = FreebieItem.gql("WHERE freebie_giver = :1", giverkey)
                for record in query:
                    record.freebie_owner = avname
                    record.freebie_timedate = timestring
                    record.freebie_location = location
                    record.put()
                    logging.info('Updated %s from %s' %
                                 (record.freebie_name, avname))

            #deliveries = FreebieDelivery.gql("WHERE giverkey = :1", giverkey)
            token = "deliveries_%s" % giverkey
            deliveries = memcache.get(token)
            if deliveries is not None:
                response = ""
                #take the list of lists and format it
                #write each out in form <objname>|receiverkey, one per line
                out = '\n'.join(['|'.join(x) for x in deliveries])
                self.response.out.write(out)
                logging.info('%s got delivery string\n%s' % (givername, out))
                memcache.delete(token)
            else:
                self.response.out.write('')
Exemple #17
0
    def post(self):
        #check linden IP  and allowed avs
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
#        elif not distributors.Distributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
#            logging.info("Illegal attempt to request an item from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
#            self.error(403)
        elif not db.WRITE_CAPABILITY.is_enabled():
            self.response.set_status(503)
            self.response.headders['Retry-After'] = 120
            logging.info("Told that the db was down for maintenance to %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
            self.response.out.write('Currently down for maintenance')
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]

            try:
                name = params['objname']
                item = tools.get_item(name, True)
                if item is None:
                    #could not find item to look up its deliverer.  return an error
                    logging.error('Error, Paid item %s not found. Requested by %s using %s.' % (name, self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name']))
                    self.error(403)
                    return
                name_version = "%s - %s" % (name, item['version'])
                rcpt = self.request.headers['X-SecondLife-Owner-Key']
                paid = int(params['paid'])
                baseprice = int(item['baseprice'])
                if paid >= baseprice:
                    pass
                else:

                            logging.error('Rejecting request: Wrong price by %s, gift vendor %s located in %s at %s. Item:%s Item Price:%s Price Paid:%s' % 
                              (self.request.headers['X-SecondLife-Owner-Name'],
                               self.request.headers['X-SecondLife-Object-Name'],
                               self.request.headers['X-SecondLife-Region'],
                               self.request.headers['X-SecondLife-Local-Position'],
                               name,
                               baseprice,
                               paid
                               ))
                            self.error(403)
                            return  
                #need to record record here
                record = Purchases(purchaser = rcpt, item = name, seller = self.request.headers['X-SecondLife-Owner-Key'], item_reciver = 'gift request', loc = '%s %s' % (self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']), vender_name = self.request.headers['X-SecondLife-Object-Name'], amount_paid = paid)
                record.put()
                #have the vendor transfer the money
                self.response.out.write('pay|%s|%s|%s|%s|%s' % (moneyRcpt, paid, rcpt, name, record.key().id()))#do we need all of this?
            except KeyError:
                logging.error('Key error for paid Post gift vendor  %s, queue entry: %s|%s   %s' % (item['giver'], rcpt, name_version, sys.exc_info()))
                self.error(403)
Exemple #18
0
    def post(self):
        if lindenip.inrange(os.environ["REMOTE_ADDR"]) != "Production":
            self.error(403)
        elif self.request.headers["X-SecondLife-Shard"] != "Production":
            logging.warning("Attempt while on beta grid %s" % (self.request.headers["X-SecondLife-Shard"]))
            self.response.set_status(305)
        else:
            av = self.request.headers["X-SecondLife-Owner-Key"]
            objectkey = self.request.headers["X-SecondLife-Object-Key"]
            sim_id = self.request.headers["X-SecondLife-Region"]
            logging.info("Bought items request from %s in sim %s" % (av, sim_id))

            # if paid_items == '':
            #    paid_items = '0'
            # if tags == '':
            #   tags = 'all'
            # tags = tags.split('|')
            body = self.request.body
            # Use a query parameter to keep track of the last key of the last
            # batch, to know where to start the next batch.
            last_key_str = self.request.get("start")
            last_version_str = self.request.get("last_version")
            last_version = int(last_version_str)
            current_version = int(model.GenericStorage_GetOrPutDefault("TextureTime", "0"))
            # normal work mode, lets do check and send texture
            result = ""
            logging.info(
                "Versions different (DB:%s,Vendor:%s) Starting to send update..." % (current_version, last_version_str)
            )
            if not last_key_str:
                last_key = 0
                result = "version\n%s\n" % current_version
                logging.info("no last_key, send from start")
            else:
                last_key = int(last_key_str)
                result = "continue\n%s\n" % current_version
                logging.info("last_key was: %s" % last_key_str)
            query = Purchases.all()
            query.filter("item_reciver =", av)
            entities = query.fetch(21, last_key)
            count = 0
            more = False
            for texture in entities:
                count = count + 1
                if count < 21:
                    logging.info("%s:%d" % (texture.freebie_name, texture.freebie_texture_update))
                    result = result + texture.freebie_name + "\n" + texture.freebie_texture_key + "\n"
                else:
                    last_key = last_key + 20
                    result = result + ("startwith\n%d" % (last_key))
                    more = True
                    logging.info("More texture availabe, request next time from %d" % (last_key))
            if more == False:
                logging.info("Sending finished now")
                result = result + "end\n"
            self.response.out.write(result)
Exemple #19
0
    def put(self):
        #check linden IP  and allowed avs
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)


#        elif not distributors.Distributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
#            logging.info("Illegal attempt to request an item from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
#            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" %
                            (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        elif not db.WRITE_CAPABILITY.is_enabled():
            self.response.set_status(503)
            self.response.headders['Retry-After'] = 120
            logging.info(
                "Told that the db was down for maintenance to %s, box %s located in %s at %s"
                % (self.request.headers['X-SecondLife-Owner-Name'],
                   self.request.headers['X-SecondLife-Object-Name'],
                   self.request.headers['X-SecondLife-Region'],
                   self.request.headers['X-SecondLife-Local-Position']))
            self.response.out.write('Currently down for maintenance')
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]

            try:
                recordID = int(params['id'])
                record = Purchases.get_by_id(recordID)
                if record is None:
                    #could not find item to look up its deliverer.  return an error
                    logging.error(
                        'Error, Paid record %s not found. Requested by %s using %s.'
                        % (recordID,
                           self.request.headers['X-SecondLife-Owner-Name'],
                           self.request.headers['X-SecondLife-Object-Name']))
                    self.error(403)
                    return
                #else:
                record.item_reciver = 'gift'
                record.accounted = "0"
                record.put()
                self.response.out.write('confirmed|||%s' % (recordID))
            except KeyError:
                logging.error(
                    'Key error for paid PUT gift vendor %s, queue entry: %s|%s   %s'
                    % (self.request.headers['X-SecondLife-Object-Key'],
                       record.item_reciver, recordID, sys.exc_info()))
                self.error(403)
Exemple #20
0
    def get(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        else:
            self.response.headers['Content-Type'] = 'text/plain'
            #look for an item with the requested name
            name = cgi.escape(self.request.get('object'))
            version = cgi.escape(self.request.get('version'))
            update = cgi.escape(self.request.get('update'))

            #logging.info('%s checked %s version %s' % (self.request.headers['X-SecondLife-Owner-Name'], name, version))

            item = tools.get_item(name, True)
            if item is None:
                self.response.out.write("NSO %s" % (name))
                return
            if item['baseprice'] > 0:
                    self.response.out.write("NSO %s" % (name))
                    logging.error('Rejecting request: Regquesting a paid item using the update check url by %s, vendor %s located in %s at %s. Item:%s' % 
                              (self.request.headers['X-SecondLife-Owner-Name'],
                               self.request.headers['X-SecondLife-Object-Name'],
                               self.request.headers['X-SecondLife-Region'],
                               self.request.headers['X-SecondLife-Local-Position'],
                               name
                               ))
                    return
            logging.debug('baseprice:%s' % item['baseprice'])
            thisversion = 0.0
            try:
                thisversion = float(version)
            except ValueError:
                avname = self.request.headers['X-SecondLife-Owner-Name']
                logging.error('%s is using %s with bad version "%s" and will be sent an update' % (avname, name, version))

            if thisversion < float(item['version']):
                #get recipient key from http headers or request
                rcpt = self.request.headers['X-SecondLife-Owner-Key']

                #enqueue delivery, if queue does not already contain this delivery
                name_version = "%s - %s" % (name, item['version'])
                if update != "no":
                    if tools.enqueue_delivery(item['giver'], rcpt, name_version, self.request.host_url)==False:
                        self.error(403)
                #queue = FreebieDelivery.gql("WHERE rcptkey = :1 AND itemname = :2", rcpt, name_version)
                #if queue.count() == 0:
                #    delivery = FreebieDelivery(giverkey = item.freebie_giver, rcptkey = rcpt, itemname = name_version)
                #    delivery.put()
                #in the future return null key instead of giver's key
                self.response.out.write("%s|%s - %s" % (null_key, name, item['version']))
            else:
                self.response.out.write('current')
Exemple #21
0
    def post(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        else:
            av=self.request.headers['X-SecondLife-Owner-Key']
            objectkey=self.request.headers['X-SecondLife-Object-Key']
            sim_id = self.request.headers['X-SecondLife-Region']
            logging.info('Bought items request from %s in sim %s' % (av, sim_id))

            #if paid_items == '':
            #    paid_items = '0'
            #if tags == '':
            #   tags = 'all'
            #tags = tags.split('|')
            body = self.request.body
            # Use a query parameter to keep track of the last key of the last
            # batch, to know where to start the next batch.
            last_key_str = self.request.get('start')
            last_version_str = self.request.get('last_version')
            last_version = int(last_version_str)
            current_version = int(model.GenericStorage_GetOrPutDefault('TextureTime', '0'))
            # normal work mode, lets do check and send texture
            result =''
            logging.info ('Versions different (DB:%s,Vendor:%s) Starting to send update...' % (current_version, last_version_str))
            if not last_key_str:
                last_key = 0
                result ='version\n%s\n' % current_version
                logging.info ('no last_key, send from start')
            else:
                last_key=int(last_key_str)
                result ='continue\n%s\n' % current_version
                logging.info ('last_key was: %s' % last_key_str)
            query = Purchases.all()
            query.filter('item_reciver =', av)
            entities = query.fetch(21,last_key)
            count = 0
            more = False
            for texture in entities:
                count = count + 1
                if count < 21:
                    logging.info('%s:%d' % (texture.freebie_name,texture.freebie_texture_update))
                    result=result + texture.freebie_name +"\n"+texture.freebie_texture_key+"\n"
                else:
                    last_key=last_key+20
                    result=result + ("startwith\n%d" % (last_key))
                    more = True
                    logging.info ('More texture availabe, request next time from %d' % (last_key))
            if more == False:
                logging.info ('Sending finished now')
                result = result + "end\n"
            self.response.out.write(result)
Exemple #22
0
    def post(self):
        #check linden IP  and allowed avs
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        elif not distributors.Distributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
            logging.info("Illegal attempt to request an item from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
            self.error(403)
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]

            try:
                name = params['objname']
                item = tools.get_item(name, True)
                if item is None:
                    #could not find item to look up its deliverer.  return an error
                    logging.error('Error, freebie %s not found. Requested by %s using %s.' % (name, self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name']))
                    self.error(403)
                    return
                # Support new 3.7x collars that have no version in the name.
                if item['version'] == 'NOVERSION':
                    name_version = name
                else:
                    name_version = "%s - %s" % (name, item['version'])
                rcpt = str(params['rcpt'])
                if item['baseprice'] > 0:
                    self.response.out.write("NSO %s" % (name))
                    logging.error('Rejecting request: Regquesting a paid item using the free url by %s, vendor %s located in %s at %s. Item:%s Rcpt:%s' % 
                              (self.request.headers['X-SecondLife-Owner-Name'],
                               self.request.headers['X-SecondLife-Object-Name'],
                               self.request.headers['X-SecondLife-Region'],
                               self.request.headers['X-SecondLife-Local-Position'],
                               name,
                               rcpt
                               ))
                    return
                
                if tools.enqueue_delivery(item['giver'], rcpt, name_version, self.request.host_url):
                    self.response.out.write('%s|%s' % (rcpt, name_version))
                    count_token = 'item_count_%s' % name
                    memcache.incr(count_token, initial_value=0)
                else:
                    logging.error('Enqueing failed for vendor %s, queue entry: %s|%s' % (item['giver'], rcpt, name_version))
                    self.error(403)
            except KeyError:
                logging.error('Key error for vendor %s, queue entry: %s|%s' % (item['giver'], rcpt, name_version))
                self.error(403)
Exemple #23
0
 def post(self):
     #check that we're coming from an LL ip
     if not lindenip.inrange(os.environ['REMOTE_ADDR']):
         self.error(403)
     elif not self.request.headers['X-SecondLife-Owner-Key'] in model.adminkeys:
         self.error(403)
     else:
         lines = self.request.body.split('\n')
         params = {}
         for line in lines:
             params[line.split('=')[0]] = line.split('=')[1]
         logging.info('Info receided from SL, now storing %s with key %s' % (params['name'], params['key']))
         relations.update_av(params['key'], params['name'])
Exemple #24
0
 def put(self):
     if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
         self.error(403)
     else:
         av = self.request.headers['X-SecondLife-Owner-Key']
         if av in tools.adminkeys:
             #save the notice
             title = urllib.unquote(self.request.path.split("/")[-1])
             article = Article(title = title, author = av, text = self.request.body, dts = datetime.datetime.now())
             article.put()
             self.response.out.write('Saved article %s:\n%s' % (article.key(), format_article(article)))
         else:
             self.error(403)
Exemple #25
0
    def get(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)


#        elif not distributors.Distributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
#            logging.info("Illegal attempt to request an item from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
#            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" %
                            (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        else:
            #should be newline-delimited, token=value
            #            lines = self.request.body.split('\n')
            #            params = {}
            #            for line in lines:
            #                params[line.split('=')[0]] = line.split('=')[1]
            try:
                recordID = int(self.request.get('id'))
                record = Purchases.get_by_id(recordID)
                if record is None:
                    #could not find item to look up its deliverer.  return an error
                    logging.error(
                        'Error, Paid record %s not found. Requested by %s using %s.'
                        % (recordID,
                           self.request.headers['X-SecondLife-Owner-Name'],
                           self.request.headers['X-SecondLife-Object-Name']))
                    self.error(404)
                    return
                elif record.item_reciver == self.request.headers[
                        'X-SecondLife-Owner-Key']:
                    rcpt = record.item_reciver
                    name = record.item
                    self.response.out.write(
                        tools.httpin_delivery(self, rcpt, name,
                                              record.key().id()))
                else:
                    logging.error(
                        'Error, Paid record %s found but requested by %s using %s and it is set for %s.'
                        % (recordID,
                           self.request.headers['X-SecondLife-Owner-Name'],
                           self.request.headers['X-SecondLife-Object-Name'],
                           record.item_reciver))
                    self.error(403)
            except KeyError:
                logging.error(
                    'Key error for paid PUT gift receive vendor %s, queue entry: %s|%s   %s'
                    % (self.request.headers['X-SecondLife-Object-Key'], rcpt,
                       name, sys.exc_info()))
                self.error(403)
Exemple #26
0
    def post(self):
        #check linden IP  and allowed avs`
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" %
                            (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        elif not distributors.Contributor_authorized(
                self.request.headers['X-SecondLife-Owner-Key']):
            logging.info(
                "Illegal attempt to request a list from %s, box %s located in %s at %s"
                % (self.request.headers['X-SecondLife-Owner-Name'],
                   self.request.headers['X-SecondLife-Object-Name'],
                   self.request.headers['X-SecondLife-Region'],
                   self.request.headers['X-SecondLife-Local-Position']))
            self.error(403)
        elif not db.WRITE_CAPABILITY.is_enabled():
            self.response.set_status(503)
            self.response.headders['Retry-After'] = 120
            logging.info(
                "Told that the db was down for maintenance to %s, box %s located in %s at %s"
                % (self.request.headers['X-SecondLife-Owner-Name'],
                   self.request.headers['X-SecondLife-Object-Name'],
                   self.request.headers['X-SecondLife-Region'],
                   self.request.headers['X-SecondLife-Local-Position']))
            self.response.out.write('Currently down for maintenance')
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]

            try:
                rcpt = str(params['rcpt'])
                query = Purchases.all()
                query.filter('item_reciver =', rcpt)
                items = []
                for item in query:
                    items = items + [item.item]
                result = "%s\n%s" % (rcpt, "\n".join(set(items)))
                logging.info('Sent paid items list for %s' % rcpt)
                self.response.out.write(result)
            except KeyError:
                logging.error(
                    'Key error for paid resender list vendor %s, queue entry: %s|%s   %s'
                    % (self.request.headers['X-SecondLife-Object-Key'], rcpt,
                       lines, sys.exc_info()))
                self.error(403)
Exemple #27
0
 def get(self):
     #check linden ip
     if not lindenip.inrange(os.environ['REMOTE_ADDR']):
         self.redirect("/webinterface/", False)
     else:
         av = self.request.headers['X-SecondLife-Owner-Key']        
         out = QueueString(av)
         if out is None:
             #self.error(404)
             self.response.headers['Content-Type'] = 'text/plain'                 
             self.response.out.write(out)
         else:
             self.response.headers['Content-Type'] = 'text/plain'                 
             self.response.out.write(out)
Exemple #28
0
 def get(self):
     #check linden ip
     if not lindenip.inrange(os.environ['REMOTE_ADDR']):
         self.redirect("/webinterface/", False)
     else:
         av = self.request.headers['X-SecondLife-Owner-Key']
         out = QueueString(av)
         if out is None:
             #self.error(404)
             self.response.headers['Content-Type'] = 'text/plain'
             self.response.out.write(out)
         else:
             self.response.headers['Content-Type'] = 'text/plain'
             self.response.out.write(out)
Exemple #29
0
 def post(self):
     #check that we're coming from an LL ip
     if not lindenip.inrange(os.environ['REMOTE_ADDR']):
         self.error(403)
     elif not self.request.headers[
             'X-SecondLife-Owner-Key'] in model.adminkeys:
         self.error(403)
     else:
         lines = self.request.body.split('\n')
         params = {}
         for line in lines:
             params[line.split('=')[0]] = line.split('=')[1]
         logging.info('Info receided from SL, now storing %s with key %s' %
                      (params['name'], params['key']))
         relations.update_av(params['key'], params['name'])
Exemple #30
0
 def put(self):
     #check linden IP
     if not lindenip.inrange(os.environ['REMOTE_ADDR']):
         self.error(403)
     else:        
         #get sender key
         sender = self.request.headers['X-SecondLife-Owner-Key']
         #url should be 'remote/<rcpt>/<num>/<str>        
         av = self.request.path.split("/")[-1]
         cmd = self.request.body
         #need to handle invalid keys somehow... maybe just delete all moldy queuedcommands on each request
         #enqueue command
         CleanUp()            
         Enqueue(av, cmd, sender)
         self.response.headers['Content-Type'] = 'text/plain'                 
         self.response.out.write('enqueued %s=%s' % (self.request.path, cmd))
Exemple #31
0
    def get(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        elif not distributors.Contributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
            logging.warning("Illegal attempt to check for item from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
            self.error(403)
        else:
            # get the deliveries where giverkey = key provided (this way we can
            # still have multiple givers)
            giverkey = self.request.headers['X-SecondLife-Object-Key']
            givername = self.request.headers['X-SecondLife-Object-Name']
            
            # true or false.  if true, then remove items from db on returning them
            pop = cgi.escape(self.request.get('pop'))
            
            avname = self.request.headers['X-SecondLife-Owner-Name']
            logging.info('%s (%s) from %s checked' % (givername, giverkey, avname))

# to enable/disable the update routine fast, only need to update old records
            if (False):
                timestring = datetime.datetime.utcnow()
                location = '%s @ %s' % (self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position'])

                query = FreebieItem.gql("WHERE freebie_giver = :1", giverkey)
                for record in query:
                    record.freebie_owner = avname
                    record.freebie_timedate = timestring
                    record.freebie_location = location
                    record.put()
                    logging.info('Updated %s from %s' % (record.freebie_name, avname))

            #deliveries = FreebieDelivery.gql("WHERE giverkey = :1", giverkey)
            token = "deliveries_%s" % giverkey
            deliveries = memcache.get(token)
            if deliveries is not None:
                response = ""
                #take the list of lists and format it
                #write each out in form <objname>|receiverkey, one per line
                out = '\n'.join(['|'.join(x) for x in deliveries])
                self.response.out.write(out)
                logging.info('%s got delivery string\n%s' % (givername, out))
                memcache.delete(token)
            else:
                self.response.out.write('')
Exemple #32
0
    def post(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        elif not self.request.headers['X-SecondLife-Owner-Key'] in model.adminkeys:
            self.error(403)
        else:
            self.response.headers['Content-Type'] = 'text/plain'
            name = self.request.headers['X-SecondLife-Owner-Name']
            serverkey =self.request.headers['X-SecondLife-Object-Key']
            logging.info('Receiving price info from texture server %s' % (serverkey))
            lines = self.request.body.split('\n')

            for line in lines:
                params = {}
                if line != "":
                    item = line.split('~')[0]

                    t=int(time.time())
                    ts="%d" % t

                    record = FreebieItem.gql('WHERE freebie_name = :1', item).get()
                    if record is None:
                        logging.info("Item %s not in freebielist, skipping price info %s" % (item ,line))
                    else:
                        numParms = line.count('~')
                        if numParms > 0:
                            baseprice = line.split('~')[1]
                            record.baseprice = int(baseprice)
                            if numParms > 2:
                                designer = line.split('~')[2]
                                designer_cut = line.split('~')[3]
                                record.designer_key = designer
                                record.designer_cut = int(designer_cut)
                            record.freebie_texture_update= t
                            record.put()
                            logging.info("Price updated for %s with %s form server %s at %d" % (item,line,serverkey,t))
                            token = 'item_%s' % record.freebie_name
                            token2 = 'paid_item_%s' % record.freebie_name
                            memcache.delete(token)
                            memcache.set(token2, yaml.safe_dump({"name":record.freebie_name, "version":record.freebie_version, "giver":record.freebie_giver, "givers":record.givers, "designer_key":record.designer_key, "designer_cut":record.designer_cut, "baseprice":record.baseprice}))
                        else:
                            logging.info("No info for item %s skipping" % (item))
#            model.GenericStorage_Store('TextureTime', ts)
            self.response.out.write('saved')
Exemple #33
0
    def get(self):
        # check that we're coming from an LL ip
        if not lindenip.inrange(os.environ["REMOTE_ADDR"]):
            self.error(403)
        else:
            av = self.request.headers["X-SecondLife-Owner-Key"]
            avname = self.request.headers["X-SecondLife-Owner-Name"]
            if avname != "(Loading...)":
                relations.update_av(av, avname)
            # get all relations for which av is owner or secowner
            subdict = {}
            suburldict = {}
            ownersubs = relations.getby_subj_type(av, "owns")
            for sub in ownersubs:
                id = sub.obj_id
                if id not in subdict:
                    subdict[id] = relations.key2name(id)
                    q = Lookup.get_by_key_name("URL:" + id)
                    if q is None:
                        suburldict[id] = "None"
                    else:
                        suburldict[id] = q.ownurl
                else:
                    # delete duplicates
                    sub.delete()

            secownersubs = relations.getby_subj_type(av, "secowns")
            for sub in secownersubs:
                id = sub.obj_id
                if (
                    id not in subdict
                ):  # since you can be both an owner and a secowner, ignore those here already in the owner list
                    subdict[id] = relations.key2name(id)
                    q = Lookup.get_by_key_name("URL:" + id)
                    if q is None:
                        suburldict[id] = "None"
                    else:
                        suburldict[id] = q.securl
            currenttime = time.time()
            out = ""
            subsorted = sorted(subdict.items(), key=itemgetter(1))
            for sub in subsorted:
                #                out += '%s,%s,%s,%s,' % (sub[0], sub[1], suburldict[sub[0]], currenttime)
                # fix for sub restriction we dont send actual urls but only send them on demand
                out += "%s,%s,%s,%s," % (sub[0], sub[1], "None", 0)
            memcache.set("Subs:" + av, out)
            self.response.out.write(out.rstrip(","))
Exemple #34
0
 def put(self):
     #check linden IP
     if not lindenip.inrange(os.environ['REMOTE_ADDR']):
         self.error(403)
     else:
         #get sender key
         sender = self.request.headers['X-SecondLife-Owner-Key']
         #url should be 'remote/<rcpt>/<num>/<str>
         av = self.request.path.split("/")[-1]
         cmd = self.request.body
         #need to handle invalid keys somehow... maybe just delete all moldy queuedcommands on each request
         #enqueue command
         CleanUp()
         Enqueue(av, cmd, sender)
         self.response.headers['Content-Type'] = 'text/plain'
         self.response.out.write('enqueued %s=%s' %
                                 (self.request.path, cmd))
Exemple #35
0
 def get(self):
     #check linden ip
     if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
         self.error(403)
     elif self.request.headers['X-SecondLife-Shard'] != 'Production':
         logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
         self.response.set_status(305)
     else:
         av = self.request.headers['X-SecondLife-Owner-Key']
         record = AvTokenValue.gql("WHERE av = :1 AND token = 'owner'", av).get()
         if record is not None:
             owner = record.value.split(",")[0]
             logging.warning('Remote disabled for %s' %  self.request.headers['X-SecondLife-Owner-Name'])
             self.response.out.write("remoteoff|%s" % owner)
         else:
             self.response.out.write("remoteoff|%s" % av)
             logging.warning('Remote disabled for selfowned %s' %  self.request.headers['X-SecondLife-Owner-Name'])
Exemple #36
0
    def get(self):
        #check that we're coming from an LL ip
        if not lindenip.inrange(os.environ['REMOTE_ADDR']):
            self.error(403)
        else:
            av = self.request.headers['X-SecondLife-Owner-Key']
            avname = self.request.headers['X-SecondLife-Owner-Name']
            if avname != "(Loading...)":
                relations.update_av(av, avname)
            #get all relations for which av is owner or secowner
            subdict = {}
            suburldict = {}
            ownersubs = relations.getby_subj_type(av, 'owns')
            for sub in ownersubs:
                id = sub.obj_id
                if id not in subdict:
                    subdict[id] = relations.key2name(id)
                    q = Lookup.get_by_key_name("URL:"+id)
                    if q is None :
                        suburldict[id] = 'None'
                    else:
                        suburldict[id] = q.ownurl
                else:
                    #delete duplicates
                    sub.delete()

            secownersubs = relations.getby_subj_type(av, 'secowns')
            for sub in secownersubs:
                id = sub.obj_id
                if id not in subdict:#since you can be both an owner and a secowner, ignore those here already in the owner list
                    subdict[id] = relations.key2name(id)
                    q = Lookup.get_by_key_name("URL:"+id)
                    if q is None :
                        suburldict[id] = 'None'
                    else:
                        suburldict[id] = q.securl
            currenttime = time.time()
            out = ''
            subsorted = sorted(subdict.items(), key=itemgetter(1))
            for sub in subsorted:
#                out += '%s,%s,%s,%s,' % (sub[0], sub[1], suburldict[sub[0]], currenttime)
# fix for sub restriction we dont send actual urls but only send them on demand
                out += '%s,%s,%s,%s,' % (sub[0], sub[1], "None", 0)
            memcache.set("Subs:"+av, out)
            self.response.out.write(out.rstrip(','))
Exemple #37
0
 def post(self):
     #check linden IP  and allowed avs
     logging.info('Disperse URL')
     if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
         self.error(403)
     elif self.request.headers['X-SecondLife-Shard'] != 'Production':
         logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
         self.response.set_status(305)
     elif not self.request.headers['X-SecondLife-Owner-Key'] in model.adminkeys:
         logging.warning("Illegal attempt to set disperse URL from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
         self.error(403)
     else:
         disperseurl = self.request.body
         disperse = AppSettings(key_name="disperseurl", value=disperseurl)
         disperse.put()
         memcache.set('disperseurl', disperseurl)
         logging.info('Disperse URL set to %s' % disperseurl)
         self.response.out.write('Added')
Exemple #38
0
    def post(self):
        if lindenip.inrange(os.environ["REMOTE_ADDR"]) != "Production":
            self.error(403)
        elif self.request.headers["X-SecondLife-Shard"] != "Production":
            logging.warning("Attempt while on beta grid %s" % (self.request.headers["X-SecondLife-Shard"]))
            self.response.set_status(305)
        elif not self.request.headers["X-SecondLife-Owner-Key"] in model.adminkeys:
            self.error(403)
        else:
            self.response.headers["Content-Type"] = "text/plain"
            name = self.request.headers["X-SecondLife-Owner-Name"]
            serverkey = self.request.headers["X-SecondLife-Object-Key"]
            logging.info("Receiving textures from texture server %s" % (serverkey))
            lines = unicode(self.request.body).split("\n")

            for line in lines:
                params = {}
                if line != "":
                    params["item"] = line.split("=")[0]
                    params["texture"] = line.split("=")[1]
                    item = params["item"].split("~")[0]
                    texture = params["texture"]
                    if params["item"].find("~") != -1:
                        tags = params["item"].split("~", 1)[1].split("~")
                    else:
                        tags = list()
                    t = int(time.time())
                    ts = "%d" % t

                    record = FreebieItem.gql("WHERE freebie_name = :1", item).get()
                    if record is None:
                        logging.info("Item %s not in freebielist, skipping texture %s" % (item, texture))
                    else:
                        record.freebie_texture_key = texture
                        record.freebie_texture_serverkey = serverkey
                        record.freebie_texture_update = t
                        record.tags = tags
                        record.put()
                        logging.info(
                            "Texture updated for %s with %s form server %s at %d" % (item, texture, serverkey, t)
                        )
            #            model.GenericStorage_Store('TextureTime', ts)
            self.response.out.write("saved")
Exemple #39
0
    def put(self):
        #check linden IP  and allowed avs
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
#        elif not distributors.Distributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
#            logging.info("Illegal attempt to request an item from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
#            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        elif not db.WRITE_CAPABILITY.is_enabled():
            self.response.set_status(503)
            self.response.headders['Retry-After'] = 120
            logging.info("Told that the db was down for maintenance to %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
            self.response.out.write('Currently down for maintenance')
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]
            try:
                recordID = int(params['id'])
                record = Purchases.get_by_id(recordID)
                if record is None:
                    #could not find item to look up its deliverer.  return an error
                    logging.error('Error, Paid record %s not found. Requested by %s using %s.' % (recordID, self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name']))
                    self.error(404)
                    return
                elif record.item_reciver == 'gift':
                    record.item_reciver = self.request.headers['X-SecondLife-Owner-Key']
                    record.put()
                    logging.debug('Paid record %s updated to show rcpt is %s.' % (recordID, self.request.headers['X-SecondLife-Owner-Name']))
                    rcpt = record.item_reciver
                    name = record.item
                    self.response.out.write('rcpt set|||%s' % (recordID))
                else:
                    logging.error('Error, Paid record %s not found. Requested by %s using %s.' % (recordID, self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name']))
                    self.error(403)
            except KeyError:
                logging.error('Key error for paid PUT gift receive vendor %s, queue entry: %s|%s   %s' % (self.request.headers['X-SecondLife-Object-Key'], rcpt, recordID, sys.exc_info()))
                self.error(403)
Exemple #40
0
 def post(self):
     if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
         self.error(403)
     elif self.request.headers['X-SecondLife-Shard'] != 'Production':
         logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
         self.response.set_status(305)
     elif not self.request.headers['X-SecondLife-Owner-Key'] in model.adminkeys:
         self.error(403)
     else:
         #add distributor
         #populate a dictionary with what we've been given in post
         #should be newline-delimited, token=value
         lines = self.request.body.split('\n')
         params = {}
         for line in lines:
             params[line.split('=')[0]] = line.split('=')[1]
         logging.info('Distributor removed: %s (%s)' % (params['name'], params['key']))
         distributors.Distributor_delete(params['key'], params['name'])
         self.response.out.write('Removed Distributor %s' % params['name'])
Exemple #41
0
    def post(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        elif not self.request.headers['X-SecondLife-Owner-Key'] in model.adminkeys:
            self.error(403)
        else:
            self.response.headers['Content-Type'] = 'text/plain'
            name = self.request.headers['X-SecondLife-Owner-Name']
            serverkey = self.request.headers['X-SecondLife-Object-Key']
            logging.info('Receiving textures from texture server %s' % (serverkey))
            lines = unicode(self.request.body).split('\n')

            for line in lines:
                params = {}
                if line != "":
                    params['item'] = line.split('=')[0]
                    params['texture'] = line.split('=')[1]
                    item = params['item'].split('~')[0]
                    texture = params['texture']
                    if params['item'].find('~')!= -1:
                        tags = params['item'].split('~',1)[1].split('~')
                    else:
                        tags = list()
                    t=int(time.time())
                    ts="%d" % t

                    record = FreebieItem.gql('WHERE freebie_name = :1', item).get()
                    if record is None:
                        logging.info("Item %s not in freebielist, skipping texture %s" % (item ,texture))
                    else:
                        record.freebie_texture_key = texture
                        record.freebie_texture_serverkey = serverkey
                        record.freebie_texture_update= t
                        record.tags = tags
                        record.put()
                        logging.info("Texture updated for %s with %s form server %s at %d" % (item,texture,serverkey,t))
#            model.GenericStorage_Store('TextureTime', ts)
            self.response.out.write('saved')
Exemple #42
0
 def post(self):
     if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
         self.error(403)
     elif self.request.headers['X-SecondLife-Shard'] != 'Production':
         logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
         self.response.set_status(305)
     else:
         av=self.request.headers['X-SecondLife-Owner-Key']
         if not distributors.distributor_authorized(av): # function needs to be changed to distributors.authorized_designer as soon as the database for that is fully functioning
             self.error(402)
         else:
             objectkey=self.request.headers['X-SecondLife-Object-Key']
             public = self.request.get('Public')
             version = self.request.get('tv')
             current_version = model.GenericStorage_GetOrPutDefault('TextureTime', '0')
             logging.info("Texture request from vendor with version %s, db at version %s" % (version, current_version))
             if version:
                 if current_version != version:
                     self.response.out.write('UPDATE:%s' % current_version)
                 else:
                     self.response.out.write('CURRENT')
Exemple #43
0
 def get(self):
     if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
         self.error(403)
     elif self.request.headers['X-SecondLife-Shard'] != 'Production':
         logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
         self.response.set_status(305)
     else:
         av = self.request.headers['X-SecondLife-Owner-Key']
         query = AvLastChecked.gql('WHERE av = :1', av)
         now = datetime.datetime.now()
         weekago = now + datetime.timedelta(weeks = -1)
         if query.count() == 0:
             #save the check date
             lastchecked = AvLastChecked(av = av, dts = now)
             #no date recorded, just go back a week
             cutoff = weekago
         elif query.count() == 1:
             #there's just one record, as there should be
             lastchecked = query.get()
             cutoff = lastchecked.dts
             
             if cutoff < weekago:
                 cutoff = weekago               
             
             lastchecked.dts = now
         else:
             #there's more than one record somehow.  use the first, delete the duplicates
             lastchecked = query.get() 
             cutoff = lastchecked.dts
             if cutoff < weekago:
                 cutoff = weekago
                 
             for record in query:
                 record.delete()
             #now make a new record
             lastchecked = AvLastChecked(av = av, dts = now)
         lastchecked.put()  
         articles = Article.gql('WHERE dts > :1', cutoff)                              
         self.response.out.write("\n".join([str(x.key()) for x in articles]))            
Exemple #44
0
 def get(self):
     #check linden ip
     if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
         self.error(403)
     elif self.request.headers['X-SecondLife-Shard'] != 'Production':
         logging.warning("Attempt while on beta grid %s" %
                         (self.request.headers['X-SecondLife-Shard']))
         self.response.set_status(305)
     else:
         av = self.request.headers['X-SecondLife-Owner-Key']
         record = AvTokenValue.gql("WHERE av = :1 AND token = 'owner'",
                                   av).get()
         if record is not None:
             owner = record.value.split(",")[0]
             logging.warning(
                 'Remote disabled for %s' %
                 self.request.headers['X-SecondLife-Owner-Name'])
             self.response.out.write("remoteoff|%s" % owner)
         else:
             self.response.out.write("remoteoff|%s" % av)
             logging.warning(
                 'Remote disabled for selfowned %s' %
                 self.request.headers['X-SecondLife-Owner-Name'])
Exemple #45
0
    def get(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        else:
            groupKey = self.request.get('group')
            uplook_url = 'http://world.secondlife.com/group/%s' % groupKey
            answer = urlfetch.fetch(uplook_url, method="GET", follow_redirects=True)
            if answer.status_code == 200:
                body = answer.content
                if 'AccessDenied' in body:
                    logging.info ('Group not found: %s' % groupKey)
                    self.response.out.write('X')
                else:
                    startpos = string.find(body,"<title>") + 7
                    endpos = string.find(body,"</title>")

                    groupname = body[startpos:endpos]
                    logging.info ('Group name for %s resolved: %s' % (groupKey, groupname))
                    self.response.out.write(groupname)

            else:
                logging.info ('Error on group lookup answer: %d' % answer.status_code)
                self.response.out.write('X')
Exemple #46
0
 def post(self):
     if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
         self.error(403)
     elif self.request.headers['X-SecondLife-Shard'] != 'Production':
         logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
         self.response.set_status(305)
     elif not self.request.headers['X-SecondLife-Owner-Key'] in model.adminkeys:
         self.error(403)
     else:
         t=int(time.time())
         serverkey= self.request.headers['X-SecondLife-Object-Key']
         logging.info('Texture update started from texture server %s at %d' % (serverkey, t))
         # Setting texture time to negative time to signalize texure update is in progress
         currentVersion = int(model.GenericStorage_GetOrPutDefault('TextureTime', '0'))
         if currentVersion < 0:
             if -currentVersion + updateTimeout < t:
                 logging.warning('Texture update timestamp was outdated, allowing texture update (Old timestamp: %d)' % currentVersion)
             else:
                 logging.warning('Texture update requested from texture server %s at %d, but already in progress' % (serverkey, t))
                 self.response.out.write('Update already in progress, try again later' )
                 return
         logging.info('Texture update started from texture server %s at %d' % (serverkey, t))
         model.GenericStorage_Store('TextureTime', '-%d' % t)
         self.response.out.write('Timestamp:%d' % t )
Exemple #47
0
    def post(self):
        #check linden IP  and allowed avs`
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        elif not distributors.Contributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
            logging.info("Illegal attempt to request a list from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
            self.error(403)
        elif not db.WRITE_CAPABILITY.is_enabled():
            self.response.set_status(503)
            self.response.headders['Retry-After'] = 120
            logging.info("Told that the db was down for maintenance to %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
            self.response.out.write('Currently down for maintenance')
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]

            try:
                rcpt = str(params['rcpt'])
                query = Purchases.all()
                query.filter('item_reciver =', rcpt)
                items = []
                for item in query:
                    items= items + [item.item]
                result = "%s\n%s" % (rcpt, "\n".join(set(items)))
                logging.info ('Sent paid items list for %s' % rcpt)
                self.response.out.write(result)
            except KeyError:
                logging.error('Key error for paid resender list vendor %s, queue entry: %s|%s   %s' % (self.request.headers['X-SecondLife-Object-Key'], rcpt, lines, sys.exc_info()))
                self.error(403)
Exemple #48
0
    def post(self):
        if lindenip.inrange(os.environ["REMOTE_ADDR"]) != "Production":
            self.error(403)
        elif self.request.headers["X-SecondLife-Shard"] != "Production":
            logging.warning("Attempt while on beta grid %s" % (self.request.headers["X-SecondLife-Shard"]))
            self.response.set_status(305)
        elif not self.request.headers["X-SecondLife-Owner-Key"] in model.adminkeys:
            self.error(403)
        else:
            self.response.headers["Content-Type"] = "text/plain"
            name = self.request.headers["X-SecondLife-Owner-Name"]
            serverkey = self.request.headers["X-SecondLife-Object-Key"]
            logging.info("Receiving price info from texture server %s" % (serverkey))
            lines = self.request.body.split("\n")

            for line in lines:
                params = {}
                if line != "":
                    item = line.split("~")[0]

                    t = int(time.time())
                    ts = "%d" % t

                    record = FreebieItem.gql("WHERE freebie_name = :1", item).get()
                    if record is None:
                        logging.info("Item %s not in freebielist, skipping price info %s" % (item, line))
                    else:
                        numParms = line.count("~")
                        if numParms > 0:
                            baseprice = line.split("~")[1]
                            record.baseprice = int(baseprice)
                            if numParms > 2:
                                designer = line.split("~")[2]
                                designer_cut = line.split("~")[3]
                                record.designer_key = designer
                                record.designer_cut = int(designer_cut)
                            record.freebie_texture_update = t
                            record.put()
                            logging.info(
                                "Price updated for %s with %s form server %s at %d" % (item, line, serverkey, t)
                            )
                            token = "item_%s" % record.freebie_name
                            token2 = "paid_item_%s" % record.freebie_name
                            memcache.delete(token)
                            memcache.set(
                                token2,
                                yaml.safe_dump(
                                    {
                                        "name": record.freebie_name,
                                        "version": record.freebie_version,
                                        "giver": record.freebie_giver,
                                        "givers": record.givers,
                                        "designer_key": record.designer_key,
                                        "designer_cut": record.designer_cut,
                                        "baseprice": record.baseprice,
                                    }
                                ),
                            )
                        else:
                            logging.info("No info for item %s skipping" % (item))
            #            model.GenericStorage_Store('TextureTime', ts)
            self.response.out.write("saved")
Exemple #49
0
    def get(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" %
                            (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        elif not distributors.Contributor_authorized(
                self.request.headers['X-SecondLife-Owner-Key']):
            logging.warning(
                "Illegal attempt to update item from %s, box %s located in %s at %s"
                % (self.request.headers['X-SecondLife-Owner-Name'],
                   self.request.headers['X-SecondLife-Object-Name'],
                   self.request.headers['X-SecondLife-Region'],
                   self.request.headers['X-SecondLife-Local-Position']))
            self.error(403)
        else:
            self.response.headers['Content-Type'] = 'text/plain'
            name = cgi.escape(self.request.get('object'))
            version = cgi.escape(self.request.get('version'))
            giverkey = self.request.headers['X-SecondLife-Object-Key']
            avname = self.request.headers['X-SecondLife-Owner-Name']
            location = '%s @ %s' % (
                self.request.headers['X-SecondLife-Region'],
                self.request.headers['X-SecondLife-Local-Position'])
            timestring = datetime.datetime.utcnow()
            url = cgi.escape(self.request.get('url', default_value='None'))
            if url == 'None':
                giverurl = []
            else:
                giverurl = [unicode(giverkey)]
                deliv_box = Deliver.get_or_insert("Deliv:%s" % giverkey,
                                                  timedate=0,
                                                  url='None')
                update_dist = False
                if url != deliv_box.url:
                    update_dist = True
                elif timestring - deliv_box.timedate > datetime.timedelta(
                        0, 60):
                    update_dist = True
                if update_dist:
                    deliv_box.url = url
                    deliv_box.timedate = timestring
                    deliv_box.owner = avname
                    deliv_box.location = location
                    deliv_box.put()

            # If no version provided, set a default
            version = version or 'NOVERSION'
            #look for an existing item with that name
            items = FreebieItem.gql("WHERE freebie_name = :1", name)
            item = items.get()
            if (item == None):
                newitem = FreebieItem(freebie_name=name,
                                      freebie_version=version,
                                      freebie_giver=giverkey,
                                      givers=giverurl,
                                      freebie_owner=avname,
                                      freebie_timedate=timestring,
                                      freebie_location=location)
                newitem.put()
                item = newitem
            # Version check removed because 3.7x and onwards does not include
            # version numbers in object names. So this means that it's
            # possible to downgrade and switch to delivering an older version. -Nan

            # TODO: Instead of having items identified only by name and
            # version, allow them to be identified by name and UUID.  This will
            # allow us to have unversioned items that are still delivered by
            # multiple dist boxes, because we can tell if a box is out of sync
            # by the item's UUID.
            else:
                item.givers = []
                logging.info("Clearing box list for item %s" % name)

                # will be 'NOVERSION' for 3.7x collars
                item.freebie_version = version

                item.freebie_giver = giverkey
                if giverurl != []:
                    if giverkey in item.givers:
                        #item.givers[item.givers.index(giverkey)+1] = url
                        logging.info("Box in list")
                    else:
                        item.givers[:0] = giverurl
                        logging.info("Adding box")
                elif giverkey in item.givers:
                    index = item.givers.index(giverkey)
                    item.givers[index:index] = []
                    logging.warning("Removing box")
                item.freebie_owner = avname
                item.freebie_timedate = timestring
                item.freebie_location = location
                item.put()
            #update item in memcache
            token = 'item_%s' % name
            token2 = 'paid_item_%s' % name
            data = yaml.safe_dump({
                "name": name,
                "version": item.freebie_version,
                "giver": item.freebie_giver,
                "givers": item.givers,
                "designer_key": item.designer_key,
                "designer_cut": item.designer_cut,
                "baseprice": item.baseprice
            })
            if item.baseprice == 0:
                memcache.set(token, data)
            memcache.set(token2, data)
            self.response.out.write('saved')
            logging.info('saved item %s version %s by %s with urls %s' %
                         (name, item.freebie_version, avname, item.givers))
Exemple #50
0
    def get(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        elif not distributors.Contributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
            logging.warning("Illegal attempt to update item from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
            self.error(403)
        else:
            self.response.headers['Content-Type'] = 'text/plain'
            name = cgi.escape(self.request.get('object'))
            version = cgi.escape(self.request.get('version'))
            giverkey = self.request.headers['X-SecondLife-Object-Key']
            avname = self.request.headers['X-SecondLife-Owner-Name']
            location = '%s @ %s' % (self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position'])
            timestring = datetime.datetime.utcnow()
            url = cgi.escape(self.request.get('url', default_value='None'))
            if url == 'None':
                giverurl = []
            else:
                giverurl = [unicode(giverkey)]
                deliv_box = Deliver.get_or_insert("Deliv:%s" % giverkey, timedate=0, url='None')
                update_dist = False
                if url != deliv_box.url:
                    update_dist = True
                elif timestring - deliv_box.timedate > datetime.timedelta(0, 60):
                    update_dist = True
                if update_dist:
                    deliv_box.url = url
                    deliv_box.timedate = timestring
                    deliv_box.owner = avname
                    deliv_box.location = location
                    deliv_box.put()

            # If no version provided, set a default
            version = version or 'NOVERSION'
            #look for an existing item with that name
            items = FreebieItem.gql("WHERE freebie_name = :1", name)
            item = items.get()
            if (item == None):
                newitem = FreebieItem(freebie_name = name, freebie_version = version, freebie_giver = giverkey, givers = giverurl, freebie_owner = avname, freebie_timedate = timestring, freebie_location = location)
                newitem.put()
                item = newitem
             # Version check removed because 3.7x and onwards does not include
             # version numbers in object names. So this means that it's
             # possible to downgrade and switch to delivering an older version. -Nan
            
            # TODO: Instead of having items identified only by name and
            # version, allow them to be identified by name and UUID.  This will
            # allow us to have unversioned items that are still delivered by
            # multiple dist boxes, because we can tell if a box is out of sync
            # by the item's UUID.
            else:
                item.givers = []
                logging.info("Clearing box list for item %s" % name)
                
                # will be 'NOVERSION' for 3.7x collars
                item.freebie_version = version 
                
                item.freebie_giver = giverkey
                if giverurl != []:
                    if giverkey in item.givers:
                        #item.givers[item.givers.index(giverkey)+1] = url
                        logging.info("Box in list")
                    else:
                        item.givers[:0] = giverurl
                        logging.info("Adding box")
                elif giverkey in item.givers:
                    index = item.givers.index(giverkey)
                    item.givers[index:index] = []
                    logging.warning("Removing box")
                item.freebie_owner = avname
                item.freebie_timedate = timestring
                item.freebie_location = location
                item.put()
            #update item in memcache
            token = 'item_%s' % name
            token2 = 'paid_item_%s' % name
            data = yaml.safe_dump({
                                   "name":name,
                                   "version":item.freebie_version, 
                                   "giver":item.freebie_giver, 
                                   "givers":item.givers, 
                                   "designer_key":item.designer_key, 
                                   "designer_cut":item.designer_cut, 
                                   "baseprice":item.baseprice
                                   })
            if item.baseprice == 0:
                memcache.set(token, data)
            memcache.set(token2, data)
            self.response.out.write('saved')
            logging.info('saved item %s version %s by %s with urls %s' % (name, item.freebie_version, avname, item.givers))
Exemple #51
0
 def post(self):
     if lindenip.inrange(os.environ["REMOTE_ADDR"]) != "Production":
         self.error(403)
     elif self.request.headers["X-SecondLife-Shard"] != "Production":
         logging.warning("Attempt while on beta grid %s" % (self.request.headers["X-SecondLife-Shard"]))
         self.response.set_status(305)
     else:
         av = self.request.headers["X-SecondLife-Owner-Key"]
         #            if not distributors.Distributor_authorized(av): #Really needs to be changed??? function needs to be changed to distributors.authorized_designer as soon as the database for that is fully functioning
         #                self.error(402)
         #            else:
         objectkey = self.request.headers["X-SecondLife-Object-Key"]
         sim_id = self.request.headers["X-SecondLife-Region"]
         logging.info("Gift Texture request from %s in sim %s" % (objectkey, sim_id))
         body = self.request.body
         # Use a query parameter to keep track of the last key of the last
         # batch, to know where to start the next batch.
         last_key_str = self.request.get("start")
         last_version_str = self.request.get("last_version")
         last_version = int(last_version_str)
         current_version = int(model.GenericStorage_GetOrPutDefault("TextureTime", "0"))
         if current_version < 0:
             # system updating at the moment
             logging.info("System in update mode, inform the client")
             self.response.out.write("Updating")
         else:
             # normal work mode, lets do check and send texture
             result = ""
             if not last_version_str:
                 # no last time given so we can use the stored time
                 last_version_str = "0"
                 last_version = 0
                 logging.info("no last_version, send update")
             else:
                 last_version = int(last_version_str)
                 logging.info("last_version (%s)" % last_version_str)
             if current_version == last_version:
                 logging.info("Versions are identic, no action needed")
                 self.response.out.write("CURRENT")
             else:
                 logging.info(
                     "Versions different (DB:%s,Vendor:%s) Starting to send update..."
                     % (current_version, last_version_str)
                 )
                 if not last_key_str:
                     last_key = 0
                     result = "version\n%s\n" % current_version
                     logging.info("no last_key, send from start")
                 else:
                     last_key = int(last_key_str)
                     result = "continue\n%s\n" % current_version
                     logging.info("last_key was: %s" % last_key_str)
                 query = FreebieItem.all()
                 query.filter("freebie_texture_update >", 0)
                 entities = query.fetch(21, last_key)
                 count = 0
                 more = False
                 for texture in entities:
                     count = count + 1
                     if count < 21:
                         logging.info("%s:%d" % (texture.freebie_name, texture.freebie_texture_update))
                         result = result + texture.freebie_name + "\n" + texture.freebie_texture_key + "\n"
                         result = result + "%s\n" % texture.baseprice
                     else:
                         last_key = last_key + 20
                         result = result + ("startwith\n%d" % (last_key))
                         more = True
                         logging.info("More texture availabe, request next time from %d" % (last_key))
                 if more == False:
                     logging.info("Sending finished now")
                     result = result + "end\n"
                 self.response.out.write(result)
Exemple #52
0
    def post(self):
        #check linden IP  and allowed avs
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" %
                            (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        elif not distributors.Contributor_authorized(
                self.request.headers['X-SecondLife-Owner-Key']):
            logging.info(
                "Illegal attempt to request redeliver from %s, box %s located in %s at %s"
                % (self.request.headers['X-SecondLife-Owner-Name'],
                   self.request.headers['X-SecondLife-Object-Name'],
                   self.request.headers['X-SecondLife-Region'],
                   self.request.headers['X-SecondLife-Local-Position']))
            self.error(403)
#don't need this for redelivery
#        elif not db.WRITE_CAPABILITY.is_enabled():
#            self.response.set_status(503)
#            self.response.headders['Retry-After'] = 120
#            logging.info("Told that the db was down for maintenance to %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
#            self.response.out.write('Currently down for maintenance')
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]

            try:
                rcpt = str(params['rcpt'])
                item_name = params['objname']
                query = Purchases.all(keys_only=True)
                query.filter('item_reciver =', rcpt)
                query.filter('item =', item_name)
                if query.count(1):
                    self.response.out.write(
                        tools.httpin_delivery(self, rcpt, item_name, ""))


#                    token = 'paid_item_%s' % item_name
#                    cacheditem = memcache.get(token)
#                    if cacheditem is None:
#                        paiditem = FreebieItem.gql("WHERE freebie_name = :1", item_name).get()
#                        if paiditem is None:
#                            #could not find item to look up its deliverer.  return an error
#                            logging.error('Error, Paid item %s not found yet was found before. Requested by %s using %s.' % (item_name, self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name']))
#                            self.error(503)
#                            return
#                        else:
#                            item = {"name":paiditem.freebie_name, "version":paiditem.freebie_version, "giver":paiditem.freebie_giver, "givers":paiditem.givers, "giver":paiditem.freebie_giver, "baseprice":paiditem.baseprice}
#                            memcache.set(token, yaml.safe_dump(item))
#                    else:
#                        #pull the item's details out of the yaml'd dict
#                        item = yaml.safe_load(cacheditem)
#                    name_version = "%s - %s" % (item_name, item['version'])
#                    if item['givers'] == []:
#                        logging.error('Error, Paid item %s does not have http urls.' % (name))
#                        self.error(503)
#                        return
#                    urls = item['givers']
#                    #need to add a way to rotate the urls
#                    url_token = 'url_%s' % item_name
#                    url_num = memcache.incr(url_token, initial_value=0)
#                    url_num = url_num % ((len(urls)/2))
#
#                    count_token = 'item_count_%s' % item_name
#                    memcache.incr(count_token, initial_value=0)
#                    #need to send itme here
#                    result = urlfetch.fetch(urls[url_num*2-1], method="POST", payload="%s|%s" % (name_version, rcpt) , headers={}, deadline = 10)
#                    if result.content == "sent":
#                        self.response.out.write('sent|%s|%s' % (rcpt, name_version))#do we need all of this?
#                    else:
#                        url_num = memcache.incr(url_token, initial_value=0)
#                        url_num = url_num % ((len(urls)/2))
#                        #need to send itme here
#                        result = urlfetch.fetch(urls[url_num*2-1], method="POST", payload="%s|%s" % (name_version, rcpt) , headers={}, deadline = 10)
#                        if result.content == "sent":
#                            self.response.out.write('sent|%s|%s' % (rcpt, name_version))#do we need all of this?
#                        else:
#                            logging.error('Error, Paid item %s did not get sent. Status %s Message from vendor: %s' % (name_version, result.status_code, result.content))
#                            self.error(503)
                else:
                    logging.error(
                        'Error, %s has no record of paid item %s yet redelvier requested it.'
                        % (rcpt, item_name))
                    self.error(404)
            except KeyError:
                logging.error(
                    'Key error for paid redeliver vendor %s, queue entry: %s|%s   %s'
                    % (self.request.headers['X-SecondLife-Object-Key'], rcpt,
                       item_name, sys.exc_info()))
                self.error(403)
Exemple #53
0
    def delete(self):
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':#only allow access from sl
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" % (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        else:
            av = self.request.headers['X-SecondLife-Owner-Key']#get owner av key
            avname = self.request.headers['X-SecondLife-Owner-Name']#get owner av name
            subbie = self.request.path.split("/")[-1] #get key of sub from path
            if avname != "(Loading...)":
                relations.update_av(av, avname)#resolve key 2 name for owner
            logging.info("Remove sub request from %s (%s) for sub (%s)" % (av,avname,subbie))
            answer=0
            # first check if owner
            record = AvTokenValue.gql("WHERE av = :1 AND token = :2", subbie, g_owner).get() # request owner record of subbie
            if record is not None:
                #found a record for that subbie
                if av in record.value:
                    # and the av is stil the owner, so remove it
                    ownerlist=record.value.split(",")
                    owner_index=ownerlist.index(av)
                    del ownerlist[owner_index:owner_index+2]
                    if ownerlist == []:
                        #list is emty, so just delete the record
                        record.delete()
                        logging.info("Remove sub request from %s for %s: Primary owner record deleted" % (avname,subbie))
                    else:
                        #build the new secowner list and save it
                        s=""
                        for x in ownerlist:
                            s += x+","
                        logging.info(s.rstrip(','))
                        # update the records value
                        record.value=s.rstrip(',')
                        # and save it
                        record.put()
                        logging.info("Remove sub request from %s for %s: Primary record updated: %s" % (avname,subbie, record.value))

                    #update the reealtion db
                    relations.delete(av,"owns",subbie)
                    # and prepare the answer for sl
                    answer+=1

            #now we do the same for the secowner
            record = AvTokenValue.gql("WHERE av = :1 AND token = :2", subbie, g_secowner).get() # request owner record of subbie
            if record is not None:
                #found a record for that subbie
                if av in record.value:
                    # and the av is stil the owner, so remove it
                    ownerlist=record.value.split(",")
                    owner_index=ownerlist.index(av)
                    del ownerlist[owner_index:owner_index+2]
                    if ownerlist == []:
                        #list is emty, so just delete the record
                        record.delete()
                        logging.info("Remove sub request from %s for %s: Secower owner record deleted" % (avname,subbie))
                    else:
                        #build the new secowner list and save it
                        s=""
                        for x in ownerlist:
                            s += x+","
                        logging.info(s.rstrip(','))
                        # update the records value
                        record.value=s.rstrip(',')
                        # and save it
                        record.put()
                        logging.info("Remove sub request from %s for %s: Secower record updated: %s" % (avname,subbie, record.value))

                    #update the reealtion db
                    relations.delete(av,"secowns",subbie)
                    # and prepare the answer for sl
                    answer+=2

            # updating relation again due to the bug 716: the relations got not always properly updated, so we need to be sure it happens now
            if ((answer==0)|(answer==2)):
                if (relations.delete(av,"owns",subbie)==1):
                    logging.info("Remove sub request from %s for %s: Not in subbies db, but primary owner relation removed" % (avname,subbie))
                    answer+=1
            if ((answer==0)|(answer==1)):
                if (relations.delete(av,"secowns",subbie)==1):
                    logging.info("Remove sub request from %s for %s: Not in subbies db, but secondary owner relation removed" % (avname,subbie))
                    answer+=2

            # in case the answer is 0, something is wrong and the DBs from cmds and data drifted appart. We send a delete request to cmds, which hopfully fixex it
            if answer==0:
                logging.info('Relation not found, sending safety request to cmds')
                result = urlfetch.fetch(cmdurl + '/relation/?safety/%s/%s' % (subbie, av), method="DELETE", headers={'sharedpass': sharedpass})
                if result.status_code == 202:
                    logging.info('Answer from cmds received: %s' % result.content)
                    answer = int(result.content)
                else:
                    logging.info('Problem with answer from cmds, status %d\n%s' % (result.status_code, result.content))

            #answer to sl so we know what happened
            self.response.headers['Content-Type'] = 'text/plain'
            self.response.out.write("%d" % answer)
            self.response.set_status(200)
Exemple #54
0
    def post(self):
        #check linden IP  and allowed avs
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" %
                            (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
        elif not distributors.Distributor_authorized(
                self.request.headers['X-SecondLife-Owner-Key']):
            logging.warning(
                "Illegal attempt to request an item from %s, box %s located in %s at %s"
                % (self.request.headers['X-SecondLife-Owner-Name'],
                   self.request.headers['X-SecondLife-Object-Name'],
                   self.request.headers['X-SecondLife-Region'],
                   self.request.headers['X-SecondLife-Local-Position']))
            self.error(403)
        elif not db.WRITE_CAPABILITY.is_enabled():
            self.response.set_status(503)
            self.response.headders['Retry-After'] = 120
            logging.info(
                "Told that the db was down for maintenance to %s, box %s located in %s at %s"
                % (self.request.headers['X-SecondLife-Owner-Name'],
                   self.request.headers['X-SecondLife-Object-Name'],
                   self.request.headers['X-SecondLife-Region'],
                   self.request.headers['X-SecondLife-Local-Position']))
            self.response.out.write('Currently down for maintenance')
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]

            try:
                name = params['objname']
                item = tools.get_item(name, True)
                if item is None:
                    #could not find item to look up its deliverer.  return an error
                    logging.error(
                        'Error, Paid item %s not found. Requested by %s using %s.'
                        %
                        (name, self.request.headers['X-SecondLife-Owner-Name'],
                         self.request.headers['X-SecondLife-Object-Name']))
                    self.error(403)
                    return
                name_version = "%s - %s" % (name, item['version'])
                rcpt = str(params['rcpt'])
                paid = int(params['paid'])
                baseprice = int(item['baseprice'])
                if paid >= baseprice:
                    pass
                else:
                    token = 'Distributor_%s' % self.request.headers[
                        'X-SecondLife-Owner-Key']
                    cacheditem = memcache.get(token)
                    if cacheditem is None:
                        dist = Distributor.gql(
                            "WHERE avkey = :1", self.request.
                            headers['X-SecondLife-Owner-Key']).get()
                        dist_info = {
                            "max_discount": dist.max_discount,
                            "commission": dist.commission
                        }
                        memcache.set(token, yaml.safe_dump(dist_info))
                    else:
                        #pull the item's details out of the yaml'd dict
                        dist_info = yaml.safe_load(cacheditem)
                    disprice = baseprice * (100 -
                                            dist_info['max_discount']) / 100.0
                    if paid < disprice:
                        if paid < (disprice - 50):
                            logging.error(
                                'Rejecting request: Wrong price by %s, vendor %s located in %s at %s. Item:%s Item Price:%s Price Paid:%s Max Discount:%s%%'
                                %
                                (self.request.
                                 headers['X-SecondLife-Owner-Name'], self.
                                 request.headers['X-SecondLife-Object-Name'],
                                 self.request.headers['X-SecondLife-Region'],
                                 self.request.
                                 headers['X-SecondLife-Local-Position'], name,
                                 baseprice, paid, dist_info['max_discount']))
                            self.error(403)
                            self.response.out.write(
                                'Wrong amount Item:%s Item Price:%s Price Paid:%s Max Discount:%s%%'
                                % (name, baseprice, paid,
                                   dist_info['max_discount']))
                            return
                        else:
                            logging.warning(
                                'Under Paid Item accepting: Wrong price by %s, vendor %s located in %s at %s. Item:%s Item Price:%s Price Paid:%s Max Discount:%s'
                                % (
                                    self.request.
                                    headers['X-SecondLife-Owner-Name'],
                                    self.request.
                                    headers['X-SecondLife-Object-Name'],
                                    self.request.
                                    headers['X-SecondLife-Region'],
                                    self.request.
                                    headers['X-SecondLife-Local-Position'],
                                    name,
                                    baseprice,
                                    paid,
                                ))

                #need to record record here
                record = Purchases(
                    purchaser=rcpt,
                    item=name,
                    seller=self.request.headers['X-SecondLife-Owner-Key'],
                    item_reciver='request',
                    loc='%s %s' %
                    (self.request.headers['X-SecondLife-Region'],
                     self.request.headers['X-SecondLife-Local-Position']),
                    vender_name=self.request.
                    headers['X-SecondLife-Object-Name'],
                    amount_paid=paid)
                record.put()
                #have the vendor transfer the money
                self.response.out.write(
                    'pay|%s|%s|%s|%s|%s' %
                    (moneyRcpt, paid, rcpt, name,
                     record.key().id()))  #do we need all of this?
            except KeyError:
                logging.error(
                    'Key error for paid Post vendor  %s, queue entry: %s|%s   %s'
                    % (item['giver'], rcpt, name_version, sys.exc_info()))
                self.error(403)
Exemple #55
0
    def post(self):
        #check linden IP  and allowed avs
        if lindenip.inrange(os.environ['REMOTE_ADDR']) != 'Production':
            self.error(403)
        elif self.request.headers['X-SecondLife-Shard'] != 'Production':
            logging.warning("Attempt while on beta grid %s" %
                            (self.request.headers['X-SecondLife-Shard']))
            self.response.set_status(305)
#        elif not distributors.Distributor_authorized(self.request.headers['X-SecondLife-Owner-Key']):
#            logging.info("Illegal attempt to request an item from %s, box %s located in %s at %s" % (self.request.headers['X-SecondLife-Owner-Name'], self.request.headers['X-SecondLife-Object-Name'], self.request.headers['X-SecondLife-Region'], self.request.headers['X-SecondLife-Local-Position']))
#            self.error(403)
        elif not db.WRITE_CAPABILITY.is_enabled():
            self.response.set_status(503)
            self.response.headders['Retry-After'] = 120
            logging.info(
                "Told that the db was down for maintenance to %s, box %s located in %s at %s"
                % (self.request.headers['X-SecondLife-Owner-Name'],
                   self.request.headers['X-SecondLife-Object-Name'],
                   self.request.headers['X-SecondLife-Region'],
                   self.request.headers['X-SecondLife-Local-Position']))
            self.response.out.write('Currently down for maintenance')
        else:
            #populate a dictionary with what we've been given in post
            #should be newline-delimited, token=value
            lines = self.request.body.split('\n')
            params = {}
            for line in lines:
                params[line.split('=')[0]] = line.split('=')[1]

            try:
                name = params['objname']
                item = tools.get_item(name, True)
                if item is None:
                    #could not find item to look up its deliverer.  return an error
                    logging.error(
                        'Error, Paid item %s not found. Requested by %s using %s.'
                        %
                        (name, self.request.headers['X-SecondLife-Owner-Name'],
                         self.request.headers['X-SecondLife-Object-Name']))
                    self.error(403)
                    return
                name_version = "%s - %s" % (name, item['version'])
                rcpt = self.request.headers['X-SecondLife-Owner-Key']
                paid = int(params['paid'])
                baseprice = int(item['baseprice'])
                if paid >= baseprice:
                    pass
                else:

                    logging.error(
                        'Rejecting request: Wrong price by %s, gift vendor %s located in %s at %s. Item:%s Item Price:%s Price Paid:%s'
                        % (self.request.headers['X-SecondLife-Owner-Name'],
                           self.request.headers['X-SecondLife-Object-Name'],
                           self.request.headers['X-SecondLife-Region'],
                           self.request.headers['X-SecondLife-Local-Position'],
                           name, baseprice, paid))
                    self.error(403)
                    return
                #need to record record here
                record = Purchases(
                    purchaser=rcpt,
                    item=name,
                    seller=self.request.headers['X-SecondLife-Owner-Key'],
                    item_reciver='gift request',
                    loc='%s %s' %
                    (self.request.headers['X-SecondLife-Region'],
                     self.request.headers['X-SecondLife-Local-Position']),
                    vender_name=self.request.
                    headers['X-SecondLife-Object-Name'],
                    amount_paid=paid)
                record.put()
                #have the vendor transfer the money
                self.response.out.write(
                    'pay|%s|%s|%s|%s|%s' %
                    (moneyRcpt, paid, rcpt, name,
                     record.key().id()))  #do we need all of this?
            except KeyError:
                logging.error(
                    'Key error for paid Post gift vendor  %s, queue entry: %s|%s   %s'
                    % (item['giver'], rcpt, name_version, sys.exc_info()))
                self.error(403)