Author Topic: How to Build a new module for CentOS Web Panel (CWP)  (Read 28940 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
How to Build a new module for CentOS Web Panel (CWP)
« on: May 23, 2014, 09:20:00 AM »
How to Build a new module for CentOS Web Panel (CWP)??

It’s very easy to build new module for CentOS-WebPanel

Let’s create file named: test2.php
Code: [Select]
<?php

$cpu_info 
shell_exec("cat /proc/cpuinfo");
echo 
"This is example module<br>";
echo 
"You can edit this file and make new modules based on this file<br>";
echo 
"Examples and functions are on our website: centos-webpanel.com<br>";
echo 
"<h3>CPU INFO</h3>";
echo 
"<pre>".$cpu_info."</pre>";

?>


to open this file in CentOS-WebPanel upload it to modules folder and use this link path:

Code: [Select]
http://SERVER_IP:2030/index.php?module=FILE_NAME
eg. http://123.123.123.123:2030/index.php?module=test2

How to add this module to CentOS-WebPanel menu?
It’s easy, go to include folder and make new file named 3rdparty.php ,in this file you add links one per line.
eg.

/usr/local/cwpsrv/htdocs/resources/admin/include/3rdparty.php
Code: [Select]
<li><a href="index.php?module=test2"><span class="icon16 icomoon-icon-arrow-right-3"></span>Test2 Module</a></li>
<li><a href="index.php?module=test3"><span class="icon16 icomoon-icon-arrow-right-3"></span>Test3 Module</a></li>

All useful modules will be added in CWP installation or additional module installation panel.

Admin panel modules location
/usr/local/cwpsrv/htdocs/resources/admin/modules

Client panel modules location
/usr/local/cwpsrv/htdocs/resources/client/modules

Example module developed by the 3rdParty
https://github.com/boxbillinggit/cwp_modules/blob/master/php_phalcon.php
« Last Edit: February 04, 2015, 02:26:06 AM by Administrator »
AntiDDoS Protection (web + mail)
http://centos-webpanel.com/website-ddos-protection-proxy

Join our Development Team and get paid !
http://centos-webpanel.com/develope-modules-for-cwp


Services Monitoring & RBL Monitoring
http://centos-webpanel.com/services-monitor


Do you need Fast and FREE Support included for your CWP linux server?
http://centos-webpanel.com/noc-partner-list
Installation Instructions
http://centos-webpanel.com/installation-instructions
Get Fast Support Here
http://centos-webpanel.com/support-services

Offline
*
Re: How to Build a new module for CentOS Web Panel (CWP)
« Reply #1 on: June 08, 2014, 04:23:48 AM »
Something wrong in CWP ver 0.9.1, where my file 3rdparty.php will be place?

Offline
*
Re: How to Build a new module for CentOS Web Panel (CWP)
« Reply #2 on: June 08, 2014, 07:32:15 PM »
you will need to use direct link for now as we will add this in 0.9.2 soon.
AntiDDoS Protection (web + mail)
http://centos-webpanel.com/website-ddos-protection-proxy

Join our Development Team and get paid !
http://centos-webpanel.com/develope-modules-for-cwp


Services Monitoring & RBL Monitoring
http://centos-webpanel.com/services-monitor


Do you need Fast and FREE Support included for your CWP linux server?
http://centos-webpanel.com/noc-partner-list
Installation Instructions
http://centos-webpanel.com/installation-instructions
Get Fast Support Here
http://centos-webpanel.com/support-services

Offline
***
Re: How to Build a new module for CentOS Web Panel (CWP)
« Reply #3 on: August 18, 2014, 01:26:44 PM »
you will need to use direct link for now as we will add this in 0.9.2 soon.

For root/admin user put here /usr/local/cwpsrv/htdocs/resources/admin/modules
For users put here /usr/local/cwpsrv/htdocs/resources/client/modules

Regards.
« Last Edit: August 18, 2014, 01:40:28 PM by erm3nda »
8==D it's a function that try to compare 8 (int) against D (string) which returns True or False depending on the asker.

Offline
*
Re: How to Build a new module for CentOS Web Panel (CWP)
« Reply #4 on: May 13, 2015, 06:47:25 PM »
Simple solution to adding custom built menu's to CWP 0.9.8.6 without needing to use the developer menu

Step #1 - Build your module, and add it to module directory for the admin panel.

ifconfig.php:
Code: [Select]
<?php
if(!isset($include_path)){
    echo(
"invalid access");
}else{
    
$ifconfig shell_exec("ifconfig");
    echo(
"<h3>IFCONFIG</h3><pre>".$ifconfig."</pre>");
}
?>

save your module into the admin modules directory.
/usr/local/cwpsrv/htdocs/resources/admin/modules/ifconfig.php

Step #2 - create a file named 3rdparty.php in /usr/local/cwpsrv/htdocs/resources/admin/include

The default way this file works is meant to let users add modules to the submenu Developer Menu.

The file expects modules to be added as list items like the following:
Code: [Select]
<li><a href="index.php?module=ifconfig"><span class="icon16 icomoon-icon-arrow-right-3"></span>Network Interface</a></li>
However with some minor changes we can create our own menu to use instead of the Developer Menu.

3rdparty.php:
Code: [Select]
<?php
/* File: /usr/local/cwpsrv/htdocs/resources/admin/include/3rdparty.php */
?>

</ul></li> <!-- This line closes the opened submenu tag and menu item for the Developer menu -->

<li class="custom-menu"> <!-- this class "custom-menu" was added so you can remove the Developer Menu easily if you want -->
    <a class="hasUl" href="#"><span class="icon16 icomoon-icon-hammer"></span>MY CUSTOM MENU<span class="hasDrop icon16 icomoon-icon-arrow-down-2"></span></a>
    <ul class="sub">
        <li><a href="index.php?module=ifconfig"><span class="icon16 icomoon-icon-arrow-right-3"></span>Network Interface</a></li>
    </ul>
</li>

<li style="display:none;"><ul> <!-- This line opens a new menu item and submenu that's hidden because CWP will add closing ul and li tags to the end of this file -->
<?php
/* End 3rdparty.php */
?>

Now we have added a new menu with the title "MY CUSTOM MENU" and have added the ifconfig module we built to it.

If you want to add more menus then you simply create another menu block in 3rdparty.php like so:
3rdparty.php:
Code: [Select]
<?php
/* File: /usr/local/cwpsrv/htdocs/resources/admin/include/3rdparty.php */
?>

</ul></li> <!-- This line closes the opened submenu tag and menu item for the Developer menu -->

<li class="custom-menu"> <!-- this class "custom-menu" was added so you can remove the Developer Menu easily if you want -->
    <a class="hasUl" href="#"><span class="icon16 icomoon-icon-hammer"></span>MY CUSTOM MENU<span class="hasDrop icon16 icomoon-icon-arrow-down-2"></span></a>
    <ul class="sub">
        <li><a href="index.php?module=ifconfig"><span class="icon16 icomoon-icon-arrow-right-3"></span>Network Interface</a></li>
    </ul>
</li>

<li>
    <a class="hasUl" href="#"><span class="icon16 icomoon-icon-hammer"></span>IM ANOTHER MENU<span class="hasDrop icon16 icomoon-icon-arrow-down-2"></span></a>
    <ul class="sub">
        <li><a href="index.php?module=ifconfig"><span class="icon16 icomoon-icon-arrow-right-3"></span>Network Interface</a></li>
    </ul>
</li>

<li style="display:none;"><ul> <!-- This line opens a new menu item and submenu that's hidden because CWP will add closing ul and li tags to the end of this file -->
<?php
/* End 3rdparty.php */
?>

And now there is a second new menu titled "IM ANOTHER MENU" now you can organize your modules better.
But I will write a proper module to handle menu modification to handle the menu from the UI.

If you would like to hide the Developer Menu because you aren't using it like me then you may hide it with a little jquery.
You can add this script to the end of the /usr/local/cwpsrv/htdocs/resources/admin/include/3rdparty.php
Code: [Select]
<script type='text/javascript'>$(document).ready(function(){$(".custom-menu").prev("LI").css("display","none");});</script>
That's all for now I hope you enjoyed this and can make use of it.
I have just begun to play with CentOS WebPanel but I have so many ideas of how to add some really cool stuff. it's just too bad a lot of the code is obfuscated because I would love to help build some of this stuff.
« Last Edit: May 13, 2015, 09:21:51 PM by cyberxwolf »
System Stats
 Memory RAM: 1.63GB / 127GB ( 1.3%)
 Swap Memory: 0GB / 4GB ( 0% )
 Disk Space: 7.2TB

System Info
 CPU Model:  Intel(R) Xeon(R) CPU E5-2620 v2 @ 2.10GHz 
 CPU Details: 12 Core (2100 MHz)
 Distro Name: CentOS release 6.6 (Final) 
 Kernel Version: 2.6.32-504.16.2.el6.x86_64 
 Platform: x86_64 [Dedicated]
 Server Time: Thu May 14 02:01:13 EDT 2015

Offline
*
Re: How to Build a new module for CentOS Web Panel (CWP)
« Reply #5 on: May 14, 2015, 04:49:02 AM »
Here is another easier way to add new menus.

create /usr/local/cwpsrv/htdocs/resources/admin/include/3rdparty.php

Code: [Select]
<li>
<script type="text/javascript">
function add_custom_menu($icon_class,$menu_title,$sub_menu_items){
    $the_submenus = "";
    $.each($sub_menu_items,function(ind,itm){
    $the_submenus += "<li><a href='"+itm.link+"'><span class='icon16 icomoon-icon-arrow-right-3'></span>"+itm.link_title+"</a></li>";   
    });
    $(".mainnav > ul").append("<li><a href='#' onmousedown='javascript:return false;'><span class='icon16 "+$icon_class+"'></span>"+$menu_title+"<span class='hasDrop icon16 icomoon-icon-arrow-down-2'></span></a><ul class='sub'>"+$the_submenus+"</ul></li>");
}

//Add your menu items with the add_custom_menu function.

$(function(){
    add_custom_menu("icomoon-icon-hammer","MY NEW MENU 1",[{"link":"index.php?module=example","link_title":"TEST LINK 1"},{"link":"index.php?module=example","link_title":"TEST LINK 2"},{"link":"index.php?module=example","link_title":"TEST LINK 3"}]);
    add_custom_menu("icomoon-icon-hammer","MY NEW MENU 2",[{"link":"index.php?module=example","link_title":"TEST LINK 4"},{"link":"index.php?module=example","link_title":"TEST LINK 5"},{"link":"index.php?module=example","link_title":"TEST LINK 6"}]);

});
</script>
</li>
« Last Edit: May 14, 2015, 04:58:21 AM by cyberxwolf »
System Stats
 Memory RAM: 1.63GB / 127GB ( 1.3%)
 Swap Memory: 0GB / 4GB ( 0% )
 Disk Space: 7.2TB

System Info
 CPU Model:  Intel(R) Xeon(R) CPU E5-2620 v2 @ 2.10GHz 
 CPU Details: 12 Core (2100 MHz)
 Distro Name: CentOS release 6.6 (Final) 
 Kernel Version: 2.6.32-504.16.2.el6.x86_64 
 Platform: x86_64 [Dedicated]
 Server Time: Thu May 14 02:01:13 EDT 2015

Offline
*
Re: How to Build a new module for CentOS Web Panel (CWP)
« Reply #6 on: October 24, 2015, 07:00:40 AM »
Here is another easier way to add new menus.

create /usr/local/cwpsrv/htdocs/resources/admin/include/3rdparty.php

Code: [Select]
<li>
<script type="text/javascript">
function add_custom_menu($icon_class,$menu_title,$sub_menu_items){
    $the_submenus = "";
    $.each($sub_menu_items,function(ind,itm){
    $the_submenus += "<li><a href='"+itm.link+"'><span class='icon16 icomoon-icon-arrow-right-3'></span>"+itm.link_title+"</a></li>";   
    });
    $(".mainnav > ul").append("<li><a href='#' onmousedown='javascript:return false;'><span class='icon16 "+$icon_class+"'></span>"+$menu_title+"<span class='hasDrop icon16 icomoon-icon-arrow-down-2'></span></a><ul class='sub'>"+$the_submenus+"</ul></li>");
}

//Add your menu items with the add_custom_menu function.

$(function(){
    add_custom_menu("icomoon-icon-hammer","MY NEW MENU 1",[{"link":"index.php?module=example","link_title":"TEST LINK 1"},{"link":"index.php?module=example","link_title":"TEST LINK 2"},{"link":"index.php?module=example","link_title":"TEST LINK 3"}]);
    add_custom_menu("icomoon-icon-hammer","MY NEW MENU 2",[{"link":"index.php?module=example","link_title":"TEST LINK 4"},{"link":"index.php?module=example","link_title":"TEST LINK 5"},{"link":"index.php?module=example","link_title":"TEST LINK 6"}]);

});
</script>
</li>


Him very nice thanks bro.
AGAR

Offline
**
Re: How to Build a new module for CentOS Web Panel (CWP)
« Reply #7 on: December 11, 2015, 01:22:02 AM »
Is there a way to process ajax requests (PHP side)?
How can i call my module without calling the entire index page?

Offline
*
Re: How to Build a new module for CentOS Web Panel (CWP)
« Reply #8 on: May 08, 2016, 10:02:09 AM »
if have error for 3rdparty.php

use this

open menu.php and go down
when you see
Code: [Select]
?>

add this:
Code: [Select]
<div class="mainnav">
<ul>
<li><a href="#" class="hasUl drop"><span class="icon16 icomoon-icon-hammer-2"></span>My Addons<span class="hasDrop icon16 icomoon-icon-arrow-down-2"></span></a>
<ul class="sub" style="display: block;">
<li><a href="index.php?module=test2"><span class="icon16 icomoon-icon-arrow-right-3"></span>Test</a></li>
</ul></li></ul>
</div>


Offline
*
Re: How to Build a new module for CentOS Web Panel (CWP)
« Reply #9 on: December 23, 2017, 10:38:09 PM »
not working for now