Commit 5fa744c2 by Daniel Ruf Committed by Scott

support IPv6 using inet_pton

parent cb812352
...@@ -549,7 +549,7 @@ ...@@ -549,7 +549,7 @@
} }
if (@$options['whoview']) { if (@$options['whoview']) {
$fields['who']=qa_who_to_html($isbyuser, @$post['userid'], $usershtml, @$options['ipview'] ? @$post['createip'] : null, $microdata, $post['name']); $fields['who']=qa_who_to_html($isbyuser, @$post['userid'], $usershtml, @$options['ipview'] ? inet_ntop()@$post['createip']) : null, $microdata, $post['name']);
if (isset($post['points'])) { if (isset($post['points'])) {
if (@$options['pointsview']) if (@$options['pointsview'])
...@@ -628,7 +628,7 @@ ...@@ -628,7 +628,7 @@
} }
if (isset($post['lastuserid']) && @$options['whoview']) if (isset($post['lastuserid']) && @$options['whoview'])
$fields['who_2']=qa_who_to_html(isset($userid) && ($post['lastuserid']==$userid), $post['lastuserid'], $usershtml, @$options['ipview'] ? $post['lastip'] : null, false); $fields['who_2']=qa_who_to_html(isset($userid) && ($post['lastuserid']==$userid), $post['lastuserid'], $usershtml, @$options['ipview'] ? inet_ntop($post['lastip']) : null, false);
} }
...@@ -890,7 +890,7 @@ ...@@ -890,7 +890,7 @@
if (@$options['whoview']) { if (@$options['whoview']) {
$isbyuser=qa_post_is_by_user(array('userid' => $question['ouserid'], 'cookieid' => @$question['ocookieid']), $userid, $cookieid); $isbyuser=qa_post_is_by_user(array('userid' => $question['ouserid'], 'cookieid' => @$question['ocookieid']), $userid, $cookieid);
$fields['who']=qa_who_to_html($isbyuser, $question['ouserid'], $usershtml, @$options['ipview'] ? @$question['oip'] : null, false, @$question['oname']); $fields['who']=qa_who_to_html($isbyuser, $question['ouserid'], $usershtml, @$options['ipview'] ? inet_ntop(@$question['oip']) : null, false, @$question['oname']);
if (isset($question['opoints'])) { if (isset($question['opoints'])) {
if (@$options['pointsview']) if (@$options['pointsview'])
$fields['who']['points']=($question['opoints']==1) ? qa_lang_html_sub_split('main/1_point', '1', '1') $fields['who']['points']=($question['opoints']==1) ? qa_lang_html_sub_split('main/1_point', '1', '1')
......
...@@ -159,8 +159,7 @@ ...@@ -159,8 +159,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=INET_ATON($) AND type IN ('Q', 'A', 'C', 'Q_QUEUED', 'A_QUEUED', 'C_QUEUED')", "SELECT postid FROM ^posts WHERE createip=".inet_pton($ip)." AND type IN ('Q', 'A', 'C', 'Q_QUEUED', 'A_QUEUED', 'C_QUEUED')"
$ip
)); ));
} }
...@@ -187,7 +186,7 @@ ...@@ -187,7 +186,7 @@
*/ */
{ {
$results=qa_db_read_all_assoc(qa_db_query_sub( $results=qa_db_read_all_assoc(qa_db_query_sub(
"SELECT ^users.userid, UNIX_TIMESTAMP(created) AS created, INET_NTOA(createip) AS createip, email, handle, flags, title, content FROM ^users LEFT JOIN ^userprofile ON ^users.userid=^userprofile.userid AND LENGTH(content)>0 WHERE level<# AND NOT (flags&#) ORDER BY created DESC LIMIT #", "SELECT ^users.userid, UNIX_TIMESTAMP(created) AS created, createip, email, handle, flags, title, content FROM ^users LEFT JOIN ^userprofile ON ^users.userid=^userprofile.userid AND LENGTH(content)>0 WHERE level<# AND NOT (flags&#) ORDER BY created DESC LIMIT #",
QA_USER_LEVEL_APPROVED, QA_USER_FLAGS_USER_BLOCKED, $count QA_USER_LEVEL_APPROVED, QA_USER_FLAGS_USER_BLOCKED, $count
)); ));
...@@ -195,6 +194,7 @@ ...@@ -195,6 +194,7 @@
foreach ($results as $result) { foreach ($results as $result) {
$userid=$result['userid']; $userid=$result['userid'];
$result['createip']=inet_ntop($result['createip']);
if (!isset($users[$userid])) { if (!isset($users[$userid])) {
$users[$result['userid']]=$result; $users[$result['userid']]=$result;
......
...@@ -40,8 +40,8 @@ ...@@ -40,8 +40,8 @@
continue; continue;
qa_db_query_sub( qa_db_query_sub(
'INSERT INTO ^blobs (blobid, format, content, filename, userid, cookieid, createip, created) VALUES (#, $, $, $, $, #, INET_ATON($), NOW())', 'INSERT INTO ^blobs (blobid, format, content, filename, userid, cookieid, createip, created) VALUES (#, $, $, $, $, #, '.inet_pton($ip).', NOW())',
$blobid, $format, $content, $sourcefilename, $userid, $cookieid, $ip $blobid, $format, $content, $sourcefilename, $userid, $cookieid
); );
return $blobid; return $blobid;
...@@ -107,4 +107,4 @@ ...@@ -107,4 +107,4 @@
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
*/ */
\ No newline at end of file
...@@ -39,8 +39,8 @@ ...@@ -39,8 +39,8 @@
qa_db_query_sub( qa_db_query_sub(
'INSERT INTO ^cookies (cookieid, created, createip) '. 'INSERT INTO ^cookies (cookieid, created, createip) '.
'VALUES (#, NOW(), COALESCE(INET_ATON($), 0))', 'VALUES (#, NOW(), '.inet_pton($ipaddress).')',
$cookieid, $ipaddress $cookieid
); );
return $cookieid; return $cookieid;
...@@ -56,8 +56,8 @@ ...@@ -56,8 +56,8 @@
*/ */
{ {
qa_db_query_sub( qa_db_query_sub(
'UPDATE ^cookies SET written=NOW(), writeip=COALESCE(INET_ATON($), 0) WHERE cookieid=#', 'UPDATE ^cookies SET written=NOW(), writeip='.inet_pton($ipaddress).' WHERE cookieid=#',
$ipaddress, $cookieid $cookieid
); );
} }
...@@ -76,4 +76,4 @@ ...@@ -76,4 +76,4 @@
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
*/ */
\ No newline at end of file
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
'(a.acount+0.0)*# + '. '(a.acount+0.0)*# + '.
'(a.netvotes+0.0)*# + '. '(a.netvotes+0.0)*# + '.
'(a.views+0.0+#)*#'. '(a.views+0.0+#)*#'.
')'.($viewincrement ? ', x.views=x.views+1, x.lastviewip=INET_ATON($)' : '').' WHERE x.postid=a.postid'; ')'.($viewincrement ? ', x.views=x.views+1, x.lastviewip='.inet_pton(qa_remote_ip_address()) : '').' WHERE x.postid=a.postid';
// Additional multiples based on empirical analysis of activity on Q2A meta site to give approx equal influence for all factors // Additional multiples based on empirical analysis of activity on Q2A meta site to give approx equal influence for all factors
...@@ -59,9 +59,6 @@ ...@@ -59,9 +59,6 @@
qa_opt('hot_weight_views')*4000, qa_opt('hot_weight_views')*4000,
); );
if ($viewincrement)
$arguments[]=qa_remote_ip_address();
qa_db_query_raw(qa_db_apply_sub($query, $arguments)); qa_db_query_raw(qa_db_apply_sub($query, $arguments));
} }
} }
...@@ -69,4 +66,4 @@ ...@@ -69,4 +66,4 @@
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
*/ */
\ No newline at end of file
...@@ -42,8 +42,7 @@ ...@@ -42,8 +42,7 @@
} }
if (isset($ip)) { if (isset($ip)) {
$selects[]="(SELECT 'ip' AS limitkey, period, count FROM ^iplimits WHERE ip=COALESCE(INET_ATON($), 0) AND action=$)"; $selects[]="(SELECT 'ip' AS limitkey, period, count FROM ^iplimits WHERE ip=".inet_pton($ip)." AND action=$)";
$arguments[]=$ip;
$arguments[]=$action; $arguments[]=$action;
} }
...@@ -75,13 +74,13 @@ ...@@ -75,13 +74,13 @@
*/ */
{ {
qa_db_query_sub( qa_db_query_sub(
'INSERT INTO ^iplimits (ip, action, period, count) VALUES (COALESCE(INET_ATON($), 0), $, #, #) '. 'INSERT INTO ^iplimits (ip, action, period, count) VALUES ('.inet_pton($ip).', $, #, #) '.
'ON DUPLICATE KEY UPDATE count=IF(period=#, count+#, #), period=#', 'ON DUPLICATE KEY UPDATE count=IF(period=#, count+#, #), period=#',
$ip, $action, $period, $count, $period, $count, $count, $period $action, $period, $count, $period, $count, $count, $period
); );
} }
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
*/ */
\ No newline at end of file
...@@ -33,8 +33,8 @@ ...@@ -33,8 +33,8 @@
{ {
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 (#, $, #, $, #, INET_ATON($), $, $, $, $, $, $, NOW())', 'VALUES (#, $, #, $, #, '.inet_pton($ip).', $, $, $, $, $, $, NOW())',
$categoryid, $type, $parentid, $userid, $cookieid, $ip, $title, $content, $format, $tagstring, $notify, $name $categoryid, $type, $parentid, $userid, $cookieid, $title, $content, $format, $tagstring, $notify, $name
); );
return qa_db_last_insert_id(); return qa_db_last_insert_id();
...@@ -410,4 +410,4 @@ ...@@ -410,4 +410,4 @@
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
*/ */
\ No newline at end of file
...@@ -48,8 +48,8 @@ ...@@ -48,8 +48,8 @@
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=INET_ATON($) WHERE postid=#", "UPDATE ^posts SET updated=NOW(), updatetype=$, lastuserid=$, lastip=".inet_pton($lastip)." WHERE postid=#",
QA_UPDATE_SELECTED, $lastuserid, $lastip, $selchildid QA_UPDATE_SELECTED, $lastuserid, $selchildid
); );
} }
...@@ -62,8 +62,8 @@ ...@@ -62,8 +62,8 @@
{ {
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=INET_ATON($) WHERE postid=#", "UPDATE ^posts SET closedbyid=#, updated=NOW(), updatetype=$, lastuserid=$, lastip=".inet_pton($lastip)." WHERE postid=#",
$closedbyid, QA_UPDATE_CLOSED, $lastuserid, $lastip, $questionid $closedbyid, QA_UPDATE_CLOSED, $lastuserid, $questionid
); );
} else } else
qa_db_query_sub( qa_db_query_sub(
...@@ -80,8 +80,8 @@ ...@@ -80,8 +80,8 @@
{ {
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=INET_ATON($) WHERE postid=#', 'UPDATE ^posts SET type=$, updated=NOW(), updatetype=$, lastuserid=$, lastip='.inet_pton($lastip).' WHERE postid=#',
$type, $updatetype, $lastuserid, $lastip, $postid $type, $updatetype, $lastuserid, $postid
); );
} else } else
qa_db_query_sub( qa_db_query_sub(
...@@ -98,8 +98,8 @@ ...@@ -98,8 +98,8 @@
{ {
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=INET_ATON($) WHERE postid=#", "UPDATE ^posts SET parentid=#, updated=NOW(), updatetype=$, lastuserid=$, lastip=".inet_pton($lastip)." WHERE postid=#",
$parentid, QA_UPDATE_PARENT, $lastuserid, $lastip, $postid $parentid, QA_UPDATE_PARENT, $lastuserid, $postid
); );
else else
qa_db_query_sub( qa_db_query_sub(
...@@ -118,8 +118,8 @@ ...@@ -118,8 +118,8 @@
{ {
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=INET_ATON($) WHERE postid=#', 'UPDATE ^posts SET title=$, content=$, format=$, tags=$, name=COALESCE($, name), notify=$, updated=NOW(), updatetype=$, lastuserid=$, lastip='.inet_pton($lastip).' WHERE postid=#',
$title, $content, $format, $tagstring, $name, $notify, $updatetype, $lastuserid, $lastip, $postid $title, $content, $format, $tagstring, $name, $notify, $updatetype, $lastuserid, $postid
); );
else else
qa_db_query_sub( qa_db_query_sub(
...@@ -148,8 +148,8 @@ ...@@ -148,8 +148,8 @@
{ {
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=INET_ATON($) WHERE postid=#", "UPDATE ^posts SET categoryid=#, updated=NOW(), updatetype=$, lastuserid=$, lastip=".inet_pton($lastip)." WHERE postid=#",
$categoryid, QA_UPDATE_CATEGORY, $lastuserid, $lastip, $postid $categoryid, QA_UPDATE_CATEGORY, $lastuserid, $postid
); );
else else
qa_db_query_sub( qa_db_query_sub(
...@@ -363,4 +363,4 @@ ...@@ -363,4 +363,4 @@
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
*/ */
\ No newline at end of file
...@@ -166,15 +166,15 @@ ...@@ -166,15 +166,15 @@
$selectspec['columns']['updatetype']='^posts.updatetype'; $selectspec['columns']['updatetype']='^posts.updatetype';
$selectspec['columns'][]='^posts.format'; $selectspec['columns'][]='^posts.format';
$selectspec['columns'][]='^posts.lastuserid'; $selectspec['columns'][]='^posts.lastuserid';
$selectspec['columns']['lastip']='INET_NTOA(^posts.lastip)'; $selectspec['columns']['lastip']='^posts.lastip';
$selectspec['columns'][]='^posts.parentid'; $selectspec['columns'][]='^posts.parentid';
$selectspec['columns']['lastviewip']='INET_NTOA(^posts.lastviewip)'; $selectspec['columns']['lastviewip']='^posts.lastviewip';
} }
if ($user) { if ($user) {
$selectspec['columns'][]='^posts.userid'; $selectspec['columns'][]='^posts.userid';
$selectspec['columns'][]='^posts.cookieid'; $selectspec['columns'][]='^posts.cookieid';
$selectspec['columns']['createip']='INET_NTOA(^posts.createip)'; $selectspec['columns']['createip']='^posts.createip';
$selectspec['columns'][]='^userpoints.points'; $selectspec['columns'][]='^userpoints.points';
if (!QA_FINAL_EXTERNAL_USERS) { if (!QA_FINAL_EXTERNAL_USERS) {
...@@ -216,7 +216,7 @@ ...@@ -216,7 +216,7 @@
$selectspec['columns']['ouserid']=$poststable.($fromupdated ? '.lastuserid' : '.userid'); $selectspec['columns']['ouserid']=$poststable.($fromupdated ? '.lastuserid' : '.userid');
$selectspec['columns']['ocookieid']=$poststable.'.cookieid'; $selectspec['columns']['ocookieid']=$poststable.'.cookieid';
$selectspec['columns']['oname']=$poststable.'.name'; $selectspec['columns']['oname']=$poststable.'.name';
$selectspec['columns']['oip']='INET_NTOA('.$poststable.($fromupdated ? '.lastip' : '.createip').')'; $selectspec['columns']['oip']=$poststable.($fromupdated ? '.lastip' : '.createip');
$selectspec['columns']['otime']='UNIX_TIMESTAMP('.$poststable.($fromupdated ? '.updated' : '.created').')'; $selectspec['columns']['otime']='UNIX_TIMESTAMP('.$poststable.($fromupdated ? '.updated' : '.created').')';
$selectspec['columns']['oflagcount']=$poststable.'.flagcount'; $selectspec['columns']['oflagcount']=$poststable.'.flagcount';
...@@ -323,12 +323,9 @@ ...@@ -323,12 +323,9 @@
$selectspec['source'].=" JOIN (SELECT postid FROM ^posts WHERE ". $selectspec['source'].=" JOIN (SELECT postid FROM ^posts WHERE ".
qa_db_categoryslugs_sql_args($categoryslugs, $selectspec['arguments']). qa_db_categoryslugs_sql_args($categoryslugs, $selectspec['arguments']).
(isset($createip) ? "createip=INET_ATON($) AND " : ""). (isset($createip) ? "createip=".inet_pton($createip)." AND " : "").
"type=$ ".$sortsql." LIMIT #,#) y ON ^posts.postid=y.postid"; "type=$ ".$sortsql." LIMIT #,#) y ON ^posts.postid=y.postid";
if (isset($createip))
$selectspec['arguments'][]=$createip;
array_push($selectspec['arguments'], $type, $start, $count); array_push($selectspec['arguments'], $type, $start, $count);
$selectspec['sortdesc']=$sort; $selectspec['sortdesc']=$sort;
...@@ -406,13 +403,10 @@ ...@@ -406,13 +403,10 @@
" LEFT JOIN ^userpoints AS auserpoints ON aposts.userid=auserpoints.userid". " LEFT JOIN ^userpoints AS auserpoints ON aposts.userid=auserpoints.userid".
" JOIN (SELECT postid FROM ^posts WHERE ". " JOIN (SELECT postid FROM ^posts WHERE ".
qa_db_categoryslugs_sql_args($categoryslugs, $selectspec['arguments']). qa_db_categoryslugs_sql_args($categoryslugs, $selectspec['arguments']).
(isset($createip) ? "createip=INET_ATON($) AND " : ""). (isset($createip) ? "createip=".inet_pton($createip)." AND " : "").
"type=$ ORDER BY ^posts.created DESC LIMIT #,#) y ON aposts.postid=y.postid". "type=$ ORDER BY ^posts.created DESC LIMIT #,#) y ON aposts.postid=y.postid".
($specialtype ? '' : " WHERE ^posts.type='Q'"); ($specialtype ? '' : " WHERE ^posts.type='Q'");
if (isset($createip))
$selectspec['arguments'][]=$createip;
array_push($selectspec['arguments'], $type, $start, $count); array_push($selectspec['arguments'], $type, $start, $count);
$selectspec['sortdesc']='otime'; $selectspec['sortdesc']='otime';
...@@ -449,13 +443,10 @@ ...@@ -449,13 +443,10 @@
" LEFT JOIN ^userpoints AS cuserpoints ON cposts.userid=cuserpoints.userid". " LEFT JOIN ^userpoints AS cuserpoints ON cposts.userid=cuserpoints.userid".
" JOIN (SELECT postid FROM ^posts WHERE ". " JOIN (SELECT postid FROM ^posts WHERE ".
qa_db_categoryslugs_sql_args($categoryslugs, $selectspec['arguments']). qa_db_categoryslugs_sql_args($categoryslugs, $selectspec['arguments']).
(isset($createip) ? "createip=INET_ATON($) AND " : ""). (isset($createip) ? "createip=".inet_pton($createip)." AND " : "").
"type=$ ORDER BY ^posts.created DESC LIMIT #,#) y ON cposts.postid=y.postid". "type=$ ORDER BY ^posts.created DESC LIMIT #,#) y ON cposts.postid=y.postid".
($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))
$selectspec['arguments'][]=$createip;
array_push($selectspec['arguments'], $type, $start, $count); array_push($selectspec['arguments'], $type, $start, $count);
$selectspec['sortdesc']='otime'; $selectspec['sortdesc']='otime';
...@@ -487,14 +478,11 @@ ...@@ -487,14 +478,11 @@
" LEFT JOIN ^userpoints AS edituserpoints ON editposts.lastuserid=edituserpoints.userid". " LEFT JOIN ^userpoints AS edituserpoints ON editposts.lastuserid=edituserpoints.userid".
" JOIN (SELECT postid FROM ^posts WHERE ". " JOIN (SELECT postid FROM ^posts WHERE ".
qa_db_categoryslugs_sql_args($categoryslugs, $selectspec['arguments']). qa_db_categoryslugs_sql_args($categoryslugs, $selectspec['arguments']).
(isset($lastip) ? "lastip=INET_ATON($) AND " : ""). (isset($lastip) ? "lastip=".inet_pton($lastip)." AND " : "").
($onlyvisible ? "type IN ('Q', 'A', 'C')" : "1"). ($onlyvisible ? "type IN ('Q', 'A', 'C')" : "1").
" ORDER BY ^posts.updated DESC LIMIT #,#) y ON editposts.postid=y.postid". " ORDER BY ^posts.updated DESC LIMIT #,#) y ON editposts.postid=y.postid".
($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))
$selectspec['arguments'][]=$lastip;
array_push($selectspec['arguments'], $start, $count); array_push($selectspec['arguments'], $start, $count);
$selectspec['sortdesc']='otime'; $selectspec['sortdesc']='otime';
...@@ -1199,7 +1187,7 @@ ...@@ -1199,7 +1187,7 @@
'columns' => array( 'columns' => array(
'^users.userid', 'passsalt', 'passcheck' => 'HEX(passcheck)', 'passhash', 'email', 'level', 'emailcode', 'handle', '^users.userid', 'passsalt', 'passcheck' => 'HEX(passcheck)', 'passhash', 'email', 'level', 'emailcode', 'handle',
'created' => 'UNIX_TIMESTAMP(created)', 'sessioncode', 'sessionsource', 'flags', 'loggedin' => 'UNIX_TIMESTAMP(loggedin)', 'created' => 'UNIX_TIMESTAMP(created)', 'sessioncode', 'sessionsource', 'flags', 'loggedin' => 'UNIX_TIMESTAMP(loggedin)',
'loginip' => 'INET_NTOA(loginip)', 'written' => 'UNIX_TIMESTAMP(written)', 'writeip' => 'INET_NTOA(writeip)', 'loginip', 'written' => 'UNIX_TIMESTAMP(written)', 'writeip',
'avatarblobid' => 'BINARY avatarblobid', // cast to BINARY due to MySQL bug which renders it signed in a union 'avatarblobid' => 'BINARY avatarblobid', // cast to BINARY due to MySQL bug which renders it signed in a union
'avatarwidth', 'avatarheight', 'points', 'wallposts', 'avatarwidth', 'avatarheight', 'points', 'wallposts',
), ),
...@@ -1678,8 +1666,7 @@ ...@@ -1678,8 +1666,7 @@
{ {
return array( return array(
'columns' => array('action', 'period', 'count'), 'columns' => array('action', 'period', 'count'),
'source' => '^iplimits WHERE ip=COALESCE(INET_ATON($), 0)', 'source' => '^iplimits WHERE ip='.inet_pton($ip),
'arguments' => array($ip),
'arraykey' => 'action', 'arraykey' => 'action',
); );
} }
...@@ -1711,4 +1698,4 @@ ...@@ -1711,4 +1698,4 @@
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
*/ */
\ No newline at end of file
...@@ -47,16 +47,16 @@ ...@@ -47,16 +47,16 @@
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(), COALESCE(INET_ATON($), 0), $, $, #, $, NOW(), COALESCE(INET_ATON($), 0))', 'VALUES (NOW(), '.inet_pton($ip).', $, $, #, $, NOW(), '.inet_pton($ip).')',
$ip, $email, isset($password) ? password_hash($password, PASSWORD_BCRYPT) : null, (int)$level, $handle, $ip $email, isset($password) ? password_hash($password, PASSWORD_BCRYPT) : null, (int)$level, $handle
); );
} else { } else {
$salt = isset($password) ? qa_random_alphanum(16) : null; $salt = isset($password) ? qa_random_alphanum(16) : null;
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(), COALESCE(INET_ATON($), 0), $, $, UNHEX($), #, $, NOW(), COALESCE(INET_ATON($), 0))', 'VALUES (NOW(), '.inet_pton($ip).', 0), $, $, UNHEX($), #, $, NOW(), '.inet_pton($ip).')',
$ip, $email, $salt, isset($password) ? qa_db_calc_passcheck($password, $salt) : null, (int)$level, $handle, $ip $email, $salt, isset($password) ? qa_db_calc_passcheck($password, $salt) : null, (int)$level, $handle
); );
} }
...@@ -236,8 +236,8 @@ ...@@ -236,8 +236,8 @@
*/ */
{ {
qa_db_query_sub( qa_db_query_sub(
'UPDATE ^users SET loggedin=NOW(), loginip=COALESCE(INET_ATON($), 0) WHERE userid=$', 'UPDATE ^users SET loggedin=NOW(), loginip='.inet_pton($ip).' WHERE userid=$',
$ip, $userid $userid
); );
} }
...@@ -248,8 +248,8 @@ ...@@ -248,8 +248,8 @@
*/ */
{ {
qa_db_query_sub( qa_db_query_sub(
'UPDATE ^users SET written=NOW(), writeip=COALESCE(INET_ATON($), 0) WHERE userid=$', 'UPDATE ^users SET written=NOW(), writeip='.inet_pton($ip).' WHERE userid=$',
$ip, $userid $userid
); );
} }
......
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
$message['content']=qa_lang_html('users/registered_label').' '. $message['content']=qa_lang_html('users/registered_label').' '.
strtr(qa_lang_html('users/x_ago_from_y'), array( strtr(qa_lang_html('users/x_ago_from_y'), array(
'^1' => qa_time_to_string(qa_opt('db_time')-$user['created']), '^1' => qa_time_to_string(qa_opt('db_time')-$user['created']),
'^2' => qa_ip_anchor_html($user['createip']), '^2' => qa_ip_anchor_html(inet_ntop($user['createip'])),
)).'<br/>'; )).'<br/>';
$htmlemail=qa_html($user['email']); $htmlemail=qa_html($user['email']);
......
...@@ -430,8 +430,8 @@ ...@@ -430,8 +430,8 @@
(!qa_is_http_post()) && (!qa_is_http_post()) &&
qa_is_human_probably() && qa_is_human_probably() &&
( (!$question['views']) || ( // if it has more than zero views ( (!$question['views']) || ( // if it has more than zero views
( ($question['lastviewip']!=qa_remote_ip_address()) || (!isset($question['lastviewip'])) ) && // then it must be different IP from last view ( (inet_ntop($question['lastviewip'])!=qa_remote_ip_address()) || (!isset($question['lastviewip'])) ) && // then it must be different IP from last view
( ($question['createip']!=qa_remote_ip_address()) || (!isset($question['createip'])) ) && // and different IP from the creator ( (inet_ntop($question['createip'])!=qa_remote_ip_address()) || (!isset($question['createip'])) ) && // and different IP from the creator
( ($question['userid']!=$userid) || (!isset($question['userid'])) ) && // and different user from the creator ( ($question['userid']!=$userid) || (!isset($question['userid'])) ) && // and different user from the creator
( ($question['cookieid']!=$cookieid) || (!isset($question['cookieid'])) ) // and different cookieid from the creator ( ($question['cookieid']!=$cookieid) || (!isset($question['cookieid'])) ) // and different cookieid from the creator
) ) ) )
...@@ -444,4 +444,4 @@ ...@@ -444,4 +444,4 @@
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
*/ */
\ No newline at end of file
...@@ -583,7 +583,7 @@ ...@@ -583,7 +583,7 @@
'value' => 'value' =>
strtr(qa_lang_html('users/x_ago_from_y'), array( strtr(qa_lang_html('users/x_ago_from_y'), array(
'^1' => qa_time_to_string(qa_opt('db_time')-$useraccount['loggedin']), '^1' => qa_time_to_string(qa_opt('db_time')-$useraccount['loggedin']),
'^2' => qa_ip_anchor_html($useraccount['loginip']), '^2' => qa_ip_anchor_html(inet_ntop($useraccount['loginip'])),
)), )),
'note' => $userediting ? null : qa_lang_html('users/only_shown_moderators'), 'note' => $userediting ? null : qa_lang_html('users/only_shown_moderators'),
'id' => 'lastlogin', 'id' => 'lastlogin',
...@@ -596,7 +596,7 @@ ...@@ -596,7 +596,7 @@
'value' => 'value' =>
strtr(qa_lang_html('users/x_ago_from_y'), array( strtr(qa_lang_html('users/x_ago_from_y'), array(
'^1' => qa_time_to_string(qa_opt('db_time')-$useraccount['written']), '^1' => qa_time_to_string(qa_opt('db_time')-$useraccount['written']),
'^2' => qa_ip_anchor_html($useraccount['writeip']), '^2' => qa_ip_anchor_html(inet_ntop($useraccount['writeip'])),
)), )),
'note' => $userediting ? null : qa_lang_html('users/only_shown_moderators'), 'note' => $userediting ? null : qa_lang_html('users/only_shown_moderators'),
'id' => 'lastwrite', 'id' => 'lastwrite',
...@@ -979,4 +979,4 @@ ...@@ -979,4 +979,4 @@
/* /*
Omit PHP closing tag to help avoid accidental output Omit PHP closing tag to help avoid accidental output
*/ */
\ No newline at end of file
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