4images Forum & Community
Welcome, Guest. Please login or register.
Did you miss your activation email?
October 21, 2014, 09:03:16 AM

Login with username, password and session length
Search:     Advanced search
Togle to toolbar
Translate this page with =>
Translate this page >
* Home Help Search Login Register
 
+  4images Forum & Community
|-+  4images Issues / Ausgaben
| |-+  Feedback & Suggestions (Moderator: Acidgod)
| | |-+  [FIX] - includes/functions.php file (format_url function)
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: [FIX] - includes/functions.php file (format_url function)  (Read 9443 times)
thunderstrike
4images Guru
*******
Offline Offline

Posts: 2327

Thank You
-Given: 0
-Receive: 10


View Profile
« on: January 15, 2008, 04:41:34 AM »

This is VERY IMPORTANT fix Exclamation

Jan is code format_url function for check https:// and http:// protocol but rational chars is no check. Is say if empty, nothing is show in member profile for user_homepage field but if user enter no valid chars URL type, is still show. E.g: http://www. ... where is full URL ?  Shocked

So - I create fix (and include fix for check http and https). Wink

In includes/functions.php file,

find:

1
2
3
4
5
6
7
8
9
10
11
function format_url($url) {
  if (empty($url)) {
    return '';
  }

  if (!preg_match("/^https?:\/\//i", $url)) {
    $url = "http://".$url;
  }

  return $url;
}

replace:

1
2
3
4
5
6
7
8
9
10
11
12
13
function format_url($url) {
  $url = preg_replace("/[^a-z0-9\_\-\/\.\:]+/i", "", $url);
 
  if (!preg_match("/[a-z0-9]+\.[a-z0-9_-]+\.[a-z]/i", $url)) {
      return '';
  }

  if (!preg_match("/^http|https?:\/\//i", $url)) {
    $url = "http://".$url;
  }
 
  return $url;
}

After install fix:

1 - No possible for add empty URL, no valid chars or no full URL (http or https - no matter).
2 - Save ressource for member editprofile page (USERS_TABLE update SQL query). Empty result is no use action for update SQL query.

Smile
« Last Edit: January 15, 2008, 05:34:02 AM by thunderstrike » Logged

8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?
thunderstrike
4images Guru
*******
Offline Offline

Posts: 2327

Thank You
-Given: 0
-Receive: 10


View Profile
« Reply #1 on: January 15, 2008, 05:34:17 AM »

I update fix (replace function again).
Logged

8 steps need when ask question -

- PHP version (ACP - > phpinfo())
- mySQL version (ACP - > phpinfo())
- 4images version
- Post screenshot / URL
- Post code in BB Code (no need full file for code) or post attach file
- It doesn't work. What is say - what is do for no work
- Install MOD ? If so - please say (troubleshooting)
- Read FAQ ? Install Bug fixes ?
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!
Page created in 0.1 seconds with 19 queries.
Post your comments here