PDA

View Full Version : HomePage permissions


Harley D
06-18-2003, 04:11 PM
I am a beginner hacker, and have tried many HomePage hacks on my clients VB site. All of them cause the site to slow down with all the queries and tables, So I have created my own HomePage hack using pieces of other hacks, mostly the "Extra page driven by forum templates" Hack.
But my client wanted userstats to show, This is what I came up with, And yes it works great, BUT I need to know how to get the permissions set to allow everone to view just this page.

If any of the code here, is not allowed to be shown, or breaks any rules, I will promptly remove it!

What I have done:
I created a template called index2

The original "pageviatemplates" Hack, says to paste this into the template:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!-- no cache headers -->
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="no-cache">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="Cache-Control" content="no-cache">
<!-- end no cache headers -->
<meta name="keywords" content="vbulletin,forum,bbs,discussion,jelsoft">
<meta name="description" content="$bbtitle is a discussion forum powered by vBulletin. To visit the forum, go to $bburl/ . To find out about vBulletin, go to http://www.vbulletin.com/ .">
<title>$bbtitle - powered by vBulletin</title>
$headinclude
</head>
<body>
$header

<!-- YOUR CONTENT GOES HERE -->

$footer
</body>
</html>


I pasted this instead:
See attached .txt file at the bottom of this post.

Then I created a text file, uploaded it to my /Forums dir. and renamed it
The original Hack "pageviatemplates", only says to add <?php
error_reporting(7);

require('./global.php');


eval("dooutput(\"".gettemplate('forumprivacy')."\");");

?>

I added this instead:

<?php
error_reporting(7);

$templatesused='forumhome_birthdaybit,forumhome_pm loggedin,forumhome_welcometext,forumhome_logoutcod e,forumhome_newposts,forumhome_todayposts,forumhom e_logincode,forumhome_loggedinuser,forumhome_logge dinusers,forumhome_lastpostby,forumhome_moderator, forumhome_forumbit_level1_nopost,forumhome_forumbi t_level1_post,forumhome_forumbit_level2_nopost,for umhome_forumbit_level2_post,forumhome,forumhome_un regmessage';
$loadbirthdays=1;
$loadmaxusers=1;


require('./global.php');

if ($bbuserinfo[userid]!=0) {
$avatarurl=getavatarurl($bbuserinfo[userid]);
if ($avatarurl=='') {
$avatarurl='images/avatars/noavatar.gif';
}
$avatarimage='<a href="member.php?s='.$session[sessionhash].'&action=editavatar"><img src="'.$avatarurl.'" border="0">';
} else {
$avatarimage='<a href="register.php?s='.$session[sessionhash].'&action=signup"><img src="images/avatars/guestavatar.gif" border="0"></a>';
}
//check usergroup of user to see if they can use PMs
//$permissions=getpermissions($forumid);
if ($enablepms==1 and $permissions['canusepm'] and $bbuserinfo['receivepm']) {
$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");

if ($newpm['messages']==0) {
$lightbulb='off';
} else {
$lightbulb='on';
}
eval("\$pminfo = \"".gettemplate('forumhome_pmloggedin')."\";");

} else {
$pminfo='';
}

$numbersmembers=$DB_site->query_first('SELECT COUNT(*) AS users,MAX(userid) AS max FROM user');
$numbermembers=number_format($numbersmembers['users']);

// get total posts
$countposts=$DB_site->query_first('SELECT COUNT(*) AS posts FROM post');
$totalposts=number_format($countposts['posts']);

$countthreads=$DB_site->query_first('SELECT COUNT(*) AS threads FROM thread');
$totalthreads=number_format($countthreads['threads']);

// get newest member
$getnewestusers=$DB_site->query_first("SELECT userid,username FROM user WHERE userid=$numbersmembers[max]");
$newusername=$getnewestusers['username'];
$newuserid=$getnewestusers['userid'];

// if user is know, then welcome
$getnewthread=$DB_site->query_first("SELECT COUNT(*) AS threads FROM thread WHERE lastpost > '$bbuserinfo[lastvisit]'");
$getnewpost=$DB_site->query_first("SELECT count(*) AS posts FROM post WHERE dateline > '$bbuserinfo[lastvisit]'");
if ($bbuserinfo['userid']!=0) {
$username=$bbuserinfo['username'];
eval("\$welcometext = \"".gettemplate('forumhome_welcometext')."\";");
eval("\$logincode = \"".gettemplate('forumhome_logoutcode')."\";");
eval("\$newposts = \"".gettemplate('forumhome_newposts')."\";");

} else {
$welcometext = "";
eval("\$newposts = \"".gettemplate('forumhome_todayposts')."\";");
eval("\$logincode = \"".gettemplate('forumhome_logincode')."\";");
}

$birthdaybits="";
if ($showbirthdays) {

$birthdays = gettemplate('birthdays',0,0);
$btoday = explode('|||',$birthdays);
$today = vbdate("Y-m-d",time());
if (($today != $btoday[0] and $today != $btoday[1]) or empty($birthdays)) { // Need to update!
if (empty($birthdays)) {
$DB_site->query("INSERT INTO template (templateid, templatesetid, title, template) VALUES (NULL, '-2', 'birthdays', '')");
}
getbirthdays();
$birthdays = $DB_site->query_first("SELECT template FROM template WHERE title='birthdays' and templatesetid = -2");
$birthdays = $birthdays[template];
$btoday = explode('|||',$birthdays);
}

if ($today == $btoday[0]) {
$birthdays = $btoday[2];
} elseif ($today == $btoday[1]) {
$birthdays = $btoday[3];
}

if ($birthdays) {
eval("\$birthdaybits = \"".gettemplate("forumhome_birthdaybit")."\";");
}
}
eval("dooutput(\"".gettemplate('index2')."\");");

?>


Now the reason for all the added stuff was to be able to pull the information needed to make the stats show properly.
I realize it may be overkill, but it works :)

So If anyone has any Idea how to get this page to show to all users, please advise. This page doesn't show up in the ADMINs MODIFY PERMISSIONS area, so changing the Permission there doesn't work.

I also wouldn't mind other comments and/or suggestions, but please be nice, I'm learning as I go.

Thank you