Inheritance: extends Codendi_Request
コード例 #1
0
ファイル: class.httprequest.php プロジェクト: Bakyenga/kyengs
 function DownloadToString()
 {
     $crlf = "\r\n";
     // generate request
     $req = 'GET ' . $this->_uri . ' HTTP/1.0' . $crlf . 'Host: ' . $this->_host . $crlf . $crlf;
     // fetch
     $this->_fp = fsockopen(($this->_protocol == 'https' ? 'ssl://' : '') . $this->_host, $this->_port);
     fwrite($this->_fp, $req);
     while (is_resource($this->_fp) && $this->_fp && !feof($this->_fp)) {
         $response .= fread($this->_fp, 1024);
     }
     fclose($this->_fp);
     // split header and body
     $pos = strpos($response, $crlf . $crlf);
     if ($pos === false) {
         return $response;
     }
     $header = substr($response, 0, $pos);
     $body = substr($response, $pos + 2 * strlen($crlf));
     // parse headers
     $headers = array();
     $lines = explode($crlf, $header);
     foreach ($lines as $line) {
         if (($pos = strpos($line, ':')) !== false) {
             $headers[strtolower(trim(substr($line, 0, $pos)))] = trim(substr($line, $pos + 1));
         }
     }
     // redirection?
     if (isset($headers['location'])) {
         $http = new HTTPRequest($headers['location']);
         return $http->DownloadToString($http);
     } else {
         return $body;
     }
 }
コード例 #2
0
 /**
  * @param HTTPRequest $request
  * @return bool
  */
 public function userIsAdmin(HTTPRequest $request)
 {
     $user = $request->getCurrentUser();
     $forge_user_manager = new User_ForgeUserGroupPermissionsManager(new User_ForgeUserGroupPermissionsDao());
     $has_special_permission = $forge_user_manager->doesUserHavePermission($user, new User_ForgeUserGroupPermission_MediawikiAdminAllProjects());
     return $has_special_permission || $user->isMember($request->getProject()->getID(), 'A');
 }
コード例 #3
0
 public function retrieve_user_details()
 {
     // Get the stream to the user page via the Snipt API
     $request = new HTTPRequest(SNIPT_API . SNIPT_USER . SNIPT_FORMAT, HTTP_METH_GET);
     echo "Connecting to Snipt API....\n";
     $request->send();
     if ($request->getResponseCode() == 200) {
         $this->user_details = json_decode($request->getResponseBody());
         echo "Snipt entries to retrieve : {$this->user_details->count}\n";
         foreach ($this->user_details->snipts as $snipt) {
             // Retrieve the snipt entry
             $request = new HTTPRequest(SNIPT_API . SNIPT_SNIPT . $snipt . "." . SNIPT_FORMAT . SNIPT_STYLE);
             $request->send();
             if ($request->getResponseCode() == 200) {
                 $this->snipts[$snipt] = json_decode($request->getResponseBody());
             } else {
                 echo "[ERROR] Could not retrieve the data for snipt entry {$snipt}\n";
             }
         }
         return true;
     } else {
         echo "Invalid data received, exiting....\n";
         return false;
     }
 }
コード例 #4
0
 /**
  * Process date reminder requests
  *
  * @param TrackerManager $trackerManager
  * @param HTTPRequest    $request
  * @param PFUser           $currentUser
  *
  * @return Void
  */
 public function processReminder(TrackerManager $trackerManager, HTTPRequest $request, $currentUser)
 {
     $action = $request->get('action');
     $do_redirect = false;
     $feedback = false;
     try {
         if ($request->get('submit') && $action == 'new_reminder') {
             $this->getDateReminderRenderer()->getDateReminderFactory()->addNewReminder($request);
             $feedback = 'tracker_date_reminder_added';
             $do_redirect = true;
         } elseif ($request->get('submit') && $action == 'update_reminder') {
             $this->getDateReminderRenderer()->getDateReminderFactory()->editTrackerReminder($request);
             $feedback = 'tracker_date_reminder_updated';
             $do_redirect = true;
         } elseif ($request->get('confirm_delete') && $action == 'confirm_delete_reminder') {
             $this->getDateReminderRenderer()->getDateReminderFactory()->deleteTrackerReminder($request->get('reminder_id'));
             $feedback = 'tracker_date_reminder_deleted';
         }
         if ($feedback) {
             $GLOBALS['Response']->addFeedback('info', $GLOBALS['Language']->getText('plugin_tracker_date_reminder', $feedback));
         }
     } catch (Tracker_DateReminderException $e) {
         $GLOBALS['Response']->addFeedback('error', $e->getMessage());
     }
     if ($do_redirect || $request->get('cancel_delete_reminder')) {
         $GLOBALS['Response']->redirect(TRACKER_BASE_URL . '/?func=admin-notifications&tracker=' . $this->getTracker()->getId());
     }
 }
