Возможность получить старый path нахождения аттачей или аватар используя одну функцию

This commit is contained in:
PheRum 2014-11-06 12:38:57 +03:00
commit dd6e9aed8e
17 changed files with 113 additions and 103 deletions

View file

@ -89,8 +89,7 @@ if ($is_moderator)
'S_GROUP_CONFIG_ACTION' => "group_edit.php?" . POST_GROUPS_URL . "=$group_id", 'S_GROUP_CONFIG_ACTION' => "group_edit.php?" . POST_GROUPS_URL . "=$group_id",
'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], $bb_cfg['group_avatars']['max_width'], $bb_cfg['group_avatars']['max_height'], (round($bb_cfg['group_avatars']['max_size'] / 1024))), 'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], $bb_cfg['group_avatars']['max_width'], $bb_cfg['group_avatars']['max_height'], (round($bb_cfg['group_avatars']['max_size'] / 1024))),
'AVATAR_URL_PATH' => ($group_info['avatar_ext_id']) ? get_avatar_path(GROUP_AVATAR_MASK . $group_id, $group_info['avatar_ext_id']) : '', 'AVATAR_IMG' => get_avatar(GROUP_AVATAR_MASK . $group_id, $group_info['avatar_ext_id']),
'RELEASE_GROUP' => ($group_info['release_group']) ? true : false, 'RELEASE_GROUP' => ($group_info['release_group']) ? true : false,
)); ));

View file

@ -381,7 +381,7 @@ if ($bb_cfg['birthday_check_day'] && $bb_cfg['birthday_enabled'])
continue; continue;
} }
$week_list[] = profile_url($week) .' <span class="small">('. birthday_age($week['user_birthday']) .')</span>'; $week_list[] = profile_url($week) .' <span class="small">('. birthday_age($week['user_birthday']-1) .')</span>';
} }
$week_all = ($week_all) ? '&nbsp;<a class="txtb" href="#" onclick="ajax.exec({action: \'index_data\', mode: \'birthday_week\'}); return false;" title="'. $lang['ALL'] .'">...</a>' : ''; $week_all = ($week_all) ? '&nbsp;<a class="txtb" href="#" onclick="ajax.exec({action: \'index_data\', mode: \'birthday_week\'}); return false;" title="'. $lang['ALL'] .'">...</a>' : '';
$week_list = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], join(', ', $week_list)) . $week_all; $week_list = sprintf($lang['BIRTHDAY_WEEK'], $bb_cfg['birthday_check_day'], join(', ', $week_list)) . $week_all;

View file

