Exemple #1
0
 function CloseFtp()
 {
     global $g_ftpLink;
     if ($g_ftpLink) {
         @ftp_quit($g_ftpLink);
     }
 }
/**
* FTP File to Location
*/
function ftp_file($source_file, $dest_file, $mimetype, $disable_error_mode = false)
{
    global $config, $lang, $error, $error_msg;
    $conn_id = attach_init_ftp();
    // Binary or Ascii ?
    $mode = FTP_BINARY;
    if (preg_match("/text/i", $mimetype) || preg_match("/html/i", $mimetype)) {
        $mode = FTP_ASCII;
    }
    $res = @ftp_put($conn_id, $dest_file, $source_file, $mode);
    if (!$res && !$disable_error_mode) {
        $error = true;
        if (!empty($error_msg)) {
            $error_msg .= '<br />';
        }
        $error_msg = sprintf($lang['Ftp_error_upload'], $config['ftp_path']) . '<br />';
        @ftp_quit($conn_id);
        return false;
    }
    if (!$res) {
        return false;
    }
    @ftp_site($conn_id, 'CHMOD 0644 ' . $dest_file);
    @ftp_quit($conn_id);
    return true;
}
Exemple #3
0
 function disconnect()
 {
     if ($this->socket) {
         @ftp_quit($this->socket);
         $this->FtpAccess();
     }
 }
Exemple #4
0
function enviaImagen($fRutaImagen, $fDirServ, $fNombreImagen)
{
    $host = 'ftp.laraandalucia.com';
    $usuario = 'laraandalucia.com';
    $pass = '******';
    $errorFtp = 'no';
    $dirServ = 'html/images/Lara/' . $fDirServ;
    $conexion = @ftp_connect($host);
    if ($conexion) {
        if (@ftp_login($conexion, $usuario, $pass)) {
            if (!@ftp_chdir($conexion, $dirServ)) {
                if (!@ftp_mkdir($conexion, $dirServ)) {
                    $errorFtp = 'si';
                }
            }
        } else {
            $errorFtp = 'si';
        }
    } else {
        $errorFtp = 'si';
    }
    if ($errorFtp = 'no') {
        @ftp_chdir($conexion, $dirServ);
        if (@(!ftp_put($conexion, $fNombreImagen, $fRutaImagen, FTP_BINARY))) {
            $errorFtp = 'si';
        }
    }
    @ftp_quit($conexion);
    return $errorFtp == 'no';
}
Exemple #5
0
 /**
  * Closes the session
  */
 public function close()
 {
     $success = @ftp_quit($this->handle);
     
     if( !$success )
         throw new cFTP_Exception("Could not disconnect", 2);
 }
Exemple #6
0
    public function __destruct ()
	{
		if($this->stream!==null) {
			ftp_quit($this->stream);
		}
        $this->stream = null;
    }
Exemple #7
0
 /**
  * Find out if a set of login credentials are valid.
  *
  * @param string $userId      The userId to check.
  * @param array $credentials  An array of login credentials. For FTP,
  *                            this must contain a password entry.
  *
  * @throws Horde_Auth_Exception
  */
 protected function _authenticate($userId, $credentials)
 {
     $ftp = @ftp_connect($this->_params['hostspec'], $this->_params['port']);
     $res = $ftp && @ftp_login($ftp, $userId, $credentials['password']);
     @ftp_quit($ftp);
     if ($res) {
         throw new Horde_Auth_Exception('', Horde_Auth::REASON_BADLOGIN);
     }
 }
Exemple #8
0
function ObtenerRuta()
{
    //Obriene ruta del directorio del Servidor FTP (Comando PWD)
    $id_ftp = ConectarFTP();
    //Obtiene un manejador y se conecta al Servidor FTP
    $Directorio = ftp_pwd($id_ftp);
    //Devuelve ruta
    ftp_quit($id_ftp);
    //Cierra la conexion FTP
    return $Directorio;
    //Devuelve la ruta a la función
}
Exemple #9
0
 static function GetFTPServer()
 {
     if (isset($_SERVER['HTTP_HOST'])) {
         $server = $_SERVER['HTTP_HOST'];
     } elseif (isset($_SERVER['SERVER_NAME'])) {
         $server = $_SERVER['SERVER_NAME'];
     } else {
         return '';
     }
     $conn_id = @ftp_connect($server, 21, 6);
     if ($conn_id) {
         @ftp_quit($conn_id);
         return $server;
     }
     return '';
 }
Exemple #10
0
 function sion_ftp_put($fileOri)
 {
     // ------------------------------------------------------
     // Esta funcion se encarga de poner un ARCHIVO en FTP.
     // ------------------------------------------------------
     $ftp_server = "ftpham04.hamburgsud.com";
     $ftp_user_name = "ope";
     $ftp_user_pass = "******";
     $path_parts = pathinfo($fileOri);
     $fileX = $path_parts['basename'];
     //$dirRem = $dirRem."/";
     $id_ftp = ftp_connect($ftp_server, 21);
     ftp_login($id_ftp, $ftp_user_name, $ftp_user_pass);
     ftp_pasv($id_ftp, false);
     ftp_chdir($id_ftp, "from");
     if (ftp_put($id_ftp, $fileX, $fileOri, FTP_BINARY)) {
         echo "<hr>OK Cargado : {$fileOri}<hr>";
     } else {
         echo "<hr>No subio : {$fileOri}<hr>";
     }
     ftp_quit($id_ftp);
 }
