Dragonfly CMS logo Server sponsored and hosted by
DedicatedNOW
CVS logo  
.:: Home :: Dev. Resources :: Forums ::.
Dragonfly CMS CVS Repository
 Location: / cvs / html / includes / cmsinit.inc
This is a web interface to the Dragonfly CMS CVS tree. You can browse the file hierarchy by picking directories. If you pick a file, you will see the revision history for that file.
Selecting a revision number will show that revision of the file. There are links at each revision to display diffs, annotate and download.
Note: Info about CVS and our commits can be found at our CVS Info Forum
File name: html/includes/cmsinit.inc
Revision : 8.1 (9 years 6 months 3 weeks 2 days 10 hours 49 minutes 32 seconds ago) by djmaze
Changed : +11 -2 lines
Comment: Added htmlunprepare function (mainly used in BB)


# Author Rev Line
1 djmaze 1.1 <?php
2 djmaze 1.1 /*********************************************
3 djmaze 1.1 CPG-NUKE: Advanced Content Management System
4 djmaze 1.1 ********************************************
5 djmaze 1.1 Copyright (c) 2004 by CPG-Nuke Dev Team
6 djmaze 1.1 http://www.cpgnuke.com
7 djmaze 1.1  
8 djmaze 1.1 CPG-Nuke is released under the terms and conditions
9 djmaze 1.16 of the CPG Open Source License Agreement version 1
10 djmaze 1.1  
11 djmaze 1.17 $Source: /cvs/html/includes/cmsinit.inc,v $
12 djmaze 8.1 $Revision: 8.0 $
13 djmaze 1.52 $Author: djmaze $
14 djmaze 8.1 $Date: 2004/09/30 10:34:46 $
15 djmaze 1.1  
16 djmaze 1.16 ***********************************************************************/
17 djmaze 1.22 // Disable DOS Attacks
18 djmaze 1.22 if (($_SERVER['HTTP_USER_AGENT'] == '' || $_SERVER['HTTP_USER_AGENT'] == '-') && !defined('XMLFEED')) {
19 djmaze 1.22 exit;
20 djmaze 1.22 }
21 djmaze 1.48 set_magic_quotes_runtime(0); // Disable magic_quotes_runtime
22 djmaze 1.22  
23 djmaze 1.37 // Import GET/POST/Cookie variables into the global scope
24 djmaze 1.37 //if (!ini_get("register_globals")) {
25 djmaze 1.37 if (intval(ini_get('register_globals')) == 0) {
26 djmaze 1.37 // import_request_variables('GPC');
27 djmaze 1.37 } else {
28 djmaze 1.37 // since IIS can't turn off register_globals as Apache thru .ht* we destroy them here
29 djmaze 1.37 foreach ($_REQUEST AS $key => $val) {
30 djmaze 1.44 // $temp = $_REQUEST[$key];
31 djmaze 1.37 if (isset($$key)) unset($$key);
32 djmaze 1.44 // $_REQUEST[$key] = $temp;
33 djmaze 1.37 }
34 djmaze 1.37 }
35 djmaze 1.41 if (get_magic_quotes_gpc() || ini_get('magic_quotes_sybase')) {
36 djmaze 1.42 if (is_array($_GET)) foreach ($_GET AS $k => $v) {
37 djmaze 1.42 $_GET[$k] = stripslashes($v);
38 djmaze 1.42 $_REQUEST[$k] =& $_GET[$k];
39 djmaze 1.42 }
40 djmaze 1.42 if (is_array($_POST)) foreach ($_POST AS $k => $v) {
41 djmaze 1.42 if (is_array($_POST[$k])) foreach ($_POST[$k] AS $k2 => $v2) {
42 djmaze 1.42 $_POST[$k][$k2] = stripslashes($v2);
43 djmaze 1.42 $_REQUEST[$k][$k2] =& $_POST[$k][$k2];
44 djmaze 1.42 } else {
45 djmaze 1.42 $_POST[$k] = stripslashes($v);
46 djmaze 1.42 $_REQUEST[$k] =& $_POST[$k];
47 djmaze 1.42 }
48 djmaze 1.41 }
49 djmaze 1.48 @ini_set('magic_quotes_sybase', 0);
50 djmaze 1.41 }
51 djmaze 1.37  
52 djmaze 1.20 // we define our own error handler
53 djmaze 1.23 require_once('includes/classes/cpg_debugger.php');
54 djmaze 1.1  
55 djmaze 1.22 $phpver = explode('.', phpversion());
56 djmaze 1.22 $phpver = "$phpver[0]$phpver[1]";
57 djmaze 1.1  
58 djmaze 1.1 // Compress output if server/php config allows
59 djmaze 1.1 $do_gzip_compress = false;
60 djmaze 1.1 $do_zlib_compress = false;
61 djmaze 1.30 $gzipsupport = extension_loaded('zlib');
62 djmaze 1.30 if ($gzipsupport) {
63 djmaze 1.1 if (isset($_SERVER['HTTP_ACCEPT_ENCODING']) && eregi('gzip', $_SERVER['HTTP_ACCEPT_ENCODING'])) {
64 djmaze 1.1 if ($phpver >= 43) { // PHP 4.2.x seems to give memleak
65 djmaze 1.1 ob_start('ob_gzhandler');
66 djmaze 1.30 } else {
67 djmaze 1.1 $do_gzip_compress = true;
68 djmaze 1.1 ob_start();
69 djmaze 1.1 ob_implicit_flush(0);
70 djmaze 1.1 header('Content-Encoding: gzip');
71 djmaze 1.1 }
72 djmaze 1.1 } else {
73 djmaze 1.1 // Some stupid firewalls don't send the HTTP_ACCEPT_ENCODING
74 djmaze 1.1 // So we still compress in memory for fast page generations
75 djmaze 1.1 // But it will take longer for the visitor to see the page.
76 djmaze 1.1 $do_zlib_compress = true;
77 djmaze 1.1 ob_start();
78 djmaze 1.1 ob_implicit_flush(0);
79 djmaze 1.1 }
80 djmaze 1.1 }
81 djmaze 1.1  
82 djmaze 1.1 if ($phpver >= 41) {
83 djmaze 1.1 $PHP_SELF = $_SERVER['PHP_SELF'];
84 djmaze 1.1 }
85 djmaze 1.37  
86 djmaze 1.1 // unset any vars set from globals
87 djmaze 1.1 $phpEx = 'php';
88 djmaze 1.19 $pagetitle = $modheader = $adminmenuitems = $adminmail = '';
89 djmaze 1.1 $showblocks = 1;
90 djmaze 1.1 // useless vars but still here to prevent "notice" messages
91 djmaze 1.1 $user = $admin = $cookie = '';
92 djmaze 1.1  
93 djmaze 1.1 if (!isset($file)) $file = NULL;
94 djmaze 1.1 if (!isset($name)) $name = NULL;
95 djmaze 1.1  
96 djmaze 1.1 list($usec, $sec) = explode(' ', microtime());
97 djmaze 1.1 $start_time = ($usec + $sec);
98 djmaze 1.1 if (!defined('CPG_NUKE')) define('CPG_NUKE', true);
99 djmaze 1.1  
100 trevor 1.8 // stops the page creation and shows an error page
101 djmaze 1.1 function nuke_error($message, $title='ERROR', $redirect='') {
102 djmaze 1.1 cpg_error($message, $title, $redirect);
103 djmaze 1.1 }
104 djmaze 1.1 function cpg_error($message, $title='ERROR', $redirect='') {
105 djmaze 1.1 global $userinfo, $SESS;
106 djmaze 1.1 if ($redirect) { header('Refresh: 3; url='.$redirect); }
107 djmaze 1.44 if (defined('THEME_USES_TPL') || defined('HEADER_OPEN')) {
108 djmaze 1.1 global $pagetitle, $showblocks, $home;
109 djmaze 1.1 $home = $showblocks = 0;
110 djmaze 1.1 $pagetitle = $title;
111 djmaze 1.1 require_once('header.php');
112 djmaze 1.1 OpenTable();
113 akamu 1.28 echo '<center>'.$message.'<br /><br />';
114 djmaze 1.44 $link = ($redirect!='') ? '<a href="'.$redirect.'">'._GO.'</a>' : _GOBACK;
115 akamu 1.28 echo $link.'</center>';
116 djmaze 1.1 CloseTable();
117 djmaze 1.1 require_once('footer.php');
118 djmaze 1.1 } else {
119 djmaze 1.1 require_once('includes/cpg_page.php');
120 djmaze 1.1 $errorpage = cpg_header($title);
121 djmaze 1.1 $errorpage .= "<center>$message</center>";
122 djmaze 1.1 $errorpage .= cpg_footer();
123 djmaze 1.1 if (isset($SESS)) $SESS->write_close();
124 djmaze 1.1 die($errorpage);
125 djmaze 1.1 }
126 djmaze 1.1 }
127 djmaze 1.1  
128 djmaze 1.1 // include database connection, sql abstraction layer and globally used functions
129 djmaze 1.1 require_once('config.php');
130 djmaze 1.1 require_once('db/db.php');
131 djmaze 1.1 require_once('includes/classes/session.php');
132 djmaze 1.1 require_once('includes/functions/display.php');
133 djmaze 1.1 require_once('includes/functions/linking.php');
134 djmaze 1.1 require_once('includes/classes/template.php');
135 djmaze 1.1 require_once('includes/classes/cpg_member.php');
136 djmaze 1.1 if (defined('INSTALL')) return;
137 djmaze 1.1  
138 djmaze 1.4 if (!load_cfg('MAIN_CFG')) {
139 djmaze 1.49 $result = $db->sql_query('SELECT * FROM '.$prefix.'_config_custom', true);
140 trevor 1.50 if (!$result) {
141 djmaze 1.1 url_redirect('install.php');
142 djmaze 1.1 }
143 djmaze 1.1 while ($row = $db->sql_fetchrow($result)) {
144 djmaze 1.1 $MAIN_CFG[$row['cfg_name']][$row['cfg_field']] = $row['cfg_value'];
145 djmaze 1.1 }
146 djmaze 1.1 save_cfg('MAIN_CFG');
147 djmaze 1.1 $db->sql_freeresult($result);
148 djmaze 1.4 }
149 djmaze 1.48 if ($_SERVER['HTTP_HOST'] == 'localhost' || $_SERVER['HTTP_HOST'] == '127.0.0.1') $MAIN_CFG['cookie']['domain'] = '';
150 djmaze 1.48  
151 djmaze 1.5 if (substr($MAIN_CFG['server']['path'], -1) != '/') $MAIN_CFG['server']['path'] .= '/';
152 djmaze 1.5 if ($MAIN_CFG['server']['path'][0] != '/') $MAIN_CFG['server']['path'] = '/'.$MAIN_CFG['server']['path'];
153 djmaze 1.34 if (substr($MAIN_CFG['cookie']['path'], -1) != '/') $MAIN_CFG['cookie']['path'] .= '/';
154 djmaze 1.34 if ($MAIN_CFG['cookie']['path'][0] != '/') $MAIN_CFG['cookie']['path'] = '/'.$MAIN_CFG['cookie']['path'];
155 djmaze 1.34 if (!extension_loaded('gd')) { $MAIN_CFG['global']['gfx_chk'] = 0; }
156 djmaze 1.34 $MAIN_CFG['global']['nukeurl'] = 'http://'.$MAIN_CFG['server']['domain'].substr($MAIN_CFG['server']['path'], 0, -1);
157 djmaze 1.49 if (empty($MAIN_CFG['cookie']['member'])) $MAIN_CFG['cookie']['member'] = 'member';
158 djmaze 1.49 if (empty($MAIN_CFG['cookie']['admin'])) $MAIN_CFG['cookie']['admin'] = 'admin';
159 djmaze 1.52 $BASEHREF = ($_SERVER['SERVER_PORT'] != 443 ? 'http' : 'https') . '://';
160 djmaze 1.52 $BASEHREF .= (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $MAIN_CFG['server']['domain']);
161 djmaze 1.52 $BASEHREF .= $MAIN_CFG['server']['path'];
162 djmaze 1.1 if ($phpver >= 43) { // version_compare()
163 djmaze 1.1 extract($MAIN_CFG['global'], EXTR_OVERWRITE | EXTR_REFS);
164 djmaze 1.1 } else {
165 djmaze 1.1 extract($MAIN_CFG['global'], EXTR_OVERWRITE);
166 djmaze 1.1 }
167 djmaze 1.1  
168 djmaze 1.1 if (defined('XMLFEED')) return; // no need to load everything if it's a feed
169 djmaze 1.1  
170 djmaze 1.6 global $CPG_SESS;
171 djmaze 1.6 $SESS =& new cpg_session();
172 djmaze 1.25 if (isset($_GET['name']) && ($_GET['name'] == 'gfx' || (isset($_GET['op']) && $_GET['name'] == 'Your_Account' && $_GET['op'] == 'gfx'))) {
173 djmaze 1.1 require('includes/gfxchk.php');
174 djmaze 1.1 }
175 djmaze 1.1 //$SESS = new cpg_session($dbonly, $name, $time);
176 djmaze 1.1 //register_shutdown_function(array(&$SESS, "write_close"));
177 djmaze 1.18 $CLASS['member'] =& new cpg_member();
178 djmaze 1.1 $userinfo =& $CLASS['member']->members[$CLASS['member']->user_id];
179 djmaze 1.1 $nukeuser =& $CLASS['member']->cookie;
180 djmaze 1.18 if ($CLASS['member']->loadadmin()) {
181 djmaze 1.1 foreach($CLASS['member']->admin as $var => $val) {
182 djmaze 1.4 if (ereg('radmin',$var)) { $$var =& $val; }
183 djmaze 1.1 }
184 djmaze 1.25 // $MAIN_CFG['debug']['error_level'] = E_WARNING | E_NOTICE | E_USER_WARNING | E_USER_NOTICE;
185 djmaze 1.26 } else {
186 djmaze 1.26 if (!CPG_DEBUG) { $cpgdebugger->stop(); }
187 djmaze 1.23 error_reporting(0);
188 djmaze 1.1 }
189 trevor 1.50 if ($MAIN_CFG['global']['maintenance'] && !is_admin() && !defined('ADMIN_PAGES') && !defined('INSTALL')) {
190 trevor 1.12 cpg_error('<strong>'.$MAIN_CFG['global']['maintenance_text'].'</strong>', 'Maintenance');
191 djmaze 1.1 }
192 djmaze 1.1 $SESS->init_info();
193 djmaze 1.1 /************************************************************************************/
194 djmaze 1.3 /* Include language to detect languages from browser setting and user preferences */
195 djmaze 1.1 /* Join the nuke language initiative (NLI) http://cpgnuke.com */
196 djmaze 1.1 /************************************************************************************/
197 djmaze 1.1 require_once('includes/functions/language.php');
198 djmaze 1.1  
199 djmaze 1.1 // Load cache handler
200 djmaze 1.1 if (isset($MAIN_CFG['cache']['handler'])) {
201 djmaze 1.1 // mmcache.php
202 djmaze 1.1 }
203 djmaze 1.1  
204 djmaze 1.3 /************************************************************************************/
205 djmaze 1.7 /* Load the theme template system and check if the current theme uses the system */
206 djmaze 1.7 /************************************************************************************/
207 djmaze 1.7 $ThemeSel = get_theme();
208 djmaze 1.7 define('THEME_USES_TPL', file_exists('themes/'.$ThemeSel.'/template/header.html'));
209 djmaze 1.7 // Load template handler
210 djmaze 1.7 $cpgtpl =& new cpg_template();
211 djmaze 1.7 $cpgtpl->set_template(); // dynamic language
212 djmaze 1.7 //$cpgtpl->set_template(true); // static language
213 djmaze 1.7 //$cpgtpl->cachepath = '';
214 djmaze 1.7 if (THEME_USES_TPL) { $template =& $cpgtpl; }
215 djmaze 1.7  
216 djmaze 1.7 header('Content-Type: text/html; charset='._CHARSET);
217 djmaze 1.7 header('Content-language: ' . get_langcode($currentlang, 1));
218 djmaze 1.7 // standard privacy header change to yours
219 djmaze 1.7 header('P3P: CP="CAO DSP COR CURa ADMa DEVa OUR IND PHY ONL UNI COM NAV INT DEM PRE"');
220 djmaze 1.7 //header("P3P: CP=\"ALL DSP COR NID CURa OUR STP PUR\"");
221 djmaze 1.7 // Notify server time
222 djmaze 1.7 header('Date: '.date('D, d M Y H:i:s', gmtime()).' GMT');
223 djmaze 1.39 define('USERS', 'YToxOntzOjQ6Im51a2UiO3M6MjU3OiIkY29wcGVybWluZT0iVGhpcyB3ZWJzaXRlIGVuZ2luZSBDb3B5cmlnaHQgJmNvcHk7ICIuZGF0ZSgnWScpLiIgYnkgQ1BHLU51a2UgRGV2IFRlYW08YnIgLz5GcmVlIFNvZnR3YXJlIHJlbGVhc2VkIHVuZGVy'
224 djmaze 1.39 .'IHRoZSA8YSBocmVmPVwiaHR0cDovL3d3dy5jcGdudWtlLmNvbS9PU0xBLmh0bWxcIiB0YXJnZXQ9XCJfbmV3XCI+Q1BHIE9wZW4gU291cmNlIExpY2Vuc2UgQWdyZWVtZW50PC9hPiwgbm8gd2FycmFudHkgaXMgZ2l2ZW4gb3IgaW1wbGllZC4iOyI7fQ==', true);
225 djmaze 1.7 ini_set('sendmail_from', $adminmail);
226 djmaze 1.7  
227 djmaze 1.7 /************************************************************************************/
228 djmaze 1.3 /* Check if the <form> POST is comming from this server */
229 djmaze 1.3 /************************************************************************************/
230 djmaze 1.3 if ($_SERVER['REQUEST_METHOD'] == 'POST') {
231 djmaze 1.3 if (!isset($CPG_SESS['user']['uri']) || empty($CPG_SESS['user']['uri'])) {
232 akamu 1.40 die('Please enable cookies to post on this site. If you feel you have reached this message in error please refresh the preceding page once and post again');
233 djmaze 1.3 }
234 djmaze 1.3 }
235 djmaze 1.3  
236 djmaze 1.1 // Function which removes \015\012 which causes linebreaks in SMTP email
237 djmaze 1.1 function removecrlf($str) {
238 djmaze 1.1 return strtr($str, "\015\012", ' ');
239 djmaze 1.1 }
240 djmaze 1.1 /***********************************************************************************
241 djmaze 1.1  
242 djmaze 1.1 bool send_mail(&$mailer_message, $message, $html=0, $subject="", $to="", $to_name="", $from="",$from_name="" )
243 djmaze 1.1  
244 djmaze 1.1 Sends a email thru PHP or SMTP using plain text or html formatted
245 djmaze 1.1 $mailer_message: returns info about the send mail or the error message
246 djmaze 1.1 $message : the message that you want to send
247 djmaze 1.1 $html : send message as html or text 1 = html, 0 = text(default)
248 djmaze 1.1 $subject : the subject of the message, default = _FEEDBACK
249 djmaze 1.1 $to : emailaddress of person to send to, default = admin mailaddress
250 djmaze 1.1 $to_name : name of person to send to, default = sitename
251 djmaze 1.1 $from : emailaddress of person who sends the message, default = admin mailaddress
252 djmaze 1.1 $from_name: name of person who sends the message, default = sitename
253 djmaze 1.1  
254 djmaze 1.1 ************************************************************************************/
255 djmaze 1.1 function send_mail(&$mailer_message, $message, $html=0, $subject='', $to='', $to_name='', $from='', $from_name='') {
256 djmaze 1.29 global $MAIN_CFG, $module_name, $PHPMAILER_LANG, $CLASS;
257 alexm 1.14  
258 djmaze 1.1 if ($module_name != 'Contact' && function_exists('get_lang')) {
259 djmaze 1.1 get_lang('Contact');
260 djmaze 1.1 }
261 djmaze 1.7 if ($to == '') $to = $MAIN_CFG['global']['adminmail'];
262 djmaze 1.17 if ($from == '') $from = $MAIN_CFG['global']['adminmail'];
263 djmaze 1.29 if (isset($CLASS['member']) && $CLASS['member']->demo && $to != $MAIN_CFG['global']['adminmail']) {
264 djmaze 1.29 $mailer_message = 'Emailing in Admin demo mode not allowed';
265 djmaze 1.29 return false;
266 djmaze 1.29 }
267 djmaze 1.17 if (is_email($from) < 1) {
268 djmaze 1.17 $mailer_message = $PHPMAILER_LANG['from_failed'].$from;
269 djmaze 1.17 return false;
270 djmaze 1.17 }
271 djmaze 1.17 if (is_email($to) < 1) {
272 djmaze 1.17 $mailer_message = $PHPMAILER_LANG['recipients_failed'].$to;
273 djmaze 1.17 return false;
274 djmaze 1.17 }
275 djmaze 1.17  
276 djmaze 1.1 require_once('includes/classes/phpmailer.php');
277 djmaze 1.30 $CLASS['mail']->ClearAll();
278 djmaze 1.30 // $CLASS['mail'] = new PHPMailer();
279 djmaze 1.30 $CLASS['mail']->SetLanguage();
280 djmaze 1.1 if ($MAIN_CFG['email']['smtp_on']) {
281 djmaze 1.30 $CLASS['mail']->IsSMTP(); // set mailer to use SMTP
282 djmaze 1.30 $CLASS['mail']->Host = $MAIN_CFG['email']['smtphost'];
283 djmaze 1.1 if ($MAIN_CFG['email']['smtp_auth']) {
284 djmaze 1.30 $CLASS['mail']->SMTPAuth = true; // turn on SMTP authentication
285 djmaze 1.30 $CLASS['mail']->Username = $MAIN_CFG['email']['smtp_uname']; // SMTP username
286 djmaze 1.30 $CLASS['mail']->Password = $MAIN_CFG['email']['smtp_pass']; // SMTP password
287 djmaze 1.1 }
288 djmaze 1.1 } else {
289 djmaze 1.30 $CLASS['mail']->IsMail();
290 djmaze 1.1 }
291 djmaze 1.30 $CLASS['mail']->From = removecrlf($from);
292 djmaze 1.30 $CLASS['mail']->FromName = ($from_name!='') ? removecrlf($from_name) : $MAIN_CFG['global']['sitename'];
293 djmaze 1.1 if ($to_name != ''){
294 djmaze 1.30 $CLASS['mail']->AddAddress(removecrlf($to), removecrlf($to_name));
295 djmaze 1.1 } else {
296 djmaze 1.30 $CLASS['mail']->AddAddress(removecrlf($to));
297 djmaze 1.1 }
298 djmaze 1.30 $CLASS['mail']->Priority = 3;
299 djmaze 1.30 $CLASS['mail']->Encoding = '8bit';
300 djmaze 1.30 $CLASS['mail']->CharSet = _CHARSET;
301 djmaze 1.30 $CLASS['mail']->Subject = ($subject!='') ? removecrlf($subject) : _FEEDBACK;
302 djmaze 1.1 if ($MAIN_CFG['email']['allow_html_email'] && $html) {
303 djmaze 1.1 require_once('includes/nbbcode.php');
304 djmaze 1.1 $message = decode_bbcode($message);
305 djmaze 1.30 $CLASS['mail']->IsHTML(true);
306 djmaze 1.30 $CLASS['mail']->AltBody = strip_tags($message);
307 djmaze 1.30 $CLASS['mail']->Body = $message;
308 djmaze 1.1 } else {
309 djmaze 1.30 $CLASS['mail']->IsHTML(false);
310 djmaze 1.30 $CLASS['mail']->Body = strip_tags($message);
311 djmaze 1.1 }
312 djmaze 1.1 $mailer_message ='';
313 djmaze 1.31 if (!$CLASS['mail']->Send()) {
314 djmaze 1.1 $mailer_message .= 'Message could not be sent.<p>';
315 djmaze 1.32 $mailer_message .= 'Mailer Error: ' . $CLASS['mail']->ErrorInfo;
316 djmaze 1.1 return false;
317 djmaze 1.1 } else {
318 djmaze 1.1 $mailer_message .= '<p align="center">'._SUCCESS_MESSAGE_SENT.'<br />';
319 djmaze 1.1 $mailer_message .= "<code>$message</code><br />";
320 djmaze 1.1 $mailer_message .= '<p align="center">'._MAHALO.'</center></p>';
321 djmaze 1.1 return true;
322 djmaze 1.1 }
323 djmaze 1.1 //return $mailer_message;
324 djmaze 1.1 }
325 djmaze 1.1  
326 djmaze 1.1 /***********************************************************************************
327 djmaze 1.1 Returns if the emailaddress is valid or not
328 djmaze 1.1 ************************************************************************************/
329 djmaze 1.1 function is_email(&$email) {
330 djmaze 1.10 global $DeniedEmailDomains;
331 djmaze 1.1 if (strlen($email) < 5) return 0;
332 djmaze 1.1 $email = strtolower($email);
333 djmaze 1.43 if (!ereg('^[_\.\+0-9a-z-]+@[0-9a-z-]+\.+[a-z]{2,6}$',$email) &&
334 djmaze 1.43 !ereg('^[_\.\+0-9a-z-]+@[_0-9a-z-]+\.+[_0-9a-z-]+\.+[a-z]{2,6}$',$email)) {
335 djmaze 1.47 // "#\[email\]([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si"
336 djmaze 1.1 return -1;
337 djmaze 1.1 }
338 djmaze 1.1 $email = explode('@', $email);
339 djmaze 1.10 $DeniedEmailDomains[] = 'mydomain.com';
340 djmaze 1.10 $domains = implode('|', $DeniedEmailDomains);
341 djmaze 1.10 if (eregi("($domains)", $email[1])) {
342 djmaze 1.1 return -2;
343 djmaze 1.1 }
344 djmaze 1.1 $email = implode('@', $email);
345 djmaze 1.1 return 1;
346 djmaze 1.1 }
347 djmaze 1.1  
348 djmaze 1.1 /***********************************************************************************
349 djmaze 1.1 Returns admin name if the user is an administrator, otherwise false
350 djmaze 1.1 ************************************************************************************/
351 djmaze 1.1 function is_admin() {
352 djmaze 1.1 global $CLASS;
353 djmaze 1.1 return is_object($CLASS['member']) ? $CLASS['member']->admin_id : false;
354 djmaze 1.1 }
355 djmaze 1.1 function can_admin($module='') {
356 djmaze 1.7 global $CLASS;
357 djmaze 1.7 $adminfo =& $CLASS['member']->admin;
358 djmaze 1.1 return is_array($adminfo) ? ($adminfo['radminsuper'] || (isset($adminfo['radmin'.$module]) ? $adminfo['radmin'.$module] : false)) : false;
359 djmaze 1.1 }
360 djmaze 1.1 /***********************************************************************************
361 djmaze 1.1 Returns member ID if the user is an registered member, otherwise false
362 djmaze 1.1 ************************************************************************************/
363 djmaze 1.1 function is_user() {
364 djmaze 1.1 global $CLASS;
365 djmaze 1.1 return ($CLASS['member']->user_id > 1) ? $CLASS['member']->user_id : false;
366 djmaze 1.1 }
367 djmaze 1.1 /***********************************************************************************
368 djmaze 1.36 Returns groupname if visitor is in the group, otherwise false
369 djmaze 1.1 ************************************************************************************/
370 djmaze 1.36 function in_group($id) {
371 djmaze 1.1 global $userinfo;
372 djmaze 1.36 if (isset($userinfo['_mem_of_groups'][$id])) {
373 djmaze 1.36 return $userinfo['_mem_of_groups'][$id];
374 djmaze 1.36 } else {
375 djmaze 1.36 return false;
376 djmaze 1.36 }
377 djmaze 1.1 }
378 djmaze 1.1 /***********************************************************************************
379 djmaze 1.1 See includes/classes/cpg_member -> getmemdata() for details
380 djmaze 1.1 ************************************************************************************/
381 djmaze 1.1 function getusrdata($user, $data='*') {
382 djmaze 1.1 global $CLASS;
383 djmaze 1.1 return $CLASS['member']->getmemdata($user, $data);
384 djmaze 1.1 }
385 djmaze 1.1 /***********************************************************************************
386 djmaze 1.1  
387 djmaze 1.1 bool is_active($module)
388 djmaze 1.1  
389 djmaze 1.1 Checks if the module with 'modulename' is active
390 djmaze 1.1 $module: the name of the module which you wanna check; example: 'Your_Account'
391 djmaze 1.1  
392 djmaze 1.1 ************************************************************************************/
393 djmaze 1.1 function is_active($module) {
394 djmaze 1.27 global $prefix, $db, $active_modules;
395 djmaze 1.1 static $save; // Added by steven111
396 djmaze 1.1 if (is_array($save)) {
397 djmaze 1.1 if (isset($save[$module])) return ($save[$module]);
398 djmaze 1.1 return 0;
399 djmaze 1.1 }
400 djmaze 1.27 if (!load_cfg('active_modules')) {
401 djmaze 1.27 $result = $db->sql_query('SELECT title FROM '.$prefix.'_modules WHERE active=1');
402 djmaze 1.27 while ($row = $db->sql_fetchrow($result)) {
403 djmaze 1.27 $active_modules[$row[0]] = 1;
404 djmaze 1.27 }
405 djmaze 1.27 $db->sql_freeresult($result);
406 djmaze 1.27 save_cfg('active_modules');
407 djmaze 1.1 }
408 djmaze 1.27 $save = $active_modules;
409 djmaze 1.1 if (isset($save[$module])) return ($save[$module]);
410 djmaze 1.1 return 0;
411 djmaze 1.1 }
412 djmaze 1.46  
413 djmaze 1.46 function htmlprepare($str, $nl2br=false, $spchar=ENT_QUOTES, $nohtml=false) {
414 djmaze 1.46 if ($nohtml) { $str = strip_tags($str, $nohtml); } // $nohtml : <a><br><b><i><img><li><ol><p><strong><th><u><ul>
415 djmaze 1.49 $str = htmlspecialchars($str,$spchar,'UTF-8'); // htmlentities sucks cos it converts all chars
416 djmaze 1.46 if ($nl2br) { $str = nl2br($str); }
417 djmaze 1.46 return trim($str);
418 djmaze 1.46 }
419 djmaze 8.1 function htmlunprepare($str, $nl2br=false) {
420 djmaze 8.1 $unhtml_specialchars_match = array('#&gt;#', '#&lt;#', '#&quot;#', '#&\#039;#', '#&amp;#');
421 djmaze 8.1 $unhtml_specialchars_replace = array('>', '<', '"', '\'', '&');
422 djmaze 8.1 if ($nl2br) {
423 djmaze 8.1 $unhtml_specialchars_match[] = '#<br />#';
424 djmaze 8.1 $unhtml_specialchars_replace[] = "\n";
425 djmaze 8.1 }
426 djmaze 8.1 return preg_replace($unhtml_specialchars_match, $unhtml_specialchars_replace, $str);
427 djmaze 8.1 }
428 djmaze 1.47 function html2bb($text) {
429 djmaze 1.48 $text = ereg_replace('<', ' <', $text);
430 djmaze 1.47 $text = preg_replace('/<ol type="([a1])">/si', '/\[list=\\1\]', $text);
431 djmaze 1.47 $text = preg_replace('/<(b|u|i|hr)>/sie', "'['.strtolower(\\1).']'", $text);
432 djmaze 1.47 $text = preg_replace('/<\/(b|u|i|hr)>/sie', "'[/'.strtolower(\\1).']'", $text);
433 djmaze 1.47 $text = str_replace('<ul>', '[list]', $text);
434 djmaze 1.47 $text = str_replace('<li>', '[*]', $text);
435 djmaze 1.47 $text = str_replace('</ul>', '[/list:u]', $text);
436 djmaze 1.47 $text = str_replace('</ol>', '[/list:o]', $text);
437 djmaze 1.47 $text = strip_tags($text, '<br><img><p><strong>');
438 djmaze 1.47 return trim($text);
439 djmaze 1.47 }
440 djmaze 1.1 /***********************************************************************************
441 djmaze 1.1  
442 djmaze 1.1 string Fix_Quotes(&$str, $nohtml=0)
443 djmaze 1.1  
444 djmaze 1.1 Adds slashes to string and strips PHP+HTML for SQL insertion and hack prevention
445 djmaze 1.1 $str : the string to modify
446 djmaze 1.1 $nohtml: strip PHP+HTML tags, 0 = no, 1 = yes, default = 0
447 djmaze 1.1  
448 djmaze 1.1 ************************************************************************************/
449 djmaze 1.45 function Fix_Quotes($str, $nohtml=false, $spchar=false) {
450 djmaze 1.1 global $db;
451 djmaze 1.1 if ($nohtml) { $str = strip_tags($str); }
452 djmaze 1.1 if ($spchar) { $str = htmlspecialchars($str,ENT_NOQUOTES,'UTF-8'); }
453 djmaze 1.46 return $db->sql_escape_string(trim($str));
454 djmaze 1.1 }
455 djmaze 1.1  
456 djmaze 1.1 /*********************************************************/
457 djmaze 1.1 /* text filterering */
458 djmaze 1.1 /*********************************************************/
459 djmaze 1.1  
460 djmaze 1.1 function check_words(&$Message) {
461 djmaze 1.1 global $CensorList, $CensorReplace, $CensorMode;
462 djmaze 1.1 if ($CensorMode != 0) {
463 djmaze 1.1 if (is_array($CensorList)) {
464 djmaze 1.1 if ($CensorMode == 1) {
465 djmaze 1.1 for ($i = 0; $i < count($CensorList); $i++) {
466 djmaze 1.1 $Message = eregi_replace("$CensorList[$i]([^a-zA-Z0-9])","$CensorReplace\\1",$Message);
467 djmaze 1.1 }
468 djmaze 1.1 } elseif ($CensorMode == 2) {
469 djmaze 1.1 for ($i = 0; $i < count($CensorList); $i++) {
470 djmaze 1.1 $Message = eregi_replace("(^|[^[:alnum:]])$CensorList[$i]","\\1$CensorReplace",$Message);
471 djmaze 1.1 }
472 djmaze 1.1 } elseif ($CensorMode == 3) {
473 djmaze 1.1 for ($i = 0; $i < count($CensorList); $i++) {
474 djmaze 1.1 $Message = eregi_replace($CensorList[$i],$CensorReplace,$Message);
475 djmaze 1.1 }
476 djmaze 1.1 }
477 djmaze 1.1 }
478 djmaze 1.1 }
479 djmaze 1.1 return $Message;
480 djmaze 1.1 }
481 djmaze 1.1  
482 djmaze 1.36 /*********************************************************/
483 djmaze 1.36 /* Old PHP-Nuke function to stay compatible */
484 djmaze 1.36 /*********************************************************/
485 djmaze 1.36  
486 djmaze 1.36 function cookiedecode() {
487 djmaze 1.36 trigger_error('Please replace your call to cookiedecode() and use the global $userinfo', E_USER_WARNING);
488 djmaze 1.36 global $nukeuser;
489 djmaze 1.36 return $nukeuser;
490 djmaze 1.36 }
491 djmaze 1.36 function getusrinfo() {
492 djmaze 1.36 trigger_error('Please replace your call to getusrinfo() and use the global $userinfo', E_USER_WARNING);
493 djmaze 1.36 global $userinfo;
494 djmaze 1.36 return $userinfo;
495 djmaze 1.36 }
496 djmaze 1.36 function FixQuotes($what = "") {
497 djmaze 1.36 trigger_error('Please replace your call FixQuotes() to Fix_Quotes()', E_USER_WARNING);
498 djmaze 1.36 $what = ereg_replace("'","''",$what);
499 djmaze 1.36 while (eregi("\\\\'", $what)) {
500 djmaze 1.36 $what = ereg_replace("\\\\'","'",$what);
501 djmaze 1.1 }
502 djmaze 1.36 return $what;
503 djmaze 1.1 }
504 djmaze 1.36 function formatTimestamp($time) {
505 djmaze 1.36 trigger_error('Please replace your call formatTimestamp() to formatDateTime()', E_USER_WARNING);
506 djmaze 1.36 return formatDateTime($time, _DATESTRING);
507 djmaze 1.1 }
508 djmaze 1.36 function check_html($str, $strip='') {
509 djmaze 1.36 trigger_error('Please replace your call check_html() to Fix_Quotes()', E_USER_WARNING);
510 djmaze 1.36 return Fix_Quotes($str, empty($strip));
511 djmaze 1.1 }
512 djmaze 1.1 function filter_text($Message, $strip="") {
513 djmaze 1.36 trigger_error('Please replace your call filter_text() to check_words()', E_USER_WARNING);
514 djmaze 1.36 return check_words($Message);
515 djmaze 1.36 }
516 djmaze 1.36 function delQuotes($string){
517 djmaze 1.36 trigger_error('Please remove your call to delQuotes it is obsolete', E_USER_WARNING);
518 djmaze 1.36 return $string;
519 djmaze 1.36 }
520 djmaze 1.36 function is_group() {
521 djmaze 1.36 trigger_error('is_group() not used by CPG-Nuke', E_USER_NOTICE);
522 djmaze 1.36 // Function does not exist; here for compatibility with PHP-Nuke 7 modules
523 djmaze 1.36 }
524 djmaze 1.36 function update_points() {
525 djmaze 1.36 trigger_error('update_points() not used by CPG-Nuke', E_USER_NOTICE);
526 djmaze 1.36 // Function does not exist; here for compatibility with PHP-Nuke 7 modules
527 djmaze 1.36 }
528 djmaze 1.36 function formatAidHeader($aid) {
529 djmaze 1.36 trigger_error('formatAidHeader() useless in CPG-Nuke', E_USER_NOTICE);
530 djmaze 1.36 echo $aid;
531 djmaze 1.36 }
532 djmaze 1.36 function get_author($aid) {
533 djmaze 1.36 trigger_error('get_author() useless in CPG-Nuke', E_USER_NOTICE);
534 djmaze 1.36 return $aid;
535 djmaze 1.1 }
536 djmaze 1.1  
537 djmaze 1.1 /*********************************************************/
538 djmaze 1.1 /* Time formatting */
539 djmaze 1.1 /*********************************************************/
540 djmaze 1.1  
541 djmaze 1.1 function gmtime() {
542 djmaze 1.1 static $time;
543 djmaze 1.1 if (!$time) { $time = (time() - date('Z')); }
544 djmaze 1.1 return $time;
545 djmaze 1.1 }
546 djmaze 1.1 function formatDateTime($time, $format) {
547 djmaze 1.38 global $userinfo;
548 djmaze 1.1 if (!is_numeric($time)) {
549 djmaze 1.1 ereg('([0-9]{4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})', $time, $datetime);
550 djmaze 1.1 $time = mktime($datetime[4],$datetime[5],$datetime[6],$datetime[2],$datetime[3],$datetime[1]);
551 djmaze 1.1 }
552 djmaze 1.1 if (is_user() && intval($userinfo['user_timezone']) != 0) {
553 djmaze 1.49 $time += (3600*intval($userinfo['user_timezone']));
554 djmaze 1.1 }
555 djmaze 1.38 // return utf8_encode(ucfirst(strftime($format, $time)));
556 djmaze 1.38 return ucfirst(strftime($format, $time));
557 djmaze 1.1 }
558 djmaze 1.1  
559 djmaze 1.1 function encode_ip($dotquad_ip) {
560 djmaze 1.1 $ip_sep = explode('.', $dotquad_ip);
561 djmaze 1.1 return (count($ip_sep) == 4) ? sprintf('%02x%02x%02x%02x', $ip_sep[0], $ip_sep[1], $ip_sep[2], $ip_sep[3]) : '';
562 djmaze 1.1 }
563 djmaze 1.1 function decode_ip($int_ip) {
564 djmaze 1.1 $hexipbang = explode('.', chunk_split($int_ip, 2, '.'));
565 djmaze 1.1 return hexdec($hexipbang[0]). '.' . hexdec($hexipbang[1]) . '.' . hexdec($hexipbang[2]) . '.' . hexdec($hexipbang[3]);
566 djmaze 1.1 }
567 djmaze 1.1  
568 djmaze 1.1 function save_cfg($name) {
569 djmaze 1.1 $cache_dir = 'cache';
570 djmaze 1.1 $filename = $cache_dir."/config_$name.php";
571 djmaze 1.1 if (is_dir($cache_dir) && is_writable($cache_dir)) {
572 djmaze 1.1 if ($fp = @fopen($filename, 'wb')) {
573 djmaze 1.1 @flock($fp, LOCK_EX);
574 djmaze 1.1 $data = "<?php\nif (!defined('CPG_NUKE')) { header('Location: index.php'); exit; }\n";
575 djmaze 1.1 global $$name;
576 djmaze 1.1 $config =& $$name;
577 djmaze 1.1 if (is_array($config)) {
578 djmaze 1.1 @reset($config);
579 djmaze 1.1 while (list($key, $value) = @each($config) ) {
580 djmaze 1.1 if (is_array($value)) {
581 djmaze 1.1 while (list($subkey, $subvalue) = @each($value) ) {
582 djmaze 1.1 $data .= '$'.$name.'[\''.$key.'\'][\''.$subkey.'\'] = \''.ereg_replace('\'', '\\\'', trim($subvalue))."';\n";
583 djmaze 1.1 }
584 djmaze 1.1 } else {
585 djmaze 1.1 $data .= '$'.$name.'[\''.$key.'\'] = \''.trim($value).'\';'."\n";
586 djmaze 1.1 }
587 djmaze 1.1 }
588 djmaze 1.1 }
589 djmaze 1.1 @fwrite ($fp, $data.'?>');
590 djmaze 1.1 @flock($fp, LOCK_UN);
591 djmaze 1.1 @fclose($fp);
592 djmaze 1.1 @umask(0);
593 djmaze 1.1 }
594 djmaze 1.1 }
595 djmaze 1.1 }
596 djmaze 1.1 function load_cfg($name) {
597 djmaze 1.1 global $$name;
598 djmaze 1.1 if (file_exists("cache/config_$name.php")) {
599 djmaze 1.1 include("cache/config_$name.php");
600 djmaze 1.1 return true;
601 djmaze 1.1 } else {
602 djmaze 1.1 return false;
603 djmaze 1.1 }
604 djmaze 1.1 }
605 djmaze 1.1 function delete_cfg($name) {
606 djmaze 1.1 $cache_dir = 'cache';
607 djmaze 1.1 $filename = $cache_dir."/config_$name.php";
608 djmaze 1.1 if (is_dir($cache_dir) && is_writable($cache_dir)) {
609 djmaze 1.1 if (file_exists($filename)) {
610 djmaze 1.1 @unlink($filename);
611 djmaze 1.1 }
612 djmaze 1.1 }
613 djmaze 1.51 }


Code Credits - Privacy Policy