This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Username not prepending
#1
Username not prepending
I have a new install of Sentora.  I created a user and login as that user.  I'm having two different prepending issues.

First, on the MySQL Users page.  On the form to create a new MySQL user it does not prepend the Sentora username in the form nor once that user is created.

Second, on the FTP Accounts page the prepend does not show up in the form but it does prepend once the FTP user is created.  On this one, I can just go into the zpm file for the module and add that text, that will fix this issue.

I'm bringing this up since this is a fresh download and install, that maybe something is missing from these modules.  I don't have a problem fixing it manually but that won't fix it for everyone else.

Thanks!  Smile
Reply
Thanks given by:
#2
RE: Username not prepending
*****Update*****

I compared several files in this new system to an existing one that was working correctly. (Both are v1.0.3) I found three files that were different and caused this problem. Once I copied the three files from the working system to the new, broken, system everything worked fine.

/etc/sentora/panel/modules/mysql_users/module.zpm
/etc/sentora/panel/modules/mysql_users/code/controller.ext.php
/etc/sentora/panel/modules/ftp_management/module.zpm

Again, wanting to bring this to the developers attention so that the distro can be updated and fixed. Thanks for such a great product!!
Reply
Thanks given by:
#3
RE: Username not prepending
Thanks for the report! I will check it out. It may already be there, but on the developer's installer and not yet released to the public Wink
-TGates - Project Council

SEARCH the Forums or read the DOCUMENTATION before posting!
Support Sentora and Donate: HERE

Find my support or modules useful? Donate to TGates HERE
Developers and code testers needed!
Contact TGates for more information
Reply
Thanks given by:
#4
RE: Username not prepending
Ok, I won't check that out LOL I'll let the Devs know and see if they can merge the changes into the current release or make a small patch or something.
-TGates - Project Council

SEARCH the Forums or read the DOCUMENTATION before posting!
Support Sentora and Donate: HERE

Find my support or modules useful? Donate to TGates HERE
Developers and code testers needed!
Contact TGates for more information
Reply
Thanks given by:
#5
RE: Username not prepending
Strange as the installer if you use the official one you should get only the files that were set for 1.0.3
No support using PM (Auto adding to IGNORE list!), use the forum. 
How to ask
Freelance AWS Certified Architect & SysOps// DevOps

10$ free to start your VPS
Reply
Thanks given by:
#6
RE: Username not prepending
I completely agree.....It was very weird.
Reply
Thanks given by:
#7
RE: Username not prepending
What is the exact installer you used? I just check my original Ubuntu Server (about a year old) with a newly installed VM (about a month old) and both have the prepending ftp and db. Although, FTP does not have the prepending name in the form only db does.
-TGates - Project Council

SEARCH the Forums or read the DOCUMENTATION before posting!
Support Sentora and Donate: HERE

Find my support or modules useful? Donate to TGates HERE
Developers and code testers needed!
Contact TGates for more information
Reply
Thanks given by:
#8
RE: Username not prepending
Having an issue with GitHub for Windows, so here are the updated files for the FTP Module:
module.zpm:
PHP Code:
<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>

 
   </div>

 
   <@ Result @>

 
   <% if isDeleteFTP %>
 
   <div class="zform_wrapper alert alert-danger">
 
       <h2><: Delete FTP account :>: <@ EditCurrentName @> ?</h2>
 
       <p><: Please confirm that you want to delete this FTP account. :></p>
 
       <form action="./?module=ftp_management&action=DeleteFTP" method="post">
 
           <table class="none" cellpadding="0" cellspacing="0">
 
               <tr>
 
                   <td colspan="2" align="right">
 
                       <input type="hidden" name="inDelete" value="<@ EditCurrentID @>">
 
                       <button class="button-loader delete btn btn-danger" type="submit" ><: Delete :></button>
 
                       <button class="button-loader btn btn-default" type="button" onclick="window.location.href='./?module=ftp_management';return false;"><: Cancel :></button>
 
                   </td>
 
               </tr>
 
           </table>
 
           <@ CSFR_Tag @>
 
       </form>
 
   </div>
 
   <% endif %>

 
   <% if isEditFTP %>
 
   <div class="zform_wrapper">
 
       <h2><: Reset FTP Password for user :>: <@ EditCurrentName @></h2>
 
       <form action="./?module=ftp_management&action=ResetPassword" method="post">
 
           <table class="table table-striped">
 
               <tr>
 
                   <th><: Username :>:</th>
 
                   <td><@ EditCurrentName @></td>
 
                   <td></td>
 
               </tr>
 
               <tr>
 
                   <th><: New password :>:</th>
 
                   <td><input name="inPassword" type="text" id="input-password" size="30" maxlength="50" /></td>
 
                   <td><button class="button-loader btn btn-default" type="submit" name="inReset" id="button" value="<@ EditCurrentID @>"><: Reset Password :>
 
                       </button>
 
                       <button class="button-loader btn btn-default" type="button" onclick="window.location.href='./?module=ftp_management';return false;"><: Cancel :></button></td>
 
               </tr>
 
               <tr>
 
                   <th></th>
 
                   <td><a href="#" class="link-password" id="generate"><: Generate Password :></a></td>
 
                   <td></td>
 
               </tr>
 
           </table>
 
           <@ CSFR_Tag @>
 
       </form>
 
   </div>
 
   <% endif %>

 
   <div class="zgrid_wrapper">
 
       <h2><: Current FTP accounts :></h2>
 
       <% if ClientList %>
 
       <script type="text/javascript">
 
         var ShowPass false;
 
         function ShowHide()
 
         {
 
             ShowPass = !ShowPass;
 
             if (ShowPass)
 
             
 
                 document.getElementById('ColPass').style.visibility 'visible';
 
                 document.getElementById('btn_sh').innerHTML 'Hide passwords';
 
             }
 
             else
              
{
 
                 document.getElementById('ColPass').style.visibility 'collapse';
 
                 document.getElementById('btn_sh').innerHTML 'Show passwords';
 
             }
 
             return false;
 
         }
 
       </script>
 
       <form action="./?module=ftp_management&action=EditFTP" method="post">
 
           <table class="table table-striped">
 
               <col />
 
               <col />
 
               <col />
 
               <col id="ColPass" style="visibility:collapse"/>
 
               <col />
 
               <tr>
 
                   <th><: Account name :></th>
 
                   <th><: Home directory :></th>
 
                   <th><: Permission :></th>
 
                   <th><: Password :></th>
 
                   <th><button class="button btn btn-default" id="btn_sh" onClick="return ShowHide()">Show Passwords</button></th>
 
               </tr>
 
               <% loop ClientList %>
 
               <tr>
 
                   <td><& username &></td>
 
                   <td><& directory &></td>
 
                   <td><& access &></td>
 
                   <td><& password &></td>
 
                   <td>
 
                       <button class="button-loader btn btn-default" type="submit" name="inReset_<& id &>" id="button" value="inReset_<& id &>"><: Reset Password :></button>
 
                       <button class="button-loader delete btn btn-danger" type="submit" name="inDelete_<& id &>" id="button" value="inDelete_<& id &>"><: Delete :></button>
 
                   </td>
 
               </tr>
 
               <% endloop %>
 
           </table>
 
           <@ CSFR_Tag @>
 
       </form>
 
       <% else %>
 
       <: You do not have any FTP Accounts setupCreate an FTP account using the form below. :>
 
       <% endif %>
 
   </div>

 
   <% if isCreateFTP %>
 
   <div class="zform_wrapper">
 
       <table class="none" width="100%" cellborder="0" cellspacing="0"><tr valign="top">
 
           <tr valign="top">
 
               <td>
 
                   <h2><: Create a new FTP Account :></h2>
 
                   <% if QuotaLimit %>
 
                   <form action="./?module=ftp_management&action=CreateFTP" method="post">
 
                       <table class="table table-striped">
 
                           <tr>
 
                               <th nowrap="nowrap"><: Username :>:</th>
 
                               <td class="text-right" nowrap="nowrap"><@ CurrentUserName @>_</td>
                                <
