예제 #1
0
파일: Sharing.php 프로젝트: kaibosh/nZEDb
    /**
     * Post a comment to usenet.
     *
     * @param array $row
     *
     * @access protected
     */
    protected function postComment(&$row)
    {
        // Create a unique identifier for this comment.
        $sid = sha1($row['unix_time'] . $row['text'] . $row['nzb_guid']);
        // Check if the comment is already shared.
        $check = $this->pdo->queryOneRow(sprintf('SELECT id FROM release_comments WHERE shareid = %s', $this->pdo->escapeString($sid)));
        if ($check === false) {
            // Example of a subject.
            //(_nZEDb_)nZEDb_533f16e46a5091.73152965_3d12d7c1169d468aaf50d5541ef02cc88f3ede10 - [1/1] "92ba694cebc4fbbd0d9ccabc8604c71b23af1131" (1/1) yEnc
            // Attempt to upload the comment to usenet.
            $success = $this->nntp->postArticle(self::group, '(_nZEDb_)' . $this->siteSettings['site_name'] . '_' . $this->siteSettings['site_guid'] . ' - [1/1] "' . $sid . '" yEnc (1/1)', json_encode(['USER' => $this->siteSettings['hide_users'] ? 'ANON' : $row['username'], 'TIME' => $row['unix_time'], 'SID' => $sid, 'RID' => $row['nzb_guid'], 'BODY' => $row['text']]), '<*****@*****.**>');
            // Check if we succesfully uploaded it.
            if ($this->nntp->isError($success) === false && $success === true) {
                // Update DB to say we posted the article.
                $this->pdo->queryExec(sprintf('
						UPDATE release_comments
						SET shared = 1, shareid = %s
						WHERE id = %d', $this->pdo->escapeString($sid), $row['id']));
                if (nZEDb_ECHOCLI) {
                    echo '.';
                }
            }
        } else {
            // Update the DB to say it's shared.
            $this->pdo->queryExec(sprintf('UPDATE release_comments SET shared = 1 WHERE id = %d', $row['id']));
        }
    }