Re: Private Message mod v1.2.2
Connorhd: Is it possible to add the "There are new messages" the main page of my site? Similar to this? I've tried doing it myself using:
require(PUN_ROOT.'include/pms/header_new_messages.php');
You did this in header.php so I assumed it would work, and well, I assumed wrong.
Thanks in advance for the help.
Hi,
Try this approach, paste this on top of your php file where you want the message to appear, this is my complete header for my .php because I wanted to show even the postings, board stats, my images on the gallery and create a login on my homepage... (you can strip down other portions of this and experiment)
<?
define('PUN_ROOT', './');
@include PUN_ROOT.'config.php';
//for login issues
$punbb_path = $_SERVER['SCRIPT_FILENAME'];
$punbb_split = explode('/',$punbb_path);
$punbb_page = end($punbb_split);
$punbb_count = substr_count($punbb_path,'/')-2;
$punbb_path = str_repeat('../',$punbb_count).'./';
require PUN_ROOT.'include/common.php';
define('PUN_TURN_OFF_MAINT', 1); // if forums go down the site will not
define('PUN_QUIET_VISIT', 0); // update last visit when outside of the forums
// If PUN isn't defined, config.php is missing or corrupt
if (!defined('PUN'))
exit('The file \'config.php\' doesn\'t exist or is corrupt. Please run install.php to install PunBB first.');
// Disable error reporting for uninitialized variables
error_reporting(E_ALL);
// Turn off magic_quotes_runtime
set_magic_quotes_runtime(0);
// Get the forum config
$result = $db->query('SELECT * FROM '.$db->prefix.'config') or error('Unable to fetch forum config', __FILE__, __LINE__, $db->error());
while ($cur_config_item = $db->fetch_row($result))
$pun_config[$cur_config_item[0]] = $cur_config_item[1];
// Make sure we (guests) have permission to read the forums
$result = $db->query('SELECT g_read_board FROM '.$db->prefix.'groups WHERE g_id=3') or error('Unable to fetch group info', __FILE__, __LINE__, $db->error());
if ($db->result($result) == '0')
exit('No permission');
// Attempt to load the common language file
@include PUN_ROOT.'lang/'.$pun_config['o_default_lang'].'/common.php';
if (!isset($lang_common))
exit('There is no valid language pack \''.$pun_config['o_default_lang'].'\' installed. Please reinstall a language of that name.');
//
// Converts the CDATA end sequence ]]> into ]]>
//
function escape_cdata($str)
{
return str_replace(']]>', ']]>', $str);
}
// Load the index.php language file
require PUN_ROOT.'lang/'.$pun_config['o_default_lang'].'/index.php';
?>
Then to show the count for your messages and some links, paste the code below:
<?
$result_messages = $db->query('SELECT COUNT(id) FROM '.$db->prefix.'messages WHERE showed=0 AND owner='.$pun_user['id']) or error('Unable to check for new messages', __FILE__, __LINE__, $db->error());
if ($db->result($result_messages, 0)){
$notify = "<font color=red>You Have <b>".$db->result($result_messages, 0)."</b> New Message(s)</font>";
}else{
$notify = "(You Have No New Message)";
}
if($pun_user['id'] > 1)
{
echo "Welcome back <b>".$pun_user['username']."!</b> ".$notify."<br>";
echo "<a href=profile.php?id=".$pun_user['id'].">Edit Profile</a> - <a href=search.php?action=show_user&user_id=".$pun_user['id'].">View Your Posts</a> - <a href=message_list.php>Go To Inbox</a> - <a href=login.php?action=out&id=".$pun_user['id'].">Logout</a><br>Last Visit: ".format_time($pun_user['last_visit'])."<br>";
}
else
{
?>
<form id="login" method="post" action="/login.php?action=in" onsubmit="return process_form(this)">
<a href="login.php?action=forget"><b>Forgotten Password</b></a><br>
<input type="hidden" name="form_sent" value="1" />
<input type="hidden" name="redirect_url" value="<?php echo $_SERVER['SCRIPT_NAME'] ?>" />
<input type="text" name="req_username" size="10" maxlength="25" class="login" />
<input type="password" name="req_password" size="10" maxlength="16" class="login" />
<input type="submit" name="login" value="Login" />
</form>
<?
}
?>
That should do the trick...
Note:
This was taken off my board that includes a login box in place of the message box when not logged in as I have coded it so you may need to edit it accordingly to fit in your board...
If you use the complete code, you can also echo some of the portions of the board in your frontpage or any other page, using the header code above, you can try adding a quickjump on your other .php file then
EX. for quickjump drop down
<?
// Display the "Jump to" drop list
if ($pun_config['o_quickjump'] == '1')
{
// Load cached quickjump
@include PUN_ROOT.'cache/cache_quickjump_'.$pun_user['g_id'].'.php';
if (!defined('PUN_QJ_LOADED'))
{
require_once PUN_ROOT.'include/cache.php';
generate_quickjump_cache($pun_user['g_id']);
require PUN_ROOT.'cache/cache_quickjump_'.$pun_user['g_id'].'.php';
}
}
?>
Showing off your gallery randomly on your other .php file
<?php
$result = $db->query('SELECT id, poster, poster_id, message, posted FROM '.$db->prefix.'gallery_img ORDER BY RAND() LIMIT 4') or error('Unable to fetch user data', __FILE__, __LINE__, $db->error());
while ($data = $db->fetch_assoc($result))
{
echo "".'<a href=img/gallery/'.$data['poster_id'].'_'.$data['posted'].'.jpg target=_blank><img src="img/gallery/'.$data['poster_id'].'_thumbs_'.$data['posted'].'.jpg" alt="'.$data['poster'].' - '.$data['message'].'" border="0">'."</a> ";
}
?>
and so on and so forth... customizing punbb is endless, it only ends when you are burnt... lol