MyBB Community Forums

Full Version: Only mods or admins can access the page
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
I have a custom made php page in MyBB, but i want to know the code so only moderators or admins can access the page. Or how to add a custom admin page?

Thanks.
Regards
http://
if(!$mybb->usergroup['canmodcp'])
    error_no_permission();
(2016-07-23, 04:00 PM).m. Wrote: [ -> ]see this reply

Notice: Undefined variable: mybb in C:\xampp\htdocs\mybb\results.php on line 2

Notice: Trying to get property of non-object in C:\xampp\htdocs\mybb\results.php on line 2
(2016-07-23, 04:38 PM)http:// Wrote: [ -> ]
(2016-07-23, 04:00 PM).m. Wrote: [ -> ]see this reply

Notice: Undefined variable: mybb in C:\xampp\htdocs\mybb\results.php on line 2

Notice: Trying to get property of non-object in C:\xampp\htdocs\mybb\results.php on line 2

Please post your current code.
(2016-07-23, 04:39 PM)Sazze Wrote: [ -> ]
(2016-07-23, 04:38 PM)http:// Wrote: [ -> ]
(2016-07-23, 04:00 PM).m. Wrote: [ -> ]see this reply

Notice: Undefined variable: mybb in C:\xampp\htdocs\mybb\results.php on line 2

Notice: Trying to get property of non-object in C:\xampp\htdocs\mybb\results.php on line 2

Please post your current code.

<?php
if (in_array($mybb->user['usergroup'] , array(1,7)))error_no_permission();


$connection = mysql_connect('localhost', 'root', ''); //The Blank string is the password
mysql_select_db('mybb');

$query = "SELECT * FROM staffapps"; //You don't need a ; like you do in SQL
$result = mysql_query($query);

echo "<table border='20'>"; // start a table tag in the HTML

while($row = mysql_fetch_array($result)){   //Creates a loop to loop through results
echo
"<tr>
<td>" . $row['realname'] . "</td>" .
"<td>" . $row['forums'] . "</td>" .
"<td>" . $row['ingame'] . "</td>" .
"<td>" . $row['account'] . "</td>" .
"<td>" . $row['dateb'] . "</td>" .
"<td>" . $row['nationality'] . "</td>" .
"<td>" . $row['englishskills'] . "</td>" .
"<td>" . $row['timezone'] . "</td>" .
"<td>" . $row['dailypt'] . "</td>" .
"<td>" . $row['totalpt'] . "</td>" .
"<td>" . $row['punishlog'] . "</td>" .
"<td>" . $row['aboutyou'] . "</td>" .
"<td>" . $row['groups'] . "</td>" .
"<td>" . $row['inactive'] . "</td>
</tr>";
 //$row['index'] the index here is a field name
}

echo "</table>"; //Close the table in HTML

mysql_close(); //Make sure to close out the database connection



?>
(2016-07-23, 04:40 PM)http:// Wrote: [ -> ]
(2016-07-23, 04:39 PM)Sazze Wrote: [ -> ]
(2016-07-23, 04:38 PM)http:// Wrote: [ -> ]
(2016-07-23, 04:00 PM).m. Wrote: [ -> ]see this reply

Notice: Undefined variable: mybb in C:\xampp\htdocs\mybb\results.php on line 2

Notice: Trying to get property of non-object in C:\xampp\htdocs\mybb\results.php on line 2

Please post your current code.

<?php
if (in_array($mybb->user['usergroup'] , array(1,7)))error_no_permission();


$connection = mysql_connect('localhost', 'root', ''); //The Blank string is the password
mysql_select_db('mybb');

$query = "SELECT * FROM staffapps"; //You don't need a ; like you do in SQL
$result = mysql_query($query);

echo "<table border='20'>"; // start a table tag in the HTML

while($row = mysql_fetch_array($result)){   //Creates a loop to loop through results
echo
"<tr>
<td>" . $row['realname'] . "</td>" .
"<td>" . $row['forums'] . "</td>" .
"<td>" . $row['ingame'] . "</td>" .
"<td>" . $row['account'] . "</td>" .
"<td>" . $row['dateb'] . "</td>" .
"<td>" . $row['nationality'] . "</td>" .
"<td>" . $row['englishskills'] . "</td>" .
"<td>" . $row['timezone'] . "</td>" .
"<td>" . $row['dailypt'] . "</td>" .
"<td>" . $row['totalpt'] . "</td>" .
"<td>" . $row['punishlog'] . "</td>" .
"<td>" . $row['aboutyou'] . "</td>" .
"<td>" . $row['groups'] . "</td>" .
"<td>" . $row['inactive'] . "</td>
</tr>";
 //$row['index'] the index here is a field name
}

