public function __construct($sTumblrID = null,$sHTTPUserAgent = 'phpTumblr') {
		if ($sTumblrID == null) { unset($this); return false; }

		$this->sTumblrID = $sTumblrID;
		$sTumblrURL = $sTumblrID.'.tumblr.com';
		
		$oNetHttp = &$this->oNetHttp;
		$oNetHttp = new netHttp($sTumblrURL);
		$oNetHttp->setUserAgent($sHTTPUserAgent);
		$oNetHttp->get('/');
		if ($oNetHttp->getStatus() != 200) { unset($this); return false; }
		
		$this->__getTumblelogInfos();
		
		return true;
	}
 public function isSpam($type, $author, $email, $site, $ip, $content, $post_id, &$status)
 {
     if ($type != 'trackback') {
         return;
     }
     try {
         $default_parse = array('scheme' => '', 'host' => '', 'path' => '', 'query' => '');
         $S = array_merge($default_parse, parse_url($site));
         if ($S['scheme'] != 'http' || !$S['host'] || !$S['path']) {
             throw new Exception('Invalid URL');
         }
         # Check incomink link page
         $post = $this->core->blog->getPosts(array('post_id' => $post_id));
         $post_url = $post->getURL();
         $P = array_merge($default_parse, parse_url($post_url));
         if ($post_url == $site) {
             throw new Exception('Same source and destination');
         }
         $o = netHttp::initClient($site, $path);
         $o->setTimeout(3);
         $o->get($path);
         # Trackback source does not return 200 status code
         if ($o->getStatus() != 200) {
             throw new Exception('Invalid Status Code');
         }
         $tb_page = $o->getContent();
         # Do we find a link to post in trackback source?
         if ($S['host'] == $P['host']) {
             $pattern = $P['path'] . ($P['query'] ? '?' . $P['query'] : '');
         } else {
             $pattern = $post_url;
         }
         $pattern = preg_quote($pattern, '/');
         if (!preg_match('/' . $pattern . '/', $tb_page)) {
             throw new Exception('Unfair');
         }
     } catch (Exception $e) {
         throw new Exception('Trackback not allowed for this URL.');
     }
 }
 public function download($url, $zip_file)
 {
     $this->zip_file = $zip_file;
     // Check and add default protocol if necessary
     if (!preg_match('%^http[s]?:\\/\\/%', $url)) {
         $url = 'http://' . $url;
     }
     // Download package
     if ($client = netHttp::initClient($url, $path)) {
         try {
             $client->setUserAgent('DotClear.org CKEditorBrowser/0.1');
             $client->useGzip(false);
             $client->setPersistReferers(false);
             $client->setOutput($this->zip_file);
             $client->get($path);
             unset($client);
         } catch (Exception $e) {
             unset($client);
             throw new Exception(__('An error occurred while downloading the file.'));
         }
     } else {
         throw new Exception(__('An error occurred while downloading the file.'));
     }
 }
Example #4
0
 /**
  * Downloads new version to destination $sDest.
  *
  * @param string $sDest
  * @throws Exception
  */
 public function download($sDest)
 {
     $sUrl = $this->getFileURL();
     if (!$sUrl) {
         throw new Exception(__('c_a_update_no_file_to_download'));
     }
     if (!is_writable(dirname($sDest))) {
         throw new Exception(__('c_a_update_root_directory_not_writable'));
     }
     try {
         $oClient = netHttp::initClient($sUrl, $sPath);
         $oClient->setTimeout(4);
         $oClient->setUserAgent($_SERVER['HTTP_USER_AGENT']);
         $oClient->useGzip(false);
         $oClient->setPersistReferers(false);
         $oClient->setOutput($sDest);
         $oClient->get($sPath);
         if ($oClient->getStatus() != 200) {
             @unlink($sDest);
             throw new Exception();
         }
     } catch (Exception $e) {
         throw new Exception(__('c_a_update_error_occurred_while_downloading'));
     }
 }