/**
* Check if Attachment exist
*/
function attachment_exists($filename)
{
    global $upload_dir, $config;
    $filename = basename($filename);
    if (!intval($config['allow_ftp_upload'])) {
        if (!@file_exists(@amod_realpath($upload_dir . '/' . $filename))) {
            return false;
        } else {
            return true;
        }
    } else {
        $found = false;
        $conn_id = attach_init_ftp();
        $file_listing = array();
        $file_listing = @ftp_rawlist($conn_id, $filename);
        for ($i = 0, $size = sizeof($file_listing); $i < $size; $i++) {
            if (ereg("([-d])[rwxst-]{9}.* ([0-9]*) ([a-zA-Z]+[0-9: ]*[0-9]) ([0-9]{2}:[0-9]{2}) (.+)", $file_listing[$i], $regs)) {
                if ($regs[1] == 'd') {
                    $dirinfo[0] = 1;
                    // Directory == 1
                }
                $dirinfo[1] = $regs[2];
                // Size
                $dirinfo[2] = $regs[3];
                // Date
                $dirinfo[3] = $regs[4];
                // Filename
                $dirinfo[4] = $regs[5];
                // Time
            }
            if ($dirinfo[0] != 1 && $dirinfo[4] == $filename) {
                $found = true;
            }
        }
        @ftp_quit($conn_id);
        return $found;
    }
}
function listPfiles($datasrc, $filter = "")
{
    $con = ftp_connect($datasrc->host) or die("Couldn't connect to {$datasrc->host}");
    if (!ftp_login($con, $datasrc->user, $datasrc->pwd)) {
        trigger_error("ftp login to {$datasrc->host} failed.");
        $pfileTree = 0;
    } else {
        $rawFiles = ftp_rawlist($con, $datasrc->dataDir);
        foreach ($rawFiles as $raw) {
            //echo $raw;
            ereg("([-d])([rwxst-]{9}).* ([0-9]*) ([a-zA-Z]+[0-9: ]* [0-9]{2}:?[0-9]{2}) (.+)", $raw, $regs);
            $files[] = array("is_dir" => $regs[1] == "d" ? true : false, "mod" => $regs[2], "size" => $regs[3], "time" => $regs[4], "name" => $regs[5], "raw" => $regs[0]);
        }
        // Find all P-files
        foreach ($files as $f) {
            if (ereg("^P.*\\.7\$", basename($f["name"]))) {
                $pfiles[] = basename($f["name"]);
            }
        }
        if (count($pfiles) > 0) {
            // Now find the tree of files associated with each P-file
            foreach ($pfiles as $pfileNum => $pfile) {
                foreach ($files as $f) {
                    if (ereg(".*" . $pfile . ".*", basename($f["name"]))) {
                        $pfileTree[$pfile]->name[] = $f["name"];
                        $pfileTree[$pfile]->size[] = $f["size"];
                        $pfileTree[$pfile]->time[] = $f["time"];
                    }
                }
            }
        } else {
            $pfileTree = 0;
        }
    }
    ftp_quit($con);
    return $pfileTree;
}
function SendViaFTP($i, $source_file, $conn_msg = 1)
{
    global $config, $out, $lang;
    flush();
    if ($conn_msg == 1) {
        $out .= '<span class="success">' . $lang['L_FILESENDFTP'] . "(" . $config['ftp_server'][$i] . " - " . $config['ftp_user'][$i] . ")</span><br>";
    }
    // Herstellen der Basis-Verbindung
    if ($config['ftp_useSSL'][$i] == 0) {
        $conn_id = @ftp_connect($config['ftp_server'][$i], $config['ftp_port'][$i], $config['ftp_timeout'][$i]);
    } else {
        $conn_id = @ftp_ssl_connect($config['ftp_server'][$i], $config['ftp_port'][$i], $config['ftp_timeout'][$i]);
    }
    // Einloggen mit Benutzername und Kennwort
    $login_result = @ftp_login($conn_id, $config['ftp_user'][$i], $config['ftp_pass'][$i]);
    if ($config['ftp_mode'][$i] == 1) {
        ftp_pasv($conn_id, true);
    }
    // Verbindung überprüfen
    if (!$conn_id || !$login_result) {
        $out .= '<span class="error">' . $lang['L_FTPCONNERROR'] . $config['ftp_server'][$i] . $lang['L_FTPCONNERROR1'] . $config['ftp_user'][$i] . $lang['L_FTPCONNERROR2'] . '</span><br>';
    } else {
        if ($conn_msg == 1) {
            $out .= '<span class="success">' . $lang['L_FTPCONNECTED1'] . $config['ftp_server'][$i] . $lang['L_FTPCONNERROR1'] . $config['ftp_user'][$i] . '</span><br>';
        }
    }
    // Upload der Datei
    $dest = $config['ftp_dir'][$i] . $source_file;
    $source = $config['paths']['backup'] . $source_file;
    $upload = @ftp_put($conn_id, $dest, $source, FTP_BINARY);
    // Upload-Status überprüfen
    if (!$upload) {
        $out .= '<span class="error">' . $lang['L_FTPCONNERROR3'] . "<br>({$source} -> {$dest})</span><br>";
    } else {
        $out .= '<span class="success">' . $lang['L_FILE'] . ' <a href="' . $config['paths']['backup'] . $source_file . '" class="smallblack">' . $source_file . '</a>' . $lang['L_FTPCONNECTED2'] . $config['ftp_server'][$i] . $lang['L_FTPCONNECTED3'] . '</span><br>';
        WriteLog("'{$source_file}' sent via FTP.");
    }
    // Schließen des FTP-Streams
    @ftp_quit($conn_id);
}
Exemple #14
0
 /**
  * close FTP connection
  *
  * @return boolean
  */
 function ftpClose()
 {
     if (!$this->ftp) {
         return false;
     }
     if (@ftp_quit($this->ftp)) {
         $this->addMsg("Closed connection to {$this->host}:{$this->port}");
         $this->ftp = null;
         return true;
     }
     $this->addMsg("Could not close connection to {$this->host}:{$this->port}", 'error');
     return false;
 }
function getProtocol($datasrc, $category, $protocol)
{
    // Try to prevent rogue users from getting any random file from the server.
    // This should prevent 'category=../../../' style hacks.
    $category = basename($category);
    $protocol = basename($protocol);
    $con = ftp_connect($datasrc->host) or die("Couldn't connect to {$datasrc->host}");
    if (!ftp_login($con, $datasrc->user, $datasrc->pwd)) {
        trigger_error("ftp login to {$datasrc->host} failed.");
    } else {
        $temp = tmpfile();
        $getFile = $datasrc->protocolDir . "/" . $category . "/" . $protocol;
        $stat = ftp_fget($con, $temp, $getFile, FTP_ASCII);
        rewind($temp);
        $protStr = fread($temp, 1000000);
        fclose($temp);
    }
    ftp_quit($con);
    // PARSE PROTOCOL FILE
    // For debugging:
    //echo "<pre>$protStr</pre>";
    // First, remove the many useless 'GLOBAL' lines
    $protStr = preg_replace("/global .*\n/", "", $protStr);
    // Extract the protocol description fields
    preg_match("/set PROTNAME \"(.*)\"/", $protStr, $matches);
    $p["name"] = $matches[1];
    preg_match("/set REVNO \"(.*)\"/", $protStr, $matches);
    $p["revno"] = $matches[1];
    preg_match("/set SCANNUM \"(.*)\"/", $protStr, $matches);
    $p["scanNum"] = $matches[1];
    preg_match("/set SERIESNUM \"(.*)\"/", $protStr, $matches);
    $p["seriesNum"] = $matches[1];
    // Now, parse each series
    $ser = explode('proc ', $protStr);
    array_shift($ser);
    foreach ($ser as $seriesNum => $seriesStr) {
        $tmp = explode('set ', $seriesStr);
        array_shift($tmp);
        foreach ($tmp as $paramNum => $paramStr) {
            preg_match("/(.*) \"(.*)\"/", $paramStr, $matches);
            $p['series'][$seriesNum + 1][strtolower(trim($matches[1]))] = $matches[2];
            //echo "$seriesNum $matches[1] $p[$seriesNum+1][$matches[1]]";
        }
    }
    return $p;
}
function ftp_closeconnection($conn_id)
{
    // --------------
    // This function closes an ftp connection
    // --------------
    ftp_quit($conn_id);
}
Exemple #17
0
         page_common_form($s_hidden_fields, $lang['Download_config']);
     }
     page_footer();
     exit;
 } else {
     // Write out a temp file...
     $tmpfname = @tempnam('/tmp', 'cfg');
     @unlink($tmpfname);
     // unlink for safety on php4.0.3+
     $fp = @fopen($tmpfname, 'w');
     @fwrite($fp, stripslashes($HTTP_POST_VARS['config_data']));
     @fclose($fp);
     // Now ftp it across.
     @ftp_chdir($conn_id, $ftp_dir);
     $res = ftp_put($conn_id, 'config.' . $phpEx, $tmpfname, FTP_ASCII);
     @ftp_quit($conn_id);
     unlink($tmpfname);
     if ($upgrade == 1) {
         require 'upgrade.' . $phpEx;
         exit;
     }
     // Ok we are basically done with the install process let's go on
     // and let the user configure their board now. We are going to do
     // this by calling the admin_board.php from the normal board admin
     // section.
     $s_hidden_fields = '<input type="hidden" name="username" value="' . $admin_name . '" />';
     $s_hidden_fields .= '<input type="hidden" name="password" value="' . $admin_pass1 . '" />';
     $s_hidden_fields .= '<input type="hidden" name="redirect" value="../admin/index.' . $phpEx . '" />';
     $s_hidden_fields .= '<input type="hidden" name="submit" value="' . $lang['Login'] . '" />';
     page_header($lang['Inst_Step_2']);
     page_common_form($s_hidden_fields, $lang['Finish_Install']);
                if ($ftpserver = @parse_url($phpAds_config['type_web_ftp'])) {
                    $type_web_ftp_password = $ftpserver['pass'];
                }
            }
            if (isset($type_web_ftp_host) && ($ftpsock = @ftp_connect($type_web_ftp_host))) {
                if (@ftp_login($ftpsock, $type_web_ftp_user, $type_web_ftp_password)) {
                    if (empty($type_web_ftp_path) || @ftp_chdir($ftpsock, $type_web_ftp_path)) {
                        $type_web_ftp = 'ftp://' . urlencode($type_web_ftp_user) . ':' . urlencode($type_web_ftp_password) . '@' . $type_web_ftp_host . '/' . urlencode($type_web_ftp_path);
                        phpAds_SettingsWriteAdd('type_web_ftp', $type_web_ftp);
                    } else {
                        $errormessage[2][] = $strTypeFTPErrorDir;
                    }
                } else {
                    $errormessage[2][] = $strTypeFTPErrorConnect;
                }
                @ftp_quit($ftpsock);
            } else {
                $errormessage[2][] = $strTypeFTPErrorHost;
            }
        }
    }
    phpAds_SettingsWriteAdd('type_html_auto', isset($type_html_auto));
    phpAds_SettingsWriteAdd('type_html_php', isset($type_html_php));
    if (!count($errormessage)) {
        if (phpAds_SettingsWriteFlush()) {
            header("Location: settings-admin.php");
            exit;
        }
    }
}
/*********************************************************/
 private function sendTrouthFTP($host, $user, $password, $folder_local, $file_name, $folder_remout)
 {
     // Соединение с удаленным FTP-сервером
     print "Соединение с сервером {$host}<br>";
     $connect = ftp_connect($host);
     if (!$connect) {
         echo "Ошибка соединения";
         exit;
     } else {
         echo "Соединение установлено<br><br>";
     }
     // Регистрация на FTP-сервере
     print "Регистрация на FTP-сервере<br>Логин {$user}<br>Пароль {$password}<br>";
     $result = ftp_login($connect, $user, $password);
     if (!$result) {
         echo "Не залогинились";
         exit;
     } else {
         echo "Залогинились<br><br>";
     }
     ftp_pasv($connect, true);
     //  $new_dir = "home/i/itwebnetru/rusneon/public_html";
     // сохраняем имя текущего рабочего каталога
     print $current_dir = ftp_pwd($connect);
     //        $folder_remout = "/rusneon/public_html/";
     //        $folder_remout = $current_dir;
     // Копируем файл
     //        $folder_local = $_SERVER['DOCUMENT_ROOT'] . "/";
     //        $file_name = "200812111155_1ddbf8a5.tar.gz";
     $rrr = ftp_put($connect, $folder_local . $file_name, $folder_remout . $file_name, FTP_BINARY);
     print "Копирование файла {$file_name}<br>";
     if (!$rrr) {
         echo "Завершилось неудачей (((";
     } else {
         echo "Удачно скопировано )))";
     }
     // Закрываем соединение
     ftp_quit($connect);
 }
Exemple #20
0
                    $table[$z][3]['text'] = $lineinfo['rounded_size'];
                } elseif ($lineinfo['folder'] == TRUE and $lineinfo['name'] != "." and $lineinfo['name'] != "..") {
                    $linkurl = rawurlencode($lineinfo['name']);
                    $table[$z][0]['text'] = '<img src="design/' . $auth['design'] . '/images/downloads_folder.gif" border="0">';
                    $table[$z][0]['link'] = 'index.php?mod=downloads&action=show&go_dir=' . $linkurl;
                    $table[$z][1]['text'] = "<a href=\"index.php?mod=downloads&action=show&go_dir=" . $linkurl . "\" class=\"menu\" >" . $lineinfo['name'] . "</a>";
                    $table[$z][1]['link'] = 'index.php?mod=downloads&action=show&go_dir=' . $linkurl;
                    $table[$z][2]['text'] = "Ordner";
                    $table[$z][3]['text'] = "&nbsp;";
                }
                unset($lineinfo);
                $z++;
            }
        } else {
            $func->information(t('Kein Inhalt vorhanden'));
        }
        $dsp->NewContent(t('Downloads'), t('Hier kannst du zum Download bereitgestellte Dateien downloaden. Ordner sind durch ein Ordner-Symbol gekennzeichnet und können per Klick auf dieses oder den Namen ge&ouml;ffnet werden. Bei &ouml;ffnen eines Unterverzeichnisses wird das aktuelle Verzeichnis am oberen Rand angezeigt. Ebenfalls angezeigt wird ein Symbol mit dem du zum nächst höhergelegenen Verzeichnis gelangst'));
        if (count($_SESSION['downloads_dir']) > "0") {
            $dsp->AddSingleRow('<a href="index.php?mod=downloads&action=show&go_dir=up"><img src="design/' . $auth['design'] . '/images/downloads_goup.gif" border="0"></a> ' . $dir . '/');
        }
        $dsp->AddTableRow($table);
        $dsp->AddContent();
        $quit = ftp_quit($connect);
        $debugFTP[] = "FTP> Quit connection " . $connect . HTML_NEWLINE;
    } else {
        $func->error(t('Konnte Verbindung zum Downloadserver "%1" auf Port %2 nicht herstellen', $server, $port));
    }
    if (isset($debug) and $cfg['sys_showdebug_ftp'] == "1") {
        $debug->addvar('FTP', $debugFTP);
    }
}
Exemple #21
0
/**
* Alias to ftp_quit()
*/
function ftp_close(&$control)
{
    return ftp_quit($control);
}
Exemple #22
0
function file_ftp_disconnect($p_conn_id)
{
    ftp_quit($p_conn_id);
}
function line($head, $textok, $info, $running, $notonload, $command)
{
    $host = "127.0.0.1";
    $timeout = "1";
    global $i, $TEXT;
    $curdir = getcwd();
    list($partwampp, $directorwampp) = spliti('\\\\security', $curdir);
    $htaccess = ".htaccess";
    $configinc = "config.inc.php";
    $notrun = 0;
    $status = 0;
    $notload = 0;
    $newstatus = "nok";
    global $htxampp;
    global $phpmyadminconf;
    $htxampp = $partwampp . "\\htdocs\\xampp\\" . $htaccess;
    $phpmyadminconf = $partwampp . "\\phpmyadmin\\" . $configinc;
    if ($command == "phpmyadmin") {
        if (file_exists($phpmyadminconf)) {
            $datei = fopen($phpmyadminconf, 'r');
            $status = 1;
            while (!feof($datei)) {
                $zeile = fgets($datei, 255);
                @(list($left, $right) = split('=', $zeile));
                if (preg_match("/'auth_type'/i", $left)) {
                    if (preg_match("/'http'/i", $right)) {
                        $newstatus = "ok";
                    } elseif (preg_match("/'cookie'/i", $right)) {
                        $newstatus = "ok";
                    }
                    if ($newstatus == "ok") {
                        $status = 0;
                    } else {
                        $status = 1;
                    }
                }
            }
            fclose($datei);
        } else {
            $notrun = 1;
        }
    }
    if ($command == "mysqlroot") {
        if (($handle = @fsockopen($host, 3306, $errno, $errstr, $timeout)) == true) {
            @fclose($handle);
            if (@mysql_connect($host, "root", "")) {
                $status = 1;
            } else {
                $status = 0;
            }
        } else {
            $notrun = 1;
        }
    }
    if ($command == "xampp") {
        if (file_exists($htxampp)) {
            $status = 0;
        } else {
            $status = 1;
        }
    }
    if ($command == "php") {
        if (ini_get('safe_mode')) {
            $status = 0;
        } else {
            $status = 1;
        }
    }
    if ($command == "ftp") {
        if (($handle = @fsockopen($host, 21, $errno, $errstr, $timeout)) == true) {
            @fclose($handle);
            $conn_id = ftp_connect("127.0.0.1");
            $login_result = @ftp_login($conn_id, "newuser", "wampp");
            if (!$conn_id || !$login_result) {
                $status = 0;
            } else {
                $status = 1;
                ftp_quit($conn_id);
            }
        } else {
            $notrun = 1;
        }
    }
    if (extension_loaded("imap")) {
        if ($command == "pop") {
            if (($handle = @fsockopen($host, 110, $errno, $errstr, $timeout)) == true) {
                @fclose($handle);
                if ($mbox = @imap_open("{localhost/pop3:110}INBOX", "newuser", "wampp")) {
                    $status = 1;
                    imap_close($mbox);
                } else {
                    $status = 0;
                }
            } else {
                $notrun = 1;
            }
        }
    } else {
        $notload = 1;
    }
    if ($i > 0) {
        echo "<tr valign='bottom'>";
        echo "<td bgcolor='#ffffff' height='1' style='background-image:url(img/strichel.gif)' colspan='4'></td>";
        echo "</tr>";
    }
    echo "<tr bgcolor='#ffffff' valign='middle'><td><img src='img/blank.gif' alt='' width='1' height='20'></td><td class='tabval'>";
    if ($notload == 1) {
        echo $notonload;
    }
    if ($status == 0 && ($notrun == "" || $notrun < 1)) {
        echo $textok;
    } elseif ($notrun == 1) {
        echo $running;
    } else {
        echo $head;
    }
    echo "</td>";
    if ($status == 0 && $notrun != 1) {
        echo "<td>&nbsp;&nbsp;<span class='green'>&nbsp;" . $TEXT['security-ok'] . "&nbsp;</span></td>";
    } elseif ($status == 1) {
        echo "<td>&nbsp;&nbsp;<span class='red'>&nbsp;" . $TEXT['security-nok'] . "&nbsp;</span></td>";
    } elseif ($notrun == 1) {
        echo "<td>&nbsp;&nbsp;<span class='yellow'>&nbsp;" . $TEXT['security-noidea'] . "&nbsp;</span></td>";
    } else {
        echo "<td>&nbsp;&nbsp;<span class='yellow'>&nbsp;" . $TEXT['security-noidea'] . "&nbsp;</span></td>";
    }
    echo "<td>&nbsp;</td></tr>";
    if ($notrun == 1) {
        echo "<tr bgcolor='#ffffff'><td></td><td colspan='1' class='small'>{$running}<br><img src='img/blank.gif' alt='' width='10' height='10' border='0'></td><td></td><td></td></tr>";
    } elseif ($status) {
        echo "<tr bgcolor='#ffffff'><td></td><td colspan='1' class='small'>{$info}<br><img src='img/blank.gif' alt='' width='10' height='10' border='0'></td><td></td><td></td></tr>";
    }
    $i++;
}
Exemple #24
0
 function get($filename = '', $save_as = '', $passive = TRUE)
 {
     # SET THE ERROR REPORTING LEVEL OFF!
     error_reporting(0);
     $conn = $this->return_connection();
     if (!$conn) {
         return false;
     }
     @ftp_pasv($conn, $passive);
     $this->set_remote_dir(ftp_pwd($conn));
     if (!ftp_get($conn, $save_as, $this->remote_dir . $filename, FTP_BINARY)) {
         @ftp_quit($this->conn);
         return false;
     } else {
         @ftp_quit($this->conn);
         return true;
     }
 }
 /**
  * Close ftp session (CLOSE)
  * @access private
  */
 function _close()
 {
     if (!$this->connection) {
         return false;
     }
     return @ftp_quit($this->connection);
 }
 public function close()
 {
     @ftp_quit($this->link_id);
 }
