<commit_before><?
  require_once dirname($_SERVER['DOCUMENT_ROOT']) . '/lib/track7.php';
  require_once 'auForm.php';
  require_once 'auText.php';
  $cmtform = new auForm('pagecomments', '/comments.php');
  $cmtform->AddData('page', '');
  $cmtform->AddData('ref', '');
  if($user->Valid) {  
    $cmtform->AddData('uid', '');
    //$cmtform->AddText('name', '');
  } else {
    $cmtform->AddField('name', 'name', 'enter your name so i will know who you are', false);
    $cmtform->AddField('contact', 'contact', 'enter an e-mail address or a url', false);
  }
  $cmtform->AddField('pagecomments', 'comments', 'enter your comments (you may use t7code)', true, '', _AU_FORM_FIELD_BBCODE, array('cols' => 40));
  $cmtform->AddButtons(array('save', 'update'), 'post your comment on this page');
  switch($cmtform->Submitted()) {
    case 'save':
      if($cmtform->CheckInput($user->Valid)) {
        if(isset($_POST['uid']) && is_numeric($_POST['uid'])) {
          if($user->Valid && $_POST['uid'] == $user->ID) {
            if(false !== $db->Put('insert into comments (page, instant, uid, comments) values (\'' . addslashes($_POST['page']) . '\', ' . time() . ', ' . +$_POST['uid'] . ', \'' . addslashes(auText::BB2HTML($_POST['pagecomments'])) . '\')', 'error saving comment')) {
              $db->Change('update userstats set comments=comments+1 where uid=' . +$_POST['uid']);
              $user->UpdateRank();
              if($_POST['uid'] != 1)
                @mail('misterhaan@' . _HOST, $user->Name . ' has commented on ' . $_POST['page'], 'http://' . $_SERVER['HTTP_HOST'] . $_POST['page'] . '#comments' . "\n\n" . $_POST['pagecomments'],
                  'From: track7 comments <<EMAIL>ay@' . _HOST . ">\r\n" .
                  'X-Mailer: PHP/' . phpversion() . "\r\n");
              if($_POST['ref'])
                $_POST['page'] = $_POST['ref'];
              header('Location: http://' . $_SERVER['HTTP_HOST'] . $_POST['page'] . '#comments');
              die;
            }
          } else
            $page->Error('not logged in as user you are trying to post as!&nbsp; either something has gone wrong or you are trying to do things you shouldn\'t.');
        } else {
          if(preg_match('/&lt;a .*href=(&quot;)?.+(&quot;)?&gt;/is', $_POST['pagecomments']) || strpos($_POST['pagecomments'], '^)') !== false || strpos($_POST['pagecomments'], 'Hello world') !== false) {
            $page->Start('spam somewhere else, fool', 'no coming in, please');
?>
      <p>
        you appear to have attempted to use an html link in your comment.&nbsp;
        if you are a real person (meaning not a bot or a spammer) and were
        trying to post a link, please see my post on
        <a href="/oi/f3/t1/">how to use t7code</a> for instructions and try
        again.&nbsp; if you are a bot or a spammer, please go away and cease
        your nonsense immediately.
      </p>
<?
            $page->End();
            die;
          } elseif(substr($_POST['page'], 0, 1) != '/') {
            $page->Start('spam somewhere else, fool', 'no coming in, please!');
?>
      <p>
        you appear to be trying to post a comment without using the official
        form, possibly even trying to spam a link to some crappy site nobody
        wants to see ever.&nbsp; if you actually did use the official comment
        form and got this error, please note the page you came from and
        <a href="/user/sendmessage.php?to=misterhaan">contact me about it</a>.&nbsp;
        if you are a bot or a spammer, please go away and cease your nonsense
        immediately.
      </p>
<?
            $page->End();
            die;
          } elseif(strpos($_POST['contact'], '[url') !== false) {
            $page->Start('spam somewhere else, fool', 'no coming in, please!');
?>
      <p>
        you appear to be trying to post a nasty nasty spam comment with links to
        websites that nobody will ever want to go to, ever.&nbsp; if this is not
        what you are trying to do, please
        <a href="/user/sendmessage.php?to=misterhaan">contact me about it</a>.&nbsp;
        if you are a bot or a spammer, please go away and cease your nonsense
        immediately.
      </p>
<?
            $page->End();
            die;
          }
          if(strlen($_POST['name']) <= 0)
            $_POST['name'] = 'anonymous';
          if(false !== $db->Put('insert into comments (page, instant, name, url, comments) values (\'' . addslashes(htmlspecialchars($_POST['page'])) . '\', ' . time() . ', \'' . addslashes(htmlspecialchars($_POST['name'])) . '\', \'' . addslashes(auText::FixLink($_POST['contact'])) . '\', \'' . addslashes(auText::BB2HTML($_POST['pagecomments'])) . '\')', 'error saving comments')) {
            @mail('misterhaan@' . _HOST, $_POST['name'] . ' has commented on ' . $_POST['page'], 'http://' . $_SERVER['HTTP_HOST'] . $_POST['page'] . '#comments' . "\n\n" . $_POST['pagecomments'],
                    'From: track7 comments <whatyousay@' . _HOST . ">\r\n" .
                    'X-Mailer: PHP/' . phpversion() . "\r\n");
            if($_POST['ref'])
              $_POST['page'] = $_POST['ref'];
            header('Location: http://' . $_SERVER['HTTP_HOST'] . $_POST['page'] . "#comments\r\n");
            die;
          }
        }
      } else
        $page->Error('looks like you messed something up!&nbsp; make sure to enter some comments, and don\'t fill in the spam trapper fields (which you shouldn\'t see anyway) unless you\'re spamming.');
      $page->Start('error saving comment');
      $page->End();
      die;
      break;
    case 'update':
      if(is_numeric($_POST['id'])) {
        if($user->GodMode) {
          $olduser = 'select uid from comments where id=' . +$_POST['id'];
          if(false !== $olduser = $db->GetValue($olduser, 'error looking up current user id for this comment', 'cannot find comment', true)) {
            if($olduser != $_POST['uid']) {
              if($olduser > 0)
                $db->Change('update userstats set comments=comments-1 where uid=' . +$olduser);
              if($_POST['uid'] > 0)
                $db->Change('update userstats set comments=comments+1 where uid=\'' . $_POST['uid'] . '\'');
            }
            $update = 'update comments set page=\'' . addslashes($_POST['page']) . '\', uid=\'' . addslashes($_POST['uid']) . '\', name=\'' . addslashes(htmlspecialchars($_POST['name'])) . '\', url=\'' . addslashes(htmlspecialchars($_POST['url'])) . '\', comments=\'' . addslashes(auText::BB2HTML($_POST['pagecomments'])) . '\' where id=' . $_POST['id'];
            if(false !== $db->Change($update, 'error updating comment')) {
              header('Location: http://' . $_SERVER['HTTP_HOST'] . $_POST['goback']);
              die;
            }
          }
        } else {
          $update = 'update comments set comments=\'' . addslashes(auText::BB2HTML($_POST['pagecomments'])) . '\' where id=' . +$_POST['id'] . ' and uid=\'' . $user->id . '\'';
          if(false !== $db->Change($update, 'error updating comment', 'unable to update comment:&nbsp; either you are not logged in or this comment is not yours', true)) {<commit_msg>allow users to edit their comments again<commit_after><?
  require_once dirname($_SERVER['DOCUMENT_ROOT']) . '/lib/track7.php';
  require_once 'auForm.php';
  require_once 'auText.php';
  $cmtform = new auForm('pagecomments', '/comments.php');
  $cmtform->AddData('page', '');
  $cmtform->AddData('ref', '');
  if($user->Valid) {  
    $cmtform->AddData('uid', '');
    //$cmtform->AddText('name', '');
  } else {
    $cmtform->AddField('name', 'name', 'enter your name so i will know who you are', false);
    $cmtform->AddField('contact', 'contact', 'enter an e-mail address or a url', false);
  }
  $cmtform->AddField('pagecomments', 'comments', 'enter your comments (you may use t7code)', true, '', _AU_FORM_FIELD_BBCODE, array('cols' => 40));
  $cmtform->AddButtons(array('save', 'update'), 'post your comment on this page');
  switch($cmtform->Submitted()) {
    case 'save':
      if($cmtform->CheckInput($user->Valid)) {
        if(isset($_POST['uid']) && is_numeric($_POST['uid'])) {
          if($user->Valid && $_POST['uid'] == $user->ID) {
            if(false !== $db->Put('insert into comments (page, instant, uid, comments) values (\'' . addslashes($_POST['page']) . '\', ' . time() . ', ' . +$_POST['uid'] . ', \'' . addslashes(auText::BB2HTML($_POST['pagecomments'])) . '\')', 'error saving comment')) {
              $db->Change('update userstats set comments=comments+1 where uid=' . +$_POST['uid']);
              $user->UpdateRank();
              if($_POST['uid'] != 1)
                @mail('misterhaan@' . _HOST, $user->Name . ' has commented on ' . $_POST['page'], 'http://' . $_SERVER['HTTP_HOST'] . $_POST['page'] . '#comments' . "\n\n" . $_POST['pagecomments'],
                  'From: track7 comments <whatyousay@' . _HOST . ">\r\n" .
                  'X-Mailer: PHP/' . phpversion() . "\r\n");
              if($_POST['ref'])
                $_POST['page'] = $_POST['ref'];
              header('Location: http://' . $_SERVER['HTTP_HOST'] . $_POST['page'] . '#comments');
              die;
            }
          } else
            $page->Error('not logged in as user you are trying to post as!&nbsp; either something has gone wrong or you are trying to do things you shouldn\'t.');
        } else {
          if(preg_match('/&lt;a .*href=(&quot;)?.+(&quot;)?&gt;/is', $_POST['pagecomments']) || strpos($_POST['pagecomments'], '^)') !== false || strpos($_POST['pagecomments'], 'Hello world') !== false) {
            $page->Start('spam somewhere else, fool', 'no coming in, please');
?>
      <p>
        you appear to have attempted to use an html link in your comment.&nbsp;
        if you are a real person (meaning not a bot or a spammer) and were
        trying to post a link, please see my post on
        <a href="/oi/f3/t1/">how to use t7code</a> for instructions and try
        again.&nbsp; if you are a bot or a spammer, please go away and cease
        your nonsense immediately.
      </p>
<?
            $page->End();
            die;
          } elseif(substr($_POST['page'], 0, 1) != '/') {
            $page->Start('spam somewhere else, fool', 'no coming in, please!');
?>
      <p>
        you appear to be trying to post a comment without using the official
        form, possibly even trying to spam a link to some crappy site nobody
        wants to see ever.&nbsp; if you actually did use the official comment
        form and got this error, please note the page you came from and
        <a href="/user/sendmessage.php?to=misterhaan">contact me about it</a>.&nbsp;
        if you are a bot or a spammer, please go away and cease your nonsense
        immediately.
      </p>
<?
            $page->End();
            die;
          } elseif(strpos($_POST['contact'], '[url') !== false) {
            $page->Start('spam somewhere else, fool', 'no coming in, please!');
?>
      <p>
        you appear to be trying to post a nasty nasty spam comment with links to
        websites that nobody will ever want to go to, ever.&nbsp; if this is not
        what you are trying to do, please
        <a href="/user/sendmessage.php?to=misterhaan">contact me about it</a>.&nbsp;
        if you are a bot or a spammer, please go away and cease your nonsense
        immediately.
      </p>
<?
            $page->End();
            die;
          }
          if(strlen($_POST['name']) <= 0)
            $_POST['name'] = 'anonymous';
          if(false !== $db->Put('insert into comments (page, instant, name, url, comments) values (\'' . addslashes(htmlspecialchars($_POST['page'])) . '\', ' . time() . ', \'' . addslashes(htmlspecialchars($_POST['name'])) . '\', \'' . addslashes(auText::FixLink($_POST['contact'])) . '\', \'' . addslashes(auText::BB2HTML($_POST['pagecomments'])) . '\')', 'error saving comments')) {
            @mail('misterhaan@' . _HOST, $_POST['name'] . ' has commented on ' . $_POST['page'], 'http://' . $_SERVER['HTTP_HOST'] . $_POST['page'] . '#comments' . "\n\n" . $_POST['pagecomments'],
                    'From: track7 comments <whatyousay@' . _HOST . ">\r\n" .
                    'X-Mailer: PHP/' . phpversion() . "\r\n");
            if($_POST['ref'])
              $_POST['page'] = $_POST['ref'];
            header('Location: http://' . $_SERVER['HTTP_HOST'] . $_POST['page'] . "#comments\r\n");
            die;
          }
        }
      } else
        $page->Error('looks like you messed something up!&nbsp; make sure to enter some comments, and don\'t fill in the spam trapper fields (which you shouldn\'t see anyway) unless you\'re spamming.');
      $page->Start('error saving comment');
      $page->End();
      die;
      break;
    case 'update':
      if(is_numeric($_POST['id'])) {
        if($user->GodMode) {
          $olduser = 'select uid from comments where id=' . +$_POST['id'];
          if(false !== $olduser = $db->GetValue($olduser, 'error looking up current user id for this comment', 'cannot find comment', true)) {
            if($olduser != $_POST['uid']) {
              if($olduser > 0)
                $db->Change('update userstats set comments=comments-1 where uid=' . +$olduser);
              if($_POST['uid'] > 0)
                $db->Change('update userstats set comments=comments+1 where uid=\'' . $_POST['uid'] . '\'');
            }
            $update = 'update comments set page=\'' . addslashes($_POST['page']) . '\', uid=\'' . addslashes($_POST['uid']) . '\', name=\'' . addslashes(htmlspecialchars($_POST['name'])) . '\', url=\'' . addslashes(htmlspecialchars($_POST['url'])) . '\', comments=\'' . addslashes(auText::BB2HTML($_POST['pagecomments'])) . '\' where id=' . $_POST['id'];
            if(false !== $db->Change($update, 'error updating comment')) {
              header('Location: http://' . $_SERVER['HTTP_HOST'] . $_POST['goback']);
              die;
            }
          }
        } else {
          $update = 'update comments set comments=\'' . addslashes(auText::BB2HTML($_POST['pagecomments'])) . '\' where id=' . +$_POST['id'] . ' and uid=\'' . $user->ID . '\'';
          if(false !== $db->Change($update, 'error updating comment', 'unable to update comment:&nbsp; either you are not logged in or this comment is not yours', true)) {
{'fraction_non_alphanumeric': 0.1910143714245849, 'fraction_numerical': 0.0030696246686200642, 'mean_word_length': 2.5438813349814584, 'pattern_counts': {'":': 0, '<': 42, '<?xml version=': 0, '>': 116, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1008284', 'n_tokens_mistral': 4315, 'n_tokens_neox': 4260, 'n_words': 1206}