Location: PHPKode > projects > ADbNewsSender > ADbNewsSender 2.1.0/protected/admin/nl/viewPLentries.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_viewPLentries.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 & session vars:
    //ShowPLoption
    //ShowPLoptiondeleteEntry

  

    if($MyRequestHandler->getNLModuleKeyValue("ShowPLoption") !="search" && $MyRequestHandler->getNLModuleKeyValue("ShowPLoption") !="showall" )
    {
	//no option selected, show menu:
	    print "<h2>$ShowPLEntries_menu_title</h2>";
	    print "$ShowPLEntries_menu_select<br><br>";
	    print "<ul>";
	    print "<li><a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowPLoption")."=search\">".$ShowPLEntries_menu[0]."</a></li>";
	    print "<li><a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowPLoption")."=showall\">".$ShowPLEntries_menu[1]."</a></li>";
	    
	    
	    print "</ul>";
    }

    //search for an entry:
    if($MyRequestHandler->getNLModuleKeyValue("ShowPLoption")=="search")
    {
	//Session & request keys:
	//ShowPLEntrySubmitnow
	//ShowEntryPL_emailaddress
	//ShowEntryPL_deleteID
	if($MyRequestHandler->getNLModuleKeyValue("ShowPLoptiondeleteEntry")=="yes")
	{
	    if($MyNL->delete_from_PL($MyRequestHandler->getNLModuleKeyValue("ShowEntryPL_deleteID")))
	    {
		 print preg_replace("/<-ID->/",$MyRequestHandler->getNLModuleKeyValue("ShowEntryPL_deleteID"),$ShowPLEntry_deleted)."<br>";
	    }
	    print "<br>";
	    print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowPLoption")."=search\">$ShowPLEntry_Searchforanother</a><br>";
	}
	else
	{
	    print "<h2>$ShowPLEntry_search_Title</h2>";
	    if($MyRequestHandler->getNLModuleKeyValue("ShowPLEntrySubmitnow")=="yes")
	    {
		$EntryID=$MyNL->get_PL_entry_id(preg_replace("/ /","",$MyRequestHandler->getNLModuleKeyValue("ShowEntryPL_emailaddress")));
		if($EntryID >0)
		{	//if the e-mail adress is on PL:
			print "<b>$ShowPLEntry_search_success</b><br><br>";
			$result=array();
			$result=$MyNL->get_PL_entry_data($EntryID);
			$timezone= $timezone=$MyCFG->get_timezone();
			print "<table>";
			print "<tr><td>$ShowPLEntry_ID:</td><td>".$result["id"]."</td></tr>";
			print "<tr><td>$ShowPLEntry_Email:</td><td>".$result["email"]."</td></tr>";
			print "<tr><td>$ShowPLEntry_IP:</td><td>".$result["ip"]."</td></tr>";
			print "<tr><td>$ShowPLEntry_Random:</td><td>".$result["randomcode"]."</td></tr>";
			print "<tr><td>$ShowPLEntry_ConfAtt:</td><td>".intval($result["numberofattempts"])."</td></tr>";
			print "<tr><td>$ShowPLEntry_EntryDate:</td><td>".date("$dateformat, $timeformat",$result["timestamp_entry"])." ($timezone)</td></tr>";
			print "<tr><td>$ShowPLEntry_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("ShowPLoptiondeleteEntry")."\" value=\"yes\">";
			print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowPLoption")."\" value=\"search\">";
			print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowEntryPL_deleteID")."\" value=\"$EntryID\">";
			print "<input type=\"submit\" value=\"$ShowPLEntry_deleteEntry\"></form><br>";
	    
		}
		else
		{	//if it is not on PL:
			
			print $ShowPLEntry_notfound."<br>";
		}
		
		print "<br>";
		print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowPLoption")."=search\">$ShowPLEntry_Searchforanother</a><br>";
	    }
	    else
	    {
		print "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"post\">";
		print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowPLEntrySubmitnow")."\" value=\"yes\">";
		print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowPLoption")."\" value=\"search\">";
		print "$ShowPLEntry_Email: <input type=\"text\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowEntryPL_emailaddress")."\" value=\"\" size=35>";
		print "<input type=\"submit\" value=\"$ShowPLEntry_search_submit\"></form>";
	    }
	}
	print "<br><br><a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowPLoption")."=menu\">$ShowPLEntriesBackToMenu</a>";
    }
    //show entries in a table:
    if($MyRequestHandler->getNLModuleKeyValue("ShowPLoption")=="showall")
    {
	$ShowAllperPageDefault=25;
	//Session & request vars :
	//ShowPLshowalldeletelist
	//ShowPLshowalldeletelistcount   
	if($MyRequestHandler->getNLModuleKeyValue("ShowPLoptiondeleteEntry")=="yes")
	{
	    //delete entries
	    $MySessionHandler->setNLModuleKey("ShowPLshowallStartat",0);
	  
	    $MySessionHandler->setNLModuleKey("ShowPLshowallEndat", $MySessionHandler->getNLModuleKeyValue("ShowPLshowallperpage"));

	    $i=0;
	    $entryid=0;
	    $deletelist=$MyRequestHandler->getNLModuleKeyValue("ShowPLshowalldeletelist");
	    while($i <intval($MyRequestHandler->getNLModuleKeyValue("ShowPLshowalldeletelistcount")))
	    {
		
		if($MyNL->delete_from_PL($deletelist[$i]))
		{
		    print preg_replace("/<-ID->/",$deletelist[$i],$ShowPLEntry_deleted)."<br>";
		}
		
		$i++;
	    }
	    print "<br><br>";
	}
	
	if($MyNL->number_of_PL_entries() <1)
	{
	    //No entries available:
	    print "$ShowPLEntries_no_entries";

	    
	    
	}
	else
	{
	    
	    
	   //session & request vars:
	   //ShowPLshowallDirection //ASC or DESC
	   //ShowPLshowallOrderby //field name (lower case)
	   //ShowPLshowalllastnext //last or next
	   //ShowPLshowallperpage //number 1-200
	   //ShowPLshowallStartat
	   //ShowPLshowallEndat
	    
	
	    //setting defaults:
	    if(!$MySessionHandler->getNLModuleKeyValue("ShowPLshowallOrderby"))
	    {
		$MySessionHandler->setNLModuleKey("ShowPLshowallOrderby","id");

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

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

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

	    }
	    if(!$MySessionHandler->getNLModuleKeyValue("ShowPLshowallEndat"))
	    {
		$MySessionHandler->setNLModuleKey("ShowPLshowallEndat", $MySessionHandler->getNLModuleKeyValue("ShowPLshowallperpage"));

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

	    }
	    

	    //looking for changes:
	    
	    if($MyRequestHandler->getNLModuleKeyValue("ShowPLshowallDirection"))
	    {
		$MySessionHandler->setNLModuleKey("ShowPLshowallDirection",$MyRequestHandler->getNLModuleKeyValue("ShowPLshowallDirection"));
		$MySessionHandler->setNLModuleKey("ShowPLshowallStartat",0);
		$MySessionHandler->setNLModuleKey("ShowPLshowallEndat", $MySessionHandler->getNLModuleKeyValue("ShowPLshowallperpage"));
	    }
	    if($MyRequestHandler->getNLModuleKeyValue("ShowPLshowallOrderby"))
	    {
		$MySessionHandler->setNLModuleKey("ShowPLshowallOrderby",$MyRequestHandler->getNLModuleKeyValue("ShowPLshowallOrderby"));
		$MySessionHandler->setNLModuleKey("ShowPLshowallStartat",0);
		$MySessionHandler->setNLModuleKey("ShowPLshowallEndat", $MySessionHandler->getNLModuleKeyValue("ShowPLshowallperpage"));
	    }
	    if($MyRequestHandler->issetNLModuleKey("ShowPLshowallStartat"))
	    {
		$MySessionHandler->setNLModuleKey("ShowPLshowallStartat",$MyRequestHandler->getNLModuleKeyValue("ShowPLshowallStartat"));
	
		
	    }
	     if($MyRequestHandler->getNLModuleKeyValue("ShowPLshowallEndat"))
	    {
		$MySessionHandler->setNLModuleKey("ShowPLshowallEndat",$MyRequestHandler->getNLModuleKeyValue("ShowPLshowallEndat"));
	
		
	    }
	   
	    if($MyRequestHandler->getNLModuleKeyValue("ShowPLshowallperpage"))
	    {
		$MySessionHandler->setNLModuleKey("ShowPLshowallperpage",$MyRequestHandler->getNLModuleKeyValue("ShowPLshowallperpage"));
		$MySessionHandler->setNLModuleKey("ShowPLshowallStartat",0);
		$MySessionHandler->setNLModuleKey("ShowPLshowallEndat", $MySessionHandler->getNLModuleKeyValue("ShowPLshowallperpage"));
	    }

	    $NumberOfEntries=$MyNL->number_of_PL_entries();
	   
	   //fetching PL entries:
	    $entries=array();
	    $offset=$MySessionHandler->getNLModuleKeyValue("ShowPLshowallEndat") -$MySessionHandler->getNLModuleKeyValue("ShowPLshowallStartat");
	    $entries=$MyNL->get_PL_entries($MySessionHandler->getNLModuleKeyValue("ShowPLshowallStartat"),$offset,$MySessionHandler->getNLModuleKeyValue("ShowPLshowallOrderby"),$MySessionHandler->getNLModuleKeyValue("ShowPLshowallDirection"));					
	  
	    //displaying table:
	    
	    print $ShowPLEntries_table_Title;
	    

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

	     print "<option value=\"DESC\"";
	    if($MySessionHandler->getNLModuleKeyValue("ShowPLshowallDirection")== "DESC")
	    {
		print " selected ";
	    }
	    print ">$ShowPLEntries_order_Desc</option></select>";
	    
	    print "$ShowPLEntries_showperpage: ";
	    print "<select name=\"".$MyRequestHandler->getNLModuleKeyName("ShowPLshowallperpage")."\">";
	    
	    $i=1;
	    while($i <= 200)
	    {
		print "<option value=\"$i\"";
		if ($i ==$MySessionHandler->getNLModuleKeyValue("ShowPLshowallperpage"))
		{
		   print " selected ";
		}
		print ">$i</option>";
		
		$i++;
	    }
	    print "</select><input type=\"submit\" value=\"$ShowPLEntries_change_options\"></form>";
	    print "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"post\">";
	    print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowPLoption")."\" value=\"showall\">";
	    print "<table border=1 class=\"showentries\">";
	    
	    print "<tr><td>$ShowPLEntries_table_delete</td>";
	    //table column ID:
	    print "<td>";
	    print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowPLshowallOrderby")."=id&".$MyRequestHandler->getNLModuleKeyName("ShowPLoption")."=showall\" title=\"$ShowPLEntries_tooltext_orderby\">";
	    if($MySessionHandler->getNLModuleKeyValue("ShowPLshowallOrderby")=="id")
	    {
		print "<b>$ShowPLEntries_table_id</b>";
	    }
	    else
	    {
		print "$ShowPLEntries_table_id";
	    }
	    print "</a></td>";
	    
	    //table column e-mail
	     print "<td>";
	    print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowPLshowallOrderby")."=email&".$MyRequestHandler->getNLModuleKeyName("ShowPLoption")."=showall\" title=\"$ShowPLEntries_tooltext_orderby\">";
	    if($MySessionHandler->getNLModuleKeyValue("ShowPLshowallOrderby")=="email")
	    {
		print "<b>$ShowPLEntries_table_email</b>";
	    }
	    else
	    {
		print "$ShowPLEntries_table_email";
	    }
	    print "</a></td>";
	    //table column ip
	     print "<td>";
	     print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowPLshowallOrderby")."=ip&".$MyRequestHandler->getNLModuleKeyName("ShowPLoption")."=showall\" title=\"$ShowPLEntries_tooltext_orderby\">";
	    if($MySessionHandler->getNLModuleKeyValue("ShowPLshowallOrderby")=="ip")
	    {
		print "<b>$ShowPLEntries_table_ip</b>";
	    }
	    else
	    {
		print "$ShowPLEntries_table_ip";
	    }
	    print "</a></td>";

	   
	     //table column Conf attempts
	     print "<td>";
	     print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowPLshowallOrderby")."=numberofattempts&".$MyRequestHandler->getNLModuleKeyName("ShowPLoption")."=showall\" title=\"$ShowPLEntries_tooltext_orderby\">";
	    if($MySessionHandler->getNLModuleKeyValue("ShowPLshowallOrderby")=="numberofattempts")
	    {
		print "<b>$ShowPLEntries_table_NumbAttempts</b>";
	    }
	    else
	    {
		print "$ShowPLEntries_table_NumbAttempts";
	    }
	    print "</a></td>";

	    //column timestamp entry:
	     print "<td>";

	     print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowPLshowallOrderby")."=timestamp_entry&".$MyRequestHandler->getNLModuleKeyName("ShowPLoption")."=showall\" title=\"$ShowPLEntries_tooltext_orderby\">";
	    if($MySessionHandler->getNLModuleKeyValue("ShowPLshowallOrderby")=="timestamp_entry")
	    {
		print "<b>$ShowPLEntries_table_entrydate</b>";
	    }
	    else
	    {
		print "$ShowPLEntries_table_entrydate";
	    }
	    print "</a></td>";
	    //column timestamp expires
	    print "<td>";
	    print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowPLshowallOrderby")."=timestamp_expires&".$MyRequestHandler->getNLModuleKeyName("ShowPLoption")."=showall\" title=\"$ShowPLEntries_tooltext_orderby\">";
	    if($MySessionHandler->getNLModuleKeyValue("ShowPLshowallOrderby")=="timestamp_expires")
	    {
		print "<b>$ShowPLEntries_table_expires</b>";
	    }
	    else
	    {
		print "$ShowPLEntries_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("ShowPLshowalldeletelist")."[$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>".$entries[$i]["numberofattempts"]."</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("ShowPLoptiondeleteEntry")."\" value=\"yes\">";
	    print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowPLshowalldeletelistcount")."\" value=\"$i\">";
	    print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowPLshowallStartat")."\" value=\"0\">";
	    print "<input type=\"hidden\" name=\"".$MyRequestHandler->getNLModuleKeyName("ShowPLshowallEndat")."\" value=\"".$MySessionHandler->getNLModuleKeyValue("ShowPLshowallperpage")."\">";
	    print "<input type=\"submit\" value=\"$ShowPLEntries_deleteSelected\"></form>";
	    
	    //next/last
	    //show last:
	    $last_entries=0;
	   if($MySessionHandler->getNLModuleKeyValue("ShowPLshowallStartat") >0)
	   {
		if($MySessionHandler->getNLModuleKeyValue("ShowPLshowallStartat")-$MySessionHandler->getNLModuleKeyValue("ShowPLshowallperpage") >=0)
		{
		    $last_entries=$MySessionHandler->getNLModuleKeyValue("ShowPLshowallperpage");

		}
		else
		{
		    $last_entries=$MySessionHandler->getNLModuleKeyValue("ShowPLshowallStartat");
		}
		print "<a href=\"".$_SERVER["PHP_SELF"]."?".$MyRequestHandler->getNLModuleKeyName("ShowPLshowallStartat")."=";
		print ($MySessionHandler->getNLModuleKeyValue("ShowPLshowallStartat")-$last_entries)."&".$MyRequestHandler->getNLModuleKeyName("ShowPLshowallEndat")."=";
		print ($MySessionHandler->getNLModuleKeyValue("ShowPLshowallStartat"))."&".$MyRequestHandler->getNLModuleKeyName("ShowPLoption")."=showall\">&lt;- $ShowPLEntries_showlast  $last_entries</a>"; 
	   }

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

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