#
# $Id: category-maintenance.php,v 1.2 2006-12-17 12:06:08 dan Exp $
#
# Copyright (c) 2003 DVL Software Limited
#
require_once $_SERVER['DOCUMENT_ROOT'] . '/../include/common.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/../include/freshports.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/../include/databaselogin.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/../include/getvalues.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/user_tasks.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/categories.php';
$Title = 'Category maintenance';
$CategoryName = pg_escape_string($_REQUEST['category']);
$Category = new Category($db);
$CategoryID = $Category->FetchByName($CategoryName);
if (!$CategoryID) {
    die("I don't know that category: {$CategoryName}");
}
if ($Category->IsPrimary() == 't') {
    $IsPrimary = 1;
} else {
    $IsPrimary = 0;
}
if (isset($_REQUEST['update'])) {
    $Category->{description} = pg_escape_string($_REQUEST['description']);
    $Category->UpdateDescription();
}
freshports_Start($Title . ' - ' . $CategoryName, 'freshports - new ports, applications', 'FreeBSD, index, applications, ports');
?>
<TABLE WIDTH="<?php 
Example #2
0
        $WatchLists = new WatchLists($db);
        $wlid = $WatchLists->GetDefaultWatchListID($User->id);
        if ($Debug) {
            echo "GetDefaultWatchListID => \$wlid='{$wlid}'";
        }
    }
}
if (!freshports_IsInt($wlid)) {
    $msg = "\$wlid = '{$wlid}', which is not an integer as expected.";
    syslog(LOG_ERR, $msg . " User = '******' in " . __FILE__ . ':' . __LINE__);
    die($msg);
}
$Category = new Category($db);
if (isset($_REQUEST['category'])) {
    $category = pg_escape_string($_REQUEST['category']);
    $CategoryID = $Category->FetchByName($category);
    if (!$CategoryID) {
        $msg = "category '{$category}' not found";
        syslog(LOG_ERR, $msg . " User = '******' in " . __FILE__ . ':' . __LINE__);
        die($msg);
    }
} else {
    $msg = "category not supplied";
    syslog(LOG_ERR, $msg . " User = '******' in " . __FILE__ . ':' . __LINE__);
    die($msg);
}
if ($submit) {
    pg_exec($db, "BEGIN");
    $WatchList = new WatchList($db);
    $WatchList->EmptyTheListCategory($User->id, $wlid, $Category->id);
    $ports = $_POST["ports"];
Example #3
0
function freshports_Parse404URI($REQUEST_URI, $db)
{
    #
    # we have a pending 404
    # if we can parse it, then do so and return a false value;
    # otherwise, return a non-false value.
    global $User;
    $Debug = 0;
    $result = '';
    $IsPort = false;
    $IsCategory = false;
    $IsElement = false;
    if ($Debug) {
        echo "Debug is turned on.  Only 404 will be returned now because we cannot alter the headers at this time.<br>\n";
    }
    $CategoryID = 0;
    define('FRESHPORTS_PORTS_TREE_PREFIX', '/ports/head/');
    $URLParts = parse_url($_SERVER['SCRIPT_URI']);
    if ($Debug) {
        echo 'the URI is <pre>' . $_SERVER['SCRIPT_URI'] . "</pre><br>\n";
        echo 'the url parts are <pre>' . print_r($URLParts) . "</pre><br>\n";
    }
    $pathname = $URLParts['path'];
    if ($Debug) {
        echo "The pathname is '{$pathname}'<br>";
    }
    require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/element_record.php';
    $ElementRecord = new ElementRecord($db);
    # first goal, remove leading / and leading ports/
    if (substr($pathname, 0, 1) == '/') {
        $pathname = substr($pathname, 1);
    }
    if (preg_match('|^ports/|', $pathname)) {
        $pathname = substr($pathname, 6);
    }
    define('PATH_NAME', $pathname);
    if ($Debug) {
        echo "PATH_NAME='" . FRESHPORTS_PORTS_TREE_PREFIX . PATH_NAME . "'<br>";
    }
    if ($ElementRecord->FetchByName(FRESHPORTS_PORTS_TREE_PREFIX . $pathname)) {
        $IsElement = true;
        if ($Debug) {
            echo 'Yes, we found an element for that path!<br>';
            echo '<pre>';
            echo print_r($ElementRecord, true);
            echo '</pre>';
        }
        if ($ElementRecord->IsCategory()) {
            $IsCategory = true;
            if ($Debug) {
                echo 'This is a category<br>';
            }
            require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/categories.php';
            $Category = new Category($db);
            $CategoryID = $Category->FetchByElementID($ElementRecord->id);
        } else {
            if ($Debug) {
                echo 'That path does not point at a category!<br>';
            }
        }
        if ($ElementRecord->IsPort()) {
            $IsPort = true;
            # we don't use list($category, $port) so we don't have to worry
            # about extra bits
            $PathParts = explode('/', PATH_NAME);
            $category = $PathParts[0];
            $port = $PathParts[1];
            if ($Debug) {
                echo "This is a port!<br>";
            }
            if ($Debug) {
                echo "Category='{$category}'<br>";
            }
            if ($Debug) {
                echo "Port='{$port}'<br>";
            }
        } else {
            if ($Debug) {
                echo 'The call to ElementRecord indicates this is not a port<br>';
            }
        }
    } else {
        if ($Debug) {
            echo 'not an element<br>';
        }
        # let's see if this is a virtual category!
        $result = $REQUEST_URI;
        $PathParts = explode('/', PATH_NAME);
        if ($Debug) {
            echo '<pre>';
            print_r($PathParts);
            echo '</pre>';
        }
        # start with nothing.
        unset($category);
        unset($port);
        # if the URL looks like /afterstep/, then we'll get two elements
        # in the array.  The second will be empty.  Hence the != ''
        #
        # grab whatever we have
        #
        if (isset($PathParts[0]) && $PathParts[0] != '') {
            $category = $PathParts[0];
            if ($Debug) {
                echo "Category is '{$category}'<br>";
            }
        }
        if (isset($PathParts[1]) && $PathParts[1] != '') {
            $port = $PathParts[1];
            if ($Debug) {
                echo "Port is '{$port}'<br>";
            }
        }
        if (isset($port)) {
            $IsPort = true;
            $IsPort = false;
            $result = $REQUEST_URI;
            if ($Debug) {
                echo 'This is a Port but there is no element for it.<br>';
            }
        }
        if (isset($category) && !$IsPort) {
            # we have a valid category, but no valid port.
            # we will display the category only if they did *try* to speciy a port.
            # i.e. they suuplied an invalid port name
            if ($Debug) {
                echo 'This is a category<br>';
            }
            if (isset($port)) {
                if ($Debug) {
                    'Invalid port supplied for a valid category<br>';
                }
            } else {
                require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/categories.php';
                $Category = new Category($db);
                $CategoryID = $Category->FetchByName($category);
                if ($CategoryID) {
                    $IsCategory = true;
                }
            }
        }
    }
    if ($Debug) {
        echo 'let us see what we will include now....<br>';
    }
    if ($IsPort) {
        if ($Debug) {
            echo 'including missing-port ' . $Debug . '<BR>';
        }
        require_once $_SERVER['DOCUMENT_ROOT'] . '/missing-port.php';
        if ($Debug) {
            echo 'including missing-port ' . $Debug . '<BR>';
        }
        # if zero is returned, all is well, otherwise, we can't display that category/port.
        if (freshports_PortDisplay($db, $category, $port)) {
            echo 'freshports_PortDisplay returned non-zero';
            exit;
        }
    }
    if ($IsCategory && !$IsPort) {
        if ($Debug) {
            echo 'This is a category<br>';
        }
        require_once $_SERVER['DOCUMENT_ROOT'] . '/missing-category.php';
        freshports_CategoryByID($db, $CategoryID, 1, $User->page_size);
        exit;
    }
    if ($IsElement && !$IsPort) {
        if ($Debug) {
            echo 'This is an element<br>';
        }
        require_once $_SERVER['DOCUMENT_ROOT'] . '/missing-non-port.php';
        freshports_NonPortDescription($db, $ElementRecord);
        exit;
    }
    return $result;
}
Example #4
0
 } else {
     echo "no connection";
 }
 echo "</TABLE>\n";
 parse_str($_SERVER['QUERY_STRING'], $query_parts);
 $FilesForJustOnePort = isset($query_parts['category']) && isset($query_parts['port']);
 $files = isset($query_parts['files']) ? $query_parts['files'] : 'n';
 $ShowAllFilesURL = '<a href="' . htmlspecialchars($_SERVER['SCRIPT_URL'] . '?message_id=' . $message_id . '&files=yes') . '">show all files</a>';
 $HideAllFilesURL = '<a href="' . htmlspecialchars($_SERVER['SCRIPT_URL'] . '?message_id=' . $message_id) . '">hide all files</a>';
 if ($FilesForJustOnePort) {
     // TODO need to validate category/port here!
     $clean['category'] = $query_parts['category'];
     $clean['port'] = $query_parts['port'];
     require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/categories.php';
     $Category = new Category($database);
     $CategoryID = $Category->FetchByName($clean['category']);
     if (!$CategoryID) {
         die('I don\'t know that category: . ' . htmlentities($clean['category']));
     }
     require_once $_SERVER['DOCUMENT_ROOT'] . '/../classes/element_record.php';
     $elementName = '/ports/head/' . $clean['category'] . '/' . $clean['port'];
     $Element = new ElementRecord($database);
     $ElementID = $Element->FetchByName($elementName);
     if (!$ElementID) {
         die('I don\'t know that port.');
     }
     if (!$Element->IsPort()) {
         die('That is not a port.');
     }
     $PortURL = '<a href="/' . $clean['category'] . '/' . $clean['port'] . '/">' . $clean['category'] . '/' . $clean['port'] . '</a>';
     echo '<p>Showing files for just one port: <big><b>' . $PortURL . '</b></big></p>';