Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Controller for Blackbook fix [ruby]
- if (request.post?) or (!params["contact_type"].nil?)
- #get contacts
- @contacts = []
- @type = params["contact_type"]
- if ["gmail", "yahoo", "hotmail", "aol"].include?(params["contact_type"])
- begin
- username = "#{params["username"]}@#{params["contact_type"]}.com"
- pass = "#{params["password"]}"
- @bl = Blackbook.get(:username => username, :password => pass)
- @bl.each do |item|
- unless item.blank?
- if params["contact_type"].eql?("hotmail")
- if item[:email].blank? and !item[:name][/[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,4}/].nil?
- item[:email] = item[:name]
- item[:name] = ""
- end
- end
- @clean_email = item[:email][/[a-zA-Z0-9._%+-]+@(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,4}/]
- @contacts << [item[:name], @clean_email] unless @clean_email.blank?
- end
- end
- @contacts = process_contacts unless @contacts.blank?
- flash[:warning] = nil unless flash[:warning].nil?
- #do something
- rescue Exception => ex
- flash[:warning] = ex
- #do something
- end
- end
Add Comment
Please, Sign In to add comment