function generate_link($link = false, $link_options = false) { global $_CLASS, $_CORE_CONFIG; //static $SEO = array('?', '&', '&'); $options = array('admin' => false, 'full' => false, 'sid' => true, 'force_sid' => false, 'seo' => true); if (is_array($link_options)) { $options = array_merge($options, $link_options); } $options['seo'] = $options['force_sid'] ? true : $_CORE_CONFIG['global']['link_optimization'] && $options['seo']; if ($options['admin']) { $options['seo'] = false; } if ($link && strpos($link, '#')) { list($link, $what_you_call_this) = explode('#', $link, 2); } else { /* No really, I want to know what you call that */ $what_you_call_this = false; } $file = $options['admin'] ? ADMIN_PAGE : INDEX_PAGE; if (!$link) { if ($options['sid'] && $_CLASS['core_user']->need_sid) { $options['seo'] = $options['force_sid'] = false; $link = $file . '?' . $_CLASS['core_user']->sid_link; } else { $link = $options['seo'] ? 'index' : $file; } } else { if ($options['sid'] && $_CLASS['core_user']->need_sid) { $link .= '&' . $_CLASS['core_user']->sid_link; } if ($link[0] === '&') { $link = $_CLASS['core_display']->page['page_name'] . $link; } if (!$options['seo']) { $link = $file . '?mod=' . $link; } else { $link = str_replace(array('?', '&', '&'), '/', $link); } } if ($what_you_call_this) { $link .= $options['seo'] ? '.html#' . $what_you_call_this : '#' . $what_you_call_this; } elseif ($options['seo']) { $link .= '.html'; } return $options['full'] ? generate_base_url() . $link : $link; }
$GDok = TRUE; // ------------ config section -------------------- $IMGFOLDER_name = 'images/'; $path_to_drupal_root = '../../../../../../../../../'; $url_prefix = 'drupal/'; $VIDEOICON = 'video.jpg'; $AUDIOICON = 'audio.jpg'; // language setting en $LARGEIMG = 'Large image'; $DELETEIMG = 'Delete image'; $INSERTIMG = 'Insert image into HTML'; $UPLOADIMG = 'Upload'; $HELPSTR = 'Click a image!'; // ------------------------------------------------- $IMGFOLDER = $path_to_drupal_root . $IMGFOLDER_name; $IMGURL = generate_base_url() . $url_prefix . $IMGFOLDER_name; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" /> </head> <body> <?php function make_thumb($img_name, $filename, $new_w, $new_h) { $fsize = filesize($img_name); if (!$fsize) { return; } if ($fsize > 100000) {
function generate_link($link = false, $link_options = false) { global $_CLASS, $_CORE_MODULE; $options = array('admin' => false, 'full' => false, 'sid' => true, 'force_sid' => false); if (is_array($link_options)) { $options = array_merge($options, $link_options); } if ($link && strpos($link, '#')) { list($link, $what_you_call_this) = explode('#', $link, 2); } else { $what_you_call_this = false; } $file = $options['admin'] ? ADMIN_PAGE : INDEX_PAGE; if (!$link) { $link = $file; if ($options['force_sid'] || $options['sid'] && $_CLASS['core_user']->sid_link) { $link .= '?' . $_CLASS['core_user']->sid_link; } } else { if ($link[0] == '&') { $link = $_CORE_MODULE['name'] . $link; } $link = $file . '?mod=' . $link; if ($options['force_sid'] || $options['sid'] && $_CLASS['core_user']->sid_link) { $link .= '&' . $_CLASS['core_user']->sid_link; } } if ($what_you_call_this) { $link .= '#' . $what_you_call_this; } return $options['full'] ? generate_base_url() . $link : $link; }
function magic_url() { static $match; static $replace; if (!is_array($match)) { $match = $replace = array(); // Be sure to not let the matches cross over. ;) // relative urls for this board $match[] = '#(^|[\\n ]|\\()(' . preg_quote(preg_replace('/^\\/?(.*?)(\\/)?$/', '$1', generate_base_url()), '#') . ')/(.*?([^ \\t\\n\\r<"\'\\)]*)?)#i'; $replace[] = '$1<!-- l --><a href="$2/$3">$3</a><!-- l -->'; // matches a xxxx://aaaaa.bbb.cccc. ... $match[] = '#(^|[\\n ]|\\()([\\w]+?://.*?([^ \\t\\n\\r<"\'\\)]*)?)#ie'; $replace[] = "'\$1<!-- m --><a href=\"\$2\" target=\"_blank\">' . ((strlen('\$2') > 55) ? substr(str_replace('&', '&', '\$2'), 0, 39) . ' ... ' . substr(str_replace('&', '&', '\$2'), -10) : '\$2') . '</a><!-- m -->'"; // matches a "www.xxxx.yyyy[/zzzz]" kinda lazy URL thing $match[] = '#(^|[\\n ]|\\()(www\\.[\\w\\-]+\\.[\\w\\-.\\~]+(?:/[^ \\t\\n\\r<"\'\\)]*)?)#ie'; $replace[] = "'\$1<!-- w --><a href=\"http://\$2\" target=\"_blank\">' . ((strlen('\$2') > 55) ? substr(str_replace('&', '&', '\$2'), 0, 39) . ' ... ' . substr(str_replace('&', '&', '\$2'), -10) : '\$2') . '</a><!-- w -->'"; // matches an email@domain type address at the start of a line, or after a space. $match[] = '#(^|[\\n ]|\\()([a-z0-9&\\-_.]+?@[\\w\\-]+\\.([\\w\\-\\.]+\\.)?[\\w]+)#ie'; $replace[] = "'\$1<!-- e --><a href=\"mailto:\$2\">' . ((strlen('\$2') > 55) ? substr('\$2', 0, 39) . ' ... ' . substr('\$2', -10) : '\$2') . '</a><!-- e -->'"; } /* IMPORTANT NOTE (Developer inability to do advanced regular expressions) - Acyd Burn: Transforming < (<) to <&lt; in order to bypass the inability of preg_replace supporting multi-character sequences (POSIX - [..]). Since all message text is specialchared by default a match against < will always fail, since it is a < sequence within the text. Replacing with <&lt; and switching back thereafter produces no problems, because < will never show up with &lt; in the same text (due to this specialcharing). The < is put in front of &lt; to let the url break gracefully. I hope someone can lend me a hand here, telling me how to achive the wanted result without switching to ereg_replace. */ $this->message = preg_replace($match, $replace, str_replace('<', '<&lt;', $this->message)); $this->message = str_replace('<&lt;', '<', $this->message); }
/** * Parse Message */ function parse($allow_html, $allow_bbcode, $allow_magic_url, $allow_smilies, $allow_img_bbcode = true, $allow_flash_bbcode = true, $allow_quote_bbcode = true, $allow_url_bbcode = true, $update_this_message = true, $mode = 'post') { global $config, $_CLASS; $mode = $mode != 'sig' ? 'post' : 'sig'; $this->mode = $mode; $this->allow_img_bbcode = $allow_img_bbcode; $this->allow_flash_bbcode = $allow_flash_bbcode; $this->allow_quote_bbcode = $allow_quote_bbcode; $this->allow_url_bbcode = $allow_url_bbcode; // If false, then $this->message won't be altered, the text will be returned instead. if (!$update_this_message) { $tmp_message = $this->message; $return_message =& $this->message; } if ($this->message_status == 'display') { $this->decode_message(); } // Do some general 'cleanup' first before processing message, // e.g. remove excessive newlines(?), smilies(?) // Transform \r\n and \r into \n $match = array('#\\r\\n?#', '#sid=[a-z0-9]*?&?#', "#([\n][\\s]+){3,}#", '#(script|about|applet|activex|chrome):#i'); $replace = array("\n", '', "\n\n", "\\1:"); $this->message = preg_replace($match, $replace, trim($this->message)); // Message length check. -1 disables this check completely. if ($config['max_' . $mode . '_chars'] != -1) { $msg_len = $mode === 'post' ? strlen($this->message) : strlen(preg_replace('#\\[\\/?[a-z\\*\\+\\-]+(=[\\S]+)?\\]#is', ' ', $this->message)); if (!$msg_len && $mode !== 'sig' || $config['max_' . $mode . '_chars'] && $msg_len > $config['max_' . $mode . '_chars']) { $this->warn_msg[] = !$msg_len ? $_CLASS['core_user']->lang['TOO_FEW_CHARS'] : $_CLASS['core_user']->lang['TOO_MANY_CHARS']; return $this->warn_msg; } } // Parse HTML if ($allow_html && $config['allow_html_tags']) { $this->html($config['allow_html_tags']); } // Prepare BBcode (just prepares some tags for better parsing) if ($allow_bbcode && strpos($this->message, '[') !== false) { $this->bbcode_init(); $disallow = array('img', 'flash', 'quote', 'url'); foreach ($disallow as $bool) { if (!${'allow_' . $bool . '_bbcode'}) { $this->bbcodes[$bool]['disabled'] = true; } } $this->prepare_bbcodes(); } // Parse smilies if ($allow_smilies) { $this->smilies($config['max_' . $mode . '_smilies']); } $num_urls = 0; // Parse BBCode if ($allow_bbcode && strpos($this->message, '[') !== false) { $this->parse_bbcode(); $num_urls += $this->parsed_items['url']; } // Parse URL's if ($allow_magic_url) { $this->magic_url(generate_base_url()); if ($config['max_' . $mode . '_urls']) { $num_urls += preg_match_all('#\\<!-- (l|m|w|e) --\\>.*?\\<!-- \\1 --\\>#', $this->message, $matches); } } // Check number of links if ($config['max_' . $mode . '_urls'] && $num_urls > $config['max_' . $mode . '_urls']) { $this->warn_msg[] = sprintf($_CLASS['core_user']->lang['TOO_MANY_URLS'], $config['max_' . $mode . '_urls']); return $this->warn_msg; } if (!$update_this_message) { unset($this->message); $this->message = $tmp_message; return $return_message; } $this->message_status = 'parsed'; return false; }
function display_header($title = false) { global $_CLASS, $_CORE_CONFIG, $_CORE_MODULE; if ($this->displayed['header']) { return; } $this->displayed['header'] = true; if (extension_loaded('zlib') && !ob_get_length()) { ob_start('ob_gzhandler'); } if ($title) { $_CORE_MODULE['module_title'] = $title; } elseif (!$_CORE_MODULE['module_title']) { // should move this somewhere else $_CORE_MODULE['module_title'] = $_CORE_MODULE['module_name']; } $this->headers(); if ($_CLASS['core_user']->is_user && $_CLASS['core_user']->data['user_new_privmsg'] && $_CLASS['core_user']->user_data_get('popuppm')) { $this->header['js'][] = '<script type="text/javascript">window.open(\'' . preg_replace('/&/', '&', generate_link('Control_Panel&i=pm&mode=popup', array('full' => true))) . "', '_phpbbprivmsg','height=135,resizable=yes,status=no,width=400');</script>"; //$_CLASS['core_db']->sql_query('UPDATE ' . USERS_TABLE . ' SET user_new_privmsg = 0 WHERE user_id = ' . $_CLASS['core_user']->data['user_id']); } $this->header['regular'][] = '<meta name="generator" content="Viperal CMS ( www.viperal.com ) Copyright(c) ' . date('Y') . '" />'; if (file_exists('favicon.ico')) { $this->header['regular'][] = '<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />'; } $this->header['regular'][] = '<link rel="alternate" type="application/xml" title="RSS" href="' . generate_base_url() . 'feed.php?feed=rdf" />'; if ($_CORE_CONFIG['maintenance']['active'] && $_CORE_CONFIG['maintenance']['start'] < $_CLASS['core_user']->time) { $this->message = '<b>System is in maintenance mode</b><br />'; } $this->header['js'][] = '<script type="text/javascript" src="javascript/common.js"></script>'; $this->header['js'][] = "<script type=\"text/javascript\">\nvar cms_session_id = '{$_CLASS['core_user']->data['session_id']}';\nvar cms_cookie_path = '{$_CORE_CONFIG['server']['cookie_path']}';\nvar cms_cookie_domain = '{$_CORE_CONFIG['server']['cookie_domain']}';\n</script>"; $this->header['meta'][] = '<base href="' . generate_base_url() . '" />'; $_CLASS['core_template']->assign_array(array('SITE_LANG' => $_CLASS['core_user']->lang['LANG'], 'SITE_TITLE' => $_CORE_CONFIG['global']['site_name'] . ': ' . (is_array($_CORE_MODULE['module_title']) ? implode(' > ', $_CORE_MODULE['module_title']) : $_CORE_MODULE['module_title']), 'SITE_URL' => generate_base_url(), 'SID' => empty($_CLASS['core_user']->data['session_id']) ? '' : $_CLASS['core_user']->data['session_id'], 'SITE_NAME' => $_CORE_CONFIG['global']['site_name'], 'HEADER_MESSAGE' => $this->message, 'HEADER_META' => empty($this->header['meta']) ? '' : implode("\n", $this->header['meta']), 'HEADER_REGULAR' => empty($this->header['regular']) ? '' : implode("\n", $this->header['regular']), 'HEADER_JS' => empty($this->header['js']) ? '' : implode("\n", $this->header['js']), 'FOOTER_CONTENT' => $this->footer)); $_CLASS['core_blocks']->display(BLOCK_MESSAGE_TOP); if ($this->homepage) { $_CLASS['core_blocks']->display(BLOCK_TOP); } $this->theme->theme_header(); }