Пример #1
0
include_once '../package.class.php';
$myts =& MyTextSanitizer::getInstance();
$pkgid = intval($_GET['pkgid']);
$file = $myts->stripSlashesGPC($_GET['file']);
$type = isset($_GET['type']) ? $_GET['type'] : "";
$pkg = new InstallPackage($pkgid);
$reverse = false;
if (empty($pkg->dirname)) {
    // future version?
    $res = $xoopsDB->query("SELECT vcheck FROM " . UPDATE_PKG . " WHERE pversion='HEAD' AND pname=" . $xoopsDB->quoteString($pkg->getVar('pname')));
    list($dirname) = $xoopsDB->fetchRow($res);
    $pkg->dirname = $pkg->getVar('vcheck');
    $pkg->setVar('vcheck', $dirname);
    $pkg->reverse = true;
}
$diff = $pkg->dbDiff($file);
if ($type == "raw") {
    $name = basename($file) . ".diff";
    header("Content-Type: text/plain; charset" . _CHARSET);
    header("Content-Disposition: inline; filename={$name}");
    echo $diff;
    exit;
}
$chg = $pkg->checkFile($file);
$atitle = htmlspecialchars($pkg->getVar('name') . ": " . $pkg->getRealPath($file, false));
header("Content-Type: text/html; charset" . _CHARSET);
echo "<!DOCTYPE html PUBLIC '//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>";
echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . _LANGCODE . '" lang="' . _LANGCODE . '">
<head>
<meta http-equiv="content-type" content="text/html; charset=' . _CHARSET . '" />
<title>' . $atitle . '</title>
Пример #2
0
function detail_package($pid, $vmode = false, $new = 0)
{
    global $file_state, $xoopsModuleConfig;
    $pkg = new InstallPackage($pid);
    $dirname = $pkg->getVar('vcheck');
    $title = $pkg->getVar('name');
    if ($dirname) {
        $title .= " ({$dirname})";
    }
    if ($new) {
        $newpkg = new Package($new);
        $title .= _AM_UPDATE_TO . $newpkg->getVar('name');
        $files = $pkg->checkFiles($newpkg);
        $id = $new;
        //$files = $pkg->checkPackage($newpkg);
    } else {
        if ($vmode) {
            $files = $pkg->modifyFiles();
            if ($xoopsModuleConfig['check_extra']) {
                $files = array_merge($files, $pkg->checkExtra());
                ksort($files);
            }
        } else {
            $files = $pkg->checkFiles();
        }
        $id = $pid;
    }
    if (count($files) == 0) {
        echo _AM_NODATA;
        return;
    }
    echo mystyle();
    echo "<h3>{$title}</h3>";
    if (!$vmode) {
        echo "<form method='POST' name='FileMark'>\n";
        echo "<input type='hidden' name='pkgid' value='{$pid}'/>\n";
    }
    $dels = count(array_keys($files, 'del'));
    if ($dels && $vmode) {
        $sw = " &nbsp; <a href='index.php?op=detail&pkgid={$pid}&view=";
        if ($vmode == 'yes') {
            $sw .= "all'>" . _AM_VIEW_ALL;
        } else {
            $sw .= "yes'>" . _AM_VIEW_SCRIPT;
        }
        $sw .= "</a>";
        $fm = "<form method='post'>\n<input name='clear' type='submit' value='" . _AM_UPDATE_CLEAR . "'/>\n<input name='pkgid' type='hidden' value='{$pid}'/>\n</form>";
    } else {
        $sw = $fm = "";
    }
    echo "<table cellspacing='5'>\n<tr>\n<td>" . _AM_FILE_ALL . " " . count($pkg->files) . "</td>\n<td>" . _AM_CHG . " " . count(array_keys($files, 'chg')) . "</td><td>" . _AM_DEL . " " . $dels . "</td><td>" . $sw . "</td>\n</tr>\n</table>\n";
    echo "<table cellspacing='1' class='outer'>\n";
    $checkall = "<input type='checkbox' id='allconf' name='allconf' onclick='xoopsCheckAll(\"FileMark\", \"allconf\")'/>";
    echo "<tr>";
    if (!$vmode) {
        echo "<th align='center' class='ckbox'>{$checkall}</th>";
    }
    echo "<th>" . _AM_STATUS . "</th><th>" . _AM_FILE . "</th></tr>\n";
    $n = 0;
    foreach ($files as $file => $stat) {
        if ($vmode == 'yes') {
            if ($stat == 'del') {
                continue;
            }
            if (is_binary($file) || preg_match('/\\.css$/', $file)) {
                continue;
            }
        }
        $bg = $n++ % 2 ? 'even' : 'odd';
        $ck = "<input type='checkbox' name='conf[]' value='{$file}'/>";
        $slabel = $file_state[$stat];
        switch ($stat) {
            case 'chg':
                $slabel = "<a href='diff.php?pkgid={$id}&file={$file}' target='diff'>{$slabel}</a>";
                break;
            case 'new':
                $slabel = "<b>{$slabel}</b>";
                break;
        }
        if ($vmode) {
            $diff = $pkg->dbDiff($file);
            if ($stat == 'extra') {
            } elseif (empty($diff)) {
                $stat = 'same';
                $adiff = $new ? $newpkg->getDiff($file) : "";
                if (empty($adiff)) {
                    $file .= " =";
                }
            } elseif (count(preg_split('/\\n/', $diff) < 6) && preg_match('/\\n .*\\n-\\n$/', $diff)) {
                $stat = 'same';
                $file .= " +";
            } elseif ($new) {
                $adiff = $newpkg->getDiff($file);
                if ($adiff == $diff) {
                    $stat = 'mod';
                    $file .= " *";
                }
            }
            $ck = "";
        } else {
            $ck = "<td class='ckbox'><input type='checkbox' name='conf[]' value='{$file}'/></td>";
        }
        $myfile = $pkg->getRealPath($file, false);
        echo "<tr class='{$bg}'>{$ck}";
        echo "<td>{$slabel}</td><td class='{$stat}'>{$myfile}</td></tr>\n";
    }
    echo "</table>\n";
    if (!$vmode) {
        echo "<input type='submit' name='accept' value='" . _AM_REGIST_SUBMIT . "'/>\n";
        echo "</form>\n";
    }
    if ($fm && count($files) && !$new) {
        echo "<hr/>" . $fm;
    }
}