Commit b41f36c7 authored by 神楽坂玲奈's avatar 神楽坂玲奈

临时提交

parent e2481da7
......@@ -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")
@actions = ["注册"]
respond_to do |format|
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 /注册成功/
when "ok"
open("http://140.113.242.66:7922/?pass=zh99998&operation=saveuser"){} rescue nil
true
when "用户已存在"
@user.errors.add :name, "用户已存在"
false
else
nil
reply
end
end
rescue Exception => exception
reply = ([exception] + exception.backtrace).join("\n")
nil
([exception] + exception.backtrace).join("\n")
end
@user.errors.add :name, "注册失败,可能是服务器故障,请与管理员联系 Email/GT/QQ: zh99998@gmail.com 详情: #{reply}" if success.nil?
respond_to do |format|
if success
if@user.save
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
......
......@@ -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
<%= 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>
......@@ -10,32 +10,14 @@
</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>
<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>
<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
......@@ -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>
......
......@@ -220,6 +220,12 @@ zh-CN:
models:
user: 用户
attributes:
user:
name: 用户名
nickname: 昵称
id: id
email: 邮箱
created_at: 注册时间
pm:
to_user: "收件人"
content: "正文"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment