Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
Ygopro Arena Web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Ygopro Arena Web
Commits
b41f36c7
Commit
b41f36c7
authored
Apr 09, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
临时提交
parent
e2481da7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
77 deletions
+48
-77
app/controllers/users_controller.rb
app/controllers/users_controller.rb
+17
-25
app/views/layouts/ygo.html.erb
app/views/layouts/ygo.html.erb
+1
-1
app/views/users/_form.html.erb
app/views/users/_form.html.erb
+14
-32
app/views/users/show.html.erb
app/views/users/show.html.erb
+10
-19
config/locales/zh-CN.yml
config/locales/zh-CN.yml
+6
-0
No files found.
app/controllers/users_controller.rb
View file @
b41f36c7
...
...
@@ -62,36 +62,28 @@ class UsersController < ApplicationController
# POST /users.xml
def
create
@user
=
User
.
new
(
params
[
:user
])
#验证ygocore服务器是否可注册,true为成功,false为重名,nil为异常
reply
=
""
success
=
begin
open
(
"http://140.113.242.66:7922/?userregist=NEW&username=
#{
CGI
.
escape
@user
.
name
}
&password=
#{
CGI
.
escape
@user
.
password
}
"
)
do
|
file
|
file
.
set_encoding
(
"GBK"
)
case
reply
=
file
.
read
.
encode
(
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
)
when
/注册成功/
open
(
"http://140.113.242.66:7922/?pass=zh99998&operation=saveuser"
){}
rescue
nil
true
when
"用户已存在"
@user
.
errors
.
add
:name
,
"用户已存在"
false
else
nil
end
end
rescue
Exception
=>
exception
reply
=
([
exception
]
+
exception
.
backtrace
).
join
(
"
\n
"
)
nil
end
@user
.
errors
.
add
:name
,
"注册失败,可能是服务器故障,请与管理员联系 Email/GT/QQ: zh99998@gmail.com 详情:
#{
reply
}
"
if
success
.
nil?
@actions
=
[
"注册"
]
respond_to
do
|
format
|
if
success
if
@user
.
save
if
@user
.
save
reply
=
begin
open
(
"http://140.113.242.66:7922/?pass=zh99998&operation=forceuserpass&username=
#{
CGI
.
escape
@user
.
name
}
&password=
#{
CGI
.
escape
@user
.
password
}
"
,
'r:GBK'
)
do
|
file
|
case
reply
=
file
.
read
.
encode
(
"UTF-8"
,
:invalid
=>
:replace
,
:undef
=>
:replace
)
when
"ok"
open
(
"http://140.113.242.66:7922/?pass=zh99998&operation=saveuser"
){}
rescue
nil
true
else
reply
end
end
rescue
Exception
=>
exception
([
exception
]
+
exception
.
backtrace
).
join
(
"
\n
"
)
end
if
reply
==
true
session
[
:user_id
]
=
@user
.
id
format
.
html
{
redirect_to
(
@user
,
:notice
=>
'注册成功'
)
}
format
.
xml
{
render
:xml
=>
@user
,
:status
=>
:created
,
:location
=>
@user
}
else
@user
.
errors
.
add
:name
,
"注册失败,可能是服务器故障,请与管理员联系 Email/GT/QQ: zh99998@gmail.com 详情:
#{
reply
}
"
format
.
html
{
render
:action
=>
"new"
}
format
.
xml
{
render
:xml
=>
@user
.
errors
,
:status
=>
:unprocessable_entity
}
end
...
...
app/views/layouts/ygo.html.erb
View file @
b41f36c7
...
...
@@ -24,7 +24,7 @@
</div>
</div>
<footer
id=
"footer"
>
YGO DULE BATTLENET
YGO DULE BATTLENET
由
<a
href=
"http://fh-sky.5d6d.com/"
>
凤凰(FH)战队
</a>
提供技术支持
</footer>
</body>
</html>
\ No newline at end of file
app/views/users/_form.html.erb
View file @
b41f36c7
<%=
form_for
(
@user
)
do
|
f
|
%>
<%=
form_for
@user
,
:url
=>
user_path
,
:html
=>
{
:multipart
=>
true
}
do
|
f
|
%>
<%
if
@user
.
errors
.
any?
%>
<div
id=
"error_explanation"
>
<h2>
<%=
pluralize
(
@user
.
errors
.
count
,
"error"
)
%>
prohibited this user from being saved:
</h2>
<ul>
<%
@user
.
errors
.
full_messages
.
each
do
|
msg
|
%>
<li>
<%=
msg
%>
</li>
<%
end
%>
<%
@user
.
errors
.
full_messages
.
each
do
|
msg
|
%>
<li>
<%=
msg
%>
</li>
<%
end
%>
</ul>
</div>
<%
end
%>
<div
class=
"field"
>
<%=
f
.
label
:name
%>
<br
/>
<%=
f
.
text_field
:name
%>
</div>
<div
class=
"field"
>
<%=
f
.
label
:password
%>
<br
/>
<%=
f
.
text_field
:password
%>
</div>
<div
class=
"field"
>
<%=
f
.
label
:email
%>
<br
/>
<%=
f
.
text_field
:email
%>
</div>
<div
class=
"field"
>
<%=
f
.
label
:credit
%>
<br
/>
<%=
f
.
text_field
:credit
%>
</div>
<div
class=
"field"
>
<%=
f
.
label
:usergroup
%>
<br
/>
<%=
f
.
text_field
:usergroup
%>
</div>
<div
class=
"field"
>
<%=
f
.
label
:admingroup
%>
<br
/>
<%=
f
.
text_field
:admingroup
%>
</div>
<div
class=
"actions"
>
<%=
f
.
submit
%>
<div
id=
"avatar"
>
<div>
<%=
image_tag
@user
.
avatar
.
url
(
:middle
)
%>
</div>
<div>
<%=
f
.
file_field
:avatar
,
style
:"width:120px"
,
onchange:
"submit(); this.disabled=true;"
%>
</div>
</div>
<%
end
%>
<p>
<%=
f
.
label
:name
%>
:
<%=
@user
.
name
%>
</p>
<p>
<%=
f
.
label
:nickname
%>
:
<%=
f
.
text_field
:nickname
%><%=
f
.
submit
%>
</p>
<p>
<%=
f
.
label
:id
%>
:
<%=
@user
.
id
%>
</p>
<p>
<%=
f
.
label
:email
%>
:
<%=
f
.
text_field
:email
%><%=
f
.
submit
%>
</p>
<p>
<%=
f
.
label
:created_at
%>
:
<%=
l
@user
.
created_at
,
:format
=>
:long
%>
</p>
<p>
决斗统计:胜
<%=
@user
.
wins
.
count
%>
:负
<%=
@user
.
losts
.
count
%>
总场次:
<%=
@user
.
duels
.
count
%>
</p>
<%
end
%>
\ No newline at end of file
app/views/users/show.html.erb
View file @
b41f36c7
...
...
@@ -9,6 +9,8 @@
#user
p
{
text-align
:
left
}
#user
#avatar
{
float
:
right
}
#user_nickname
{
width
:
150px
}
#user_email
{
width
:
150px
}
.card
{
float
:
left
;
padding-left
:
10px
;
padding-bottom
:
9px
;}
.card
img
{
width
:
40px
;
height
:
50px
;
border
:
0px
;}
.user
{
width
:
330px
;
font-size
:
20px
;
color
:
#ffcc66
;
float
:
left
;
cursor
:
pointer
;
line-height
:
40px
;
padding-left
:
12px
;
font-weight
:
bold
;}
...
...
@@ -17,28 +19,17 @@
</style>
<div
id=
"user"
>
<%=
form_for
@user
,
:url
=>
user_path
,
:html
=>
{
:multipart
=>
true
}
do
|
f
|
%>
<%
if
@user
.
errors
.
any?
%>
<div
id=
"error_explanation"
>
<h2>
<%=
pluralize
(
@user
.
errors
.
count
,
"error"
)
%>
prohibited this user from being saved:
</h2>
<ul>
<%
@user
.
errors
.
full_messages
.
each
do
|
msg
|
%>
<li>
<%=
msg
%>
</li>
<%
end
%>
</ul>
</div>
<%
end
%>
<%
if
@user
==
@current_user
%>
<%=
render
'form'
%>
<%
else
%>
<div
id=
"avatar"
>
<div>
<%=
image_tag
@user
.
avatar
.
url
(
:middle
)
%>
</div>
<%
if
@user
==
@current_user
%>
<div>
<%=
f
.
file_field
:avatar
,
style
:"width:120px"
,
onchange:
"submit(); this.disabled=true;"
%>
</div>
<%
end
%>
</div>
<p>
用户名:
<%=
@user
.
name
%>
</p>
<p>
id:
<%=
@user
.
id
%>
</p>
<p>
邮箱:
<%=
@user
.
email
%>
</p>
<p>
注册时间:
<%=
l
@user
.
created_at
,
:format
=>
:long
%>
</p>
<p>
<%=
User
.
human_attribute_name
:name
%>
:
<%=
@user
.
name
%>
</p>
<%
unless
@user
.
nickname
.
blank?
%>
<p>
<%=
User
.
human_attribute_name
:nickname
%>
:
<%=
@user
.
nickname
%>
</p>
<%
end
%>
<p>
<%=
User
.
human_attribute_name
:id
%>
:
<%=
@user
.
id
%>
</p>
<p>
<%=
User
.
human_attribute_name
:email
%>
:
<%=
@user
.
email
%>
</p>
<p>
<%=
User
.
human_attribute_name
:created_at
%>
:
<%=
l
@user
.
created_at
,
:format
=>
:long
%>
</p>
<p>
决斗统计:胜
<%=
@user
.
wins
.
count
%>
:负
<%=
@user
.
losts
.
count
%>
总场次:
<%=
@user
.
duels
.
count
%>
</p>
<%
end
%>
</div>
...
...
config/locales/zh-CN.yml
View file @
b41f36c7
...
...
@@ -220,6 +220,12 @@ zh-CN:
models
:
user
:
用户
attributes
:
user
:
name
:
用户名
nickname
:
昵称
id
:
id
email
:
邮箱
created_at
:
注册时间
pm
:
to_user
:
"
收件人"
content
:
"
正文"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment