Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: Trying to make [include] work  (Read 192 times)

Tominator

  • Newbie
  • *
  • Karma: 2
  • Posts: 45
Trying to make [include] work
« on: February 07, 2013, 03:23:24 AM »

OK, I have this really basic survey software system installed (nightmare of config stuff) but it seems to be running ok. It's installed in a subdirectory called phpesp off my public_html directory. Snews 1.7 (1.3) is installed in the root of public_html. Both work fine independently but I'd like to be able to load a survey into an sNews page, ie:

http://geldner.com/phpESP/public/survey.php?name=Test

I think the parameter may be giving the [include] function fits since the page just spits back the URL and not the survey. Is there a way around this?
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Trying to make [include] work
« Reply #1 on: February 07, 2013, 04:18:18 AM »

The trick is to integrate your survey application with sNews so that it can function as if it is part of sNews, much as an add-on module would. I've gone through this before with a few stand-alone PHP apps.

At the very least - you would need to eliminate the d-base connection script used by the survey application and include all of its files/functions at the top of your sNews index.php file directly after the snews.php file include string. That way the survey script's functions will be loaded along with snews.php and should connect to the snews database along with it.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Tominator

  • Newbie
  • *
  • Karma: 2
  • Posts: 45
Re: Trying to make [include] work
« Reply #2 on: February 07, 2013, 04:53:31 AM »

OK, that's above my paygrade for sure.  I'm mostly a cut & paste kinda guy. :(

I started reading about using the survey program's files to build it into another app and promptly got lost. Here's an example they give.  ::)

Code: [Select]
<?php
// example use of handler.php
$template_file file_get_contents("http://blahblahblah.site.org/index.php?module=webpage&id=27");
$page_header preg_replace ('/FORM_BODY.*/s','',$template_file);
$page_header preg_replace ('/<div class="title">Survey<\/div>/s','',$page_header);
$page_footer preg_replace ('/.*FORM_BODY/s','',$template_file);

 
$sid=0;
 if (isset(
$_GET['sid'])) $sid=intval($_GET['sid']);
 
$lang="en_US";
 
# this must be included before any output happens
 
include("public/phpESP.first.php");

 if (
$sid>0) {
    echo 
$page_header;
    include(
"public/handler.php");
    echo 
$page_footer;
 }
?>
Logged

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: Trying to make [include] work
« Reply #3 on: February 07, 2013, 03:13:36 PM »

Tom, I don't have much insight into what could be going wrong with the include - and there are no guarantees that including the survey file actually works within sNews - but one thing to check is the function file_include in snews.php (it's towards the bottom third of the file).
The first part of this function looks like this:

Code: [Select]
<?php
function file_include($text$shorten) {
    
$fulltext substr($text0$shorten);
    if(
substr_count ($fulltext'&')>0){$fulltext str_replace('&''&amp;'str_replace('&amp;''&'$fulltext));}
?>

Try commenting out the if(substr_count(...)) statement, like this:
Code: [Select]
<?php
#   if(substr_count ($fulltext, '&')>0){$fulltext = str_replace('&', '&amp;', str_replace('&amp;', '&', $fulltext));}
?>

Important note: this should not be tried on a live site since commenting out the above line will alter how HTML entities like ampersands are handled by the system, meaning that normally you just write an ampersand in article texts and it gets treated correctly, but when the above line is commented out ampersands must be written in its HTML entity form "&_amp;" (minus the underscore), so handle with care.

(Obviously, if the if-statement in question already is commented out then disreagrd this.)
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Trying to make [include] work
« Reply #4 on: February 07, 2013, 03:30:47 PM »

Hi Tominator - you didn't mention the name of the survey script you are using - is it phpESP - php Easy Survey Package? It looks like a fairly old script (the linked article was posted on October 8, 2003) with the first offering made around 2000, and it appears it hasn't had any updating or work done on it for about 5 years... as near as I can tell.

I'll see if I can get it to work relatively quickly with a default localhost 1.7.1 install project.
Now that I've had a bit of a look at the installation steps... it doesn't look simple and would take more time to fiddle with than I have to spare. But I've downloaded the package and will keep it on hand for now. :)
« Last Edit: February 07, 2013, 07:14:15 PM by Keyrocks »
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6019
  • Semantically Challenged
    • snews.ca
Re: Trying to make [include] work
« Reply #5 on: February 07, 2013, 07:18:08 PM »

As an alternative, you could use Survey Monkey for your surveys to eliminate adding a survey application to your website.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Tominator

  • Newbie
  • *
  • Karma: 2
  • Posts: 45
Re: Trying to make [include] work
« Reply #6 on: February 07, 2013, 07:24:58 PM »

Hey I appreciate that. Yes, it's phpESP. Last updates were in 2009. To get it running, read the post from easterne at http://sourceforge.net/projects/phpesp/. He explains the source mods needed to make it work under php 5+ along with putting php.ini files into key folders. At least I was able to do that much.  ;)

The project has largely been abandoned but the only other pluggable survey system I've found is LimeSurvey and it's just huge. I think something like 120mb worth of code. Way overkill for what we need. I've located another one from iscripts.com Easy Web Survey. I'm going to look at it too.
Logged