Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's
Author Message
maddog
New Member
New Member


Joined: Jul 07, 2005
Posts: 19

PostPosted: Fri Jul 08, 2005 5:17 pm Reply with quote

Hello i recently attempted to install the WelcomePM capability into my phpnuke site. After i did a temp sign up and loged in as a user the "Your_account" main page says i have a new message. But when i go check my inbox their is nothing their. Any idea where i might have made a flaw in the installing of this very usefull and nice script? I run phpnuke 7.7 as well as autotheme lite .8 and nukeSentinel.
 
View user's profile Send private message
Raven
Site Admin/Owner


Joined: Aug 27, 2002
Posts: 17086

PostPosted: Fri Jul 08, 2005 10:54 pm Reply with quote

Check your server error log to see if anything is being recorded.
 
View user's profile Send private message
maddog
PostPosted: Sat Jul 09, 2005 11:30 am Reply with quote

ya their is nothing saying anything about error. If you want i can send you the code i changed and see if i did something wrong or paste the code here or you can sign up on site and see for yourself.
 
Raven
PostPosted: Sat Jul 09, 2005 12:33 pm Reply with quote

Changed? You shouldn't be changing any code. You just need to add that code to the index.php file.
 
maddog
PostPosted: Sat Jul 09, 2005 12:35 pm Reply with quote

Yeah thats what i mean. the code i added.
 
maddog
PostPosted: Sun Jul 10, 2005 10:57 am Reply with quote

Here is the code that i added to the index.php: (whole activate function code):
Code:
function activate($username, $check_num) {

   global $db, $user_prefix, $module_name, $language;
   $past = time()-86400;
   $db->sql_query("DELETE FROM ".$user_prefix."_users_temp WHERE time < $past");
   $sql = "SELECT * FROM ".$user_prefix."_users_temp WHERE username='$username' AND check_num='$check_num'";
   $result = $db->sql_query($sql);
   if ($db->sql_numrows($result) == 1) {
      $row = $db->sql_fetchrow($result);
      if ($check_num == $row[check_num]) {
         $db->sql_query("INSERT INTO ".$user_prefix."_users (user_id, username, user_email, user_password, user_avatar, user_avatar_type, user_regdate, user_lang) VALUES (NULL, '$row[username]', '$row[user_email]', '$row[user_password]', 'gallery/blank.gif', 3, '$row[user_regdate]', '$language')");
         $db->sql_query("DELETE FROM ".$user_prefix."_users_temp WHERE username='$username' AND check_num='$check_num'");
         include("header.php");
         title(""._ACTIVATIONYES."");
         OpenTable();
         // BEGIN -- The following code is courtesy of Chatserv 2005 -- //
      $pmResult = $db->sql_query("SELECT user_id FROM ".$user_prefix."_users WHERE username='$row[username]'");
      $pmRow = $db->sql_fetchrow($pmResult);
      $guserid = intval($pmRow[user_id]);
      $db->sql_query("INSERT INTO ".$prefix."_bbgroups (group_name, group_description, group_single_user, group_moderator) VALUES ('', 'Personal User', '1', '0')");
      $group_id = $db->sql_nextid();
      $db->sql_query("INSERT INTO ".$prefix."_bbuser_group (user_id, group_id, user_pending) VALUES ('$guserid', '$group_id', '0')");
      // END -- The above code is courtesy of Chatserv 2005 -- //

      $pmResult = $db->sql_query("SELECT user_id FROM ".$user_prefix."_users WHERE username='"._PRIVMSGS_FROM_USERNAME."'");
      $pmRow = $db->sql_fetchrow($pmResult);
      $privmsgs_from_userid = intval($pmRow[user_id]);

      $register_pm_subject  = _REGISTER_PM_SUBJECT;
      $register_pm          = _REGISTER_PM;
      $privmsgs_date        = date("U");

      $sql = "UPDATE ".$user_prefix."_users SET user_new_privmsg='1', user_last_privmsg='65534', user_unread_privmsg='1', user_popup_pm='1', user_notify='1', user_notify_pm='1' WHERE user_id='$guserid'";
      if (!$db->sql_query($sql)) {
         echo sprintf(_MYSQL_ERROR,'USERS').mysql_error();
         CloseTable();
         include('footer.php');
      }
      $sql = "INSERT INTO ".$user_prefix."_bbprivmsgs (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig) VALUES ('0', '" . str_replace("\'", "''", addslashes(sprintf($register_pm_subject,$sitename))) . "', '$privmsgs_from_userid', '$guserid', '$privmsgs_date', '0', '1', '1', '0')";
      if (!$db->sql_query($sql)) {
         echo sprintf(_MYSQL_ERROR,'_BBPRIVMSGS').mysql_error();
         CloseTable();
         include('footer.php');
      }
      $privmsgs_text = $register_pm_subject;
      $privmsg_sent_id = $db->sql_nextid();
      $sql = "INSERT INTO ".$user_prefix."_bbprivmsgs_text (privmsgs_text_id, privmsgs_text) VALUES ($privmsg_sent_id, '" . str_replace("\'", "''", addslashes(sprintf($register_pm,$username,$sitename,$sitename))) . "')";
      if (!$db->sql_query($sql)) {
         echo sprintf(_MYSQL_ERROR,'_BBPRIVMSGS_TEXT').mysql_error();
         CloseTable();
         include('footer.php');
      }
         echo "<center><b>$row[username]:</b> "._ACTMSG."</center>";
         CloseTable();
         include("footer.php");
         die();
      } else {
         include("header.php");
         title(""._ACTIVATIONERROR."");
         OpenTable();
         echo "<center>"._ACTERROR1."</center>";
         CloseTable();
         include("footer.php");
         die();
      }
   } else {
      include("header.php");
      title(""._ACTIVATIONERROR."");
      OpenTable();
      echo "<center>"._ACTERROR2."</center>";
      CloseTable();
      include("footer.php");
      die();
   }

}

