Example #1
0
 public function testGet()
 {
     $failureAffects = "Affects all get requests sent from Login.";
     ob_start();
     CURLHandler::Get("https://www.google.com/accounts/ClientLogin");
     $result = ob_get_contents();
     ob_end_clean();
     $this->assertContains('Error=BadAuthentication', $result, $failureAffects);
 }
Example #2
0
 public static function allAvailableRepositories()
 {
     // 1. Read the config file. Find a link to WebSVN page
     $web_svn_url = self::_webSvnUrl();
     // 2. Retrieve the content of WebSVN front page
     ob_start();
     echo CURLHandler::Get($web_svn_url);
     $html = ob_get_contents();
     ob_end_clean();
     // 3. form the regex pattern. We are searching the html for lines like this:
     // '<a href="listing.php?repname=admin&amp;">admin</a>'. Resulting matches are dumped into 'project' array.
     $repoLinkFragment = preg_quote(self::_repoLinkFragment());
     $regexp = "<a\\s[^>]*href=[\"']" . $repoLinkFragment . "\\b[^>]*>(?P<project>.*)<\\/a>";
     return preg_match_all("/{$regexp}/siU", $html, $matches) ? $matches['project'] : array();
 }
Example #3
0
 public function sendHipchat_notification($message, $message_format = 'html', $notify = 0)
 {
     $success = true;
     $room_id = 0;
     $token = $this->getHipchatNotificationToken();
     $url = HIPCHAT_API_AUTH_URL . $token;
     $response = CURLHandler::Get($url, array());
     $response = json_decode($response);
     if (count($response->rooms)) {
         foreach ($response->rooms as $key => $room) {
             if ($room->name == trim($this->getHipchatRoom())) {
                 $room_id = $room->room_id;
                 break;
             }
         }
         if ($room_id > 0) {
             $url = HIPCHAT_API_MESSAGE_URL . $token;
             $fields = array('room_id' => $room_id, 'from' => 'Worklist.net', 'message' => $message, 'message_format' => $message_format, 'notify' => $notify, 'color' => $this->getHipchatColor());
             $result = CURLHandler::Post($url, $fields);
             $result = json_decode($result);
             if ($result->status != 'sent') {
                 $success = false;
                 $body = "Failed to send message: " . $message;
             }
         } else {
             $success = false;
             $body = "Failed to find room " . $this->getHipchatRoom() . ".";
         }
     } else {
         $success = false;
         $body = "Failed to authenticate to hipchat.";
     }
     if ($success == false) {
         $email = $this->getContactInfo();
         $subject = "HipChat Notification Failed";
         if (!Utils::send_email($email, $subject, $body, $body, array('Cc' => OPS_EMAIL))) {
             error_log("project-class.php: sendHipchat_notification : Utils::send_email failed");
         }
     }
 }