|
|
|
I set up a web based interface that our office users can utilize to send instant messages via the Windows Net Send command.
The users names are pulled from a MySQL database. I also used an old javascript I pull from the internet years ago to put
the messaging screen in a pop-up format. It uses 4 files to complete the task although the second and third pages could be
combined. The 4th file is the batch file built on the third page.
/* Put this link on your main page or wherever you want to place the link*/
| | <A HREF="" onClick="window.open('file1.php', 'indexWnd', 'width=370,height=240,status=1'); return false;"> Instant Messaging</A> | |
//Save this as file1.php or again whatever you choose to call it
| <BODY bgcolor="#99ccff" text="#000000" vlink="#FFD700" link="#800000">
<?php
//I use an inc file to hold the database connection info
include("connect1.inc");
@MYSQL_SELECT_DB($dbname) or die ("Unable to select database");
$sql="SELECT * FROM table order by usr desc";
/* usr is the field name in the database that contains the message receiptants name the table also holds the computer host name */
$result=mysql_query($sql);
$num=mysql_numrows($result);
$row = mysql_fetch_array($result);
mysql_close();
$i=0;
echo "<table><td><tr><b>Instant Messaging System</b><br></td>" ;
echo "<form method=\"POST\" action=\"file2.php\">";
echo "<select name=\"sfield\" size=\"1\">";
echo "<option selected value=\"Make Selection\">Make Selection</option>";
while ($i < $num) {
$var2=mysql_result($result,$i, "usr");
echo "<option value=\"$var2\">$var2</option>";
$i ++;
}
echo "</select>";
?>
</select></p>
<p><input type="text" name="message" align="LEFT" value="" size="50"></p></input>
<p> </p>
<p><input type="submit" value="Send Message" name="B1"></p> </form>
</body> | |
// This is the final file or file2.php
| <?php
$var1=$_POST['message'];
$sfield=$_POST['sfield'];
include("connect1.inc"); // again I use an inc file to house the database connection info
@MYSQL_SELECT_DB($dbname) or die ("Unable to select database");
$sql="SELECT * FROM tablewhere usr like '%$sfield%' ";
$result=mysql_query($sql);
$num=mysql_numrows($result);
$row = mysql_fetch_array($result);
$i=0;
mysql_close();
while ($i < $num) {
$host=mysql_result($result,$i, 'computer_name');
$sfield=mysql_result($result,$i, 'usr');
$i ++;
}
echo "Message sent to $sfield<br>";
if(is_file("send.bat")) {
unlink("send.bat") or die ("Could not delete file.");
}
$myFile = "send.bat";
$fh = fopen($myFile, 'a+') or die("can't open file");
$stringData = "net send ";
fwrite($fh, $stringData);
$stringData = "$host ";
fwrite($fh, $stringData);
$stringData = "$var1 ";
fwrite($fh, $stringData);
fclose($fh);
exec("send.bat",$output);
//loop back to the original page
include("test.php");
?> | | |
|
| bookmarker - PHP, PHPLIB, MySQL WWW based bookmark manager Categories : MySQL, PHP, MySQL, Complete Programs, Databases | | | This PHP function creates dropdown select lists for time and date that you can change, outputs a 14 char MySQL timestamp in a text field Categories : PHP, MySQL, Java Script, HTML and PHP | | | Solution to those 'tell-a-friend' type email issues Categories : PHP, Email, Databases, MySQL | | | Report Generation in Microsoft Access from a MYSQL database Categories : PHP, MySQL, Databases, MS Access | | | PHP and MySQL scripting for Muyltiple CheckBoxes Categories : HTML and PHP, MySQL, Databases, PHP | | | A very simple and efficient split bar the B-Z bar , for mysql and php ...
Tired of obfuscated code try this one ...
Categories : PHP, Databases, MySQL, Algorithms | | | Add Boolean Logic Functions to Database Queries Easily. A
function to write a WHERE clause dynamically to search a
database from a search form.
Categories : MySQL, PHP, Search | | | MySQL Connection/Query Class Categories : Databases, MySQL, PHP, PHP Classes | | | Identify and log search engine access (spiders, robots, etc.) to a page. Categories : HTTP, Environment Variables, PHP, MySQL, Databases | | | Three ways to access data selected by a mysql query Categories : MySQL, PHP, Databases | | | Mimic ASP's GetString function with PHP Categories : PHP, Databases, MySQL, Strings | | | Visits-tracking Categories : PHP, Databases, MySQL, Errors and Logging, Functions | | | Create and restore backup of MySQL databases Categories : MySQL, Databases, PHP, PHP Classes, Complete Programs | | | Paginating the mySQL data Categories : PHP, Algorithms, Databases, MySQL, HTML and PHP | | | Specify your connection settings and create a link to a MySQL database. Categories : PHP, PHP Classes, Databases, MySQL, Beginner Guides | |
|
|
|