ucenter 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ucenter/interface/app.rb +5 -2
- data/lib/ucenter/interface/base.rb +8 -7
- data/lib/ucenter/interface/user.rb +17 -1
- data/lib/ucenter/version.rb +1 -1
- data/ucenter.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b5edfc93a65098a7c44d33b99473a523d2188f33
|
4
|
+
data.tar.gz: b44bf15c3d41881d85fa24c54176fc2536ad41ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c7b93cdad2cec9c19ec572d7eefa05e95553b82907714cfd5a5031019a52f58d6d3fc713f0d484a35c414989a6c3968ce47029e74992a9b828ac9d06c5cb22b
|
7
|
+
data.tar.gz: 865d3f7b7740bc1b30172f99d940e90fcd87c0a995254b0f9754807259023d661ecd71eeb6e963c27869bd356d218b7b49b0ef35e144f223f22323ddd37a2376
|
@@ -6,9 +6,12 @@ module Ucenter
|
|
6
6
|
where = db_client.escape(where)
|
7
7
|
data = db_client.query("SELECT #{col} FROM #{Ucenter::Config.uc_dbtablepre}applications #{where!="" ? " WHERE #{where} " : ""}").to_a
|
8
8
|
data.each_with_index do |item,index|
|
9
|
-
item['extra']
|
10
|
-
|
9
|
+
if item['extra'] and item['extra'].strip!=""
|
10
|
+
item['extra'] = Ucenter::Tools::PHP.unserialize(item['extra'])
|
11
|
+
data[index] = item
|
12
|
+
end
|
11
13
|
end
|
14
|
+
data
|
12
15
|
end
|
13
16
|
end
|
14
17
|
end
|
@@ -4,6 +4,13 @@ module Ucenter
|
|
4
4
|
class Base
|
5
5
|
def initialize(client)
|
6
6
|
@client = client
|
7
|
+
config = Hash.new
|
8
|
+
config[:host] = Ucenter::Config.uc_dbhost unless Ucenter::Config.uc_dbhost.nil?
|
9
|
+
config[:username] = Ucenter::Config.uc_dbuser unless Ucenter::Config.uc_dbuser.nil?
|
10
|
+
config[:password] = Ucenter::Config.uc_dbpw unless Ucenter::Config.uc_dbpw.nil?
|
11
|
+
config[:database] = Ucenter::Config.uc_dbname unless Ucenter::Config.uc_dbname.nil?
|
12
|
+
config[:encoding] = Ucenter::Config.uc_dbcharset unless Ucenter::Config.uc_dbcharset.nil?
|
13
|
+
@db_client = Mysql2::Client.new(config)
|
7
14
|
end
|
8
15
|
|
9
16
|
def get(path, opts={}, &block)
|
@@ -15,13 +22,7 @@ module Ucenter
|
|
15
22
|
end
|
16
23
|
|
17
24
|
def db_client
|
18
|
-
|
19
|
-
config[:host] = Ucenter::Config.uc_dbhost unless Ucenter::Config.uc_dbhost.nil?
|
20
|
-
config[:username] = Ucenter::Config.uc_dbuser unless Ucenter::Config.uc_dbuser.nil?
|
21
|
-
config[:password] = Ucenter::Config.uc_dbpw unless Ucenter::Config.uc_dbpw.nil?
|
22
|
-
config[:database] = Ucenter::Config.uc_dbname unless Ucenter::Config.uc_dbname.nil?
|
23
|
-
config[:encoding] = Ucenter::Config.uc_dbcharset unless Ucenter::Config.uc_dbcharset.nil?
|
24
|
-
Mysql2::Client.new(config)
|
25
|
+
@db_client
|
25
26
|
end
|
26
27
|
|
27
28
|
end
|
@@ -53,8 +53,20 @@ module Ucenter
|
|
53
53
|
db_client.query("SELECT count(*) FROM #{Ucenter::Config.uc_dbtablepre}mergemembers WHERE appid='#{Ucenter::Config.app_id}' AND username='#{username}'").to_a[0]
|
54
54
|
end
|
55
55
|
|
56
|
-
def add_user
|
56
|
+
def add_user (username, password, email, uid = 0, questionid = '', answer = '', regip = '', phone = '')
|
57
57
|
# TODO: 注册
|
58
|
+
# Aaron 2014-08-28
|
59
|
+
salt = UUID.new.generate[1,6]
|
60
|
+
password = md5(md5(password)+salt)
|
61
|
+
sqladd = uid.to_i==0 ? "" : ("uid='" + uid.to_i.to_s + "', " )
|
62
|
+
sqladd += questionid.to_i > 0 ? (" secques='" + quescrypt(questionid,answer) + "', ") : " secques='', "
|
63
|
+
sqladd += phone.empty? ? " " : " phone='#{phone}', "
|
64
|
+
sql= "insert into #{Ucenter::Config.uc_dbtablepre}members set #{sqladd} username='#{username}', password='#{password}', email='#{email}', regip='#{regip}', regdate='#{Time.now.to_i}', salt='#{salt}'"
|
65
|
+
client = db_client
|
66
|
+
client.query(sql)
|
67
|
+
inserted_id = client.last_id
|
68
|
+
client.query("insert into #{Ucenter::Config.uc_dbtablepre}memberfields set uid='#{inserted_id}'")
|
69
|
+
inserted_id
|
58
70
|
end
|
59
71
|
|
60
72
|
def edit_user
|
@@ -82,6 +94,10 @@ module Ucenter
|
|
82
94
|
db_client.query("SELECT * FROM #{Ucenter::Config.uc_dbtablepre}members WHERE phone='#{username}'").to_a[0]
|
83
95
|
end
|
84
96
|
|
97
|
+
def quescrypt(questionid, answer)
|
98
|
+
return questionid > 0 && answer != '' ? md5(answer.md5(questionid))[16,8] : '';
|
99
|
+
end
|
100
|
+
|
85
101
|
private
|
86
102
|
def md5 str; Digest::MD5.hexdigest str.to_s end
|
87
103
|
end
|
data/lib/ucenter/version.rb
CHANGED
data/ucenter.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ucenter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willin Wang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: uuid
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: http://willin.wang visit for more info.
|
70
84
|
email: willin@willin.org
|
71
85
|
executables: []
|