include('login/auth.php'); ?>
#################################################
# podblogger 0.5 #
# by Christian Rotzoll #
# co author Hagen Tönnies #
# #
# christian.rotzoll@medien.uni-weimar.de #
# Doku unter http://www.rotzoll.de/podblogger #
# #
#################################################
# index.php #
#################################################
##############################################################################
# this page builds the html main page of the podbloggersystem
# it rehash all relevant data an send it to the SMARTY-TEMPLATE-ENGINE
# which builds the specified Layout defined by the user.
#
# changes can be made in the following file 'std_index.tpl'
# Path := 'htmlContent/smarty_templates'
##############################################################################
/**
* Files that have to be included
*
* require_once ("include/funktions_sammlung.inc.php");
* require_once ("include/article.class.php");
* require_once ("include/layout.class.php");
* require_once ('include/smarty/Smarty.class.php');
* require_once ('include/bbcode.inc.php');
*
* HINT: "include/funktions_sammlung.inc.php" includes the "include/load_config.inc.php". In this file
* the system will check if a configuration is already set or not. If there is no "config.txt" in the
* directory "podbloggerData" then it will redirect to the "installcheck.php" to make a initial setting
* of configuration values. So on the first call of "index.php" the "INSTALLCHECK" will start automatically,
* because the podblogger is shipped withot a "config.txt" in the beginning.
*
*/
require_once ("include/funktions_sammlung.inc.php");
require_once ("include/article.class.php");
require_once ("include/layout.class.php");
require_once ('include/smarty/Smarty.class.php');
require_once ('include/bbcode.inc.php');
function specialCharactersToHTML($text)
{
$text = str_replace('Ä',"Ä",$text);
$text = str_replace('ä',"ä",$text);
$text = str_replace('Ü',"Ü",$text);
$text = str_replace('ü',"ü",$text);
$text = str_replace('Ö',"Ö",$text);
$text = str_replace('ö',"ö",$text);
$text = str_replace('"',""",$text);
$text = str_replace('ß',"ß",$text);
return $text;
}
// check if the Podbloggersystem is still runable after install or update
if ($PODBLOGGER_STATUS != "READY")
{
// Print out that the Podbloggersystem is just under construction.
print "
".
"Die Seite wird gerade vom Administrator überarbeitet. ".
"Bitte probieren Sie es zu einem späteren Zeitpunkt erneut. ".
"DANKE für Ihr Verständnis.
";
exit();
}
session_start();
//echo "der username ist hier: ".$_SESSION['username'];
// get Parameter 'cat' from site via URL
if (issetPostGet('cat')) {$cat = getPostGetText('cat');}
// get Parameter 'includehost' from site via URL
// includehost is the host wich includes the Podbloggersystem e.g.(www.radiostudio.org)
if (issetPostGet('includehost'))
{
$includehost=getPostGetText('includehost');
$hostHTTP = array_shift(explode("?",$includehost,2));
if (strpos($includehost,"?")>0) {$includehost.="&includehost=".urlencode($includehost);}
else {$includehost.="?includehost=".urlencode($includehost);}
// Overwriting UserIP
if ( isset($INCLUDEHOST_IPS) )
{
$ipArray = explode(';',$INCLUDEHOST_IPS);
if (!in_array($_SERVER['REMOTE_ADDR'],$ipArray))
{ print "Sorry. Your Server is not allowed to inlcude Data from this podblogger system.\n The ADMIN need to add the IP to the manSetting.txt (INCLUDEHOST_IPS === ".$_SERVER['REMOTE_ADDR'].")"; exit(); }
else
{
// check for override
if (issetPostGet('REMOTE_ADDR'))
{ $_SERVER['REMOTE_ADDR'] = getPostGetText('REMOTE_ADDR'); }
}
}
}
else
{
$hostHTTP = "";
$includehost = "";
}
// for permalink view
if (issetPostGet('permalink')) {$permalink = getPostGetText('permalink');}
else {$permalink = FALSE;}
// if commententry
if (issetPostGet('commenttext'))
{
$commenttext = getPostGetText('commenttext');
$commentname = getPostGetText('commentname');
$commentmail = getPostGetText('commentmail');
$randomcode = getPostGetInt('randomcode');
$commenttext = chop(@strip_tags($commenttext));
$commentname = chop(@strip_tags($commentname));
$commentmail = chop(@strip_tags($commentmail));
}
else {$commenttext = "";}
// get Parameter 'weiterbei' from site via URL
// browsing thru the contributions
if (issetPostGet('weiterbei')) {$weiterbei = getPostGetInt('weiterbei');}
else {$weiterbei = 1;}
// instancing SMARTY Template dataobjekt
$smarty = new Smarty;
$smarty->template_dir = LAYOUTDIR;
$smarty->compile_dir = SMARTYPATH_COMPILE;
$smarty->config_dir = SMARTYPATH_CONFIG;
$smarty->cache_dir = SMARTYPATH_CACHE;
// check if a searchword is given
if (issetPostGet('search'))
{
$search = getPostGetText('search');
$smarty->assign('PODCAST_searchword',$search);
}
//changing german special characters for each category
foreach($PODCAST_KATEGORIEN as $kat)
{
$kat=htmlspecialchars($kat);
}
//assign the SMARTY Template dataobjekt with config data values
$smarty->assign('PODCAST_sitename',$PODCAST_NAME);
$smarty->assign('PODCAST_admin_name',$ADMIN_NAME);
$smarty->assign('PODCAST_admin_mail',$ADMIN_EMAIL);
$smarty->assign('PODCAST_httpbaseadress',"http://".HTTP_BASISADRESSE);
$smarty->assign('PODCAST_kategorien_array',$PODCAST_KATEGORIEN);
$smarty->assign('PODCAST_category_array',$PODCAST_KATEGORIEN);
if (isset($cat))
{
$smarty->assign('PODCAST_category',$cat);
}
else
{
$smarty->assign('PODCAST_category',"");
}
if (strlen("http://".HTTP_BASISADRESSE."rss.php") < 50)
{
$smarty->assign('PODCAST_rssfeedtextadress',"http://".HTTP_BASISADRESSE."rss.php");
}
else
{
$smarty->assign('PODCAST_rssfeedtextadress',"");
}
$smarty->assign('podblogger_version',$PODBLOGGER_VERSION);
// writing headerinformation to determine caching
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
if (!$permalink)
{
//searching for all avalible article files
$articles = getFilesFromDirWithEnding("publicData","article");
}
else
{
$articles = array();
// checks if article exists
if (file_exists("publicData/".$permalink.".article"))
{
// just this ONE artcle to show
array_push($articles,$permalink.".article");
// sercurity code for comment entry from
session_start();
if (!isset($_SESSION['randomcode']))
{ $_SESSION['randomcode'] = rand(1000,9999); }
}
else
{
$permalink = FALSE;
}
}
//building associative array with UnixTime as key
$keyArray = array();
foreach ($articles as $articleFile)
{
$artikel = article::loadArticleFromFile("publicData/".$articleFile);
// maybe check fileaccess rights
$article_access = "FULLACCESS";
if ( (isset($GLOBALS['RESTRICTED_ACCESS'])) && ($GLOBALS['RESTRICTED_ACCESS']=="YES") )
{
$fileaccess = $artikel->getRightsData('fileaccess');
if ($fileaccess=="NOT_PUBLISHED") { $article_access="READONLY"; /*continue;*/ } // dont use this item in index.php
elseif ($fileaccess=="RESTRICTED_ACCESS")
{
// include user defined function to test access rights
if (!file_exists("podbloggerData/mod_include/security.inc.php")) { continue; }
include_once("podbloggerData/mod_include/security.inc.php");
if (!function_exists("is_valid_access_article")) { continue; }
// check if user got is allowed to view item
$article_access = is_valid_access_article($artikel->getID());
if ($article_access == 0) { continue; } // user is not allowed, continue with next item
if ($article_access == 1) { $article_access="READONLY"; }
// check if INTERNAL_ARCHIVE_MODE in on (READONLY just allowed on serach)
// if ( (isset($GLOBALS['INTERNAL_ARCHIVE_MODE'])) && ($GLOBALS['INTERNAL_ARCHIVE_MODE']=="ON") && (!isset($search)) && ($article_access=="READONLY") ) { continue; }
}
}
$artikel->setRightsData('accessmode',$article_access);
if (($artikel!=FALSE) && ($artikel->checkValid()))
{
// only match contributions to a category wich not start with !
$kat = $artikel->getCategory();
if ($kat[0] != '!')
{
$unixtime = $artikel->getUnixTime();
// The following is just a quick tweak to define intro-items
// everything item that date is in the year 1970 should
// be shown on the top of the list
if ($unixtime<32000000) { $unixtime=9999999999; }
if ((!isset($cat)) && (!isset($search)))
{
// a intro item should only be visible in subcategories
if ($unixtime!=9999999999) $keyArray[$unixtime] = $artikel;
}
else
{
// category filter
if (isset($cat))
{
if ($artikel->getCategory() == $cat)
{
$keyArray[$unixtime] = $artikel;
}
}
// searchword filter
elseif (isset($search))
{
if ($artikel->matchesSearchString($search))
{
$keyArray[$unixtime] = $artikel;
}
}
}
}
}
}
uksort($keyArray,"cmp");
reset($keyArray);
$output_beitraege = array();
if (count($keyArray) > ($weiterbei-1))
{
$ccount=1;
foreach ($keyArray as $artikel)
{
$mp3Beitrag = array();
if ( ( file_exists("publicData/".$artikel->getFile()) ) && ($ccount >= $weiterbei) && ($ccount < ($weiterbei+$DATEIEN_PRO_SEITE)) )
{
$mp3Beitrag['titel'] = specialCharactersToHTML(sonderzeichenRueckkodierung($artikel->getTitle()));
$mp3Beitrag['kategorie'] = specialCharactersToHTML(sonderzeichenRueckkodierung($artikel->getCategory()));
$mp3Beitrag['beschreibung'] = bbcode_inc::renderBBCode(sonderzeichenRueckkodierung($artikel->getDescription()));
$mp3Beitrag['autor_name'] = specialCharactersToHTML(sonderzeichenRueckkodierung($artikel->getAuthorName()));
$mp3Beitrag['autor_mail'] = specialCharactersToHTML(sonderzeichenRueckkodierung($artikel->getAuthorMail()));
$mp3Beitrag['zeit'] = date("d.m.y",$artikel->getUnixTime());
$mp3Beitrag['date'] = date("y-m-d",$artikel->getUnixTime());
$mp3Beitrag['zeit_int'] = $artikel->getUnixTime();
$mp3Beitrag['id'] = $artikel->getID();
$mp3Beitrag['article_access'] = $artikel->getRightsData('accessmode');
$mp3Beitrag['file_access'] = $artikel->getRightsData('fileaccess');
// make extendeddata available
$keys = "";
foreach ($artikel->getExtendedData() as $key=>$value)
{
$key = strtolower(sonderzeichenWandeln($key));
$key = str_replace(' ',"_",$key);
$mp3Beitrag[$key] = specialCharactersToHTML($value);
$keys .= ", ".$key;
}
$keys = substr($keys, 2);
// xtraFieldKeys contains all available xtraField keys on this item
$mp3Beitrag['xtraFieldKeys'] = $keys;
// check if Comments (textcomments, trackbacks ,..) existing for the article
if ($GLOBALS['TEXTCOMMENTS']!="AUS")
{
$mp3Beitrag['textcomments'] = $artikel->gotComments("TEXTCOMMENT");
}
else
{
$mp3Beitrag['textcomments'] = 0;
}
if ($GLOBALS['TRACKBACKS']!="AUS")
{
$mp3Beitrag['trackbacks'] = $artikel->gotComments("TRACKBACK");
}
else
{
$mp3Beitrag['trackbacks'] = 0;
}
// contributions with Unixtime from 1970 starting contributions
if ($artikel->getUnixTime()<32000000)
{
$mp3Beitrag['zeit'] = "";
$mp3Beitrag['kategorie'] = "Intro";
}
// maybe statistik for Mp3 requests thru the getMedia.php
if ($PODCAST_MP3_STATS == "JA")
{
$mp3Beitrag['link'] = "http://".HTTP_BASISADRESSE."getMedia.php?from=BROWSER&file=publicData/".$artikel->getFile();
$playerLink = "publicData/".$artikel->getFile();
}
else
{
$mp3Beitrag['link'] = "http://".HTTP_BASISADRESSE."publicData/".$artikel->getFile();
$playerLink = "publicData/".$artikel->getFile();
}
// if there are more than one file available ...
$audiofiles = array();
foreach ($artikel->getAvailableFormats() as $format)
{
if (isset($artikel->alternative_files[$format]['NORM']))
{
$fname = $artikel->alternative_files[$format]['NORM'];
$flink="";
if ($mp3Beitrag['article_access']!="READONLY")
{
if ($PODCAST_MP3_STATS == "JA")
{$flink = "http://".HTTP_BASISADRESSE."getMedia.php?from=BROWSER&file=publicData/".$artikel->getFile();}
else
{$flink = "http://".HTTP_BASISADRESSE."publicData/".$artikel->getFile();}
}
array_push($audiofiles, array('format' => strtoupper($format), 'filename' => $fname, 'link' => $flink));
}
}
if (count($audiofiles)==0) {array_push($audiofiles, array('format' => "MP3", 'filename' => $artikel->getFile(), 'link' => $mp3Beitrag['link'])); }
$mp3Beitrag['audiofiles'] = $audiofiles;
if ($PODCAST_MP3FLASHPLAYER == "JA")
{
if (strtoupper(getDateiEndung($artikel->getFile()))=="MP3")
{
$mp3Beitrag['audioplayer_code'] = '
';
}
elseif (strtoupper(getDateiEndung($artikel->getFile()))=="MOV")
{
$mp3Beitrag['audioplayer_code'] = '
';
}
else
{
$mp3Beitrag['audioplayer_code'] = '
';
}
}
else
{
$mp3Beitrag['audioplayer_code'] = '
';
}
// Destroy Playercode and Downloadlink if article access is just READONLY
if ($artikel->getRightsData('accessmode')=="READONLY")
{
$mp3Beitrag['audioplayer_code'] = "";
$mp3Beitrag['link'] = "";
}
$size = round(filesize("publicData/".$artikel->getFile()) / 1048576);
if ($size == 0) {$size = 1;}
$mp3Beitrag['dateigroesse'] = $size;
array_push($output_beitraege,$mp3Beitrag);
}
$ccount++;
}
$smarty->assign('PODCAST_item_count',$ccount);
$smarty->assign('PODCAST_item_array',$output_beitraege);
// Zusätzliche Parameter, wenn ein Artikel in der Einzelansicht angezeigt wird
if ($permalink)
{
// Artikel laden, der in der Einzelnansicht angezeigt wird
$artikel = article::loadArticleFromFile("publicData/".$permalink.".article");
// ggf. Kommentareintrag entgegen nehmen
if (($commenttext!="") && ($GLOBALS['TEXTCOMMENTS']=="AN"))
{
if ($randomcode==$_SESSION['randomcode'])
{
if (!$commentname=="")
{
// Kommentar auf Artikel eintragen
$newcomment = new textcomment($commentname, $commenttext);
$newcomment->setAuthorMail($commentmail);
if ($artikel->addComment($newcomment))
{
$artikel->save("publicData");
$smarty->assign('PODCAST_commentfeedback',get_lang('index_commentOK'));
// ggf. eMail mit QuickDeleteCode an ADMIN versenden
if ($GLOBALS['ADMIN_EMAILNOTIFICATION']=="JA")
{
$aname = $artikel->getTitle();
$validdate = date("D d.m.Y - H:i",(time()+3*24*60*60));
$linktoadmin = "http://".HTTP_BASISADRESSE."admin.php";
$quickdeletelink = $linktoadmin."?aktion=commentQuickDelete&articleID=".$artikel->getID()."&commentID=".$newcomment->getPublishedUnixtime()."&quickDeleteCode=".$newcomment->getQuickdeleteCode();
$mailtext = get_lang('admin_quickdelete_mailtext1',$GLOBALS['PODCAST_NAME'],$aname,$commentname,$commentmail,$commenttext,$validdate,$quickdeletelink, $linktoadmin);
require_once("include/mail_wrapper.class.php");
mail_wrapper::sendmail($GLOBALS['ADMIN_EMAIL'], '[podblogger-mail] '.get_lang('admin_quickdelete_subject1'), $mailtext);
}
}
else
{
$smarty->assign('PODCAST_commentfeedback',get_lang('index_commentERROR'));
}
}
else
{
// Name fehlt
$smarty->assign('PODCAST_commentfeedback',get_lang('index_noName'));
}
}
else
{
$smarty->assign('PODCAST_commentfeedback',"");
}
// Neuen Randomcode setzten
$_SESSION['randomcode']=rand(1000,9999);
}
else
{
$smarty->assign('PODCAST_commentfeedback','');
}
$smarty->assign('PODCAST_isSingleArticleView','TRUE');
$smarty->assign('PODCAST_articleID',$permalink);
$smarty->assign('PODCAST_randomcode',$_SESSION['randomcode']);
if ($GLOBALS['TEXTCOMMENTS']=="AN")
{
$smarty->assign('PODCAST_showComments' ,"TRUE");
$smarty->assign('PODCAST_writeComments',"TRUE");
}
elseif ($GLOBALS['TEXTCOMMENTS']=="NURANZEIGEN")
{
$smarty->assign('PODCAST_showComments' ,"TRUE");
$smarty->assign('PODCAST_writeComments',"FALSE");
}
else // $GLOBALS['TEXTCOMMENTS']=="AUS"
{
$smarty->assign('PODCAST_showComments' ,"FALSE");
$smarty->assign('PODCAST_writeComments',"FALSE");
}
if ($GLOBALS['TRACKBACKS']=="AN")
{
$smarty->assign('PODCAST_showTrackbacks' ,"TRUE");
$smarty->assign('PODCAST_writeTrackbacks',"TRUE");
}
elseif ($GLOBALS['TRACKBACKS']=="NURANZEIGEN")
{
$smarty->assign('PODCAST_showTrackbacks' ,"TRUE");
$smarty->assign('PODCAST_writeTrackbacks',"FALSE");
}
else // $GLOBALS['TRACKBACKS']=="AUS"
{
$smarty->assign('PODCAST_showTrackbacks' ,"FALSE");
$smarty->assign('PODCAST_writeTrackbacks',"FALSE");
}
// Textkommentardaten für Einzelansicht bereitstellen
if ( ($GLOBALS['TEXTCOMMENTS']!="AUS") && ($artikel->gotComments("TEXTCOMMENT")))
{
$textcomments = array();
$smarty->assign('PODCAST_textcomment_count',$artikel->gotComments("TEXTCOMMENT"));
foreach ($artikel->getComments("TEXTCOMMENT") as $comment)
{
$commentdata = array();
$commentdata['date'] = date("d.m.y",$comment->getPublishedUnixtime());
$commentdata['date_english'] = date("Y-m-d / h:m",$comment->getPublishedUnixtime());
$commentdata['authorname'] = htmlspecialchars($comment->getAuthorName());
$commentdata['authormail'] = htmlspecialchars($comment->getAuthorMail());
$commentdata['text'] = htmlspecialchars($comment->getCommenttext());
array_push($textcomments, $commentdata);
}
$smarty->assign('PODCAST_textcomment_array',$textcomments);
}
// Trackbackdaten für Einzelansicht bereitstellen
if ( ($GLOBALS['TRACKBACKS']!="AUS") && ($artikel->gotComments("TRACKBACK")))
{
$trackbacks = array();
$smarty->assign('PODCAST_trackback_count',$artikel->gotComments("TRACKBACK"));
foreach ($artikel->getComments("TRACKBACK") as $comment)
{
$commentdata = array();
$commentdata['date'] = date("d.m.y",$comment->getPublishedUnixtime());
$commentdata['url'] = htmlspecialchars($comment->getURL());
$commentdata['blogname'] = htmlspecialchars($comment->getBlogname());
$commentdata['title'] = htmlspecialchars($comment->getTitle());
$commentdata['excerpt'] = htmlspecialchars($comment->getExcerpt());
array_push($trackbacks, $commentdata);
}
$smarty->assign('PODCAST_trackback_array',$trackbacks);
}
}
else
{
$smarty->assign('PODCAST_isSingleArticleView','FALSE');
}
// forward cat-filter or search-filter values if activated
$filter = "";
if (isset($search)) {$filter .= "&search=".urlencode($search);}
if (isset($cat)) {$filter .= "&cat=".urlencode($cat);}
if ( $weiterbei > $DATEIEN_PRO_SEITE )
{ if ($includehost=="") { $smarty->assign('PODCAST_backlink','index.php?weiterbei='.($weiterbei-$DATEIEN_PRO_SEITE).$filter);}
else { $smarty->assign('PODCAST_backlink',$includehost.'&weiterbei='.($weiterbei-$DATEIEN_PRO_SEITE).$filter);}
}
else
{
$smarty->assign('PODCAST_backlink','off');
}
if ( count($keyArray) >= ($weiterbei+$DATEIEN_PRO_SEITE) )
{
if ($includehost=="") { $smarty->assign('PODCAST_forwardlink','index.php?weiterbei='.($weiterbei+$DATEIEN_PRO_SEITE)); }
else { $smarty->assign('PODCAST_forwardlink',$includehost.'&weiterbei='.($weiterbei+$DATEIEN_PRO_SEITE)); }
}
else
{
$smarty->assign('PODCAST_forwardlink','off');
}
}
else
{
$smarty->assign('PODCAST_item_count',0);
$smarty->assign('PODCAST_backlink','off');
$smarty->assign('PODCAST_forwardlink','off');
}
$smarty->assign('PODCAST_includehost',$includehost);
$smarty->assign('PODCAST_hostHTTP',$hostHTTP);
$smarty->assign('PODCAST_serverHTTP',"http://".HTTP_BASISADRESSE);
//load Layout data arrays
$o_layout = layout::loadLayoutFromPluginDir($LAYOUT_ID);
if (is_object($o_layout))
{
$defs = $o_layout->getDefinitionArray();
//exit(serialize($defs));
foreach ($defs as $def)
{
if (isset($def['value'])) { $smarty->assign($def['smartyname'],$def['value']); }
else { $smarty->assign($def['smartyname'],""); }
}
}
else
{
die("Could not load Layout. Go to admin-site and change to a valid layout.");
}
// set publicupload like it is set in the ADMIN menu
$smarty->assign("publicupload",$JUST_ADMIN_UPLOAD);
// let SMARTY print the page (layout-index-site)
$smarty->display($LAYOUT_ID.'/index.tpl');
?>