Dies ist der Quellcode:
Code
<? include('includes/first.php'); ?>
<td bgcolor="#FFFFFF" width="550" style="border:1px solid #000000;" align="center" valign="top">
<?
#################################################
# xLinks 2002 #
#################################################
# © by Robert Klikics | http://x-dev.de #
# eMail: [email]rob@x-dev.de[/email] #
#################################################
# License: GPL #
# please don't remove this copyright - thx #
#################################################
# FILE: view.php #
#################################################
// die if !$cat
if(!$cat) die("<h4>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 ("<h1>Database '$mydb' does not exist or mySQL is not connected!
Please check your settings ...</h1>");
//Check
if(!$conn) die("<h1>mySQL-Connection-Error
Check your settings ...</h1>");
#======================================================================#
# 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
<meta http-equiv="refresh" content="2; URL=$PHP_SELF?cat=$cat&s=$s">
<table width="100%" border="0" cellspacing="3" cellpadding="3" height="95%">
<tr valign="middle" align="center">
<td>
end_xx;
echo "\n<font size='2'>".VIEW_VOTE_AUTOLINK."[/b]\n";
echo "
[ [url='$PHP_SELF?cat=$cat&s=$s']link[/url] ]";
echo <<<end_x
</td>
</tr>
</table>
</body>
</html>
end_x;
exit;
} // endif $yourvote
#======================================================================#
# get data from db by right order ...
#======================================================================#
if(($cat) && (!$yourvote))
{
if($sort == "new" || $incatsort == "id") { $incatsort = "id"; $sortby = "DESC"; $act_sort = VIEW_SORTING_NEW; } // sorting by old/new
if($sort == "old") { $incatsort = "id"; $sortby = "ASC"; $act_sort = VIEW_SORTING_OLD; }
if($sort == "vote" || $incatsort == "hp_vote") { $incatsort = "hp_vote"; $sortby = "DESC"; $act_sort = VIEW_SORT_BY_VOTE; } //sort by rating
if($sort == "hits" || $incatsort == "hp_votes") { $incatsort = "Hits"; $sortby = "DESC"; $act_sort = VIEW_SORT_BY_HITS; } //sort by hits
if($sort == "name" || $incatsort == "name") { $incatsort = "name"; $sortby = "ASC"; $act_sort = VIEW_SORTING_NAME; } //sort by name
//when searching
if($cat == "search") {
$result = MYSQL_QUERY("SELECT * FROM $table_linkdata WHERE name LIKE \"%$q%\" order by $incatsort $sortby LIMIT 0,$max_search "); // get seach-query's to $max_search
$scnt = MYSQL_NUM_ROWS($result);
} else {
if(!$s) { $showfrom = 0; $datasets = $perpage; // params for default--output (on 1 page)
} else {
$showfrom = $s; $datasets = $perpage; } // set params for page--output (multiple pages)
// get total number of links in a cat
$countz = MYSQL_QUERY("SELECT COUNT(id) FROM $table_linkdata WHERE cat = $cat ");
$anz = MYSQL_RESULT($countz,0);
MYSQL_FREE_RESULT($countz); //mem
$result = MYSQL_QUERY("SELECT * FROM $table_linkdata WHERE cat = $cat order by $incatsort $sortby LIMIT $showfrom,$datasets "); //get linkdata
} //endif $search
#======================================================================#
# javascript for jump-menu
#======================================================================#
?>
<script language='javascript'>
<!--
// jump-menu
function jumper(targ,selObj,restore)
{
eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
if (restore) selObj.selectedIndex=0;
}
//-->
</script>
<table width="100%" border="0" cellspacing="3" cellpadding="3" height="95%">
<tr valign="middle" align="center">
<td>
<table border='0' cellspacing='1' cellpadding='1' align='center' width='<?=$linkwidth?>'>
<tr>
<td align='center'>
<?
#======================================================================#
# render cat-info & some NAVI-links
#======================================================================#
if($cat != "search") //show not if searching
{
$hello = MYSQL_QUERY("SELECT * FROM $table_cat WHERE id = $cat"); // get cat-info
$world = MYSQL_FETCH_ARRAY($hello);
echo "\n\n\n\n";
echo "<h4>$listname | ".VIEW_BEFORE_CAT_TXT." '$world[name]'</h4>\n"; // print cat-info
echo "</td>\n</tr>\n";
MYSQL_FREE_RESULT($hello); // give memory free
} else {
echo "<h4>$listname | ".SEARCH_RESULTS." $q ($max_search max.)</h4>\n"; } // print search-resluts header
// show some navigation for sorting ...
if($q) $qstring = "&q=$q";
echo "<tr>\n<td>\n[ [url='index.php']".LINK_TO_INDEX."[/url] :: [url='add.php?from=$cat']".ADD_NEW_LINK."[/url] ]\n</td>\n</tr>\n";
echo "<tr>\n<td>\n[ ".VIEW_SORTING." [url='$PHP_SELF?cat=$cat&s=$s&sort=name$qstring']".VIEW_SORTING_NAME."[/url] | [url='$PHP_SELF?cat=$cat&s=$s&sort=old$qstring']".VIEW_SORTING_OLD."[/url] | [url='$PHP_SELF?cat=$cat&s=$s&sort=new$qstring']".VIEW_SORTING_NEW."[/url] | [url='$PHP_SELF?cat=$cat&s=$s&sort=vote$qstring']".VIEW_SORT_BY_VOTE."[/url] | [url='$PHP_SELF?cat=$cat&s=$s&sort=hits$qstring']".VIEW_SORT_BY_HITS."[/url] ]\n";
echo "\n[ ".VIEW_CURRENT_SORT." [b]$act_sort[/b] ]\n</td>\n</tr>\n";
echo "</table>\n";
#======================================================================#
# render output-table for each link
#======================================================================#
if(!$scnt && $cat == "search") echo SEARCH_NO_RESULTS; // msg if no search-results found
//function to generate the <select>-field for 'vote'
function VoteSelect()
{
global $PHP_SELF;
global $cat;
global $row;
global $s;
// <select> for vote
echo "\t<select name='a_vote' onchange=\"jumper('self',this,0)\">\n";
echo "\t<option>".VIEW_VOTE_SELECT."\n";
echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=1'>1 - ".VIEW_BADDEST_VOTE."\n";
echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=2'>2\n";
echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=3'>3\n";
echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=4'>4\n";
echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=5'>5\n";
echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=6'>6\n";
echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=7'>7\n";
echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=8'>8\n";
echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=9'>9\n";
echo "\t<option value='$PHP_SELF?cat=$cat&id=$row[id]&s=$s&yourvote=10'>10 - ".VIEW_BEST_VOTE."\n";
echo "\t</select>\n";
}
while ($row = MYSQL_FETCH_ARRAY($result))
{
// get date of posting and format as set
if($timeformat == 1) $pd = strftime("%d.%m.%Y", $row[poster_time]);
elseif($timeformat == 2) $pd = strftime("%A, %d-%m-%Y %R", $row[poster_time]);
elseif($timeformat == 3) $pd = strftime("%d-%m-%Y", $row[poster_time]);
else $pd = strftime("%Y-%d-%m", $row[poster_time]);
//strip-slashes
if($html == "ON")
{
$row[hp_desc] = stripslashes($row[hp_desc]);
$row[name] = stripslashes($row[name]);
$row[url] = stripslashes($row[url]);
$row[poster_name] = stripslashes($row[poster_name]);
$row[poster_email] = stripslashes($row[poster_email]);
}
// include design.inc.php and render table's
include("inc/design.inc.php");
}
MYSQL_FREE_RESULT($result); // give memory free
} //endif $cat
?>
<table border='0' align='center' width='<?=$linkwidth?>'>
<tr>
<td align='left'>[url='javascript:scroll(0,0)']<?=VIEW_LINK_TOP;?>[/url]</td>
<td align='right'>
<?
// <select> for catjump
/* echo VIEW_CATJUMP_SEL."";
echo "<select name='mycatisjumping' onchange=\"jumper('self',this,0)\" onmouseover='this.focus()'>\n";
echo "<option value=''>".ADD_HP_CAT_SELECT."\n";
$sweet = MYSQL_QUERY("SELECT * FROM $table_cat order by $catorder");
while ($cats = MYSQL_FETCH_ARRAY($sweet))
{
if($cats[id] != $cat) echo "<option value='$PHP_SELF?cat=$cats[id]&sort=$sort'>$cats[name]\n"; // render cat-selection
}
MYSQL_FREE_RESULT($sweet); // give memory free
echo "</select>\n";
*/
?>
</td>
</tr>
</table>
<table border='0' align='center' width='<?=$linkwidth?>'>
<tr>
<td align='center'>
<?
#======================================================================#
# navigation @ page bottom of the cat-view
# (only if not searching)
#======================================================================#
if($cat != "search")
{
//var's
$ges = $anz / $perpage;
if(is_integer($ges)) $pgcnt = $ges;
else $pgcnt = $ges + 1; // get page-counter in a cat
//$lastpg = $anz - $perpage; // $s of last page
$actpg = $s / $perpage + 1; // get number of actual page
$sh_to = $showfrom + $perpage; // $s for next page
$sh_strt = $showfrom - $perpage; // $s for prev. page
if($sh_to > $anz) $sh_to = $anz; // ---- "" ----
if($sort) $linkvar = "&sort=$sort"; // string for sorting if set
//output
if($s) echo "[ [url='$PHP_SELF?cat=$cat&s=$sh_strt$linkvar']<[/url] ] ::\n";
echo "[b][[/b] ".VIEW_LINKS_PAGE." $actpg ".VIEW_LINKS_FROM." ".sprintf("%d","$pgcnt")." [b]][/b] ";
if($s + $perpage < $anz) echo ":: [ [url='$PHP_SELF?cat=$cat&s=$sh_to$linkvar']>[/url] ]\n";
} //endif $q
// HTML:
?>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?
#======================================================================#
# footer &
# END OF FILE
#======================================================================#
// PLEASE DONT CHANGE THIS [for dev]
#################################################################################################################
// echo "\n\n"; #
// echo "\n<p align='center'>© [url='jump.php?id=x']xLinks[/url] 2002\n"; # #
//disconnect from mySQL #
MYSQL_CLOSE(); #
#################################################################################################################
include("./inc/foot.inc");
?>
</td>
<? include('includes/second.php'); ?>
Alles anzeigen
Und so sieht das alles dargestellt aus:
http://www.freshn.de/view.php?cat=6
Ich möchte ein paar Sachen da weghaben, find die Zeilen aber im Quellcode nicht.
Weg soll:
- "freshlinks
lustige und interessante Links | Links in 'Sonstiges'" (ganz oben) , evtl durch anderen Text ersetzten
- [ Übersicht ::
- Link hinzufügen ] , soll im neuen Fenster geöffnet werden (<a href=\"javascript:fenster('add.php',500,500)\">)
- [ Aktuell: neue Links ]
Ich glaub das wars. Wäre echt super wenn mir da jmd weiterhelfen könnte.