get('entryOrder')) { $rows=$DB->getRows('chronological'); } else { $rows=$DB->getRows('reversechronological'); } /* If not using private entry place holders, then remove private entries. */ if(!$options->get('privatePlaceholders')) { $temp=array(); foreach($rows as $row) { if(!$row['private']) { $temp[$row['id']]=$row; } } $rows=$temp; } /* If guestbook empty, then redirect. */ if(!count($rows)) { header('location: '.$options->get('emptyGoTo')); exit(); } $totalEntries=count($rows); $templates=new PYGTEMPLATES(); $entriesPerPage=$options->get('entriesPerPage'); if($options->get('spanPages')&&$totalEntries) { /* Set beginning entry. */ if( isset($_GET['beginningEntry'])&& /* Must be set. */ settype($_GET['beginningEntry'],'integer')&& /* Must be an integer. */ $_GET['beginningEntry']>0&& /* Must be greater than zero. */ $_GET['beginningEntry']<=$totalEntries /* Must be less than or equal to the total number of entries. */ ) { /* Good. Do nothing. */ } else { $_GET['beginningEntry']=1; } /* Set ending entry. */ if( isset($_GET['endingEntry'])&& /* Must be set. */ settype($_GET['endingEntry'],'integer')&& /* Must be an integer. */ $_GET['endingEntry']>0&& /* Must be greater than zero. */ $_GET['endingEntry']>=$_GET['beginningEntry']&& /* Must be greater than or equal to beginning entry. */ $_GET['endingEntry']<=$totalEntries /* Must be less than or equal to the total number of entries. */ ) { /* Good. Do nothing. */ } elseif($_GET['beginningEntry']+$entriesPerPage-1<=$totalEntries) { $_GET['endingEntry']=$_GET['beginningEntry']+$entriesPerPage-1; } else { $_GET['endingEntry']=$totalEntries; } /* Set beginning entry for next page. */ if($_GET['endingEntry']+1>$totalEntries) { $bNextPage=1; } else { $bNextPage=$_GET['endingEntry']+1; } /* Set ending entry for next page. */ if($bNextPage+$entriesPerPage-1>$totalEntries) { $eNextPage=$totalEntries; } else { $eNextPage=$bNextPage+$entriesPerPage-1; } /* Set beginning entry for previous page. */ if($_GET['beginningEntry']==1) { $bPreviousPage=$totalEntries-$entriesPerPage+1; } elseif($_GET['beginningEntry']-$entriesPerPage<1) { $bPreviousPage=1; } else { $bPreviousPage=$_GET['beginningEntry']-$entriesPerPage; } /* Set ending entry for previous page. */ if($_GET['beginningEntry']==1) { $ePreviousPage=$totalEntries; } else { $ePreviousPage=$_GET['beginningEntry']-1; } /* Extract only the rows needed. */ $rows=array_slice($rows,$_GET['beginningEntry']-1,$_GET['endingEntry']-$_GET['beginningEntry']+1); } elseif(!$totalEntries) { $bPreviousPage=$bNextPage=$_GET['beginningEntry']=0; $ePreviousPage=$eNextPage=$_GET['endingEntry']=0; } else { $bPreviousPage=$bNextPage=$_GET['beginningEntry']=1; $ePreviousPage=$eNextPage=$_GET['endingEntry']=$totalEntries; } $counter=0; $entriesHTML=''; foreach($rows as $row) { $fieldNames=$DB->getColumnNames(); /* Handle max word length limit. */ for($i=0;$iget('maxWordLength'),' ')); } $words[$j]=implode("\r\n",$moreWords); } $row[$fieldNames[$i]]=implode(' ',$words); } /* Handle entries containing HTML. */ if(!$options->get('allowHTML')) { foreach($fieldNames as $fieldName) { $row[$fieldName]=pyg_htmlspecialchars($row[$fieldName]); } } /* Handle smilies in comments and reply. */ if($options->get('smiliesEnabled')) { $smilies=new PYGSMILIES(); foreach($smilies->get() as $smiley) { if($smiley['advanced']) { $smileyString=$smiley['advanced']; } else { $smileyString=''; } if($options->get('allowHTML')) { $row['comments']=str_replace($smiley['emoticon'],$smileyString,$row['comments']); $row['reply']=str_replace($smiley['emoticon'],$smileyString,$row['reply']); } else { $row['comments']=str_replace(pyg_htmlspecialchars($smiley['emoticon']),$smileyString,$row['comments']); $row['reply']=str_replace(pyg_htmlspecialchars($smiley['emoticon']),$smileyString,$row['reply']); } } } /* Replace line break with HTML line breaks. */ foreach($fieldNames as $fieldName) { $row[$fieldName]=str_replace("\r\n",'
',$row[$fieldName]); } /* Handle private entry place holders. */ if($options->get('privatePlaceholders')&&$row['private']) { $row['comments']='View private message (Admin only).'; $row['name']= $row['email']= $row['homepage']= $row['location']= $row['ip']= $row['extraField1']= $row['extraField2']= $row['extraField3']= $row['extraField4']= $row['extraField5']='Private'; } /* Check email validity. */ if(strpos($row['email'],'.')===false||strpos($row['email'],'@')===false) { $emailValid=false; } else { $emailValid=true; } /* Link email if valid. */ if($emailValid) { $emailLinked=''.$row['email'].''; } else { $emailLinked=$row['email']; } /* Create email icon if valid. */ if($emailValid) { $emailIcon=''; } else { $emailIcon=''; } /* Check homepage URL validity. */ if(strpos($row['homepage'],'.')===false) { $homepageValid=false; } else { $homepageValid=true; } /* Link homepage if valid. */ if($homepageValid) { $homepageLinked=''.$row['homepage'].''; } else { $homepageLinked=$row['homepage']; } /* Create homepage icons if valid. */ if($homepageValid) { $homepageIcon=''; $homepageIconBlank=''; $homepageIconTop=''; } else { $homepageIcon=''; $homepageIconBlank=''; $homepageIconTop=''; } $entry=$templates->get('viewEntry'); /* Parse tags. */ $timestamp=$row['dateAndTime']; $months=array( $options->get('month1'), $options->get('month2'), $options->get('month3'), $options->get('month4'), $options->get('month5'), $options->get('month6'), $options->get('month7'), $options->get('month8'), $options->get('month9'), $options->get('month10'), $options->get('month11'), $options->get('month12') ); $daysOfWeek=array( $options->get('day1'), $options->get('day2'), $options->get('day3'), $options->get('day4'), $options->get('day5'), $options->get('day6'), $options->get('day7') ); $entry=str_replace('',date('Y',$timestamp),$entry); $entry=str_replace('',date('y',$timestamp),$entry); $entry=str_replace('',date('n',$timestamp),$entry); $entry=str_replace('',date('m',$timestamp),$entry); $entry=str_replace('',$months[date('n',$timestamp)-1],$entry); $entry=str_replace('',date('j',$timestamp),$entry); $entry=str_replace('',date('d',$timestamp),$entry); $entry=str_replace('',$daysOfWeek[date('w',$timestamp)],$entry); $entry=str_replace('',date('g',$timestamp),$entry); $entry=str_replace('',date('h',$timestamp),$entry); $entry=str_replace('',date('G',$timestamp),$entry); $entry=str_replace('',date('H',$timestamp),$entry); $entry=str_replace('',intval(date('i',$timestamp)),$entry); $entry=str_replace('',date('i',$timestamp),$entry); $entry=str_replace('',intval(date('s',$timestamp)),$entry); $entry=str_replace('',date('s',$timestamp),$entry); $entry=str_replace('',date('a',$timestamp),$entry); if($options->get('entryNumbersOrder')) { $entry=str_replace('',$totalEntries-($_GET['beginningEntry']+$counter++)+1,$entry); } else { $entry=str_replace('',$_GET['beginningEntry']+$counter++,$entry); } $entry=str_replace('',$row['name'],$entry); $entry=str_replace('',$row['email'],$entry); $entry=str_replace('',$emailLinked,$entry); $entry=str_replace('',$emailIcon,$entry); if($emailValid) { $entry=str_replace('',string2JavaScript($row['email']),$entry); $entry=str_replace('',string2JavaScript($emailLinked),$entry); $entry=str_replace('',string2JavaScript($emailIcon),$entry); } else { $entry=str_replace('',$row['email'],$entry); $entry=str_replace('',$emailLinked,$entry); $entry=str_replace('','',$entry); } $entry=str_replace('',$row['homepage'],$entry); $entry=str_replace('',$homepageLinked,$entry); $entry=str_replace('',$homepageIcon,$entry); $entry=str_replace('',$homepageIconBlank,$entry); $entry=str_replace('',$homepageIconTop,$entry); $entry=str_replace('',$row['location'],$entry); $entry=str_replace('',$row['comments'],$entry); $entry=str_replace('',$row['ip'],$entry); if($options->get('hostNameByIP')) { $entry=str_replace('',pyg_gethostbyaddr($row['ip']),$entry); } else { $entry=str_replace('','',$entry); } if($row['reply']) { $entry=str_replace('',str_replace('',$row['reply'],$templates->get('reply')),$entry); } else { $entry=str_replace('','',$entry); } $entry=str_replace('',$row['extraField1'],$entry); $entry=str_replace('',$row['extraField2'],$entry); $entry=str_replace('',$row['extraField3'],$entry); $entry=str_replace('',$row['extraField4'],$entry); $entry=str_replace('',$row['extraField5'],$entry); $entry=str_replace('',$row['id'],$entry); /* Make delete URL. */ if($_GET['beginningEntry']==$totalEntries) { $entry=str_replace('','admin.php?action=deleteEntry&status=active&id='.$row['id'].'&from=view&beginningEntry='.$bPreviousPage,$entry); } else { $entry=str_replace('','admin.php?action=deleteEntry&status=active&id='.$row['id'].'&from=view&beginningEntry='.$_GET['beginningEntry'],$entry); } /* Make edit URL. */ $entry=str_replace('','admin.php?display=editEntryForm&status=active&id='.$row['id'].'&from=view&beginningEntry='.$_GET['beginningEntry'],$entry); /* Make reply URL. */ $entry=str_replace('','admin.php?display=replyForm&status=active&id='.$row['id'].'&from=view&beginningEntry='.$_GET['beginningEntry'],$entry); $entriesHTML.=$entry; } $buffer=$templates->get('viewHeader').$entriesHTML.$templates->get('viewFooter'); /* Additional tags to be parsed. Can appear anywhere in HTML. */ if($options->get('entryNumbersOrder')) { $buffer=str_replace('',$totalEntries-$_GET['beginningEntry']+1,$buffer); $buffer=str_replace('',$totalEntries-$_GET['endingEntry']+1,$buffer); } else { $buffer=str_replace('',$_GET['beginningEntry'],$buffer); $buffer=str_replace('',$_GET['endingEntry'],$buffer); } $buffer=str_replace('',$totalEntries,$buffer); $buffer=str_replace('',$bNextPage,$buffer); $buffer=str_replace('',$bPreviousPage,$buffer); $buffer=str_replace('',$eNextPage,$buffer); $buffer=str_replace('',$ePreviousPage,$buffer); $buffer=str_replace('','view.php?beginningEntry='.$bNextPage.'&endingEntry='.$eNextPage,$buffer); $buffer=str_replace('','view.php?beginningEntry='.$bPreviousPage.'&endingEntry='.$ePreviousPage,$buffer); $buffer=str_replace('',GUESTBOOK_NAME,$buffer); $buffer=str_replace('Purple Yin Guestbook Version 1.0.0',GUESTBOOK_NAME,$buffer); $buffer=str_replace('Purple Yin Guestbook Version 1.0.1',GUESTBOOK_NAME,$buffer); print($buffer); ?>