Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/photo/components/server_test.php
Строк: 131
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_Admin_photo_server_test extends VModule_Admin_photo
{
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
render()
    {
        
$db VF::factory('database');
    
        
$errors        = array();
        
$messages    = array();
        
$tests        = array();
        
$server        = array();
        
$id            = (isset($_GET['id'])) ? (int) trim($_GET['id']) : 0;

        
$db->query("SELECT * FROM #__photo_servers WHERE server_id = ".$id." LIMIT 1");
        if (
$db->affected_rows()) {
            
$server    $db->fetch_assoc();
            
            if (
$conn_id ftp_connect($server['ftp_host'], (int) $server['ftp_port'])) {
                
$tests[]    = 'Connected to '.$server['ftp_host'].':'.$server['ftp_port'].' via FTP...';
                if (
ftp_login($conn_id$server['ftp_username'], $server['ftp_password'])) {
                    
$tests[]     = 'Logged in using username: '.$server['ftp_username'].'...';
                    if (
ftp_chdir($conn_id$server['ftp_root'])) {
                        
$tests[]     = 'Directory changed to: '.$server['ftp_root'].'!';
                        
$base        ftp_pwd($conn_id);
                        
                        if (
ftp_pasv($conn_idTRUE)) {
                            
$tests[]     = 'Passive FTP enabled!';
                        } else {
                            
$tests[]    = 'Failed to enable Passive FTP!';
                        }
                        
                        if (
ftp_chdir($conn_id'media/photos')) {
                            
$tests[]    = 'Changed directory to '.$server['ftp_root'].'/media/photos...';
                            
                            
$src        ADMIN_DIR.'/modules/photo/files/logo.png';
                            if (
ftp_put($conn_id'logo.png'$srcFTP_BINARY)) {
                                
$tests[]    = 'Uploaded logo.png!';
                                if (
ftp_delete($conn_id'logo.png')) {
                                    
$tests[]    = 'Deleted logo.png!';
                                } else {
                                    
$tests[]    = 'Failed to delete logo.png!';
                                }
                            } else {
                                
$tests[] = 'Failed to upload logo.png!';
                            }
                        } else {
                            
$tests[]    = 'Failed to change directory to: media/photos!';
                        }
                        
                        
ftp_chdir($conn_id$base);
                        if (
ftp_chdir($conn_id'media/photos/covers')) {
                            
$tests[]    = 'Changed directory to '.$server['ftp_root'].'/media/photos/covers...';
                            
                            
$src        ADMIN_DIR.'/modules/photo/files/logo.png';
                            if (
ftp_put($conn_id'logo.png'$srcFTP_BINARY)) {
                                
$tests[]    = 'Uploaded logo.png!';
                                if (
ftp_delete($conn_id'logo.png')) {
                                    
$tests[]    = 'Deleted logo.png!';
                                } else {
                                    
$tests[]    = 'Failed to delete logo.png!';
                                }
                            } else {
                                
$tests[] = 'Failed to upload logo.png!';
                            }
                        } else {
                            
$tests[]    = 'Failed to change directory to: media/photos/covers!';
                        }
                        
                        
ftp_chdir($conn_id$base);
                        if (
ftp_chdir($conn_id'media/photos/mobile')) {
                            
$tests[]    = 'Changed directory to '.$server['ftp_root'].'/media/photos/mobile...';
                        
                            
$src        ADMIN_DIR.'/modules/photo/files/logo.png';
                            if (
ftp_put($conn_id'logo.png'$srcFTP_BINARY)) {
                                
$tests[]    = 'Uploaded logo.png!';
                                if (
ftp_delete($conn_id'logo.png')) {
                                    
$tests[]    = 'Deleted logo.png!';
                                } else {
                                    
$tests[]    = 'Failed to delete logo.png!';
                                }
                            } else {
                                
$tests[] = 'Failed to upload logo.png!';
                            }
                        } else {
                            
$tests[]    = 'Failed to change directory to: media/photos/mobile!';
                        }

                        
ftp_chdir($conn_id$base);
                        if (
ftp_chdir($conn_id'media/photos/orig')) {
                            
$tests[]    = 'Changed directory to '.$server['ftp_root'].'/media/photos/orig...';
                        
                            
$src        ADMIN_DIR.'/modules/photo/files/logo.png';
                            if (
ftp_put($conn_id'logo.png'$srcFTP_BINARY)) {
                                
$tests[]    = 'Uploaded logo.png!';
                                if (
ftp_delete($conn_id'logo.png')) {
                                    
$tests[]    = 'Deleted logo.png!';
                                } else {
                                    
$tests[]    = 'Failed to delete logo.png!';
                                }
                            } else {
                                
$tests[] = 'Failed to upload logo.png!';
                            }
                        } else {
                            
$tests[]    = 'Failed to change directory to: media/photos/orig!';
                        }

                        
ftp_chdir($conn_id$base);
                        if (
ftp_chdir($conn_id'media/photos/thumbs')) {
                            
$tests[]    = 'Changed directory to '.$server['ftp_root'].'/media/photos/thumbs...';
                        
                            
$src        ADMIN_DIR.'/modules/photo/files/logo.png';
                            if (
ftp_put($conn_id'logo.png'$srcFTP_BINARY)) {
                                
$tests[]    = 'Uploaded logo.png!';
                                if (
ftp_delete($conn_id'logo.png')) {
                                    
$tests[]    = 'Deleted logo.png!';
                                } else {
                                    
$tests[]    = 'Failed to delete logo.png!';
                                }
                            } else {
                                
$tests[] = 'Failed to upload logo.png!';
                            }
                        } else {
                            
$tests[]    = 'Failed to change directory to: media/photos/thumbs!';
                        }
                    } else {
                        
$tests[]    = 'Failed to change directory to: '.$server['ftp_root'].'!';
                    }
                } else {
                    
$tests[]    = 'Failed to login to FTP Server (username: '.$ftp['username'].')!';    
                }
            } else {
                
$tests[]    = 'Failed to connect to FTP Server ('.$server['ftp_host'].':'.$server['ftp_port'].')!';
            }
        }
    
        
$tpl VF::factory('template');
        
$tpl->menu            'photo';
        
$tpl->submenu        'photo_server';
        
$tpl->meta_title    'Photo::Server::Test';
        
$tpl->errors        $errors;
        
$tpl->messages        $messages;
        
$tpl->server        $server;
        
$tpl->tests            $tests;
        
$tpl->load(array('header''photo_server_test''footer'));
        
$tpl->display();
    }
}
Онлайн: 3
Реклама