[b]This is the code that i added to the the bottom of the lang-english.php but right before the ?>:[/b]

// START - Send PM On User Register
/* Change the text 'Raven' in define("_PRIVMSGS_FROM_USERNAME","Raven"); to the name of the user that you want the Welcome message PM to be FROM
*/
global $sitename, $adminmail;
define("_MYSQL_ERROR","Unable to update %s table - MySQL said: ");
define("_PRIVMSGS_FROM_USERNAME","IGL Administration");
define("_REGISTER_PM_SUBJECT","Welcome to $sitename");
define("_REGISTER_PM","Hello!<br /><br />Welcome to $sitename. <br /><br />We hope you enjoy your time at this site! <br /><br />Feel free to join in and share with others or start your own discussion! <br /><br />Before posting please take time to read <a href=\"http://ravenphpscripts.com/postp41533.html\" title=\"Welcome to $sitename - Read Me First\">[b]this welcome message[/b]</a><br /><br />~Enjoy!<br />$sitename Staff");
// END - Send PM On User Register


far as i can see thats exactly how its suppose to be, i do not know why its not working because the PM utility does function i have successfully cent pm's already.
 
Raven
PostPosted: Sun Jul 10, 2005 11:17 am Reply with quote

Please restore the header/comment block to this code. By stripping it out you have removed the credits Sad. That is specifically stated in the header
License : GNU/GPL - Use it, modify it, but please respect the Credits

Then repost your code.
 
maddog
PostPosted: Sun Jul 10, 2005 11:46 am Reply with quote

Ah, sorry about that didn't mean to take any rights to it.
Here is the code that i added to the index.php: (whole activate function code):

Code:
function activate($username, $check_num) {

   global $db, $user_prefix, $module_name, $language;
   $past = time()-86400;
   $db->sql_query("DELETE FROM ".$user_prefix."_users_temp WHERE time < $past");
   $sql = "SELECT * FROM ".$user_prefix."_users_temp WHERE username='$username' AND check_num='$check_num'";
   $result = $db->sql_query($sql);
   if ($db->sql_numrows($result) == 1) {
      $row = $db->sql_fetchrow($result);
      if ($check_num == $row[check_num]) {
         $db->sql_query("INSERT INTO ".$user_prefix."_users (user_id, username, user_email, user_password, user_avatar, user_avatar_type, user_regdate, user_lang) VALUES (NULL, '$row[username]', '$row[user_email]', '$row[user_password]', 'gallery/blank.gif', 3, '$row[user_regdate]', '$language')");
         $db->sql_query("DELETE FROM ".$user_prefix."_users_temp WHERE username='$username' AND check_num='$check_num'");
         include("header.php");
         title(""._ACTIVATIONYES."");
         OpenTable();
         /**************************************************************************************************/
/* Mod Name     : Your_Account Mod to Send PM On User Register                                    */
/* Author       : Raven http://ravenphpscripts.com -- http://ravenwebhosting.com                  */
/* Version      : 1.0.0                                                                           */
/* Release Date : July 6, 2005                                                                    */
/* License      : GNU/GPL - Use it, modify it, but please respect the Credits                     */
/* Usage Notes  : Be sure that you have added the language text to the language file and that you */
/*                have modified it for your site.                                                 */
/**************************************************************************************************/
/* Other Credits:                                                                                 */
/*   -- Inspired by and Adapted from John B. Abela's © Forum Send PM On User Register Mod ©       */
/*      http://www.phpbb2mods.com                                                                 */
/*                                                                                                */
/*   -- Contributed by Chatserv 2005                                                              */
/*      Assign a group_id to new users to get rid of user and group permission errors in forums.  */
/*      http://www.nukefixes.com -- http://www.nukeresources.com                                  */
/**************************************************************************************************/

         // BEGIN -- The following code is courtesy of Chatserv 2005 -- //
      $pmResult = $db->sql_query("SELECT user_id FROM ".$user_prefix."_users WHERE username='$row[username]'");
      $pmRow = $db->sql_fetchrow($pmResult);
      $guserid = intval($pmRow[user_id]);
      $db->sql_query("INSERT INTO ".$prefix."_bbgroups (group_name, group_description, group_single_user, group_moderator) VALUES ('', 'Personal User', '1', '0')");
      $group_id = $db->sql_nextid();
      $db->sql_query("INSERT INTO ".$prefix."_bbuser_group (user_id, group_id, user_pending) VALUES ('$guserid', '$group_id', '0')");
      // END -- The above code is courtesy of Chatserv 2005 -- //

      $pmResult = $db->sql_query("SELECT user_id FROM ".$user_prefix."_users WHERE username='"._PRIVMSGS_FROM_USERNAME."'");
      $pmRow = $db->sql_fetchrow($pmResult);
      $privmsgs_from_userid = intval($pmRow[user_id]);

      $register_pm_subject  = _REGISTER_PM_SUBJECT;
      $register_pm          = _REGISTER_PM;
      $privmsgs_date        = date("U");

      $sql = "UPDATE ".$user_prefix."_users SET user_new_privmsg='1', user_last_privmsg='65534', user_unread_privmsg='1', user_popup_pm='1', user_notify='1', user_notify_pm='1' WHERE user_id='$guserid'";
      if (!$db->sql_query($sql)) {
         echo sprintf(_MYSQL_ERROR,'USERS').mysql_error();
         CloseTable();
         include('footer.php');
      }
      $sql = "INSERT INTO ".$user_prefix."_bbprivmsgs (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig) VALUES ('0', '" . str_replace("\'", "''", addslashes(sprintf($register_pm_subject,$sitename))) . "', '$privmsgs_from_userid', '$guserid', '$privmsgs_date', '0', '1', '1', '0')";
      if (!$db->sql_query($sql)) {
         echo sprintf(_MYSQL_ERROR,'_BBPRIVMSGS').mysql_error();
         CloseTable();
         include('footer.php');
      }
      $privmsgs_text = $register_pm_subject;
      $privmsg_sent_id = $db->sql_nextid();
      $sql = "INSERT INTO ".$user_prefix."_bbprivmsgs_text (privmsgs_text_id, privmsgs_text) VALUES ($privmsg_sent_id, '" . str_replace("\'", "''", addslashes(sprintf($register_pm,$username,$sitename,$sitename))) . "')";
      if (!$db->sql_query($sql)) {
         echo sprintf(_MYSQL_ERROR,'_BBPRIVMSGS_TEXT').mysql_error();
         CloseTable();
         include('footer.php');
      }
      /**************************************************************************************************/
/**************************************************************************************************/
         echo "<center><b>$row[username]:</b> "._ACTMSG."</center>";
         CloseTable();
         include("footer.php");
         die();
      } else {
         include("header.php");
         title(""._ACTIVATIONERROR."");
         OpenTable();
         echo "<center>"._ACTERROR1."</center>";
         CloseTable();
         include("footer.php");
         die();
      }
   } else {
      include("header.php");
      title(""._ACTIVATIONERROR."");
      OpenTable();
      echo "<center>"._ACTERROR2."</center>";
      CloseTable();
      include("footer.php");
      die();
   }

}



