Browse files

makeis impossible to insert incorect link into fields twitter,linkedi…

…n,facebook (close #81)
  • Loading branch information...
1 parent 870b105 commit 46642d08b08342a06564fcb9737b4d1d5069fb06 @KryDos KryDos committed Dec 24, 2012
Showing with 17 additions and 0 deletions.
  1. +3 −0 lang/English/profile.php
  2. +14 −0 profile.php
View
3 lang/English/profile.php
@@ -92,6 +92,9 @@
'AOL IM' => 'AOL IM',
'Forbidden title' => 'The title you entered contains a forbidden word. You must choose a different title.',
'Bad ICQ' => 'You entered an invalid ICQ UIN.',
+'Bad Twitter' => 'You entered an invalid Twitter accaunt.',
+'Bad Facebook' => 'You entered an invalid Facebook accaunt.',
+'Bad LinkedIn' => 'You entered an invalid LinkedIn accaunt.',
'Yahoo' => 'Yahoo! Messenger',
'Posts and topics' => 'Posts and topics',
'Private info' => 'Private information',
View
14 profile.php
@@ -975,6 +975,20 @@ function extract_elements($allowed_elements)
if ($form['url'] != '' && strpos(strtolower($form['url']), 'http://') !== 0 && strpos(strtolower($form['url']), 'https://') !== 0)
$form['url'] = 'http://'.$form['url'];
+ //check Facebook for validity
+ if (strpos($form['facebook'], 'http://') === 0 || strpos($form['facebook'], 'https://') === 0)
+ if (!preg_match('#https?://(www\.)?facebook.com/.+?#', $form['facebook']))
+ $errors[] = $lang_profile['Bad Facebook'];
+
+ //check Twitter for validity
+ if (strpos($form['twitter'], 'http://') === 0 || strpos($form['twitter'], 'https://') === 0)
+ if (!preg_match('#https?://twitter.com/.+?#', $form['twitter']))
+ $errors[] = $lang_profile['Bad Twitter'];
+
+ //check LinkedIn for validity
+ if (!preg_match('#https?://(www\.)?linkedin.com/.+?#', $form['linkedin']))
+ $errors[] = $lang_profile['Bad LinkedIn'];
+
// Add http:// if the LinkedIn doesn't contain it or https:// already
if ($form['linkedin'] != '' && strpos(strtolower($form['linkedin']), 'http://') !== 0 && strpos(strtolower($form['linkedin']), 'https://') !== 0)
$form['linkedin'] = 'http://'.$form['linkedin'];

0 comments on commit 46642d0

Please sign in to comment.