WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : This is a simple PHP3 script to send an instant msg to the webmaster (only for Windows NT).
Categories : PHP, Misc, Miscellaneous Update Picture
Richard Vrijhof
Date : Mar 06th 2000
Grade : Be the 1st to grade this Code Example
Viewed : 3152
File : InstaMSG.zip
Images : No Images for this code example.
Search : More code by Richard Vrijhof
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

<?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>



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
icq status checker online offline disabled unknown
Categories : PHP, Miscellaneous
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
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
What does "PHP" stand for?
Categories : Miscellaneous, PHP
The meaning of your name
Categories : PHP, Arrays, Misc
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
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
MIME records PHP Array
Categories : PHP, 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
Invision Forums Latest Threads list
Categories : PHP, Miscellaneous, Databases, MySQL
Retrieve text from table and email to your e- address in pipe delimited format.
Categories : PHP, MySQL
Accepts a database & hostname from a user and then HTTP username and password. Uses this to connect to a MySQL database. Produces a form based on the tables it finds there to allow the user to do SELECTs, INSERTs, and DELETEs.
Categories : Databases, PHP, MySQL, Complete Programs
A PHP function to encrypt and decrypt a number or string or a combination of the two.
Categories : PHP, Encryption, Security
Using $PHP_AUTH_USER and $PHP_AUTH_PW to authenticate.
Categories : Authentication, PHP