Location: PHPKode > projects > Pimped-Fusion > files/tag.php
<?php
/*---------------------------------------------------------------------------+
| Pimped-Fusion Content Management System
| Copyright (C) 2009 - 2010
| http://www.pimped-fusion.net
+----------------------------------------------------------------------------+
| Filename: tag.php
| Version: Pimped Fusion v0.09.00
+----------------------------------------------------------------------------+
| Authors: slaughter
+----------------------------------------------------------------------------+
| This program is released as free software under the Affero GPL license.
| You can redistribute it and/or modify it under the terms of this license
| which you can read by viewing the included agpl.txt or online
| at www.gnu.org/licenses/agpl.html. Removal of this copyright header is
| strictly prohibited without written permission from the original author(s).
+---------------------------------------------------------------------------*/
require_once "maincore.php";
require_once TEMPLATES."header.php";

$tag = isset($_GET['tag']) ? stripinput($_GET['tag']) : false;
$error = false;

if($tag) {

$result = dbquery("SELECT tag_item_id, tag_type, tag_name FROM ".DB_TAGS." WHERE tag_name LIKE '%".($tag)."%'");
$rows = dbrows($result);

if ($rows) {

opentable("Tag: ".$tag);

while ($data = dbarray($result)) {
	
	
	$tag_a = explode(",", $data['tag_name']);
	$tag_r = "";
	if (is_array($tag_a) && count($tag_a)) {
		foreach ($tag_a as $tag_e) {
		$tag_r .= ($tag_r ? ", " : "").$tag_e;
		}
	} else {
		$tag_r = $tag_a;
	}
	
	
	if($data['tag_type'] == "A") {
	
	$result2 = dbquery(
		"SELECT ta.article_subject, ta.article_article, ta.article_breaks, ta.article_datestamp, ta.article_reads,
		ta.article_keywords, ta.article_allow_comments, ta.article_allow_ratings,
		tac.article_cat_id, tac.article_cat_name, tu.user_id, tu.user_name, tu.user_status
		FROM ".DB_ARTICLES." ta
		INNER JOIN ".DB_ARTICLE_CATS." tac ON ta.article_cat=tac.article_cat_id
		LEFT JOIN ".DB_USERS." tu ON ta.article_name=tu.user_id
		WHERE ".groupaccess('tac.article_cat_access')." AND article_id='".(int)$data['tag_item_id']."' AND article_draft='0'"
	);
	
	if (dbrows($result2)) {
		$data2 = dbarray($result2);
		
		echo " Article Subject: <a href='".make_url("articles.php?article_id=".$data['tag_item_id'], SEO_ARTICLE_A.SEO_ARTICLE_B1.$data['tag_item_id'].SEO_ARTICLE_B2, $data2['article_subject'], SEO_ARTICLE_C)."'>".$data2['article_subject']."</a>";
		echo "<br /> Tags: ".$tag_r."<br />";
		echo "<span class='small'>written by ".profile_link($data2['user_id'],$data2['user_name'],$data2['user_status'])."</span>";
		echo "<br /><br />";
		
	}
	
	} elseif($data['tag_type'] == "N") {
	
	$result2 = dbquery("SELECT tn.news_subject, tn.news_cat, tn.news_image, tn.news_image_t1, tn.news_news, tn.news_extended, tn.news_breaks, 
		tn.news_datestamp, tn.news_reads, tn.news_sticky, tn.news_keywords, tn.news_allow_comments, tn.news_allow_ratings,
		tc.news_cat_id, tc.news_cat_name, tc.news_cat_image, tu.user_id, tu.user_name, tu.user_status
		FROM ".DB_NEWS." tn
		LEFT JOIN ".DB_USERS." tu ON tn.news_name=tu.user_id
		LEFT JOIN ".DB_NEWS_CATS." tc ON tn.news_cat=tc.news_cat_id
		WHERE ".groupaccess('news_visibility')." AND news_id='".(int)$data['tag_item_id']."' AND news_draft='0'");
		
		if (dbrows($result2)) {
		$data2 = dbarray($result2);
		
		echo " News Subject: <a href='".make_url(BASEDIR."news.php?readmore=".$data['tag_item_id'], BASEDIR.SEO_NEWS_A.SEO_NEWS_B1.$data['tag_item_id'].SEO_NEWS_B2, $data2['news_subject'], SEO_NEWS_C)."'>".$data2['news_subject']."</a>";
		echo "<br /> Tags: ".$tag_r."<br />";
		echo "<span class='small'>written by ".profile_link($data2['user_id'],$data2['user_name'],$data2['user_status'])."</span>";
		echo "<br /><br />";
		
		}
		
	} elseif($data['tag_type'] == "C") {
	
	$result2 = dbquery("SELECT page_title, page_access, page_content, page_keywords, page_allow_comments, page_allow_ratings
		FROM ".DB_CUSTOM_PAGES." WHERE ".groupaccess('page_access')." AND page_id='".(int)$data['tag_item_id']."'");
	
		if (dbrows($result2)) {
			$data2 = dbarray($result2);
			echo " Page Subject: <a href='".make_url("viewpage.php?page_id=".$data['tag_item_id'], SEO_PAGE_A.SEO_PAGE_B1.$data['tag_item_id'].SEO_PAGE_B2, $data2['page_title'], SEO_PAGE_C)."'>".$data2['page_title']."</a>";
			echo "<br /> Tags: ".$tag_r."";
		echo "<br /><br />";
		}
	
	
	} elseif($data['tag_type'] == "F") {
	
	
	$result2 = dbquery(
	"SELECT t.thread_id, t.thread_subject, t.thread_lastpost, t.thread_poll, t.thread_sticky, t.thread_locked, t.thread_resolved, t.thread_author,
	f.forum_id, f.forum_cat, f.forum_parent, f.forum_name, f.forum_moderators, f.forum_access,
	f.forum_post, f.forum_reply, f.forum_vote, f.forum_attach, f.forum_markresolved,
	f2.forum_name AS forum_cat_name,
	tu.user_id, tu.user_name, tu.user_status
	FROM ".DB_THREADS." t
	LEFT JOIN ".DB_FORUMS." f ON t.forum_id=f.forum_id
	LEFT JOIN ".DB_FORUMS." f2 ON f.forum_cat=f2.forum_id
	LEFT JOIN ".DB_USERS." tu ON t.thread_author=tu.user_id
	WHERE t.thread_id='".(int)$data['tag_item_id']."' AND t.thread_hidden='0' LIMIT 1
	");
	
		if (dbrows($result2)) {
			$data2 = dbarray($result2);
			if (checkgroup($data2['forum_access']) && $data2['forum_cat']) {
				
			echo " Thread Subject: <a href='".make_url(FORUM."viewthread.php?thread_id=".$data['tag_item_id'], SEO_F_THREAD_A.SEO_F_THREAD_B1.$data['tag_item_id'].SEO_F_THREAD_B2, $data2['thread_subject'], SEO_F_THREAD_C)."'>".$data2['thread_subject']."</a>";
			echo "<br /> Tags: ".$tag_r."<br />";
		echo "<span class='small'>written by ".profile_link($data2['user_id'],$data2['user_name'],$data2['user_status'])."</span>";
		echo "<br /><br />";
				
			}
		}
	
	}
	


}

closetable();

} else { $error = "sorry this tag could not be found: ".$tag; }

} else { $error = "error no tag"; }

if($error) {
opentable("Error");
echo $error;
closetable();
}

require_once TEMPLATES."footer.php";
?>
Return current item: Pimped-Fusion