<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
defined('MAXIMUS') or die ('Access denied block mailing list MAXIMUS directly...');

$modname = "Mailing_List";
get_lang($modname);
$content = "";
global  $bgcolor2, $cookie, $prefix;
  $user2 = base64_decode($user);
  $cookie = explode(":", $user2);

  if ($cookie[0] > 0) {
  $SQL = "SELECT `user_email` FROM `".TABLE_USERS."` WHERE `user_id`='$cookie[0]'";
  if ( !($resultat = $GLOBALS['db']->sql_query($sql)) )
{ query_die(CORE_ERROR, 'Could not obtain _users', '', __LINE__, __FILE__, $sql);}
    $row      = $GLOBALS['db']->sql_fetchrow($resultat);
    $usermail = stripslashes($row['user_email']);
  }
  $content .= "<table align=\"center\" border=\"0\">\n";
  $content .= "<form action=\"modules.php?name=$modname&amp;op=MLAction\" method=\"post\">\n";
  $content .= "<tr><td bgcolor=\"$bgcolor2\"><b>"._ML_EMAILADDRESS."</b></td><td><input type=\"text\" name=\"email\" value=\"".$usermail."\" size=\"20\" maxlength=\"100\" /></td></tr>\n";
  $content .= "<tr><td bgcolor=\"$bgcolor2\"><b>"._ML_MAIN."</b></td><td><select name =\"lid\">\n";
  $sql1 = "SELECT `lid`, `title` FROM `".$prefix."_nsnml_lists`";
  if ( !($result = $GLOBALS['db']->sql_query($sql1)) )
{ query_die(CORE_ERROR, 'Could not obtain _nsnml_lists', '', __LINE__, __FILE__, $sql1);}
  while($list_info = $GLOBALS['db']->sql_fetchrow($result)) {
  $lid = $GLOBALS['db']->XMFnum($list_info['lid']);
  $title = stripslashes($list_info['title']);
  $content .= "<option value=\"".$lid."\">".$title."</option>\n"; }
  $content .= "</select></td></tr>\n";
  $content .= "<tr><td bgcolor=\"$bgcolor2\"><b>"._ML_CHOOSEPLEASE."</b></td><td><select name =\"sub\">\n";
  $content .= "<option value=\"sub\">"._ML_SUBSCRIBE."</option>\n";
  $content .= "<option value=\"unsub\">"._ML_UNSUBSCRIBE."</option>\n";
  $content .= "</select></td></tr>\n";
  $content .= "<tr><td bgcolor=\"$bgcolor2\"><b>"._ML_CHOOSETYPE."</b></td><td><select name =\"type\">\n";
  $content .= "<option value=\"0\">"._ML_TYPETEXT."</option>\n";
  $content .= "<option value=\"1\">"._ML_TYPEHTML."</option>\n";
  $content .= "</select></td></tr>\n";
  $content .= "<tr><td align=\"center\" colspan=\"2\"><input type=\"submit\" value=\""._ML_SEND."\" /></td></tr>\n";
  $content .= "</form>\n";
  $content .= "</table>\n";
  if ($cookie[0] > 0) { $GLOBALS['db']->sql_freeresult($resultat); }
  $GLOBALS['db']->sql_freeresult($result);