Author
|
zPlus <->
2016-04-21 12:47:57
|
Committer
|
zPlus <->
2016-04-21 12:47:57
|
Commit
|
ed6bc91
(patch)
|
Tree
|
72006f6
|
Parent(s)
|
|
New submission: add HTTP as default URL Scheme when missing
commits diff:
5adaffa..ed6bc91
1 file changed,
13 insertions,
2 deletions
—
download
Diffstat
Diff options
+13/-2
M submit.php
33
|
33
|
|
exit ();
|
34
|
34
|
|
}
|
35
|
35
|
|
|
36
|
|
- |
// Title is ok, add the new post
|
37
|
|
- |
$post_hash_id = $db->new_post ($title, $_POST['link'], $_POST['text'], Session::get_userid());
|
|
36
|
+ |
// Normalize Link
|
|
37
|
+ |
$link = trim ($_POST['link']);
|
|
38
|
+ |
|
|
39
|
+ |
if (strlen ($link) > 0)
|
|
40
|
+ |
{
|
|
41
|
+ |
$link_components = parse_url ($link);
|
|
42
|
+ |
|
|
43
|
+ |
if (!isset ($link_components['scheme']))
|
|
44
|
+ |
$link = 'http://' . $link;
|
|
45
|
+ |
}
|
|
46
|
+ |
|
|
47
|
+ |
// Add the new post
|
|
48
|
+ |
$post_hash_id = $db->new_post ($title, $link, $_POST['text'], Session::get_userid());
|
38
|
49
|
|
|
39
|
50
|
|
// Redirect to the new post page
|
40
|
51
|
|
header ('Location: ./post/' . $post_hash_id);
|