echo "</table>"; //Close the table in HTML

mysql_close(); //Make sure to close out the database connection



?>

Uhm that's now how you are supposed to do it.

<?php

define('IN_MYBB', 1);
define('THIS_SCRIPT', basename(__FILE__));
require_once './global.php';
add_breadcrumb('Staff Applications');

$query = $db->simple_select('staffaps', '*', NULL);

while($row = $db->fetch_array($query))
{
	eval("\$staffaps_rows .= \"".$templates->get('staffaps_rows')."\";");
}

eval("\$staffaps = \"".$templates->get('staffaps')."\";");
output_page($staffaps);

?>

Next thing you need to do is:
1. Go to global templates and create a new template called "staffaps", this is where the results show should
2. Create another one called "staffaps_rows" with this content:
<tr>
<td>{$row['realname']}</td>
<td>{$row['forums']}</td>
<td>{$row['ingame']}</td>
<td>{$row['account']}</td>
<td>{$row['dateb']}</td>
<td>{$row['nationality']}</td>
<td>{$row['englishskills']}</td>
<td>{$row['timezone']}</td>
<td>{$row['dailypt']}</td>
<td>{$row['totalpt']}</td>
<td>{$row['punishlog']}</td>
<td>{$row['aboutyou']}</td>
<td>{$row['groups']}</td>
<td>{$row['inactive']}</td>
</tr>

Once that's done, you can enter this variable in your staffaps template to show the results:

{staffaps_rows}

NOTE: There are XSS vulnerabilities, but I'm not if all the data is text.

Let me know if it all works well.
(2016-07-23, 04:53 PM)Sazze Wrote: [ -> ]
(2016-07-23, 04:40 PM)http:// Wrote: [ -> ]
(2016-07-23, 04:39 PM)Sazze Wrote: [ -> ]
(2016-07-23, 04:38 PM)http:// Wrote: [ -> ]
(2016-07-23, 04:00 PM).m. Wrote: [ -> ]see this reply

Notice: Undefined variable: mybb in C:\xampp\htdocs\mybb\results.php on line 2

Notice: Trying to get property of non-object in C:\xampp\htdocs\mybb\results.php on line 2

Please post your current code.

<?php
if (in_array($mybb->user['usergroup'] , array(1,7)))error_no_permission();


$connection = mysql_connect('localhost', 'root', ''); //The Blank string is the password
mysql_select_db('mybb');

$query = "SELECT * FROM staffapps"; //You don't need a ; like you do in SQL
$result = mysql_query($query);

echo "<table border='20'>"; // start a table tag in the HTML

while($row = mysql_fetch_array($result)){   //Creates a loop to loop through results
echo
"<tr>
<td>" . $row['realname'] . "</td>" .
"<td>" . $row['forums'] . "</td>" .
"<td>" . $row['ingame'] . "</td>" .
"<td>" . $row['account'] . "</td>" .
"<td>" . $row['dateb'] . "</td>" .
"<td>" . $row['nationality'] . "</td>" .
"<td>" . $row['englishskills'] . "</td>" .
"<td>" . $row['timezone'] . "</td>" .
"<td>" . $row['dailypt'] . "</td>" .
"<td>" . $row['totalpt'] . "</td>" .
"<td>" . $row['punishlog'] . "</td>" .
"<td>" . $row['aboutyou'] . "</td>" .
"<td>" . $row['groups'] . "</td>" .
"<td>" . $row['inactive'] . "</td>
</tr>";
 //$row['index'] the index here is a field name
}

echo "</table>"; //Close the table in HTML

mysql_close(); //Make sure to close out the database connection



?>

Uhm that's now how you are supposed to do it.

<?php

define('IN_MYBB', 1);
define('THIS_SCRIPT', basename(__FILE__));
require_once './global.php';
add_breadcrumb('Staff Applications');

$query = $db->simple_select('staffaps', '*', NULL);

while($row = $db->fetch_array($query))
{
 eval("\$staffaps_rows .= \"".$templates->get('staffaps_rows')."\";");
}

eval("\$staffaps = \"".$templates->get('staffaps')."\";");
output_page($staffaps);

?>

Next thing you need to do is:
1. Go to global templates and create a new template called "staffaps", this is where the results show should
2. Create another one called "staffaps_rows" with this content:
<tr>
<td>{$row['realname']}</td>
<td>{$row['forums']}</td>
<td>{$row['ingame']}</td>
<td>{$row['account']}</td>
<td>{$row['dateb']}</td>
<td>{$row['nationality']}</td>
<td>{$row['englishskills']}</td>
<td>{$row['timezone']}</td>
<td>{$row['dailypt']}</td>
<td>{$row['totalpt']}</td>
<td>{$row['punishlog']}</td>
<td>{$row['aboutyou']}</td>
<td>{$row['groups']}</td>
<td>{$row['inactive']}</td>
</tr>