コード例 #5
0
ファイル: RawData.php プロジェクト: na2axl/FlatOS
 public function __construct($path = NULL)
 {
     $this->FS = new FS();
     $this->httpResponse = new HTTPResponse();
     $this->httpRequest = new HTTPRequest();
     $this->path = isset($path) ? $path : ($this->httpRequest->getExists('path') ? $this->httpRequest->getData('path') : NULL);
 }
コード例 #6
0
    protected static function submit()
    {
        $id = $_GET['item'];
        $item = Items::get_instance()->get_item($id);
        if (false === $item) {
            throw new Exception(_r('Invalid item ID specified', 'instapaper'));
        }
        $user = get_option('instapaper_user');
        if (empty($user)) {
            throw new Exception(sprintf(_r('Please set your username and password in the <a href="%s">settings</a>.', 'instapaper'), get_option('baseurl') . 'admin/settings.php'));
        }
        if (!check_nonce('instapaper-submit', $_GET['_nonce'])) {
            throw new Exception(_r('Nonces did not match. Try again.', 'instapaper'));
        }
        $data = array('username' => get_option('instapaper_user', ''), 'password' => get_option('instapaper_pass', ''), 'url' => $item->permalink, 'title' => apply_filters('the_title', $item->title));
        $request = new HTTPRequest('', 2);
        $response = $request->post("https://www.instapaper.com/api/add", array(), $data);
        switch ($response->status_code) {
            case 400:
                throw new Exception(_r('Internal error. Please report this.', 'instapaper'));
            case 403:
                throw new Exception(sprintf(_r('Invalid username/password. Please check your details in the <a href="%s">settings</a>.', 'instapaper'), get_option('baseurl') . 'admin/settings.php'));
            case 500:
                throw new Exception(_r('An error occurred when contacting Instapaper. Please try again later.', 'instapaper'));
        }
        Instapaper::page_head();
        ?>
		<div id="message">
			<h1><?php 
        _e('Success!');
        ?>
</h1>
			<p class="sidenote"><?php 
        _e('Closing window in...', 'instapaper');
        ?>
</p>
			<p class="sidenote" id="counter">3</p>
		</div>
		<script>
			$(document).ready(function () {
				setInterval(countdown, 1000);
			});

			function countdown() {
				if(timer > 0) {
					$('#counter').text(timer);
					timer--;
				}
				else {
					self.close();
				}
			}

			var timer = 2;
		</script>
	<?php 
        Instapaper::page_foot();
        die;
    }
コード例 #7
0
 function getPostData()
 {
     $var = new HTTPRequest();
     $username = $var->get('username');
     $password = $var->get('password');
     //$option=$var->get('option');
     $this->check($username, $password);
 }
コード例 #8
0
 public function executeAnnounceList(HTTPRequest $request)
 {
     $announceId = htmlspecialchars($request->getData('announceId'));
     $listOfFeedbacks = $this->_feedbacksManager->getByAnnounceId($announceId);
     $this->page->smarty()->assign('listOfFeedbacks', $listOfFeedbacks);
     $this->page->smarty()->assign('profilesManager', $this->_profilesManager);
     $this->page->smarty()->assign('usersManager', $this->_usersManager);
 }
コード例 #9
0
	/**
	 * Faz a requisição no webservice
	 * @return	string XML de retorno
	 */
	public function call() {
		$this->httpRequester->open( $this->url );

		$this->requestXML = $this->createXMLNode();
		$this->responseXML = $this->httpRequester->execute( array( 'mensagem' => $this->requestXML ) , HTTPRequestMethod::POST );

		return $this->responseXML;
	}
コード例 #10
0
 function getPostData()
 {
     $var = new HTTPRequest();
     $user_id = $var->get('user_id');
     //var_dump($user_id);
     //$password=$var->get('password');
     //$option=$var->get('option');
     $this->vehicleDetails($user_id);
 }
コード例 #11
0
 protected function response($data)
 {
     $request = new HTTPRequest($this->gateway->getHost(), $this->endpoint, 'POST', true);
     $result = $request->connect($data);
     if ($result < 400) {
         return $request;
     }
     return false;
 }