function net2ftp_module_sendHttpHeaders()
{
    // --------------
    // This function sends HTTP headers
    // --------------
    global $net2ftp_settings, $net2ftp_globals, $net2ftp_messages, $net2ftp_result, $net2ftp_output;
    // ------------------------------------
    // 1. Register the global variables
    // ------------------------------------
    if ($net2ftp_globals["screen"] == 2) {
        // Code for old file jupload applet (jupload version 0.86)
        //		$file_counter = 0;
        //		foreach($_FILES as $tagname=>$object) {
        //			if ($object['name'] != "") {
        //				$file_counter = $file_counter + 1;
        //				$uploadedFilesArray["$file_counter"]["name"]               = $object['name'];
        //				$uploadedFilesArray["$file_counter"]["tmp_name"]           = $object['tmp_name'];
        //				$uploadedFilesArray["$file_counter"]["size"]               = $object['size'];
        //				$uploadedFilesArray["$file_counter"]["error"]              = $object['error'];
        //				// Look for special encoded jupload files
        //				$contentType = $object['type'];
        //				if (substr($contentType,0,7) == "jupload") {
        //					$base64_encoded_path = substr($contentType,8);
        //					$base64_decoded_path = base64_decode($base64_encoded_path);
        //					$uploadedFilesArray["$file_counter"]["absolute_directory"] = $base64_decoded_path;
        //				} // end if
        //			} // end if
        //		} // end foreach
        // Code for new file jupload applet (jupload version 5.0.8)
        $file_counter = 0;
        foreach ($_FILES as $tagname => $object) {
            if ($object['name'] != "") {
                $file_counter = $file_counter + 1;
                $uploadedFilesArray["{$file_counter}"]["name"] = $object['name'];
                $uploadedFilesArray["{$file_counter}"]["type"] = $object['type'];
                $uploadedFilesArray["{$file_counter}"]["tmp_name"] = $object['tmp_name'];
                $uploadedFilesArray["{$file_counter}"]["error"] = $object['error'];
                $uploadedFilesArray["{$file_counter}"]["size"] = $object['size'];
                $uploadedFilesArray["{$file_counter}"]["mime"] = validateEntry($_POST["mimetype" . $file_counter]);
                $uploadedFilesArray["{$file_counter}"]["relative_directory"] = validateDirectory($_POST["relpathinfo" . $file_counter]);
                $uploadedFilesArray["{$file_counter}"]["mtime"] = validateEntry($_POST["filemodificationdate" . $file_counter]);
            }
            // end if
        }
        // end foreach
        echo "Please wait, the files are being transferred to the FTP server...<br />\n";
        flush();
        // ------------------------------------
        // 2. POST METHOD: Move files from the *webserver's* temporary directory to *net2ftp's*
        // temporary directory (move_uploaded_files).
        // ------------------------------------
        if ($_SERVER["REQUEST_METHOD"] == "POST" && sizeof($uploadedFilesArray) > 0) {
            $moved_counter = 0;
            for ($j = 1; $j <= sizeof($uploadedFilesArray); $j++) {
                $file_name = $uploadedFilesArray["{$j}"]["name"];
                $file_tmp_name = $uploadedFilesArray["{$j}"]["tmp_name"];
                $file_size = $uploadedFilesArray["{$j}"]["size"];
                $file_error = $uploadedFilesArray["{$j}"]["error"];
                $file_relative_directory = $uploadedFilesArray["{$j}"]["relative_directory"];
                if ($file_name != "" && $file_tmp_name == "" || $file_size > $net2ftp_settings["max_filesize"]) {
                    // The case ($file_name != "" && $file_tmp_name == "") occurs when the file is bigger than the directives set in php.ini
                    // In that case, only $uploadedFilesArray["$j"]["name"] is filled in.
                    echo "WARNING: File <b>{$file_name}</b> skipped: this file is too big.<br />\n";
                    @unlink($file_tmp_name);
                    continue;
                } elseif (checkAuthorizedName($file_name) == false || checkAuthorizedName($file_relative_directory) == false) {
                    echo "WARNING: File <b>{$file_relative_directory}</b> skipped: it contains a banned keyword.<br />\n";
                    $skipped = $skipped + 1;
                    @unlink($file_tmp_name);
                    continue;
                }
                // Create the temporary filename as follows: (from left to right)
                // - Use prefix "upload__", to be able to identify from where this temporary file comes from
                // - Create a random filename
                // - Add the original filename extension, to be able to identify the filetype
                // - Add suffix ".txt" to avoid that the file would be executed on the webserver
                $extension = get_filename_extension($file_name);
                if (substr($file_name, -6) == "tar.gz") {
                    $extension = "tar.gz";
                }
                $tempfilename = tempnam2($net2ftp_globals["application_tempdir"], "upload__", "." . $extension . ".txt");
                if ($tempfilename == false) {
                    // If you get this warning message, you've probably forgotten to chmod 777 the /temp directory
                    echo "WARNING: File <b>{$file_name}</b> skipped: unable to create a temporary file on the webserver.<br />\n";
                    @unlink($file_tmp_name);
                    continue;
                }
                // Move the uploaded file
                $move_uploaded_file_result = move_uploaded_file($uploadedFilesArray["{$j}"]["tmp_name"], $tempfilename);
                if ($move_uploaded_file_result == false) {
                    echo "WARNING: File <b>{$file_name}</b> skipped: unable to move the uploaded file to the webserver's temporary directory.<br />\n";
                    @unlink($file_tmp_name);
                    @unlink($tempfilename);
                    continue;
                } else {
                    $moved_counter = $moved_counter + 1;
                    $acceptedFilesArray["{$moved_counter}"] = $uploadedFilesArray["{$j}"];
                    // Copy all parameters for this file from the $uploadedFilesArray to the $acceptedFilesArray
                    $acceptedFilesArray["{$moved_counter}"]["tmp_name"] = $tempfilename;
                    // Overwrite the old temporary name by the new one
                }
            }
            // end for j
            flush();
        }
        // end if elseif
        // ------------------------------------
        // 3. Move the files from net2ftp's temporary directory to the FTP server.
        // ------------------------------------
        if (sizeof($acceptedFilesArray) == 0 && sizeof($uploadedFilesArray) != 0) {
            echo "WARNING: No files were accepted (see messages above), so nothing will be transferred to the FTP server.<br />\n";
        } elseif (sizeof($acceptedFilesArray) > 0) {
            // ------------------------------
            // 3.1 Open connection
            // ------------------------------
            // Open connection
            echo __("Connecting to the FTP server") . "<br />\n";
            $conn_id = ftp_openconnection();
            if ($net2ftp_result["success"] == false) {
                echo "ERROR: " . $net2ftp_result["errormessage"] . "<br />\n";
                return false;
            }
            // ------------------------------
            // For loop (loop over all the files)
            // ------------------------------
            for ($k = 1; $k <= sizeof($acceptedFilesArray); $k++) {
                $file_name = $acceptedFilesArray["{$k}"]["name"];
                $file_tmp_name = $acceptedFilesArray["{$k}"]["tmp_name"];
                $file_size = $acceptedFilesArray["{$k}"]["size"];
                $file_error = $acceptedFilesArray["{$k}"]["error"];
                $file_relative_directory = $acceptedFilesArray["{$k}"]["relative_directory"];
                $ftpmode = ftpAsciiBinary($file_name);
                if ($ftpmode == FTP_ASCII) {
                    $printftpmode = "FTP_ASCII";
                } elseif ($ftpmode == FTP_BINARY) {
                    $printftpmode = "FTP_BINARY";
                }
                // ------------------------------
                // 3.2 Within the for loop: create the subdirectory if needed
                // ------------------------------
                // Replace Windows-style backslashes \ by Unix-style slashes /
                $file_relative_directory = str_replace("\\", "/", trim($file_relative_directory));
                // Get the names of the subdirectories by splitting the string using slashes /
                $file_subdirectories = explode("/", $file_relative_directory);
                // $targetdirectory contains the successive directories to be created
                $targetdirectory = $net2ftp_globals["directory"];
                // Loop over sizeof()-1 because the last part is the filename itself:
                for ($m = 0; $m < sizeof($file_subdirectories) - 1; $m++) {
                    // Create the targetdirectory string
                    $targetdirectory = glueDirectories($targetdirectory, $file_subdirectories[$m]);
                    // Check if the subdirectories exist
                    if ($targetdirectory != "") {
                        $result = @ftp_chdir($conn_id, $targetdirectory);
                        if ($result == false) {
                            $ftp_mkdir_result = ftp_mkdir($conn_id, $targetdirectory);
                            if ($ftp_mkdir_result == false) {
                                echo "WARNING: Unable to create the directory <b>{$targetdirectory}</b>. The script will try to continue...<br />\n";
                                continue;
                            }
                            echo "Directory {$targetdirectory} created.<br />\n";
                        }
                        // end if
                        flush();
                    }
                    // end if
                }
                // end for m
                // Store the $targetdirectory in the $acceptedFilesArray
                if ($targetdirectory != "" && $targetdirectory != "/") {
                    $acceptedFilesArray["{$k}"]["targetdirectory"] = $targetdirectory;
                }
                // ------------------------------
                // 3.3 Within the for loop: put local file to remote file
                // ------------------------------
                ftp_putfile($conn_id, "", $acceptedFilesArray["{$k}"]["tmp_name"], $acceptedFilesArray["{$k}"]["targetdirectory"], $acceptedFilesArray["{$k}"]["name"], $ftpmode, "move");
                if ($net2ftp_result["success"] == false) {
                    echo "ERROR: File <b>{$file_name}</b> skipped. Message: " . $net2ftp_result["errormessage"] . "<br />\n";
                    setErrorVars(true, "", "", "", "");
                    continue;
                } else {
                    echo "The file <b>{$file_name}</b> was transferred to the FTP server successfully. <br />\n";
                }
                flush();
            }
            // End for k
            // Note: the java applet is looking for the word "SUCCESS" to determine if the upload result is OK or not (see applet parameter stringUploadSuccess)
            // The applet doesn't seem to recognize the words "SUCCESS", "WARNING" or "ERROR" when they are issued by the code above
            echo "SUCCESS";
            // ------------------------------
            // 3.4 Close connection
            // ------------------------------
            ftp_quit($conn_id);
        }
        // end if
    }
    // end if $screen == 2
}
Exemple #28
0
 public function SendCompany($id_company)
 {
     $result = 0;
     $file = $_SERVER["DOCUMENT_ROOT"] . '/arka/test.txt';
     // send file
     $connect = ftp_connect($ftp_server);
     if ($connect) {
         $login_result = ftp_login($connect, $ftp_login, $ftp_password);
         if (ftp_put($connect, 'test.txt', $file, FTP_BINARY)) {
             $result = 1;
         }
         ftp_quit($connect);
     } else {
         // return error
     }
     return $result;
 }