Once that's done, you can enter this variable in your staffaps template to show the results:

{staffaps_rows}

NOTE: There are XSS vulnerabilities, but I'm not if all the data is text.

Let me know if it all works well.

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1146 - Table 'mybb.mybb_staffapps' doesn't exist
Query:
SELECT * FROM mybb_staffapps

EDIT
I renamed the table to mybb_staffapps
give me second.

EDIT 2
I have rows in that table now but the php page shows blank with no errors
(2016-07-23, 05:01 PM)http:// Wrote: [ -> ]
(2016-07-23, 04:53 PM)Sazze Wrote: [ -> ]
(2016-07-23, 04:40 PM)http:// Wrote: [ -> ]
(2016-07-23, 04:39 PM)Sazze Wrote: [ -> ]
(2016-07-23, 04:38 PM)http:// Wrote: [ -> ]Notice: Undefined variable: mybb in C:\xampp\htdocs\mybb\results.php on line 2

Notice: Trying to get property of non-object in C:\xampp\htdocs\mybb\results.php on line 2

Please post your current code.

<?php
if (in_array($mybb->user['usergroup'] , array(1,7)))error_no_permission();


$connection = mysql_connect('localhost', 'root', ''); //The Blank string is the password
mysql_select_db('mybb');

$query = "SELECT * FROM staffapps"; //You don't need a ; like you do in SQL
$result = mysql_query($query);

echo "<table border='20'>"; // start a table tag in the HTML

while($row = mysql_fetch_array($result)){   //Creates a loop to loop through results
echo
"<tr>
<td>" . $row['realname'] . "</td>" .
"<td>" . $row['forums'] . "</td>" .
"<td>" . $row['ingame'] . "</td>" .
"<td>" . $row['account'] . "</td>" .
"<td>" . $row['dateb'] . "</td>" .
"<td>" . $row['nationality'] . "</td>" .
"<td>" . $row['englishskills'] . "</td>" .
"<td>" . $row['timezone'] . "</td>" .
"<td>" . $row['dailypt'] . "</td>" .
"<td>" . $row['totalpt'] . "</td>" .
"<td>" . $row['punishlog'] . "</td>" .
"<td>" . $row['aboutyou'] . "</td>" .
"<td>" . $row['groups'] . "</td>" .
"<td>" . $row['inactive'] . "</td>
</tr>";
 //$row['index'] the index here is a field name
}

echo "</table>"; //Close the table in HTML

mysql_close(); //Make sure to close out the database connection



?>

Uhm that's now how you are supposed to do it.

<?php

define('IN_MYBB', 1);
define('THIS_SCRIPT', basename(__FILE__));
require_once './global.php';
add_breadcrumb('Staff Applications');

$query = $db->simple_select('staffaps', '*', NULL);

while($row = $db->fetch_array($query))
{
 eval("\$staffaps_rows .= \"".$templates->get('staffaps_rows')."\";");
}

eval("\$staffaps = \"".$templates->get('staffaps')."\";");
output_page($staffaps);

?>

Next thing you need to do is:
1. Go to global templates and create a new template called "staffaps", this is where the results show should
2. Create another one called "staffaps_rows" with this content:
<tr>
<td>{$row['realname']}</td>
<td>{$row['forums']}</td>
<td>{$row['ingame']}</td>
<td>{$row['account']}</td>
<td>{$row['dateb']}</td>
<td>{$row['nationality']}</td>
<td>{$row['englishskills']}</td>
<td>{$row['timezone']}</td>
<td>{$row['dailypt']}</td>
<td>{$row['totalpt']}</td>
<td>{$row['punishlog']}</td>
<td>{$row['aboutyou']}</td>
<td>{$row['groups']}</td>
<td>{$row['inactive']}</td>
</tr>

Once that's done, you can enter this variable in your staffaps template to show the results:

{staffaps_rows}

NOTE: There are XSS vulnerabilities, but I'm not if all the data is text.

Let me know if it all works well.

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1146 - Table 'mybb.mybb_staffapps' doesn't exist
Query:
SELECT * FROM mybb_staffapps

Do you have Phpmyadmin installed? Check the table prefix, it should be like this

[Image: xxibwh.png]
QL Error:
1146 - Table 'mybb.mybb_staffapps' doesn't exist
Query:
SELECT * FROM mybb_staffapps

EDIT
I renamed the table to mybb_staffapps
give me second.

EDIT 2
I have rows in that table now but the php page shows blank with no errors
Pages: 1 2