Posted by elg3ne on 10 Mar 2008 9:30 am. Filed under
Computer Networking.
Network Patch Cable – Straight

Network Patch Cable – Crossover

Note: I did not create this image. I just found it on the web. I’m just sharing it.
Thank you.
Posted by elg3ne on 10 Mar 2008 8:56 am. Filed under
Scipts & Tutorials.
<html>
<head>
<title>MD5 password generator</title>
</head>
<body>
<h2>MD5 password generator</h2>
<?php
import_request_variables('P');
if($pw)
{
echo "The encrypted version of <b>$pw</b> is:<br>";
echo "<br><tt>" . strtoupper(decrypt_md5
($pw)) . "</tt>";
}
?>
<p>
<form name="pw" method="post">
Enter a password to encrypt:<br>
<input type="text" name="pw">
<br>
<input type="submit" value="Submit">
</form>
<p>
<a href="md5.php.txt">View the source of this page</a>
</body>
</html>
Note: I did not write this script. I just found it on the web. I’m just sharing the script. I used it once on my page.
Thank you.
Posted by elg3ne on 10 Mar 2008 8:47 am. Filed under
Scipts & Tutorials.
*** Use this code anyway you want. Credit to Ash Young, author of the script. ***
<?php
if ($_SESSION[username
] == 'unep' && $_SESSION[password
] == 'biomass') {
########################################################
# Script Info
# ===========
# File: DirectoryListing.php
# Author: Ash Young (ash@evoluted.net
# Created: 20/12/03
# Modified: 27/09/04
# Website: http://evoluted.net/directorylisting.php
# Requirements: PHP
#
# Description
# ===========
# Displays all files contained within a directory in
# a well formed table, with category-image tags
#
# If you have any functions that you like to see
# implemented in this script then please just send
# an email to ash@evoluted.net
#
# Useage
# ======
#
# To change the colours display when using the script
# scroll down to set up section
#
# To use the script just upload to your server with
# the images and point your browser to the scripts
# filename
#
# SETUP
# =====
#
# Change the following variables to display what colours
# the script outputs
########################################################
DEFINE("IMAGEROOT", "../images2/"); #CHANGE /images/ TO THE PATH OF THE ASSOCIATED IMAGES
$textcolor = "#FFFFFF"; #TEXT COLOUR
$bgcolor = "#eeeeee"; #PAGE BACKGROUND COLOUR
$normalcolor = "#0066FF"; #TABLE ROW BACKGROUND COLOUR
$highlightcolor = "#006699"; #TABLE ROW BACKGROUND COLOUR WHEN HIGHLIGHTED
$headercolor = "#FF9900"; #TABLE HEADER BACKGROUND COLOUR
$bordercolor = "#202750"; #TABLE BORDER COLOUR
?>
<html>
<head>
<title>Directory Listings of
<? echo $_SERVER["REQUEST_URI"]; ?> </title>
<style type='text/css'>
<!--
body { color:
<? echo $textcolor; ?>; font: tahoma, small verdana,arial,helvetica,sans-serif; background-color:
<? echo $bgcolor; ?>; }
table { font-family: tahoma, Verdana, Geneva, sans-serif; font-size: 9pt; border: 1px; border-style: solid; border-color:
<? echo $bordercolor; ?>; }
.row { background-color:
<? echo $normalcolor; ?>; border: 0px;}
a:link { color:
<? echo $textcolor; ?>; text-decoration: none; }
a:visited { color:
<? echo $textcolor; ?>; text-decoration: none; }
a:hover, a:active { color:
<? echo $textcolor; ?>; text-decoration: none; }
img {border: 0;}
#bottomborder {border:
<? echo $bordercolor;?>;border-style: solid;border-top-width: 0px;border-right-width: 0px;border-bottom-width: 1px;border-left-width: 0px}
.copy { text-align: center; color:
<? echo $textcolor; ?>; font-family: tahoma, Verdana, Geneva, sans-serif; font-size: 9pt; text-decoration: underline; }
//-->
</style>
</head>
<body>
<?php
clearstatcache();
if ($handle = opendir('.')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != ".." && $file != "index.php" && $file != "list.php" && $file != "index2.php" && $file != ".htaccess" && $file != ".index.php.swp" && $file != ".list.php.swp" && $file != substr($PHP_SELF, -(strlen($PHP_SELF) - strrpos($PHP_SELF, "/") - 1
))) {
if (filetype($file) == "dir") {
//SET THE KEY ENABLING US TO SORT
$n++;
if($_REQUEST['sort']=="date") {
$key = filemtime($file) . ".$n";
}
else {
$key = $n;
}
$dirs[$key] = $file . "/";
}
else {
//SET THE KEY ENABLING US TO SORT
$n++;
if($_REQUEST['sort']=="date") {
$key = filemtime($file) . ".$n";
}
elseif($_REQUEST['sort']=="size") {
$key = filesize($file) . ".$n";
}
else {
$key = $n;
}
$files[$key] = $file;
}
}
}
closedir($handle);
}
#USE THE CORRECT ALGORITHM AND SORT OUR ARRAY
if($_REQUEST['sort']=="date") {
@ksort($dirs, SORT_NUMERIC
);
@ksort($files, SORT_NUMERIC
);
}
elseif($_REQUEST['sort']=="size") {
@natcasesort($dirs);
@ksort($files, SORT_NUMERIC
);
}
else {
@natcasesort($dirs);
@natcasesort($files);
}
#ORDER ACCORDING TO ASCENDING OR DESCENDING AS REQUESTED
if($_REQUEST['order']=="desc" && $_REQUEST['sort']!="size") {$dirs = @array_reverse($dirs);}
if($_REQUEST['order']=="desc") {$files = @array_reverse($files);}
$dirs = @array_values($dirs); $files = @array_values($files);
echo "<table width=\"550\" border=\"0\" cellspacing=\"0\" align=\"center\"><tr bgcolor=\"$headercolor\"><td colspan=\"2\" id=\"bottomborder\">";
if($_REQUEST['sort']!="name") {
echo "<a href=\"".$_SERVER['PHP_SELF']."?sort=name&order=asc\">";
}
else {
if($_REQUEST['order']=="desc") {#
echo "<a href=\"".$_SERVER['PHP_SELF']."?sort=name&order=asc\">";
}
else {
echo "<a href=\"".$_SERVER['PHP_SELF']."?sort=name&order=desc\">";
}
}
echo "File</td><td id=\"bottomborder\" width=\"50\"></a>";
if($_REQUEST['sort']!="size") {
echo "<a href=\"".$_SERVER['PHP_SELF']."?sort=size&order=asc\">";
}
else {
if($_REQUEST['order']=="desc") {#
echo "<a href=\"".$_SERVER['PHP_SELF']."?sort=size&order=asc\">";
}
else {
echo "<a href=\"".$_SERVER['PHP_SELF']."?sort=size&order=desc\">";
}
}
echo "Size</td><td id=\"bottomborder\" width=\"120\" nowrap></a>";
if($_REQUEST['sort']!="date") {
echo "<a href=\"".$_SERVER['PHP_SELF']."?sort=date&order=asc\">";
}
else {
if($_REQUEST['order']=="desc") {#
echo "<a href=\"".$_SERVER['PHP_SELF']."?sort=date&order=asc\">";
}
else {
echo "<a href=\"".$_SERVER['PHP_SELF']."?sort=date&order=desc\">";
}
}
echo "Date Modified</a></td></tr>";
$arsize = sizeof($dirs);
for($i=0;$i<$arsize;$i++) {
echo "\t<tr class=\"row\" onMouseOver=\"this.style.backgroundColor='$highlightcolor'; this.style.cursor='hand';\" onMouseOut=\"this.style.backgroundColor='$normalcolor';\" onClick=\"window.location.href='" . $dirs[$i] . "';\">";
echo "\t\t<td width=\"16\"><img src=\"" . IMAGEROOT
. "folder.gif\" width=\"16\" height=\"16\" alt=\"Directory\"></td>";
echo "\t\t<td><a href=\"" . $dirs[$i] . "\">" . $dirs[$i] . "</a></td>";
echo "\t\t<td width=\"50\" align=\"left\">-</td>";
echo "\t\t<td width=\"120\" align=\"left\" nowrap>" . date ("M d Y h:i:s A", filemtime($dirs[$i])) . "</td>";
echo "\t</tr>";
}
$arsize = sizeof($files);
for($i=0;$i<$arsize;$i++) {
switch (substr($files[$i], -3
)) {
case "jpg":
$img = "jpg.gif";
break;
case "gif":
$img = "gif.gif";
break;
case "zip":
$img = "zip.gif";
break;
case "png":
$img = "png.gif";
break;
case "avi":
$img = "move.gif";
break;
case "mpg":
$img = "move.gif";
break;
case "pdf":
$img = "acrobat.gif";
break;
case "doc":
$img = "doc.gif";
break;
case "xls":
$img = "xls.gif";
break;
case "ppt":
$img = "ppt.gif";
break;
default:
$img = "what.gif";
break;
}
echo "\t<tr class=\"row\" onMouseOver=\"this.style.backgroundColor='$highlightcolor'; this.style.cursor='hand';\" onMouseOut=\"this.style.backgroundColor='$normalcolor';\" onClick=\"window.location.href='" . $files[$i] . "';\">\r\n";
echo "\t\t<td width=\"16\"><img src=\"" . IMAGEROOT
. "$img\" width=\"16\" height=\"16\" alt=\"Directory\"></td>\r\n";
echo "\t\t<td><a href=\"" . $files[$i] . "\" target=\"blank\">" . $files[$i] . "</a></td>\r\n";
echo "\t\t<td width=\"60\" align=\"left\">" . round(filesize($files[$i])/1024) . "KB</td>\r\n";
echo "\t\t<td width=\"160\" align=\"left\" nowrap>" . date ("M d Y h:i:s A", filemtime($files[$i])) . "</td>\r\n";
echo "\t</tr>\r\n";
}
echo "</table>";
} else {
echo "You must be logged in to access this page.";
echo "<br><br>Click <a href=index.php>here</a> to log in.";
unset($_SESSION[username
]);
unset($_SESSION[password
]);
// session_destroy();
}
?>
</body>
</html>
Posted by elg3ne on 10 Mar 2008 8:45 am. Filed under
Scipts & Tutorials.
Posted by elg3ne on 10 Mar 2008 8:37 am. Filed under
Scipts & Tutorials.
<?php
//set the random id length
$random_id_length = 6;
//generate a random id encrypt it and store it in $rnd_id
$rnd_id = crypt(uniqid(rand(),1
));
//to remove any slashes that might have come
$rnd_id = strip_tags(stripslashes($rnd_id));
//Removing any . or / and reversing the string
$rnd_id = str_replace(".","",$rnd_id);
$rnd_id = strrev(str_replace("/","",$rnd_id));
//finally I take the first 10 characters from the $rnd_id
$rnd_id = substr($rnd_id,0
,$random_id_length);
$today = date("mdy");
#echo "Random Id: $today$rnd_id";
$random_req_id=("$today$rnd_id");
?>
Note: I did not write this script. I just found it on the web. I’m just sharing the script. I used it once on my page.
Thank you.
Posted by elg3ne on 5 Mar 2008 10:09 am. Filed under
Scipts & Tutorials.
I used this script to add watermark image on the picture uploaded to my previous site. Very nice script.
*** Use this code anyway you want. Credit to Simon Jansson, author of the script. ***
============================
WATERMARK.PHP
============================
<?php
// NOTE: class is experimental
// Copyright (c) 2006, Simon Jansson <http://www.litewebsite.com> all rights reserved.
// License <http://litewebsite.com/license_BSD.html>
//liteStamp::GDversion();
//$stamp = new LiteStamp('originalImage.jpg', 'stampImage.jpg', 'stamp_');
//$stamp->stampPicture();
class LiteStamp
{
// class variables
private $fileHandle = null;
private $newPictureName = null;
private $pictureInfo = null;
private $pictureName = null;
private $prefix = null;
private $stampInfo = null;
private $stampName = null;
private $stampXpos = null;
private $stampYpos = null;
function __construct
($picture, $stamp, $prefix = 'stamp_'){
$this->
;pictureName
= $picture; // original picture to place stamp/watermark on
$this->
;stampName
= $stamp; // stamp/watermark picture
$this->
;prefix
= $prefix; // prefix of new stamped picture
}// end of construct
public static
function GDversion
(){
// GD 2.0.28 or newer is recommended version to use
// http://www.php.net/manual/en/function.gd-info.php
var_dump(gd_info()); // dump information about your GD version
return true;
}// end of GDversion
private function openImage
($fileName, $type){
// open picture with correct image function. Add more types if needed.
// GIF: http://php.net/manual/en/function.imagecreatefromgif.php
// JPG/JPEG: http://php.net/manual/en/function.imagecreatefromjpeg.php
// PNG: http://php.net/manual/en/function.imagecreatefrompng.php
switch ($type){
case 1: // GIF
$this->
;fileHandle
= imagecreatefromgif($fileName);
break;// case 1
case 2: // JPG/JPEG
$this->
;fileHandle
= imagecreatefromjpeg($fileName);
break;// case 2
case 3: // PNG
$this->
;fileHandle
= imagecreatefrompng($fileName);
break;// case 3
default:
die('Unsupported filetype: '.$fileName);
}
return $this->
;fileHandle
;
}// end of openImage
public function stampPicture
(){
// get picture info such as width, height and extension
// http://php.net/manual/en/function.getimagesize.php
$this->
;pictureInfo
= getimagesize($this->
;pictureName
) or
die('Error getting picture info. Double check file path.');
$this->
;stampInfo
= getimagesize($this->
;stampName
) or
die('Error getting stamp info. Double check file path.');
// open images with class method openImage()
$this->
;pictureFile
= $this->
;openImage
($this->
;pictureName
, $this->
;pictureInfo
[2
]);
$this->
;stampFile
= $this->
;openImage
($this->
;stampName
, $this->
;stampInfo
[2
]);
// position the stamp in the lower right corner
$this->
;stampXpos
= $this->
;pictureInfo
[0
] - $this->
;stampInfo
[0
] - 15; // width - width - margin
$this->
;stampYpos
= $this->
;pictureInfo
[1
] - $this->
;stampInfo
[1
] - 15; // height - height - margin
// set a new name for the stamped picture and keep the original picture intact
$this->
;newPictureName
= $this->
;prefix
.$this->
;pictureName
;
// alpha blending: http://php.net/manual/en/function.imagealphablending.php
imagealphablending($this->
;pictureFile
, true);
// merge the two images: http://php.net/manual/en/function.imagecopymerge.php
imagecopymerge($this->
;pictureFile
, $this->
;stampFile
, $this->
;stampXpos
, $this->
;stampYpos
, 0
, 0
, $this->
;stampInfo
[0
], $this->
;stampInfo
[1
], 100
);
// output the stamped image as GIF, JPG/JPEG or PNG. Add more types if needed.
// default type is the same as the original file
// GIF: http://php.net/manual/en/function.imagegif.php
// JPG/JPEG: http://php.net/manual/en/function.imagejpeg.php
// PNG: http://php.net/manual/en/function.imagepng.php
switch ($this->
;pictureInfo
[2
]){
case 1: // GIF
imagegif($this->
;pictureFile
, $this->
;newPictureName
);
break;// case 1
case 2:// JPG/JPEG
imagejpeg($this->
;pictureFile
, $this->
;newPictureName
);
break;// case 2
case 3: // PNG
imagepng($this->
;pictureFile
, $this->
;newPictureName
);
break;// case 3
default:
die('Unsupported filetype: '.$fileName);
}
return true;
}// end of stampPicture
function destruct
(){
unset($fileHandle, $newPictureName, $pictureInfo, $pictureName, $prefix, $stampInfo, $stampName, $stampXpos, $stampYpos);
}// end of destruct
}// end of class
?>
<?php
$stamp = new LiteStamp
('location_map2.gif', 'watermark.png', 'stamp_');
$stamp->
;stampPicture
();
?>
Posted by elg3ne on 3 Mar 2008 11:13 am. Filed under
Tips & Tricks.
Tips – MSWord Keyboard Shortcut
Keyboard Shortcut
|
Result in Microsoft Word
|
| CTRL and A |
Selects all in the current document. |
| CTRL and B |
Bold text. |
| CTRL and C |
Copies the item or text to the Clipboard and can be pasted using CTRL and V. |
| CTRL and D |
Displays the Font dialogue box. |
| CTRL and E |
Centre Alignment. |
| CTRL and F |
Displays the Find dialog box, to search the current document. |
| CTRL and G |
Displays the Go to dialog box, to go to a specific location in the current document. |
| CTRL and H |
Displays the Replace dialogue box. |
| CTRL and I |
Italic text. |
| CTRL and J |
Full Justification. |
| CTRL and K |
Create Hyperlink |
| CTRL and L |
Left Alignment |
| CTRL and M |
Tab |
| CTRL and N |
Creates a new document. |
| CTRL and O |
Displays the Open File dialogue box. |
| CTRL and P |
Displays the Print dialog box. |
| CTRL and R |
Right Alignment. |
| CTRL and S |
Displays the Save dialog box. |
| CTRL and U |
Underline text |
| CTRL and V |
Pastes the copied item or text from the Clipboard into the current position in the document. |
| CTRL and X |
Cuts the item or text selected to the Clipboard. |
| CTRL and Y |
Redo the last undone action. |
| CTRL and Z |
Undoes the last action. |
| CTRL and ENTER |
Insert Page Break. |
| CTRL and F2 |
Show Print preview. |
| CTRL and F4 |
Closes the active document window. |
| CTRL and F6 |
Opens the next document window. |
Posted by elg3ne on 3 Mar 2008 10:34 am. Filed under
Scipts & Tutorials.
This is very useful if you want to have a countdown script on your web page. I used this script to my online voting script, when the countdown is finished, the online voting is disable.
*** Use this code anyway you want. Credit to Robert Hashemian, author of the script. ***
============================
COUNTDOWN.JS
============================
/*
Author: Robert Hashemian
http://www.hashemian.com/
You can use this code in any manner so long as the author's
name, Web address and this disclaimer is kept intact.
********************************************************
Usage Sample:
<script language="JavaScript"> TargetDate = "12/31/2020 5:00 AM"; BackColor = "palegreen"; ForeColor = "navy"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds."; FinishMessage = "It is finally here!"; </script>
<script src="http://scripts.hashemian.com/js/countdown.js" language="JavaScript"></script>
*/
function calcage(secs, num1, num2) {
s = ((Math.floor(secs/num1))%num2).toString();
if (LeadingZero && s.length < 2)
s = "0" + s;
return "<strong>" + s + "</strong>";
}
function CountBack(secs) {
if (secs < 0) {
document.getElementById("cntdwn").innerHTML = FinishMessage;
return;
}
DisplayStr = DisplayFormat.replace(/%%D%%/g, calcage(secs,86400,100000));
DisplayStr = DisplayStr.replace(/%%H%%/g, calcage(secs,3600,24));
DisplayStr = DisplayStr.replace(/%%M%%/g, calcage(secs,60,60));
DisplayStr = DisplayStr.replace(/%%S%%/g, calcage(secs,1,60));
document.getElementById("cntdwn").innerHTML = DisplayStr;
if (CountActive)
setTimeout("CountBack(" + (secs+CountStepper) + ")", SetTimeOutPeriod);
}
function putspan(backcolor, forecolor) {
document.write("<span id="cntdwn"></span>");
}
if (typeof(BackColor)=="undefined")
BackColor = "white";
if (typeof(ForeColor)=="undefined")
ForeColor= "black";
if (typeof(TargetDate)=="undefined")
TargetDate = "12/31/2020 5:00 AM";
if (typeof(DisplayFormat)=="undefined")
DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
if (typeof(CountActive)=="undefined")
CountActive = true;
if (typeof(FinishMessage)=="undefined")
FinishMessage = "";
if (typeof(CountStepper)!="number")
CountStepper = -1;
if (typeof(LeadingZero)=="undefined")
LeadingZero = true;
CountStepper = Math.ceil(CountStepper);
if (CountStepper == 0)
CountActive = false;
var SetTimeOutPeriod = (Math.abs(CountStepper)-1)*1000 + 990;
putspan(BackColor, ForeColor);
var dthen = new Date(TargetDate);
var dnow = new Date();
if(CountStepper>0)
ddiff = new Date(dnow-dthen);
else
ddiff = new Date(dthen-dnow);
gsecs = Math.floor(ddiff.valueOf()/1000);
CountBack(gsecs);