PDA

View Full Version : CGI scripting with CMRL


stubby
12-20-2008, 04:18 AM
For reference, CMRL is a offshoot of XML and is used with DOTGO SMS service (dotgo.com). I am trying to get a cgi countdown to work with CMRL. From what I can tell from the dotgo website, any scripting language can be used with the CMRL language. They give an example of how to make a cgi script work on the site.

It looks like if I can get the cgi countdown to output the data from the script into a variable, I can place the variable into the CMRL code as follows:

****NEED A PRINT FUNCTION HERE****
<message>
<content>VARIABLE</content>
</message>

For the CMRL/CGI example see (http://dotgo.com/support/documentation/doc0002.1.0/html-1/)

If anyone has any ideas on how to do this it would be greatly appreciated.

The countdown code I was going to use was:

#!/usr/bin/perl
##############################################################################
# Countdown Version 1.21 #
# Copyright 1996 Matt Wright mattw@scriptarchive.com #
# Created 9/1/95 Last Modified 10/8/95 #
# Scripts Archive at: http://www.scriptarchive.com/ #
##############################################################################
# COPYRIGHT NOTICE #
# Copyright 1996 Matthew M. Wright All Rights Reserved. #
# #
# Countdown may be used and modified free of charge by anyone so long as #
# this copyright notice and the comments above remain intact. By using this #
# code you agree to indemnify Matthew M. Wright from any liability that #
# might arise from it's use. #
# #
# Selling the code for this program without prior written consent is #
# expressly forbidden. In other words, please ask first before you try and #
# make money off of my program. #
# #
# Obtain permission before redistributing this software over the Internet or #
# in any other medium. In all cases copyright and header must remain intact.#
##############################################################################
# Define Variables

# @from_date = (yyyy,mm,dd,hh,mm,ss);
# Which means: (year,month,day,hour,minute,second)
@from_date = (2009,9,6,18,0,0);

# Done
##############################################################################

$ENV{'QUERY_STRING'} =~ s/%2C/,/g;
$ENV{'QUERY_STRING'} =~ s/=//g;

if ($ENV{'QUERY_STRING'}) {
@from_date = split(/,/, $ENV{'QUERY_STRING'});
}

# Define when various things occur, different dates, etc...
&define_dates;

# Calculate the Differences in the two dates
&calc_dates;

# Make Sure we don't get negative times.. That's not cool...
&no_negative;

# Top of HTML Page Information
&html_header;

# We don't want it to say 1 Years, now, do we? Of course not!
&proper_english;

# End of HTML Page Information
&html_trailer;

#####################################
# Subroutines

sub define_dates {
($f_year,$f_month,$f_day,$f_hour,$f_minute,$f_second) = @from_date;

($second,$minute,$hour,$day,$month,$year,$wday,$yday,$isdst) = localtime(time);

$year += 1900;

&leap_year_check;

@months = ("XX","January","February","March","April","May","June","July",
"August","September","October","November","December");

@days = ("XX","1st","2nd","3rd","4th","5th","6th","7th","8th","9th","10th",
"11th","12th","13th","14th","15th","16th","17th","18th","19th",
"20th","21st","22nd","23rd","24th","25th","26th","27th","28th",
"29th","30th","31st");

@days_in_month = (31,$feb_days,31,30,31,30,31,31,30,31,30,31);

$date_term = "$months[$f_month] $days[$f_day]";

unless ($f_year eq 'XX') {
$date_term = "$date_term, $f_year";
}
unless ($f_hour eq 'XX') {
$date_term = "$date_term $f_hour";
}
unless ($f_minute eq 'XX') {
if ($f_minute < 10) {
$date_term = "$date_term:0$f_minute";
}
else {
$date_term = "$date_term:$f_minute";
}
}
unless ($f_second eq 'XX') {
if ($f_second < 10) {
$date_term = "$date_term:0$f_second";
}
else {
$date_term = "$date_term:$f_second";
}
}

$current_date = "$months[($month + 1)] $days[$day], $year $hour";
if ($minute < 10) {
$current_date = "$current_date:0$minute";
}
else {
$current_date = "$current_date:$minute";
}
if ($second < 10) {
$current_date = "$current_date:0$second";
}
else {
$current_date = "$current_date:$second";
}

}

sub leap_year_check {
if ($year % 4 != 0 || ($year % 100 == 0 && $year % 400 != 0)) {
$feb_days = "28";
}
else {
$feb_days = "29";
}
}

sub calc_dates {
$real_year = ($f_year - $year);
$real_month = (($f_month - 1) - $month);
$real_day = ($f_day - $day);
$real_hour = ($f_hour - $hour);
$real_minute = ($f_minute - $minute);
$real_second = ($f_second - $second);
}

sub no_negative {
if ($real_second < 0) {
$real_second = ($real_second + 60);
$real_minute--;
}

if ($real_minute < 0) {
$real_minute = ($real_minute + 60);
$real_hour--;
}

if ($real_hour < 0) {
$real_hour = ($real_hour + 24);
$real_day--;
}

if ($real_day < 0) {
$real_day = ($real_day + @days_in_month[$month]);
$real_month--;
}

if ($real_month < 0) {
$real_month = ($real_month + 12);
$real_year--;
}
}

sub proper_english {
unless ($f_year eq 'XX') {
if ($real_year eq '1') {
print "$real_year Year<br>\n";
} else {
print "$real_year Years<br>\n";
}
}

unless ($f_month eq 'XX') {
if ($real_month eq '1') {
print "$real_month Month<br>\n";
} else {
print "$real_month Months<br>\n";
}
}

unless ($f_day eq 'XX') {
if ($real_day eq '1') {
print "$real_day Day<br>\n";
} else {
print "$real_day Days<br>\n";
}
}

unless ($f_hour eq 'XX') {
if ($real_hour eq '1') {
print "$real_hour Hour<br>\n";
} else {
print "$real_hour Hours<br>\n";
}
}

unless ($f_minute eq 'XX') {
if ($real_minute eq '1') {
print "$real_minute Minute<br>\n";
} else {
print "$real_minute Minutes<br>\n";
}
}

unless ($f_second eq 'XX') {
if ($real_second eq '1') {
print "$real_second Second<br>\n";
} else {
print "$real_second Seconds<br>\n";
}
}


}

sub html_header {
print "Content-type: text/html\n\n";
print "<html><head><title>Countdown to: $date_term</title></head>\n";
print "<body><center><h1>Countdown to: $date_term</h1>\n";
print "<hr>\n";
}

sub html_trailer {
print "<hr>\n";
print "It is currently $current_date\n";
print "</center>\n";
print "</body></html>\n";
}


Thanks for the help!

KevinADC
12-20-2008, 05:42 AM
have you read any of the DOTGO documentation? Thats the place to start.

http://dotgo.com/support/documentation/doc0001.1.0/html/

stubby
12-22-2008, 02:51 AM
I have read through the documentation, but I am a cgi newbie. Do you have any ideas?

FishMonger
12-22-2008, 03:33 AM
You have not provided us with enough info to be able to help you.

What part of the setup is giving you problems?
What error message(s) are you receiving?
Does dotgo.com provide you with any support other than searching their web site?

To begin with, Matt's scripts are poorly written and really shouldn't be used. I can't understand why he still promotes his scripts when he admits that they are not written well and in fact he doesn't use them himself. Instead you should be using the countdown script from the NMS project (Not Matt's Scripts), which even Matt recommends over his own script(s).

http://nms-cgi.sourceforge.net/scripts.shtml

triantic
09-08-2009, 11:32 AM
Apologize if I'm not supposed to do this. Please redirect me to an appropriate freelancer site if able.

We are looking for a coder to help implement a simple query via CMRL. We operate directory sites with zip/radius searches that deliver local listings. The idea would be to be able to sent an SMS to DOTGO with the domain name of the directory and a zip code. The CMRL code would parse the query, input the zip into our existing zip search field, and return the top 3-5 results.

Our test/learning site is www.findnotaries.com. To see how this might work select Find Notaries at the top (www.findnotaries.com/listing). Click on the Zipcode tab of the search box.

Not sure if this is CGI or Java but we should default to 25mi.

Thanks in advance for recommendations/direction.

KFayal
10-04-2009, 10:29 AM
We are looking for a coder to help implement a simple query via CMRL. We operate directory sites with zip/radius searches that deliver local listings. The idea would be to be able to sent an SMS to DOTGO with the domain name of the directory and a zip code. The CMRL code would parse the query, input the zip into our existing zip search field, and return the top 3-5 results.


triantic,
I can help you with this, but you probably have most of the work already done. You implement this through a CMRL engine. The CMRL "code" doesn't really do anything. The real work is done in the implemented engine. If you already have code (javascript, php, perl, asp, aspx - whatever) you can probably have it modified to handle a call from the CMRL file.

Check out my site at http://www.7text.com you can get in touch with me that way.

xion.truth
06-14-2010, 06:43 AM
A great option for getting up and running quick with your CMRL is http://www.dktext.com the basic package is free and then there are some paid packages too.