Exemple #29
0
                 $GLOBALS['phpgw']->template->set_var('name', macro_get_link('cwd', $fileinfo['name']));
                 $GLOBALS['phpgw']->template->set_var('del_link', macro_get_link('rmdir', lang('Delete')));
                 $GLOBALS['phpgw']->template->set_var('size', '- ' . lang('dir') . ' -');
             } else {
                 $file = $fileinfo['name'];
                 $GLOBALS['phpgw']->template->set_var('del_link', macro_get_link('delete', lang('Delete')));
                 $GLOBALS['phpgw']->template->set_var('name', macro_get_link('get', $fileinfo['name']));
                 $GLOBALS['phpgw']->template->set_var('size', $fileinfo['size']);
             }
             $GLOBALS['phpgw']->template->set_var('rename_link', macro_get_link('rename', lang('Rename')));
             $GLOBALS['phpgw']->template->set_var('bgclass', $bgclass[$i % 2]);
             $GLOBALS['phpgw']->template->fp('rowlist_dir', 'row', True);
             $i++;
         }
     }
     ftp_quit($ftp);
     $GLOBALS['phpgw']->template->pfp('out', 'main');
 } else {
     updateSession();
     $sessionUpdated = true;
     if (!$tried_default) {
         $pass = '******';
         if (!empty($connInfo['password'])) {
             $pass = '******';
         }
         $GLOBALS['phpgw']->template->set_var('error_message', lang('Failed to connect to %1 with user %2 and password %3', $connInfo['ftpserver'], $connInfo['username'], $pass), true);
         $GLOBALS['phpgw']->template->parse('out', 'bad_connect', false);
         $GLOBALS['phpgw']->template->p('out');
     }
     newLogin($connInfo['ftpserver'], $connInfo['username'], '');
 }