Example #5
0
 public static function dotwitWidget(&$w)
 {
     global $core;
     $cache_file = self::$path_cache . 'dotwit_' . md5($w->idTwitter . $w->timeline_friends);
     //Affichage page d'accueil seulement
     if ($w->homeonly && $core->url->type != 'default') {
         return;
     }
     try {
         $host = 'twitter.com';
         if ($w->timeline_friends) {
             $url = 'http://twitter.com/statuses/friends_timeline/' . $w->idTwitter . '.xml';
             //$path = '/statuses/friends_timeline/'.$w->idTwitter.'.xml';
         } else {
             $url = 'http://twitter.com/statuses/user_timeline/' . $w->idTwitter . '.xml';
             //$path = '/statuses/user_timeline/'.$w->idTwitter.'.xml';
         }
         if (@filemtime($cache_file) < time() - 60 * 15) {
             $oHttp = new netHttp('');
             $oHttp->readURL($url, $ssl, $host, $port, $path, $user, $pass);
             $oHttp->setHost($host, $port);
             //$oHttp->useSSL($ssl);
             $user = $w->idTwitter;
             $pass = $w->pwdTwitter;
             $oHttp->setAuthorization($user, $pass);
             $oHttp->get($path);
             $xml_file = $oHttp->getContent();
             if ($xml = @simplexml_load_string($xml_file)) {
                 if ($xml->error == '' && ($fp = @fopen($cache_file, 'wb'))) {
                     fwrite($fp, $xml_file);
                     fclose($fp);
                 }
             } else {
                 $xml = @simplexml_load_string(@file_get_contents($cache_file));
             }
         } elseif (file_exists($cache_file)) {
             $xml = @simplexml_load_string(@file_get_contents($cache_file));
         }
     } catch (Exception $e) {
     }
     $res = '<div id="doTwit">' . ($w->title ? '<h2><a href="http://twitter.com/' . $w->idTwiter . '">' . $w->title . '</a></h2>' : '') . '<ul>';
     $nb = 0;
     if (count($xml->status) == 0) {
         $res .= 'Données indisponible sur Twitter !';
         return $res;
     }
     foreach ($xml->status as $elm) {
         $twi['id'][$nb] = (int) $elm->id;
         $twi['desc'][$nb] = eregi_replace("(http|mailto|news|ftp|https)://(([-éa-z0-9\\/\\.\\?_=#@:~])*)", "<a href=\"\\1://\\2\" target=\"_blank\">\\1://\\2</a>", $elm->text);
         $twi['screen_name'][$nb] = (string) $elm->user->screen_name;
         $twi['name'][$nb] = (string) $elm->user->name;
         $twi['location'][$nb] = (string) $elm->user->location;
         if ($w->display_profil_image) {
             $twi['img'][$nb] = eregi_replace("_normal.", "_mini.", $elm->user->profile_image_url);
         }
         if ($w->display_timeout) {
             $twi['time'][$nb] = (int) strtotime($elm->created_at);
             $twi['date'][$nb] = date('d F Y, H:i', $twi['time'][$nb]);
             $twi['desc'][$nb] .= ' <a class="date" href="http://twitter.com/' . $twi['screen_name'][$nb] . '/statuses/' . $twi['id'][$nb] . '" target="_blank"> ' . $twi['date'][$nb] . '</a>';
         }
         $nb++;
         if ($nb >= $w->limit) {
             break;
         }
     }
     for ($i = 0; $i < $nb; $i++) {
         if ($w->display_profil_image && $twi['img'][$i] != '') {
             $res .= '<li>';
             $res .= '<span class="twitter-username">';
             $res .= '<a href="http://twitter.com/' . $twi['screen_name'][$i] . '" target="_blank" title="' . $twi['name'][$i] . ' (' . $twi['location'][$i] . ')">';
             $res .= '<img src="' . $twi['img'][$i] . '" alt="' . $twi['name'][$i] . '" />';
             $res .= $twi['screen_name'][$i] . '</a>';
             $res .= '</span>';
             $res .= '<span class="twitter-content">';
             $res .= $twi['desc'][$i];
             $res .= '</span>';
             $res .= '</li>';
         } else {
             $res .= '<li>';
             $res .= '<span class="twitter-username">';
             $res .= '<a href="http://twitter.com/' . $twi['screen_name'][$i] . '" target="_blank" title="' . $twi['name'][$i] . ' (' . $twi['location'][$i] . ')">';
             $res .= $twi['screen_name'][$i];
             $res .= '</a></span><span class="twitter-content">' . $twi['desc'][$i] . '</span>';
             $res .= '</li>';
         }
     }
     $res .= '</ul></div>';
     self::clean_cache();
     return $res;
 }
