The Geek Forum

  • April 27, 2024, 08:16:04 PM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

Due to the prolific nature of these forums, poster aggression is advised.

*

Recent Forum Posts

Shout Box

Members
Stats
  • Total Posts: 129552
  • Total Topics: 7149
  • Online Today: 180
  • Online Ever: 1013
  • (January 12, 2023, 01:18:11 AM)

Author Topic: General question regarding CGI programming  (Read 3496 times)

scribcake

  • Troll
  • *
  • Coolio Points: +42/-2
  • Offline Offline
  • Gender: Male
  • Posts: 287
    • View Profile
General question regarding CGI programming
« on: January 14, 2009, 09:43:33 AM »

Hey guys, know I haven't posted in a while. I was pretty busy with school for the last 4 months...

I started learning PHP and PostgreSQL as one of my new years resolutions for 2009, and to facilitate in my learning, I decided to develop an actual application, rather than just write random little scripts  :-P

Basically the application is a networked sales vendor system, for the metaverse Second Life (which I have been a long time member of), that utilizes a PHP backend to keep track of sales for individual users. Allowing users to view tables of their sales, and sort them based on sale volume, vendors sold from, etc... And then export the data to excel.

Anyway, one problem that I am facing at this point is how I am going to remove vendor records from the database, when they are deleted within Second Life. There is no way for me to send requests from the server into Second Life; I can only send http requests from SL to my server.

One solution I have devised is to have a timer in my scripts that will have the vendors ping my server, updating a timestamp. I will then have CGI on my server that will run a garbage collection routine that will go through my database and flag entries which have not had the timestamp updated within a certain amount of time, and alerting the user that their vendors/servers are no longer available in world.

The problem I'm having is I don't know the first thing about CGI. I'm thinking that Perl would be good for this, but I'm not absolutely sure...

Does anyone know some good tutorials for Perl CGI programming that would allow me to have a script like this, which continuously runs in the background on my server? I tried Google but I am having difficulty finding what I'm looking for... :|
Logged

BizB

  • Forum Moderator
  • Hacker
  • *
  • Coolio Points: +439/-15
  • Offline Offline
  • Gender: Male
  • Posts: 4324
  • Keep making circles
    • View Profile
Re: General question regarding CGI programming
« Reply #1 on: January 14, 2009, 10:10:31 AM »

You're looking for something to accept the ping from the vendors and update the time stamp in the table, right?

PERL would work well for this.  You can write a PERL script and pass parameters in the URL.  It's not exactly rocket surgery.

http://tinyurl.com/76f8co
Logged
Without me, it's just 'aweso'.

scribcake

  • Troll
  • *
  • Coolio Points: +42/-2
  • Offline Offline
  • Gender: Male
  • Posts: 287
    • View Profile
Re: General question regarding CGI programming
« Reply #2 on: January 14, 2009, 10:16:14 AM »

I do all the http request handling with PHP, so updating the time stamps is not a problem. The problem is how I can have a routine running on my server that would check my database, and flag the old entries.

Again I am not really completely certain whether I am even looking in the right place for a solution... maybe the answer is with something other than CGI o.O

Edit: I just got an IM from one of my friends on skype, apparently I can run php stand alone on my server... which I was completely unaware of  :oops:.. so I guess I might just be able to use php for this. I'll have to look into it when I get home from work :-p
« Last Edit: January 14, 2009, 10:19:03 AM by scribcake »
Logged

BizB

  • Forum Moderator
  • Hacker
  • *
  • Coolio Points: +439/-15
  • Offline Offline
  • Gender: Male
  • Posts: 4324
  • Keep making circles
    • View Profile
Re: General question regarding CGI programming
« Reply #3 on: January 14, 2009, 10:29:35 AM »

Oh!  You should be able to schedule a process on the MySQL to do that.
Logged
Without me, it's just 'aweso'.

scribcake

  • Troll
  • *
  • Coolio Points: +42/-2
  • Offline Offline
  • Gender: Male
  • Posts: 287
    • View Profile
Re: General question regarding CGI programming
« Reply #4 on: January 14, 2009, 10:37:56 AM »

Alright, I was thinking it might be possible to do something like that as well...

My friend mentioned using cron jobs though... but I think setting up a process on my MySQL server directly would be much easier, since all it really needs to do is check the table containing vendor keys for all the users for entries with a timestamp that is say more than 10 minutes old, and set a field for that entry to true.

Although I may want to implement a system of emailing the user when a vendor/server is flagged as offline, so they can know if their systems go offline in world asap. I'll probably have to do it with cron if I want to implement something like that.
Logged

ivan

  • Forum Moderator
  • Hacker
  • *
  • Coolio Points: +499/-50
  • Offline Offline
  • Posts: 4929
  • Not a Mod, nor a Rocker. A Mocker.
    • View Profile
Re: General question regarding CGI programming
« Reply #5 on: January 14, 2009, 11:00:31 AM »

This does not address your question exactly, but: How many vendors are you anticipating? If it's just a handful, then the timestamp cycle will be fine, but if it's thousands it can be a costly script to run. Why not just send a daily list of active vendors from SL to your server?
Logged
"I TYPE 120 WORDS PER MINUTE, BUT IT'S IN MY OWN LANGUAGE!"  -Detta

xolik: WHERE IS OBAMA'S GIFT CERTIFICATE?
Demosthenes: Is that from the gifters movement?


Detta: Crappy old shorts and a tank top.  This is how I dress for work. Because my job is to get puked on.
Demosthenes: So is mine.  I work in IT.


bananaskittles: The world is 4chan and God is a troll.

scribcake

  • Troll
  • *
  • Coolio Points: +42/-2
  • Offline Offline
  • Gender: Male
  • Posts: 287
    • View Profile
Re: General question regarding CGI programming
« Reply #6 on: January 14, 2009, 11:14:27 AM »

That is actually a good point ivan...

While this is somewhat just a personal project as a way of learning php, I do plan to market it if it works as intended. So there could be hundreds to thousands of vendors. So I can see your point...

But I am having trouble thinking of a way sending a daily list to the server would resolve the problem without some sort of scheduled script to check the database...
Logged

ivan

  • Forum Moderator
  • Hacker
  • *
  • Coolio Points: +499/-50
  • Offline Offline
  • Posts: 4929
  • Not a Mod, nor a Rocker. A Mocker.
    • View Profile
Re: General question regarding CGI programming
« Reply #7 on: January 14, 2009, 02:50:38 PM »

Well, since I know some SQL, I would find a way to schedule a mySQL script, as BizB suggested.

Assuming you have a vendor table, I would set up an Active Vendors table that gets filled by a feed from SL.

Your SQL script would find vendors in your vendor table that are missing in the Active Vendors table, mark them as deleted, then truncate Active Vendors for the next run.

I don't know what the limitations of mySQL are, but with regular MSSQL you can do practically anything.
Logged
"I TYPE 120 WORDS PER MINUTE, BUT IT'S IN MY OWN LANGUAGE!"  -Detta

xolik: WHERE IS OBAMA'S GIFT CERTIFICATE?
Demosthenes: Is that from the gifters movement?


Detta: Crappy old shorts and a tank top.  This is how I dress for work. Because my job is to get puked on.
Demosthenes: So is mine.  I work in IT.


bananaskittles: The world is 4chan and God is a troll.