collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 665
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

NEED HELP? If you're looking for support with Simple Portal, look no further than the Support Board!

Author Topic: Custom PHP block not reading ini file  (Read 8144 times)

0 Members and 1 Guest are viewing this topic.

Offline Xandar

  • Semi Newbie
  • *
  • Posts: 5
    • Hill Country Volleyball Club
  • SMF Version: 1.1.8
  • SP Version: 2.2.1
Custom PHP block not reading ini file
« on: May 15, 2009, 10:58:19 AM »
In my custom PHP block, I put the following:

<?php include('rotator.php'); ?>

<?php showImage(); ?>


---

The information that is displayed when I go look at it is as follows:


Unable to read ini file.

This error actually shows up and takes over all blocks so that there is no display. http://www.hcvc.us is fine as a guest, but as soon as I log in (it's only administrator view currently), all of the home page blocks vanish and the php block is the only one that exists.

---

The rotator script information is located at http://www.alistapart.com/articles/betterrotator/.

---

Anyone have a suggestion?  The ini file is in the same directory and is chmod 666 (rw-rw-rw-).  Is there a different directory that should be used? 



Thank you,
 X

PS:

 I'm also open to other rotator code suggestions. What I'm trying to accomplish is an image with a link that can be used for affiliates or sponsors.

Offline Eliana Tamerin

  • Comrade
  • *
  • Posts: 2889
  • Gender: Female
  • SMF Version: 2 RC2
  • SP Version: 2.3.2
Re: Custom PHP block not reading ini file
« Reply #1 on: May 15, 2009, 12:40:00 PM »
You do not need to include the opening and closing php tags in the php box, these are prepended and appended by the code automatically. You should use this code instead:

Code: [Select]
include('rotator.php');

showImage();
Ms. Eliana TamerinIt should be painfully obvious by now that I don't respond to support PMs. Don't send me PMs for support. They will be ignored and deleted, post on the Support Boards to get support.

Offline Xandar

  • Semi Newbie
  • *
  • Posts: 5
    • Hill Country Volleyball Club
  • SMF Version: 1.1.8
  • SP Version: 2.2.1
Re: Custom PHP block not reading ini file
« Reply #2 on: May 15, 2009, 01:25:14 PM »
Thank you. I have made that change, however it has not fixed the issue.

I still only see one block that has the Name of "Test" and the contents of "Unable to read ini file".  All other blocks are missing from the main portal page.

Offline ccbtimewiz

  • Hero Member
  • *****
  • Posts: 2185
  • Gender: Male
  • $("div.content:dd").hide();
  • SMF Version: None
  • SP Version: None
  • Elkarte Version: None
  • EhPortal Version: None
Re: Custom PHP block not reading ini file
« Reply #3 on: May 16, 2009, 01:23:34 AM »
What version of PHP are you using?

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: Custom PHP block not reading ini file
« Reply #4 on: May 16, 2009, 03:17:12 AM »
Try using relative path to the file for the include. Like:

Code: [Select]
include('home/www/my_scripts/rotator.php');
If it is in your forum root, you can use:

Code: [Select]
global $boarddir;

include($boarddir . '/rotator.php');
And slowly, you come to realize... It's all as it should be...

Offline Xandar

  • Semi Newbie
  • *
  • Posts: 5
    • Hill Country Volleyball Club
  • SMF Version: 1.1.8
  • SP Version: 2.2.1
Re: Custom PHP block not reading ini file
« Reply #5 on: May 16, 2009, 10:02:27 AM »
PHP Version 5.2.8-pl2-gentoo

The relative path didn't work nor did global. 

I'll keep trying to figure it out. The weird thing is you pull it out of SimplePortal and it works fine, but as soon as you add it into the Custom php block, it returns the can not read the .ini file.

I've tried relative path for the ini file too.

Based on the php code, the error is driven by:

    # read the config file into an array or die trying
    $images = @parse_ini_file($ini_file,true);
    if (! $images) {
      die('Unable to read ini file.');

- X

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: Custom PHP block not reading ini file
« Reply #6 on: May 16, 2009, 10:08:42 AM »
If it is your script, that gives the error; than I can't see why this would be related to SimplePortal itself. Would you post all your codes here?
And slowly, you come to realize... It's all as it should be...

Offline Xandar

  • Semi Newbie
  • *
  • Posts: 5
    • Hill Country Volleyball Club
  • SMF Version: 1.1.8
  • SP Version: 2.2.1
Re: Custom PHP block not reading ini file
« Reply #7 on: May 16, 2009, 10:13:08 AM »
The code (http://www.alistapart.com/articles/betterrotator/) is included below.  The only reason I'm saying that it has to do with the portal is because http://www.hcvc.us/test.php works (ignore the images, they should be broken right now -- the links refresh as I was expecting in SimplePortal). 

All that I have in test.php is:



Code: [Select]
  <?php include('rotator.php'); ?>

  <?php showImage(); ?>








rotater.php

Code: [Select]
<?php

/*

  Author: Dan Benjamin - http://hivelogic.com/

  Copyright (c) 2004 Automatic, Ltd. All Rights Reserved.

  THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT ANY WARRANTY OR CONDITION OF 
  ANY KIND, EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION ANY 
  IMPLIED WARRANTIES OF ACCURACY, MERCHANTABILITY, FITNESS FOR A PARTICULAR 
  PURPOSE OR NONINFRINGEMENT.  

  IN NO EVENT SHALL DAN BENJAMIN, A LIST APART, OR AUTOMATIC, LTD. BE LIABLE
  FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES OR
  LOST PROFITS ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE (HOWEVER
  ARISING, INCLUDING NEGLIGENCE), EVEN IF DAN BENJAMIN, A LIST APART, OR
  AUTOMATIC, LTD. IS AWARE OF THE POSSIBILITY OF SUCH DAMAGES.

*/



  # file containg your image descriptions

  
$IMG_CONFIG_FILE 'images.ini';



  
# You shouldn't need to change anything below this point

  
function showImage$ini=null ) {
    global 
$IMG_CONFIG_FILE;
    
# if no custom ini file has been specified, use the default
    
$ini_file $ini $ini $IMG_CONFIG_FILE;
    
# read the config file into an array or die trying
    
$images = @parse_ini_file($ini_file,true);
    if (! 
$images) {
      die(
'Unable to read ini file.');
    }
    
# pick a random image from the parsed config file
    
$img array_rand($images);
    
# get the selected image's css id if one exists
    
$id $images[$img]['id'] ?
      
sprintf' id="%s" '$images[$img]['id'] ) :
      
'';
    
# get the selected image's css class if one exists
    
$class $images[$img]['class'] ?
      
sprintf' class="%s" '$images[$img]['class'] ) :
      
'';
    
# get selected image's dimensions
    
$size = @getimagesize$images[$img]['src'] );
    
# if an url was specified, output the opening A HREF tag
    
if ( $images[$img]['url'] ) {
      
printf(
        
'<a href="%s" title="%s">',
        
$images[$img]['url'],
        
$images[$img]['title']
      );
    }
    
# output the IMG tag
    
printf(
      
'<img src="%s" alt="%s" %s %s%s/>',
      
$images[$img]['src'],
      
$images[$img]['alt'],
      
$size[3],
      
$id,
      
$class
    
);
    
# if an url was specified, output the closing A HREF tag
    
if ( $images[$img]['url'] ) {
      echo(
'</a>');
    }
  }


?>


Image.ini file
Code: [Select]
[TheDonald]
src   = img/trump.jpg
alt   = Donand Trump
url   = http://trump.com/
title = The Donald

[Tony]
src   = img/tony.jpg
alt   = Tony
url   = http://hbo.com/
title = The Sopranos

[Bond]
src   = img/bond.jpg
alt   = James Bond
url   = http://jamesbond.com/
title = James Bond Website

[Doctor]
src   = img/drwho.jpg
alt   = Tom Baker
url   = http://www.bbc.co.uk/cult/doctorwho/
title = Dr. Who

[FightClub]
src   = img/edsoap.jpg
alt   = I Am Jack's Soap
url   = http://www.imdb.com/title/tt0137523/
title = Fight Club

[Kubrick]
src   = img/kubrick.jpg
alt   = Stanley
url   = http://www.kubrick.com/
title = Kubrick

[Serling]
src   = img/rod.jpg
alt   = Rod
url   = http://www.scifi.com/twilightzone/
title = Rod Serling

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: Custom PHP block not reading ini file
« Reply #8 on: May 17, 2009, 04:24:48 AM »
I'm not sure about the reason but $IMG_CONFIG_FILE becomes NULL in showImage() function. This will work:

Code: [Select]
require('rotator.php');
showImage('images.ini');
And slowly, you come to realize... It's all as it should be...

Offline Xandar

  • Semi Newbie
  • *
  • Posts: 5
    • Hill Country Volleyball Club
  • SMF Version: 1.1.8
  • SP Version: 2.2.1
Re: Custom PHP block not reading ini file
« Reply #9 on: May 18, 2009, 09:23:48 AM »
Awesome! Thank you. That fixes it. I really appreciate the help.

- X

Offline cthunders

  • Just Registered
  • Posts: 1
  • SMF Version: None
  • SP Version: None
Re: Custom PHP block not reading ini file
« Reply #10 on: May 31, 2009, 10:27:50 AM »
I was wondering exactly where you added the:

require('rotator.php');
showImage('images.ini');


Offline Eliana Tamerin

  • Comrade
  • *
  • Posts: 2889
  • Gender: Female
  • SMF Version: 2 RC2
  • SP Version: 2.3.2
Re: Custom PHP block not reading ini file
« Reply #11 on: May 31, 2009, 10:51:33 AM »
In a php block.
Ms. Eliana TamerinIt should be painfully obvious by now that I don't respond to support PMs. Don't send me PMs for support. They will be ignored and deleted, post on the Support Boards to get support.

Offline jjwinc

  • Semi Newbie
  • *
  • Posts: 37
  • Gender: Male
    • ATU85
  • SMF Version: 2 RC3
  • SP Version: 2.3.2
Re: Custom PHP block not reading ini file
« Reply #12 on: September 21, 2009, 06:54:50 PM »
I'm not sure about the reason but $IMG_CONFIG_FILE becomes NULL in showImage() function. This will work:

Code: [Select]
require('rotator.php');
showImage('images.ini');


Old thread, but same issue.  I am trying to use the same code on my site BowlThis.com and it works fine as long as I'm previewing the block.  The minute I try to save it, SP returns an error stating Syntax Error in Block Code.  Please check the code.  Unfortunately, I don't see any hints as to where the error may originate.

Any suggestions on where I could start?  Also, of course, I have Disable PHP Validation unchecked on my site.  Not feeling too safe about bypassing the validation until I can try to ferret out what's going on.
« Last Edit: September 21, 2009, 07:26:22 PM by jjwinc »