Changeset 1550 in ExiteCMS
- Timestamp:
- 07/27/08 14:26:17 (4 years ago)
- Location:
- trunk/includes
- Files:
-
- 3 edited
-
core_functions.php (modified) (1 diff)
-
forum_functions_include.php (modified) (6 diffs)
-
geoip_include.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/core_functions.php
r1522 r1550 385 385 $urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*"; // HOSTNAME or IP 386 386 $urlregex .= "(\:[0-9]{2,5})?"; // PORT (optional) 387 $urlregex .= "(\/([a-z0-9+\$_ -]\.?)+)*\/?";// PATH (optional)387 $urlregex .= "(\/([a-z0-9+\$_%-]\.?)+)*\/?"; // PATH (optional) 388 388 $urlregex .= "(\?[a-z+&\$_.-][a-z0-9;:@/&%=+\$_.-]*)?"; // GET querystring (optional) 389 389 $urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)?\$"; // ANCHOR (optional) -
trunk/includes/forum_functions_include.php
r1527 r1550 18 18 $codeblocks = array(); 19 19 $urlblocks = array(); 20 $imgblocks = array(); 20 21 $blockcount = 0; 21 22 $raw_color_blocks = false; … … 337 338 return ""; 338 339 } 339 // trim the values passed 340 341 // remove leading CRLF 342 if (substr($matches[2],0,2) == "\r\n") { 343 $matches[2] = substr($matches[2],2); 344 } 345 346 // remove the leading '=' from the file type 340 347 $matches[1] = trim(substr($matches[1],1)); 341 348 349 // colorize the code if requested 342 350 if ($raw_color_blocks == false) { 343 351 require_once PATH_GESHI."/geshi.php"; 344 352 $geshi =& new GeSHi("", ""); 345 // colorize the code346 353 $geshi->set_language($matches[1]); 347 354 $geshi->set_header_type(GESHI_HEADER_DIV); … … 351 358 } 352 359 360 // if a raw block was requested, bail out here 353 361 if ($raw_color_blocks) { 354 362 $codeblocks[] = array($matches[2], $matches[1]); … … 376 384 } 377 385 378 // message parser, strip [code] and [url] sections, parse for BBcode and smiley's, then insert the sections again 386 function _parseubb_imgblock($matches) { 387 global $imgblocks; 388 389 $imgblocks[] = array($matches[1], $matches[1]); 390 return "{@*@".(count($imgblocks)-1)."@*@}"; 391 } 392 393 // message parser, strip [code], [img] and [url] sections, parse for BBcode, smiley's, then insert the sections again 379 394 function parsemessage($msg_array) { 380 395 global $settings, $db_prefix, $codeblocks, $urlblocks, $current_message; … … 392 407 $codeblocks = array(); 393 408 $urlblocks = array(); 409 $imgblocks = array(); 410 411 // convert any newlines to html <br> 412 $rawmsg = nl2br($rawmsg); 394 413 395 414 // strip CODE bbcode, optionally perform Geshi color coding 396 415 $rawmsg = preg_replace_callback('#\[code(=.*?)?\](.*?)([\r\n]*)\[/code\]#si', '_parseubb_codeblock', $rawmsg); 397 416 417 // find URL's in the text, and convert them to a [url] BBcode 418 $rawmsg = preg_replace("#(^|\s)(www|WWW)\.([^\s<>\/]+)\/([^\s\r\n<>\)\,\:\;\[]+)#sm", "\\1[url=http://\\2.\\3/\\4]http://\\2.\\3[/url]", $rawmsg); 419 $rawmsg = preg_replace("#(^|[^\"=\]]{1})(http|HTTP|ftp)(s|S)?://([^\s<>\/]+)\/([^\s\r\n<>\,\[]+)#sm", "\\1[url=\\2\\3://\\4/\\5]\\2\\3://\\4\\5[/url]", $rawmsg); 420 398 421 // strip URL bbcode 399 422 $rawmsg = preg_replace_callback('#\[url(=.*?)\](.*?)([\r\n]*)\[/url\]#si', '_parseubb_urlblock', $rawmsg); 423 424 // strip IMG bbcode 425 // $rawmsg = preg_replace_callback('#\[img\](.*?)([\r\n]*)\[/img\]#si', '_parseubb_imgblock', $rawmsg); 400 426 401 427 // detect and convert wikitags to wiki bbcodes if needed … … 406 432 $result = dbquery("SELECT DISTINCT tag FROM ".$db_prefix."wiki_pages"); 407 433 while ($data = dbarray($result)) { 408 $search[] = "/([[:space:]\.\,-])+?(".$data['tag'].")([[:space:]\.\,-]+?|\]|$)/i"; 409 $replace[] = "\\1[wiki]\\2[/wiki]\\3"; 434 if (!empty($data['tag'])) { 435 $search[] = "/(\b)(".$data['tag'].")(\b)/i"; 436 $replace[] = "\\1[wiki]\\2[/wiki]\\3"; 437 } 410 438 } 411 439 $rawmsg = preg_replace($search, $replace, $rawmsg); 440 } 441 442 // re-insert the saved img blocks 443 foreach($imgblocks as $key => $imgblock) { 444 $rawmsg = str_replace("{*@*".$key."*@*}", $imgblock[0], $rawmsg); 412 445 } 413 446 414 447 // parse the smileys in the message 415 448 if ($smileys) $rawmsg = parsesmileys($rawmsg); 449 416 450 // parse all ubbcode 417 451 $rawmsg = parseubb($rawmsg); 418 // convert any newlines to html <br>419 $rawmsg = str_replace("\r\n\r\n", "\r\n", $rawmsg);420 $rawmsg = nl2br($rawmsg);421 452 422 423 453 // re-insert the saved code blocks 424 454 foreach($codeblocks as $key => $codeblock) { -
trunk/includes/geoip_include.php
r1478 r1550 29 29 global $db_prefix, $_GeoIP_result; 30 30 31 // convert the IP address to a number32 $ipnum = GeoIP_IP2Num($ip_addr);33 if (!$ipnum) return false;34 35 31 // not cached? 36 if (!isset($_GeoIP_result[$ip num])) {32 if (!isset($_GeoIP_result[$ip_addr])) { 37 33 38 34 // check if there is an exception defined … … 40 36 if ($data = dbarray($result)) { 41 37 // add it to the cache 42 $_GeoIP_result[$ip num] = $data['ip_code'];38 $_GeoIP_result[$ip_addr] = $data['ip_code']; 43 39 } else { 40 // convert the IP address to a number 41 $ipnum = GeoIP_IP2Num($ip_addr); 42 if (!$ipnum) return false; 44 43 // look this IP address up 45 44 $result = dbquery("SELECT * FROM ".$db_prefix."GeoIP WHERE '".sprintf("%u", $ipnum)."' BETWEEN ip_start_num AND ip_end_num LIMIT 1"); 46 45 if ($data = dbarray($result)) { 47 46 // add it to the cache 48 $_GeoIP_result[$ip num] = $data['ip_code'];47 $_GeoIP_result[$ip_addr] = $data['ip_code']; 49 48 } else { 50 $_GeoIP_result[$ip num] = false;49 $_GeoIP_result[$ip_addr] = false; 51 50 } 52 51 } … … 54 53 } 55 54 56 return $_GeoIP_result[$ip num];55 return $_GeoIP_result[$ip_addr]; 57 56 } 58 57 … … 71 70 global $db_prefix, $settings; 72 71 73 $result = dbquery("SELECT locales_value FROM ".$db_prefix."locales WHERE locales_code = '".$settings['locale_code']."' AND locales_name = 'countrycode' AND locales_key = '".$ip_code."' LIMIT 1"); 74 if (!dbrows($result)) { 75 // no translated country names found, load the english set instead 76 $result = dbquery("SELECT locales_value FROM ".$db_prefix."locales WHERE locales_code = 'en' AND locales_name = 'countrycode' AND locales_key = '".$ip_code."' LIMIT 1"); 72 // not cached? 73 if (!isset($_GeoIP_result[$ip_code])) { 74 75 $result = dbquery("SELECT locales_value FROM ".$db_prefix."locales WHERE locales_code = '".$settings['locale_code']."' AND locales_name = 'countrycode' AND locales_key = '".$ip_code."' LIMIT 1"); 76 if (!dbrows($result)) { 77 // no translated country names found, load the english set instead 78 $result = dbquery("SELECT locales_value FROM ".$db_prefix."locales WHERE locales_code = 'en' AND locales_name = 'countrycode' AND locales_key = '".$ip_code."' LIMIT 1"); 79 } 80 if (dbrows($result) == 0) { 81 $_GeoIP_result[$ip_code] = ""; 82 } else { 83 $data = dbarray($result); 84 $_GeoIP_result[$ip_code] = $data['locales_value']; 85 } 77 86 } 78 if (dbrows($result) == 0) { 79 return ""; 80 } 81 $data = dbarray($result); 82 return $data['locales_value']; 87 88 return $_GeoIP_result[$ip_code]; 83 89 } 84 90
Note: See TracChangeset
for help on using the changeset viewer.
