$v){
if(empty($iscripts[$k])){
continue;
}
$top[$k] = $v['ratings']*$v['votes'];
}
// Sorting according to top ratings
arsort($top);
//To fill up the scripts if less than 7 are selected by admin
$ext_fill = array();
$ext_fill = $top;
if(file_exists($globals['path'].'/conf/top_scripts.php')){
$selected_top = $top = unserialize(file_get_contents($globals['path'].'/conf/top_scripts.php'));
}
// If Admin has checked Append scripts than only append the scripts. Otherwise Only Selected Scripts will be displayed.
if(count($top) < 7 && !empty($globals['append_apps'])){
foreach($ext_fill as $k => $v){
$top[$k] = $k;
}
array_unique($top);
}
//r_print($globals);
if(!empty($globals['show_cscript_in_top'])){
//r_print($top_custom_list);
foreach($cscripts as $ck => $cv){
if(array_key_exists($ck, $iscripts)){
$top_custom[$ck] = $ck;
}
}
$tmp_top = $top;
// Do we need to add any other default scripts ?
if(!empty($top_custom)){
$top = $top_custom;
}
if(!empty($tmp_top)){
$top += $tmp_top;
}
}
foreach($scripts as $k => $v){
// We have to remove the scripts which are not enabled AND yet coming from top_scripts.php (i.e. Admin have saved it from top scripts)
if(!array_key_exists($k, $iscripts) && !empty($top[$k])){
unset($top[$k]);
}
if(empty($iscripts[$k]) || (empty($selected_top[$k]) && !empty($scripts[$k]['parent']) && !empty($iscripts[$scripts[$k]['parent']]))){
unset($top[$k]);
}
}
/* // Do we need to add SitePad ?
if(can_show_sitepad() && !file_exists($globals['path'].'/conf/top_scripts.php')){
$tmp_top = $top;
$top = array();
if(!array_key_exists(26, $tmp_top)){
$tmp_top = array_reverse($tmp_top, true);
$tmp_top[-1] = 5;
$top = array_reverse($tmp_top, true);
}else{
foreach($tmp_top as $tk => $tv){
$top[$tk] = $tv;
if($tk == 26){
$top[-1] = 5;
}
}
}
} */
//r_print($top);
$updates_available = 0;
foreach($user['ins'] as $insid => $soft){
if(!empty($iscripts[$soft['sid']]) ){
if(is_upgradable($insid)){
$updates_available++;
}
}
}
if($globals['softimages'] != $globals['mirror_images']){
if($globals['softpanel'] == 'cpanel'){
$globals['softimages'] = 'softaculous/'.$globals['softimages'];
}elseif($globals['softpanel'] == 'directadmin'){
$globals['softimages'] = 'CMD_PLUGINS/softaculous/'.$globals['softimages'];
}elseif($globals['softpanel'] == 'webuzo'){
$globals['softimages'] = 'softaculous/'.$globals['softimages'];
}
}
$url = $globals['softimages'];
$cat_image_path = 'themes/default/images/cats/';
if($globals['softpanel'] == 'directadmin'){
$fullurl = 'CMD_PLUGINS/softaculous';
$cat_image_path = 'images/themes/default/images/cats/';
}elseif($globals['softpanel'] == 'cpanel'){
$fullurl = 'softaculous';
}elseif($globals['softpanel'] == 'plesk'){
$fullurl = '/modules/softaculous';
}elseif($globals['softpanel'] == 'webuzo'){
$fullurl = 'softaculous';
}else{
$fullurl = 'http://localhost/ampps';
}
$cat_width = 24;
$cat_height = 40;
if($globals['theme'] != 'default'){
if(is_cp_theme('paper_lantern') || is_cp_theme('jupiter')){
$cat_image_path = 'themes/default/';
if($globals['softpanel'] == 'directadmin'){
$fullurl = 'CMD_PLUGINS/softaculous';
$cat_image_path = 'images/themes/default/';
}elseif($globals['softpanel'] == 'cpanel'){
$fullurl = 'softaculous';
}elseif($globals['softpanel'] == 'plesk'){
$fullurl = '/modules/softaculous';
}elseif($globals['softpanel'] == 'webuzo'){
$fullurl = 'softaculous';
}else{
$fullurl = 'http://localhost/ampps';
}
$cat_width = 90;
$cat_height = 40;
}else{
$cat_width = 70;
$cat_height = 40;
}
}
$no_cat = (!empty($globals['disable_cats']) ? $globals['disable_cats'] : optGET('nocat'));
$my_ins = (!empty($globals['enable_myins']) ? $globals['enable_myins'] : optGET('noins'));
// For directadmin evolution theme we need to pass JSON data in the below format
if($globals['softpanel'] == 'directadmin' && $softpanel->detect_theme() == 'evolution'){
// This theme needs full path i.e. /
// Sometimes it is https://images.softaculous.com
$fullurl = (!preg_match('/^http(s|)\:/is', $fullurl) ? '/' : '').$fullurl;
$url = (!preg_match('/^http(s|)\:/is', $url) ? '/' : '').$url;
$menu_count = 0;
// For Users installations
if(!empty($my_ins) && !empty($user['ins'])){
$menu[$menu_count]['name'] = $l['installed_apps'];
$menu[$menu_count]['icon'] = $fullurl.'/'.$theme['images'].'soft.png';
$i = 0;
// We want the new installations first
$user_ins = array_reverse($user['ins']);
foreach($user_ins as $uk => $uv){
$img_path = 'top15/48/'.$scripts[$uv['sid']]['softname'].'.png';
// custom scripts logos path
if($uv['sid'] > 10000){
if(file_exists($theme['images'].'topscripts/48/'.$uv['sid'].'__logo.gif')){
$cscript_img_path = '/CMD_PLUGINS/softaculous/'.$theme['images'].'topscripts/48/'.$uv['sid'].'__logo.gif"';
}elseif(file_exists($theme['images'].'topscripts/32/'.$uv['sid'].'__logo.gif')){
$cscript_img_path = '/CMD_PLUGINS/softaculous/'.$theme['images'].'topscripts/32/'.$uv['sid'].'__logo.gif"';
}else{
$cscript_img_path = $fullurl.'/'.$theme['images'].'top14_custom_script.png"';
}
}
$imgsrc = ($uv['sid'] > 10000 ? $cscript_img_path : $url.$img_path);
// Check if the script supports Sign On
$has_sign_on = has_sign_on($uv['sid']);
$_site_name = @unserialize($uv['site_name']);
$hrefurl = (!empty($has_sign_on) ? $fullurl.'/'.$globals['ind'].'act=sign_on&insid='.$uv['insid'].'&autoid='.srandstr(32) : $fullurl.'/'.$globals['ind'].'act=editdetail&insid='.$uv['insid']);
// Make the entries
$menu[$menu_count]['entries'][$i]['href'] = $hrefurl;
$menu[$menu_count]['entries'][$i]['name'] = (!empty($uv['site_name']) ? (!empty($_site_name) ? $_site_name : $uv['site_name']) : $iscripts[$uv['sid']]['name']);
$menu[$menu_count]['entries'][$i]['icon'] = $imgsrc;
$menu[$menu_count]['entries'][$i]['newTab'] = true;
$menu[$menu_count]['entries'][$i]['updates'] = 0;
$i++;
// Display max 13 installations
if($i == 13){
// Make the entries for Show More
$menu[$menu_count]['entries'][$i]['href'] = $fullurl.'/'.$globals['ind'].'act=installations';
$menu[$menu_count]['entries'][$i]['name'] = $l['show_all'];
$menu[$menu_count]['entries'][$i]['icon'] = '/CMD_PLUGINS/softaculous/'.$theme['images'].'plus.png';
$menu[$menu_count]['entries'][$i]['newTab'] = true;
$menu[$menu_count]['entries'][$i]['updates'] = 0;
break;
}
}
$menu_count++;
} // End of $my_ins
$menu[$menu_count]['name'] = $globals['show_top_scripts'];
$menu[$menu_count]['icon'] = $fullurl.'/'.$theme['images'].'soft.png';
$i = 0;
foreach($top as $k => $v){
// -1 is exception for SitePad
if(empty($iscripts[$k]) && $k != -1){
continue;
}
$hrefurl = $fullurl.'/'.$globals['ind'].'act='.($iscripts[$k]['type'] == 'perl' ? 'perl' : ($iscripts[$v]['type'] == 'js' ? 'js' : 'software' )).'&soft='.$k;
$img_path = 'top15/48/'.$scripts[$k]['softname'].'.png';
// custom scripts logos path
if($k > 10000){
if(file_exists($theme['images'].'topscripts/48/'.$k.'__logo.gif')){
$cscript_img_path = '/CMD_PLUGINS/softaculous/'.$theme['images'].'topscripts/48/'.$k.'__logo.gif';
}elseif(file_exists($theme['images'].'topscripts/32/'.$k.'__logo.gif')){
$cscript_img_path = '/CMD_PLUGINS/softaculous/'.$theme['images'].'topscripts/32/'.$k.'__logo.gif';
}else{
$cscript_img_path = $fullurl.'/'.$theme['images'].'top14_custom_script.png';
}
}
$imgsrc = ($k > 10000 ? $cscript_img_path : $url.$img_path);
// Make the entries
$menu[$menu_count]['entries'][$i]['href'] = $hrefurl;
$menu[$menu_count]['entries'][$i]['name'] = $iscripts[$k]['name'];
$menu[$menu_count]['entries'][$i]['icon'] = $imgsrc;
$menu[$menu_count]['entries'][$i]['newTab'] = true;
$menu[$menu_count]['entries'][$i]['updates'] = 0;
$i++;
if($i == 14 && !empty($globals['append_apps'])){
break;
}elseif(!file_exists($globals['path'].'/conf/top_scripts.php') && empty($globals['append_apps']) && $i == 14){
// This is the DEFAULT case if scripts are not selected AND append_apps is not checked then display 14 scripts by default.
break;
}
}
//r_print($menu);
$data = json_encode($menu, JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT);
echo $data;
return true;
}
$custome_width = optGET('width');
if($globals['softpanel'] == 'plesk'){
$width = '450px';
$s_width = '455px';
}else{
$width = 'auto';
$s_width = 'auto';
}
if(!empty($custome_width) && is_numeric($custome_width)){
$width = $custome_width.'px';
$s_width = ($custome_width+5).'px';
}
//Including font-awesome style here since the class 'fa' was conflicting with cPanel's style class 'fa'
/* $fa_class = file_get_contents($globals['path']."/enduser/themes/default/css/font-awesome-5.css");
//Changing the class name in style
$fa_class = str_replace('.fa {', '.sai_fa {', $fa_class);
//Changing the fonts URL
$fa_class = str_replace('url(\'fonts', 'url(\'softaculous/themes/default/fonts', $fa_class);
//Adding double slashes since one gets parsed by the browser
$fa_class = str_replace('content: "\\', 'content: "\\\\', $fa_class); */
// Some modifications to make the category look good in cPanel's Dark and Light style
if((!empty($softpanel->cp_style)) && $softpanel->cp_style == 'dark'){
$cat_color = '#FFF';
$cat_scroll_left = 'white_move_left.png';
$cat_scroll_right = 'white_move_right.png';
$softac_cat_bgcolor = '#333';
$softac_cat_color = 'color:#FFF;';
}elseif($globals['softpanel'] == 'webuzo'){
$cat_color = '#3f51b5';
$cat_scroll_left = 'move_left.png';
$cat_scroll_right = 'move_right.png';
$softac_cat_bgcolor = '#EEE';
$softac_cat_color = 'color: black;';
}else{
$cat_color = '#348AC4';
$cat_scroll_left = 'move_left.png';
$cat_scroll_right = 'move_right.png';
$softac_cat_bgcolor = '#EEE';
$softac_cat_color = '';
}
$link_style = '';
if(is_cp_theme('jupiter')){
$link_style = '
a:link, a:visited, a:hover, a:active {
color: #365aa2;
}';
if(empty($softpanel->cp_style) || $softpanel->cp_style != 'dark'){
$cat_color = '#365aa2';
}
}
$str = '
';
if($globals['softpanel'] == 'directadmin'){
$str .= '
';
}
if($globals['softpanel'] == 'plesk'){
$str .= '
';
}
if(!empty($updates_available)){
$str .= '
';
}
// For Users installations
if(!empty($my_ins) && !empty($user['ins'])){
$str .= '
'.$l['my_installations'].' :
';
// We want the new installations first
$user_ins = array_reverse($user['ins']);
foreach($user_ins as $uk => $uv){
// We have to make some chnages as per the theme (i.e for x3 and paper_lantern)
if(is_cp_theme('paper_lantern') || is_cp_theme('jupiter') || $globals['softpanel'] == 'webuzo'){
$img_path = 'top15/48/'.$scripts[$uv['sid']]['softname'].'.png';
$td_width = 100;
$td_height = 80;
}else{
$img_path = 'top15/32/'.$uv['sid'].'__logo.gif';
$td_width = 80;
$td_height = 50;
}
// custom scripts logos path
if($uv['sid'] > 10000){
if((is_cp_theme('paper_lantern') || is_cp_theme('jupiter') || $globals['softpanel'] == 'webuzo') && file_exists($theme['images'].'topscripts/48/'.$uv['sid'].'__logo.gif')){
$cscript_img_path = 'softaculous/'.$theme['images'].'topscripts/48/'.$uv['sid'].'__logo.gif"';
}elseif(file_exists($theme['images'].'topscripts/32/'.$uv['sid'].'__logo.gif')){
$cscript_img_path = 'softaculous/'.$theme['images'].'topscripts/32/'.$uv['sid'].'__logo.gif"';
}else{
$cscript_img_path = $fullurl.'/'.$theme['images'].'top14_custom_script.png"';
}
}
// Check if the script supports Sign On
$has_sign_on = has_sign_on($uv['sid']);
$_site_name = @unserialize($uv['site_name']);
$str .= ' '.(!empty($has_sign_on) ? ''.(is_cp_theme('paper_lantern') || is_cp_theme('jupiter') || is_cp_theme('x3') || $globals['softpanel'] == 'webuzo' ? ' ' : ' ').' ' : '').''.(!empty($uv['site_name']) ? (!empty($_site_name) ? stripslashes($_site_name) : stripslashes($uv['site_name'])) : $iscripts[$uv['sid']]['name']).' ';
}
$str .= '
';
} // End of $my_ins
if(empty($no_cat) || !empty($my_ins)){
$str .= '
'.$l['script'].':
';
}
$str .= '
';
$i=1;
foreach($top as $k => $v){
// -1 is exception for SitePad
if(empty($iscripts[$k]) && $k != -1){
continue;
}
// We have to make some chnages as per the theme (i.e for x3 and paper_lantern)
if(is_cp_theme('paper_lantern') || is_cp_theme('jupiter') || $globals['softpanel'] == 'webuzo'){
$img_path = 'top15/48/'.$scripts[$k]['softname'].'.png';
$td_width = 100;
$td_height = 80;
$td_pading = "padding-left:5px;padding-right:5px;padding-bottom:5px;";
}else{
$img_path = 'top15/32/'.$k.'__logo.gif';
$td_width = 80;
$td_height = 50;
$td_pading = "";
}
// custom scripts logos path
if($k > 10000){
if((is_cp_theme('paper_lantern') || is_cp_theme('jupiter')) && file_exists($theme['images'].'topscripts/48/'.$iscripts[$k]['softname'].'.png')){
$cscript_img_path = 'softaculous/'.$theme['images'].'topscripts/48/'.$iscripts[$k]['softname'].'.png"';
}elseif((is_cp_theme('paper_lantern') || is_cp_theme('jupiter')) && file_exists($theme['images'].'topscripts/48/'.$k.'__logo.gif')){
$cscript_img_path = 'softaculous/'.$theme['images'].'topscripts/48/'.$k.'__logo.gif"';
}elseif(file_exists($theme['images'].'topscripts/32/'.$k.'__logo.gif')){
$cscript_img_path = 'softaculous/'.$theme['images'].'topscripts/32/'.$k.'__logo.gif"';
}elseif(is_cp_theme('paper_lantern') || is_cp_theme('jupiter')){
$cscript_img_path = $fullurl.'/'.$theme['images'].'top14_custom_script_48.png"';
}else{
$cscript_img_path = $fullurl.'/'.$theme['images'].'top14_custom_script.png"';
}
}
if($k == -1){
$hrefurl = $fullurl.'/'.$globals['ind'].'act='.(!empty($user_sitepad['apikey']) ? 'sitepad' : 'sitepad_overview');
$imgsrc = $fullurl.'/'.$theme['images'].'sitepad_'.(is_cp_theme('paper_lantern') || is_cp_theme('jupiter') ? '48' : '32').'.png';
$link_name = 'SitePad';
}else{
$hrefurl = $fullurl.'/'.$globals['ind'].'act='.($iscripts[$k]['type'] == 'perl' ? 'perl' : ($iscripts[$v]['type'] == 'js' ? 'js' : 'software' )).'&soft='.$k;
$imgsrc = ($k > 10000 ? $cscript_img_path : $url.$img_path.'"');
$link_name = $iscripts[$k]['name'];
}
$str .= ' '.$link_name.' ';
$i++;
if($i == 15 && !empty($globals['append_apps'])){
break;
}elseif(!file_exists($globals['path'].'/conf/top_scripts.php') && empty($globals['append_apps']) && $i == 15){
// This is the DEFAULT case if scripts are not selected AND append_apps is not checked then display 14 scripts by default.
break;
}
}
$str .= '
';
// Disable category
if(empty($no_cat)){
$str .= '
'.$l['category'].' :
';
} // End of $no_cat
// If its Dirctadmin than Closing the DIV
if($globals['softpanel'] == 'directadmin'){
$str .= '
';
}
echo 'var softOffsets = function(e){
e = e || window.event;
var
//cache document variables
_d = document, _dBody = _d.body, _dDocEl = _d.documentElement, _o = null,
//calculate scroll values
_scroll_left = _dDocEl.scrollLeft ? _dDocEl.scrollLeft : 0 + _dBody.scrollLeft ? _dBody.scrollLeft : 0,
_scroll_top = _dDocEl.scrollTop ? _dDocEl.scrollTop : 0 + _dBody.scrollTop ? _dBody.scrollTop : 0,
window_pos = {
_x: (e.pageX || e.clientX) + _scroll_left, _y: (e.pageY || e.clientY) + _scroll_top
},
viewport_pos = {
_x: (e.pageX || e.clientX), _y: (e.pageY || e.clientY)
},
_console = function(o, type) {
o = (typeof o === "object") ? o : _d.getElementById(o);
o.innerHTML = type + " = [ " +
" X: " + ((type === "viewport") ? viewport_pos._x : window_pos._x) +
" Y: " + ((type === "viewport") ? viewport_pos._y : window_pos._y) +
" ] Foo: " + Math.random()
};
return {
ViewPortX: viewport_pos._x,
ViewPortY: viewport_pos._y,
WindowX: window_pos._x,
WindowY: window_pos._y,
ViewPort: [viewport_pos._x, viewport_pos._y],
Window: [window_pos._x, window_pos._y],
ToString: _console
};
};
//Finds the position of the element
function findelpos(ele){
var curleft = 0;
var curtop = 0;
if(ele.offsetParent){
while(1){
curleft += ele.offsetLeft;
curtop += ele.offsetTop;
if(!ele.offsetParent){
break;
}
ele = ele.offsetParent;
}
}else if(ele.x){
curleft += ele.x;
curtop += ele.y;
}
return [curleft,curtop];
};
function mousemove(id, e){
if(typeof softac[id+"left"] == "undefined"){
softac[id+"right"] = "";
softac[id+"left"] = "";
softac[id+"entered"] = false;
}
if(softac[id+"entered"] == true){
return false;
}
softac[id+"entered"] = true;
var ele = document.getElementById(id);
var mouse = softOffsets(e);
mouse[0] = mouse.ViewPortX;
softac[id+"elpos"] = findelpos(ele);
softac[id+"menuwidth"] = ele.offsetWidth;
softac[id+"leftbound"] =((softac[id+"menuwidth"]-20)/2) + softac[id+"elpos"][0];
softac[id+"rightbound"] =((softac[id+"menuwidth"]+20)/2) + softac[id+"elpos"][0];
//alert(softac[id+"leftbound"]+" "+softac[id+"rightbound"]+" "+mouse[0]);
//document.getElementById("aaa").innerHTML = mouse[0]+" "+document.getElementById("aaa").innerHTML;
if (mouse[0]>softac[id+"rightbound"]){
softLeft(id);
}else if (mouse[0]
'.lang_vars($l['updates_available_notice'], array($updates_available)).' ';
echo 'var soft_html = \''.str_replace(array('\'', "
", "\r"), array('\\\'', '\'+"\n"+\'', '\'+"\n"+\''),$str).'\';
';
if($globals['softpanel'] == 'directadmin'){
echo 'document.getElementById("soft_div1").innerHTML = soft_html;';
}elseif($globals['softpanel'] == 'plesk'){
echo 'document.getElementById("secondary").innerHTML = "" + soft_html+ "
"+document.getElementById("secondary").innerHTML;';
}elseif($globals['softpanel'] == 'webuzo'){
echo 'document.getElementById("panel_softaculousTopScripts").innerHTML = soft_html;';
}else{
//Top Scripts were loaded before the div 'soft_div-body' creation
echo 'window.onload = function() {
setTimeout(show_topscripts, 1000);
};
function show_topscripts(){';
if(!empty($globals['show_top_scripts'])){
echo 'document.getElementById("soft_div-body").innerHTML = soft_html;';
}
if(!empty($globals['show_in_notice']) && $updates_available > 0){
echo 'var soft_notice = \''.str_replace(array('\'', "
", "\r"), array('\\\'', '\'+"\n"+\'', '\'+"\n"+\''),$notice).'\';
document.getElementById("noticeboard").innerHTML += soft_notice;';
}
echo '};';
}
}
?>