author | Dan |
Sun, 09 Nov 2008 09:02:35 -0500 | |
changeset 730 | b09cb1dab505 |
parent 720 | e2762777b170 |
child 741 | a216e412c439 |
permissions | -rw-r--r-- |
1 | 1 |
<?php |
2 |
||
3 |
/* |
|
4 |
* Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between |
|
685
17ebe24cdf85
Rebranded as 1.1.5 (Caoineag alpha 5) and fixed a couple bugs related to CDN support in template_nodb and installerUI. Updated readme.
Dan
parents:
667
diff
changeset
|
5 |
* Version 1.1.5 (Caoineag alpha 5) |
536 | 6 |
* Copyright (C) 2006-2008 Dan Fuhry |
1 | 7 |
* |
8 |
* This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License |
|
9 |
* as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
|
12 |
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details. |
|
13 |
*/ |
|
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
14 |
|
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
15 |
/** |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
16 |
* Fetch a value from the site configuration. |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
17 |
* @param string The identifier of the value ("site_name" etc.) |
620
58852672ff12
Added "default" option for getConfig() and made setConfig() only set if the new value is different
Dan
parents:
613
diff
changeset
|
18 |
* @param string If specified, this is the "default" value for the configuration entry. Defaults to false. |
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
19 |
* @return string Configuration value, or bool(false) if the value is not set |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
20 |
*/ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
21 |
|
620
58852672ff12
Added "default" option for getConfig() and made setConfig() only set if the new value is different
Dan
parents:
613
diff
changeset
|
22 |
function getConfig($n, $default = false) |
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
23 |
{ |
1 | 24 |
global $enano_config; |
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
25 |
if ( isset( $enano_config[ $n ] ) ) |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
26 |
{ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
27 |
return $enano_config[$n]; |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
28 |
} |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
29 |
else |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
30 |
{ |
620
58852672ff12
Added "default" option for getConfig() and made setConfig() only set if the new value is different
Dan
parents:
613
diff
changeset
|
31 |
return $default; |
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
32 |
} |
1 | 33 |
} |
34 |
||
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
35 |
/** |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
36 |
* Update or change a configuration value. |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
37 |
* @param string The identifier of the value ("site_name" etc.) |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
38 |
* @param string The new value |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
39 |
* @return null |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
40 |
*/ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
41 |
|
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
42 |
function setConfig($n, $v) |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
43 |
{ |
1 | 44 |
global $enano_config, $db; |
620
58852672ff12
Added "default" option for getConfig() and made setConfig() only set if the new value is different
Dan
parents:
613
diff
changeset
|
45 |
|
58852672ff12
Added "default" option for getConfig() and made setConfig() only set if the new value is different
Dan
parents:
613
diff
changeset
|
46 |
if ( isset($enano_config[$n]) ) |
58852672ff12
Added "default" option for getConfig() and made setConfig() only set if the new value is different
Dan
parents:
613
diff
changeset
|
47 |
{ |
58852672ff12
Added "default" option for getConfig() and made setConfig() only set if the new value is different
Dan
parents:
613
diff
changeset
|
48 |
if ( $enano_config[$n] === $v ) |
58852672ff12
Added "default" option for getConfig() and made setConfig() only set if the new value is different
Dan
parents:
613
diff
changeset
|
49 |
{ |
58852672ff12
Added "default" option for getConfig() and made setConfig() only set if the new value is different
Dan
parents:
613
diff
changeset
|
50 |
// configuration already matches this value |
58852672ff12
Added "default" option for getConfig() and made setConfig() only set if the new value is different
Dan
parents:
613
diff
changeset
|
51 |
return true; |
58852672ff12
Added "default" option for getConfig() and made setConfig() only set if the new value is different
Dan
parents:
613
diff
changeset
|
52 |
} |
58852672ff12
Added "default" option for getConfig() and made setConfig() only set if the new value is different
Dan
parents:
613
diff
changeset
|
53 |
} |
58852672ff12
Added "default" option for getConfig() and made setConfig() only set if the new value is different
Dan
parents:
613
diff
changeset
|
54 |
|
1 | 55 |
$enano_config[$n] = $v; |
56 |
$v = $db->escape($v); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
57 |
|
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
58 |
$e = $db->sql_query('DELETE FROM '.table_prefix.'config WHERE config_name=\''.$n.'\';'); |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
59 |
if ( !$e ) |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
60 |
{ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
61 |
$db->_die('Error during generic setConfig() call row deletion.'); |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
62 |
} |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
63 |
|
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
64 |
$e = $db->sql_query('INSERT INTO '.table_prefix.'config(config_name, config_value) VALUES(\''.$n.'\', \''.$v.'\')'); |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
65 |
if ( !$e ) |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
66 |
{ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
67 |
$db->_die('Error during generic setConfig() call row insertion.'); |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
68 |
} |
1 | 69 |
} |
70 |
||
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
71 |
/** |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
72 |
* Create a URI for an internal link. |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
73 |
* @param string The full identifier of the page to link to (Special:Administration) |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
74 |
* @param string The GET query string to append |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
75 |
* @param bool If true, perform htmlspecialchars() on the return value to make it HTML-safe |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
76 |
* @return string |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
77 |
*/ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
78 |
|
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
79 |
if ( !function_exists('makeUrl') ) |
1 | 80 |
{ |
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
81 |
function makeUrl($t, $query = false, $escape = false) |
377
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
parents:
376
diff
changeset
|
82 |
{ |
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
83 |
global $db, $session, $paths, $template, $plugins; // Common objects |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
84 |
$flags = ''; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
85 |
$sep = urlSeparator; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
86 |
$t = sanitize_page_id($t); |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
87 |
if ( isset($_GET['printable'] ) ) |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
88 |
{ |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
89 |
$flags .= $sep . 'printable=yes'; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
90 |
$sep = '&'; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
91 |
} |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
92 |
if ( isset($_GET['theme'] ) ) |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
93 |
{ |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
94 |
$flags .= $sep . 'theme='.$session->theme; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
95 |
$sep = '&'; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
96 |
} |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
97 |
if ( isset($_GET['style'] ) ) |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
98 |
{ |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
99 |
$flags .= $sep . 'style='.$session->style; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
100 |
$sep = '&'; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
101 |
} |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
102 |
if ( isset($_GET['lang']) && preg_match('/^[a-z0-9_]+$/', @$_GET['lang']) ) |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
103 |
{ |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
104 |
$flags .= $sep . 'lang=' . urlencode($_GET['lang']); |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
105 |
$sep = '&'; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
106 |
} |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
107 |
|
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
108 |
$url = $session->append_sid(contentPath.$t.$flags); |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
109 |
if($query) |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
110 |
{ |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
111 |
$sep = strstr($url, '?') ? '&' : '?'; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
112 |
$url = $url . $sep . $query; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
113 |
} |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
114 |
|
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
115 |
return ($escape) ? htmlspecialchars($url) : $url; |
377
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
parents:
376
diff
changeset
|
116 |
} |
1 | 117 |
} |
118 |
||
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
119 |
/** |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
120 |
* Create a URI for an internal link, and be namespace-friendly. Watch out for this one because it's different from most other Enano functions, in that the namespace is the first parameter. |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
121 |
* @param string The namespace ID |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
122 |
* @param string The page ID |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
123 |
* @param string The GET query string to append |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
124 |
* @param bool If true, perform htmlspecialchars() on the return value to make it HTML-safe |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
125 |
* @return string |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
126 |
*/ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
127 |
|
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
128 |
if ( !function_exists('makeUrlNS') ) |
1 | 129 |
{ |
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
130 |
function makeUrlNS($n, $t, $query = false, $escape = false) |
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
131 |
{ |
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
132 |
global $db, $session, $paths, $template, $plugins; // Common objects |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
133 |
$flags = ''; |
468
194a19711346
Fixed the fact that cron just didn't work at all (brain fart that day or something)
Dan
parents:
458
diff
changeset
|
134 |
|
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
135 |
if(defined('ENANO_BASE_CLASSES_INITIALIZED')) |
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
136 |
{ |
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
137 |
$sep = urlSeparator; |
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
138 |
} |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
139 |
else |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
140 |
{ |
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
141 |
$sep = (strstr($_SERVER['REQUEST_URI'], '?')) ? '&' : '?'; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
142 |
} |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
143 |
if ( isset( $_GET['printable'] ) ) { |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
144 |
$flags .= $sep . 'printable'; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
145 |
$sep = '&'; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
146 |
} |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
147 |
if ( isset( $_GET['theme'] ) ) |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
148 |
{ |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
149 |
$flags .= $sep . 'theme='.$session->theme; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
150 |
$sep = '&'; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
151 |
} |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
152 |
if ( isset( $_GET['style'] ) ) |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
153 |
{ |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
154 |
$flags .= $sep . 'style='.$session->style; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
155 |
$sep = '&'; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
156 |
} |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
157 |
if ( isset($_GET['lang']) && preg_match('/^[a-z0-9_]+$/', @$_GET['lang']) ) |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
158 |
{ |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
159 |
$flags .= $sep . 'lang=' . urlencode($_GET['lang']); |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
160 |
$sep = '&'; |
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
161 |
} |
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
162 |
|
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
163 |
$ns_prefix = "$n:"; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
164 |
|
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
165 |
if(defined('ENANO_BASE_CLASSES_INITIALIZED')) |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
166 |
{ |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
167 |
$ns_prefix = ( isset($paths->nslist[$n]) ) ? $paths->nslist[$n] : $n . substr($paths->nslist['Special'], -1); |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
168 |
$url = contentPath . $ns_prefix . $t . $flags; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
169 |
} |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
170 |
else |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
171 |
{ |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
172 |
// If the path manager hasn't been initted yet, take an educated guess at what the URI should be |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
173 |
$url = contentPath . $n . ':' . $t . $flags; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
174 |
} |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
175 |
|
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
176 |
if($query) |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
177 |
{ |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
178 |
if(strstr($url, '?')) |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
179 |
{ |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
180 |
$sep = '&'; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
181 |
} |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
182 |
else |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
183 |
{ |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
184 |
$sep = '?'; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
185 |
} |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
186 |
$url = $url . $sep . $query . $flags; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
187 |
} |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
188 |
|
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
189 |
if(defined('ENANO_BASE_CLASSES_INITIALIZED')) |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
190 |
{ |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
191 |
$url = $session->append_sid($url); |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
192 |
} |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
193 |
|
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
194 |
return ($escape) ? htmlspecialchars($url) : $url; |
1 | 195 |
} |
196 |
} |
|
197 |
||
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
198 |
/** |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
199 |
* Create a URI for an internal link, be namespace-friendly, and add http://hostname/scriptpath to the beginning if possible. Watch out for this one because it's different from most other Enano functions, in that the namespace is the first parameter. |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
200 |
* @param string The namespace ID |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
201 |
* @param string The page ID |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
202 |
* @param string The GET query string to append |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
203 |
* @param bool If true, perform htmlspecialchars() on the return value to make it HTML-safe |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
204 |
* @return string |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
205 |
*/ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
206 |
|
1 | 207 |
function makeUrlComplete($n, $t, $query = false, $escape = false) |
208 |
{ |
|
209 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
210 |
$flags = ''; |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
211 |
|
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
212 |
if(defined('ENANO_BASE_CLASSES_INITIALIZED')) |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
213 |
{ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
214 |
$sep = urlSeparator; |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
215 |
} |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
216 |
else |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
217 |
{ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
218 |
$sep = (strstr($_SERVER['REQUEST_URI'], '?')) ? '&' : '?'; |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
219 |
} |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
220 |
if ( isset( $_GET['printable'] ) ) { |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
221 |
$flags .= $sep . 'printable'; |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
222 |
$sep = '&'; |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
223 |
} |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
224 |
if ( isset( $_GET['theme'] ) ) |
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
225 |
{ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
226 |
$flags .= $sep . 'theme='.$session->theme; |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
227 |
$sep = '&'; |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
228 |
} |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
229 |
if ( isset( $_GET['style'] ) ) |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
230 |
{ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
231 |
$flags .= $sep . 'style='.$session->style; |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
232 |
$sep = '&'; |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
233 |
} |
377
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
parents:
376
diff
changeset
|
234 |
if ( isset($_GET['lang']) && preg_match('/^[a-z0-9_]+$/', @$_GET['lang']) ) |
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
parents:
376
diff
changeset
|
235 |
{ |
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
parents:
376
diff
changeset
|
236 |
$flags .= $sep . 'lang=' . urlencode($_GET['lang']); |
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
parents:
376
diff
changeset
|
237 |
$sep = '&'; |
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
parents:
376
diff
changeset
|
238 |
} |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
239 |
|
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
240 |
if(defined('ENANO_BASE_CLASSES_INITIALIZED')) |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
241 |
{ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
242 |
$url = $session->append_sid(contentPath . $paths->nslist[$n] . $t . $flags); |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
243 |
} |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
244 |
else |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
245 |
{ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
246 |
// If the path manager hasn't been initted yet, take an educated guess at what the URI should be |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
247 |
$url = contentPath . $n . ':' . $t . $flags; |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
248 |
} |
1 | 249 |
if($query) |
250 |
{ |
|
251 |
if(strstr($url, '?')) $sep = '&'; |
|
252 |
else $sep = '?'; |
|
253 |
$url = $url . $sep . $query . $flags; |
|
254 |
} |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
255 |
|
1 | 256 |
$baseprot = 'http' . ( isset($_SERVER['HTTPS']) ? 's' : '' ) . '://' . $_SERVER['HTTP_HOST']; |
257 |
$url = $baseprot . $url; |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
258 |
|
1 | 259 |
return ($escape) ? htmlspecialchars($url) : $url; |
260 |
} |
|
261 |
||
262 |
/** |
|
345
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
343
diff
changeset
|
263 |
* Enano replacement for date(). Accounts for individual users' timezone preferences. |
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
343
diff
changeset
|
264 |
* @param string Date-formatted string |
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
343
diff
changeset
|
265 |
* @param int Optional - UNIX timestamp value to use. If omitted, the current time is used. |
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
343
diff
changeset
|
266 |
* @return string Formatted string |
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
343
diff
changeset
|
267 |
*/ |
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
343
diff
changeset
|
268 |
|
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
343
diff
changeset
|
269 |
function enano_date($string, $timestamp = false) |
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
343
diff
changeset
|
270 |
{ |
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
343
diff
changeset
|
271 |
if ( !is_int($timestamp) && !is_double($timestamp) && strval(intval($timestamp)) !== $timestamp ) |
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
343
diff
changeset
|
272 |
$timestamp = time(); |
406
7468a663315f
Added some basic timezone support; DST support is still to come.
Dan
parents:
391
diff
changeset
|
273 |
|
7468a663315f
Added some basic timezone support; DST support is still to come.
Dan
parents:
391
diff
changeset
|
274 |
// perform timestamp offset |
7468a663315f
Added some basic timezone support; DST support is still to come.
Dan
parents:
391
diff
changeset
|
275 |
global $timezone; |
7468a663315f
Added some basic timezone support; DST support is still to come.
Dan
parents:
391
diff
changeset
|
276 |
// it's gonna be in minutes, so multiply by 60 to offset the unix timestamp |
7468a663315f
Added some basic timezone support; DST support is still to come.
Dan
parents:
391
diff
changeset
|
277 |
$timestamp = $timestamp + ( $timezone * 60 ); |
7468a663315f
Added some basic timezone support; DST support is still to come.
Dan
parents:
391
diff
changeset
|
278 |
|
711
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
279 |
// are we in DST? |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
280 |
global $dst_params; |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
281 |
if ( check_timestamp_dst($timestamp, $dst_params[0], $dst_params[1], $dst_params[2], $dst_params[3]) ) |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
282 |
{ |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
283 |
// offset for DST |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
284 |
$timestamp += ( $dst_params[4] * 60 ); |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
285 |
} |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
286 |
|
406
7468a663315f
Added some basic timezone support; DST support is still to come.
Dan
parents:
391
diff
changeset
|
287 |
// Let PHP do the work for us =) |
556
63e131c38876
More work done on effective permissions API, namely reporting of page group and usergroup names
Dan
parents:
542
diff
changeset
|
288 |
return gmdate($string, $timestamp); |
345
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
343
diff
changeset
|
289 |
} |
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
343
diff
changeset
|
290 |
|
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
343
diff
changeset
|
291 |
/** |
711
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
292 |
* Determine if a timestamp is within DST. |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
293 |
* @param int Timestamp |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
294 |
* @param int Start month (1-12) of DST |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
295 |
* @param int Which Sunday DST starts on (*_SUNDAY constants) |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
296 |
* @param int End month of DST |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
297 |
* @param int Which Sunday DST ends on |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
298 |
* @return bool |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
299 |
*/ |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
300 |
|
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
301 |
function check_timestamp_dst($time, $start_month, $start_sunday, $end_month, $end_sunday) |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
302 |
{ |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
303 |
static $sundays = array(FIRST_SUNDAY, SECOND_SUNDAY, THIRD_SUNDAY, LAST_SUNDAY); |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
304 |
|
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
305 |
// perform timestamp offset |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
306 |
global $timezone; |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
307 |
// it's gonna be in minutes, so multiply by 60 to offset the unix timestamp |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
308 |
$time = $time + ( $timezone * 60 ); |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
309 |
$year = intval(gmdate('Y', $time)); |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
310 |
|
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
311 |
// one-pass validation |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
312 |
if ( !in_array($start_sunday, $sundays) || !in_array($end_sunday, $sundays) || |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
313 |
$start_month < 1 || $start_month > 12 || $end_month < 1 || $end_month > 12 ) |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
314 |
return false; |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
315 |
|
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
316 |
// get timestamp of the selected sunday (start) |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
317 |
$dst_start = get_sunday_timestamp($start_month, $start_sunday, $year); |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
318 |
$dst_end = get_sunday_timestamp($end_month, $end_sunday, $year); |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
319 |
|
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
320 |
if ( $dst_start > $dst_end ) |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
321 |
{ |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
322 |
// start time is past the end time, this means we're in the southern hemisphere |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
323 |
// as a result, if we're within the range, DST is NOT in progress. |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
324 |
return !( $time >= $dst_start && $time <= $dst_end ); |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
325 |
} |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
326 |
|
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
327 |
return $time >= $dst_start && $time <= $dst_end; |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
328 |
} |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
329 |
|
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
330 |
/** |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
331 |
* Returns a timestamp for the given *_SUNDAY index. |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
332 |
* @param int Month |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
333 |
* @param int Which Sunday (FIRST, SECOND, THIRD, or LAST) |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
334 |
* @param int Year that we're doing our calculations in |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
335 |
* @return int |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
336 |
*/ |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
337 |
|
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
338 |
function get_sunday_timestamp($month, $sunday, $year) |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
339 |
{ |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
340 |
$days_in_month = array( |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
341 |
1 => 31, |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
342 |
2 => $year % 4 == 0 && ( $year % 100 != 0 || ( $year % 100 == 0 && $year % 400 == 0 ) ) ? 29 : 28, |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
343 |
3 => 31, |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
344 |
4 => 30, |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
345 |
5 => 31, |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
346 |
6 => 30, |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
347 |
7 => 31, |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
348 |
8 => 31, |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
349 |
9 => 30, |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
350 |
10 => 31, |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
351 |
11 => 30, |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
352 |
12 => 31 |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
353 |
); |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
354 |
|
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
355 |
$result = mktime(0, 0, 0, $month, 1, $year); |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
356 |
|
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
357 |
// hack. allows a specific day of the month to be set instead of a sunday. not a good place to do this. |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
358 |
if ( is_string($sunday) && substr($sunday, -1) === 'd' ) |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
359 |
{ |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
360 |
$result += 86400 * ( intval($sunday) - 1); |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
361 |
return $result; |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
362 |
} |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
363 |
|
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
364 |
$tick = 0; |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
365 |
$days_remaining = $days_in_month[$month]; |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
366 |
while ( true ) |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
367 |
{ |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
368 |
if ( date('D', $result) == 'Sun' ) |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
369 |
{ |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
370 |
$tick++; |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
371 |
if ( ( $tick == 1 && $sunday == FIRST_SUNDAY ) || |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
372 |
( $tick == 2 && $sunday == SECOND_SUNDAY ) || |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
373 |
( $tick == 3 && $sunday == THIRD_SUNDAY ) || |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
374 |
( $sunday == LAST_SUNDAY && $days_remaining < 7 ) ) |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
375 |
break; |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
376 |
} |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
377 |
$days_remaining--; |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
378 |
$result += 86400; |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
379 |
} |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
380 |
|
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
381 |
return $result; |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
382 |
} |
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
383 |
|
f70d764aab33
Added initial support for DST. Rules are defined in constants.php and are extensible.
Dan
parents:
710
diff
changeset
|
384 |
/** |
62
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
385 |
* Tells you the title for the given page ID string |
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
386 |
* @param string Page ID string (ex: Special:Administration) |
91 | 387 |
* @param bool Optional. If true, and if the namespace turns out to be something other than Article, the namespace prefix will be prepended to the return value. |
62
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
388 |
* @return string |
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
389 |
*/ |
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
390 |
|
91 | 391 |
function get_page_title($page_id, $show_ns = true) |
62
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
392 |
{ |
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
393 |
global $db, $session, $paths, $template, $plugins; // Common objects |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
394 |
|
62
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
395 |
$idata = RenderMan::strToPageID($page_id); |
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
396 |
$page_id_key = $paths->nslist[ $idata[1] ] . $idata[0]; |
91 | 397 |
$page_id_key = sanitize_page_id($page_id_key); |
473
518bc2b214f1
Added modal dialog support for page editor; added customizability for breadcrumbs (thanks to Manoj for idea)
Dan
parents:
472
diff
changeset
|
398 |
$page_data = @$paths->pages[$page_id_key]; |
91 | 399 |
$title = ( isset($page_data['name']) ) ? |
400 |
( ( $page_data['namespace'] == 'Article' || !$show_ns ) ? |
|
401 |
'' : |
|
402 |
$paths->nslist[ $idata[1] ] ) |
|
403 |
. $page_data['name'] : |
|
404 |
( $show_ns ? $paths->nslist[$idata[1]] : '' ) . str_replace('_', ' ', dirtify_page_id( $idata[0] ) ); |
|
62
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
405 |
return $title; |
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
406 |
} |
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
407 |
|
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
408 |
/** |
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
409 |
* Tells you the title for the given page ID and namespace |
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
410 |
* @param string Page ID |
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
411 |
* @param string Namespace |
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
412 |
* @return string |
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
413 |
*/ |
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
414 |
|
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
415 |
function get_page_title_ns($page_id, $namespace) |
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
416 |
{ |
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
417 |
global $db, $session, $paths, $template, $plugins; // Common objects |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
418 |
|
468
194a19711346
Fixed the fact that cron just didn't work at all (brain fart that day or something)
Dan
parents:
458
diff
changeset
|
419 |
$ns_prefix = ( isset($paths->nslist[ $namespace ]) ) ? $paths->nslist[ $namespace ] : $namespace . substr($paths->nslist['Special'], -1); |
194a19711346
Fixed the fact that cron just didn't work at all (brain fart that day or something)
Dan
parents:
458
diff
changeset
|
420 |
$page_id_key = $ns_prefix . $page_id; |
320
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
421 |
if ( isset($paths->pages[$page_id_key]) ) |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
422 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
423 |
$page_data = $paths->pages[$page_id_key]; |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
424 |
} |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
425 |
else |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
426 |
{ |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
427 |
$page_data = array(); |
112debff64bd
SURPRISE! Preliminary PostgreSQL support added. The required schema file is not present in this commit and will be included at a later date. No installer support is implemented. Also in this commit: several fixes including <!-- SYSMSG ... --> was broken in template compiler; set fixed width on included images to prevent the thumbnail box from getting huge; added a much more friendly interface to AJAX responses that are invalid JSON
Dan
parents:
317
diff
changeset
|
428 |
} |
468
194a19711346
Fixed the fact that cron just didn't work at all (brain fart that day or something)
Dan
parents:
458
diff
changeset
|
429 |
$title = ( isset($page_data['name']) ) ? $page_data['name'] : $ns_prefix . str_replace('_', ' ', dirtify_page_id( $page_id ) ); |
62
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
430 |
return $title; |
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
431 |
} |
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
432 |
|
9dc4fded30e6
Redirect pages actually work stable-ish now; critical extraneous debug message removed (oops!)
Dan
parents:
48
diff
changeset
|
433 |
/** |
1 | 434 |
* Redirect the user to the specified URL. |
435 |
* @param string $url The URL, either relative or absolute. |
|
436 |
* @param string $title The title of the message |
|
437 |
* @param string $message A short message to show to the user |
|
556
63e131c38876
More work done on effective permissions API, namely reporting of page group and usergroup names
Dan
parents:
542
diff
changeset
|
438 |
* @param string $timeout Timeout, in seconds, to delay the redirect. Defaults to 3. If 0, sends a 307 Temporary Redirect. |
1 | 439 |
*/ |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
440 |
|
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
209
diff
changeset
|
441 |
function redirect($url, $title = 'etc_redirect_title', $message = 'etc_redirect_body', $timeout = 3) |
1 | 442 |
{ |
443 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
209
diff
changeset
|
444 |
global $lang; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
445 |
|
343
eefe9ab7fe7c
Localized the first parts of the admin panel. As a consequence, also wrote a brand new Admin:PageManager that doesn't suck like the old one did.
Dan
parents:
335
diff
changeset
|
446 |
// POST check added in 1.1.x because Firefox asks us if we want to "resend the form |
eefe9ab7fe7c
Localized the first parts of the admin panel. As a consequence, also wrote a brand new Admin:PageManager that doesn't suck like the old one did.
Dan
parents:
335
diff
changeset
|
447 |
// data to the new location", which can be confusing for some users. |
eefe9ab7fe7c
Localized the first parts of the admin panel. As a consequence, also wrote a brand new Admin:PageManager that doesn't suck like the old one did.
Dan
parents:
335
diff
changeset
|
448 |
if ( $timeout == 0 && empty($_POST) ) |
1 | 449 |
{ |
450 |
header('Location: ' . $url); |
|
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
451 |
header('Content-length: 0'); |
1 | 452 |
header('HTTP/1.1 307 Temporary Redirect'); |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
453 |
|
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
454 |
// with 3xx codes HTTP clients expect a response of 0 bytes, so just die here |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
455 |
exit(); |
1 | 456 |
} |
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
270
diff
changeset
|
457 |
|
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
270
diff
changeset
|
458 |
if ( !is_object($template) ) |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
270
diff
changeset
|
459 |
{ |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
270
diff
changeset
|
460 |
$template = new template_nodb(); |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
270
diff
changeset
|
461 |
$template->load_theme('oxygen', 'bleu', false); |
574 | 462 |
$template->assign_vars(array( |
463 |
'SITE_NAME' => 'Enano', |
|
464 |
'SITE_DESC' => 'This site is experiencing a critical error and cannot load.', |
|
465 |
'COPYRIGHT' => 'Powered by Enano CMS - © 2006-2008 Dan Fuhry. This program is Free Software; see the <a href="' . scriptPath . '/install.php?mode=license">GPL file</a> included with this package for details.', |
|
466 |
'PAGE_NAME' => htmlspecialchars($title) |
|
467 |
)); |
|
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
270
diff
changeset
|
468 |
} |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
469 |
|
1 | 470 |
$template->add_header('<meta http-equiv="refresh" content="' . $timeout . '; url=' . str_replace('"', '\\"', $url) . '" />'); |
471 |
$template->add_header('<script type="text/javascript"> |
|
472 |
function __r() { |
|
473 |
// FUNCTION AUTOMATICALLY GENERATED |
|
474 |
window.location="' . str_replace('"', '\\"', $url) . '"; |
|
475 |
} |
|
476 |
setTimeout(\'__r();\', ' . $timeout . '000); |
|
477 |
</script> |
|
478 |
'); |
|
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
270
diff
changeset
|
479 |
|
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
270
diff
changeset
|
480 |
if ( get_class($template) == 'template_nodb' ) |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
270
diff
changeset
|
481 |
$template->init_vars(); |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
482 |
|
574 | 483 |
$template->assign_vars(array('PAGE_NAME' => $title)); |
1 | 484 |
$template->header(true); |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
209
diff
changeset
|
485 |
echo '<p>' . $message . '</p>'; |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
209
diff
changeset
|
486 |
$subst = array( |
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents:
334
diff
changeset
|
487 |
'timeout' => $timeout, |
210
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
209
diff
changeset
|
488 |
'redirect_url' => str_replace('"', '\\"', $url) |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
209
diff
changeset
|
489 |
); |
2b283402e4e4
Added language export to JSON page and localization for Javascript using $lang.get(). Localized AJAX login interface.
Dan
parents:
209
diff
changeset
|
490 |
echo '<p>' . $lang->get('etc_redirect_timeout', $subst) . '</p>'; |
1 | 491 |
$template->footer(true); |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
492 |
|
1 | 493 |
$db->close(); |
494 |
exit(0); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
495 |
|
1 | 496 |
} |
497 |
||
562
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
498 |
/** |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
499 |
* Generates a confirmation form if a CSRF check fails. Will terminate execution. |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
500 |
*/ |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
501 |
|
573
43e7254afdb4
Renamed some functions (that were new in this release anyway) due to compatibility broken with PunBB bridge
Dan
parents:
566
diff
changeset
|
502 |
function csrf_request_confirm() |
562
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
503 |
{ |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
504 |
global $db, $session, $paths, $template, $plugins; // Common objects |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
505 |
global $lang; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
506 |
|
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
507 |
// If the token was overridden with the correct one, the user confirmed the action using this form. Continue exec. |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
508 |
if ( isset($_POST['cstok']) || isset($_GET ['cstok']) ) |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
509 |
{ |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
510 |
// using the if() check makes sure that the token isn't in a cookie, since $_REQUEST includes $_COOKIE. |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
511 |
$token_check =& $_REQUEST['cstok']; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
512 |
if ( $token_check === $session->csrf_token ) |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
513 |
{ |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
514 |
// overridden token matches, continue exec |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
515 |
return true; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
516 |
} |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
517 |
} |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
518 |
|
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
519 |
$template->tpl_strings['PAGE_NAME'] = htmlspecialchars($lang->get('user_csrf_confirm_title')); |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
520 |
$template->header(); |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
521 |
|
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
522 |
// initial info |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
523 |
echo '<p>' . $lang->get('user_csrf_confirm_body') . '</p>'; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
524 |
|
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
525 |
// start form |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
526 |
$form_method = ( empty($_POST) ) ? 'get' : 'post'; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
527 |
echo '<form action="' . htmlspecialchars($_SERVER['REQUEST_URI']) . '" method="' . $form_method . '" enctype="multipart/form-data">'; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
528 |
|
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
529 |
echo '<fieldset enano:expand="closed">'; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
530 |
echo '<legend>' . $lang->get('user_csrf_confirm_btn_viewrequest') . '</legend><div>'; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
531 |
|
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
532 |
if ( empty($_POST) ) |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
533 |
{ |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
534 |
// GET request |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
535 |
echo csrf_confirm_get_recursive(); |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
536 |
} |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
537 |
else |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
538 |
{ |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
539 |
// POST request |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
540 |
echo csrf_confirm_post_recursive(); |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
541 |
} |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
542 |
echo '</div></fieldset>'; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
543 |
// insert the right CSRF token |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
544 |
echo '<input type="hidden" name="cstok" value="' . $session->csrf_token . '" />'; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
545 |
echo '<p><input type="submit" value="' . $lang->get('user_csrf_confirm_btn_continue') . '" /></p>'; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
546 |
echo '</form>'; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
547 |
|
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
548 |
$template->footer(); |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
549 |
|
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
550 |
exit; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
551 |
} |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
552 |
|
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
553 |
function csrf_confirm_get_recursive($_inner = false, $pfx = false, $data = false) |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
554 |
{ |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
555 |
// make posted arrays work right |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
556 |
if ( !$data ) |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
557 |
( $_inner == 'post' ) ? $data =& $_POST : $data =& $_GET; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
558 |
foreach ( $data as $key => $value ) |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
559 |
{ |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
560 |
$pfx_this = ( empty($pfx) ) ? $key : "{$pfx}[{$key}]"; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
561 |
if ( is_array($value) ) |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
562 |
{ |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
563 |
csrf_confirm_get_recursive(true, $pfx_this, $value); |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
564 |
} |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
565 |
else if ( empty($value) ) |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
566 |
{ |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
567 |
echo htmlspecialchars($pfx_this . " = <nil>") . "<br />\n"; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
568 |
echo '<input type="hidden" name="' . htmlspecialchars($pfx_this) . '" value="" />'; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
569 |
} |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
570 |
else |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
571 |
{ |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
572 |
echo htmlspecialchars($pfx_this . " = " . $value) . "<br />\n"; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
573 |
echo '<input type="hidden" name="' . htmlspecialchars($pfx_this) . '" value="' . htmlspecialchars($value) . '" />'; |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
574 |
} |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
575 |
} |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
576 |
} |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
577 |
|
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
578 |
function csrf_confirm_post_recursive() |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
579 |
{ |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
580 |
csrf_confirm_get_recursive('post'); |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
581 |
} |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
582 |
|
1 | 583 |
// Removed wikiFormat() from here, replaced with RenderMan::render |
584 |
||
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
585 |
/** |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
586 |
* Tell me if the page exists or not. |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
587 |
* @param string the full page ID (Special:Administration) of the page to check for |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
588 |
* @return bool True if the page exists, false otherwise |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
589 |
*/ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
590 |
|
1 | 591 |
function isPage($p) { |
592 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
593 |
|
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
594 |
// Try the easy way first ;-) |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
595 |
if ( isset( $paths->pages[ $p ] ) ) |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
596 |
{ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
597 |
return true; |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
598 |
} |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
599 |
|
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
600 |
// Special case for Special, Template, and Admin pages that can't have slashes in their URIs |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
601 |
$ns_test = RenderMan::strToPageID( $p ); |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
602 |
|
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
603 |
if($ns_test[1] != 'Special' && $ns_test[1] != 'Template' && $ns_test[1] != 'Admin') |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
604 |
{ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
605 |
return false; |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
606 |
} |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
607 |
|
22
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
608 |
$particles = explode('/', $p); |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
609 |
if ( isset ( $paths->pages[ $particles[ 0 ] ] ) ) |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
610 |
{ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
611 |
return true; |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
612 |
} |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
613 |
else |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
614 |
{ |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
615 |
return false; |
d0314575e2f0
More preliminary l10n work; userpage portal style basics implemented
Dan
parents:
21
diff
changeset
|
616 |
} |
1 | 617 |
} |
618 |
||
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
619 |
/** |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
620 |
* These are some old functions that were used with the Midget codebase. They are deprecated and should not be used any more. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
621 |
*/ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
622 |
|
1 | 623 |
function arrayItemUp($arr, $keyname) { |
624 |
$keylist = array_keys($arr); |
|
625 |
$keyflop = array_flip($keylist); |
|
626 |
$idx = $keyflop[$keyname]; |
|
627 |
$idxm = $idx - 1; |
|
628 |
$temp = $arr[$keylist[$idxm]]; |
|
629 |
if($arr[$keylist[0]] == $arr[$keyname]) return $arr; |
|
630 |
$arr[$keylist[$idxm]] = $arr[$keylist[$idx]]; |
|
631 |
$arr[$keylist[$idx]] = $temp; |
|
632 |
return $arr; |
|
633 |
} |
|
634 |
||
635 |
function arrayItemDown($arr, $keyname) { |
|
636 |
$keylist = array_keys($arr); |
|
637 |
$keyflop = array_flip($keylist); |
|
638 |
$idx = $keyflop[$keyname]; |
|
639 |
$idxm = $idx + 1; |
|
640 |
$temp = $arr[$keylist[$idxm]]; |
|
641 |
$sz = sizeof($arr); $sz--; |
|
642 |
if($arr[$keylist[$sz]] == $arr[$keyname]) return $arr; |
|
643 |
$arr[$keylist[$idxm]] = $arr[$keylist[$idx]]; |
|
644 |
$arr[$keylist[$idx]] = $temp; |
|
645 |
return $arr; |
|
646 |
} |
|
647 |
||
648 |
function arrayItemTop($arr, $keyname) { |
|
649 |
$keylist = array_keys($arr); |
|
650 |
$keyflop = array_flip($keylist); |
|
651 |
$idx = $keyflop[$keyname]; |
|
652 |
while( $orig != $arr[$keylist[0]] ) { |
|
653 |
// echo 'Keyname: '.$keylist[$idx] . '<br />'; flush(); ob_flush(); // Debugger |
|
654 |
if($idx < 0) return $arr; |
|
655 |
if($keylist[$idx] == '' || $keylist[$idx] < 0 || !$keylist[$idx]) { |
|
656 |
return $arr; |
|
657 |
} |
|
658 |
$arr = arrayItemUp($arr, $keylist[$idx]); |
|
659 |
$idx--; |
|
660 |
} |
|
661 |
return $arr; |
|
662 |
} |
|
663 |
||
664 |
function arrayItemBottom($arr, $keyname) { |
|
665 |
$keylist = array_keys($arr); |
|
666 |
$keyflop = array_flip($keylist); |
|
667 |
$idx = $keyflop[$keyname]; |
|
668 |
$sz = sizeof($arr); $sz--; |
|
669 |
while( $orig != $arr[$keylist[$sz]] ) { |
|
670 |
// echo 'Keyname: '.$keylist[$idx] . '<br />'; flush(); ob_flush(); // Debugger |
|
671 |
if($idx > $sz) return $arr; |
|
672 |
if($keylist[$idx] == '' || $keylist[$idx] < 0 || !$keylist[$idx]) { |
|
673 |
echo 'Infinite loop caught in arrayItemBottom(<br /><pre>'; |
|
674 |
print_r($arr); |
|
675 |
echo '</pre><br />, '.$keyname.');<br /><br />EnanoCMS: Critical error during function call, exiting to prevent excessive server load.'; |
|
676 |
exit; |
|
677 |
} |
|
678 |
$arr = arrayItemDown($arr, $keylist[$idx]); |
|
679 |
$idx++; |
|
680 |
} |
|
681 |
return $arr; |
|
682 |
} |
|
683 |
||
606
daf8c556ada7
Moved enano_safe_array_merge() to functions.php as comment.php depends on it
Dan
parents:
599
diff
changeset
|
684 |
/** |
daf8c556ada7
Moved enano_safe_array_merge() to functions.php as comment.php depends on it
Dan
parents:
599
diff
changeset
|
685 |
* Implementation of array_merge() that preserves key names. $arr2 takes precedence over $arr1. |
daf8c556ada7
Moved enano_safe_array_merge() to functions.php as comment.php depends on it
Dan
parents:
599
diff
changeset
|
686 |
* @param array $arr1 |
daf8c556ada7
Moved enano_safe_array_merge() to functions.php as comment.php depends on it
Dan
parents:
599
diff
changeset
|
687 |
* @param array $arr2 |
daf8c556ada7
Moved enano_safe_array_merge() to functions.php as comment.php depends on it
Dan
parents:
599
diff
changeset
|
688 |
* @return array |
daf8c556ada7
Moved enano_safe_array_merge() to functions.php as comment.php depends on it
Dan
parents:
599
diff
changeset
|
689 |
*/ |
daf8c556ada7
Moved enano_safe_array_merge() to functions.php as comment.php depends on it
Dan
parents:
599
diff
changeset
|
690 |
|
daf8c556ada7
Moved enano_safe_array_merge() to functions.php as comment.php depends on it
Dan
parents:
599
diff
changeset
|
691 |
function enano_safe_array_merge($arr1, $arr2) |
daf8c556ada7
Moved enano_safe_array_merge() to functions.php as comment.php depends on it
Dan
parents:
599
diff
changeset
|
692 |
{ |
daf8c556ada7
Moved enano_safe_array_merge() to functions.php as comment.php depends on it
Dan
parents:
599
diff
changeset
|
693 |
$arr3 = $arr1; |
daf8c556ada7
Moved enano_safe_array_merge() to functions.php as comment.php depends on it
Dan
parents:
599
diff
changeset
|
694 |
foreach($arr2 as $k => $v) |
daf8c556ada7
Moved enano_safe_array_merge() to functions.php as comment.php depends on it
Dan
parents:
599
diff
changeset
|
695 |
{ |
daf8c556ada7
Moved enano_safe_array_merge() to functions.php as comment.php depends on it
Dan
parents:
599
diff
changeset
|
696 |
$arr3[$k] = $v; |
daf8c556ada7
Moved enano_safe_array_merge() to functions.php as comment.php depends on it
Dan
parents:
599
diff
changeset
|
697 |
} |
daf8c556ada7
Moved enano_safe_array_merge() to functions.php as comment.php depends on it
Dan
parents:
599
diff
changeset
|
698 |
return $arr3; |
daf8c556ada7
Moved enano_safe_array_merge() to functions.php as comment.php depends on it
Dan
parents:
599
diff
changeset
|
699 |
} |
daf8c556ada7
Moved enano_safe_array_merge() to functions.php as comment.php depends on it
Dan
parents:
599
diff
changeset
|
700 |
|
1 | 701 |
// Convert IP address to hex string |
702 |
// Input: 127.0.0.1 (string) |
|
703 |
// Output: 0x7f000001 (string) |
|
704 |
// Updated 12/8/06 to work with PHP4 and not use eval() (blech) |
|
705 |
function ip2hex($ip) { |
|
706 |
if ( preg_match('/^([0-9a-f:]+)$/', $ip) ) |
|
707 |
{ |
|
708 |
// this is an ipv6 address |
|
709 |
return str_replace(':', '', $ip); |
|
710 |
} |
|
711 |
$nums = explode('.', $ip); |
|
712 |
if(sizeof($nums) != 4) return false; |
|
713 |
$str = '0x'; |
|
714 |
foreach($nums as $n) |
|
715 |
{ |
|
221
e5302cb1945c
Localized a good part, if not all, of the registration page and a couple other things.
Dan
parents:
214
diff
changeset
|
716 |
$byte = (string)dechex($n); |
e5302cb1945c
Localized a good part, if not all, of the registration page and a couple other things.
Dan
parents:
214
diff
changeset
|
717 |
if ( strlen($byte) < 2 ) |
e5302cb1945c
Localized a good part, if not all, of the registration page and a couple other things.
Dan
parents:
214
diff
changeset
|
718 |
$byte = '0' . $byte; |
1 | 719 |
} |
720 |
return $str; |
|
721 |
} |
|
722 |
||
723 |
// Convert DWord to IP address |
|
724 |
// Input: 0x7f000001 |
|
725 |
// Output: 127.0.0.1 |
|
726 |
// Updated 12/8/06 to work with PHP4 and not use eval() (blech) |
|
727 |
function hex2ip($in) { |
|
728 |
if(substr($in, 0, 2) == '0x') $ip = substr($in, 2, 8); |
|
729 |
else $ip = substr($in, 0, 8); |
|
730 |
$octets = enano_str_split($ip, 2); |
|
731 |
$str = ''; |
|
732 |
$newoct = Array(); |
|
733 |
foreach($octets as $o) |
|
734 |
{ |
|
735 |
$o = (int)hexdec($o); |
|
736 |
$newoct[] = $o; |
|
737 |
} |
|
738 |
return implode('.', $newoct); |
|
739 |
} |
|
740 |
||
741 |
// Function strip_php moved to RenderMan class |
|
742 |
||
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
743 |
/** |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
744 |
* Immediately brings the site to a halt with an error message. Unlike grinding_halt() this can only be called after the config has been |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
745 |
* fetched (plugin developers don't even need to worry since plugins are always loaded after the config) and shows the site name and |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
746 |
* description. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
747 |
* @param string The title of the error message |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
748 |
* @param string The body of the message, this can be HTML, and should be separated into paragraphs using the <p> tag |
479
192db6ac195b
Added $no_wrapper parameter to die_semicritical, useful for some upcoming PageProcessor tweaks.
Dan
parents:
473
diff
changeset
|
749 |
* @param bool Added in 1.1.3. If true, only the error is output. Defaults to false. |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
750 |
*/ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
751 |
|
479
192db6ac195b
Added $no_wrapper parameter to die_semicritical, useful for some upcoming PageProcessor tweaks.
Dan
parents:
473
diff
changeset
|
752 |
function die_semicritical($t, $p, $no_wrapper = false) |
1 | 753 |
{ |
754 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
755 |
$db->close(); |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
519
diff
changeset
|
756 |
|
1 | 757 |
if ( ob_get_status() ) |
758 |
ob_end_clean(); |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
519
diff
changeset
|
759 |
|
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
519
diff
changeset
|
760 |
// If the config hasn't been fetched yet, call grinding_halt. |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
519
diff
changeset
|
761 |
if ( !defined('ENANO_CONFIG_FETCHED') ) |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
519
diff
changeset
|
762 |
{ |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
519
diff
changeset
|
763 |
grinding_halt($t, $p); |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
519
diff
changeset
|
764 |
} |
500
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
765 |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
519
diff
changeset
|
766 |
// also do grinding_halt() if we're in CLI mode |
500
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
767 |
if ( defined('ENANO_CLI') ) |
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
768 |
{ |
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
769 |
grinding_halt($t, $p); |
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
770 |
} |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
771 |
|
479
192db6ac195b
Added $no_wrapper parameter to die_semicritical, useful for some upcoming PageProcessor tweaks.
Dan
parents:
473
diff
changeset
|
772 |
if ( $no_wrapper ) |
192db6ac195b
Added $no_wrapper parameter to die_semicritical, useful for some upcoming PageProcessor tweaks.
Dan
parents:
473
diff
changeset
|
773 |
{ |
192db6ac195b
Added $no_wrapper parameter to die_semicritical, useful for some upcoming PageProcessor tweaks.
Dan
parents:
473
diff
changeset
|
774 |
echo '<h2>' . htmlspecialchars($t) . '</h2>'; |
192db6ac195b
Added $no_wrapper parameter to die_semicritical, useful for some upcoming PageProcessor tweaks.
Dan
parents:
473
diff
changeset
|
775 |
echo "<p>$p</p>"; |
192db6ac195b
Added $no_wrapper parameter to die_semicritical, useful for some upcoming PageProcessor tweaks.
Dan
parents:
473
diff
changeset
|
776 |
exit; |
192db6ac195b
Added $no_wrapper parameter to die_semicritical, useful for some upcoming PageProcessor tweaks.
Dan
parents:
473
diff
changeset
|
777 |
} |
192db6ac195b
Added $no_wrapper parameter to die_semicritical, useful for some upcoming PageProcessor tweaks.
Dan
parents:
473
diff
changeset
|
778 |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
519
diff
changeset
|
779 |
$theme = ( defined('ENANO_CONFIG_FETCHED') ) ? getConfig('theme_default') : 'oxygen'; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
519
diff
changeset
|
780 |
$style = ( defined('ENANO_CONFIG_FETCHED') ) ? '__foo__' : 'bleu'; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
519
diff
changeset
|
781 |
|
1 | 782 |
$tpl = new template_nodb(); |
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
519
diff
changeset
|
783 |
$tpl->load_theme($theme, $style); |
1 | 784 |
$tpl->tpl_strings['SITE_NAME'] = getConfig('site_name'); |
785 |
$tpl->tpl_strings['SITE_DESC'] = getConfig('site_desc'); |
|
786 |
$tpl->tpl_strings['COPYRIGHT'] = getConfig('copyright_notice'); |
|
787 |
$tpl->tpl_strings['PAGE_NAME'] = $t; |
|
788 |
$tpl->header(); |
|
789 |
echo $p; |
|
790 |
$tpl->footer(); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
791 |
|
1 | 792 |
exit; |
793 |
} |
|
794 |
||
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
795 |
/** |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
796 |
* Halts Enano execution with a message. This doesn't have to be an error message, it's sometimes used to indicate success at an operation. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
797 |
* @param string The title of the message |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
798 |
* @param string The body of the message, this can be HTML, and should be separated into paragraphs using the <p> tag |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
799 |
*/ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
800 |
|
1 | 801 |
function die_friendly($t, $p) |
802 |
{ |
|
803 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
804 |
|
1 | 805 |
if ( ob_get_status() ) |
806 |
ob_end_clean(); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
807 |
|
1 | 808 |
$paths->cpage['name'] = $t; |
809 |
$template->tpl_strings['PAGE_NAME'] = $t; |
|
810 |
$template->header(); |
|
811 |
echo $p; |
|
812 |
$template->footer(); |
|
813 |
$db->close(); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
814 |
|
1 | 815 |
exit; |
816 |
} |
|
817 |
||
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
818 |
/** |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
819 |
* Immediately brings the site to a halt with an error message, and focuses on immediately closing the database connection and shutting down Enano in the event that an attack may happen. This should only be used very early on to indicate very severe errors, or if the site may be under attack (like if the DBAL detects a malicious query). In the vast majority of cases, die_semicritical() is more appropriate. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
820 |
* @param string The title of the error message |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
821 |
* @param string The body of the message, this can be HTML, and should be separated into paragraphs using the <p> tag |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
822 |
*/ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
823 |
|
1 | 824 |
function grinding_halt($t, $p) |
825 |
{ |
|
826 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
125
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
827 |
|
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
828 |
if ( !defined('scriptPath') ) |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
829 |
require( ENANO_ROOT . '/config.php' ); |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
830 |
|
125
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
831 |
if ( is_object($db) ) |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
832 |
$db->close(); |
500
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
833 |
|
1 | 834 |
if ( ob_get_status() ) |
835 |
ob_end_clean(); |
|
500
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
836 |
|
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
837 |
if ( defined('ENANO_CLI') ) |
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
838 |
{ |
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
839 |
// set console color |
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
840 |
echo "\x1B[31;1m"; |
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
841 |
// error title |
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
842 |
echo "Critical error in Enano runtime: "; |
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
843 |
// unbold |
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
844 |
echo "$t\n"; |
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
845 |
// bold |
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
846 |
echo "\x1B[37;1m"; |
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
847 |
echo "Error: "; |
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
848 |
// unbold |
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
849 |
echo "\x1B[0m"; |
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
850 |
echo "$p\n"; |
662
fcab604da9a7
Made grinding_halt() exit with status 1 for POSIX compatibility; jscompress.php utility now accepts non-CDN websites
Dan
parents:
621
diff
changeset
|
851 |
exit(1); |
500
455277559782
Added basic CLI support for the Enano API. Loads automatically, just include common.php as normal. REVISION 500!!! :-D
Dan
parents:
481
diff
changeset
|
852 |
} |
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
519
diff
changeset
|
853 |
$theme = ( defined('ENANO_CONFIG_FETCHED') ) ? getConfig('theme_default') : 'oxygen'; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
519
diff
changeset
|
854 |
$style = ( defined('ENANO_CONFIG_FETCHED') ) ? '__foo__' : 'bleu'; |
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
519
diff
changeset
|
855 |
|
1 | 856 |
$tpl = new template_nodb(); |
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
519
diff
changeset
|
857 |
$tpl->load_theme($theme, $style); |
1 | 858 |
$tpl->tpl_strings['SITE_NAME'] = 'Critical error'; |
859 |
$tpl->tpl_strings['SITE_DESC'] = 'This website is experiencing a serious error and cannot load.'; |
|
860 |
$tpl->tpl_strings['COPYRIGHT'] = 'Unable to retrieve copyright information'; |
|
861 |
$tpl->tpl_strings['PAGE_NAME'] = $t; |
|
862 |
$tpl->header(); |
|
863 |
echo $p; |
|
864 |
$tpl->footer(); |
|
533
698a8f04957c
Huge improvements to the template_nodb class and surrounding code; moved template compiler core to its own non-classed function to allow code re-use
Dan
parents:
519
diff
changeset
|
865 |
|
1 | 866 |
exit; |
867 |
} |
|
868 |
||
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
869 |
/** |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
870 |
* Prints out the categorization box found on most regular pages. Doesn't take or return anything, but assumes that the page information is already set in $paths. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
871 |
*/ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
872 |
|
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
873 |
function show_category_info() |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
874 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
875 |
global $db, $session, $paths, $template, $plugins; // Common objects |
214 | 876 |
global $lang; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
877 |
|
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
878 |
if ( $paths->namespace == 'Category' ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
879 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
880 |
// Show member pages and subcategories |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
881 |
$q = $db->sql_query('SELECT p.urlname, p.namespace, p.name, p.namespace=\'Category\' AS is_category FROM '.table_prefix.'categories AS c |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
882 |
LEFT JOIN '.table_prefix.'pages AS p |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
883 |
ON ( p.urlname = c.page_id AND p.namespace = c.namespace ) |
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
884 |
WHERE c.category_id=\'' . $db->escape($paths->page_id) . '\' |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
885 |
ORDER BY is_category DESC, p.name ASC;'); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
886 |
if ( !$q ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
887 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
888 |
$db->_die(); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
889 |
} |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
890 |
echo '<h3>' . $lang->get('onpage_cat_heading_subcategories') . '</h3>'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
891 |
echo '<div class="tblholder">'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
892 |
echo '<table border="0" cellspacing="1" cellpadding="4">'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
893 |
echo '<tr>'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
894 |
$ticker = 0; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
895 |
$counter = 0; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
896 |
$switched = false; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
897 |
$class = 'row1'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
898 |
while ( $row = $db->fetchrow() ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
899 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
900 |
if ( $row['is_category'] == 0 && !$switched ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
901 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
902 |
if ( $counter > 0 ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
903 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
904 |
// Fill-in |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
905 |
while ( $ticker < 3 ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
906 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
907 |
$ticker++; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
908 |
echo '<td class="' . $class . '" style="width: 33.3%;"></td>'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
909 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
910 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
911 |
else |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
912 |
{ |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
913 |
echo '<td class="' . $class . '">' . $lang->get('onpage_cat_msg_no_subcategories') . '</td>'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
914 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
915 |
echo '</tr></table></div>' . "\n\n"; |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
916 |
echo '<h3>' . $lang->get('onpage_cat_heading_pages') . '</h3>'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
917 |
echo '<div class="tblholder">'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
918 |
echo '<table border="0" cellspacing="1" cellpadding="4">'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
919 |
echo '<tr>'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
920 |
$counter = 0; |
129
0b5244001799
Rebranded as 1.0.1.1; fixed category page drawing bug; updated link to GPL in the about page to the GPLv2
Dan
parents:
128
diff
changeset
|
921 |
$ticker = -1; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
922 |
$switched = true; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
923 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
924 |
$counter++; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
925 |
$ticker++; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
926 |
if ( $ticker == 3 ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
927 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
928 |
echo '</tr><tr>'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
929 |
$ticker = 0; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
930 |
$class = ( $class == 'row3' ) ? 'row1' : 'row3'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
931 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
932 |
echo "<td class=\"{$class}\" style=\"width: 33.3%;\">"; // " to workaround stupid jEdit bug |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
933 |
|
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
934 |
$link = makeUrlNS($row['namespace'], sanitize_page_id($row['urlname'])); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
935 |
echo '<a href="' . $link . '"'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
936 |
$key = $paths->nslist[$row['namespace']] . sanitize_page_id($row['urlname']); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
937 |
if ( !isPage( $key ) ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
938 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
939 |
echo ' class="wikilink-nonexistent"'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
940 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
941 |
echo '>'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
942 |
$title = get_page_title_ns($row['urlname'], $row['namespace']); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
943 |
echo htmlspecialchars($title); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
944 |
echo '</a>'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
945 |
|
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
946 |
echo "</td>"; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
947 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
948 |
if ( !$switched ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
949 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
950 |
if ( $counter > 0 ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
951 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
952 |
// Fill-in |
129
0b5244001799
Rebranded as 1.0.1.1; fixed category page drawing bug; updated link to GPL in the about page to the GPLv2
Dan
parents:
128
diff
changeset
|
953 |
while ( $ticker < 2 ) |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
954 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
955 |
$ticker++; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
956 |
echo '<td class="' . $class . '" style="width: 33.3%;"></td>'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
957 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
958 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
959 |
else |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
960 |
{ |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
961 |
echo '<td class="' . $class . '">' . $lang->get('onpage_cat_msg_no_subcategories') . '</td>'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
962 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
963 |
echo '</tr></table></div>' . "\n\n"; |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
964 |
echo '<h3>' . $lang->get('onpage_cat_heading_pages') . '</h3>'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
965 |
echo '<div class="tblholder">'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
966 |
echo '<table border="0" cellspacing="1" cellpadding="4">'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
967 |
echo '<tr>'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
968 |
$counter = 0; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
969 |
$ticker = 0; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
970 |
$switched = true; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
971 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
972 |
if ( $counter > 0 ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
973 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
974 |
// Fill-in |
129
0b5244001799
Rebranded as 1.0.1.1; fixed category page drawing bug; updated link to GPL in the about page to the GPLv2
Dan
parents:
128
diff
changeset
|
975 |
while ( $ticker < 2 ) |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
976 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
977 |
$ticker++; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
978 |
echo '<td class="' . $class . '" style="width: 33.3%;"></td>'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
979 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
980 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
981 |
else |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
982 |
{ |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
983 |
echo '<td class="' . $class . '">' . $lang->get('onpage_cat_msg_no_pages') . '</td>'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
984 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
985 |
echo '</tr></table></div>' . "\n\n"; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
986 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
987 |
|
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
988 |
if ( $paths->namespace != 'Special' && $paths->namespace != 'Admin' ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
989 |
{ |
86
c162ca39db8f
Finished pagination code (was incomplete in previous revision) and added a few hacks for an upcoming theme
Dan
parents:
82
diff
changeset
|
990 |
echo '<div class="mdg-comment" style="margin: 10px 0 0 0;" id="category_box_wrapper">'; |
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
991 |
echo '<div style="float: right;">'; |
214 | 992 |
echo '(<a href="#" onclick="ajaxCatToTag(); return false;">' . $lang->get('tags_catbox_link') . '</a>)'; |
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
993 |
echo '</div>'; |
214 | 994 |
echo '<div id="mdgCatBox">' . $lang->get('catedit_catbox_lbl_categories') . ' '; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
995 |
|
322
5f1cd51bf1be
Many changes. Installer with PostgreSQL is broken badly and will be for some time.
Dan
parents:
320
diff
changeset
|
996 |
$where = '( c.page_id=\'' . $db->escape($paths->page_id) . '\' AND c.namespace=\'' . $db->escape($paths->namespace) . '\' )'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
997 |
$prefix = table_prefix; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
998 |
$sql = <<<EOF |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
999 |
SELECT c.category_id FROM {$prefix}categories AS c |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1000 |
LEFT JOIN {$prefix}pages AS p |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1001 |
ON ( ( p.urlname = c.page_id AND p.namespace = c.namespace ) OR ( p.urlname IS NULL AND p.namespace IS NULL ) ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1002 |
WHERE $where |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1003 |
ORDER BY p.name ASC, c.page_id ASC; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1004 |
EOF; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1005 |
$q = $db->sql_query($sql); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1006 |
if ( !$q ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1007 |
$db->_die(); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1008 |
|
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1009 |
if ( $row = $db->fetchrow() ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1010 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1011 |
$list = array(); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1012 |
do |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1013 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1014 |
$cid = sanitize_page_id($row['category_id']); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1015 |
$title = get_page_title_ns($cid, 'Category'); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1016 |
$link = makeUrlNS('Category', $cid); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1017 |
$list[] = '<a href="' . $link . '">' . htmlspecialchars($title) . '</a>'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1018 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1019 |
while ( $row = $db->fetchrow() ); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1020 |
echo implode(', ', $list); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1021 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1022 |
else |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1023 |
{ |
214 | 1024 |
echo $lang->get('catedit_catbox_lbl_uncategorized'); |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1025 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1026 |
|
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1027 |
$can_edit = ( $session->get_permissions('edit_cat') && ( !$paths->page_protected || $session->get_permissions('even_when_protected') ) ); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1028 |
if ( $can_edit ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1029 |
{ |
214 | 1030 |
$edit_link = '<a href="' . makeUrl($paths->page, 'do=catedit', true) . '" onclick="ajaxCatEdit(); return false;">' . $lang->get('catedit_catbox_link_edit') . '</a>'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1031 |
echo ' [ ' . $edit_link . ' ]'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1032 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1033 |
|
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1034 |
echo '</div></div>'; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1035 |
|
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1036 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1037 |
|
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1038 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1039 |
|
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1040 |
/** |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1041 |
* Prints out the file information box seen on File: pages. Doesn't take or return anything, but assumes that the page information is already set in $paths, and expects $paths->namespace to be File. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1042 |
*/ |
1 | 1043 |
|
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
1044 |
function show_file_info($page = false) |
1 | 1045 |
{ |
1046 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1047 |
global $lang; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1048 |
|
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
1049 |
$local_page_id = $paths->page_id; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
1050 |
$local_namespace = $paths->namespace; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
1051 |
|
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
1052 |
if ( is_object($page) ) |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
1053 |
{ |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
1054 |
$local_page = $page->page_id; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
1055 |
$local_namespace = $page->namespace; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
1056 |
} |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
1057 |
|
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1058 |
// Prevent unnecessary work |
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
1059 |
if ( $local_namespace != 'File' ) |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1060 |
return null; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1061 |
|
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
1062 |
$selfn = $local_page_id; |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1063 |
if ( substr($paths->cpage['name'], 0, strlen($paths->nslist['File'])) == $paths->nslist['File']) |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1064 |
{ |
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
1065 |
$selfn = substr($local_page_id, strlen($paths->nslist['File']), strlen($local_page_id)); |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1066 |
} |
481
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1067 |
$selfn = $db->escape($selfn); |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1068 |
$q = $db->sql_query('SELECT f.mimetype,f.time_id,f.size,l.log_id FROM ' . table_prefix . "files AS f\n" |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1069 |
. " LEFT JOIN " . table_prefix . "logs AS l\n" |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1070 |
. " ON ( l.time_id = f.time_id AND ( l.action = 'reupload' OR l.action IS NULL ) )\n" |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1071 |
. " WHERE f.page_id = '$selfn'\n" |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1072 |
. " ORDER BY f.time_id DESC;"); |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1073 |
if ( !$q ) |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1074 |
{ |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1075 |
$db->_die('The file type could not be fetched.'); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1076 |
} |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1077 |
|
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1078 |
if ( $db->numrows() < 1 ) |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1079 |
{ |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1080 |
echo '<div class="mdg-comment" style="margin-left: 0;"> |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1081 |
<h3>' . $lang->get('onpage_filebox_heading') . '</h3> |
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
1082 |
<p>' . $lang->get('onpage_filebox_msg_not_found', array('upload_link' => makeUrlNS('Special', 'UploadFile/'.$local_page_id))) . '</p> |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1083 |
</div> |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1084 |
<br />'; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1085 |
return; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1086 |
} |
1 | 1087 |
$r = $db->fetchrow(); |
1088 |
$mimetype = $r['mimetype']; |
|
345
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
343
diff
changeset
|
1089 |
$datestring = enano_date('F d, Y h:i a', (int)$r['time_id']); |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1090 |
echo '<div class="mdg-comment" style="margin-left: 0;"> |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1091 |
<h3>' . $lang->get('onpage_filebox_heading') . '</h3> |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1092 |
<p>' . $lang->get('onpage_filebox_lbl_type') . ' '.$r['mimetype'].'<br />'; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1093 |
|
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1094 |
$size = $r['size'] . ' ' . $lang->get('etc_unit_bytes'); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1095 |
if ( $r['size'] >= 1048576 ) |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1096 |
{ |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1097 |
$size .= ' (' . ( round($r['size'] / 1048576, 1) ) . ' ' . $lang->get('etc_unit_megabytes_short') . ')'; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1098 |
} |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1099 |
else if ( $r['size'] >= 1024 ) |
1 | 1100 |
{ |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1101 |
$size .= ' (' . ( round($r['size'] / 1024, 1) ) . ' ' . $lang->get('etc_unit_kilobytes_short') . ')'; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1102 |
} |
481
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1103 |
|
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1104 |
echo $lang->get('onpage_filebox_lbl_size', array('size' => $size)); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1105 |
|
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1106 |
echo '<br />' . $lang->get('onpage_filebox_lbl_uploaded') . ' ' . $datestring . '</p>'; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1107 |
if ( substr($mimetype, 0, 6) != 'image/' && ( substr($mimetype, 0, 5) != 'text/' || $mimetype == 'text/html' || $mimetype == 'text/javascript' ) ) |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1108 |
{ |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1109 |
echo '<div class="warning-box"> |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1110 |
' . $lang->get('onpage_filebox_msg_virus_warning') . ' |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1111 |
</div>'; |
1 | 1112 |
} |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1113 |
if ( substr($mimetype, 0, 6) == 'image/' ) |
1 | 1114 |
{ |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1115 |
echo '<p> |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1116 |
<a href="'.makeUrlNS('Special', 'DownloadFile'.'/'.$selfn).'"> |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1117 |
<img style="border: 0;" alt="'.$paths->page.'" src="'.makeUrlNS('Special', 'DownloadFile'.'/'.$selfn.htmlspecialchars(urlSeparator).'preview').'" /> |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1118 |
</a> |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1119 |
</p>'; |
1 | 1120 |
} |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1121 |
echo '<p> |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1122 |
<a href="'.makeUrlNS('Special', 'DownloadFile'.'/'.$selfn.'/'.$r['time_id'].htmlspecialchars(urlSeparator).'download').'"> |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1123 |
' . $lang->get('onpage_filebox_btn_download') . ' |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1124 |
</a>'; |
1 | 1125 |
if(!$paths->page_protected && ( $paths->wiki_mode || $session->get_permissions('upload_new_version') )) |
1126 |
{ |
|
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1127 |
echo ' | <a href="'.makeUrlNS('Special', 'UploadFile'.'/'.$selfn).'"> |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1128 |
' . $lang->get('onpage_filebox_btn_upload_new') . ' |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1129 |
</a>'; |
1 | 1130 |
} |
1131 |
echo '</p>'; |
|
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1132 |
if ( $db->numrows() > 1 ) |
1 | 1133 |
{ |
481
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1134 |
// requery, sql_result_seek() doesn't work on postgres |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1135 |
$db->free_result(); |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1136 |
$q = $db->sql_query('SELECT f.mimetype,f.time_id,f.size,l.log_id FROM ' . table_prefix . "files AS f\n" |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1137 |
. " LEFT JOIN " . table_prefix . "logs AS l\n" |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1138 |
. " ON ( l.time_id = f.time_id AND ( l.action = 'reupload' OR l.action IS NULL ) )\n" |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1139 |
. " WHERE f.page_id = '$selfn'\n" |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1140 |
. " ORDER BY f.time_id DESC;"); |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1141 |
if ( !$q ) |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1142 |
$db->_die(); |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1143 |
|
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1144 |
echo '<h3>' . $lang->get('onpage_filebox_heading_history') . '</h3><p>'; |
481
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1145 |
$last_rollback_id = false; |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1146 |
while ( $r = $db->fetchrow() ) |
1 | 1147 |
{ |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1148 |
echo '(<a href="'.makeUrlNS('Special', 'DownloadFile'.'/'.$selfn.'/'.$r['time_id'].htmlspecialchars(urlSeparator).'download').'">' . $lang->get('onpage_filebox_btn_this_version') . '</a>) '; |
481
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1149 |
if ( $session->get_permissions('history_rollback') && $last_rollback_id ) |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1150 |
echo ' (<a href="#rollback:' . $last_rollback_id . '" onclick="ajaxRollback(\''.$last_rollback_id.'\'); return false;">' . $lang->get('onpage_filebox_btn_revert') . '</a>) '; |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1151 |
else if ( $session->get_permissions('history_rollback') && !$last_rollback_id ) |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1152 |
echo ' (' . $lang->get('onpage_filebox_btn_current') . ') '; |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
1153 |
$last_rollback_id = $r['log_id']; |
1 | 1154 |
$mimetype = $r['mimetype']; |
345
4ccdfeee9a11
WiP commit for admin panel localization. All modules up to Admin:UserManager (working down the list) are localized except Admin:ThemeManager, which is due for a rewrite
Dan
parents:
343
diff
changeset
|
1155 |
$datestring = enano_date('F d, Y h:i a', (int)$r['time_id']); |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1156 |
|
1 | 1157 |
echo $datestring.': '.$r['mimetype'].', '; |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1158 |
|
1 | 1159 |
$fs = $r['size']; |
1160 |
$fs = (int)$fs; |
|
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1161 |
|
1 | 1162 |
if($fs >= 1048576) |
1163 |
{ |
|
1164 |
$fs = round($fs / 1048576, 1); |
|
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1165 |
$size = $fs . ' ' . $lang->get('etc_unit_megabytes_short'); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1166 |
} |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1167 |
else |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1168 |
if ( $fs >= 1024 ) |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1169 |
{ |
1 | 1170 |
$fs = round($fs / 1024, 1); |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1171 |
$size = $fs . ' ' . $lang->get('etc_unit_kilobytes_short'); |
1 | 1172 |
} |
391
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1173 |
else |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1174 |
{ |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1175 |
$size = $fs . ' ' . $lang->get('etc_unit_bytes'); |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1176 |
} |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1177 |
|
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1178 |
echo $size; |
85f91037cd4f
Localization is FINISHED, DAMN IT HELLAH YEAH! OVER WITH! Man, it feels to get that off my chest. Release is in under 48 hours, folks. And we're ready for it.
Dan
parents:
387
diff
changeset
|
1179 |
|
1 | 1180 |
echo '<br />'; |
1181 |
} |
|
1182 |
echo '</p>'; |
|
1183 |
} |
|
1184 |
$db->free_result(); |
|
1185 |
echo '</div><br />'; |
|
1186 |
} |
|
1187 |
||
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1188 |
/** |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1189 |
* Shows header information on the current page. Currently this is only the delete-vote feature. Doesn't take or return anything, but assumes that the page information is already set in $paths. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1190 |
*/ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1191 |
|
1 | 1192 |
function display_page_headers() |
1193 |
{ |
|
1194 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
214 | 1195 |
global $lang; |
1 | 1196 |
if($session->get_permissions('vote_reset') && $paths->cpage['delvotes'] > 0) |
1197 |
{ |
|
112
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
91
diff
changeset
|
1198 |
$delvote_ips = unserialize($paths->cpage['delvote_ips']); |
008b1c42be72
Rewrote all code related to delvote_ips column to use serialize()
Dan
parents:
91
diff
changeset
|
1199 |
$hr = htmlspecialchars(implode(', ', $delvote_ips['u'])); |
214 | 1200 |
|
1201 |
$string_id = ( $paths->cpage['delvotes'] == 1 ) ? 'delvote_lbl_votes_one' : 'delvote_lbl_votes_plural'; |
|
1202 |
$string = $lang->get($string_id, array('num_users' => $paths->cpage['delvotes'])); |
|
1203 |
||
1 | 1204 |
echo '<div class="info-box" style="margin-left: 0; margin-top: 5px;" id="mdgDeleteVoteNoticeBox"> |
214 | 1205 |
<b>' . $lang->get('etc_lbl_notice') . '</b> ' . $string . '<br /> |
1206 |
<b>' . $lang->get('delvote_lbl_users_that_voted') . '</b> ' . $hr . '<br /> |
|
1207 |
<a href="'.makeUrl($paths->page, 'do=deletepage').'" onclick="ajaxDeletePage(); return false;">' . $lang->get('delvote_btn_deletepage') . '</a> | <a href="'.makeUrl($paths->page, 'do=resetvotes').'" onclick="ajaxResetDelVotes(); return false;">' . $lang->get('delvote_btn_resetvotes') . '</a> |
|
1 | 1208 |
</div>'; |
1209 |
} |
|
1210 |
} |
|
1211 |
||
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1212 |
/** |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1213 |
* Displays page footer information including file and category info. This also has the send_page_footers hook. Doesn't take or return anything, but assumes that the page information is already set in $paths. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1214 |
*/ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1215 |
|
1 | 1216 |
function display_page_footers() |
1217 |
{ |
|
1218 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
1219 |
if(isset($_GET['nofooters'])) return; |
|
1220 |
$code = $plugins->setHook('send_page_footers'); |
|
1221 |
foreach ( $code as $cmd ) |
|
1222 |
{ |
|
1223 |
eval($cmd); |
|
1224 |
} |
|
1225 |
show_file_info(); |
|
1226 |
show_category_info(); |
|
1227 |
} |
|
1228 |
||
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1229 |
/** |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1230 |
* Essentially an return code reader for a socket. Don't use this unless you're writing mail code and smtp_send_email doesn't cut it. Ported from phpBB's smtp.php. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1231 |
* @param socket A socket resource |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1232 |
* @param string The expected response from the server, this needs to be exactly three characters. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1233 |
*/ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1234 |
|
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1235 |
function smtp_get_response($socket, $response, $line = __LINE__) |
1 | 1236 |
{ |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1237 |
$server_response = ''; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1238 |
while (substr($server_response, 3, 1) != ' ') |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1239 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1240 |
if (!($server_response = fgets($socket, 256))) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1241 |
{ |
1 | 1242 |
die_friendly('SMTP Error', "<p>Couldn't get mail server response codes</p>"); |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1243 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1244 |
} |
1 | 1245 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1246 |
if (!(substr($server_response, 0, 3) == $response)) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1247 |
{ |
1 | 1248 |
die_friendly('SMTP Error', "<p>Ran into problems sending mail. Response: $server_response</p>"); |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1249 |
} |
1 | 1250 |
} |
1251 |
||
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1252 |
/** |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1253 |
* Wrapper for smtp_send_email_core that takes the sender as the fourth parameter instead of additional headers. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1254 |
* @param string E-mail address to send to |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1255 |
* @param string Subject line |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1256 |
* @param string The body of the message |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1257 |
* @param string Address of the sender |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1258 |
*/ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1259 |
|
1 | 1260 |
function smtp_send_email($to, $subject, $message, $from) |
1261 |
{ |
|
1262 |
return smtp_send_email_core($to, $subject, $message, "From: <$from>\n"); |
|
1263 |
} |
|
1264 |
||
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1265 |
/** |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1266 |
* Replacement or substitute for PHP's mail() builtin function. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1267 |
* @param string E-mail address to send to |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1268 |
* @param string Subject line |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1269 |
* @param string The body of the message |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1270 |
* @param string Message headers, separated by a single newline ("\n") |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1271 |
* @copyright (C) phpBB Group |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1272 |
* @license GPL |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1273 |
*/ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1274 |
|
1 | 1275 |
function smtp_send_email_core($mail_to, $subject, $message, $headers = '') |
1276 |
{ |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1277 |
// Fix any bare linefeeds in the message to make it RFC821 Compliant. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1278 |
$message = preg_replace("#(?<!\r)\n#si", "\r\n", $message); |
1 | 1279 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1280 |
if ($headers != '') |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1281 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1282 |
if (is_array($headers)) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1283 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1284 |
if (sizeof($headers) > 1) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1285 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1286 |
$headers = join("\n", $headers); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1287 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1288 |
else |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1289 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1290 |
$headers = $headers[0]; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1291 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1292 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1293 |
$headers = chop($headers); |
1 | 1294 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1295 |
// Make sure there are no bare linefeeds in the headers |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1296 |
$headers = preg_replace('#(?<!\r)\n#si', "\r\n", $headers); |
1 | 1297 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1298 |
// Ok this is rather confusing all things considered, |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1299 |
// but we have to grab bcc and cc headers and treat them differently |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1300 |
// Something we really didn't take into consideration originally |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1301 |
$header_array = explode("\r\n", $headers); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1302 |
@reset($header_array); |
1 | 1303 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1304 |
$headers = ''; |
472
bc4b58034f4d
Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents:
468
diff
changeset
|
1305 |
$cc = ''; |
bc4b58034f4d
Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents:
468
diff
changeset
|
1306 |
$bcc = ''; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1307 |
while(list(, $header) = each($header_array)) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1308 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1309 |
if (preg_match('#^cc:#si', $header)) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1310 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1311 |
$cc = preg_replace('#^cc:(.*)#si', '\1', $header); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1312 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1313 |
else if (preg_match('#^bcc:#si', $header)) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1314 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1315 |
$bcc = preg_replace('#^bcc:(.*)#si', '\1', $header); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1316 |
$header = ''; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1317 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1318 |
$headers .= ($header != '') ? $header . "\r\n" : ''; |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1319 |
} |
1 | 1320 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1321 |
$headers = chop($headers); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1322 |
$cc = explode(', ', $cc); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1323 |
$bcc = explode(', ', $bcc); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1324 |
} |
1 | 1325 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1326 |
if (trim($subject) == '') |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1327 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1328 |
die_friendly(GENERAL_ERROR, "No email Subject specified"); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1329 |
} |
1 | 1330 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1331 |
if (trim($message) == '') |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1332 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1333 |
die_friendly(GENERAL_ERROR, "Email message was blank"); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1334 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1335 |
|
1 | 1336 |
// setup SMTP |
1337 |
$host = getConfig('smtp_server'); |
|
1338 |
if ( empty($host) ) |
|
1339 |
return 'No smtp_host in config'; |
|
1340 |
if ( strstr($host, ':' ) ) |
|
1341 |
{ |
|
1342 |
$n = explode(':', $host); |
|
1343 |
$smtp_host = $n[0]; |
|
1344 |
$port = intval($n[1]); |
|
1345 |
} |
|
1346 |
else |
|
1347 |
{ |
|
1348 |
$smtp_host = $host; |
|
1349 |
$port = 25; |
|
1350 |
} |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1351 |
|
1 | 1352 |
$smtp_user = getConfig('smtp_user'); |
1353 |
$smtp_pass = getConfig('smtp_password'); |
|
1354 |
||
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1355 |
// Ok we have error checked as much as we can to this point let's get on |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1356 |
// it already. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1357 |
if( !$socket = @fsockopen($smtp_host, $port, $errno, $errstr, 20) ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1358 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1359 |
die_friendly(GENERAL_ERROR, "Could not connect to smtp host : $errno : $errstr"); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1360 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1361 |
|
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1362 |
// Wait for reply |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1363 |
smtp_get_response($socket, "220", __LINE__); |
1 | 1364 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1365 |
// Do we want to use AUTH?, send RFC2554 EHLO, else send RFC821 HELO |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1366 |
// This improved as provided by SirSir to accomodate |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1367 |
if( !empty($smtp_user) && !empty($smtp_pass) ) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1368 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1369 |
enano_fputs($socket, "EHLO " . $smtp_host . "\r\n"); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1370 |
smtp_get_response($socket, "250", __LINE__); |
1 | 1371 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1372 |
enano_fputs($socket, "AUTH LOGIN\r\n"); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1373 |
smtp_get_response($socket, "334", __LINE__); |
1 | 1374 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1375 |
enano_fputs($socket, base64_encode($smtp_user) . "\r\n"); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1376 |
smtp_get_response($socket, "334", __LINE__); |
1 | 1377 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1378 |
enano_fputs($socket, base64_encode($smtp_pass) . "\r\n"); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1379 |
smtp_get_response($socket, "235", __LINE__); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1380 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1381 |
else |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1382 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1383 |
enano_fputs($socket, "HELO " . $smtp_host . "\r\n"); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1384 |
smtp_get_response($socket, "250", __LINE__); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1385 |
} |
1 | 1386 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1387 |
// From this point onward most server response codes should be 250 |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1388 |
// Specify who the mail is from.... |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1389 |
enano_fputs($socket, "MAIL FROM: <" . getConfig('contact_email') . ">\r\n"); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1390 |
smtp_get_response($socket, "250", __LINE__); |
1 | 1391 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1392 |
// Specify each user to send to and build to header. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1393 |
$to_header = ''; |
1 | 1394 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1395 |
// Add an additional bit of error checking to the To field. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1396 |
$mail_to = (trim($mail_to) == '') ? 'Undisclosed-recipients:;' : trim($mail_to); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1397 |
if (preg_match('#[^ ]+\@[^ ]+#', $mail_to)) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1398 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1399 |
enano_fputs($socket, "RCPT TO: <$mail_to>\r\n"); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1400 |
smtp_get_response($socket, "250", __LINE__); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1401 |
} |
1 | 1402 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1403 |
// Ok now do the CC and BCC fields... |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1404 |
@reset($bcc); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1405 |
while(list(, $bcc_address) = each($bcc)) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1406 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1407 |
// Add an additional bit of error checking to bcc header... |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1408 |
$bcc_address = trim($bcc_address); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1409 |
if (preg_match('#[^ ]+\@[^ ]+#', $bcc_address)) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1410 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1411 |
enano_fputs($socket, "RCPT TO: <$bcc_address>\r\n"); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1412 |
smtp_get_response($socket, "250", __LINE__); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1413 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1414 |
} |
1 | 1415 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1416 |
@reset($cc); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1417 |
while(list(, $cc_address) = each($cc)) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1418 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1419 |
// Add an additional bit of error checking to cc header |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1420 |
$cc_address = trim($cc_address); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1421 |
if (preg_match('#[^ ]+\@[^ ]+#', $cc_address)) |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1422 |
{ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1423 |
enano_fputs($socket, "RCPT TO: <$cc_address>\r\n"); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1424 |
smtp_get_response($socket, "250", __LINE__); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1425 |
} |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1426 |
} |
1 | 1427 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1428 |
// Ok now we tell the server we are ready to start sending data |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1429 |
enano_fputs($socket, "DATA\r\n"); |
1 | 1430 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1431 |
// This is the last response code we look for until the end of the message. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1432 |
smtp_get_response($socket, "354", __LINE__); |
1 | 1433 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1434 |
// Send the Subject Line... |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1435 |
enano_fputs($socket, "Subject: $subject\r\n"); |
1 | 1436 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1437 |
// Now the To Header. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1438 |
enano_fputs($socket, "To: $mail_to\r\n"); |
1 | 1439 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1440 |
// Now any custom headers.... |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1441 |
enano_fputs($socket, "$headers\r\n\r\n"); |
1 | 1442 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1443 |
// Ok now we are ready for the message... |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1444 |
enano_fputs($socket, "$message\r\n"); |
1 | 1445 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1446 |
// Ok the all the ingredients are mixed in let's cook this puppy... |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1447 |
enano_fputs($socket, ".\r\n"); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1448 |
smtp_get_response($socket, "250", __LINE__); |
1 | 1449 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1450 |
// Now tell the server we are done and close the socket... |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1451 |
enano_fputs($socket, "QUIT\r\n"); |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1452 |
fclose($socket); |
1 | 1453 |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1454 |
return TRUE; |
1 | 1455 |
} |
1456 |
||
1457 |
/** |
|
1458 |
* Tell which version of Enano we're running. |
|
1459 |
* @param bool $long if true, uses English version names (e.g. alpha, beta, release candidate). If false (default) uses abbreviations (1.0a1, 1.0b3, 1.0RC2, etc.) |
|
685
17ebe24cdf85
Rebranded as 1.1.5 (Caoineag alpha 5) and fixed a couple bugs related to CDN support in template_nodb and installerUI. Updated readme.
Dan
parents:
667
diff
changeset
|
1460 |
* @param bool If true, prevents nightly build information from being appended, useful for upgrade/versioning checks. |
1 | 1461 |
* @return string |
1462 |
*/ |
|
1463 |
||
1464 |
function enano_version($long = false, $no_nightly = false) |
|
1465 |
{ |
|
1466 |
$r = getConfig('enano_version'); |
|
1467 |
$rc = ( $long ) ? ' release candidate ' : 'RC'; |
|
1468 |
$b = ( $long ) ? ' beta ' : 'b'; |
|
1469 |
$a = ( $long ) ? ' alpha ' : 'a'; |
|
1470 |
if($v = getConfig('enano_rc_version')) $r .= $rc.$v; |
|
1471 |
if($v = getConfig('enano_beta_version')) $r .= $b.$v; |
|
1472 |
if($v = getConfig('enano_alpha_version')) $r .= $a.$v; |
|
1473 |
if ( defined('ENANO_NIGHTLY') && !$no_nightly ) |
|
1474 |
{ |
|
1475 |
$nightlytag = ENANO_NIGHTLY_MONTH . '-' . ENANO_NIGHTLY_DAY . '-' . ENANO_NIGHTLY_YEAR; |
|
1476 |
$nightlylong = ' nightly; build date: ' . ENANO_NIGHTLY_MONTH . '-' . ENANO_NIGHTLY_DAY . '-' . ENANO_NIGHTLY_YEAR; |
|
1477 |
$r = ( $long ) ? $r . $nightlylong : $r . '-nightly-' . $nightlytag; |
|
1478 |
} |
|
1479 |
return $r; |
|
1480 |
} |
|
1481 |
||
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1482 |
/** |
132
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1483 |
* Give the codename of the release of Enano being run. |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1484 |
* @return string |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1485 |
*/ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1486 |
|
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1487 |
function enano_codename() |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1488 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1489 |
$names = array( |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1490 |
'1.0RC1' => 'Leprechaun', |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1491 |
'1.0RC2' => 'Clurichaun', |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1492 |
'1.0RC3' => 'Druid', |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1493 |
'1.0' => 'Banshee', |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1494 |
'1.0.1' => 'Loch Ness', |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1495 |
'1.0.1.1'=> 'Loch Ness internal bugfix build', |
145 | 1496 |
'1.0.2b1'=> 'Coblynau unstable', |
317 | 1497 |
'1.0.2' => 'Coblynau', |
387
92664d2efab8
Rebranded source code as 1.1.1; added TinyMCE ACL rule as per Vadi's request: http://forum.enanocms.org/viewtopic.php?f=7&t=54
Dan
parents:
382
diff
changeset
|
1498 |
'1.0.3' => 'Dyrad', |
92664d2efab8
Rebranded source code as 1.1.1; added TinyMCE ACL rule as per Vadi's request: http://forum.enanocms.org/viewtopic.php?f=7&t=54
Dan
parents:
382
diff
changeset
|
1499 |
'1.1.1' => 'Caoineag alpha 1', |
411 | 1500 |
'1.1.2' => 'Caoineag alpha 2', |
436
242353360e37
Added support for Diffie-Hellman key exchange during login. w00t!
Dan
parents:
424
diff
changeset
|
1501 |
'1.1.3' => 'Caoineag alpha 3', |
536 | 1502 |
'1.1.4' => 'Caoineag alpha 4', |
685
17ebe24cdf85
Rebranded as 1.1.5 (Caoineag alpha 5) and fixed a couple bugs related to CDN support in template_nodb and installerUI. Updated readme.
Dan
parents:
667
diff
changeset
|
1503 |
'1.1.5' => 'Caoineag alpha 5', |
132
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1504 |
); |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1505 |
$version = enano_version(); |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1506 |
if ( isset($names[$version]) ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1507 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1508 |
return $names[$version]; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1509 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1510 |
return 'Anonymous build'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1511 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1512 |
|
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
1513 |
/** |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1514 |
* Badly named function to send back eval'able Javascript code with an error message. Deprecated, use JSON instead. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1515 |
* @param string Message to send |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1516 |
*/ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1517 |
|
1 | 1518 |
function _die($t) { |
1519 |
$_ob = 'document.getElementById("ajaxEditContainer").innerHTML = unescape(\'' . rawurlencode('' . $t . '') . '\')'; |
|
1520 |
die($_ob); |
|
1521 |
} |
|
1522 |
||
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1523 |
/** |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1524 |
* Same as _die(), but sends an SQL backtrace with the error message, and doesn't halt execution. |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1525 |
* @param string Message to send |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1526 |
*/ |
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1527 |
|
1 | 1528 |
function jsdie($text) { |
1529 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
1530 |
$text = rawurlencode($text . "\n\nSQL Backtrace:\n" . $db->sql_backtrace()); |
|
1531 |
echo 'document.getElementById("ajaxEditContainer").innerHTML = unescape(\''.$text.'\');'; |
|
1532 |
} |
|
1533 |
||
1534 |
/** |
|
1535 |
* Capitalizes the first letter of a string |
|
1536 |
* @param $text string the text to be transformed |
|
1537 |
* @return string |
|
1538 |
*/ |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1539 |
|
1 | 1540 |
function capitalize_first_letter($text) |
1541 |
{ |
|
1542 |
return strtoupper(substr($text, 0, 1)) . substr($text, 1); |
|
1543 |
} |
|
1544 |
||
1545 |
/** |
|
1546 |
* Checks if a value in a bitfield is on or off |
|
1547 |
* @param $bitfield int the bit-field value |
|
1548 |
* @param $value int the value to switch off |
|
1549 |
* @return bool |
|
1550 |
*/ |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1551 |
|
1 | 1552 |
function is_bit($bitfield, $value) |
1553 |
{ |
|
1554 |
return ( $bitfield & $value ) ? true : false; |
|
1555 |
} |
|
1556 |
||
1557 |
/** |
|
1558 |
* Trims spaces/newlines from the beginning and end of a string |
|
1559 |
* @param $text the text to process |
|
1560 |
* @return string |
|
1561 |
*/ |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1562 |
|
1 | 1563 |
function trim_spaces($text) |
1564 |
{ |
|
1565 |
$d = true; |
|
1566 |
while($d) |
|
1567 |
{ |
|
1568 |
$c = substr($text, 0, 1); |
|
1569 |
$a = substr($text, strlen($text)-1, strlen($text)); |
|
1570 |
if($c == "\n" || $c == "\r" || $c == "\t" || $c == ' ') $text = substr($text, 1, strlen($text)); |
|
1571 |
elseif($a == "\n" || $a == "\r" || $a == "\t" || $a == ' ') $text = substr($text, 0, strlen($text)-1); |
|
1572 |
else $d = false; |
|
1573 |
} |
|
1574 |
return $text; |
|
1575 |
} |
|
1576 |
||
1577 |
/** |
|
1578 |
* Enano-ese equivalent of str_split() which is only found in PHP5 |
|
1579 |
* @param $text string the text to split |
|
1580 |
* @param $inc int size of each block |
|
1581 |
* @return array |
|
1582 |
*/ |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1583 |
|
1 | 1584 |
function enano_str_split($text, $inc = 1) |
1585 |
{ |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1586 |
if($inc < 1) |
14
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1587 |
{ |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1588 |
return false; |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1589 |
} |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1590 |
if($inc >= strlen($text)) |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1591 |
{ |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1592 |
return Array($text); |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1593 |
} |
1 | 1594 |
$len = ceil(strlen($text) / $inc); |
1595 |
$ret = Array(); |
|
14
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1596 |
for ( $i = 0; $i < strlen($text); $i = $i + $inc ) |
1 | 1597 |
{ |
1598 |
$ret[] = substr($text, $i, $inc); |
|
1599 |
} |
|
1600 |
return $ret; |
|
1601 |
} |
|
1602 |
||
1603 |
/** |
|
1604 |
* Converts a hexadecimal number to a binary string. |
|
1605 |
* @param text string hexadecimal number |
|
1606 |
* @return string |
|
1607 |
*/ |
|
1608 |
function hex2bin($text) |
|
1609 |
{ |
|
1610 |
$arr = enano_str_split($text, 2); |
|
1611 |
$ret = ''; |
|
1612 |
for ($i=0; $i<sizeof($arr); $i++) |
|
1613 |
{ |
|
1614 |
$ret .= chr(hexdec($arr[$i])); |
|
1615 |
} |
|
1616 |
return $ret; |
|
1617 |
} |
|
1618 |
||
1619 |
/** |
|
1620 |
* Generates and/or prints a human-readable backtrace |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1621 |
* @param bool $return - if true, this function returns a string, otherwise returns null and prints the backtrace |
1 | 1622 |
* @return mixed |
1623 |
*/ |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1624 |
|
1 | 1625 |
function enano_debug_print_backtrace($return = false) |
1626 |
{ |
|
1627 |
ob_start(); |
|
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
1628 |
if ( !$return ) |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
1629 |
echo '<pre>'; |
19
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
parents:
16
diff
changeset
|
1630 |
if ( function_exists('debug_print_backtrace') ) |
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
parents:
16
diff
changeset
|
1631 |
{ |
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
parents:
16
diff
changeset
|
1632 |
debug_print_backtrace(); |
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
parents:
16
diff
changeset
|
1633 |
} |
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
parents:
16
diff
changeset
|
1634 |
else |
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
parents:
16
diff
changeset
|
1635 |
{ |
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
parents:
16
diff
changeset
|
1636 |
echo '<b>Warning:</b> No debug_print_backtrace() support!'; |
5d003b6c9e89
Added demo mode functionality to various parts of Enano (unlocked only with a plugin) and fixed groups table
Dan
parents:
16
diff
changeset
|
1637 |
} |
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
1638 |
if ( !$return ) |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
1639 |
echo '</pre>'; |
1 | 1640 |
$c = ob_get_contents(); |
1641 |
ob_end_clean(); |
|
1642 |
if($return) return $c; |
|
1643 |
else echo $c; |
|
1644 |
return null; |
|
1645 |
} |
|
1646 |
||
1647 |
/** |
|
1648 |
* Like rawurlencode(), but encodes all characters |
|
1649 |
* @param string $text the text to encode |
|
1650 |
* @param optional string $prefix text before each hex character |
|
1651 |
* @param optional string $suffix text after each hex character |
|
1652 |
* @return string |
|
1653 |
*/ |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1654 |
|
1 | 1655 |
function hexencode($text, $prefix = '%', $suffix = '') |
1656 |
{ |
|
1657 |
$arr = enano_str_split($text); |
|
1658 |
$r = ''; |
|
1659 |
foreach($arr as $a) |
|
1660 |
{ |
|
1661 |
$nibble = (string)dechex(ord($a)); |
|
1662 |
if(strlen($nibble) == 1) $nibble = '0' . $nibble; |
|
1663 |
$r .= $prefix . $nibble . $suffix; |
|
1664 |
} |
|
1665 |
return $r; |
|
1666 |
} |
|
1667 |
||
1668 |
/** |
|
1669 |
* Enano-ese equivalent of get_magic_quotes_gpc() |
|
1670 |
* @return bool |
|
1671 |
*/ |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1672 |
|
1 | 1673 |
function enano_get_magic_quotes_gpc() |
1674 |
{ |
|
1675 |
if(function_exists('get_magic_quotes_gpc')) |
|
1676 |
{ |
|
1677 |
return ( get_magic_quotes_gpc() == 1 ); |
|
1678 |
} |
|
1679 |
else |
|
1680 |
{ |
|
1681 |
return ( strtolower(@ini_get('magic_quotes_gpc')) == '1' ); |
|
1682 |
} |
|
1683 |
} |
|
1684 |
||
1685 |
/** |
|
1686 |
* Recursive stripslashes() |
|
1687 |
* @param array |
|
1688 |
* @return array |
|
1689 |
*/ |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1690 |
|
1 | 1691 |
function stripslashes_recurse($arr) |
1692 |
{ |
|
1693 |
foreach($arr as $k => $xxxx) |
|
1694 |
{ |
|
1695 |
$val =& $arr[$k]; |
|
1696 |
if(is_string($val)) |
|
1697 |
$val = stripslashes($val); |
|
1698 |
elseif(is_array($val)) |
|
1699 |
$val = stripslashes_recurse($val); |
|
1700 |
} |
|
1701 |
return $arr; |
|
1702 |
} |
|
1703 |
||
1704 |
/** |
|
14
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1705 |
* Recursive function to remove all NUL bytes from a string |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1706 |
* @param array |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1707 |
* @return array |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1708 |
*/ |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1709 |
|
14
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1710 |
function strip_nul_chars($arr) |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1711 |
{ |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1712 |
foreach($arr as $k => $xxxx_unused) |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1713 |
{ |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1714 |
$val =& $arr[$k]; |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1715 |
if(is_string($val)) |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1716 |
$val = str_replace("\000", '', $val); |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1717 |
elseif(is_array($val)) |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1718 |
$val = strip_nul_chars($val); |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1719 |
} |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1720 |
return $arr; |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1721 |
} |
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1722 |
|
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1723 |
/** |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1724 |
* If magic_quotes_gpc is on, calls stripslashes() on everything in $_GET/$_POST/$_COOKIE. Also strips any NUL characters from incoming requests, as these are typically malicious. |
14
ce6053bb48d8
Security: NUL characters are now stripped from GPC; several code readability standards changes
Dan
parents:
1
diff
changeset
|
1725 |
* @ignore - this doesn't work too well in my tests |
1 | 1726 |
* @todo port version from the PHP manual |
1727 |
* @return void |
|
1728 |
*/ |
|
1729 |
function strip_magic_quotes_gpc() |
|
1730 |
{ |
|
1731 |
if(enano_get_magic_quotes_gpc()) |
|
1732 |
{ |
|
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
38
diff
changeset
|
1733 |
$_POST = stripslashes_recurse($_POST); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
38
diff
changeset
|
1734 |
$_GET = stripslashes_recurse($_GET); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
38
diff
changeset
|
1735 |
$_COOKIE = stripslashes_recurse($_COOKIE); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
38
diff
changeset
|
1736 |
$_REQUEST = stripslashes_recurse($_REQUEST); |
1 | 1737 |
} |
40
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
38
diff
changeset
|
1738 |
$_POST = strip_nul_chars($_POST); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
38
diff
changeset
|
1739 |
$_GET = strip_nul_chars($_GET); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
38
diff
changeset
|
1740 |
$_COOKIE = strip_nul_chars($_COOKIE); |
723bb7acf914
Fixed a lot of bugs with Safari and Konqueror; improved Opera compatibility
Dan
parents:
38
diff
changeset
|
1741 |
$_REQUEST = strip_nul_chars($_REQUEST); |
78
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
1742 |
$_POST = decode_unicode_array($_POST); |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
1743 |
$_GET = decode_unicode_array($_GET); |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
1744 |
$_COOKIE = decode_unicode_array($_COOKIE); |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
1745 |
$_REQUEST = decode_unicode_array($_REQUEST); |
1 | 1746 |
} |
1747 |
||
1748 |
/** |
|
1749 |
* A very basic single-character compression algorithm for binary strings/bitfields |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1750 |
* @param string $bits the text to compress, should be only 1s and 0s |
1 | 1751 |
* @return string |
1752 |
*/ |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1753 |
|
1 | 1754 |
function compress_bitfield($bits) |
1755 |
{ |
|
1756 |
$crc32 = crc32($bits); |
|
1757 |
$bits .= '0'; |
|
1758 |
$start_pos = 0; |
|
1759 |
$current = substr($bits, 1, 1); |
|
1760 |
$last = substr($bits, 0, 1); |
|
1761 |
$chunk_size = 1; |
|
1762 |
$len = strlen($bits); |
|
1763 |
$crc = $len; |
|
1764 |
$crcval = 0; |
|
1765 |
for ( $i = 1; $i < $len; $i++ ) |
|
1766 |
{ |
|
1767 |
$current = substr($bits, $i, 1); |
|
1768 |
$last = substr($bits, $i - 1, 1); |
|
1769 |
$next = substr($bits, $i + 1, 1); |
|
1770 |
// Are we on the last character? |
|
1771 |
if($current == $last && $i+1 < $len) |
|
1772 |
$chunk_size++; |
|
1773 |
else |
|
1774 |
{ |
|
1775 |
if($i+1 == $len && $current == $next) |
|
1776 |
{ |
|
1777 |
// This character completes a chunk |
|
1778 |
$chunk_size++; |
|
1779 |
$i++; |
|
1780 |
$chunk = substr($bits, $start_pos, $chunk_size); |
|
1781 |
$chunklen = strlen($chunk); |
|
1782 |
$newchunk = $last . '[' . $chunklen . ']'; |
|
1783 |
$newlen = strlen($newchunk); |
|
1784 |
$bits = substr($bits, 0, $start_pos) . $newchunk . substr($bits, $i, $len); |
|
1785 |
$chunk_size = 1; |
|
1786 |
$i = $start_pos + $newlen; |
|
1787 |
$start_pos = $i; |
|
1788 |
$len = strlen($bits); |
|
1789 |
$crcval = $crcval + $chunklen; |
|
1790 |
} |
|
1791 |
else |
|
1792 |
{ |
|
1793 |
// Last character completed a chunk |
|
1794 |
$chunk = substr($bits, $start_pos, $chunk_size); |
|
1795 |
$chunklen = strlen($chunk); |
|
1796 |
$newchunk = $last . '[' . $chunklen . '],'; |
|
1797 |
$newlen = strlen($newchunk); |
|
1798 |
$bits = substr($bits, 0, $start_pos) . $newchunk . substr($bits, $i, $len); |
|
1799 |
$chunk_size = 1; |
|
1800 |
$i = $start_pos + $newlen; |
|
1801 |
$start_pos = $i; |
|
1802 |
$len = strlen($bits); |
|
1803 |
$crcval = $crcval + $chunklen; |
|
1804 |
} |
|
1805 |
} |
|
1806 |
} |
|
1807 |
if($crc != $crcval) |
|
1808 |
{ |
|
1809 |
echo __FUNCTION__.'(): ERROR: length check failed, this is a bug in the algorithm<br />Debug info: aiming for a CRC val of '.$crc.', got '.$crcval; |
|
1810 |
return false; |
|
1811 |
} |
|
1812 |
$compressed = 'cbf:len='.$crc.';crc='.dechex($crc32).';data='.$bits.'|end'; |
|
1813 |
return $compressed; |
|
1814 |
} |
|
1815 |
||
1816 |
/** |
|
1817 |
* Uncompresses a bitfield compressed with compress_bitfield() |
|
1818 |
* @param string $bits the compressed bitfield |
|
1819 |
* @return string the uncompressed, original (we hope) bitfield OR bool false on error |
|
1820 |
*/ |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1821 |
|
1 | 1822 |
function uncompress_bitfield($bits) |
1823 |
{ |
|
1824 |
if(substr($bits, 0, 4) != 'cbf:') |
|
1825 |
{ |
|
1826 |
echo __FUNCTION__.'(): ERROR: Invalid stream'; |
|
1827 |
return false; |
|
1828 |
} |
|
1829 |
$len = intval(substr($bits, strpos($bits, 'len=')+4, strpos($bits, ';')-strpos($bits, 'len=')-4)); |
|
1830 |
$crc = substr($bits, strpos($bits, 'crc=')+4, 8); |
|
1831 |
$data = substr($bits, strpos($bits, 'data=')+5, strpos($bits, '|end')-strpos($bits, 'data=')-5); |
|
1832 |
$data = explode(',', $data); |
|
1833 |
foreach($data as $a => $b) |
|
1834 |
{ |
|
1835 |
$d =& $data[$a]; |
|
1836 |
$char = substr($d, 0, 1); |
|
1837 |
$dlen = intval(substr($d, 2, strlen($d)-1)); |
|
1838 |
$s = ''; |
|
1839 |
for($i=0;$i<$dlen;$i++,$s.=$char); |
|
1840 |
$d = $s; |
|
1841 |
unset($s, $dlen, $char); |
|
1842 |
} |
|
1843 |
$decompressed = implode('', $data); |
|
1844 |
$decompressed = substr($decompressed, 0, -1); |
|
1845 |
$dcrc = (string)dechex(crc32($decompressed)); |
|
1846 |
if($dcrc != $crc) |
|
1847 |
{ |
|
1848 |
echo __FUNCTION__.'(): ERROR: CRC check failed<br />debug info:<br />original crc: '.$crc.'<br />decomp\'ed crc: '.$dcrc.'<br />'; |
|
1849 |
return false; |
|
1850 |
} |
|
1851 |
return $decompressed; |
|
1852 |
} |
|
1853 |
||
1854 |
/** |
|
1855 |
* Exports a MySQL table into a SQL string. |
|
1856 |
* @param string $table The name of the table to export |
|
1857 |
* @param bool $structure If true, include a CREATE TABLE command |
|
1858 |
* @param bool $data If true, include the contents of the table |
|
1859 |
* @param bool $compact If true, omits newlines between parts of SQL statements, use in Enano database exporter |
|
1860 |
* @return string |
|
1861 |
*/ |
|
1862 |
||
1863 |
function export_table($table, $structure = true, $data = true, $compact = false) |
|
1864 |
{ |
|
1865 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
1866 |
$struct_keys = ''; |
|
1867 |
$divider = (!$compact) ? "\n" : "\n"; |
|
1868 |
$spacer1 = (!$compact) ? "\n" : " "; |
|
1869 |
$spacer2 = (!$compact) ? " " : " "; |
|
1870 |
$rowspacer = (!$compact) ? "\n " : " "; |
|
1871 |
$index_list = Array(); |
|
1872 |
$cols = $db->sql_query('SHOW COLUMNS IN '.$table.';'); |
|
1873 |
if(!$cols) |
|
1874 |
{ |
|
1875 |
echo 'export_table(): Error getting column list: '.$db->get_error_text().'<br />'; |
|
1876 |
return false; |
|
1877 |
} |
|
1878 |
$col = Array(); |
|
1879 |
$sqlcol = Array(); |
|
1880 |
$collist = Array(); |
|
1881 |
$pri_keys = Array(); |
|
1882 |
// Using fetchrow_num() here to compensate for MySQL l10n |
|
1883 |
while( $row = $db->fetchrow_num() ) |
|
1884 |
{ |
|
1885 |
$field =& $row[0]; |
|
1886 |
$type =& $row[1]; |
|
1887 |
$null =& $row[2]; |
|
1888 |
$key =& $row[3]; |
|
1889 |
$def =& $row[4]; |
|
1890 |
$extra =& $row[5]; |
|
1891 |
$col[] = Array( |
|
1892 |
'name'=>$field, |
|
1893 |
'type'=>$type, |
|
1894 |
'null'=>$null, |
|
1895 |
'key'=>$key, |
|
1896 |
'default'=>$def, |
|
1897 |
'extra'=>$extra, |
|
1898 |
); |
|
1899 |
$collist[] = $field; |
|
1900 |
} |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1901 |
|
1 | 1902 |
if ( $structure ) |
1903 |
{ |
|
1904 |
$db->sql_query('SET SQL_QUOTE_SHOW_CREATE = 0;'); |
|
1905 |
$struct = $db->sql_query('SHOW CREATE TABLE '.$table.';'); |
|
1906 |
if ( !$struct ) |
|
1907 |
$db->_die(); |
|
1908 |
$row = $db->fetchrow_num(); |
|
1909 |
$db->free_result(); |
|
1910 |
$struct = $row[1]; |
|
1911 |
$struct = preg_replace("/\n\) ENGINE=(.+)$/", "\n);", $struct); |
|
1912 |
unset($row); |
|
1913 |
if ( $compact ) |
|
1914 |
{ |
|
1915 |
$struct_arr = explode("\n", $struct); |
|
1916 |
foreach ( $struct_arr as $i => $leg ) |
|
1917 |
{ |
|
1918 |
if ( $i == 0 ) |
|
1919 |
continue; |
|
1920 |
$test = trim($leg); |
|
1921 |
if ( empty($test) ) |
|
1922 |
{ |
|
1923 |
unset($struct_arr[$i]); |
|
1924 |
continue; |
|
1925 |
} |
|
1926 |
$struct_arr[$i] = preg_replace('/^([\s]*)/', ' ', $leg); |
|
1927 |
} |
|
1928 |
$struct = implode("", $struct_arr); |
|
1929 |
} |
|
1930 |
} |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1931 |
|
1 | 1932 |
// Structuring complete |
1933 |
if($data) |
|
1934 |
{ |
|
1935 |
$datq = $db->sql_query('SELECT * FROM '.$table.';'); |
|
1936 |
if(!$datq) |
|
1937 |
{ |
|
1938 |
echo 'export_table(): Error getting column list: '.$db->get_error_text().'<br />'; |
|
1939 |
return false; |
|
1940 |
} |
|
1941 |
if($db->numrows() < 1) |
|
1942 |
{ |
|
1943 |
if($structure) return $struct; |
|
1944 |
else return ''; |
|
1945 |
} |
|
1946 |
$rowdata = Array(); |
|
1947 |
$dataqs = Array(); |
|
1948 |
$insert_strings = Array(); |
|
1949 |
$z = false; |
|
1950 |
while($row = $db->fetchrow_num()) |
|
1951 |
{ |
|
1952 |
$z = false; |
|
1953 |
foreach($row as $i => $cell) |
|
1954 |
{ |
|
1955 |
$str = mysql_encode_column($cell, $col[$i]['type']); |
|
1956 |
$rowdata[] = $str; |
|
1957 |
} |
|
1958 |
$dataqs2 = implode(",$rowspacer", $dataqs) . ",$rowspacer" . '( ' . implode(', ', $rowdata) . ' )'; |
|
1959 |
$ins = 'INSERT INTO '.$table.'( '.implode(',', $collist).' ) VALUES' . $dataqs2 . ";"; |
|
1960 |
if ( strlen( $ins ) > MYSQL_MAX_PACKET_SIZE ) |
|
1961 |
{ |
|
1962 |
// We've exceeded the maximum allowed packet size for MySQL - separate this into a different query |
|
1963 |
$insert_strings[] = 'INSERT INTO '.$table.'( '.implode(',', $collist).' ) VALUES' . implode(",$rowspacer", $dataqs) . ";";; |
|
1964 |
$dataqs = Array('( ' . implode(', ', $rowdata) . ' )'); |
|
1965 |
$z = true; |
|
1966 |
} |
|
1967 |
else |
|
1968 |
{ |
|
1969 |
$dataqs[] = '( ' . implode(', ', $rowdata) . ' )'; |
|
1970 |
} |
|
1971 |
$rowdata = Array(); |
|
1972 |
} |
|
1973 |
if ( !$z ) |
|
1974 |
{ |
|
1975 |
$insert_strings[] = 'INSERT INTO '.$table.'( '.implode(',', $collist).' ) VALUES' . implode(",$rowspacer", $dataqs) . ";";; |
|
1976 |
$dataqs = Array(); |
|
1977 |
} |
|
1978 |
$datstring = implode($divider, $insert_strings); |
|
1979 |
} |
|
1980 |
if($structure && !$data) return $struct; |
|
1981 |
elseif(!$structure && $data) return $datstring; |
|
1982 |
elseif($structure && $data) return $struct . $divider . $datstring; |
|
1983 |
elseif(!$structure && !$data) return ''; |
|
1984 |
} |
|
1985 |
||
1986 |
/** |
|
1987 |
* Encodes a string value for use in an INSERT statement for given column type $type. |
|
1988 |
* @access private |
|
1989 |
*/ |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
1990 |
|
1 | 1991 |
function mysql_encode_column($input, $type) |
1992 |
{ |
|
1993 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
1994 |
// Decide whether to quote the string or not |
|
1995 |
if(substr($type, 0, 7) == 'varchar' || $type == 'datetime' || $type == 'text' || $type == 'tinytext' || $type == 'smalltext' || $type == 'longtext' || substr($type, 0, 4) == 'char') |
|
1996 |
{ |
|
1997 |
$str = "'" . $db->escape($input) . "'"; |
|
1998 |
} |
|
1999 |
elseif(in_array($type, Array('blob', 'longblob', 'mediumblob', 'smallblob')) || substr($type, 0, 6) == 'binary' || substr($type, 0, 9) == 'varbinary') |
|
2000 |
{ |
|
2001 |
$str = '0x' . hexencode($input, '', ''); |
|
2002 |
} |
|
2003 |
elseif(is_null($input)) |
|
2004 |
{ |
|
2005 |
$str = 'NULL'; |
|
2006 |
} |
|
2007 |
else |
|
2008 |
{ |
|
2009 |
$str = (string)$input; |
|
2010 |
} |
|
2011 |
return $str; |
|
2012 |
} |
|
2013 |
||
2014 |
/** |
|
2015 |
* Creates an associative array defining which file extensions are allowed and which ones aren't |
|
2016 |
* @return array keyname will be a file extension, value will be true or false |
|
2017 |
*/ |
|
2018 |
||
2019 |
function fetch_allowed_extensions() |
|
2020 |
{ |
|
2021 |
global $mime_types; |
|
2022 |
$bits = getConfig('allowed_mime_types'); |
|
2023 |
if(!$bits) return Array(false); |
|
2024 |
$bits = uncompress_bitfield($bits); |
|
2025 |
if(!$bits) return Array(false); |
|
2026 |
$bits = enano_str_split($bits, 1); |
|
2027 |
$ret = Array(); |
|
2028 |
$mt = array_keys($mime_types); |
|
2029 |
foreach($bits as $i => $b) |
|
2030 |
{ |
|
2031 |
$ret[$mt[$i]] = ( $b == '1' ) ? true : false; |
|
2032 |
} |
|
2033 |
return $ret; |
|
2034 |
} |
|
2035 |
||
2036 |
/** |
|
2037 |
* Generates a random key suitable for encryption |
|
2038 |
* @param int $len the length of the key |
|
2039 |
* @return string a BINARY key |
|
2040 |
*/ |
|
2041 |
||
2042 |
function randkey($len = 32) |
|
2043 |
{ |
|
2044 |
$key = ''; |
|
2045 |
for($i=0;$i<$len;$i++) |
|
2046 |
{ |
|
2047 |
$key .= chr(mt_rand(0, 255)); |
|
2048 |
} |
|
2049 |
return $key; |
|
2050 |
} |
|
2051 |
||
2052 |
/** |
|
2053 |
* Decodes a hex string. |
|
2054 |
* @param string $hex The hex code to decode |
|
2055 |
* @return string |
|
2056 |
*/ |
|
2057 |
||
2058 |
function hexdecode($hex) |
|
2059 |
{ |
|
2060 |
$hex = enano_str_split($hex, 2); |
|
2061 |
$bin_key = ''; |
|
2062 |
foreach($hex as $nibble) |
|
2063 |
{ |
|
2064 |
$byte = chr(hexdec($nibble)); |
|
2065 |
$bin_key .= $byte; |
|
2066 |
} |
|
2067 |
return $bin_key; |
|
2068 |
} |
|
2069 |
||
2070 |
/** |
|
2071 |
* Enano's own (almost) bulletproof HTML sanitizer. |
|
2072 |
* @param string $html The input HTML |
|
2073 |
* @return string cleaned HTML |
|
2074 |
*/ |
|
2075 |
||
2076 |
function sanitize_html($html, $filter_php = true) |
|
2077 |
{ |
|
163 | 2078 |
// Random seed for substitution |
2079 |
$rand_seed = md5( sha1(microtime()) . mt_rand() ); |
|
2080 |
||
593
4f9bec0d65c1
More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents:
592
diff
changeset
|
2081 |
// We need MediaWiki |
4f9bec0d65c1
More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents:
592
diff
changeset
|
2082 |
require_once(ENANO_ROOT . '/includes/wikiengine/Tables.php'); |
4f9bec0d65c1
More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents:
592
diff
changeset
|
2083 |
|
163 | 2084 |
// Strip out comments that are already escaped |
2085 |
preg_match_all('/<!--(.*?)-->/', $html, $comment_match); |
|
2086 |
$i = 0; |
|
2087 |
foreach ( $comment_match[0] as $comment ) |
|
2088 |
{ |
|
2089 |
$html = str_replace_once($comment, "{HTMLCOMMENT:$i:$rand_seed}", $html); |
|
2090 |
$i++; |
|
2091 |
} |
|
2092 |
||
2093 |
// Strip out code sections that will be postprocessed by Text_Wiki |
|
2094 |
preg_match_all(';^<code(\s[^>]*)?>((?:(?R)|.)*?)\n</code>(\s|$);msi', $html, $code_match); |
|
2095 |
$i = 0; |
|
2096 |
foreach ( $code_match[0] as $code ) |
|
2097 |
{ |
|
2098 |
$html = str_replace_once($code, "{TW_CODE:$i:$rand_seed}", $html); |
|
2099 |
$i++; |
|
2100 |
} |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2101 |
|
1 | 2102 |
$html = preg_replace('#<([a-z]+)([\s]+)([^>]+?)'.htmlalternatives('javascript:').'(.+?)>(.*?)</\\1>#is', '<\\1\\2\\3javascript:\\59>\\60</\\1>', $html); |
2103 |
$html = preg_replace('#<([a-z]+)([\s]+)([^>]+?)'.htmlalternatives('javascript:').'(.+?)>#is', '<\\1\\2\\3javascript:\\59>', $html); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2104 |
|
1 | 2105 |
if($filter_php) |
2106 |
$html = str_replace( |
|
2107 |
Array('<?php', '<?', '<%', '?>', '%>'), |
|
2108 |
Array('<?php', '<?', '<%', '?>', '%>'), |
|
2109 |
$html); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2110 |
|
1 | 2111 |
$tag_whitelist = array_keys ( setupAttributeWhitelist() ); |
2112 |
if ( !$filter_php ) |
|
2113 |
$tag_whitelist[] = '?php'; |
|
164 | 2114 |
// allow HTML comments |
2115 |
$tag_whitelist[] = '!--'; |
|
1 | 2116 |
$len = strlen($html); |
2117 |
$in_quote = false; |
|
2118 |
$quote_char = ''; |
|
2119 |
$tag_start = 0; |
|
2120 |
$tag_name = ''; |
|
2121 |
$in_tag = false; |
|
2122 |
$trk_name = false; |
|
2123 |
for ( $i = 0; $i < $len; $i++ ) |
|
2124 |
{ |
|
2125 |
$chr = $html{$i}; |
|
2126 |
$prev = ( $i == 0 ) ? '' : $html{ $i - 1 }; |
|
2127 |
$next = ( ( $i + 1 ) == $len ) ? '' : $html { $i + 1 }; |
|
2128 |
if ( $in_quote && $in_tag ) |
|
2129 |
{ |
|
2130 |
if ( $quote_char == $chr && $prev != '\\' ) |
|
2131 |
$in_quote = false; |
|
2132 |
} |
|
2133 |
elseif ( ( $chr == '"' || $chr == "'" ) && $prev != '\\' && $in_tag ) |
|
2134 |
{ |
|
2135 |
$in_quote = true; |
|
2136 |
$quote_char = $chr; |
|
2137 |
} |
|
2138 |
if ( $chr == '<' && !$in_tag && $next != '/' ) |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2139 |
{ |
1 | 2140 |
// start of a tag |
2141 |
$tag_start = $i; |
|
2142 |
$in_tag = true; |
|
2143 |
$trk_name = true; |
|
2144 |
} |
|
2145 |
elseif ( !$in_quote && $in_tag && $chr == '>' ) |
|
2146 |
{ |
|
2147 |
$full_tag = substr($html, $tag_start, ( $i - $tag_start ) + 1 ); |
|
2148 |
$l = strlen($tag_name) + 2; |
|
2149 |
$attribs_only = trim( substr($full_tag, $l, ( strlen($full_tag) - $l - 1 ) ) ); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2150 |
|
1 | 2151 |
// Debugging message |
2152 |
// echo htmlspecialchars($full_tag) . '<br />'; |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2153 |
|
450
35f9d6c93eec
Fixed case where HTML comments were getting stripped when opening tag not followed by whitespace (<!--foo--> was stripped, <!-- foo --> was not, neither is stripped now)
Dan
parents:
325
diff
changeset
|
2154 |
if ( !in_array($tag_name, $tag_whitelist) && substr($tag_name, 0, 3) != '!--' ) |
1 | 2155 |
{ |
2156 |
// Illegal tag |
|
2157 |
//echo $tag_name . ' '; |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2158 |
|
1 | 2159 |
$s = ( empty($attribs_only) ) ? '' : ' '; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2160 |
|
1 | 2161 |
$sanitized = '<' . $tag_name . $s . $attribs_only . '>'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2162 |
|
1 | 2163 |
$html = substr($html, 0, $tag_start) . $sanitized . substr($html, $i + 1); |
2164 |
$html = str_replace('</' . $tag_name . '>', '</' . $tag_name . '>', $html); |
|
2165 |
$new_i = $tag_start + strlen($sanitized); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2166 |
|
1 | 2167 |
$len = strlen($html); |
2168 |
$i = $new_i; |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2169 |
|
1 | 2170 |
$in_tag = false; |
2171 |
$tag_name = ''; |
|
2172 |
continue; |
|
2173 |
} |
|
2174 |
else |
|
2175 |
{ |
|
164 | 2176 |
// If not filtering PHP, don't bother to strip |
1 | 2177 |
if ( $tag_name == '?php' && !$filter_php ) |
2178 |
continue; |
|
164 | 2179 |
// If this is a comment, likewise skip this "tag" |
2180 |
if ( $tag_name == '!--' ) |
|
2181 |
continue; |
|
1 | 2182 |
$f = fixTagAttributes( $attribs_only, $tag_name ); |
2183 |
$s = ( empty($f) ) ? '' : ' '; |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2184 |
|
1 | 2185 |
$sanitized = '<' . $tag_name . $f . '>'; |
2186 |
$new_i = $tag_start + strlen($sanitized); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2187 |
|
1 | 2188 |
$html = substr($html, 0, $tag_start) . $sanitized . substr($html, $i + 1); |
2189 |
$len = strlen($html); |
|
2190 |
$i = $new_i; |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2191 |
|
1 | 2192 |
$in_tag = false; |
2193 |
$tag_name = ''; |
|
2194 |
continue; |
|
2195 |
} |
|
2196 |
} |
|
2197 |
elseif ( $in_tag && $trk_name ) |
|
2198 |
{ |
|
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
19
diff
changeset
|
2199 |
$is_alphabetical = ( strtolower($chr) != strtoupper($chr) || in_array($chr, array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9')) || $chr == '?' || $chr == '!' || $chr == '-' ); |
1 | 2200 |
if ( $is_alphabetical ) |
2201 |
$tag_name .= $chr; |
|
2202 |
else |
|
2203 |
{ |
|
2204 |
$trk_name = false; |
|
2205 |
} |
|
2206 |
} |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2207 |
|
1 | 2208 |
} |
164 | 2209 |
|
15
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2210 |
// Vulnerability from ha.ckers.org/xss.html: |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2211 |
// <script src="http://foo.com/xss.js" |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2212 |
// < |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2213 |
// The rule is so specific because everything else will have been filtered by now |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2214 |
$html = preg_replace('/<(script|iframe)(.+?)src=([^>]*)</i', '<\\1\\2src=\\3<', $html); |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2215 |
|
163 | 2216 |
// Restore stripped comments |
2217 |
$i = 0; |
|
2218 |
foreach ( $comment_match[0] as $comment ) |
|
2219 |
{ |
|
2220 |
$html = str_replace_once("{HTMLCOMMENT:$i:$rand_seed}", $comment, $html); |
|
2221 |
$i++; |
|
2222 |
} |
|
2223 |
||
2224 |
// Restore stripped code |
|
2225 |
$i = 0; |
|
2226 |
foreach ( $code_match[0] as $code ) |
|
2227 |
{ |
|
2228 |
$html = str_replace_once("{TW_CODE:$i:$rand_seed}", $code, $html); |
|
2229 |
$i++; |
|
2230 |
} |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2231 |
|
1 | 2232 |
return $html; |
2233 |
} |
|
2234 |
||
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2235 |
/** |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2236 |
* Using the same parsing code as sanitize_html(), this function adds <litewiki> tags around certain block-level elements |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2237 |
* @param string $html The input HTML |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2238 |
* @return string formatted HTML |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2239 |
*/ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2240 |
|
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2241 |
function wikiformat_process_block($html) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2242 |
{ |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2243 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2244 |
$tok1 = "<litewiki>"; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2245 |
$tok2 = "</litewiki>"; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2246 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2247 |
$block_tags = array('div', 'p', 'table', 'blockquote', 'pre'); |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2248 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2249 |
$len = strlen($html); |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2250 |
$in_quote = false; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2251 |
$quote_char = ''; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2252 |
$tag_start = 0; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2253 |
$tag_name = ''; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2254 |
$in_tag = false; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2255 |
$trk_name = false; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2256 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2257 |
$diag = 0; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2258 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2259 |
$block_tagname = ''; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2260 |
$in_blocksec = 0; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2261 |
$block_start = 0; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2262 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2263 |
for ( $i = 0; $i < $len; $i++ ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2264 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2265 |
$chr = $html{$i}; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2266 |
$prev = ( $i == 0 ) ? '' : $html{ $i - 1 }; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2267 |
$next = ( ( $i + 1 ) == $len ) ? '' : $html { $i + 1 }; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2268 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2269 |
// Are we inside of a quoted section? |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2270 |
if ( $in_quote && $in_tag ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2271 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2272 |
if ( $quote_char == $chr && $prev != '\\' ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2273 |
$in_quote = false; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2274 |
} |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2275 |
elseif ( ( $chr == '"' || $chr == "'" ) && $prev != '\\' && $in_tag ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2276 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2277 |
$in_quote = true; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2278 |
$quote_char = $chr; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2279 |
} |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2280 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2281 |
if ( $chr == '<' && !$in_tag && $next == '/' ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2282 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2283 |
// Iterate through until we've got a tag name |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2284 |
$tag_name = ''; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2285 |
$i++; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2286 |
while(true) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2287 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2288 |
$i++; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2289 |
// echo $i . ' '; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2290 |
$chr = $html{$i}; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2291 |
$prev = ( $i == 0 ) ? '' : $html{ $i - 1 }; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2292 |
$next = ( ( $i + 1 ) == $len ) ? '' : $html { $i + 1 }; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2293 |
$tag_name .= $chr; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2294 |
if ( $next == '>' ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2295 |
break; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2296 |
} |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2297 |
// echo '<br />'; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2298 |
if ( in_array($tag_name, $block_tags) ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2299 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2300 |
if ( $block_tagname == $tag_name ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2301 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2302 |
$in_blocksec -= 1; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2303 |
if ( $in_blocksec == 0 ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2304 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2305 |
$block_tagname = ''; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2306 |
$i += 2; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2307 |
// echo 'Finished wiki litewiki wraparound calc at pos: ' . $i; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2308 |
$full_litewiki = substr($html, $block_start, ( $i - $block_start )); |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2309 |
$new_text = "{$tok1}{$full_litewiki}{$tok2}"; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2310 |
$html = substr($html, 0, $block_start) . $new_text . substr($html, $i); |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2311 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2312 |
$i += ( strlen($tok1) + strlen($tok2) ) - 1; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2313 |
$len = strlen($html); |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2314 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2315 |
//die('<pre>' . htmlspecialchars($html) . '</pre>'); |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2316 |
} |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2317 |
} |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2318 |
} |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2319 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2320 |
$in_tag = false; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2321 |
$in_quote = false; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2322 |
$tag_name = ''; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2323 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2324 |
continue; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2325 |
} |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2326 |
else if ( $chr == '<' && !$in_tag && $next != '/' ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2327 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2328 |
// start of a tag |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2329 |
$tag_start = $i; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2330 |
$in_tag = true; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2331 |
$trk_name = true; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2332 |
} |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2333 |
else if ( !$in_quote && $in_tag && $chr == '>' ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2334 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2335 |
if ( !in_array($tag_name, $block_tags) ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2336 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2337 |
// Inline tag - reset and go to the next one |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2338 |
// echo '<inline ' . $tag_name . '> '; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2339 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2340 |
$in_tag = false; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2341 |
$tag_name = ''; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2342 |
continue; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2343 |
} |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2344 |
else |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2345 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2346 |
// echo '<block: ' . $tag_name . ' @ ' . $i . '><br/>'; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2347 |
if ( $in_blocksec == 0 ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2348 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2349 |
//die('Found a starting tag for a block element: ' . $tag_name . ' at pos ' . $tag_start); |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2350 |
$block_tagname = $tag_name; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2351 |
$block_start = $tag_start; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2352 |
$in_blocksec++; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2353 |
} |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2354 |
else if ( $block_tagname == $tag_name ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2355 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2356 |
$in_blocksec++; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2357 |
} |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2358 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2359 |
$in_tag = false; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2360 |
$tag_name = ''; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2361 |
continue; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2362 |
} |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2363 |
} |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2364 |
elseif ( $in_tag && $trk_name ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2365 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2366 |
$is_alphabetical = ( strtolower($chr) != strtoupper($chr) || in_array($chr, array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9')) || $chr == '?' || $chr == '!' || $chr == '-' ); |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2367 |
if ( $is_alphabetical ) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2368 |
$tag_name .= $chr; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2369 |
else |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2370 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2371 |
$trk_name = false; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2372 |
} |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2373 |
} |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2374 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2375 |
// Tokenization complete |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2376 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2377 |
} |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2378 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2379 |
$regex = '/' . str_replace('/', '\\/', preg_quote($tok2)) . '([\s]*)' . preg_quote($tok1) . '/is'; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2380 |
// die(htmlspecialchars($regex)); |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2381 |
$html = preg_replace($regex, '\\1', $html); |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2382 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2383 |
return $html; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2384 |
|
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2385 |
} |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2386 |
|
1 | 2387 |
function htmlalternatives($string) |
2388 |
{ |
|
2389 |
$ret = ''; |
|
2390 |
for ( $i = 0; $i < strlen($string); $i++ ) |
|
2391 |
{ |
|
2392 |
$chr = $string{$i}; |
|
2393 |
$ch1 = ord($chr); |
|
2394 |
$ch2 = dechex($ch1); |
|
2395 |
$byte = '(&\\#([0]*){0,7}' . $ch1 . ';|\\\\([0]*){0,7}' . $ch1 . ';|\\\\([0]*){0,7}' . $ch2 . ';|&\\#x([0]*){0,7}' . $ch2 . ';|%([0]*){0,7}' . $ch2 . '|' . preg_quote($chr) . ')'; |
|
2396 |
$ret .= $byte; |
|
2397 |
$ret .= '([\s]){0,2}'; |
|
2398 |
} |
|
2399 |
return $ret; |
|
2400 |
} |
|
2401 |
||
2402 |
/** |
|
2403 |
* Paginates (breaks into multiple pages) a MySQL result resource, which is treated as unbuffered. |
|
2404 |
* @param resource The MySQL result resource. This should preferably be an unbuffered query. |
|
2405 |
* @param string A template, with variables being named after the column name |
|
2406 |
* @param int The number of total results. This should be determined by a second query. |
|
2407 |
* @param string sprintf-style formatting string for URLs for result pages. First parameter will be start offset. |
|
2408 |
* @param int Optional. Start offset in individual results. Defaults to 0. |
|
2409 |
* @param int Optional. The number of results per page. Defualts to 10. |
|
2410 |
* @param int Optional. An associative array of functions to call, with key names being column names, and values being function names. Values can also be an array with key 0 being either an object or a string(class name) and key 1 being a [static] method. |
|
2411 |
* @param string Optional. The text to be sent before the result list, only if there are any results. Possibly the start of a table. |
|
2412 |
* @param string Optional. The text to be sent after the result list, only if there are any results. Possibly the end of a table. |
|
2413 |
* @return string |
|
2414 |
*/ |
|
2415 |
||
2416 |
function paginate($q, $tpl_text, $num_results, $result_url, $start = 0, $perpage = 10, $callers = Array(), $header = '', $footer = '') |
|
2417 |
{ |
|
2418 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
359 | 2419 |
global $lang; |
2420 |
||
1 | 2421 |
$parser = $template->makeParserText($tpl_text); |
2422 |
$num_pages = ceil ( $num_results / $perpage ); |
|
2423 |
$out = ''; |
|
2424 |
$i = 0; |
|
2425 |
$this_page = ceil ( $start / $perpage ); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2426 |
|
1 | 2427 |
// Build paginator |
82
03c7f5ec1e4c
Fixed IE6 + Admin theme, version typo in installer, and paginator + IE6
Dan
parents:
81
diff
changeset
|
2428 |
$pg_css = ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ) ? |
03c7f5ec1e4c
Fixed IE6 + Admin theme, version typo in installer, and paginator + IE6
Dan
parents:
81
diff
changeset
|
2429 |
// IE-specific hack |
03c7f5ec1e4c
Fixed IE6 + Admin theme, version typo in installer, and paginator + IE6
Dan
parents:
81
diff
changeset
|
2430 |
'display: block; width: 1px;': |
03c7f5ec1e4c
Fixed IE6 + Admin theme, version typo in installer, and paginator + IE6
Dan
parents:
81
diff
changeset
|
2431 |
// Other browsers |
03c7f5ec1e4c
Fixed IE6 + Admin theme, version typo in installer, and paginator + IE6
Dan
parents:
81
diff
changeset
|
2432 |
'display: table; margin: 10px 0 0 auto;'; |
03c7f5ec1e4c
Fixed IE6 + Admin theme, version typo in installer, and paginator + IE6
Dan
parents:
81
diff
changeset
|
2433 |
$begin = '<div class="tblholder" style="'. $pg_css . '"> |
1 | 2434 |
<table border="0" cellspacing="1" cellpadding="4"> |
359 | 2435 |
<tr><th>' . $lang->get('paginate_lbl_page') . '</th>'; |
1 | 2436 |
$block = '<td class="row1" style="text-align: center;">{LINK}</td>'; |
2437 |
$end = '</tr></table></div>'; |
|
2438 |
$blk = $template->makeParserText($block); |
|
2439 |
$inner = ''; |
|
2440 |
$cls = 'row2'; |
|
2441 |
if ( $num_pages < 5 ) |
|
2442 |
{ |
|
2443 |
for ( $i = 0; $i < $num_pages; $i++ ) |
|
2444 |
{ |
|
2445 |
$cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
|
2446 |
$offset = strval($i * $perpage); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2447 |
$url = htmlspecialchars(sprintf($result_url, $offset)); |
1 | 2448 |
$j = $i + 1; |
2449 |
$link = ( $offset == strval($start) ) ? "<b>$j</b>" : "<a href=".'"'."$url".'"'." style='text-decoration: none;'>$j</a>"; |
|
2450 |
$blk->assign_vars(array( |
|
2451 |
'CLASS'=>$cls, |
|
2452 |
'LINK'=>$link |
|
2453 |
)); |
|
2454 |
$inner .= $blk->run(); |
|
2455 |
} |
|
2456 |
} |
|
2457 |
else |
|
2458 |
{ |
|
2459 |
if ( $this_page + 5 > $num_pages ) |
|
2460 |
{ |
|
2461 |
$list = Array(); |
|
2462 |
$tp = $this_page; |
|
2463 |
if ( $this_page + 0 == $num_pages ) $tp = $tp - 3; |
|
2464 |
if ( $this_page + 1 == $num_pages ) $tp = $tp - 2; |
|
2465 |
if ( $this_page + 2 == $num_pages ) $tp = $tp - 1; |
|
2466 |
for ( $i = $tp - 1; $i <= $tp + 1; $i++ ) |
|
2467 |
{ |
|
2468 |
$list[] = $i; |
|
2469 |
} |
|
2470 |
} |
|
2471 |
else |
|
2472 |
{ |
|
2473 |
$list = Array(); |
|
2474 |
$current = $this_page; |
|
2475 |
$lower = ( $current < 3 ) ? 1 : $current - 1; |
|
2476 |
for ( $i = 0; $i < 3; $i++ ) |
|
2477 |
{ |
|
2478 |
$list[] = $lower + $i; |
|
2479 |
} |
|
2480 |
} |
|
2481 |
$url = sprintf($result_url, '0'); |
|
362
02d315d1cc58
Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents:
359
diff
changeset
|
2482 |
$link = ( 0 == $start ) ? "<b>" . $lang->get('paginate_btn_first') . "</b>" : "<a href=".'"'."$url".'"'." style='text-decoration: none;'>« " . $lang->get('paginate_btn_first') . "</a>"; |
1 | 2483 |
$blk->assign_vars(array( |
2484 |
'CLASS'=>$cls, |
|
2485 |
'LINK'=>$link |
|
2486 |
)); |
|
2487 |
$inner .= $blk->run(); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2488 |
|
1 | 2489 |
// if ( !in_array(1, $list) ) |
2490 |
// { |
|
2491 |
// $cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
|
2492 |
// $blk->assign_vars(array('CLASS'=>$cls,'LINK'=>'...')); |
|
2493 |
// $inner .= $blk->run(); |
|
2494 |
// } |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2495 |
|
1 | 2496 |
foreach ( $list as $i ) |
2497 |
{ |
|
2498 |
if ( $i == $num_pages ) |
|
2499 |
break; |
|
2500 |
$cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
|
2501 |
$offset = strval($i * $perpage); |
|
2502 |
$url = sprintf($result_url, $offset); |
|
2503 |
$j = $i + 1; |
|
2504 |
$link = ( $offset == strval($start) ) ? "<b>$j</b>" : "<a href=".'"'."$url".'"'." style='text-decoration: none;'>$j</a>"; |
|
2505 |
$blk->assign_vars(array( |
|
2506 |
'CLASS'=>$cls, |
|
2507 |
'LINK'=>$link |
|
2508 |
)); |
|
2509 |
$inner .= $blk->run(); |
|
2510 |
} |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2511 |
|
1 | 2512 |
$total = $num_pages * $perpage - $perpage; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2513 |
|
1 | 2514 |
if ( $this_page < $num_pages ) |
2515 |
{ |
|
2516 |
// $cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
|
2517 |
// $blk->assign_vars(array('CLASS'=>$cls,'LINK'=>'...')); |
|
2518 |
// $inner .= $blk->run(); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2519 |
|
1 | 2520 |
$cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
2521 |
$offset = strval($total); |
|
2522 |
$url = sprintf($result_url, $offset); |
|
2523 |
$j = $i + 1; |
|
362
02d315d1cc58
Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents:
359
diff
changeset
|
2524 |
$link = ( $offset == strval($start) ) ? "<b>" . $lang->get('paginate_btn_last') . "</b>" : "<a href=".'"'."$url".'"'." style='text-decoration: none;'>" . $lang->get('paginate_btn_last') . " »</a>"; |
1 | 2525 |
$blk->assign_vars(array( |
2526 |
'CLASS'=>$cls, |
|
2527 |
'LINK'=>$link |
|
2528 |
)); |
|
2529 |
$inner .= $blk->run(); |
|
2530 |
} |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2531 |
|
1 | 2532 |
} |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2533 |
|
1 | 2534 |
$inner .= '<td class="row2" style="cursor: pointer;" onclick="paginator_goto(this, '.$this_page.', '.$num_pages.', '.$perpage.', unescape(\'' . rawurlencode($result_url) . '\'));">↓</td>'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2535 |
|
1 | 2536 |
$paginator = "\n$begin$inner$end\n"; |
2537 |
$out .= $paginator; |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2538 |
|
1 | 2539 |
$cls = 'row2'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2540 |
|
1 | 2541 |
if ( $row = $db->fetchrow($q) ) |
2542 |
{ |
|
2543 |
$i = 0; |
|
2544 |
$out .= $header; |
|
2545 |
do { |
|
2546 |
$i++; |
|
2547 |
if ( $i <= $start ) |
|
2548 |
{ |
|
2549 |
continue; |
|
2550 |
} |
|
2551 |
if ( ( $i - $start ) > $perpage ) |
|
2552 |
{ |
|
2553 |
break; |
|
2554 |
} |
|
2555 |
$cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
|
2556 |
foreach ( $row as $j => $val ) |
|
2557 |
{ |
|
2558 |
if ( isset($callers[$j]) ) |
|
2559 |
{ |
|
74
68469a95658d
Various bugfixes and cleanups, too much to remember... see the diffs for what got changed :-)
Dan
parents:
73
diff
changeset
|
2560 |
$tmp = ( is_callable($callers[$j]) ) ? @call_user_func($callers[$j], $val, $row) : $val; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2561 |
|
575
9c1ab9c74662
Fixed two bugs in paginator: noisy warning when rows run out and empty strings not being treated as valid from formatting functions
Dan
parents:
574
diff
changeset
|
2562 |
if ( is_string($tmp) ) |
1 | 2563 |
{ |
2564 |
$row[$j] = $tmp; |
|
2565 |
} |
|
2566 |
} |
|
2567 |
} |
|
2568 |
$parser->assign_vars($row); |
|
2569 |
$parser->assign_vars(array('_css_class' => $cls)); |
|
2570 |
$out .= $parser->run(); |
|
575
9c1ab9c74662
Fixed two bugs in paginator: noisy warning when rows run out and empty strings not being treated as valid from formatting functions
Dan
parents:
574
diff
changeset
|
2571 |
} while ( $row = @$db->fetchrow($q) ); |
1 | 2572 |
$out .= $footer; |
2573 |
} |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2574 |
|
1 | 2575 |
$out .= $paginator; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2576 |
|
1 | 2577 |
return $out; |
2578 |
} |
|
2579 |
||
2580 |
/** |
|
2581 |
* This is the same as paginate(), but it processes an array instead of a MySQL result resource. |
|
2582 |
* @param array The results. Each value is simply echoed. |
|
2583 |
* @param int The number of total results. This should be determined by a second query. |
|
2584 |
* @param string sprintf-style formatting string for URLs for result pages. First parameter will be start offset. |
|
2585 |
* @param int Optional. Start offset in individual results. Defaults to 0. |
|
2586 |
* @param int Optional. The number of results per page. Defualts to 10. |
|
2587 |
* @param string Optional. The text to be sent before the result list, only if there are any results. Possibly the start of a table. |
|
2588 |
* @param string Optional. The text to be sent after the result list, only if there are any results. Possibly the end of a table. |
|
2589 |
* @return string |
|
2590 |
*/ |
|
2591 |
||
2592 |
function paginate_array($q, $num_results, $result_url, $start = 0, $perpage = 10, $header = '', $footer = '') |
|
2593 |
{ |
|
2594 |
global $db, $session, $paths, $template, $plugins; // Common objects |
|
362
02d315d1cc58
Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents:
359
diff
changeset
|
2595 |
global $lang; |
02d315d1cc58
Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents:
359
diff
changeset
|
2596 |
|
1 | 2597 |
$num_pages = ceil ( $num_results / $perpage ); |
2598 |
$out = ''; |
|
2599 |
$i = 0; |
|
2600 |
$this_page = ceil ( $start / $perpage ); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2601 |
|
1 | 2602 |
// Build paginator |
2603 |
$begin = '<div class="tblholder" style="display: table; margin: 10px 0 0 auto;"> |
|
2604 |
<table border="0" cellspacing="1" cellpadding="4"> |
|
362
02d315d1cc58
Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents:
359
diff
changeset
|
2605 |
<tr><th>' . $lang->get('paginate_lbl_page') . '</th>'; |
1 | 2606 |
$block = '<td class="row1" style="text-align: center;">{LINK}</td>'; |
2607 |
$end = '</tr></table></div>'; |
|
2608 |
$blk = $template->makeParserText($block); |
|
2609 |
$inner = ''; |
|
2610 |
$cls = 'row2'; |
|
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
270
diff
changeset
|
2611 |
$total = $num_pages * $perpage - $perpage; |
362
02d315d1cc58
Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents:
359
diff
changeset
|
2612 |
/* |
1 | 2613 |
if ( $start > 0 ) |
2614 |
{ |
|
2615 |
$url = sprintf($result_url, abs($start - $perpage)); |
|
359 | 2616 |
$link = "<a href=".'"'."$url".'"'." style='text-decoration: none;'>« " . $lang->get('paginate_btn_prev') . "</a>"; |
1 | 2617 |
$cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
2618 |
$blk->assign_vars(array( |
|
2619 |
'CLASS'=>$cls, |
|
2620 |
'LINK'=>$link |
|
2621 |
)); |
|
2622 |
$inner .= $blk->run(); |
|
2623 |
} |
|
362
02d315d1cc58
Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents:
359
diff
changeset
|
2624 |
*/ |
1 | 2625 |
if ( $num_pages < 5 ) |
2626 |
{ |
|
2627 |
for ( $i = 0; $i < $num_pages; $i++ ) |
|
2628 |
{ |
|
2629 |
$cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
|
2630 |
$offset = strval($i * $perpage); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2631 |
$url = htmlspecialchars(sprintf($result_url, $offset)); |
1 | 2632 |
$j = $i + 1; |
2633 |
$link = ( $offset == strval($start) ) ? "<b>$j</b>" : "<a href=".'"'."$url".'"'." style='text-decoration: none;'>$j</a>"; |
|
2634 |
$blk->assign_vars(array( |
|
2635 |
'CLASS'=>$cls, |
|
2636 |
'LINK'=>$link |
|
2637 |
)); |
|
2638 |
$inner .= $blk->run(); |
|
2639 |
} |
|
2640 |
} |
|
2641 |
else |
|
2642 |
{ |
|
2643 |
if ( $this_page + 5 > $num_pages ) |
|
2644 |
{ |
|
2645 |
$list = Array(); |
|
2646 |
$tp = $this_page; |
|
2647 |
if ( $this_page + 0 == $num_pages ) $tp = $tp - 3; |
|
2648 |
if ( $this_page + 1 == $num_pages ) $tp = $tp - 2; |
|
2649 |
if ( $this_page + 2 == $num_pages ) $tp = $tp - 1; |
|
2650 |
for ( $i = $tp - 1; $i <= $tp + 1; $i++ ) |
|
2651 |
{ |
|
2652 |
$list[] = $i; |
|
2653 |
} |
|
2654 |
} |
|
2655 |
else |
|
2656 |
{ |
|
2657 |
$list = Array(); |
|
2658 |
$current = $this_page; |
|
2659 |
$lower = ( $current < 3 ) ? 1 : $current - 1; |
|
2660 |
for ( $i = 0; $i < 3; $i++ ) |
|
2661 |
{ |
|
2662 |
$list[] = $lower + $i; |
|
2663 |
} |
|
2664 |
} |
|
2665 |
$url = sprintf($result_url, '0'); |
|
362
02d315d1cc58
Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents:
359
diff
changeset
|
2666 |
$link = ( 0 == $start ) ? "<b>" . $lang->get('paginate_btn_first') . "</b>" : "<a href=".'"'."$url".'"'." style='text-decoration: none;'>« " . $lang->get('paginate_btn_first') . "</a>"; |
1 | 2667 |
$blk->assign_vars(array( |
2668 |
'CLASS'=>$cls, |
|
2669 |
'LINK'=>$link |
|
2670 |
)); |
|
2671 |
$inner .= $blk->run(); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2672 |
|
1 | 2673 |
// if ( !in_array(1, $list) ) |
2674 |
// { |
|
2675 |
// $cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
|
2676 |
// $blk->assign_vars(array('CLASS'=>$cls,'LINK'=>'...')); |
|
2677 |
// $inner .= $blk->run(); |
|
2678 |
// } |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2679 |
|
1 | 2680 |
foreach ( $list as $i ) |
2681 |
{ |
|
2682 |
if ( $i == $num_pages ) |
|
2683 |
break; |
|
2684 |
$cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
|
2685 |
$offset = strval($i * $perpage); |
|
2686 |
$url = sprintf($result_url, $offset); |
|
2687 |
$j = $i + 1; |
|
2688 |
$link = ( $offset == strval($start) ) ? "<b>$j</b>" : "<a href=".'"'."$url".'"'." style='text-decoration: none;'>$j</a>"; |
|
2689 |
$blk->assign_vars(array( |
|
2690 |
'CLASS'=>$cls, |
|
2691 |
'LINK'=>$link |
|
2692 |
)); |
|
2693 |
$inner .= $blk->run(); |
|
2694 |
} |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2695 |
|
1 | 2696 |
if ( $this_page < $num_pages ) |
2697 |
{ |
|
2698 |
// $cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
|
2699 |
// $blk->assign_vars(array('CLASS'=>$cls,'LINK'=>'...')); |
|
2700 |
// $inner .= $blk->run(); |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2701 |
|
1 | 2702 |
$cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
2703 |
$offset = strval($total); |
|
2704 |
$url = sprintf($result_url, $offset); |
|
2705 |
$j = $i + 1; |
|
362
02d315d1cc58
Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents:
359
diff
changeset
|
2706 |
$link = ( $offset == strval($start) ) ? "<b>" . $lang->get('paginate_btn_last') . "</b>" : "<a href=".'"'."$url".'"'." style='text-decoration: none;'>" . $lang->get('paginate_btn_last') . " »</a>"; |
1 | 2707 |
$blk->assign_vars(array( |
2708 |
'CLASS'=>$cls, |
|
2709 |
'LINK'=>$link |
|
2710 |
)); |
|
2711 |
$inner .= $blk->run(); |
|
2712 |
} |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2713 |
|
1 | 2714 |
} |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2715 |
|
362
02d315d1cc58
Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents:
359
diff
changeset
|
2716 |
/* |
1 | 2717 |
if ( $start < $total ) |
2718 |
{ |
|
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
270
diff
changeset
|
2719 |
$link_offset = abs($start + $perpage); |
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
270
diff
changeset
|
2720 |
$url = htmlspecialchars(sprintf($result_url, strval($link_offset))); |
359 | 2721 |
$link = "<a href=".'"'."$url".'"'." style='text-decoration: none;'>" . $lang->get('paginate_btn_next') . " »</a>"; |
1 | 2722 |
$cls = ( $cls == 'row1' ) ? 'row2' : 'row1'; |
2723 |
$blk->assign_vars(array( |
|
2724 |
'CLASS'=>$cls, |
|
2725 |
'LINK'=>$link |
|
2726 |
)); |
|
2727 |
$inner .= $blk->run(); |
|
2728 |
} |
|
362
02d315d1cc58
Started localization on User CP. Localized pagination, password strength, and various other small widgets. Fixed bug in path manager causing return of fullpage from get_page_id_from_url() even when namespace is Special.
Dan
parents:
359
diff
changeset
|
2729 |
*/ |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2730 |
|
1 | 2731 |
$inner .= '<td class="row2" style="cursor: pointer;" onclick="paginator_goto(this, '.$this_page.', '.$num_pages.', '.$perpage.', unescape(\'' . rawurlencode($result_url) . '\'));">↓</td>'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2732 |
|
1 | 2733 |
$paginator = "\n$begin$inner$end\n"; |
2734 |
if ( $total > 1 ) |
|
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
270
diff
changeset
|
2735 |
{ |
1 | 2736 |
$out .= $paginator; |
272
e0ec986c0af3
Searching sucks, and Enano's search algorithm was complete bullcrap. So I rewrote it. No, it does not use Google search technology. Like they have a patent for using the Arial font on search result pages anyway.
Dan
parents:
270
diff
changeset
|
2737 |
} |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2738 |
|
1 | 2739 |
$cls = 'row2'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2740 |
|
1 | 2741 |
if ( sizeof($q) > 0 ) |
2742 |
{ |
|
2743 |
$i = 0; |
|
2744 |
$out .= $header; |
|
2745 |
foreach ( $q as $val ) { |
|
2746 |
$i++; |
|
2747 |
if ( $i <= $start ) |
|
2748 |
{ |
|
2749 |
continue; |
|
2750 |
} |
|
2751 |
if ( ( $i - $start ) > $perpage ) |
|
2752 |
{ |
|
2753 |
break; |
|
2754 |
} |
|
2755 |
$out .= $val; |
|
2756 |
} |
|
2757 |
$out .= $footer; |
|
2758 |
} |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2759 |
|
1 | 2760 |
if ( $total > 1 ) |
2761 |
$out .= $paginator; |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2762 |
|
1 | 2763 |
return $out; |
2764 |
} |
|
2765 |
||
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2766 |
/** |
1 | 2767 |
* Enano version of fputs for debugging |
2768 |
*/ |
|
2769 |
||
2770 |
function enano_fputs($socket, $data) |
|
2771 |
{ |
|
2772 |
// echo '<pre>' . htmlspecialchars($data) . '</pre>'; |
|
2773 |
// flush(); |
|
2774 |
// ob_flush(); |
|
2775 |
// ob_end_flush(); |
|
2776 |
return fputs($socket, $data); |
|
2777 |
} |
|
2778 |
||
2779 |
/** |
|
2780 |
* Sanitizes a page URL string so that it can safely be stored in the database. |
|
2781 |
* @param string Page ID to sanitize |
|
2782 |
* @return string Cleaned text |
|
2783 |
*/ |
|
2784 |
||
2785 |
function sanitize_page_id($page_id) |
|
2786 |
{ |
|
325
e17cc42d77cf
Fixed: $paths->page_id not set when the page doesn't exist; finally fixed garbled page names for IP addresses
Dan
parents:
322
diff
changeset
|
2787 |
global $db, $session, $paths, $template, $plugins; // Common objects |
e17cc42d77cf
Fixed: $paths->page_id not set when the page doesn't exist; finally fixed garbled page names for IP addresses
Dan
parents:
322
diff
changeset
|
2788 |
|
e17cc42d77cf
Fixed: $paths->page_id not set when the page doesn't exist; finally fixed garbled page names for IP addresses
Dan
parents:
322
diff
changeset
|
2789 |
if ( isset($paths->nslist['User']) ) |
e17cc42d77cf
Fixed: $paths->page_id not set when the page doesn't exist; finally fixed garbled page names for IP addresses
Dan
parents:
322
diff
changeset
|
2790 |
{ |
377
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
parents:
376
diff
changeset
|
2791 |
if ( preg_match('/^' . str_replace('/', '\\/', preg_quote($paths->nslist['User'])) . '/', $page_id) ) |
325
e17cc42d77cf
Fixed: $paths->page_id not set when the page doesn't exist; finally fixed garbled page names for IP addresses
Dan
parents:
322
diff
changeset
|
2792 |
{ |
377
bb3e6c3bd4f4
Removed stray debugging info from ACL editor success notification; added ability for guests to set language on URI (?lang=eng); added html_in_pages ACL type and separated from php_in_pages so HTML can be embedded but not PHP; rewote portions of the path manager to better abstract URL input; added Zend Framework into list of BSD-licensed libraries; localized some remaining strings; got the migration script working, but just barely; fixed display bug in Special:Contributions; localized Main Page button in admin panel
Dan
parents:
376
diff
changeset
|
2793 |
$ip = preg_replace('/^' . str_replace('/', '\\/', preg_quote($paths->nslist['User'])) . '/', '', $page_id); |
325
e17cc42d77cf
Fixed: $paths->page_id not set when the page doesn't exist; finally fixed garbled page names for IP addresses
Dan
parents:
322
diff
changeset
|
2794 |
if ( is_valid_ip($ip) ) |
e17cc42d77cf
Fixed: $paths->page_id not set when the page doesn't exist; finally fixed garbled page names for IP addresses
Dan
parents:
322
diff
changeset
|
2795 |
{ |
e17cc42d77cf
Fixed: $paths->page_id not set when the page doesn't exist; finally fixed garbled page names for IP addresses
Dan
parents:
322
diff
changeset
|
2796 |
return $page_id; |
e17cc42d77cf
Fixed: $paths->page_id not set when the page doesn't exist; finally fixed garbled page names for IP addresses
Dan
parents:
322
diff
changeset
|
2797 |
} |
e17cc42d77cf
Fixed: $paths->page_id not set when the page doesn't exist; finally fixed garbled page names for IP addresses
Dan
parents:
322
diff
changeset
|
2798 |
} |
e17cc42d77cf
Fixed: $paths->page_id not set when the page doesn't exist; finally fixed garbled page names for IP addresses
Dan
parents:
322
diff
changeset
|
2799 |
} |
e17cc42d77cf
Fixed: $paths->page_id not set when the page doesn't exist; finally fixed garbled page names for IP addresses
Dan
parents:
322
diff
changeset
|
2800 |
|
685
17ebe24cdf85
Rebranded as 1.1.5 (Caoineag alpha 5) and fixed a couple bugs related to CDN support in template_nodb and installerUI. Updated readme.
Dan
parents:
667
diff
changeset
|
2801 |
if ( empty($page_id) ) |
17ebe24cdf85
Rebranded as 1.1.5 (Caoineag alpha 5) and fixed a couple bugs related to CDN support in template_nodb and installerUI. Updated readme.
Dan
parents:
667
diff
changeset
|
2802 |
return ''; |
17ebe24cdf85
Rebranded as 1.1.5 (Caoineag alpha 5) and fixed a couple bugs related to CDN support in template_nodb and installerUI. Updated readme.
Dan
parents:
667
diff
changeset
|
2803 |
|
15
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2804 |
// Remove character escapes |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2805 |
$page_id = dirtify_page_id($page_id); |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2806 |
|
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
19
diff
changeset
|
2807 |
$pid_clean = preg_replace('/[\w\.\/:;\(\)@\[\]_-]/', 'X', $page_id); |
1 | 2808 |
$pid_dirty = enano_str_split($pid_clean, 1); |
685
17ebe24cdf85
Rebranded as 1.1.5 (Caoineag alpha 5) and fixed a couple bugs related to CDN support in template_nodb and installerUI. Updated readme.
Dan
parents:
667
diff
changeset
|
2809 |
|
1 | 2810 |
foreach ( $pid_dirty as $id => $char ) |
2811 |
{ |
|
2812 |
if ( $char == 'X' ) |
|
2813 |
continue; |
|
2814 |
$cid = ord($char); |
|
2815 |
$cid = dechex($cid); |
|
2816 |
$cid = strval($cid); |
|
2817 |
if ( strlen($cid) < 2 ) |
|
2818 |
{ |
|
2819 |
$cid = strtoupper("0$cid"); |
|
2820 |
} |
|
2821 |
$pid_dirty[$id] = ".$cid"; |
|
2822 |
} |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2823 |
|
1 | 2824 |
$pid_chars = enano_str_split($page_id, 1); |
2825 |
$page_id_cleaned = ''; |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2826 |
|
1 | 2827 |
foreach ( $pid_chars as $id => $char ) |
2828 |
{ |
|
2829 |
if ( $pid_dirty[$id] == 'X' ) |
|
2830 |
$page_id_cleaned .= $char; |
|
2831 |
else |
|
2832 |
$page_id_cleaned .= $pid_dirty[$id]; |
|
2833 |
} |
|
325
e17cc42d77cf
Fixed: $paths->page_id not set when the page doesn't exist; finally fixed garbled page names for IP addresses
Dan
parents:
322
diff
changeset
|
2834 |
|
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
19
diff
changeset
|
2835 |
// global $mime_types; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2836 |
|
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
19
diff
changeset
|
2837 |
// $exts = array_keys($mime_types); |
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
19
diff
changeset
|
2838 |
// $exts = '(' . implode('|', $exts) . ')'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2839 |
|
21
663fcf528726
Updated all version numbers back to Banshee; a few preliminary steps towards full UTF-8 support in page URLs
Dan
parents:
19
diff
changeset
|
2840 |
// $page_id_cleaned = preg_replace('/\.2e' . $exts . '$/', '.\\1', $page_id_cleaned); |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2841 |
|
1 | 2842 |
return $page_id_cleaned; |
2843 |
} |
|
2844 |
||
2845 |
/** |
|
15
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2846 |
* Removes character escapes in a page ID string |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2847 |
* @param string Page ID string to dirty up |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2848 |
* @return string |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2849 |
*/ |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2850 |
|
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2851 |
function dirtify_page_id($page_id) |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2852 |
{ |
38 | 2853 |
global $db, $session, $paths, $template, $plugins; // Common objects |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2854 |
// First, replace spaces with underscores |
15
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2855 |
$page_id = str_replace(' ', '_', $page_id); |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2856 |
|
38 | 2857 |
// Exception for userpages for IP addresses |
325
e17cc42d77cf
Fixed: $paths->page_id not set when the page doesn't exist; finally fixed garbled page names for IP addresses
Dan
parents:
322
diff
changeset
|
2858 |
if ( is_valid_ip($page_id) ) |
38 | 2859 |
{ |
325
e17cc42d77cf
Fixed: $paths->page_id not set when the page doesn't exist; finally fixed garbled page names for IP addresses
Dan
parents:
322
diff
changeset
|
2860 |
return $page_id; |
38 | 2861 |
} |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2862 |
|
15
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2863 |
preg_match_all('/\.[A-Fa-f0-9][A-Fa-f0-9]/', $page_id, $matches); |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2864 |
|
15
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2865 |
foreach ( $matches[0] as $id => $char ) |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2866 |
{ |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2867 |
$char = substr($char, 1); |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2868 |
$char = strtolower($char); |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2869 |
$char = intval(hexdec($char)); |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2870 |
$char = chr($char); |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2871 |
$page_id = str_replace($matches[0][$id], $char, $page_id); |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2872 |
} |
325
e17cc42d77cf
Fixed: $paths->page_id not set when the page doesn't exist; finally fixed garbled page names for IP addresses
Dan
parents:
322
diff
changeset
|
2873 |
|
15
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2874 |
return $page_id; |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2875 |
} |
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2876 |
|
ad5986a53197
Fixed complicated SQL injection vulnerability in URL handler, updated license info for Tigra Tree Menu, and killed one XSS vulnerability
Dan
parents:
14
diff
changeset
|
2877 |
/** |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2878 |
* Inserts commas into a number to make it more human-readable. Floating point-safe and doesn't flirt with the number like number_format() does. |
1 | 2879 |
* @param int The number to process |
2880 |
* @return string Input number with commas added |
|
2881 |
*/ |
|
2882 |
||
2883 |
function commatize($num) |
|
2884 |
{ |
|
2885 |
$num = (string)$num; |
|
2886 |
if ( strpos($num, '.') ) |
|
2887 |
{ |
|
2888 |
$whole = explode('.', $num); |
|
2889 |
$num = $whole[0]; |
|
2890 |
$dec = $whole[1]; |
|
2891 |
} |
|
2892 |
else |
|
2893 |
{ |
|
2894 |
$whole = $num; |
|
2895 |
} |
|
2896 |
$offset = ( strlen($num) ) % 3; |
|
2897 |
$len = strlen($num); |
|
2898 |
$offset = ( $offset == 0 ) |
|
2899 |
? 3 |
|
2900 |
: $offset; |
|
2901 |
for ( $i = $offset; $i < $len; $i=$i+3 ) |
|
2902 |
{ |
|
2903 |
$num = substr($num, 0, $i) . ',' . substr($num, $i, $len); |
|
2904 |
$len = strlen($num); |
|
2905 |
$i++; |
|
2906 |
} |
|
2907 |
if ( isset($dec) ) |
|
2908 |
{ |
|
2909 |
return $num . '.' . $dec; |
|
2910 |
} |
|
2911 |
else |
|
2912 |
{ |
|
2913 |
return $num; |
|
2914 |
} |
|
2915 |
} |
|
2916 |
||
32
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2917 |
/** |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2918 |
* Injects a string into another string at the specified position. |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2919 |
* @param string The haystack |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2920 |
* @param string The needle |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2921 |
* @param int Position at which to insert the needle |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2922 |
*/ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2923 |
|
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2924 |
function inject_substr($haystack, $needle, $pos) |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2925 |
{ |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2926 |
$str1 = substr($haystack, 0, $pos); |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2927 |
$pos++; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2928 |
$str2 = substr($haystack, $pos); |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2929 |
return "{$str1}{$needle}{$str2}"; |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2930 |
} |
4d87aad3c4c0
Finished everything on the TODO list (yay!); several CSS cleanups; tons more changes in this commit - see the patch for details
Dan
parents:
22
diff
changeset
|
2931 |
|
38 | 2932 |
/** |
2933 |
* Tells if a given IP address is valid. |
|
2934 |
* @param string suspected IP address |
|
2935 |
* @return bool true if valid, false otherwise |
|
2936 |
*/ |
|
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2937 |
|
38 | 2938 |
function is_valid_ip($ip) |
2939 |
{ |
|
710
1fbce408813c
Fixed IPv6 address match (the one from phpBB3 did not work)
Dan
parents:
685
diff
changeset
|
2940 |
// This next one came from phpBB3. |
38 | 2941 |
$ipv4 = '(?:(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.){3}(?:\d{1,2}|1\d\d|2[0-4]\d|25[0-5])'; |
710
1fbce408813c
Fixed IPv6 address match (the one from phpBB3 did not work)
Dan
parents:
685
diff
changeset
|
2942 |
$ipv6 = '(?:[a-f0-9]{0,4}):(?:[a-f0-9]{0,4}):(?:[a-f0-9]{0,4}:|:)?(?:[a-f0-9]{0,4}:|:)?(?:[a-f0-9]{0,4}:|:)?(?:[a-f0-9]{0,4}:|:)?(?:[a-f0-9]{0,4}:|:)?(?:[a-f0-9]{1,4})'; |
76
608dee512bf0
Work started on page tags, still aways to go, but syncing to Nighthawk
Dan
parents:
74
diff
changeset
|
2943 |
|
38 | 2944 |
if ( preg_match("/^{$ipv4}$/", $ip) || preg_match("/^{$ipv6}$/", $ip) ) |
2945 |
return true; |
|
2946 |
else |
|
2947 |
return false; |
|
2948 |
} |
|
2949 |
||
48
fc9762553a3c
E-mail address mask engine non-Javascript fallback now picks random substitutions for @ and . to make address more unreadable by bots
Dan
parents:
40
diff
changeset
|
2950 |
/** |
fc9762553a3c
E-mail address mask engine non-Javascript fallback now picks random substitutions for @ and . to make address more unreadable by bots
Dan
parents:
40
diff
changeset
|
2951 |
* Replaces the FIRST given occurrence of needle within haystack with thread |
fc9762553a3c
E-mail address mask engine non-Javascript fallback now picks random substitutions for @ and . to make address more unreadable by bots
Dan
parents:
40
diff
changeset
|
2952 |
* @param string Needle |
fc9762553a3c
E-mail address mask engine non-Javascript fallback now picks random substitutions for @ and . to make address more unreadable by bots
Dan
parents:
40
diff
changeset
|
2953 |
* @param string Thread |
fc9762553a3c
E-mail address mask engine non-Javascript fallback now picks random substitutions for @ and . to make address more unreadable by bots
Dan
parents:
40
diff
changeset
|
2954 |
* @param string Haystack |
fc9762553a3c
E-mail address mask engine non-Javascript fallback now picks random substitutions for @ and . to make address more unreadable by bots
Dan
parents:
40
diff
changeset
|
2955 |
*/ |
fc9762553a3c
E-mail address mask engine non-Javascript fallback now picks random substitutions for @ and . to make address more unreadable by bots
Dan
parents:
40
diff
changeset
|
2956 |
|
fc9762553a3c
E-mail address mask engine non-Javascript fallback now picks random substitutions for @ and . to make address more unreadable by bots
Dan
parents:
40
diff
changeset
|
2957 |
function str_replace_once($needle, $thread, $haystack) |
fc9762553a3c
E-mail address mask engine non-Javascript fallback now picks random substitutions for @ and . to make address more unreadable by bots
Dan
parents:
40
diff
changeset
|
2958 |
{ |
fc9762553a3c
E-mail address mask engine non-Javascript fallback now picks random substitutions for @ and . to make address more unreadable by bots
Dan
parents:
40
diff
changeset
|
2959 |
$needle_len = strlen($needle); |
593
4f9bec0d65c1
More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents:
592
diff
changeset
|
2960 |
if ( $pos = strstr($haystack, $needle) ) |
48
fc9762553a3c
E-mail address mask engine non-Javascript fallback now picks random substitutions for @ and . to make address more unreadable by bots
Dan
parents:
40
diff
changeset
|
2961 |
{ |
593
4f9bec0d65c1
More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents:
592
diff
changeset
|
2962 |
$upto = substr($haystack, 0, ( strlen($haystack) - strlen($pos) )); |
4f9bec0d65c1
More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents:
592
diff
changeset
|
2963 |
$from = substr($pos, $needle_len); |
4f9bec0d65c1
More optimization work. Moved special page init functions to common instead of common_post hook. Allowed paths to cache page metadata on filesystem. Phased out the redundancy in $paths->pages that paired a number with every urlname as foreach loops are allowed now (and have been for some time). Fixed missing includes for several functions. Rewrote str_replace_once to be a lot more efficient.
Dan
parents:
592
diff
changeset
|
2964 |
return "{$upto}{$thread}{$from}"; |
48
fc9762553a3c
E-mail address mask engine non-Javascript fallback now picks random substitutions for @ and . to make address more unreadable by bots
Dan
parents:
40
diff
changeset
|
2965 |
} |
fc9762553a3c
E-mail address mask engine non-Javascript fallback now picks random substitutions for @ and . to make address more unreadable by bots
Dan
parents:
40
diff
changeset
|
2966 |
return $haystack; |
fc9762553a3c
E-mail address mask engine non-Javascript fallback now picks random substitutions for @ and . to make address more unreadable by bots
Dan
parents:
40
diff
changeset
|
2967 |
} |
fc9762553a3c
E-mail address mask engine non-Javascript fallback now picks random substitutions for @ and . to make address more unreadable by bots
Dan
parents:
40
diff
changeset
|
2968 |
|
78
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
2969 |
/** |
581
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2970 |
* Replaces all given occurences of needle in haystack, case insensitively. |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2971 |
* @param string Needle |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2972 |
* @param string Thread |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2973 |
* @param string Haystack |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2974 |
* @return string |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2975 |
*/ |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2976 |
|
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2977 |
function str_replace_i($needle, $thread, $haystack) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2978 |
{ |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2979 |
$needle_len = strlen($needle); |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2980 |
$haystack_len = strlen($haystack); |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2981 |
for ( $i = 0; $i < $haystack_len; $i++ ) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2982 |
{ |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2983 |
$test = substr($haystack, $i, $needle_len); |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2984 |
if ( strtolower($test) == strtolower($needle) ) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2985 |
{ |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2986 |
// Got it! |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2987 |
$upto = substr($haystack, 0, $i); |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2988 |
$from = substr($haystack, ( $i + $needle_len )); |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2989 |
$haystack = "{$upto}{$thread}{$from}"; |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2990 |
$haystack_len = strlen($haystack); |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2991 |
$i = $i + strlen($thread); |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2992 |
} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2993 |
} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2994 |
return $haystack; |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2995 |
} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2996 |
|
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2997 |
/** |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2998 |
* Highlights a term in a string. |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
2999 |
* @param string Needle (term to highlight) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3000 |
* @param string Haystack (search string) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3001 |
* @param string Starting tag (<b>) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3002 |
* @param string Ending tag (</b>) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3003 |
* @return string |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3004 |
*/ |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3005 |
|
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3006 |
function highlight_term($needle, $haystack, $start_tag = '<b>', $end_tag = '</b>') |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3007 |
{ |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3008 |
$needle_len = strlen($needle); |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3009 |
$haystack_len = strlen($haystack); |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3010 |
for ( $i = 0; $i < $haystack_len; $i++ ) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3011 |
{ |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3012 |
$test = substr($haystack, $i, $needle_len); |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3013 |
if ( strtolower($test) == strtolower($needle) ) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3014 |
{ |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3015 |
// Got it! |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3016 |
$upto = substr($haystack, 0, $i); |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3017 |
$from = substr($haystack, ( $i + $needle_len )); |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3018 |
$haystack = "{$upto}{$start_tag}{$test}{$end_tag}{$from}"; |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3019 |
$haystack_len = strlen($haystack); |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3020 |
$i = $i + strlen($needle) + strlen($start_tag) + strlen($end_tag); |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3021 |
} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3022 |
} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3023 |
return $haystack; |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3024 |
} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3025 |
|
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
575
diff
changeset
|
3026 |
/** |
78
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3027 |
* From http://us2.php.net/urldecode - decode %uXXXX |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3028 |
* @param string The urlencoded string |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3029 |
* @return string |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3030 |
*/ |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3031 |
|
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3032 |
function decode_unicode_url($str) |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3033 |
{ |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3034 |
$res = ''; |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3035 |
|
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3036 |
$i = 0; |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3037 |
$max = strlen($str) - 6; |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3038 |
while ($i <= $max) |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3039 |
{ |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3040 |
$character = $str[$i]; |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3041 |
if ($character == '%' && $str[$i + 1] == 'u') |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3042 |
{ |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3043 |
$value = hexdec(substr($str, $i + 2, 4)); |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3044 |
$i += 6; |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3045 |
|
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3046 |
if ($value < 0x0080) |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3047 |
{ |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3048 |
// 1 byte: 0xxxxxxx |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3049 |
$character = chr($value); |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3050 |
} |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3051 |
else if ($value < 0x0800) |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3052 |
{ |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3053 |
// 2 bytes: 110xxxxx 10xxxxxx |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3054 |
$character = |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3055 |
chr((($value & 0x07c0) >> 6) | 0xc0) |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3056 |
. chr(($value & 0x3f) | 0x80); |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3057 |
} |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3058 |
else |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3059 |
{ |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3060 |
// 3 bytes: 1110xxxx 10xxxxxx 10xxxxxx |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3061 |
$character = |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3062 |
chr((($value & 0xf000) >> 12) | 0xe0) |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3063 |
. chr((($value & 0x0fc0) >> 6) | 0x80) |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3064 |
. chr(($value & 0x3f) | 0x80); |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3065 |
} |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3066 |
} |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3067 |
else |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3068 |
{ |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3069 |
$i++; |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3070 |
} |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3071 |
|
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3072 |
$res .= $character; |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3073 |
} |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3074 |
|
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3075 |
return $res . substr($str, $i); |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3076 |
} |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3077 |
|
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3078 |
/** |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3079 |
* Recursively decodes an array with UTF-8 characters in its strings |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3080 |
* @param array Can be multi-depth |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3081 |
* @return array |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3082 |
*/ |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3083 |
|
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3084 |
function decode_unicode_array($array) |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3085 |
{ |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3086 |
foreach ( $array as $i => $val ) |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3087 |
{ |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3088 |
if ( is_string($val) ) |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3089 |
{ |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3090 |
$array[$i] = decode_unicode_url($val); |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3091 |
} |
270
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3092 |
else if ( is_array($val) ) |
78
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3093 |
{ |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3094 |
$array[$i] = decode_unicode_array($val); |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3095 |
} |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3096 |
} |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3097 |
return $array; |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3098 |
} |
4df25dfdde63
Modified Text_Wiki parser to fully support UTF-8 strings; several other UTF-8 fixes, international characters seem to work reasonably well now
Dan
parents:
76
diff
changeset
|
3099 |
|
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3100 |
/** |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3101 |
* Sanitizes a page tag. |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3102 |
* @param string |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3103 |
* @return string |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3104 |
*/ |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3105 |
|
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3106 |
function sanitize_tag($tag) |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3107 |
{ |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3108 |
$tag = strtolower($tag); |
315
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
311
diff
changeset
|
3109 |
$tag = preg_replace('/[^\w @\$%\^&-]+/', '', $tag); |
f49e3c8b638c
Fixed focus of AJAX login form fields in IE; removed stale/unused call to $template->makeParserText() in paginate_array(); added hook page_create_request to possibly help control creation of pages of certain namespaces from plugins; fixed critical bug in user CP that prevented plugins from adding custom CP modules
Dan
parents:
311
diff
changeset
|
3110 |
$tag = str_replace('_', ' ', $tag); |
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3111 |
$tag = trim($tag); |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3112 |
return $tag; |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3113 |
} |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3114 |
|
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3115 |
/** |
610
de33b0d26741
Fixed gzip output - no longer depends on ob_gzhandler(), uses gzencode() now with a failsafe available if gzencode() is not available. Public function gzip_output() remains unchanged.
Dan
parents:
606
diff
changeset
|
3116 |
* Replacement for gzencode() which doesn't always work. |
de33b0d26741
Fixed gzip output - no longer depends on ob_gzhandler(), uses gzencode() now with a failsafe available if gzencode() is not available. Public function gzip_output() remains unchanged.
Dan
parents:
606
diff
changeset
|
3117 |
* @param string Data to compress |
de33b0d26741
Fixed gzip output - no longer depends on ob_gzhandler(), uses gzencode() now with a failsafe available if gzencode() is not available. Public function gzip_output() remains unchanged.
Dan
parents:
606
diff
changeset
|
3118 |
* @param int Compression level - 0 (no compression) to 9 (maximum compression) |
de33b0d26741
Fixed gzip output - no longer depends on ob_gzhandler(), uses gzencode() now with a failsafe available if gzencode() is not available. Public function gzip_output() remains unchanged.
Dan
parents:
606
diff
changeset
|
3119 |
* @param string Filename to encode into the compressed data - defaults to blank |
de33b0d26741
Fixed gzip output - no longer depends on ob_gzhandler(), uses gzencode() now with a failsafe available if gzencode() is not available. Public function gzip_output() remains unchanged.
Dan
parents:
606
diff
changeset
|
3120 |
* @param string Comment for archive - defaults to blank |
de33b0d26741
Fixed gzip output - no longer depends on ob_gzhandler(), uses gzencode() now with a failsafe available if gzencode() is not available. Public function gzip_output() remains unchanged.
Dan
parents:
606
diff
changeset
|
3121 |
* @return string Compressed data |
de33b0d26741
Fixed gzip output - no longer depends on ob_gzhandler(), uses gzencode() now with a failsafe available if gzencode() is not available. Public function gzip_output() remains unchanged.
Dan
parents:
606
diff
changeset
|
3122 |
*/ |
de33b0d26741
Fixed gzip output - no longer depends on ob_gzhandler(), uses gzencode() now with a failsafe available if gzencode() is not available. Public function gzip_output() remains unchanged.
Dan
parents:
606
diff
changeset
|
3123 |
|
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
3124 |
function enano_gzencode($data = "", $level = 6, $filename = "", $comments = "") |
610
de33b0d26741
Fixed gzip output - no longer depends on ob_gzhandler(), uses gzencode() now with a failsafe available if gzencode() is not available. Public function gzip_output() remains unchanged.
Dan
parents:
606
diff
changeset
|
3125 |
{ |
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
3126 |
$flags = (empty($comment)? 0 : 16) + (empty($filename)? 0 : 8); |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
3127 |
$mtime = time(); |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
3128 |
|
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
3129 |
if ( !function_exists('gzdeflate') ) |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
3130 |
return false; |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
3131 |
|
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
3132 |
return (pack("C1C1C1C1VC1C1", 0x1f, 0x8b, 8, $flags, $mtime, 2, 0xFF) . |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
3133 |
(empty($filename) ? "" : $filename . "\0") . |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
3134 |
(empty($comment) ? "" : $comment . "\0") . |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
3135 |
gzdeflate($data, $level) . |
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
3136 |
pack("VV", crc32($data), strlen($data))); |
610
de33b0d26741
Fixed gzip output - no longer depends on ob_gzhandler(), uses gzencode() now with a failsafe available if gzencode() is not available. Public function gzip_output() remains unchanged.
Dan
parents:
606
diff
changeset
|
3137 |
} |
de33b0d26741
Fixed gzip output - no longer depends on ob_gzhandler(), uses gzencode() now with a failsafe available if gzencode() is not available. Public function gzip_output() remains unchanged.
Dan
parents:
606
diff
changeset
|
3138 |
|
de33b0d26741
Fixed gzip output - no longer depends on ob_gzhandler(), uses gzencode() now with a failsafe available if gzencode() is not available. Public function gzip_output() remains unchanged.
Dan
parents:
606
diff
changeset
|
3139 |
/** |
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3140 |
* Gzips the output buffer. |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3141 |
*/ |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3142 |
|
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3143 |
function gzip_output() |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3144 |
{ |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3145 |
global $do_gzip; |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3146 |
|
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3147 |
// |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3148 |
// Compress buffered output if required and send to browser |
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
3149 |
// Sorry, doesn't work in IE. What else is new? |
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3150 |
// |
720
e2762777b170
Fixed attempt at gzip compression after headers sent; hopefully safely escape args to scale_image() instead of erroring out
Dan
parents:
711
diff
changeset
|
3151 |
if ( $do_gzip && function_exists('gzdeflate') && !strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') && !headers_sent() ) |
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3152 |
{ |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3153 |
$gzip_contents = ob_get_contents(); |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3154 |
ob_end_clean(); |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3155 |
|
667
72818d2bf336
Fixed improperly set up gzencode() replacement; fixed bad regexp in scale_image() security check
Dan
parents:
662
diff
changeset
|
3156 |
$return = @enano_gzencode($gzip_contents); |
81
d7fc25acd3f3
Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents:
80
diff
changeset
|
3157 |
if ( $return ) |
d7fc25acd3f3
Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents:
80
diff
changeset
|
3158 |
{ |
d7fc25acd3f3
Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents:
80
diff
changeset
|
3159 |
header('Content-encoding: gzip'); |
542
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
3160 |
echo $return; |
81
d7fc25acd3f3
Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents:
80
diff
changeset
|
3161 |
} |
d7fc25acd3f3
Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents:
80
diff
changeset
|
3162 |
else |
d7fc25acd3f3
Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents:
80
diff
changeset
|
3163 |
{ |
d7fc25acd3f3
Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents:
80
diff
changeset
|
3164 |
echo $gzip_contents; |
d7fc25acd3f3
Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents:
80
diff
changeset
|
3165 |
} |
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3166 |
} |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3167 |
} |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3168 |
|
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3169 |
/** |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3170 |
* Aggressively and hopefully non-destructively optimizes a blob of HTML. |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3171 |
* @param string HTML to process |
294
4ab30e8dd168
Nothing special. ksort()ing list of allowed filetypes in the admin panel to make editing the list marginally easier
Dan
parents:
276
diff
changeset
|
3172 |
* @return string much smaller HTML |
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3173 |
*/ |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3174 |
|
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3175 |
function aggressive_optimize_html($html) |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3176 |
{ |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3177 |
$size_before = strlen($html); |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3178 |
|
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3179 |
// kill carriage returns |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3180 |
$html = str_replace("\r", "", $html); |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3181 |
|
125
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
3182 |
// Which tags to strip for JAVASCRIPT PROCESSING ONLY - you can change this if needed |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
3183 |
$strip_tags = Array('enano:no-opt'); |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
3184 |
$strip_tags = implode('|', $strip_tags); |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
3185 |
|
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
3186 |
// Strip out the tags and replace with placeholders |
183
91127e62f38f
Fixed some regular expressions in HTML optimization algorithm; regex page groups can be edited now (oops)
Dan
parents:
174
diff
changeset
|
3187 |
preg_match_all("#<($strip_tags)([ ]+.*?)?>(.*?)</($strip_tags)>#is", $html, $matches); |
125
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
3188 |
$seed = md5(microtime() . mt_rand()); // Random value used for placeholders |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
3189 |
for ($i = 0;$i < sizeof($matches[1]); $i++) |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
3190 |
{ |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
3191 |
$html = str_replace($matches[0][$i], "{DONT_STRIP_ME_NAKED:$seed:$i}", $html); |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
3192 |
} |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
3193 |
|
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3194 |
// Optimize (but don't obfuscate) Javascript |
184
d74ff822acc9
Replaced autocompleting username with a much more efficient algorithm and caching system
Dan
parents:
183
diff
changeset
|
3195 |
preg_match_all('/<script([ ]+.*?)?>(.*?)(\]\]>)?<\/script>/is', $html, $jscript); |
562
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
3196 |
require_once(ENANO_ROOT . '/includes/js-compressor.php'); |
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
3197 |
$jsc = new JavascriptCompressor(); |
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3198 |
|
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3199 |
// list of Javascript reserved words - from about.com |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3200 |
$reserved_words = array('abstract', 'as', 'boolean', 'break', 'byte', 'case', 'catch', 'char', 'class', 'continue', 'const', 'debugger', 'default', 'delete', 'do', |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3201 |
'double', 'else', 'enum', 'export', 'extends', 'false', 'final', 'finally', 'float', 'for', 'function', 'goto', 'if', 'implements', 'import', |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3202 |
'in', 'instanceof', 'int', 'interface', 'is', 'long', 'namespace', 'native', 'new', 'null', 'package', 'private', 'protected', 'public', |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3203 |
'return', 'short', 'static', 'super', 'switch', 'synchronized', 'this', 'throw', 'throws', 'transient', 'true', 'try', 'typeof', 'use', 'var', |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3204 |
'void', 'volatile', 'while', 'with'); |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3205 |
|
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3206 |
$reserved_words = '(' . implode('|', $reserved_words) . ')'; |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3207 |
|
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3208 |
for ( $i = 0; $i < count($jscript[0]); $i++ ) |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3209 |
{ |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3210 |
$js =& $jscript[2][$i]; |
582
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
581
diff
changeset
|
3211 |
if ( empty($js) ) |
a38876c0793c
Majorly reworked Javascript runtime stuff to use on-demand loading.
Dan
parents:
581
diff
changeset
|
3212 |
continue; |
183
91127e62f38f
Fixed some regular expressions in HTML optimization algorithm; regex page groups can be edited now (oops)
Dan
parents:
174
diff
changeset
|
3213 |
|
562
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
3214 |
$js = $jsc->getClean($js); |
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3215 |
|
81
d7fc25acd3f3
Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents:
80
diff
changeset
|
3216 |
$replacement = "<script{$jscript[1][$i]}>/* <![CDATA[ */ $js /* ]]> */</script>"; |
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3217 |
// apply changes |
81
d7fc25acd3f3
Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents:
80
diff
changeset
|
3218 |
$html = str_replace($jscript[0][$i], $replacement, $html); |
562
75df0b2c596c
Got initial CSRF token framework implemented and sample implementation added in Special:Logout; removing Javascript compression engine from aggressive_optimize_html() and instead calling JavascriptCompressor class from js-compressor.php
Dan
parents:
556
diff
changeset
|
3219 |
|
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3220 |
} |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3221 |
|
125
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
3222 |
// Re-insert untouchable tags |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
3223 |
for ($i = 0;$i < sizeof($matches[1]); $i++) |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
3224 |
{ |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
3225 |
$html = str_replace("{DONT_STRIP_ME_NAKED:$seed:$i}", "<{$matches[1][$i]}{$matches[2][$i]}>{$matches[3][$i]}</{$matches[4][$i]}>", $html); |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
3226 |
} |
fb31c951d3a2
Fixed some rather major bugs in the registration system, this will need a release followup
Dan
parents:
112
diff
changeset
|
3227 |
|
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3228 |
// Which tags to strip - you can change this if needed |
137
3bce0c320e80
Fix: textarea tags got stripped naked by the HTML optimizer, now no longer
Dan
parents:
132
diff
changeset
|
3229 |
$strip_tags = Array('pre', 'script', 'style', 'enano:no-opt', 'textarea'); |
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3230 |
$strip_tags = implode('|', $strip_tags); |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3231 |
|
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3232 |
// Strip out the tags and replace with placeholders |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3233 |
preg_match_all("#<($strip_tags)(.*?)>(.*?)</($strip_tags)>#is", $html, $matches); |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3234 |
$seed = md5(microtime() . mt_rand()); // Random value used for placeholders |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3235 |
for ($i = 0;$i < sizeof($matches[1]); $i++) |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3236 |
{ |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3237 |
$html = str_replace($matches[0][$i], "{DONT_STRIP_ME_NAKED:$seed:$i}", $html); |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3238 |
} |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3239 |
|
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3240 |
// Finally, process the HTML |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3241 |
$html = preg_replace("#\n([ ]*)#", " ", $html); |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3242 |
|
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3243 |
// Remove annoying spaces between tags |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3244 |
$html = preg_replace("#>([ ][ ]+)<#", "> <", $html); |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3245 |
|
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3246 |
// Re-insert untouchable tags |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3247 |
for ($i = 0;$i < sizeof($matches[1]); $i++) |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3248 |
{ |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3249 |
$html = str_replace("{DONT_STRIP_ME_NAKED:$seed:$i}", "<{$matches[1][$i]}{$matches[2][$i]}>{$matches[3][$i]}</{$matches[4][$i]}>", $html); |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3250 |
} |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3251 |
|
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3252 |
// Remove <enano:no-opt> blocks (can be used by themes that don't want their HTML optimized) |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3253 |
$html = preg_replace('#<(\/|)enano:no-opt(.*?)>#', '', $html); |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3254 |
|
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3255 |
$size_after = strlen($html); |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3256 |
|
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3257 |
// Tell snoopish users what's going on |
81
d7fc25acd3f3
Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents:
80
diff
changeset
|
3258 |
$html = str_replace('<html', "\n".'<!-- NOTE: Enano has performed an HTML optimization routine on the HTML you see here. This is to enhance page loading speeds. |
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3259 |
To view the uncompressed source of this page, add the "nocompress" parameter to the URI of this page: index.php?title=Main_Page&nocompress or Main_Page?nocompress'." |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3260 |
Size before compression: $size_before bytes |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3261 |
Size after compression: $size_after bytes |
81
d7fc25acd3f3
Replaced the menu in the admin theme with something much more visually pleasureable; minor fix in Special:UploadFile; finished patching a couple of XSS problems from Banshee; finished Admin:PageGroups; removed unneeded code in flyin.js; finished tag system (except tag cloud); 1.0.1 release candidate
Dan
parents:
80
diff
changeset
|
3262 |
-->\n<html", $html); |
80
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3263 |
return $html; |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3264 |
} |
cb7dde69c301
Improved and enabled HTML optimization algorithm; enabled gzip compression; added but did not test at all the tag cloud class in includes/tagcloud.php, this is still very preliminary and not ready for any type of production use
Dan
parents:
78
diff
changeset
|
3265 |
|
128
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3266 |
/** |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3267 |
* For an input range of numbers (like 25-256) returns an array filled with all numbers in the range, inclusive. |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3268 |
* @param string |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3269 |
* @return array |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3270 |
*/ |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3271 |
|
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3272 |
function int_range($range) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3273 |
{ |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3274 |
if ( strval(intval($range)) == $range ) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3275 |
return $range; |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3276 |
if ( !preg_match('/^[0-9]+(-[0-9]+)?$/', $range) ) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3277 |
return false; |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3278 |
$ends = explode('-', $range); |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3279 |
if ( count($ends) != 2 ) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3280 |
return $range; |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3281 |
$ret = array(); |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3282 |
if ( $ends[1] < $ends[0] ) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3283 |
$ends = array($ends[1], $ends[0]); |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3284 |
else if ( $ends[0] == $ends[1] ) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3285 |
return array($ends[0]); |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3286 |
for ( $i = $ends[0]; $i <= $ends[1]; $i++ ) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3287 |
{ |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3288 |
$ret[] = $i; |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3289 |
} |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3290 |
return $ret; |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3291 |
} |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3292 |
|
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3293 |
/** |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3294 |
* Parses a range or series of IP addresses, and returns the raw addresses. Only parses ranges in the last two octets to prevent DOSing. |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3295 |
* Syntax for ranges: x.x.x.x; x|y.x.x.x; x.x.x-z.x; x.x.x-z|p.q|y |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3296 |
* @param string IP address range string |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3297 |
* @return array |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3298 |
*/ |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3299 |
|
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3300 |
function parse_ip_range($range) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3301 |
{ |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3302 |
$octets = explode('.', $range); |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3303 |
if ( count($octets) != 4 ) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3304 |
// invalid range |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3305 |
return $range; |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3306 |
$i = 0; |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3307 |
$possibilities = array( 0 => array(), 1 => array(), 2 => array(), 3 => array() ); |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3308 |
foreach ( $octets as $octet ) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3309 |
{ |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3310 |
$existing =& $possibilities[$i]; |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3311 |
$inner = explode('|', $octet); |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3312 |
foreach ( $inner as $bit ) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3313 |
{ |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3314 |
if ( $i >= 2 ) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3315 |
{ |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3316 |
$bits = int_range($bit); |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3317 |
if ( $bits === false ) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3318 |
return false; |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3319 |
else if ( !is_array($bits) ) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3320 |
$existing[] = intval($bits); |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3321 |
else |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3322 |
$existing = array_merge($existing, $bits); |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3323 |
} |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3324 |
else |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3325 |
{ |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3326 |
$bit = intval($bit); |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3327 |
$existing[] = $bit; |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3328 |
} |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3329 |
} |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3330 |
$existing = array_unique($existing); |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3331 |
$i++; |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3332 |
} |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3333 |
$ips = array(); |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3334 |
|
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3335 |
// The only way to combine all those possibilities. ;-) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3336 |
foreach ( $possibilities[0] as $oc1 ) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3337 |
foreach ( $possibilities[1] as $oc2 ) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3338 |
foreach ( $possibilities[2] as $oc3 ) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3339 |
foreach ( $possibilities[3] as $oc4 ) |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3340 |
$ips[] = "$oc1.$oc2.$oc3.$oc4"; |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3341 |
|
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3342 |
return $ips; |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3343 |
} |
01955bf53f96
Improved ban control page and allowed multiple entries/IP ranges; changed some parameters on jBox; user level changes are logged now
Dan
parents:
125
diff
changeset
|
3344 |
|
270
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3345 |
/** |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3346 |
* Parses a valid IP address range into a regular expression. |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3347 |
* @param string IP range string |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3348 |
* @return string |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3349 |
*/ |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3350 |
|
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3351 |
function parse_ip_range_regex($range) |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3352 |
{ |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3353 |
// Regular expression to test the range string for validity |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3354 |
$regex = '/^(([0-9]+(-[0-9]+)?)(\|([0-9]+(-[0-9]+)?))*)\.' |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3355 |
. '(([0-9]+(-[0-9]+)?)(\|([0-9]+(-[0-9]+)?))*)\.' |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3356 |
. '(([0-9]+(-[0-9]+)?)(\|([0-9]+(-[0-9]+)?))*)\.' |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3357 |
. '(([0-9]+(-[0-9]+)?)(\|([0-9]+(-[0-9]+)?))*)$/'; |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3358 |
if ( !preg_match($regex, $range) ) |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3359 |
{ |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3360 |
return false; |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3361 |
} |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3362 |
$octets = array(0 => array(), 1 => array(), 2 => array(), 3 => array()); |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3363 |
list($octets[0], $octets[1], $octets[2], $octets[3]) = explode('.', $range); |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3364 |
$return = '^'; |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3365 |
foreach ( $octets as $octet ) |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3366 |
{ |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3367 |
// alternatives array |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3368 |
$alts = array(); |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3369 |
if ( strpos($octet, '|') ) |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3370 |
{ |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3371 |
$particles = explode('|', $octet); |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3372 |
} |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3373 |
else |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3374 |
{ |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3375 |
$particles = array($octet); |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3376 |
} |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3377 |
foreach ( $particles as $atom ) |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3378 |
{ |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3379 |
// each $atom will be either |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3380 |
if ( strval(intval($atom)) == $atom ) |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3381 |
{ |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3382 |
$alts[] = $atom; |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3383 |
continue; |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3384 |
} |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3385 |
else |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3386 |
{ |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3387 |
// it's a range - parse it out |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3388 |
$alt2 = int_range($atom); |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3389 |
if ( !$alt2 ) |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3390 |
return false; |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3391 |
foreach ( $alt2 as $neutrino ) |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3392 |
$alts[] = $neutrino; |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3393 |
} |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3394 |
} |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3395 |
$alts = array_unique($alts); |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3396 |
$alts = '|' . implode('|', $alts) . '|'; |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3397 |
// we can further optimize/compress this by weaseling our way into using some character ranges |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3398 |
for ( $i = 1; $i <= 25; $i++ ) |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3399 |
{ |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3400 |
$alts = str_replace("|{$i}0|{$i}1|{$i}2|{$i}3|{$i}4|{$i}5|{$i}6|{$i}7|{$i}8|{$i}9|", "|{$i}[0-9]|", $alts); |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3401 |
} |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3402 |
$alts = str_replace("|1|2|3|4|5|6|7|8|9|", "|[1-9]|", $alts); |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3403 |
$alts = '(' . substr($alts, 1, -1) . ')'; |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3404 |
$return .= $alts . '\.'; |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3405 |
} |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3406 |
$return = substr($return, 0, -2); |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3407 |
$return .= '$'; |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3408 |
return $return; |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3409 |
} |
5bcdee999015
Major fixes to the ban system - large IP match lists don't slow down the server miserably anymore.
Dan
parents:
256
diff
changeset
|
3410 |
|
504
bc8e0e9ee01d
Added support for embedding language data into plugins; updated all version numbers on plugin files
Dan
parents:
500
diff
changeset
|
3411 |
/** |
bc8e0e9ee01d
Added support for embedding language data into plugins; updated all version numbers on plugin files
Dan
parents:
500
diff
changeset
|
3412 |
* Validates an e-mail address. Uses a compacted version of the regular expression generated by the scripts at <http://examples.oreilly.com/regex/>. |
bc8e0e9ee01d
Added support for embedding language data into plugins; updated all version numbers on plugin files
Dan
parents:
500
diff
changeset
|
3413 |
* @param string E-mail address |
bc8e0e9ee01d
Added support for embedding language data into plugins; updated all version numbers on plugin files
Dan
parents:
500
diff
changeset
|
3414 |
* @return bool |
bc8e0e9ee01d
Added support for embedding language data into plugins; updated all version numbers on plugin files
Dan
parents:
500
diff
changeset
|
3415 |
*/ |
bc8e0e9ee01d
Added support for embedding language data into plugins; updated all version numbers on plugin files
Dan
parents:
500
diff
changeset
|
3416 |
|
bc8e0e9ee01d
Added support for embedding language data into plugins; updated all version numbers on plugin files
Dan
parents:
500
diff
changeset
|
3417 |
function check_email_address($email) |
bc8e0e9ee01d
Added support for embedding language data into plugins; updated all version numbers on plugin files
Dan
parents:
500
diff
changeset
|
3418 |
{ |
bc8e0e9ee01d
Added support for embedding language data into plugins; updated all version numbers on plugin files
Dan
parents:
500
diff
changeset
|
3419 |
static $regexp = '(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*|(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]*(?:(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[^()<>@,;:".\\\[\]\x80-\xff\000-\010\012-\037]*)*<[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*(?:,[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*)*:[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)?(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|"[^\\\x80-\xff\n\015"]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015"]*)*")[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*@[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:\.[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*(?:[^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff]+(?![^(\040)<>@,;:".\\\[\]\000-\037\x80-\xff])|\[(?:[^\\\x80-\xff\n\015\[\]]|\\[^\x80-\xff])*\])[\040\t]*(?:\([^\\\x80-\xff\n\015()]*(?:(?:\\[^\x80-\xff]|\([^\\\x80-\xff\n\015()]*(?:\\[^\x80-\xff][^\\\x80-\xff\n\015()]*)*\))[^\\\x80-\xff\n\015()]*)*\)[\040\t]*)*)*>)'; |
bc8e0e9ee01d
Added support for embedding language data into plugins; updated all version numbers on plugin files
Dan
parents:
500
diff
changeset
|
3420 |
return ( preg_match("/^$regexp$/", $email) ) ? true : false; |
bc8e0e9ee01d
Added support for embedding language data into plugins; updated all version numbers on plugin files
Dan
parents:
500
diff
changeset
|
3421 |
} |
bc8e0e9ee01d
Added support for embedding language data into plugins; updated all version numbers on plugin files
Dan
parents:
500
diff
changeset
|
3422 |
|
132
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3423 |
function password_score_len($password) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3424 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3425 |
if ( !is_string($password) ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3426 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3427 |
return -10; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3428 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3429 |
$len = strlen($password); |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3430 |
$score = $len - 7; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3431 |
return $score; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3432 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3433 |
|
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3434 |
/** |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3435 |
* Give a numerical score for how strong a password is. This is an open-ended scale based on a score added to or subtracted |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3436 |
* from based on certain complexity rules. Anything less than about 1 or 0 is weak, 3-4 is strong, and 10 is not to be easily cracked. |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3437 |
* Based on the Javascript function of the same name. |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3438 |
* @param string Password to test |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3439 |
* @param null Will be filled with an array of debugging info |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3440 |
* @return int |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3441 |
*/ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3442 |
|
472
bc4b58034f4d
Implemented password reset (albeit hackishly) into the new login API; added dummy window.console object to hopefully reduce errors when Firebug isn't around; fixed the longstanding ACL dismiss/close button bug; fixed a couple undefined variables in mailer; fixed PHP error on attempted opening of /dev/(u)random in rijndael.php; clarified documentation for PageProcessor::update_page(); fixed some logic problems in theme ACL code; disabled CAPTCHA debug
Dan
parents:
468
diff
changeset
|
3443 |
function password_score($password, &$debug = false) |
132
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3444 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3445 |
if ( !is_string($password) ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3446 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3447 |
return -10; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3448 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3449 |
$score = 0; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3450 |
$debug = array(); |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3451 |
// length check |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3452 |
$lenscore = password_score_len($password); |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3453 |
|
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3454 |
$debug[] = "<b>How this score was calculated</b>\nYour score was tallied up based on an extensive algorithm which outputted\nthe following scores based on traits of your password. Above you can see the\ncomposite score; your individual scores based on certain tests are below.\n\nThe scale is open-ended, with a minimum score of -10. 10 is very strong, 4\nis strong, 1 is good and -3 is fair. Below -3 scores \"Weak.\"\n"; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3455 |
|
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3456 |
$debug[] = 'Adding '.$lenscore.' points for length'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3457 |
|
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3458 |
$score += $lenscore; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3459 |
|
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3460 |
$has_upper_lower = false; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3461 |
$has_symbols = false; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3462 |
$has_numbers = false; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3463 |
|
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3464 |
// contains uppercase and lowercase |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3465 |
if ( preg_match('/[A-z]+/', $password) && strtolower($password) != $password ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3466 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3467 |
$score += 1; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3468 |
$has_upper_lower = true; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3469 |
$debug[] = 'Adding 1 point for having uppercase and lowercase'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3470 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3471 |
|
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3472 |
// contains symbols |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3473 |
if ( preg_match('/[^A-z0-9]+/', $password) ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3474 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3475 |
$score += 1; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3476 |
$has_symbols = true; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3477 |
$debug[] = 'Adding 1 point for having nonalphanumeric characters (matching /[^A-z0-9]+/)'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3478 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3479 |
|
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3480 |
// contains numbers |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3481 |
if ( preg_match('/[0-9]+/', $password) ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3482 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3483 |
$score += 1; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3484 |
$has_numbers = true; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3485 |
$debug[] = 'Adding 1 point for having numbers'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3486 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3487 |
|
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3488 |
if ( $has_upper_lower && $has_symbols && $has_numbers && strlen($password) >= 9 ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3489 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3490 |
// if it has uppercase and lowercase letters, symbols, and numbers, and is of considerable length, add some serious points |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3491 |
$score += 4; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3492 |
$debug[] = 'Adding 4 points for having uppercase and lowercase, numbers, and nonalphanumeric and being more than 8 characters'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3493 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3494 |
else if ( $has_upper_lower && $has_symbols && $has_numbers ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3495 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3496 |
// still give some points for passing complexity check |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3497 |
$score += 2; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3498 |
$debug[] = 'Adding 2 points for having uppercase and lowercase, numbers, and nonalphanumeric'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3499 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3500 |
else if ( ( $has_upper_lower && $has_symbols ) || |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3501 |
( $has_upper_lower && $has_numbers ) || |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3502 |
( $has_symbols && $has_numbers ) ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3503 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3504 |
// if 2 of the three main complexity checks passed, add a point |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3505 |
$score += 1; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3506 |
$debug[] = 'Adding 1 point for having 2 of 3 complexity checks'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3507 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3508 |
else if ( preg_match('/^[0-9]*?([a-z]+)[0-9]?$/', $password) ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3509 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3510 |
// password is something like magnum1 which will be cracked in seconds |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3511 |
$score += -4; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3512 |
$debug[] = 'Adding -4 points for being of the form [number][word][number]'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3513 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3514 |
else if ( ( !$has_upper_lower && !$has_numbers && $has_symbols ) || |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3515 |
( !$has_upper_lower && !$has_symbols && $has_numbers ) || |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3516 |
( !$has_numbers && !$has_symbols && $has_upper_lower ) ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3517 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3518 |
$score += -2; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3519 |
$debug[] = 'Adding -2 points for only meeting 1 complexity check'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3520 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3521 |
else if ( !$has_upper_lower && !$has_numbers && !$has_symbols ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3522 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3523 |
$debug[] = 'Adding -3 points for not meeting any complexity checks'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3524 |
$score += -3; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3525 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3526 |
|
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3527 |
// |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3528 |
// Repetition |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3529 |
// Example: foobar12345 should be deducted points, where f1o2o3b4a5r should be given points |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3530 |
// |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3531 |
|
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3532 |
if ( preg_match('/([A-Z][A-Z][A-Z][A-Z]|[a-z][a-z][a-z][a-z])/', $password) ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3533 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3534 |
$debug[] = 'Adding -2 points for having more than 4 letters of the same case in a row'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3535 |
$score += -2; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3536 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3537 |
else if ( preg_match('/([A-Z][A-Z][A-Z]|[a-z][a-z][a-z])/', $password) ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3538 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3539 |
$debug[] = 'Adding -1 points for having more than 3 letters of the same case in a row'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3540 |
$score += -1; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3541 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3542 |
else if ( preg_match('/[A-z]/', $password) && !preg_match('/([A-Z][A-Z][A-Z]|[a-z][a-z][a-z])/', $password) ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3543 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3544 |
$debug[] = 'Adding 1 point for never having more than 2 letters of the same case in a row'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3545 |
$score += 1; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3546 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3547 |
|
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3548 |
if ( preg_match('/[0-9][0-9][0-9][0-9]/', $password) ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3549 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3550 |
$debug[] = 'Adding -2 points for having 4 or more numbers in a row'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3551 |
$score += -2; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3552 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3553 |
else if ( preg_match('/[0-9][0-9][0-9]/', $password) ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3554 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3555 |
$debug[] = 'Adding -1 points for having 3 or more numbers in a row'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3556 |
$score += -1; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3557 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3558 |
else if ( $has_numbers && !preg_match('/[0-9][0-9][0-9]/', $password) ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3559 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3560 |
$debug[] = 'Adding 1 point for never more than 2 numbers in a row'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3561 |
$score += -1; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3562 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3563 |
|
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3564 |
// make passwords like fooooooooooooooooooooooooooooooooooooo totally die by subtracting a point for each character repeated at least 3 times in a row |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3565 |
$prev_char = ''; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3566 |
$warn = false; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3567 |
$loss = 0; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3568 |
for ( $i = 0; $i < strlen($password); $i++ ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3569 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3570 |
$chr = $password{$i}; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3571 |
if ( $chr == $prev_char && $warn ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3572 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3573 |
$loss += -1; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3574 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3575 |
else if ( $chr == $prev_char && !$warn ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3576 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3577 |
$warn = true; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3578 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3579 |
else if ( $chr != $prev_char && $warn ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3580 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3581 |
$warn = false; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3582 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3583 |
$prev_char = $chr; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3584 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3585 |
if ( $loss < 0 ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3586 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3587 |
$debug[] = 'Adding '.$loss.' points for immediate character repetition'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3588 |
$score += $loss; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3589 |
// this can bring the score below -10 sometimes |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3590 |
if ( $score < -10 ) |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3591 |
{ |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3592 |
$debug[] = 'Setting score to -10 because it went below ('.$score.')'; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3593 |
$score = -10; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3594 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3595 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3596 |
|
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3597 |
return $score; |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3598 |
} |
0ae1b281a884
[sync only] Minor display change in Special:About_Enano; added initial PHP function for password strength testing
Dan
parents:
129
diff
changeset
|
3599 |
|
191
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3600 |
/** |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3601 |
* Registers a task that will be run every X hours. Scheduled tasks should always be scheduled at runtime - they are not stored in the DB. |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3602 |
* @param string Function name to call, or array(object, string method) |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3603 |
* @param int Interval between runs, in hours. Defaults to 24. |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3604 |
*/ |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3605 |
|
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3606 |
function register_cron_task($func, $hour_interval = 24) |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3607 |
{ |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3608 |
global $cron_tasks; |
541
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
3609 |
$hour_interval = strval($hour_interval); |
191
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3610 |
if ( !isset($cron_tasks[$hour_interval]) ) |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3611 |
$cron_tasks[$hour_interval] = array(); |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3612 |
$cron_tasks[$hour_interval][] = $func; |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3613 |
} |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3614 |
|
230
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3615 |
/** |
542
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
3616 |
* Gets the timestamp for the next estimated cron run. |
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
3617 |
* @return int |
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
3618 |
*/ |
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
3619 |
|
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
3620 |
function get_cron_next_run() |
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
3621 |
{ |
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
3622 |
global $cron_tasks; |
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
3623 |
$lowest_ivl = min(array_keys($cron_tasks)); |
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
3624 |
$last_run = intval(getConfig("cron_lastrun_ivl_$lowest_ivl")); |
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
3625 |
return intval($last_run + ( 3600 * $lowest_ivl )) - 30; |
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
3626 |
} |
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
3627 |
|
5841df0ab575
Added ETag support and increased caching settings to try and speed the system up. Result of a YSlow audit.
Dan
parents:
541
diff
changeset
|
3628 |
/** |
209 | 3629 |
* Installs a language. |
3630 |
* @param string The ISO-639-3 identifier for the language. Maximum of 6 characters, usually 3. |
|
3631 |
* @param string The name of the language in English (Spanish) |
|
3632 |
* @param string The name of the language natively (Español) |
|
3633 |
* @param string The path to the file containing the language's strings. Optional. |
|
191
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3634 |
*/ |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3635 |
|
209 | 3636 |
function install_language($lang_code, $lang_name_neutral, $lang_name_local, $lang_file = false) |
191
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3637 |
{ |
209 | 3638 |
global $db, $session, $paths, $template, $plugins; // Common objects |
3639 |
||
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
362
diff
changeset
|
3640 |
$q = $db->sql_query('SELECT 1 FROM '.table_prefix.'language WHERE lang_code = \'' . $db->escape($lang_code) . '\';'); |
209 | 3641 |
if ( !$q ) |
3642 |
$db->_die('functions.php - checking for language existence'); |
|
3643 |
||
3644 |
if ( $db->numrows() > 0 ) |
|
3645 |
// Language already exists |
|
3646 |
return false; |
|
3647 |
||
3648 |
$q = $db->sql_query('INSERT INTO ' . table_prefix . 'language(lang_code, lang_name_default, lang_name_native) |
|
3649 |
VALUES( |
|
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
362
diff
changeset
|
3650 |
\'' . $db->escape($lang_code) . '\', |
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
362
diff
changeset
|
3651 |
\'' . $db->escape($lang_name_neutral) . '\', |
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3652 |
\'' . $db->escape($lang_name_local) . '\' |
209 | 3653 |
);'); |
3654 |
if ( !$q ) |
|
3655 |
$db->_die('functions.php - installing language'); |
|
3656 |
||
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
362
diff
changeset
|
3657 |
if ( ENANO_DBLAYER == 'PGSQL' ) |
241
c671f3bb8aed
Trying to get lang import to work in the installer; it's not working ATM - cache file is generated with lang_id = 0. Syncing to Nighthawk.
Dan
parents:
238
diff
changeset
|
3658 |
{ |
371
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
362
diff
changeset
|
3659 |
// exception for Postgres, which doesn't support insert IDs |
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
362
diff
changeset
|
3660 |
// This will cause the Language class to just load by lang code |
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
362
diff
changeset
|
3661 |
// instead of by numeric ID |
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
362
diff
changeset
|
3662 |
$lang_id = $lang_code; |
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
362
diff
changeset
|
3663 |
} |
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
362
diff
changeset
|
3664 |
else |
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
362
diff
changeset
|
3665 |
{ |
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
362
diff
changeset
|
3666 |
$lang_id = $db->insert_id(); |
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
362
diff
changeset
|
3667 |
if ( empty($lang_id) || $lang_id == 0 ) |
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
362
diff
changeset
|
3668 |
{ |
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
362
diff
changeset
|
3669 |
$db->_die('functions.php - invalid returned lang_id'); |
dc6026376919
Improved compatibility with PostgreSQL and fixed a number of installer bugs; fixed missing "meta" category declaration in language files
Dan
parents:
362
diff
changeset
|
3670 |
} |
241
c671f3bb8aed
Trying to get lang import to work in the installer; it's not working ATM - cache file is generated with lang_id = 0. Syncing to Nighthawk.
Dan
parents:
238
diff
changeset
|
3671 |
} |
209 | 3672 |
|
3673 |
// Do we also need to install a language file? |
|
3674 |
if ( is_string($lang_file) && file_exists($lang_file) ) |
|
3675 |
{ |
|
3676 |
$lang = new Language($lang_id); |
|
3677 |
$lang->import($lang_file); |
|
3678 |
} |
|
3679 |
else if ( is_string($lang_file) && !file_exists($lang_file) ) |
|
3680 |
{ |
|
3681 |
echo '<b>Notice:</b> Can\'t load language file, so the specified language wasn\'t fully installed.<br />'; |
|
3682 |
return false; |
|
3683 |
} |
|
3684 |
return true; |
|
191
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3685 |
} |
3dbe848431b0
Added a cron framework. Currently tasks will not be run; will implement into templates in next commit
Dan
parents:
184
diff
changeset
|
3686 |
|
230
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3687 |
/** |
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3688 |
* Lists available languages. |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3689 |
* @return array Multi-depth. Associative, with children associative containing keys name, name_eng, and dir. |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3690 |
*/ |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3691 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3692 |
function list_available_languages() |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3693 |
{ |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3694 |
// Pulled from install/includes/common.php |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3695 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3696 |
// Build a list of available languages |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3697 |
$dir = @opendir( ENANO_ROOT . '/language' ); |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3698 |
if ( !$dir ) |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3699 |
die('CRITICAL: could not open language directory'); |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3700 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3701 |
$languages = array(); |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3702 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3703 |
while ( $dh = @readdir($dir) ) |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3704 |
{ |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3705 |
if ( $dh == '.' || $dh == '..' ) |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3706 |
continue; |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3707 |
if ( file_exists( ENANO_ROOT . "/language/$dh/meta.json" ) ) |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3708 |
{ |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3709 |
// Found a language directory, determine metadata |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3710 |
$meta = @file_get_contents( ENANO_ROOT . "/language/$dh/meta.json" ); |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3711 |
if ( empty($meta) ) |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3712 |
// Could not read metadata file, continue silently |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3713 |
continue; |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3714 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3715 |
// Do some syntax correction on the metadata |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3716 |
$meta = enano_clean_json($meta); |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3717 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3718 |
$meta = enano_json_decode($meta); |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3719 |
if ( isset($meta['lang_name_english']) && isset($meta['lang_name_native']) && isset($meta['lang_code']) ) |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3720 |
{ |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3721 |
$languages[$meta['lang_code']] = array( |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3722 |
'name' => $meta['lang_name_native'], |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3723 |
'name_eng' => $meta['lang_name_english'], |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3724 |
'dir' => $dh |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3725 |
); |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3726 |
} |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3727 |
} |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3728 |
} |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3729 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3730 |
return $languages; |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3731 |
} |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3732 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
3733 |
/** |
230
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3734 |
* Scales an image to the specified width and height, and writes the output to the specified |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3735 |
* file. Will use ImageMagick if present, but if not will attempt to scale with GD. This will |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3736 |
* always scale images proportionally. |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3737 |
* @param string Path to image file |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3738 |
* @param string Path to output file |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3739 |
* @param int Image width, in pixels |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3740 |
* @param int Image height, in pixels |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3741 |
* @param bool If true, the output file will be deleted if it exists before it is written |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3742 |
* @return bool True on success, false on failure |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3743 |
*/ |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3744 |
|
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3745 |
function scale_image($in_file, $out_file, $width = 225, $height = 225, $unlink = false) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3746 |
{ |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3747 |
global $db, $session, $paths, $template, $plugins; // Common objects |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3748 |
|
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3749 |
if ( !is_int($width) || !is_int($height) ) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3750 |
return false; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3751 |
|
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3752 |
if ( !file_exists($in_file) ) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3753 |
return false; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3754 |
|
720
e2762777b170
Fixed attempt at gzip compression after headers sent; hopefully safely escape args to scale_image() instead of erroring out
Dan
parents:
711
diff
changeset
|
3755 |
$in_file = escapeshellarg($in_file); |
e2762777b170
Fixed attempt at gzip compression after headers sent; hopefully safely escape args to scale_image() instead of erroring out
Dan
parents:
711
diff
changeset
|
3756 |
$out_file = escapeshellarg($out_file); |
230
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3757 |
|
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3758 |
if ( file_exists($out_file) && !$unlink ) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3759 |
return false; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3760 |
else if ( file_exists($out_file) && $unlink ) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3761 |
@unlink($out_file); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3762 |
if ( file_exists($out_file) ) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3763 |
// couldn't unlink (delete) the output file |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3764 |
return false; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3765 |
|
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3766 |
$file_ext = substr($in_file, ( strrpos($in_file, '.') + 1)); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3767 |
switch($file_ext) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3768 |
{ |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3769 |
case 'png': |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3770 |
$func = 'imagecreatefrompng'; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3771 |
break; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3772 |
case 'jpg': |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3773 |
case 'jpeg': |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3774 |
$func = 'imagecreatefromjpeg'; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3775 |
break; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3776 |
case 'gif': |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3777 |
$func = 'imagecreatefromgif'; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3778 |
break; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3779 |
case 'xpm': |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3780 |
$func = 'imagecreatefromxpm'; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3781 |
break; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3782 |
default: |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3783 |
return false; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3784 |
} |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3785 |
|
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3786 |
$magick_path = getConfig('imagemagick_path'); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3787 |
$can_use_magick = ( |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3788 |
getConfig('enable_imagemagick') == '1' && |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3789 |
file_exists($magick_path) && |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3790 |
is_executable($magick_path) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3791 |
); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3792 |
$can_use_gd = ( |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3793 |
function_exists('getimagesize') && |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3794 |
function_exists('imagecreatetruecolor') && |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3795 |
function_exists('imagecopyresampled') && |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3796 |
function_exists($func) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3797 |
); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3798 |
if ( $can_use_magick ) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3799 |
{ |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3800 |
if ( !preg_match('/^([\/A-z0-9_-]+)$/', $magick_path) ) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3801 |
{ |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3802 |
die('SECURITY: ImageMagick path is screwy'); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3803 |
} |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3804 |
$cmdline = "$magick_path \"$in_file\" -resize \"{$width}x{$height}>\" \"$out_file\""; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3805 |
system($cmdline, $return); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3806 |
if ( !file_exists($out_file) ) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3807 |
return false; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3808 |
return true; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3809 |
} |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3810 |
else if ( $can_use_gd ) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3811 |
{ |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3812 |
@list($width_orig, $height_orig) = @getimagesize($in_file); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3813 |
if ( !$width_orig || !$height_orig ) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3814 |
return false; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3815 |
// calculate new width and height |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3816 |
|
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3817 |
$ratio = $width_orig / $height_orig; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3818 |
if ( $ratio > 1 ) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3819 |
{ |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3820 |
// orig. width is greater that height |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3821 |
$new_width = $width; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3822 |
$new_height = round( $width / $ratio ); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3823 |
} |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3824 |
else if ( $ratio < 1 ) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3825 |
{ |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3826 |
// orig. height is greater than width |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3827 |
$new_width = round( $height / $ratio ); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3828 |
$new_height = $height; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3829 |
} |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3830 |
else if ( $ratio == 1 ) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3831 |
{ |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3832 |
$new_width = $width; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3833 |
$new_height = $width; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3834 |
} |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3835 |
if ( $new_width > $width_orig || $new_height > $height_orig ) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3836 |
{ |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3837 |
// Too big for our britches here; set it to only convert the file |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3838 |
$new_width = $width_orig; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3839 |
$new_height = $height_orig; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3840 |
} |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3841 |
|
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3842 |
$newimage = @imagecreatetruecolor($new_width, $new_height); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3843 |
if ( !$newimage ) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3844 |
return false; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3845 |
$oldimage = @$func($in_file); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3846 |
if ( !$oldimage ) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3847 |
return false; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3848 |
|
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3849 |
// Perform scaling |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3850 |
imagecopyresampled($newimage, $oldimage, 0, 0, 0, 0, $new_width, $new_height, $width_orig, $height_orig); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3851 |
|
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3852 |
// Get output format |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3853 |
$out_ext = substr($out_file, ( strrpos($out_file, '.') + 1)); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3854 |
switch($out_ext) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3855 |
{ |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3856 |
case 'png': |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3857 |
$outfunc = 'imagepng'; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3858 |
break; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3859 |
case 'jpg': |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3860 |
case 'jpeg': |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3861 |
$outfunc = 'imagejpeg'; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3862 |
break; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3863 |
case 'gif': |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3864 |
$outfunc = 'imagegif'; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3865 |
break; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3866 |
case 'xpm': |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3867 |
$outfunc = 'imagexpm'; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3868 |
break; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3869 |
default: |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3870 |
imagedestroy($newimage); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3871 |
imagedestroy($oldimage); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3872 |
return false; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3873 |
} |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3874 |
|
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3875 |
// Write output |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3876 |
$outfunc($newimage, $out_file); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3877 |
|
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3878 |
// clean up |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3879 |
imagedestroy($newimage); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3880 |
imagedestroy($oldimage); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3881 |
|
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3882 |
// done! |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3883 |
return true; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3884 |
} |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3885 |
// Neither scaling method worked; we'll let plugins try to scale it, and then if the file still doesn't exist, die |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3886 |
$code = $plugins->setHook('scale_image_failure'); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3887 |
foreach ( $code as $cmd ) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3888 |
{ |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3889 |
eval($cmd); |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3890 |
} |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3891 |
if ( file_exists($out_file) ) |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3892 |
return true; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3893 |
return false; |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3894 |
} |
3daa715e0f69
Alternate scaling using GD is implemented now; images will be scaled with ImageMagick if enabled and working; else, GD will be used. No UI changes to speak of, but a check in the installer will be added in a later commit
Dan
parents:
191
diff
changeset
|
3895 |
|
328
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3896 |
/** |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3897 |
* Determines whether a GIF file is animated or not. Credit goes to ZeBadger from <http://www.php.net/imagecreatefromgif>. |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3898 |
* Modified to conform to Enano coding standards. |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3899 |
* @param string Path to GIF file |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3900 |
* @return bool If animated, returns true |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3901 |
*/ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3902 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3903 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3904 |
function is_gif_animated($filename) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3905 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3906 |
$filecontents = @file_get_contents($filename); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3907 |
if ( empty($filecontents) ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3908 |
return false; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3909 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3910 |
$str_loc = 0; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3911 |
$count = 0; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3912 |
while ( $count < 2 ) // There is no point in continuing after we find a 2nd frame |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3913 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3914 |
$where1 = strpos($filecontents,"\x00\x21\xF9\x04", $str_loc); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3915 |
if ( $where1 === false ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3916 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3917 |
break; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3918 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3919 |
else |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3920 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3921 |
$str_loc = $where1 + 1; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3922 |
$where2 = strpos($filecontents,"\x00\x2C", $str_loc); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3923 |
if ( $where2 === false ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3924 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3925 |
break; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3926 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3927 |
else |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3928 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3929 |
if ( $where1 + 8 == $where2 ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3930 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3931 |
$count++; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3932 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3933 |
$str_loc = $where2 + 1; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3934 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3935 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3936 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3937 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3938 |
return ( $count > 1 ) ? true : false; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3939 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3940 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3941 |
/** |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3942 |
* Retrieves the dimensions of a GIF image. |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3943 |
* @param string The path to the GIF file. |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3944 |
* @return array Key 0 is width, key 1 is height |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3945 |
*/ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3946 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3947 |
function gif_get_dimensions($filename) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3948 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3949 |
$filecontents = @file_get_contents($filename); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3950 |
if ( empty($filecontents) ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3951 |
return false; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3952 |
if ( strlen($filecontents) < 10 ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3953 |
return false; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3954 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3955 |
$width = substr($filecontents, 6, 2); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3956 |
$height = substr($filecontents, 8, 2); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3957 |
$width = unpack('v', $width); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3958 |
$height = unpack('v', $height); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3959 |
return array($width[1], $height[1]); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3960 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3961 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3962 |
/** |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3963 |
* Determines whether a PNG image is animated or not. Based on some specification information from <http://wiki.mozilla.org/APNG_Specification>. |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3964 |
* @param string Path to PNG file. |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3965 |
* @return bool If animated, returns true |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3966 |
*/ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3967 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3968 |
function is_png_animated($filename) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3969 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3970 |
$filecontents = @file_get_contents($filename); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3971 |
if ( empty($filecontents) ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3972 |
return false; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3973 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3974 |
$parsed = parse_png($filecontents); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3975 |
if ( !$parsed ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3976 |
return false; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3977 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3978 |
if ( !isset($parsed['fdAT']) ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3979 |
return false; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3980 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3981 |
if ( count($parsed['fdAT']) > 1 ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3982 |
return true; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3983 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3984 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3985 |
/** |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3986 |
* Gets the dimensions of a PNG image. |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3987 |
* @param string Path to PNG file |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3988 |
* @return array Key 0 is width, key 1 is length. |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3989 |
*/ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3990 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3991 |
function png_get_dimensions($filename) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3992 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3993 |
$filecontents = @file_get_contents($filename); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3994 |
if ( empty($filecontents) ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3995 |
return false; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3996 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3997 |
$parsed = parse_png($filecontents); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3998 |
if ( !$parsed ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
3999 |
return false; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4000 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4001 |
$ihdr_stream = $parsed['IHDR'][0]; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4002 |
$width = substr($ihdr_stream, 0, 4); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4003 |
$height = substr($ihdr_stream, 4, 4); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4004 |
$width = unpack('N', $width); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4005 |
$height = unpack('N', $height); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4006 |
$x = $width[1]; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4007 |
$y = $height[1]; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4008 |
return array($x, $y); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4009 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4010 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4011 |
/** |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4012 |
* Internal function to parse out the streams of a PNG file. Based on the W3 PNG spec: http://www.w3.org/TR/PNG/ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4013 |
* @param string The contents of the PNG |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4014 |
* @return array Associative array containing the streams |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4015 |
*/ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4016 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4017 |
function parse_png($data) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4018 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4019 |
// Trim off first 8 bytes to check for PNG header |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4020 |
$header = substr($data, 0, 8); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4021 |
if ( $header != "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a" ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4022 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4023 |
return false; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4024 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4025 |
$return = array(); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4026 |
$data = substr($data, 8); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4027 |
while ( strlen($data) > 0 ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4028 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4029 |
$chunklen_bin = substr($data, 0, 4); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4030 |
$chunk_type = substr($data, 4, 4); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4031 |
$chunklen = unpack('N', $chunklen_bin); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4032 |
$chunklen = $chunklen[1]; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4033 |
$chunk_data = substr($data, 8, $chunklen); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4034 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4035 |
// If the chunk type is not valid, this may be a malicious PNG with bad offsets. Break out of the loop. |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4036 |
if ( !preg_match('/^[A-z]{4}$/', $chunk_type) ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4037 |
break; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4038 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4039 |
if ( !isset($return[$chunk_type]) ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4040 |
$return[$chunk_type] = array(); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4041 |
$return[$chunk_type][] = $chunk_data; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4042 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4043 |
$offset_next = 4 // Length |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4044 |
+ 4 // Type |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4045 |
+ $chunklen // Data |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4046 |
+ 4; // CRC |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4047 |
$data = substr($data, $offset_next); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4048 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4049 |
return $return; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4050 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4051 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4052 |
/** |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4053 |
* Retreives information about the intrinsic characteristics of the jpeg image, such as Bits per Component, Height and Width. This function is from the PHP JPEG Metadata Toolkit. Licensed under the GPLv2 or later. |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4054 |
* @param array The JPEG header data, as retrieved from the get_jpeg_header_data function |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4055 |
* @return array An array containing the intrinsic JPEG values FALSE - if the comment segment couldnt be found |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4056 |
* @license GNU General Public License |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4057 |
* @copyright Copyright Evan Hunter 2004 |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4058 |
*/ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4059 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4060 |
function get_jpeg_intrinsic_values( $jpeg_header_data ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4061 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4062 |
// Create a blank array for the output |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4063 |
$Outputarray = array( ); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4064 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4065 |
//Cycle through the header segments until Start Of Frame (SOF) is found or we run out of segments |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4066 |
$i = 0; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4067 |
while ( ( $i < count( $jpeg_header_data) ) && ( substr( $jpeg_header_data[$i]['SegName'], 0, 3 ) != "SOF" ) ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4068 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4069 |
$i++; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4070 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4071 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4072 |
// Check if a SOF segment has been found |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4073 |
if ( substr( $jpeg_header_data[$i]['SegName'], 0, 3 ) == "SOF" ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4074 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4075 |
// SOF segment was found, extract the information |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4076 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4077 |
$data = $jpeg_header_data[$i]['SegData']; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4078 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4079 |
// First byte is Bits per component |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4080 |
$Outputarray['Bits per Component'] = ord( $data{0} ); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4081 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4082 |
// Second and third bytes are Image Height |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4083 |
$Outputarray['Image Height'] = ord( $data{ 1 } ) * 256 + ord( $data{ 2 } ); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4084 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4085 |
// Forth and fifth bytes are Image Width |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4086 |
$Outputarray['Image Width'] = ord( $data{ 3 } ) * 256 + ord( $data{ 4 } ); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4087 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4088 |
// Sixth byte is number of components |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4089 |
$numcomponents = ord( $data{ 5 } ); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4090 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4091 |
// Following this is a table containing information about the components |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4092 |
for( $i = 0; $i < $numcomponents; $i++ ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4093 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4094 |
$Outputarray['Components'][] = array ( 'Component Identifier' => ord( $data{ 6 + $i * 3 } ), |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4095 |
'Horizontal Sampling Factor' => ( ord( $data{ 7 + $i * 3 } ) & 0xF0 ) / 16, |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4096 |
'Vertical Sampling Factor' => ( ord( $data{ 7 + $i * 3 } ) & 0x0F ), |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4097 |
'Quantization table destination selector' => ord( $data{ 8 + $i * 3 } ) ); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4098 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4099 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4100 |
else |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4101 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4102 |
// Couldn't find Start Of Frame segment, hence can't retrieve info |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4103 |
return FALSE; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4104 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4105 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4106 |
return $Outputarray; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4107 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4108 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4109 |
/** |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4110 |
* Reads all the JPEG header segments from an JPEG image file into an array. This function is from the PHP JPEG Metadata Toolkit. Licensed under the GPLv2 or later. Modified slightly for Enano coding standards and to remove unneeded capability. |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4111 |
* @param string the filename of the file to JPEG file to read |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4112 |
* @return string Array of JPEG header segments, or FALSE - if headers could not be read |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4113 |
* @license GNU General Public License |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4114 |
* @copyright Copyright Evan Hunter 2004 |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4115 |
*/ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4116 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4117 |
function get_jpeg_header_data( $filename ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4118 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4119 |
// Attempt to open the jpeg file - the at symbol supresses the error message about |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4120 |
// not being able to open files. The file_exists would have been used, but it |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4121 |
// does not work with files fetched over http or ftp. |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4122 |
$filehnd = @fopen($filename, 'rb'); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4123 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4124 |
// Check if the file opened successfully |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4125 |
if ( ! $filehnd ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4126 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4127 |
// Could't open the file - exit |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4128 |
return FALSE; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4129 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4130 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4131 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4132 |
// Read the first two characters |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4133 |
$data = fread( $filehnd, 2 ); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4134 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4135 |
// Check that the first two characters are 0xFF 0xDA (SOI - Start of image) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4136 |
if ( $data != "\xFF\xD8" ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4137 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4138 |
// No SOI (FF D8) at start of file - This probably isn't a JPEG file - close file and return; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4139 |
fclose($filehnd); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4140 |
return FALSE; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4141 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4142 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4143 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4144 |
// Read the third character |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4145 |
$data = fread( $filehnd, 2 ); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4146 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4147 |
// Check that the third character is 0xFF (Start of first segment header) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4148 |
if ( $data{0} != "\xFF" ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4149 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4150 |
// NO FF found - close file and return - JPEG is probably corrupted |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4151 |
fclose($filehnd); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4152 |
return FALSE; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4153 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4154 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4155 |
// Flag that we havent yet hit the compressed image data |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4156 |
$hit_compressed_image_data = FALSE; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4157 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4158 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4159 |
// Cycle through the file until, one of: 1) an EOI (End of image) marker is hit, |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4160 |
// 2) we have hit the compressed image data (no more headers are allowed after data) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4161 |
// 3) or end of file is hit |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4162 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4163 |
while ( ( $data{1} != "\xD9" ) && (! $hit_compressed_image_data) && ( ! feof( $filehnd ) )) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4164 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4165 |
// Found a segment to look at. |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4166 |
// Check that the segment marker is not a Restart marker - restart markers don't have size or data after them |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4167 |
if ( ( ord($data{1}) < 0xD0 ) || ( ord($data{1}) > 0xD7 ) ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4168 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4169 |
// Segment isn't a Restart marker |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4170 |
// Read the next two bytes (size) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4171 |
$sizestr = fread( $filehnd, 2 ); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4172 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4173 |
// convert the size bytes to an integer |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4174 |
$decodedsize = unpack ("nsize", $sizestr); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4175 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4176 |
// Save the start position of the data |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4177 |
$segdatastart = ftell( $filehnd ); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4178 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4179 |
// Read the segment data with length indicated by the previously read size |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4180 |
$segdata = fread( $filehnd, $decodedsize['size'] - 2 ); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4181 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4182 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4183 |
// Store the segment information in the output array |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4184 |
$headerdata[] = array( "SegType" => ord($data{1}), |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4185 |
"SegName" => $GLOBALS[ "JPEG_Segment_Names" ][ ord($data{1}) ], |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4186 |
"SegDataStart" => $segdatastart, |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4187 |
"SegData" => $segdata ); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4188 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4189 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4190 |
// If this is a SOS (Start Of Scan) segment, then there is no more header data - the compressed image data follows |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4191 |
if ( $data{1} == "\xDA" ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4192 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4193 |
// Flag that we have hit the compressed image data - exit loop as no more headers available. |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4194 |
$hit_compressed_image_data = TRUE; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4195 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4196 |
else |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4197 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4198 |
// Not an SOS - Read the next two bytes - should be the segment marker for the next segment |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4199 |
$data = fread( $filehnd, 2 ); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4200 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4201 |
// Check that the first byte of the two is 0xFF as it should be for a marker |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4202 |
if ( $data{0} != "\xFF" ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4203 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4204 |
// NO FF found - close file and return - JPEG is probably corrupted |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4205 |
fclose($filehnd); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4206 |
return FALSE; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4207 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4208 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4209 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4210 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4211 |
// Close File |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4212 |
fclose($filehnd); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4213 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4214 |
// Return the header data retrieved |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4215 |
return $headerdata; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4216 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4217 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4218 |
/** |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4219 |
* Returns the dimensions of a JPEG image in the same format as {php,gif}_get_dimensions(). |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4220 |
* @param string JPEG file to check |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4221 |
* @return array Key 0 is width, key 1 is height |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4222 |
*/ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4223 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4224 |
function jpg_get_dimensions($filename) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4225 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4226 |
if ( !file_exists($filename) ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4227 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4228 |
echo "Doesn't exist<br />"; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4229 |
return false; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4230 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4231 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4232 |
$headers = get_jpeg_header_data($filename); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4233 |
if ( !$headers ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4234 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4235 |
echo "Bad headers<br />"; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4236 |
return false; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4237 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4238 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4239 |
$metadata = get_jpeg_intrinsic_values($headers); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4240 |
if ( !$metadata ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4241 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4242 |
echo "Bad metadata: <pre>" . print_r($metadata, true) . "</pre><br />"; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4243 |
return false; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4244 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4245 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4246 |
if ( !isset($metadata['Image Width']) || !isset($metadata['Image Height']) ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4247 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4248 |
echo "No metadata<br />"; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4249 |
return false; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4250 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4251 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4252 |
return array($metadata['Image Width'], $metadata['Image Height']); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4253 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4254 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4255 |
/** |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4256 |
* Generates a URL for the avatar for the given user ID and avatar type. |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4257 |
* @param int User ID |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4258 |
* @param string Image type - must be one of jpg, png, or gif. |
621
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4259 |
* @param string User's e-mail address, makes Special:Avatar redirect if not specified |
328
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4260 |
* @return string |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4261 |
*/ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4262 |
|
621
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4263 |
function make_avatar_url($user_id, $avi_type, $user_email = false) |
328
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4264 |
{ |
541
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4265 |
static $img_types = array( |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4266 |
'png' => IMAGE_TYPE_PNG, |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4267 |
'gif' => IMAGE_TYPE_GIF, |
621
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4268 |
'jpg' => IMAGE_TYPE_JPG, |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4269 |
'grv' => IMAGE_TYPE_GRV |
541
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4270 |
); |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4271 |
|
328
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4272 |
if ( !is_int($user_id) ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4273 |
return false; |
541
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4274 |
if ( !isset($img_types[$avi_type]) ) |
328
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4275 |
return false; |
621
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4276 |
|
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4277 |
if ( $avi_type == 'grv' ) |
541
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4278 |
{ |
621
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4279 |
if ( $user_email ) |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4280 |
{ |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4281 |
return make_gravatar_url($user_email); |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4282 |
} |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4283 |
} |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4284 |
else |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4285 |
{ |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4286 |
$avi_relative_path = '/' . getConfig('avatar_directory') . '/' . $user_id . '.' . $avi_type; |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4287 |
if ( !file_exists(ENANO_ROOT . $avi_relative_path) ) |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4288 |
{ |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4289 |
return ''; |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4290 |
} |
541
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4291 |
} |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4292 |
|
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4293 |
$img_type = $img_types[$avi_type]; |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4294 |
|
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4295 |
$dateline = @filemtime(ENANO_ROOT . $avi_relative_path); |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4296 |
$avi_id = pack('VVv', $dateline, $user_id, $img_type); |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4297 |
$avi_id = hexencode($avi_id, '', ''); |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4298 |
|
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4299 |
// return scriptPath . $avi_relative_path; |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4300 |
return makeUrlNS('Special', "Avatar/$avi_id"); |
328
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4301 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4302 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4303 |
/** |
621
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4304 |
* Generates a URL to the Gravatar for a user based on his/her e-mail address. |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4305 |
* @param string E-mail address |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4306 |
* @param int Size - defaults to site-wide limits |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4307 |
* @return string URL |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4308 |
*/ |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4309 |
|
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4310 |
function make_gravatar_url($email, $size = false) |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4311 |
{ |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4312 |
$email = md5($email); |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4313 |
|
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4314 |
// gravatar parameters |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4315 |
if ( $size ) |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4316 |
{ |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4317 |
$max_size = intval($size); |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4318 |
} |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4319 |
else |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4320 |
{ |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4321 |
$max_x = intval(getConfig('avatar_max_width', '150')); |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4322 |
$max_y = intval(getConfig('avatar_max_height', '150')); |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4323 |
// ?s= |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4324 |
$max_size = ( $max_x > $max_y ) ? $max_y : $max_x; |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4325 |
} |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4326 |
|
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4327 |
// ?r= |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4328 |
$rating = getConfig('gravatar_rating', 'g'); |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4329 |
|
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4330 |
// final URL |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4331 |
$url = "http://www.gravatar.com/avatar/$email?r=$rating&s=$max_size"; |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4332 |
|
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4333 |
return $url; |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4334 |
} |
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4335 |
|
68f8a9cc0a18
Added Gravatar support! And it's really configurable too.
Dan
parents:
620
diff
changeset
|
4336 |
/** |
328
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4337 |
* Determines an image's filetype based on its signature. |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4338 |
* @param string Path to image file |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4339 |
* @return string One of gif, png, or jpg, or false if none of these. |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4340 |
*/ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4341 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4342 |
function get_image_filetype($filename) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4343 |
{ |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4344 |
$filecontents = @file_get_contents($filename); |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4345 |
if ( empty($filecontents) ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4346 |
return false; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4347 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4348 |
if ( substr($filecontents, 0, 8) == "\x89\x50\x4e\x47\x0d\x0a\x1a\x0a" ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4349 |
return 'png'; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4350 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4351 |
if ( substr($filecontents, 0, 6) == 'GIF87a' || substr($filecontents, 0, 6) == 'GIF89a' ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4352 |
return 'gif'; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4353 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4354 |
if ( substr($filecontents, 0, 2) == "\xFF\xD8" ) |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4355 |
return 'jpg'; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4356 |
|
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4357 |
return false; |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4358 |
} |
dc838fd61a06
Added initial avatar support. Currently rather feature complete except for admin controls for avatar.
Dan
parents:
326
diff
changeset
|
4359 |
|
334
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4360 |
/** |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4361 |
* Generates a JSON encoder/decoder singleton. |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4362 |
* @return object |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4363 |
*/ |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4364 |
|
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4365 |
function enano_json_singleton() |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4366 |
{ |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4367 |
static $json_obj; |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4368 |
if ( !is_object($json_obj) ) |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4369 |
$json_obj = new Services_JSON(SERVICES_JSON_LOOSE_TYPE | SERVICES_JSON_SUPPRESS_ERRORS); |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4370 |
|
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4371 |
return $json_obj; |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4372 |
} |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4373 |
|
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4374 |
/** |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4375 |
* Wrapper for JSON encoding. |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4376 |
* @param mixed Variable to encode |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4377 |
* @return string JSON-encoded string |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4378 |
*/ |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4379 |
|
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4380 |
function enano_json_encode($data) |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4381 |
{ |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4382 |
/* |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4383 |
if ( function_exists('json_encode') ) |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4384 |
{ |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4385 |
// using PHP5 with JSON support |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4386 |
return json_encode($data); |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4387 |
} |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4388 |
*/ |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4389 |
|
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4390 |
return Zend_Json::encode($data, true); |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4391 |
} |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4392 |
|
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4393 |
/** |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4394 |
* Wrapper for JSON decoding. |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4395 |
* @param string JSON-encoded string |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4396 |
* @return mixed Decoded value |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4397 |
*/ |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4398 |
|
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4399 |
function enano_json_decode($data) |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4400 |
{ |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4401 |
/* |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4402 |
if ( function_exists('json_decode') ) |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4403 |
{ |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4404 |
// using PHP5 with JSON support |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4405 |
return json_decode($data); |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4406 |
} |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4407 |
*/ |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4408 |
|
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4409 |
return Zend_Json::decode($data, Zend_Json::TYPE_ARRAY); |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4410 |
} |
c72b545f1304
More localization work. Resolved major issue with JSON parser not parsing files over ~50KB. Switched JSON parser to the one from the Zend Framework (BSD licensed). Forced to split enano.json into five different files.
Dan
parents:
328
diff
changeset
|
4411 |
|
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4412 |
/** |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4413 |
* Cleans a snippet of JSON for closer standards compliance (shuts up the picky Zend parser) |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4414 |
* @param string Dirty JSON |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4415 |
* @return string Clean JSON |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4416 |
*/ |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4417 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4418 |
function enano_clean_json($json) |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4419 |
{ |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4420 |
// eliminate comments |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4421 |
$json = preg_replace(array( |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4422 |
// eliminate single line comments in '// ...' form |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4423 |
'#^\s*//(.+)$#m', |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4424 |
// eliminate multi-line comments in '/* ... */' form, at start of string |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4425 |
'#^\s*/\*(.+)\*/#Us', |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4426 |
// eliminate multi-line comments in '/* ... */' form, at end of string |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4427 |
'#/\*(.+)\*/\s*$#Us' |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4428 |
), '', $json); |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4429 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4430 |
$json = preg_replace('/([,\{\[])([\s]*?)([a-z0-9_]+)([\s]*?):/', '\\1\\2"\\3" :', $json); |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4431 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4432 |
return $json; |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4433 |
} |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4434 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4435 |
/** |
519
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
507
diff
changeset
|
4436 |
* Trims a snippet of text to the first and last curly braces. Useful for JSON. |
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
507
diff
changeset
|
4437 |
* @param string Text to trim |
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
507
diff
changeset
|
4438 |
* @return string |
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
507
diff
changeset
|
4439 |
*/ |
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
507
diff
changeset
|
4440 |
|
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
507
diff
changeset
|
4441 |
function enano_trim_json($json) |
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
507
diff
changeset
|
4442 |
{ |
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
507
diff
changeset
|
4443 |
return preg_replace('/^([^{]+)\{/', '{', preg_replace('/\}([^}]+)$/', '}', $json)); |
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
507
diff
changeset
|
4444 |
} |
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
507
diff
changeset
|
4445 |
|
94214ec0871c
Started work on the new plugin manager and associated management code. Very incomplete at this point and not usable.
Dan
parents:
507
diff
changeset
|
4446 |
/** |
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4447 |
* Starts the profiler. |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4448 |
*/ |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4449 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4450 |
function profiler_start() |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4451 |
{ |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4452 |
global $_profiler; |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4453 |
$_profiler = array(); |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4454 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4455 |
if ( !defined('ENANO_DEBUG') ) |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4456 |
return false; |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4457 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4458 |
$_profiler[] = array( |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4459 |
'point' => 'Profiling started', |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4460 |
'time' => microtime_float(), |
424
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4461 |
'backtrace' => false, |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4462 |
'mem' => false |
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4463 |
); |
424
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4464 |
if ( function_exists('memory_get_usage') ) |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4465 |
{ |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4466 |
$_profiler[ count($_profiler) - 1 ]['mem'] = memory_get_usage(); |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4467 |
} |
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4468 |
} |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4469 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4470 |
/** |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4471 |
* Logs something in the profiler. |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4472 |
* @param string Point name or message |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4473 |
* @param bool Optional. If true (default), a backtrace will be generated and added to the profiler data. False disables this, often for security reasons. |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4474 |
*/ |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4475 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4476 |
function profiler_log($point, $allow_backtrace = true) |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4477 |
{ |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4478 |
if ( !defined('ENANO_DEBUG') ) |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4479 |
return false; |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4480 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4481 |
global $_profiler; |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4482 |
$backtrace = false; |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4483 |
if ( $allow_backtrace && function_exists('debug_print_backtrace') ) |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4484 |
{ |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4485 |
list(, $backtrace) = explode("\n", enano_debug_print_backtrace(true)); |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4486 |
} |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4487 |
$_profiler[] = array( |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4488 |
'point' => $point, |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4489 |
'time' => microtime_float(), |
424
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4490 |
'backtrace' => $backtrace, |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4491 |
'mem' => false |
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4492 |
); |
424
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4493 |
if ( function_exists('memory_get_usage') ) |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4494 |
{ |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4495 |
$_profiler[ count($_profiler) - 1 ]['mem'] = memory_get_usage(); |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4496 |
} |
566
06d241de3151
Made ajaxReset() call the actual requested title instead of effective title; fixed (again) template compiler bug not matching certain tags (probably PCRE bug)
Dan
parents:
562
diff
changeset
|
4497 |
return true; |
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4498 |
} |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4499 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4500 |
/** |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4501 |
* Returns the profiler's data (so far). |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4502 |
* @return array |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4503 |
*/ |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4504 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4505 |
function profiler_dump() |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4506 |
{ |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4507 |
return $GLOBALS['_profiler']; |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4508 |
} |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4509 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4510 |
/** |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4511 |
* Generates an HTML version of the performance profile. Not localized because only used as a debugging tool. |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4512 |
* @return string |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4513 |
*/ |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4514 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4515 |
function profiler_make_html() |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4516 |
{ |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4517 |
if ( !defined('ENANO_DEBUG') ) |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4518 |
return ''; |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4519 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4520 |
$profile = profiler_dump(); |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4521 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4522 |
$html = '<div class="tblholder">'; |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4523 |
$html .= '<table border="0" cellspacing="1" cellpadding="4">'; |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4524 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4525 |
$time_start = $time_last = $profile[0]['time']; |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4526 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4527 |
foreach ( $profile as $i => $entry ) |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4528 |
{ |
592 | 4529 |
// $time_since_last = $entry['time'] - $time_last; |
4530 |
// if ( $time_since_last < 0.01 ) |
|
4531 |
// continue; |
|
4532 |
||
382
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4533 |
$html .= "<!-- ########################################################## -->\n<tr>\n <th colspan=\"2\">Event $i</th>\n</tr>"; |
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4534 |
|
382
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4535 |
$html .= '<tr>' . "\n"; |
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4536 |
$html .= ' <td class="row2">Event:</td>' . "\n"; |
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4537 |
$html .= ' <td class="row1">' . htmlspecialchars($entry['point']) . '</td>' . "\n"; |
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4538 |
$html .= '</tr>' . "\n"; |
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4539 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4540 |
$time = $entry['time'] - $time_start; |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4541 |
|
382
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4542 |
$html .= '<tr>' . "\n"; |
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4543 |
$html .= ' <td class="row2">Time since start:</td>' . "\n"; |
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4544 |
$html .= ' <td class="row1">' . $time . 's</td>' . "\n"; |
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4545 |
$html .= '</tr>' . "\n"; |
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4546 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4547 |
$time = $entry['time'] - $time_last; |
382
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4548 |
if ( $time < 0.0001 ) |
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4549 |
$time = 'Marginal'; |
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4550 |
else |
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4551 |
$time = "{$time}s"; |
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4552 |
|
382
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4553 |
$html .= '<tr>' . "\n"; |
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4554 |
$html .= ' <td class="row2">Time since last event:</td>' . "\n"; |
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4555 |
$html .= ' <td class="row1">' . $time . '</td>' . "\n"; |
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4556 |
$html .= '</tr>' . "\n"; |
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4557 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4558 |
if ( $entry['backtrace'] ) |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4559 |
{ |
382
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4560 |
$html .= '<tr>' . "\n"; |
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4561 |
$html .= ' <td class="row2">Called from:</td>' . "\n"; |
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4562 |
$html .= ' <td class="row1">' . htmlspecialchars($entry['backtrace']) . '</td>' . "\n"; |
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4563 |
$html .= '</tr>' . "\n"; |
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4564 |
} |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4565 |
|
424
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4566 |
if ( $entry['mem'] ) |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4567 |
{ |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4568 |
$html .= '<tr>' . "\n"; |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4569 |
$html .= ' <td class="row2">Total mem usage:</td>' . "\n"; |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4570 |
$html .= ' <td class="row1">' . htmlspecialchars($entry['mem']) . ' (bytes)</td>' . "\n"; |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4571 |
$html .= '</tr>' . "\n"; |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4572 |
} |
f58e0b6e9c22
Some memory usage improvements, I think. PHP is being weird to me.
Dan
parents:
411
diff
changeset
|
4573 |
|
382
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4574 |
$html .= "\n"; |
2ccb55995aef
Profiling enabled for RenderMan's wikiformat routine; [minor] made HTML from profiler more pretty
Dan
parents:
381
diff
changeset
|
4575 |
|
372
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4576 |
$time_last = $entry['time']; |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4577 |
} |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4578 |
$html .= '</table></div>'; |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4579 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4580 |
return $html; |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4581 |
} |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4582 |
|
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4583 |
// Might as well start the profiler, it has no external dependencies except from this file. |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4584 |
profiler_start(); |
5bd429428101
A number of scattered changes. Profiler added and only enabled in debug mode (currently on), but awfully useful for fixing performance in the future. Started work on Admin:LangManager
Dan
parents:
371
diff
changeset
|
4585 |
|
376 | 4586 |
/** |
4587 |
* Returns the number of times a character occurs in a given string. |
|
4588 |
* @param string Haystack |
|
4589 |
* @param string Needle |
|
4590 |
* @return int |
|
4591 |
*/ |
|
4592 |
||
4593 |
function get_char_count($string, $char) |
|
4594 |
{ |
|
4595 |
$char = substr($char, 0, 1); |
|
4596 |
$count = 0; |
|
4597 |
for ( $i = 0; $i < strlen($string); $i++ ) |
|
4598 |
{ |
|
4599 |
if ( $string{$i} == $char ) |
|
4600 |
$count++; |
|
4601 |
} |
|
4602 |
return $count; |
|
4603 |
} |
|
4604 |
||
4605 |
/** |
|
4606 |
* Returns the number of lines in a string. |
|
4607 |
* @param string String to check |
|
4608 |
* @return int |
|
4609 |
*/ |
|
4610 |
||
4611 |
function get_line_count($string) |
|
4612 |
{ |
|
4613 |
return ( get_char_count($string, "\n") ) + 1; |
|
4614 |
} |
|
4615 |
||
481
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4616 |
if ( !function_exists('sys_get_temp_dir') ) |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4617 |
{ |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4618 |
// Based on http://www.phpit.net/ |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4619 |
// article/creating-zip-tar-archives-dynamically-php/2/ |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4620 |
/** |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4621 |
* Attempt to get the system's temp directory. |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4622 |
* @return string or bool false on failure |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4623 |
*/ |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4624 |
|
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4625 |
function sys_get_temp_dir() |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4626 |
{ |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4627 |
// Try to get from environment variable |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4628 |
if ( !empty($_ENV['TMP']) ) |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4629 |
{ |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4630 |
return realpath( $_ENV['TMP'] ); |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4631 |
} |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4632 |
else if ( !empty($_ENV['TMPDIR']) ) |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4633 |
{ |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4634 |
return realpath( $_ENV['TMPDIR'] ); |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4635 |
} |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4636 |
else if ( !empty($_ENV['TEMP']) ) |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4637 |
{ |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4638 |
return realpath( $_ENV['TEMP'] ); |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4639 |
} |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4640 |
|
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4641 |
// Detect by creating a temporary file |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4642 |
else |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4643 |
{ |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4644 |
// Try to use system's temporary directory |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4645 |
// as random name shouldn't exist |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4646 |
$temp_file = tempnam( md5(uniqid(rand(), TRUE)), '' ); |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4647 |
if ( $temp_file ) |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4648 |
{ |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4649 |
$temp_dir = realpath( dirname($temp_file) ); |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4650 |
unlink( $temp_file ); |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4651 |
return $temp_dir; |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4652 |
} |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4653 |
else |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4654 |
{ |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4655 |
return FALSE; |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4656 |
} |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4657 |
} |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4658 |
} |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4659 |
} |
07bf15b066bc
Hopefully completed rewrite and localization of rollback backend and interface
Dan
parents:
479
diff
changeset
|
4660 |
|
541
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4661 |
/** |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4662 |
* Grabs and processes all rank information directly from the database. |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4663 |
*/ |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4664 |
|
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4665 |
function fetch_rank_data() |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4666 |
{ |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4667 |
global $db, $session, $paths, $template, $plugins; // Common objects |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4668 |
global $lang; |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4669 |
|
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4670 |
$sql = $session->generate_rank_sql(); |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4671 |
$q = $db->sql_query($sql); |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4672 |
if ( !$q ) |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4673 |
$db->_die(); |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4674 |
|
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4675 |
$GLOBALS['user_ranks'] = array(); |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4676 |
global $user_ranks; |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4677 |
|
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4678 |
while ( $row = $db->fetchrow($q) ) |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4679 |
{ |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4680 |
$user_id = $row['user_id']; |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4681 |
$username = $row['username']; |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4682 |
$row = $session->calculate_user_rank($row); |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4683 |
$user_ranks[$username] = $row; |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4684 |
$user_ranks[$user_id] =& $user_ranks[$username]; |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4685 |
} |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4686 |
} |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4687 |
|
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4688 |
/** |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4689 |
* Caches the computed user rank information. |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4690 |
*/ |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4691 |
|
573
43e7254afdb4
Renamed some functions (that were new in this release anyway) due to compatibility broken with PunBB bridge
Dan
parents:
566
diff
changeset
|
4692 |
function generate_cache_userranks() |
541
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4693 |
{ |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4694 |
global $db, $session, $paths, $template, $plugins; // Common objects |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4695 |
global $lang; |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4696 |
global $user_ranks; |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4697 |
|
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4698 |
fetch_rank_data(); |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4699 |
|
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4700 |
$user_ranks_stripped = array(); |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4701 |
foreach ( $user_ranks as $key => $value ) |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4702 |
{ |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4703 |
if ( is_int($key) ) |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4704 |
$user_ranks_stripped[$key] = $value; |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4705 |
} |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4706 |
|
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4707 |
$ranks_exported = "<?php\n\n// Automatically generated user rank cache.\nglobal \$user_ranks;\n" . '$user_ranks = ' . $lang->var_export_string($user_ranks_stripped) . ';'; |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4708 |
$uid_map = array(); |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4709 |
foreach ( $user_ranks as $id => $row ) |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4710 |
{ |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4711 |
if ( !is_int($id) ) |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4712 |
{ |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4713 |
$username = $id; |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4714 |
continue; |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4715 |
} |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4716 |
|
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4717 |
$un_san = addslashes($username); |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4718 |
$ranks_exported .= "\n\$user_ranks['$un_san'] =& \$user_ranks[{$row['user_id']}];"; |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4719 |
} |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4720 |
$ranks_exported .= "\n\ndefine('ENANO_RANKS_CACHE_LOADED', 1); \n?>"; |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4721 |
|
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4722 |
// open ranks cache file |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4723 |
$fh = @fopen( ENANO_ROOT . '/cache/cache_ranks.php', 'w' ); |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4724 |
if ( !$fh ) |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4725 |
return false; |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4726 |
fwrite($fh, $ranks_exported); |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4727 |
fclose($fh); |
613 | 4728 |
|
4729 |
return true; |
|
541
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4730 |
} |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4731 |
|
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4732 |
/** |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4733 |
* Loads the rank data, first attempting the cache file and then the database. |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4734 |
*/ |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4735 |
|
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4736 |
function load_rank_data() |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4737 |
{ |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4738 |
if ( file_exists( ENANO_ROOT . '/cache/cache_ranks.php' ) ) |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4739 |
{ |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4740 |
@include(ENANO_ROOT . '/cache/cache_ranks.php'); |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4741 |
} |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4742 |
if ( !defined('ENANO_RANKS_CACHE_LOADED') ) |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4743 |
{ |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4744 |
fetch_rank_data(); |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4745 |
} |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4746 |
} |
acb7e23b6ffa
Massive commit with various changes. Added user ranks system (no admin interface yet) and ability for users to have custom user titles. Made cron framework accept fractions of hours through floating-point intervals. Modifed ACL editor to use miniPrompt framework for close confirmation box. Made avatar system use a special page as opposed to fetching the files directly for caching reasons.
Dan
parents:
536
diff
changeset
|
4747 |
|
599
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4748 |
/** |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4749 |
* Function to purge all caches used in Enano. Useful for upgrades, maintenance, backing the site up, etc. |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4750 |
*/ |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4751 |
|
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4752 |
function purge_all_caches() |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4753 |
{ |
613 | 4754 |
global $cache; |
599
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4755 |
if ( $dh = opendir(ENANO_ROOT . '/cache') ) |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4756 |
{ |
613 | 4757 |
$cache->purge('page_meta'); |
4758 |
$cache->purge('anon_sidebar'); |
|
4759 |
$cache->purge('plugins'); |
|
4760 |
||
599
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4761 |
$data_files = array( |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4762 |
'aes_decrypt.php', |
613 | 4763 |
// ranks cache is stored using a custom engine (not enano's default cache) |
599
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4764 |
'cache_ranks.php' |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4765 |
); |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4766 |
while ( $file = @readdir($dh) ) |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4767 |
{ |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4768 |
$fullpath = ENANO_ROOT . "/cache/$file"; |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4769 |
// we don't want to mess with directories |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4770 |
if ( !is_file($fullpath) ) |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4771 |
continue; |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4772 |
|
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4773 |
// data files |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4774 |
if ( in_array($file, $data_files) ) |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4775 |
unlink($fullpath); |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4776 |
// template files |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4777 |
else if ( preg_match('/\.(?:tpl|css)\.php$/', $file) ) |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4778 |
unlink($fullpath); |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4779 |
// compressed javascript |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4780 |
else if ( preg_match('/^jsres_(?:[A-z0-9_-]+)\.js\.json$/', $file) ) |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4781 |
unlink($fullpath); |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4782 |
// tinymce stuff |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4783 |
else if ( preg_match('/^tiny_mce_(?:[a-f0-9]+)\.gz$/', $file) ) |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4784 |
unlink($fullpath); |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4785 |
// language files |
613 | 4786 |
else if ( preg_match('/^lang_json_(?:[a-f0-9]+?)\.php$/', $file) || preg_match('/^(?:cache_)?lang_(?:[0-9]+?)\.php$/', $file) ) |
599
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4787 |
unlink($fullpath); |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4788 |
} |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4789 |
return true; |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4790 |
} |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4791 |
return false; |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4792 |
} |
52bffa6c499f
Added purge_all_caches() routine to functions.php. Temporary, will be discarded once the new cache code is implemented
Dan
parents:
593
diff
changeset
|
4793 |
|
1 | 4794 |
//die('<pre>Original: 01010101010100101010100101010101011010'."\nProcessed: ".uncompress_bitfield(compress_bitfield('01010101010100101010100101010101011010')).'</pre>'); |
4795 |
||
4796 |
?> |