Browse Source

v 3.25

pull/3/head
M@d D3n 7 years ago
parent
commit
d88076284b
  1. 4
      README.md
  2. 92
      admin/functions/func.admin.common.php
  3. 5
      admin/settings.php
  4. 1
      admin/start.php
  5. 40
      admin/templates/js/main.js
  6. 2
      admin/templates/rubs/list.tpl
  7. 6
      admin/templates/rubs/tmpls.tpl
  8. 2
      admin/templates/start.tpl
  9. 23
      class/class.database.php
  10. 10
      class/class.rubs.php
  11. 2
      inc/config.php
  12. 18
      inc/sitemap.php
  13. 25
      inc/thumb.php

4
README.md

@ -1,4 +1,4 @@
# AVE.cms v3.24 # AVE.cms v3.25
###### Многофункциональная, система управления сайтом. ###### Многофункциональная, система управления сайтом.
## Оглавление ## Оглавление
@ -73,4 +73,4 @@ Google+: [Google+](https://plus.google.com/106406255345948508717)
--- ---
Copyright © 2007-2018 [Ave-Cms.Ru](https://ave-cms.ru) | [AVE.cms 3.24](https://ave-cms.ru) Copyright © 2007-2018 [Ave-Cms.Ru](https://ave-cms.ru) | [AVE.cms 3.25](https://ave-cms.ru)

92
admin/functions/func.admin.common.php

@ -8,6 +8,7 @@
* @filesource * @filesource
*/ */
/** /**
* Если был referer, то перенапрявляем на него * Если был referer, то перенапрявляем на него
* *
@ -75,27 +76,34 @@
$AVE_Template->assign('logs', $logs); $AVE_Template->assign('logs', $logs);
} }
/** /**
* Список пользователей за последние $onlinetime секунд * Список пользователей за последние $onlinetime секунд
* *
* @param int $onlinetime количество секунд * @param int $onlinetime количество секунд
* @return Array массив из пользователей отсортированный по последней активности * @return Array массив из пользователей отсортированный по последней активности
*/ */
function get_online_users($onlinetime=USERS_TIME_SHOW) function get_online_users($onlinetime = USERS_TIME_SHOW)
{ {
global $AVE_DB, $AVE_Template; global $AVE_DB, $AVE_Template;
$time=(time()-intval($onlinetime)); $time=(time()-intval($onlinetime));
$sql=@$AVE_DB->Query("SELECT * FROM ".PREFIX."_users WHERE last_visit>".$time." ORDER BY last_visit DESC"); $sql=@$AVE_DB->Query("SELECT * FROM ".PREFIX."_users WHERE last_visit>".$time." ORDER BY last_visit DESC");
$online_users=Array(); $online_users=Array();
while ($row = $sql->FetchRow()) while ($row = $sql->FetchRow())
{ {
$row->user_name = get_username_by_id($row->Id); $row->user_name = get_username_by_id($row->Id);
$row->user_group_name = get_usergroup_by_id($row->user_group); $row->user_group_name = get_usergroup_by_id($row->user_group);
array_push($online_users,$row); array_push($online_users,$row);
} }
$AVE_Template->assign('online_users', $online_users); $AVE_Template->assign('online_users', $online_users);
} }
/** /**
* Форматированный вывод размера * Форматированный вывод размера
* *
@ -105,21 +113,13 @@
function format_size($file_size) function format_size($file_size)
{ {
if ($file_size >= 1073741824) if ($file_size >= 1073741824)
{
$file_size = round($file_size / 1073741824 * 100) / 100 . ' Gb'; $file_size = round($file_size / 1073741824 * 100) / 100 . ' Gb';
}
elseif ($file_size >= 1048576) elseif ($file_size >= 1048576)
{
$file_size = round($file_size / 1048576 * 100) / 100 . ' Mb'; $file_size = round($file_size / 1048576 * 100) / 100 . ' Mb';
}
elseif ($file_size >= 1024) elseif ($file_size >= 1024)
{
$file_size = round($file_size / 1024 * 100) / 100 . ' Kb'; $file_size = round($file_size / 1024 * 100) / 100 . ' Kb';
}
else else
{
$file_size = $file_size . ' b'; $file_size = $file_size . ' b';
}
return $file_size; return $file_size;
} }
@ -135,37 +135,50 @@
$cnts = array(); $cnts = array();
$cnts['templates'] = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_templates")->GetCell(); $cnts['templates'] = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_templates")->GetCell();
$cnts['documents'] = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_documents")->GetCell(); $cnts['request'] = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_request")->GetCell();
$cnts['request'] = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_request") ->GetCell(); $cnts['rubrics'] = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_rubrics")->GetCell();
$cnts['rubrics'] = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_rubrics") ->GetCell();
$sql = $AVE_DB->Query(" $sql = $AVE_DB->Query("
SELECT SELECT
`ModuleStatus`, `ModuleStatus`,
COUNT(`ModuleStatus`) AS cntStatus COUNT(`ModuleStatus`) AS cntStatus
FROM " . PREFIX . "_module FROM
" . PREFIX . "_module
GROUP BY `ModuleStatus` GROUP BY `ModuleStatus`
"); ");
while ($row = $sql->FetchRow()) while ($row = $sql->FetchRow())
{
$cnts['modules_' . $row->ModuleStatus] = $row->cntStatus; $cnts['modules_' . $row->ModuleStatus] = $row->cntStatus;
}
$sql = $AVE_DB->Query(" $sql = $AVE_DB->Query("
SELECT SELECT
status, status,
COUNT(status) AS cntStatus COUNT(status) AS cntStatus
FROM " . PREFIX . "_users FROM
" . PREFIX . "_users
GROUP BY status GROUP BY status
"); ");
while ($row = $sql->FetchRow()) while ($row = $sql->FetchRow())
{
$cnts['users_' . $row->status] = $row->cntStatus; $cnts['users_' . $row->status] = $row->cntStatus;
}
$AVE_Template->assign('cnts', $cnts); $AVE_Template->assign('cnts', $cnts);
} }
function countDocuments($rubric_id = null)
{
global $AVE_DB;
if (is_numeric($rubric_id) && $rubric_id > 0)
$count = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_documents WHERE rubric_id = '".$rubric_id."'")->GetCell();
else
$count = $AVE_DB->Query("SELECT COUNT(*) FROM " . PREFIX . "_documents")->GetCell();
echo $count;
}
/** /**
* Размер дириктории * Размер дириктории
* *
@ -175,12 +188,16 @@
function get_dir_size($directory) function get_dir_size($directory)
{ {
if (!is_dir($directory)) return -1; if (!is_dir($directory)) return -1;
$size = 0; $size = 0;
if ($DIR = opendir($directory)) if ($DIR = opendir($directory))
{ {
while (($dirfile = readdir($DIR)) !== false) while (($dirfile = readdir($DIR)) !== false)
{ {
if (@is_link($directory . '/' . $dirfile) || $dirfile == '.' || $dirfile == '..') continue; if (@is_link($directory . '/' . $dirfile) || $dirfile == '.' || $dirfile == '..')
continue;
if (@is_file($directory . '/' . $dirfile)) if (@is_file($directory . '/' . $dirfile))
{ {
$size += filesize($directory . '/' . $dirfile); $size += filesize($directory . '/' . $dirfile);
@ -188,22 +205,21 @@
elseif (@is_dir($directory . '/' . $dirfile)) elseif (@is_dir($directory . '/' . $dirfile))
{ {
$dirSize = get_dir_size($directory . '/' . $dirfile); $dirSize = get_dir_size($directory . '/' . $dirfile);
if ($dirSize >= 0) if ($dirSize >= 0)
{
$size += $dirSize; $size += $dirSize;
}
else else
{
return -1; return -1;
} }
} }
}
closedir($DIR); closedir($DIR);
} }
return $size; return $size;
} }
/** /**
* Размер базы данных * Размер базы данных
* *
@ -214,11 +230,11 @@
global $AVE_DB; global $AVE_DB;
$mysql_size = 0; $mysql_size = 0;
$sql = $AVE_DB->Query("SHOW TABLE STATUS LIKE '" . PREFIX . "_%'"); $sql = $AVE_DB->Query("SHOW TABLE STATUS LIKE '" . PREFIX . "_%'");
while ($row = $sql->FetchAssocArray()) while ($row = $sql->FetchAssocArray())
{
$mysql_size += $row['Data_length'] + $row['Index_length']; $mysql_size += $row['Data_length'] + $row['Index_length'];
}
return format_size($mysql_size); return format_size($mysql_size);
} }
@ -392,14 +408,19 @@
$handle = fopen($filename, 'rb'); $handle = fopen($filename, 'rb');
if ($handle === false) return false; if ($handle === false)
return false;
while (!feof($handle)) while (!feof($handle))
{ {
$buffer = fread($handle, $chunksize); $buffer = fread($handle, $chunksize);
echo $buffer; echo $buffer;
flush(); flush();
if ($retbytes) $cnt += strlen($buffer);
if ($retbytes)
$cnt += strlen($buffer);
} }
$status = fclose($handle); $status = fclose($handle);
@ -504,7 +525,9 @@
$row->canDelete = 0; $row->canDelete = 0;
$row->canEndDel = 0; $row->canEndDel = 0;
$row->canOpenClose = 0; $row->canOpenClose = 0;
$row->rubric_admin_teaser_template=@eval2var(' ?>'.($row->rubric_admin_teaser_template>'' ? @showrequestelement($row,$row->rubric_admin_teaser_template) : '').'<?php '); $row->rubric_admin_teaser_template = @eval2var(' ?>'.($row->rubric_admin_teaser_template > ''
? @showrequestelement($row, $row->rubric_admin_teaser_template)
: '').'<?php ');
// разрешаем редактирование и удаление // разрешаем редактирование и удаление
// если автор имеет право изменять свои документы в рубрике // если автор имеет право изменять свои документы в рубрике
@ -549,7 +572,7 @@
function showrubricName($id) function showrubricName($id)
{ {
global $AVE_DB, $AVE_Template; global $AVE_DB;
$sql = $AVE_DB->Query("SELECT rubric_title FROM " . PREFIX . "_rubrics WHERE Id='$id'"); $sql = $AVE_DB->Query("SELECT rubric_title FROM " . PREFIX . "_rubrics WHERE Id='$id'");
$row = $sql->fetchrow(); $row = $sql->fetchrow();
@ -558,7 +581,7 @@
function showuserName($id) function showuserName($id)
{ {
global $AVE_DB, $AVE_Template; global $AVE_DB;
$sql = $AVE_DB->Query("SELECT user_name FROM " . PREFIX . "_users WHERE Id='$id'"); $sql = $AVE_DB->Query("SELECT user_name FROM " . PREFIX . "_users WHERE Id='$id'");
$row = $sql->fetchrow(); $row = $sql->fetchrow();
@ -569,13 +592,16 @@
{ {
global $AVE_Template; global $AVE_Template;
$showCache = format_size(get_dir_size($AVE_Template->compile_dir)+get_dir_size($AVE_Template->cache_dir_root)); $showCache = format_size(get_dir_size($AVE_Template->cache_dir_root));
echo json_encode(array($showCache, 'accept')); echo json_encode(array($showCache, 'accept'));
} }
function templateName($id) function templateName($id)
{ {
global $AVE_DB, $AVE_Template; global $AVE_DB;
$sql = $AVE_DB->Query(" $sql = $AVE_DB->Query("
SELECT * FROM " . PREFIX . "_templates SELECT * FROM " . PREFIX . "_templates
@ -588,7 +614,7 @@
function groupName($id) function groupName($id)
{ {
global $AVE_DB, $AVE_Template; global $AVE_DB;
$sql = $AVE_DB->Query(" $sql = $AVE_DB->Query("
SELECT * FROM " . PREFIX . "_user_groups SELECT * FROM " . PREFIX . "_user_groups

5
admin/settings.php

@ -148,6 +148,11 @@
case 'showcache': case 'showcache':
cacheShow(); cacheShow();
exit; exit;
case 'showcountdocs':
$rubric_id = isset($_REQUEST['rubric_id']) ? $_REQUEST['rubric_id'] : null;
countDocuments($rubric_id);
exit;
} }
break; break;

1
admin/start.php

@ -23,7 +23,6 @@
get_online_users(); get_online_users();
getLogRecords(); getLogRecords();
//$AVE_Template->config_load(BASE_DIR . '/admin/lang/' . $_SESSION['admin_language'] . '/main.txt', 'index');
$AVE_Template->assign('php_version', (@PHP_VERSION != '') ? @PHP_VERSION : 'unknow'); $AVE_Template->assign('php_version', (@PHP_VERSION != '') ? @PHP_VERSION : 'unknow');
$AVE_Template->assign('domain', $_SERVER["HTTP_HOST"]); $AVE_Template->assign('domain', $_SERVER["HTTP_HOST"]);
$AVE_Template->assign('mysql_version', $GLOBALS['AVE_DB']->mysql_version()); $AVE_Template->assign('mysql_version', $GLOBALS['AVE_DB']->mysql_version());

40
admin/templates/js/main.js

@ -366,6 +366,7 @@ var AveAdmin = {
this.clear_revisions(); this.clear_revisions();
this.clear_counter(); this.clear_counter();
this.cache_show(); this.cache_show();
this.docs_show();
this.main_form(); this.main_form();
this.select_form(); this.select_form();
this.sticky_panel(); this.sticky_panel();
@ -675,6 +676,45 @@ var AveAdmin = {
}, },
//Показать размер кэша
docs_show: function() {
$('.showDocs').click(function(event, x) {
event.preventDefault();
var title = cacheShowTitle;
var confirm = cacheShowConfirm;
var rubric_id = $(this).attr('data-rubric-id');
var block = $(this);
jConfirm(
confirm,
title,
function(b) {
if (b) {
$.alerts._overlay('hide');
$.alerts._overlay('show');
$.ajax({
url: ave_path + 'admin/index.php?do=settings&sub=showcountdocs',
type: 'POST',
data: ({
rubric_id: rubric_id
}),
success: function(data) {
$.alerts._overlay('hide');
block.before(data).remove();
}
});
}
}
);
});
},
//Окно удаления едемента //Окно удаления едемента
confirm_delete: function() { confirm_delete: function() {

2
admin/templates/rubs/list.tpl

@ -179,7 +179,7 @@ $(function() {ldelim}
</select> </select>
{/if} {/if}
</td> </td>
<td align="center"><strong class="code">{$rubric->doc_count}</strong></td> <td align="center"><strong class="code"><a href="javascript:void(0);" class="link showDocs" data-rubric-id="{$rubric->Id}">{#MAIN_STAT_CACHE_SHOW#}</a></strong></td>
<td align="center"> <td align="center">
{if check_permission('rubric_edit')} {if check_permission('rubric_edit')}
<input type="checkbox" name="rubric_docs_active[{$rubric->Id}]" value="1" {if $rubric->rubric_docs_active == 1}checked="checked"{/if}> <input type="checkbox" name="rubric_docs_active[{$rubric->Id}]" value="1" {if $rubric->rubric_docs_active == 1}checked="checked"{/if}>

6
admin/templates/rubs/tmpls.tpl

@ -104,7 +104,6 @@ $(document).ready(function(){ldelim}
<col width="20"> <col width="20">
<col width="20"> <col width="20">
<col width="20"> <col width="20">
<col width="20">
{if $templates} {if $templates}
<thead> <thead>
@ -113,7 +112,6 @@ $(document).ready(function(){ldelim}
<td>{#RUBRIC_TMPLS_NAME#}</td> <td>{#RUBRIC_TMPLS_NAME#}</td>
<td>{#RUBRIC_TMPLS_AUTHOR#}</td> <td>{#RUBRIC_TMPLS_AUTHOR#}</td>
<td>{#RUBRIC_TMPLS_DATE#}</td> <td>{#RUBRIC_TMPLS_DATE#}</td>
<td align="center"><a href="javascript:void(0);" class="topDir icon_sprite ico_list float" style="cursor: help; display: inline-block" title="{#RUBRIC_TMPLS_COUNT_DOCS#}"></a></td>
{if check_permission('rubric_edit')}<td colspan="3">{#RUBRIC_TMPLS_ACTIONS#}</td>{/if} {if check_permission('rubric_edit')}<td colspan="3">{#RUBRIC_TMPLS_ACTIONS#}</td>{/if}
</tr> </tr>
</thead> </thead>
@ -139,10 +137,6 @@ $(document).ready(function(){ldelim}
<span class="date_text dgrey">{$template->created|date_format:$TIME_FORMAT|pretty_date}</span> <span class="date_text dgrey">{$template->created|date_format:$TIME_FORMAT|pretty_date}</span>
</td> </td>
<td>
<strong class="code">{$template->doc_count}</strong>
</td>
{if check_permission('rubric_edit')} {if check_permission('rubric_edit')}
<td nowrap="nowrap" width="1%" align="center"> <td nowrap="nowrap" width="1%" align="center">
<a class="topleftDir CopyTmpl icon_sprite ico_copy" title="{#RUBRIC_TMPLS_COPY#}" href="index.php?do=rubs&action=tmpls_copy&tmpls_id={$template->id}&rubric_id={$smarty.request.Id|escape}&cp={$sess}"></a> <a class="topleftDir CopyTmpl icon_sprite ico_copy" title="{#RUBRIC_TMPLS_COPY#}" href="index.php?do=rubs&action=tmpls_copy&tmpls_id={$template->id}&rubric_id={$smarty.request.Id|escape}&cp={$sess}"></a>

2
admin/templates/start.tpl

@ -164,7 +164,7 @@
<tbody> <tbody>
<tr class="noborder"> <tr class="noborder">
<td>{#MAIN_STAT_DOCUMENTS#}</td> <td>{#MAIN_STAT_DOCUMENTS#}</td>
<td align="right"><span class="cmsStats">{$cnts.documents}</span></td> <td align="right"><span class="cmsStats"><a href="javascript:void(0);" class="link showDocs">{#MAIN_STAT_CACHE_SHOW#}</a></span></td>
</tr> </tr>
<tr> <tr>
<td>{#MAIN_STAT_RUBRICS#}</td> <td>{#MAIN_STAT_RUBRICS#}</td>

23
class/class.database.php

@ -1414,6 +1414,29 @@
} }
/**
* Метод, предназначенный для очищения кеша документов
*
* @param $cache_id
* @return bool
*/
public function clearCurrentCache($cache_id, $sql = '', $ext = '')
{
$cache_id = $this->cacheId($cache_id);
$cache_file = md5($sql) . $ext;
$cache_dir = BASE_DIR . '/tmp/cache/sql/' . (trim($cache_id) > ''
? trim($cache_id) . '/'
: substr($cache_file, 0, 2) . '/' . substr($cache_file, 2, 2) . '/' . substr($cache_file, 4, 2) . '/');
if (file_exists($cache_dir . $cache_file))
unlink($cache_dir . $cache_file);
return true;
}
/** /**
* Метод, предназначенный для очищения кеша документов * Метод, предназначенный для очищения кеша документов
* *

10
class/class.rubs.php

@ -75,14 +75,11 @@
$sql = $AVE_DB->Query(" $sql = $AVE_DB->Query("
SELECT SELECT
rub.*, rub.*,
COUNT(doc.Id) AS doc_count, (SELECT 1 FROM " . PREFIX . "_documents WHERE rubric_id = rub.Id LIMIT 1) AS doc_count,
(SELECT count(*) FROM " . PREFIX . "_rubric_fields AS fld WHERE fld.rubric_id = rub.Id) AS fld_count, (SELECT count(*) FROM " . PREFIX . "_rubric_fields AS fld WHERE fld.rubric_id = rub.Id) AS fld_count,
(SELECT count(*) FROM " . PREFIX . "_rubric_templates AS tmpls WHERE tmpls.rubric_id = rub.Id) AS tmpls_count (SELECT count(*) FROM " . PREFIX . "_rubric_templates AS tmpls WHERE tmpls.rubric_id = rub.Id) AS tmpls_count
FROM FROM
" . PREFIX . "_rubrics AS rub " . PREFIX . "_rubrics AS rub
LEFT JOIN
" . PREFIX . "_documents AS doc
ON rubric_id = rub.Id
GROUP BY rub.Id GROUP BY rub.Id
ORDER BY rub.rubric_position ORDER BY rub.rubric_position
LIMIT " . $set_start . "," . $page_limit LIMIT " . $set_start . "," . $page_limit
@ -1972,15 +1969,12 @@
SELECT SELECT
rub.*, rub.*,
rubrics.rubric_title, rubrics.rubric_title,
COUNT(doc.Id) AS doc_count (SELECT 1 FROM " . PREFIX . "_documents WHERE rubric_id = rub.rubric_id AND rubric_tmpl_id = rub.id LIMIT 1) AS doc_count
FROM FROM
" . PREFIX . "_rubric_templates AS rub " . PREFIX . "_rubric_templates AS rub
LEFT JOIN LEFT JOIN
" . PREFIX . "_rubrics AS rubrics " . PREFIX . "_rubrics AS rubrics
ON rubrics.Id = rub.rubric_id ON rubrics.Id = rub.rubric_id
LEFT JOIN
" . PREFIX . "_documents AS doc
ON (doc.rubric_id = rub.rubric_id AND doc.rubric_tmpl_id = rub.id)
WHERE WHERE
rub.rubric_id = '" . (int)$_REQUEST['Id'] . "' rub.rubric_id = '" . (int)$_REQUEST['Id'] . "'
GROUP GROUP

2
inc/config.php

@ -12,7 +12,7 @@
*/ */
@define('APP_NAME', 'AVE.cms'); @define('APP_NAME', 'AVE.cms');
@define('APP_VERSION', '3.24'); @define('APP_VERSION', '3.25');
@define('APP_INFO', '<a target="_blank" href="https://www.ave-cms.ru/">Ave-Cms.Ru</a> '.'&copy; 2007-' . date('Y')); @define('APP_INFO', '<a target="_blank" href="https://www.ave-cms.ru/">Ave-Cms.Ru</a> '.'&copy; 2007-' . date('Y'));
$GLOBALS['CMS_CONFIG']['USER_IP'] = array('DESCR' =>'Использовать IP для автологина на сайте','default'=>false,'TYPE'=>'bool','VARIANT'=>''); $GLOBALS['CMS_CONFIG']['USER_IP'] = array('DESCR' =>'Использовать IP для автологина на сайте','default'=>false,'TYPE'=>'bool','VARIANT'=>'');

18
inc/sitemap.php

@ -11,7 +11,6 @@
* @license GPL v.2 * @license GPL v.2
*/ */
header ('Content-type: text/xml');
define ('START_MICROTIME', microtime()); define ('START_MICROTIME', microtime());
@ -53,6 +52,8 @@
'6' => 'never' '6' => 'never'
); );
if (! isset($_REQUEST['id'])):
// Вытаскиваем кол-во документов // Вытаскиваем кол-во документов
$sql = " $sql = "
SELECT STRAIGHT_JOIN SELECT STRAIGHT_JOIN
@ -91,7 +92,8 @@
if ($num > $_end) if ($num > $_end)
$parts = ceil($num/$_end); $parts = ceil($num/$_end);
if (! isset($_REQUEST['id'])): header ('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL; echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
echo '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL; echo '<sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL;
@ -149,7 +151,17 @@
LIMIT ".$_start.",".$_end."; LIMIT ".$_start.",".$_end.";
"; ";
$res = $AVE_DB->Query($sql, SITEMAP_CACHE_LIFETIME, 'sitemap'); $res = $AVE_DB->Query($sql, SITEMAP_CACHE_LIFETIME, 'sitemap', true, '.limit');
if (! $res->NumRows())
{
report404();
$AVE_DB->clearCurrentCache('sitemap', $sql, '.limit');
header ($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true);
exit;
}
header ('Content-type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL; echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL; echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . PHP_EOL;

25
inc/thumb.php

@ -69,7 +69,10 @@
} }
//-- Подгружаем настройки системы //-- Подгружаем настройки системы
require(dirname(__FILE__) . '/config.php'); require (dirname(__FILE__) . '/config.php');
//-- Подгружаем функции логирования
require_once BASE_DIR . '/functions/func.logs.php';
//-- Разрешенные расширения файлов //-- Разрешенные расширения файлов
$allowedExt = array('jpg', 'jpeg', 'png', 'gif', 'JPG', 'JPEG', 'PNG', 'GIF'); $allowedExt = array('jpg', 'jpeg', 'png', 'gif', 'JPG', 'JPEG', 'PNG', 'GIF');
@ -130,13 +133,23 @@
exit; exit;
} }
else
{
report404();
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
exit(0);
}
list(, $thumbPath) = explode('/' . UPLOAD_DIR . '/', dirname($imagefile), 2); list(, $thumbPath) = explode('/' . UPLOAD_DIR . '/', dirname($imagefile), 2);
$lenThumbDir = strlen(THUMBNAIL_DIR); $lenThumbDir = strlen(THUMBNAIL_DIR);
// --
if ($lenThumbDir && substr($thumbPath, -$lenThumbDir) != THUMBNAIL_DIR) if ($lenThumbDir && substr($thumbPath, -$lenThumbDir) != THUMBNAIL_DIR)
{
exit(0); exit(0);
}
$thumbPath = $baseDir . '/' . UPLOAD_DIR . '/' . $thumbPath; $thumbPath = $baseDir . '/' . UPLOAD_DIR . '/' . $thumbPath;
$imagePath = $lenThumbDir ? dirname($thumbPath) : $thumbPath; $imagePath = $lenThumbDir ? dirname($thumbPath) : $thumbPath;
@ -145,7 +158,7 @@
$nameParts = explode('.', $thumbName); $nameParts = explode('.', $thumbName);
$countParts = count($nameParts); $countParts = count($nameParts);
if ($countParts < 2 || !in_array(strtolower(end($nameParts)), $allowedExt)) if ($countParts < 2 || ! in_array(strtolower(end($nameParts)), $allowedExt))
exit(0); exit(0);
$matches = array(); $matches = array();
@ -156,6 +169,8 @@
//-- Если нет параметров, отдаем 404 //-- Если нет параметров, отдаем 404
if (! isset($matches[0])) if (! isset($matches[0]))
{ {
report404();
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
exit(0); exit(0);
} }
@ -167,6 +182,8 @@
{ {
if (! in_array($check, $allowedAdmin)) if (! in_array($check, $allowedAdmin))
{ {
report404();
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
exit(0); exit(0);
} }
@ -224,6 +241,8 @@
{ {
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found');
report404();
$imageName = 'noimage.png'; $imageName = 'noimage.png';
if (! file_exists("$imagePath/$imageName")) if (! file_exists("$imagePath/$imageName"))
@ -281,7 +300,7 @@
//-- Если можно сохранять миниатюру //-- Если можно сохранять миниатюру
if ($save) if ($save)
{ {
if (! file_exists($thumbPath) && ! mkdir($thumbPath, 0777)) if (! file_exists($thumbPath) && ! mkdir($thumbPath, 0777, true))
exit(0); exit(0);
if ($thumb->save("$thumbPath/$thumbName")) if ($thumb->save("$thumbPath/$thumbName"))

Loading…
Cancel
Save