X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Futil.php;h=46aa7f90121f0edfc258e312ae48cf364ab1b3bf;hb=9f15febf88769493aa834cab5b916cb46298842a;hp=31a78a876a529f253318148348f151cbe3b15fdf;hpb=8782f5fedfc9eaf98a1d72a545b62cc5bc387e26;p=quix0rs-gnu-social.git diff --git a/lib/util.php b/lib/util.php index 31a78a876a..46aa7f9012 100644 --- a/lib/util.php +++ b/lib/util.php @@ -127,8 +127,17 @@ function common_check_user($nickname, $password) if (is_null($user) || $user === false) { return false; } else { - if (0 == strcmp(common_munge_password($password, $user->id), - $user->password)) { + $authenticated = false; + Event::handle('CheckPassword', array($nickname, $password, &$authenticated)); + if(! $authenticated){ + //no handler asserted the user, so check ourselves + if (0 == strcmp(common_munge_password($password, $user->id), + $user->password)) { + //internal checking passed + $authenticated = true; + } + } + if($authenticated){ return $user; } else { return false; @@ -422,7 +431,7 @@ function common_render_text($text) function common_replace_urls_callback($text, $callback, $notice_id = null) { // Start off with a regex $regex = '#'. - '(?:^|[\s\(\)\[\]\{\}\\\'\\\";]+)(?![\@\!\#])'. + '(?:^|[\s\<\>\(\)\[\]\{\}\\\'\\\";]+)(?![\@\!\#])'. '('. '(?:'. '(?:'. //Known protocols @@ -480,6 +489,10 @@ function callback_helper($matches, $callback, $notice_id) { array( 'left'=>'{', 'right'=>'}' + ), + array( + 'left'=>'<', + 'right'=>'>' ) ); $cannotEndWith=array('.','?',',','#'); @@ -1366,9 +1379,28 @@ function common_memcache() } } +function common_license_terms($uri) +{ + if(preg_match('/creativecommons.org\/licenses\/([^\/]+)/', $uri, $matches)) { + return explode('-',$matches[1]); + } + return array($uri); +} + function common_compatible_license($from, $to) { + $from_terms = common_license_terms($from); + // public domain and cc-by are compatible with everything + if(count($from_terms) == 1 && ($from_terms[0] == 'publicdomain' || $from_terms[0] == 'by')) { + return true; + } + $to_terms = common_license_terms($to); + // sa is compatible across versions. IANAL + if(in_array('sa',$from_terms) || in_array('sa',$to_terms)) { + return count(array_diff($from_terms, $to_terms)) == 0; + } // XXX: better compatibility check needed here! + // Should at least normalise URIs return ($from == $to); }