MyBB Community Forums

Full Version: we can edite a file.php like we can edite a template ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Maybe it s a stupide question. But i do a plugin and i need to know if with the plugins installation we can edit a file.php like we can edit a template ? If yes how ?

Because on online.php we can find this code :

if($mybb->usergroup['canviewonline'] == 0)
{
	error_no_permission();
}

and i need to remplace it by :

if($mybb->user['uid'] == 0 || $mybb->usergroup['canmodcp'] != 1)
{
    error_no_permission();
}


thank in advance
It is possible, yes. If I were you, I'd advise looking at frostschutz's PluginLibrary as it provides a method to alter core files amongst other features: http://community.mybb.com/forum-68.html
thanks for your answere i check that Wink
Yes i read something like that, first you have to put a code to change permission on the php file and then replace the code with some new, after this you have to put another code to put permission to php file aggain to denny access xD.

I do not probe it, but it's for sure it works, because i try some codes in here and all works if you write correctly that codes xD.

$PL->edit_core('my-plugin_name', 'online.php',
               array('search' => 'if($mybb->usergroup['canviewonline'] == 0)',
                     'replace' => 'if($mybb->user['uid'] == 0 || $mybb->usergroup['canmodcp'] != 1)'),
               true);


but after my plugin doesn't work maybe i'm not on the right way ? or i need something for my plugin accept this command ?

sorry for my english, thank in advance.
Have you actually included PluginLibrary and initialised it and stuff?
only installed, PluginLibrary on my forum test. and he is activated
Could you paste your full code here please?
My plugin name is : my-plugin_name
the php file i want edit is online.php


<?php


if(!defined("IN_MYBB"))
{
    die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

if(!defined("PLUGINLIBRARY"))
{
    define("PLUGINLIBRARY", MYBB_ROOT."inc/plugins/pluginlibrary.php");
}

function my-plugin_name_info()
{
    return array(
        "name" => "my-plugin_name",
        "description" => "!!!!",
        "website" => "!!!!",
        "author" => "emiak",
        "authorsite" => "!!!!!",
        "version" => "1.0",
        "compatibility" => "*",
        "guid" => "952860e468e6e9367948b6cb63ba2ec8"
        
    );
}

function my-plugin_name_activate()
global $PL;
$PL or require_once PLUGINLIBRARY;
{
$PL->edit_core('my-plugin_name', 'online.php',
               array('search' => 'if($mybb->usergroup['canviewonline'] == 0)',
                     'replace' => 'if($mybb->user['uid'] == 0 || $mybb->usergroup['canmodcp'] != 1)'),
               true);
}



function my-plugin_name_deactivate()
global $PL;
$PL or require_once PLUGINLIBRARY;
{
$PL->edit_core('my-plugin_name', 'online.php',
               array('search' => 'if($mybb->user['uid'] == 0 || $mybb->usergroup['canmodcp'] != 1)',
                     'replace' => 'if($mybb->usergroup['canviewonline'] == 0)'),
               true);
}

?>

i have erased some activate and deactivate function because they work correctly, and my plugins Submission is not approved for the moment, i dont want post all the code here but you can see all my code in the Submission plugins on MyBB Mods