rucaptcha 1.2.0 → 2.0.0.beta3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/CHANGELOG.md +11 -0
 - data/README.md +0 -9
 - data/app/controllers/ru_captcha/captcha_controller.rb +4 -2
 - data/ext/rucaptcha/extconf.rb +4 -0
 - data/ext/rucaptcha/font.h +27 -0
 - data/ext/rucaptcha/rucaptcha.c +221 -0
 - data/lib/rucaptcha.rb +1 -6
 - data/lib/rucaptcha/cache.rb +0 -42
 - data/lib/rucaptcha/configuration.rb +0 -11
 - data/lib/rucaptcha/controller_helpers.rb +5 -4
 - data/lib/rucaptcha/engine.rb +0 -5
 - data/lib/rucaptcha/version.rb +1 -1
 - data/lib/rucaptcha/view_helpers.rb +2 -2
 - metadata +23 -6
 - data/lib/rucaptcha/captcha.rb +0 -125
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: f92a176b27e156909683cc97c9c218b642f6d82e
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 7e3661aaad88123af8d173bb9772d7c3789510ce
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 7353880dcc6d05db34cf8bc8337321727300e1adffbb5dbdca8bc58c0cfd47e1f0741c9bd6794720a3748b6f45196b6079044471eb638b3ac280d715d56adccf
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: a802c98fa2e84e02b27a716c431382dcc5b246f17b7ea975486e1c75fc34390639b4de3b3eecf389244f61fe451083f4b991095ff700e133b1d8441811608ae6
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,3 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            2.0.0
         
     | 
| 
      
 2 
     | 
    
         
            +
            -----
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            *Break Changes!*
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            WARNING!: This version have so many break changes!
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            - Use C ext instead of ImageMagick, now it's no dependencies!
         
     | 
| 
      
 9 
     | 
    
         
            +
            - New captcha style, because C code is complex, just generate black chars.
         
     | 
| 
      
 10 
     | 
    
         
            +
            - Remove `len`, `style`, `font_size`, `cache_limit` config key, no support now.
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       1 
12 
     | 
    
         
             
            1.2.0
         
     | 
| 
       2 
13 
     | 
    
         
             
            -----
         
     | 
| 
       3 
14 
     | 
    
         | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -55,17 +55,8 @@ Create `config/initializers/rucaptcha.rb` 
     | 
|
| 
       55 
55 
     | 
    
         | 
| 
       56 
