Current File : /home/inlingua/www/decay_sym/root/var/softaculous/apps/pureftpd/themes/enduser/ftp_theme.php |
<?php
//////////////////////////////////////////////////////////////
//===========================================================
// WEBUZO CONTROL PANEL
// Inspired by the DESIRE to be the BEST OF ALL
// ----------------------------------------------------------
// Started by: Pulkit
// Date: 10th Jan 2009
// Time: 21:00 hrs
// Site: https://webuzo.com/ (WEBUZO)
// ----------------------------------------------------------
// Please Read the Terms of Use at https://webuzo.com/terms
// ----------------------------------------------------------
//===========================================================
// (c) Softaculous Ltd.
//===========================================================
//////////////////////////////////////////////////////////////
if(!defined('SOFTACULOUS')){
die('Hacking Attempt');
}
function ftp_theme(){
global $user, $globals, $theme, $softpanel, $WE, $catwise, $error, $scripts, $ftp_list, $done, $tuser, $is_running, $ftp_clients;
if(!empty($done)){
load_ftp();
}
//check host
if(optREQ('check_host')){
if(!empty($done)){
//Domain doesn't resolve to Webuzo
echo '1'.__('Your Domain does not resolve to the server IP ! So use the IP as Host instead of the domain name, while connecting.');
return true;
}else{
//Domain resolve to Webuzo
echo '0';
return true;
}
}
echo '
<div class="card soft-card p-3">
<div class="sai_main_head">
<img src="'.$theme['images'].'ftp.png" alt="" class="webu_head_img me-2"/>
<h5 class="d-inline-block">'.__('Manage FTP').'</h5>
</div>
</div>
<div class="card soft-card p-4 mt-4">';
// Check for the service working or not
if(empty($is_running)){
echo '
<div class="row mt-3">
<div class="col-12">
<div class="alert alert-danger text-center p-2">
<i class="fas fa-ban me-2"></i>'.__('Your Pure-FTPd service is not running currently.').'
</div>
</div>
</div>';
}
echo '
<div class="row-fluid" style="display: none;" id="check_host">
<div class="alert alert-warning text-center" style="padding:10px ; font-size: 15px; border-radius:12pz;" id="check_host_msg">
<i class="fas fa-info-circle" style="color:#8a6d3b;vertical-align: middle;"></i>
</div>
</div>';
echo '
<div class="sai_sub_head record-table mb-2 position-relative">
<input type="button" class="btn btn-danger delete_selected mb-1" value="'.__('Delete Selected').'" name="delete_selected" id="delete_selected" onclick="" disabled>
<a class="add_ftp float-end" href="'.$globals['ind'].'act=ftp_account">
<button type="button" class="flat-butt mb-1">'.__('Add New FTP User').'</button>
</a>
</div>
<div id="showrectab" class="table-responsive">';
ftp_list();
echo '
</div>
</div>';
}
function ftp_list(){
global $user, $globals, $theme, $softpanel, $WE, $catwise, $error, $scripts, $ftp_list, $done, $tuser, $port, $ftp_clients, $hostname;
echo '
<table class="table align-middle table-nowrap mb-0 webuzo-table">
<thead class="sai_head2">
<tr>
<th><input type="checkbox" id="checkall"></th>
<th class="align-middle">'.__('User Name').'</th>
<th class="align-middle">'.__('Directory').'</th>
<th class="align-middle">'.__('Usage').'</th>
<th class="align-middle">'.__('Quota').'</th>
<th colspan="6" class="text-center">'.__('Option').'</th>
</tr>
</thead>
<tbody>';
$i=1;
foreach ($ftp_list as $key => $value){
echo '
<tr id="tr'.$i.'">
<td><input type="checkbox" name="check_ftp" value="'.$i.'" '.($key == $WE->user['user'] ? 'disabled' : 'class="check_ftp"').'></td>
<td>
<p class="text-break m-0">'.$key.'</p>
</td>';
echo '
<td>
'.$value['path'].'
</td>';
echo '
<td>
'.(!empty($value['usage']) ? $value['usage'] : 0). ' '.__('MB').'
</td>';
if(preg_match('/unlimited/is', $value['quota'])){
echo '
<td>
<span id="quo'.$i.'">'.__('Unlimited').'</span>
<span id="quota_limit'.$i.'" style="display:none;" >
<input type="radio" name="quota'.$i.'" id="qunlimit'.$i.'" value="unlimited" checked="checked" onchange="disableinput('.$i.')" /> '.__('Unlimited').'
<input type="radio" name="quota'.$i.'" id="qlimit'.$i.'" value="limited" onchange="enableinput('.$i.')" /> <input type="text" name="qutamb" id="qutamb'.$i.'" size="5" value="1000" disabled="disabled" />'.__('MB').'</span>
</td>';
}else{
$qlimit = explode('(',$value['quota']);
$q_limit = explode('M',$qlimit[0]);
echo '
<td>
<span id="quo'.$i.'">'.trim($q_limit[0]).' '.__('MB').'</span>
<span id="quota_limit'.$i.'" style="display:none;">
<input type="radio" name="quota'.$i.'" id="qunlimit'.$i.'" value="unlimited" onchange="disableinput('.$i.')" /> '.__('Unlimited').'
<input type="radio" name="quota'.$i.'" id="qlimit'.$i.'" value="limited" checked="checked" onchange="enableinput('.$i.')" /> <input type="text" name="qutamb" id="qutamb'.$i.'" size="5" value="'.trim($q_limit[0]).'" />'.__('MB').'</span>
</td>';
}
if($key != $WE->user['user']){
echo '
<td width="1%">
<i class="fas fa-undo cancel-icon cancel" title="'.__('Cancel').'" id="cid'.$i.'" style="display:none;"></i>
</td>
<td width="1%">
<i class="fas fa-pencil-alt edit-icon edit" title="'.__('Edit').'" id="eid'.$i.'"></i>
</td>
<td width="1%">
<a href="'.$globals['ind'].'act=editftp&fuser='.$key.'" title="'.__('Change Password').'">
<i class="fas fa-key" title="'.__('Change Password').'" id="eid'.$i.'"></i>
</a>
</td>
<td width="1%" id="did'.$i.'">
<i class="fas fa-trash delete delete-icon" title="'.__('Delete').'" id="did'.$i.'"></i>
</td>';
}else{
echo '
<td width="1%"></td>
<td width="1%"></td>
<td width="1%"></td>
<td width="1%"></td>';
}
echo '
<td width="1%">
<i class="fa fa-wrench configure-icon configure" style="cursor:pointer" title="'.__('Configure FTP Clients').'" id="con'.$i.'" data-bs-toggle="collapse" data-bs-target="#configid'.$i.'"></i>
</td>';
echo '
</tr>
<tr class="webuzo-table" style="background-color:#e9ecef;">
<td colspan="12" class="p-0">
<div class="accordian-body collapse" id="configid'.$i.'">
<div class="d-flex justify-content-center p-2">
<div class="card col-sm-4 m-1">
<h6 class="card-header">'.__('Manual Settings').'</h6>
<div class="card-body">
<div class="p-2">
<b>FTP Username: </b> '.$key.'</br>
<b>FTP IP: </b> '.$globals['WU_PRIMARY_IP'].'</br>
<b>FTP Server: </b> '.$hostname.'</br>
<b>FTP Port: </b> '.$port.'
</div>
</div>
</div>
<div class="card col-sm-8 col-lg-6 m-1">
<h6 class="card-header">'.__('Configuration Files').'</h6>
<div class="card-body">
<div class="row">
<div class="col-md-6 text-center">
<img src="'.$theme['images'].'coreftp.png" alt="" height="80"/><br/>
<p>coreFTP (Windows)</p>
<input type="button" class="btn flat-butt" name="download_script" id="windows_dwld'.$i.'" data-user="'.$key.'" value="'.__('FTP Configuration File').'" />
</div>
<div class="col-md-6 text-center">
<img src="'.$theme['images'].'cyberduck.png" alt="" height="80"/><br/>
<p>Cyberduck (MacOS)</p>
<input type="button" class="btn flat-butt" name="download_script" id="macos_dwld'.$i.'" data-user="'.$key.'" value="'.__('FTP Configuration File').'" />
</div>
</div>
</div>
</div>
</div>
<div>
</td>
</tr>';
$i++;
}
echo '
</tbody>
</table>
<br />
<script language="javascript" type="text/javascript"><!-- // --><![CDATA[
$(document).ready(function(){
//check host
$.ajax({
type: "POST",
url: window.location+"&check_host=1",
success: function(data){
var result = data.substring(0,1);
if(result == "1"){
var msg = data.substring(1);
$("#check_host_msg").append(msg);
$("#check_host").show();
}
}
});
$(".configure").on("click", function(){
var id = $(this).attr(\'id\').replace("con", "");
$("#windows_dwld"+id).on("click", function(){
var d = $(this).data("user");
window.location.href = "'.$globals['index'].'act=ftp&os=windows&user="+d+"&download_script=1";
});
$("#macos_dwld"+id).on("click", function(){
var d = $(this).data("user");
window.location.href = "'.$globals['index'].'act=ftp&os=macos&user="+d+"&download_script=1";
});
$(".accordian-body ").collapse("hide");
});
});
$(".delete").click(function() {
var did = $(this).attr(\'id\');
did = did.substr(3);
var d = show_message_r("'.__js('Warning').'", \''.__js('Are you sure want to delete this FTP user ?').' <br /><input type="checkbox" name="ftp_home_del" id="ftp_home_del" /> <b>'.__js('Select the checkbox to delete the FTP home directory').'</b>'.'\');
d.alert = "alert-danger";
d.confirm.push(function(){
var del_home = document.getElementById("ftp_home_del");
var ftp_home_del = "";
if(del_home.checked == true){
ftp_home_del = 1;
}
var d = "&delete_fuser_id="+did+"&delete_home_dir="+ftp_home_del;
submitit(d, {
sm_done_onclose: function(){
location.reload();
}
});
});
show_message(d);
});
$(".edit").click(function() {
var id = $(this).attr(\'id\');
id = id.substr(3);
$("#cid"+id).show();
// Submit the form
if($("#eid"+id).hasClass("fa-save")){
if($_("qlimit"+id).checked){
var quota_limit = ($("#qutamb"+id).val());
var tmp = ""a=limit"a_limit="+quota_limit;
}else{
var tmp =""a=unlimited";
}
var d = $("#tr"+id).find("input, textarea, select").serialize();
d += "&edit_record="+id+tmp;
//console.log(id, "d++", d);return;
submitit(d, {
done: function(){
var tr = $("#tr"+id);
tr.find(".cancel").click();// Revert showing the inputs
tr.find("input, textarea, select").each(function(){
var jE = $(this);
if(jE.attr("type") == "hidden"){
return;
}
jE.closest("td").find("span").html(jE.val());
});
if(quota_limit){
$("#quo"+id).val("");
$("#quo"+id).html(quota_limit +\' ' .__js('MB').'\');
}
},
sm_done_onclose: function(){
if(quota_limit){
$("#quo"+id).val("");
$("#quo"+id).html(quota_limit +\' ' .__js('MB').'\');
}
location.reload();
}
});
}else{
$("#eid"+id).addClass("fa-save").removeClass("fa-edit");
$("#tr"+id).find("span").hide();
$("#tr"+id).find("input,.input").show();
$("#quo"+id).hide();
$("#quota_limit"+id)
.val($("#quo"+id).text())
.show()
.focus();
}
});
// For cancel
$(".cancel").click(function() {
var id = $(this).attr(\'id\');
id = id.substr(3);
$("#cid"+id).hide();
$("#eid"+id).attr("class","fas fa-pencil-alt edit-icon edit");
$("#quota_limit"+id).hide();
$("#quo"+id).show();
});
function enableinput(idi){
$_("qutamb"+idi).disabled=false;
}
function disableinput(idi){
$_("qutamb"+idi).disabled=true;
}
//multi-delete code
$(document).ready(function(){
$("#checkall").change(function(){
$(".check_ftp").prop("checked", $(this).prop("checked"));
});
$("input:checkbox").change(function(){
if($(".check_ftp:checked").length){
$("#delete_selected").removeAttr("disabled");
}else{
$("#delete_selected").prop("disabled",true);
}
});
});
$(".delete_selected").click(function() {
var arr = [];
$("input:checkbox[name=check_ftp]:checked").each(function(){
var id = $(this).val();
console.log(id);
arr.push(id);
});
var d = show_message_r("'.__js('Warning').'", \''.__js('Are you sure want to delete this FTP user ?').' <br /><input type="checkbox" name="ftp_home_del" id="ftp_home_del" /> <b>'.__js('Select the checkbox to delete the FTP home directory').'</b>'.'\');
d.alert = "alert-danger";
d.confirm.push(function(){
var del_home = document.getElementById("ftp_home_del");
var ftp_home_del = "";
if(del_home.checked == true){
ftp_home_del = 1;
}
var d = "&delete_fuser_id="+arr+"&delete_home_dir="+ftp_home_del;
submitit(d, {
sm_done_onclose: function(){
location.reload();
}
});
});
show_message(d);
});
// ]]></script>';
}