3 // On which page are we ?
4 if (preg_match('#([^/]+.php)#', $PHP_SELF, $self_matches)) {
5 $pagenow = $self_matches[1];
6 } else if (strstr($PHP_SELF, '?')) {
7 $pagenow = explode('/', $PHP_SELF);
8 $pagenow = trim($pagenow[(sizeof($pagenow)-1)]);
9 $pagenow = explode('?', $pagenow);
10 $pagenow = $pagenow[0];
12 $pagenow = 'index.php';
15 // Simple browser detection
16 $is_lynx = 0; $is_gecko = 0; $is_winIE = 0; $is_macIE = 0; $is_opera = 0; $is_NS4 = 0;
17 if (!isset($HTTP_USER_AGENT)) {
18 $HTTP_USER_AGENT = $_SERVER['HTTP_USER_AGENT'];
20 if (preg_match('/Lynx/', $HTTP_USER_AGENT)) {
22 } elseif (preg_match('/Gecko/', $HTTP_USER_AGENT)) {
24 } elseif ((preg_match('/MSIE/', $HTTP_USER_AGENT)) && (preg_match('/Win/', $HTTP_USER_AGENT))) {
26 } elseif ((preg_match('/MSIE/', $HTTP_USER_AGENT)) && (preg_match('/Mac/', $HTTP_USER_AGENT))) {
28 } elseif (preg_match('/Opera/', $HTTP_USER_AGENT)) {
30 } elseif ((preg_match('/Nav/', $HTTP_USER_AGENT) ) || (preg_match('/Mozilla\/4\./', $HTTP_USER_AGENT))) {
33 $is_IE = (($is_macIE) || ($is_winIE));
36 $is_apache = ( strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') || strstr($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') ) ? 1 : 0;
37 $is_IIS = strstr($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') ? 1 : 0;
39 // On OS X Server, $_SERVER['REMOTE_ADDR'] is the server's address. Workaround this
40 // by using $_SERVER['HTTP_PC_REMOTE_ADDR'], which *is* the remote address.
41 if ( isset($_SERVER['HTTP_PC_REMOTE_ADDR']) )
42 $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_PC_REMOTE_ADDR'];
44 // if the config file does not provide the smilies array, let's define it here
45 if (!isset($wpsmiliestrans)) {
46 $wpsmiliestrans = array(
47 ' :)' => 'icon_smile.gif',
48 ' :D' => 'icon_biggrin.gif',
49 ' :-D' => 'icon_biggrin.gif',
50 ':grin:' => 'icon_biggrin.gif',
51 ' :)' => 'icon_smile.gif',
52 ' :-)' => 'icon_smile.gif',
53 ':smile:' => 'icon_smile.gif',
54 ' :(' => 'icon_sad.gif',
55 ' :-(' => 'icon_sad.gif',
56 ':sad:' => 'icon_sad.gif',
57 ' :o' => 'icon_surprised.gif',
58 ' :-o' => 'icon_surprised.gif',
59 ':eek:' => 'icon_surprised.gif',
60 ' 8O' => 'icon_eek.gif',
61 ' 8-O' => 'icon_eek.gif',
62 ':shock:' => 'icon_eek.gif',
63 ' :?' => 'icon_confused.gif',
64 ' :-?' => 'icon_confused.gif',
65 ' :???:' => 'icon_confused.gif',
66 ' 8)' => 'icon_cool.gif',
67 ' 8-)' => 'icon_cool.gif',
68 ':cool:' => 'icon_cool.gif',
69 ':lol:' => 'icon_lol.gif',
70 ' :x' => 'icon_mad.gif',
71 ' :-x' => 'icon_mad.gif',
72 ':mad:' => 'icon_mad.gif',
73 ' :P' => 'icon_razz.gif',
74 ' :-P' => 'icon_razz.gif',
75 ':razz:' => 'icon_razz.gif',
76 ':oops:' => 'icon_redface.gif',
77 ':cry:' => 'icon_cry.gif',
78 ':evil:' => 'icon_evil.gif',
79 ':twisted:' => 'icon_twisted.gif',
80 ':roll:' => 'icon_rolleyes.gif',
81 ':wink:' => 'icon_wink.gif',
82 ' ;)' => 'icon_wink.gif',
83 ' ;-)' => 'icon_wink.gif',
84 ':!:' => 'icon_exclaim.gif',
85 ':?:' => 'icon_question.gif',
86 ':idea:' => 'icon_idea.gif',
87 ':arrow:' => 'icon_arrow.gif',
88 ' :|' => 'icon_neutral.gif',
89 ' :-|' => 'icon_neutral.gif',
90 ':neutral:' => 'icon_neutral.gif',
91 ':mrgreen:' => 'icon_mrgreen.gif',
95 // sorts the smilies' array
96 if (!function_exists('smiliescmp')) {
97 function smiliescmp ($a, $b) {
98 if (strlen($a) == strlen($b)) {
99 return strcmp($a, $b);
101 return (strlen($a) > strlen($b)) ? -1 : 1;
104 uksort($wpsmiliestrans, 'smiliescmp');
106 // generates smilies' search & replace arrays
107 foreach($wpsmiliestrans as $smiley => $img) {
108 $wp_smiliessearch[] = $smiley;
109 $smiley_masked = htmlspecialchars( trim($smiley) , ENT_QUOTES);
110 $wp_smiliesreplace[] = " <img src='" . get_settings('siteurl') . "/wp-includes/images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> ";