Lid |
|
Hallo allemaal!
Ik heb een linkpartnerscript (zonder MySQL) maar als ik een link wil plaatsen gebeurd er niks. Kan iemand me daar mee helpen??
Dit is de code: (code staat ook hier: http://www.plaatscode.be/137361/)
<?php
ob_start();
function control_url($in) {
$start_url = "(http(s)?\:\/\/)?";
$punten = "([\w_-]{2,}\.)+";
$laatste_deel = "([\w_-]{2,})";
$user = "((\/)(\~)[\w_-]+)?((\/)[\w_-]+)*";
$eind = "((\/)|(\/)[\w_-]+\.[\w]{2,})?";
$qstring1 = "((\?[\w_-]+\=([^\#]+)){0,1}";
$qstring2 = "(\&[\w_-]+\=([^\#]+))*)?";
$bkmrk = "(#[\w_-]+)?";
$exp = "/^".$start_url.$punten.$laatste_deel.$user.$eind.$qstring1.$qstring2.$bkmrk."$/i";
return preg_match($exp, $in);
}
$bestand = "links.txt";
$fp = fopen($bestand, "r");
$links = fread($fp, filesize ($bestand));
fclose($fp);
$catogorie = array("Winkels", "Startpagina's", "Hobbysites");
$links_totaal = explode("*&!#@", $links);
foreach($catogorie as $key => $value){
$links_in_catogorie = explode("?-`~%", $links_totaal[$key]);
?>
<table class="link_tabel" cellspacing="0" cellpadding="2">
<tr>
<td class="link_catogorie"><?php echo $value ?></td>
</tr>
<tr>
<td><?php
for($i = 0; $i < count($links_in_catogorie)-1; $i ++){
echo "- <a href=\"".$links_in_catogorie[$i]."\" target=\"blank\">".$links_in_catogorie[$i]."</a><br>";
}
?></td>
</tr>
</table><br>
<?php
}
?>
<form method="post">
<table class="link_tabel" cellspacing="0" cellpadding="2">
<tr>
<td class="link_catogorie" colspan="2">Link toevoegen</td>
</tr>
<tr>
<td>Link:</td>
<td><input type="text" name="adres" value="http://" size="40">
<?php
if(isset($_POST['verzenden'])){
if(control_url($_POST['adres'])) {
for($i = 0; $i < count($catogorie); $i++)
{
if($i == $_POST['catogorie']){
$invoegen.=$_POST['adres']."?-`~%".$links_totaal[$_POST['catogorie']]."*&!#@";
}
else
{
$invoegen.= $links_totaal[$i]."*&!#@";
}
}
$fp = fopen($bestand, "w");
fputs($fp, $invoegen);
fclose($fp);
header("location:".$_SERVER['PHP_SELF']);
}
else
{
echo "<font color=\"red\">Url klopt niet!</p>";
}
}
?>
</td>
</tr>
<tr>
<td>Categorie:</td>
<td><select name="catogorie"><?php
foreach($catogorie as $key => $value){
echo "<option value=".$key.">".$value."</option>";
}
?></select></td>
</tr>
<tr>
<td><!-- No contents --></td>
<td><input type="submit" name="verzenden" value="Verzenden"></td>
</tr>
</table>
</form>
<?php function control_url($in) { $start_url = "(http(s)?\:\/\/)?"; $punten = "([\w_-]{2,}\.)+"; $laatste_deel = "([\w_-]{2,})"; $user = "((\/)(\~)[\w_-]+)?((\/)[\w_-]+)*"; $eind = "((\/)|(\/)[\w_-]+\.[\w]{2,})?"; $qstring1 = "((\?[\w_-]+\=([^\#]+)){0,1}"; $qstring2 = "(\&[\w_-]+\=([^\#]+))*)?"; $bkmrk = "(#[\w_-]+)?"; $exp = "/^".$start_url.$punten.$laatste_deel.$user.$eind.$qstring1.$qstring2.$bkmrk."$/i"; } $bestand = "links.txt"; $fp = fopen($bestand, "r"); $catogorie = array("Winkels", "Startpagina's", "Hobbysites"); $links_totaal = explode("*&!#@", $links); foreach($catogorie as $key => $value){ $links_in_catogorie = explode("?-`~%", $links_totaal[$key]); ?> <table class="link_tabel" cellspacing="0" cellpadding="2"> <tr> <td class="link_catogorie"> <?php echo $value ?></td> </tr> <tr> <td><?php for($i = 0; $i < count($links_in_catogorie)-1; $i ++){ echo "- <a href=\"".$links_in_catogorie[$i]."\" target=\"blank\">".$links_in_catogorie[$i]."</a><br>"; } ?></td> </tr> </table><br> <?php } ?> <form method="post"> <table class="link_tabel" cellspacing="0" cellpadding="2"> <tr> <td class="link_catogorie" colspan="2">Link toevoegen</td> </tr> <tr> <td>Link:</td> <td><input type="text" name="adres" value="http://" size="40"> <?php if(isset($_POST['verzenden'])){ if(control_url($_POST['adres'])) { for($i = 0; $i < count($catogorie); $i++) { if($i == $_POST['catogorie']){ $invoegen.=$_POST['adres']."?-`~%".$links_totaal[$_POST['catogorie']]."*&!#@"; } else { $invoegen.= $links_totaal[$i]."*&!#@"; } } $fp = fopen($bestand, "w"); header("location:".$_SERVER['PHP_SELF']); } else { echo "<font color=\"red\">Url klopt niet!</p>"; } } ?> </td> </tr> <tr> <td>Categorie:</td> <td><select name="catogorie"><?php foreach($catogorie as $key => $value){ echo "<option value=".$key.">".$value."</option>"; } ?></select></td> </tr> <tr> <td><!-- No contents --></td> <td><input type="submit" name="verzenden" value="Verzenden"></td> </tr> </table> </form>
|