#################################################
# xLinks 2002 #
#################################################
# © by Robert Klikics | http://x-dev.de #
# eMail: rob@x-dev.de #
#################################################
# License: GPL #
# please don't remove this copyright - thx #
#################################################
# FILE: view.php #
#################################################
// die if !$cat
if(!$cat) die("
Script says: \"I need a category to show!!!\" ");
#======================================================================#
# the includes & mySQL-conn
#======================================================================#
require("./inc/conf.inc.php"); // cfg
require("./inc/connect.php"); // mySQL
require("./lang/$language"); // language-file
include("./inc/head.inc"); // header
//set table-vars
$table_linkdata = $db_prefix."linkdata";
$table_cat = $db_prefix."cat";
$table_votes = $db_prefix."votes";
$table_languages = $db_prefix."languages";
//Connect to mySQL
$conn = @MYSQL_CONNECT($server, $user, $pass);
//Select DB
@MYSQL_SELECT_DB($mydb) or die ("Database '$mydb' does not exist or mySQL is not connected!
Please check your settings ...");
//Check
if(!$conn) die("
mySQL-Connection-Error
Check your settings ...
");
#======================================================================#
# add vote to db & check if already voted
#======================================================================#
if($yourvote)
{
//save vote in db
$sql = "INSERT INTO $table_votes (vote, link_id, cat)";
$sql.= "VALUES ('$yourvote', '$id', '$cat')";
MYSQL_QUERY($sql);
//vote counter +1
MYSQL_QUERY("UPDATE $table_linkdata SET hp_votes = hp_votes + 1 WHERE id = $id");
// generate actual vote-count and put into "LINKDATA-->hp_votes"
$result = MYSQL_QUERY("SELECT vote FROM $table_votes WHERE link_id = $id");
$anzahl = MYSQL_NUM_ROWS($result);
while ($row = MYSQL_FETCH_ARRAY($result)) { $allvotes = $allvotes + $row[vote]; } // summary of votes for an id
if($anzahl == 1) $allvotes = $yourvote; // set $allvotes to 1, if it's the first one
$av_votes = round($allvotes / $anzahl, 1); // get & round the average-votes
// put $av_votes to db
MYSQL_QUERY("UPDATE $table_linkdata SET hp_vote = $av_votes WHERE id = $id");
// show auto-link if vote added
echo <<
|
end_xx;
echo "\n".VIEW_VOTE_AUTOLINK."\n";
echo " [ link ]";
echo <<
|