Guest User

Untitled

a guest
May 23rd, 2018
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. ## Controller for Blackbook fix [ruby]
  2.  
  3. if (request.post?) or (!params["contact_type"].nil?)
  4. #get contacts
  5. @contacts = []
  6. @type = params["contact_type"]
  7.  
  8. if ["gmail", "yahoo", "hotmail", "aol"].include?(params["contact_type"])
  9. begin
  10. username = "#{params["username"]}@#{params["contact_type"]}.com"
  11. pass = "#{params["password"]}"
  12.  
  13. @bl = Blackbook.get(:username => username, :password => pass)
  14. @bl.each do |item|
  15. unless item.blank?
  16.  
  17. if params["contact_type"].eql?("hotmail")
  18. if item[:email].blank? and !item[:name][/[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,4}/].nil?
  19. item[:email] = item[:name]
  20. item[:name] = ""
  21. end
  22. end
  23.  
  24. @clean_email = item[:email][/[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,4}/]
  25. @contacts << [item[:name], @clean_email] unless @clean_email.blank?
  26.  
  27. end
  28. end
  29.  
  30. @contacts = process_contacts unless @contacts.blank?
  31. flash[:warning] = nil unless flash[:warning].nil?
  32. #do something
  33. rescue Exception => ex
  34. flash[:warning] = ex
  35. #do something
  36. end
  37. end
Add Comment
Please, Sign In to add comment