Monday, August 16, 2010

Javascript Disable Functionality of Back Button & Reload or trace when the BACK/Reload button have been clicked

Some people think it cannot be done, and some says "why disabling the functionality of Back & Reload"... for those who really need to disable the functionality of back & reload button only knows why they need to disable it. For example.. most of secure banking site will disable BACK & RELOAD functionality.. which is when user hit BACK button or RELOAD it will destroy your session and redirect to the login page (User must use system menu for navigation in the system). For those who are intend to do such kind of things, you're at right place.

The following code is to destroy user session when user hit BACK & RELOAD button/contextmenu (its mean, anywhere to go inside the system it must be through system menu no BACK button please) and considering the system have a user login session check on every page and html output setting cannot be cached by browser & proxy (in PHP normally set as session_cache_limiter('nocache')) or by sending the following header to make the page is fresh everytime:-


header( "Expires: Sun, 03 Aug 1980 03:00:00 GMT" );
header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
header( "Cache-Control: no-cache, must-revalidate" );
header( "Pragma: no-cache" );


here is the javascript of mine to kill session when user hit back & reload:


var historylength = history.length;
var inithistorylength = historylength;
function prepareKillSession(){
window.history.forward();
temp = history.length;
if(historylength == temp && inithistorylength != temp){
//whatever code you want to do here... can alert or redirect to warning page
document.location.href = 'login.php';
} else{
historylength = temp;
}
}




the system uses IFRAME.. and the page of the system will be loaded into the IFRAME and the javascript code to disable the BACK & RELOAD functionality will be put in the header of page that hold the IFRAME code

call the javascript function inside the IFRAME onload e.g:

< i f r a m e  src="index.php" height="300" id="mainframe" onload="prepareKillSession();" width="400">< / i f r a m e >


Ok done.. thats all.. already tested on Mozilla,IExplorer & Google Chrome

Any advice,suggestion & critics are welcome... it might be some other good way to do.. i dont know... you might be knew something else better

Labels: , , , , ,

Wednesday, December 17, 2008

BitmapExporter Flash Player 10 File Reference Issue

I skip using the filereference object class to open the Save Dialog Box since i noticed the security enghancement in the filereference class in flash player 10.

here is my trick

i used the browser browser open/save dialog instead of flash command to open the dialog...i set the dontRetrieve value to true, so it will not do a retrieve task by popping up the save dialog box by filereference object.

in the flash document..
put the 'saved' listener as follows

BitmapExporter.
addEventListener( "progress", this);
BitmapExporter.addEventListener( "status", this);
BitmapExporter.addEventListener( "error", this);
BitmapExporter.addEventListener("saved", this);


and this is the listener function

function saved(evt:Object):Void {
getURL(evt.url + "&delete=1", "_blank");
}


i set the dontRetrieve value to true

BitmapExporter.saveBitmap( bitmap:BitmapData, filename:String, [mode:String], [lossBits:Number], [jpegQuality:Number], [dontRetrieve:Boolean] );


BitmapExporter.saveBitmap(snapshot, "Recommendation_Sheet.jpg", "default", 0,70,true);

By setting it to TRUE, it will not use the FileReference() to open the dialog window....


Then in the BitmapExporter.php add the following line

header('Content-Disposition: attachment; filename="myfilename.'.$format.'"');

see my code below where i put the line

----------------------------------------

case "download":
$file = $RELATIVE_SAVEPATH.basename($_GET["name"]);
if (isset($_GET["delete"]))
{
$deleteFile = ($_GET["delete"] == "1");
}
if (file_exists($file))
{
$_format = explode( ".", $file);
$format = strtolower( $_format[1] );

switch ( $format )
{
case "png":
header ("Content-type: image/png");
break;

case "jpg":
case "jpeg":
header ("Content-type: image/jpeg");
break;

case "bmp":
header ("Content-type: image/bmp");
break;

default:
if ($LOGGING) error_log("Unknown filetype: ".$format, 3, "be_log" );
exit();
break;
}
header('Content-Disposition: attachment; filename="Recommendation_Sheet.'.$format.'"');
header("Content-Length: ".(string)(filesize($file)));

readfile( $file );
if ($deleteFile) while(!unlink( $file ));
} else {
if ($LOGGING) error_log($file." does not exist", 3, "be_log" );
exit();
}

cleanUpTempFolder();
break;

Labels: , ,

Wednesday, August 01, 2007

How to bypass WPA (Windows Activation) on Windows XP

How to bypass WPA (Windows Activation) on Windows XP
Tested on Windows XP Professional SP2 and Windows Server 2003 R2.

First, click "Run..." on your start menu, type "regedit" and press enter.
The Registry Editor opens up, and you are presented with a long list of keys on the left.
Browse through the list to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\WPAEvents.
(If you can't find this key, you're screwed!)
On the right, you should see a stringz value named OOBETimer.
This is the activation stuff. If you change it, Windows will change it back within a few seconds.
Whatever its value is, change it to FF D5 71 D6 8B 6A 8D 6F D5 33 93 FD.
(At first I thought this was different for each machine/serial number, but it's always the same if windows is activated...LOL)
After you've changed it, right-click WPAEvents and choose "Permissions..."
A little window opens up with a list of user names. Click SYSTEM, and in the list below ("Permissions for SYSTEM") check every box under "Deny". Click OK to own windows. You don't even have to reboot lol.
If you're too slow windows might change it back, so just hit F5 to refresh and make sure it got saved.
If not, just try again. Microsoft owns for making it so easy to hack their software.
So, just keep on enjoying an activated version of windows. swapnil_009 over and out!

The problem most of you are probably having is when you get to the "Permissions" section, so i expand on this tricky area.

Under "Permissions..." for WPAEvents, Go into the Advanced settings.

UNCHECK "Inhereit from parent the permission entries that apply to child objects. Include these with entries explicitly defined here"

When prompted what course of action to take from here, click "COPY"

From there, Highlight the SYSTEM line, and click edit.

Deny all options, apply, and run a free copy of windows.

Thursday, May 17, 2007

Change oracle data type

Run through the following steps, substituting your table and field names, and the required datatype.

-- Create a new temporary holding field with the target datatype

ALTER TABLE table_name
ADD temporary_field VARCHAR2(100) NULL;


-- Move the data to the new field and cast to the new datatype accordingly

UPDATE table_name
SET temporary_field=TO_CHAR(original_field);


-- If the original_field has dependent constraints, they

-- must be dropped now.


-- If the original_field is the primary key
-- Drop the primary key constraint

ALTER table table_name
DROP PRIMARY KEY;



-- If the original field cannot be null
-- Update the not null constraint for the original field

ALTER TABLE table_name
MODIFY original_field NULL;


-- Delete everything in the original field

UPDATE table_name
SET original_field=NULL;


-- Modify the datatype of the original field

ALTER TABLE table_name
MODIFY original_field VARCHAR2(100);


-- Move the data back to the original field

UPDATE table_name
SET original_field=temporary_field;


-- Add the not null constraint back if necessary

ALTER TABLE table_name
MODIFY original_field NOT NULL;


-- Add the primary key back if necessary
ALTER TABLE table_name
ADD PRIMARY KEY (original_field);


-- Drop the temporary holding field

ALTER TABLE table_name
DROP COLUMN temporary_field;


-- Done.

Tuesday, May 15, 2007

PHP: My Country Dropdown List


function ComboCountry($selected = 0){



$countries = "[Please Select]:Afghanistan:Albania:Algeria:American Samoa:Andorra:Angola:Anguilla:Antarctica:Antigua and Barbuda:Argentina:Armenia:Aruba:Ascension Island:Australia:Austria:Azerbaijan:Bahamas:Bahrain:Bangladesh:Barbados:Belarus:Belgium:Belize:Benin:Bermuda:Bhutan:Bolivia:Bosnia and Herzegovina:Botswana:Bouvet Island:Brazil:British Indian Ocean Territory:Brunei:Bulgaria:Burkina Faso:Burundi:Cambodia:Cameroon:Canada:Cape Verde:Cayman Islands:Central African Republic:Chad:Chile:China:Christmas Island:Cocos (Keeling) Islands:Colombia:Comoros:Congo:Congo (DRC):Cook Islands:Costa Rica:Côte d'Ivoire:Croatia:Cuba:Cyprus:Czech Republic:Denmark:Djibouti:Dominica:Dominican Republic:Ecuador:Egypt:El Salvador:Equatorial Guinea:Eritrea:Estonia:Ethiopia:Falkland Islands (Islas Malvinas):Faroe Islands:Fiji Islands:Finland:France:French Guiana:French Polynesia:French Southern and Antarctic Lands:Gabon:Gambia, The:Georgia:Germany:Ghana:Gibraltar:Greece:Greenland:Grenada:Guadeloupe:Guam:Guatemala:Guernsey:Guinea:Guinea-Bissau:Guyana:Haiti:Heard Island and McDonald Islands:Honduras:Hong Kong SAR:Hungary:Iceland:India:Indonesia:Iran:Iraq:Ireland:Isle of Man:Israel:Italy:Jamaica:Japan:Jersey:Jordan:Kazakhstan:Kenya:Kiribati:Korea:Kuwait:Kyrgyzstan:Laos:Latvia:Lebanon:Lesotho:Liberia:Libya:Liechtenstein:Lithuania:Luxembourg:Macao SAR:Macedonia, Former Yugoslav Republic of:Madagascar:Malawi:Malaysia:Maldives:Mali:Malta:Marshall Islands:Martinique:Mauritania:Mauritius:Mayotte:Mexico:Micronesia:Moldova:Monaco:Mongolia:Montserrat:Morocco:Mozambique:Myanmar:Namibia:Nauru:Nepal:Netherlands:Netherlands Antilles:New Caledonia:New Zealand:Nicaragua:Niger:Nigeria:Niue:Norfolk Island:North Korea:Northern Mariana Islands:Norway:Oman:Pakistan:Palau:Palestinian Authority:Panama:Papua New Guinea:Paraguay:Peru:Philippines:Pitcairn Islands:Poland:Portugal:Puerto Rico:Qatar:Reunion:Romania:Russia:Rwanda:Samoa:San Marino:São Tomé and Príncipe:Saudi Arabia:Senegal:Serbia, Montenegro:Seychelles:Sierra Leone:Singapore:Slovakia:Slovenia:Solomon Islands:Somalia:South Africa:South Georgia and the South Sandwich Islands:Spain:Sri Lanka:St. Helena:St. Kitts and Nevis:St. Lucia:St. Pierre and Miquelon:St. Vincent and the Grenadines:Sudan:Suriname:Svalbard and Jan Mayen:Swaziland:Sweden:Switzerland:Syria:Taiwan:Tajikistan:Tanzania:Thailand:Timor-Leste:Togo:Tokelau:Tonga:Trinidad and Tobago:Tristan da Cunha:Tunisia:Turkey:Turkmenistan:Turks and Caicos Islands:Tuvalu:Uganda:Ukraine:United Arab Emirates:United Kingdom:United States:United States Minor Outlying Islands:Uruguay:Uzbekistan:Vanuatu:Vatican City:Venezuela:Vietnam:Virgin Islands:Virgin Islands, British:Wallis and Futuna:Yemen:Zambia:Zimbabwe";



$arr = explode(":",$countries);



echo "<select name=\"Country\" id=\"Country\">";

for($a=0;$a<count($arr);$a++){

echo "<option value=\"".$a."\" ";

if($selected == $a){

echo "selected";

}

echo ">".$arr[$a]."</option>";

}

echo "</select>";

}

Labels:

Monday, May 14, 2007

Unable to Open Hard or USB Flash Drive with Windows Script Host Cannot Find Script File autorun.vbs Error

In some situation especially when anti-virus program has cleaned, healed, disinfected or removed a worm, trojan horse or virus from computer, there may be error happening whenever users try to open or access the drive by double clicking on the disk drive icon in Explorer or My Computer window to try to enter the drive’s folder. The problem or symptom happens in hard disk drive, portable hard disk drive or USB flash drive, and Windows will prompt a dialog box with the following message:


Windows Script Host

Can not find script file autorun.vbs.

Sometimes you will be asked to debug the VBScript with error code of 800A041F - Unexpected ‘Next’.

or

Choose the program you want to use to open this file with:

In this case, the “Always use the selected program to open this kind of file” option is grayed out.

The symptom occurs because when autorun.vbs is created by trojan horse or virus. The virus normally loads autorun.inf file to root folder of all hard drive or USB drive, and then execute autorun.bat file which contains script to apply and merge autorun.reg into the registry, with possible change to the following registry key to ensure that virus is loaded when system starts:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
Userinit=userinit.exe,autorun.exe

Finally, autorun.bat will call wscript.exe to run autorun.vbs.

When antivirus or security software detected the autorun.vbs file as infected, the file will be deleted or removed or quarantined. However, other files (autorun.*) and registry value still referring to autorun.vbs, and this document no longer exists, hence the error when users double click to open a drive folder.

To correct and solve this error, follow this steps:

Run Task Manager (Ctrl-Alt-Del or right click on Taskbar)
Stop wscript.exe process if available by highlighting the process name and clicking End Process.
Then terminate explorer.exe process.
In Task Manager, click on File -> New Task (Run…).
Type “cmd” (without quotes) into the Open text box and click OK.
Type the following command one by one followed by hitting Enter key:
del c:\autorun.* /f /s /q /a
del d:\autorun.* /f /s /q /a
del e:\autorun.* /f /s /q /a

c, d, e each represents drive letters on Windows system. If there are more drives or partitions available, continue to command by altering to other drive letter. Note that you must also clean the autorun files from USB flash drive or portable hard disk as the external drive may also be infected.

In Task Manager, click on File -> New Task (Run…).
Type “regedit” (without quotes) into the Open text box and click OK.
Navigate to the following registry key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon

Check if the value name and value data for the key is correct (the value data of userint.exe include the path which may be different than C drive, which is also valid, note also the comma which is also needed):
“Userinit”=”C:\WINDOWS\system32\userinit.exe,”

If the value is incorrent, modify it to the valid value data.

Labels:

Friday, December 08, 2006

Filter Input; Only Alphnumeric

if (!ctype_alnum($input)){
//Invalid input
}

//return true if $input = "abcdeFg123DDD"

//return false if $input = "#a!bcdeFg123DDD";