td><input name="inFTPUsername" type="text" id="inFTPUsername" size="30" value="" maxlength="50"/></td>
 
                           </tr>
 
                           <tr>
 
                               <th colspan="2"><: Password :>:</th>
 
                               <td><input name="inPassword" type="password" id="inPassword" size="30" maxlength="50" /></td>
 
                           </tr>
 
                           <tr>
 
                               <th colspan="2" nowrap="nowrap"><: Access type :>:</th>
 
                               <td><select name="inAccess" size="1">
 
                                       <option value="RO" selected="selected"><: Read-only :></option>
 
                                       <option value="WO"><: Write-only :></option>
 
                                       <option value="RW"><: Full access :></option>
 
                                   </select></td>
 
                           </tr>
 
                           <tr>
 
                               <th colspan="2" nowrap="nowrap"><: Home directory :>:</th>
 
                               <td><input name="inAutoHome" type="radio" id="inAutoHome" value="1" onclick="hide_div('showmasterselect')&hide_div('showdomainselect');" CHECKED />&nbsp;<: Create a new home directory :></td>
 
                           </tr>
 
                           <tr>
 
                               <th colspan="2">&nbsp;</th>
 
                               <td><input name="inAutoHome" type="radio" id="inAutoHome" value="2" onclick="show_div('showmasterselect')&hide_div('showdomainselect');" />&nbsp;<: Set Master home directory :></td>
 
                           </tr>
 
                           <tr>
 
                               <th colspan="2">&nbsp;</th>
 
                               <td>
 
                                   <div id="showmasterselect" style="display:none;">
 
                                       <select name="inDestination" id="inDestination">
 
                                           <option value="">/ (root)</option>
 
                                           <% loop MasterDirsList %>
 
                                           <option value="<& domains &>">/<& domains &></option>
 
                                           <% endloop %>
 
                                       </select>
 
                                   </div>
 
                               </td>
 
                           </tr>
 
                           <tr>
 
                               <th colspan="2">&nbsp;</th>
 
                               <td><input name="inAutoHome" type="radio" id="inAutoHome" value="3" onclick="show_div('showdomainselect')&hide_div('showmasterselect');" />&nbsp;<: Use Domain directory :></td>
 
                           </tr>
 
                           <tr>
 
                               <th colspan="2">&nbsp;</th>
 
                               <td>
 
                                   <div id="showdomainselect" style="display:none;">
 
                                       <select name="inDomainDestination" id="inDomainDestination">
 
                                           <option value="">/ (root)</option>
 
                                           <% loop DomainDirsList %>
 
                                           <option value="public_html/<& domains &>">/<& domains &></option>
 
                                           <% endloop %>
 
                                       </select>
 
                                   </div>
 
                               </td>
 
                           </tr>
 
                           <tr>
 
                               <th colspan="2" align="right">
 
                                   <button class="button-loader btn btn-primary" type="submit" name="inSubmit" id="inSubmit" value=""><: Create :></button></th>
 
                           </tr>
 
                       </table>
 
                       <@ CSFR_Tag @>
 
                   </form>
 
                   <% else %>
 
                   <: You have reached your FTP account limit! :>
 
                   <% endif %>
 
               </td>
 
               <td align="right"><@ FTPUsagepChart @></td>
 
           </tr>
 
       </table>
 
   </div>
 
   <% endif %>

</
div>

<
script type="text/javascript">
 
   <!--
 
   function show_div(id) {
 
       var e document.getElementById(id);
 
       if(e.style.display == 'none')
 
           e.style.display 'block';
 
   }
 
   //-->
</script>
<
script type="text/javascript">
 
   <!--
 
   function hide_div(id) {
 
       var e document.getElementById(id);
 
       if(e.style.display == 'block')
 
           e.style.display 'none';
 
   }
 
   //-->
</script>
<
script type="text/JavaScript">
 
   $.extend({
 
       password: function (lengthspecial) {
 
           var iteration 0;
 
           var password "";
 
           var randomNumber;
 
           if(special == undefined){
 
               var special false;
 
           }
 
           while(iteration length){
 
               randomNumber = (Math.floor((Math.random() * 100)) % 94) + 33;
 
               if(!special){
 
                   if ((randomNumber >=33) && (randomNumber <=47)) { continue; }
 
                   if ((randomNumber >=58) && (randomNumber <=64)) { continue; }
 
                   if ((randomNumber >=91) && (randomNumber <=96)) { continue; }
 
                   if ((randomNumber >=123) && (randomNumber <=126)) { continue; }
 
               }
 
               iteration++;
 
               password += String.fromCharCode(randomNumber);
 
           }
 
           return password;
 
       }
 
   });
 
   $(document).ready(function() {
 
       $('.link-password').click(function(e){
 
           linkId = $(this).attr('id');
 
           if (linkId == 'generate'){
 
               password = $.password(9,false);
 
               $('#input-password').val(password);
 
           }
 
           e.preventDefault();
 
       });
 
   });