This is the code that i added to the the bottom of the lang-english.php but right before the ?>:

Code:


// START - Send PM On User Register
/* Change the text 'Raven' in define("_PRIVMSGS_FROM_USERNAME","Raven"); to the name of the user that you want the Welcome message PM to be FROM
*/
global $sitename, $adminmail;
define("_MYSQL_ERROR","Unable to update %s table - MySQL said: ");
define("_PRIVMSGS_FROM_USERNAME","IGL Administration");
define("_REGISTER_PM_SUBJECT","Welcome to $sitename");
define("_REGISTER_PM","Hello!<br /><br />Welcome to $sitename. <br /><br />We hope you enjoy your time at this site! <br /><br />Feel free to join in and share with others or start your own discussion! <br /><br />Before posting please take time to read <a href=\"http://ravenphpscripts.com/postp41533.html\" title=\"Welcome to $sitename - Read Me First\">[b]this welcome message[/b]</a><br /><br />~Enjoy!<br />$sitename Staff");
// END - Send PM On User Register


Far as i can see thats exactly how its suppose to be, i do not know why its not working because the PM utility does function i have successfully sent pm's already.
 
Raven
PostPosted: Sun Jul 10, 2005 12:43 pm Reply with quote

Let's start debugging Wink. First off, comment out
Code:
         // BEGIN -- The following code is courtesy of Chatserv 2005 -- //

      $pmResult = $db->sql_query("SELECT user_id FROM ".$user_prefix."_users WHERE username='$row[username]'");
      $pmRow = $db->sql_fetchrow($pmResult);
      $guserid = intval($pmRow[user_id]);
      $db->sql_query("INSERT INTO ".$prefix."_bbgroups (group_name, group_description, group_single_user, group_moderator) VALUES ('', 'Personal User', '1', '0')");
      $group_id = $db->sql_nextid();
      $db->sql_query("INSERT INTO ".$prefix."_bbuser_group (user_id, group_id, user_pending) VALUES ('$guserid', '$group_id', '0')");
      // END -- The above code is courtesy of Chatserv 2005 -- //
and try it.
 
maddog
PostPosted: Sun Jul 10, 2005 12:54 pm Reply with quote

alright i did that, this time it doesnt even say that i got any PM's waiting. It just looks normal like this script was never their.
 
Raven
PostPosted: Sun Jul 10, 2005 12:57 pm Reply with quote

My bad Embarassed. Don't comment this line
Code:
$guserid = intval($pmRow[user_id]);
 
maddog
PostPosted: Sun Jul 10, 2005 1:19 pm Reply with quote

ok fixing trying again after i make a quick adjustment for something else.
 
maddog
PostPosted: Sun Jul 10, 2005 1:24 pm Reply with quote

Yup tried it i have the same result as before.
 
Raven
PostPosted: Sun Jul 10, 2005 1:39 pm Reply with quote

Please post your _bbprivmsgs and _bbprivmsgs_text schema. Also, you say there are no errors in your error log. Make sure that in .htaccess you have the following line
Code:
php_flag display_errors on

Then check your error log.
 
maddog
PostPosted: Sun Jul 10, 2005 1:54 pm Reply with quote