@ -538,50 +538,6 @@ $bb_cfg['ad_blocks'] = array(
), ),
); );
// Attachments
$bb_cfg['attach'] = array(
'upload_path' => DATA_DIR . 'torrent_files', // without '/'
'max_size' => 250*1024, // bytes
);
$bb_cfg['file_id_ext'] = array(
1 => 'gif',
2 => 'gz',
3 => 'jpg',
4 => 'png',
5 => 'rar',
6 => 'tar',
7 => 'tiff',
8 => 'torrent',
9 => 'zip',
);
$bb_cfg['tor_forums_allowed_ext'] = array('torrent', 'zip', 'rar'); // для разделов с раздачами
$bb_cfg['gen_forums_allowed_ext'] = array('zip', 'rar'); // для обычных разделов
// Avatars
$bb_cfg['avatars'] = array(
'allowed_ext' => array('gif','jpg','jpeg','png'), // разрешенные форматы файлов
'bot_avatar' => 'gallery/bot.gif', // аватара бота
'max_size' => 100*1024, // размер аватары в байтах
'max_height' => 100, // высота аватара в px
'max_width' => 100, // ширина аватара в px
'no_avatar' => 'gallery/noavatar.png', // дефолтная аватара
'upload_path' => BB_ROOT . 'data/avatars/', // путь к директории с аватарами
'up_allowed' => true, // разрешить загрузку аватар
);
// Group avatars
$bb_cfg['group_avatars'] = array(
'allowed_ext' => array('gif','jpg','jpeg','png'), // разрешенные форматы файлов
'max_size' => 300*1024, // размер аватары в байтах
'max_height' => 300, // высота аватара в px
'max_width' => 300, // ширина аватара в px
'no_avatar' => 'gallery/noavatar.png', // дефолтная аватара
'upload_path' => BB_ROOT . 'data/avatars/', // путь к директории с аватарами
'up_allowed' => true, // разрешить загрузку аватар
);
// Misc // Misc
define('MEM_USAGE', function_exists('memory_get_usage')); define('MEM_USAGE', function_exists('memory_get_usage'));
@ -618,18 +574,62 @@ $bb_cfg['user_agreement_url'] = 'info.php?show=user_agreement';
$bb_cfg['copyright_holders_url'] = 'info.php?show=copyright_holders'; $bb_cfg['copyright_holders_url'] = 'info.php?show=copyright_holders';
$bb_cfg['advert_url'] = 'info.php?show=advert'; $bb_cfg['advert_url'] = 'info.php?show=advert';
$bb_cfg['file_id_ext'] = array(
1 => 'gif',
2 => 'gz',
3 => 'jpg',
4 => 'png',
5 => 'rar',
6 => 'tar',
7 => 'tiff',
8 => 'torrent',
9 => 'zip',
);
$bb_cfg['tor_forums_allowed_ext'] = array('torrent', 'zip', 'rar'); // для разделов с раздачами
$bb_cfg['gen_forums_allowed_ext'] = array('zip', 'rar'); // для обычных разделов
// Attachments
$bb_cfg['attach'] = array(
'upload_path' => DATA_DIR . 'torrent_files', // путь к директории с torrent файлами
'max_size' => 250*1024, // размер аватары в байтах
);
// Avatars
$bb_cfg['avatars'] = array(
'allowed_ext' => array('gif','jpg','jpeg','png'), // разрешенные форматы файлов
'bot_avatar' => 'gallery/bot.gif', // аватара бота
'max_size' => 100*1024, // размер аватары в байтах
'max_height' => 100, // высота аватара в px
'max_width' => 100, // ширина аватара в px
'no_avatar' => 'gallery/noavatar.png', // дефолтная аватара
'upload_path' => BB_ROOT . 'data/avatars/', // путь к директории с аватарами
'up_allowed' => true, // разрешить загрузку аватар
);
// Group avatars
$bb_cfg['group_avatars'] = array(
'allowed_ext' => array('gif','jpg','jpeg','png'), // разрешенные форматы файлов
'max_size' => 300*1024, // размер аватары в байтах
'max_height' => 300, // высота аватара в px
'max_width' => 300, // ширина аватара в px
'no_avatar' => 'gallery/noavatar.png', // дефолтная аватара
'upload_path' => BB_ROOT . 'data/avatars/', // путь к директории с аватарами
'up_allowed' => true, // разрешить загрузку аватар
);
// Captcha // Captcha
$bb_cfg['captcha'] = array( $bb_cfg['captcha'] = array(
'disabled' => false, 'disabled' => false,
'secret_key' => 'secret_key', 'secret_key' => 'secret_key',
'img_path' => INT_DATA_DIR .'captcha/', # with '/' 'img_path' => INT_DATA_DIR .'captcha/', // with '/'
'img_url' => './internal_data/captcha/', # with '/' 'img_url' => './internal_data/captcha/', // with '/'
); );
// Atom feed // Atom feed
$bb_cfg['atom'] = array( $bb_cfg['atom'] = array(
'path' => INT_DATA_DIR .'atom', # without '/' 'path' => INT_DATA_DIR .'atom', // without '/'
'url' => './internal_data/atom', # without '/' 'url' => './internal_data/atom', // without '/'
); );
// Nofollow // Nofollow

View file

@ -1,5 +1,7 @@
<?php <?php
if (!defined('BB_ROOT')) die(basename(__FILE__));
// //
// $Id: sphinxapi.php 2055 2009-11-06 23:09:58Z shodan $ // $Id: sphinxapi.php 2055 2009-11-06 23:09:58Z shodan $
// //

View file

@ -1,5 +1,7 @@
<?php <?php
if (!defined('BB_ROOT')) die(basename(__FILE__));
/** /**
* Captcha * Captcha
*/ */

View file

@ -1,4 +1,7 @@
<?php <?php
if (!defined('BB_ROOT')) die(basename(__FILE__));
/** /**
* Automatic correction of the language for words in the text because of the wrong keyboard layout * Automatic correction of the language for words in the text because of the wrong keyboard layout
* Автоматическое исправление языка для слов в тексте из-за неправильной раскладки клавиатуры * Автоматическое исправление языка для слов в тексте из-за неправильной раскладки клавиатуры

View file

@ -1,4 +1,7 @@
<?php <?php
if (!defined('BB_ROOT')) die(basename(__FILE__));
/** /**
* A class for validating method parameters to allowed types via reflection. * A class for validating method parameters to allowed types via reflection.
* *

View file

@ -1,5 +1,7 @@
<?php <?php
if (!defined('BB_ROOT')) die(basename(__FILE__));
class sitemap class sitemap
{ {
var $home = ''; var $home = '';

View file

@ -1,4 +1,7 @@
<?php <?php
if (!defined('BB_ROOT')) die(basename(__FILE__));
/** /**
* PHP5 UTF-8 is a UTF-8 aware library of functions mirroring PHP's own string functions. * PHP5 UTF-8 is a UTF-8 aware library of functions mirroring PHP's own string functions.
* *

View file

@ -9,22 +9,25 @@ function get_path_from_id ($id, $ext_id, $base_path, $first_div, $sec_div)
return ($base_path ? "$base_path/" : '') . floor($id/$first_div) .'/'. ($id % $sec_div) .'/'. $id . ($ext ? ".$ext" : ''); return ($base_path ? "$base_path/" : '') . floor($id/$first_div) .'/'. ($id % $sec_div) .'/'. $id . ($ext ? ".$ext" : '');
} }
function get_avatar_path ($id, $ext_id, $base_path = '')
{
return get_path_from_id($id, $ext_id, $base_path, 5000, 100);
}
function delete_avatar ($user_id, $avatar_ext_id) function delete_avatar ($user_id, $avatar_ext_id)
{ {
global $bb_cfg; global $bb_cfg;
$avatar_file = ($avatar_ext_id) ? get_avatar_path($user_id, $avatar_ext_id, $bb_cfg['avatars']['upload_path']) : ''; $avatar_file = ($avatar_ext_id) ? get_avatar_path($user_id, $avatar_ext_id) : '';
return ($avatar_file && file_exists($avatar_file)) ? @unlink($avatar_file) : false; return ($avatar_file && file_exists($avatar_file)) ? @unlink($avatar_file) : false;
} }
function get_attach_path ($id) function get_avatar_path ($id, $ext_id, $base_path = null, $first_div = 10000, $sec_div = 100)
{ {
global $bb_cfg; global $bb_cfg;
return get_path_from_id($id, '', $bb_cfg['attach']['upload_path'], 1000, 100); $base_path = isset($base_path) ? $base_path : $bb_cfg['avatars']['upload_path'];
return get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div);
}
function get_attach_path ($id, $ext_id = '', $base_path = null, $first_div = 10000, $sec_div = 100)
{
global $bb_cfg;
$base_path = isset($base_path) ? $base_path : $bb_cfg['attach']['upload_path'];
return get_path_from_id($id, $ext_id, $base_path, $first_div, $sec_div);
} }
function get_tracks ($type) function get_tracks ($type)
@ -2755,17 +2758,17 @@ function get_avatar ($user_id, $ext_id, $allow_avatar = true, $size = true, $hei
$height = ($height != '') ? 'height="'. $height .'"' : ''; $height = ($height != '') ? 'height="'. $height .'"' : '';
$width = ($width != '') ? 'width="'. $width .'"' : ''; $width = ($width != '') ? 'width="'. $width .'"' : '';
$user_avatar = '<img src="'. $bb_cfg['avatars']['upload_path'] . $bb_cfg['avatars']['no_avatar'] .'" alt="'. $user_id .'" '. $height .' '. $width .' />'; $user_avatar = '<img src="'. make_url($bb_cfg['avatars']['upload_path'] . $bb_cfg['avatars']['no_avatar']) .'" alt="'. $user_id .'" '. $height .' '. $width .' />';
if ($user_id == BOT_UID && $bb_cfg['avatars']['bot_avatar']) if ($user_id == BOT_UID && $bb_cfg['avatars']['bot_avatar'])
{ {
$user_avatar = '<img src="'. $bb_cfg['avatars']['upload_path'] . $bb_cfg['avatars']['bot_avatar'] .'" alt="'. $user_id .'" '. $height .' '. $width .' />'; $user_avatar = '<img src="'. make_url($bb_cfg['avatars']['upload_path'] . $bb_cfg['avatars']['bot_avatar']) .'" alt="'. $user_id .'" '. $height .' '. $width .' />';
} }
else if ($allow_avatar && $ext_id) else if ($allow_avatar && $ext_id)
{ {
if (file_exists($bb_cfg['avatars']['upload_path'] . get_avatar_path($user_id, $ext_id))) if (file_exists(get_avatar_path($user_id, $ext_id)))
{ {
$user_avatar = '<img src="'. $bb_cfg['avatars']['upload_path'] . get_avatar_path($user_id, $ext_id) .'" alt="'. $user_id .'" '. $height .' '. $width .' />'; $user_avatar = '<img src="'. make_url(get_avatar_path($user_id, $ext_id)) .'" alt="'. $user_id .'" '. $height .' '. $width .' />';
} }
} }

View file

@ -1,5 +1,7 @@
<?php <?php
if (!defined('BB_ROOT')) die(basename(__FILE__));
class upload_common class upload_common
{ {
var $cfg = array( var $cfg = array(
@ -121,7 +123,7 @@ class upload_common
if ($mode == 'avatar') if ($mode == 'avatar')
{ {
delete_avatar($params['user_id'], $params['avatar_ext_id']); delete_avatar($params['user_id'], $params['avatar_ext_id']);
$file_path = get_avatar_path($params['user_id'], $this->file_ext_id, $bb_cfg['avatars']['upload_path']); $file_path = get_avatar_path($params['user_id'], $this->file_ext_id);
return $this->_move($file_path); return $this->_move($file_path);
} }
else if ($mode == 'attach') else if ($mode == 'attach')

View file

@ -766,14 +766,13 @@ $template->assign_vars(array(
'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], $bb_cfg['avatars']['max_width'], $bb_cfg['avatars']['max_height'], (round($bb_cfg['avatars']['max_size'] / 1024))), 'AVATAR_EXPLAIN' => sprintf($lang['AVATAR_EXPLAIN'], $bb_cfg['avatars']['max_width'], $bb_cfg['avatars']['max_height'], (round($bb_cfg['avatars']['max_size'] / 1024))),
'AVATAR_DISALLOWED' => bf($pr_data['user_opt'], 'user_opt', 'dis_avatar'), 'AVATAR_DISALLOWED' => bf($pr_data['user_opt'], 'user_opt', 'dis_avatar'),
'AVATAR_DIS_EXPLAIN' => sprintf($lang['AVATAR_DISABLE'], $bb_cfg['terms_and_conditions_url']), 'AVATAR_DIS_EXPLAIN' => sprintf($lang['AVATAR_DISABLE'], $bb_cfg['terms_and_conditions_url']),
'AVATAR_IMG' => get_avatar($pr_data['user_id'], $pr_data['avatar_ext_id'], !bf($pr_data['user_opt'], 'user_opt', 'dis_avatar')),
'SIGNATURE_EXPLAIN' => sprintf($lang['SIGNATURE_EXPLAIN'], $bb_cfg['max_sig_chars']), 'SIGNATURE_EXPLAIN' => sprintf($lang['SIGNATURE_EXPLAIN'], $bb_cfg['max_sig_chars']),
'SIG_DISALLOWED' => bf($pr_data['user_opt'], 'user_opt', 'dis_sig'), 'SIG_DISALLOWED' => bf($pr_data['user_opt'], 'user_opt', 'dis_sig'),
'PR_USER_ID' => $pr_data['user_id'], 'PR_USER_ID' => $pr_data['user_id'],
'U_RESET_AUTOLOGIN' => LOGIN_URL . "?logout=1&amp;reset_autologin=1&amp;sid={$userdata['session_id']}", 'U_RESET_AUTOLOGIN' => LOGIN_URL . "?logout=1&amp;reset_autologin=1&amp;sid={$userdata['session_id']}",
'AVATAR_URL_PATH' => ($pr_data['avatar_ext_id']) ? get_avatar_path($pr_data['user_id'], $pr_data['avatar_ext_id']) : '',
)); ));
print_page('usercp_register.tpl'); print_page('usercp_register.tpl');

View file

@ -1,9 +1,9 @@
<div> <div>
<h3>BitTorrent clients</h3> <h3>BitTorrent clients</h3>
<ul> <ul>
<li><a rel="nofollow" href="http://www.utorrent.com/" class="med"><b>uTorrent</b></a> <span class="med nowrap">(recommended: <b>3.4</b>)</span></li> <li><a rel="nofollow" href="http://www.utorrent.com/" class="med"><b>uTorrent</b></a></li>
<li><a rel="nofollow" href="http://www.bittorrent.com/" class="med"><b>BitTorrent</b></a> <span class="med nowrap">(recommended: <b>7.9</b>)</span></li> <li><a rel="nofollow" href="http://www.bittorrent.com/" class="med"><b>BitTorrent</b></a></li>
<li><a rel="nofollow" href="http://www.transmissionbt.com/" class="med"><b>Transmission</b></a> <span class="med nowrap">(recommended: <b>2.82</b>)</span></li> <li><a rel="nofollow" href="http://www.transmissionbt.com/" class="med"><b>Transmission</b></a></li>
</ul> </ul>
</div> </div>

View file

@ -1,9 +1,9 @@
<div> <div>
<h3>BitTorrent клиенты</h3> <h3>BitTorrent клиенты</h3>
<ul> <ul>
<li><a rel="nofollow" href="http://www.utorrent.com/" class="med"><b>uTorrent</b></a> <span class="med nowrap">(рекомендуемый: <b>3.4</b>)</span></li> <li><a rel="nofollow" href="http://www.utorrent.com/" class="med"><b>uTorrent</b></a></li>
<li><a rel="nofollow" href="http://www.bittorrent.com/" class="med"><b>BitTorrent</b></a> <span class="med nowrap">(рекомендуемый: <b>7.9</b>)</span></li> <li><a rel="nofollow" href="http://www.bittorrent.com/" class="med"><b>BitTorrent</b></a></li>
<li><a rel="nofollow" href="http://www.transmissionbt.com/" class="med"><b>Transmission</b></a> <span class="med nowrap">(рекомендуемый: <b>2.82</b>)</span></li> <li><a rel="nofollow" href="http://www.transmissionbt.com/" class="med"><b>Transmission</b></a></li>
</ul> </ul>
</div> </div>

View file

@ -1,9 +1,9 @@
<div> <div>
<h3>BitTorrent клієнти</h3> <h3>BitTorrent клієнти</h3>
<ul> <ul>
<li><a rel="nofollow" href="http://www.utorrent.com/intl/ru/" class="med"><b>uTorrent</b></a> <span class="med nowrap">(рекомендований: <b>3.4</b>)</span></li> <li><a rel="nofollow" href="http://www.utorrent.com/" class="med"><b>uTorrent</b></a></li>
<li><a rel="nofollow" href="http://www.bittorrent.com/intl/ru/" class="med"><b>BitTorrent</b></a> <span class="med nowrap">(рекомендований: <b>7.9</b>)</span></li> <li><a rel="nofollow" href="http://www.bittorrent.com/" class="med"><b>BitTorrent</b></a></li>
<li><a rel="nofollow" href="http://www.transmissionbt.com/" class="med"><b>Transmission</b></a> <span class="med nowrap">(рекомендований: <b>2.82</b>)</span></li> <li><a rel="nofollow" href="http://www.transmissionbt.com/" class="med"><b>Transmission</b></a></li>
</ul> </ul>
</div> </div>

View file

@ -68,19 +68,11 @@ function manage_group(mode, value) {
</tr> </tr>
<tr> <tr>
<td> <td>
{L_AVATAR}: {L_AVATAR}: <br /><br />
<!-- IF AVATAR_URL_PATH -->
<br /><br />
<div id="avatar" align="center"> <div id="avatar" align="center">
<p> <p>{AVATAR_IMG}</p><br />
<img src="{AVATARS_URL}/{AVATAR_URL_PATH}" alt="avatar" /> <p><input type="button" name="delete_avatar" value="{L_DELETE_IMAGE}" onclick="manage_group(this.name,this.value)" /></p>
</p>
<br />
<p>
<input type="button" name="delete_avatar" value="{L_DELETE_IMAGE}" onclick="manage_group(this.name,this.value)" />
</p>
</div> </div>
<!-- ENDIF -->
</td> </td>
<td valign="top"> <td valign="top">
<div id="avatar_explain" class="med">{AVATAR_EXPLAIN}</div> <div id="avatar_explain" class="med">{AVATAR_EXPLAIN}</div>

View file

@ -288,8 +288,8 @@ ajax.callback.posts = function(data){
<!-- ENDIF --> <!-- ENDIF -->
</td> </td>
<td class="tCenter nowrap"> <td class="tCenter nowrap">
<p class="mrg_6"><!-- IF AVATAR_URL_PATH --><img src="{AVATARS_URL}/{AVATAR_URL_PATH}" alt="avatar" /><!-- ELSE -->--<!-- ENDIF --></p> <p class="mrg_6">{AVATAR_IMG}</p>
<p><label><input type="checkbox" name="delete_avatar" <!-- IF not AVATAR_URL_PATH -->disabled="disabled"<!-- ENDIF --> /> {L_DELETE_IMAGE}</label></p> <p><label><input type="checkbox" name="delete_avatar" /> {L_DELETE_IMAGE}</label></p>
</td> </td>
</tr> </tr>
</table> </table>