21
spiff
Re: Protector installation & Headlines module
  • 2005/1/12 20:18

  • spiff

  • Just popping in

  • Posts: 47

  • Since: 2003/4/16


Ate dinner, changed php.ini to enable allow_url_fopen, and xoopsheadline works again.

Until this conflict is resolved (not sure a blogroll can be implemented in php at all if allow_url_fopen is off), then I wager there should be a disclaimer in the Protector advisory page stating that any module accessing external urls will fail if allow_url_fopen is turned off (including the display of XOOPS News in the admin section).



22
spiff
Re: Protector installation & Headlines module
  • 2005/1/12 19:23

  • spiff

  • Just popping in

  • Posts: 47

  • Since: 2003/4/16


Ah well, isn't the answer in my question?

Setting allow_url_fopen to Off effectively disables access to urls for the headlines module if it uses file('some_url') to refresh its data, right?



23
spiff
Re: Protector installation & Headlines module
  • 2005/1/12 19:14

  • spiff

  • Just popping in

  • Posts: 47

  • Since: 2003/4/16


GIJOE, folks: I seem to be having an issue with the change I made last night.

Problem:
The headlines module fails to refresh feed data: the block gradually empties itself until nothing displays at all; main headlines page remains blank below the list of registered feeds.

Changes made:
- installed Protector 2.2
- turned off register_globals & allow_url_fopen in php.ini, restarted Apache

Two XOOPS sites have the same symptoms, so it would look as though this is reproductible.

I'll try to investigate later tonight as to why this happens, but some of you may already have figured out a workaround, or know the reasons behind the failure. Please share.



24
spiff
Re: Admin > mail users > image
  • 2005/1/11 18:26

  • spiff

  • Just popping in

  • Posts: 47

  • Since: 2003/4/16


Well, 2.0.1 is starting to get old... You really should consider upgrading Xoops, however painful that may be, if only for security reasons. Template changes will survive the upgrade, and language file changes can easily be backed up before the upgrade, then restored.

Have you tried XMail? I doubt it's compatible with 2.0.1, but you never know...

If that doesn't work either, you can try the following, but that's tested with 2.0.9.2 (latest version) and may not even work under 2.0.1...

(Keep a log of this change in your XOOPS log file, it will serve you as a check list for future upgrades).

Before anything, BACK UP the following files, under \modules\system\admin\mailusers\:
mailusers.php -> mailusers.php.old
mailform
.php -> mailform.php.old

To send in HTML format, in file \modules\system\admin\mailusers\mailusers.php, replace (around line 185):
$xoopsMailer->send(true);

with:
if (!empty($_POST['mail_format_html'])) {
  
$xoopsMailer->multimailer->IsHTML(true);
  
$body $myts->oopsStripSlashesGPC($_POST['mail_body']);
  
$body $myts->nl2br($body);
  
$xoopsMailer->setBody($body);
}
$xoopsMailer->send(true);

To have a checkbox appear in the form to let you choose between formats, in file \modules\system\admin\mailusers\mailform.php (around line 82), replace:
$body_text = new XoopsFormTextArea($body_caption"mail_body"""10);

with:
$body_text = new XoopsFormTextArea(''"mail_body"""10);
$html_cbox = new XoopsFormCheckBox(''"mail_format_html");
$html_cbox->addOption(1_AM_MAILHTML);
$body_tray = new XoopsFormElementTray($body_caption"<br /><br />");
$body_tray->addElement($body_text);
$body_tray->addElement($html_cbox);

And at the bottom of the same file, replace:
$form->addElement($body_text);

with:
$form->addElement($body_tray);

Now add the language tag in the language file (if you only use one language in your site, you can simply replace _AM_MAILHTML in the code above with 'Send as html'), in files /modules/system/language/ * /admin/mailusers.php:
define(_AM_MAILHTML,'Send as HTML');

If this breaks Xoops, you can always revert:
mailusers.php.old -> mailusers.php
mailform
.php.old -> mailform.php

Good luck,
Eric



25
spiff
Browser-contextual themes
  • 2005/1/9 16:05

  • spiff

  • Just popping in

  • Posts: 47

  • Since: 2003/4/16


Thought this might come in handy to folks out there wanting to design different themes according to the browser/OS used.

Paste the following at the bottom of 'include/common.php', just before the closing bracket:

if (preg_match('/msie/i',$_SERVER['HTTP_USER_AGENT'])) {
  
$xoopsConfig['theme_set'] = 'explorertheme';
}


Explanation: if the user agent mentions MSIE (the user is accessing XOOPS with Internet Explorer), present the site with the theme defined in '/themes/explorertheme', otherwise use the theme set in XOOPS preferences.

Note: This brute force method overrides manual theme selection for anyone matching the test, so you might have to turn off user-selectable themes.

There may be other ways to implement browser-contextual themes, but a quick browse didn't produce any results. Did anyone else do it in a different way?



26
spiff
Re: Site won't load when news feed is down
  • 2004/8/17 16:36

  • spiff

  • Just popping in

  • Posts: 47

  • Since: 2003/4/16


This seems to have been an issue last night with one of our sites running 2.0.7.

