B / Y / U / S
HOME À¥ È£½ºÆà µµ¸ÞÀÎ ¸Å´º¾ó °í°´Áö¿ø ¼³Á¤Á¤º¸ °èÁ¤½Åû 2024-12-23 Monday 
À¥ È£½ºÆÃ
# °øÁö »çÇ×
# ÀÚÁÖ ¹¯´Â Áú¹®
# Áú¹®°ú ´äº¯
# °¡ÀÔ ¹®ÀÇ
Ä¿¹Â´ÏƼ
# ÀÚÀ¯°Ô½ÃÆÇ
# ¸®´ª½ºÆÁ
# ¾ÆÀÌÅ¥ Å×½ºÆ®
# ³»È¨ ¼Ò°³
# °Ö·¯¸®
# ÀÚ·á½Ç

  ¸®´ª½ºÆÁ  Go Unix Power Tools Online Book Go Bash Guide
Read No. 7 article 2001-08-04 08:22:42
NickName   Ç®ºñ´©
Subject   À¯¿ëÇÑ PHP À¯Æ¿¸®Æ¼ ÇÔ¼ö ¶óÀ̺귯¸® Àü°Ý °ø°³ !
±è°üÁß ´ÔÀÇ ±ÛÀÔ´Ï´Ù.

¾à 2³â °¡±î¿î ¼¼¿ùµ¿¾È PHP·Î ÇÁ·Î±×·¥À» ÇØ¿À¸é¼­ ¼ö½Ã·Î ºó¹øÇÏ°Ô »ç¿ëµÊ¿¡µµ ºÒ±¸ÇÏ°í 
¸Å¹ø »õ·Î ÄÚµùÇϱ⠽¬¿î ºÎºÐµéÀ» ÇϳªµÑ¾¿ ÇÔ¼ö·Î ¸¸µé¾î ¸ð¾Æ³õ°í ÇÊ¿äÇÒ¶§ includeÇؼ­ 
»ç¿ëÇØ¿Ô´ø °ÍµéÀÔ´Ï´Ù. ´Ù¸¥ PHP ÇÁ·Î±×·¡¸Óµµ ºñ½ÁÇÑ ºÎºÐ¿¡¼­ ³ë°¡´Ù°¡ µÇ´Â °ÍÀ» 
´À³¢¼ÌÀ» °Í °°¾Æ¼­ ÀÌ·¸°Ô °ø°³ÇÏ°Ô µÇ¾ú½À´Ï´Ù. º°°Å ¾Æ´Ò¼öµµ ÀÖ°ÚÁö¸¸ µµ¿òÀÌ µÆÀ¸¸é 
ÇÕ´Ï´Ù. ´Ù¸¥ ºÐµéÀº ÀÌ·± ºÎºÐÀ» ¾î¶»°Ô ó¸®ÇÏ°í °è½ÅÁö ±Ã±ÝÇϳ׿ä. 

¡Ø ¾Æ·¡ÀÇ ÇÔ¼ö¸»°íµµ MySQL,Oracle,PostgreSQLµîÀÇ º¹ÀâÇÑ DB 󸮷çƾÀ» °£´ÜÈ÷ 
Çϱâ À§ÇØ °øÅë ÀÎÅÍÆäÀ̽ºÃ³·³ ¸¸µç ÇÔ¼öµéµµ Àִµ¥ ±×°Ç ³ªÁß¿¡ ½Ã°£ÀÌ ³ª¸é ¿Ã¸®°Ú½À´Ï´Ù. 



// 
// Filename : FUNC.PHP (±×³É Á¦°¡ ¾²´Â ÆÄÀϸíÀÔ´Ï´Ù.) 
// Author : Spectator(Kim Kwan Joong) 
// 