コード例 #12
0
ファイル: svnPlugin.class.php プロジェクト: blestab/tuleap
 public function process(HTTPRequest $request)
 {
     if (!PluginManager::instance()->isPluginAllowedForProject($this, $request->getProject()->getId())) {
         $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('plugin_svn_manage_repository', 'plugin_not_activated'));
         $GLOBALS['Response']->redirect('/projects/' . $request->getProject()->getUnixNameMixedCase() . '/');
     } else {
         $this->getRouter()->route($request);
     }
 }
コード例 #13
0
 public function executeDelete(HTTPRequest $request)
 {
     $id = $request->getData('carrouselId');
     $carrousel = $this->_carrouselsManager->get($id);
     $announceId = $carrousel->getAnnounceId();
     $this->_carrouselsManager->delete($id);
     $this->app->httpResponse()->redirect('/view/member/announce-' . $announceId);
     exit;
 }
コード例 #14
0
ファイル: paypal.php プロジェクト: craighays/nsfhp
 /**
  * @return HTTPRequest
  */
 private function response($data)
 {
     $r = new HTTPRequest($this->host, $this->endpoint, 'POST', true);
     $result = $r->connect($data);
     if ($result < 400) {
         return $r;
     }
     return false;
 }
コード例 #15
0
 public function settheme(HTTPRequest $request)
 {
     $newTheme = $request->param("ID");
     $newTheme = Convert::raw2sql($newTheme);
     DB::query("Update SiteConfig SET Theme = '{$newTheme}';");
     Session::set("theme", $newTheme);
     SSViewer::flush_template_cache();
     $this->redirect($this->Link());
 }
コード例 #16
0
 function httpTestAction()
 {
     YuppLoader::load('core.http', 'HTTPRequest');
     $url = 'http://www.imdb.com/find?s=all';
     $req = new HTTPRequest();
     $req->setTimeOut(5);
     $res = $req->HTTPRequestPost($url, array('q' => 'The+Matrix'));
     return $this->renderString($res->getBody());
 }
コード例 #17
0
function WPMediaFeed_content_filter($content)
{
    $url = "";
    $delimiter = "";
    $start = 0;
    $mode = "";
    $dest_url = "";
    //Some validation and filtering
    if (strpos($content, "[WPMediaFeed-Youtube]") !== false) {
        $content = str_replace("[WPMediaFeed-Youtube]", "", $content);
        $url = get_option('WPMediaFeed-Youtube-Channel');
        $delimiter = "watch?v=";
        $start = 1;
        //For YT, skip the first record. It's garbage.
        $dest_url = "http://www.youtube.com/watch?v=";
        $mode = "youtube";
    } else {
        if (strpos($content, "[WPMediaFeed-Soundcloud]") !== false) {
            $content = str_replace("[WPMediaFeed-Soundcloud]", "", $content);
            $url = get_option('WPMediaFeed-Soundcloud-Channel');
            $delimiter = '<a class="sound__coverArt" href="';
            $dest_url = "https://w.soundcloud.com/player/?url=" . $url;
            $mode = "soundcloud";
        } else {
            //Only get the feed if the shortcode is present.
            return $content;
        }
    }
    if (!$url || $url == "") {
        return $content;
    }
    //Download the channel HTML
    require_once dirname(__FILE__) . '/HTTPRequest.class.php';
    $req = new HTTPRequest($url);
    $html = $req->DownloadToString();
    //Next, parse it to get the media IDs
    $mediaParts = explode($delimiter, $html);
    $mediaIds = array();
    //skip the first one - it's bogus
    for ($i = $start; $i < sizeof($mediaParts); $i++) {
        $part = $mediaParts[$i];
        $mediaId = strstr($part, "\"", true);
        //echo "VideoId: $videoId , length: " . strlen($videoId) . "<br>";
        //Youtube videoIds should always be 11 chars long, but let's keep it open for future compatibility
        if ($mode == "youtube" && strlen($mediaId) > 10 || $mode == "soundcloud") {
            if (!in_array($mediaId, $mediaIds)) {
                array_push($mediaIds, $mediaId);
            }
        }
    }
    //Finally, output the embed links to the unique videos
    foreach ($mediaIds as $mediaId) {
        $content .= '[embed]' . $dest_url . $mediaId . '[/embed]';
    }
    return $content;
}
コード例 #18
0
 public function displayHeader(HTTPRequest $request, $title)
 {
     $toolbar = array();
     if ($this->userIsAdmin($request->getCurrentUser())) {
         $toolbar[] = array('title' => $GLOBALS['Language']->getText('global', 'Administration'), 'url' => MEDIAWIKI_BASE_URL . '/forge_admin?' . http_build_query(array('group_id' => $request->get('group_id'))));
     }
     $title = $title . ' - ' . $GLOBALS['Language']->getText('plugin_mediawiki', 'service_lbl_key');
     $breadcrumbs = array();
     parent::displayHeader($title, $breadcrumbs, $toolbar);
 }
