예제 #1
0
 /**
  * Sets the URL for this request
  *
  * If the URL has userinfo part (username & password) these will be removed
  * and converted to auth data. If the URL does not have a path component,
  * that will be set to '/'.
  *
  * @param string|Net_URL2 $url Request URL
  *
  * @return   HTTP_Request2
  * @throws   HTTP_Request2_LogicException
  */
 public function setUrl($url)
 {
     if (is_string($url)) {
         $url = new Net_URL2($url, array(Net_URL2::OPTION_USE_BRACKETS => $this->config['use_brackets']));
     }
     if (!$url instanceof Net_URL2) {
         throw new HTTP_Request2_LogicException('Parameter is not a valid HTTP URL', HTTP_Request2_Exception::INVALID_ARGUMENT);
     }
     // URL contains username / password?
     if ($url->getUserinfo()) {
         $username = $url->getUser();
         $password = $url->getPassword();
         $this->setAuth(rawurldecode($username), $password ? rawurldecode($password) : '');
         $url->setUserinfo('');
     }
     if ('' == $url->getPath()) {
         $url->setPath('/');
     }
     $this->url = $url;
     return $this;
 }
예제 #2
0
 /**
  * Appends url path.
  * 
  * @param string $urlPath url path to append.
  * 
  * @return none.
  */
 public function appendUrlPath($urlPath)
 {
     Validate::isString($urlPath, 'urlPath');
     $newUrlPath = parse_url($this->_url, PHP_URL_PATH) . $urlPath;
     $this->_url->setPath($newUrlPath);
 }
예제 #3
0
 /**
  * Sets the URL for this request
  *
  * If the URL has userinfo part (username & password) these will be removed
  * and converted to auth data. If the URL does not have a path component,
  * that will be set to '/'.
  *
  * @param    string|Net_URL2 Request URL
  * @return   HTTP_Request2
  * @throws   HTTP_Request2_Exception
  */
 public function setUrl($url)
 {
     if (is_string($url)) {
         $url = new Net_URL2($url);
     }
     if (!$url instanceof Net_URL2) {
         throw new HTTP_Request2_Exception('Parameter is not a valid HTTP URL');
     }
     // URL contains username / password?
     if ($url->getUserinfo()) {
         $username = $url->getUser();
         $password = $url->getPassword();
         $this->setAuth(rawurldecode($username), $password ? rawurldecode($password) : '');
         $url->setUserinfo('');
     }
     if ('' == $url->getPath()) {
         $url->setPath('/');
     }
     $this->url = $url;
     return $this;
 }
예제 #4
0
파일: edit.php 프로젝트: stof/pearweb
$project_link->setLabel("Project Homepage");
$project_link->addFilter("htmlspecialchars");
$project_link->addRule('required', "Please enter your project link");
$is_active = $form->addElement("checkbox", 'is_active', array('checked' => $channel["is_active"] ? 'checked' : ''));
$is_active->setLabel("Active?");
$form->addElement("submit");
if ($form->validate()) {
    $url = new Net_URL2($project_name->getValue());
    try {
        $req = new HTTP_Request2();
        $dir = explode("/", $url->getPath());
        if (!empty($dir)) {
            array_pop($dir);
        }
        $dir[] = 'channel.xml';
        $url->setPath(implode("/", $dir));
        $req->setURL($url->getURL());
        channel::validate($req, $chan);
        channel::edit($channel['name'], $project_label->getValue(), $project_link->getValue(), $contact_name->getValue(), $contact_email->getValue());
        if ($is_active->getValue()) {
            channel::activate($channel['name']);
        } else {
            channel::deactivate($channel['name']);
        }
        echo "<div class=\"success\">Changes saved</div>\n";
    } catch (Exception $exception) {
        echo '<div class="errors">';
        switch ($exception->getMessage()) {
            case "Invalid channel site":
            case "Empty channel.xml":
                echo "The submitted URL does not ";
예제 #5
0
 /**
  * This is a regression test to test that setting "0" as path
  * does not break normalize().
  *
  * It was reported as Bug #20157 on 2013-12-27 23:42 UTC that
  * normalize() with "0" as path would not work.
  *
  * @covers Net_URL2::normalize
  * @return void
  */
 public function test20157()
 {
     $subject = 'http://example.com';
     $url = new Net_URL2($subject);
     $url->setPath('0');
     $url->normalize();
     $this->assertSame("{$subject}/0", (string) $url);
 }