vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Main Site Page Login/Private Message Hack Request (https://vborg.vbsupport.ru/showthread.php?t=41937)

Mithan 08-05-2002 03:05 PM

Main Site Page Login/Private Message Hack Request
 
I was wondering if there is a way to just do a login/log off on the front page of my site, and have it show your Private Message (if any) hack?

I have seen a few remote login hacks, but none shows the Private Messages.

Is this possible?

Logician 08-05-2002 04:54 PM

1- make it a php file (rename it as index.php)
2- add:

PHP Code:

<?php require('boardurl/global.php'); ?>

in the begining of this file..

3- before ?> part you can query the db to get pms

PHP Code:

if ($bbuserinfo[userid]>=1)
{
$ignoreusers="";
  if (
trim($bbuserinfo['ignorelist'])!="") {
    
$ignoreusers='AND fromuserid<>'.implode(' AND fromuserid<>',explode(' 'trim($bbuserinfo['ignorelist'])));
  }
$allpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] $ignoreusers");
  
$newpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND dateline>$bbuserinfo[lastvisit] AND folderid=0 $ignoreusers");
  
$unreadpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND messageread=0 AND folderid=0 $ignoreusers");


Now you can use variables ($unreadpm, $newpm, $allpm) to refer main page visitor's pms if he is a member..

Well this is basically the structure you need but a little bit PHP knowledge to apply will help a lot..

Mithan 08-05-2002 05:18 PM

Hi and thanks for the quick reply, but maybe you can help me a little bit more.

First, my site is www.ac2hq.com

In the top navbar, near Skins, I was hoping to put the login, password info. That little area is a seperate little template php file called skins.php that gets called.

Anyways, I put this in that file but no luck.


PHP Code:

<?php
require('http://www.ac2hq.com/forum/global.php'); 

if (
$bbuserinfo[userid]>=1)
{
$ignoreusers="";
  if (
trim($bbuserinfo['ignorelist'])!="") {
    
$ignoreusers='AND fromuserid<>'.implode(' AND fromuserid<>',explode(' 'trim($bbuserinfo['ignorelist'])));
  }
$allpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] $ignoreusers");
  
$newpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND dateline>$bbuserinfo[lastvisit] AND folderid=0 $ignoreusers");
  
$unreadpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND messageread=0 AND folderid=0 $ignoreusers");
}

echo 
"
$unreadpm $newpm $allpm
"
;

?>


Any idea what I did wrong?

Logician 08-05-2002 06:44 PM

1- did u get a error message?
2- have you loaded the page after you logged-in to your board?

Let's test it, try this code and it will give you the clues:
PHP Code:

<?php
// enter your URL below. It's the URL relative to your host:
chdir('/home/www/forum/');
require(
'./global.php'); 

if (
$bbuserinfo[userid]>=1)
{
$ignoreusers="";
  if (
trim($bbuserinfo['ignorelist'])!="") {
    
$ignoreusers='AND fromuserid<>'.implode(' AND fromuserid<>',explode(' 'trim($bbuserinfo['ignorelist'])));
  }
$allpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] $ignoreusers");
  
$newpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND dateline>$bbuserinfo[lastvisit] AND folderid=0 $ignoreusers");
  
$unreadpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND messageread=0 AND folderid=0 $ignoreusers");
}

echo 
$unreadpm $newpm $allpm";

echo 
"<br>userid=".$bbuserinfo['userid'].'<br>';
echo 
"username=".$bbuserinfo['username'].'<br>';


?>


Mithan 08-05-2002 06:54 PM

Ok this is what I get:

Array Array Array
userid=1
username=Mithan

Unlogged in people get:
userid=0
username=Unregistered



PS thanks again for the help :)

Logician 08-05-2002 07:04 PM

sorry my bad, replace line:

echo " $unreadpm $newpm $allpm";

AS:

PHP Code:

echo "Unread PMs=".$unreadpm['messages'].'<br>';
echo 
"New PMs=".$newpm['messages'].'<br>';
echo 
"All PMs".$allpm['messages'].'<br>'

it will display the pm numbers correctly..

As for login info you can add this code:
PHP Code:

if ($bbuserinfo[userid]>=1)
{
?>
Use here any HTML code that will be displayed to your members

<?php
}
else 
{
?>
Use here any HTML code that will be displayed to your non-members..
<?php
}

Hope this helps..

Mithan 08-05-2002 07:39 PM

Ok that all seems to be working great. One last question, where can I find a Log in code that will work with this? (ie- allow you log in remotly).

Logician 08-05-2002 08:02 PM

PHP Code:

<table border="0" bgcolor="#000000" cellpadding="4" cellspacing="1" align="center">
<
form action="http://wwww.yoursite.com/forum/member.php" method="post"><input type="hidden" name="s" value="1502242d035662dae7418a6042f8eb6e">
<
tr valign="top">
<
td bgcolor="#EEEEEE"><font face="verdana, arial, helvetica" size="2" ><b>Your User Name:</b></font></td>
<
td bgcolor="#EEEEEE"><font face="verdana, arial, helvetica" size="2" ><input type="text" class="bginput" name="username" size="25">      &nbsp;&nbsp;</font>
<
font face="verdana,arial,helvetica" size="1" ><a href="http://wwww.yoursite.com/forum/register.php?action=signup">Want to register?</a></font></td>
</
tr><tr valign="top">
<
td bgcolor="#FFFFFF"><font face="verdana, arial, helvetica" size="2" ><b>Your Password:</b></font></td>
<
td bgcolor="#FFFFFF"><font face="verdana, arial, helvetica" size="2" ><input type="password" class="bginput" name="password" value="" size="25">&nbsp;&nbsp;</font>
<
font face="verdana,arial,helvetica" size="1" ><a href="http://wwww.yoursite.com/forum/member.php?action=lostpw">Forgotten your password?</a></font></td></tr>
</
table

