Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Jul 2012
    Posts
    70
    Thanks
    5
    Thanked 0 Times in 0 Posts

    How To Syntax This?

    I am making A http://mybb.com plugin, everything is going great so far, Except one issue. I am trying to add the functionality on who can view the announcement (yes it's an announcement plugin)

    How can I add it in the code if I add
    if($user_is_admin==true)
    die;

    All that will do is kill the whole software instead of the plugin itself.


    Please make sure you have the Mybb software installed http://mybb.com then install the plugin if you can help.

    Thanks.




    Thanks,

    Spudster
    Attached Files Attached Files
    Last edited by Spudster; 07-09-2013 at 07:33 AM.

  • #2
    New Coder
    Join Date
    Jul 2012
    Posts
    70
    Thanks
    5
    Thanked 0 Times in 0 Posts
    no reply?

    Need help as soon as possible. i'm stump and I don't want to change the whole code around to add it. Shouldn't be to hard.

  • #3
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,902
    Thanks
    15
    Thanked 226 Times in 226 Posts
    For someone who needs a lot of help soon, you're not being very forward with information about what you want to do, and the nature of the problem.
    PHP Code:
    if($user_is_admin==true// do admin stuff here.
    else include "./warning.php";
    die; 
    Welcome to http://www.myphotowizard.net

    where you can edit images, make a photo calendar, add text to images, and do much more.


    When you know what you're doing it's called Engineering, when you don't know, it's called Research and Development. And you can always charge more for Research and Development.

  • #4
    New Coder
    Join Date
    Jul 2012
    Posts
    70
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Ok Thanks.

    I wasn't sure how to include it.

    I try to solve problems myself now on.

    Thanks

  • #5
    New Coder
    Join Date
    Jul 2012
    Posts
    70
    Thanks
    5
    Thanked 0 Times in 0 Posts
    I have tried that better whenever die is called it kills the whole forum instead of the plugin itself.

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by Spudster View Post
    I have tried that better whenever die is called it kills the whole forum instead of the plugin itself.
    Which is normal. Die doesn't terminate an inclusion, it halts the processor.
    If you want it to stop, you have one of two options. The first is to deal only within the branches which is what I'd recommend, and the other is to issue a return which halts the current script that was included and returns the control to the caller. Consider it as a recursive call to the main() method, where the return of the inclusion only terminates the inner main.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #7
    New Coder
    Join Date
    Jul 2012
    Posts
    70
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Ok.

    Thanks that should work, Thought return was only used for returning vars.

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    It is, but you can also return from a logical main. A value is not required, but it is atypical to return void.
    When you return in a script, you are returning control to the caller, halting this script termination (assuming you're running the script main), and return the result. So in php, it is perfectly valid to do this:
    PHP Code:
    <?php
    // 1

    return 4;
    ?>
    <?php

    $res 
    = include '1.php';
    print(
    "Include returned: %d" PHP_EOL$res);
    It is just uncommon to do so (specifically because you require the return in the script main, which is not common and hence why I recommended the use of logical branches instead).
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #9
    New Coder
    Join Date
    Jul 2012
    Posts
    70
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Will that seemed to mork pefectly

    Here is what I have done

    PHP Code:
    if $mybb->usergroup['cancp']!=true) {
    return 
    false


    In other words if he is not an admin then return false; which seems to termniate the script by returning false

    Thabks for the help :.)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •