MyBB Community Forums

Full Version: Integration
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I want to add the loginbox with the lastest posts in my web by means of an include, but it gives me a error.

The source code is: link
<?php
$rel = "foro/";
chdir($rel);
require $rel."global.php";
?>

<html>
<head>
	<title>Pasionwe - Gadget</title>
<script>
function submitted()
{
 setTimeout("refresh()",6000);
}
function refresh()
{
 var sURL = unescape(window.location.pathname);
 window.location.href = sURL;
}
</script> 
<style type="text/css">
.contenedor  {
background-color:	#FBFFFF;
border-style:	solid;
border-width:	1px;
font-family:	Verdana, Arial, Sans-Serif;
font-size:	8pt;
margin:	0;
padding:	4px;
}

body  {
background-color:	#FBFBFB;
margin:	0;
padding:	0;
}
</style>
</head>
<body>
<div class="contenedor">
<?php
if($mybb->user["uid"])
{
?>
&nbsp;• <a href="<?php echo $rel; ?>private.php">Ver Msjs Privados</a><br />
&nbsp;• <a href="<?php echo $rel; ?>usercp.php">User CP</a><br /><br /><br />

<?php
$host = "fdb1.awardspace.com"; // Your database host
$user = "pasionwe_foro"; // Your database username
$pass = "pasala"; // Your database password
$data = "pasionwe_foro"; // The name of your database
$prfx = "mybb_"; // The table prefix of your database
$col1 = "#FFFFFF"; // The color of the first row--alternating row colours
$col2 = "#FCFCFC"; // The color of the second row
// NOTE: I didn't include ./global.php because I wasn't sure what the variables look like.
$num = 6; // The number of recent posts to show
$author = TRUE; // Should we display the post author? (TRUE or FALSE)

$conn = mysql_connect($host,$user,$pass) or die("<b>Error:</b> Fallo la conexion con la BD");
$sel = mysql_select_db($data,$conn) or die("<b>Error:</b> Fallo la conecion con la BD");

if($author == TRUE)
{
?>
<table>
<?php
}
$i = 0;
$q = mysql_query("SELECT * FROM ".$prfx."posts ORDER BY dateline DESC LIMIT ".$num);
while($row = mysql_fetch_array($q))
{
 if($i % 2 == 0)
 {
  $bgcolor = $col1;
 }
 else
 {
  $bgcolor = $col2;
 }
 $i++;
 $q2 = mysql_query("SELECT * FROM ".$prfx."forums WHERE fid = '".$row["fid"]."';");
 $row = mysql_fetch_array($q2);
?>
 <tr>
  <td width="50%" bgcolor="<?php echo $bgcolor; ?>">
<a title="In forum: <?php echo $row["name"]; ?>" href="<?php echo $rel; ?>showthread.php?tid=<?php echo $row["tid"]; ?>&action=lastpost">
<b><?php echo $row["subject"]; ?></b></a></p></td>
<?php
 if($author == TRUE)
 {
?>
  <td width="50%" bgcolor="<?php echo $bgcolor; ?>">by 
<b><a title="<?php echo $row["username"]; ?>'s Profile" href="<?php echo $rel; ?>member.php?action=profile&uid=<?php echo $row["uid"]; ?>">
<?php echo $row["username"]; ?></b></a></td>
<?php
 }
?>
 </tr>
<?php
}
?>
</table> 
<?php
}
else
{
?>
<table>
 <form method="POST" action="<?php echo $rel; ?>member.php" onsubmit="return submitted();">
  <input type="hidden" name="action" value="do_login">
  <input type="hidden" name="url" value="">
  <tr>
   <td>Nombre de usuario</td>
   <td><input type="text" name="username" size="15"></td>
  </tr>
  <tr>
   <td>Password</td>
   <td><input type="password" name="password" size="15"></td>
  </tr>
  <tr>
   <td colspan="2"><center><input type="submit" value="Ingresar" name="submit"></center></td>
  </tr>
 </form>
</table>
<?php
}
?>

</div>

cheers!
Add
define("IN_MYBB", 1);
After
<?php
Either change to the MyBB directory (foro in your case) OR include the MyBB directory name in front of global.php; do not do both.

<?php
define(IN_MYBB, 1);
$rel = "foro/";
require $rel."global.php";
?>

Se precisar de ajuda em português, pode pedir-me por PM.
1. Thank you very much, work well!, but it shows me neither the topics and the authors of the lastests posts.

2. How I can add [hello, "username"] at the top

Cheers...
Leandro17 Wrote:1. Thank you very much, work well!, but it shows me neither the topics and the authors of the lastests posts.

2. How I can add [hello, "username"] at the top

Cheers...


echo "[Hello {$mybb->user['username']}!]";
DCR Wrote:
echo "[Hello {$mybb->user['username']}!]";

Thank you for answering, but it doesn´t transform this variable...

I have other questions..

How can I do in order that when the user enters by means of the loginbox it is not forwarded to the portal, in the same place?

does Exsist a script it shows the recent POSTS in the same file?
There are a couple of plugins in the mod section that will make it very easy to disply the new posts on other pages.

As for the login redirect change the form parameter so the the url of your page is sent to mybb.

<input type="hidden" name="url" value="PUT YOUR URL IN HERE">

Fishntassie...
Leandro17 Wrote:
DCR Wrote:
echo "[Hello {$mybb->user['username']}!]";

Thank you for answering, but it doesn´t transform this variable...

You need to place it after your "require './global.php.';" and it should replace the variable with the username (if the user is not a guest)
fishntassie Wrote:
<input type="hidden" name="url" value="PUT YOUR URL IN HERE">
DennisTT Wrote:You need to place it after your "require './global.php.';" and it should replace the variable with the username (if the user is not a guest)

Thank you very much both codes work ok!

fishntassie Wrote:There are a couple of plugins in the mod section that will make it very easy to disply the new posts on other pages.

I view in mods.mybboard.net but I did not find any that shows the last posts, the only similar mod is to show the recent threads...
...
Sorry for asking so muchRolleyes .. how can I add the content of portal_welcome_membertext and portal_latestthreads in this file?

Cheers!