Exemple #30
0
function send_file_to_browser($attachment, $upload_dir)
{
    global $HTTP_USER_AGENT, $HTTP_SERVER_VARS, $lang, $db, $attach_config;
    $filename = $upload_dir == '' ? $attachment['physical_filename'] : $upload_dir . '/' . $attachment['physical_filename'];
    $gotit = false;
    if (!intval($attach_config['allow_ftp_upload'])) {
        if (@(!file_exists(@amod_realpath($filename)))) {
            message_die(GENERAL_ERROR, $lang['Error_no_attachment'] . "<br /><br /><b>404 File Not Found:</b> The File <i>" . $filename . "</i> does not exist.");
        } else {
            $gotit = true;
        }
    }
    //
    // Determine the Browser the User is using, because of some nasty incompatibilities.
    // Most of the methods used in this function are from phpMyAdmin. :)
    //
    if (!empty($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) {
        $HTTP_USER_AGENT = $HTTP_SERVER_VARS['HTTP_USER_AGENT'];
    } else {
        if (!isset($HTTP_USER_AGENT)) {
            $HTTP_USER_AGENT = '';
        }
    }
    if (ereg('Opera(/| )([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
        $browser_version = $log_version[2];
        $browser_agent = 'opera';
    } else {
        if (ereg('MSIE ([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
            $browser_version = $log_version[1];
            $browser_agent = 'ie';
        } else {
            if (ereg('OmniWeb/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
                $browser_version = $log_version[1];
                $browser_agent = 'omniweb';
            } else {
                if (ereg('Netscape([0-9]{1})', $HTTP_USER_AGENT, $log_version)) {
                    $browser_version = $log_version[1];
                    $browser_agent = 'netscape';
                } else {
                    if (ereg('Mozilla/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
                        $browser_version = $log_version[1];
                        $browser_agent = 'mozilla';
                    } else {
                        if (ereg('Konqueror/([0-9].[0-9]{1,2})', $HTTP_USER_AGENT, $log_version)) {
                            $browser_version = $log_version[1];
                            $browser_agent = 'konqueror';
                        } else {
                            $browser_version = 0;
                            $browser_agent = 'other';
                        }
                    }
                }
            }
        }
    }
    // Correct the mime type - we force application/octetstream for all files, except images
    // Please do not change this, it is a security precaution
    if (!strstr($attachment['mimetype'], 'image')) {
        $attachment['mimetype'] = $browser_agent == 'ie' || $browser_agent == 'opera' ? 'application/octetstream' : 'application/octet-stream';
    }
    // Now the tricky part... let's dance
    //	@ob_end_clean();
    //	@ini_set('zlib.output_compression', 'Off');
    header('Pragma: public');
    //	header('Content-Transfer-Encoding: none');
    $real_filename = html_entity_decode(basename($attachment['real_filename']));
    // Send out the Headers
    header('Content-Type: ' . $attachment['mimetype'] . '; name="' . $real_filename . '"');
    header('Content-Disposition: attachment; filename="' . $real_filename . '"');
    unset($real_filename);
    //
    // Now send the File Contents to the Browser
    //
    if ($gotit) {
        $size = @filesize($filename);
        if ($size) {
            header("Content-length: {$size}");
        }
        readfile($filename);
    } else {
        if (!$gotit && intval($attach_config['allow_ftp_upload'])) {
            $conn_id = attach_init_ftp();
            $ini_val = @phpversion() >= '4.0.0' ? 'ini_get' : 'get_cfg_var';
            $tmp_path = !@$ini_val('safe_mode') ? '/tmp' : $upload_dir;
            $tmp_filename = @tempnam($tmp_path, 't0000');
            @unlink($tmp_filename);
            $mode = FTP_BINARY;
            if (preg_match("/text/i", $attachment['mimetype']) || preg_match("/html/i", $attachment['mimetype'])) {
                $mode = FTP_ASCII;
            }
            $result = @ftp_get($conn_id, $tmp_filename, $filename, $mode);
            if (!$result) {
                message_die(GENERAL_ERROR, $lang['Error_no_attachment'] . "<br /><br /><b>404 File Not Found:</b> The File <i>" . $filename . "</i> does not exist.");
            }
            @ftp_quit($conn_id);
            $size = @filesize($tmp_filename);
            if ($size) {
                header("Content-length: {$size}");
            }
            readfile($tmp_filename);
            @unlink($tmp_filename);
        } else {
            message_die(GENERAL_ERROR, $lang['Error_no_attachment'] . "<br /><br /><b>404 File Not Found:</b> The File <i>" . $filename . "</i> does not exist.");
        }
    }
    exit;
}