<?php
/********************************************************/
/* NSN GR Downloads                                     */
/* By: NukeScripts Network (webmaster@nukescripts.net)  */
/* http://www.nukescripts.net                           */
/* Copyright  2000-2005 by NukeScripts Network         */
/********************************************************/
if (!defined('ADMIN_ALLOW') && !defined('ADMIN_MAX')) {
	die ("Access Denied");
}
$pagetitle = _DOWNLOADSADMIN;
$numrows = $db->sql_numrows($db->sql_query("SELECT url FROM ".TABLE_NSNGD_DOWNLOADS." WHERE url='$url'"));
if ($numrows>0) {
  incoh();
  title($pagetitle);
  adminmain();
  br('1');
  Max_OpenTable();
  echo "<center><font class='content'><b>"._ERRORURLEXIST."</b></center><br />";
  echo "<center>"._GOBACK."</center>";
  Max_CloseTable();
  incof();
} else {
  if ($title=="" || $url=="" || $description=="") {
    incoh();
    title($pagetitle);
    adminmain();
    echo "<br />\n";
    Max_OpenTable();
    if($title=="") { echo "<center><font class='content'><b>"._ERRORNOTITLE."</b></center><br />"; }
    if($url=="") { echo "<center><font class='content'><b>"._ERRORNOURL."</b></center><br />"; }
    if($description=="") { echo "<center><font class='content'><b>"._ERRORNODESCRIPTION."</b></center><br />"; }
    echo "<center>"._GOBACK."</center>";
    Max_CloseTable();
    incof();
  }
  $title = stripslashes(FixQuotes($title));
  $url = stripslashes(FixQuotes($url));
  $description = stripslashes(FixQuotes($description));
  $sname = stripslashes(FixQuotes($sname));
  $email = stripslashes(FixQuotes($email));
  $sub_ip = $_SERVER['REMOTE_ADDR'];
  if ($submitter == "") { $submitter = $aname; }
  $db->sql_query("INSERT INTO ".TABLE_NSNGD_DOWNLOADS." VALUES (NULL, '$cat', '$perm', '$title', '$url', '$description', now(), '$sname', '$email', '$hits', '$submitter', '$sub_ip', '$filesize', '$version', '$homepage', '1')");
  echo "<br /><center><font class='option'>"._NEWDOWNLOADADDED."<br /><br />";
  echo "[ <a href='".$admin_file.".php?op=Downloads'>"._DOWNLOADSADMIN."</a> ]</center><br /><br />";
  if ($new==1) {
    $result = $db->sql_numrows($db->sql_query("SELECT * FROM ".TABLE_NSNGD_ACCESSES." WHERE username='$sname'"));
    if ($result < 1) {
      $db->sql_query("INSERT INTO ".TABLE_NSNGD_ACCESSES." VALUES ('$sname', 0, 1)");
    } else {
      $db->sql_query("UPDATE ".TABLE_NSNGD_ACCESSES." SET uploads=uploads+1 WHERE username='$submitter'");
    }
    $db->sql_query("DELETE FROM ".TABLE_NSNGD_NEW." WHERE lid='$lid'");
    if ($email!="") {
      $subject = ""._YOURDOWNLOADAT." $sitename";
      $message = ""._HELLO." $sname:\n\n"._DL_APPROVEDMSG."\n\n"._TITLE.": $title\n"._URL.": $url\n"._DESCRIPTION.": $description\n\n\n"._YOUCANBROWSEUS." $nukeurl/modules.php?name=$module_name\n\n"._THANKS4YOURSUBMISSION."\n\n$sitename "._TEAM."";
      $from = "$sitename";
      @mail($email, $subject, $message, "From: $from\nX-Mailer: PHP/" . phpversion());
    }
  }
  if($xop == "DownloadNew") { $zop = $xop; } else { $zop = "Downloads"; }
  redirect_url("".$admin_file.".php?op=".$zop);
}