コード例 #19
0
ファイル: Syndication.php プロジェクト: webhacking/Textcube
 public static function leave($link)
 {
     return false;
     $link = trim($link);
     if (empty($link)) {
         return false;
     }
     $request = new HTTPRequest('POST', TEXTCUBE_SYNC_URL);
     $request->contentType = 'application/x-www-form-urlencoded; charset=utf-8';
     return $request->send("mode=0&path=" . urlencode($link)) && checkResponseXML($request->responseText) === 0;
 }
コード例 #20
0
ファイル: cron.php プロジェクト: Avantians/Textcube
function checkCronJob()
{
    $context = Model_Context::getInstance();
    /* Cron, only in single page request, not in a page dead link */
    if (!empty($_SERVER['HTTP_REFERER']) || !dumbCronScheduler(true)) {
        return;
    }
    $request = new HTTPRequest('GET', $context->getProperty('uri.default') . '/cron');
    $request->timeout = 2;
    $request->send();
}
コード例 #21
0
 /**
  * Action to render results for an autocomplete filter.
  *
  * @param HTTPRequest $request
  * @return void
  */
 function filter($request)
 {
     //$model = singleton($this->modelClass);
     $context = $this->dataObject->getDefaultSearchContext();
     $value = $request->getVar('q');
     $results = $context->getResults(array("Name" => $value));
     header("Content-Type: text/plain");
     foreach ($results as $result) {
         echo $result->Name . "\n";
     }
 }
コード例 #22
0
ファイル: tractis_identity.php プロジェクト: AgoraUS1516/G03
 function check_auth_response($params = array())
 {
     $httpclient = new HTTPRequest($this->check_url);
     // Add Api key to response
     $params['api_key'] = $this->api_key;
     $res = $httpclient->Post($params, true);
     if ($res['http']['code'] == 200 && $res['body'] == $params['verification_code']) {
         return true;
     } else {
         return false;
     }
 }
コード例 #23
0
 public function executeCancel(HTTPRequest $request)
 {
     $reservationid = $request->getData('reservationId');
     $reservation = $this->_reservationsManager->get($reservationid);
     if ($this->app->httpRequest()->postExists('submit-form')) {
         $reservation->setStateId(PaiementStates::CANCELED);
         $reservation->setUpdatedTime(time());
         $this->_reservationsManager->save($reservation);
         $this->app->httpResponse()->redirect('/admin/history');
         exit;
     }
     $this->page->smarty()->assign('reservation', $reservation);
 }
コード例 #24
0
 private function parseForm(HTTPRequest $request, Category $category)
 {
     $name = htmlspecialchars($request->postData('name'));
     $description = htmlspecialchars($request->postData('description'));
     $isRoot = !$request->postExists('parent-category');
     $category->setName($name);
     $category->setIsRoot($isRoot);
     $category->setDescription($description);
     if (!$isRoot) {
         $parentCategoryId = $request->postData('parent-category');
         $category->setParentCategoryId($parentCategoryId);
     }
 }
コード例 #25
0
 public function route(HTTPRequest $request, Layout $response)
 {
     $valid_route = new Valid_WhiteList('func', $this->routes);
     $valid_route->required();
     if ($request->valid($valid_route)) {
         $route = $request->get('func');
         $controller = new OpenId_LoginController($this->logger, new OpenId_AccountManager(new Openid_Dao(), UserManager::instance()), $request, $response);
         $controller->{$route}();
     } else {
         $response->addFeedback(Feedback::ERROR, 'Invalid request for ' . __CLASS__);
         $response->redirect('/');
     }
 }
コード例 #26
0
 public function executeRefuse(HTTPRequest $request)
 {
     $announce = $this->_announcementsManager->get($request->getData('announceId'));
     $this->page->smarty()->assign('announce', $announce);
     if ($request->postExists('confirm')) {
         $announce->setStateId(AnnouncementStates::STATE_REFUSED);
         $announce->setAdminComment(htmlspecialchars($request->postData('admin-comment')));
         $this->_announcementsManager->save($announce);
         $this->app->user()->setFlash('announce-refused');
         //TODO : Envoyer un mail à l'utilistateur
         $this->app->httpResponse()->redirect('/admin/announcements');
         exit;
     }
 }
