Код <?php
/*-------------------------------------------------------+
| PHP-Fusion Content Management System
| Copyright (C) 2002 - 2011 Nick Jones
| http://www.php-fusion.co.uk/
+--------------------------------------------------------+
| Name: Thumb Ratings
| Type: Infusion
| File: thumb_ratings_panel.php
| Version: 1.0
| Author and Developer: Ankur Thakur
| Site: http://ankurthakur.in
+--------------------------------------------------------+
| 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 http://www.gnu.org/licenses/agpl.html. Removal of this
| copyright header is strictly prohibited without
| written permission from the original author(s).
+--------------------------------------------------------*/
if (!defined("IN_FUSION")) { die("Access Denied"); }
if (file_exists(INFUSIONS."thumb_ratings_panel/locale/".$settings['locale'].".php")) {
include INFUSIONS."thumb_ratings_panel/locale/".$settings['locale'].".php";
} else {
include INFUSIONS."thumb_ratings_panel/locale/English.php";
}
include INFUSIONS."thumb_ratings_panel/infusion_db.php";
// Fetching Database Settings
$trsettings = array();
$result = dbquery("SELECT * FROM ".DB_SETTINGS_INF." WHERE settings_inf='thumb_ratings_panel'");
if (dbrows($result)) {
while ($data = dbarray($result)) {
$trsettings[$data['settings_name']] = $data['settings_value'];
}
}
add_to_head("<script type='text/javascript' src='".INFUSIONS."thumb_ratings_panel/ajax/rate.js'></script>");
// For Photos
if (FUSION_SELF == 'photogallery.php')
{
if (isset($_GET['photo_id']))
{
if ($trsettings['tr_photo_enabled'] == 1)
{
global $userdata;
$check_user = dbarray(dbquery("SELECT photo_user FROM ".DB_PHOTOS." WHERE photo_id='".stripinput($_GET['photo_id'])."'"),0);
ob_start();
if ($trsettings['tr_photo_position'] == 0)
{ echo "<!--photogallery_photo_desc-->"; }
else { echo "</div>\n<!--sub_photo-->"; }
$to_replace = ob_get_contents();
ob_end_clean();
$to_replace = str_replace("'", "\'", $to_replace);
ob_start();
if (iMEMBER)
{
if ($check_user['photo_user'] == $userdata['user_id'])
{
echo "<br /><span id='thumb_rating' style='font-weight: bold;'>".$trsettings['tr_photo_text']." ";
echo "<img src='".INFUSIONS."thumb_ratings_panel/images/good.png' alt='".$locale['tr_alt_01']."' border='0' /> ".number_format(dbcount("(rating_id)", DB_THUMB_RATINGS, "data_id='".stripinput($_GET['photo_id'])."' AND data_type='P' AND rating_value=1"));
echo " <img src='".INFUSIONS."thumb_ratings_panel/images/bad.png' alt='".$locale['tr_alt_02']."' border='0' /> ".number_format(dbcount("(rating_id)", DB_THUMB_RATINGS, "data_id='".stripinput($_GET['photo_id'])."' AND data_type='P' AND rating_value=2"))."</span>\n";
}
else
{
echo "<br /><span id='thumb_rating' style='font-weight: bold;'>".$trsettings['tr_photo_text']." ";
echo "<span id='buttons_".$_GET['photo_id']."'><a href='javascript:rateup(".stripinput($_GET['photo_id']).",\"P\")'><img src='".INFUSIONS."thumb_ratings_panel/images/good.png' alt='".$locale['tr_alt_01']."' border='0' /></a> ".number_format(dbcount("(rating_id)", DB_THUMB_RATINGS, "data_id='".stripinput($_GET['photo_id'])."' AND data_type='P' AND rating_value=1"));
echo " <a href='javascript:ratedown(".stripinput($_GET['photo_id']).",\"P\")'><img src='".INFUSIONS."thumb_ratings_panel/images/bad.png' alt='".$locale['tr_alt_02']."' border='0' /></a> ".number_format(dbcount("(rating_id)", DB_THUMB_RATINGS, "data_id='".stripinput($_GET['photo_id'])."' AND data_type='P' AND rating_value=2"))."</span></span>\n";
}
}
else if (iGUEST)
{
echo "<br /><span id='thumb_rating' style='font-weight: bold;'>".$trsettings['tr_photo_text']." ";
echo "<img src='".INFUSIONS."thumb_ratings_panel/images/good.png' alt='".$locale['tr_alt_01']."' border='0' /> ".number_format(dbcount("(rating_id)", DB_THUMB_RATINGS, "data_id='".stripinput($_GET['photo_id'])."' AND data_type='P' AND rating_value=1"));
echo " <img src='".INFUSIONS."thumb_ratings_panel/images/bad.png' alt='".$locale['tr_alt_02']."' border='0' /> ".number_format(dbcount("(rating_id)", DB_THUMB_RATINGS, "data_id='".stripinput($_GET['photo_id'])."' AND data_type='P' AND rating_value=2"))."</span>\n";
}
if ($trsettings['tr_photo_position'] == 0)
{ echo "<br /><br /><!--photogallery_photo_desc-->"; }
else { echo "</div>\n<!--sub_photo-->"; }
$replace_with = ob_get_contents();
ob_end_clean();
$replace_with = str_replace("'", "\'", $replace_with);
replace_in_output($to_replace, $replace_with);
}
}
}
// For Articles
if (FUSION_SELF == 'articles.php')
{
if (isset($_GET['article_id']))
{
if ($trsettings['tr_article_enabled'] == 1)
{
global $userdata;
$check_user = dbarray(dbquery("SELECT article_name FROM ".DB_ARTICLES." WHERE article_id='".stripinput($_GET['article_id'])."'"),0);
ob_start();
if ($trsettings['tr_article_position'] == 0)
{ echo "<!--article_poster-->"; }
else { echo "<!--sub_article-->"; }
$to_replace = ob_get_contents();
ob_end_clean();
$to_replace = str_replace("'", "\'", $to_replace);
ob_start();
if ($trsettings['tr_article_position'] != 0)
{ echo "<div align='center' style='border: 2px dashed #ddd; padding: 15px 0px; background-color: #fbf7ec;'>"; }
if (iMEMBER)
{
if ($check_user['article_name'] == $userdata['user_id'])
{
echo "<span id='thumb_rating' style='font-weight: bold;'>".$trsettings['tr_article_text']." ";
echo "<img src='".INFUSIONS."thumb_ratings_panel/images/good.png' alt='".$locale['tr_alt_01']."' align='middle' border='0' /> ".number_format(dbcount("(rating_id)", DB_THUMB_RATINGS, "data_id='".stripinput($_GET['article_id'])."' AND data_type='A' AND rating_value=1"));
echo " <img src='".INFUSIONS."thumb_ratings_panel/images/bad.png' alt='".$locale['tr_alt_02']."' align='middle' border='0' /> ".number_format(dbcount("(rating_id)", DB_THUMB_RATINGS, "data_id='".stripinput($_GET['article_id'])."' AND data_type='A' AND rating_value=2"))."</span>\n";
}
else
{
echo "<span id='thumb_rating' style='font-weight: bold;'>".$trsettings['tr_article_text']." ";
echo "<span id='buttons_".$_GET['article_id']."'><a href='javascript:rateup(".stripinput($_GET['article_id']).",\"A\")'><img src='".INFUSIONS."thumb_ratings_panel/images/good.png' alt='".$locale['tr_alt_01']."' align='middle' border='0' /></a> ".number_format(dbcount("(rating_id)", DB_THUMB_RATINGS, "data_id='".stripinput($_GET['article_id'])."' AND data_type='A' AND rating_value=1"));
echo " <a href='javascript:ratedown(".stripinput($_GET['article_id']).",\"A\")'><img src='".INFUSIONS."thumb_ratings_panel/images/bad.png' alt='".$locale['tr_alt_02']."' align='middle' border='0' /></a> ".number_format(dbcount("(rating_id)", DB_THUMB_RATINGS, "data_id='".stripinput($_GET['article_id'])."' AND data_type='A' AND rating_value=2"))."</span></span>\n";
}
}
else if (iGUEST)
{
echo "<span id='thumb_rating' style='font-weight: bold;'>".$trsettings['tr_article_text']." ";
echo "<img src='".INFUSIONS."thumb_ratings_panel/images/good.png' alt='".$locale['tr_alt_01']."' align='middle' border='0' /> ".number_format(dbcount("(rating_id)", DB_THUMB_RATINGS, "data_id='".stripinput($_GET['article_id'])."' AND data_type='A' AND rating_value=1"));
echo " <img src='".INFUSIONS."thumb_ratings_panel/images/bad.png' alt='".$locale['tr_alt_02']."' align='middle' border='0' /> ".number_format(dbcount("(rating_id)", DB_THUMB_RATINGS, "data_id='".stripinput($_GET['article_id'])."' AND data_type='A' AND rating_value=2"))."</span>\n";
}
if ($trsettings['tr_article_position'] != 0)
{ echo "</div>"; }
if ($trsettings['tr_article_position'] == 0)
{ echo "<!--article_poster-->"; }
else { echo "<!--sub_article-->"; }
$replace_with = ob_get_contents();
ob_end_clean();
$replace_with = str_replace("'", "\'", $replace_with);
replace_in_output($to_replace, $replace_with);
}
}
}
// For News
if (FUSION_SELF == 'news.php')
{
if (isset($_GET['readmore']))
{
if ($trsettings['tr_news_enabled'] == 1)
{
global $userdata;
$check_user = dbarray(dbquery("SELECT news_name FROM ".DB_NEWS." WHERE news_id='".stripinput($_GET['readmore'])."'"),0);
ob_start();
if ($trsettings['tr_news_position'] == 0)
{ echo "<!--news_poster-->"; }
else { echo "<!--news_sub_readmore-->"; }
$to_replace = ob_get_contents();
ob_end_clean();
$to_replace = str_replace("'", "\'", $to_replace);
ob_start();
if ($trsettings['tr_news_position'] != 0)
{ echo "<div align='center' style='border: 2px dashed #ddd; padding: 15px 0px; background-color: #eff9fc;'>"; }
if (iMEMBER)
{
if ($check_user['news_name'] == $userdata['user_id'])
{
echo "<span id='thumb_rating' style='font-weight: bold;'>".$trsettings['tr_news_text']." ";
echo "<img src='".INFUSIONS."thumb_ratings_panel/images/good.png' alt='".$locale['tr_alt_01']."' align='middle' border='0' /> ".number_format(dbcount("(rating_id)", DB_THUMB_RATINGS, "data_id='".stripinput($_GET['readmore'])."' AND data_type='N' AND rating_value=1"));
echo " <img src='".INFUSIONS."thumb_ratings_panel/images/bad.png' alt='".$locale['tr_alt_02']."' align='middle' border='0' /> ".number_format(dbcount("(rating_id)", DB_THUMB_RATINGS, "data_id='".stripinput($_GET['readmore'])."' AND data_type='N' AND rating_value=2"))."</span>\n";
}
else
{
echo "<span id='thumb_rating' style='font-weight: bold;'>".$trsettings['tr_news_text']." ";
echo "<span id='buttons_".$_GET['readmore']."'><a href='javascript:rateup(".stripinput($_GET['readmore']).",\"N\")'><img src='".INFUSIONS."thumb_ratings_panel/images/good.png' alt='".$locale['tr_alt_01']."' align='middle' border='0' /></a> ".number_format(dbcount("(rating_id)", DB_THUMB_RATINGS, "data_id='".stripinput($_GET['readmore'])."' AND data_type='N' AND rating_value=1"));
echo " <a href='javascript:ratedown(".stripinput($_GET['readmore']).",\"N\")'><img src='".INFUSIONS."thumb_ratings_panel/images/bad.png' alt='".$locale['tr_alt_02']."' align='middle' border='0' /></a> ".number_format(dbcount("(rating_id)", DB_THUMB_RATINGS, "data_id='".stripinput($_GET['readmore'])."' AND data_type='N' AND rating_value=2"))."</span></span>\n";
}
}
else if (iGUEST)
{
echo "<span id='thumb_rating' style='font-weight: bold;'>".$trsettings['tr_news_text']." ";
echo "<img src='".INFUSIONS."thumb_ratings_panel/images/good.png' alt='".$locale['tr_alt_01']."' align='middle' border='0' /> ".number_format(dbcount("(rating_id)", DB_THUMB_RATINGS, "data_id='".stripinput($_GET['readmore'])."' AND data_type='N' AND rating_value=1"));
echo " <img src='".INFUSIONS."thumb_ratings_panel/images/bad.png' alt='".$locale['tr_alt_02']."' align='middle' border='0' /> ".number_format(dbcount("(rating_id)", DB_THUMB_RATINGS, "data_id='".stripinput($_GET['readmore'])."' AND data_type='N' AND rating_value=2"))."</span>\n";
}
if ($trsettings['tr_news_position'] != 0)
{ echo "</div>"; }
if ($trsettings['tr_news_position'] == 0)
{ echo "<!--news_poster-->"; }
else { echo "<!--news_sub_readmore-->"; }
$replace_with = ob_get_contents();
ob_end_clean();
$replace_with = str_replace("'", "\'", $replace_with);
replace_in_output($to_replace, $replace_with);
}
}
}
// A Hidden Linkback to Author's Website - This will not be shown in the panel- Please Do not Remove
echo "<div style='display: none;'><a href='http://ankurthakur.in/'>".$locale['ds_authorsite']."</a></div>";
?>