Location: PHPKode > projects > ProNuke. Postnuke To Oracle > postnuke/html/modules/Downloads/dl-adddownload.php
<?php
// File: $Id: dl-adddownload.php,v 1.2 2001/12/08 12:17:01 jgm Exp $ $Name:  $
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Francisco Burzi
// Purpose of file:
// ----------------------------------------------------------------------

function AddDownload() {
    global $cookie, $user, $pntable, $downloads_anonadddownloadlock, $ModName, $dbconn;
    include("header.php");

    if (!(authorised(0, 'Downloads::Item', '::', ACCESS_COMMENT))) {
        echo _DOWNLOADSADDNOAUTH;
        include 'footer.php';
        return;
    }
    $maindownload = 1;
    menu(1);
    echo "<br>";
    OpenTable();
    echo "<center><font class=\"pn-title\">"._ADDADOWNLOAD."</font></center><br><br>";
    if (is_user($user) || $downloads_anonadddownloadlock != 1) {
        echo "<font class=\"pn-titlel\">"._INSTRUCTIONS.":</font><br>"
        ."<font class=\"pn-normal\"><strong><big>&middot;</big></strong> "._DSUBMITONCE."<br>"
        ."<strong><big>&middot;</big></strong> "._DPOSTPENDING."<br>"
        ."<strong><big>&middot;</big></strong> "._USERANDIP."</font><br>"
        ."<form action=\"modules.php\" method=\"post\">"
        ."<input type=\"hidden\" name=\"op\" value=\"modload\">\n"
        ."<input type=\"hidden\" name=\"name\" value=\"$ModName\">\n"
        ."<input type=\"hidden\" name=\"file\" value=\"index\">"
        ."<font class=\"pn-normal\">"._DOWNLOADNAME."</font>: <input type=\"text\" name=\"title\" size=\"40\" maxlength=\"100\"><br>"
        ."<font class=\"pn-normal\">"._FILEURL."</font>: <input type=\"text\" name=\"url\" size=\"50\" maxlength=\"100\" value=\"http://\"><br>";
        $column = &$pntable['downloads_categories_column'];
        $result=$dbconn->Execute("SELECT $column[cid], $column[title]
                                FROM $pntable[downloads_categories]
                                ORDER BY $column[title]");
        echo "<font class=\"pn-normal\">"._CATEGORY."</font>: <select name=\"cat\">";
// FTO Check EOF and databse error
        if (!$result) {
               PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
               die();
            }
        while(!$result->EOF) {

            list($cid, $title) = $result->fields;

            $result->MoveNext();
            if (authorised(0, 'Downloads::Category', "$title::$cid", ACCESS_COMMENT)) {
                echo "<option value=\"$cid\">$title</option>";
                $column=&$pntable['downloads_subcategories_column'];
                $result2=$dbconn->Execute("SELECT $column[sid], $column[title]
                                           FROM $pntable[downloads_subcategories]
                                           WHERE $column[cid]=$cid ORDER BY $column[title]");
// FTO Check EOF and databse error
                if (!$result2) {
                   PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
                   die();
                }
                while(!$result2->EOF) {

                    list($sid, $stitle) = $result2->fields;

                    $result2->MoveNext();
                    if (authorised(0, 'Downloads::Category', "$stitle::$sid", ACCESS_COMMENT)) {
                        echo "<option value=\"$cid-$sid\">$title / $stitle</option>";
                    }
                }
            }
        }
        echo "</select><br><br>"
        ."<font class=\"pn-normal\">"._LDESCRIPTION."</font><br><textarea name=\"description\" cols=\"60\" rows=\"8\"></textarea><br><br>"
        ."<font class=\"pn-normal\">"._AUTHORNAME."</font>: <input type=\"text\" name=\"nname\" size=\"30\" maxlength=\"60\"><br>"
        ."<font class=\"pn-normal\">"._AUTHOREMAIL."</font>: <input type=\"text\" name=\"email\" size=\"30\" maxlength=\"60\"><br>"
        ."<font class=\"pn-normal\">"._FILESIZE."</font>: <input type=\"text\" name=\"filesize\" size=\"12\" maxlength=\"11\"> <font class=\"pn-normal\">("._INBYTES.")</font><br>"
        ."<font class=\"pn-normal\">"._VERSION."</font>: <input type=\"text\" name=\"version\" size=\"11\" maxlength=\"10\"><br>"
        ."<font class=\"pn-normal\">"._HOMEPAGE."</font>: <input type=\"text\" name=\"homepage\" size=\"50\" maxlength=\"200\" value=\"http://\"><br><br>"
        ."<input type=\"hidden\" name=\"req\" value=\"Add\">"
        ."<input type=\"submit\" value=\""._ADDTHISFILE."\"> <font class=\"pn-normal\">"._GOBACK."</font><br><br>"
        ."</form>";
    } else {
        echo "<center><font class=\"pn-normal\">"._DOWNLOADSNOTUSER1."<br>"
        .""._DOWNLOADSNOTUSER2."<br><br>"
        .""._DOWNLOADSNOTUSER3."<br>"
        .""._DOWNLOADSNOTUSER4."<br>"
        .""._DOWNLOADSNOTUSER5."<br>"
        .""._DOWNLOADSNOTUSER6."<br>"
        .""._DOWNLOADSNOTUSER7."<br><br>"
        .""._DOWNLOADSNOTUSER8."</font></center>";
    }
    CloseTable();
    include("footer.php");
}

function Add($title, $url, $nname, $cat, $description, $name, $email, $filesize, $version, $homepage) {
    global $user, $pntable, $ModName, $dbconn;

    csrfcheck();

    $column=&$pntable['downloads_downloads_column'];
/* hootbah: I think that this is only getting the count(*) value back.
 *
 *  $result = $dbconn->query("SELECT $column[url]
 *                            FROM $pntable[downloads_downloads]
 *                            WHERE $column[url]='$url'");
 *  $numrows = numRows($result);
 */
    include("header.php");
    menu(1);

//    $cat = explode("-", $cat);
//    if ($cat[1]=="") {
//        $cat[1] = 0;
//    }

    $catname = downloads_CatNameFromCID($cat);
    if (!(authorised(0, 'Downloads::Item', "$title:$catname:", ACCESS_COMMENT))) {
        echo _DOWNLOADSADDNOAUTH;
        include 'footer.php';
        return;
    }

    echo "<br>";
    OpenTable();
    $result = $dbconn->Execute("SELECT count(*)
                              FROM $pntable[downloads_downloads]
                              WHERE $column[url]='$url'");
    list($numrows) = $result->fields;
    if ($numrows>0) {
        echo "<center><font class=\"pn-normal\">"._DOWNLOADALREADYEXT."</font><br><br>"
        ."<font class=\"pn-normal\">"._GOBACK."</font>";
        CloseTable();
        include("footer.php");
    } else {
        if(is_user($user)) {
            $user2 = base64_decode($user);
            $cookie = explode(":", $user2);
            cookiedecode($user);
            $submitter = $cookie[1];
        }
// Check if Title exist
        if ($title=="") {
            echo "<center><font class=\"pn-normal\">"._DOWNLOADNOTITLE."</font><br><br>"
            ."<font class=\"pn-normal\">"._GOBACK."</font>";
            CloseTable();
            include("footer.php");
            return;
        }
// Check if URL exist
        if ($url=="") {
            echo "<center><font class=\"pn-normal\">"._DOWNLOADNOURL."</font><br><br>"
            ."<font class=\"pn-normal\">"._GOBACK."</font>";
            CloseTable();
            include("footer.php");
            return;
        }
// Check if Description exist
        if ($description=="") {
            echo "<center><font class=\"pn-normal\">"._DOWNLOADNODESC."</font><br><br>"
            ."<font class=\"pn-normal\">"._GOBACK."</font>";
            CloseTable();
            include("footer.php");
            return;
        }
        $title = stripslashes(FixQuotes($title));
        $url = stripslashes(FixQuotes($url));
        $description = stripslashes(FixQuotes($description));
        $name = stripslashes(FixQuotes($name));
        $email = stripslashes(FixQuotes($email));
        $filesize = ereg_replace("\.","",$filesize);
        $filesize = ereg_replace("\,","",$filesize);
        $column = &$pntable['downloads_newdownload_column'];

        // FTO : Call the GenId function to support autoinc.
        // FTO : Add SEQ suffix to avoid conflict name with ORACLE
        $newid = $dbconn->GenId("{$pntable['downloads_newdownload']}_SEQ");

        $result=$dbconn->Execute("INSERT INTO $pntable[downloads_newdownload]
                                ($column[lid], $column[cid], $column[sid],
                                 $column[title], $column[url], $column[description],
                                 $column[name], $column[email], $column[submitter],
                                 $column[filesize], $column[version],
                                 $column[homepage])
                                VALUES ($newid, '$cat[0]', '$cat[1]', '$title', '$url',
                                 '$description', '$nname', '$email', '$submitter',
                                 '$filesize', '$version', '$homepage')");
        echo "<center><font class=\"pn-normal\">"._DOWNLOADRECEIVED."</font><br>";
        if ($email == "") {
            echo "<font class=\"pn-normal\">"._CHECKFORIT."</font>";
        }
        CloseTable();
        include("footer.php");
    }
}
?>
Return current item: ProNuke. Postnuke To Oracle