ÇÁ·Î±×·¡¹Ö

 3198, 1/160 ȸ¿ø°¡ÀÔ  ·Î±×ÀΠ 
   smile_mut
   [PHP] hackthissite.org Áú¹®

http://www.hackerschool.org/HS_Boards/zboard.php?AllArticle=true&no=2970 [º¹»ç]


¾È³çÇϼ¼¿ä.
ÇÏ·çÀü ¿¡ Áú¹®¿Ã·Á³õ°í °±ÀÚ±â ÇÁ·Î±×·¥ÀÌ Á¦´ë·Î µ¹¾Æ°¡¼­ ÇÇÇØ¸¸ÁØ ³ÑÀÔ´Ï´Ù ¤».
Á¦°¡  algorithms.php À» ¸¸µçÀÌÀ¯´Â hackthissite.org ¿¡ ÀÖ´Â programming mission 1À» Çϱâ À§Çؼ­ ¿´´Âµ¥¿ä.
¸·»ó ÇÏ·Á´Ï ¾ÈµÅ³×¿ä. (´Ù¸¥ ¾ð¾î·Î ¸¸µé¼ö´Â ÀÖÁö¸¸ Áö±ÝÀº php °øºÎÁßÀÌ¿©¼­ ²À php ·Î ¸¸µé°í ½Í¾î¿ä ^0^ )
ÀÌÆ²µ¿¾È °í·Á ºÃ´Âµ¥ ¾ÈµÅ³×¿ä ¤Ð¤Ð.
¹Ì¼Ç ¼³¸í = Á¦°øÇÑ txt ÆÄÀÏ¿¡´Â 2000 ¿©°³ÀÇ ´Ü¾î°¡ Àִµ¥¿ä. ¹Ì¼ÇÀ» ½ÃÀÛÇÏ¸é ±×Áß 10°³ÀÇ ´Ü¾î¸¦ ¹«ÀÛÀ§·Î ¼±ÅÃÇÏ¿©¼­
´Ü¾î¼øÀ» ¼¯¾î ¹ö¸³´Ï´Ù. ÆÄÀÏÀ» ÀÌ¿ëÇØ¼­ original ´Ü¾î¸¦ ã¾Æ¾ß µÅ´Â°ÅÁÒ [Çѱ¹¸»ÀÌ ¼­Åõ·¯¼­ Àß ¼³¸íÀÌ µÆ´ÂÁö ¸ð¸£°Ú³×¿ä]

index.php ÄÚµå
<?php
        require_once('algorithms.php');

        /* Getting the txt file and putting it in to array $word_bank*/
        if(isset($_POST['submit'])){
                $text_file = $_FILES['text_file']['name'];
                $word_bank = array();

                /* Get the file & Make $word_bank array */
                if(!empty($text_file)){
                        $file_tmp_name = $_FILES['text_file']['tmp_name'];
                        $file = fopen($file_tmp_name, "r");
                        while(!feof($file))
                                array_push($word_bank, fgets($file));
                        fclose($file);
                        @unlink($file_tmp_name);
                }
                else{
                        echo '<p>Please choose your file.</p>';
                        exit();
                }

                /* Receive the words and put them in to array $word*/
                $words = $_POST['words'];
                $word = explode("\n",$words);
              
                find_word($word, $word_bank);
                exit();
        }
?>
        <!--Form that receives the randomly picked words and the text file-->
        <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" enctype = "multipart/form-data">
                <fieldset>
                        <legend>Programming Mission 1</legend>
                        <label for="words">Words:</label><br>
                        <textarea name="words" id="words" cols="30" rows="4"></textarea>
                        <br>
                        <label for="text_file">Choose the file</label>
                        <input type="file" name="text_file">
                </fieldset>
                <input type="submit" name="submit" value="Done">
        </form>



algorithms.php ÆÄÀÏ ÄÚµå
<?php
        function find_word($a, $b){
                // $a =  scrambled word
                // $b = one getting compared to (from the original list)
                for($i=0; $i<count($a); $i++){
                        for($ii=0; $ii<count($b); $ii++){
                                $a_split= str_split($a[$i]);
                                $b_split= str_split($b[$ii]);
                                sort($a_split);
                                sort($b_split);
                                $new_a = implode('',$a_split);
                                $new_b = implode('',$b_split);
                                if($new_a == $new_b){
                                        echo $b[$ii].', ';
                                }
                        }
                }
        }
?>

  Hit : 4022     Date : 2011/04/27 09:01



    
smile_mut ¾²°í ³ª´Ï ÂÍ (¾öû) ±æ¾î Á³³×¿ä... ¼ö°íÇØÁÖ¼¼¿ë :) 2011/04/27  
¸Û¸Û ¾ù Áú¹®Àº ¹¹¼¼¿è~? 2011/04/27  
ÄÚÅл̱⠤»¤»¤» 2011/04/27  
smile_mut ¾Æ, ¿¹»óÇß´øµ¥·Î ÇÁ·Î±×·¥ÀÌ ¾Èµ¹¾Æ°¡³×¿ä.
¾îµð°¡ ¹®Á¦ÀÎÁö ¸ð¸£°Ú¾î¿ä
2011/04/27  
prosper 1723°³ÀÇ »çÀü ´Ü¾î¿Í 10°³ÀÇ ·£´ý¹®ÀÚ¿­À» ºñ±³Çؼ­ 30ÃÊÀ̳» Ǫ´Â ¹®Á¦±º¿ä

php¹®Á¦´Â ¾Æ´Ï°í ÇÁ·Î±×·¡¹ÖÇÏ¿© 30Ãʳ»¿¡ Ç®¾î¼­ 1~10¹®ÀÚ¸¦ , ·Î Á¤·ÄÇØ¼­ ÀûÀ¸¸é Ç®¸®´Â¹®Á¦.

¾Ë°í¸®ÁòÀº ÀßÇ߳׿ä ^^
2011/05/09  
prosper http://www.hackerschool.org/HS_Boards/zboard.php?id=Free_Board&page=1&sn1=&divpage=4&sn=off&ss=on&sc=on&select_arrange=headnum&desc=asc&no=20822 2011/05/09  
smile_mut prosper ´Ô °¨»çÇÕ´Ï´Ù :) 2011/05/15