Location: PHPKode > projects > ADbNewsSender > ADbNewsSender 2.1.0/protected/admin/nl/viewMLentries.php.inc
<?php
//Copyright (c) Florian Grannemann
//Last change in version: 2.1 Alpha 3
/*
    ******************************************************************************
    ADbNewsSender 2

    Copyright (C) 2010 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($MySessionHandler->getNLID() && $MyCFG->NL_exists($MySessionHandler->getNLID()))
{
    //preparing mudule variables:
    $NLID=$MySessionHandler->getNLID();
    $curModul=$MySessionHandler->getCurrentModule();
    //Request variables
    //ShowMLoption
    //showMLshowallWhat
    //ShowMLoptiondeleteEntry

  

    if($MyRequestHandler->getNLModuleKeyValue("ShowMLoption") !="search" && $MyRequestHandler->getNLModuleKeyValue("ShowMLoption") !="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"]."?".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."=search\">".$ShowMLEntries_menu[0]."</a></li>";
	    print "<li><a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."=showall&".$MyRequestHandler->getNLModuleKeyName("ShowMLshowallWhat")."=all\">".$ShowMLEntries_menu[1]."</a></li>";
	    
	    if($MyNL->number_of_expiring_entries() >0)
	    {
		print "<li><a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."=showall&".$MyRequestHandler->getNLModuleKeyName("ShowMLshowallWhat")."=expiring\">".$ShowMLEntries_menu[2]."</a></li>";
	    }
	    if($MyNL->number_of_ML_entries_today()>0)
	    {
		print "<li><a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."=showall&".$MyRequestHandler->getNLModuleKeyName("ShowMLshowallWhat")."=today\">".$ShowMLEntries_menu[3]."</a></li>";
	    }
	    print "</ul>";
    }

    //search for an entry:
    if($MyRequestHandler->getNLModuleKeyValue("ShowMLoption")=="search")
    {
	//request variables:
	//ShowMLEntrySubmitnow
	//ShowEntryML_emailaddress
	//ShowEntryML_deleteID
	if($MyRequestHandler->getNLModuleKeyValue("ShowMLoptiondeleteEntry")=="yes")
	{
	    if($MyNL->delete_from_ML($MyRequestHandler->getNLModuleKeyValue("ShowEntryML_deleteID")))
	    {
		 print preg_replace("/<-ID->/",$MyRequestHandler->getNLModuleKeyValue("ShowEntryML_deleteID"),$ShowMLEntry_deleted)."<br>";
	    }
	    print "<br>";
	    print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."=search\">$ShowMLEntry_Searchforanother</a><br>";
	}
	else
	{
	    print "<h2>$ShowMLEntry_search_Title</h2>";
	    if($MyRequestHandler->getNLModuleKeyValue("ShowMLEntrySubmitnow")=="yes")
	    {
		$EntryID=$MyNL->get_ML_entry_id(preg_replace("/ /","",$MyRequestHandler->getNLModuleKeyValue("ShowEntryML_emailaddress")));
		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=\"".$MyRequestHandler->getNLModuleKeyName("ShowMLoptiondeleteEntry")."\" value=\"yes\">";
			print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."\" value=\"search\">";
			print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowEntryML_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"]."?".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."=search\">$ShowMLEntry_Searchforanother</a><br>";
	    }
	    else
	    {
		print "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"post\">";
		print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowMLEntrySubmitnow")."\" value=\"yes\">";
		print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."\" value=\"search\">";
		print "$ShowMLEntry_Email: <input type=\"text\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowEntryML_emailaddress")."\" value=\"\" size=35>";
		print "<input type=\"submit\" value=\"$ShowMLEntry_search_submit\"></form>";
	    }
	}
	print "<br><br><a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."=menu\">$ShowMLEntriesBackToMenu</a>";
    }
    //show entries in a table:
    if($MyRequestHandler->getNLModuleKeyValue("ShowMLoption")=="showall")
    {
	$ShowAllperPageDefault=25;
	
	//Session & request vars:
	//ShowMLshowalldeletelist
	//ShowMLshowalldeletelistcount
	//ShowMLshowallperpage
	//ShowMLshowallStartat
	//ShowMLshowallEndat
	
	if($MyRequestHandler->getNLModuleKeyValue("ShowMLoptiondeleteEntry")=="yes")
	{
	    //delete entries
	    $MySessionHandler->setNLModuleKey("ShowMLshowallStartat",0);
	
	    $MySessionHandler->setNLModuleKey("ShowMLshowallEndat",$MySessionHandler->getNLModuleKeyValue("ShowMLshowallperpage"));

	    $i=0;
	    $entryid=0;
	    $deletelist=$MyRequestHandler->getNLModuleKeyValue("ShowMLshowalldeletelist");
	    while($i <intval($MyRequestHandler->getNLModuleKeyValue("ShowMLshowalldeletelistcount")))
	    {
		
		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
	{
	   
	    //Session & request vars:
	    //ShowMLshowallDirection //ASC or DESC
	    //ShowMLshowallOrderby //field name (lower case)
	    //ShowMLshowalllastnext //last or next
	  
	  
	    
	    //setting defaults:
	    if(!$MySessionHandler->getNLModuleKeyValue("ShowMLshowallOrderby"))
	    {
		$MySessionHandler->setNLModuleKey("ShowMLshowallOrderby","id");

	    }
	    if(!$MySessionHandler->getNLModuleKeyValue("ShowMLshowallStartat"))
	    {
		$MySessionHandler->setNLModuleKey("ShowMLshowallStartat",0);

	    }
	    if(!$MySessionHandler->getNLModuleKeyValue("ShowMLshowalllastnext"))
	    {
		$MySessionHandler->setNLModuleKey("ShowMLshowalllastnext","next");

	    }
	    if(!$MySessionHandler->getNLModuleKeyValue("ShowMLshowallperpage"))
	    {
		$MySessionHandler->setNLModuleKey("ShowMLshowallperpage",$ShowAllperPageDefault);

	    }
	    if(!$MySessionHandler->getNLModuleKeyValue("ShowMLshowallEndat"))
	    {
		$MySessionHandler->setNLModuleKey("ShowMLshowallEndat",$MySessionHandler->getNLModuleKeyValue("ShowMLshowallperpage"));

	    }
	    
	     if(!$MySessionHandler->getNLModuleKeyValue("ShowMLshowallDirection"))
	    {
		$MySessionHandler->setNLModuleKey("ShowMLshowallDirection","ASC");

	    }
	     if(!$MySessionHandler->getNLModuleKeyValue("ShowMLshowallWhat"))
	    {
		$MySessionHandler->setNLModuleKey("ShowMLshowallWhat","all");

	    }


	    //looking for changes:
	    if($MyRequestHandler->getNLModuleKeyValue("ShowMLshowallWhat"))
	    {
		$MySessionHandler->setNLModuleKey("ShowMLshowallWhat",$MyRequestHandler->getNLModuleKeyValue("ShowMLshowallWhat"));
		$MySessionHandler->setNLModuleKey("ShowMLshowallStartat",0);
		
		$MySessionHandler->setNLModuleKey("ShowMLshowallEndat",$MySessionHandler->getNLModuleKeyValue("ShowMLshowallperpage"));
	    }
	    if($MyRequestHandler->getNLModuleKeyValue("ShowMLshowallDirection"))
	    {
		$MySessionHandler->setNLModuleKey("ShowMLshowallDirection",$MyRequestHandler->getNLModuleKeyValue("ShowMLshowallDirection"));
		$MySessionHandler->setNLModuleKey("ShowMLshowallStartat",0);
		$MySessionHandler->setNLModuleKey("ShowMLshowallEndat",$MySessionHandler->getNLModuleKeyValue("ShowMLshowallperpage"));
	    }
	    if($MyRequestHandler->getNLModuleKeyValue("ShowMLshowallOrderby"))
	    {
		$MySessionHandler->setNLModuleKey("ShowMLshowallOrderby",$MyRequestHandler->getNLModuleKeyValue("ShowMLshowallOrderby"));
		$MySessionHandler->setNLModuleKey("ShowMLshowallStartat",0);
		$MySessionHandler->setNLModuleKey("ShowMLshowallEndat",$MySessionHandler->getNLModuleKeyValue("ShowMLshowallperpage"));
	    }
	    if($MyRequestHandler->issetNLModuleKey("ShowMLshowallStartat"))
	    {
		$MySessionHandler->setNLModuleKey("ShowMLshowallStartat",$MyRequestHandler->getNLModuleKeyValue("ShowMLshowallStartat"));
	
		
	    }
	     if($MyRequestHandler->getNLModuleKeyValue("ShowMLshowallEndat"))
	    {
		$MySessionHandler->setNLModuleKey("ShowMLshowallEndat",$MyRequestHandler->getNLModuleKeyValue("ShowMLshowallEndat"));
	
		
	    }
	   
	    if($MyRequestHandler->getNLModuleKeyValue("ShowMLshowallperpage"))
	    {
		
		$MySessionHandler->setNLModuleKey("ShowMLshowallperpage",$MyRequestHandler->getNLModuleKeyValue("ShowMLshowallperpage"));
		
		$MySessionHandler->setNLModuleKey("ShowMLshowallStartat",0);
		$MySessionHandler->setNLModuleKey("ShowMLshowallEndat",$MySessionHandler->getNLModuleKeyValue("ShowMLshowallperpage"));
	    }

	    $NumberOfEntries=$MyNL->number_of_ML_entries();
	    if($MySessionHandler->getNLModuleKeyValue("ShowMLshowallWhat")=="expiring")
	    {
		$NumberOfEntries=$MyNL->number_of_expiring_entries();
	    }
	    if($MySessionHandler->getNLModuleKeyValue("ShowMLshowallWhat")=="today")
	    {
		$NumberOfEntries=$MyNL->number_of_ML_entries_today();
	    }

	   //fetching ML entries:
	    $entries=array();
	    $offset=$MySessionHandler->getNLModuleKeyValue("ShowMLshowallEndat") -$MySessionHandler->getNLModuleKeyValue("ShowMLshowallStartat");
	    $entries=$MyNL->get_ML_entries($MySessionHandler->getNLModuleKeyValue("ShowMLshowallStartat"),$offset,$MySessionHandler->getNLModuleKeyValue("ShowMLshowallOrderby"),$MySessionHandler->getNLModuleKeyValue("ShowMLshowallDirection"),$MySessionHandler->getNLModuleKeyValue("ShowMLshowallWhat"));					
	  
	    //displaying table:
	    
	    print $ShowMLEntries_table_Title[$MySessionHandler->getNLModuleKeyValue("ShowMLshowallWhat")];
	    

	    print "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"post\">$ShowMLEntries_order_Direction: ";
	    print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."\" value=\"showall\">";
	    print "<select name=\"".$MyRequestHandler->getNLModuleKeyName("ShowMLshowallDirection")."\">";
	   
	    print "<option value=\"ASC\"";
	    if($MySessionHandler->getNLModuleKeyValue("ShowMLshowallDirection")== "ASC")
	    {
		print " selected ";
	    }
	    print ">$ShowMLEntries_order_Asc</option>";

	     print "<option value=\"DESC\"";
	    if($MySessionHandler->getNLModuleKeyValue("ShowMLshowallDirection")== "DESC")
	    {
		print " selected ";
	    }
	    print ">$ShowMLEntries_order_Desc</option></select>";
	    
	    print "$ShowMLEntries_showperpage: ";
	    
	    print "<select name=\"".$MyRequestHandler->getNLModuleKeyName("ShowMLshowallperpage")."\">";
	    
	    $i=1;

	    while($i <= 200)
	    {
		print "<option value=\"$i\"";
		if ($i ==$MySessionHandler->getNLModuleKeyValue("ShowMLshowallperpage"))
		{
		    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=\"".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."\" value=\"showall\">";
	    print "<table border=1 class=\"showentries\">";
	    
	    print "<tr><td>$ShowMLEntries_table_delete</td>";

	    print "<td>";
	    print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowMLshowallOrderby")."=id&".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."=showall\" title=\"$ShowMLEntries_tooltext_orderby\">";
	    if($MySessionHandler->getNLModuleKeyValue("ShowMLshowallOrderby")=="id")
	    {
		print "<b>$ShowMLEntries_table_id</b>";
	    }
	    else
	    {
		print "$ShowMLEntries_table_id";
	    }
	    print "</a></td>";
	    
	     print "<td>";
	    print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowMLshowallOrderby")."=email&".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."=showall\" title=\"$ShowMLEntries_tooltext_orderby\">";
	    if($MySessionHandler->getNLModuleKeyValue("ShowMLshowallOrderby")=="email")
	    {
		print "<b>$ShowMLEntries_table_email</b>";
	    }
	    else
	    {
		print "$ShowMLEntries_table_email";
	    }
	    print "</a></td>";
	     print "<td>";
	     print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowMLshowallOrderby")."=ip&".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."=showall\" title=\"$ShowMLEntries_tooltext_orderby\">";
	
	    if($MySessionHandler->getNLModuleKeyValue("ShowMLshowallOrderby")=="ip")
	    {
		
		print "<b>$ShowMLEntries_table_ip</b>";
	    }
	    else
	    {
		print "$ShowMLEntries_table_ip";
	    }
	    print "</a></td>";

	     print "<td>";

	     print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowMLshowallOrderby")."=timestamp_entry&".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."=showall\" title=\"$ShowMLEntries_tooltext_orderby\">";
	    if($MySessionHandler->getNLModuleKeyValue("ShowMLshowallOrderby")=="timestamp_entry")
	    {
		print "<b>$ShowMLEntries_table_entrydate</b>";
	    }
	    else
	    {
		print "$ShowMLEntries_table_entrydate";
	    }
	    print "</a></td>";
	    print "<td>";
	    print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowMLshowallOrderby")."=timestamp_expires&".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."=showall\" title=\"$ShowMLEntries_tooltext_orderby\">";
	    if($MySessionHandler->getNLModuleKeyValue("ShowMLshowallOrderby")=="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=\"".$MyRequestHandler->getNLModuleKeyName("ShowMLshowalldeletelist")."[$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=\"".$MyRequestHandler->getNLModuleKeyName("ShowMLoptiondeleteEntry")."\" value=\"yes\">";
	    print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowMLshowalldeletelistcount")."\" value=\"$i\">";
	    print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowMLshowallStartat")."\" value=\"0\">";
	    print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowMLshowallEndat")."\" value=\"".$MySessionHandler->getNLModuleKeyValue("ShowMLshowallperpage]")."\">";
	    print "<input type=\"submit\" value=\"$ShowMLEntries_deleteSelected\"></form>";
	    
	    //next/last
	    //show last:
	    $last_entries=0;
	   if($MySessionHandler->getNLModuleKeyValue("ShowMLshowallStartat") >0)
	   {
		if($MySessionHandler->getNLModuleKeyValue("ShowMLshowallStartat")-$MySessionHandler->getNLModuleKeyValue("ShowMLshowallperpage") >=0)
		{
		    $last_entries=$MySessionHandler->getNLModuleKeyValue("ShowMLshowallperpage");

		}
		else
		{
		    $last_entries=$MySessionHandler->getNLModuleKeyValue("ShowMLshowallStartat");
		}
		print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowMLshowallStartat")."=";
		print ($MySessionHandler->getNLModuleKeyValue("ShowMLshowallStartat")-$last_entries)."&".$MyRequestHandler->getNLModuleKeyName("ShowMLshowallEndat")."=";
		print $MySessionHandler->getNLModuleKeyValue("ShowMLshowallStartat")."&".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."=showall\">&lt;- $ShowMLEntries_showlast  $last_entries</a>"; 
	   }

	    //show next:
	   $next_entries=0;
	   if($MySessionHandler->getNLModuleKeyValue("ShowMLshowallEndat") < ($NumberOfEntries) )
	    {
		if($MySessionHandler->getNLModuleKeyValue("ShowMLshowallEndat")+$MySessionHandler->getNLModuleKeyValue("ShowMLshowallperpage") <=($NumberOfEntries-1))
		{
		    $next_entries=$MySessionHandler->getNLModuleKeyValue("ShowMLshowallperpage");
		}
		else
		{
		    $next_entries=($NumberOfEntries)-$MySessionHandler->getNLModuleKeyValue("ShowMLshowallEndat");

		}
		if ($last_entries >0)
		{
		    print " | ";
		}
		print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowMLshowallStartat")."=";
		print ($MySessionHandler->getNLModuleKeyValue("ShowMLshowallEndat"))."&".$MyRequestHandler->getNLModuleKeyName("ShowMLshowallEndat")."=";
		print ($MySessionHandler->getNLModuleKeyValue("ShowMLshowallEndat")+$next_entries)."&".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."=showall\">$ShowMLEntries_shownext  $next_entries -&gt;</a>"; 
	    }
	   
	  
	}
	
	print "<br><br><a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowMLoption")."=menu\">$ShowMLEntriesBackToMenu</a>";
    }
}
else
{
      print $ErrorNLdoesnotExist;
} 
?>
Return current item: ADbNewsSender