Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
de852fc7
Commit
de852fc7
authored
Feb 23, 2016
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix inet_pton warnings
parent
cf0a2b7e
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
31 additions
and
29 deletions
+31
-29
admin.php
qa-include/db/admin.php
+1
-1
blobs.php
qa-include/db/blobs.php
+1
-1
cookies.php
qa-include/db/cookies.php
+2
-2
hotness.php
qa-include/db/hotness.php
+1
-1
limits.php
qa-include/db/limits.php
+2
-2
post-create.php
qa-include/db/post-create.php
+1
-1
post-update.php
qa-include/db/post-update.php
+6
-6
selects.php
qa-include/db/selects.php
+5
-5
users.php
qa-include/db/users.php
+6
-4
qa-base.php
qa-include/qa-base.php
+6
-6
No files found.
qa-include/db/admin.php
View file @
de852fc7
...
...
@@ -160,7 +160,7 @@
{
return
qa_db_read_all_values
(
qa_db_query_sub
(
"SELECT postid FROM ^posts WHERE createip=$ AND type IN ('Q', 'A', 'C', 'Q_QUEUED', 'A_QUEUED', 'C_QUEUED')"
,
inet_pton
(
$ip
)
@
inet_pton
(
$ip
)
));
}
...
...
qa-include/db/blobs.php
View file @
de852fc7
...
...
@@ -41,7 +41,7 @@
qa_db_query_sub
(
'INSERT INTO ^blobs (blobid, format, content, filename, userid, cookieid, createip, created) VALUES (#, $, $, $, $, #, $, NOW())'
,
$blobid
,
$format
,
$content
,
$sourcefilename
,
$userid
,
$cookieid
,
inet_pton
(
$ip
)
$blobid
,
$format
,
$content
,
$sourcefilename
,
$userid
,
$cookieid
,
@
inet_pton
(
$ip
)
);
return
$blobid
;
...
...
qa-include/db/cookies.php
View file @
de852fc7
...
...
@@ -40,7 +40,7 @@
qa_db_query_sub
(
'INSERT INTO ^cookies (cookieid, created, createip) '
.
'VALUES (#, NOW(), $)'
,
$cookieid
,
inet_pton
(
$ipaddress
)
$cookieid
,
@
inet_pton
(
$ipaddress
)
);
return
$cookieid
;
...
...
@@ -57,7 +57,7 @@
{
qa_db_query_sub
(
'UPDATE ^cookies SET written=NOW(), writeip=$ WHERE cookieid=#'
,
inet_pton
(
$ipaddress
),
$cookieid
@
inet_pton
(
$ipaddress
),
$cookieid
);
}
...
...
qa-include/db/hotness.php
View file @
de852fc7
...
...
@@ -60,7 +60,7 @@
);
if
(
$viewincrement
)
$arguments
[]
=
inet_pton
(
qa_remote_ip_address
());
$arguments
[]
=
@
inet_pton
(
qa_remote_ip_address
());
qa_db_query_raw
(
qa_db_apply_sub
(
$query
,
$arguments
));
}
...
...
qa-include/db/limits.php
View file @
de852fc7
...
...
@@ -43,7 +43,7 @@
if
(
isset
(
$ip
))
{
$selects
[]
=
"(SELECT 'ip' AS limitkey, period, count FROM ^iplimits WHERE ip=$ AND action=$)"
;
$arguments
[]
=
inet_pton
(
$ip
);
$arguments
[]
=
@
inet_pton
(
$ip
);
$arguments
[]
=
$action
;
}
...
...
@@ -77,7 +77,7 @@
qa_db_query_sub
(
'INSERT INTO ^iplimits (ip, action, period, count) VALUES ($, $, #, #) '
.
'ON DUPLICATE KEY UPDATE count=IF(period=#, count+#, #), period=#'
,
inet_pton
(
$ip
),
$action
,
$period
,
$count
,
$period
,
$count
,
$count
,
$period
@
inet_pton
(
$ip
),
$action
,
$period
,
$count
,
$period
,
$count
,
$count
,
$period
);
}
...
...
qa-include/db/post-create.php
View file @
de852fc7
...
...
@@ -34,7 +34,7 @@
qa_db_query_sub
(
'INSERT INTO ^posts (categoryid, type, parentid, userid, cookieid, createip, title, content, format, tags, notify, name, created) '
.
'VALUES (#, $, #, $, #, $, $, $, $, $, $, $, NOW())'
,
$categoryid
,
$type
,
$parentid
,
$userid
,
$cookieid
,
inet_pton
(
$ip
),
$title
,
$content
,
$format
,
$tagstring
,
$notify
,
$name
$categoryid
,
$type
,
$parentid
,
$userid
,
$cookieid
,
@
inet_pton
(
$ip
),
$title
,
$content
,
$format
,
$tagstring
,
$notify
,
$name
);
return
qa_db_last_insert_id
();
...
...
qa-include/db/post-update.php
View file @
de852fc7
...
...
@@ -49,7 +49,7 @@
if
(
isset
(
$selchildid
)
&&
isset
(
$lastuserid
)
&&
isset
(
$lastip
))
qa_db_query_sub
(
"UPDATE ^posts SET updated=NOW(), updatetype=$, lastuserid=$, lastip=$ WHERE postid=#"
,
QA_UPDATE_SELECTED
,
$lastuserid
,
inet_pton
(
$lastip
),
$selchildid
QA_UPDATE_SELECTED
,
$lastuserid
,
@
inet_pton
(
$lastip
),
$selchildid
);
}
...
...
@@ -63,7 +63,7 @@
if
(
isset
(
$lastuserid
)
||
isset
(
$lastip
))
{
qa_db_query_sub
(
"UPDATE ^posts SET closedbyid=#, updated=NOW(), updatetype=$, lastuserid=$, lastip=$ WHERE postid=#"
,
$closedbyid
,
QA_UPDATE_CLOSED
,
$lastuserid
,
inet_pton
(
$lastip
),
$questionid
$closedbyid
,
QA_UPDATE_CLOSED
,
$lastuserid
,
@
inet_pton
(
$lastip
),
$questionid
);
}
else
qa_db_query_sub
(
...
...
@@ -81,7 +81,7 @@
if
(
isset
(
$lastuserid
)
||
isset
(
$lastip
))
{
qa_db_query_sub
(
'UPDATE ^posts SET type=$, updated=NOW(), updatetype=$, lastuserid=$, lastip=$ WHERE postid=#'
,
$type
,
$updatetype
,
$lastuserid
,
inet_pton
(
$lastip
),
$postid
$type
,
$updatetype
,
$lastuserid
,
@
inet_pton
(
$lastip
),
$postid
);
}
else
qa_db_query_sub
(
...
...
@@ -99,7 +99,7 @@
if
(
isset
(
$lastuserid
)
||
isset
(
$lastip
))
qa_db_query_sub
(
"UPDATE ^posts SET parentid=#, updated=NOW(), updatetype=$, lastuserid=$, lastip=$ WHERE postid=#"
,
$parentid
,
QA_UPDATE_PARENT
,
$lastuserid
,
inet_pton
(
$lastip
),
$postid
$parentid
,
QA_UPDATE_PARENT
,
$lastuserid
,
@
inet_pton
(
$lastip
),
$postid
);
else
qa_db_query_sub
(
...
...
@@ -119,7 +119,7 @@
if
(
isset
(
$lastuserid
)
||
isset
(
$lastip
))
// use COALESCE() for name since $name=null means it should not be modified (for backwards compatibility)
qa_db_query_sub
(
'UPDATE ^posts SET title=$, content=$, format=$, tags=$, name=COALESCE($, name), notify=$, updated=NOW(), updatetype=$, lastuserid=$, lastip=$ WHERE postid=#'
,
$title
,
$content
,
$format
,
$tagstring
,
$name
,
$notify
,
$updatetype
,
$lastuserid
,
inet_pton
(
$lastip
),
$postid
$title
,
$content
,
$format
,
$tagstring
,
$name
,
$notify
,
$updatetype
,
$lastuserid
,
@
inet_pton
(
$lastip
),
$postid
);
else
qa_db_query_sub
(
...
...
@@ -149,7 +149,7 @@
if
(
isset
(
$lastuserid
)
||
isset
(
$lastip
))
qa_db_query_sub
(
"UPDATE ^posts SET categoryid=#, updated=NOW(), updatetype=$, lastuserid=$, lastip=$ WHERE postid=#"
,
$categoryid
,
QA_UPDATE_CATEGORY
,
$lastuserid
,
inet_pton
(
$lastip
),
$postid
$categoryid
,
QA_UPDATE_CATEGORY
,
$lastuserid
,
@
inet_pton
(
$lastip
),
$postid
);
else
qa_db_query_sub
(
...
...
qa-include/db/selects.php
View file @
de852fc7
...
...
@@ -327,7 +327,7 @@
"type=$ "
.
$sortsql
.
" LIMIT #,#) y ON ^posts.postid=y.postid"
;
if
(
isset
(
$createip
))
$selectspec
[
'arguments'
][]
=
inet_pton
(
$createip
);
$selectspec
[
'arguments'
][]
=
@
inet_pton
(
$createip
);
array_push
(
$selectspec
[
'arguments'
],
$type
,
$start
,
$count
);
...
...
@@ -411,7 +411,7 @@
(
$specialtype
?
''
:
" WHERE ^posts.type='Q'"
);
if
(
isset
(
$createip
))
$selectspec
[
'arguments'
][]
=
inet_pton
(
$createip
);
$selectspec
[
'arguments'
][]
=
@
inet_pton
(
$createip
);
array_push
(
$selectspec
[
'arguments'
],
$type
,
$start
,
$count
);
...
...
@@ -454,7 +454,7 @@
(
$specialtype
?
''
:
" WHERE ^posts.type='Q' AND ((parentposts.type='Q') OR (parentposts.type='A'))"
);
if
(
isset
(
$createip
))
$selectspec
[
'arguments'
][]
=
inet_pton
(
$createip
);
$selectspec
[
'arguments'
][]
=
@
inet_pton
(
$createip
);
array_push
(
$selectspec
[
'arguments'
],
$type
,
$start
,
$count
);
...
...
@@ -493,7 +493,7 @@
(
$onlyvisible
?
" WHERE parentposts.type IN ('Q', 'A', 'C') AND ^posts.type IN ('Q', 'A', 'C')"
:
""
);
if
(
isset
(
$lastip
))
$selectspec
[
'arguments'
][]
=
inet_pton
(
$lastip
);
$selectspec
[
'arguments'
][]
=
@
inet_pton
(
$lastip
);
array_push
(
$selectspec
[
'arguments'
],
$start
,
$count
);
...
...
@@ -1679,7 +1679,7 @@
return
array
(
'columns'
=>
array
(
'action'
,
'period'
,
'count'
),
'source'
=>
'^iplimits WHERE ip=$'
,
'arguments'
=>
array
(
inet_pton
(
$ip
)),
'arguments'
=>
array
(
@
inet_pton
(
$ip
)),
'arraykey'
=>
'action'
,
);
}
...
...
qa-include/db/users.php
View file @
de852fc7
...
...
@@ -44,11 +44,13 @@
{
require_once
QA_INCLUDE_DIR
.
'util/string.php'
;
$ipbin
=
@
inet_pton
(
$ip
);
if
(
QA_PASSWORD_HASH
)
{
qa_db_query_sub
(
'INSERT INTO ^users (created, createip, email, passhash, level, handle, loggedin, loginip) '
.
'VALUES (NOW(), $, $, $, #, $, NOW(), $)'
,
inet_pton
(
$ip
),
$email
,
isset
(
$password
)
?
password_hash
(
$password
,
PASSWORD_BCRYPT
)
:
null
,
(
int
)
$level
,
$handle
,
inet_pton
(
$ip
)
$ipbin
,
$email
,
isset
(
$password
)
?
password_hash
(
$password
,
PASSWORD_BCRYPT
)
:
null
,
(
int
)
$level
,
$handle
,
$ipbin
);
}
else
{
$salt
=
isset
(
$password
)
?
qa_random_alphanum
(
16
)
:
null
;
...
...
@@ -56,7 +58,7 @@
qa_db_query_sub
(
'INSERT INTO ^users (created, createip, email, passsalt, passcheck, level, handle, loggedin, loginip) '
.
'VALUES (NOW(), $, $, $, UNHEX($), #, $, NOW(), $)'
,
inet_pton
(
$ip
),
$email
,
$salt
,
isset
(
$password
)
?
qa_db_calc_passcheck
(
$password
,
$salt
)
:
null
,
(
int
)
$level
,
$handle
,
inet_pton
(
$ip
)
$ipbin
,
$email
,
$salt
,
isset
(
$password
)
?
qa_db_calc_passcheck
(
$password
,
$salt
)
:
null
,
(
int
)
$level
,
$handle
,
$ipbin
);
}
...
...
@@ -237,7 +239,7 @@
{
qa_db_query_sub
(
'UPDATE ^users SET loggedin=NOW(), loginip=$ WHERE userid=$'
,
inet_pton
(
$ip
),
$userid
@
inet_pton
(
$ip
),
$userid
);
}
...
...
@@ -249,7 +251,7 @@
{
qa_db_query_sub
(
'UPDATE ^users SET written=NOW(), writeip=$ WHERE userid=$'
,
inet_pton
(
$ip
),
$userid
@
inet_pton
(
$ip
),
$userid
);
}
...
...
qa-include/qa-base.php
View file @
de852fc7
...
...
@@ -202,11 +202,11 @@
if
(
QA_PASSWORD_HASH
)
{
require_once
QA_INCLUDE_DIR
.
'vendor/password_compat.php'
;
}
// http://stackoverflow.com/a/18277167
function
ipv6_numeric
(
$ip
)
{
$binNum
=
''
;
foreach
(
unpack
(
'C*'
,
inet_pton
(
$ip
))
as
$byte
)
{
foreach
(
unpack
(
'C*'
,
@
inet_pton
(
$ip
))
as
$byte
)
{
$binNum
.=
str_pad
(
decbin
(
$byte
),
8
,
"0"
,
STR_PAD_LEFT
);
}
return
base_convert
(
ltrim
(
$binNum
,
'0'
),
2
,
10
);
...
...
@@ -230,10 +230,10 @@
}
$ip
=
implode
(
$wildcards
,
":"
);
}
$hex
=
unpack
(
"H*hex"
,
inet_pton
(
$ip
));
$hex
=
unpack
(
"H*hex"
,
@
inet_pton
(
$ip
));
$ip
=
substr
(
preg_replace
(
"/([A-f0-9]
{
4
}
)/"
,
"$1:"
,
$hex
[
'hex'
]),
0
,
-
1
);
if
(
$ipv6_wildcard
){
$wildcards
=
explode
(
":"
,
$ip
);
foreach
(
$wildcards_matched
as
$index
=>
$value
){
...
...
@@ -241,7 +241,7 @@
}
$ip
=
implode
(
$wildcards
,
":"
);
}
return
$ip
;
}
}
...
...
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