Friday, December 10, 2004

How to run a piece of JavaScript code after a certain timed delay?

This allows you to execute a section of code after a specified amount of time
has passed.


<script type="text/javascript">

<!--

setTimeout("alert('Thirty seconds has passed.');",30000);

// -->

</script>

Allow EZ_Result to display +5Pages link

You can download ez_resuls.php from http://php.justinvincent.com/


Allow EZ_Result to display nav bar like this

365 Results: [start] 1 2 3 4 5 +5Pages [last]


For this to work, I added a few lines to the ez_results.php class as follows


/********************************************************

* NAVIGATION FORMATTING

*/

var $show_next_x_page = true;

var $text_hover_msg_next_x = '+NUMBER Pages';

var $text_next_x_page = '+NUMBER Pages';


In function build_navigation(), I added the following.


$current_page = ($_REQUEST['BRSR'] / $this->num_results_per_page) +1;

$page_left = $this->num_pages-$current_page ;



if($this->show_next_x_page)

if ( ($this->num_pages >= $this->num_browse_links) && (($_REQUEST['BRSR']
+ $this->num_results_per_page) < $this->num_results))

{

if(($page_left * $this->num_results_per_page >= $this->num_results
) || ($current_page * $this->num_results_per_page) < $this->num_results
)

{

if($page_left >= $this->next_x_pages){

$cur_a = $_REQUEST['BRSR'] + $this->num_results_per_page * $this->next_x_pages;

$out .= $this->create_link(preg_replace("/\?.*/",'',$_SERVER['PHP_SELF'])
. '?BRSR='. ($cur_a) .$this->qs,$this->merge_num('next_x_page',$this->next_x_pages),$this->merge_num('hover_msg_next_x',$this->next_x_pages),$this->get_style('next')).'
';

}

else{

$cur_a = $_REQUEST['BRSR'] + $this->num_results_per_page * $page_left;

$out .= $this->create_link(preg_replace("/\?.*/",'',$_SERVER['PHP_SELF'])
. '?BRSR='. ($cur_a) .$this->qs,$this->merge_num('next_x_page',$page_left),$this->merge_num('hover_msg_next_x',$page_left),$this->get_style('next')).'
';

}

}



}

Thursday, December 09, 2004

How do I identify unknown open ports and their associated applications.?

You can go to http://www.foundstone.com
and download Fport. It will show you something like this


FPort v2.0 - TCP/IP Process to Port Mapper

Copyright 2000 by Foundstone, Inc.

http://www.foundstone.com


Pid Process Port Proto Path

1764 inetinfo -> 25 TCP C:\WINDOWS\System32\inetsrv\inetinfo.exe

1764 inetinfo -> 80 TCP C:\WINDOWS\System32\inetsrv\inetinfo.exe

1620 Apache -> 81 TCP C:\Apache\Apache2\bin\Apache.exe

988 -> 135 TCP

4 System -> 139 TCP

1764 inetinfo -> 443 TCP C:\WINDOWS\System32\inetsrv\inetinfo.exe

4 System -> 445 TCP

1764 inetinfo -> 1038 TCP C:\WINDOWS\System32\inetsrv\inetinfo.exe

2536 mqsvc -> 1047 TCP C:\WINDOWS\System32\mqsvc.exe

5632 msnmsgr -> 1056 TCP C:\Program Files\MSN Messenger\msnmsgr.exe

5632 msnmsgr -> 1057 TCP C:\Program Files\MSN Messenger\msnmsgr.exe

5632 msnmsgr -> 1058 TCP C:\Program Files\MSN Messenger\msnmsgr.exe

5632 msnmsgr -> 1059 TCP C:\Program Files\MSN Messenger\msnmsgr.exe

5632 msnmsgr -> 1060 TCP C:\Program Files\MSN Messenger\msnmsgr.exe

3076 -> 1062 TCP

1736 FlashComAdmin -> 1111 TCP C:\Program Files\Macromedia\Flash Communica

tion Server MX\FlashComAdmin.exe

3796 OSDK62http -> 1422 TCP C:\Program Files\Openwave\SDK 6.2.2\program

\http\OSDK62http.exe

5480 firefox -> 1668 TCP C:\Program Files\Mozilla Firefox\firefox.ex

e

5480 firefox -> 1669 TCP C:\Program Files\Mozilla Firefox\firefox.ex

e

2536 mqsvc -> 1801 TCP C:\WINDOWS\System32\mqsvc.exe

2492 FlashCom -> 1935 TCP C:\Program Files\Macromedia\Flash Communica

tion Server MX\FlashCom.exe

2184 omtsreco -> 2030 TCP c:\oracle\ora92\bin\omtsreco.exe

2536 mqsvc -> 2103 TCP C:\WINDOWS\System32\mqsvc.exe

2536 mqsvc -> 2105 TCP C:\WINDOWS\System32\mqsvc.exe

2536 mqsvc -> 2107 TCP C:\WINDOWS\System32\mqsvc.exe

How to open a file as a string from a URL in PHP?

//
// This will read the text file from http://yoursite.com/test.txt

// and store the contents of test.txt into $contents

//


$handle = fopen("http://yoursite.com/test.txt", "rb");

$contents = '';

while (!feof($handle)) {

$contents .= fread($handle, 8192);

}

fclose($handle);

Tuesday, December 07, 2004

WML 怎麼顯示中文?

因為 WML 只接受 UNICODE, 如果你沒有經過 convert, 你就會看到亂碼

下面 mb_convert_encoding($str, "UTF-8", "BIG-5"); 就可以把字串 convert
成 Unicode 啦

<?php

// send wml headers

header("Content-type: text/vnd.wap.wml");

echo "<?xml version=\"1.0\"?>";

echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\""

. " \"http://www.wapforum.org/DTD/wml_1.1.xml\">";

?>

<wml>

<card>

<p>

<?php

$str = "哈囉";

$str = mb_convert_encoding($str, "UTF-8", "BIG-5");

print "<br/>Hello World! $str";

?>

</p>

</card>

</wml>

How to create a Hello World WML script using PHP?

// send wml headers
header("Content-type: text/vnd.wap.wml");
echo "";
echo ". " \"http://www.wapforum.org/DTD/wml_1.1.xml\">";
?>



print "
Hello World!";
?>