Here is the _bbprivmsgs structure:
Code:


 Field  Type Attributes Null Default Extra Action
   privmsgs_id  mediumint(8)  UNSIGNED No    auto_increment             
   privmsgs_type  tinyint(4)   No  0               
   privmsgs_subject  varchar(255)   No  0               
   privmsgs_from_userid  mediumint(8)   No  0               
   privmsgs_to_userid  mediumint(8)   No  0               
   privmsgs_date  int(11)   No  0               
   privmsgs_ip  varchar(8)   No                 
   privmsgs_enable_bbcode  tinyint(1)   No  1               
   privmsgs_enable_html  tinyint(1)   No  0               
   privmsgs_enable_smilies  tinyint(1)   No  1               
   privmsgs_attach_sig  tinyint(1)   No  1               


When i went to go and browse this it did show the welcome messages and the test pm i tried

Here is the _bbprivmsgs_text structure:
Code:


 Field  Type Attributes Null Default Extra Action
   privmsgs_text_id  mediumint(8)  UNSIGNED No  0               
   privmsgs_bbcode_uid  varchar(10)   No  0               
   privmsgs_text  text   Yes  NULL               

This too showed the message the actual text of the pm

This is all i have in my .htaccess file:

Code:
Options All -Indexes

DirectoryIndex index.php index.htm index.html

# -------------------------------------------
# Start of NukeSentinel(tm) admin.php Auth
# -------------------------------------------
<Files .ftaccess>
  deny from all
</Files>

<Files .staccess>
  deny from all
</Files>

<Files admin.php>
   <Limit GET POST PUT>
      require valid-user
   </Limit>
   AuthName "Restricted"
   AuthType Basic
   AuthUserFile /path/to/your/.staccess
</Files>

# -------------------------------------------
# Start of NukeSentinel(tm) DENY FROM area
# -------------------------------------------
 
Raven
PostPosted: Sun Jul 10, 2005 1:59 pm Reply with quote

Well, add that line to .htaccess. So now I'm confused. If the 2 tables are showing the additions, why do you say it isn't there? Check the value of privmsgs_to_userid and verify that it is the user_id of the person you are logged in as.
 
maddog
PostPosted: Sun Jul 10, 2005 2:05 pm Reply with quote

the privmsgs_to_userid says 0. while the user_id 13 of the person who signed up. and same with the privmsgs_bbcode_uid is at 0 as well.
 
maddog
PostPosted: Sun Jul 10, 2005 4:05 pm Reply with quote

It looks to me like somehow the db isn't getting the new user id when an account is activated and is just using 0 by default when it sends the WelcomePM, so user doesnt ever actually recieve the actually PM.
 
Raven
PostPosted: Sun Jul 10, 2005 4:18 pm Reply with quote

I have PM'd you to try some code. Let me know.
 
maddog
PostPosted: Sun Jul 10, 2005 4:34 pm Reply with quote

Tried it their is no change if anything it messes up a little when users clicks on the confirmation e-mail. it works like orginal way. which is still not working hehe.
 
Raven
PostPosted: Sun Jul 10, 2005 4:45 pm Reply with quote

Well, I'm all out of suggestions at this point because it seems to work here. Actually, I PM'd you the wrong code. This is the code I use
Code:
/**************************************************************************************************/

