Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules
Author Message
CodyG
Life Cycles Becoming CPU Cycles



Joined: Jan 02, 2003
Posts: 714
Location: Vancouver Island

PostPosted: Thu Sep 18, 2008 4:15 pm Reply with quote

I hope to move a site to a new server, and I'd like this old (2003) 'Instant Messaging" script to work on that server. Besides, it's long overdue that it gets some updating.

/* Site Messenger Module */
/* ============================ */
/* rewrite and modified by: */
/* [ Only registered users can see links on this board! Get registered or login! ] */
/* [ Only registered users can see links on this board! Get registered or login! ] */
/* */
/* Original by: [ Only registered users can see links on this board! Get registered or login! ]

I use it on a site for local seniors. 1000 members averaged 100 uses each, over the past few years. I'm told, it's way easier, and more fun, than Forums PM. And, they get that sad puppy look when I tell them technology moves on and couldn't we just drop it? Laughing

It 'works' with RN2.0, php and mysql4, but the scripting is old and tired, has bbcode from 2001, it likely has ton of security issues, and the developers are elsewhere. Today I'm getting db errors on my test domain, RN2.3, php and mysql 5. I want to fix those errors and clean up the coding.


I'm pretty sure I've updated all the db calls. But my current db error is on this snippet fom the index.php file ... it doesn't like the sql_fetch_array and throws a Fatal error: Call to undefined method sql_db::sql_fetch_array()

I tried finding something more suitable for fetch_array in mysql.php, but nada. Anyone know what's breaking? Or a clue for fixing?

Code:



while ($myrow = $db->sql_fetch_array($result)) {
                        if (!$myrow["msg_image"]) $myrow["msg_image"]=$subjectdefaulticon;
                        $postedtime= strftime(_PMSTIMESTRING,$myrow["msgtimestamp"]);
                        echo "<tr>\n\t<td bgcolor=\"$bgcolor1\" width=\"2%\" align=\"center\"><input type=\"checkbox\" onclick=\"CheckCheckAll();\" name=\"msg_id[$count]\" value=\"".$myrow["msg_id"]."\" style=\"background-color: transparent;\">";
                        echo "</td>\n";
                        echo "\t<td width=\"5%\" align=\"center\" bgcolor=\"$bgcolor1\">";
                        if ($myrow["read_msg"] == 1) {
                                echo "&nbsp;";
                                }
                        else {
                                echo "<img src=\"$url_images/read.gif\" border=\"0\" alt=\""._PMSNOTREAD."\">";
                                }

                        echo "\t<td bgcolor=\"$bgcolor1\" width=\"10%\"><font class=\"content\" color=\"$textcolor2\">".$myrow["fromname"]."</font></td>\n";

//etc...



This mod needs way more paramedical help than what I have the talent for, so thank you all who share.


I can't remember where I found this script back in 2003, I only remember it didn't come with the db installation and it took me months to find the one db table it used in an old version of nuke with splatt?? If anyone is interested in helping out with this project just pm me your email and I'll try to pull together an archive with all the bits and pieces in one place.

Happy nuking!

_________________
"We want to see if life is ubiquitous." D.Goldin 
View user's profile Send private message
Gremmie
Former Moderator in Good Standing



Joined: Apr 06, 2006
Posts: 2415
Location: Iowa, USA

PostPosted: Thu Sep 18, 2008 4:24 pm Reply with quote

I see a member function called sql_fetchrowset() that returns an array.

_________________
GCalendar - An Event Calendar for PHP-Nuke
Member_Map - A Google Maps Nuke Module 
View user's profile Send private message
Palbin
Site Admin



Joined: Mar 30, 2006
Posts: 2583
Location: Pittsburgh, Pennsylvania

PostPosted: Thu Sep 18, 2008 4:48 pm Reply with quote

Change "sql_fetch_array" to "sql_fetchrow".

But I believe what Gremmie said will work just the same. I'm not sure if there is a "correct" one to use.
 
View user's profile Send private message
Gremmie







PostPosted: Thu Sep 18, 2008 5:05 pm Reply with quote

Underneath the sheets sql_fetchrowset() calls mysql_fetch_array(), and it looks like the above code wants an array, so I would try that.

sql_fetchrow() only gets 1 row at a time and it doesn't look like that is what you want in that code snippet.
 
CodyG







PostPosted: Thu Sep 18, 2008 8:18 pm Reply with quote

Well that worked to clear up the db error! Smile But is it pulling everything out of the db? IOW, there are far too many windows opening, only the unread message should open.

Which may lead to the next issue ... although everything looks right, and sent messages are getting stored in the database, nothing is displaying to the screen. For example, in the block file, online members should be displayed, but nada.


I'm looking at a lot of variables not enclosed in quotes. ie: $guest=1; should be #guest='1';
Right?


Code:


$ip = getenv("REMOTE_ADDR");
if (is_user($user)){

        $uname = $cookie[1];
        $user_id = $cookie[0];
        $guest=0;
        }
else {
        $uname = "$ip";
        $guest=1;
        $showscrollist=0;
        }


$past = time()-900; $ctime = time();
$countpm=0; $countpmunread=0;
$userlist=""; $totalmembers=0;
$gbactiv=0; $gbnewentries=0;
$whoonlinelist = ""; $whoonlineselect = "";
$member_online_num = 1; $guest_online_num=0;
$pmactiv=0;
$isseradmin=is_admin($admin);
# SQL-bedingung fuer excluded Users erstellen
$exusers = explode (",", $excludedusers);
if(!$isseradmin){
        while (list($key, $val) = each($exusers)) {
                $xexusers[]="\"".trim($val)."\"";
                }
        }
$xexusers[]="\"$anonymous\"";

$excludedusers=implode($xexusers,",");



And then there is this mess which likely doesn't work with php5, right? Any ideas?

Code:
$forumpage = 1;


if (!is_user($HTTP_COOKIE_VARS["user"])) {
        Header("Location: modules.php?name=Your_Account&op=login");
        exit;
        }
else {
        $userdata = getusrinfo($HTTP_COOKIE_VARS["user"]);

        if(isset($HTTP_POST_VARS["op"])){                $op=$HTTP_POST_VARS["op"];                }
        else if(isset($HTTP_GET_VARS["op"])){                $op=$HTTP_GET_VARS["op"];                }
        else{                $op="index";                }

        if(isset($HTTP_POST_VARS["username"])){                 $username=$HTTP_POST_VARS["username"];                }
        else if(isset($HTTP_GET_VARS["username"])){                $username=$HTTP_GET_VARS["username"];                }
        else{                $username=$userdata["user_id"];                }

        include_once("modules/".$module_name."/config.php");
        include_once("modules/$module_name/language/SM-$SM_lang.php");
        include_once("modules/".$module_name."/functions.php");
        include('header.php');

        echo "\n\n<!-- beginn $module_name output -->\n";
        if ($op=="read"){
                readmessage($HTTP_GET_VARS["id"], $userdata["user_id"]);
                }
        else if ($op=="reply"){
                sendmessage($HTTP_GET_VARS["id"], $userdata["user_id"]);
                }
        else if ($op=="send"){
                sendmessage(0, $username);
                }
        else if ($op=="submit"){
                if (isset($HTTP_POST_VARS["submit"])){
                        submitmessage($HTTP_POST_VARS, $userdata["user_id"]);
                        }
                else{
                        cancelsubmit($HTTP_POST_VARS["msg_id"], $userdata["user_id"]);
                        }
                }
        else if ($op=="delete"){
                deletemessage($HTTP_GET_VARS["msg_id"], $userdata["user_id"]);
                }
        else if ($op=="delete_messages"){
                deletemessages($HTTP_POST_VARS, $userdata["user_id"]);
                }
        else {
                if (isset($HTTP_POST_VARS["file"]) && isset($HTTP_POST_VARS["send"]) && isset($HTTP_POST_VARS["username"])){ # von Your_Account etc.
                        sendmessage(0, $HTTP_POST_VARS["username"]);
                        }
                else {
                        msgindex($userdata["user_id"]);
                        }
                }
        echo "\n<!-- end $module_name output -->\n\n";
        include('footer.php');
        }
 
Gremmie







PostPosted: Thu Sep 18, 2008 8:26 pm Reply with quote

CodyG wrote:

I'm looking at a lot of variables not enclosed in quotes. ie: $guest=1; should be #guest='1';
Right?


No, that's ok. I mean, it depends on what they are doing, but you can't say that is wrong. 1 in this case is integer 1.

CodyG wrote:

And then there is this mess which likely doesn't work with php5, right? Any ideas?


Why do you think it won't work with PHP5? I skimmed it and nothing jumped out at me that says "this won't work with 5".
 
CodyG







PostPosted: Thu Sep 18, 2008 8:55 pm Reply with quote

Thanks Gremmie! I just worry too much. Wink

What about iframes? The block file uses one. Any reason an iframe wouldn't work with RN2.3 and php/mysql 5?

Can you tell? I'm in guessing mode. Wink

I think I'll sleep on this disappearing text error and see what the morning brings.
 
Gremmie







PostPosted: Fri Sep 19, 2008 7:23 am Reply with quote

I'd have to see all the code and sit down and try and run it. It looks like the code is in pretty bad shape. Sorry.
 
Guardian2003
Site Admin



Joined: Aug 28, 2003
Posts: 6799
Location: Ha Noi, Viet Nam

PostPosted: Fri Sep 19, 2008 10:32 am Reply with quote

CodyG I may have missed something from your first post so I just want to clarify something for myself - this script sends instant messages (PM's) to users as against being a 'live chat' environment?
 
View user's profile Send private message Send e-mail
Gremmie







PostPosted: Fri Sep 19, 2008 11:07 am Reply with quote

Cody, another thing you can try is to turn on the RN database logging and see what database errors you are getting.
 
CodyG







PostPosted: Fri Sep 19, 2008 3:01 pm Reply with quote

Yes, the purpose is to facilitate private instant messages in both a pop-up and as a managable list, from user to user. It uses the default RN2.0 nuke_sessions table to populate a list of who is online, in the block, which also has links to the module files and functions. One link is to a list of offline users. (Oddly, this function is working.)

I'm guessing ... the module isn't authenticating my user session, therefore the db output fails. Another guess.

I use my error logs and rnlogs and I think I've cleared up the obvious the db issues. Wink There was one last fetch-array > fetchrowset I missed the previous time round. But I'll have to look at the functions again, I may have put a fetchrowset in a place where I want a fetchrow.

I'm not sure if I can follow the logic that allows the module to authenticate the user and therefore output the user's data. But this is based on the assumption that things are different in this environment than they were in RN2.0 php4.

Text cleaning is done with a bbcode thing. There are a ton of php notices about undefined variables and previously defined constants.
And there is a jabascript error in the module, this shows in IE status bar. It's an event of some sort. jabascript is 1.2 And those are the least of my worries. Smile

If it can't be resucitated, this module may belong in a museum. <sigh>

I've set up a couple of guest accounts on my test site. If intrigued send me a pm and I'll send you the details.
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Modules

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©