// require³ª include½Ã Áߺ¹¼±¾ð ¹æÁö¸¦ À§ÇÑ ºÎºÐ 
if( !$__FUNC_PHP__ )   
{ 
  $__FUNC_PHP__ = 1; 


  // óÀ½ ¸î°³´Â ÀÚ¹Ù½ºÅ©¸³Æ®¸¦ ó¸®ÇÏ´Â ÇÔ¼öÀÔ´Ï´Ù. 
  // ½ÇÁ¦·Î °¡Àå ÀÚÁÖ »ç¿ëµÇ´Â ÇÔ¼öµéÀÌÁÒ. 
  // (ÀÏÀÏÀÌ <script>...</script> ÀÔ·ÂÇÏ´Â ³ë°¡´Ù¶õ...-_-;) 


  // GoBack() : ÀÌÀüÆäÀÌÁö·Î ¹Ù·Î °©´Ï´Ù. 
  // GoBack($msg) : $msg¸¦ °æ°í¸Þ½ÃÁö·Î Ãâ·ÂÇÏ°í °©´Ï´Ù. 

  function GoBack($msg = "") 
  { 
    echo "<script language=javascript>\n<!--\n"; 
    if( $msg ) 
      echo "alert('" . $msg . "');\n"; 
    echo "history.back();\n"; 
    echo "// -->\n</script>\n"; 
  } 


  // CloseWin() : ÇöÀç À©µµ¿ìâÀ» ´Ý½À´Ï´Ù. 
  // CloseWin($msg) : $msg¸¦ °æ°í¸Þ½ÃÁö·Î Ãâ·ÂÇÏ°í ´Ý½À´Ï´Ù. 
  // CloseWin($msg,1) : 
  //  $msg¸¦ °æ°í¸Þ½ÃÁö·Î Ãâ·ÂÇÏ°í ¿ø·¡ ÀÚ½ÅÀ» ¿¬ ºÎ¸ðÀ©µµ¿ì¸¦ 
  //  Reload½Ãŵ´Ï´Ù. (¹Ù²ï ³»¿ëÀ» Àû¿ë½Ãų¶§ »ç¿ë) 

  function CloseWin($msg = "", $refresh = 0) 
  { 
    echo "<script language=javascript>\n<!--\n"; 
    if( $msg ) 
      echo "alert('" . $msg . "');\n"; 
    if( $refresh ) 
      echo "opener.location.reload();\n"; 
    echo "top.close();\n"; 
    echo "// -->\n</script>\n"; 
  } 


  // GoTo($url) : ÇöÀç ÆäÀÌÁö¸¦ $url·Î ´ëÄ¡½Ãŵ´Ï´Ù. 
  // ÇöÀç ÆäÀÌÁö´Â history»ó¿¡ ³²Áö ¾Ê½À´Ï´Ù. 
  // (ÀԷ¹ÞÀº Á¤º¸¸¦ DBµî¿¡ ÀúÀåÇÏ°í ³­ µÚ¿¡ ´Ù¸¥ ÆäÀÌÁö·Î À̵¿ÇÒ¶§ 
  // ÀúÀåÇÏ´Â ÆäÀÌÁö°¡ È÷½ºÅ丮¿¡ ³²À¸¸é "µÚ·Î"¸¦ ´­·¶À» ¶§ ÁÁÁö 
  // ¾ÊÀº ÀÏÀÌ ¹ß»ýÇÏ°ÚÁÒ...) 
  // GoTo($url, $msg) : $msg¸¦ °æ°í¸Þ½ÃÁö·Î Ãâ·ÂÇÏ°í À̵¿ÇÕ´Ï´Ù. 
  // GoTo($url, $msg, $target) : $msg¸¦ °æ°í¸Þ½ÃÁö·Î Ãâ·ÂÇÏ°í 
  // $target¿¡ ÇØ´çÇÏ´Â ÇÁ·¹ÀÓÀ» $url·Î ´ëÄ¡½Ãŵ´Ï´Ù. 

  function GoTo($url, $msg = "", $target = "") 
  { 
    echo "<script language=javascript>\n<!--\n"; 
    if( $msg ) 
      echo "alert('" . $msg . "');\n"; 
    if( $target ) 
      echo $target . "."; 
    echo "location.replace('" . $url . "');\n"; 
    echo "// -->\n</script>\n"; 
  } 


  // Alert($msg) : ´Ü¼øÈ÷ $msg¸¦ °æ°í¸Þ½ÃÁö·Î Ãâ·ÂÇÕ´Ï´Ù. 
  // (È®ÀÎÀ» ´©¸£¸é °è¼Ó ±× µÚÀÇ Ã³¸®¸¦ °è¼ÓÇÕ´Ï´Ù) 

  function Alert($msg) 
  { 
    echo "<script language=javascript>\n<!--\n"; 
    echo "alert('" . $msg . "');\n"; 
    echo "// -->\n</script>\n"; 
  } 


  // FreadAll($filename) : $filename¿¡ ÇØ´çÇÏ´Â ÆÄÀϳ»¿ë Àüü¸¦ Àо 
  // ¹®ÀÚ¿­·Î ¸®ÅÏÇØÁÝ´Ï´Ù. (ºñ½ÁÇÑ readfile()À̳ª file()ÇÔ¼ö°¡ ÀÖÁö¸¸ 
  // readfile()Àº ¹«Á¶°Ç Ç¥ÁØÃâ·ÂÀ¸·Î °¡°í file()Àº °¢ ÇàÀÌ ¹è¿­·Î 
  // ÀÐÇôÁö±â ¶§¹®¿¡ ÀüüÆÄÀÏÀ» ÁöÁ¤ÇÑ º¯¼ö·Î ÀоîµéÀÏ ¶§´Â ÀÌ ÇÔ¼ö¸¦ 
  // »ç¿ëÇÕ´Ï´Ù.) 

  function FreadAll($filename) 
  { 
    if( !file_exists($filename) ) 
      return ""; 

    $fp = fopen($filename, "r"); 
    $text = fread($fp, filesize($filename)); 
    fclose($fp); 

    return $text; 
  } 


  // FwriteAll($filename, $text) : FreadAll()°ú ¹Ý´ë·Î $text ¹®ÀÚ¿­ 
  // Àüü¸¦ $filenameÀ¸·Î µÈ ÆÄÀÏ·Î ÀúÀåÇÕ´Ï´Ù. 

  function FwriteAll($filename, $text) 
  { 
    $fp = fopen($filename, "w"); 
    $ret = fwrite($fp, $text); 
    fclose($fp); 

    return $ret; 
  } 


  // html_format($text) : º»¹®ÀÇ ÀϺηΠ³ª¿À´Â ³»¿ëÀÌ Àüü html¿¡ 
  // ¿µÇâÀ» ¹ÌÄ¡´Â °ÍÀ» ¸·°Å³ª ƯÁ¤Å±×ÀÇ »ç¿ëÀ» ¹æÁöÇϱâ À§ÇØ 
  // È­¸é¿¡ Ãâ·ÂÇϱâ Àü¿¡ ű׸¦ ¹«È¿È­½Ãų ¶§ »ç¿ëÇÏ´Â ÇÔ¼öÀÔ´Ï´Ù. 
  // (Daum¿¡¼­ ƯÁ¤Å±׸¦ ¹æÁöÇÏ´Â °ÍÀ» º¸°í ¸¸µé¾îºÃ½À´Ï´Ù.) 
  // ±âº»ÀûÀ¸·Î nl2br()·Î Ç౸ºÐÀ» <br>·Î ó¸®ÇÕ´Ï´Ù. 
  // html_format($text, 0) : nl2br()󸮸¸ ÇÏÁö ¾Ê½À´Ï´Ù. 

  function html_format($text, $break = 1) 
  { 
    $text = stripslashes($text); 
    $text = ereg_replace("<\?", "<?", $text); 
    $text = ereg_replace("\?>", "?>", $text); 
    $text = eregi_replace("<html", "<x-html", $text); 
    $text = eregi_replace("</html", "</x-html", $text); 
    $text = eregi_replace("<body", "<x-body", $text); 
    $text = eregi_replace("</body", "</x-body", $text); 
    $text = eregi_replace("<head", "<x-head", $text); 
    $text = eregi_replace("</head", "</x-head", $text); 
    $text = eregi_replace("<title", "<x-title", $text); 
    $text = eregi_replace("</title", "</x-title", $text); 
    $text = eregi_replace("<script", "<x-script", $text); 
    $text = eregi_replace("</script", "</x-script", $text); 
    $text = eregi_replace("<form", "<x-form", $text); 
    $text = eregi_replace("</form", "</x-form", $text); 
    $text = eregi_replace("<select", "<x-select", $text); 
    $text = eregi_replace("</select", "</x-select", $text); 
    $text = eregi_replace("<textarea", "<x-textarea", $text); 
    $text = eregi_replace("</textarea", "</x-textarea", $text); 
    $text = eregi_replace("<input", "<x-input", $text); 

    // °ø¹é¸¸Å­ °ø°£À» ³ÐÇôÁÖ±â À§ÇÑ ºÎºÐÀÔ´Ï´Ù. 
    // ereg_replace(" "," ", $text)ó·³ »ç¿ëÇÏ°Ô µÇ¸é 
    // ºê¶ó¿ìÀú¿¡¼­ ÀÚµ¿ Ç౸ºÐÀ» ¸øÇØÁֱ⠶§¹®¿¡ ¹®ÀÚ¿­ÀÇ ±æÀ̸¸Å­ 
    // Ç¥ÀÇ ÆøÀÌ ´Ã¾î³ª°Å³ª ÇÏ´Â ºÎÀÛ¿ëÀÌ »ý±æ ¼ö ÀÖ½À´Ï´Ù. 
    // ÀÌ ºÎºÐÀº ÇÊ¿ä¿¡ µû¶ó »ç¿ëÇÏ½Ã¸é µË´Ï´Ù. 
    $text = ereg_replace("  ","  ",$text); 

    if( $break ) 
      $text = nl2br($text); 

    return $text; 
  } 


  // LongCut($s, $l) : ¹®ÀÚ¿­ $s¸¦ $l¸¸Å­ À߶󳻰í "..."À» µÚ¿¡ 
  // ºÙ¿©ÁÝ´Ï´Ù. °Ô½ÃÆÇ ¸®½ºÆ® µî¿¡¼­ ±ä ¹®ÀÚ¿­À» ª°Ô º¸¿©ÁÙ ¶§ 
  // »ç¿ëÇÕ´Ï´Ù. ¹«Á¶°Ç À߶󳻸é ÇѱÛÀÌ Áß°£¿¡ °É·ÈÀ» ¶§ "?"·Î 
  // 󸮵DZ⠶§¹®¿¡ µÚ¿¡¼­ºÎÅÍ ½ºÄµÇؼ­ À߸®Áö ¾Êµµ·Ï ó¸®Çß½À´Ï´Ù. 

  function LongCut($s, $l) 
  { 
    if( strlen($s) <= ($l+3) ) 
      return $s; 

    if( ord($s[$l-1]) > 127 ) 
    { 
      $nc = 2; 
      while( ord($s[$l-$nc]) > 127 ) 
        $nc++; 
      $l -= !($nc & 1); 
    } 

    return substr($s, 0, $l) . "..."; 
  } 


  // ParseSession($sess) : $sess·Î ¹ÞÀº ¼¼¼Ç°ª(¼­¹ö»ó¿¡ ÀúÀåµÇ´Â ÆÄÀÏ) 
  // À» name => value·Î ÀÌ·ç¾îÁø array·Î ¸®ÅÏÇÕ´Ï´Ù. 
  // ȸ¿øÀÎÁõÀ» ¼¼¼ÇÀ¸·Î ó¸®ÇÑ´Ù°í Çصµ ÇöÀç Á¢¼ÓÇØ Àִ ȸ¿øµéÀÌ 
  // ´©°¡ ÀÖ´ÂÁö ¾Ë¾Æº¸·Á°í ÇÏ¸é ¼­¹ö¿¡ ÀúÀåµÇ¾î ÀÖ´Â ¼¼¼ÇÆÄÀϵéÀ» 
  // Á÷Á¢ Àоîµé¿© ó¸®ÇÏÁö ¾ÊÀ¸¸é ¾Ë ±æÀÌ ¾ø¾î¼­ ¼¼¼ÇÆÄÀÏÀ» ºÐ¼®ÇÑ 
  // ³¡¿¡ ¸¸µé¾îºÃ½À´Ï´Ù. ¿Ö ÀÌ ÇÔ¼ö°¡ Á¦°øµÇÁö ¾Ê´ÂÁö ±Ã±ÝÇϱº¿ä. 
  // ¸¸¾à $sess°¡ 'id|s:5:"guest";name|s:6:"¹æ¹®ÀÚ";' ÀÌ·¸°Ô µÅÀÖÀ»¶§ 
  // $buf = ParseSession($sess); 
  // => $buf[id] = "guest"; $buf[name] = "¹æ¹®ÀÚ"; ÀÌ·¸°Ô µË´Ï´Ù. 

  function ParseSession($sess) 
  { 
    $p = explode(";", $sess); 
    $m = count($p); 

    for($i=0; $i < ($m-1); $i++) 
    { 
      for($k=$i; !strstr($p[$i+1], "|") && (($i+1) < $m); $i++) 
        $p[$k] .= ";" . $p[$i+1]; 

      $t[] = $p[$k]; 
    } 

    $n = count($t); 

    for($i=0; $i < $n; $i++) 
    { 
      $t1 = explode("|", $t[$i]); 
      $t2 = explode(":", $t1[1]); 
      $buf[$t1[0]] = substr($t2[2], 1, $t2[1]); 
    } 

    return $buf; 
  } 


  // GetExtension($filename) : $filename¿¡¼­ ¸¶Áö¸· "."ÀÌÈÄÀÇ 
  // È®ÀåÀÚ¸¸ Àß¶ó¼­ ¼Ò¹®ÀÚ·Î ¸®ÅÏÇÑ´Ù. 

  function GetExtension($filename) 
  { 
    $filename = trim($filename); 
    $right = strrchr($filename, "."); 

    return strtolower(substr($right,1)); 
  } 


  // GetOtherName($filename) : $filenameÀÌ "name.ext" ÀÏ °æ¿ì 
  // "name1.ext"¸¦ ¸®ÅÏÇØÁÝ´Ï´Ù. ¾÷·ÎµåµÈ ÆÄÀÏÀ» ÀúÀåÇÏ·Á°í ÇÒ ¶§ 
  // µ¿ÀÏÇÑ ÆÄÀÏÀÌ ÀÖÀ» °æ¿ì ÀÌ·± ½ÄÀ¸·Î À̸§ºÎºÐ¿¡¸¸ 1À» ºÙ¿©¼­ 
  // ÀúÀåÇÔÀ¸·Î½á È®ÀåÀÚ°¡ ±×´ë·Î Àû¿ëµÇµµ·Ï ÇÒ ¼ö ÀÖ½À´Ï´Ù. 

  function GetOtherName($filename) 
  { 
    $filename = trim($filename); 
    $l_all = strlen($filename); 
    $right = strrchr($filename, "."); 
    $l_left = $l_all - strlen($right); 

    return substr($filename,0,$l_left) . "1" . $right; 
  } 


} // End of if( !$__FUNC_PHP__ )
Regist Addr [ 210.221.19.151 ] ¸ñ·Ïº¸±â À­±Û ¾Æ·§±Û
Á¤±ÔÇ¥Çö½Ä [ »ó¼¼ °Ë»ö ]
Page Loading [ 0.05 Sec ] SQL Time [ 0 Sec ]

Copyleft 1999-2024 by JSBoard Open Project
Theme Designed by IDOO And follow GPL2

°³ÀÎÁ¤º¸ Ãë±Þ¹æħ ÀÌ¿ë ¾à°ü »çÀÌÆ® ¸Ê ¾îµå¹Î °ü¸®