Location: PHPKode > projects > ADbNewsSender > ADbNewsSender_2.0.4/protected/admin/nl/viewMLentries.php.inc
<?php
//Copyright (c) Florian Grannemann
//Last change in version: 2.0 RC 4
/*
    ******************************************************************************
    ADbNewsSender 2

    Copyright (C) 2009  Florian Grannemann (hide@address.com)
    Website: http://adbnewssender.sf.net



    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 3 of the License, or
    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.

    You should have received a copy of the GNU General Public License			
    along with this program.  If not, see http://www.gnu.org/licenses/
    ******************************************************************************
*/
include "$path_to_languagefolder/lang_admin_viewMLentries.php.inc";
include "$path_to_languagefolder/localsettings.php.inc";
//Do not edit anything unless you realy REALY know what you are doing!
if($_SESSION["CurrentNL"] && $MyCFG->NL_exists($_SESSION["CurrentNL"]))
{
    //preparing mudule variables:
    $NLID=$_SESSION["CurrentNL"];
    $curModul=$_SESSION["currentModulType"]."|".intval($_SESSION["currentModulNr"]);
    $ShowNLIDMLoption="Show".$NLID."MLoption";
    $ShowNLIDMLshowallWhat="Show".$NLID."MLshowallWhat";
    $ShowNLIDMLoptiondeleteEntry="Show".$NLID."deleteEntry";

  

    if($_REQUEST[$ShowNLIDMLoption] !="search" && $_REQUEST[$ShowNLIDMLoption] !="showall" )
    {
	//no option selected, show menu:
	    print "<h2>$ShowNLEntries_menu_title</h2>";
	    print "$ShowNLEntries_menu_select<br><br>";
	    print "<ul>";
	    print "<li><a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDMLoption."=search\">".$ShowMLEntries_menu[0]."</a></li>";
	    print "<li><a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDMLoption."=showall&".$ShowNLIDMLshowallWhat."=all\">".$ShowMLEntries_menu[1]."</a></li>";
	    
	    if($MyNL->number_of_expiring_entries() >0)
	    {
		print "<li><a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDMLoption."=showall&".$ShowNLIDMLshowallWhat."=expiring\">".$ShowMLEntries_menu[2]."</a></li>";
	    }
	    if($MyNL->number_of_ML_entries_today()>0)
	    {
		print "<li><a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDMLoption."=showall&".$ShowNLIDMLshowallWhat."=today\">".$ShowMLEntries_menu[3]."</a></li>";
	    }
	    print "</ul>";
    }

    //search for an entry:
    if($_REQUEST[$ShowNLIDMLoption]=="search")
    {
	$ShowNLIDMLEntrySubmitnow="Show".$NLID."MLSubmitnow";
	$ShowEntryNLIDML_emailadress="Show".$NLID."ML_emailadress";
	$ShowEntryNLIDML_deleteID="Show".$NLID."ML_deleteID";
	if($_POST[$ShowNLIDMLoptiondeleteEntry]=="yes")
	{
	    if($MyNL->delete_from_ML($_POST[$ShowEntryNLIDML_deleteID]))
	    {
		 print preg_replace("/<-ID->/",$_POST[$ShowEntryNLIDML_deleteID],$ShowMLEntry_deleted)."<br>";
	    }
	    print "<br>";
	    print "<a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDMLoption."=search\">$ShowMLEntry_Searchforanother</a><br>";
	}
	else
	{
	    print "<h2>$ShowMLEntry_search_Title</h2>";
	    if($_POST[$ShowNLIDMLEntrySubmitnow]=="yes")
	    {
		$EntryID=$MyNL->get_ML_entry_id(preg_replace("/ /","",$_POST[$ShowEntryNLIDML_emailadress]));
		if($EntryID >0)
		{	//if the e-mail adress is on ML:
			print "<b>$ShowMLEntry_search_success</b><br><br>";
			$result=array();
			$result=$MyNL->get_ML_entry_data($EntryID);
			$timezone= $timezone=$MyCFG->get_timezone();
			print "<table>";
			print "<tr><td>$ShowMLEntry_ID:</td><td>".$result["id"]."</td></tr>";
			print "<tr><td>$ShowMLEntry_Email:</td><td>".$result["email"]."</td></tr>";
			print "<tr><td>$ShowMLEntry_IP:</td><td>".$result["ip"]."</td></tr>";
			print "<tr><td>$ShowMLEntry_EntryDate:</td><td>".date("$dateformat, $timeformat",$result["timestamp_entry"])." ($timezone)</td></tr>";
			print "<tr><td>$ShowMLEntry_Expires:</td><td>".date("$dateformat, $timeformat",$result["timestamp_expires"])." ($timezone)</td></tr>";
			print "</table>";
			print "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"post\">";
			print "<input type=\"hidden\" name=\"$ShowNLIDMLoptiondeleteEntry\" value=\"yes\">";
			print "<input type=\"hidden\" name=\"$ShowNLIDMLoption\" value=\"search\">";
			print "<input type=\"hidden\" name=\"$ShowEntryNLIDML_deleteID\" value=\"$EntryID\">";
			print "<input type=\"submit\" value=\"$ShowMLEntry_deleteEntry\"></form><br>";
	    
		}
		else
		{	//if it is not on ML:
			
			print $ShowMLEntry_notfound."<br>";
		}
		
		print "<br>";
		print "<a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDMLoption."=search\">$ShowMLEntry_Searchforanother</a><br>";
	    }
	    else
	    {
		print "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"post\">";
		print "<input type=\"hidden\" name=\"$ShowNLIDMLEntrySubmitnow\" value=\"yes\">";
		print "<input type=\"hidden\" name=\"$ShowNLIDMLoption\" value=\"search\">";
		print "$ShowMLEntry_Email: <input type=\"text\" name=\"$ShowEntryNLIDML_emailadress\" value=\"\" size=35>";
		print "<input type=\"submit\" value=\"$ShowMLEntry_search_submit\"></form>";
	    }
	}
	print "<br><br><a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDMLoption."=menu\">$ShowMLEntriesBackToMenu</a>";
    }
    //show entries in a table:
    if($_REQUEST[$ShowNLIDMLoption]=="showall")
    {
	$ShowAllperPageDefault=25;
	$ShowNLIDMLshowalldeletelist="Show".$NLID."MLshowalldeletelist";
	$ShowNLIDMLshowalldeletelistcount="Show".$NLID."MLshowalldeletelistcount";
	$ShowNLIDMLshowallperpage="Show".$NLID."MLshowallperpage"; //number 1-50
	$ShowNLIDMLshowallStartat="Show".$NLID."MLshowallStartat";
	$ShowNLIDMLshowallEndat="Show".$NLID."MLshowallEndat";
	if($_POST[$ShowNLIDMLoptiondeleteEntry]=="yes")
	{
	    //delete entries
	    $_SESSION[$ShowNLIDMLshowallStartat]=0;
	
	    $_SESSION[$ShowNLIDMLshowallEndat]=$_SESSION[$ShowNLIDMLshowallperpage];

	    $i=0;
	    $entryid=0;
	    $deletelist=$_POST[$ShowNLIDMLshowalldeletelist];
	    while($i <intval($_POST[$ShowNLIDMLshowalldeletelistcount]))
	    {
		
		if($MyNL->delete_from_ML($deletelist[$i]))
		{
		    print preg_replace("/<-ID->/",$deletelist[$i],$ShowMLEntry_deleted)."<br>";
		}
		
		$i++;
	    }
	    print "<br><br>";
	}
	
	if($MyNL->number_of_ML_entries() <1)
	{
	    //No entries available:
	    print "$ShowMLEntries_no_entries";

	    
	    
	}
	else
	{
	    
	    //preparing:
	    $ShowNLIDMLshowallDirection="Show".$NLID."MLshowallDirection"; //ASC or DESC
	    $ShowNLIDMLshowallOrderby="Show".$NLID."MLshowallOrderby"; //field name (lower case)
	    $ShowNLIDMLshowalllastnext="Show".$NLID."MLshowalllastnext"; //last or next
	  
	  
	  
	    
	    //setting defaults:
	    if(!isset($_SESSION[$ShowNLIDMLshowallOrderby]))
	    {
		$_SESSION[$ShowNLIDMLshowallOrderby]="id";

	    }
	    if(!isset($_SESSION[$ShowNLIDMLshowallStartat]))
	    {
		$_SESSION[$ShowNLIDMLshowallStartat]=0;

	    }
	    if(!isset($_SESSION[$ShowNLIDMLshowalllastnext]))
	    {
		$_SESSION[$ShowNLIDMLshowalllastnext]="next";

	    }
	    if(!isset($_SESSION[$ShowNLIDMLshowallperpage]))
	    {
		$_SESSION[$ShowNLIDMLshowallperpage]=$ShowAllperPageDefault;

	    }
	    if(!isset($_SESSION[$ShowNLIDMLshowallEndat]))
	    {
		$_SESSION[$ShowNLIDMLshowallEndat]=$_SESSION[$ShowNLIDMLshowallperpage];

	    }
	    
	     if(!isset($_SESSION[$ShowNLIDMLshowallDirection]))
	    {
		$_SESSION[$ShowNLIDMLshowallDirection]="ASC";

	    }
	     if(!isset($_SESSION[$ShowNLIDMLshowallWhat]))
	    {
		$_SESSION[$ShowNLIDMLshowallWhat]="all";

	    }


	    //looking for changes:
	    if($_REQUEST[$ShowNLIDMLshowallWhat])
	    {
		$_SESSION[$ShowNLIDMLshowallWhat]=$_REQUEST[$ShowNLIDMLshowallWhat];
		$_SESSION[$ShowNLIDMLshowallStartat]=0;
		
		$_SESSION[$ShowNLIDMLshowallEndat]=$_SESSION[$ShowNLIDMLshowallperpage];
	    }
	    if($_REQUEST[$ShowNLIDMLshowallDirection])
	    {
		$_SESSION[$ShowNLIDMLshowallDirection]=$_REQUEST[$ShowNLIDMLshowallDirection];
		$_SESSION[$ShowNLIDMLshowallStartat]=0;
		$_SESSION[$ShowNLIDMLshowallEndat]=$_SESSION[$ShowNLIDMLshowallperpage];
	    }
	    if($_REQUEST[$ShowNLIDMLshowallOrderby])
	    {
		$_SESSION[$ShowNLIDMLshowallOrderby]=$_REQUEST[$ShowNLIDMLshowallOrderby];
		$_SESSION[$ShowNLIDMLshowallStartat]=0;
		$_SESSION[$ShowNLIDMLshowallEndat]=$_SESSION[$ShowNLIDMLshowallperpage];
	    }
	    if(isset($_REQUEST[$ShowNLIDMLshowallStartat]))
	    {
		$_SESSION[$ShowNLIDMLshowallStartat]=$_REQUEST[$ShowNLIDMLshowallStartat];
	
		
	    }
	     if($_REQUEST[$ShowNLIDMLshowallEndat])
	    {
		$_SESSION[$ShowNLIDMLshowallEndat]=$_REQUEST[$ShowNLIDMLshowallEndat];
	
		
	    }
	   
	    if($_REQUEST[$ShowNLIDMLshowallperpage])
	    {
		
		$_SESSION[$ShowNLIDMLshowallperpage]=$_REQUEST[$ShowNLIDMLshowallperpage];
		
		$_SESSION[$ShowNLIDMLshowallStartat]=0;
		$_SESSION[$ShowNLIDMLshowallEndat]=$_SESSION[$ShowNLIDMLshowallperpage];
	    }

	    $NumberOfEntries=$MyNL->number_of_ML_entries();
	    if($_SESSION[$ShowNLIDMLshowallWhat]=="expiring")
	    {
		$NumberOfEntries=$MyNL->number_of_expiring_entries();
	    }
	    if($_SESSION[$ShowNLIDMLshowallWhat]=="today")
	    {
		$NumberOfEntries=$MyNL->number_of_ML_entries_today();
	    }

	   //fetching ML entries:
	    $entries=array();
	    $offset=$_SESSION[$ShowNLIDMLshowallEndat] -$_SESSION[$ShowNLIDMLshowallStartat];
	    $entries=$MyNL->get_ML_entries($_SESSION[$ShowNLIDMLshowallStartat],$offset,$_SESSION[$ShowNLIDMLshowallOrderby],$_SESSION[$ShowNLIDMLshowallDirection],$_SESSION[$ShowNLIDMLshowallWhat]);					
	  
	    //displaying table:
	    
	    print $ShowMLEntries_table_Title[$_SESSION[$ShowNLIDMLshowallWhat]];
	    

	    print "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"post\">$ShowMLEntries_order_Direction: ";
	    print "<input type=\"hidden\" name=\"$ShowNLIDMLoption\" value=\"showall\">";
	    print "<select name=\"$ShowNLIDMLshowallDirection\">";
	   
	    print "<option value=\"ASC\"";
	    if($_SESSION[$ShowNLIDMLshowallDirection]== "ASC")
	    {
		print " selected ";
	    }
	    print ">$ShowMLEntries_order_Asc</option>";

	     print "<option value=\"DESC\"";
	    if($_SESSION[$ShowNLIDMLshowallDirection]== "DESC")
	    {
		print " selected ";
	    }
	    print ">$ShowMLEntries_order_Desc</option></select>";
	    
	    print "$ShowMLEntries_showperpage: ";
	    
	    print "<select name=\"$ShowNLIDMLshowallperpage\">";
	    
	    $i=1;

	    while($i <= 50)
	    {
		print "<option value=\"$i\"";
		if ($i ==$_SESSION[$ShowNLIDMLshowallperpage])
		{
		    print " selected ";
		}
		print ">$i</option>";
		
		$i++;
	    }
	    print "</select><input type=\"submit\" value=\"$ShowMLEntries_change_options\"></form>";
	    print "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"post\">";
	    print "<input type=\"hidden\" name=\"$ShowNLIDMLoption\" value=\"showall\">";
	    print "<table border=1 class=\"showentries\">";
	    
	    print "<tr><td>$ShowMLEntries_table_delete</td>";

	    print "<td>";
	    print "<a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDMLshowallOrderby."=id&".$ShowNLIDMLoption."=showall\" title=\"$ShowMLEntries_tooltext_orderby\">";
	    if($_SESSION[$ShowNLIDMLshowallOrderby]=="id")
	    {
		print "<b>$ShowMLEntries_table_id</b>";
	    }
	    else
	    {
		print "$ShowMLEntries_table_id";
	    }
	    print "</a></td>";
	    
	     print "<td>";
	    print "<a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDMLshowallOrderby."=email&".$ShowNLIDMLoption."=showall\" title=\"$ShowMLEntries_tooltext_orderby\">";
	    if($_SESSION[$ShowNLIDMLshowallOrderby]=="email")
	    {
		print "<b>$ShowMLEntries_table_email</b>";
	    }
	    else
	    {
		print "$ShowMLEntries_table_email";
	    }
	    print "</a></td>";
	     print "<td>";
	     print "<a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDMLshowallOrderby."=ip&".$ShowNLIDMLoption."=showall\" title=\"$ShowMLEntries_tooltext_orderby\">";
	    if($_SESSION[$ShowNLIDMLshowallOrderby]=="ip")
	    {
		print "<b>$ShowMLEntries_table_ip</b>";
	    }
	    else
	    {
		print "$ShowMLEntries_table_ip";
	    }
	    print "</a></td>";

	     print "<td>";

	     print "<a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDMLshowallOrderby."=timestamp_entry&".$ShowNLIDMLoption."=showall\" title=\"$ShowMLEntries_tooltext_orderby\">";
	    if($_SESSION[$ShowNLIDMLshowallOrderby]=="timestamp_entry")
	    {
		print "<b>$ShowMLEntries_table_entrydate</b>";
	    }
	    else
	    {
		print "$ShowMLEntries_table_entrydate";
	    }
	    print "</a></td>";
	    print "<td>";
	    print "<a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDMLshowallOrderby."=timestamp_expires&".$ShowNLIDMLoption."=showall\" title=\"$ShowMLEntries_tooltext_orderby\">";
	    if($_SESSION[$ShowNLIDMLshowallOrderby]=="timestamp_expires")
	    {
		print "<b>$ShowMLEntries_table_expires</b>";
	    }
	    else
	    {
		print "$ShowMLEntries_table_expires";
	    }
	    print "</a></td>";

	    print "</tr>";

	     //displaying entries:
	    $i=0;
	    $timezone=$MyCFG->get_timezone();
	    while($i < count($entries))
	    {	
		if ($entries[$i]["id"])
		{
		    print "<tr><td>";
		    print  "<input type=\"checkbox\" name=\"".$ShowNLIDMLshowalldeletelist."[$i]\" value=\"".$entries[$i]["id"]."\"></td>";
		    print "</td>";
		    print "<td>".$entries[$i]["id"]."</td>";
		    print "<td>".$entries[$i]["email"]."</td>";
		    print "<td>".$entries[$i]["ip"]."</td>";
		    print "<td>".date("$dateformat, $timeformat",$entries[$i]["timestamp_entry"])." ($timezone)</td>";
		    print "<td>".date("$dateformat, $timeformat",$entries[$i]["timestamp_expires"])." ($timezone)</td>";
		    print "</tr>";
		}
		$i++;
	    }

	    print "</table>";
	    print "<input type=\"hidden\" name=\"$ShowNLIDMLoptiondeleteEntry\" value=\"yes\">";
	    print "<input type=\"hidden\" name=\"$ShowNLIDMLshowalldeletelistcount\" value=\"$i\">";
	    print "<input type=\"hidden\" name=\"$ShowNLIDMLshowallStartat\" value=\"0\">";
	    print "<input type=\"hidden\" name=\"$ShowNLIDMLshowallEndat\" value=\"".$_SESSION[$ShowNLIDMLshowallperpage]."\">";
	    print "<input type=\"submit\" value=\"$ShowMLEntries_deleteSelected\"></form>";
	    
	    //next/last
	    //show last:
	    $last_entries=0;
	   if($_SESSION[$ShowNLIDMLshowallStartat] >0)
	   {
		if($_SESSION[$ShowNLIDMLshowallStartat]-$_SESSION[$ShowNLIDMLshowallperpage] >=0)
		{
		    $last_entries=$_SESSION[$ShowNLIDMLshowallperpage];

		}
		else
		{
		    $last_entries=$_SESSION[$ShowNLIDMLshowallStartat];
		}
		print "<a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDMLshowallStartat."=";
		print ($_SESSION[$ShowNLIDMLshowallStartat]-$last_entries)."&".$ShowNLIDMLshowallEndat."=";
		print ($_SESSION[$ShowNLIDMLshowallStartat])."&".$ShowNLIDMLoption."=showall\">&lt;- $ShowMLEntries_showlast  $last_entries</a>"; 
	   }

	    //show next:
	   $next_entries=0;
	   if($_SESSION[$ShowNLIDMLshowallEndat] < ($NumberOfEntries) )
	    {
		if($_SESSION[$ShowNLIDMLshowallEndat]+$_SESSION[$ShowNLIDMLshowallperpage] <=($NumberOfEntries-1))
		{
		    $next_entries=$_SESSION[$ShowNLIDMLshowallperpage];
		}
		else
		{
		    $next_entries=($NumberOfEntries)-$_SESSION[$ShowNLIDMLshowallEndat];

		}
		if ($last_entries >0)
		{
		    print " | ";
		}
		print "<a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDMLshowallStartat."=";
		print ($_SESSION[$ShowNLIDMLshowallEndat])."&".$ShowNLIDMLshowallEndat."=";
		print ($_SESSION[$ShowNLIDMLshowallEndat]+$next_entries)."&".$ShowNLIDMLoption."=showall\">$ShowMLEntries_shownext  $next_entries -&gt;</a>"; 
	    }
	   
	  
	}
	
	print "<br><br><a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDMLoption."=menu\">$ShowMLEntriesBackToMenu</a>";
    }
}
else
{
      print $ErrorNLdoesnotExist;
} 
?>
Return current item: ADbNewsSender