Jeg har lavet et script hvor man skal skrive en URL til et avatar billed
mit problem er så bare at hvis jeg skriver:
www.side.com/avatar.gifså gemmer den det som
http://www.minside.dk/www.side.com/avatar.gifmen hvis jeg skriver
http://www.side.com/avatar.gifså hvis jeg sætter http:// foran kan den godt finde ud af det er en anden side den skal finde billedet... men uden http:// tror den at det ligger på min side... og der er mange der bruger det og det er jo ikke alle der er klar over at de SKAL skrive http:// foran
her er mine sider (ved ikke hvad for en af dem den er galt med)
addtutorial.php
<?
ob_start();
include("config.php");
?>
<?PHP
//If the submit button is pressed
if($_POST['submit']){
//Get form data
$title = $_POST['title'];
$description = $_POST['description'];
$avatar = $_POST['avatar'];
$tutorial = $_POST['tutorial'];
$author = $logged['username'];
$date = date("dS M Y");
//Insert Data Into Mysql Database
$results = mysql_query("INSERT INTO tutorials (id, title, description, avatar, tutorial, author, date)
VALUES ('', '$title', '$description', '$avatar', '$tutorial', '$author', '$date' )") or die('Error making query'.mysql_error());
//Tell the user that the staff member has been added
echo "Thank you! The staff member has successfully been added.";
}
//Now we end php and show the form
?>
<table width='90%' cellpadding='0' cellspacing='0' style='border:1px solid #00000000;'>
<tr>
<td>
<center><form action="<? $_SERVER['PHP_SELF'] ?>" method="post">
<table width=\\"400\\" align=\\"center\\" cellpadding=\\"2\\" cellspacing=\\"2\\">
<tr>
<td width="150">Title:</td>
<td><input name="title" type="text"></td>
</tr>
<tr>
<td>Short description:</td>
<td><input name="description" type="text"></td>
</tr>
<tr>
<td>Link to avatar:</td>
<td><input name="avatar" type="text"></td>
</tr>
<tr>
<td valign="top">Tutorial:<br><br><br>
<br>
BBcode:<br><br>
[b]text[/b]<br>
<b>text</b>
<br><br>
[i]text[/i]<br>
<i>text</i>
<br><br>
[u]text[/u]<br>
<u>text</u>
<br><br>
[u]www.site.com[/u]<br>
<a href="www.site.com">www.site.com</a><br><br>
[url=www.site.com]text[/u]<br>
<a href="www.site.com">text</a><br><br>
[img]www.danishdevils.dk/view.gif[/img]<br>
<img src="images/view.gif">
</td>
<td valign="top"><textarea name="tutorial" cols="30" rows="25"></textarea></td>
</tr>
<tr>
<td> </td>
<td><input name="submit" type="submit" value="Submit"></td>
</tr>
</table>
</form></center>
</td></tr>
</table>
<?
ob_start();
include("config.php");
?>
<?php
function bbcode_format ($str) {
$str = htmlentities($str);
$simple_search = array(
'/\\[b\\](.*?)\\[\\/b\\]/is',
'/\\[i\\](.*?)\\[\\/i\\]/is',
'/\\[u\\](.*?)\\[\\/u\\]/is',
'/\\[url\\=(.*?)\\](.*?)\\[\\/url\\]/is',
'/\\[url\\](.*?)\\[\\/url\\]/is',
'/\\[align\\=(left|center|right)\\](.*?)\\[\\/align\\]/is',
'/\\[img\\](.*?)\\[\\/img\\]/is',
'/\\[mail\\=(.*?)\\](.*?)\\[\\/mail\\]/is',
'/\\[mail\\](.*?)\\[\\/mail\\]/is',
'/\\[font\\=(.*?)\\](.*?)\\[\\/font\\]/is',
'/\\[size\\=(.*?)\\](.*?)\\[\\/size\\]/is',
'/\\[color\\=(.*?)\\](.*?)\\[\\/color\\]/is',
);
$simple_replace = array(
'<strong>$1</strong>',
'<em>$1</em>',
'<u>$1</u>',
'<a href="$1">$2</a>',
'<a href="$1">$1</a>',
'<div style="text-align: $1;">$2</div>',
'<img src="$1" />',
'<a href="mailto:$1">$2</a>',
'<a href="mailto:$1">$1</a>',
'<span style="font-family: $1;">$2</span>',
'<span style="font-size: $1;">$2</span>',
'<span style="color: $1;">$2</span>',
);
// Do simple BBCode's
$str = preg_replace ($simple_search, $simple_replace, $str);
// Do <blockquote> BBCode
$str = bbcode_quote ($str);
return $str;
}
function bbcode_quote ($str) {
$open = '<blockquote>';
$close = '</blockquote>';
// How often is the open tag?
preg_match_all ('/\\[quote\\]/i', $str, $matches);
$opentags = count($matches['0']);
// How often is the close tag?
preg_match_all ('/\\[\\/quote\\]/i', $str, $matches);
$closetags = count($matches['0']);
// Check how many tags have been unclosed
// And add the unclosing tag at the end of the message
$unclosed = $opentags - $closetags;
for ($i = 0; $i < $unclosed; $i++) {
$str .= '</blockquote>';
}
// Do replacement
$str = str_replace ('[' . 'quote]', $open, $str);
$str = str_replace ('[/' . 'quote]', $close, $str);
return $str;
}
?>
<?PHP
$id = $_GET['id'];
$sql_events = mysql_query("SELECT * FROM tutorials WHERE id = '" . $id . "'") or die (mysql_error());
while ($row = mysql_fetch_array($sql_events)) {
$id = $row["id"];
$title = $row["title"];
$author = $row["author"];
$tutorial = bbcode_format($row["tutorial"]);
echo "
<table width=\\"400\\" align=\\"center\\" cellpadding=\\"2\\" cellspacing=\\"2\\">
<tr>
<td align=\\"center\\"><font size=\\"2\\" face=\\"Tahoma\\"><b>$title</b></font></td>
</tr>
<tr>
<td align=\\"center\\"><b>Created by:</b> <a href=\\"index.php?page=Members&user=$author\\">$author</a></td>
</tr>
<tr>
<td></td>
</tr>
<tr>
<td align=\\"left\\" width=\\"350\\">$tutorial</td>
</tr>
</table>
";
}
?>