1
Anonymous
xoops 2.4.2 and SmartSection 2.13
  • 2009/12/2 16:19

  • Anonymous

  • Posts: 0

  • Since:


Guys, Something has changed in XOOPS 2.4.2 compared to 2.3.3 to cause a problem with files linked to SmartSection 2.13 articles. See this page on my site as an example. As you can see, the first linked file is fubar; it displays normally on my 2.3.3 test site on the same server. The template (smartsection_item.html) code that displays the linked files is this:
<!-- BEGIN DYNAMIC BLOCK -->
      <{foreach 
item=file from=$item.files}>
      <
tr>
         <
td valign="middle" class="odd" align="left">
        <
a href="<{$xoops_url}>/modules/smartsection/visit.php?fileid=<{$file.fileid}>" target="_blank"><img src="<{$smartsection_url}>images/icon/file.gif" title="<{$lang_download_file}>" alt="<{$lang_download_file}>"/>&nbsp;<b><{$file.name}></b></a>
        <
div><{$file.description}></div >
         <
td valign="middle" class="odd" align="center"><{$file.datesub}></td>
         <
td valign="middle" class="odd" align="center"><{$file.hits}></td>
     </
tr>
      <{/foreach}>
    <!-- 
END DYNAMIC BLOCK -->
visit.php, the file references above is:
<?php
/**
* $Id: visit.php,v 1.2 2005/08/29 17:17:37 malanciault Exp $
* Module: SmartSection
* Author: marcan <marcan@notrevie.ca>
* Licence: GNU
*/

include_once "header.php";

$fileid = isset($_GET['fileid']) ? intval($_GET['fileid']) : 0;

// Creating the item object for the selected item
$fileObj $smartsection_file_handler->get($fileid);
$fileObj->updateCounter();

if (!
preg_match("/^ed2k*:///i"$fileObj->getFileUrl())) {
    
Header("Location: " $fileObj->getFileUrl());
}

echo 
"<html><head><meta http-equiv="Refresh" content="0URL=".$myts->oopsHtmlSpecialChars($fileObj->getFileUrl()).""></meta></head><body></body></html>";
exit();
?>
The php code (from item.php) is this, I think:
// Creating the files object associated with this item
$filesObj $itemObj->getFiles();

$files = array();
$embeded_files = array();

foreach(
$filesObj as $fileObj)
{
    if (
$fileObj->mimetype() == 'application/x-shockwave-flash') {
        
$file['content'] = $fileObj->displayFlash();

        if (
strpos($item['maintext'], '[flash-' $fileObj->getVar('fileid') . ']')) {
            
$item['maintext'] = str_replace('[flash-' $fileObj->getVar('fileid') . ']'$file['content'], $item['maintext']);
        } else {
            
$embeded_files[] = $file;
        }
        unset(
$file);
    } else {
        
$file['fileid'] = $fileObj->fileid();
        
$file['name'] = $fileObj->name();
        
$file['description'] = $fileObj->description();
        
$file['name'] = $fileObj->name();
        
$file['type'] = $fileObj->mimetype();
        
$file['datesub'] = $fileObj->datesub();
        
$file['hits'] = $fileObj->counter();
        
$files[] = $file;
        unset(
$file);
    }

}
$item['files'] = $files;
$item['embeded_files'] = $embeded_files;
And before anyone asks, the database is correct; the files are referenced as they should be and adding a new file to the article causes the fubar one to display correctly. Ideas?

2
trabis
Re: xoops 2.4.2 and SmartSection 2.13
  • 2009/12/2 20:23

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


HI, in item.php use this:
$file = array(); // add this
$files = array();
$embeded_files = array();


Diference is in 2.4 is in include/common.php:
if ($xoopsModule->getVar('dirname''n') != 'system') {
        if (
file_exists($file $xoops->path('modules/' $xoopsModule->getVar('dirname''n') . '/language/' $xoopsConfig['language'] . '/main.php'))) {
            include_once 
$file;
        } else if (
file_exists($file $xoops->path('modules/' $xoopsModule->getVar('dirname''n') . '/language/english/main.php'))) {
            include_once 
$file;
        }
    }


We should use unset($file) on next XOOPS version. It would be wiser than ask module developers to prefix variables and make sure they are not global, lol. I would classify this as core bug yes.

OK, so forget what I said. Open include/common.php and add this:
if ($xoopsModule->getVar('dirname''n') != 'system') {
        if (
file_exists($file $xoops->path('modules/' $xoopsModule->getVar('dirname''n') . '/language/' $xoopsConfig['language'] . '/main.php'))) {
            include_once 
$file;
        } else if (
file_exists($file $xoops->path('modules/' $xoopsModule->getVar('dirname''n') . '/language/english/main.php'))) {
            include_once 
$file;
        }
    }
    unset(
$file); //add this

3
Anonymous
Re: xoops 2.4.2 and SmartSection 2.13
  • 2009/12/2 20:37

  • Anonymous

  • Posts: 0

  • Since:


Thanks buddy - that's sorted it

PS: I understand why, too..... never too old to learn

4
Yurdal
Re: xoops 2.4.2 and SmartSection 2.13
  • 2009/12/3 9:08

  • Yurdal

  • Friend of XOOPS

  • Posts: 386

  • Since: 2005/3/27


Is this problem also persist in 2.14 version ?

5
Anonymous
Re: xoops 2.4.2 and SmartSection 2.13
  • 2009/12/3 9:14

  • Anonymous

  • Posts: 0

  • Since:


Quote:
Yurdal wrote:
Is this problem also persist in 2.14 version ?


I don't know; I didn't upgrade to 2.14 because this requires the installation of the SmartObjects framework and I was reluctant to install another framework just for one module.

However, I suspect that the problem will exist because, as trabis said, it is a "core" bug rather than a problem with the module.

It may be that other modules will be affected too? If you have problems then try trabis's solution (the include/common.php one) first.

HTH

6
allnewtome
Re: xoops 2.4.2 and SmartSection 2.13 [and 2.14]
  • 2009/12/24 4:18

  • allnewtome

  • Not too shy to talk

  • Posts: 175

  • Since: 2005/11/30


Yes, it did cause the same problem with Smartsection 2.14 and trabis's solution (adding a line to item.php) does solve it.

Thank you very much for raising this issue.

I've taken the liberty of marking this thread "solved"!


Login

Who's Online

168 user(s) are online (113 user(s) are browsing Support Forums)


Members: 0


Guests: 168


more...

Donat-O-Meter

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

Latest GitHub Commits