2007-12-31

* php : IP checker (korean IP)

IPCheck.php
=====================================================
<?
$isDebug = $HTTP_GET_VARS['debug'];
$thisIP = $_SERVER['REMOTE_ADDR'];

function isKoreaIP($ip)
{
  if (!empty($ip) && ip2long($ip)!=-1)
  {
    include("IPKorea.php");
    foreach ($korea_ips as $r)
    {
      $min = ip2long($r[0]);
      $max = ip2long($r[1]);
      if ((ip2long($ip) >= $min) && (ip2long($ip) <= $max))
      {
        return 1;
      }
    }

    return 0;
  }
  else
  {
    return 0;
  }
}

echo isKoreaIP($thisIP);
if($isDebug) echo "<hr>MyIP : $thisIP";
exit();
?>
=====================================================

IPKorea.php
=====================================================
<?
$korea_ips = array
(
  array('202.6.95.0','202.6.95.255'),
  array('202.14.103.0','202.14.103.255'),
  array('202.14.165.0','202.14.165.255'),
  array('202.21.0.0','202.21.7.255'),
  array('202.20.82.0','202.20.82.255'),
  array('202.20.83.0','202.20.86.255'),
  array('202.20.128.0','202.20.255.255'),
  array('202.20.99.0','202.20.99.255'),
  array('202.20.119.0','202.20.119.255'),
  array('202.30.0.0','202.31.255.255'),
  array('203.252.0.0','203.255.255.255'),
  array('203.248.0.0','203.251.255.255'),
  array('203.244.0.0','203.247.255.255'),
  array('117.53.192.0','117.53.255.255'),
  array('117.55.128.0','117.55.191.255'),
  array('117.58.128.0','117.58.143.255'),
  array('152.99.0.0','152.99.255.255'),
  array('117.110.0.0','117.111.255.255'),
  array('118.32.0.0','118.63.255.255')
);
?>
=====================================================

korean IP
* http://ipstat.nida.or.kr/korea_ip/korea_ip4_data.jsp (http://ipstat.nida.or.kr/)

Labels: , , , , ,

* bash : bash pipe redirect

1>filename
# Redirect stdout to file "filename".
1>>filename
# Redirect and append stdout to file "filename".
2>filename
# Redirect stderr to file "filename".
2>>filename
# Redirect and append stderr to file "filename".
&>filename
# Redirect both stdout and stderr to file "filename".

Labels: , ,

2007-12-23

* gvim : .vimrc linux vim config

.vimrc file

set nocompatible
set autoindent
set tabstop=4
set number
set ruler
set background=dark
set nobackup
colorscheme torte
syntax on
set noerrorbells
set t_vb=
map :set enc=utf8
map :set enc=cp949

Labels: , , , ,

* gvim : IE(Internet Explorer) source viewer registry setting

gvim_ie_viewet.reg


REGEDIT4

; This REG-file is generated by ToniArts EasyCleaner
; This contains UNDO-information for the entries deleted. Double click this file
; in Windows Explorer to add these entries back to registry.
; Generated on 2005-08-24 @ AM 10:35:12.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\View Source Editor\Editor Name]
@="C:\\Program Files\\Vim\\vim71\\gvim.exe"

Labels: , , , ,

* php : php + mssql function compile

1. freetds
$ ./configure --prefix=/home/mncast/DBTools/freetds
$ make; make install

2. php
$ ./configure --prefix=/home/mncast/DBTools/php --with-mssql=/home/mncast/DBTools/freetds --disable-libxml --disable-dom --disable-simplexml --disable-xml --disable-xmlreader --disable-xmlwriter --without-pear
$ make; make install


3. freetds.conf

[mncastDB]
host = 10.1.11.2
port = 1433
client charset=EUCKR
tds version = 8.0

Labels: , , , ,

2007-12-13

* vim : remove blank line

:%s/\n^$//gc
:%s/\n^$//c
:%s/\n^$//

g mean global
c mean confirmation

Labels: ,

2007-12-05

* asp : UTF8 encoding Header

asp page include 2 line

<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<% response.Charset="utf-8"%>

1st line mean : tell to script engine encoding type utf8
2nd line mean : tell to browser encoding type utf8

Labels: ,

2007-12-04

* http : how can know http form file upload size before file sending? (Check file size before upload)

if your send file input page like this.

<FORM ACTION="http://somehost/get.php" ENCTYPE="multipart/form-data" METHOD=POST>
What is your name? <INPUT TYPE=TEXT NAME=submitter>
What files are you sending? <INPUT TYPE=FILE NAME=pics>
<input type='submit'>
</FORM>

but the file get.php is not present..
what happen??
normlay..

your browser send all of your choosen file(it 700MB)..
and somehost response to your browser..
"Sorry, the page you requested was not found." <== 404 error

so...
you can't know file size before all file sended.

but

you can know file size before file sneding....

'windows iis http server' is soluntion..
iis is default do not have fileupload function..
so iis server disconnect socket when browser upload file longtime.

upload using put.html to up.asp
(up.asp page return error, socket disconnect but c:\temp\fileNo123\23444 file created)
and
call get.asp?fileSeq=fileNo123

you can get file size which you uploaded.
(size is some diffrent original file, but is not problem)

put.html
////////////////////
<form method='post' action='up.asp?fileNo123' enctype='multipart/form-data'>
<input type='file' name='upfile'>
<input type='submit' value='send'>
</form>
////////////////////

up.asp
////////////////////
<% option explicit %>
<%
Server.ScriptTimeOut = 7200

dim fileSize : fileSize = trim(request.ServerVariables("CONTENT_LENGTH"))
dim fileSeq : fileSeq = trim(request.ServerVariables("QUERY_STRING"))

dim fileName, folderName
folderName = "c:\temp\" & fileSeq
fileName = folderName & "\" & fileSize

'response.write("<hr>")
'response.write(fileSize)
'response.write("<hr>")
'response.write(fileSeq)
'response.write("<hr>")
'response.write(folderName)
'response.write("<hr>")
'response.write(fileName)
'response.write("<hr>")
'response.end()

dim fso
set fso=createobject("scripting.filesystemobject")
'{
  if not fso.FolderExists(folderName) then
    fso.createfolder folderName
  end if

  fso.CreateTextFile fileName, true
'}
set fso=nothing
%>
////////////////////

get.asp
////////////////////
<% option explicit %>
<%
dim fileSeq : fileSeq = trim(request.QueryString("fileSeq"))

dim folderName
folderName = "c:\temp\" & fileSeq

'response.write("<hr>")
'response.write(folderName)
'response.end()

Dim fso, item, fileSize
set fso=createobject("scripting.filesystemobject")
'{
  for each item in fso.GetFolder(folderName).files
    if isnumeric(item.Name) then fileSize = item.Name
 next
'}
set fso = nothing

response.write fileSize
%>
////////////////////

** origin from psseo

Labels: , , , , , , , ,

2007-12-03

* php : ip to long

use php function

ip2long($REMOTE_ADDR);


print ip2long('10.1.100.99')

it print 167863395

Labels:

* vim : ftp edit

vim : ftp edit

:e ftp://loginid@ftp.somedomain.com:21/somefile.txt

loginid : ftp server login account

Labels: ,

* linux : get web server info(os,web server)

linux : get web server info(os,web server)

use this

wget -S http://www.google.com
wget -S http://www.daum.com

Labels: , ,

* windows : disable window zip folders

windows : disable window zip folders

if you do not wan't windows zip folder style

do

1. move c:\windows\system32\dllcache\zipfldr.dll c:\windows\system32\dllcache\~zipfldr.dll
2. regsvr32 /u zipfldr.dll
3. del c:\windows\system32\zipfldr.dll

4. if confirm dll restore cd. cancle and yes

it will work!!

Labels: , , ,

* asp : break loop in while, for loop

asp : break loop in while, for loop
do while loop : exit do
for loop : exit for

ex)
do while i < 10
   document.write(i & "<br>")
   i=i+1
   exit do
loop


for each x in names
   document.write(x & "<br>")
   exit for
next

Labels:

* sed : remove or replace string

sed : remove or replace string

bash script

#!/bin/bash
cat fromFile.txt sed s/"<link>"// > toFile.txt

Labels: