Welcome to Geeklog Monday, November 20 2017 @ 07:38 pm EST


Status: offline

Ectropian

Forum User
Chatty
Registered: 19/06/2002
Posts: 61
HELP! I can't get this php page into the wrapper? Any ideas?

http://www.fbcofshelby.org/new/Mediaplayer/index.php

OH, and yes, I have the header/footer and include in the proper place.
--Ted(Ectropian)

Status: offline

Ectropian

Forum User
Chatty
Registered: 19/06/2002
Posts: 61
Common Guys! I know this can't be hard. What would cause this index.php to "break out" of the geeklog wrapper??
--Ted(Ectropian)

Status: offline

Dirk

Site Admin
Admin
Registered: 12/01/2002
Posts: 13073
Location:Stuttgart, Germany
And how do you expect us to debug your code without seeing it?

I'd say you're outputting some stuff directly and the header/footer later, but that's only a guess.

bye, Dirk

Status: offline

Ectropian

Forum User
Chatty
Registered: 19/06/2002
Posts: 61
Ok, and since I know nothing about outputting php, lemme add this. the index.php calls 3 other .php files. None of which seem to require a header. I know this sounds weird, but this might just be the next music addon for Geeklog Smile
--Ted(Ectropian)

Status: offline

geiss

Forum User
Full Member
Registered: 10/02/2004
Posts: 176
Location:Boise, Idaho
Along those same lines, I am having the same issue and am looking for a quick fix. :wink:

I know that according to http://www.geeklog.net/faqman/index.php?op=view&t=12 you must enable use of PHP, place the code in lib-custom.php, use the function call "phpblock_your_function_name", and finally that it MUST use return statements, NOT echo statements, correct?

OK, so I have integrated a separate php calendar script called TotalCalendar. (www.sweetphp.com) ( I am not asking for help with the script, it works fine, but it uses echo statements throughout the entire codebase, and I believe this is why it is rendering above the GL header.

Originally, the code to call the calendar block in lib-custom.php was:

PHP Formatted Code

/**
* Shows current month mini calendar from totalcalendar
* totalcalendar by sweetphp.com
*/


function phpblock_minitotalcal2()
{
$tcalRootPath = "my path"; // Path with trailing slash
$tcalUrlPath = "my path"; // Url path with trailing slash
$tcalSelectedCal = 1; // Calendar id number to display
$tcalSelectedDate = time(); // Selected date for boxes
$tcalLang = "en-US"; // Language for the boxes $tcalUrlPath
$tcalTheme = "green"; // Theme for the boxes
require_once($tcalRootPath."box_loaderGL_MOD.php");

echo "<table><tr><td><div align=\"center\">";
showCalBox("Current_Month_Mini");
echo "</div></td></tr></table>";
}
 


So, I changed it to remove the echo statements, and in their place used retvals and a return statement:

PHP Formatted Code

/**
* Shows current month mini calendar from totalcalendar
* totalcalendar by sweetphp.com
*/


function phpblock_minitotalcal2()
{
$tcalRootPath = "filled in my path"; // Path with trailing slash
$tcalUrlPath = "http://filled in my path"; // Url path with trailing slash
$tcalSelectedCal = 1; // Calendar id number to display
$tcalSelectedDate = time(); // Selected date for boxes
$tcalLang = "en-US"; // Language for the boxes $tcalUrlPath
$tcalTheme = "green"; // Theme for the boxes
require_once($tcalRootPath."box_loaderGL_MOD.php");

$retval = '';
$retval = '<table><tr><td><div align="center">' . showCalBox("Current_Month_Mini") . '</div></td></tr></table>';
return $retval;

}

 


But I get no difference in the final output. Both instances display the calendar block above the header.

An example GIF can be found at http://familycorner.us/block_funkiness.gif

So,... a couple questions:

1- Is there an easier way to modify the GL code to allow the use of echo statements in blocks?
2- Are there any security risks inherent in doing so?
3- I assume the issue lies in that all the code that is referenced in the require_once file at times uses echo statements (and subsequent require_once files referenced from that file and so on), yes? This is why I am asking question 1.
:pray:

Thanks in advance for help!
Synergy - Stability - Style --- Visit us at glfusion.org

Status: offline

jmucchiello

Forum User
Full Member
Registered: 29/08/2005
Posts: 985
Look into the output buffer functions in PHP:
PHP Formatted Code

/**
* Shows current month mini calendar from totalcalendar
* totalcalendar by sweetphp.com
*/


function phpblock_minitotalcal2()
{
    ob_start();

$tcalRootPath = "my path"; // Path with trailing slash
$tcalUrlPath = "my path"; // Url path with trailing slash
$tcalSelectedCal = 1; // Calendar id number to display
$tcalSelectedDate = time(); // Selected date for boxes
$tcalLang = "en-US"; // Language for the boxes $tcalUrlPath
$tcalTheme = "green"; // Theme for the boxes
require_once($tcalRootPath."box_loaderGL_MOD.php");

echo "<table><tr><td><div align="center">";
showCalBox("Current_Month_Mini");
echo "</div></td></tr></table>";

   $retval = ob_get_contents();
   ob_end_clean();
   return $retval;
}
 

Status: offline

geiss

Forum User
Full Member
Registered: 10/02/2004
Posts: 176
Location:Boise, Idaho
Hey Joe!

Thanks so much for the quick reply and the advice! It was just what I was hoping for!

Since we went back to using echo statements, I had to add the backslashes to the div tag so my final beautiful results look like this:

PHP Formatted Code


/**
* Shows current month mini calendar from totalcalendar
* totalcalendar by sweetphp.com
*/


function phpblock_minitotalcal3()
{
    ob_start();

$tcalRootPath = "place your server path here"; // Path with trailing slash
$tcalUrlPath = "place your http:// path here"; // Url path with trailing slash
$tcalSelectedCal = 1; // Calendar id number to display
$tcalSelectedDate = time(); // Selected date for boxes
$tcalLang = "en-US"; // Language for the boxes $tcalUrlPath
$tcalTheme = "green"; // Theme for the boxes
require_once($tcalRootPath."box_loader.php");

echo "<center><table width=\"195\"><tr><td><div align=\"center\">";
showCalBox("Current_Month_Mini");
echo "</div></td></tr></table></center>";

   $retval = ob_get_contents();
   ob_end_clean();
   return $retval;
}

 


Thanks again for your insight Joe!
Quick question: Are there any security risks inherent in using these output buffers?


You Rock! :chestslam:
Synergy - Stability - Style --- Visit us at glfusion.org

Status: offline

jmucchiello

Forum User
Full Member
Registered: 29/08/2005
Posts: 985
Not inherently. But since you are running code you don't really know much about, you are taking a risk there. But the same risk applies to the parts of Geeklog you don't know much about.

Status: offline

geiss

Forum User
Full Member
Registered: 10/02/2004
Posts: 176
Location:Boise, Idaho
Gotcha.

Thanks again for the help!


Synergy - Stability - Style --- Visit us at glfusion.org

All times are EST. The time is now 07:38 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content