Enjoy..

Mithan 08-05-2002 08:24 PM

Actually I found that the table within vB worked...

Quote:

<table border="0" cellpadding="0" cellspacing="0">
<form action="http://www.ac2hq.com/forum/member.php" method="post">
<tr>
<td nowrap><smallfont><b>Not cookied?</b><br>Login with username and password:</smallfont></td>
</tr><tr>
<td nowrap><input type="hidden" name="s" value="$session[sessionhash]">
<input type="hidden" name="action" value="login">
<input type="text" class="bginput" name="username" size="7">
<input type="password" class="bginput" name="password" size="7">
<input type="submit" class="bginput" value="Login!"></td>
</tr>
</form>
</table>

Now to just figure out the code to make that Private Message think clickable, so it takes you to your messages :)

Logician 08-05-2002 08:30 PM

Quote:

Originally posted by Mithan
Now to just figure out the code to make that Private Message think clickable, so it takes you to your messages :)
$pmlink="http://www.yoururl.com/forum/private.php?s=".$session[sessionhash];

echo "<href=".$pmlink.">your PMs></a>";

Mithan 08-05-2002 08:45 PM

I put

$pmlink="http://www.yoururl.com/forum/private.php?s=".$session[sessionhash];

near the top of the original code, and the echo part in as well, but all its returning is a

your PMs

Any idea?

Logician 08-05-2002 08:53 PM

yep forget 1 extra char in the code.. use this:

echo "<href=".$pmlink.">your PMs</a>";

Mithan 08-05-2002 09:03 PM

Hmmm, still not working. I had taken that littke > out before as well...

This is the full code.


Quote:

<?php
// enter your URL below. It's the URL relative to your host:
chdir("/home/ac2hq/www/forum/");

require('./global.php');

if ($bbuserinfo[userid]>=1)

{
$ignoreusers="";
if (trim($bbuserinfo['ignorelist'])!="") {
$ignoreusers='AND fromuserid<>'.implode(' AND fromuserid<>',explode(' ', trim($bbuserinfo['ignorelist'])));
}
$allpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] $ignoreusers");
$newpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND dateline>$bbuserinfo[lastvisit] AND folderid=0 $ignoreusers");
$unreadpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND messageread=0 AND folderid=0 $ignoreusers");
$pmlink="http://www.ac2hq.com/forum/private.php?s=".$session[sessionhash];
}

if ($bbuserinfo[userid]>=1)
{

echo "Welcome ".$bbuserinfo['username']. ". You have ".$unreadpm['messages']. " Private Message." . '<br>';
echo "<href=".$pmlink.">your PMs</a>";

?>

<?php
}
else
{
?>
<form action="http://www.ac2hq.com/forum/member.php" method="post">
<font size="2">Please Login: </font>
<input type="hidden" name="s" value="$session[sessionhash]">
<input type="hidden" name="action" value="login">
<input type="text" class="bginput" name="username" size="2">
<input type="password" class="bginput" name="password" size="2">
<input type="submit" class="bginput" value="Login!">
</form>


<?php
}

chdir("/home/ac2hq/www/");
?>

Logician 08-05-2002 09:10 PM

sorry it is:

echo "<a href=".$pmlink.">your PMs</a>";

I guess I need a sleep.. :knockedout:

Mithan 08-05-2002 09:16 PM

bla
I should of seen that too....

Anyways thanks for the info. Do you mind if I clean this up and possible post it on the Hacks forum or something? I think this is something people would really like.

Full credit goes to you of course...

Mithan 08-05-2002 09:33 PM

One last error im getting:

Warning: Cannot add header information - headers already sent by (output started at /home/www/ac2hq/index.php:86) in /home/www/ac2hq/forum/admin/functions.php on line 1582

Everything works fine, but I get this until I log into the forum, then it goes away...

Any clue?

[D]Vincent 08-05-2002 09:43 PM

Vincent]This doesn't really have to do with anything but I don't see the point in having the
PHP Code:

?>

<?php

in

PHP Code:

echo "Welcome ".$bbuserinfo['username']. ". You have ".$unreadpm['messages']. " Private Message." . '<br>';
echo "<href=".$pmlink.">your PMs</a>";

?>

<?php
}


Logician 08-05-2002 10:33 PM

Quote:

Do you mind if I clean this up and possible post it on the Hacks forum or something? I think this is something people would really like.
IMO it's not worth releasing especially considering the fact that there are better and more powerful main page alternatives already released. But I personally dont mind your releasing it if you want to. However I must say that I can NOT support (=answer questions) the release thread since I have already too many hacks of my own to support..

BTW. the code is really raw, you'd better clean it up and polish it if you are determined to release it (like the lines Vincent mentioned) and be ready to get plenty of "how can I add this into that hack" questions. :glasses:

Quote:

Warning: Cannot add header information - headers already sent by (output started at /home/www/ac2hq/index.php:86) in /home/www/ac2hq/forum/admin/functions.php on line 1582
What's line 86?

Mithan 08-05-2002 11:36 PM

This is what goes at line 86...


Quote:

<? //error checker thingy, don't want the whole thing to fail if one include can't cut it
// this one is the header code (title, css, etc, this will let us change the header in the future

if(!file_exists("include/$header.php") ) {
include("include/headercode.php");
} else {
include("include/$header.php");
}



?>
Unsure why that would interfere with anything... strange.


All times are GMT. The time now is 06:23 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01206 seconds
  • Memory Usage 1,841KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (9)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (19)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete