Commit de852fc7 by Scott

Fix inet_pton warnings

parent cf0a2b7e
......@@ -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)
));
}
......
......@@ -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;
......
......@@ -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
);
}
......
......@@ -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));
}
......
......@@ -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
);
}
......
......@@ -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();
......
......@@ -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(
......
......@@ -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',
);
}
......
......@@ -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
);
}
......
......@@ -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;
}
}
......
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