It would be pretty easy to hack the headlines update script to first ping sites before attempting to load a feed to prevent having the server wait for a timeout.

In the file /modules/xoopsheadline/class/headlinerenderer.php, replacing this code (around line 60):
function updateCache()
{
  if (!
$fp fopen($this->_hl->getVar('headline_rssurl'), 'r')) {
    
$this->_setErrors('Could not open file: '.$this->_hl->getVar('headline_rssurl'));
    return 
false;
  }
  <
etc>

with the following (UNTESTED):
function pingDomain$url ) {
  
preg_match_all'/http://([w.]{2,})/i'$url$match );
  
$url $match[1][0];
  
exec"ping -n 4 $url"$list );
  foreach ( 
$list as $l ) {
    if ( 
preg_match'/unknown host/i'$l ) )
      return 
false;
    if ( 
preg_match'/100% packet loss/i'$l ) )
      return 
false;
  }
  return 
true;
}
function 
updateCache()
{
  
$url $this->_hl->getVar('headline_rssurl');
  if ( !
pingDomain$url ) ) {
    
$this->_setErrors('Could not access domain: '.$url);
    return 
false;
  }
  if (!
$fp fopen($url'r')) {
    
$this->_setErrors('Could not open file: '.$url);
    return 
false;
  }


Of course, the pingDomain() method could be refactored out as a general-purpose utility function, since it could be useful to other modules as well.

I think this would greatly speed up the headlines module on failing feeds, since the fopen() wouldn't have to wait for the timeout.

The above code is not a universal solution. The format of return results on the ping command could be extended to other systems than Windows/Linux if applicable. It also depends on the availability of shell commands in the running PHP version. I'm not aware of a built-in ping command in PHP.

Please comment.

Eric

[EDIT: modified some errors in code, added UNTESTED ]



27
spiff
Re: Headlines Block Disappears
  • 2004/8/17 15:47

  • spiff

  • Just popping in

  • Posts: 47

  • Since: 2003/4/16


This is only a suggestion, as I've never faced this issue:

Do you validate your news feed before adding it to your headlines module? If not, it could be the headlines update fails on a feed and makes the script time out upon creating the block cache.

From what I've read, clearing the cache should take care of this issue.

Discrepancies between cache times in the headlines module and headline block may also be at stake.

Eric



28
spiff
Re: RSS backend, bandwidth and conditional GET
  • 2004/8/2 15:41

  • spiff

  • Just popping in

  • Posts: 47

  • Since: 2003/4/16


I guess what I'm driving at is ways to alleviate bandwidth for a XOOPS site, and whether implementing Conditional GET in backend.php would help at all.

Obviously that would do nothing for the number of requests coming for the backend feed. But it would do something for the number of bytes sent back in response to those requests.

Eric



29
spiff
Re: RSS backend, bandwidth and conditional GET
  • 2004/8/2 14:02

  • spiff

  • Just popping in

  • Posts: 47

  • Since: 2003/4/16


Doesn't the caching feature only imply that feed content is reconstructed regularly to limit database access? Correct me if I'm wrong: the entire (cached) feed is still sent for every request that comes in to backend.php, right?

Conditional GET would send back a near-empty response to a feed request, something like:

Last-Modified: <timestamp>
HTTP/1.0 304 Not Modified


According to RSS specifications, aggregators should send requests including two variables (namely HTTP_IF_MODIFIED_SINCE and HTTP_IF_NONE_MATCH). Checking the variables against actual RSS modification time would enable sending back a server-304 response when the feed doesn't contain any update.

While not all aggregators implement RSS specs as they should (yet), sending back 304 headers to responsible aggregators would be less bandwidth-expensive than sending back the whole feed with the last 10 news stories.

Consider Thunderbird's aggregator integration. Provided Thunderbird follows the specs (and I'm pretty sure it does), and even if it implements a minimal time between updates (doubtful), I'd much rather send a Bird user a 200-byte header than a 30Kb file.

As for processing power, I honestly think RSS is there to stay, even for individual users (Thunderbird is further proof that it's been widely accepted). RSS proxy networks might come in handy at some stage, providing relays to obtain feeds from. But that's outside of the scope of Xoops...

Eric



30
spiff
RSS backend, bandwidth and conditional GET
  • 2004/8/1 14:47

  • spiff

  • Just popping in

  • Posts: 47

  • Since: 2003/4/16


Hello everyone,

As mentioned in RSS bandwidth rules, the issues with bandwidth have to do with either server-side implementations (when the entire feed data is served regardless of whether there is a date component in the request) or client-side implementations (asking for an RSS update every two minutes). Further discussion here.

In order to alleviate server load, Charles Miller blogged on HTTP Conditional Get for RSS Hackers, which basically allows clients to only download a feed when there's new stuff in it, and servers to reply with a polite "no new stuff" answer when they have nothing new to tell.

I was wondering whether anybody had looked into implementing this for Xoops, and whether it's relevant at all to try to do so in PHP vs. Apache (there's a start of a discussion and PHP implementation of Conditional Get here).

Comments also appreciated.

Eric




TopTop
« 1 2 (3) 4 5 »



Login

Who's Online

204 user(s) are online (132 user(s) are browsing Support Forums)


Members: 0


Guests: 204


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits