<?php

/********************************************************/
/* NSN Mailing List                                     */
/* By: NukeScripts Network (webmaster@nukescripts.net)  */
/* http://www.nukescripts.net                           */
/* Copyright  2000-2005 by NukeScripts Network         */
/********************************************************/

$pagetitle = " - "._ML_ADMIN." ".$ml_config['version_number'];
incoh();
title(_ML_CREATENEWISSUE);
ML_Admin();
br('1');
$maxstories = 50;
$send = $adminmail;
if (strlen($sub) == 0) { $sub = _ML_TITLE; }
$text = stripslashes($text);
$htmltext = stripslashes($htmltext);
$num1 = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_nsnml_users"));
$num2 = $db->sql_numrows($db->sql_query("SELECT * FROM ".$prefix."_nsnml_lists"));
if($num1 && $num2) {
  Max_OpenTable();
  echo "<table align='center' border='0'>\n";
  echo "<form action='".$admin_file.".php?op=MLSend' method='POST'>\n";
  echo "<tr><td bgcolor='$bgcolor2'><b>"._ML_SUBJECT."</b></td><td><input type='text' name='sub' value='".$sub."' size='50' maxlength='100'></td></tr>\n";
  echo "<tr><td bgcolor='$bgcolor2'><b>"._ML_MAIN."</b></td><td><select name ='lid'>\n";
  $result = $db->sql_query("SELECT * FROM ".$prefix."_nsnml_lists");
  while($list_info = $db->sql_fetchrow($result)) { echo "<option value='".$list_info['lid']."'>".$list_info['title']."</option>\n"; }
  echo "</select></td></tr>\n";
  echo "<tr><td bgcolor='$bgcolor2' valign='top'><b>"._ML_ENTERTEXTPLAIN."</b></td><td><textarea name='text' rows='20' cols='60'>".$text."</textarea></td></tr>\n";
  echo "<tr><td bgcolor='$bgcolor2' valign='top'><b>"._ML_ENTERTEXTHTML."</b></td><td><textarea name='htmltext' rows='20' cols='60'>".$htmltext."</textarea></td></tr>\n";
  echo "<tr><td align='center' colspan='2'><input type='submit' value='"._ML_SEND."'></td></tr>\n";
  echo "</form>\n";
  echo "</table>\n";
  Max_CloseTable();
  $result = $db->sql_query("SELECT sid, title FROM ".TABLE_STORIES." ORDER BY sid DESC LIMIT $maxstories");
  $num = $db->sql_numrows($result);
  if($num) {
    br('1');
    Max_OpenTable();
    echo "<table align='center' border='0'>\n";
    echo "<form action='".$admin_file.".php?op=MLAddStory' method='POST'>\n";
    echo "<input type='hidden' name='sub' value='".htmlspecialchars($sub, ENT_QUOTES)."'>\n";
    echo "<input type='hidden' name='text' value='".htmlspecialchars($text, ENT_QUOTES)."'>\n";
    echo "<input type='hidden' name='htmltext' value='".htmlspecialchars($htmltext, ENT_QUOTES)."'>\n";
    echo "<tr><td bgcolor='$bgcolor2'><b>"._ML_ADDSTORY."</b></td><td><select name ='sid[]' size='5' multiple>\n";
    while (list ($sid, $title) = $db->sql_fetchrow($result)) { echo "<option value='$sid'>$title</option>\n"; }
    echo "</select></td></tr>\n";
    echo "<tr><td bgcolor='$bgcolor2'><b>"._ML_ADDAS."</b></td><td><select name ='sidtype'>\n";
    echo "<option value='1'>"._ML_TITLELINK."</option>\n";
    echo "<option value='2'>"._ML_HOMELINK."</option>\n";
    echo "<option value='3'>"._ML_FULLTEXT."</option>\n";
    echo "</select></td></tr>\n";
    echo "<tr><td bgcolor='$bgcolor2'><b>"._ML_ADDSEPERATOR."</b></td><td><input type='checkbox' name='seperator' value='1' checked='checked'></td></tr>\n";
    echo "<tr><td align='center' colspan='2'><input type='submit' value='"._ML_ADD."'></td></tr>\n";
    echo "</form>";
    echo "</table>\n";
    Max_CloseTable();
  }
  $result = $db->sql_query("SELECT lid, title FROM ".TABLE_NSNGD_DOWNLOADS." ORDER BY date DESC");
  $num = $db->sql_numrows($result);
  if($num) {
    br('1');
    Max_OpenTable();
    echo "<table align='center' border='0'>\n";
    echo "<form action='".$admin_file.".php?op=MLAddDownload' method='POST'>\n";
    echo "<input type='hidden' name='sub' value='".htmlspecialchars($sub, ENT_QUOTES)."'>\n";
    echo "<input type='hidden' name='text' value='".htmlspecialchars($text, ENT_QUOTES)."'>\n";
    echo "<input type='hidden' name='htmltext' value='".htmlspecialchars($htmltext, ENT_QUOTES)."'>\n";
    echo "<tr><td bgcolor='$bgcolor2' valign='top'><b>"._ML_ADDDOWNLOAD."</b></td><td><select name ='lid[]' size='5' multiple>\n";
    while (list ($lid, $title) = $db->sql_fetchrow($result)) { echo "<option value='$lid'>$title</option>\n"; }
    echo "</select></td></tr>\n";
    echo "<tr><td bgcolor='$bgcolor2'><b>"._ML_ADDAS."</b></td><td><select name ='lidtype'>\n";
    echo "<option value='1'>"._ML_DOWNLOADLINK."</option>\n";
    echo "<option value='2'>"._ML_DESCRIPTIONLINK."</option>\n";
    echo "</select></td></tr>\n";
    echo "<tr><td bgcolor='$bgcolor2'><b>"._ML_ADDSEPERATOR."</b></td><td><input type='checkbox' name='seperator' value='1' checked='checked'></td></tr>\n";
    echo "<tr><td align='center' colspan='2'><input type='submit' value='"._ML_ADD."'></td></tr>\n";
    echo "</form>";
    echo "</table>\n";
    Max_CloseTable();
  }
  $result = $db->sql_query("SELECT bid, imageurl FROM ".$prefix."_banner");
  $num = $db->sql_numrows($result);
  if($num) {
    echo "<br />\n";
    Max_OpenTable();
    echo "<table align='center' border='0'>\n";
    echo "<form action='".$admin_file.".php?op=MLAddBanner' method='POST'>\n";
    echo "<input type='hidden' name='sub' value='".htmlspecialchars($sub, ENT_QUOTES)."'>\n";
    echo "<input type='hidden' name='text' value='".htmlspecialchars($text, ENT_QUOTES)."'>\n";
    echo "<input type='hidden' name='htmltext' value='".htmlspecialchars($htmltext, ENT_QUOTES)."'>\n";
    echo "<tr><td bgcolor='$bgcolor2' valign='top'><b>"._ML_ADDBANNER."</b></td><td>";
    while (list ($bid, $imageurl) = $db->sql_fetchrow($result)) {
      if (strlen($imageurl) > 0) {
        echo("<input type='radio' name='bid' value='$bid'> <img src='$imageurl' width='200' height='40'><br />\n");
      }
    }
    echo "</td></tr>";
    echo "<tr><td bgcolor='$bgcolor2'><b>"._ML_ADDSEPERATOR."</b></td><td><input type='checkbox' name='seperator' value='1' checked='checked'></td></tr>\n";
    echo "<tr><td align='center' colspan='2'><input type='submit' value='"._ML_ADD."'></td></tr>\n";
    echo "</form>\n";
    echo "</table>\n";
    Max_CloseTable();
  }
} else {
  Max_OpenTable();
  if(!$num1) { echo "<center><b>"._ML_NOSUBSCRIBERS."</b></center><br />\n"; }
  if(!$num2) { echo "<center><b>"._ML_NOLISTS."</b></center><br />\n"; }
  echo "<center>"._GOBACK."</center>";
  Max_CloseTable();
}
incof();

?>