mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
Перенос файлов движка в корень
This commit is contained in:
parent
584f692288
commit
f94c0dd2ee
585 changed files with 14 additions and 14 deletions
2
library/includes/classes/.htaccess
Normal file
2
library/includes/classes/.htaccess
Normal file
|
@ -0,0 +1,2 @@
|
|||
order allow,deny
|
||||
deny from all
|
3104
library/includes/classes/correct.php
Normal file
3104
library/includes/classes/correct.php
Normal file
File diff suppressed because it is too large
Load diff
244
library/includes/classes/emailer.php
Normal file
244
library/includes/classes/emailer.php
Normal file
|
@ -0,0 +1,244 @@
|
|||
<?php
|
||||
|
||||
if (!defined('BB_ROOT')) die(basename(__FILE__));
|
||||
|
||||
class emailer
|
||||
{
|
||||
var $msg, $subject, $extra_headers;
|
||||
var $addresses, $reply_to, $from;
|
||||
var $use_smtp;
|
||||
|
||||
var $tpl_msg = array();
|
||||
var $vars = array();
|
||||
|
||||
function emailer ($use_smtp/*$tpl_name, $sbj, $to_address*/)
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
||||
$this->reset();
|
||||
$this->from = $bb_cfg['board_email'];
|
||||
$this->reply_to = $bb_cfg['board_email'];
|
||||
$this->use_smtp = $use_smtp; /*!empty($bb_cfg['smtp_host']);
|
||||
|
||||
$this->use_template($tpl_name);
|
||||
$this->set_subject($sbj);
|
||||
$this->email_address($to_address);*/
|
||||
}
|
||||
|
||||
function set_default_vars ()
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
||||
$this->vars = array(
|
||||
'BOARD_EMAIL' => $bb_cfg['board_email'],
|
||||
'SITENAME' => $bb_cfg['board_email_sitename'],
|
||||
'EMAIL_SIG' => !empty($bb_cfg['board_email_sig']) ? "-- \n{$bb_cfg['board_email_sig']}" : '',
|
||||
);
|
||||
}
|
||||
|
||||
// Resets all the data (address, template file, etc etc to default
|
||||
function reset ()
|
||||
{
|
||||
$this->addresses = array();
|
||||
$this->msg = $this->extra_headers = '';
|
||||
$this->set_default_vars();
|
||||
}
|
||||
|
||||
// Sets an email address to send to
|
||||
function email_address ($address)
|
||||
{
|
||||
$this->addresses['to'] = trim($address);
|
||||
}
|
||||
|
||||
function cc ($address)
|
||||
{
|
||||
$this->addresses['cc'][] = trim($address);
|
||||
}
|
||||
|
||||
function bcc ($address)
|
||||
{
|
||||
$this->addresses['bcc'][] = trim($address);
|
||||
}
|
||||
|
||||
function replyto ($address)
|
||||
{
|
||||
$this->reply_to = trim($address);
|
||||
}
|
||||
|
||||
function from ($address)
|
||||
{
|
||||
$this->from = trim($address);
|
||||
}
|
||||
|
||||
// set up subject for mail
|
||||
function set_subject ($subject = '')
|
||||
{
|
||||
$this->subject = trim(preg_replace('#[\n\r]+#s', '', $subject));
|
||||
}
|
||||
|
||||
// set up extra mail headers
|
||||
function extra_headers ($headers)
|
||||
{
|
||||
$this->extra_headers .= trim($headers) . "\n";
|
||||
}
|
||||
|
||||
function use_template ($template_file, $template_lang = '')
|
||||
{
|
||||
global $bb_cfg;
|
||||
|
||||
if (trim($template_file) == '')
|
||||
{
|
||||
bb_die('No template file set');
|
||||
}
|
||||
|
||||
if (trim($template_lang) == '')
|
||||
{
|
||||
$template_lang = $bb_cfg['default_lang'];
|
||||
}
|
||||
|
||||
if (empty($this->tpl_msg[$template_lang . $template_file]))
|
||||
{
|
||||
$tpl_file = LANG_ROOT_DIR ."$template_lang/email/$template_file.tpl";
|
||||
|
||||
if (!@file_exists(@bb_realpath($tpl_file)))
|
||||
{
|
||||
$tpl_file = LANG_ROOT_DIR ."{$bb_cfg['default_lang']}/email/$template_file.tpl";
|
||||
|
||||
if (!@file_exists(@bb_realpath($tpl_file)))
|
||||
{
|
||||
bb_die('Could not find email template file :: ' . $template_file);
|
||||
}
|
||||
}
|
||||
|
||||
if (!($fd = @fopen($tpl_file, 'r')))
|
||||
{
|
||||
bb_die('Failed opening template file :: ' . $tpl_file);
|
||||
}
|
||||
|
||||
$this->tpl_msg[$template_lang . $template_file] = fread($fd, filesize($tpl_file));
|
||||
fclose($fd);
|
||||
}
|
||||
|
||||
$this->msg = $this->tpl_msg[$template_lang . $template_file];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// assign variables
|
||||
function assign_vars ($vars)
|
||||
{
|
||||
$this->vars = array_merge($this->vars, $vars);
|
||||
}
|
||||
|
||||
// Send the mail out to the recipients set previously in var $this->address
|
||||
function send ($email_format = 'text')
|
||||
{
|
||||
global $bb_cfg, $lang;
|
||||
|
||||
if ($bb_cfg['emailer_disabled'])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Escape all quotes
|
||||
$this->msg = str_replace ("'", "\'", $this->msg);
|
||||
$this->msg = preg_replace('#\{([a-z0-9\-_]*?)\}#is', "' . $\\1 . '", $this->msg);
|
||||
|
||||
// Set vars
|
||||
reset ($this->vars);
|
||||
while (list($key, $val) = each($this->vars))
|
||||
{
|
||||
$$key = $val;
|
||||
}
|
||||
|
||||
eval("\$this->msg = '$this->msg';");
|
||||
|
||||
// Clear vars
|
||||
reset ($this->vars);
|
||||
while (list($key, $val) = each($this->vars))
|
||||
{
|
||||
unset($$key);
|
||||
}
|
||||
|
||||
// We now try and pull a subject from the email body ... if it exists,
|
||||
// do this here because the subject may contain a variable
|
||||
$drop_header = '';
|
||||
$match = array();
|
||||
if (preg_match('#^(Subject:(.*?))$#m', $this->msg, $match))
|
||||
{
|
||||
$this->subject = (trim($match[2]) != '') ? trim($match[2]) : (($this->subject != '') ? $this->subject : 'No Subject');
|
||||
$drop_header .= '[\r\n]*?' . preg_quote($match[1], '#');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->subject = (($this->subject != '') ? $this->subject : 'No Subject');
|
||||
}
|
||||
|
||||
if (preg_match('#^(Charset:(.*?))$#m', $this->msg, $match))
|
||||
{
|
||||
$this->encoding = (trim($match[2]) != '') ? trim($match[2]) : trim($lang['CONTENT_ENCODING']);
|
||||
$drop_header .= '[\r\n]*?' . preg_quote($match[1], '#');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->encoding = trim($lang['CONTENT_ENCODING']);
|
||||
}
|
||||
$this->subject = $this->encode($this->subject);
|
||||
|
||||
if ($drop_header != '')
|
||||
{
|
||||
$this->msg = trim(preg_replace('#' . $drop_header . '#s', '', $this->msg));
|
||||
}
|
||||
|
||||
$to = @$this->addresses['to'];
|
||||
|
||||
$cc = (@count($this->addresses['cc'])) ? implode(', ', $this->addresses['cc']) : '';
|
||||
$bcc = (@count($this->addresses['bcc'])) ? implode(', ', $this->addresses['bcc']) : '';
|
||||
|
||||
// Build header
|
||||
$type = ($email_format == 'html') ? 'html' : 'plain';
|
||||
$this->extra_headers = (($this->reply_to != '') ? "Reply-to: $this->reply_to\n" : '') . (($this->from != '') ? "From: $this->from\n" : "From: " . $bb_cfg['board_email'] . "\n") . "Return-Path: " . $bb_cfg['board_email'] . "\nMessage-ID: <" . md5(uniqid(TIMENOW)) . "@" . $bb_cfg['server_name'] . ">\nMIME-Version: 1.0\nContent-type: text/$type; charset=" . $this->encoding . "\nContent-transfer-encoding: 8bit\nDate: " . date('r', TIMENOW) . "\nX-Priority: 0\nX-MSMail-Priority: Normal\nX-Mailer: Microsoft Office Outlook, Build 11.0.5510\nX-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441\nX-Sender: " . $bb_cfg['board_email'] . "\n" . $this->extra_headers . (($cc != '') ? "Cc: $cc\n" : '') . (($bcc != '') ? "Bcc: $bcc\n" : '');
|
||||
|
||||
// Send message
|
||||
if ($this->use_smtp)
|
||||
{
|
||||
if (!defined('SMTP_INCLUDED'))
|
||||
{
|
||||
include(INC_DIR .'smtp.php');
|
||||
}
|
||||
|
||||
$result = smtpmail($to, $this->subject, $this->msg, $this->extra_headers);
|
||||
}
|
||||
else
|
||||
{
|
||||
$to = ($to == '') ? ' ' : $to;
|
||||
|
||||
$result = @mail($to, $this->subject, preg_replace("#(?<!\r)\n#s", "\n", $this->msg), $this->extra_headers);
|
||||
}
|
||||
|
||||
// Did it work?
|
||||
if (!$result)
|
||||
{
|
||||
bb_die('Failed sending email :: ' . (($this->use_smtp) ? 'SMTP' : 'PHP') . ' :: ' . $result);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function encode ($str)
|
||||
{
|
||||
if ($this->encoding == '')
|
||||
{
|
||||
return $str;
|
||||
}
|
||||
|
||||
// define start delimimter, end delimiter and spacer
|
||||
$start = "=?$this->encoding?B?";
|
||||
$end = "?=";
|
||||
|
||||
// encode the string and split it into chunks with spacers after each chunk
|
||||
$str = base64_encode($str);
|
||||
|
||||
return $start . $str . $end;
|
||||
}
|
||||
}
|
183
library/includes/classes/reflection.php
Normal file
183
library/includes/classes/reflection.php
Normal file
|
@ -0,0 +1,183 @@
|
|||
<?php
|
||||
/**
|
||||
* A class for validating method parameters to allowed types via reflection.
|
||||
*
|
||||
* Purpose
|
||||
* Used as a more convenient multiple assert(), standing after the declaration of the methods.
|
||||
*
|
||||
* Features and advantage
|
||||
* * Very easy to use
|
||||
* * Ability to turn off on the production server
|
||||
*
|
||||
* WARNING
|
||||
* On a production server, it is important to disable assert, that would save server resources.
|
||||
* For this, use the assert_options(ASSERT_ACTIVE, false) or INI setting "assert.active 0".
|
||||
* In this case ReflectionTypeHint::isValid() always returns TRUE!
|
||||
*
|
||||
* Useful links
|
||||
* http://www.ilia.ws/archives/205-Type-hinting-for-PHP-5.3.html
|
||||
* http://php.net/manual/en/language.oop5.typehinting.php
|
||||
*
|
||||
* @example ReflectionTypeHint_example.php
|
||||
* @link http://code.google.com/p/php5-reflection-type-hint/
|
||||
* @license http://creativecommons.org/licenses/by-sa/3.0/
|
||||
* @author Nasibullin Rinat
|
||||
* @version 1.1.0
|
||||
*/
|
||||
class ReflectionTypeHint
|
||||
{
|
||||
protected static $hints = array(
|
||||
'int' => 'is_int',
|
||||
'integer' => 'is_int',
|
||||
'digit' => 'ctype_digit',
|
||||
'number' => 'ctype_digit',
|
||||
'float' => 'is_float',
|
||||
'double' => 'is_float',
|
||||
'real' => 'is_float',
|
||||
'numeric' => 'is_numeric',
|
||||
'str' => 'is_string',
|
||||
'string' => 'is_string',
|
||||
'char' => 'is_string',
|
||||
'bool' => 'is_bool',
|
||||
'boolean' => 'is_bool',
|
||||
'null' => 'is_null',
|
||||
'array' => 'is_array',
|
||||
'obj' => 'is_object',
|
||||
'object' => 'is_object',
|
||||
'res' => 'is_resource',
|
||||
'resource' => 'is_resource',
|
||||
'scalar' => 'is_scalar', #integer, float, string or boolean
|
||||
'cb' => 'is_callable',
|
||||
'callback' => 'is_callable',
|
||||
);
|
||||
|
||||
#calling the methods of this class only statically!
|
||||
private function __construct() {}
|
||||
|
||||
public static function isValid()
|
||||
{
|
||||
if (! assert_options(ASSERT_ACTIVE)) return true;
|
||||
$bt = self::debugBacktrace(null, 1);
|
||||
extract($bt); //to $file, $line, $function, $class, $object, $type, $args
|
||||
if (! $args) return true; #speed improve
|
||||
$r = new ReflectionMethod($class, $function);
|
||||
$doc = $r->getDocComment();
|
||||
$cache_id = $class. $type. $function;
|
||||
preg_match_all('~ [\r\n]++ [\x20\t]++ \* [\x20\t]++
|
||||
@param
|
||||
[\x20\t]++
|
||||
\K #memory reduce
|
||||
( [_a-z]++[_a-z\d]*+
|
||||
(?>[|/,][_a-z]+[_a-z\d]*)*+
|
||||
) #1 types
|
||||
[\x20\t]++
|
||||
&?+\$([_a-z]++[_a-z\d]*+) #2 name
|
||||
~sixSX', $doc, $params, PREG_SET_ORDER);
|
||||
$parameters = $r->getParameters();
|
||||
//d($args, $params, $parameters);
|
||||
if (count($parameters) > count($params))
|
||||
{
|
||||
$message = 'phpDoc %d piece(s) @param description expected in %s%s%s(), %s given, ' . PHP_EOL
|
||||
. 'called in %s on line %d ' . PHP_EOL
|
||||
. 'and defined in %s on line %d';
|
||||
$message = sprintf($message, count($parameters), $class, $type, $function, count($params), $file, $line, $r->getFileName(), $r->getStartLine());
|
||||
trigger_error($message, E_USER_NOTICE);
|
||||
}
|
||||
foreach ($args as $i => $value)
|
||||
{
|
||||
if (! isset($params[$i])) return true;
|
||||
if ($parameters[$i]->name !== $params[$i][2])
|
||||
{
|
||||
$param_num = $i + 1;
|
||||
$message = 'phpDoc @param %d in %s%s%s() must be named as $%s, $%s given, ' . PHP_EOL
|
||||
. 'called in %s on line %d ' . PHP_EOL
|
||||
. 'and defined in %s on line %d';
|
||||
$message = sprintf($message, $param_num, $class, $type, $function, $parameters[$i]->name, $params[$i][2], $file, $line, $r->getFileName(), $r->getStartLine());
|
||||
trigger_error($message, E_USER_NOTICE);
|
||||
}
|
||||
|
||||
$hints = preg_split('~[|/,]~sSX', $params[$i][1]);
|
||||
if (! self::checkValueTypes($hints, $value))
|
||||
{
|
||||
$param_num = $i + 1;
|
||||
$message = 'Argument %d passed to %s%s%s() must be an %s, %s given, ' . PHP_EOL
|
||||
. 'called in %s on line %d ' . PHP_EOL
|
||||
. 'and defined in %s on line %d';
|
||||
$message = sprintf($message, $param_num, $class, $type, $function, implode('|', $hints), (is_object($value) ? get_class($value) . ' ' : '') . gettype($value), $file, $line, $r->getFileName(), $r->getStartLine());
|
||||
trigger_error($message, E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return stacktrace. Correctly work with call_user_func*()
|
||||
* (totally skip them correcting caller references).
|
||||
* If $return_frame is present, return only $return_frame matched caller, not all stacktrace.
|
||||
*
|
||||
* @param string|null $re_ignore example: '~^' . preg_quote(__CLASS__, '~') . '(?![a-zA-Z\d])~sSX'
|
||||
* @param int|null $return_frame
|
||||
* @return array
|
||||
*/
|
||||
public static function debugBacktrace($re_ignore = null, $return_frame = null)
|
||||
{
|
||||
$trace = debug_backtrace();
|
||||
|
||||
$a = array();
|
||||
$frames = 0;
|
||||
for ($i = 0, $n = count($trace); $i < $n; $i++)
|
||||
{
|
||||
$t = $trace[$i];
|
||||
if (! $t) continue;
|
||||
|
||||
// Next frame.
|
||||
$next = isset($trace[$i+1])? $trace[$i+1] : null;
|
||||
|
||||
// Dummy frame before call_user_func*() frames.
|
||||
if (! isset($t['file']) && $next)
|
||||
{
|
||||
$t['over_function'] = $trace[$i+1]['function'];
|
||||
$t = $t + $trace[$i+1];
|
||||
$trace[$i+1] = null; // skip call_user_func on next iteration
|
||||
}
|
||||
|
||||
// Skip myself frame.
|
||||
if (++$frames < 2) continue;
|
||||
|
||||
// 'class' and 'function' field of next frame define where this frame function situated.
|
||||
// Skip frames for functions situated in ignored places.
|
||||
if ($re_ignore && $next)
|
||||
{
|
||||
// Name of function "inside which" frame was generated.
|
||||
$frame_caller = (isset($next['class']) ? $next['class'] . $next['type'] : '')
|
||||
. (isset($next['function']) ? $next['function'] : '');
|
||||
if (preg_match($re_ignore, $frame_caller)) continue;
|
||||
}
|
||||
|
||||
// On each iteration we consider ability to add PREVIOUS frame to $a stack.
|
||||
if (count($a) === $return_frame) return $t;
|
||||
$a[] = $t;
|
||||
}
|
||||
return $a;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks a value to the allowed types
|
||||
*
|
||||
* @param array $types
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkValueTypes(array $types, $value)
|
||||
{
|
||||
foreach ($types as $type)
|
||||
{
|
||||
$type = strtolower($type);
|
||||
if (array_key_exists($type, self::$hints) && call_user_func(self::$hints[$type], $value)) return true;
|
||||
if (is_object($value) && @is_a($value, $type)) return true;
|
||||
if ($type === 'mixed') return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
216
library/includes/classes/sitemap.php
Normal file
216
library/includes/classes/sitemap.php
Normal file
|
@ -0,0 +1,216 @@
|
|||
<?php
|
||||
|
||||
class sitemap
|
||||
{
|
||||
var $home = '';
|
||||
var $limit = 0;
|
||||
var $topic_priority = '0.5';
|
||||
var $stat_priority = '0.5';
|
||||
var $priority = '0.6';
|
||||
var $cat_priority = '0.7';
|
||||
|
||||
function sitemap () {
|
||||
global $bb_cfg;
|
||||
$this->home = 'http://'.$bb_cfg['server_name'].'/';
|
||||
}
|
||||
|
||||
function build_map () {
|
||||
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
|
||||
$map .= $this->get_static();
|
||||
$map .= $this->get_forum();
|
||||
$map .= $this->get_topic();
|
||||
$map .= "</urlset>";
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
function build_index ($count) {
|
||||
$lm = date('c');
|
||||
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
|
||||
$map .= "<sitemap>\n<loc>{$this->home}sitemap/sitemap1.xml</loc>\n<lastmod>{$lm}</lastmod>\n</sitemap>\n";
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$t = $i + 2;
|
||||
$map .= "<sitemap>\n<loc>{$this->home}sitemap/sitemap{$t}.xml</loc>\n<lastmod>{$lm}</lastmod>\n</sitemap>\n";
|
||||
}
|
||||
$map .= "</sitemapindex>";
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
function build_stat () {
|
||||
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
|
||||
$map .= $this->get_static();
|
||||
$map .= $this->get_forum();
|
||||
$map .= "</urlset>";
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
function build_map_topic ($n) {
|
||||
$map = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">\n";
|
||||
$map .= $this->get_topic($n);
|
||||
$map .= "</urlset>";
|
||||
|
||||
return $map;
|
||||
}
|
||||
|
||||
function get_forum () {
|
||||
global $datastore;
|
||||
|
||||
$this->priority = $this->cat_priority;
|
||||
$xml = '';
|
||||
$lm = date('c');
|
||||
|
||||
if (!$forums = $datastore->get('cat_forums')) {
|
||||
$datastore->update('cat_forums');
|
||||
$forums = $datastore->get('cat_forums');
|
||||
}
|
||||
|
||||
$not_forums_id = $forums['not_auth_forums']['guest_view'];
|
||||
$ignore_forum_sql = ($not_forums_id) ? "WHERE forum_id NOT IN($not_forums_id)" : '';
|
||||
|
||||
$sql = DB()->sql_query("SELECT forum_id, forum_topics, forum_parent, forum_name FROM " . BB_FORUMS . " " . $ignore_forum_sql . " ORDER BY forum_id ASC");
|
||||
|
||||
while ($row = DB()->sql_fetchrow($sql)) {
|
||||
if (function_exists('seo_url')) $loc = $this->home . seo_url(FORUM_URL . $row['forum_id'], $row['forum_name']);
|
||||
else $loc = $this->home . FORUM_URL . $row['forum_id'];
|
||||
$xml .= $this->get_xml($loc, $lm);
|
||||
}
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
function get_topic ($page = false) {
|
||||
global $datastore;
|
||||
|
||||
$xml = '';
|
||||
$this->priority = $this->topic_priority;
|
||||
|
||||
if ($page) {
|
||||
$page = $page - 1;
|
||||
$page = $page * 40000;
|
||||
$this->limit = " LIMIT {$page},40000";
|
||||
} else {
|
||||
if ($this->limit < 1) $this->limit = false;
|
||||
if ($this->limit) {
|
||||
$this->limit = " LIMIT 0," . $this->limit;
|
||||
} else {
|
||||
$this->limit = '';
|
||||
}
|
||||
}
|
||||
|
||||
if (!$forums = $datastore->get('cat_forums')) {
|
||||
$datastore->update('cat_forums');
|
||||
$forums = $datastore->get('cat_forums');
|
||||
}
|
||||
|
||||
$not_forums_id = $forums['not_auth_forums']['guest_view'];
|
||||
$ignore_forum_sql = ($not_forums_id) ? "WHERE forum_id NOT IN($not_forums_id)" : '';
|
||||
|
||||
$sql = DB()->sql_query("SELECT topic_id, topic_title, topic_time FROM " . BB_TOPICS . " " . $ignore_forum_sql . " ORDER BY topic_time ASC" . $this->limit);
|
||||
|
||||
while ($row = DB()->sql_fetchrow($sql)) {
|
||||
if (function_exists('seo_url')) $loc = $this->home . seo_url(TOPIC_URL . $row['topic_id'], $row['topic_title']);
|
||||
else $loc = $this->home . TOPIC_URL . $row['topic_id'];
|
||||
$xml .= $this->get_xml($loc, date('c', $row['topic_time']));
|
||||
}
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
function get_static () {
|
||||
global $bb_cfg;
|
||||
|
||||
$xml = '';
|
||||
$lm = date('c');
|
||||
$this->priority = $this->stat_priority;
|
||||
|
||||
if (isset($bb_cfg['static_sitemap'])) {
|
||||
$static_url = preg_replace("/\s/", '', $bb_cfg['static_sitemap']); //вырезаем переносы строк
|
||||
preg_match_all('#(https?://[\w-]+[\.\w-]+/((?!https?://)[\w- ./?%&=])+)#', $static_url, $out);
|
||||
|
||||
$static_url = count($out['0']);
|
||||
if ($static_url > 0) {
|
||||
foreach ($out['0'] as $url) {
|
||||
$loc = $url;
|
||||
$xml .= $this->get_xml($loc, $lm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
function get_xml ($loc, $lm) {
|
||||
$xml = "\t<url>\n";
|
||||
$xml .= "\t\t<loc>$loc</loc>\n";
|
||||
$xml .= "\t\t<lastmod>$lm</lastmod>\n";
|
||||
$xml .= "\t\t<priority>" . $this->priority . "</priority>\n";
|
||||
$xml .= "\t</url>\n";
|
||||
|
||||
return $xml;
|
||||
}
|
||||
|
||||
function send_url ($url, $map) {
|
||||
$data = false;
|
||||
$file = $url.urlencode($map);
|
||||
|
||||
if (function_exists('curl_init')) {
|
||||
$ch = curl_init();
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, $file);
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 6);
|
||||
|
||||
$data = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
|
||||
return $data;
|
||||
} else {
|
||||
return @file_get_contents($file);
|
||||
}
|
||||
}
|
||||
|
||||
function create () {
|
||||
$row = DB()->fetch_row("SELECT COUNT(*) AS count FROM " . BB_TOPICS);
|
||||
|
||||
if (!$this->limit) $this->limit = $row['count'];
|
||||
if ($this->limit > 40000) {
|
||||
$pages_count = @ceil($row['count'] / 40000);
|
||||
|
||||
$sitemap = $this->build_index($pages_count);
|
||||
$handler = fopen(SITEMAP_DIR. "sitemap.xml", "wb+");
|
||||
fwrite($handler, $sitemap);
|
||||
fclose($handler);
|
||||
@chmod(SITEMAP_DIR. "sitemap.xml", 0666);
|
||||
|
||||
$sitemap = $this->build_stat();
|
||||
$handler = fopen(SITEMAP_DIR. "sitemap1.xml", "wb+");
|
||||
fwrite($handler, $sitemap);
|
||||
fclose($handler);
|
||||
@chmod(SITEMAP_DIR. "sitemap.xml", 0666);
|
||||
|
||||
for ($i = 0; $i < $pages_count; $i++) {
|
||||
$t = $i + 2;
|
||||
$n = $i + 1;
|
||||
|
||||
$sitemap = $this->build_map_topic($n);
|
||||
$handler = fopen(SITEMAP_DIR. "sitemap{$t}.xml", "wb+");
|
||||
fwrite($handler, $sitemap);
|
||||
fclose($handler);
|
||||
@chmod(SITEMAP_DIR. "sitemap{$t}.xml", 0666);
|
||||
}
|
||||
} else {
|
||||
$sitemap = $this->build_map();
|
||||
$handler = fopen(SITEMAP_DIR. "sitemap.xml", "wb+");
|
||||
fwrite($handler, $sitemap);
|
||||
fclose($handler);
|
||||
@chmod(SITEMAP_DIR. "sitemap.xml", 0666);
|
||||
}
|
||||
|
||||
$params['sitemap_time'] = TIMENOW;
|
||||
bb_update_config($params);
|
||||
}
|
||||
}
|
4071
library/includes/classes/utf8.php
Normal file
4071
library/includes/classes/utf8.php
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue