Current File : //root/panel/modules/apachemodule/module.zpm |
<style>
.apache_mod{font-size:13px;font-weight:bold;}
.php_desc{width:100%;min-height:40px;}
.mod_dis {width:200px;min-height:20px;word-wrap: break-word;}
input::-moz-focus-inner{border:0}
.bld{font-weight:bold;color:#629338;}
.btn{width:80px;min-height:20px;border:none;background-color:#3b7eb0;}
.btn1{width:80px;min-height:20px;border:none;background-color:#Ad0403;}
#error_dis { width:100%;text-align:center;}
#error_id{font-size:12px;color:#629338;font-weight:bold;}
.clearboth1{width:100%;height:1px;clear:both;}
.clearboth2{width:100%;height:2px;clear:both;}
.clearboth5{width:100%;height:5px;clear:both;}
.clearboth10{width:100%;height:10px;clear:both;}
.clearboth20{width:100%;height:20px;clear:both;}
</style>
<div class="zmodule_content panel" id="zmodule_header_<@ ModuleName @>">
<div class="panel-heading">
<img src="<@ ModuleIcon @>" width="35" height="35" border="0" alt="<@ ModuleName @>">
<div class="zmodule_title">
<@ ModuleName @>
</div>
<div class="zmodule_desc" id="zmodule_desc_<@ ModuleName @>"><@ ModuleDesc @></div>
<style>
.helpicon {
display: block;
float: right;
border: 1px solid #ccc;
background-color: #f3f3f3;
padding: 5px 10px;
font-size: 12px;
margin-top:-118px;
margin-right:5px;
-webkit-box-shadow: -8px 7px 5px 0px rgba(204,204,204,1);
-moz-box-shadow: -8px 7px 5px 0px rgba(204,204,204,1);
box-shadow: -8px 7px 5px 0px rgba(204,204,204,1);
-webkit-box-shadow: 8px 7px 5px 0px rgba(204,204,204,1);
-moz-box-shadow: 8px 7px 5px 0px rgba(204,204,204,1);
box-shadow: 8px 7px 5px 0px rgba(204,204,204,1);
}
</style>
<div class="helpicon">
<a href="<@ helpicon @>" target="_blank"><img src="etc/styles/CstyleX-master/images/help.png" style="float:left;" ><span style="float:left;margin-top:8px;font-weight:bold;font-size:12px;" >Video Tutorial</span></a>
</div>
<div class="clearboth5" > </div>
</div>
<div id="error_dis" ><span id="error_id" > </span></div>
<div class="clearboth20" > </div>
<div class = "apache_mod" >Apache enable disable module </div>
<div class ="apache_desc" id = "apache_desc" > </div>
</div>
<script>
var isd="";
var timer ="";
var m_url = document.location.origin;
var err = {"ins":"Apache module optimization, process started","s_error":"Something wrong please contact sys admin","pkg_ins":"Module enable process is going on, please wait" ,"pkg_uns":"Module disable process is going on, please wait","d_msg":"Processing please wait","proc_comp":"Process has completed"};
var ins_array = [0,1,2,3];
function mhrpanel()
{
var _self = this;
_self.checkmodule = function()
{
var ajaxdata1={
"ajaxurl":"./?module=apachemodule&action=packdetail",
"ajaxmethod":"POST",
"ajaxsync":true,
"calldetail":2,
"statusdetail":3,
"datadetail":"",
"callback":function(response)
{
if( typeof response['status'] !="undefined")
{
if( parseInt(response['status']) == 1 && typeof response['apache_array'] != "undefined" && typeof response['apache_array'] != "undefined" )
{
var apache_array = response['apache_array'],k="";
var d1 ="<table border='1' >";
for(k in apache_array)
{
d1 +="<tr>";
d1 +="<td><div class = 'mod_dis' ><span class='bld' >"+k+"</span> </div></td>";
if( apache_array[k] == 1) { d1 +="<td><input type='button' value='Disable' class='btn btn1' onclick=\"isd.rivpkg(2,'"+k+"')\" ></td>"; }
else { d1 +="<td><input type='button' value='Enable' class='btn' onclick=\"isd.rivpkg(1,'"+k+"')\" ></td>"; }
d1 +="</tr>";
}
d1 += "</table";
document.getElementById("apache_desc").innerHTML = d1;
}
}
}
}
_self.ajaxcall(ajaxdata1);
}
_self.rivpkg = function(st,namd)
{
var err_id = document.getElementById("error_id");
err_id.innerHTML = err.ins ;
namd = namd.replace(/\s+/g,'').trim();
var stg = parseInt(st);
if(stg == 1 || stg == 2)
{
var ajaxdata1={
"ajaxurl":"./?module=apachemodule&action=packinstall",
"ajaxmethod":"POST",
"ajaxsync":true,
"calldetail":2,
"statusdetail":3,
"datadetail":"stv="+encodeURIComponent(stg)+"&packs="+encodeURIComponent(namd),
"callback":function(response)
{
if (typeof response['status'] !="undefined" )
{
var res_t = response['status'];
if(res_t == 0)
{
err_id.innerHTML = response['msg'];
}
else if (res_t == 1)
{
if(stg == 2)
{
err_id.innerHTML = err.pkg_ins;
}
else{
err_id.innerHTML = err.pkg_uns;
}
_self.check_module_status(namd,st);
}
else
{
document.location.href = m_url;
}
}
else
{
err_id.innerHTML = err.s_error;
}
}
};
_self.ajaxcall(ajaxdata1);
}
}
_self.check_module_status=function(named,st)
{
var ajaxdata1={
"ajaxurl":"./?module=apachemodule&action=checkhttpdinstall",
"ajaxmethod":"POST",
"ajaxsync":true,
"calldetail":2,
"statusdetail":3,
"datadetail":"stv="+encodeURIComponent(st)+"&packs="+encodeURIComponent(named),
"callback":function(response)
{
if (typeof response['status'] !="undefined" )
{
if (parseInt(response['status']) == 1 )
{
document.getElementById("error_id").innerHTML = err.proc_comp;
_self.checkmodule();
}
else if (response['status'] == 2)
{
document.getElementById("error_id").innerHTML = err.d_msg;
timer = setTimeout(function(){
_self.check_module_status(named,st);
}
,3000 );
}
else
{
if (typeof response['msg'] != "undefined" )
{
document.getElementById("error_id").innerHTML=response['msg'];
}
}
}
}
}
_self.ajaxcall(ajaxdata1);
}
_self.ajaxcall = function(ajaxdata) {
var xmlhttp = ""; // The variable that makes Ajax possible!
try {
// Opera 8.0+, Firefox, Safari
xmlhttp = new XMLHttpRequest();
} catch (e) {
// Internet Explorer Browsers
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
// Something went wrong
// console.log("Your browser broke!");
return false;
}
}
}
// Create a function that will receive data sent from the server
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
//console.log(xmlhttp.responseText);
try{
var jsondata = JSON.parse(xmlhttp.responseText);
ajaxdata.callback(jsondata)
}
catch(ex)
{
console.log(ex);
}
} else if (xmlhttp.status == 404 || xmlhttp.status == 500) {
console.log("404 or 505 error");
} else {}
}
if (ajaxdata.ajaxsync == true) {
xmlhttp.open(ajaxdata.ajaxmethod, ajaxdata.ajaxurl, ajaxdata.ajaxsync);
} else {
xmlhttp.open(ajaxdata.ajaxmethod, ajaxdata.ajaxurl);
}
if (ajaxdata.statusdetail == 4) {
xmlhttp.send(ajaxdata.formdata);
} else {
xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xmlhttp.send(ajaxdata.datadetail);
}
}
}
document.addEventListener("DOMContentLoaded",function()
{
isd = new mhrpanel();
isd.checkmodule();
});
</script>