introduce option to disable vizhash for paranoid admins, resolves #20 point 2.4

This commit is contained in:
El RIDO 2016-07-18 10:14:38 +02:00
parent 20cf678a75
commit ff0c55c0d6
5 changed files with 83 additions and 11 deletions

View file

@ -325,6 +325,13 @@ class privatebin_db extends privatebin_abstract
*/
public function createComment($pasteid, $parentid, $commentid, $comment)
{
foreach (array('nickname', 'vizhash') as $key)
{
if (!array_key_exists($key, $comment['meta']))
{
$comment['meta'][$key] = null;
}
}
return self::_exec(
'INSERT INTO ' . self::_sanitizeIdentifier('comment') .
' VALUES(?,?,?,?,?,?,?)',
@ -367,9 +374,9 @@ class privatebin_db extends privatebin_abstract
$comments[$i]->data = $row['data'];
$comments[$i]->meta = new stdClass;
$comments[$i]->meta->postdate = (int) $row['postdate'];
if (array_key_exists('nickname', $row))
if (array_key_exists('nickname', $row) && !empty($row['nickname']))
$comments[$i]->meta->nickname = $row['nickname'];
if (array_key_exists('vizhash', $row))
if (array_key_exists('vizhash', $row) && !empty($row['vizhash']))
$comments[$i]->meta->vizhash = $row['vizhash'];
}
ksort($comments);