In order to create the necessary files for your new module you must execute the following:
chattr -i -R /usr/local/cwpsrv/htdocs/admin
For the creation of a module for the administador we must take into account these 3 files
1.- /usr/local/cwpsrv/htdocs/resources/admin/modules/MY_MODULE.php
2.- /usr/local/cwpsrv/htdocs/resources/admin/modules/language/en/MY_MODULE.ini
3.- /usr/local/cwpsrv/htdocs/resources/admin/addons/ajax/ajax_MY_MODULE.php
Where:
1. MY_MODULE.php: It is the file that will make up the whole module, here you can include php, html and js code without any type of problem.
Example:
<?php
if(!isset($include_path)){echo "invalid access"; exit(); }
if(!isset($_GET['lang'])){
if(!file_exists('/usr/local/cwpsrv/htdocs/resources/admin/modules/language/en/MY_MODULE.ini')){
if(!file_exists('/usr/local/cwpsrv/htdocs/resources/admin/modules/language/en/')){
shell_exec('mkdir -p /usr/local/cwpsrv/htdocs/resources/admin/modules/language/en/');
}
shell_exec('touch /usr/local/cwpsrv/htdocs/resources/admin/modules/language/en/MY_MODULE.ini');
}
$lang=parse_ini_file('/usr/local/cwpsrv/htdocs/resources/admin/modules/language/en/MY_MODULE.ini');
}else{
$lang=parse_ini_file('/usr/local/cwpsrv/htdocs/resources/admin/modules/language/'.$_GET['lang'].'/MY_MODULE.ini');
}
?>
<h4><?=$lang['TITLE']?></h4>
<div class="panel-body" style="padding-bottom: 5px; display: block;">
<div class="row" style="padding-bottom: 10px;">
<div><b><?=$lang['LABEL1']?></b></div>
<div><b><?=$lang['LABEL2']?></b></div>
<div><b><?=$lang['LABEL3']?></b></div>
<div><b><?=$lang['LABEL4']?></b></div>
</div>
<?php
$resp=mysqli_query($mysql_conn,"Select `domain` FROM `user` ORDER BY domain");
while ($row=mysqli_fetch_assoc($resp)){
echo '<div class="row" style="padding-bottom: 10px;">
<div>'.$row['username'].'</div>
<div>'.$row['email'].'</div>
<div>'.$row['domain'].'</div>
<div>'.$row['package'].'</div>
</div>';
}
</div>
2. MY_MODULE.ini: It is the language file, it contains all the tags and translations of a language for the module in development
Example:
ADDDTLASW="Module Addons"
3. ajax_MY_MODULE.php: It is the file destined to receive the ajax requests of the module.
Example:
<?php
if($_GET['acc']=='monitorlog'){
$tail = shell_exec('tail -n 5 /var/log/cwp/account_transfer.log');
echo str_replace(PHP_EOL, '<br>', $tail);
die;
}
Important note:
You can obtain the course of the connection to the BD using the following variables:
$mysqli = new mysqli($db_host, $db_user, $db_pass, $db_name);