</
script
controller.ext.php:
PHP 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
{

 
   static $error;
 
   static $alreadyexists;
 
   static $blank;
 
   static $badname;
 
   static $invalidPath;
 
   static $ok;
 
   static $delete;
 
   static $reset;
 
   static $create;

 
   /**
     * 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();

 
       if ($numrows->fetchColumn() <> 0) {
 
           $sql $zdbh->prepare($sql);
 
           $res = array();
 
           $sql->bindParam(':userid'$uid);
 
           $sql->execute();
 
           while ($rowclients $sql->fetch()) {
 
               $res[] = array('id' => $rowclients['ft_id_pk'],
 
                   'directory' => runtime_xss::xssClean($rowclients['ft_directory_vc']),
 
                   'access' => runtime_xss::xssClean($rowclients['ft_access_vc']),
 
                   'password' => runtime_xss::xssClean($rowclients['ft_password_vc']),
 
                   'username' => runtime_xss::xssClean($rowclients['ft_user_vc']));
 
           }
 
           return $res;
 
       } else {
 
           return false;
 
       }
 
   }

 
   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();

 
       if ($numrows->fetchColumn() <> 0) {
 
           $sql $zdbh->prepare($sql);
 
           $sql->bindParam(':userid'$uid);
 
           $res = array();
 
           $sql->execute();
 
           while ($rowclients $sql->fetch()) {
 
               $res[] = array('id' => $rowclients['ft_id_pk'],
 
                   'directory' => runtime_xss::xssClean($rowclients['ft_directory_vc']),
 
                   'access' => runtime_xss::xssClean($rowclients['ft_access_vc']),
 
                   'password' => runtime_xss::xssClean($rowclients['ft_password_vc']),
 
                   'username' => runtime_xss::xssClean($rowclients['ft_user_vc']));
 
           }
 
           return $res;
 
       } else {
 
           return false;
 
       }
 
   }

 
   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() == ) {
 
           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_path777);
 
                   @chmod($full_path0777);
 
               }
 
           } 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);

 
           if!== strpos($realPath$baseDir))
 
           {
 
               self::$invalidPath true;
 
               return false;
 
           }

 
           $sql $zdbh->prepare("INSERT INTO x_ftpaccounts (ft_acc_fk, ft_user_vc, ft_directory_vc, ft_access_vc, ft_password_vc, ft_created_ts) VALUES (:userid, :username, :homedir, :accesstype, :password, :time)");
 
           $sql->bindParam(':userid'$currentuser['userid']);
 
           $sql->bindParam(':username'$username);
 
           $sql->bindParam(':homedir'$homedirectory_to_use);
 
           $sql->bindParam(':accesstype'$access_type);
 
           $sql->bindParam(':password'$password);
 
           $sql->bindParam(':time'time());
 
           $sql->execute();
 
           self::$create 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);
 
           }
 
           runtime_hook::Execute('OnAfterCreateFTPAccount');
 
           return true;
 
       }
 
       return false;
 
   }

 
   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 IsValidUserName($username)
 
   {
 
       return preg_match('/^[a-z\d_][a-z\d_-]{0,62}$/i'$username) || preg_match('/-$/'$username) == 1;
 
   }

 
   static function ExecuteDeleteFTP($ft_id_pk$uid)
 
   {
 
       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() == ) {
 
           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;
 
   }

 
   /**
     * End 'worker' methods.
     */

 
   /**
     * Webinterface sudo methods.
     */
 
   static function doCreateFTP()
 
   {
 
       global $controller;
 
       runtime_csfr::Protect();
 
       $currentuser ctrl_users::GetUserDetail();
 
       $formvars $controller->GetAllControllerRequests('FORM');
 
       if (self::ExecuteCreateFTP($currentuser['userid'], $formvars['inFTPUsername'], $formvars['inPassword'], $formvars['inDestination'], $formvars['inDomainDestination'], $formvars['inAccess'], $formvars['inAutoHome'])) {
 
           self::$ok true;
 
           return true;
 
       } else {
 
           return false;
 
       }
 
   }

 
   static function doDeleteFTP()
 
   {
 
       global $controller;
 
       runtime_csfr::Protect();
 
       $formvars $controller->GetAllControllerRequests('FORM');
 
       if (self::ExecuteDeleteFTP($formvars['inDelete']))
 
           self::$ok true;
 
       return true;
 
   }

 
   static function doResetPassword()
 
   {
 
       global $controller;
 
       runtime_csfr::Protect();
 
       $formvars $controller->GetAllControllerRequests('FORM');
 
       if (self::ExecuteResetPassword($formvars['inReset'], $formvars['inPassword']))
 
           self::$ok true;
 
       return true;
 
   }

    static function 
getCurrentUserName()
 
   {
 
       $currentuser ctrl_users::GetUserDetail();
 
       return $currentuser['username'];
 
   }

 
   static function getClientList()
 
   {
 
       $currentuser ctrl_users::GetUserDetail();
 
       $clientlist self::ListClients($currentuser['userid']);
 
       return (!fs_director::CheckForEmptyValue($clientlist)) ? $clientlist false;
 
   }

 
   static function getDomainDirsList()
 
   {
 
       $currentuser ctrl_users::GetUserDetail();
 
       $domaindirectories self::ListDomainDirs($currentuser['userid']);
 
       return (!fs_director::CheckForEmptyValue($domaindirectories)) ? $domaindirectories false;
 
   }

 
   static function getMasterDirsList()
 
   {
 
       $currentuser ctrl_users::GetUserDetail();
 
       $domaindirectories self::ListMasterDirs($currentuser['userid']);
 
       return (!fs_director::CheckForEmptyValue($domaindirectories)) ? $domaindirectories false;
 
   }

 
   static function doEditFTP()
 
   {
 
       global $controller;
 
       runtime_csfr::Protect();
 
       $currentuser ctrl_users::GetUserDetail();
 
       $formvars $controller->GetAllControllerRequests('FORM');
 
       foreach (self::ListClients($currentuser['userid']) as $row) {
 
           if (isset($formvars['inDelete_' $row['id'] . ''])) {
 
               header("location: ./?module=" $controller->GetCurrentModule() . "&show=Delete&other=" $row['id']);
 
               exit;
 
           }
 
           if (isset($formvars['inReset_' $row['id'] . ''])) {
 
               header("location: ./?module=" $controller->GetCurrentModule() . "&show=Edit&other=" $row['id']);
 
               exit;
 
           }
 
       }
 
       return;
 
   }

 
   static function getisCreateFTP()
 
   {
 
       global $controller;
 
       $urlvars $controller->GetAllControllerRequests('URL');
 
       return !isset($urlvars['show']);
 
   }

 
   static function getisDeleteFTP($uid)
 
   {
 
       global $controller;
 
       global $zdbh;

 
       $urlvars $controller->GetAllControllerRequests('URL');

 
       // 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() == ) {
 
           return;
 
       }

 
       // Show User Info
 
       return (isset($urlvars['show'])) && ($urlvars['show'] == "Delete");
 
   }

 
   static function getisEditFTP($uid)
 
   {
 
       global $controller;
 
       global $zdbh;

 
       $urlvars     $controller->GetAllControllerRequests('URL');

 
       // 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() == ) {
 
           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 getQuotaLimit()
 
   {
 
       $currentuser ctrl_users::GetUserDetail();
 
       return ($currentuser['ftpaccountsquota'] < ) or //-1 = unlimited
 
               ($currentuser['ftpaccountsquota'] > ctrl_users::GetQuotaUsages('ftpaccounts'$currentuser['userid']));
 
   }

 
   static function getFTPUsagepChart()
 
   {
 
   global $controller;
 
   $currentuser ctrl_users::GetUserDetail();
 
   $maximum $currentuser['ftpaccountsquota'];
 
   if ($maximum 0) { //-1 = unlimited
 
           if (file_exists(ui_tpl_assetfolderpath::Template() . 'img/misc/unlimited.png')) {
 
       return '<img src="' ui_tpl_assetfolderpath::Template() . 'img/misc/unlimited.png" alt="' ui_language::translate('Unlimited') . '"/>';
 
     } else {
 
       return '<img src="modules/' $controller->GetControllerRequest('URL''module') . '/assets/unlimited.png" alt="' ui_language::translate('Unlimited') . '"/>';
 
     }
 
       } else {
 
           $used ctrl_users::GetQuotaUsages('ftpaccounts'$currentuser['userid']);
 
           $free max($maximum $used0);
 
           return '<img src="etc/lib/pChart2/sentora/z3DPie.php?score=' $free '::' $used
                    
'&labels=Free: ' $free '::Used: ' $used
                    
'&legendfont=verdana&legendfontsize=8&imagesize=240::190&chartsize=120::90&radius=100&legendsize=150::160"'
 
                   ' alt="' ui_language::translate('Pie chart') . '"/>';
 
       }
 
   }

 
   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.
     */

-TGates - Project Council

SEARCH the Forums or read the DOCUMENTATION before posting!
Support Sentora and Donate: HERE

Find my support or modules useful? Donate to TGates HERE
Developers and code testers needed!
Contact TGates for more information
Reply
Thanks given by:


Possibly Related Threads…
Thread Author Replies Views Last Post
change username from email umarzuki@gmail.com 0 1 ,300 11-25-2022, 05:46 PM
Last Post: umarzuki@gmail.com
hat is the MYSQL default Username owenclements 1 4 ,242 08-07-2019, 11:13 PM
Last Post: Ron-e
What is the MYSQL default Username laurencesch 1 4 ,196 05-22-2017, 07:34 PM
Last Post: Me.B

Forum Jump:


Users browsing this thread: 1 Guest(s)