Nieuw lid |
|
He ik ben totaal beginner in php
Ik heb een news systeem ergens vandaan gehaald (werkt prima)
maar nu heb ik een foutje ondekt..
kijk maar op www.citexx.nl en druk maar een op "join us" dan komt de tekst er boven te staan en het news er onder maar ik wil dat news weg hebben. Hoe werkt dat..
het is eeen heel goed scriptje maar ik laat hem tog ffjtes zien..
heb alleen de eerste 3 regeltjes toegevoegd.
<?php
if($action == "join"){
echo "We hebben geen mensen meer nodig op dit moment";
} //alleen deze 3 regeltjes heb ik gemaakt waarschijnlijk staat die heer fout ofzow
ob_start();
include 'config.php';
session_start();
ob_end_clean();
$tmpname = $_SESSION['name'];
if($tmpname == ""){
}else{
$sql = "SELECT user FROM `$newsadmin` WHERE user = '$tmpname'";
$query = mysql_query($sql);
$tmpname = mysql_result($query,0);
}
$sql = "SELECT nppage FROM `$newsoptions` WHERE 1";
$query = mysql_query($sql);
$nppage = mysql_result($query,0);
$sql = "SELECT cppage FROM `$newsoptions` WHERE 1";
$query = mysql_query($sql);
$cppage = mysql_result($query,0);
$sql = "SELECT * FROM `$newscomments` WHERE pid = '$_GET[id]'";
$query = mysql_query($sql);
$totalcomments = mysql_num_rows($query);
$sql = "SELECT * FROM `$newstable`";
$query = mysql_query($sql);
$totalnews = mysql_num_rows($query);
$from = $_GET['from'];
if($from == ""){
$from = 0;
}
$page = $_GET['page'];
if($page == ""){
$page = 1;
}
$sql = "SELECT commentsorder FROM `$newsoptions` WHERE 1";
$query = mysql_query($sql);
$commentsorder = mysql_result($query,0);
$sql = "SELECT newsorder FROM `$newsoptions` WHERE 1";
$query = mysql_query($sql);
$newsorder = mysql_result($query,0);
$sql = "SELECT * FROM $newstable ORDER BY 0+ID $newsorder LIMIT $from ,$nppage";
$result = mysql_query($sql)
or die ("Couldn't execute query.");
$sql2 = "SELECT header FROM $newsoptions WHERE 1";
$result2 = mysql_query($sql2);
$sql3 = "SELECT footer FROM $newsoptions WHERE 1";
$result3 = mysql_query($sql3);
$sql4 = "SELECT template FROM $newsoptions WHERE 1";
$result4 = mysql_query($sql4);
$header = mysql_result($result2,0);
$footer = mysql_result($result3,0);
$template = mysql_result($result4,0);
echo $header;
if($_GET['comments'] == ""){
while($row = mysql_fetch_array( $result )) {
$sql5 = "SELECT * FROM $newscomments WHERE pid = '$row[id]'";
$query5 = mysql_query($sql5);
$numcomments = mysql_num_rows($query5);
$template2 = $template;
$template2 = str_replace("{title}",$row[title],$template2);
$template2 = str_replace("{story}",$row[story],$template2);
$template2 = str_replace("{author}",$row[author],$template2);
$template2 = str_replace("{date}",$row[date],$template2);
$template2 = str_replace("{id}",$row[id],$template2);
$template2 = str_replace("[email]","<a href=\"mailto:$row[email]\">",$template2);
$template2 = str_replace("[/email]","</a>",$template2);
$template2 = str_replace("{email}",$row[email],$template2);
$template2 = str_replace("[comments]","<a href=\"?comments=true&id=$row[id]\">",$template2);
$template2 = str_replace("[/comments]","</a>",$template2);
$template2 = str_replace("{comments}",$numcomments,$template2);
$template2 = str_replace("[img]","<img src=\"",$template2);
$template2 = str_replace("[/img]","\">",$template2);
if($row[avatar] == ""){
$template2 = str_replace("{avatar}","",$template2);
} else {
$template2 = str_replace("{avatar}","<img src=\"$row[avatar]\">",$template2);
}
$sql = "SELECT * FROM $newssmilies";
$query = mysql_query($sql);
while($row = mysql_fetch_array( $query )) {
$template2 = str_replace($row['keycode'],"<img src=\"$row[path]\">",$template2);
}
echo $template2;
}
$i = ($totalnews / $nppage);
$i = ceil($i);
$s = 1;
function previous($from,$nppage){
if($from == 0){
return " ";
}else{
$b = ($from - $nppage);
return "<a href=\"?from=$b\"> ";
}
}
$prev = previous($from,$nppage);
echo $prev;
function pages($nppage, $s , $i, $from){
while ($s <= $i){
$y = $s * $nppage;
$x = $y - $nppage;
if($from == $x){
$c .= "$s ";
}else{
$c .= "<a href=\"?from=$x&page=$s\">$s</a> ";
}
$s++;
}
return $c;
}
function nextlink($totalnews, $nppage, $page, $from){
if($page >= ($totalnews / $nppage)){
return " ";
}else{
$b = ($from + $nppage);
$c = ($page + 1);
return "<a href=\"?from=$b&page=$c\">";
}
}
$sql = "SELECT npagintation FROM `$newsoptions` WHERE 1";
$query = mysql_query($sql);
$npagintation = mysql_result($query,0);
$npagintation = str_replace("[prev-link]", previous($from,$nppage),$npagintation);
$npagintation = str_replace("[/prev-link]", "</a>",$npagintation);
$npagintation = str_replace("[next-link]", nextlink($totalnews, $nppage, $page, $from),$npagintation);
$npagintation = str_replace("[/next-link]", "</a>",$npagintation);
$npagintation = str_replace("{pages}", pages($nppage,$s,$i,$from),$npagintation);
echo $npagintation;
}else{
$sql2 = "SELECT * FROM $newstable WHERE id = '$_GET[id]'";
$result2 = mysql_query($sql2);
$sql3 = "SELECT comments FROM $newsoptions WHERE 1";
$result3 = mysql_query($sql3);
$commentstemplate = mysql_result($result3,0);
while($row = mysql_fetch_array($result2)) {
$sql5 = "SELECT * FROM $newscomments WHERE pid = '$row[id]' ORDER BY 0+ID $commentsorder LIMIT $from ,$cppage";
$query5 = mysql_query($sql5);
$sql = "SELECT * FROM $newscomments WHERE pid = '$row[id]'";
$query = mysql_query($sql);
$numcomments = mysql_num_rows($query);
$template2 = $template;
$template2 = str_replace("{title}",$row[title],$template2);
$template2 = str_replace("{story}",$row[story],$template2);
$template2 = str_replace("{author}",$row[author],$template2);
$template2 = str_replace("{date}",$row[date],$template2);
$template2 = str_replace("{id}",$row[id],$template2);
$template2 = str_replace("[email]","<a href=\"mailto:$row[email]\">",$template2);
$template2 = str_replace("[/email]","</a>",$template2);
$template2 = str_replace("{email}",$row[email],$template2);
$template2 = str_replace("[comments]","",$template2);
$template2 = str_replace("[/comments]","",$template2);
$template2 = str_replace("{comments}",$numcomments,$template2);
$template2 = str_replace("[img]","<img src=\"",$template2);
$template2 = str_replace("[/img]","\">",$template2);
if($row[avatar] == ""){
$template2 = str_replace("{avatar}","",$template2);
} else {
$template2 = str_replace("{avatar}","<img src=\"$row[avatar]\">",$template2);
}
$sql = "SELECT * FROM $newssmilies";
$query = mysql_query($sql);
while($row = mysql_fetch_array( $query )) {
$template2 = str_replace($row['keycode'],"<img src=\"$row[path]\">",$template2);
}
echo $template2;
while($row = mysql_fetch_array($query5)) {
$commentstemplate2 = $commentstemplate;
$commentstemplate2 = str_replace("{date}",$row[date],$commentstemplate2);
$author = strip_tags($row['user']);
$commentstemplate2 = str_replace("{author}",$author,$commentstemplate2);
$message = strip_tags($row['message']);
$commentstemplate2 = str_replace("{message}",$message,$commentstemplate2);
$email2 = strip_tags($row['email']);
$commentstemplate2 = str_replace("{email}",$email2,$commentstemplate2);
if($email2 == ""){
$commentstemplate2 = str_replace("[email]","",$commentstemplate2);
$commentstemplate2 = str_replace("[/email]","",$commentstemplate2);
}else{
$commentstemplate2 = str_replace("[email]","<a href=\"mailto:$row[email]\">",$commentstemplate2);
$commentstemplate2 = str_replace("[/email]","</a>",$commentstemplate2);
}
$sql = "SELECT * FROM $newsfilter";
$result = mysql_query($sql);
while($row = mysql_fetch_array($result)) {
$commentstemplate2 = eregi_replace($row['filter'],$row['alt'],$commentstemplate2);
}
echo $commentstemplate2;
}
}
$i = ($totalcomments / $cppage);
$i = ceil($i);
$s = 1;
function cprevious($from,$cppage){
if($from == 0){
return " ";
}else{
$b = ($from - $cppage);
return "<a href=\"?comments=true&id=$_GET[id]&from=$b\"> ";
}
}
$prev = cprevious($from,$cppage);
echo $prev;
function cpages($cppage, $s , $i, $from){
while ($s <= $i){
$y = $s * $cppage;
$x = $y - $cppage;
if($from == $x){
$c .= "$s ";
}else{
$c .= "<a href=\"?comments=true&id=$_GET[id]&from=$x&page=$s\">$s</a> ";
}
$s++;
}
return $c;
}
function cnextlink($totalcomments, $cppage, $page, $from){
if($page >= ($totalcomments / $cppage)){
return " ";
}else{
$b = ($from + $cppage);
$c = ($page + 1);
return "<a href=\"?comments=true&id=$_GET[id]&from=$b&page=$c\">";
}
}
$sql = "SELECT cpagintation FROM `$newsoptions` WHERE 1";
$query = mysql_query($sql);
$cpagintation = mysql_result($query,0);
$cpagintation = str_replace("[prev-link]", cprevious($from,$cppage),$cpagintation);
$cpagintation = str_replace("[/prev-link]", "</a>",$cpagintation);
$cpagintation = str_replace("[next-link]", cnextlink($totalcomments, $cppage, $page, $from),$cpagintation);
$cpagintation = str_replace("[/next-link]", "</a>",$cpagintation);
$cpagintation = str_replace("{pages}", cpages($cppage,$s,$i,$from),$cpagintation);
echo $cpagintation;
if($_POST['B1'] == ""){
$sql2 = "SELECT commentsform FROM $newsoptions WHERE 1";
$result2 = mysql_query($sql2);
if($tmpname == ""){
}else{
$sql = "SELECT email FROM $newsadmin WHERE user = '$tmpname'";
$query = mysql_query($sql);
$email = mysql_result($query,0);
}
$commentsform = mysql_result($result2,0);
$commentsform = str_replace("{id}",$_GET['id'],$commentsform);
$commentsform = str_replace("<","<",$commentsform);
$commentsform = str_replace(">",">",$commentsform);
$commentsform = str_replace("{name}","$tmpname",$commentsform);
$commentsform = str_replace("{email}","$email",$commentsform);
echo $commentsform;
}else{
$sql = "SELECT * FROM `$newsadmin` WHERE user='$_POST[T1]'";
$query = mysql_query($sql);
$numrows = mysql_num_rows($query);
if($numrows > 0){
if($tmpname == $_POST['T1']){
}else{
echo "<font color=\"FF0000\">Please choose a different name. or log into the admin area <a href=\"admin.php\">here</a>.";
die;
}
}
$sql2 = "SELECT commentsform FROM $newsoptions WHERE 1";
$result2 = mysql_query($sql2);
$commentsform = mysql_result($result2,0);
$commentsform = str_replace("{id}",$_GET['id'],$commentsform);
$commentsform = str_replace("<","<",$commentsform);
$commentsform = str_replace(">",">",$commentsform);
$commentsform = str_replace("{name}","$tmpname",$commentsform);
$commentsform = str_replace("{email}","$email",$commentsform);
if($_POST['T1'] == ""){
echo "<font color=\"FF0000\">Please enter a username.</font>";
echo $commentsform;
}elseif($_POST['S1'] == ""){
echo "<font color=\"FF0000\">Please enter a message.</font>";
echo $commentsform;
}else{
$sql = "SELECT * FROM `$newscomments` WHERE pid = '$_GET[id]'";
$result = mysql_query($sql);
$comm = mysql_num_rows($result);
$comm = $comm + 1;
$user = $_POST['T1'];
$user = strip_tags($user);
$email = $_POST['T2'];
$email = strip_tags($email);
$message = $_POST['S1'];
$message = strip_tags($message);
$sql = "SELECT commentstime FROM `$newsoptions` WHERE 1";
$query = mysql_query($sql);
$date2 = mysql_result($query,0);
$date = gmdate($date2);
$sql = "INSERT INTO $newscomments (user,email,date,message,pid,id) VALUES ('$user','$email','$date','$message','$_GET[id]','$comm')";
$result = mysql_query ($sql);
$sql = "UPDATE $newstable SET comments = '$comm' WHERE id = '$_GET[id]'";
$result = mysql_query ($sql);
echo "Comment added.";
echo "<SCRIPT LANGUAGE=\"JavaScript\">";
echo "window.location=\"index.php?comments=true&id=$_GET[id]\"";
echo "</script>";
}
}
if($action == "join"){
echo "We hebben geen mensen meer nodig op dit moment";
}
}
echo "\n$footer";
?>
<?php if($action == "join"){ echo "We hebben geen mensen meer nodig op dit moment"; } //alleen deze 3 regeltjes heb ik gemaakt waarschijnlijk staat die heer fout ofzow include 'config.php'; $tmpname = $_SESSION['name']; if($tmpname == ""){ }else{ $sql = "SELECT user FROM `$newsadmin` WHERE user = '$tmpname'"; } $sql = "SELECT nppage FROM `$newsoptions` WHERE 1"; $sql = "SELECT cppage FROM `$newsoptions` WHERE 1"; $sql = "SELECT * FROM `$newscomments` WHERE pid = '$_GET[id]'"; $sql = "SELECT * FROM `$newstable`"; $from = $_GET['from']; if($from == ""){ $from = 0; } $page = $_GET['page']; if($page == ""){ $page = 1; } $sql = "SELECT commentsorder FROM `$newsoptions` WHERE 1"; $sql = "SELECT newsorder FROM `$newsoptions` WHERE 1"; $sql = "SELECT * FROM $newstable ORDER BY 0+ID $newsorder LIMIT $from ,$nppage"; or die ("Couldn't execute query."); $sql2 = "SELECT header FROM $newsoptions WHERE 1"; $sql3 = "SELECT footer FROM $newsoptions WHERE 1"; $sql4 = "SELECT template FROM $newsoptions WHERE 1"; if($_GET['comments'] == ""){ $sql5 = "SELECT * FROM $newscomments WHERE pid = '$row[id]'"; $template2 = $template; $template2 = str_replace("{title}",$row[title ],$template2); $template2 = str_replace("{story}",$row[story ],$template2); $template2 = str_replace("{author}",$row[author ],$template2); $template2 = str_replace("[email]","<a href=\"mailto:$row[email]\">",$template2); $template2 = str_replace("[/email]","</a>",$template2); $template2 = str_replace("{email}",$row[email ],$template2); $template2 = str_replace("[comments]","<a href=\"?comments=true&id=$row[id]\">",$template2); $template2 = str_replace("[/comments]","</a>",$template2); $template2 = str_replace("{comments}",$numcomments,$template2); $template2 = str_replace("[img]","<img src=\"",$template2); if($row[avatar] == ""){ } else { $template2 = str_replace("{avatar}","<img src=\"$row[avatar]\">",$template2); } $sql = "SELECT * FROM $newssmilies"; $template2 = str_replace($row['keycode'],"<img src=\"$row[path]\">",$template2); } } $i = ($totalnews / $nppage); $s = 1; function previous($from,$nppage){ if($from == 0){ return " "; }else{ $b = ($from - $nppage); return "<a href=\"?from=$b\"> "; } } $prev = previous($from,$nppage); function pages($nppage, $s , $i, $from){ while ($s <= $i){ $y = $s * $nppage; $x = $y - $nppage; if($from == $x){ $c .= "$s "; }else{ $c .= "<a href=\"?from=$x&page=$s\">$s</a> "; } $s++; } return $c; } function nextlink($totalnews, $nppage, $page, $from){ if($page >= ($totalnews / $nppage)){ return " "; }else{ $b = ($from + $nppage); $c = ($page + 1); return "<a href=\"?from=$b&page=$c\">"; } } $sql = "SELECT npagintation FROM `$newsoptions` WHERE 1"; $npagintation = str_replace("[prev-link]", previous ($from,$nppage),$npagintation); $npagintation = str_replace("[/prev-link]", "</a>",$npagintation); $npagintation = str_replace("[next-link]", nextlink ($totalnews, $nppage, $page, $from),$npagintation); $npagintation = str_replace("[/next-link]", "</a>",$npagintation); $npagintation = str_replace("{pages}", pages ($nppage,$s,$i,$from),$npagintation); }else{ $sql2 = "SELECT * FROM $newstable WHERE id = '$_GET[id]'"; $sql3 = "SELECT comments FROM $newsoptions WHERE 1"; $sql5 = "SELECT * FROM $newscomments WHERE pid = '$row[id]' ORDER BY 0+ID $commentsorder LIMIT $from ,$cppage"; $sql = "SELECT * FROM $newscomments WHERE pid = '$row[id]'"; $template2 = $template; $template2 = str_replace("{title}",$row[title ],$template2); $template2 = str_replace("{story}",$row[story ],$template2); $template2 = str_replace("{author}",$row[author ],$template2); $template2 = str_replace("[email]","<a href=\"mailto:$row[email]\">",$template2); $template2 = str_replace("[/email]","</a>",$template2); $template2 = str_replace("{email}",$row[email ],$template2); $template2 = str_replace("{comments}",$numcomments,$template2); $template2 = str_replace("[img]","<img src=\"",$template2); if($row[avatar] == ""){ } else { $template2 = str_replace("{avatar}","<img src=\"$row[avatar]\">",$template2); } $sql = "SELECT * FROM $newssmilies"; $template2 = str_replace($row['keycode'],"<img src=\"$row[path]\">",$template2); } $commentstemplate2 = $commentstemplate; $commentstemplate2 = str_replace("{author}",$author,$commentstemplate2); $commentstemplate2 = str_replace("{message}",$message,$commentstemplate2); $commentstemplate2 = str_replace("{email}",$email2,$commentstemplate2); if($email2 == ""){ $commentstemplate2 = str_replace("[email]","",$commentstemplate2); $commentstemplate2 = str_replace("[/email]","",$commentstemplate2); }else{ $commentstemplate2 = str_replace("[email]","<a href=\"mailto:$row[email]\">",$commentstemplate2); $commentstemplate2 = str_replace("[/email]","</a>",$commentstemplate2); } $sql = "SELECT * FROM $newsfilter"; $commentstemplate2 = eregi_replace($row['filter'],$row['alt'],$commentstemplate2); } } } $i = ($totalcomments / $cppage); $s = 1; function cprevious($from,$cppage){ if($from == 0){ return " "; }else{ $b = ($from - $cppage); return "<a href=\"?comments=true&id=$_GET[id]&from=$b\"> "; } } $prev = cprevious($from,$cppage); function cpages($cppage, $s , $i, $from){ while ($s <= $i){ $y = $s * $cppage; $x = $y - $cppage; if($from == $x){ $c .= "$s "; }else{ $c .= "<a href=\"?comments=true&id=$_GET[id]&from=$x&page=$s\">$s</a> "; } $s++; } return $c; } function cnextlink($totalcomments, $cppage, $page, $from){ if($page >= ($totalcomments / $cppage)){ return " "; }else{ $b = ($from + $cppage); $c = ($page + 1); return "<a href=\"?comments=true&id=$_GET[id]&from=$b&page=$c\">"; } } $sql = "SELECT cpagintation FROM `$newsoptions` WHERE 1"; $cpagintation = str_replace("[prev-link]", cprevious ($from,$cppage),$cpagintation); $cpagintation = str_replace("[/prev-link]", "</a>",$cpagintation); $cpagintation = str_replace("[next-link]", cnextlink ($totalcomments, $cppage, $page, $from),$cpagintation); $cpagintation = str_replace("[/next-link]", "</a>",$cpagintation); $cpagintation = str_replace("{pages}", cpages ($cppage,$s,$i,$from),$cpagintation); if($_POST['B1'] == ""){ $sql2 = "SELECT commentsform FROM $newsoptions WHERE 1"; if($tmpname == ""){ }else{ $sql = "SELECT email FROM $newsadmin WHERE user = '$tmpname'"; } $commentsform = str_replace("{id}",$_GET['id'],$commentsform); $commentsform = str_replace("{name}","$tmpname",$commentsform); $commentsform = str_replace("{email}","$email",$commentsform); }else{ $sql = "SELECT * FROM `$newsadmin` WHERE user='$_POST[T1]'"; if($numrows > 0){ if($tmpname == $_POST['T1']){ }else{ echo "<font color=\"FF0000\">Please choose a different name. or log into the admin area <a href=\"admin.php\">here</a>."; } } $sql2 = "SELECT commentsform FROM $newsoptions WHERE 1"; $commentsform = str_replace("{id}",$_GET['id'],$commentsform); $commentsform = str_replace("{name}","$tmpname",$commentsform); $commentsform = str_replace("{email}","$email",$commentsform); if($_POST['T1'] == ""){ echo "<font color=\"FF0000\">Please enter a username.</font>"; }elseif($_POST['S1'] == ""){ echo "<font color=\"FF0000\">Please enter a message.</font>"; }else{ $sql = "SELECT * FROM `$newscomments` WHERE pid = '$_GET[id]'"; $comm = $comm + 1; $user = $_POST['T1']; $email = $_POST['T2']; $message = $_POST['S1']; $sql = "SELECT commentstime FROM `$newsoptions` WHERE 1"; $sql = "INSERT INTO $newscomments (user,email,date,message,pid,id) VALUES ('$user','$email','$date','$message','$_GET[id]','$comm')"; $sql = "UPDATE $newstable SET comments = '$comm' WHERE id = '$_GET[id]'"; echo "<SCRIPT LANGUAGE=\"JavaScript\">"; echo "window.location=\"index.php?comments=true&id=$_GET[id]\""; } } if($action == "join"){ echo "We hebben geen mensen meer nodig op dit moment"; } } ?>
|