Как запустить????

Discussion in 'PHP' started by {BuT@Min}, 2 Feb 2010.

  1. {BuT@Min}

    {BuT@Min} Elder - Старейшина

    Joined:
    23 Nov 2006
    Messages:
    43
    Likes Received:
    5
    Reputations:
    -1
    Вобщем дали мне код а как запустить незнаю,про руби узнал тока сегодня помогите плз.

    Code:
    #!/usr/bin/ruby
    require 'net/http'
    #require 'net/https'
    
    if ARGV.size<4 or ARGV.size>6
      puts "Not enought arguments\n<logfile> <maillistfile> <outfile> <count> [<threads count> <begin no>]"
      puts "default threads count is equal 50"
      exit
    end  
    
    $logfile=ARGV[0]
    $maillistfile=ARGV[1]
    $outputfile=ARGV[2]
    $count=ARGV[3].to_i
    if ARGV.size>=5 then $max_th_count = ARGV[4].to_i else $max_th_count=50 end
    if ARGV.size==6 then $beg_no=ARGV[5].to_i else $beg_no=0 end
    begin
      $logf=File.open($logfile,"a")
    rescue
      puts "Can't create logfile #{$logfile}"
      exit
    end
      
    def exist_mail(login)
    
      begin
        http = Net::HTTP.new('id.rambler.ru', 80)
      rescue => e
        $logf.puts "#{Time.now}: Socket error: #{e}"
      end
    
      path = '/script/newuser.cgi'
    
      # GET request -> so the host can set his cookies
      begin
        resp, data = http.get(path, nil)
      rescue => e
        $logf.puts "#{Time.now}: Can't get page: #{e}"
      end
      cookie = resp.response['set-cookie']
    
      # POST request -> logging in
      data = "back=&step=one&login=#{login}&firstname=fuck&lastname=fuck"
      headers = {
        'Cookie' => cookie,
        'Referer' => 'http://id.rambler.ru/script/newuser.cgi',
        'Content-Type' => 'application/x-www-form-urlencoded'
      }
      begin
        resp, data = http.post(path, data, headers)
      rescue => e
        $logf.puts "#{Time.now}: Can't send form: #{e}"
      end
    
      return (!(data.include?("captcha")) and data.include?("<input type=\"text\" name=\"firstname\""))
    end#def
    
    begin
      $mlf=File.open($maillistfile,"r")
    rescue => e
      puts "#{Time.now}: Can't read #{$maillistfile}: #{e}"
      $logf.puts "#{Time.now}: Can't read #{$maillistfile}: #{e}"
      exit
    end
    
    $th_cnt=0
    kk=0
    while kk<$beg_no do 
    	$mlf.gets 
    	kk+=1
    end
    
    
    $num=0
    while $num<$count do
      	while $th_cnt>=$max_th_count do sleep(3) end
      	$th_cnt+=1
    	sleep(0.1)
    	th=Thread.new do 
    		     str=$mlf.gets
    		     $num+=1
    		     if str!=nil
    			if exist_mail(str.chop!) 
    		              puts "#{$num}) #{Time.now}  #{str}@rambler.ru ========== EXIST ==========="
            		      File.open($outputfile,"a"){|sfile| sfile.puts "#{str}@rambler.ru"}  
            		else
    			      puts "#{$num}) #{Time.now}  #{str}@rambler.ru FAIL"
    			end
    		     end
    		     $th_cnt-=1
    	  end
      
    end
    $mlf.close
    $logf.close
     
  2. superboy4

    superboy4 Banned

    Joined:
    17 Jul 2007
    Messages:
    151
    Likes Received:
    19
    Reputations:
    -8
    в консоли напиши ruby filename.rb
     
  3. lukmus

    lukmus Elder - Старейшина

    Joined:
    18 Nov 2009
    Messages:
    401
    Likes Received:
    118
    Reputations:
    23
    посмотри исходную тему я все там расписал