Пример #1
0
 public static function dumpException($e, $moredata = false)
 {
     System::dumpError(($moredata != false ? "{$moredata}: " : '') . $e->getMessage());
 }
Пример #2
0
 public function add($to, $message, $options = [])
 {
     extract($options);
     $news = !empty($news);
     $project = !empty($project);
     $issue = !empty($issue);
     $language = !empty($language) ? $language : false;
     if ($language) {
         if (!in_array($language, System::getAvailableLanguages())) {
             return 'error: INVALID_LANGUAGE';
         }
     } else {
         $language = $this->user->getLanguage();
     }
     $table = ($project ? 'groups_' : '') . 'posts';
     $retStr = Db::query(['INSERT INTO "' . $table . '" ("from","to","message","news","lang") VALUES (:id,:to,:message, :news, :language)', [':id' => $_SESSION['id'], ':to' => $to, ':message' => Comments::parseQuote(htmlspecialchars($message, ENT_QUOTES, 'UTF-8')), ':news' => $news ? 'true' : 'false', ':language' => $language]], Db::FETCH_ERRSTR);
     if ($retStr != Db::NO_ERRSTR) {
         return $retStr;
     }
     if ($project && $issue && $to == Config\ISSUE_BOARD) {
         require_once __DIR__ . '/vendor/autoload.php';
         $client = new \Github\Client();
         $client->authenticate(Config\ISSUE_GIT_KEY, null, \Github\client::AUTH_URL_TOKEN);
         $message = static::stripTags($message);
         try {
             $client->api('issue')->create('nerdzeu', 'nerdz.eu', ['title' => substr($message, 0, 128), 'body' => User::getUsername() . ': ' . $message]);
         } catch (\Github\Exception\RuntimeException $exception) {
             System::dumpError('GitHub API: ' . $exception->getMessage());
             System::dumpError('GitHub API: ' . $exception->getPrevious());
         }
     }
     return $retStr;
 }