MyBB Community Forums

Full Version: [Page Manager] Share your custom pages
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
(2012-09-21, 02:10 AM)MadComp Wrote: [ -> ]
(2012-09-20, 11:06 PM)Leefish Wrote: [ -> ]well, it works on user id, I have never tried it on usergroups.

It might work, so

class="thead hide_{$mybb->user['usergroup']} in the inline with a css class of .hide_7{display:none;} might hide it to banned as banned have a usergroup of 7.

NOT TESTED.
That's not the right code as it looks the same as the code above. It'll just hide that link from user #7.

Hmm, I think it might be correct you know. The second one says look at the users usergroup - the first code said to look at the user id. Two very different things.

For template conditionals, I use this:

<if in_array($GLOBALS['mybb']->user['usergroup'], array(4,5,6)) then>
 stuff for usergroup 4,5,6
</if>
Yeah, I think I need to hide the entire page not just the toplink. My problem is that I don't know php...my custom pages are all html and I get nothing but errors everytime I try to add the php do not allow bit. Here is one of my pages curently...

<P>
<div style="line-height:33px;"><span style="color:#000000;font-family:Arial;font-size:19px;">18 Pa.C.S. §505. Use of Force in Self-Protection.</span></div>
<div style="line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;"><br></span></div>
<div style="line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(a) Use of force justifiable for protection of the person.--The use of force upon or toward another person is justifiable when the </span></div>
<div style="line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">actor believes that such force is immediately necessary for the purpose of protecting himself against the use of unlawful force by </span></div>
<div style="line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">such other person on the present occasion.</span></div>
<div style="line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(b) Limitations on justifying necessity for use of force.--</span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(1) The use of force is not justifiable under this section:</span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; (i) to resist an arrest which the actor knows is being made by a peace officer, although the arrest is unlawful; or</span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(ii) to resist force used by the occupier or possessor of property or by another person on his behalf, where the actor </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">knows that the person using the force is doing so under a claim of right to protect the property, except that this limitation </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">shall not apply if:</span></div>
<div style="margin-left:108px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(A) the actor is a public officer acting in the performance of his duties or a person lawfully assisting him therein or a </span></div>
<div style="margin-left:108px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">person making or assisting in a lawful arrest;</span></div>
<div style="margin-left:108px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(B) the actor has been unlawfully dispossessed of the property and is making a reentry or recaption justified by </span></div>
<div style="margin-left:108px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">section 507 of this title (relating to use of force for the protection of property); or</span></div>
<div style="margin-left:108px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(C) the actor believes that such force is necessary to protect himself against death or serious bodily injury.</span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(2) The use of deadly force is not justifiable under this section unless the actor believes that such force is necessary to </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">protect himself against death, serious bodily injury, kidnapping or sexual intercourse compelled by force or threat; nor is it </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">justifiable if: </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(i) the actor, with the intent of causing death or serious bodily injury, provoked the use of force against himself in the </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">same encounter; or </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(ii) the actor knows that he can avoid the necessity of using such force with complete safety by retreating, except the </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">actor is not obliged to retreat from his dwelling or place of work, unless he was the initial aggressor or is assailed in his </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">place of work by another person whose place of work the actor knows it to be. </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(2.1) Except as otherwise provided in paragraph (2.2), an actor is presumed to have a reasonable belief that deadly force is </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">immediately necessary to protect himself against death, serious bodily injury, kidnapping or sexual intercourse compelled by </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">force or threat if both of the following conditions exist: </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(i) The person against whom the force is used is in the process of unlawfully and forcefully entering, or has unlawfully and </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">forcefully entered and is present within, a dwelling, residence or occupied vehicle; or the person against whom the force </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">is used is or is attempting to unlawfully and forcefully remove another against that other's will from the dwelling, </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">residence or occupied vehicle. </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(ii) The actor knows or has reason to believe that the unlawful and forceful entry or act is occurring or has occurred. </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(2.2) The presumption set forth in paragraph (2.1) does not apply if: </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(i) the person against whom the force is used has the right to be in or is a lawful resident of the dwelling, residence or </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">vehicle, such as an owner or lessee; </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(ii) the person sought to be removed is a child or grandchild or is otherwise in the lawful custody or under the lawful </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">guardianship of the person against whom the protective force is used; </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(iii) the actor is engaged in a criminal activity or is using the dwelling, residence or occupied vehicle to further a criminal </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">activity; or </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(iv) the person against whom the force is used is a peace officer acting in the performance of his official duties and the </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">actor using force knew or reasonably should have known that the person was a peace officer. </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(2.3) An actor who is not engaged in a criminal activity, who is not in illegal possession of a firearm and who is attacked in </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">any place where the actor would have a duty to retreat under paragraph (2)(ii) has no duty to retreat and has the right to stand </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">his ground and use force, including deadly force, if: </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(i) the actor has a right to be in the place where he was attacked; </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(ii) the actor believes it is immediately necessary to do so to protect himself against death, serious bodily injury, </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">kidnapping or sexual intercourse by force or threat; and </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(iii) the person against whom the force is used displays or otherwise uses: </span></div>
<div style="margin-left:108px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(A) a firearm or replica of a firearm as defined in 42 Pa.C.S. § 9712 (relating to sentences for offenses committed </span></div>
<div style="margin-left:108px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">with firearms); or </span></div>
<div style="margin-left:108px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(B) any other weapon readily or apparently capable of lethal use.</span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(2.4) The exception to the duty to retreat set forth under paragraph (2.3) does not apply if the person against whom the force </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">is used is a peace officer acting in the performance of his official duties and the actor using force knew or reasonably should </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">have known that the person was a peace officer. </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(2.5) Unless one of the exceptions under paragraph (2.2) applies, a person who unlawfully and by force enters or attempts to </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">enter an actor's dwelling, residence or occupied vehicle or removes or attempts to remove another against that other's will </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">from the actor's dwelling, residence or occupied vehicle is presumed to be doing so with the intent to commit: </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(i) an act resulting in death or serious bodily injury; or </span></div>
<div style="margin-left:72px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(ii) kidnapping or sexual intercourse by force or threat. </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(2.6) A public officer justified in using force in the performance of his duties or a person justified in using force in his </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">assistance or a person justified in using force in making an arrest or preventing an escape is not obliged to desist from </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">efforts to perform such duty, effect such arrest or prevent such escape because of resistance or threatened resistance by or </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">on behalf of the person against whom such action is directed. </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(3) Except as otherwise required by this subsection, a person employing protective force may estimate the necessity thereof </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">under the circumstances as he believes them to be when the force is used, without retreating, surrendering possession, </span></div>
<div style="margin-left:36px;line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">doing any other act which he has no legal duty to do or abstaining from any lawful action. </span></div>
<div style="line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(c) Use of confinement as protective force.--The justification afforded by this section extends to the use of confinement as </span></div>
<div style="line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">protective force only if the actor takes all reasonable measures to terminate the confinement as soon as he knows that he safely </span></div>
<div style="line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">can, unless the person confined has been arrested on a charge of crime. </span></div>
<div style="line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">(d) Definition.--As used in this section, the term &quot;criminal activity&quot; means conduct which is a misdemeanor or felony, is not </span></div>
<div style="line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;">justifiable under this chapter and is related to the confrontation between an actor and the person against whom force is used.</span></div>
<div style="line-height:27px;"><span style="color:#000000;font-family:Arial;font-size:16px;"><br></span></div>
<div style="line-height:28px;"><span style="color:#000000;font-family:Arial;font-size:16px;"><em>Act 1972-334 (S.B. 455), P.L. 1482, § 1, approved Dec. 6, 1972, eff. in 6 months; Act 2011-10 (H.B. 40), P.L. 48 § 2, approved </em></span></div>
<div style="line-height:19px;"><span style="color:#000000;font-family:Arial;font-size:16px;"><em>June 28, 2011, eff. in 60 days.</em></span></div>
It displays like this now:
http://www.pa2a.org/misc.php?page=self_protection

