Пример #1
0
                $res = $cpanel_file->uploadfiles($_FILES['file'], _post('upload_path'));
                add_message($res);
            }
        }
    }
    /**
     * write file
     */
    if ($task == 'savefile') {
        //save file to this path
        $target_dir = _post('path');
        if (!$target_dir) {
            $target_dir = _post('path1');
        }
        #$cpanel_file = HW_CPanel_Fileman::init($cpanel);
        $cpanel_file = HW_CPanel_Fileman::loadacct($acc_id);
        $filedata = array('dir' => $target_dir, 'file' => _post('filename'), 'content' => _post('content'));
        $res = $cpanel_file->savefile($filedata);
        add_message($res);
    }
}
invalid_form:
//list saved accounts
$accts = list_whm_accts();
?>
<html xmlns="http://www.w3.org/1999/html">
<head>
    <title>File Manager (cPanel)</title>
    <?php 
include 'template/head.php';
?>
Пример #2
0
 /**
  * upload tool
  * @param $acc_id
  * @param $subdomain
  * @param $runfile located in ../tmp/ folder
  * @return mixed
  */
 function upload_wptool($acc_id = '', $subdomain = '', $runfile = '')
 {
     if (!$acc_id) {
         $acc_id = $this->acc_id;
     }
     #$subdomain = _post('subdomain');
     $upload_path = '/public_html/' . $subdomain;
     if (empty($runfile)) {
         $runfile = HW_WP_TOOL_FILE;
     }
     $file = array('fullpath' => file_exists($runfile) ? $runfile : ROOT_DIR . "/tmp/{$runfile}", 'type' => 'text/plain', 'name' => $runfile);
     $cpanel_file = HW_CPanel_Fileman::loadacct($acc_id, true);
     //$this->get_instance('fileman');//
     $res = $cpanel_file->uploadfiles($file, $upload_path);
     return $res;
 }
Пример #3
0
/**
 * list files
 * @param $data
 */
function listfiles($data)
{
    //get path to list files
    $dir = _post('path');
    if (!$dir && _post('path1')) {
        $dir = _post('path1');
    }
    //type
    $types = $type = _post('type');
    if ($type == 'zip') {
        $types = 'file';
    }
    /*
    $query = "/json-api/cpanel?cpanel_jsonapi_user={$cpaneluser}&cpanel_jsonapi_apiversion=2&cpanel_jsonapi_module=Fileman&cpanel_jsonapi_func=listfiles&checkleaf=1&dir={$dir}&filelist=0&showdotfiles=0&types={$types}";
    
    $cpanel = HW_CPanel::loadacct_instance($acc_id, false);
    $result = $cpanel->cpanelapi($query);
    //ajax_output($result) ;
    */
    //authorize
    $cpanel_file = HW_CPanel_Fileman::loadacct($data->acc_id);
    $result = $cpanel_file->listfiles(array('type' => _post('type'), 'dir' => _post('path'), 'dir1' => _post('path1')));
    $result = json_decode($result);
    if (isset($result->cpanelresult->data) && count($result->cpanelresult->data)) {
        echo '<table border="1px" cellpadding="3" cellspacing="1" class="hover-table">';
        echo '<tr>
            <td><strong>File/folder</strong></td>
            <td><strong>fullpath</strong></td>
            <td><strong>chmod</strong></td>
            <td><strong>Size</strong></td>
            <td><strong>type</strong></td>
            <td></td>
        </tr>';
        foreach ($result->cpanelresult->data as $file) {
            if ($file->type == 'file' && $type == 'zip' && !preg_match('#(\\.tar\\.gz|\\.zip)$#', $file->file)) {
                continue;
            }
            //unzip link
            $unzip_opt = '';
            if ($file->type == 'file' && preg_match('#(\\.tar\\.gz|\\.zip)$#', $file->file)) {
                $unzip_opt = '<a class="tooltip-top" title="Extract this zip file" href="javascript:void(0)" data-cpid="' . $data->acc_id . '" onclick="hw_extractfile(this, \'' . $file->file . '\', \'' . $file->path . '\')">extract</a>';
            }
            //del link
            $del_link = '<a class="tooltip-top" title="Delete file on server" href="javascript:void(0)" data-cpid="' . $data->acc_id . '" onclick="hw_delfile(this, \'' . $file->file . '\', \'' . $file->path . '\')">Delete</a>';
            $move_link = '<a class="tooltip-top" title="Move this file" id="" href="javascript:void(0)" data-cpid="' . $data->acc_id . '" onclick="hw_moveobj(this,\'' . $file->fullpath . '\' )">Move file/folder</a>';
            if ($file->type == 'dir') {
                //$move_dirfiles_link = '<a id="" href="javascript:void(0)" data-cpid="'.$acc_id.'" onclick="hw_moveobj(this,\''.$file->fullpath.'\' )">Move file/folder</a>';
            }
            //$cpanel_pathfile = str_replace('/home/'.$cpaneluser.'/','',$file->fullpath);
            $download_link = '<a class="tooltip-top" title="Download this file" id="" href="javascript:void(0)" data-cpid="' . $data->acc_id . '" onclick="hw_downloadfile(this,\'' . $file->fullpath . '\' )">Download</a>';
            $transer2other_server = '<a class="tooltip-top" title="Transfer this backup to other server" id="" href="javascript:void(0)" data-cpid="' . $data->acc_id . '" onclick="hw_transfer_backup_4other_acct(this ,\'' . $data->acc_id . '\')" data-file="' . $file->fullpath . '">Transfer to other server</a>';
            echo '<tr>';
            echo "<td>{$file->file}</td>";
            echo "<td>{$file->fullpath}</td>";
            echo "<td>{$file->nicemode}</td>";
            echo "<td>{$file->humansize}</td>";
            echo "<td>{$file->type}</td>";
            echo "<td>{$unzip_opt} | {$del_link} | {$move_link}|{$download_link}<br/>{$transer2other_server}</td>";
            echo '</tr>';
        }
        echo '</table>';
    }
}
Пример #4
0
/**
 * restore backup
 * @param $data
 */
function restore_backup($data)
{
    $cpanel_file = HW_CPanel_Fileman::loadacct($data->acc_id);
    $result = $cpanel_file->restore_backup();
    ajax_output($result);
}