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

Revision 2436, 3.7 kB (checked in by ryan, 4 years ago)

Introducing wp_redirect(), first cut. http://mosquito.wordpress.org/view.php?id=592 Props: Toby Simmons

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