Author Topic: Pop-up Chat window conflict with lib/output.php  (Read 3532 times)

Alchemion

  • Guest
Pop-up Chat window conflict with lib/output.php
« on: November 23, 2009, 03:05:39 pm »
Hi, Oliver,

Long time, no see...

I got some more spare time this period and I remembered that I would like to finish installing and start administering, occasionally, my nb-core game...

Well, I installed a new module from DP, respectively the Pop-up Chat module.

It gets an error when trying to click the link and open the pop-up chat window...

It says:
Code: [Select]
Fatal error: Call to a member function rawoutput() on a non-object in /mounted-storage/home113a/sub007/sc41001-XJFO/alchemion.net/lib/output.php on line 394
The 394 lib/output.php line is:
Code: [Select]
$output->rawoutput($indata);
I put up a question to the author, on DP, yet, he asked about the version I use and updated the module, but the same error ocurs...

The code of the popupcr.php module is:
Code: [Select]
<?php
/*
version 1.5
- Added section control setting.
- Added Min and Max refresh time setting.
- Replaced [DEL] links from commentary for SUs.
*/
function popupcr_getmoduleinfo(){
$info = array(
"name"=>"PopUp Chat Room",
"version"=>"1.5",
"author"=>"`2Shane`0, for `#C`&on`#t`&ess`#a",
"category"=>"General",
"settings"=>array(
"PopUp Chat Room Settings,title",
"section"=>"Section:,enum,popupcr,PopUp Chat Room,village,Village,gardens,Gardens",
"minref"=>"Min refresh time(in seconds; best not to set under 30):,int|60",
"maxref"=>"Max refresh time(in seconds; best not to set over 900):,int|240",
),
"prefs"=>array(
"PopUp Chat,title",
// thanks to maZice
"user_refresh"=>"Automatically refresh the chat?,bool|1",
"user_refreshtime"=>"Seconds to automatically refresh:,int|120",
"Do not set this to too low as you will then be unable to type anything.,note",
),
"override_forced_nav"=>true,
);
return 
$info;
}
function 
popupcr_install(){
module_addhook("charstats");
return 
true;
}
function 
popupcr_uninstall(){
return 
true;
}
function 
popupcr_dohook($hookname,$args){
global $session;
switch($hookname){
case 
"charstats":
$display.="<a href='runmodule.php?module=popupcr' onClick=\"".popup("runmodule.php?module=popupcr").";return false;\" target='_blank' align='center' class=\"charinfo\" style=\"font-size:10px\">Open</a>";
addcharstat("Popup Chats");
addcharstat("PopUp Chat Room"$display);
addnav("","runmodule.php?module=popupcr");
break;
}
return 
$args;
}
function 
popupcr_run(){
global $session;
popup_header("PopUp Chat Room");
$op=httpget('op');
if (
$op==""){
output("`n`n");
require_once("lib/commentary.php");
addcommentary();
output("`@Speak with others:`n`n");
$section get_module_setting("section");
viewcommentary($section,"Speak",20,"says");
modulehook("mod_popupcr");
global $output;
$output preg_replace("/<a href='bio\.php(.*?)'>(.*?)<\/a>/i"'$2'$output);
$output preg_replace("/<a href='runmodule\.php(.*?)'>(.*?)<\/a>/i"'$2'$output);
// refresh code
if (get_module_pref("user_refresh")==1){
$time get_module_pref("user_refreshtime");
if ($time get_module_setting("maxref")) $time get_module_setting("maxref");
if ($time get_module_setting("minref")) $time get_module_setting("minref");
rawoutput("<meta http-equiv='refresh' content='$time'>");
}
}
if (
$op=="clear"){
output("`n`n`nAll commentary has been cleared for this section. Close this window and refresh for the effects to take place.");
db_query("DELETE FROM commentary WHERE section = 'popupcr'");
}
popup_footer();
}

Obviously it may be a conflict with the new nb-core lib/output.php ... and the coder does not know your lotgd version...

Please, point out where is the issue...

Edit: I cut out some/all $output code from the module and it works... but not as intended... with the output/pregreplace cut out, the bio.php link sticks to the user name... where is the error and how can we get rid of bio.php ?...

Thank you very much.
Emanuel C.

« Last Edit: November 23, 2009, 04:04:30 pm by Alchemion »

Alchemion

  • Guest
Re: Pop-up Chat window conflict with lib/output.php
« Reply #1 on: November 25, 2009, 03:51:01 pm »
Hoping you get helthier sooner,
Regards,
E.C.

p.s. some PM with Ymessenger ID? Thanks.

Nightborn

  • Administrator
  • Sr. Member
  • *****
  • Posts: 320
  • Karma: +20/-0
    • View Profile
    • Shinobilegends
Re: Pop-up Chat window conflict with lib/output.php
« Reply #2 on: November 27, 2009, 02:20:51 pm »
Hi,

sorry, I don't  check in on daily basis really ^^

The problem is, the module is trying to do something I don't like: it hacks directly into the global vars.
Gladly, it breaks.

This is very very bad style, though sometimes there is no other way.

Code: [Select]
global $output;
$output = preg_replace("/<a href='bio\.php(.*?)'>(.*?)<\/a>/i", '$2', $output);
$output = preg_replace("/<a href='runmodule\.php(.*?)'>(.*?)<\/a>/i", '$2', $output);

<--output is no string, it is an object in the nb-core, hence these calls returns a string, then the next output() try goes bad - as I expect $output to be an object.

Rewrite them properly using the functions in lib/output.php ... you can get and set the entire string as far as I know using class functions.


It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro

Alchemion

  • Guest
Re: Pop-up Chat window conflict with lib/output.php
« Reply #3 on: November 29, 2009, 10:24:08 am »
Problem solved (for me) !

I have modified the lib/commentary.php, duplicating some code with this (in bold)

             $nobios = array("motd.php"=>true);
   if (!array_key_exists(basename($_SERVER['SCRIPT_NAME']),$nobios)) $nobios[basename($_SERVER['SCRIPT_NAME'])] = false;
   if ($nobios[basename($_SERVER['SCRIPT_NAME'])])
      $linkbios=false;
   else
      $linkbios=true;

   if ($_GET['module'] == 'popupcr')
      $linkbios=false;
   else
      $linkbios=true;


I know, I know... since one is customising his own game... I guess it's ok...