root/branches/2.0/wp-includes/vars.php

Revision 6066, 3.8 kB (checked in by markjaquith, 1 year ago)

Better $pagenow determination. fixes #4748 for 2.0

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2
3 // On which page are we ?
4 if ( is_admin() ) {
5     // wp-admin pages are checked more carefully
6     preg_match('#/wp-admin/?(.*?)$#i', $PHP_SELF, $self_matches);
7     $pagenow = $self_matches[1];
8     $pagenow = preg_replace('#\?.*?$#', '', $pagenow);
9     if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) {
10         $pagenow = 'index.php';
11     } else {
12         preg_match('#(.*?)(/|$)#', $pagenow, $self_matches);
13         $pagenow = strtolower($self_matches[1]);
14         if ( '.php' !== substr($pagenow, -4, 4) )
15             $pagenow .= '.php'; // for Options +Multiviews: /wp-admin/themes/index.php (themes.php is queried)
16     }
17 } else {
18     if ( preg_match('#([^/]+\.php)([?/].*?)?$#i', $PHP_SELF, $self_matches) )
19         $pagenow = strtolower($self_matches[1]);
20     else
21         $pagenow = 'index.php';
22 }
23
24 // Simple browser detection
25 $is_lynx = 0; $is_gecko = 0; $is_winIE = 0; $is_macIE = 0; $is_opera = 0; $is_NS4 = 0;
26
27 if (preg_match('/Lynx/', $_SERVER['HTTP_USER_AGENT'])) {
28     $is_lynx = 1;
29 } elseif (preg_match('/Gecko/', $_SERVER['HTTP_USER_AGENT'])) {
30     $is_gecko = 1;
31 } elseif ((preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT'])) && (preg_match('/Win/', $_SERVER['HTTP_USER_AGENT']))) {
32     $is_winIE = 1;
33 } elseif ((preg_match('/MSIE/', $_SERVER['HTTP_USER_AGENT'])) && (preg_match('/Mac/', $_SERVER['HTTP_USER_AGENT']))) {
34     $is_macIE = 1;
35 } elseif (preg_match('/Opera/', $_SERVER['HTTP_USER_AGENT'])) {
36     $is_opera = 1;
37 } elseif ((preg_match('/Nav/', $_SERVER['HTTP_USER_AGENT']) ) || (preg_match('/Mozilla\/4\./', $_SERVER['HTTP_USER_AGENT']))) {
38     $is_NS4 = 1;
39 }
40 $is_IE    = (($is_macIE) || ($is_winIE));
41
42 // Server detection
43 $is_apache = ( strstr($_SERVER['SERVER_SOFTWARE'], 'Apache') || strstr($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') ) ? 1 : 0;
44 $is_IIS = strstr($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') ? 1 : 0;
45
46 // On OS X Server, $_SERVER['REMOTE_ADDR'] is the server's address. Workaround this
47 // by using $_SERVER['HTTP_PC_REMOTE_ADDR'], which *is* the remote address.
48 if ( isset($_SERVER['HTTP_PC_REMOTE_ADDR']) )
49     $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_PC_REMOTE_ADDR'];
50
51 // if the config file does not provide the smilies array, let's define it here
52 if (!isset($wpsmiliestrans)) {
53     $wpsmiliestrans = array(
54     ':mrgreen:'    => 'icon_mrgreen.gif',
55     ':neutral:'    => 'icon_neutral.gif',
56     ':twisted:'    => 'icon_twisted.gif',
57     ':arrow:'    => 'icon_arrow.gif',
58     ':shock:'    => 'icon_eek.gif',
59     ':smile:'    => 'icon_smile.gif',
60     ' :???:'    => 'icon_confused.gif',
61     ':cool:'    => 'icon_cool.gif',
62     ':evil:'    => 'icon_evil.gif',
63     ':grin:'    => 'icon_biggrin.gif',
64     ':idea:'    => 'icon_idea.gif',
65     ':oops:'    => 'icon_redface.gif',
66     ':razz:'    => 'icon_razz.gif',
67     ':roll:'    => 'icon_rolleyes.gif',
68     ':wink:'    => 'icon_wink.gif',
69     ':cry:'        => 'icon_cry.gif',
70     ':eek:'        => 'icon_surprised.gif',
71     ':lol:'        => 'icon_lol.gif',
72     ':mad:'        => 'icon_mad.gif',
73     ':sad:'        => 'icon_sad.gif',
74     ' 8-)'        => 'icon_cool.gif',
75     ' 8-O'        => 'icon_eek.gif',
76     ' :-('        => 'icon_sad.gif',
77     ' :-)'        => 'icon_smile.gif',
78     ' :-?'        => 'icon_confused.gif',
79     ' :-D'        => 'icon_biggrin.gif',
80     ' :-P'        => 'icon_razz.gif',
81     ' :-o'        => 'icon_surprised.gif',
82     ' :-x'        => 'icon_mad.gif',
83     ' :-|'        => 'icon_neutral.gif',
84     ' ;-)'        => 'icon_wink.gif',
85     ' 8)'        => 'icon_cool.gif',
86     ' 8O'        => 'icon_eek.gif',
87     ' :('        => 'icon_sad.gif',
88     ' :)'        => 'icon_smile.gif',
89     ' :?'        => 'icon_confused.gif',
90     ' :D'        => 'icon_biggrin.gif',
91     ' :P'        => 'icon_razz.gif',
92     ' :o'        => 'icon_surprised.gif',
93     ' :x'        => 'icon_mad.gif',
94     ' :|'        => 'icon_neutral.gif',
95     ' ;)'        => 'icon_wink.gif',
96     ':!:'        => 'icon_exclaim.gif',
97     ':?:'        => 'icon_question.gif',
98     );
99 }
100
101
102 // generates smilies' search & replace arrays
103 foreach($wpsmiliestrans as $smiley => $img) {
104     $wp_smiliessearch[] = $smiley;
105     $smiley_masked = htmlspecialchars( trim($smiley) , ENT_QUOTES);
106     $wp_smiliesreplace[] = " <img src='" . get_settings('siteurl') . "/wp-includes/images/smilies/$img' alt='$smiley_masked' class='wp-smiley' /> ";
107 }
108
109 ?>
110
Note: See TracBrowser for help on using the browser.