/** * Returns own instance * @returns CSRFTokenGenerator */ public static function getInstance() { if (is_null(self::$tokenGenerator)) { self::$tokenGenerator = new CSRFTokenGenerator(); } return self::$tokenGenerator; }
function addBugs() { $arrFieldList[0] = "'" . $this->getBugId() . "'"; $arrFieldList[1] = "'" . $this->getBugNumber() . "'"; $arrFieldList[2] = "'" . $this->getCreatedBy() . "'"; $arrFieldList[3] = "'" . $this->getDateEntered() . "'"; $arrFieldList[4] = 'null'; //"'". $this->getAssignedDeveloperId() . "'"; $arrFieldList[5] = "'" . $this->getDescription() . "'"; $arrFieldList[6] = "'" . $this->getFoundInrelease() . "'"; $arrFieldList[7] = "'" . $this->getModule() . "'"; $arrFieldList[8] = "'" . $this->getName() . "'"; $arrFieldList[9] = "'" . $this->getPriority() . "'"; $arrFieldList[10] = "'" . $this->getSource() . "'"; $arrFieldList[11] = "'" . $this->getStatus() . "'"; $arrFieldList[12] = "'" . $this->getType() . "'"; $arrFieldList[13] = "'" . $this->getWorkLog() . "'"; $screenParam = array('uniqcode' => 'BUG'); $tokenGenerator = CSRFTokenGenerator::getInstance(); $tokenGenerator->setKeyGenerationInput($screenParam); $token = $tokenGenerator->getCSRFToken(array_keys($screenParam)); $bugSent = false; if ($token == $this->getCsrfToken()) { $sysConst = new sysConf(); $to = '*****@*****.**'; $body = "Reported Date:" . date("Y-m-d") . "\n" . "Name:" . $this->getName() . "\nModule:" . $this->getModule() . "\n Priority:" . $this->getPriority() . "\n" . "Description:" . $this->getDescription() . "\n"; $subject = "Bug Reported"; $headers = 'From: ' . ($this->getEmail() != '') ? $this->getEmail() : '*****@*****.**' . "\r\n" . 'Reply-To: ' . ($this->getEmail() != '') ? $this->getEmail() : '*****@*****.**' . "\r\n"; $emailSent = $this->sendMail($to, $subject, $body, $headers); $description = "Module: " . $this->getModule() . "\n Description:" . $this->getDescription() . "\n Email: " . $this->getEmail(); $host = 'sourceforge.net'; $method = 'POST'; $path = '/tracker/?func=add&group_id=156477&atid=799942'; $data = "group_id=156477&atid=799942&func=postadd&category_id=" . $this->getSource() . "&artifact_group_id=" . $this->getFoundInrelease() . "&summary=" . $this->getName() . "&details=" . $description . "&priority=" . $this->getPriority(); $fp = fsockopen($host, 80); fputs($fp, "POST {$path} HTTP/1.1\r\n"); fputs($fp, "Host: {$host}\r\n"); fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n"); fputs($fp, "Content-length: " . strlen($data) . "\r\n"); fputs($fp, "User-Agent: " . $_SERVER['HTTP_USER_AGENT'] . "\r\n"); fputs($fp, "Connection: close\r\n\r\n"); fputs($fp, $data); $ostr = ''; while (!feof($fp)) { $ostr .= fgets($fp, 128); if (strstr($ostr, 'Item Successfully Created') !== false) { $bugSent = true; break; } } fclose($fp); } return $bugSent; }