Info  
Door: PeckMoeilijkheidsgraad: 2/3
Geplaatst op: 19-03-2007 Reacties: 0
Views: 188414Log in om zelf te reageren
 Waardering: 7/10 (3 stemmen)

Uitleg

Dit is een redelijk uitgebreid linksysteem met administratiefunctie, inloggen kan door naar "index.php?action=login" te surfen, en de adminpagina is te bereiken via "index.php?action=admin". Ik heb er geen uitgebreid loginsysteem bij geschreven met een databasetabel etc., want je zal waarschijnlijk toch al je eigen loginsysteem hebben en dan is het enkel maar lastig om dat er uit te krijgen. Uitleg over hoe je een gebruiker moet aanmaken staat in het script.

De lay-out is niet echt zo voor gebruik vatbaar, maar in css.css kan je deze al voor een groot deel naar eigen smaak aanpassen. Ik geeft de naam van de file met het script in nu "index.php", maar die mag naar eigen wensen worden aangepast zonder dat het script zijn functionaliteit verliest.

Er is ook een tabel bij die je maakt met de volgende query:

CREATE TABLE `link_links` (
`id` int(5) NOT NULL auto_increment,
`description` varchar(55) NOT NULL,
`url` varchar(55) NOT NULL,
`linktext` varchar(55) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Script

//---- css.css
A:link    { color: #bababa; text-decoration:none;}
A:visited { color: #bababa; text-decoration:none;}
A:hover   { color: #d3d3d3; text-decoration:underline}
A:active  { color: #d3d3d3; text-decoration:underline;}
BODY {
    background-color: #225479;
    font-family: Tahoma;
}
.linkstable {
    margin: 0 auto;
    width: 60%;
}
.linkstable_header
{
    border: 1px solid black;
    height: 25px;
    background-color: #1A4A64;
    text-align: center;
    vertical-align: middle;
    font-size: 14px;
    font-weight: bold;
}
.linkstable_header_left
{
    border-left: 1px solid black;
    border-top: 1px solid black;
    border-bottom: 1px solid black;
    height: 25px;
    background-color: #1A4A64;
    text-align: center;
    vertical-align: middle;
    font-size: 15px;
    font-weight: bold;
}
.linkstable_header_right
{
    font-size: 15px;
    border: 1px solid black;
    height: 25px;
    background-color: #1A4A64;
    text-align: center;
    vertical-align: middle;
    font-weight: bold;
}
.linkstable_middle {
    font-size: 14px;
    border-left: 1px solid black;
    border-bottom: 1px solid black;
    border-right: 1px solid black;
    text-align: left;
    padding: 5px;
    vertical-align: middle;
}
.linkstable_middle_left {
    font-size: 14px;
    border-left: 1px solid black;
    border-bottom: 1px solid black;
    height: 20px;
    text-align: left;
    vertical-align: middle;
    padding: 5px;
}
.linkstable_middle_right {
    font-size: 14px;
    height: 20px;
    border-left: 1px solid black;
    border-bottom: 1px solid black;
    border-right: 1px solid black;
    text-align: right;
    padding: 5px;
    vertical-align: middle;
}
input {
    border: 1px solid black;
    background-color: #1C5371;
}

//-- index.php
<?php
ob_start
();
session_start();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Linksysteem</title>
<link rel="stylesheet" type="text/css" href="css.css">

<script language="javascript" type="text/javascript">
function checkAll(formName) {
    for(var i=0;i<formName.elements.length;i++) {
        var element = formName.elements[i];
        if((element.name != "allbox") && (element.type == "checkbox")) {
            element.checked = formName.allbox.checked;
        }
    }
}
function askConfirm(txt,url) {
    if (confirm(txt) == true) {
        document.location=url
    return true;
    }
}
</script>

</head>
<body>
<?php
//-- Databaseconnectie
$host "localhost"// database host
$user "username"// database user
$pass "password"// database pass
$db "database"// database
$tblprefix "link_"// tabel voorvoegsel (standaard "link_")
$linksperpage 10// aantal links per pagina

/*
Gebruikers aanmaken doe je als volgt:
$login['2']['user'] = "gebruiker2";
$login['2']['password'] = "wachtwoordvangebruiker2";

$login['3']['user'] = "gebruiker3";
$login['3']['password'] = "wachtwoordvangebruiker3";
....
*/
$login['1']['user'] = "Peck";
$login['1']['password'] = "wachtwoord";


define("TABLE_PREFIX",$tblprefix);

//-- connectie maken met de database
if (@mysql_connect($host,$user,$pass) && @mysql_select_db($db))
{
    
}
else
{
    exit(
"<span style=\"color: red;\">Kon geen connectie met de database maken. Neem contact op met de beheerder.</span>");
}

//-- linkoverzicht weergeven
if (empty($_GET['action']))
{
    
$count_links2 mysql_query("SELECT * FROM ".TABLE_PREFIX."links");
    
$count_links mysql_num_rows($count_links2);
    
    
$count_pages ceil($count_links $linksperpage);
    
    if(empty(
$_GET['page']) || !is_numeric($_GET['page']))
    {
        
$page 1;
    }
    else
    {
        
$page $_GET['page'];
    }
    
    
$start_value = ($page $linksperpage) - $linksperpage;
    
    
$query mysql_query("SELECT * FROM ".TABLE_PREFIX."links LIMIT $start_value,$linksperpage");
    
    echo 
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"width: 60%; font-size: 14px;\" class=\"linkstable\">\n";
        echo 
"<tr>\n";
            echo 
"<td class=\"linkstable_header_left\">\n";
                echo 
"Link";
            echo 
"</td>\n";
            echo 
"<td class=\"linkstable_header_right\">\n";
                echo 
"Beschrijving";
            echo 
"</td>";
        echo 
"</tr>\n";
        
    if (
$count_links == 0)
    {
            echo 
"<tr>\n";
                echo 
"<td class=\"linkstable_middle\" colspan=\"2\" style=\"text-align: center;\">\n";
                    echo 
"Geen links aanwezig\n";
                echo 
"</td>\n";
            echo 
"</tr>";
    }
    else
    {
        while (
$data mysql_fetch_array($query))
        {
            
$linktext htmlentities(ucfirst($data['linktext']), ENT_QUOTES);
            
$url $data['url'];
            
$beschrijving htmlentities(ucfirst($data['description']), ENT_QUOTES);
            
            echo 
"<tr>\n";
                echo 
"<td class=\"linkstable_middle_left\">\n";
                    echo 
"<a href=\"" $url "\" title=\"" $linktext "\" target=\"_blank\">".$linktext."</a>\n";
                echo 
"</td>\n";
                echo 
"<td class=\"linkstable_middle_right\" style=\"text-align: left;\">\n";
                    echo 
$beschrijving;
                echo 
"</td>\n";
            echo 
"</tr>";
        }
    }
    echo 
"</table>";
    
    if (
$count_links != 0) {
        echo 
"<br>Pagina: ";
        if(
$page != 1) {
            echo 
'<a href="' $_SERVER['PHP_SELF'] . '?page='.($page 1).'">&lt;</a>&nbsp;';
        } else {
            echo 
'&lt; ';
        }
        for(
$i 1$i $count_pages 1$i++) {
            if(
$i != $page) {
                echo 
'<a href="' $_SERVER['PHP_SELF'] . '?page='.$i.'">'.$i.'</a>&nbsp;';
            } else {
                echo 
$i.'&nbsp;';
            }
        }
        if(
$page $count_pages) {
            echo 
'<a href="' $_SERVER['PHP_SELF'] . '?page='.($page 1).'">&gt;</A>&nbsp;';
        } else {
            echo 
'&gt;';
        }
        echo 
"<br>";
    }
}

//-- loginpagina
elseif ($_GET['action'] == "login" && !isset($_POST['login']))
{
    if (isset(
$_SESSION['userid']))
    {
        
header('Location: '.$_SERVER['PHP_SELF'].'?action=admin');
    }
    echo 
$_SESSION['userid'];
    echo 
"<form action=\"" $_SERVER['PHP_SELF'] . "?action=login\" method=\"post\">\n";
    echo 
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"width: 60%; font-size: 14px;\" class=\"linkstable\">\n";
        echo 
"<tr>\n";
            echo 
"<td class=\"linkstable_header\" colspan=\"2\">\n";
                echo 
"Aanmelden\n";
            echo 
"</td>\n";
        echo 
"</tr>\n";
        echo 
"<tr>\n";
            echo 
"<td class=\"linkstable_middle_left\">\n";
                echo 
"Gebruikersnaam";
            echo 
"</td>";
            echo 
"<td class=\"linkstable_middle_right\">\n";
                echo 
"<input type=\"text\" name=\"username\">";
            echo 
"</td>";
        echo 
"</tr>";
        echo 
"<tr>";
            echo 
"<td class=\"linkstable_middle_left\">\n";
                echo 
"Wachtwoord";
            echo 
"</td>";
            echo 
"<td class=\"linkstable_middle_right\">\n";
                echo 
"<input type=\"password\" name=\"password\">\n";
            echo 
"</td>\n";
        echo 
"</tr>\n";
        echo 
"<tr>\n";
            echo 
"<td class=\"linkstable_middle_right\" colspan=\"2\" style=\"text-align: left;\">\n";
                echo 
"<input type=\"submit\" value=\"Aanmelden\" name=\"login\">\n";
            echo 
"</td>\n";
        echo 
"</tr>\n";
    echo 
"</table>\n";
    echo 
"</form>\n";
}

//-- login, verwerking
elseif ($_GET['action'] == "login" && isset($_POST['login']))
{
    
$username $_POST['username'];
    
$password $_POST['password'];
    
    foreach(
$login as $key => $value)
    {
        if (
is_array($value) && is_numeric($key))
        {
            
$arraynr $key;
            foreach(
$value as $key => $value)
            {
                if (
array_key_exists("user",$login[$arraynr]) && array_key_exists("password",$login[$arraynr]))
                {
                    if (
strtolower($login[$arraynr]['user']) == strtolower($username) && strtolower($login[$arraynr]['password']) == strtolower($password))
                    {
                        
$_SESSION['userid'] = $arraynr;
                    }
                }
            }
        }
    }
    if (empty(
$_SESSION['userid']))
    {
        echo 
"Foute gebruikersnaam en/of wachtwoord opgegeven";
    }
    else
    {
        
header('Location:'.$_SERVER['PHP_SELF'].'?action=admin');
    }
}

//-- uitloggen
elseif ($_GET['action'] == "logout")
{
    if (isset(
$_SESSION['userid']))
    {
        
session_unset();
        
session_destroy();
        
header('Location: '.$_SERVER['PHP_SELF']);
    }
    else
    {
        
header('Location: '.$_SERVER['PHP_SELF'].'?action=login');
    }
}

//-- administratiepagina
elseif ($_GET['action'] == "admin" && !isset($_GET['sub']))
{
    if (isset(
$_SESSION['userid']))
    {
        echo 
"<h3 style=\"text-align: center;\">Welkom op het adminpaneel</h3>";
        
        
        
$query mysql_query("SELECT * FROM ".TABLE_PREFIX."links");
        
$count_links mysql_num_rows($query);
        
        echo 
"<form action=\"" $_SERVER['PHP_SELF'] . "?action=admin&amp;sub=del\" method=\"post\">";
        echo 
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"width: 60%; font-size: 14px;\" class=\"linkstable\">\n";
        echo 
"<tr>\n";
            echo 
"<td class=\"linkstable_header_left\">\n";
                echo 
"Link";
            echo 
"</td>\n";
            echo 
"<td class=\"linkstable_header_left\">\n";
                echo 
"Beschrijving";
            echo 
"</td>";
            echo 
"<td class=\"linkstable_header_left\">\n";
                echo 
"Bewerk";
            echo 
"</td>\n";
            echo 
"<td class=\"linkstable_header_left\">\n";
                echo 
"Verwijder";
            echo 
"</td>";
            echo 
"<td class=\"linkstable_header_right\">\n";
                echo 
"<input name=\"allbox\" title=\"Select All\" value=\"Check All\" onclick=\"checkAll(this.form)\" type=\"checkbox\">";
            echo 
"</td>";
        echo 
"</tr>\n";
        
        if (
$count_links != "0")
        {
            while (
$data mysql_fetch_array($query))
            {
                
$linktext htmlentities(ucfirst($data['linktext']), ENT_QUOTES);
                
$url $data['url'];
                
$beschrijving htmlentities(ucfirst($data['description']), ENT_QUOTES);
                
$id $data['id'];
                
                echo 
"<tr>\n";
                    echo 
"<td class=\"linkstable_middle_left\">\n";
                        echo 
"<a href=\"" $url "\" title=\"" $linktext "\" target=\"_blank\">".$linktext."</a>\n";
                    echo 
"</td>\n";
                    echo 
"<td class=\"linkstable_middle_left\">\n";
                        echo 
$beschrijving;
                    echo 
"</td>\n";
                    echo 
"<td class=\"linkstable_middle_left\">\n";
                        echo 
"<a href=\"" $_SERVER['PHP_SELF'] . "?action=admin&amp;sub=edit&amp;id=" $id "\">Bewerk</a>\n";
                    echo 
"</td>\n";
                    echo 
"<td class=\"linkstable_middle_left\">\n";
                        echo 
"<a href=\"javascript:askConfirm('Bent u zeker dat u deze link wilt verwijderen?','" $_SERVER['PHP_SELF'] . "?action=admin&amp;sub=del&amp;id=" $id "');\">Verwijder</a>\n";
                    echo 
"</td>\n";
                    echo 
"<td class=\"linkstable_middle_right\" style=\"text-align: center;\">\n";
                        echo 
"<input type=\"checkbox\" name=\"checkbox[".$id."]\" value='yes'\">\n";
                    echo 
"</td>\n";
                echo 
"</tr>\n";
            }
            echo 
"<tr>\n";
                echo 
"<td class=\"linkstable_middle_right\" colspan=\"5\" style=\"text-align: left;\">\n";
                    echo 
"<input type=\"submit\" value=\"Verwijder geselecteerde\" name=\"del\">\n";
                echo 
"</td>\n";
            echo 
"</tr>\n";
        }
        else
        {
            echo 
"<tr>\n";
                echo 
"<td class=\"linkstable_middle_right\" colspan=\"5\" style=\"text-align: center;\">\n";
                    echo 
"Geen links aanwezig.\n";
                echo 
"</td>\n";
            echo 
"</tr>\n";
        }
        echo 
"</table>\n";
        echo 
"</form>\n";
        echo 
"<br>\n";
        echo 
"<small style=\"margin-left: 20px; color: #bababa;\">[ <a href=\"" $_SERVER['PHP_SELF'] . "?action=logout\">logout</a> ] &nbsp;&nbsp;&nbsp;[ <a href=\"" $_SERVER['PHP_SELF'] . "?action=admin&amp;sub=newlink\">Link toevoegen</a> ]</small>\n";
    }
    else
    {
        
header('Location:'.$_SERVER['PHP_SELF'].'?action=login');
    }
}

//-- links verwijderen, verwerking
elseif ($_GET['action'] == "admin" && $_GET['sub'] == "del" && (isset($_POST['del']) || isset($_GET['id'])))
{
    if (isset(
$_SESSION['userid']))
    {
        if (isset(
$_POST['del']))
        {
            
$checkboxes $_POST['checkbox'];
            
            foreach (
$checkboxes as $key => $value)
            {
                
$query[] = mysql_query("DELETE FROM ".TABLE_PREFIX."links WHERE id='" $key "'");
            }
            
            echo 
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"width: 60%; font-size: 14px;\" class=\"linkstable\">\n";
                echo 
"<tr>";
                    echo 
"<td class=\"linkstable_header\">\n";
                        echo 
"Links succesvol verwijderd";
                    echo 
"</td>";
                echo 
"</tr>";
                echo 
"<tr>";
                    echo 
"<td class=\"linkstable_middle\">\n";
                        echo 
"Uw links werd succesvol verwijderd.";
                    echo 
"</td>";
                echo 
"</tr>";
                echo 
"<tr>\n";
                    echo 
"<td class=\"linkstable_middle_right\" colspan=\"3\" style=\"text-align: left;\">\n";
                        echo 
"<a href=\"" $_SERVER['PHP_SELF'] . "?action=admin\">&laquo;&nbsp;Ga naar adminpaneel</a>\n";
                    echo 
"</td>\n";
                echo 
"</tr>\n";
            echo 
"</table>";
        }
        elseif (isset(
$_GET['id']))
        {
            
$id $_GET['id'];
            
            
$count_query mysql_query("SELECT * FROM ".TABLE_PREFIX."links WHERE id='" $id "'");
            
$count mysql_num_rows($count_query);
            
            if (
$count != "0")
            {
                
$query mysql_query("DELETE FROM ".TABLE_PREFIX."links WHERE id='" $id "'");
                
                if (
$query)
                {
                    echo 
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"width: 60%; font-size: 14px;\" class=\"linkstable\">\n";
                        echo 
"<tr>";
                            echo 
"<td class=\"linkstable_header\">\n";
                                echo 
"Link succesvol verwijderd";
                            echo 
"</td>";
                        echo 
"</tr>";
                        echo 
"<tr>";
                            echo 
"<td class=\"linkstable_middle\">\n";
                                echo 
"Uw link werd succesvol verwijderd.";
                            echo 
"</td>";
                        echo 
"</tr>";
                        echo 
"<tr>\n";
                            echo 
"<td class=\"linkstable_middle_right\" colspan=\"3\" style=\"text-align: left;\">\n";
                                echo 
"<a href=\"" $_SERVER['PHP_SELF'] . "?action=admin\">&laquo;&nbsp;Ga naar adminpaneel</a>\n";
                            echo 
"</td>\n";
                        echo 
"</tr>\n";
                    echo 
"</table>";
                }
                else
                {
                    echo 
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"width: 60%; font-size: 14px;\" class=\"linkstable\">\n";
                        echo 
"<tr>";
                            echo 
"<td class=\"linkstable_header\">\n";
                                echo 
"Link niet verwijderd";
                            echo 
"</td>";
                        echo 
"</tr>";
                        echo 
"<tr>";
                            echo 
"<td class=\"linkstable_middle\">\n";
                                echo 
"Er is een fout opgetreden tijdens het verwijderen van de links.";
                            echo 
"</td>";
                        echo 
"</tr>";
                        echo 
"<tr>\n";
                            echo 
"<td class=\"linkstable_middle_right\" colspan=\"3\" style=\"text-align: left;\">\n";
                                echo 
"<a href=\"" $_SERVER['PHP_SELF'] . "?action=admin\">&laquo;&nbsp;Ga naar adminpaneel</a>\n";
                            echo 
"</td>\n";
                        echo 
"</tr>\n";
                    echo 
"</table>";
                }
            }
            else
            {
                echo 
"De door u opgegeven link bestaat niet";
            }
        }
    }
    else
    {
        
header('Location:'.$_SERVER['PHP_SELF'].'?action=login');
    }
}

//-- link toevoegen
elseif ($_GET['action'] == "admin" && $_GET['sub'] == "newlink" && !isset($_POST['newlink']))
{
    if (isset(
$_SESSION['userid']))
    {
        echo 
"<h3 style=\"text-align: center;\">Een nieuwe link toevoegen</h3>";

        echo 
"<form action=\"" $_SERVER['PHP_SELF'] . "?action=admin&amp;sub=newlink\" method=\"post\">\n";
        echo 
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"width: 60%; font-size: 14px;\" class=\"linkstable\">\n";
            echo 
"<tr>";
                echo 
"<td class=\"linkstable_header_left\">\n";
                    echo 
"Linknaam";
                echo 
"</td>";
                echo 
"<td class=\"linkstable_header_left\">\n";
                    echo 
"Link";
                echo 
"</td>";
                echo 
"<td class=\"linkstable_header_right\">\n";
                    echo 
"Beschrijving";
                echo 
"</td>";
            echo 
"</tr>";
            echo 
"<tr>";
                echo 
"<td class=\"linkstable_middle_left\">\n";
                    echo 
"<input type=\"text\" name=\"linknaam\" size=\"30\">";
                echo 
"</td>";
                echo 
"<td class=\"linkstable_middle_left\">\n";
                    echo 
"<input type=\"text\" name=\"link\" size=\"30\">";
                echo 
"</td>";
                echo 
"<td class=\"linkstable_middle_right\" style=\"text-align: left;\">\n";
                    echo 
"<input type=\"text\" name=\"beschrijving\" size=\"30\">";
                echo 
"</td>";
            echo 
"</tr>";
            echo 
"<tr>\n";
                echo 
"<td class=\"linkstable_middle_right\" colspan=\"3\" style=\"text-align: left;\">\n";
                    echo 
"<input type=\"submit\" value=\"Toevoegen\" name=\"newlink\">\n";
                echo 
"</td>\n";
            echo 
"</tr>\n";
            echo 
"<tr>\n";
                echo 
"<td class=\"linkstable_middle_right\" colspan=\"3\" style=\"text-align: left;\">\n";
                    echo 
"<a href=\"" $_SERVER['PHP_SELF'] . "?action=admin\">&laquo;&nbsp;Ga naar adminpaneel</a>\n";
                echo 
"</td>\n";
            echo 
"</tr>\n";
        echo 
"</table>";
        echo 
"</form>";
    }
    else
    {
        
header('Location:'.$_SERVER['PHP_SELF'].'?action=login');
    }
}

//-- link toevoegen, verwerking
elseif ($_GET['action'] == "admin" && $_GET['sub'] == "newlink" && isset($_POST['newlink']))
{
    if (isset(
$_SESSION['userid']))
    {
        
$beschrijving $_POST['beschrijving'];
        
$linknaam $_POST['linknaam'];
        
$link $_POST['link'];
        
        if (!empty(
$beschrijving) && !empty($link))
        {
            if (empty(
$linknaam))
            {
                
$linknaam $link;
            }
            else
            {
                
$linknaam $linknaam;
            }
            
            if (
strpos($link,"tp://") == "2")
            {
                
$link $link;
            }
            else
            {
                
$link "http://".$link;
            }
            
            
$actions "'" $link "',";
            
$actions .= "'" $linknaam "',";
            
$actions .= "'" $beschrijving "'";
            
            
$query mysql_query("INSERT INTO ".TABLE_PREFIX."links (url, linktext, description) VALUES (" $actions ")");
            
            if (
$query)
            {
                echo 
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"width: 60%; font-size: 14px;\" class=\"linkstable\">\n";
                    echo 
"<tr>";
                        echo 
"<td class=\"linkstable_header\">\n";
                            echo 
"Link succesvol toegevoegd";
                        echo 
"</td>";
                    echo 
"</tr>";
                    echo 
"<tr>";
                        echo 
"<td class=\"linkstable_middle\">\n";
                            echo 
"Uw link werd succesvol toegevoegd.";
                        echo 
"</td>";
                    echo 
"</tr>";
                    echo 
"<tr>\n";
                        echo 
"<td class=\"linkstable_middle_right\" colspan=\"3\" style=\"text-align: left;\">\n";
                            echo 
"<a href=\"" $_SERVER['PHP_SELF'] . "?action=admin\">&laquo;&nbsp;Ga naar adminpaneel</a>\n";
                        echo 
"</td>\n";
                    echo 
"</tr>\n";
                echo 
"</table>";
            }
            else
            {
                echo 
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"width: 60%; font-size: 14px;\" class=\"linkstable\">\n";
                    echo 
"<tr>";
                        echo 
"<td class=\"linkstable_header\">\n";
                            echo 
"Link niet toegevoegd";
                        echo 
"</td>";
                    echo 
"</tr>";
                    echo 
"<tr>";
                        echo 
"<td class=\"linkstable_middle\">\n";
                            echo 
"Er is een fout opgetreden tijdens het toevoegen van de link. Klik op 'Ga terug' om het nogmaals te proberen.";
                        echo 
"</td>";
                    echo 
"</tr>";
                    echo 
"<tr>\n";
                        echo 
"<td class=\"linkstable_middle_right\" colspan=\"3\" style=\"text-align: left;\">\n";
                            echo 
"<a href=\"javascript:history.go(-1)\">&laquo;&nbsp;Ga terug</a>\n";
                        echo 
"</td>\n";
                    echo 
"</tr>\n";
                echo 
"</table>";
            }
        }
        else
        {
            echo 
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"width: 60%; font-size: 14px;\" class=\"linkstable\">\n";
                echo 
"<tr>";
                    echo 
"<td class=\"linkstable_header\">\n";
                        echo 
"Geen beschrijving en/of link opgegeven";
                    echo 
"</td>";
                echo 
"</tr>";
                echo 
"<tr>";
                    echo 
"<td class=\"linkstable_middle\">\n";
                        echo 
"U heeft geen link en/of beschrijving opgegeven. Klik op 'Ga terug' om het nogmaals te proberen.";
                    echo 
"</td>";
                echo 
"</tr>";
                echo 
"<tr>\n";
                    echo 
"<td class=\"linkstable_middle_right\" colspan=\"3\" style=\"text-align: left;\">\n";
                        echo 
"<a href=\"javascript:history.go(-1)\">&laquo;&nbsp;Ga terug</a>\n";
                    echo 
"</td>\n";
                echo 
"</tr>\n";
            echo 
"</table>";
        }
    }
    else
    {
        
header('Location:'.$_SERVER['PHP_SELF'].'?action=login');
    }
}

//-- link wijzigen
elseif ($_GET['action'] == "admin" && $_GET['sub'] == "edit" && isset($_GET['id']) && !isset($_POST['editlink']))
{
    if (isset(
$_SESSION['userid']))
    {
        
$query mysql_query("SELECT * FROM ".TABLE_PREFIX."links WHERE id='" $_GET['id'] . "'");
        
        
$count mysql_num_rows($query);
        
        if (
$count != "0")
        {
            
$data mysql_fetch_array($query);
            
            
$linktext $data['linktext'];
            
$link $data['url'];
            
$description $data['description'];
            
            echo 
"<h3 style=\"text-align: center;\">Een link wijzigen</h3>";
    
            echo 
"<form action=\"" $_SERVER['PHP_SELF'] . "?action=admin&amp;sub=edit&amp;id=" $_GET['id'] . "\" method=\"post\">\n";
            echo 
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"width: 60%; font-size: 14px;\" class=\"linkstable\">\n";
                echo 
"<tr>";
                    echo 
"<td class=\"linkstable_header_left\">\n";
                        echo 
"Linknaam";
                    echo 
"</td>";
                    echo 
"<td class=\"linkstable_header_left\">\n";
                        echo 
"Link";
                    echo 
"</td>";
                    echo 
"<td class=\"linkstable_header_right\">\n";
                        echo 
"Beschrijving";
                    echo 
"</td>";
                echo 
"</tr>";
                echo 
"<tr>";
                    echo 
"<td class=\"linkstable_middle_left\">\n";
                        echo 
"<input type=\"text\" name=\"linknaam\" size=\"30\" value=\"" $linktext "\">";
                    echo 
"</td>";
                    echo 
"<td class=\"linkstable_middle_left\">\n";
                        echo 
"<input type=\"text\" name=\"link\" size=\"30\" value=\"" $link "\">";
                    echo 
"</td>";
                    echo 
"<td class=\"linkstable_middle_right\" style=\"text-align: left;\">\n";
                        echo 
"<input type=\"text\" name=\"beschrijving\" size=\"30\" value=\"" $description "\">";
                    echo 
"</td>";
                echo 
"</tr>";
                echo 
"<tr>\n";
                    echo 
"<td class=\"linkstable_middle_right\" colspan=\"3\" style=\"text-align: left;\">\n";
                        echo 
"<input type=\"submit\" value=\"Wijzigen\" name=\"editlink\">\n";
                    echo 
"</td>\n";
                echo 
"</tr>\n";
                echo 
"<tr>\n";
                    echo 
"<td class=\"linkstable_middle_right\" colspan=\"3\" style=\"text-align: left;\">\n";
                        echo 
"<a href=\"" $_SERVER['PHP_SELF'] . "?action=admin\">&laquo;&nbsp;Ga naar adminpaneel</a>\n";
                    echo 
"</td>\n";
                echo 
"</tr>\n";
            echo 
"</table>";
            echo 
"</form>";
        }
        else
        {
            echo 
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"width: 60%; font-size: 14px;\" class=\"linkstable\">\n";
                echo 
"<tr>";
                    echo 
"<td class=\"linkstable_header\">\n";
                        echo 
"Link niet gevonden";
                    echo 
"</td>";
                echo 
"</tr>";
                echo 
"<tr>";
                    echo 
"<td class=\"linkstable_middle\">\n";
                        echo 
"De door u opgegeven link werd niet gevonden.";
                    echo 
"</td>";
                echo 
"</tr>";
                echo 
"<tr>\n";
                    echo 
"<td class=\"linkstable_middle_right\" colspan=\"3\" style=\"text-align: left;\">\n";
                        echo 
"<a href=\"" $_SERVER['PHP_SELF'] . "?action=admin\">&laquo;&nbsp;Ga naar adminpaneel</a>\n";
                    echo 
"</td>\n";
                echo 
"</tr>\n";
            echo 
"</table>";
        }
    }
    else
    {
        
header('Location:'.$_SERVER['PHP_SELF'].'?action=login');
    }
}

//-- link wijzigen, verwerking
elseif ($_GET['action'] == "admin" && $_GET['sub'] == "edit" && isset($_GET['id']) && isset($_POST['editlink']))
{
    if (isset(
$_SESSION['userid']))
    {
        
$beschrijving $_POST['beschrijving'];
        
$linknaam $_POST['linknaam'];
        
$link $_POST['link'];
        
        if (!empty(
$beschrijving) && !empty($link))
        {
            if (empty(
$linknaam))
            {
                
$linknaam $link;
            }
            else
            {
                
$linknaam $linknaam;
            }
            
            if (
strpos($link,"tp://") == "2")
            {
                
$link $link;
            }
            else
            {
                
$link "http://".$link;
            }
            
            
$actions "url='" $link "',";
            
$actions .= "linktext='" $linknaam "',";
            
$actions .= "description='" $beschrijving "'";
            
            
$query mysql_query("UPDATE ".TABLE_PREFIX."links SET " $actions " WHERE id='" $_GET['id'] . "'");
            
            if (
$query)
            {
                echo 
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"width: 60%; font-size: 14px;\" class=\"linkstable\">\n";
                    echo 
"<tr>";
                        echo 
"<td class=\"linkstable_header\">\n";
                            echo 
"Link succesvol gewijzigd";
                        echo 
"</td>";
                    echo 
"</tr>";
                    echo 
"<tr>";
                        echo 
"<td class=\"linkstable_middle\">\n";
                            echo 
"Uw link werd succesvol gewijzigd.";
                        echo 
"</td>";
                    echo 
"</tr>";
                    echo 
"<tr>\n";
                        echo 
"<td class=\"linkstable_middle_right\" colspan=\"3\" style=\"text-align: left;\">\n";
                            echo 
"<a href=\"" $_SERVER['PHP_SELF'] . "?action=admin\">&laquo;&nbsp;Ga naar adminpaneel</a>\n";
                        echo 
"</td>\n";
                    echo 
"</tr>\n";
                echo 
"</table>";
            }
            else
            {
                echo 
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"width: 60%; font-size: 14px;\" class=\"linkstable\">\n";
                    echo 
"<tr>";
                        echo 
"<td class=\"linkstable_header\">\n";
                            echo 
"Link niet gewijzigd";
                        echo 
"</td>";
                    echo 
"</tr>";
                    echo 
"<tr>";
                        echo 
"<td class=\"linkstable_middle\">\n";
                            echo 
"Er is een fout opgetreden tijdens het wijzigen van de link. Klik op 'Ga terug' om het nogmaals te proberen.";
                        echo 
"</td>";
                    echo 
"</tr>";
                    echo 
"<tr>\n";
                        echo 
"<td class=\"linkstable_middle_right\" colspan=\"3\" style=\"text-align: left;\">\n";
                            echo 
"<a href=\"javascript:history.go(-1)\">&laquo;&nbsp;Ga terug</a>\n";
                        echo 
"</td>\n";
                    echo 
"</tr>\n";
                echo 
"</table>";
            }
        }
        else
        {
            echo 
"<table cellspacing=\"0\" cellpadding=\"0\" style=\"width: 60%; font-size: 14px;\" class=\"linkstable\">\n";
                echo 
"<tr>";
                    echo 
"<td class=\"linkstable_header\">\n";
                        echo 
"Geen beschrijving en/of link opgegeven";
                    echo 
"</td>";
                echo 
"</tr>";
                echo 
"<tr>";
                    echo 
"<td class=\"linkstable_middle\">\n";
                        echo 
"U heeft geen link en/of beschrijving opgegeven. Klik op 'Ga terug' om het nogmaals te proberen.";
                    echo 
"</td>";
                echo 
"</tr>";
                echo 
"<tr>\n";
                    echo 
"<td class=\"linkstable_middle_right\" colspan=\"3\" style=\"text-align: left;\">\n";
                        echo 
"<a href=\"javascript:history.go(-1)\">&laquo;&nbsp;Ga terug</a>\n";
                    echo 
"</td>\n";
                echo 
"</tr>\n";
            echo 
"</table>";
        }
    }
    else
    {
        
header('Location:'.$_SERVER['PHP_SELF'].'?action=login');
    }
}
?>
</body>
</html>

Nog geen reacties

Om te reageren moet je ingelogd zijn.
Nog niet geregistreerd? Doe dat dan nu!


Terug naar gewone pagina

Websitemaken wordt gehost door Nucleus.be, uw Hosting Solution Builder