コード例 #27
0
 public function updateProject(HTTPRequest $request)
 {
     $token = new CSRFSynchronizerToken('/admin/svn/svn_tokens.php?action=update_project');
     $token->check();
     $project_to_add = $request->get('project-to-allow');
     if ($request->get('allow-project') && !empty($project_to_add)) {
         $this->allowSVNTokensForProject($project_to_add);
     }
     $project_ids_to_remove = $request->get('project-ids-to-revoke');
     if ($request->get('revoke-project') && !empty($project_ids_to_remove)) {
         $this->revokeProjectsAuthorization($project_ids_to_remove);
     }
     $GLOBALS['Response']->redirect('/admin/svn/svn_tokens.php?action=index');
 }
コード例 #28
0
ファイル: update-functions.php プロジェクト: rmccue/Lilina
/**
 * Checks to see if a new version of Lilina is available
 * @author WordPress
 */
function lilina_version_check()
{
    if (strpos($_SERVER['REQUEST_URI'], 'install.php') !== false || defined('LILINA_INSTALLING') || !is_admin()) {
        return;
    }
    $lilina_version = LILINA_CORE_VERSION;
    $php_version = phpversion();
    // We need this for unique identification of installations, but we take the hash of it
    $id = sha1(get_option('baseurl'));
    $data = new DataHandler();
    $current = $data->load('core-update-check.data');
    if ($current !== null) {
        $current = unserialize($current);
    }
    $locale = get_option('locale');
    if (isset($current->last_checked) && 43200 > time() - $current->last_checked && $current->version_checked == $lilina_version) {
        return false;
    }
    $new_option = '';
    $new_option->last_checked = time();
    // this gets set whether we get a response or not, so if something is down or misconfigured it won't delay the page load for more than 3 seconds, twice a day
    $new_option->version_checked = $lilina_version;
    try {
        $headers = apply_filters('update_http_headers', array('X-Install-ID' => $id));
        $request = new HTTPRequest('', 2);
        $response = $request->get("http://api.getlilina.org/core/version-check/1.2/?version={$lilina_version}&php={$php_version}&locale={$locale}", $headers);
    } catch (Exception $e) {
        $response = (object) array('success' => false);
    }
    if (!$response->success) {
        // Save it anyway
        $data->save('core-update-check.data', serialize($new_option));
        return false;
    }
    $body = trim($response->body);
    $body = str_replace(array("\r\n", "\r"), "\n", $body);
    $returns = explode("\n", $body);
    $new_option->response = $returns[0];
    if (isset($returns[1])) {
        $new_option->url = $returns[1];
    }
    if (isset($returns[2])) {
        $new_option->download = $returns[2];
    }
    if (isset($returns[3])) {
        $new_option->version = $returns[3];
    }
    $data->save('core-update-check.data', serialize($new_option));
    return $new_option;
}
コード例 #29
0
 public function executePublish(HTTPRequest $request)
 {
     $opinionId = $request->getData('opinionId');
     $opinion = $this->_opinionsManager->get($opinionId);
     if ($request->postExists('submit-form')) {
         $opinion->setIsPublished(true);
         $this->_opinionsManager->save($opinion);
         $this->app->user()->setFlash('opinion-published');
         $this->app->httpResponse()->redirect('/admin/opinion');
         exit;
     }
     $this->page->smarty()->assign('opinion', $opinion);
     $this->page->smarty()->assign('opinionsManager', $this->_opinionsManager);
     $this->page->smarty()->assign('usersManager', $this->_usersManager);
 }
コード例 #30
0
 public function decode($point = array('lat' => null, 'lng' => null))
 {
     $uri = 'http://apis.map.qq.com/ws/geocoder/v1?location=' . $point['lat'] . ',' . $point['lng'] . '&output=json&key=' . $this->conf['key'];
     $http = new \HTTPRequest($uri, HTTP_METH_GET);
     $http->send();
     $code = $http->getResponseCode();
     if ($code != 200) {
         throw new Exception('http error', $code);
     }
     $r = json_decode($http->getResponseBody(), true);
     if (!isset($r['result']['address'])) {
         throw new Exception($r['message'], $r['status']);
     }
     return array('address' => $r['result']['address']);
 }