<?php # ScriptUpdate - Management # $Id: diff.php,v 1.5 2008/02/25 15:09:56 nobu Exp $ include '../../../include/cp_header.php'; 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);
$updatedir = "update-{$date}"; $backupdir = "backup-{$date}"; ob_start(); if ($xoopsDB->getRowsNum($res)) { // force clean work files $work = XOOPS_UPLOAD_PATH . "/update/work"; if (is_dir("{$work}/{$updatedir}")) { system("rm -rf '{$work}/{$updatedir}'"); } if (is_dir("{$work}/{$backupdir}")) { system("rm -rf '{$work}/{$backupdir}'"); } while ($data = $xoopsDB->fetchArray($res)) { $pkg = new InstallPackage($data); $pkg->load(); $pname = $pkg->getVar('pname'); $newpkg = new Package($pname, $pkgs[$pkg->dirname]['pversion']); if ($pkg->getVar('parent') != $newpkg->getVar('pkgid')) { if ($op == 'exec') { $pkg->backupPackage($newpkg, $backupdir); $pkg->updatePackage($newpkg, $updatedir); package_expire($pname); } elseif ($op == 'update') { $pkg->updatePackage($newpkg, $updatedir); } else { $pkg->backupPackage($newpkg, $backupdir); } $pkgn++; } } }
function options_setting() { global $myts; $id = intval($_POST['pkgid']); $pkg = new InstallPackage($id); $dirs = array(); if (isset($_POST['optdir'])) { foreach ($_POST['optdir'] as $dir) { $dirs[$myts->stripSlashesGPC($dir)] = true; } } $nchg = 0; foreach ($pkg->options as $path => $v) { if ($v) { $chg = empty($dirs[$path]); } else { $chg = isset($dirs[$path]); } if ($chg) { $pkg->setOptions($path, !$v); $nchg++; } } if ($nchg) { package_expire($pkg->getVar('pname')); } return $nchg; }