/* Mod Name     : Your_Account Mod to Send PM On User Register                                    */
/* Author       : Raven http://ravenphpscripts.com -- http://ravenwebhosting.com                  */
/* Version      : 1.0.0                                                                           */
/* Release Date : July 6, 2005                                                                    */
/* License      : GNU/GPL - Use it, modify it, but please respect the Credits                     */
/* Usage Notes  : Be sure that you have added the language text to the language file and that you */
/*                have modified it for your site.                                                 */
/**************************************************************************************************/
/* Other Credits:                                                                                 */
/*   -- Inspired by and Adapted from John B. Abela's © Forum Send PM On User Register Mod ©       */
/*      http://www.phpbb2mods.com                                                                 */
/*                                                                                                */
/*   -- Contributed by Chatserv 2005                                                              */
/*      Assign a group_id to new users to get rid of user and group permission errors in forums.  */
/*      http://www.nukefixes.com -- http://www.nukeresources.com                                  */
/**************************************************************************************************/

      // BEGIN -- The following code is courtesy of Chatserv 2005 -- //
      $pmResult = $db->sql_query("SELECT user_id FROM ".$user_prefix."_users WHERE username='$row[username]'");
      $pmRow = $db->sql_fetchrow($pmResult);
      $guserid = intval($pmRow[user_id]);
      $db->sql_query("INSERT INTO ".$prefix."_bbgroups (group_name, group_description, group_single_user, group_moderator) VALUES ('', 'Personal User', '1', '0')");
      $group_id = $db->sql_nextid();
      $db->sql_query("INSERT INTO ".$prefix."_bbuser_group (user_id, group_id, user_pending) VALUES ('$guserid', '$group_id', '0')");
      // END -- The above code is courtesy of Chatserv 2005 -- //

      $pmResult = $db->sql_query("SELECT user_id FROM ".$user_prefix."_users WHERE username='"._PRIVMSGS_FROM_USERNAME."'");
      $pmRow = $db->sql_fetchrow($pmResult);
      $privmsgs_from_userid = intval($pmRow[user_id]);

      $register_pm_subject  = _REGISTER_PM_SUBJECT;
      $register_pm          = _REGISTER_PM;
      $privmsgs_date        = date("U");

      $sql = "UPDATE ".$user_prefix."_users SET user_new_privmsg='1', user_last_privmsg='65534', user_unread_privmsg='1', user_popup_pm='1', user_notify='1', user_notify_pm='1' WHERE user_id='$guserid'";
      if (!$db->sql_query($sql)) {
         echo sprintf(_MYSQL_ERROR,'USERS').mysql_error();
         CloseTable();
         include('footer.php');
      }
      $sql = "INSERT INTO ".$user_prefix."_bbprivmsgs (privmsgs_type, privmsgs_subject, privmsgs_from_userid, privmsgs_to_userid, privmsgs_date, privmsgs_enable_html, privmsgs_enable_bbcode, privmsgs_enable_smilies, privmsgs_attach_sig) VALUES ('5', '" . str_replace("\'", "''", addslashes(sprintf($register_pm_subject,$sitename))) . "', '$privmsgs_from_userid', '$guserid', '$privmsgs_date', '0', '1', '1', '0')";
      if (!$db->sql_query($sql)) {
         echo sprintf(_MYSQL_ERROR,'_BBPRIVMSGS').mysql_error();
         CloseTable();
         include('footer.php');
      }
      $privmsgs_text = $register_pm_subject;
      $privmsg_sent_id = $db->sql_nextid();
      $sql = "INSERT INTO ".$user_prefix."_bbprivmsgs_text (privmsgs_text_id, privmsgs_text) VALUES ($privmsg_sent_id, '" . str_replace("\'", "''", addslashes(sprintf($register_pm,$username,$sitename,$sitename))) . "')";
      if (!$db->sql_query($sql)) {
         echo sprintf(_MYSQL_ERROR,'_BBPRIVMSGS_TEXT').mysql_error();
         CloseTable();
         include('footer.php');
      }
/**************************************************************************************************/
/**************************************************************************************************/
 
maddog
PostPosted: Sun Jul 10, 2005 4:58 pm Reply with quote

Yeah still no change. Do you or can u recommend another program maybe even a module that does the same type or sort of thing, either within pm or here. Either way thanks for your support and assistance.
 
Raven
PostPosted: Sun Jul 10, 2005 6:10 pm Reply with quote

I just saw that you are using this define
Code:
define("_PRIVMSGS_FROM_USERNAME","IGL Administration");

Is "IGL Administration" a regsistered user on your site?
 
maddog
PostPosted: Sun Jul 10, 2005 6:17 pm Reply with quote

No it is not. I didnt know it had to be lol
 
Raven
PostPosted: Sun Jul 10, 2005 6:19 pm Reply with quote

Quote:
/* Change the text 'Raven' in define("_PRIVMSGS_FROM_USERNAME","Raven"); to the name of the user that you want the Welcome message PM to be FROM
*/

Only registered users can send PM's Smile
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> How To's

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 ©