56 
     | 
    
         
             
            ```rb
         
     | 
| 
       57 
57 
     | 
    
         
             
            RuCaptcha.configure do
         
     | 
| 
       58 
     | 
    
         
            -
              # Number of chars, default: 4
         
     | 
| 
       59 
     | 
    
         
            -
              self.len = 4
         
     | 
| 
       60 
     | 
    
         
            -
              # Image font size, default: 45
         
     | 
| 
       61 
     | 
    
         
            -
              self.font_size = 45
         
     | 
| 
       62 
     | 
    
         
            -
              # Cache generated images in file store, this is config files limit, default: 100
         
     | 
| 
       63 
     | 
    
         
            -
              # set 0 to disable file cache.
         
     | 
| 
       64 
     | 
    
         
            -
              self.cache_limit = 100
         
     | 
| 
       65 
58 
     | 
    
         
             
              # Custom captcha code expire time if you need, default: 2 minutes
         
     | 
| 
       66 
59 
     | 
    
         
             
              # self.expires_in = 120
         
     | 
| 
       67 
     | 
    
         
            -
              # Color style, default: :colorful, allows: [:colorful, :black_white]
         
     | 
| 
       68 
     | 
    
         
            -
              # self.style = :colorful
         
     | 
| 
       69 
60 
     | 
    
         
             
              # [Requirement]
         
     | 
| 
       70 
61 
     | 
    
         
             
              # Store Captcha code where, this config more like Rails config.cache_store
         
     | 
| 
       71 
62 
     | 
    
         
             
              # default: Rails application config.cache_store
         
     | 
| 
         @@ -3,11 +3,13 @@ module RuCaptcha 
     | 
|
| 
       3 
3 
     | 
    
         
             
                def index
         
     | 
| 
       4 
4 
     | 
    
         
             
                  headers['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate'
         
     | 
| 
       5 
5 
     | 
    
         
             
                  headers['Pragma'] = 'no-cache'
         
     | 
| 
      
 6 
     | 
    
         
            +
                  data = generate_rucaptcha
         
     | 
| 
      
 7 
     | 
    
         
            +
                  opts = { disposition: 'inline', type: 'image/gif' }
         
     | 
| 
       6 
8 
     | 
    
         | 
| 
       7 
9 
     | 
    
         
             
                  if Gem.win_platform?
         
     | 
| 
       8 
     | 
    
         
            -
                    send_file  
     | 
| 
      
 10 
     | 
    
         
            +
                    send_file data, opts
         
     | 
| 
       9 
11 
     | 
    
         
             
                  else
         
     | 
| 
       10 
     | 
    
         
            -
                    send_data  
     | 
| 
      
 12 
     | 
    
         
            +
                    send_data data, opts
         
     | 
| 
       11 
13 
     | 
    
         
             
                  end
         
     | 
| 
       12 
14 
     | 
    
         
             
                end
         
     | 
| 
       13 
15 
     | 
    
         
             
              end
         
     | 
| 
         @@ -0,0 +1,27 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            static int8_t lt0[]={-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-4,11,7,5,3,1,0,0,0,1,3,7,13,-100,-2,11,3,0,0,0,0,0,0,0,0,0,0,0,0,9,-100,-1,7,0,0,0,0,0,0,3,9,11,9,3,0,0,0,0,13,-100,9,0,0,0,0,0,0,3,-5,3,0,0,0,7,-100,5,0,0,0,0,0,1,13,-5,9,0,0,0,1,-100,7,0,0,0,0,1,13,-6,13,0,0,0,0,-100,-1,9,1,0,5,13,-8,0,0,0,0,13,-100,-14,0,0,0,0,11,-100,-14,0,0,0,0,11,-100,-14,0,0,0,0,11,-100,-12,13,5,0,0,0,0,11,-100,-8,13,9,5,1,0,0,0,0,0,0,11,-100,-4,13,7,3,1,0,0,0,0,1,1,0,0,0,0,11,-100,-2,13,5,0,0,0,0,0,5,9,13,-2,0,0,0,0,11,-100,-1,13,1,0,0,0,0,7,-6,0,0,0,0,11,-100,13,1,0,0,0,0,13,-7,0,0,0,0,11,-100,5,0,0,0,0,5,-8,0,0,0,0,11,-100,0,0,0,0,0,11,-8,0,0,0,0,11,-100,0,0,0,0,0,13,-7,13,0,0,0,0,11,-100,1,0,0,0,0,-7,9,0,0,0,0,0,9,-3,9,-100,5,0,0,0,0,3,13,-3,11,3,0,0,0,0,0,0,0,9,13,3,5,-100,13,0,0,0,0,0,0,1,1,0,0,0,1,11,9,0,0,0,0,0,0,1,13,-100,-1,11,1,0,0,0,0,0,0,0,0,5,-3,9,0,0,0,0,0,11,-100,-2,13,7,3,0,0,0,3,7,13,-5,9,0,1,3,9,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 2 
     | 
    
         
            +
            static int8_t lt1[]={-100,-100,-4,13,5,0,3,-100,-3,11,1,0,0,0,7,-100,-2,7,0,0,0,0,0,3,-100,13,3,0,0,0,0,0,0,5,-100,1,0,0,0,0,0,0,0,9,-100,1,0,0,0,0,0,0,0,13,-100,13,3,0,0,0,0,0,1,-100,-2,5,0,0,0,0,5,-100,-3,0,0,0,0,9,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,9,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,3,13,9,5,3,1,0,0,1,3,5,9,-100,-3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,13,-100,-3,0,0,0,0,0,5,13,-2,13,11,9,5,0,0,0,0,1,13,-100,-3,0,0,0,0,1,-8,13,1,0,0,0,5,-100,-3,3,0,0,0,5,-9,13,0,0,0,0,11,-100,-3,0,0,0,0,9,-10,7,0,0,0,5,-100,-3,1,0,0,0,11,-10,13,0,0,0,0,-100,-3,3,0,0,0,11,-11,3,0,0,0,11,-100,-3,1,0,0,0,11,-11,7,0,0,0,7,-100,-3,0,0,0,0,11,-11,9,0,0,0,3,-100,-3,0,0,0,0,11,-11,11,0,0,0,1,-100,-3,0,0,0,0,11,-11,11,0,0,0,1,-100,-3,0,0,0,0,11,-11,11,0,0,0,0,-100,-3,0,0,0,0,11,-11,9,0,0,0,0,-100,-3,0,0,0,0,11,-11,7,0,0,0,3,-100,-3,0,0,0,0,11,-11,3,0,0,0,7,-100,-3,0,0,0,0,11,-11,0,0,0,0,11,-100,-3,0,0,0,0,11,-10,9,0,0,0,3,-100,-3,0,0,0,0,9,-10,3,0,0,0,11,-100,-3,0,0,0,0,3,-9,11,0,0,0,5,-100,-2,13,0,0,0,0,0,9,-7,11,1,0,0,3,-100,-2,7,0,0,0,0,0,0,7,13,-2,13,9,3,0,0,0,3,13,-100,-2,13,0,0,5,13,11,1,0,0,0,0,0,0,0,0,0,7,-100,-3,9,11,-4,7,3,1,0,0,1,5,9,13,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 3 
     | 
    
         
            +
            static int8_t lt2[]={-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-6,13,7,3,1,0,0,1,3,7,13,-100,-5,9,0,0,0,0,0,0,0,0,0,0,5,13,-100,-3,13,3,0,0,0,5,13,13,7,0,0,0,0,0,1,13,-100,-2,13,1,0,0,0,9,-4,7,0,0,0,0,0,1,-100,-1,13,1,0,0,0,9,-6,5,0,0,0,0,0,13,-100,-1,5,0,0,0,3,-8,1,0,0,0,3,-100,13,0,0,0,0,11,-8,13,3,0,3,-100,7,0,0,0,1,-100,5,0,0,0,5,-100,3,0,0,0,9,-100,1,0,0,0,11,-100,0,0,0,0,11,-100,0,0,0,0,11,-100,0,0,0,0,11,-100,0,0,0,0,9,-100,1,0,0,0,5,-100,5,0,0,0,0,13,-100,11,0,0,0,0,7,-100,-1,3,0,0,0,0,13,-100,-1,11,0,0,0,0,3,-12,9,-100,-2,7,0,0,0,0,3,13,-8,9,1,3,-100,-3,5,0,0,0,0,1,9,-5,9,3,0,0,11,-100,-4,5,0,0,0,0,0,0,1,1,1,0,0,0,0,11,-100,-5,9,1,0,0,0,0,0,0,0,0,0,3,13,-100,-7,11,7,3,1,0,1,3,7,11,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 4 
     | 
    
         
            +
            static int8_t lt3[]={-100,-100,-100,-100,-18,11,3,0,-100,-16,13,3,0,0,0,-100,-14,9,3,0,0,0,0,0,-100,-13,3,0,0,0,0,0,0,0,-100,-13,0,0,0,0,0,0,0,0,-100,-13,9,1,0,0,0,0,0,0,-100,-15,13,5,0,0,0,0,-100,-17,1,0,0,0,-100,-17,3,0,0,0,-100,-17,1,0,0,0,-100,-17,0,0,0,0,-100,-16,13,0,0,0,0,-100,-16,13,0,0,0,0,-100,-6,11,5,3,1,0,0,1,5,9,13,13,0,0,0,0,-100,-4,13,3,0,0,0,0,0,0,0,0,0,0,3,0,0,0,0,-100,-3,13,1,0,0,0,0,5,11,-1,13,11,3,0,0,0,0,0,0,-100,-2,13,1,0,0,0,0,7,-6,11,0,0,0,0,0,-100,-2,3,0,0,0,0,9,-8,11,0,0,0,0,-100,-1,9,0,0,0,0,7,-9,11,0,0,0,0,-100,-1,1,0,0,0,0,13,-9,11,0,0,0,0,-100,11,0,0,0,0,3,-10,11,0,0,0,0,-100,5,0,0,0,0,13,-10,11,0,0,0,0,-100,3,0,0,0,3,-11,11,0,0,0,0,-100,0,0,0,0,7,-11,11,0,0,0,0,-100,0,0,0,0,11,-11,11,0,0,0,0,-100,0,0,0,0,11,-11,11,0,0,0,0,-100,0,0,0,0,11,-11,11,0,0,0,0,-100,1,0,0,0,9,-11,11,0,0,0,0,-100,3,0,0,0,7,-11,11,0,0,0,0,-100,7,0,0,0,3,-11,11,0,0,0,0,-100,13,0,0,0,0,13,-10,13,0,0,0,0,-100,-1,3,0,0,0,5,-11,0,0,0,0,-100,-1,13,0,0,0,0,11,-10,0,0,0,0,-100,-2,7,0,0,0,1,13,-8,13,0,0,0,0,13,-100,-3,5,0,0,0,1,11,-7,5,0,0,0,0,9,-100,-4,5,0,0,0,0,3,9,13,-1,13,11,1,0,0,0,0,0,0,0,5,-100,-5,9,1,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,1,13,-100,-7,9,3,1,0,0,3,7,13,-1,11,1,0,1,5,7,11,-100,-18,13,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 5 
     | 
    
         
            +
            static int8_t lt4[]={-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-7,13,5,1,1,0,1,3,9,13,-100,-6,5,0,0,0,0,0,0,0,0,0,9,-100,-4,11,1,0,0,3,11,-1,13,7,1,0,0,0,9,-100,-3,9,0,0,0,1,13,-5,3,0,0,1,-100,-2,9,0,0,0,0,13,-6,11,0,0,0,9,-100,-1,13,0,0,0,0,9,-8,0,0,0,1,-100,-1,5,0,0,0,0,13,-8,3,0,0,0,11,-100,-1,0,0,0,0,0,-8,13,1,0,0,0,5,-100,9,0,0,0,0,0,3,11,-4,13,11,1,0,0,0,0,1,-100,5,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,-100,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,-100,1,0,0,0,1,13,-100,0,0,0,0,11,-100,0,0,0,0,11,-100,1,0,0,0,9,-100,3,0,0,0,7,-100,7,0,0,0,5,-100,13,0,0,0,0,11,-100,-1,5,0,0,0,1,13,-100,-1,13,1,0,0,0,1,13,-10,13,11,-100,-2,11,0,0,0,0,1,13,-8,13,1,1,-100,-3,11,0,0,0,0,0,7,13,-4,11,7,0,0,9,-100,-4,11,1,0,0,0,0,0,1,1,1,0,0,0,0,7,-100,-5,13,5,0,0,0,0,0,0,0,0,0,1,9,-100,-7,13,7,3,0,0,0,1,5,9,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 6 
     | 
    
         
            +
            static int8_t lt5[]={-100,-100,-100,-100,-9,13,9,3,1,0,1,5,13,-100,-8,7,0,0,0,0,0,0,0,3,-100,-7,3,0,0,0,0,0,0,0,0,1,-100,-6,5,0,0,0,0,0,0,0,0,0,3,-100,-5,13,0,0,3,13,9,1,0,0,0,0,11,-100,-5,9,0,0,13,-2,13,5,0,1,9,-100,-5,5,0,0,-100,-5,1,0,1,-100,-5,1,0,0,-100,-5,0,0,0,-100,-5,0,0,0,13,-100,-5,0,0,0,9,-100,-5,0,0,0,7,-100,-5,0,0,0,5,-100,-3,13,7,0,0,0,0,9,-1,13,11,13,-100,3,0,0,0,0,0,0,0,0,0,0,0,0,0,9,-100,3,0,0,0,0,0,0,0,0,0,0,0,0,0,9,-100,-1,11,13,-1,7,0,0,0,0,5,-1,13,11,13,-100,-5,0,0,0,0,11,-100,-5,0,0,0,0,11,-100,-5,0,0,0,0,11,-100,-5,0,0,0,0,11,-100,-5,0,0,0,0,11,-100,-5,0,0,0,0,11,-100,-5,0,0,0,0,11,-100,-5,0,0,0,0,11,-100,-5,0,0,0,0,11,-100,-5,0,0,0,0,11,-100,-5,0,0,0,0,11,-100,-5,0,0,0,0,11,-100,-5,0,0,0,0,11,-100,-5,0,0,0,0,11,-100,-5,0,0,0,0,11,-100,-5,0,0,0,0,7,-100,-3,13,5,0,0,0,0,0,7,13,-100,-1,5,0,0,0,0,0,0,0,0,0,0,0,1,11,-100,-1,7,1,0,0,0,0,0,0,0,0,1,3,7,13,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 7 
     | 
    
         
            +
            static int8_t lt6[]={-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-7,11,7,3,1,0,0,1,3,7,13,-4,13,7,5,7,11,-100,-5,11,3,0,0,0,0,0,0,0,0,0,0,5,13,13,5,0,0,0,0,0,-100,-4,9,0,0,0,5,13,-1,13,9,3,0,0,0,0,0,0,0,0,0,0,0,1,-100,-3,11,0,0,0,5,-6,5,0,0,0,0,0,11,13,9,3,0,9,-100,-2,13,0,0,0,0,13,-7,1,0,0,0,0,13,-100,-2,1,0,0,0,7,-8,7,0,0,0,0,7,-100,-2,0,0,0,0,9,-8,11,0,0,0,0,3,-100,-2,0,0,0,0,11,-9,0,0,0,0,1,-100,-2,0,0,0,0,11,-9,0,0,0,0,0,-100,-2,0,0,0,0,9,-8,13,0,0,0,0,1,-100,-2,3,0,0,0,5,-8,9,0,0,0,0,7,-100,-2,13,1,0,0,0,13,-7,5,0,0,0,0,13,-100,-3,11,0,0,0,3,13,-5,7,0,0,0,0,11,-100,-4,7,0,0,0,1,9,13,-1,13,7,0,0,0,1,11,-100,-4,13,0,0,0,0,0,0,0,0,0,0,0,5,13,-100,-4,13,0,0,0,0,0,0,1,3,5,9,-100,-2,13,5,0,11,-100,-1,13,1,0,0,-100,-1,3,0,0,0,1,7,13,-100,-1,0,0,0,0,0,0,0,1,3,7,9,11,13,-100,-1,5,0,0,0,0,0,0,0,0,0,0,0,0,0,1,3,5,11,-100,-2,11,7,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,11,-100,-4,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,-100,-3,9,1,0,3,9,13,13,11,7,3,0,0,0,0,0,0,0,0,0,13,-100,-1,7,1,0,0,9,-8,11,7,3,0,0,0,0,0,5,-100,9,0,0,0,3,-13,11,1,0,0,1,-100,1,0,0,0,9,-15,0,0,0,-100,0,0,0,0,9,-14,13,0,0,1,-100,3,0,0,0,1,-14,7,0,0,5,-100,11,0,0,0,0,5,-12,11,0,0,0,13,-100,-1,11,1,0,0,0,1,7,11,13,-1,13,13,11,9,5,3,1,0,0,3,13,-100,-3,9,3,0,0,0,0,0,0,0,0,0,0,0,0,0,1,9,-100,-6,9,7,3,1,1,0,0,1,1,3,7,11,-100,-101};
         
     | 
| 
      
 8 
     | 
    
         
            +
            static int8_t lt7[]={-100,-100,-100,-100,-4,13,7,1,9,-100,-2,13,7,0,0,0,3,-100,-1,7,0,0,0,0,0,5,-100,1,0,0,0,0,0,0,7,-100,3,0,0,0,0,0,0,7,-100,13,7,0,0,0,0,0,9,-100,-2,5,0,0,0,0,9,-100,-2,11,0,0,0,0,9,-100,-3,0,0,0,0,9,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-5,11,5,1,0,1,7,-100,-3,0,0,0,0,11,-3,13,3,0,0,0,0,0,0,3,-100,-3,0,0,0,0,11,-2,7,0,0,0,0,0,0,0,0,0,9,-100,-3,0,0,0,0,11,11,3,0,5,11,-1,13,9,1,0,0,0,3,-100,-3,0,0,0,0,3,0,1,11,-6,1,0,0,0,13,-100,-3,0,0,0,0,0,5,-8,11,0,0,0,11,-100,-3,0,0,0,0,11,-10,0,0,0,7,-100,-3,0,0,0,0,13,-10,0,0,0,7,-100,-3,0,0,0,0,11,-10,0,0,0,7,-100,-3,0,0,0,0,11,-10,0,0,0,7,-100,-3,0,0,0,0,13,-10,0,0,0,9,-100,-3,0,0,0,0,13,-10,0,0,0,9,-100,-3,0,0,0,0,-11,0,0,0,11,-100,-3,0,0,0,1,-11,0,0,0,13,-100,-3,0,0,0,1,-11,0,0,0,13,-100,-3,0,0,0,3,-11,0,0,0,-100,-3,0,0,0,3,-11,0,0,0,-100,-3,0,0,0,3,-11,0,0,0,-100,-3,0,0,0,3,-10,13,0,0,0,13,-100,-3,0,0,0,1,-10,13,0,0,0,11,-100,-2,9,0,0,0,0,-10,11,0,0,0,5,-100,-1,7,0,0,0,0,0,5,13,-7,13,3,0,0,0,0,7,-100,5,0,0,0,0,0,0,0,0,3,-5,1,0,0,0,0,0,0,1,3,11,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 9 
     | 
    
         
            +
            static int8_t lt8[]={-100,-100,-100,-100,-3,5,1,0,3,11,-100,-2,7,0,0,0,0,0,11,-100,-2,1,0,0,0,0,0,5,-100,-2,0,0,0,0,0,0,5,-100,-2,5,0,0,0,0,0,11,-100,-3,7,0,0,3,9,-100,-4,13,-100,-100,-100,-100,-100,-100,-100,-4,11,3,0,9,-100,-2,9,3,0,0,0,9,-100,11,1,0,0,0,0,0,7,-100,1,0,0,0,0,0,0,7,-100,1,0,0,0,0,0,0,9,-100,-1,11,0,0,0,0,0,9,-100,-2,7,0,0,0,0,11,-100,-3,0,0,0,0,13,-100,-3,1,0,0,0,-100,-3,1,0,0,0,13,-100,-3,1,0,0,0,13,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-2,13,0,0,0,0,7,-100,-2,13,0,0,0,0,1,-100,-2,7,0,0,0,0,0,9,-100,7,0,0,0,0,0,0,0,0,3,-100,9,5,1,1,0,0,1,1,3,5,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 10 
     | 
    
         
            +
            static int8_t lt9[]={-100,-100,-100,-100,-6,5,0,1,5,13,-100,-5,5,0,0,0,0,1,-100,-5,1,0,0,0,0,0,13,-100,-5,0,0,0,0,0,0,-100,-5,5,0,0,0,0,3,-100,-6,7,1,0,5,13,-100,-100,-100,-100,-100,-100,-100,-100,-6,13,7,3,0,13,-100,-5,7,0,0,0,0,11,-100,-3,7,1,0,0,0,0,0,11,-100,-2,13,0,0,0,0,0,0,0,11,-100,-3,11,3,0,0,0,0,0,11,-100,-5,9,0,0,0,0,11,-100,-6,1,0,0,0,11,-100,-6,3,0,0,0,11,-100,-6,5,0,0,0,11,-100,-6,5,0,0,0,11,-100,-6,5,0,0,0,11,-100,-6,5,0,0,0,11,-100,-6,3,0,0,0,11,-100,-6,3,0,0,0,11,-100,-6,1,0,0,0,11,-100,-6,1,0,0,0,13,-100,-6,1,0,0,0,13,-100,-6,1,0,0,0,13,-100,-6,1,0,0,0,13,-100,-6,1,0,0,0,13,-100,-6,1,0,0,0,-100,-6,1,0,0,0,-100,-6,1,0,0,1,-100,-6,1,0,0,3,-100,-6,0,0,0,5,-100,-6,0,0,0,7,-100,-6,0,0,0,11,-100,11,0,0,0,5,5,0,0,5,-100,3,0,0,0,0,0,0,3,-100,0,0,0,0,0,0,0,13,-100,1,0,0,0,0,0,11,-100,13,3,0,0,3,11,-100,-100,-101};
         
     | 
| 
      
 11 
     | 
    
         
            +
            static int8_t lt10[]={-100,-100,-100,-100,-6,9,1,13,-100,-3,13,5,0,0,0,11,-100,-1,13,5,0,0,0,0,0,11,-100,13,1,0,0,0,0,0,0,11,-100,3,0,0,0,0,0,0,0,11,-100,11,3,0,0,0,0,0,0,11,-100,-2,13,0,0,0,0,0,11,-100,-3,9,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-7,3,0,0,0,0,0,0,0,0,0,3,-100,-4,0,0,0,0,11,-7,5,0,0,0,0,0,0,0,1,7,13,-100,-4,0,0,0,0,11,-8,9,0,0,0,1,9,-100,-4,0,0,0,0,11,-7,13,1,0,0,7,-100,-4,0,0,0,0,11,-7,5,0,3,13,-100,-4,0,0,0,0,11,-6,5,0,5,-100,-4,0,0,0,0,11,-5,5,1,11,-100,-4,0,0,0,0,11,-3,11,3,1,-100,-4,0,0,0,0,11,-1,11,3,0,0,1,-100,-4,0,0,0,0,11,9,0,0,0,0,0,11,-100,-4,0,0,0,0,0,0,1,0,0,0,0,3,-100,-4,0,0,0,0,0,9,-1,11,1,0,0,0,9,-100,-4,0,0,0,0,5,-4,3,0,0,0,11,-100,-4,0,0,0,0,11,-4,13,1,0,0,0,13,-100,-4,0,0,0,0,11,-5,11,0,0,0,1,13,-100,-4,0,0,0,0,11,-6,3,0,0,0,3,-100,-4,0,0,0,0,11,-6,11,0,0,0,0,7,-100,-4,0,0,0,0,11,-7,3,0,0,0,0,7,-100,-3,13,0,0,0,0,11,-7,13,0,0,0,0,0,7,-100,-2,13,3,0,0,0,0,7,-7,9,0,0,0,0,0,0,3,11,-100,-1,1,0,0,0,0,0,0,0,0,1,3,-4,0,0,0,0,0,0,0,0,0,0,3,-100,-1,7,1,0,0,0,0,0,0,0,0,7,-4,3,0,0,0,0,0,0,1,1,5,9,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 12 
     | 
    
         
            +
            static int8_t lt11[]={-100,-100,-100,-6,11,7,11,-100,-4,11,3,0,0,5,-100,-3,5,0,0,0,0,5,-100,-1,11,1,0,0,0,0,0,7,-100,7,0,0,0,0,0,0,0,7,-100,0,0,0,0,0,0,0,0,9,-100,7,0,0,0,0,0,0,0,9,-100,-2,9,1,0,0,0,0,9,-100,-3,11,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,7,-100,-3,5,0,0,0,0,0,13,-100,-1,9,1,0,0,0,0,0,0,0,1,9,-100,-1,5,1,0,0,0,0,0,0,0,1,11,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 13 
     | 
    
         
            +
            static int8_t lt12[]={-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-5,11,5,0,-21,7,1,0,3,9,-100,-4,7,0,0,0,13,-4,11,5,1,1,0,1,7,-7,11,3,0,0,0,0,0,5,-100,-2,11,1,0,0,0,0,11,-2,9,1,0,0,0,0,0,0,0,9,-4,13,5,0,0,0,0,0,0,0,0,7,-100,13,3,0,0,0,0,0,0,7,13,3,0,0,0,1,0,0,0,0,0,0,7,-1,13,7,0,0,0,0,0,0,0,0,0,0,0,11,-100,3,0,0,0,0,0,0,0,1,0,0,5,11,-3,11,0,0,0,0,0,0,0,3,9,13,13,-3,7,0,0,0,0,5,-100,13,3,0,0,0,0,0,0,0,7,13,-6,3,0,0,0,0,0,9,-8,5,0,0,0,1,-100,-2,11,0,0,0,0,0,3,-8,9,0,0,0,0,7,-9,11,0,0,0,0,-100,-3,3,0,0,0,0,7,-8,13,0,0,0,0,-10,11,0,0,0,0,-100,-3,7,0,0,0,0,11,-9,0,0,0,0,-10,11,0,0,0,1,-100,-3,11,0,0,0,0,11,-9,0,0,0,0,-10,11,0,0,0,3,-100,-3,13,0,0,0,0,11,-8,13,0,0,0,0,-10,11,0,0,0,5,-100,-3,13,0,0,0,0,11,-8,11,0,0,0,0,-10,11,0,0,0,5,-100,-4,0,0,0,0,13,-8,9,0,0,0,0,-10,11,0,0,0,5,-100,-4,0,0,0,0,13,-8,11,0,0,0,0,-10,11,0,0,0,3,-100,-4,0,0,0,0,13,-8,11,0,0,0,0,-10,11,0,0,0,0,-100,-3,13,0,0,0,1,-9,13,0,0,0,0,-10,11,0,0,0,0,-100,-3,11,0,0,0,13,-10,0,0,0,0,-10,11,0,0,0,0,-100,-4,0,0,0,11,-10,0,0,0,0,-10,11,0,0,0,0,-100,-3,13,0,0,0,3,-9,13,0,0,0,0,13,-9,9,0,0,0,0,-100,-3,7,0,0,0,0,13,-8,11,0,0,0,0,11,-9,7,0,0,0,0,13,-100,-3,3,0,0,0,0,9,-8,5,0,0,0,0,5,-9,5,0,0,0,0,7,-100,-1,13,3,0,0,0,0,0,1,11,-6,9,0,0,0,0,0,0,3,-7,11,1,0,0,0,0,1,13,-100,11,0,0,0,0,0,0,0,0,0,3,-4,3,0,0,0,0,0,0,0,0,5,-5,1,0,0,0,0,0,0,0,0,9,-100,13,1,0,0,0,0,0,0,0,1,9,-4,1,0,0,0,0,0,0,0,1,5,-5,1,0,0,0,0,0,0,0,0,7,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 14 
     | 
    
         
            +
            static int8_t lt13[]={-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-3,13,7,3,0,13,-5,13,7,1,0,0,3,7,-100,-2,5,0,0,0,0,-4,13,3,0,0,0,0,0,0,0,7,-100,7,1,0,0,0,0,0,-3,7,0,0,0,0,0,0,0,0,0,0,13,-100,1,0,0,0,0,0,0,13,9,1,0,5,11,13,-1,11,3,0,0,0,0,9,-100,13,3,0,0,0,0,0,1,1,7,-7,3,0,0,0,3,-100,-2,1,0,0,0,0,7,-9,13,0,0,0,1,-100,-2,7,0,0,0,0,-11,1,0,0,0,-100,-2,9,0,0,0,0,-11,1,0,0,0,13,-100,-2,11,0,0,0,0,-11,3,0,0,0,13,-100,-2,11,0,0,0,0,-11,5,0,0,0,11,-100,-2,11,0,0,0,0,-11,3,0,0,0,11,-100,-2,11,0,0,0,0,-11,1,0,0,0,11,-100,-2,11,0,0,0,0,-11,0,0,0,0,11,-100,-2,11,0,0,0,0,-11,0,0,0,0,11,-100,-2,11,0,0,0,0,-11,1,0,0,0,11,-100,-2,11,0,0,0,0,-11,3,0,0,0,11,-100,-2,11,0,0,0,0,-11,3,0,0,0,11,-100,-2,11,0,0,0,0,13,-10,5,0,0,0,11,-100,-2,11,0,0,0,0,13,-10,5,0,0,0,11,-100,-2,11,0,0,0,0,9,-10,5,0,0,0,9,-100,-2,7,0,0,0,0,5,-10,3,0,0,0,7,-100,-1,13,1,0,0,0,0,1,11,-7,11,5,0,0,0,0,0,3,9,-100,-1,1,0,0,0,0,0,0,0,0,3,-4,3,0,0,0,0,0,0,0,0,0,3,-100,-1,0,0,0,0,0,0,0,0,0,3,-4,5,1,0,0,0,0,0,0,0,0,1,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 15 
     | 
    
         
            +
            static int8_t lt14[]={-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-7,13,7,3,1,0,0,1,5,9,-100,-6,7,0,0,0,0,0,0,0,0,0,1,7,-100,-4,11,1,0,0,1,9,13,-1,13,11,5,0,0,0,3,13,-100,-3,11,0,0,0,3,13,-6,13,1,0,0,0,13,-100,-2,11,0,0,0,1,13,-8,13,0,0,0,5,-100,-2,0,0,0,0,9,-10,5,0,0,0,11,-100,-1,7,0,0,0,1,-11,13,0,0,0,1,-100,-1,1,0,0,0,5,-12,1,0,0,0,9,-100,11,0,0,0,0,11,-12,5,0,0,0,3,-100,7,0,0,0,0,13,-12,9,0,0,0,0,-100,3,0,0,0,0,13,-12,11,0,0,0,0,-100,1,0,0,0,0,-13,11,0,0,0,1,-100,0,0,0,0,0,-13,11,0,0,0,1,-100,0,0,0,0,0,13,-12,11,0,0,0,0,-100,1,0,0,0,0,13,-12,9,0,0,0,1,-100,5,0,0,0,0,11,-12,5,0,0,0,3,-100,9,0,0,0,0,9,-12,3,0,0,0,7,-100,-1,1,0,0,0,5,-12,0,0,0,0,11,-100,-1,9,0,0,0,3,-11,13,0,0,0,3,-100,-2,3,0,0,0,13,-10,7,0,0,0,11,-100,-2,13,1,0,0,3,-9,13,0,0,0,7,-100,-3,13,1,0,0,3,13,-6,13,1,0,0,5,-100,-4,13,1,0,0,1,7,13,-3,9,0,0,0,7,-100,-6,7,0,0,0,0,0,0,0,0,0,3,11,-100,-7,13,7,3,0,0,0,0,3,11,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 16 
     | 
    
         
            +
            static int8_t lt15[]={-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-6,11,7,-100,-4,11,3,0,0,7,11,5,3,0,0,0,1,5,9,-100,-2,11,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,-100,13,5,0,0,0,0,0,0,0,1,7,11,13,-1,13,3,0,0,0,5,-100,1,0,0,0,0,0,0,0,3,-7,7,0,0,0,7,-100,1,0,0,0,0,0,0,0,11,-8,7,0,0,0,13,-100,-1,11,5,0,0,0,0,0,11,-9,1,0,0,3,-100,-3,7,0,0,0,0,11,-9,5,0,0,0,11,-100,-3,9,0,0,0,0,11,-9,9,0,0,0,5,-100,-3,11,0,0,0,0,11,-9,11,0,0,0,0,13,-100,-3,11,0,0,0,0,11,-9,13,0,0,0,0,11,-100,-3,13,0,0,0,0,11,-10,0,0,0,0,11,-100,-3,13,0,0,0,0,11,-10,0,0,0,0,11,-100,-3,13,0,0,0,0,11,-10,0,0,0,0,11,-100,-4,0,0,0,0,11,-10,0,0,0,0,13,-100,-4,0,0,0,0,11,-10,0,0,0,0,13,-100,-4,0,0,0,0,13,-10,0,0,0,0,-100,-4,0,0,0,9,-11,0,0,0,3,-100,-4,0,0,0,3,-11,0,0,0,9,-100,-4,0,0,0,0,13,-10,0,0,0,13,-100,-4,0,0,0,0,11,-9,5,0,0,0,-100,-4,0,0,0,0,11,-8,7,0,0,0,7,-100,-4,0,0,0,0,5,-7,9,0,0,0,3,-100,-4,0,0,0,0,0,3,11,13,-3,9,0,0,0,1,-100,-4,0,0,0,0,5,7,0,0,0,1,1,0,0,0,1,13,-100,-4,0,0,0,0,11,-2,9,5,1,0,0,3,7,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,7,-100,-4,0,0,0,0,3,-100,-3,7,0,0,0,0,0,9,-100,-1,5,0,0,0,0,0,0,0,0,0,0,5,-100,-1,3,1,0,0,0,0,0,0,0,0,0,5,-100,-101};
         
     | 
| 
      
 17 
     | 
    
         
            +
            static int8_t lt16[]={-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-19,7,11,-100,-6,11,5,1,0,0,1,5,11,-4,5,0,3,-100,-4,13,3,0,0,0,0,0,0,0,0,1,11,13,5,0,0,1,-100,-3,13,1,0,0,1,5,11,-3,11,3,0,0,0,0,0,3,-100,-2,13,1,0,0,3,-8,3,0,0,0,0,5,-100,-1,13,1,0,0,0,13,-8,7,0,0,0,0,5,-100,-1,3,0,0,0,5,-9,11,0,0,0,0,7,-100,9,0,0,0,0,11,-9,13,0,0,0,0,9,-100,3,0,0,0,0,-10,13,0,0,0,0,9,-100,1,0,0,0,1,-11,0,0,0,0,9,-100,0,0,0,0,3,-11,0,0,0,0,11,-100,0,0,0,0,5,-11,0,0,0,0,11,-100,0,0,0,0,9,-11,0,0,0,0,11,-100,0,0,0,0,11,-11,0,0,0,0,11,-100,0,0,0,0,11,-11,0,0,0,0,11,-100,1,0,0,0,11,-11,0,0,0,0,11,-100,3,0,0,0,9,-11,0,0,0,0,11,-100,7,0,0,0,5,-11,0,0,0,0,11,-100,11,0,0,0,0,-11,0,0,0,0,11,-100,-1,1,0,0,0,7,-9,11,0,0,0,0,11,-100,-1,9,0,0,0,0,13,-8,9,0,0,0,0,11,-100,-2,3,0,0,0,1,13,-7,5,0,0,0,0,11,-100,-2,13,3,0,0,0,1,9,13,-3,13,7,0,0,0,0,0,11,-100,-4,9,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,11,-100,-6,11,7,3,1,0,0,5,9,-1,13,0,0,0,0,11,-100,-16,0,0,0,0,13,-100,-16,0,0,0,0,13,-100,-16,0,0,0,0,13,-100,-16,0,0,0,0,13,-100,-15,13,0,0,0,0,13,-100,-15,9,0,0,0,0,11,-100,-15,1,0,0,0,0,5,-100,-12,7,5,1,0,0,0,0,0,0,1,3,9,-100,-11,13,1,0,0,0,0,0,0,0,0,0,0,7,-100,-101};
         
     | 
| 
      
 18 
     | 
    
         
            +
            static int8_t lt17[]={-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-3,13,5,0,3,-5,9,3,1,0,0,3,-100,-1,11,3,0,0,0,0,-3,7,0,0,0,0,0,0,0,5,-100,9,0,0,0,0,0,0,-2,3,0,0,0,0,0,0,0,0,1,-100,0,0,0,0,0,0,0,11,3,0,0,0,0,0,0,0,0,0,1,-100,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,9,-100,-1,7,0,0,0,0,0,0,7,13,-2,11,7,3,1,3,11,-100,-2,3,0,0,0,0,3,-100,-2,7,0,0,0,0,9,-100,-2,11,0,0,0,0,13,-100,-2,13,0,0,0,0,-100,-3,0,0,0,0,-100,-3,0,0,0,0,13,-100,-3,0,0,0,0,13,-100,-3,0,0,0,0,13,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,11,-100,-3,0,0,0,0,9,-100,-1,13,3,0,0,0,0,1,13,-100,3,0,0,0,0,0,0,0,0,0,0,13,-100,5,1,0,0,0,0,0,0,0,0,3,13,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 19 
     | 
    
         
            +
            static int8_t lt18[]={-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-3,13,7,1,0,1,3,9,11,9,9,13,-100,-2,13,1,0,0,0,0,0,0,0,0,0,5,-100,-2,1,0,5,13,-1,13,11,3,0,0,0,1,-100,-1,9,0,1,-6,9,0,0,0,13,-100,-1,3,0,9,-7,11,1,0,9,-100,-1,0,0,-9,13,1,5,-100,-1,0,0,11,-9,13,11,-100,13,0,0,1,13,-100,13,0,0,0,1,9,-100,-1,0,0,0,0,0,0,5,9,-100,-1,5,0,0,0,0,0,0,0,1,7,13,-100,-1,13,0,0,0,0,0,0,0,0,0,0,9,-100,-2,13,1,0,0,0,0,0,0,0,0,0,7,-100,-4,11,5,0,0,0,0,0,0,0,0,7,-100,-7,9,5,0,0,0,0,0,0,13,-100,-9,13,7,0,0,0,0,7,-100,-11,13,3,0,0,3,-100,-13,0,0,0,-100,7,5,-11,1,0,0,-100,1,0,5,-10,1,0,3,-100,0,0,0,3,-9,0,0,9,-100,1,0,0,0,3,13,-6,5,0,3,-100,7,0,0,0,0,1,7,11,13,13,9,3,0,1,13,-100,13,0,0,0,0,0,0,0,0,0,0,0,3,13,-100,-1,5,3,9,7,3,1,0,0,1,5,11,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 20 
     | 
    
         
            +
            static int8_t lt19[]={-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-6,5,0,5,-100,-5,13,0,0,0,7,-100,-5,7,0,0,0,9,-100,-5,3,0,0,0,13,-100,-4,11,0,0,0,0,-100,-4,3,0,0,0,0,-100,-3,5,0,0,0,0,1,-100,-2,3,0,0,0,0,0,7,-100,13,1,0,0,0,0,0,0,1,11,-100,3,0,0,0,0,0,0,0,0,0,0,0,0,0,5,13,-100,1,0,0,0,0,0,0,0,0,0,0,0,0,0,5,-100,-3,9,0,0,0,0,7,13,-100,-4,0,0,0,0,11,-100,-4,1,0,0,0,11,-100,-4,1,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,0,0,0,0,11,-100,-4,1,0,0,0,11,-100,-4,3,0,0,0,11,-100,-4,5,0,0,0,11,-100,-4,3,0,0,0,11,-100,-4,3,0,0,0,11,-100,-4,1,0,0,0,9,-100,-4,0,0,0,0,5,-100,-4,0,0,0,0,1,-100,-4,1,0,0,0,0,11,-100,-4,3,0,0,0,0,1,13,-1,9,5,1,3,-100,-4,9,0,0,0,0,0,0,0,0,0,0,5,-100,-5,5,0,0,0,0,0,0,0,0,5,-100,-6,9,3,1,0,0,1,5,11,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 21 
     | 
    
         
            +
            static int8_t lt20[]={-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-4,13,9,1,0,13,-11,11,5,1,5,-100,-2,11,3,0,0,0,0,11,-8,11,5,0,0,0,0,1,-100,13,3,0,0,0,0,0,0,11,-6,7,1,0,0,0,0,0,0,7,-100,5,0,0,0,0,0,0,0,11,-5,5,0,0,0,0,0,0,0,0,11,-100,11,1,0,0,0,0,0,0,11,-5,9,0,0,0,0,0,0,0,0,11,-100,-2,11,1,0,0,0,0,11,-6,13,7,3,0,0,0,0,0,11,-100,-3,9,0,0,0,0,11,-9,9,0,0,0,0,11,-100,-3,11,0,0,0,0,11,-10,0,0,0,0,11,-100,-3,13,0,0,0,0,11,-10,0,0,0,0,11,-100,-4,0,0,0,0,11,-10,0,0,0,0,11,-100,-4,0,0,0,0,11,-10,0,0,0,0,11,-100,-4,0,0,0,0,11,-10,0,0,0,0,11,-100,-4,0,0,0,0,11,-10,0,0,0,0,11,-100,-4,0,0,0,0,11,-10,0,0,0,0,11,-100,-4,0,0,0,0,11,-10,0,0,0,0,11,-100,-4,0,0,0,0,11,-10,0,0,0,0,11,-100,-4,0,0,0,0,11,-10,0,0,0,0,11,-100,-4,1,0,0,0,11,-9,13,0,0,0,0,11,-100,-4,1,0,0,0,11,-9,5,0,0,0,0,11,-100,-4,5,0,0,0,7,-8,7,0,0,0,0,0,11,-100,-4,7,0,0,0,0,13,-5,13,5,0,0,0,0,0,0,11,-100,-4,13,0,0,0,0,1,11,-1,13,11,5,0,0,7,5,0,0,0,0,3,13,-100,-5,3,0,0,0,0,0,0,0,0,0,3,13,-2,0,0,0,0,0,0,7,-100,-5,11,0,0,0,0,0,0,0,1,9,-4,0,0,0,0,0,0,0,-100,-6,13,5,1,0,1,3,9,-6,3,1,3,7,9,11,13,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 22 
     | 
    
         
            +
            static int8_t lt21[]={-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-6,13,9,1,3,13,-5,13,1,0,0,0,0,1,3,9,-100,1,0,0,0,0,0,0,0,0,0,1,-5,1,0,0,0,0,0,0,0,0,9,-100,3,0,0,0,0,0,0,0,0,0,5,-5,3,0,0,0,0,0,0,0,0,13,-100,-1,9,3,0,0,0,0,0,5,13,-7,13,9,0,0,0,0,1,11,-100,-3,7,0,0,0,0,-11,7,0,0,5,-100,-4,0,0,0,0,9,-10,9,0,5,-100,-4,5,0,0,0,1,-10,5,0,11,-100,-4,11,0,0,0,0,9,-9,0,1,-100,-5,1,0,0,0,3,-8,9,0,7,-100,-5,7,0,0,0,0,13,-7,3,0,13,-100,-5,13,0,0,0,0,7,-6,13,0,3,-100,-6,3,0,0,0,1,-6,7,0,11,-100,-6,9,0,0,0,0,9,-5,0,1,-100,-6,13,0,0,0,0,3,-4,7,0,7,-100,-7,5,0,0,0,0,11,-3,1,0,13,-100,-7,11,0,0,0,0,1,-2,9,0,5,-100,-8,1,0,0,0,0,5,-1,1,0,11,-100,-8,7,0,0,0,0,0,0,0,3,-100,-8,13,0,0,0,0,0,0,0,9,-100,-9,3,0,0,0,0,0,1,-100,-9,9,0,0,0,0,0,7,-100,-10,0,0,0,0,0,13,-100,-10,5,0,0,0,1,-100,-10,13,1,0,0,7,-100,-11,11,1,5,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 23 
     | 
    
         
            +
            static int8_t lt22[]={-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-29,13,-100,5,0,0,1,1,1,3,3,5,7,-3,7,0,0,0,0,0,0,0,0,0,11,-4,3,0,0,0,0,0,0,1,3,11,-100,5,0,0,0,0,0,0,0,1,7,-3,9,0,0,0,0,0,0,0,0,1,11,-4,9,1,0,0,0,0,0,0,1,13,-100,-1,13,5,0,0,0,0,0,13,-5,13,5,0,0,0,0,0,3,-8,9,0,0,0,0,5,-100,-3,5,0,0,0,0,-8,11,0,0,0,0,9,-9,9,0,0,9,-100,-4,1,0,0,0,13,-8,11,0,0,0,3,-10,0,3,-100,-4,7,0,0,0,11,-8,13,0,0,0,0,13,-8,9,0,11,-100,-4,13,0,0,0,7,-8,11,0,0,0,0,7,-8,1,1,-100,-5,5,0,0,1,-8,7,0,0,0,0,3,-8,5,11,-100,-5,11,0,0,0,9,-7,1,0,0,0,0,0,13,-100,-6,0,0,0,3,-6,9,0,3,13,0,0,0,7,-6,5,-100,-6,3,0,0,0,13,-5,1,0,11,-1,3,0,0,3,-6,1,-100,-6,9,0,0,0,9,-4,11,0,3,-2,7,0,0,0,13,-4,11,1,-100,-6,13,0,0,0,3,-4,5,0,9,-2,13,0,0,0,7,-4,5,3,-100,-7,3,0,0,0,13,-3,1,1,-4,0,0,0,1,-4,1,7,-100,-7,9,0,0,0,5,-2,13,0,7,-4,5,0,0,0,9,-2,9,0,13,-100,-8,1,0,0,0,13,-1,7,1,-5,11,0,0,0,1,-2,1,3,-100,-8,7,0,0,0,1,13,1,5,-6,1,0,0,0,13,9,0,9,-100,-8,13,0,0,0,0,0,0,11,-6,7,0,0,0,1,0,1,-100,-9,3,0,0,0,0,3,-7,13,0,0,0,0,0,9,-100,-9,9,0,0,0,0,5,-8,3,0,0,0,0,13,-100,-9,13,0,0,0,0,11,-8,9,0,0,0,1,-100,-10,3,0,0,0,-10,3,0,0,5,-100,-10,11,0,0,7,-10,13,1,1,13,-100,-11,11,11,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 24 
     | 
    
         
            +
            static int8_t lt23[]={-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-16,13,13,-1,13,9,5,1,0,1,5,13,-100,-1,3,0,0,0,0,0,0,0,0,1,7,-4,1,0,0,0,0,0,0,0,0,0,1,-100,-1,1,0,0,0,0,0,0,0,0,1,11,-4,7,0,0,0,0,0,0,0,0,0,5,-100,-2,13,7,0,0,0,0,0,0,13,-6,13,5,0,0,0,0,5,9,13,-100,-4,13,3,0,0,0,0,3,-7,13,0,0,5,13,-100,-6,3,0,0,0,0,5,-6,7,0,7,-100,-7,3,0,0,0,0,11,-4,11,0,9,-100,-8,5,0,0,0,1,-3,11,0,7,-100,-9,3,0,0,0,1,11,11,0,7,-100,-9,13,1,0,0,0,0,0,7,-100,-10,13,1,0,0,0,0,9,-100,-11,11,0,0,0,0,1,-100,-12,0,0,0,0,0,7,-100,-11,9,0,0,0,0,0,0,11,-100,-10,9,0,5,13,3,0,0,0,1,13,-100,-9,11,0,3,-2,13,1,0,0,0,1,13,-100,-8,11,0,3,13,-3,13,1,0,0,0,1,13,-100,-7,9,0,1,13,-5,11,0,0,0,0,1,13,-100,-6,9,0,0,7,-7,9,0,0,0,0,1,11,-100,-5,5,0,0,0,13,-8,7,0,0,0,0,0,9,-100,-3,13,3,0,0,0,0,13,-8,13,0,0,0,0,0,0,5,-100,9,3,1,0,0,0,0,0,0,1,11,-6,11,1,0,0,0,0,0,0,0,1,3,13,-100,3,0,0,0,0,0,0,0,0,0,3,-6,11,5,3,1,0,0,0,1,1,3,5,-100,13,13,13,13,-100,-100,-100,-100,-100,-100,-100,-100,-100,-101};
         
     | 
| 
      
 25 
     | 
    
         
            +
            static int8_t lt24[]={-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-100,-1,13,13,-2,13,13,11,11,11,13,-6,11,11,11,11,11,11,11,11,13,-100,3,0,0,0,0,0,0,0,0,0,0,3,-4,1,0,0,0,0,0,0,0,0,1,-100,7,0,0,0,0,0,0,0,0,0,0,5,-4,3,0,0,0,0,0,0,0,0,9,-100,-2,11,5,0,0,0,0,0,0,11,-6,11,0,0,0,0,1,7,13,-100,-4,11,0,0,0,0,0,-8,9,0,0,1,13,-100,-5,7,0,0,0,0,13,-7,9,0,0,13,-100,-6,1,0,0,0,9,-7,5,0,5,-100,-6,7,0,0,0,3,-7,1,0,13,-100,-6,13,0,0,0,0,13,-5,11,0,1,-100,-7,5,0,0,0,7,-5,7,0,7,-100,-7,11,0,0,0,3,-5,1,0,11,-100,-8,1,0,0,0,13,-3,13,0,3,-100,-8,7,0,0,0,7,-3,7,0,9,-100,-8,13,0,0,0,3,-3,1,1,-100,-9,5,0,0,0,13,-1,9,0,7,-100,-9,11,0,0,0,3,13,1,0,13,-100,-10,1,0,0,0,0,0,3,-100,-10,9,0,0,0,0,0,9,-100,-11,1,0,0,0,1,-100,-11,5,0,0,0,7,-100,-11,9,0,0,0,13,-100,-11,13,0,0,3,-100,-12,0,0,9,-100,-12,0,1,-100,-11,13,0,7,-100,-11,7,0,11,-100,-11,1,0,-100,-2,7,0,1,7,-4,11,0,3,-100,-1,11,0,0,0,0,1,9,13,11,1,0,9,-100,-1,3,0,0,0,0,0,0,0,0,0,3,-100,-1,0,0,0,0,0,0,0,0,0,1,13,-100,-1,7,0,0,0,0,0,0,0,1,13,-100,-2,9,3,0,0,1,3,7,-100,-101};
         
     | 
| 
      
 26 
     | 
    
         
            +
            static int8_t *lt[]={lt0,lt1,lt2,lt3,lt0,lt5,lt0,lt7,lt8,lt9,lt10,lt11,lt12,lt13,lt14,lt15,lt16,lt17,lt18,lt19,lt20,lt21,lt22,lt23,lt24,};
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,221 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            // http://github.com/ITikhonov/captcha
         
     | 
| 
      
 2 
     | 
    
         
            +
            const int gifsize;
         
     | 
| 
      
 3 
     | 
    
         
            +
            void captcha(unsigned char im[70*200], unsigned char l[6]);
         
     | 
| 
      
 4 
     | 
    
         
            +
            void makegif(unsigned char im[70*200], unsigned char gif[gifsize]);
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            #include <unistd.h>
         
     | 
| 
      
 7 
     | 
    
         
            +
            #include <stdint.h>
         
     | 
| 
      
 8 
     | 
    
         
            +
            #include <fcntl.h>
         
     | 
| 
      
 9 
     | 
    
         
            +
            #include <string.h>
         
     | 
| 
      
 10 
     | 
    
         
            +
            #include <ruby.h>
         
     | 
| 
      
 11 
     | 
    
         
            +
            #include "font.h"
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            static int8_t *lt[];
         
     | 
| 
      
 14 
     | 
    
         
            +
            const int gifsize=17646;
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            void makegif(unsigned char im[70*200], unsigned char gif[gifsize]) {
         
     | 
| 
      
 17 
     | 
    
         
            +
             	// tag ; widthxheight ; GCT:0:0:7 ; bgcolor + aspect // GCT
         
     | 
| 
      
 18 
     | 
    
         
            +
             	// Image Separator // left x top // widthxheight // Flags
         
     | 
| 
      
 19 
     | 
    
         
            +
            	// LZW code size
         
     | 
| 
      
 20 
     | 
    
         
            +
            	memcpy(gif,"GIF89a" "\xc8\0\x46\0" "\x83" "\0\0"
         
     | 
| 
      
 21 
     | 
    
         
            +
            		"\x00\x00\x00"
         
     | 
| 
      
 22 
     | 
    
         
            +
            		"\x10\x10\x10"
         
     | 
| 
      
 23 
     | 
    
         
            +
            		"\x20\x20\x20"
         
     | 
| 
      
 24 
     | 
    
         
            +
            		"\x30\x30\x30"
         
     | 
| 
      
 25 
     | 
    
         
            +
            		"\x40\x40\x40"
         
     | 
| 
      
 26 
     | 
    
         
            +
            		"\x50\x50\x50"
         
     | 
| 
      
 27 
     | 
    
         
            +
            		"\x60\x60\x60"
         
     | 
| 
      
 28 
     | 
    
         
            +
            		"\x70\x70\x70"
         
     | 
| 
      
 29 
     | 
    
         
            +
            		"\x80\x80\x80"
         
     | 
| 
      
 30 
     | 
    
         
            +
            		"\x90\x90\x90"
         
     | 
| 
      
 31 
     | 
    
         
            +
            		"\xa0\xa0\xa0"
         
     | 
| 
      
 32 
     | 
    
         
            +
            		"\xb0\xb0\xb0"
         
     | 
| 
      
 33 
     | 
    
         
            +
            		"\xc0\xc0\xc0"
         
     | 
| 
      
 34 
     | 
    
         
            +
            		"\xd0\xd0\xd0"
         
     | 
| 
      
 35 
     | 
    
         
            +
            		"\xe0\xe0\xe0"
         
     | 
| 
      
 36 
     | 
    
         
            +
            		"\xff\xff\xff"
         
     | 
| 
      
 37 
     | 
    
         
            +
            		"," "\0\0\0\0" "\xc8\0\x46\0" "\0" "\x04",13+48+10+1);
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            	int x,y;
         
     | 
| 
      
 40 
     | 
    
         
            +
            	unsigned char *i=im;
         
     | 
| 
      
 41 
     | 
    
         
            +
            	unsigned char *p=gif+13+48+10+1;
         
     | 
| 
      
 42 
     | 
    
         
            +
            	for(y=0;y<70;y++) {
         
     | 
| 
      
 43 
     | 
    
         
            +
            		*p++=250; // Data length 5*50=250
         
     | 
| 
      
 44 
     | 
    
         
            +
            		for(x=0;x<50;x++)
         
     | 
| 
      
 45 
     | 
    
         
            +
            		{
         
     | 
| 
      
 46 
     | 
    
         
            +
            			unsigned char a=i[0]>>4,b=i[1]>>4,c=i[2]>>4,d=i[3]>>4;
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
            			p[0]=16|(a<<5);			// bbb10000
         
     | 
| 
      
 49 
     | 
    
         
            +
            			p[1]=(a>>3)|64|(b<<7);	// b10000xb
         
     | 
| 
      
 50 
     | 
    
         
            +
            			p[2]=b>>1;			// 0000xbbb
         
     | 
| 
      
 51 
     | 
    
         
            +
            			p[3]=1|(c<<1);		// 00xbbbb1
         
     | 
| 
      
 52 
     | 
    
         
            +
            			p[4]=4|(d<<3);		// xbbbb100
         
     | 
| 
      
 53 
     | 
    
         
            +
            			i+=4;
         
     | 
| 
      
 54 
     | 
    
         
            +
            			p+=5;
         
     | 
| 
      
 55 
     | 
    
         
            +
            		}
         
     | 
| 
      
 56 
     | 
    
         
            +
            	}
         
     | 
| 
      
 57 
     | 
    
         
            +
             
     | 
| 
      
 58 
     | 
    
         
            +
             	// Data length // End of LZW (b10001) // Terminator // GIF End
         
     | 
| 
      
 59 
     | 
    
         
            +
            	memcpy(gif+gifsize-4,"\x01" "\x11" "\x00" ";",4);
         
     | 
| 
      
 60 
     | 
    
         
            +
            }
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
            static const int8_t sw[200]={0, 4, 8, 12, 16, 20, 23, 27, 31, 35, 39, 43, 47, 50, 54, 58, 61, 65, 68, 71, 75, 78, 81, 84, 87, 90, 93, 96, 98, 101, 103, 105, 108, 110, 112, 114, 115, 117, 119, 120, 121, 122, 123, 124, 125, 126, 126, 127, 127, 127, 127, 127, 127, 127, 126, 126, 125, 124, 123, 122, 121, 120, 119, 117, 115, 114, 112, 110, 108, 105, 103, 101, 98, 96, 93, 90, 87, 84, 81, 78, 75, 71, 68, 65, 61, 58, 54, 50, 47, 43, 39, 35, 31, 27, 23, 20, 16, 12, 8, 4, 0, -4, -8, -12, -16, -20, -23, -27, -31, -35, -39, -43, -47, -50, -54, -58, -61, -65, -68, -71, -75, -78, -81, -84, -87, -90, -93, -96, -98, -101, -103, -105, -108, -110, -112, -114, -115, -117, -119, -120, -121, -122, -123, -124, -125, -126, -126, -127, -127, -127, -127, -127, -127, -127, -126, -126, -125, -124, -123, -122, -121, -120, -119, -117, -115, -114, -112, -110, -108, -105, -103, -101, -98, -96, -93, -90, -87, -84, -81, -78, -75, -71, -68, -65, -61, -58, -54, -50, -47, -43, -39, -35, -31, -27, -23, -20, -16, -12, -8, -4};
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
            #define MAX(x,y) ((x>y)?(x):(y))
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
            static int letter(int n, int pos, unsigned char im[70*200], unsigned char swr[200], uint8_t s1, uint8_t s2) {
         
     | 
| 
      
 68 
     | 
    
         
            +
            	int8_t *p=lt[n];
         
     | 
| 
      
 69 
     | 
    
         
            +
            	unsigned char *r=im+200*16+pos;
         
     | 
| 
      
 70 
     | 
    
         
            +
            	unsigned char *i=r;
         
     | 
| 
      
 71 
     | 
    
         
            +
            	int sk1=s1+pos;
         
     | 
| 
      
 72 
     | 
    
         
            +
            	int sk2=s2+pos;
         
     | 
| 
      
 73 
     | 
    
         
            +
            	int mpos=pos;
         
     | 
| 
      
 74 
     | 
    
         
            +
            	int row=0;
         
     | 
| 
      
 75 
     | 
    
         
            +
            	for(;*p!=-101;p++) {
         
     | 
| 
      
 76 
     | 
    
         
            +
            		if(*p<0) {
         
     | 
| 
      
 77 
     | 
    
         
            +
            			if(*p==-100) { r+=200; i=r; sk1=s1+pos; row++; continue; }
         
     | 
| 
      
 78 
     | 
    
         
            +
            			i+=-*p;
         
     | 
| 
      
 79 
     | 
    
         
            +
            			continue;
         
     | 
| 
      
 80 
     | 
    
         
            +
            		}
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
            		if(sk1>=200) sk1=sk1%200;
         
     | 
| 
      
 83 
     | 
    
         
            +
            		int skew=sw[sk1]/16;
         
     | 
| 
      
 84 
     | 
    
         
            +
            		sk1+=(swr[pos+i-r]&0x1)+1;
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
            		if(sk2>=200) sk2=sk2%200;
         
     | 
| 
      
 87 
     | 
    
         
            +
            		int skewh=sw[sk2]/70;
         
     | 
| 
      
 88 
     | 
    
         
            +
            		sk2+=(swr[row]&0x1);
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
            		unsigned char *x=i+skew*200+skewh;
         
     | 
| 
      
 91 
     | 
    
         
            +
            		mpos=MAX(mpos,pos+i-r);
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
            		if((x-im)<70*200) *x=(*p)<<4;
         
     | 
| 
      
 94 
     | 
    
         
            +
            		i++;
         
     | 
| 
      
 95 
     | 
    
         
            +
            	}
         
     | 
| 
      
 96 
     | 
    
         
            +
            	return mpos;
         
     | 
| 
      
 97 
     | 
    
         
            +
            }
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
            #define NDOTS 100
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
            uint32_t dr[NDOTS];
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
            static void line(unsigned char im[70*200], unsigned char swr[200], uint8_t s1) {
         
     | 
| 
      
 104 
     | 
    
         
            +
            	int x;
         
     | 
| 
      
 105 
     | 
    
         
            +
            	int sk1=s1;
         
     | 
| 
      
 106 
     | 
    
         
            +
            	for(x=0;x<199;x++) {
         
     | 
| 
      
 107 
     | 
    
         
            +
            		if(sk1>=200) sk1=sk1%200;
         
     | 
| 
      
 108 
     | 
    
         
            +
            		int skew=sw[sk1]/16;
         
     | 
| 
      
 109 
     | 
    
         
            +
            		sk1+=swr[x]&0x3+1;
         
     | 
| 
      
 110 
     | 
    
         
            +
            		unsigned char *i= im+(200*(45+skew)+x);
         
     | 
| 
      
 111 
     | 
    
         
            +
            		i[0]=0; i[1]=0; i[200]=0; i[201]=0;
         
     | 
| 
      
 112 
     | 
    
         
            +
            	}
         
     | 
| 
      
 113 
     | 
    
         
            +
            }
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
      
 115 
     | 
    
         
            +
            static void dots(unsigned char im[70*200]) {
         
     | 
| 
      
 116 
     | 
    
         
            +
            	int n;
         
     | 
| 
      
 117 
     | 
    
         
            +
            	for(n=0;n<NDOTS;n++) {
         
     | 
| 
      
 118 
     | 
    
         
            +
            		uint32_t v=dr[n];
         
     | 
| 
      
 119 
     | 
    
         
            +
            		unsigned char *i=im+v%(200*67);
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
            		i[0]=0xff;
         
     | 
| 
      
 122 
     | 
    
         
            +
            		i[1]=0xff;
         
     | 
| 
      
 123 
     | 
    
         
            +
            		i[2]=0xff;
         
     | 
| 
      
 124 
     | 
    
         
            +
            		i[200]=0xff;
         
     | 
| 
      
 125 
     | 
    
         
            +
            		i[201]=0xff;
         
     | 
| 
      
 126 
     | 
    
         
            +
            		i[202]=0xff;
         
     | 
| 
      
 127 
     | 
    
         
            +
            	}
         
     | 
| 
      
 128 
     | 
    
         
            +
            }
         
     | 
| 
      
 129 
     | 
    
         
            +
            static void blur(unsigned char im[70*200]) {
         
     | 
| 
      
 130 
     | 
    
         
            +
            	unsigned char *i=im;
         
     | 
| 
      
 131 
     | 
    
         
            +
            	int x,y;
         
     | 
| 
      
 132 
     | 
    
         
            +
            	for(y=0;y<68;y++) {
         
     | 
| 
      
 133 
     | 
    
         
            +
              	for(x=0;x<198;x++) {
         
     | 
| 
      
 134 
     | 
    
         
            +
            			unsigned int c11=*i,c12=i[1],c21=i[200],c22=i[201];
         
     | 
| 
      
 135 
     | 
    
         
            +
            			*i++=((c11+c12+c21+c22)/4);
         
     | 
| 
      
 136 
     | 
    
         
            +
              	}
         
     | 
| 
      
 137 
     | 
    
         
            +
            	}
         
     | 
| 
      
 138 
     | 
    
         
            +
            }
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
            static void filter(unsigned char im[70*200]) {
         
     | 
| 
      
 141 
     | 
    
         
            +
            	unsigned char om[70*200];
         
     | 
| 
      
 142 
     | 
    
         
            +
            	unsigned char *i=im;
         
     | 
| 
      
 143 
     | 
    
         
            +
            	unsigned char *o=om;
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
            	memset(om,0xff,sizeof(om));
         
     | 
| 
      
 146 
     | 
    
         
            +
             
     | 
| 
      
 147 
     | 
    
         
            +
            	int x,y;
         
     | 
| 
      
 148 
     | 
    
         
            +
            	for(y=0;y<70;y++) {
         
     | 
| 
      
 149 
     | 
    
         
            +
            		for(x=4;x<200-4;x++) {
         
     | 
| 
      
 150 
     | 
    
         
            +
            			if(i[0]>0xf0 && i[1]<0xf0) { o[0]=0; o[1]=0; }
         
     | 
| 
      
 151 
     | 
    
         
            +
            			else if(i[0]<0xf0 && i[1]>0xf0) { o[0]=0; o[1]=0; }
         
     | 
| 
      
 152 
     | 
    
         
            +
             
     | 
| 
      
 153 
     | 
    
         
            +
            			i++;
         
     | 
| 
      
 154 
     | 
    
         
            +
            			o++;
         
     | 
| 
      
 155 
     | 
    
         
            +
            		}
         
     | 
| 
      
 156 
     | 
    
         
            +
            	}
         
     | 
| 
      
 157 
     | 
    
         
            +
             
     | 
| 
      
 158 
     | 
    
         
            +
            	memmove(im,om,sizeof(om));
         
     | 
| 
      
 159 
     | 
    
         
            +
            }
         
     | 
| 
      
 160 
     | 
    
         
            +
             
     | 
| 
      
 161 
     | 
    
         
            +
            static const char *letters="abcdafahijklmnopqrstuvwxyz";
         
     | 
| 
      
 162 
     | 
    
         
            +
             
     | 
| 
      
 163 
     | 
    
         
            +
            void captcha(unsigned char im[70*200], unsigned char l[6]) {
         
     | 
| 
      
 164 
     | 
    
         
            +
            	unsigned char swr[200];
         
     | 
| 
      
 165 
     | 
    
         
            +
            	uint8_t s1,s2;
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
            	int f=open("/dev/urandom",O_RDONLY);
         
     | 
| 
      
 168 
     | 
    
         
            +
            	read(f,l,5); read(f,swr,200); read(f,dr,sizeof(dr)); read(f,&s1,1); read(f,&s2,1);
         
     | 
| 
      
 169 
     | 
    
         
            +
            	close(f);
         
     | 
| 
      
 170 
     | 
    
         
            +
             
     | 
| 
      
 171 
     | 
    
         
            +
            	memset(im,0xff,200*70); s1=s1&0x7f; s2=s2&0x3f; l[0]%=25; l[1]%=25; l[2]%=25; l[3]%=25; l[4]%=25; l[5]=0;
         
     | 
| 
      
 172 
     | 
    
         
            +
            	int p=30; p=letter(l[0],p,im,swr,s1,s2); p=letter(l[1],p,im,swr,s1,s2); p=letter(l[2],p,im,swr,s1,s2); p=letter(l[3],p,im,swr,s1,s2); letter(l[4],p,im,swr,s1,s2);
         
     | 
| 
      
 173 
     | 
    
         
            +
            	line(im,swr,s1); dots(im); // blur(im); // filter(im);
         
     | 
| 
      
 174 
     | 
    
         
            +
            	l[0]=letters[l[0]]; l[1]=letters[l[1]]; l[2]=letters[l[2]]; l[3]=letters[l[3]]; l[4]=letters[l[4]];
         
     | 
| 
      
 175 
     | 
    
         
            +
            }
         
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
      
 177 
     | 
    
         
            +
            // #ifdef CAPTCHA
         
     | 
| 
      
 178 
     | 
    
         
            +
            //
         
     | 
| 
      
 179 
     | 
    
         
            +
            // int main() {
         
     | 
| 
      
 180 
     | 
    
         
            +
            //   char l[6];
         
     | 
| 
      
 181 
     | 
    
         
            +
            //   unsigned char im[70*200];
         
     | 
| 
      
 182 
     | 
    
         
            +
            //   unsigned char gif[gifsize];
         
     | 
| 
      
 183 
     | 
    
         
            +
            //
         
     | 
| 
      
 184 
     | 
    
         
            +
            //   captcha(im,l);
         
     | 
| 
      
 185 
     | 
    
         
            +
            //   makegif(im,gif);
         
     | 
| 
      
 186 
     | 
    
         
            +
            //
         
     | 
| 
      
 187 
     | 
    
         
            +
            //   write(1,gif,gifsize);
         
     | 
| 
      
 188 
     | 
    
         
            +
            //   write(2,l,5);
         
     | 
| 
      
 189 
     | 
    
         
            +
            //
         
     | 
| 
      
 190 
     | 
    
         
            +
            //   return 0;
         
     | 
| 
      
 191 
     | 
    
         
            +
            // }
         
     | 
| 
      
 192 
     | 
    
         
            +
            //
         
     | 
| 
      
 193 
     | 
    
         
            +
            // #endif
         
     | 
| 
      
 194 
     | 
    
         
            +
             
     | 
| 
      
 195 
     | 
    
         
            +
            VALUE RuCaptcha = Qnil;
         
     | 
| 
      
 196 
     | 
    
         
            +
             
     | 
| 
      
 197 
     | 
    
         
            +
            void Init_rucaptcha();
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
            VALUE create(VALUE self);
         
     | 
| 
      
 200 
     | 
    
         
            +
             
     | 
| 
      
 201 
     | 
    
         
            +
            void Init_rucaptcha() {
         
     | 
| 
      
 202 
     | 
    
         
            +
              RuCaptcha = rb_define_module("RuCaptcha");
         
     | 
| 
      
 203 
     | 
    
         
            +
              rb_define_singleton_method(RuCaptcha, "create", create, 0);
         
     | 
| 
      
 204 
     | 
    
         
            +
            }
         
     | 
| 
      
 205 
     | 
    
         
            +
             
     | 
| 
      
 206 
     | 
    
         
            +
            VALUE create(VALUE self) {
         
     | 
| 
      
 207 
     | 
    
         
            +
            	char l[6];
         
     | 
| 
      
 208 
     | 
    
         
            +
            	unsigned char im[80*200];
         
     | 
| 
      
 209 
     | 
    
         
            +
            	unsigned char gif[gifsize];
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
      
 211 
     | 
    
         
            +
            	captcha(im,l);
         
     | 
| 
      
 212 
     | 
    
         
            +
            	makegif(im,gif);
         
     | 
| 
      
 213 
     | 
    
         
            +
             
     | 
| 
      
 214 
     | 
    
         
            +
              VALUE result = rb_ary_new2(2);
         
     | 
| 
      
 215 
     | 
    
         
            +
              rb_ary_push(result, rb_str_new2(l));
         
     | 
| 
      
 216 
     | 
    
         
            +
              rb_ary_push(result, rb_str_new(gif, gifsize));
         
     | 
| 
      
 217 
     | 
    
         
            +
             
     | 
| 
      
 218 
     | 
    
         
            +
              return result;
         
     | 
| 
      
 219 
     | 
    
         
            +
            }
         
     | 
| 
      
 220 
     | 
    
         
            +
             
     | 
| 
      
 221 
     | 
    
         
            +
             
     | 
    
        data/lib/rucaptcha.rb
    CHANGED
    
    | 
         @@ -1,12 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'rails'
         
     | 
| 
       2 
2 
     | 
    
         
             
            require 'action_controller'
         
     | 
| 
       3 
3 
     | 
    
         
             
            require 'active_support/all'
         
     | 
| 
      
 4 
     | 
    
         
            +
            require_relative 'rucaptcha/rucaptcha'
         
     | 
| 
       4 
5 
     | 
    
         
             
            require_relative 'rucaptcha/version'
         
     | 
| 
       5 
6 
     | 
    
         
             
            require_relative 'rucaptcha/configuration'
         
     | 
| 
       6 
7 
     | 
    
         
             
            require_relative 'rucaptcha/controller_helpers'
         
     | 
| 
       7 
8 
     | 
    
         
             
            require_relative 'rucaptcha/view_helpers'
         
     | 
| 
       8 
9 
     | 
    
         
             
            require_relative 'rucaptcha/cache'
         
     | 
| 
       9 
     | 
    
         
            -
            require_relative 'rucaptcha/captcha'
         
     | 
| 
       10 
10 
     | 
    
         
             
            require_relative 'rucaptcha/engine'
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
            module RuCaptcha
         
     | 
| 
         @@ -14,12 +14,7 @@ module RuCaptcha 
     | 
|
| 
       14 
14 
     | 
    
         
             
                def config
         
     | 
| 
       15 
15 
     | 
    
         
             
                  return @config if defined?(@config)
         
     | 
| 
       16 
16 
     | 
    
         
             
                  @config = Configuration.new
         
     | 
| 
       17 
     | 
    
         
            -
                  @config.len         = 4
         
     | 
| 
       18 
     | 
    
         
            -
                  @config.font_size   = 45
         
     | 
| 
       19 
     | 
    
         
            -
                  @config.implode     = 0.3
         
     | 
| 
       20 
     | 
    
         
            -
                  @config.cache_limit = 100
         
     | 
| 
       21 
17 
     | 
    
         
             
                  @config.expires_in  = 2.minutes
         
     | 
| 
       22 
     | 
    
         
            -
                  @config.style       = :colorful
         
     | 
| 
       23 
18 
     | 
    
         
             
                  if Rails.application
         
     | 
| 
       24 
19 
     | 
    
         
             
                    @config.cache_store = Rails.application.config.cache_store
         
     | 
| 
       25 
20 
     | 
    
         
             
                  else
         
     | 
    
        data/lib/rucaptcha/cache.rb
    CHANGED
    
    | 
         @@ -8,46 +8,4 @@ module RuCaptcha 
     | 
|
| 
       8 
8 
     | 
    
         
             
                  @cache
         
     | 
| 
       9 
9 
     | 
    
         
             
                end
         
     | 
| 
       10 
10 
     | 
    
         
             
              end
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
              # File Cache
         
     | 
| 
       13 
     | 
    
         
            -
              module Cache
         
     | 
| 
       14 
     | 
    
         
            -
                def self.prepended(base)
         
     | 
| 
       15 
     | 
    
         
            -
                  class << base
         
     | 
| 
       16 
     | 
    
         
            -
                    prepend ClassMethods
         
     | 
| 
       17 
     | 
    
         
            -
                  end
         
     | 
| 
       18 
     | 
    
         
            -
                end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                module ClassMethods
         
     | 
| 
       21 
     | 
    
         
            -
                  def create(code)
         
     | 
| 
       22 
     | 
    
         
            -
                    file_cache.fetch(code, expires_in: 1.days) do
         
     | 
| 
       23 
     | 
    
         
            -
                      super(code)
         
     | 
| 
       24 
     | 
    
         
            -
                    end
         
     | 
| 
       25 
     | 
    
         
            -
                  end
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                  def random_chars
         
     | 
| 
       28 
     | 
    
         
            -
                    if cached_codes.length >= RuCaptcha.config.cache_limit
         
     | 
| 
       29 
     | 
    
         
            -
                      return cached_codes.sample
         
     | 
| 
       30 
     | 
    
         
            -
                    end
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                    code = super
         
     | 
| 
       33 
     | 
    
         
            -
                    cached_codes << code
         
     | 
| 
       34 
     | 
    
         
            -
                    code
         
     | 
| 
       35 
     | 
    
         
            -
                  end
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
                  def file_cache
         
     | 
| 
       38 
     | 
    
         
            -
                    return @file_cache if defined?(@file_cache)
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                    cache_path = Rails.root.join('tmp', 'cache', 'rucaptcha')
         
     | 
| 
       41 
     | 
    
         
            -
                    FileUtils.mkdir_p(cache_path) unless File.exist? cache_path
         
     | 
| 
       42 
     | 
    
         
            -
                    @file_cache = ActiveSupport::Cache::FileStore.new(cache_path)
         
     | 
| 
       43 
     | 
    
         
            -
                    # clear expired captcha cache files on Process restart
         
     | 
| 
       44 
     | 
    
         
            -
                    @file_cache.cleanup
         
     | 
| 
       45 
     | 
    
         
            -
                    @file_cache
         
     | 
| 
       46 
     | 
    
         
            -
                  end
         
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
                  def cached_codes
         
     | 
| 
       49 
     | 
    
         
            -
                    @cached_codes ||= []
         
     | 
| 
       50 
     | 
    
         
            -
                  end
         
     | 
| 
       51 
     | 
    
         
            -
                end
         
     | 
| 
       52 
     | 
    
         
            -
              end
         
     | 
| 
       53 
11 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,19 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module RuCaptcha
         
     | 
| 
       2 
2 
     | 
    
         
             
              class Configuration
         
     | 
| 
       3 
     | 
    
         
            -
                # Image font size, default 45
         
     | 
| 
       4 
     | 
    
         
            -
                attr_accessor :font_size
         
     | 
| 
       5 
     | 
    
         
            -
                # Number of chars, default 4
         
     | 
| 
       6 
     | 
    
         
            -
                attr_accessor :len
         
     | 
| 
       7 
     | 
    
         
            -
                # implode, default 0.3
         
     | 
| 
       8 
     | 
    
         
            -
                attr_accessor :implode
         
     | 
| 
       9 
3 
     | 
    
         
             
                # Store Captcha code where, this config more like Rails config.cache_store
         
     | 
| 
       10 
4 
     | 
    
         
             
                # default: Rails application config.cache_store
         
     | 
| 
       11 
5 
     | 
    
         
             
                attr_accessor :cache_store
         
     | 
| 
       12 
     | 
    
         
            -
                # Number of Captcha codes limit
         
     | 
| 
       13 
     | 
    
         
            -
                # set 0 to disable limit and file cache, default: 100
         
     | 
| 
       14 
     | 
    
         
            -
                attr_accessor :cache_limit
         
     | 
| 
       15 
     | 
    
         
            -
                # Color style, default: :colorful, allows: [:colorful, :black_white]
         
     | 
| 
       16 
     | 
    
         
            -
                attr_accessor :style
         
     | 
| 
       17 
6 
     | 
    
         
             
                # rucaptcha expire time, default 2 minutes
         
     | 
| 
       18 
7 
     | 
    
         
             
                attr_accessor :expires_in
         
     | 
| 
       19 
8 
     | 
    
         
             
              end
         
     | 
| 
         @@ -8,18 +8,19 @@ module RuCaptcha 
     | 
|
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
                # session key of rucaptcha
         
     | 
| 
       10 
10 
     | 
    
         
             
                def rucaptcha_sesion_key_key
         
     | 
| 
       11 
     | 
    
         
            -
                   
     | 
| 
      
 11 
     | 
    
         
            +
                  session_id = session.respond_to?(:id) ? session.id : session[:session_id]
         
     | 
| 
      
 12 
     | 
    
         
            +
                  ['rucaptcha-session', session_id].join(':')
         
     | 
| 
       12 
13 
     | 
    
         
             
                end
         
     | 
| 
       13 
14 
     | 
    
         | 
| 
       14 
15 
     | 
    
         
             
                # Generate a new Captcha
         
     | 
| 
       15 
16 
     | 
    
         
             
                def generate_rucaptcha
         
     | 
| 
       16 
     | 
    
         
            -
                   
     | 
| 
      
 17 
     | 
    
         
            +
                  res = RuCaptcha.create()
         
     | 
| 
       17 
18 
     | 
    
         
             
                  session_val = {
         
     | 
| 
       18 
     | 
    
         
            -
                    code:  
     | 
| 
      
 19 
     | 
    
         
            +
                    code: res[0],
         
     | 
| 
       19 
20 
     | 
    
         
             
                    time: Time.now.to_i
         
     | 
| 
       20 
21 
     | 
    
         
             
                  }
         
     | 
| 
       21 
22 
     | 
    
         
             
                  RuCaptcha.cache.write(rucaptcha_sesion_key_key, session_val, expires_in: RuCaptcha.config.expires_in)
         
     | 
| 
       22 
     | 
    
         
            -
                   
     | 
| 
      
 23 
     | 
    
         
            +
                  res[1]
         
     | 
| 
       23 
24 
     | 
    
         
             
                end
         
     | 
| 
       24 
25 
     | 
    
         | 
| 
       25 
26 
     | 
    
         
             
                # Verify captcha code
         
     | 
    
        data/lib/rucaptcha/engine.rb
    CHANGED
    
    | 
         @@ -3,11 +3,6 @@ module RuCaptcha 
     | 
|
| 
       3 
3 
     | 
    
         
             
                isolate_namespace RuCaptcha
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
                initializer 'rucaptcha.prepend.cache' do
         
     | 
| 
       6 
     | 
    
         
            -
                  # enable cache if cache_limit less than 1
         
     | 
| 
       7 
     | 
    
         
            -
                  if RuCaptcha.config.cache_limit >= 1
         
     | 
| 
       8 
     | 
    
         
            -
                    RuCaptcha::Captcha.send(:prepend, RuCaptcha::Cache)
         
     | 
| 
       9 
     | 
    
         
            -
                  end
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
6 
     | 
    
         
             
                  cache_store = RuCaptcha.config.cache_store
         
     | 
| 
       12 
7 
     | 
    
         
             
                  store_name = cache_store.is_a?(Array) ? cache_store.first : cache_store
         
     | 
| 
       13 
8 
     | 
    
         
             
                  if [:memory_store, :null_store, :file_store].include?(store_name)
         
     | 
    
        data/lib/rucaptcha/version.rb
    CHANGED
    
    
| 
         @@ -5,8 +5,8 @@ module RuCaptcha 
     | 
|
| 
       5 
5 
     | 
    
         
             
                  opts[:type]           = 'text'
         
     | 
| 
       6 
6 
     | 
    
         
             
                  opts[:autocorrect]    = 'off'
         
     | 
| 
       7 
7 
     | 
    
         
             
                  opts[:autocapitalize] = 'off'
         
     | 
| 
       8 
     | 
    
         
            -
                  opts[:pattern]        = '[ 
     | 
| 
       9 
     | 
    
         
            -
                  opts[:maxlength]      =  
     | 
| 
      
 8 
     | 
    
         
            +
                  opts[:pattern]        = '[a-zA-Z]*'
         
     | 
| 
      
 9 
     | 
    
         
            +
                  opts[:maxlength]      = 5
         
     | 
| 
       10 
10 
     | 
    
         
             
                  opts[:autocomplete]   = 'off'
         
     | 
| 
       11 
11 
     | 
    
         
             
                  tag(:input, opts)
         
     | 
| 
       12 
12 
     | 
    
         
             
                end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: rucaptcha
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version:  
     | 
| 
      
 4 
     | 
    
         
            +
              version: 2.0.0.beta3
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Jason Lee
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-01-20 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: railties
         
     | 
| 
         @@ -24,10 +24,25 @@ dependencies: 
     | 
|
| 
       24 
24 
     | 
    
         
             
                - - ">="
         
     | 
| 
       25 
25 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
26 
     | 
    
         
             
                    version: '3.2'
         
     | 
| 
      
 27 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 28 
     | 
    
         
            +
              name: rake-compiler
         
     | 
| 
      
 29 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 30 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 32 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 33 
     | 
    
         
            +
                    version: '1'
         
     | 
| 
      
 34 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 35 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 36 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 37 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 38 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 39 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 40 
     | 
    
         
            +
                    version: '1'
         
     | 
| 
       27 
41 
     | 
    
         
             
            description: 
         
     | 
| 
       28 
42 
     | 
    
         
             
            email: huacnlee@gmail.com
         
     | 
| 
       29 
43 
     | 
    
         
             
            executables: []
         
     | 
| 
       30 
     | 
    
         
            -
            extensions: 
     | 
| 
      
 44 
     | 
    
         
            +
            extensions:
         
     | 
| 
      
 45 
     | 
    
         
            +
            - ext/rucaptcha/extconf.rb
         
     | 
| 
       31 
46 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       32 
47 
     | 
    
         
             
            files:
         
     | 
| 
       33 
48 
     | 
    
         
             
            - CHANGELOG.md
         
     | 
| 
         @@ -38,9 +53,11 @@ files: 
     | 
|
| 
       38 
53 
     | 
    
         
             
            - config/locales/rucaptcha.zh-CN.yml
         
     | 
| 
       39 
54 
     | 
    
         
             
            - config/locales/rucaptcha.zh-TW.yml
         
     | 
| 
       40 
55 
     | 
    
         
             
            - config/routes.rb
         
     | 
| 
      
 56 
     | 
    
         
            +
            - ext/rucaptcha/extconf.rb
         
     | 
| 
      
 57 
     | 
    
         
            +
            - ext/rucaptcha/font.h
         
     | 
| 
      
 58 
     | 
    
         
            +
            - ext/rucaptcha/rucaptcha.c
         
     | 
| 
       41 
59 
     | 
    
         
             
            - lib/rucaptcha.rb
         
     | 
| 
       42 
60 
     | 
    
         
             
            - lib/rucaptcha/cache.rb
         
     | 
| 
       43 
     | 
    
         
            -
            - lib/rucaptcha/captcha.rb
         
     | 
| 
       44 
61 
     | 
    
         
             
            - lib/rucaptcha/configuration.rb
         
     | 
| 
       45 
62 
     | 
    
         
             
            - lib/rucaptcha/controller_helpers.rb
         
     | 
| 
       46 
63 
     | 
    
         
             
            - lib/rucaptcha/engine.rb
         
     | 
| 
         @@ -61,9 +78,9 @@ required_ruby_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       61 
78 
     | 
    
         
             
                  version: 2.0.0
         
     | 
| 
       62 
79 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
       63 
80 
     | 
    
         
             
              requirements:
         
     | 
| 
       64 
     | 
    
         
            -
              - - " 
     | 
| 
      
 81 
     | 
    
         
            +
              - - ">"
         
     | 
| 
       65 
82 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       66 
     | 
    
         
            -
                  version:  
     | 
| 
      
 83 
     | 
    
         
            +
                  version: 1.3.1
         
     | 
| 
       67 
84 
     | 
    
         
             
            requirements: []
         
     | 
| 
       68 
85 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       69 
86 
     | 
    
         
             
            rubygems_version: 2.5.2
         
     | 
    
        data/lib/rucaptcha/captcha.rb
    DELETED
    
    | 
         @@ -1,125 +0,0 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            require 'open3'
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
            module RuCaptcha
         
     | 
| 
       4 
     | 
    
         
            -
              class Captcha
         
     | 
| 
       5 
     | 
    
         
            -
                class << self
         
     | 
| 
       6 
     | 
    
         
            -
                  # Genrate ranom RGB color
         
     | 
| 
       7 
     | 
    
         
            -
                  def random_color
         
     | 
| 
       8 
     | 
    
         
            -
                    if RuCaptcha.config.style == :colorful
         
     | 
| 
       9 
     | 
    
         
            -
                      color1 = rand(56) + 15
         
     | 
| 
       10 
     | 
    
         
            -
                      color2 = rand(10) + 140
         
     | 
| 
       11 
     | 
    
         
            -
                      color = [color1, color2, rand(15)]
         
     | 
| 
       12 
     | 
    
         
            -
                      color.shuffle!
         
     | 
| 
       13 
     | 
    
         
            -
                      color
         
     | 
| 
       14 
     | 
    
         
            -
                    else
         
     | 
| 
       15 
     | 
    
         
            -
                      color_seed = rand(40) + 10
         
     | 
| 
       16 
     | 
    
         
            -
                      [color_seed, color_seed, color_seed]
         
     | 
| 
       17 
     | 
    
         
            -
                    end
         
     | 
| 
       18 
     | 
    
         
            -
                  end
         
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                  # Genrate random Captcha code
         
     | 
| 
       21 
     | 
    
         
            -
                  def random_chars
         
     | 
| 
       22 
     | 
    
         
            -
                    chars = SecureRandom.hex(RuCaptcha.config.len / 2).downcase
         
     | 
| 
       23 
     | 
    
         
            -
                    chars.gsub!(/[0ol1]/i, (rand(8) + 2).to_s)
         
     | 
| 
       24 
     | 
    
         
            -
                    chars
         
     | 
| 
       25 
     | 
    
         
            -
                  end
         
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
                  # Create Captcha image by code
         
     | 
| 
       28 
     | 
    
         
            -
                  def create(code)
         
     | 
| 
       29 
     | 
    
         
            -
                    chars        = code.split('')
         
     | 
| 
       30 
     | 
    
         
            -
                    full_width   = RuCaptcha.config.font_size * chars.size
         
     | 
| 
       31 
     | 
    
         
            -
                    full_height  = RuCaptcha.config.font_size
         
     | 
| 
       32 
     | 
    
         
            -
                    size         = "#{full_width}x#{full_height}"
         
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
                    return convert_for_windows(size, code) if Gem.win_platform?
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
                    opts = command_line_opts(chars, full_width)
         
     | 
| 
       37 
     | 
    
         
            -
                    convert(size, opts)
         
     | 
| 
       38 
     | 
    
         
            -
                  end
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                  private
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                  def command_line_opts(chars, full_width)
         
     | 
| 
       43 
     | 
    
         
            -
                    font_size    = RuCaptcha.config.font_size
         
     | 
| 
       44 
     | 
    
         
            -
                    all_left     = 20
         
     | 
| 
       45 
     | 
    
         
            -
                    half_width   = full_width / 2
         
     | 
| 
       46 
     | 
    
         
            -
                    text_top     = 0
         
     | 
| 
       47 
     | 
    
         
            -
                    text_left    = 0 - (font_size * 0.28).to_i
         
     | 
| 
       48 
     | 
    
         
            -
                    text_width   = font_size + text_left
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
                    opts = { text: [], line: [] }
         
     | 
| 
       51 
     | 
    
         
            -
                    rgbs = uniq_rgbs_for_each_chars(chars)
         
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                    chars.each_with_index do |char, i|
         
     | 
| 
       54 
     | 
    
         
            -
                      rgb = RuCaptcha.config.style == :colorful ? rgbs[i] : rgbs[0]
         
     | 
| 
       55 
     | 
    
         
            -
                      text_color = "rgba(#{rgb.join(',')}, 1)"
         
     | 
| 
       56 
     | 
    
         
            -
                      line_color = "rgba(#{rgb.join(',')}, 0.6)"
         
     | 
| 
       57 
     | 
    
         
            -
                      opts[:text] << %(-fill '#{text_color}' -draw 'text #{(text_left + text_width) * i + all_left},#{text_top} "#{char}"')
         
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
                      left_y = rand_line_top(text_top, font_size)
         
     | 
| 
       60 
     | 
    
         
            -
                      right_x = half_width + (half_width * 0.3).to_i
         
     | 
| 
       61 
     | 
    
         
            -
                      right_y = rand_line_top(text_top, font_size)
         
     | 
| 
       62 
     | 
    
         
            -
                      opts[:line] << %(-draw 'stroke #{line_color} line #{rand(10)},#{left_y} #{right_x},#{right_y}')
         
     | 
| 
       63 
     | 
    
         
            -
                    end
         
     | 
| 
       64 
     | 
    
         
            -
                    opts
         
     | 
| 
       65 
     | 
    
         
            -
                  end
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
                  def convert(size, opts)
         
     | 
| 
       68 
     | 
    
         
            -
                    stroke_width = (RuCaptcha.config.font_size * 0.05).to_i + 1
         
     | 
| 
       69 
     | 
    
         
            -
                    command = <<-CODE
         
     | 
| 
       70 
     | 
    
         
            -
                      convert -size #{size} \
         
     | 
| 
       71 
     | 
    
         
            -
                      -strokewidth #{stroke_width} \
         
     | 
| 
       72 
     | 
    
         
            -
                      #{opts[:line].join(' ')} \
         
     | 
| 
       73 
     | 
    
         
            -
                      -pointsize #{RuCaptcha.config.font_size} -weight 500 \
         
     | 
| 
       74 
     | 
    
         
            -
                      #{opts[:text].join(' ')}  \
         
     | 
| 
       75 
     | 
    
         
            -
                      -wave #{rand(2) + 3}x#{rand(2) + 1} \
         
     | 
| 
       76 
     | 
    
         
            -
                      -rotate #{rand(10) - 5} \
         
     | 
| 
       77 
     | 
    
         
            -
                      -gravity NorthWest -sketch 1x10+#{rand(2)} \
         
     | 
| 
       78 
     | 
    
         
            -
                      -fill none \
         
     | 
| 
       79 
     | 
    
         
            -
                      -implode #{RuCaptcha.config.implode} -trim label:- png:-
         
     | 
| 
       80 
     | 
    
         
            -
                    CODE
         
     | 
| 
       81 
     | 
    
         
            -
                    command.strip!
         
     | 
| 
       82 
     | 
    
         
            -
                    out, err, _st = Open3.capture3(command)
         
     | 
| 
       83 
     | 
    
         
            -
                    warn "  RuCaptcha #{err.strip}" if err.present?
         
     | 
| 
       84 
     | 
    
         
            -
                    out
         
     | 
| 
       85 
     | 
    
         
            -
                  end
         
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
                  # Generate a simple captcha image for Windows Platform
         
     | 
| 
       88 
     | 
    
         
            -
                  def convert_for_windows(size, code)
         
     | 
| 
       89 
     | 
    
         
            -
                    png_file_path = Rails.root.join('tmp', 'cache', "#{code}.png")
         
     | 
| 
       90 
     | 
    
         
            -
                    command = "convert -size #{size} xc:White -gravity Center -weight 12 -pointsize 20 -annotate 0 \"#{code}\" -trim #{png_file_path}"
         
     | 
| 
       91 
     | 
    
         
            -
                    _out, err, _st = Open3.capture3(command)
         
     | 
| 
       92 
     | 
    
         
            -
                    warn "  RuCaptcha #{err.strip}" if err.present?
         
     | 
| 
       93 
     | 
    
         
            -
                    png_file_path
         
     | 
| 
       94 
     | 
    
         
            -
                  end
         
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
                  # Geneate a uniq rgba colors for each chars
         
     | 
| 
       97 
     | 
    
         
            -
                  def uniq_rgbs_for_each_chars(chars)
         
     | 
| 
       98 
     | 
    
         
            -
                    rgbs = []
         
     | 
| 
       99 
     | 
    
         
            -
                    chars.count.times do |i|
         
     | 
| 
       100 
     | 
    
         
            -
                      color = random_color
         
     | 
| 
       101 
     | 
    
         
            -
                      if i > 0
         
     | 
| 
       102 
     | 
    
         
            -
                        preview_color = rgbs[i - 1]
         
     | 
| 
       103 
     | 
    
         
            -
                        # Avoid color same as preview color
         
     | 
| 
       104 
     | 
    
         
            -
                        if color.index(color.min) == preview_color.index(preview_color.min) &&
         
     | 
| 
       105 
     | 
    
         
            -
                           color.index(color.max) == preview_color.index(preview_color.max)
         
     | 
| 
       106 
     | 
    
         
            -
                          # adjust RGB order
         
     | 
| 
       107 
     | 
    
         
            -
                          color = [color[1], color[2], color[0]]
         
     | 
| 
       108 
     | 
    
         
            -
                        end
         
     | 
| 
       109 
     | 
    
         
            -
                      end
         
     | 
| 
       110 
     | 
    
         
            -
                      rgbs << color
         
     | 
| 
       111 
     | 
    
         
            -
                    end
         
     | 
| 
       112 
     | 
    
         
            -
                    rgbs
         
     | 
| 
       113 
     | 
    
         
            -
                  end
         
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
                  def rand_line_top(text_top, font_size)
         
     | 
| 
       116 
     | 
    
         
            -
                    text_top + rand(font_size * 0.7).to_i
         
     | 
| 
       117 
     | 
    
         
            -
                  end
         
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
                  def warn(msg)
         
     | 
| 
       120 
     | 
    
         
            -
                    msg = "  RuCaptcha #{msg}"
         
     | 
| 
       121 
     | 
    
         
            -
                    Rails.logger.error(msg)
         
     | 
| 
       122 
     | 
    
         
            -
                  end
         
     | 
| 
       123 
     | 
    
         
            -
                end
         
     | 
| 
       124 
     | 
    
         
            -
              end
         
     | 
| 
       125 
     | 
    
         
            -
            end
         
     |