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

Revision 3319, 4.0 kB (checked in by ryan, 3 years ago)

Populate PHP_SELF from REQUEST_URI if blank.

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