[Not Solved]
Can't see anything on FTP Accounts function 11-12-2018, 11:52 AM
Hello, I get an big problem with Sentora. That is can't using FTP Account function in Sentora panel.
It's show a message only:
Code:
Using this module you can create FTP accounts which will enable you and any other accounts you create to have the ability to upload and manage files on your hosting space.
Don't have any thing else!
Please help me diagnose what's problem happening.
--
Thanks for all!
[Not Solved]
RE: Can't see anything on FTP Accounts function 11-12-2018, 01:45 PM (This post was last modified: 11-12-2018, 01:45 PM by fearworks.)
(11-12-2018, 11:52 AM)caochitam Wrote: Hello, I get an big problem with Sentora. That is can't using FTP Account function in Sentora panel.
It's show a message only:
Code:
Using this module you can create FTP accounts which will enable you and any other accounts you create to have the ability to upload and manage files on your hosting space.
Don't have any thing else!
Please help me diagnose what's problem happening.
--
Thanks for all!
Several things:
1. Do you definitely have ProFTPd installed correctly? Depending on which version of Sentora you installed, and when you installed it, there have been issues with ProFTPd not installing correctly.
2. Are you having this "blank" module issue with any other modules or just the FTP one?
3. Which browser are you using to view the page?
4. Please copy and paste the contents of these files into your reply (there were/are some issues that I had to fix for the FTP module to work correctly on my servers):
[Not Solved]
RE: Can't see anything on FTP Accounts function 11-12-2018, 07:12 PM (This post was last modified: 11-12-2018, 07:19 PM by caochitam.)
Thank you, Fearwork.
1. ProFTPd service is running. I don't sure it's work correctly But it is running
Status check Is OK. ==> Captured in Attachment below
2. Only FTP module is "BLANK", all of monule is work fine.
3. My browser is Google Chrome 70. I don't think have problem with web browser
4. The file you have just require: File ftp_management/module.zpm Uploaded to Google Drive File ftp_management/code/controller.ext.php Uploaded to Google Drive
--------
Sorry, I still don't know what's happening. Please help me, Fearwork.
Thank a lot for your help!
1. ProFTPd service is running. I don't sure it's work correctly But it is running
Status check Is OK. ==> Captured in Attachment below
2. Only FTP module is "BLANK", all of monule is work fine.
3. My browser is Google Chrome 70. I don't think have problem with web browser
4. The file you have just require: File ftp_management/module.zpm Uploaded to Google Drive File ftp_management/code/controller.ext.php Uploaded to Google Drive
--------
Sorry, I still don't know what's happening. Please help me, Fearwork.
Thank a lot for your help!
Ok, in the controller.ext.php file, there are 3 lines that need changing slightly. I'm not sure when these errors crept into the code, and I haven't traced it back through the code to see what is causing it (probably a few rogue function calls), but the fix is to add "= null" in three places. This is the fixed code for that file, so copy and replace the entire contents with this:
Code:
<?php
/**
* @copyright 2014-2015 Sentora Project (http://www.sentora.org/)
* Sentora is a GPL fork of the ZPanel Project whose original header follows:
*
* ZPanel - A Cross-Platform Open-Source Web Hosting Control panel.
*
* @package ZPanel
* @version $Id$
* @author Bobby Allen - ballen@bobbyallen.me
* @copyright (c) 2008-2014 ZPanel Group - http://www.zpanelcp.com/
* @license http://opensource.org/licenses/gpl-3.0.html GNU Public License v3
*
* This program (ZPanel) is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
class module_controller extends ctrl_module
{
/**
* The 'worker' methods.
*/
static function ListClients($uid)
{
global $zdbh;
$sql = "SELECT * FROM x_ftpaccounts WHERE ft_acc_fk=:userid AND ft_deleted_ts IS NULL";
$numrows = $zdbh->prepare($sql);
$numrows->bindParam(':userid', $uid);
$numrows->execute();
static function ListCurrentClient($uid)
{
global $zdbh;
$sql = "SELECT * FROM x_ftpaccounts WHERE ft_id_pk=:userid AND ft_deleted_ts IS NULL";
$numrows = $zdbh->prepare($sql);
$numrows->bindParam(':userid', $uid);
$numrows->execute();
static function ListMasterDirs($uid)
{
$currentuser = ctrl_users::GetUserDetail($uid);
$res = array();
$handle = @opendir(ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . "");
$chkdir = ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . "/";
if (!$handle) {
// Log an error as the folder cannot be opened...
} else {
while ($file = @readdir($handle)) {
if ($file != '.' && $file != '..' && $file != '_errorpages') {
if (is_dir($chkdir . $file)) {
$res[] = array('domains' => runtime_xss::xssClean($file));
}
}
}
closedir($handle);
}
return $res;
}
static function ListDomainDirs($uid)
{
$currentuser = ctrl_users::GetUserDetail($uid);
$res = array();
$handle = @opendir(ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . "/public_html");
$chkdir = ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . "/public_html/";
if (!$handle) {
// Log an error as the folder cannot be opened...
} else {
while ($file = @readdir($handle)) {
if ($file != "." && $file != ".." && $file != "_errorpages") {
if (is_dir($chkdir . $file)) {
$res[] = array('domains' => runtime_xss::xssClean($file));
}
}
}
closedir($handle);
}
return $res;
}
static function ExecuteResetPassword($ft_id_pk, $password)
{
global $zdbh;
global $controller;
// Verify if Current user can Edit FTP Account.
$currentuser = ctrl_users::GetUserDetail($uid);
$sql = "SELECT * FROM x_ftpaccounts WHERE ft_acc_fk=:userid AND ft_id_pk=:editedUsrID AND ft_deleted_ts IS NULL";
$numrows = $zdbh->prepare($sql);
$numrows->bindParam(':userid', $currentuser['userid']);
$numrows->bindParam(':editedUsrID', $ft_id_pk);
$numrows->execute();
if( $numrows->rowCount() == 0 ) {
return;
}
// Change User Password
runtime_hook::Execute('OnBeforeResetFTPPassword');
$rowftpsql = "SELECT * FROM x_ftpaccounts WHERE ft_id_pk=:ftIdPk";
$rowftpfind = $zdbh->prepare($rowftpsql);
$rowftpfind->bindParam(':ftIdPk', $ft_id_pk);
$rowftpfind->execute();
$rowftp = $rowftpfind->fetch();
$sql = $zdbh->prepare("UPDATE x_ftpaccounts SET ft_password_vc=:password WHERE ft_id_pk=:ftpid");
$sql->bindParam(':password', $password);
$sql->bindParam(':ftpid', $ft_id_pk);
$sql->execute();
self::$reset = true;
// Include FTP server specific file here.
$FtpModuleFile = 'modules/' . $controller->GetControllerRequest('URL', 'module') . '/code/' . ctrl_options::GetSystemOption('ftp_php');
if (file_exists($FtpModuleFile)) {
include($FtpModuleFile);
}
$retval = TRUE;
runtime_hook::Execute('OnAfterResetFTPPassword');
return $retval;
}
static function ExecuteCreateFTP($uid, $username, $password, $destination, $domainDestination, $access_type, $home)
{
global $zdbh;
global $controller;
$currentuser = ctrl_users::GetUserDetail($uid);
$username = $currentuser['username'] . '_' . $username;
runtime_hook::Execute('OnBeforeCreateFTPAccount');
if (fs_director::CheckForEmptyValue(self::CheckForErrors($username, $password))) {
// Check to see if its a new home directory or use a current one...
if ($home == 1) {
$homedirectory_to_use = '/' . str_replace('.', '_', $username);
$full_path = ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . $homedirectory_to_use . '/';
// Create the new home directory... (If it doesnt already exist.)
if (!file_exists($full_path)) {
@mkdir($full_path, 777);
@chmod($full_path, 0777);
}
} else if ($home == 3) {
$homedirectory_to_use = '/' . $domainDestination;
} else {
$homedirectory_to_use = '/' . $destination;
}
// Check if Path is inside user home directory.
$full_homeDir = ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'] . $homedirectory_to_use . '/';
$baseDir = ctrl_options::GetSystemOption('hosted_dir') . $currentuser['username'];
$realPath = realpath($full_homeDir);
static function CheckForErrors($username, $password)
{
global $zdbh;
$retval = FALSE;
// Check to make sure the username and password is not blank before we go any further...
if ($username == '' || $password == '') {
self::$blank = TRUE;
$retval = TRUE;
}
// Check for invalid username
if (!self::IsValidUserName($username)) {
self::$badname = true;
$retval = TRUE;
}
// Check to make sure the cron is not a duplicate...
$sql = "SELECT COUNT(*) FROM x_ftpaccounts WHERE ft_user_vc=:userid AND ft_deleted_ts IS NULL";
$numrows = $zdbh->prepare($sql);
$numrows->bindParam(':userid', $username);
if ($numrows->execute()) {
if ($numrows->fetchColumn() <> 0) {
self::$alreadyexists = TRUE;
$retval = TRUE;
}
}
return $retval;
}
static function ExecuteDeleteFTP($ft_id_pk, $uid = null)
{
global $zdbh;
global $controller;
// Verify if Current user can Edit FTP Account.
$currentuser = ctrl_users::GetUserDetail($uid);
$sql = "SELECT * FROM x_ftpaccounts WHERE ft_acc_fk=:userid AND ft_id_pk=:editedUsrID AND ft_deleted_ts IS NULL";
$numrows = $zdbh->prepare($sql);
$numrows->bindParam(':userid', $currentuser['userid']);
$numrows->bindParam(':editedUsrID', $ft_id_pk);
$numrows->execute();
if( $numrows->rowCount() == 0 ) {
return;
}
// Delete User
runtime_hook::Execute('OnBeforeDeleteFTPAccount');
$rowftpsql = "SELECT * FROM x_ftpaccounts WHERE ft_id_pk=:ftIdPk";
$rowftpfind = $zdbh->prepare($rowftpsql);
$rowftpfind->bindParam(':ftIdPk', $ft_id_pk);
$rowftpfind->execute();
$rowftp = $rowftpfind->fetch();
$sql = $zdbh->prepare("UPDATE x_ftpaccounts SET ft_deleted_ts=:time WHERE ft_id_pk=:ftpid");
$sql->bindParam(':ftpid', $ft_id_pk);
$sql->bindParam(':time', $ft_id_pk);
$sql->execute();
self::$delete = true;
// Include FTP server specific file here.
$FtpModuleFile = 'modules/' . $controller->GetControllerRequest('URL', 'module') . '/code/' . ctrl_options::GetSystemOption('ftp_php');
if (file_exists($FtpModuleFile)) {
include($FtpModuleFile);
}
$retval = TRUE;
runtime_hook::Execute('OnAfterDeleteFTPAccount');
return $retval;
}
// Verify if Current user can Edit FTP Account.
// This shall avoid exposing ftp username based on ID lookups.
$currentuser = ctrl_users::GetUserDetail($uid);
$sql = " SELECT * FROM x_ftpaccounts WHERE ft_acc_fk=:userid AND ft_id_pk=:editedUsrID AND ft_deleted_ts IS NULL";
$numrows = $zdbh->prepare($sql);
$numrows->bindParam(':userid', $currentuser['userid']);
$numrows->bindParam(':editedUsrID', $urlvars['other']);
$numrows->execute();
if( $numrows->rowCount() == 0 ) {
return;
}
// Show User Info
return (isset($urlvars['show'])) && ($urlvars['show'] == "Delete");
}
static function getisEditFTP($uid = null)
{
global $controller;
global $zdbh;
// Verify if Current user can Edit FTP Account.
// This shall avoid exposing ftp username based on ID lookups.
$currentuser = ctrl_users::GetUserDetail($uid);
$sql = " SELECT * FROM x_ftpaccounts WHERE ft_acc_fk=:userid AND ft_id_pk=:editedUsrID AND ft_deleted_ts IS NULL";
$numrows = $zdbh->prepare($sql);
$numrows->bindParam(':userid', $currentuser['userid']);
$numrows->bindParam(':editedUsrID', $urlvars['other']);
$numrows->execute();
if( $numrows->rowCount() == 0 ) {
return;
}
// Show User Info
return (isset($urlvars['show'])) && ($urlvars['show'] == "Edit");
}
static function getEditCurrentName()
{
global $controller;
if ($controller->GetControllerRequest('URL', 'other')) {
$current = self::ListCurrentClient($controller->GetControllerRequest('URL', 'other'));
return $current[0]['username'];
} else {
return "";
}
}
static function getEditCurrentID()
{
global $controller;
if ($controller->GetControllerRequest('URL', 'other')) {
$current = self::ListCurrentClient($controller->GetControllerRequest('URL', 'other'));
return $current[0]['id'];
} else {
return "";
}
}
static function getResult()
{
if (!fs_director::CheckForEmptyValue(self::$blank)) {
return ui_sysmessage::shout(ui_language::translate("You must enter a valid username and password to create your FTP account."), "zannounceerror");
}
if (!fs_director::CheckForEmptyValue(self::$alreadyexists)) {
return ui_sysmessage::shout(ui_language::translate("An FTP account with that name already exists."), "zannounceerror");
}
if (!fs_director::CheckForEmptyValue(self::$error)) {
return ui_sysmessage::shout(ui_language::translate("There was an error updating your FTP accounts."), "zannounceerror");
}
if (!fs_director::CheckForEmptyValue(self::$badname)) {
return ui_sysmessage::shout(ui_language::translate("Your ftp account name is not valid. Please enter a valid ftp account name."), "zannounceerror");
}
if (!fs_director::CheckForEmptyValue(self::$invalidPath)) {
return ui_sysmessage::shout(ui_language::translate("Invalid Folder."), "zannounceok");
}
if (!fs_director::CheckForEmptyValue(self::$ok)) {
return ui_sysmessage::shout(ui_language::translate("FTP accounts updated successfully."), "zannounceok");
}
return;
}
/**
* Webinterface sudo methods.
*/
}
You should now find the module works, but there is also another issue with the FTP management page. The javascript and html code is a bit mixed up, so the "show/hide" passwords button doesn't work properly. This is the code I use for module.zpm, so you might want to replace the contents of that file with this code:
[Not Solved]
RE: Can't see anything on FTP Accounts function 03-30-2020, 08:33 AM (This post was last modified: 03-30-2020, 08:41 AM by alexandru.humaila.)
Worked also for me.
Thank you very much.
One thing I want to ask. Can you make the FTP passwords visible, pls?
Regards!
LE: Just saw the button! Sorry!
LLE: It is not working Pls help!