|
|
|
<?php
/***************************************************************************************************************************
****************************************************************************************************************************
InstaMSG.php3 v1.0
by R.J. Vrijhof
March 7, 2000
Platform: Windows NT
Requirements:
-Windows NT (I use Windows NT Server 4 SP 5)
-Web server (I use Apache v1.3.9)
-PHP3 (I use v3.0.14)
-The Schedule Service must be working!
-And, last but not least, Notepad.exe must be in the same directory as the environment variable WINDIR!
You can reach me at: R.J.Vrijhof@bigfoot.com
****************************************************************************************************************************
Description
This is a simple script to send an instant msg to the webmaster. It does this by producing a temporary text file, then
scheduling an AT job, which will launch a batch file, which on its turn launches Notepad that shows the text file. After
closing Notepad, the text file is automatically deleted by the batch file.
This script only works on Windows NT, but I guess with some tweaks it could also be made working on any UNIX/Linux flavor
(with cron and some text editor like Emacs, or hell, if you'd like with VI :-|).
****************************************************************************************************************************
Installation
To install, follow the following steps:
1. Unzip the file you downloaded to a temporary directory.
2. Make a directory to hold the batch file and (temporary) text files.
3. Move the batch file (showmsg.cmd) to the directory you just created.
4. Move the PHP3 file to wherever you like on your web site, as long as it is reachable from the web (of course) and you can
execute PHP3 files in that directory.
5. Edit the variables below.
6. Done!
****************************************************************************************************************************
You have to set the following variables to the right values (don't forget the double backslashes in $workdir and
$wd_short and also make sure $workdir and $wd_short end with double backslashes!):
***************************************************************************************************************************/
$self = "http://your.site.com/path/InstaMSG.php3"; # (Relative) URL of this script.
$workdir = "C:\\somewhere\\"; # The directory created for the batch and text files.
$wd_short = "C:\\SOMEWH~1\\"; # The same, but now in 8.3 format.
$delay = 5; # Number of seconds the script has to delay before Notepad is opened (if
# it doesn't work and you see AT jobs being added with an execution date
# of tomorrow, you have to increase this number).
$text = "Message from \"%s\":\r\n\r\n%s"; # Leave as-is, or change it to whatever you like, just leave two %s in
# here (the first is the e-mail address, the second the message).
/**************************************************************************************************************************
You don't have to change anything beyond this point, but feel free to experiment with whatever you like. It is completely
in the public domain.
****************************************************************************************************************************
****************************************************************************************************************************
***************************************************************************************************************************/
/**************************************************************************************************************************
This function will display the HTML form for sending the message. No error checking is done on the form, neither in
JavaScript, nor in PHP3 after posting (in fact, the mail field can be left empty).
***************************************************************************************************************************/
function displayForm() {
global $self, $mail;
?>
<form name="form1" id="form1" action="<?php echo $self;?>" method="post">
Type your e-mail address here: <input type="text" name="mail" id="mail" size="20" maxlength="35" value="<?php echo $mail;?>"><br /><br />
Type your message here:<br />
<!-- If you like to push the Send button yourself, comment the following line out and uncomment the line after that: -->
<textarea name="msg" id="msg" rows="10" cols="60" onchange="document.form1.submit();" wrap="hard"></textarea>
<!-- <textarea name="msg" id="msg" rows="10" cols="60" wrap="hard"></textarea> -->
<br /><br />
<input type="submit" value="Send!">
</form>
<?php
}
/**************************************************************************************************************************
***************************************************************************************************************************
Start of the HTML output.
***************************************************************************************************************************
**************************************************************************************************************************/
/**************************************************************************************************************************
The HTML code complies with XHTML 1.0 Transitional standard.
**************************************************************************************************************************/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/TR/xhtml1">
<head>
<title>Send instant msg to webmaster on <?php echo getenv("SERVER_NAME");?></title>
</head>
<body>
<?php
/**************************************************************************************************************************
***************************************************************************************************************************
If the msg field is empty, then it is the first time the script is run, or no msg was typed in (and so, it starts from
scratch). If you don't like that, then you have to put some error checking code in yourself, which can display a nice error
message.
**************************************************************************************************************************/
if (empty($msg)) {
?>
<br /><center><h1>Instant MSG</h1></center><br /><br />
<?php
displayForm();
/**************************************************************************************************************************
***************************************************************************************************************************
If the msg field is not empty, do your magic!
**************************************************************************************************************************/
} else {
/**************************************************************************************************************************
Strip possible slashes added by posting:
**************************************************************************************************************************/
$mail = stripslashes($mail);
$msg = stripslashes($msg);
?>
<br /><center><h1>Message sent!</h1></center><br /><br />
<?php
displayForm();
$now = time();
/**************************************************************************************************************************
Make the temporary text file:
**************************************************************************************************************************/
$fp = fopen("$workdir$now.txt", "w");
fwrite($fp, sprintf($text, $mail, $msg));
fclose($fp);
/**************************************************************************************************************************
Schedule the AT job at $number of seconds (default: 5) from now:
**************************************************************************************************************************/
$hr = date("G", $now + $number);
$min = date("i", $now + $number);
$sec = date("s", $now + $number);
exec("at $hr:$min:$sec cmd /c \"" . $workdir . "showmsg.cmd\" $wd_short$now.txt");
}
/**************************************************************************************************************************
Just for convenience:
**************************************************************************************************************************/
if (empty($mail)) {
?>
<script language="JavaScript">
// <!--
document.form1.mail.focus();
// -->
</script>
<?php
} else {
?>
<script language="JavaScript">
// <!--
document.form1.msg.focus();
// -->
</script>
<?php
}
?>
</body>
</html>
|
|
| PHP Composer - This class is meant to render images of the musical score of ring tones notes used in cellular phones, defined in the RTTL format.
Categories : PHP, PHP Classes, Misc | | | What does "PHP" stand for? Categories : Miscellaneous, PHP | | | ANTI leech script, use this if you want that people can't
see the original URL. The files can be on your own server
or on another server. Categories : HTML, Misc, PHP | | | Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP, PHP, HTML, PDF, Excel | | | How to display any array in several rows and columns of a table. Not just
in one column or in alternate rows. This example shows a nice color table
generated with PHP, but can be used with any array values(e.g. Database) Categories : Arrays, PHP, Miscellaneous, Beginner Guides, Graphics | | | phpRecommend v1.2 - UPDATED - recommend this page to a friend
script - VERY easy install - now with data logging to text file Categories : Complete Programs, PHP, Link to Article, URLs, Misc | | | This script allows people to add their favorite quotes to your website. This
could easily be modified to be a guestbook script or comment page script. Categories : PHP, Complete Programs, HTML and PHP, Misc | | | MIME records PHP Array Categories : PHP, Misc | | | Invision Forums Latest Threads list Categories : PHP, Miscellaneous, Databases, MySQL | | | The meaning of your name Categories : PHP, Arrays, Misc | | | icq status checker online offline disabled unknown Categories : PHP, Miscellaneous | | | A complete Webmaster Content Managment Tool, with differing levels of
access. Allowing the dynamic additon and showing of: Links, Multiple
Articles and News.
Categories : PHP, MySQL, Content Management | | | Parsing Simple Template Files and Data Categories : PHP, PHP Classes, Templates, Regexps | | | Match words that are entered into a <textarea> in any layout orientation (horizontal, vertical, diagonal). Categories : PHP, Regexps | | | Advanced Image WaterMarker Categories : PHP, PHP Classes, GD image library, Graphics, Object Oriented | |
|
|