19 defined(
'XOOPS_ROOT_PATH') or die('Restricted access');
31 $name = strtolower(trim($name));
32 if (!isset($handlers[$name])) {
33 if (file_exists($hnd_file = XOOPS_ROOT_PATH .
'/kernel/' . $name .
'.php')) {
34 require_once $hnd_file;
36 $class =
'Xoops' . ucfirst($name) .
'Handler';
37 if (class_exists($class)) {
39 $handlers[$name] =
new $class(
$xoopsDB);
42 if (!isset($handlers[$name])) {
43 trigger_error(
'Class <strong>' . $class .
'</strong> does not exist<br />Handler Name: ' . $name,
44 $optional ? E_USER_WARNING : E_USER_ERROR);
46 if (isset($handlers[$name])) {
47 return $handlers[$name];
65 if (!isset($module_dir)) {
68 $module_dir =
$GLOBALS[
'xoopsModule']->getVar(
'dirname',
'n');
70 trigger_error(
'No Module is loaded', E_USER_ERROR);
73 $module_dir = trim($module_dir);
75 $name = (!isset($name)) ? $module_dir : trim($name);
76 if (!isset($handlers[$module_dir][$name])) {
77 if (file_exists($hnd_file = XOOPS_ROOT_PATH .
"/modules/{$module_dir}/class/{$name}.php")) {
78 include_once $hnd_file;
80 $class = ucfirst(strtolower($module_dir)) . ucfirst($name) .
'Handler';
81 if (class_exists($class)) {
83 $handlers[$module_dir][$name] =
new $class(
$xoopsDB);
86 if (!isset($handlers[$module_dir][$name])) {
87 trigger_error(
'Handler does not exist<br />Module: ' . $module_dir .
'<br />Name: ' . $name,
88 $optional ? E_USER_WARNING : E_USER_ERROR);
90 if (isset($handlers[$module_dir][$name])) {
91 return $handlers[$module_dir][$name];
108 if (!class_exists(
'XoopsLoad')) {
109 require_once XOOPS_ROOT_PATH .
'/class/xoopsload.php';
131 if ($name ==
'pagetype') {
141 $path = ((empty($domain) ||
'global' == $domain) ?
'' :
"modules/{$domain}/" ) .
'language';
142 if (!file_exists($fileinc =
$GLOBALS[
'xoops']->path(
"{$path}/{$language}/{$name}.php" ))) {
143 if (!file_exists( $fileinc =
$GLOBALS[
'xoops']->path(
"{$path}/english/{$name}.php"))) {
147 $ret = include_once $fileinc;
163 static $modules_active;
164 if (is_array($modules_active)) {
165 return $modules_active;
171 return $modules_active;
189 $modules_active = array();
190 foreach (array_keys($modules_obj) as $key) {
191 $modules_active[] = $modules_obj[$key]->getVar(
'dirname');
195 return $modules_active;
227 if (!headers_sent()) {
228 header(
'Content-Type:text/html; charset=' .
_CHARSET);
229 header(
'Expires: Mon, 26 Jul 1997 05:00:00 GMT');
230 header(
"Last-Modified: " . gmdate(
"D, d M Y H:i:s") .
" GMT");
231 header(
'Cache-Control: no-store, no-cache, max-age=1, s-maxage=1, must-revalidate, post-check=0, pre-check=0');
232 header(
"Pragma: no-cache");
235 echo
"<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n";
236 echo
'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' .
_LANGCODE .
'" lang="' .
_LANGCODE .
'">
238 <meta http-equiv="content-type" content="text/html; charset=' .
_CHARSET .
'" />
239 <meta http-equiv="content-language" content="' .
_LANGCODE .
'" />
240 <meta name="robots" content="' . htmlspecialchars($xoopsConfigMetaFooter[
'meta_robots']) .
'" />
241 <meta name="keywords" content="' . htmlspecialchars($xoopsConfigMetaFooter[
'meta_keywords']) .
'" />
242 <meta name="description" content="' . htmlspecialchars($xoopsConfigMetaFooter[
'meta_desc']) .
'" />
243 <meta name="rating" content="' . htmlspecialchars($xoopsConfigMetaFooter[
'meta_rating']) .
'" />
244 <meta name="author" content="' . htmlspecialchars($xoopsConfigMetaFooter[
'meta_author']) .
'" />
245 <meta name="copyright" content="' . htmlspecialchars($xoopsConfigMetaFooter[
'meta_copyright']) .
'" />
246 <meta name="generator" content="XOOPS" />
247 <title>' . htmlspecialchars($xoopsConfig[
'sitename']) .
'</title>
248 <script type="text/javascript" src="' . XOOPS_URL .
'/include/xoops.js"></script>';
250 echo
'<link rel="stylesheet" type="text/css" media="all" href="' . XOOPS_URL .
'/xoops.css" />';
252 if (file_exists(
$GLOBALS[
'xoops']->path(
'language/' .
$language .
'/style.css'))) {
253 echo
'<link rel="stylesheet" type="text/css" media="all" href="' . XOOPS_URL .
'/language/' .
$language .
'/style.css" />';
256 echo
'<link rel="stylesheet" type="text/css" media="all" href="' . $themecss .
'" />';
259 echo
'</head><body>';
270 echo
'</body></html>';
283 echo
'<div class="errorMsg">';
285 echo
'<strong>' .
$title .
'</strong><br /><br />';
287 if (is_object(
$msg)) {
290 if (is_array(
$msg)) {
291 foreach (
$msg as $key => $value) {
292 if (is_numeric($key)) {
298 echo
"<div>{$msg}</div>";
312 echo
'<div class="resultMsg">';
314 echo
'<strong>' .
$title .
'</strong><br /><br />';
316 if (is_object(
$msg)) {
319 if (is_array(
$msg)) {
320 foreach (
$msg as $key => $value) {
321 if (is_numeric($key)) {
327 echo
"<div>{$msg}</div>";
344 $submit = ($submit !=
'') ? trim($submit) :
_SUBMIT;
345 echo
'<div class="confirmMsg">' .
$msg .
'<br />
346 <form method="post" action="' .
$action .
'">';
347 foreach ($hiddens as $name => $value) {
348 if (is_array($value)) {
349 foreach ($value as $caption => $newvalue) {
350 echo
'<input type="radio" name="' . $name .
'" value="' . htmlspecialchars($newvalue) .
'" /> ' . $caption;
354 echo
'<input type="hidden" name="' . $name .
'" value="' . htmlspecialchars($value) .
'" />';
357 if ($addtoken !=
false) {
358 echo
$GLOBALS[
'xoopsSecurity']->getTokenHTML();
360 echo
'<input type="submit" name="confirm_submit" value="' . $submit .
'" title="' . $submit .
'"/>
361 <input type="button" name="confirm_back" value="' .
_CANCEL .
'" onclick="javascript:history.go(-1);" title="' .
_CANCEL .
'" />
376 if ($timeoffset ==
'') {
378 $timeoffset = $xoopsUser->getVar(
'timezone_offset');
380 $timeoffset = $xoopsConfig[
'default_TZ'];
383 $usertimestamp = intval(
$time) + (floatval($timeoffset) - $xoopsConfig[
'server_TZ']) * 3600;
384 return $usertimestamp;
402 if (!isset($userTZ)) {
403 $userTZ = $xoopsConfig[
'default_TZ'];
405 $timestamp = $timestamp - (($userTZ - $xoopsConfig[
'server_TZ']) * 3600);
417 $syllables = array(
'er',
'in',
'tia',
'wol',
'fe',
'pre',
'vet',
'jo',
'nes',
418 'al',
'len',
'son',
'cha',
'ir',
'ler',
'bo',
'ok',
'tio',
419 'nar',
'sim',
'ple',
'bla',
'ten',
'toe',
'cho',
'co',
'lat',
420 'spe',
'ak',
'er',
'po',
'co',
'lor',
'pen',
'cil',
'li',
'ght',
421 'wh',
'at',
'the',
'he',
'ck',
'is',
'mam',
'bo',
'no',
'fi',
422 've',
'any',
'way',
'pol',
'iti',
'cs',
'ra',
'dio',
'sou',
423 'rce',
'sea',
'rch',
'pa',
'per',
'com',
'bo',
'sp',
'eak',
424 'st',
'fi',
'rst',
'gr',
'oup',
'boy',
'ea',
'gle',
'tr',
425 'ail',
'bi',
'ble',
'brb',
'pri',
'dee',
'kay',
'en',
'be',
'se');
426 srand((
double) microtime() * 1000000);
427 for($count = 1; $count <= 4; $count ++) {
428 if (rand() % 10 == 1) {
429 $makepass .= sprintf(
'%0.0f', (rand() % 50) + 1);
431 $makepass .= sprintf(
'%s', $syllables[rand() % 62]);
446 if (!
$email || !preg_match(
'/^[^@]{1,64}@[^@]{1,255}$/',
$email)) {
449 $email_array = explode(
"@",
$email);
450 $local_array = explode(
".", $email_array[0]);
451 for (
$i = 0;
$i <
sizeof($local_array);
$i++) {
452 if (!preg_match(
"/^(([A-Za-z0-9!#$%&'*+\/\=?^_`{|}~-][A-Za-z0-9!#$%&'*+\/\=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$/", $local_array[
$i])) {
456 if (!preg_match(
"/^\[?[0-9\.]+\]?$/", $email_array[1])) {
457 $domain_array = explode(
".", $email_array[1]);
458 if (
sizeof($domain_array) < 2) {
461 for (
$i = 0;
$i <
sizeof($domain_array);
$i++) {
462 if (!preg_match(
"/^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$/", $domain_array[
$i])) {
484 if ((!preg_match(
'/^http[s]*:\/\//i',
$url))
485 && (!preg_match(
'/^ftp*:\/\//i',
$url))
486 && (!preg_match(
'/^ed2k*:\/\//i',
$url))
502 $bresult =
$db->query(
'SELECT COUNT(*) FROM ' .
$db->prefix(
'banner'));
503 list ($numrows) =
$db->fetchRow($bresult);
505 $numrows = $numrows - 1;
506 mt_srand((
double) microtime() * 1000000);
507 $bannum = mt_rand(0, $numrows);
512 $bresult =
$db->query(
'SELECT * FROM ' .
$db->prefix(
'banner'), 1, $bannum);
513 list ($bid, $cid, $imptotal, $impmade, $clicks, $imageurl, $clickurl,
$date, $htmlbanner, $htmlcode) =
$db->fetchRow($bresult);
514 if ($xoopsConfig[
'my_ip'] ==
xoops_getenv(
'REMOTE_ADDR')) {
517 $impmade = $impmade + 1;
518 $db->queryF(sprintf(
'UPDATE %s SET impmade = %u WHERE bid = %u',
$db->prefix(
'banner'), $impmade, $bid));
522 if ($imptotal > 0 && $impmade >= $imptotal) {
523 $newid =
$db->genId(
$db->prefix(
'bannerfinish') .
'_bid_seq');
524 $sql = sprintf(
'INSERT INTO %s (bid, cid, impressions, clicks, datestart, dateend) VALUES (%u, %u, %u, %u, %u, %u)',
$db->prefix(
'bannerfinish'), $newid, $cid, $impmade, $clicks,
$date, time());
526 $db->queryF(sprintf(
'DELETE FROM %s WHERE bid = %u',
$db->prefix(
'banner'), $bid));
533 $bannerobject = $htmlcode;
535 $bannerobject =
'<div id="xo-bannerfix">';
536 if (stristr($imageurl,
'.swf')) {
537 $bannerobject = $bannerobject
538 .
'<div id ="xo-fixbanner">'
539 .
'<a href="' . XOOPS_URL .
'/banners.php?op=click&bid=' . $bid .
'" rel="external" title="' . $clickurl .
'"></a></div>'
540 .
'<object type="application/x-shockwave-flash" width="468" height="60" data="' . $imageurl .
'" style="z-index:100;">'
541 .
'<param name="movie" value="' . $imageurl .
'" />'
542 .
'<param name="wmode" value="opaque" />'
546 $bannerobject = $bannerobject .
'<a href="' . XOOPS_URL .
'/banners.php?op=click&bid=' . $bid .
'" rel="external" title="' . $clickurl .
'"><img src="' . $imageurl .
'" alt="' . $clickurl .
'" /></a>';
549 $bannerobject = $bannerobject .
'</div>';
551 return $bannerobject;
563 $xoopsPreload->triggerEvent(
'core.include.functions.redirectheader', array(
$url,
$time, $message, $addredirect, $allowExternalLink));
565 if (preg_match(
"/[\\0-\\31]|about:|script:/i",
$url)) {
566 if (!preg_match(
'/^\b(java)?script:([\s]*)history\.go\(-[0-9]*\)([\s]*[;]*[\s]*)$/si',
$url)) {
570 if (!$allowExternalLink &&
$pos = strpos(
$url,
'://')) {
571 $xoopsLocation = substr(XOOPS_URL, strpos(XOOPS_URL,
'://') + 3);
572 if (strcasecmp(substr(
$url,
$pos + 3, strlen($xoopsLocation)), $xoopsLocation)) {
576 if (defined(
'XOOPS_CPFUNC_LOADED')) {
579 $theme = $xoopsConfig[
'theme_set'];
582 require_once XOOPS_ROOT_PATH .
'/class/template.php';
583 require_once XOOPS_ROOT_PATH .
'/class/theme.php';
589 "plugins" => array(),
"renderBanner" =>
false));
592 'xoops_theme' => $theme ,
595 'xoops_requesturi' => htmlspecialchars(
$_SERVER[
'REQUEST_URI'], ENT_QUOTES) ,
596 'xoops_sitename' => htmlspecialchars($xoopsConfig[
'sitename'], ENT_QUOTES) ,
597 'xoops_slogan' => htmlspecialchars($xoopsConfig[
'slogan'], ENT_QUOTES) ,
600 if ($xoopsConfig[
'debug_mode'] == 2 && $xoopsUserIsAdmin) {
602 $xoopsTpl->assign(
'xoops_logdump', $xoopsLogger->dump());
606 if (!empty(
$_SERVER[
'REQUEST_URI']) && $addredirect && strstr(
$url,
'user.php')) {
607 if (!strstr(
$url,
'?')) {
608 $url .=
'?xoops_redirect=' . urlencode(
$_SERVER[
'REQUEST_URI']);
610 $url .=
'&xoops_redirect=' . urlencode(
$_SERVER[
'REQUEST_URI']);
613 if (defined(
'SID')&& SID && (!isset($_COOKIE[session_name()]) || ($xoopsConfig[
'use_mysession'] && $xoopsConfig[
'session_name'] !=
'' && !isset($_COOKIE[$xoopsConfig[
'session_name']])))) {
614 if (!strstr(
$url,
'?')) {
617 $url .=
'&' . SID;
620 $url = preg_replace(
"/&/i",
'&', htmlspecialchars(
$url, ENT_QUOTES));
622 $message = trim($message) !=
'' ? $message :
_TAKINGBACK;
626 $xoopsTpl->display(
'db:system_redirect.html');
643 if (array_key_exists($key, $_ENV) && isset($_ENV[$key])) {
656 $theme =
$GLOBALS[
'xoopsConfig'][
'theme_set'];
659 if (stristr($uagent,
'mac')) {
660 $str_css =
'styleMAC.css';
661 } elseif (preg_match(
"/MSIE ([0-9]\.[0-9]{1,2})/i", $uagent)) {
662 $str_css =
'style.css';
664 $str_css =
'styleNN.css';
676 } elseif (file_exists(
XOOPS_THEME_PATH .
'/' . $theme .
'/css/style.css')) {
692 if (is_object($mailer)) {
695 include_once XOOPS_ROOT_PATH .
'/class/xoopsmailer.php';
696 if (file_exists(
$file = XOOPS_ROOT_PATH .
'/language/' . $xoopsConfig[
'language'] .
'/xoopsmailerlocal.php')) {
698 }
else if (file_exists(
$file = XOOPS_ROOT_PATH .
'/language/english/xoopsmailerlocal.php')) {
702 if (class_exists(
'XoopsMailerLocal')) {
721 $rank_id = intval($rank_id);
722 $posts = intval($posts);
724 $sql =
"SELECT rank_title AS title, rank_image AS image FROM " .
$db->prefix(
'ranks') .
" WHERE rank_id = " . $rank_id;
726 $sql =
"SELECT rank_title AS title, rank_image AS image FROM " .
$db->prefix(
'ranks') .
" WHERE rank_min <= " . $posts .
" AND rank_max >= " . $posts .
" AND rank_special = 0";
729 $rank[
'title'] =
$myts->htmlspecialchars($rank[
'title']);
730 $rank[
'id'] = $rank_id;
795 if (isset($item_id)) {
810 if (intval(
$module_id) > 0 && intval($item_id) > 0) {
815 $deleted_num = array();
816 for(
$i = 0;
$i < $count;
$i++) {
820 if ($poster_id != 0) {
821 $deleted_num[$poster_id] = !isset($deleted_num[$poster_id]) ? 1 : ($deleted_num[$poster_id] + 1);
826 foreach ($deleted_num as
$user_id => $post_num) {
829 if (is_object($com_poster)) {
830 $member_handler->updateUserByField($com_poster,
'posts', $com_poster->getVar(
'posts') - $post_num);
908 if (isset(
$GLOBALS[
'xoopsOption'][$option])) {
928 static $coreOptions = array();
930 if (is_array($coreOptions) && array_key_exists($option, $coreOptions)) {
931 return $coreOptions[$option];
941 $coreOptions[$option] =
$ret;
957 if (isset(
$GLOBALS[
'xoopsConfig'][$option]) && !is_null($new)) {
958 $GLOBALS[
'xoopsConfig'][$option] = $new;
977 static $modOptions = array();
978 if (is_array($modOptions) && array_key_exists($option, $modOptions)) {
979 return $modOptions[$option];
988 if (isset($moduleConfig[$option])) {
989 $ret = $moduleConfig[$option];
992 $modOptions[$option] =
$ret;
1014 'biz',
'com',
'edu',
'gov',
'info',
'int',
'mil',
'name',
'net',
'org',
'aero',
'asia',
'cat',
'coop',
'jobs',
'mobi',
'museum',
'pro',
'tel',
'travel',
1015 'arpa',
'root',
'berlin',
'bzh',
'cym',
'gal',
'geo',
'kid',
'kids',
'lat',
'mail',
'nyc',
'post',
'sco',
'web',
'xxx',
1016 'nato',
'example',
'invalid',
'localhost',
'test',
'bitnet',
'csnet',
'ip',
'local',
'onion',
'uucp',
'co');
1021 'ac',
'ad',
'ae',
'af',
'ag',
'ai',
'al',
'am',
'an',
'ao',
'aq',
'ar',
'as',
'at',
'au',
'aw',
'ax',
'az',
1022 'ba',
'bb',
'bd',
'be',
'bf',
'bg',
'bh',
'bi',
'bj',
'bm',
'bn',
'bo',
'br',
'bs',
'bt',
'bw',
'by',
'bz',
1023 'ca',
'cc',
'cd',
'cf',
'cg',
'ch',
'ci',
'ck',
'cl',
'cm',
'cn',
'co',
'cr',
'cu',
'cv',
'cx',
'cy',
'cz',
1024 'de',
'dj',
'dk',
'dm',
'do',
'dz',
'ec',
'ee',
'eg',
'er',
'es',
'et',
'eu',
'fi',
'fj',
'fk',
'fm',
'fo',
1025 'fr',
'ga',
'gd',
'ge',
'gf',
'gg',
'gh',
'gi',
'gl',
'gm',
'gn',
'gp',
'gq',
'gr',
'gs',
'gt',
'gu',
'gw',
1026 'gy',
'hk',
'hm',
'hn',
'hr',
'ht',
'hu',
'id',
'ie',
'il',
'im',
'in',
'io',
'iq',
'ir',
'is',
'it',
'je',
1027 'jm',
'jo',
'jp',
'ke',
'kg',
'kh',
'ki',
'km',
'kn',
'kr',
'kw',
'ky',
'kz',
'la',
'lb',
'lc',
'li',
'lk',
1028 'lr',
'ls',
'lt',
'lu',
'lv',
'ly',
'ma',
'mc',
'md',
'mg',
'mh',
'mk',
'ml',
'mm',
'mn',
'mo',
'mp',
'mq',
1029 'mr',
'ms',
'mt',
'mu',
'mv',
'mw',
'mx',
'my',
'mz',
'na',
'nc',
'ne',
'nf',
'ng',
'ni',
'nl',
'no',
'np',
1030 'nr',
'nu',
'nz',
'om',
'pa',
'pe',
'pf',
'pg',
'ph',
'pk',
'pl',
'pn',
'pr',
'ps',
'pt',
'pw',
'py',
'qa',
1031 're',
'ro',
'ru',
'rw',
'sa',
'sb',
'sc',
'sd',
'se',
'sg',
'sh',
'si',
'sk',
'sl',
'sm',
'sn',
'sr',
'st',
1032 'sv',
'sy',
'sz',
'tc',
'td',
'tf',
'tg',
'th',
'tj',
'tk',
'tl',
'tm',
'tn',
'to',
'tr',
'tt',
'tv',
'tw',
1033 'tz',
'ua',
'ug',
'uk',
'us',
'uy',
'uz',
'va',
'vc',
've',
'vg',
'vi',
'vn',
'vu',
'wf',
'ws',
'ye',
'yu',
1036 'eh',
'kp',
'me',
'rs',
'um',
'bv',
'gb',
'pm',
'sj',
'so',
'yt',
'su',
'tp',
'bu',
'cs',
'dd',
'zr');
1040 return $base_domain;
1044 $DOMAIN = explode(
'.', $full_domain);
1048 $DOMAIN = array_reverse($DOMAIN);
1053 if (count($DOMAIN) == 4 && is_numeric($DOMAIN[0]) && is_numeric($DOMAIN[3])) {
1054 return $full_domain;
1058 if (count($DOMAIN) <= 2) {
1059 return $full_domain;
1068 if (in_array($DOMAIN[0], $C_TLD) && in_array($DOMAIN[1], $G_TLD) && $DOMAIN[2] !=
'www') {
1069 $full_domain = $DOMAIN[2] .
'.' . $DOMAIN[1] .
'.' . $DOMAIN[0];
1071 $full_domain = $DOMAIN[1] .
'.' . $DOMAIN[0];
1074 return $full_domain;
1090 $_URL = parse_url(
$url);
1092 if (!empty($_URL) || !empty($_URL[
'host'])) {
1093 $domain = $_URL[
'host'];