This repository has been archived by the owner on Apr 18, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jakub Kuźma
committed
Feb 14, 2009
1 parent
8167f2e
commit 07dcbba
Showing
181 changed files
with
10,064 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
%h1 Viewing gateway | ||
|
||
= render :partial => @gateway |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
%h1 Sign up | ||
|
||
- form_for @user, :url => user_path do |f| | ||
= render :partial => 'form', :locals => { :f => f } | ||
= submit_tag 'Sign up' | ||
or | ||
= link_to "Back", new_user_session_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,51 @@ | ||
require "net/http" | ||
require "net/https" | ||
|
||
# MINI HOWTO | ||
# Gateways.orange_multi_box("username", "password") do |orange_multi_box| | ||
# amount = orange_multi_box.amount | ||
# delivered = orange_multi_box.deliver("500555555", "test") | ||
# end | ||
require "hpricot" | ||
|
||
module Gateways | ||
class OrangeMultiBox | ||
HOST = "orange.pl" | ||
PORT = 443 | ||
LOGIN_LOCATION = "/portal/map/map/homeog?_DARGS=/gear/static/home/login.jsp.loginFormId" | ||
MESSAGE_LOCATION = "/portal/map/map/message_box?_DARGS=/gear/mapmessagebox/smsform.jsp" | ||
MESSAGEBOX_LOCATION = "/portal/map/map/message_box" | ||
LOGIN_DATA = "_dyncharset=UTF-8&%%2Famg%%2Fptk%%2Fmap%%2Fcore%%2Fformhandlers%%2FAdvancedProfileFormHandler.loginErrorURL=%%2Fportal%%2Fmap%%2Fmap%%2Fsignin&_D%%3A%%2Famg%%2Fptk%%2Fmap%%2Fcore%%2Fformhandlers%%2FAdvancedProfileFormHandler.loginErrorURL=+&%%2Famg%%2Fptk%%2Fmap%%2Fcore%%2Fformhandlers%%2FAdvancedProfileFormHandler.loginSuccessURL=http%%3A%%2F%%2Fwww.orange.pl%%2Fportal%%2Fmap%%2Fmap%%2Fyour_account&_D%%3A%%2Famg%%2Fptk%%2Fmap%%2Fcore%%2Fformhandlers%%2FAdvancedProfileFormHandler.loginSuccessURL=+&%%2Famg%%2Fptk%%2Fmap%%2Fcore%%2Fformhandlers%%2FAdvancedProfileFormHandler.value.login=%s&_D%%3A%%2Famg%%2Fptk%%2Fmap%%2Fcore%%2Fformhandlers%%2FAdvancedProfileFormHandler.value.login=+&%%2Famg%%2Fptk%%2Fmap%%2Fcore%%2Fformhandlers%%2FAdvancedProfileFormHandler.value.password=%s&_D%%3A%%2Famg%%2Fptk%%2Fmap%%2Fcore%%2Fformhandlers%%2FAdvancedProfileFormHandler.value.password=+&%%2Famg%%2Fptk%%2Fmap%%2Fcore%%2Fformhandlers%%2FAdvancedProfileFormHandler.login.x=99&%%2Famg%%2Fptk%%2Fmap%%2Fcore%%2Fformhandlers%%2FAdvancedProfileFormHandler.login.y=7&_D%%3A%%2Famg%%2Fptk%%2Fmap%%2Fcore%%2Fformhandlers%%2FAdvancedProfileFormHandler.login=+&_DARGS=%%2Fgear%%2Fstatic%%2Fhome%%2Flogin.jsp.loginFormId" | ||
MESSAGE_DATA = "_dyncharset=UTF-8&%%2Famg%%2Fptk%%2Fmap%%2Fmessagebox%%2Fformhandlers%%2FMessageFormHandler.type=sms&_D%%3A%%2Famg%%2Fptk%%2Fmap%%2Fmessagebox%%2Fformhandlers%%2FMessageFormHandler.type=+&enabled=false&%%2Famg%%2Fptk%%2Fmap%%2Fmessagebox%%2Fformhandlers%%2FMessageFormHandler.errorURL=%%2Fportal%%2Fmap%%2Fmap%%2Fmessage_box%%3Fmbox_view%%3Dnewsms&_D%%3A%%2Famg%%2Fptk%%2Fmap%%2Fmessagebox%%2Fformhandlers%%2FMessageFormHandler.errorURL=+&%%2Famg%%2Fptk%%2Fmap%%2Fmessagebox%%2Fformhandlers%%2FMessageFormHandler.successURL=%%2Fportal%%2Fmap%%2Fmap%%2Fmessage_box%%3Fmbox_view%%3Dmessageslist&_D%%3A%%2Famg%%2Fptk%%2Fmap%%2Fmessagebox%%2Fformhandlers%%2FMessageFormHandler.successURL=+&smscounter=1&counter=640&%%2Famg%%2Fptk%%2Fmap%%2Fmessagebox%%2Fformhandlers%%2FMessageFormHandler.to=%s&_D%%3A%%2Famg%%2Fptk%%2Fmap%%2Fmessagebox%%2Fformhandlers%%2FMessageFormHandler.to=+&_D%%3A%%2Famg%%2Fptk%%2Fmap%%2Fmessagebox%%2Fformhandlers%%2FMessageFormHandler.body=+&%%2Famg%%2Fptk%%2Fmap%%2Fmessagebox%%2Fformhandlers%%2FMessageFormHandler.body=%s&%%2Famg%%2Fptk%%2Fmap%%2Fmessagebox%%2Fformhandlers%%2FMessageFormHandler.create.x=25&%%2Famg%%2Fptk%%2Fmap%%2Fmessagebox%%2Fformhandlers%%2FMessageFormHandler.create.y=5&%%2Famg%%2Fptk%%2Fmap%%2Fmessagebox%%2Fformhandlers%%2FMessageFormHandler.create=Wy%%C5%%9Blij&_D%%3A%%2Famg%%2Fptk%%2Fmap%%2Fmessagebox%%2Fformhandlers%%2FMessageFormHandler.create=+&_DARGS=%%2Fgear%%2Fmapmessagebox%%2Fsmsform.jsp" | ||
def initialize(username, password) | ||
login(username, password) | ||
yield self if logged_in? and block_given? | ||
rescue SocketError, Timeout::Error | ||
end | ||
|
||
def self.login(username, password, &block) | ||
http = Net::HTTP.new(HOST, PORT) | ||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | ||
http.use_ssl = true if PORT == 443 | ||
http.read_timeout = 60 | ||
http.open_timeout = 60 | ||
http_header = { "User-Agent" => "Mozilla/5.0", "Content-Type" => "application/x-www-form-urlencoded" } | ||
response = http.post(LOGIN_LOCATION, LOGIN_DATA % [CGI.escape(username), CGI.escape(password)], http_header) | ||
cookies = [] | ||
[/VisitorId=[^;]+/, /mapProfileCookie=[^;]+/, /JSESSIONID=[^;]+/, /SID=[^;]+/, /ATG_SESSION_ID=[^;]+/, /mapSecurityCookie=[^;]+/].each do |regexp| | ||
cookies << $& if response["Set-cookie"] =~ regexp | ||
end | ||
if cookies.size == 6 | ||
http_header = { "User-Agent" => "Mozilla/5.0", "Cookie" => cookies.join("; ") } | ||
yield OrangeMultiBox.new(http, http_header) if block_given? | ||
true | ||
end | ||
rescue SocketError, Timeout::Error | ||
false | ||
def logged_in? | ||
@agent.cookies.detect { |cookie| cookie.name == "mapProfileCookie" } | ||
end | ||
|
||
def amount | ||
response = @http.get(MESSAGEBOX_LOCATION, @http_header) | ||
$1.to_i if response.body =~ /<span class="value">(\d+)<\/span>/ | ||
@agent.get("http://www.orange.pl/portal/map/map/message_box") do |page| | ||
values = Hpricot(page.body) / "span.value" | ||
return values.inner_html.to_i | ||
end | ||
end | ||
|
||
def deliver(to, content) | ||
initial_amount = amount | ||
@http.post(MESSAGE_LOCATION, MESSAGE_DATA % [CGI.escape(to), CGI.escape(content)], @http_header) | ||
@agent.get("http://www.orange.pl/portal/map/map/message_box?mbox_view=newsms") do |page| | ||
sms_form = page.form_with(:name => "sendSMS") do |form| | ||
form["/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.to"] = to | ||
form["/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.body"] = content | ||
form["/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.x"] = "0" | ||
form["/amg/ptk/map/messagebox/formhandlers/MessageFormHandler.create.y"] = "0" | ||
end | ||
sms_form.submit | ||
end | ||
initial_amount > amount | ||
end | ||
|
||
protected | ||
|
||
def initialize(http, http_header) | ||
@http = http | ||
@http_header = http_header | ||
def login(username, password) | ||
@agent = WWW::Mechanize.new | ||
@agent.get("http://www.orange.pl/portal/map/map/signin") do |page| | ||
login_form = page.form_with(:name => "loginForm") do |form| | ||
form["/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.login"] = username | ||
form["/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.value.password"] = password | ||
form["/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.x"] = "0" | ||
form["/amg/ptk/map/core/formhandlers/AdvancedProfileFormHandler.login.y"] = "0" | ||
end | ||
login_form.submit | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
require "net/http" | ||
require "net/https" | ||
|
||
module Gateways | ||
class VoipDiscount | ||
HOST = "myaccount.voipdiscount.com" | ||
PORT = 443 | ||
LOGIN_LOCATION = "/clx/index.php" | ||
LOGIN_DATA = "part=menu&username=%s&password=%s" | ||
MESSAGE_LOCATION = "/clx/websms2.php" | ||
MESSAGE_DATA = "action=send&panel=&message=%s&callerid=%s&bnrphonenumber=%s&sendscheduled=no" #&day=20&month=08&hour=11&minute=12&gmt=1" | ||
AMOUNT_LOCATION = "/clx/index.php?part=menu" | ||
LOGOUT_LOCATION = "/clx/index.php?part=logoff" | ||
|
||
def self.login(login, password, &block) | ||
http = Net::HTTP.new(HOST, PORT) | ||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | ||
http.use_ssl = true if PORT == 443 | ||
http.read_timeout = 60 | ||
http.open_timeout = 60 | ||
http_header = { "User-Agent" => "Mozilla/5.0" } | ||
response = http.post(LOGIN_LOCATION, LOGIN_DATA % [CGI.escape(login), CGI.escape(password)], http_header.merge("Content-Type" => "application/x-www-form-urlencoded")) | ||
if response.body =~ /error/i | ||
return false # cannot log in with given login and password | ||
else | ||
return false unless response["Set-cookie"] # no Set-cookie | ||
return false unless http_header["Cookie"] = response["Set-cookie"].scan(/PHPSESSID=[^;]+/).last # no PHPSESSID in Set-cookie | ||
yield VoipDiscount.new(http, http_header) if block_given? | ||
http.get(LOGOUT_LOCATION, http_header) | ||
true | ||
end | ||
rescue SocketError, Timeout::Error => e | ||
false | ||
end | ||
|
||
def deliver(from, to, content) | ||
10.times do | ||
response = @http.post(MESSAGE_LOCATION, MESSAGE_DATA % [CGI.escape(self.class.translit(content)), CGI.escape(from), CGI.escape(to)], @http_header.merge("Content-Type" => "application/x-www-form-urlencoded")) | ||
return true if response.body =~ /sent/i | ||
break unless response.body =~ /session lost/i | ||
end | ||
false | ||
end | ||
|
||
def amount | ||
10.times do | ||
response = @http.get(AMOUNT_LOCATION, @http_header) | ||
return $1.to_f if response.body =~ /<span id="balanceid"><b>€ (\d+\.\d\d)<\/b><\/span>/ | ||
break unless response.body =~ /session lost/i | ||
end | ||
nil | ||
end | ||
|
||
protected | ||
|
||
def initialize(http, http_header) | ||
@http = http | ||
@http_header = http_header | ||
end | ||
|
||
def self.translit(string) | ||
Iconv.iconv('ASCII//TRANSLIT', 'UTF-8', string).first # doesn't work at all | ||
# %x{echo -n #{string} | iconv -t ASCII//TRANSLIT} # depends on iconv in system !UNSAFE! | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
$().ready(function() { | ||
$("#message_recipients").autocomplete("/recipients.txt", {selectFirst: true, multiple: true, multipleSeparator: ", "}); | ||
$("#contact_number").autocomplete("/telephone_numbers.txt", {selectFirst: true}); | ||
$(".pagination a").click(function() { | ||
$("#messages").load($(this).attr("href")); | ||
return false; | ||
}); | ||
// $(".pagination a").click(function() { | ||
// $("#messages").load($(this).attr("href")); | ||
// return false; | ||
// }); | ||
}); |
Oops, something went wrong.