Quick Search for:  in language:    
ICQ,found,code,websource,forgotten,made,minim
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Perl Stats

 Code: 74,273. lines
 Jobs: 25. postings

 How to support the site

 
Sponsored by:

 
You are in:
 
Login





Latest Code Ticker for Perl.
Click here to see a screenshot of this code!Mailing List v2.0
By Aaron L. Anderson on 1/7

(Screen Shot)

ShowIMG
By Jeff Mills on 1/5


Simple Perl Ping
By John Hass on 12/29


Very basic login script template with cookies
By Aaron L. Anderson on 12/29


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!

Affiliate Sites



 
 
   

Send an Message to an ICQ account without ICQ!

Print
Email
 
VB icon
Submitted on: 11/11/2000 8:56:18 PM
By: Brandon McPherson 
Level: Intermediate
User Rating: By 5 Users
Compatibility:5.0 (all versions)

Users have accessed this code 9780 times.
 

(About the author)
 
     I found this code on the web(source forgotten - my bad), and made minimal changes to it. This allows you to send a message to an ICQ Account.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    =**************************************
    = Name: Send an Message to an ICQ accoun
    =     t without ICQ!
    = Description:I found this code on the w
    =     eb(source forgotten - my bad), and made 
    =     minimal changes to it. This allows you t
    =     o send a message to an ICQ Account.
    = By: Brandon McPherson
    =
    = Inputs:It's all self-contained.
    =
    = Returns:HTML
    =
    = Side Effects:Excessive hair growth :)
    =
    =This code is copyrighted and has    = limited warranties.Please see http://w
    =     ww.Planet-Source-Code.com/vb/scripts/Sho
    =     wCode.asp?txtCodeId=142&lngWId;=6    =for details.    =**************************************
    
    #!/usr/bin/perl
    my $TITLE = "Page me on ICQ!";
    my $BGCOLOR = "#FFCC00";
    my $TEXT_COLOR_NORMAL = "#000000";
    my $REQUIRED_TEXT_COLOR = "Black";
    my $BACKGROUND_URL = "";
    my $CGI_DIR = "http://www.servername.com/cgi-bin";
    $SHOW_OPTIONAL_FIELDS = 0;
    my $sendmail = "/usr/sbin/sendmail";
    my $destination_email = "1234567\@pager.icq.com";
    &print;_header;
    &get;_form_data;
    if (!$FORM_DATA{'mail'}) {
    &print;_html_form;
    } else {
    $error = 0;
    ✓_form_data;
    if (!$error) {
    &send;_mail;
    &reply;_to_user;
    }
    }
    exit(0);
    sub print_header {
    print ("Content-type: text/html\n\n");
    print ("<HTML>\n<HEAD>\n<TITLE>$TITLE</TITLE>\n</HEAD>\n");
    print ("<BODY BGCOLOR=\"$BGCOLOR\" BACKGROUND=\"$BACKGROUND_URL\" ");
    print ("TEXT=\"$TEXT_COLOR_NORMAL\">\n");
    }#print_header
    sub get_form_data {
    $request_method = $ENV{'REQUEST_METHOD'};
    if ($request_method eq "GET") {
    	$form_info = $ENV{'QUERY_STRING'};
    } else {
    	$size_of_form_information = $ENV{'CONTENT_LENGTH'};
    	read (STDIN, $form_info, $size_of_form_information);
    }
    @key_value_pairs = split (/&/, $form_info);
    foreach $key_value (@key_value_pairs) {
    	($key, $value) = split (/=/, $key_value);
    	$value =~ tr/+/ /;
    	$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
    	if (defined($FORM_DATA{$key})) {
    		$FORM_DATA{$key} = join (", ", $FORM_DATA{$key}, $value);
    	} else {
    		$FORM_DATA{$key} = $value;
    	}
    }
    } #get_form_data
    sub print_html_form {
    print <<__END_OF_HTML_CODE__;
    <FORM ACTION="$CGI_DIR/icq.pl" METHOD="POST">
    <INPUT TYPE="hidden" NAME="to" VALUE="$FORM_DATA{'to'}">
    __END_OF_HTML_CODE__
    if ($SHOW_OPTIONAL_FIELDS) {
    print ("<BR><FONT COLOR=\"$REQUIRED_TEXT_COLOR\"><B>All required ");
    print ("information is bolded in this color.</B></FONT>\n");
    print ("Everything else is just for my own curiosity. <BR>");
    }
    print <<__END_OF_HTML_CODE__;
    <TABLE BORDER="0" CELLPADDING="4" CELLSPACING="2">
    <TR VALIGN="top">
    <TD>
    <TABLE>
    __END_OF_HTML_CODE__
    if ($SHOW_OPTIONAL_FIELDS) {
    print ("<TR VALIGN=\"top\">\n");
    print ("<TD>Your name:</TD>\n");
    print ("<TD><INPUT TYPE=\"text\" NAME=\"users_name\"></TD>\n");
    print ("</TR>\n");
    }
    print <<__END_OF_HTML_CODE__; 
    <TR VALIGN="top">
    <TD><FONT COLOR="$REQUIRED_TEXT_COLOR"><B>Your email:</B></FONT></TD>
    <TD><INPUT TYPE="text" NAME="users_email">
    <FONT COLOR="$REQUIRED_TEXT_COLOR">
    </TD>
    </TR>
    </TABLE>
    <BR>
    __END_OF_HTML_CODE__
    if ($SHOW_OPTIONAL_FIELDS) {
    print <<__END_OF_HTML_CODE__;
    	<TABLE>
    	<TR VALIGN="top">
    	<TD>Your country of residence:</TD>
    	<TD><INPUT TYPE="text" NAME="users_country"><BR><BR></TD>
    	</TR>
    	<TR VALIGN="top">
    	<TD>Your home State/Province:</TD>
    	<TD>
    	<INPUT TYPE="radio" NAME="state_usa" VALUE="USA">
    	If inside the U.S.:
    	<SELECT NAME="state_address1" SIZE="1">
    	<OPTION>Alabama
    	<OPTION>Alaska
    	<OPTION>Arizona
    	<OPTION>Arkansas
    	<OPTION>Hawaii
    	<OPTION>California
    	<OPTION>Colorado
    	<OPTION>Connecticut
    	<OPTION>Delaware
    	<OPTION>Florida
    	<OPTION>Georgia
    	<OPTION>Idaho
    	<OPTION>Illinois
    	<OPTION>Indiana
    	<OPTION>Iowa
    	<OPTION>Kansas
    	<OPTION>Kentucky
    	<OPTION>Louisiana
    	<OPTION>Maine
    	<OPTION>Maryland
    	<OPTION>Massachusetts
    	<OPTION>Michigan
    	<OPTION>Minnesota
    	<OPTION>Mississippi
    	<OPTION>Missouri
    	<OPTION>Montana
    	<OPTION>Nebraska
    	<OPTION>Nevada
    	<OPTION>New Hampshire
    	<OPTION>New Jersey
    	<OPTION>New Mexico
    	<OPTION>New York
    	<OPTION>North Carolina
    	<OPTION>North Dakota
    	<OPTION>Ohio
    	<OPTION>Oklahoma
    	<OPTION>Oregon
    	<OPTION>Pennsylvania
    	<OPTION>Rhode Island
    	<OPTION>South Carolina
    	<OPTION>South Dakota
    	<OPTION>Tennessee
    	<OPTION>Texas
    	<OPTION>Utah
    	<OPTION>Vermont
    	<OPTION>Virginia
    	<OPTION>Washington
    	<OPTION>Washington, D.C.
    	<OPTION>West Virginia
    	<OPTION>Wisconsin
    	<OPTION>Wyoming
    	</SELECT><BR>
    	<INPUT TYPE="radio" NAME="state_usa" VALUE="NOT_USA">
    	If outside the U.S.:
    	<INPUT TYPE="text" NAME="state_address2">
    	</TD>
    	</TR>
    	</TABLE>
    	<BR>
    __END_OF_HTML_CODE__
    }
    print <<__END_OF_HTML_CODE__;
    <FONT COLOR="$REQUIRED_TEXT_COLOR"><B>Please enter your message
    below:</B></FONT><BR>
    <TEXTAREA NAME="message" ROWS="8" COLS="40"></TEXTAREA>
    <BR>
    Please note that your are limited to 450 characters.
    <BR>
    <BR>
    <INPUT TYPE="hidden" NAME="mail" VALUE="1">
    <INPUT TYPE="submit" VALUE="$TITLE">
    </TD>
    </TR>
    </TABLE>
    <BR>
    </FORM>
    </BODY>
    </HTML>
    __END_OF_HTML_CODE__
    } #print_html_form
    sub check_form_data {
    my %error_codes = (
    "1" => "You need to enter your email address.",
    "2" => "You seemed to have forgotten to enter the
    email message you wish to send.",
    "3" =>"For security reasons, you cannot have any of the following characters in your email or subject fields: [ ; < > & \* ` \| ] "
    );
    if ($FORM_DATA{'users_email'} !~ /\@/ && 
    	$FORM_DATA{'users_email'} !~ /\w/) {
    	$error = 1;
    } elsif ($FORM_DATA{'message'} !~ /\w/) {
    	$error = 2;
    }
    if (($FORM_DATA{"subject"} =~ /[\[\;\>\<\&\*\^\$\(\)\`\|\]\']/) || ($FORM_DATA{"to"} =~ /[\[\;\>\<\&\*\^\$\(\)\`\|\]\']/)
    	|| ($FORM_DATA{"users_email"} =~ /[\[\;\>\<\&\*\^\$\(\)\`\|\]\']/)) {
    	$error = 3;
    }
    if ($error) {
    	print ("<H3>\n");
    	print ("D'OH!<br>");
    	print ("We had a little mishap. This is why:<BR> \n");
    	print ("<BR>$error_codes{$error}\n<BR>\n<BR>");
    	print ("Please hit the back button in your browser to ");
    	print ("correct this. Thank you!\n");
    	print ("</H3>\n</BODY>\n</HTML>\n");
    }
    if ($FORM_DATA{'to'} ne "") {
    	$destination_email = $FORM_DATA{'to'};
    }
    } #check_form_data
    sub send_mail {
    open (MESSAGE, "| $sendmail -t -oi ");
    print MESSAGE <<__END_OF_MESSAGE__;
    To: $destination_email
    From: $FORM_DATA{"users_email"}
    __END_OF_MESSAGE__
    if ($FORM_DATA{'users_name'} ne "") {
    	print MESSAGE ("$FORM_DATA{'users_name'} - ");
    }
    print MESSAGE ("$FORM_DATA{'users_email'} paged you on ICQ ");
    print MESSAGE ("from your website.\n");
    if ($FORM_DATA{'users_country'} ne "") {
    	print MESSAGE ("They are in the country of: $FORM_DATA{'users_country'}\n");
    }
    if ($FORM_DATA{'state_usa'} =~ /^USA$/i) {
    	print MESSAGE ("They are writing from the state of: $FORM_DATA{'state_address1'}\n\n");
    } elsif ($FORM_DATA{'state_usa'} =~ /^NOT_USA$/i) {
    	print MESSAGE ("They are writing from the province of: $FORM_DATA{'state_address2'}\n\n");
    }
    print MESSAGE ("The follow is what they had to say:\n\n");
    print MESSAGE ("$FORM_DATA{'message'}\n");
    close (MESSAGE);
    if ($FORM_DATA{'keep_copy'}) {
    	open (MESSAGE, "| $sendmail -t -oi ");
    	print MESSAGE <<__END_OF_MESSAGE__;
    To: $FORM_DATA{"users_email"}
    __END_OF_MESSAGE__
    print MESSAGE ("The following is what you wrote from the ");
    	print MESSAGE ("$TITLE webpage...:\n\n");
    print MESSAGE ("$FORM_DATA{'message'}\n");
    close (MESSAGE);
    }
    } #send_mail
    sub reply_to_user {
    print ("Thank you for paging me on ICQ<BR><BR>\n");
    print ("Below is a copy of the information you sent me:<BR>\n");
    print ("<DL>\n");
    if ($FORM_DATA{'users_name'} ne "") {
    	print ("<DT><B>Your name:</B>\n<DD>$FORM_DATA{'users_name'}<BR><BR>\n");
    }
    print ("<DT><B>Your email:</B>\n<DD>$FORM_DATA{'users_email'}<BR><BR>\n"); 
    if ($FORM_DATA{'users_country'} ne "") {
    	print ("<DT><B>Your country:</B>\n<DD>$FORM_DATA{'users_country'}<BR><BR>\n");
    }
    if ($FORM_DATA{'state_address1'} ne "" && $FORM_DATA{'state_usa'} =~ /^USA$/i) {
    	print ("<DT><B>Your state:</B>\n<DD>$FORM_DATA{'state_address1'}<BR><BR>\n"); 
    } elsif ($FORM_DATA{'state_address2'} ne "" && $FORM_DATA{'state_usa'} =~ /^NOT_USA$/i) { 
    	print ("<DT><B>Your state:</B>\n<DD>$FORM_DATA{'state_address2'}<BR><BR>\n") if ($FORM_DATA{'state_address2'} ne "");
    }
    print ("<DT><B>Your message:</B>\n<DD>$FORM_DATA{'message'}<BR><BR>\n");
    print ("</DL>\n");
    print ("</BODY>\n</HTML>\n");
    } #reply_to_user
    #FILE: icq.pl


Other 1 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments
11/12/2000 4:51:56 PM:Brandon McPherson
Please vote if you like this 
code.
We need some activity here on 
this side of the site!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
11/23/2000 1:06:24 PM:aSerb
Hi, I'm a newbie in CGI I have no idea 
on how to make this work. I have alot 
of friends that have ICQ and this would 
be cool to have on my web site but I 
can't get it to work. I have changed 
the www.servername.com to my web site 
URL and i have saved the copy-paste to 
a file name: icq.cgi and icq.pl and it 
doesn't work I also tryed to change the 
CHMOD to all "777" but nothing works. I 
dont't visit this side of the site alot 
i'm ussualy on the VB side of 
planet-source-code so plz. email me 
(aserb@aserb.com) a .zip with a 
readme.txt explaining how to make this 
work. if not plz. upload it on 
planet-source-code.com (.Zip) Thanks 
alot.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/26/2000 8:30:28 PM:nato_
hay.. what if your server doesn't have 
the sendmail program on it?.. could you 
do it w/ CDontsMail?.. and if so.. just 
how?
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
12/29/2000 2:54:13 AM:Jeff_TM@hotmail.com
sorry newbies... you need an acount 
that supports telnet first, then the 
sendmail option.  And there are many 
different reasons you can't get the 
code to work.  for one, it sounds like 
your trying to call the cgi from an 
html page.  That is what you want to 
do, but you have to set up a form as 
well.  And if there is no form set up, 
then it will give you errors.  Try 
this: put all the cgi in your cgi-bin, 
chmod them to 755,  and call them from 
a web page.  If you get something like 
"internal error", then at least you can 
call it.  The last thing to do would to 
get the form on the html page done.
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/8/2001 7:02:48 AM:Flanders
also it wont work if your server doesnt 
support cgi
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
5/15/2001 4:15:36 AM:Thushan Fernando
So there goes every1s idea for using 
GeoCities for doing this... or is it 
yahoo geocities now?? Ohhh well u know 
what i mean!
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
3/16/2002 12:06:23 PM:Draz
I expected some more from this script.. 
like direct UDP communications or 
something like that.. Still it looks 
okay to me..
Keep the Planet clean! If this comment was disrespectful, please report it:
Reason:

 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Perl Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.