SessionLogin($_COOKIE['vivvo_session']);
// if found username in users table
if ($user->Id) {
$_SESSION['Logged_In'] = "True";
$user->LoadFromDatebase();
$_SESSION['UserID'] = $user->Id;
$_SESSION['Username'] = $user->Username;
$_SESSION['FullName'] = $user->First_name." ".$user->Last_name;
// to prevent admin login:
$_SESSION['Privilegies']= 'guest'; // instead of: $user->UserTypeName($user->User_type);
$_SESSION['Privile_ctg']= $user->Category_id;
$_SESSION['Email'] = $user->Email_address;
$_SESSION['LastLogin'] = $user->Last_login;
// register login
$user->login_record();
} else {
$_SESSION['Logged_In'] = "";
}
}
if ($frontend_membership == 'Yes'){
if ($_SESSION['Logged_In'] != "True") {
$login_HTML = "Log in - Register now (free)";
} else {
$login_HTML = "Log out | {$_SESSION['Username']} logged in";
}
}else{
$login_HTML = '';
}
//user information
if (isset($_GET['category_name']) && !empty($_GET['category_name'])){
$cat_hold = 0; $category = 0;
$cat_array = explode('/',secure_sql($_GET['category_name']));
for ($i=0; $i''){
$_GET['news']=$cat_array[$i];
//XSS
$text = htmlspecialchars($text);
}
}
if (empty($category)){
Header("Location: {$url}");
}
}
if (!isset($_GET['news'])){
$_GET['category']=$category;
}
}
// Main subject HTML
// category view - int
if (isset($_GET['category']))
{
$cid=(int)($_GET['category']);
$category=new Category();
if ($category->LoadFromDatebase($cid) ===false){
return header("Location: 404.html");
}
// if (!empty($category->Redirect))
// if (substr($category->Redirect,0,5)=="http:") Header("Location: {$category->Redirect}");
// else Header("Location: {$url}{$category->Redirect}");
$category->PostedArticles();
$category->ArticleNumberPerPage();
$template_manager->assign($category->Category_name ,'/{CATEGORY_NAME}/');
//Paginacija
$cur_page = (int) $_REQUEST['pg'];
if (empty($cur_page)) $cur_page=1;
$start_from=($cur_page-1) * $category->ArticleNumberPerPage;
$pg_link=$url."index.php?category=$cid";
if (isset($_GET['sort'])) $pg_link.="&sort=" . $_GET['sort'];
$pg_link.="&pg=";
//Paginacija
$article_list = new Article_list();
$article_list->search(array('a.cid' => $cid, 'a.status' => 1, 'a.created' => $cur_date), $_GET['sort'], 'descending', $category->ArticleNumberPerPage, $start_from);
if ($category->Template != '' && file_exists($root. 'templates/content/summary/' . $category->Template)){
$summary_template = $category->Template;
}else{
$summary_template = "article_short.tpl";
}
if ($category->PostedArticles > 0) {
$category_articles_short_HTML = HTML_article_list(
$article_list,
'content_article_list_no_title.tpl',
array('BOX_TITLE' => $category->Category_name, 'BOX_ID' => 'box_article_list'),
$summary_template,
array('image_width' => $latest_news_image_width, 'word_number' => $latest_news_word_number)
);
$show_pager_HTML=HTML_Show_Pager($cur_page, $pg_link, $article_list->get_total_count(), $start_from, $category->ArticleNumberPerPage);
$template_manager->assign($category_articles_short_HTML,'/{ARTICLE_SHORT}/');
}
$template_manager->assign($show_pager_HTML,'/{PAGINATION}/');
$template_manager->assign($cid,'/{CATEGORY_ID}/');
$template_manager->assign(($show_subcategory_list == '1') ? HTML_subCategory_list() : '', '/{SUBCATEGORY_ARTICLE_LIST}/');
if (($category->PostedArticles)==0 && empty($subcategory_list))
{
$filename="$tpl_folder/category_no_articles.tpl";
$category_articles_short_HTML = file_get_contents($filename);
$template_manager->assign($category_articles_short_HTML,'/{ARTICLE_SHORT}/');
}
if ($category->PostedArticles>1){
$template_manager->assign(Category_Link_Sort(),'/{SORT_BY}/');
}else{
$template_manager->assign('','/{SORT_BY}/');
}
$template_manager->assign('','/{ADITIONAL_RSS}/');
$category->CategoryTemplate();
if ($category->Template<>''){
$index_template="$tpl_folder/".$category->Template;
if (!file_exists($index_template)) $index_template="$tpl_folder/category_Main.tpl";
} else{
$index_template="$tpl_folder/category_Main.tpl";
}
$category->CategoryTemplateHeader();
if ($category->Template_header<>''){
$index_header="$tpl_folder/".$category->Template_header;
if (!file_exists($index_header)) $index_header="$tpl_folder/header.tpl";
}else{
$index_header="$tpl_folder/header.tpl";
}
//***//
$article = new Article();
$int_title = $category->Category_name;
$keywords = $category->Category_name;
$description = $int_title.', '.$title;
$meta_names= '';
// -- end category_view - go to end -- //
}
// view_all - int
elseif (isset($_GET['view_all']))
{
$cur_page = (int) $_REQUEST['pg'];
if (empty($cur_page)) $cur_page = 1;
$results_per_page = 10;
$start_from = ($cur_page - 1) * $results_per_page;
if ($showFriendlyURL == 'yes'){
$link=$url . "all/pg=";
}else {
$link=$url . "index.php?view_all&pg=";
}
$article_list = new Article_list();
$article_list->search(array('a.status' => 1, 'a.created' => $cur_date), $_GET['sort'], 'descending', $results_per_page, $start_from);
$total_results = $article_list->get_total_count();
if ($total_results>0) $show_pager_HTML = HTML_Show_Pager($cur_page, $link, $total_results, $start_from, $results_per_page);
$category_articles_short_HTML = HTML_article_list(
$article_list,
'content_article_list_no_title.tpl',
array('BOX_TITLE' => $category->Category_name, 'BOX_ID' => 'box_article_list'),
'article_short.tpl',
array('image_width' => $latest_news_image_width, 'word_number' => $latest_news_word_number)
);
$template_manager->assign('', '/{SUBCATEGORY_ARTICLE_LIST}/');
$template_manager->assign('', '/{SORT_BY}/');
$template_manager->assign($lang['LNG_ALL_NEWS'], '/{CATEGORY_NAME}/');
$template_manager->assign($category_articles_short_HTML,'/{ARTICLE_SHORT}/');
$template_manager->assign($show_pager_HTML,'/{PAGINATION}/');
$index_template="$tpl_folder/category_Main.tpl";
$index_header="$tpl_folder/header.tpl";
// -- end view_all - go to end -- //
}
// -- calendar view -- //
else if (isset($_REQUEST['month']))
{
$month= (int) ($_REQUEST['month']);
$year= (int) ($_REQUEST['year']);
$day= (int) ($_REQUEST['day']);
$cur_page = (int) $_REQUEST['pg'];
if (empty($cur_page)) $cur_page = 1;
$results_per_page = 10;
$start_from = ($cur_page - 1) * $results_per_page;
$pg_link=$url."index.php?month=$month&day=$day_counter&year=$year";
if (isset($sort_by)) $pg_link.="&sort=$sort";
$pg_link.="&pg=";
$article_list = new Article_list();
$article_list->search(
array('a.status' => 1, 'a.created' => $cur_date, 'day' => $day, 'month' => $month, 'year' => $year),
$_GET['sort'],
'descending',
$results_per_page,
$start_from
);
$total_results = $article_list->get_total_count();
if ($total_results>0) $show_pager_HTML = HTML_Show_Pager($cur_page, $pg_link, $total_results, $start_from, $results_per_page);
// replace month name with month name in language file
if ($day != 0 ){
$Title = $day . ' ';
}else{
$Title = '';
}
$Title = $Title . $lang['LNG_'. strtoupper(substr(date('F',60*60*24*31* ($month - 1) + 3600*24), 0, 3))] . ', ' . $year;
if ($total_results > 0)
{
$category_articles_short_HTML = HTML_article_list(
$article_list,
'content_article_list_no_title.tpl',
array('BOX_TITLE' => $category->Category_name, 'BOX_ID' => 'box_article_list'),
'article_short.tpl',
array('image_width' => $latest_news_image_width, 'word_number' => $latest_news_word_number)
);
$template_manager->assign(Category_Link_Sort(), '/{SORT_BY}/');
$template_manager->assign($category_articles_short_HTML,'/{ARTICLE_SHORT}/');
}else{
$filename="$tpl_folder/category_no_articles.tpl";
$subject=file_get_contents($filename);
$template_manager->assign($subject, '/{ARTICLE_SHORT}/');
$template_manager->assign('', '/{SORT_BY}/');
}
$template_manager->assign($show_pager_HTML,'/{PAGINATION}/');
$template_manager->assign('', '/{SUBCATEGORY_ARTICLE_LIST}/');
$template_manager->assign($Title, '/{CATEGORY_NAME}/');
$index_template="$tpl_folder/category_Main.tpl";
$index_header="$tpl_folder/header.tpl";
// -- end calendar -- //
}
//Feed directory
else if (isset($_GET['feed']))
{
$category_list = new DynamicMenu($connection, $url, 'rss');
$category_list_atom = new DynamicMenu($connection, $url, 'atom');
$filename = "$tpl_folder/feed_view.tpl";
$subject = file_get_contents($filename);
$subject = str_replace('{CATEGORY_FEED_LIST}', $category_list->xml, $subject);
$subject = str_replace('{CATEGORY_FEED_LIST_ATOM}', $category_list_atom->xml, $subject);
$main_subject_HTML = $subject;
}
// Else we print news
//
else if (isset($_GET['news']))
{
if (isset($_GET['CommentAdded'])){
$dump = new dump();
$dump_message_print = $dump->get_dump_message_template(CommentAdded());
//$main_subject_HTML=CommentAdded();
}
if (isset($_POST['add_comments'])){
$dump = new dump();
$dump_message_print = $dump->get_dump_message_template(AddComments());
}
if (isset($_GET['ric'])){
$ric = (int) $_GET['ric'];
$comment_ric = new Comments();
if (($comment_ric->LoadFromDatebase($ric) !== false) && ($show_ric == 'Yes')){
$dump = new dump();
$dump_message_print = $dump->get_dump_message_template($comment_ric->report_inappropriate_content($ric));
}else{
Header("Location: {$url}");
}
}
if (isset($_GET['vote']))
{
$mark=secure_sql($_GET['vote']);
$aid=secure_sql($_GET['aid']);
// CRLF //
$aid = str_replace("\r", "", $aid);
$aid = str_replace("\n", "", $aid);
$article=new Article();
$article->LoadFromDatebase($aid);
$article->AddVote($mark);
}
if (!is_numeric($_GET['news']))
{
//Find id for article
$SEfriendly = secure_sql($_GET['news']);
$id = FindId($SEfriendly);
if (empty($id)) Header("Location: {$url}");
} else {
$id = intval($_GET['news']);
}
$article=new Article();
$article->LoadFromDatebase($id);
$category = new Category();
// private/ public redirection
if ($category->getPrivateStatus($article->Category_id) == 'N' && $_SESSION['Logged_In'] != "True" && $frontend_membership == 'Yes'){
$_SESSION['REQUEST_URI'] = $_SERVER['REQUEST_URI'];
header("Location:{$url}login.php");
}
$article_tools_HTML.= Article_Tools_Email_Print();
// Show comments
if (($article->Show_comment==1) and ($show_comments=='Yes'))
{
$article_tool_comment_HTML.= Article_Tools_Comments();
}
// Show date
$article_date_HTML .= vivvo_date($article->Created,true);
// Show author
$article_author_HTML .= $article->get_author_info();
$Breadcrumb_HTML = HTML_Article_Breadcrumb();
$Caption_Title = $article->Title;
$int_title = $article->Title;
$int_author = $article->Author;
$int_keyword = $article->SEfriendly;
if (!empty($int_keyword)) $int_keyword.=", ";
$int_keyword.= $int_title.", ";
$title_explode = explode (' ', str_replace(',','', $int_title));
$title_explode = array_unique($title_explode);
$title_implode = implode (', ',$title_explode);
$int_keyword.= $title_implode;
$int_ctg = $category->CategoryNameIfExist($article->Category_id);
$keywords = $int_ctg.', '.$int_keyword;
if (!empty($article->Keywords)) $keywords.= ', '.$article->Keywords;
$description = $int_title.', posted by '.$int_author;
if (!empty($article->Description)) $description.= ', '.$article->Description;
else $description = $int_title.', posted by '.$int_author;
$article->RobotsMeta();
$meta_names= '
';
if ($_SESSION['last_read_id'] <> $article->Id)
$article->UpdateReadings();
$_SESSION['last_read_id'] = $article->Id;
switch ($article->Type)
{
case '2':
$link='
'.$lang['LNG_VISIT_WEBSITE'].'';
break;
case '3':
$link='
'.$lang['LNG_READ_DOCUMENT'].'';
break;
default:
$link='';
break;
}
//code for showing attached image if exist
if ($article->Image == "" or !file_exists($root."files/".$article->Image))
{
$article->Image = "spacer.gif";
}
if ($show_related_articles=='Yes'){
$article_list = new Article_list();
$article_list->search(
array('a.status' => 1, 'a.created' => $cur_date, 'related' => $article->Id),
'relevance',
'descending',
10
);
if ($article_list->get_total_count() > 0) {
$article_related_HTML = HTML_article_list(
$article_list,
'box_article_list.tpl',
array('BOX_TITLE' => $lang['LNG_RELATED_NEWS'], 'BOX_ID' => 'box_related'),
'article_title.tpl',
array()
);
}else{
$article_related_HTML = HTML_article_list(
$article_list,
'box_article_list.tpl',
array('BOX_TITLE' => $lang['LNG_RELATED_LINKS'], 'BOX_ID' => 'box_related'),
'article_title.tpl',
array()
);
}
$template_manager->assign($article_related_HTML,'/{ARTICLE_RELATED_NEWS}/');
}else{
$template_manager->assign('','/{ARTICLE_RELATED_NEWS}/');
}
if (isset($_GET['mode']) && $_GET['mode'] == 'print'){
$template_manager->assign('css/print.css','/{CSS}/');
}
$article_pool_HTML=HTML_Show_Poll();
if (($article->Show_comment==1) and ($show_comments=='Yes'))
{
$article_comments=Show_Article_Comments(5);
}
$date=getDate(strtotime($article->Created));
$category->LoadFromDatebase($article->Category_id);
if ($category->Template != '' && file_exists($root. 'templates/content/' . $category->Template)){
$index_template = 'templates/content/' . $category->Template;
}else{
$index_template="$tpl_folder/article_Full.tpl";
}
$index_header=HTML_header($article->Category_id);
// end article
}
else if (isset($_GET['email']))
{
EmailToFriend();
}
else if (isset($_GET['confirm_mail']) and isset($_GET['from'])and isset($_GET['at']))
{
$main_subject_HTML = ConfirmMail(secure_sql($_GET['confirm_mail']),secure_sql($_GET['from']),secure_sql($_GET['at']));
}
else if (isset($_GET['unsubscribe_mail']) and isset($_GET['from'])and isset($_GET['at']))
{
$main_subject_HTML=UnsubscribeMail(secure_sql($_GET['unsubscribe_mail']),secure_sql($_GET['from']),secure_sql($_GET['at']));
}
else if (isset($_GET['comments']))
{
if ($only_registred_user_post_comment == 'Yes'){
if ($_SESSION['Logged_In'] != "True"){
$dump = new dump();
$dump_message_print = $dump->get_dump_message_template($lang['LNG_CANT_POSTED_COMMENTS']);
}else{
$main_subject_HTML = Show_Article_Comments_Form();
}
}else{
$main_subject_HTML = Show_Article_Comments_Form();
}
}
else if (isset($_GET['author']))
{
$main_subject_HTML = Show_Author_Info(secure_sql($_GET['author']));
if ($main_subject_HTML === false){
header("Location: index.php");
}
$secure_author = strip_tags($_GET['author']);
$template_manager->assign('','/{ADITIONAL_RSS}/');
}
else if (isset($_GET['site_map']) and (file_exists("plugins/sitemap/sitemap.php")))
{
include ("plugins/sitemap/sitemap.php");
$main_subject_HTML = Site_Map();
}
else if (isset($_GET['links']) and (file_exists("plugins/links/link_index.php")))
{
include ("plugins/links/link_index.php");
}
else if (isset($_GET['poll']) and (file_exists("plugins/polls/polls.php")))
{
include_once ("plugins/polls/polls.php");
$main_subject_HTML=vote_poll(intval($_GET['poll']),intval($_POST['pollvote']));
}
else if (isset($_GET['all_poll']) and (file_exists("plugins/polls/polls.php")))
{
// include ("plugins/polls/polls.php");
$main_subject_HTML=all_poll();
}
else if (isset($_GET['error']))
{
$dump = new dump();
$main_subject_HTML .= $dump ->get_dump_message_template($lang["LNG_PAGE_NOT_FOUND"]);
}else{
// -- - main form -- //
$category=new Category();
// $featured_news_HTML = HTML_latest_news(1);
$article_list = new Article_list();
$article_list->search(array('a.status' => 1, 'a.created' => $cur_date, 'a.featured_news'=> '0' ), 'order_desc', 'descending', $latest_news_number, 0);
$latest_news_HTML = HTML_article_list(
$article_list,
'content_article_list.tpl',
array('BOX_TITLE' => $latest_news_title, 'BOX_ID' => 'box_article_list'),
'article_short.tpl',
array('image_width' => $latest_news_image_width, 'word_number' => $latest_news_word_number, 'columns' => $frontend_latest_news_columns)
);
$template_manager->assign($latest_news_HTML,'/{LATEST_NEWS}/');
$index_template = "$tpl_folder/index.tpl";
if ($show_featured_news_box == 'Yes'){
if ($featured_news_HTML = HTML_featured_news()){
if (isset($ajax_script) && file_exists($ajax_script)){
$java_scripts = "";
}else{
$java_scripts = "";
}
}
}
}
if (isset($_GET['new_mail'])){
$dump = new dump();
$dump_message_print = $dump->get_dump_message_template(NewMailList(secure_sql($_GET['new_mail'])));
}
if (isset($_POST['mail_article'])){
$dump_mail = new dump();
$dump_message_print = $dump_mail->get_dump_message_template(mail_article($_POST['mail_article_id']));
}
//***************************************************
//***************************************************
//***************************************************
//***************************************************
include('include/header.php');
if (!isset($index_template) or (!file_exists($index_template))){
$filename=$root ."$tpl_folder/framework.tpl";
include('template_scripts/framework.php');
}else{
$filename=$root . $index_template;
include('template_scripts/default.php');
}
//$HTML_output .= $subject;
include('include/footer.php');
$template_manager->set_string_template($HTML_output);
$HTML_output = $template_manager->get_output();
$HTML_output = lang_replace($HTML_output);
echo $HTML_output;
//***************************************************
//***************************************************
//***************************************************
mysql_close($connection);
?>