Beispiel #1
0
function reg_set_packages()
{
    global $xoopsDB;
    $active = get_active_list();
    $pkgs = get_packages('all');
    if (file_exists(ROLLBACK)) {
        unlink(ROLLBACK);
    }
    // expired
    $del = "DELETE FROM " . UPDATE_PKG . " WHERE pkgid=%u";
    $sel = "SELECT pkgid FROM " . UPDATE_PKG . " WHERE vcheck=%s AND pversion='HEAD'";
    $succ = 0;
    $pnames = isset($_POST['pname']) ? $_POST['pname'] : array();
    foreach ($pkgs as $pkg) {
        $dirname = $pkg['vcheck'];
        if (array_search($dirname, $active)) {
            $res = $xoopsDB->query(sprintf($sel, $xoopsDB->quoteString($dirname)));
            $pkgid = 0;
            if ($xoopsDB->getRowsNum($res) > 0) {
                list($pkgid) = $xoopsDB->fetchRow($res);
            }
            $pname = $pkg['pname'];
            if ($pkgid && !in_array($dirname, $pnames)) {
                // unchecked? (removed)
                if ($xoopsDB->query(sprintf($del, $pkgid))) {
                    $xoopsDB->query("DELETE FROM " . UPDATE_FILE . " WHERE pkgref={$pkgid}");
                    $succ++;
                }
            }
            clean_pkginfo();
            // garbege collection
        }
    }
    $ins = "INSERT INTO " . UPDATE_PKG . "(parent,pname,pversion,vcheck) VALUES(%u,%s,'HEAD',%s)";
    foreach ($pnames as $dirname) {
        if (!in_array($dirname, $active)) {
            if (isset($pkgs[$dirname])) {
                $pkg = $pkgs[$dirname];
            } else {
                $pkg = PackageList::selectPackage($dirname);
            }
            $par = empty($pkg['pkgid']) ? 0 : $pkg['pkgid'];
            if (register_detail($pkg['pname'], $dirname)) {
                $succ++;
            }
        }
    }
    if ($succ) {
        clear_get_cache(0, 'list');
    }
    return $succ;
}
Beispiel #2
0
    }
    exit;
}
// number of checking packages
$res = $xoopsDB->query("SELECT count(pkgid) FROM " . UPDATE_PKG . " WHERE pversion='HEAD'");
list($npkg) = $xoopsDB->fetchRow($res);
if (empty($op) && $npkg == 0) {
    redirect_header('pkgadmin.php', 1, _AM_PKG_REGISTER);
    exit;
}
xoops_cp_header();
echo mystyle();
include 'mymenu.php';
switch ($op) {
    default:
        clear_get_cache(3600 * 48);
        check_packages();
        // checking regsiterd packages
        break;
    case 'pkgs':
        // package managiment
        echo "<fieldset>\n";
        import_form();
        $svr = get_update_server();
        if ($svr) {
            $src = array("{SERVER}");
            $dst = array($svr);
            echo "<p>" . str_replace($src, $dst, _AM_FETCH_DESCRIPTION) . "</p>";
        }
        echo "</fieldset>\n";
        reglist_packages();