Example #1
0
function doUpdate($remotefile, $ftpdata = false)
{
    global $up_totalfiles;
    $localtmpfile = tempnam("/tmp", "fk");
    out("dwl@Download@starting...");
    $rt = up_dlfile($remotefile, $localtmpfile);
    if ($rt == false || filesize($localtmpfile) == 0) {
        out("dwl@Download@ERROR.");
        unlink($localtmpfile);
        return;
    }
    out("dwl@Download@Ok.");
    out("unzip@Unzip@");
    $tmpdirname = $localfile . "ex";
    mkdir($tmpdirname);
    up_unzip($localtmpfile, $tmpdirname);
    $basedir = glob($tmpdirname . "/*");
    $basedir = $basedir[0];
    out("unzip@Unzip@Ok.");
    $up_totalfiles = up_count($basedir . "/");
    if (canWeWrite()) {
        out("copy@Copy@");
        up_walktree($basedir, 'up_copy');
    }
    if ($ftpdata !== false && is_array($ftpdata) && $ftpdata['ftphost'] != "") {
        out("ftpcon@Connect to FTP@");
        $conn_id = ftp_connect($ftpdata['ftphost']);
        $login_result = ftp_login($conn_id, $ftpdata['ftpuser'], $ftpdata['ftppwd']);
        if (!$conn_id || !$login_result) {
            out("ftpcon@Connect to FTP@FAILED");
            up_clean($tmpdirname, $localtmpfile);
            return;
        } else {
            out("ftpcon@Connect to FTP@Ok.");
        }
        out("copy@Copy@");
        up_walktree($basedir, 'up_ftp', 0, array($ftpdata['ftppath'], $conn_id));
        ftp_close($conn_id);
    }
    up_clean($tmpdirname, $localtmpfile);
}
Example #2
0
/**
 * @param App $a
 * @return string
 */
function admin_page_remoteupdate(&$a)
{
    if (!is_site_admin()) {
        return login(false);
    }
    $canwrite = canWeWrite();
    $canftp = function_exists('ftp_connect');
    $needupdate = true;
    $u = checkUpdate();
    if (!is_array($u)) {
        $needupdate = false;
        $u = array('', '', '');
    }
    $tpl = get_markup_template("admin_remoteupdate.tpl");
    return replace_macros($tpl, array('$baseurl' => $a->get_baseurl(true), '$submit' => t("Update now"), '$close' => t("Close"), '$localversion' => FRIENDICA_VERSION, '$remoteversion' => $u[1], '$needupdate' => $needupdate, '$canwrite' => $canwrite, '$canftp' => $canftp, '$ftphost' => array('ftphost', t("FTP Host"), '', ''), '$ftppath' => array('ftppath', t("FTP Path"), '/', ''), '$ftpuser' => array('ftpuser', t("FTP User"), '', ''), '$ftppwd' => array('ftppwd', t("FTP Password"), '', ''), '$remotefile' => array('remotefile', '', $u['2'], '')));
}