Commit de852fc7 by Scott

Fix inet_pton warnings

parent cf0a2b7e
...@@ -160,7 +160,7 @@ ...@@ -160,7 +160,7 @@
{ {
return qa_db_read_all_values(qa_db_query_sub( 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')", "SELECT postid FROM ^posts WHERE createip=$ AND type IN ('Q', 'A', 'C', 'Q_QUEUED', 'A_QUEUED', 'C_QUEUED')",
inet_pton($ip) @inet_pton($ip)
)); ));
} }
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
qa_db_query_sub( qa_db_query_sub(
'INSERT INTO ^blobs (blobid, format, content, filename, userid, cookieid, createip, created) VALUES (#, $, $, $, $, #, $, NOW())', '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; return $blobid;
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
qa_db_query_sub( qa_db_query_sub(
'INSERT INTO ^cookies (cookieid, created, createip) '. 'INSERT INTO ^cookies (cookieid, created, createip) '.
'VALUES (#, NOW(), $)', 'VALUES (#, NOW(), $)',
$cookieid, inet_pton($ipaddress) $cookieid, @inet_pton($ipaddress)
); );
return $cookieid; return $cookieid;
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
{ {
qa_db_query_sub( qa_db_query_sub(
'UPDATE ^cookies SET written=NOW(), writeip=$ WHERE cookieid=#', 'UPDATE ^cookies SET written=NOW(), writeip=$ WHERE cookieid=#',
inet_pton($ipaddress), $cookieid @inet_pton($ipaddress), $cookieid
); );
} }
......
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
); );
if ($viewincrement) 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_db_query_raw(qa_db_apply_sub($query, $arguments));
} }
......
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
if (isset($ip)) { if (isset($ip)) {
$selects[]="(SELECT 'ip' AS limitkey, period, count FROM ^iplimits WHERE ip=$ AND action=$)"; $selects[]="(SELECT 'ip' AS limitkey, period, count FROM ^iplimits WHERE ip=$ AND action=$)";
$arguments[]=inet_pton($ip); $arguments[]=@inet_pton($ip);
$arguments[]=$action; $arguments[]=$action;
} }
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
qa_db_query_sub( qa_db_query_sub(
'INSERT INTO ^iplimits (ip, action, period, count) VALUES ($, $, #, #) '. 'INSERT INTO ^iplimits (ip, action, period, count) VALUES ($, $, #, #) '.
'ON DUPLICATE KEY UPDATE count=IF(period=#, count+#, #), period=#', '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
); );
} }
......
...@@ -34,7 +34,7 @@ ...@@ -34,7 +34,7 @@
qa_db_query_sub( qa_db_query_sub(
'INSERT INTO ^posts (categoryid, type, parentid, userid, cookieid, createip, title, content, format, tags, notify, name, created) '. 'INSERT INTO ^posts (categoryid, type, parentid, userid, cookieid, createip, title, content, format, tags, notify, name, created) '.
'VALUES (#, $, #, $, #, $, $, $, $, $, $, $, NOW())', '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(); return qa_db_last_insert_id();
......
...@@ -49,7 +49,7 @@ ...@@ -49,7 +49,7 @@
if (isset($selchildid) && isset($lastuserid) && isset($lastip)) if (isset($selchildid) && isset($lastuserid) && isset($lastip))
qa_db_query_sub( qa_db_query_sub(
"UPDATE ^posts SET updated=NOW(), updatetype=$, lastuserid=$, lastip=$ WHERE postid=#", "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 @@ ...@@ -63,7 +63,7 @@
if (isset($lastuserid) || isset($lastip)) { if (isset($lastuserid) || isset($lastip)) {
qa_db_query_sub( qa_db_query_sub(
"UPDATE ^posts SET closedbyid=#, updated=NOW(), updatetype=$, lastuserid=$, lastip=$ WHERE postid=#", "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 } else
qa_db_query_sub( qa_db_query_sub(
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
if (isset($lastuserid) || isset($lastip)) { if (isset($lastuserid) || isset($lastip)) {
qa_db_query_sub( qa_db_query_sub(
'UPDATE ^posts SET type=$, updated=NOW(), updatetype=$, lastuserid=$, lastip=$ WHERE postid=#', '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 } else
qa_db_query_sub( qa_db_query_sub(
...@@ -99,7 +99,7 @@ ...@@ -99,7 +99,7 @@
if (isset($lastuserid) || isset($lastip)) if (isset($lastuserid) || isset($lastip))
qa_db_query_sub( qa_db_query_sub(
"UPDATE ^posts SET parentid=#, updated=NOW(), updatetype=$, lastuserid=$, lastip=$ WHERE postid=#", "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 else
qa_db_query_sub( qa_db_query_sub(
...@@ -119,7 +119,7 @@ ...@@ -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) 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( qa_db_query_sub(
'UPDATE ^posts SET title=$, content=$, format=$, tags=$, name=COALESCE($, name), notify=$, updated=NOW(), updatetype=$, lastuserid=$, lastip=$ WHERE postid=#', '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 else
qa_db_query_sub( qa_db_query_sub(
...@@ -149,7 +149,7 @@ ...@@ -149,7 +149,7 @@
if (isset($lastuserid) || isset($lastip)) if (isset($lastuserid) || isset($lastip))
qa_db_query_sub( qa_db_query_sub(
"UPDATE ^posts SET categoryid=#, updated=NOW(), updatetype=$, lastuserid=$, lastip=$ WHERE postid=#", "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 else
qa_db_query_sub( qa_db_query_sub(
......
...@@ -327,7 +327,7 @@ ...@@ -327,7 +327,7 @@
"type=$ ".$sortsql." LIMIT #,#) y ON ^posts.postid=y.postid"; "type=$ ".$sortsql." LIMIT #,#) y ON ^posts.postid=y.postid";
if (isset($createip)) if (isset($createip))
$selectspec['arguments'][]=inet_pton($createip); $selectspec['arguments'][]=@inet_pton($createip);
array_push($selectspec['arguments'], $type, $start, $count); array_push($selectspec['arguments'], $type, $start, $count);
...@@ -411,7 +411,7 @@ ...@@ -411,7 +411,7 @@
($specialtype ? '' : " WHERE ^posts.type='Q'"); ($specialtype ? '' : " WHERE ^posts.type='Q'");
if (isset($createip)) if (isset($createip))
$selectspec['arguments'][]=inet_pton($createip); $selectspec['arguments'][]=@inet_pton($createip);
array_push($selectspec['arguments'], $type, $start, $count); array_push($selectspec['arguments'], $type, $start, $count);
...@@ -454,7 +454,7 @@ ...@@ -454,7 +454,7 @@
($specialtype ? '' : " WHERE ^posts.type='Q' AND ((parentposts.type='Q') OR (parentposts.type='A'))"); ($specialtype ? '' : " WHERE ^posts.type='Q' AND ((parentposts.type='Q') OR (parentposts.type='A'))");
if (isset($createip)) if (isset($createip))
$selectspec['arguments'][]=inet_pton($createip); $selectspec['arguments'][]=@inet_pton($createip);
array_push($selectspec['arguments'], $type, $start, $count); array_push($selectspec['arguments'], $type, $start, $count);
...@@ -493,7 +493,7 @@ ...@@ -493,7 +493,7 @@
($onlyvisible ? " WHERE parentposts.type IN ('Q', 'A', 'C') AND ^posts.type IN ('Q', 'A', 'C')" : ""); ($onlyvisible ? " WHERE parentposts.type IN ('Q', 'A', 'C') AND ^posts.type IN ('Q', 'A', 'C')" : "");
if (isset($lastip)) if (isset($lastip))
$selectspec['arguments'][]=inet_pton($lastip); $selectspec['arguments'][]=@inet_pton($lastip);
array_push($selectspec['arguments'], $start, $count); array_push($selectspec['arguments'], $start, $count);
...@@ -1679,7 +1679,7 @@ ...@@ -1679,7 +1679,7 @@
return array( return array(
'columns' => array('action', 'period', 'count'), 'columns' => array('action', 'period', 'count'),
'source' => '^iplimits WHERE ip=$', 'source' => '^iplimits WHERE ip=$',
'arguments' => array(inet_pton($ip)), 'arguments' => array(@inet_pton($ip)),
'arraykey' => 'action', 'arraykey' => 'action',
); );
} }
......
...@@ -44,11 +44,13 @@ ...@@ -44,11 +44,13 @@
{ {
require_once QA_INCLUDE_DIR.'util/string.php'; require_once QA_INCLUDE_DIR.'util/string.php';
$ipbin = @inet_pton($ip);
if (QA_PASSWORD_HASH) { if (QA_PASSWORD_HASH) {
qa_db_query_sub( qa_db_query_sub(
'INSERT INTO ^users (created, createip, email, passhash, level, handle, loggedin, loginip) '. 'INSERT INTO ^users (created, createip, email, passhash, level, handle, loggedin, loginip) '.
'VALUES (NOW(), $, $, $, #, $, NOW(), $)', '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 { } else {
$salt = isset($password) ? qa_random_alphanum(16) : null; $salt = isset($password) ? qa_random_alphanum(16) : null;
...@@ -56,7 +58,7 @@ ...@@ -56,7 +58,7 @@
qa_db_query_sub( qa_db_query_sub(
'INSERT INTO ^users (created, createip, email, passsalt, passcheck, level, handle, loggedin, loginip) '. 'INSERT INTO ^users (created, createip, email, passsalt, passcheck, level, handle, loggedin, loginip) '.
'VALUES (NOW(), $, $, $, UNHEX($), #, $, NOW(), $)', '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 @@ ...@@ -237,7 +239,7 @@
{ {
qa_db_query_sub( qa_db_query_sub(
'UPDATE ^users SET loggedin=NOW(), loginip=$ WHERE userid=$', 'UPDATE ^users SET loggedin=NOW(), loginip=$ WHERE userid=$',
inet_pton($ip), $userid @inet_pton($ip), $userid
); );
} }
...@@ -249,7 +251,7 @@ ...@@ -249,7 +251,7 @@
{ {
qa_db_query_sub( qa_db_query_sub(
'UPDATE ^users SET written=NOW(), writeip=$ WHERE userid=$', 'UPDATE ^users SET written=NOW(), writeip=$ WHERE userid=$',
inet_pton($ip), $userid @inet_pton($ip), $userid
); );
} }
......
...@@ -202,11 +202,11 @@ ...@@ -202,11 +202,11 @@
if (QA_PASSWORD_HASH) { if (QA_PASSWORD_HASH) {
require_once QA_INCLUDE_DIR.'vendor/password_compat.php'; require_once QA_INCLUDE_DIR.'vendor/password_compat.php';
} }
// http://stackoverflow.com/a/18277167 // http://stackoverflow.com/a/18277167
function ipv6_numeric($ip) { function ipv6_numeric($ip) {
$binNum = ''; $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); $binNum .= str_pad(decbin($byte), 8, "0", STR_PAD_LEFT);
} }
return base_convert(ltrim($binNum, '0'), 2, 10); return base_convert(ltrim($binNum, '0'), 2, 10);
...@@ -230,10 +230,10 @@ ...@@ -230,10 +230,10 @@
} }
$ip=implode($wildcards,":"); $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); $ip = substr(preg_replace("/([A-f0-9]{4})/", "$1:", $hex['hex']), 0, -1);
if($ipv6_wildcard){ if($ipv6_wildcard){
$wildcards = explode(":", $ip); $wildcards = explode(":", $ip);
foreach($wildcards_matched as $index => $value){ foreach($wildcards_matched as $index => $value){
...@@ -241,7 +241,7 @@ ...@@ -241,7 +241,7 @@
} }
$ip=implode($wildcards,":"); $ip=implode($wildcards,":");
} }
return $ip; return $ip;
} }
} }
......
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