Location: PHPKode > projects > ADbNewsSender > ADbNewsSender_2.0.4/protected/admin/nl/viewPLentries.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_viewPLentries.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"]);
    $ShowNLIDPLoption="Show".$NLID."PLoption";
  
    $ShowNLIDPLoptiondeleteEntry="Show".$NLID."deleteEntry";

  

    if($_REQUEST[$ShowNLIDPLoption] !="search" && $_REQUEST[$ShowNLIDPLoption] !="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"]."?".$ShowNLIDPLoption."=search\">".$ShowPLEntries_menu[0]."</a></li>";
	    print "<li><a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDPLoption."=showall\">".$ShowPLEntries_menu[1]."</a></li>";
	    
	    
	    print "</ul>";
    }

    //search for an entry:
    if($_REQUEST[$ShowNLIDPLoption]=="search")
    {
	$ShowNLIDPLEntrySubmitnow="Show".$NLID."PLSubmitnow";
	$ShowEntryNLIDPL_emailadress="Show".$NLID."PL_emailadress";
	$ShowEntryNLIDPL_deleteID="Show".$NLID."PL_deleteID";
	if($_POST[$ShowNLIDPLoptiondeleteEntry]=="yes")
	{
	    if($MyNL->delete_from_PL($_POST[$ShowEntryNLIDPL_deleteID]))
	    {
		 print preg_replace("/<-ID->/",$_POST[$ShowEntryNLIDPL_deleteID],$ShowPLEntry_deleted)."<br>";
	    }
	    print "<br>";
	    print "<a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDPLoption."=search\">$ShowPLEntry_Searchforanother</a><br>";
	}
	else
	{
	    print "<h2>$ShowPLEntry_search_Title</h2>";
	    if($_POST[$ShowNLIDPLEntrySubmitnow]=="yes")
	    {
		$EntryID=$MyNL->get_PL_entry_id(preg_replace("/ /","",$_POST[$ShowEntryNLIDPL_emailadress]));
		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=\"$ShowNLIDPLoptiondeleteEntry\" value=\"yes\">";
			print "<input type=\"hidden\" name=\"$ShowNLIDPLoption\" value=\"search\">";
			print "<input type=\"hidden\" name=\"$ShowEntryNLIDPL_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"]."?".$ShowNLIDPLoption."=search\">$ShowPLEntry_Searchforanother</a><br>";
	    }
	    else
	    {
		print "<form action=\"".$_SERVER["PHP_SELF"]."\" method=\"post\">";
		print "<input type=\"hidden\" name=\"$ShowNLIDPLEntrySubmitnow\" value=\"yes\">";
		print "<input type=\"hidden\" name=\"$ShowNLIDPLoption\" value=\"search\">";
		print "$ShowPLEntry_Email: <input type=\"text\" name=\"$ShowEntryNLIDPL_emailadress\" value=\"\" size=35>";
		print "<input type=\"submit\" value=\"$ShowPLEntry_search_submit\"></form>";
	    }
	}
	print "<br><br><a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDPLoption."=menu\">$ShowPLEntriesBackToMenu</a>";
    }
    //show entries in a table:
    if($_REQUEST[$ShowNLIDPLoption]=="showall")
    {
	$ShowAllperPageDefault=25;
	$ShowNLIDPLshowalldeletelist="Show".$NLID."PLshowalldeletelist";
	$ShowNLIDPLshowalldeletelistcount="Show".$NLID."PLshowalldeletelistcount";
	if($_POST[$ShowNLIDPLoptiondeleteEntry]=="yes")
	{
	    //delete entries
	    $_SESSION[$ShowNLIDPLshowallStartat]=0;
	  
	    $_SESSION[$ShowNLIDPLshowallEndat]=$_SESSION[$ShowNLIDPLshowallperpage];

	    $i=0;
	    $entryid=0;
	    $deletelist=$_POST[$ShowNLIDPLshowalldeletelist];
	    while($i <intval($_POST[$ShowNLIDPLshowalldeletelistcount]))
	    {
		
		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
	{
	    
	    //preparing:
	    $ShowNLIDPLshowallDirection="Show".$NLID."PLshowallDirection"; //ASC or DESC
	    $ShowNLIDPLshowallOrderby="Show".$NLID."PLshowallOrderby"; //field name (lower case)
	    $ShowNLIDPLshowalllastnext="Show".$NLID."PLshowalllastnext"; //last or next
	    $ShowNLIDPLshowallperpage="Show".$NLID."PLshowallperpage"; //number 1-50
	  
	    $ShowNLIDPLshowallStartat="Show".$NLID."PLshowallStartat";
	     $ShowNLIDPLshowallEndat="Show".$NLID."PLshowallEndat";
	    
	    //setting defaults:
	    if(!isset($_SESSION[$ShowNLIDPLshowallOrderby]))
	    {
		$_SESSION[$ShowNLIDPLshowallOrderby]="id";

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

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

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

	    }
	    if(!isset($_SESSION[$ShowNLIDPLshowallEndat]))
	    {
		$_SESSION[$ShowNLIDPLshowallEndat]=$_SESSION[$ShowNLIDPLshowallperpage];

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

	    }
	    

	    //looking for changes:
	    
	    if($_REQUEST[$ShowNLIDPLshowallDirection])
	    {
		$_SESSION[$ShowNLIDPLshowallDirection]=$_REQUEST[$ShowNLIDPLshowallDirection];
		$_SESSION[$ShowNLIDPLshowallStartat]=0;
		$_SESSION[$ShowNLIDPLshowallEndat]=$_SESSION[$ShowNLIDPLshowallperpage];
	    }
	    if($_REQUEST[$ShowNLIDPLshowallOrderby])
	    {
		$_SESSION[$ShowNLIDPLshowallOrderby]=$_REQUEST[$ShowNLIDPLshowallOrderby];
		$_SESSION[$ShowNLIDPLshowallStartat]=0;
		$_SESSION[$ShowNLIDPLshowallEndat]=$_SESSION[$ShowNLIDPLshowallperpage];
	    }
	    if(isset($_REQUEST[$ShowNLIDPLshowallStartat]))
	    {
		$_SESSION[$ShowNLIDPLshowallStartat]=$_REQUEST[$ShowNLIDPLshowallStartat];
	
		
	    }
	     if($_REQUEST[$ShowNLIDPLshowallEndat])
	    {
		$_SESSION[$ShowNLIDPLshowallEndat]=$_REQUEST[$ShowNLIDPLshowallEndat];
	
		
	    }
	   
	    if($_REQUEST[$ShowNLIDPLshowallperpage])
	    {
		$_SESSION[$ShowNLIDPLshowallperpage]=$_REQUEST[$ShowNLIDPLshowallperpage];
		$_SESSION[$ShowNLIDPLshowallStartat]=0;
		$_SESSION[$ShowNLIDPLshowallEndat]=$_SESSION[$ShowNLIDPLshowallperpage];
	    }

	    $NumberOfEntries=$MyNL->number_of_PL_entries();
	   
	   //fetching PL entries:
	    $entries=array();
	    $offset=$_SESSION[$ShowNLIDPLshowallEndat] -$_SESSION[$ShowNLIDPLshowallStartat];
	    $entries=$MyNL->get_PL_entries($_SESSION[$ShowNLIDPLshowallStartat],$offset,$_SESSION[$ShowNLIDPLshowallOrderby],$_SESSION[$ShowNLIDPLshowallDirection]);					
	  
	    //displaying table:
	    
	    print $ShowPLEntries_table_Title;
	    

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

	     print "<option value=\"DESC\"";
	    if($_SESSION[$ShowNLIDPLshowallDirection]== "DESC")
	    {
		print " selected ";
	    }
	    print ">$ShowPLEntries_order_Desc</option></select>";
	    
	    print "$ShowPLEntries_showperpage: ";
	    print "<select name=\"$ShowNLIDPLshowallperpage\">";
	    
	    $i=1;
	    while($i <= 50)
	    {
		print "<option value=\"$i\"";
		if ($i ==$_SESSION[$ShowNLIDPLshowallperpage])
		{
		    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=\"$ShowNLIDPLoption\" 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"]."?".$ShowNLIDPLshowallOrderby."=id&".$ShowNLIDPLoption."=showall\" title=\"$ShowPLEntries_tooltext_orderby\">";
	    if($_SESSION[$ShowNLIDPLshowallOrderby]=="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"]."?".$ShowNLIDPLshowallOrderby."=email&".$ShowNLIDPLoption."=showall\" title=\"$ShowPLEntries_tooltext_orderby\">";
	    if($_SESSION[$ShowNLIDPLshowallOrderby]=="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"]."?".$ShowNLIDPLshowallOrderby."=ip&".$ShowNLIDPLoption."=showall\" title=\"$ShowPLEntries_tooltext_orderby\">";
	    if($_SESSION[$ShowNLIDPLshowallOrderby]=="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"]."?".$ShowNLIDPLshowallOrderby."=numberofattempts&".$ShowNLIDPLoption."=showall\" title=\"$ShowPLEntries_tooltext_orderby\">";
	    if($_SESSION[$ShowNLIDPLshowallOrderby]=="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"]."?".$ShowNLIDPLshowallOrderby."=timestamp_entry&".$ShowNLIDPLoption."=showall\" title=\"$ShowPLEntries_tooltext_orderby\">";
	    if($_SESSION[$ShowNLIDPLshowallOrderby]=="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"]."?".$ShowNLIDPLshowallOrderby."=timestamp_expires&".$ShowNLIDPLoption."=showall\" title=\"$ShowPLEntries_tooltext_orderby\">";
	    if($_SESSION[$ShowNLIDPLshowallOrderby]=="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=\"".$ShowNLIDPLshowalldeletelist."[$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=\"$ShowNLIDPLoptiondeleteEntry\" value=\"yes\">";
	    print "<input type=\"hidden\" name=\"$ShowNLIDPLshowalldeletelistcount\" value=\"$i\">";
	    print "<input type=\"hidden\" name=\"$ShowNLIDPLshowallStartat\" value=\"0\">";
	    print "<input type=\"hidden\" name=\"$ShowNLIDPLshowallEndat\" value=\"".$_SESSION[$ShowNLIDPLshowallperpage]."\">";
	    print "<input type=\"submit\" value=\"$ShowPLEntries_deleteSelected\"></form>";
	    
	    //next/last
	    //show last:
	    $last_entries=0;
	   if($_SESSION[$ShowNLIDPLshowallStartat] >0)
	   {
		if($_SESSION[$ShowNLIDPLshowallStartat]-$_SESSION[$ShowNLIDPLshowallperpage] >=0)
		{
		    $last_entries=$_SESSION[$ShowNLIDPLshowallperpage];

		}
		else
		{
		    $last_entries=$_SESSION[$ShowNLIDPLshowallStartat];
		}
		print "<a href=\"".$_SERVER["PHP_SELF"]."?".$ShowNLIDPLshowallStartat."=";
		print ($_SESSION[$ShowNLIDPLshowallStartat]-$last_entries)."&".$ShowNLIDPLshowallEndat."=";
		print ($_SESSION[$ShowNLIDPLshowallStartat])."&".$ShowNLIDPLoption."=showall\">&lt;- $ShowPLEntries_showlast  $last_entries</a>"; 
	   }

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

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