Ip Raiting

themes , модове , проблеми , инсталация
Post Reply
User avatar
Marik
Турист
Турист
Posts: 552
Joined: Fri Oct 13, 2006 4:21 pm
Contact:

Ip Raiting

Post by Marik » Sun May 06, 2007 8:18 pm

Така искам да попитам попринцип всеки регистриран потребител има правото да гласува за една статия по 1 път.

Искам да го направя да речеме да отчита по IP няма значение дали си регнат или не да можеш да гласуваш всеки ден по 1 път за дадената статия.

Възможно ли е и как ще стане тоя номер ?

Admin
Site Admin
Site Admin
Posts: 5
Joined: Thu Jan 01, 1970 12:00 am
Answers: 224

Re: Ip Raiting

Post by Admin » Sun May 06, 2007 9:04 pm

Marik wrote:Така искам да попитам попринцип всеки регистриран потребител има правото да гласува за една статия по 1 път.

Искам да го направя да речеме да отчита по IP няма значение дали си регнат или не да можеш да гласуваш всеки ден по 1 път за дадената статия.

Възможно ли е и как ще стане тоя номер ?


А иначе как е?

User avatar
Marik
Турист
Турист
Posts: 552
Joined: Fri Oct 13, 2006 4:21 pm
Contact:

Re: Ip Raiting

Post by Marik » Mon May 07, 2007 3:23 am

Иначе е само регистрираните имат право да гласуват и то по 1 път.
и после като влезнат в същата статия им за която са гласували им пише

You rated this as Awesome! примерно

Code: Select all

<?php

if &#40;!defined&#40;"IN_FUSION"&#41;&#41; &#123; header&#40;"Location&#58; ../index.php"&#41;; exit; &#125;

include LOCALE.LOCALESET."ratings.php";

function showratings&#40;$rating_type,$rating_item_id,$rating_link&#41; &#123;

	global $locale,$userdata;
	if &#40;iMEMBER&#41; &#123;
		$d_rating = dbarray&#40;dbquery&#40;"SELECT rating_vote,rating_datestamp FROM ".DB_PREFIX."ratings WHERE rating_item_id='".$rating_item_id."' AND rating_type='".$rating_type."' AND rating_user='".$userdata&#91;'user_id'&#93;."'"&#41;&#41;;
		if &#40;isset&#40;$_POST&#91;'post_rating'&#93;&#41;&#41; &#123;
			if &#40;isNum&#40;$_POST&#91;'rating'&#93;&#41; && $_POST&#91;'rating'&#93; > 0 && $_POST&#91;'rating'&#93; < 6 && !isset&#40;$d_rating&#91;'rating_vote'&#93;&#41;&#41; &#123;
				$result = dbquery&#40;"INSERT INTO ".DB_PREFIX."ratings &#40;rating_item_id, rating_type, rating_user, rating_vote, rating_datestamp, rating_ip&#41; VALUES &#40;'$rating_item_id', '$rating_type', '".$userdata&#91;'user_id'&#93;."', '".$_POST&#91;'rating'&#93;."', '".time&#40;&#41;."', '".USER_IP."'&#41;"&#41;;
			&#125;
			redirect&#40;$rating_link&#41;;
		&#125; elseif &#40;isset&#40;$_POST&#91;'remove_rating'&#93;&#41;&#41; &#123;
			$result = dbquery&#40;"DELETE FROM ".DB_PREFIX."ratings WHERE rating_item_id='$rating_item_id' AND rating_type='$rating_type' AND rating_user='".$userdata&#91;'user_id'&#93;."'"&#41;;
			redirect&#40;$rating_link&#41;;
		&#125;
	&#125;
	$ratings = array&#40;5 => $locale&#91;'r120'&#93;, 4 => $locale&#91;'r121'&#93;, 3 => $locale&#91;'r122'&#93;, 2 => $locale&#91;'r123'&#93;, 1 => $locale&#91;'r124'&#93;&#41;;
	tablebreak&#40;&#41;;
	opentable&#40;$locale&#91;'r100'&#93;&#41;;
	if &#40;!iMEMBER&#41; &#123;
		echo "<div align='center'>".$locale&#91;'r104'&#93;."</div>\n";
	&#125; elseif &#40;isset&#40;$d_rating&#91;'rating_vote'&#93;&#41;&#41; &#123;
		echo "<form name='removerating' method='post' action='".$rating_link."'>