Example #6
0
    } catch (Exception $e) {
        $core->error->add($e->getMessage());
    }
}
# Download a language pack
if ($is_writable && !empty($_POST['pkg_url'])) {
    try {
        if (empty($_POST['your_pwd']) || !$core->auth->checkPassword(crypt::hmac(DC_MASTER_KEY, $_POST['your_pwd']))) {
            throw new Exception(__('Password verification failed'));
        }
        $url = html::escapeHTML($_POST['pkg_url']);
        $dest = DC_L10N_ROOT . '/' . basename($url);
        if (!preg_match('#^http://[^.]+\\.dotclear\\.net/.*\\.zip$#', $url)) {
            throw new Exception(__('Invalid language file URL.'));
        }
        $client = netHttp::initClient($url, $path);
        $client->setUserAgent('Dotclear - http://www.dotclear.org/');
        $client->useGzip(false);
        $client->setPersistReferers(false);
        $client->setOutput($dest);
        $client->get($path);
        try {
            $ret_code = dc_lang_install($dest);
        } catch (Exception $e) {
            @unlink($dest);
            throw $e;
        }
        @unlink($dest);
        http::redirect('langs.php?added=' . $ret_code);
    } catch (Exception $e) {
        $core->error->add($e->getMessage());
Example #7
0
 /**
  * Build request
  *
  * Adds HTTP cache headers to common headers.
  * 
  * {@inheritdoc}
  */
 protected function buildRequest()
 {
     $headers = parent::buildRequest();
     # Cache validators
     if (!empty($this->validators)) {
         if (isset($this->validators['IfModifiedSince'])) {
             $headers[] = 'If-Modified-Since: ' . $this->validators['IfModifiedSince'];
         }
         if (isset($this->validators['IfNoneMatch'])) {
             if (is_array($this->validators['IfNoneMatch'])) {
                 $etags = implode(',', $this->validators['IfNoneMatch']);
             } else {
                 $etags = $this->validators['IfNoneMatch'];
             }
             $headers[] = '';
         }
     }
     return $headers;
 }
 public function __construct($blog_url, $api_key)
 {
     $this->blog_url = $blog_url;
     $this->ak_key = $api_key;
     $this->ak_path = sprintf($this->ak_path, $this->ak_version, '%s');
     $this->ak_host = $this->ak_key . '.' . $this->base_host;
     parent::__construct($this->ak_host, 80);
 }
Example #9
0
 /**
  * Constructor
  *
  * Creates a new instance. <var>$url</var> is the XML-RPC Server end point.
  *
  * @param string		$url			Service URL
  */
 public function __construct($url)
 {
     if (!$this->readUrl($url, $ssl, $host, $port, $path, $user, $pass)) {
         return false;
     }
     parent::__construct($host, $port);
     $this->useSSL($ssl);
     $this->setAuthorization($user, $pass);
     $this->path = $path;
     $this->user_agent = 'Clearbricks XML/RPC Client';
 }
Example #10
0
 /**
  * Retourne les informations d'un dépôt de themes donné.
  *
  * @param array $repository_url
  * @return array
  */
 protected function getRepositoryInfos($repository_url)
 {
     try {
         $repository_url = str_replace('%VERSION%', util::getVersion(), $repository_url);
         $path = '';
         $client = netHttp::initClient($repository_url, $path);
         if ($client !== false) {
             $client->setTimeout(4);
             $client->setUserAgent($_SERVER['HTTP_USER_AGENT']);
             $client->get($path);
             return $this->readRepositoryInfos($client->getContent());
         }
     } catch (Exception $e) {
         return false;
     }
 }
Example #11
0
 private static function initHttp($url, &$path)
 {
     $client = netHttp::initClient($url, $path);
     $client->setTimeout(5);
     $client->setUserAgent('Dotclear - http://www.dotclear.org/');
     $client->useGzip(false);
     $client->setPersistReferers(false);
     return $client;
 }
Example #12
0
             $m_title = $M[1];
         }
         if ($movie) {
             $m_object = '<object type="application/x-shockwave-flash" data="' . $movie . '" width="425" height="350">' . "\n" . '  <param name="movie" value="' . $movie . '" />' . "\n" . '  <param name="wmode" value="transparent" />' . "\n" . '</object>';
         }
     }
     break;
 case 'jamendo':
     if (preg_match('#^http://(www.)?jamendo.com/[a-z]{2}/(playlist|album|track)/([0-9]+)#', $media_page, $m)) {
         $type = $m[2];
         $id = $m[3];
         $req = 'name';
         if ($type == 'track') {
             $req .= '+stream';
         }
         $http = netHttp::initClient('http://api.jamendo.com/get2/' . $req . '/' . $type . '/plain/?streamencoding=mp31&id=' . $id, $media_path);
         $http->setTimeout(5);
         $http->setUserAgent($_SERVER['HTTP_USER_AGENT']);
         $http->get($media_path);
         if ($http->getStatus() != 200) {
             throw new Exception(__('Invalid page URL'));
         }
         if ($type != 'track') {
             $m_title = $http->getContent();
             $m_object = '<object width="200" height="300" type="application/x-shockwave-flash"' . "\n" . 'data="http://widgets.jamendo.com/fr/' . $type . '/?playertype=2008&amp;' . $type . '_id=' . $id . '">' . "\n" . '</object>';
             $m_url = $media_page;
         } else {
             $t = explode("\t", $http->getContent());
             $m_title = $t[0];
             $url = $t[1];
             $m_object = dcMedia::mp3player($url, $core->blog->getQmarkURL() . 'pf=player_mp3.swf');
Example #13
0
 /**
 Downloads new version to destination $dest.
 */
 public function download($dest)
 {
     $url = $this->getFileURL();
     if (!$url) {
         throw new Exception(__('No file to download'));
     }
     if (!is_writable(dirname($dest))) {
         throw new Exception(__('Root directory is not writable.'));
     }
     try {
         $client = netHttp::initClient($url, $path);
         $client->setTimeout(4);
         $client->setUserAgent($_SERVER['HTTP_USER_AGENT']);
         $client->useGzip(false);
         $client->setPersistReferers(false);
         $client->setOutput($dest);
         $client->get($path);
         if ($client->getStatus() != 200) {
             @unlink($dest);
             throw new Exception();
         }
     } catch (Exception $e) {
         throw new Exception(__('An error occurred while downloading archive.'));
     }
 }
Example #14
0
     to allow admins to update other settings.
     Otherwise dcCore::getBlogCursor() throws an exception.
     */
     echo form::field('blog_id', 30, 32, html::escapeHTML($blog_id), '', '', false, 'hidden="hidden"');
     echo form::field('blog_url', 50, 255, html::escapeHTML($blog_url), '', '', false, 'hidden="hidden"');
 }
 echo '<p><label for="blog_name" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Blog name:') . '</label>' . form::field('blog_name', 30, 255, html::escapeHTML($blog_name)) . '</p>';
 if ($core->auth->isSuperAdmin()) {
     echo '<p><label for="blog_url" class="required"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Blog URL:') . '</label>' . form::field('blog_url', 50, 255, html::escapeHTML($blog_url)) . '</p>' . '<p><label for="url_scan">' . __('URL scan method:') . '</label>' . form::combo('url_scan', $url_scan_combo, $blog_settings->system->url_scan) . '</p>';
     try {
         # Test URL of blog by testing it's ATOM feed
         $file = $blog_url . $core->url->getURLFor('feed', 'atom');
         $path = '';
         $status = '404';
         $content = '';
         $client = netHttp::initClient($file, $path);
         if ($client !== false) {
             $client->setTimeout(4);
             $client->setUserAgent($_SERVER['HTTP_USER_AGENT']);
             $client->get($path);
             $status = $client->getStatus();
             $content = $client->getContent();
         }
         if ($status != '200') {
             // Might be 404 (URL not found), 670 (blog not online), ...
             echo '<p class="form-note warn">' . sprintf(__('The URL of blog or the URL scan method might not be well set (<code>%s</code> return a <strong>%s</strong> status).'), $file, $status) . '</p>';
         } else {
             if (substr($content, 0, 6) != '<?xml ') {
                 // Not well formed XML feed
                 echo '<p class="form-note warn">' . sprintf(__('The URL of blog or the URL scan method might not be well set (<code>%s</code> does not return an ATOM feed).'), $file) . '</p>';
             }
 /**
 Constructor, no parameters.
 */
 public function __construct()
 {
     parent::__construct($this->host, 80, $this->timeout);
 }