<?php
/**
* PHP versions 4 and 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to hide@address.com so we can mail you a copy immediately.
*
* @package QuickTalk Guestbook
* @author Philippe Vandenberghe <hide@address.com>
* @copyright 2009-2012 The PHP Group
* @version 2.5 build:20100731
*/
session_start();
require_once('bin/qtg_init.php');
// INI
$intId = -1;
$strName = '';
$intAge = '';
$strFrom = '';
$strMail = '';
$strMsg = '';
$strCode = '';
$bCol = $qtg_column_default;
if ( isset($_GET['v']) ) $_SESSION['qtgview']=$_GET['v'];
if ( isset($_GET['page']) ) { $limit = ($_GET['page']-1)*$qtg_page_size; $page=intval($_GET['page']); } else { $limit=0; $page=1; }
if ( isset($_SESSION['qtgview']) ) $bCol = ($_SESSION['qtgview']=='col');
if ( $page<1 ) $page=1;
// Map
if ( !empty($qtg_gkey) )
{
include('qtg_map_lib.php');
include(GetLang().'qtg_map.php');
if ( !$qtg_separateform ) $qtg_separateform=true; // force separate form when map in used
$strBodyAddOnunload='GUnload()';
}
// COUNT TOPICS
$intMessages = 0;
if ( is_a($oDB,'cDT') )
{
$intMessages = $oDB->FilesCount('y'); // this uses GetFiles(), thus $oDT->arrFiles is created!
}
else
{
$oDB->Query( 'SELECT count(id) as countid FROM '.TABMESSAGE.' WHERE id>=0 AND visible="Y"' );
$row = $oDB->Getrow();
$intMessages = intval($row['countid']);
}
$pg_url='qtg_index.php';
// --------
// HTML START
// --------
include('qtg_p_header.php');
// TIPS WELCOME
echo '
<!-- tips -->
<table class="welcome" cellspacing="0">
<tr class="welcome">
<td class="welcome welcome_l">
<div class="welcome">
';
if ( file_exists(GetLang().'qtg_welcome.txt') ) { include(GetLang().'qtg_welcome.txt'); } else { echo $L['Welcome']; }
echo '
</div>
</td>
<td class="welcome welcome_r">
<div class="ctrl">';
if ( $qtg_home<>'' ) echo ' <a href="',$qtg_home,'"><img class="ctrl ctrl_home" alt="H" src="',$qtg_skin,'/img_trans.gif" width="1" height="1" title="',$L['Home'],'"/></a>';
if ( $qtg_column_change ) echo ' <a href="',Href(),'?v=std"><img class="ctrl ctrl_std" alt="H" src="',$qtg_skin,'/img_trans.gif" width="1" height="1" title="',$L['View_std'],'"/></a> <a href="qtg_index.php?v=col"><img class="ctrl ctrl_col" alt="H" src="',$qtg_skin,'/img_trans.gif" width="1" height="1" title="',$L['View_col'],'"/></a>';
echo '</div>
</td>
</tr>
</table>
';
if ( $qtg_actif )
{
if ( $qtg_separateform )
{
echo '<div class="signbutton"><span class="signbutton"><a class="signbutton" href="',Href('qtg_msg_add.php').'">',$L['Sign'.$qtg_type],'</a></span></div>';
}
}
// PAGER
$pager = MakePager(Href(),$intMessages,$qtg_page_size,$page);
if ( $pager!='' )
{
echo '<div class="pager_top">',$L['Page'],$pager,'</div>
';
}
// QUERY
if ( is_a($oDB,'cDT') )
{
// $oDB->GetFiles('y'); GetList is already done by the count
rsort($oDB->arrFiles);
if ( count($oDB->arrFiles)>$qtg_page_size ) $oDB->arrFiles = array_slice($oDB->arrFiles, $limit, $qtg_page_size-1);
$oDB->curFiles=0;
}
else
{
$oDB->Query( LimitSQL($oDB->type,'* FROM '.TABMESSAGE.' WHERE id>=0 AND visible="Y"','issuedate DESC',$limit,$qtg_page_size,$intMessages) );
}
// DISPLAY
if ( $bCol )
{
echo '
<!-- 2 columns start -->
<table class="column" cellspacing="0">
<colgroup span="2"><col style="width:50%"></col><col style="width:50%"></col></colgroup>
<tr class="column"><td class="column">
<!-- 2 columns start -->
';
}
$iCol = 1;
while($row=$oDB->Getrow())
{
$oPost = new cPost($row);
if ( is_a($oDB,'cDT') ) $oPost->id = cPost::Hash($oPost->id);// from here id is only used in url
$id = $oPost->id;
if ( !empty($qtg_gkey) ) {
if ( $oPost->x!=0 && $oPost->y!=0 ) {
$strPname = substr(QTconv($oPost->name,'1'),0,25);
$strPlink = '<a href="http://maps.google.com?q='.$oPost->y.','.$oPost->x.'+('.$strPname.')" class="small" title="'.$L['map']['In_google'].'" target="_blank">[G]</a>';
$strPtxt = QTconv(QTcompact(QTunbbc($oPost->message,true),150,' '),'3').($qtg_use_from && !empty($oPost->postfrom) ? '<br/>'.QTconv($oPost->postfrom,'1') : '');
$strPtxt = str_replace("\r\n"," ",$strPtxt);
$strPtxt = str_replace("\n"," ",$strPtxt);
$oMapPoint = new cMapPoint(floatval($oPost->y),floatval($oPost->x),QTconv($oPost->name,'-3'),'<div class="ginfo"><b>'.QTconv($strPname,'2').'</b><br/>'.$strPtxt.'<br/>'.QTconv(QTdatestr($oPost->issuedate,'$','$',true),'2').' '.$strPlink.'</div>',false);
if ( isset($qtg_gsymbol) ) $oMapPoint->icon = $qtg_gsymbol;
if ( isset($qtg_gshadow) ) $oMapPoint->shadow = $qtg_gshadow;
if ( isset($qtg_gprinticon) ) $oMapPoint->printicon = $qtg_gprinticon;
if ( isset($qtg_gprintshadow) ) $oMapPoint->printshadow = $qtg_gprintshadow;
$arrExtData[$id] = $oMapPoint;
}}
// ------------
include('qtg_msg_inc.php');
// ------------
if ( $_SERVER['REMOTE_ADDR']==$oPost->ip ) {
if ( isset($_SESSION['qtg_beginedit']) && isset($_SESSION['qtg_endedit']) ) {
if ( $oPost->issuedate >= date('YmdHis',$_SESSION['qtg_beginedit']) && $oPost->issuedate < date('YmdHis',$_SESSION['qtg_endedit']) ) {
if ( time()+0 < $_SESSION['qtg_endedit'] )
{
echo ' <a href="',Href('qtg_msg_edit.php'),'?id=',$id,'">[',$L['Edit_my_message'],']</a> <a href="',Href('qtg_msg_del.php'),'?id=',$id,'">[',$L['Delete_my_message'],']</a><br/><br/>';
}
else
{
unset($_SESSION['qtg_endedit']);
unset($_SESSION['qtg_beginedit']);
}
}}}
if ( $bCol )
{
if ( $iCol==1 ) echo '</td><td class="column">',N;
if ( $iCol==2 ) echo '</td></tr><tr class="column"><td class="column">',N;
$iCol++;
if ( $iCol>2 ) $iCol=1;
}
}
// end column layout
$iCol = 1;
if ( $bCol )
{
echo '
<!-- 2 columns end -->
</td>
</tr>
</table>
<!-- 2 columns end -->
';
}
if ( !empty($qtg_gkey) )
{
if ( count($arrExtData)==0 )
{
echo '<div class="gmap_disabled">'.$L['map']['E_noposition'].'</div>';
}
else
{
//select zoomto (maximum 20 items in the list)
if ( count($arrExtData)>1 )
{
$str = '<p class="gmap" style="margin:0 0 4px 0"><a class="gmap" href="javascript:void(0)" onclick="zoomToFullExtend(); return false;">'.$L['map']['zoomtoall'].'</a> | '.$L['map']['jumpto'].' <select class="gmap" id="zoomto" name="zoomto" size="1" onchange="map.setCenter(eval(this.value));">';
$str .= '<option class="small_gmap" value="new GLatLng('.QTgety($qtg_gcenter).','.QTgetx($qtg_gcenter).')"> </option>';
$i=0;
foreach($arrExtData as $oMapPoint)
{
$str .= '<option class="small_gmap" value="new GLatLng('.$oMapPoint->y.','.$oMapPoint->x.')">'.$oMapPoint->title.'</option>';
$i++; if ( $i>20 ) break;
}
$str .= '</select></p>';
}
echo '
<div class="gmap">
',( count($arrExtData)>1 ? $str :'' ),'
<div id="map_canvas" style="width:100%; height:350px;"></div>
<p class="gmap" style="margin:4px 0 0 0">',sprintf($L['map']['items'],strtolower( LangS('Message',count($arrExtData))),strtolower(LangS('Message',$intMessages)) ),'</p>
</div>
';
}
}
if ( $pager!='' )
{
echo '<div class="pager_bot">',$L['Page'],$pager,'</div>
';
}
if ($qtg_checkip)
{
if ( strstr($qtg_checkip_list,($_SERVER['REMOTE_ADDR'])) )
{
echo '<p style="text-align:center">',$L['E_ip_denied'],'</p>';
$qtg_actif=false;
}
}
if ($qtg_actif)
{
if ($qtg_separateform)
{
if ( $intMessages>2 ) echo '<div class="signbutton"><span class="signbutton"><a class="signbutton" href="',Href('qtg_msg_add.php'),'">',$L['Sign'.$qtg_type],'</a></span></div>';
}
else
{
$oPost = new cPost();
$formaction = Href('qtg_msg_add.php');
include('qtg_form_msg.php');
}
}
else
{
echo '<p style="text-align:center">';
if ( file_exists(GetLang().'qtg_stop.txt') ) { include(GetLang().'qtg_stop.txt'); } else { echo 'Guestbook temporary closed. Please wait...'; }
echo '</p>';
}
// --------
// HTML END
// --------
if ( !empty($qtg_gkey) )
{
if ( count($arrExtData)>0 )
{
$y = floatval(QTgety($qtg_gcenter));
$x = floatval(QTgetx($qtg_gcenter));
// center on the first item
foreach($arrExtData as $oMapPoint)
{
if ( !empty($oMapPoint->y) && !empty($oMapPoint->x) )
{
$y=$oMapPoint->y;
$x=$oMapPoint->x;
break;
}
}
$strFooterAddScript = QTgmapscript($qtg_gkey).'
<script type="text/javascript">
<!--
'.QTgmappoints(false,$y,$x,'click',$arrExtData).'
mapload();
-->
</script>
';
}
else
{
$strFooterAddScript = '
<script type="text/javascript">
<!--
function GUnload() { return true; }
-->
</script>
';
}
}
include('qtg_p_footer.php');
?>