<div align='center'>".sprintf&#40;$locale&#91;'r105'&#93;, $ratings&#91;$d_rating&#91;'rating_vote'&#93;&#93;, showdate&#40;"longdate", $d_rating&#91;'rating_datestamp'&#93;&#41;&#41;."<br><br>
<input type='submit' name='remove_rating' value='".$locale&#91;'r102'&#93;."' class='button'></div>
</form>";
	&#125; else &#123;
		echo "<form name='postrating' method='post' action='".$rating_link."'>
<div align='center'>".$locale&#91;'r106'&#93;."&#58; <select name='rating' class='textbox'>
<option value='0'>".$locale&#91;'r107'&#93;."</option>\n";
		foreach&#40;$ratings as $rating=>$rating_info&#41; &#123;
			echo "<option value='".$rating."'>$rating_info</option>\n";
		&#125;
		echo "</select>\n";
		echo "<input type='submit' name='post_rating' value='".$locale&#91;'r103'&#93;."' class='button'>
</form>\n";
	&#125;
	echo "<hr>";
	$tot_votes = dbcount&#40;"&#40;rating_item_id&#41;", "ratings", "rating_item_id='".$rating_item_id."' AND rating_type='".$rating_type."'"&#41;;
	if&#40;$tot_votes&#41;&#123;
		echo "<table align='center' cellpadding='0' cellspacing='1' class='tbl-border'>
<tr>
<td>
<table align='center' cellpadding='0' cellspacing='0'>\n";
		foreach&#40;$ratings as $rating=>$rating_info&#41; &#123;
			$num_votes = dbcount&#40;"&#40;rating_item_id&#41;", "ratings", "rating_item_id='".$rating_item_id."' AND rating_type='".$rating_type."' AND rating_vote='".$rating."'"&#41;;
			$pct_rating = number_format&#40;100 / $tot_votes * $num_votes&#41;;
			if &#40;$num_votes == 0&#41; &#123;
				$votecount = "&#91;".$locale&#91;'r108'&#93;."&#93;";
			&#125; elseif &#40;$num_votes == 1&#41; &#123;
				$votecount = "&#91;1 ".$locale&#91;'r109'&#93;."&#93;";
			&#125; else &#123;
				$votecount = "&#91;".$num_votes." ".$locale&#91;'r110'&#93;."&#93;";
			&#125;
			$class = &#40;$rating % 2==0?"tbl1"&#58;"tbl2"&#41;;
			echo "<tr>
<td class='$class'>$rating_info</td>
<td width='250' class='$class'><img src='".THEME."images/pollbar.gif' alt='$rating_info' height='12' width='".$pct_rating."%' class='poll'></td>
<td class='$class'>".$pct_rating."%</td>
<td class='$class'>$votecount</td>
</tr>\n";
		&#125;
		echo "</td>\n</table>\n</td>\n</tr>\n</table>";
	&#125;else&#123;
		echo "<div align='center'>".$locale&#91;'r101'&#93;."</div>\n";
	&#125;
	closetable&#40;&#41;;
&#125;
?>

User avatar
Marik
Турист
Турист
Posts: 552
Joined: Fri Oct 13, 2006 4:21 pm
Contact:

Re: Ip Raiting

Post by Marik » Mon May 07, 2007 12:20 pm

Някой знаели дали е възможно и какво точно трябва да се промени в кода който пастнах :roll:

tolka
Нов
Нов
Posts: 1
Joined: Sat Jan 31, 2015 9:17 am

Post by tolka » Sat Jan 31, 2015 9:28 am

Мерси много admin, аз
отдавна съм се занимавал с PHP Fusion, знаех че може някъде от менюто, но просто това ми е убягнало....!!!!!!!!!!!!!




____________________

Post Reply