Errors with V2.06 lib/init.php changes
10 posts by 4 authors in: Forums > CMS Builder
Last Post: September 27, 2010 (RSS)
Seems like you've made some necessary changes in the V.2.06 lib/init.php file to accommodate error checking in newer PHP versions.
Up to now, to suppress errors in an implementation of a CAPTCHA program I’ve been using, I had to change the opening lines of the init.php file, from this:
<?php
// error reporting
error_reporting(E_ALL | 2048); // display all errors (2048 = E_STRICT which isn't defined in PHP 4)
To this:
<?php
// error reporting
// error_reporting(E_ALL | 2048); // display all errors (2048 = E_STRICT which isn't defined in PHP 4)
error_reporting('E_ALL & ~E_WARNING');
I know I’ll have to change something in 2.06, but rather than guessing, breaking something, and finding out the hard way, I thought that I’d ask for some guidance.
VIEWER CODE
This is the code that I’ve been using in my viewer:
<?php
session_start();
require_once "cmsAdmin/lib/viewer_functions.php";
list($common_informationRecords, $common_informationMetaData) = getRecords(array(
'tableName' => 'common_information',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$common_informationRecord = @$common_informationRecords[0]; // get first record
?>
<?php include_once "/hsphere/local/home/c307025/cogancameras.com/spambot-email-protector.php" ?>
<?php
include_once('captcha/captchac_lib.php');
if(!isset($_SESSION))
{
session_start();
}
?>
And this is the error I’m now getting (again):
Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in /hsphere/local/home/c307025/cmsAdmin/lib/init.php on line 326 Notice: A session had already been started - ignoring session_start() in /hsphere/local/home/c307025//cmsAdmin/lib/init.php on line 327
(Of course, I’d really rather solve the problem at the viewer level but a mod to the init.php file would work just fine)
Thanks.
Best,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Errors with V2.06 lib/init.php changes
By Chris - September 23, 2010
I think you'll want to remove this line from your viewer:
session_start();
viewer_functions.php will call init.php and that will start the session for you.
Also, you can set error_reporting(E_ALL & ~E_WARNING) in your viewer code right before you include your CAPTCHA script if you'd like.
I hope this helps! Please let me know if you have any questions.
Chris
Re: [chris] Errors with V2.06 lib/init.php changes
Thanks for the quick response.
I tried your suggestions, but unfortunately, I'm still getting the same error response.
here's he new code in case I misunderstood:
<?php
session_start();
require_once "cmsAdmin/lib/viewer_functions.php";
list($common_informationRecords, $common_informationMetaData) = getRecords(array(
'tableName' => 'common_information',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$common_informationRecord = @$common_informationRecords[0]; // get first record
?>
<?php include_once "/hsphere/local/home/c307025/cogancameras.com/spambot-email-protector.php" ?>
<?php
error_reporting('E_ALL & ~E_WARNING');
include_once('captcha/captchac_lib.php');
if(!isset($_SESSION))
{
// session_start();
}
?>
And here's the error I still get:
Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in /hsphere/local/home/c307025/cogancameras.com/cmsAdmin/lib/init.php on line 326 Notice: A session had already been started - ignoring session_start() in /hsphere/local/home/c307025/cogancameras.com/cmsAdmin/lib/init.php on line 327
Best,
Jerry
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Errors with V2.06 lib/init.php changes
By Jason - September 24, 2010
I think the problem is your "session_start()" that appears just before the require_once statement. Try this:
<?php
require_once "cmsAdmin/lib/viewer_functions.php";
list($common_informationRecords, $common_informationMetaData) = getRecords(array(
'tableName' => 'common_information',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$common_informationRecord = @$common_informationRecords[0]; // get first record
?>
<?php include_once "/hsphere/local/home/c307025/cogancameras.com/spambot-email-protector.php" ?>
<?php
error_reporting('E_ALL & ~E_WARNING');
include_once('captcha/captchac_lib.php');
if(!isset($_SESSION))
{
session_start();
}
?>
Hope this helps
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Errors with V2.06 lib/init.php changes
Sorry, I had commented out the wrong session_start();
Here’s what I found so far.
If I load the CAPTCHA before common_information table, as in the code below, then the CAPTCHA works but the viewer still shows the error message above.
<?php
error_reporting('E_ALL & ~E_WARNING');
include_once('captcha/captchac_lib.php');
?>
<?php include_once "/hsphere/local/home/c307025/cogancameras.com/spambot-email-protector.php" ?>
<?php
require_once "cmsAdmin/lib/viewer_functions.php";
list($common_informationRecords, $common_informationMetaData) = getRecords(array(
'tableName' => 'common_information',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$common_informationRecord = @$common_informationRecords[0]; // get first record
?>
If I change the loading order to load the common_information table first, then the CAPTCHA code doesn’t work (the error message is still there).
No matter where (or if) I insert error_reporting('E_ALL & ~E_WARNING'); it doesn’t seem to make a difference.
Hope you’ve got an idea.
Worst case, can I modify the init.php file to 2.05 code and how would I do that? Can I upload V2.05 over 2.06 without destroying the site (database compatibility) ?
Thanks,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Errors with V2.06 lib/init.php changes
By Jason - September 24, 2010
You could over write the init file with one from an older version. This shouldn't cause any problems (do a backup of everything just in case).
If you want, I could take a quick look at it and see if I can track down the issue. If you could email all of details along with the name of the page that has this issue to jason@interactivetools.com
Hope this helps.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] Errors with V2.06 lib/init.php changes
The error message that I was seeing only appeared when the Captcha generating program "Captcha Creator" was called on a page and only when using CMSB V2.06.
After discussing the issue with Jason, the (temporary) solution agreed on was to write over the V2.06 init.php file with a V2.05 init.php file that was modified as described in the CMSB Cookbook recipe for Captcha Creator implementation.
I like Captcha Creator because it's easily customizable and unobtrusive on a web page, but it seems to have some coding problems that make it unusable with CMSB in the long term.
So, if anyone can recommend a Captcha program (besides re-captcha) that works well with CMSB, could you post the information here?
Thanks,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Errors with V2.06 lib/init.php changes
By Djulia - September 26, 2010 - edited: September 26, 2010
You tried to use the session_write_close(); ?
<?php
require_once "lib/viewer_functions.php";
...
session_write_close ();
session_name ("captcha"); // if necessary for your script
session_start ();
include_once('captcha/captchac_lib.php');
?>
http://www.php.net/manual/en/function.session-write-close.php
Djulia
Re: [Djulia] Errors with V2.06 lib/init.php changes
No, I didn't but I'll certainly give it a try and let you know.
I didn't even know it existed.
Thanks,
Jerry
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
Re: [gkornbluth] Errors with V2.06 lib/init.php changes
IT WORKED!!!!
I had to change the order of the sessions to start with the captcha session, close that session and then open the CMSB session, but it works like a charm.
<?php
include_once('captcha/captchac_lib.php');
session_write_close ();
?>
<?php
require_once "cmsAdmin/lib/viewer_functions.php";
list($common_informationRecords, $common_informationMetaData) = getRecords(array(
'tableName' => 'common_information',
'where' => whereRecordNumberInUrl(1),
'limit' => '1',
));
$common_informationRecord = @$common_informationRecords[0]; // get first record
?>
<?php include_once "/hsphere/local/home/c307025/spambot-email-protector.php" ?>
Thanks you for your help.
Best,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php