2006-01-09, 09:53 AM
chdir("forums"); // path to MyBB
require "./global.php";
if($mybb->user['uid'])
{
// logged in
}
else
{
// logged out
}
I use that code, but I get some wierd error.
http://gamesrule.mihopa.com/test.php
chdir("forums"); // path to MyBB
require "./global.php";
if($mybb->user['uid'])
{
// logged in
}
else
{
// logged out
}
chdir("forums"); // path to MyBB
require "./global.php";
<?php
if($mybb->user['uid'])
{
// logged in
Thanks
}
else
{
// logged out
<form action="forums/member.php" method="post">
Username: <input type="text" name="username" size="25" maxlength="30" /><br />
Password: <input type="password" name="password" size="25" />
<input type="hidden" name="action" value="do_login">
<input type="hidden" name="url" value="index.php" />
<input type="submit" class="submit" name="submit" value="Login" /> <br>
<br>
You may login with your forum username and password when you registered.<br>
<br>
If you haven't Registered, Please do so by clicking
<a href="forums/member.php?action=register">here</a>.<br>
<br>
Please note we do not openly distribute your details.</form>
}
?>
Quote:16 users active in the past 15 minutes (1 members, 0 of whom are invisible, and 0 guests).Just a note, I am including the global.php with this code:
usernames here with link to their profile page
chdir("forum"); // path to MyBB
require "./global.php";
if($loadpmpopup)
{
$onload = "onload=\"javascript:newPM();\"";
}
<?php if($mybb->settings['portal_showwol'] != "no")
{
$timesearch = time() - $mybb->settings['wolcutoff'];
$comma = "";
$guestcount = 0;
$membercount = 0;
$query = $db->query("SELECT s.sid, s.ip, s.uid, s.time, s.location, u.username, u.invisible, u.usergroup, u.displaygroup FROM ".TABLE_PREFIX."sessions s LEFT JOIN ".TABLE_PREFIX."users u ON (s.uid=u.uid) WHERE s.time>'$timesearch' ORDER BY u.username ASC, s.time DESC");
while($user = $db->fetch_array($query))
{
if($user['uid'] == "0")
{
$guestcount++;
}
else
{
if($doneusers[$user['uid']] < $user['time'] || !$doneusers[$user['uid']])
{
$doneusers[$user['uid']] = $user['time'];
$membercount++;
if($user['invisible'] != "yes" || $mybb->usergroup['canviewwolinvis'] == "yes")
{
if($user['invisible'] == "yes")
{
$invisiblemark = "*";
}
else
{
$invisiblemark = "";
}
$user['username'] = formatname($user['username'], $user['usergroup'], $user['displaygroup']);
eval("\$onlinemembers .= \"".$templates->get("portal_whosonline_memberbit", 1, 0)."\";");
$comma = ", ";
}
}
}
}
$onlinecount = $membercount + $guestcount + $anoncount;
// Most users online
$mostonline = $cache->read("mostonline");
if($onlinecount > $mostonline['numusers'])
{
$time = time();
$mostonline['numusers'] = $onlinecount;
$mostonline['time'] = $time;
$cache->update("mostonline", $mostonline);
}
$recordcount = $mostonline['numusers'];
$recorddate = mydate($mybb->settings['dateformat'], $mostonline['time']);
$recordtime = mydate($mybb->settings['timeformat'], $mostonline['time']);
$lang->online_users = sprintf($lang->online_users, $onlinecount);
$lang->online_counts = sprintf($lang->online_counts, $membercount, $guestcount);
eval("\$whosonline = \"".$templates->get("portal_whosonline")."\";");
}
// Latest forum discussions
if($mybb->settings['portal_showdiscussions'] != "no" && $mybb->settings['portal_showdiscussionsnum'])
{
$altbg = "trow1";
$query = $db->query("SELECT t.*, u.username FROM ".TABLE_PREFIX."threads t LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=t.uid) WHERE 1=1 $unviewwhere AND t.visible='1' AND t.closed NOT LIKE 'moved|%' ORDER BY t.lastpost DESC LIMIT 0, ".$mybb->settings['portal_showdiscussionsnum']);
while($thread = $db->fetch_array($query))
{
if($thread['lastpost'] != "" && $thread['lastposter'] != "")
{
$lastpostdate = mydate($mybb->settings['dateformat'], $thread['lastpost']);
$lastposttime = mydate($mybb->settings['timeformat'], $thread['lastpost']);
eval("\$lastpost = \"".$templates->get("portal_latestthreads_thread_lastpost")."\";");
}
else
{
$lastpost = "";
}
$thread['subject'] = stripslashes($thread['subject']);
if(strlen($thread['subject']) > 25)
{
$thread['subject'] = substr($thread['subject'], 0, 25) . "...";
}
$thread['subject'] = htmlspecialchars_uni($thread['subject']);
eval("\$threadlist .= \"".$templates->get("portal_latestthreads_thread")."\";");
if($altbg == "trow1")
{
$altbg = "trow2";
}
else
{
$altbg = "trow1";
}
}
if($threadlist)
{ // show the table only if there are threads
eval("\$latestthreads = \"".$templates->get("portal_latestthreads")."\";");
}
}
// Get latest news announcements
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."forums WHERE fid='".$mybb->settings['portal_announcementsfid']."'");
$forum = $db->fetch_array($query);
$pids = "";
$comma="";
$query = $db->query("SELECT p.pid, p.message, p.tid FROM ".TABLE_PREFIX."posts p LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid AND t.dateline=p.dateline) WHERE t.fid='".$mybb->settings['portal_announcementsfid']."' AND t.visible='1' AND t.closed NOT LIKE 'moved|%' ORDER BY t.dateline DESC LIMIT 0, ".$mybb->settings['portal_numannouncements']);
while($getid = $db->fetch_array($query))
{
$pids .= ",'$getid[pid]'";
$posts[$getid['tid']] = $getid;
}
$pids = "pid IN(0$pids)";
// Now lets fetch all of the attachments for these posts
$query = $db->query("SELECT * FROM ".TABLE_PREFIX."attachments WHERE $pids");
while($attachment = $db->fetch_array($query))
{
$attachcache[$attachment['pid']][$attachment['aid']] = $attachment;
}
$forumpermissions = forum_permissions($mybb->settings['portal_announcementsfid']);
$query = $db->query("SELECT t.*, i.name as iconname, i.path as iconpath, t.username AS threadusername, u.username, u.avatar FROM ".TABLE_PREFIX."threads t LEFT JOIN ".TABLE_PREFIX."icons i ON (i.iid = t.icon) LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid = t.uid) WHERE fid='".$mybb->settings['portal_announcementsfid']."' AND t.visible='1' AND t.closed NOT LIKE 'moved|%' ORDER BY t.dateline DESC LIMIT 0, ".$mybb->settings['portal_numannouncements']);
while($announcement = $db->fetch_array($query))
{
$announcement['message'] = $posts[$announcement['tid']]['message'];
$announcement['pid'] = $posts[$announcement['tid']]['pid'];
$announcement['author'] = $announcement['uid'];
if(!$announcement['username'])
{
$announcement['username'] = $announcement['threadusername'];
}
$announcement['subject'] = htmlspecialchars_uni(stripslashes($announcement['subject']));
if($announcement['iconpath'])
{
$icon = "<img src=\"$announcement[iconpath]\" alt=\"$announcement[iconname]\">";
}
else
{
$icon = " ";
}
if($announcement['avatar'] != "")
{
$avatar = "<td class=\"trow\" class=\"trow1\" width=1 align=\"center\" valign=\"top\"><img src=\"$announcement[avatar]\"></td>";
}
else
{
$avatar = "";
}
$anndate = mydate($mybb->settings['dateformat'], $announcement['dateline']);
$anntime = mydate($mybb->settings['timeformat'], $announcement['dateline']);
if($announcement['replies'])
{
eval("\$numcomments = \"".$templates->get("portal_announcement_numcomments")."\";");
}
else
{
eval("\$numcomments = \"".$templates->get("portal_announcement_numcomments_no")."\";");
$lastcomment = "";
}
if(is_array($attachcache[$announcement['pid']]))
{ // This post has 1 or more attachments
$validationcount = 0;
$id = $announcement['pid'];
foreach($attachcache[$id] as $aid => $attachment)
{
if($attachment['visible'])
{ // There is an attachment thats visible!
$attachment['name'] = htmlspecialchars_uni($attachment['name']);
$attachment['filesize'] = getfriendlysize($attachment['filesize']);
$ext = getextention($attachment['filename']);
if($ext == "jpeg" || $ext == "gif" || $ext == "bmp" || $ext == "png" || $ext == "jpg")
{
$isimage = true;
}
else
{
$isimage = false;
}
$attachment['icon'] = getattachicon($ext);
// Support for [attachment=id] code
if(stripos($announcement['message'], "[attachment=".$attachment['aid']."]") !== false)
{
if($attachment['thumbnail'] != "SMALL" && $attachment['thumbnail'] != "")
{ // We have a thumbnail to show (and its not the "SMALL" enough image
eval("\$attbit = \"".$templates->get("postbit_attachments_thumbnails_thumbnail")."\";");
}
elseif($attachment['thumbnail'] == "SMALL" && $forumpermissions['candlattachments'] == "yes")
{
// Image is small enough to show - no thumbnail
eval("\$attbit = \"".$templates->get("postbit_attachments_images_image")."\";");
}
else
{
// Show standard link to attachment
eval("\$attbit = \"".$templates->get("postbit_attachments_attachment")."\";");
}
$announcement['message'] = preg_replace("#\[attachment=".$attachment['aid']."]#si", $attbit, $announcement['message']);
}
else
{
if($attachment['thumbnail'] != "SMALL" && $attachment['thumbnail'] != "")
{ // We have a thumbnail to show
eval("\$post['thumblist'] .= \"".$templates->get("postbit_attachments_thumbnails_thumbnail")."\";");
if($tcount == 5)
{
$thumblist .= "<br />";
$tcount = 0;
}
$tcount++;
}
elseif($attachment['thumbnail'] == "SMALL" && $forumpermissions['candlattachments'] == "yes")
{
// Image is small enough to show - no thumbnail
eval("\$post['imagelist'] .= \"".$templates->get("postbit_attachments_images_image")."\";");
}
else
{
eval("\$post['attachmentlist'] .= \"".$templates->get("postbit_attachments_attachment")."\";");
}
}
}
else
{
$validationcount++;
}
}
if($post['thumblist'])
{
eval("\$post['attachedthumbs'] = \"".$templates->get("postbit_attachments_thumbnails")."\";");
}
if($post['imagelist'])
{
eval("\$post['attachedimages'] = \"".$templates->get("postbit_attachments_images")."\";");
}
if($post['attachmentlist'] || $post['thumblist'] || $post['imagelist'])
{
eval("\$post['attachments'] = \"".$templates->get("postbit_attachments")."\";");
}
}
$plugins->run_hooks("portal_announcement");
$message = postify($announcement['message'], $forum['allowhtml'], $forum['allowmycode'], $forum['allowsmilies'], $forum['allowimgcode']);
eval("\$announcements .= \"".$templates->get("portal_announcement")."\";");
unset($post);
}
eval("\$portal = \"".$templates->get("portal")."\";");