So, the big question is, how can I add this:
if(!$mybb->user['uid']) error_no_permission();
To the above code? Blush
IN page manager to allow PHP in the page you must select No on the option to automatically include MyBB headers and footers. This requires you to code a routine in PHP to store your page template and then output it.

See the Parser example given by the OP (if you need to parse bbcode) or just use an example like the php.xml provided by OP. It isn't really that complicated you will just have to do a bit of recoding.
Yeah, all you have to remember is to include {header} and {footer} if you want to include the MyBB header and footer on your page.
Use this code Rocketfoot

<?php

global $headerinclude, $header, $theme, $footer, $lang;

if(!$mybb->user['uid']) error_no_permission();
//if ($mybb->user['uid']!=1) error_no_permission();
//if (in_array($mybb->user['usergroup'] , array(1,5,7)))error_no_permission();

$template='<html>
<head>
<title>'.$pages['name'].'</title>
{$headerinclude}
</head>
<body>
{$header}
<table border="0" cellspacing="1" cellpadding="4" class="tborder">
<tr><td class="thead" colspan="4">My Page Title</td></tr>
<tr><td>

DIV WITH CONTENT HERE

</td></tr>
</table>

{$footer}
</body>
</html>';

$template=str_replace("\'", "'", addslashes($template));

add_breadcrumb($pages['name']);

eval("\$page=\"".$template."\";");

output_page($page);

?>

I included options for just one user id or a set of user groups. Just comment/uncomment as you need
When I enter my html with <div> it errors the page:


Parse error: syntax error, unexpected T_STRING in /home/bigmackt/public_html/pa2a.org/inc/plugins/pagemanager.php(799) : eval()'d code on line 65

It's not your code...it's something with my code.

http://www.pa2a.org/misc.php?page=test
I bet you have an apostrophe somewhere in your text. You need to escape them :

so,

I don't believe it, it wasn't there before

needs to be as so

I don\'t believe it, it wasn\'t there before

try that
I was thinking apostrophe's...LOL! They get you every time!

Nope, still didn't work...are there any other punctuations that mess up php?
\ < > = ! ? & [ ] all need to be encoded as their ASCII equivalents.

(Except when part of a code ie.
<?php ?>
would be okay as is.)

JM.02
Anybody else have any other cool custom pages??
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49