Seleccionar idioma:
Realizar Donación - Mods Premium - Portfolio



Este sitio utiliza cookies propias y de terceros. Si continúa navegando consideramos que acepta el uso de cookies. OK Más Información.
* Ayuda con este MOD porfas
  Leído 514 veces
* Viendo el foro
 0 Usuarios y 1 Visitante están viendo este foro.


*
Nov 12 2018


Hola a todos:


Por favor, solicito la ayuda de alguien que me pueda orientar en qué me equivoco con esto que estoy haciendo, el cual es un mod que brinda la posibilidad a los members de buscar entre adjuntos así como la posibilidad de obtener una lista de los mismos.

Creo que estoy haciendo mal la consulta a la DB ... esto, literalmente me limó el cerebro y realmente lo necesito...

Dejo el código aquí, para el que lo quiera modificar y/o utilizar ... ( ayuda porfis )

Gracias de antemano !!



Código: [Seleccionar]
<?xml version="1.0"?>
<!DOCTYPE modification SYSTEM "http://www.simplemachines.org/xml/modification">
<modification xmlns="http://www.simplemachines.org/xml/modification" xmlns:smf="http://www.simplemachines.org/">
<id>Listado de Attachments</id>
<name>genera lista</name>
<version>1.0</version>

<file name="$boarddir/index.php" >
<operation>
<search position="after"><![CDATA['buddy' => array('Subs-Members.php', 'BuddyListToggle'),]]></search>
<add><![CDATA['BrowseAttachments' => array('ManageAttachments.php', 'BrowseAttachments'),]]></add>
</operation>
</file>

<file name="$sourcedir/ManageAttachments.php" >
<operation>
<search position="after"><![CDATA[
$_SESSION['attachments_to_fix'] = $to_fix;
$_SESSION['attachments_to_fix2'] = $context['repair_errors'];

obExit();
}]]></search>
<add><![CDATA[function BrowseAttachments()
{
global $context, $smcFunc, $txt, $scripturl, $options, $modSettings, $user_info;

//Let's see who is allowed to see the list?
//No Guests :P
if($context['user']['is_guest'])
redirectexit();
   //Okay now let's work a little bit :x
else {
//Admins are everytime allowed :P
if(!$context['user']['is_admin']) {
if(empty($modSettings['Allowed_Attachments_Groups']))
redirectexit();
else {
//Clean the ModSettings i will only numbers and ,
preg_match_all('/(?:([0-9,]+)|.)/i', $modSettings['Allowed_Attachments_Groups'], $matches);
$allow_array = implode('', $matches['1']);
$allow_array = explode(',', $allow_array);
if(empty($allow_array))
redirectexit();
else {
$noredirect = FALSE;
//Huf why could it not simpler, i hate it.
foreach($allow_array as $gid) {
$noredirect = in_array($gid, $user_info['groups']);
if($noredirect) break;
}
//Okay he or she is not in the Allowed Groups... go back to the index :P
if(!$noredirect)
redirectexit();
}
}
}
}

//Language
loadLanguage('Admin');

//Need to Check something
$_REQUEST['sa'] = empty($_REQUEST['sa']) ? '' : $_REQUEST['sa'];

//Okay did you Serach something? Prepare and Redirect!
if(!empty($_REQUEST['search'])) {
$context['search'] = strtolower(trim(preg_replace('~&amp;#(\d{4,5}|[2-9]\d{2,4}|1[2-9]\d);~', '&#$1;', htmlspecialchars($_REQUEST['search']))));
$context['search'] = addslashes($context['search']);

//Okay i simple encode it :) better browser compatible!
$context['hidden_search'] = base64_encode($context['search']);

//Okay go to the serach :x
redirectexit("action=BrowseAttachments;search2=".$context['hidden_search'] . (isset($_REQUEST['searchoption']) ? ';'.$_REQUEST['searchoption'] : ''));
}

//The Real Search is now working?
elseif(!empty($_GET['search2'])) {
SearchFiles();
}

//Okay only Browsing the files xD
else {
//Load the Attachements :P
BrowseFiles();

    //Creat a new Page Index!
$context['page_index'] = constructPageIndex($scripturl . '?action=BrowseAttachments' . ($context['browse_type'] == 'attachments' ? '' : ';' . $context['browse_type']) . ';sort=' . $context['sort_by'] . ($context['sort_direction'] == 'down' ? ';desc' : ''), $_REQUEST['start'], $context['num_' . $context['browse_type']], $modSettings['defaultMaxMessages']);
$context['sub_template'] = 'browse_special';
}

//Finish it!
loadTemplate('ManageAttachments');
}

function SearchFiles()
{
global $context, $smcFunc, $txt, $scripturl, $options, $modSettings;

$context['page_title'] = $txt['attachments_avatars'];
$context['description'] = $txt['smf202'];
$context['selected'] = 'search';
$context['sub_template'] = 'browse_special';

// Attachments or avatars?
$context['browse_type'] = 'attachments';

// Some preparing ;)
if(!empty($_REQUEST['search2'])) {
$context['search'] = base64_decode($_REQUEST['search2']);
$context['hidden_search'] = $_REQUEST['search2'];
}
else {
redirectexit("action=BrowseAttachments");
}

$context['search_option'] = (isset($_REQUEST['each']) ? 'each' : isset($_REQUEST['word']) ? 'word' : '');

//Okay you want to search each splited word... (Huge...)
if(isset($_REQUEST['each'])) {
$index = split(" ", $context['search']);
$index = array_unique($index);
reset($index);
//Okay lets generate the like index :P
$context['search_query_standard'] = "
filename LIKE '%".implode("%'
AND filename LIKE '%", $index)."%'";
$context['search_query_standard_a'] = "
a.filename LIKE '%".implode("%'
AND a.filename LIKE '%", $index)."%'";
}
elseif(isset($_REQUEST['word'])) {
$index = split(" ", $context['search']);
$index = array_unique($index);
reset($index);
//Okay lets generate the like index :P
$context['search_query_standard'] = "
(filename LIKE '%".implode("%'
OR filename LIKE '%", $index)."%')";
$context['search_query_standard_a'] = "
(a.filename LIKE '%".implode("%'
OR a.filename LIKE '%", $index)."%')";
}
else {
$context['search_query_standard'] = "filename LIKE '%".$context['search']."%'";
$context['search_query_standard_a'] = "a.filename LIKE '%".$context['search']."%'";
}

if ($browse_type === 'avatars')
$request = $smcFunc['db_query']('', '
SELECT COUNT(*)
FROM {db_prefix}attachments
WHERE id_member != {int:guest_id_member}',
array(
'guest_id_member' => 0,
)
)
else {
$request = $smcFunc['db_query']('', '
SELECT COUNT(*) AS num_attach
FROM {db_prefix}attachments AS a
INNER JOIN {db_prefix}messages AS m ON (m.id_msg = a.id_msg)
INNER JOIN {db_prefix}topics AS t ON (t.id_topic = m.id_topic)
INNER JOIN {db_prefix}messages AS mf ON (mf.id_msg = t.id_first_msg)
WHERE a.attachment_type = {int:attachment_type}
AND a.id_member = {int:guest_id_member}',
array(
'attachment_type' => $browse_type === 'thumbs' ? '3 : '0',
'guest_id_member' => 0,
)
);
}

list ($num_files) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);

return $num_files;

// Also get the avatar amount.
$request = $smcFunc['db_query']('', '
SELECT COUNT(id_attach)
FROM {db_prefix}attachments
WHERE id_member != 0
AND $context[search_query_standard]',
);
$smcFunc['db_free_result']($request);

// Allow for sorting of each column...
$sort_methods = array(
'name' => 'a.filename',
'date' => $context['browse_type'] == 'avatars' ? 'mem.last_Login' : 'm.id_msg',
'size' => 'a.size',
'member' => 'mem.real_name'
);

// Set up the importantant sorting variables... if they picked one...
if (!isset($_GET['sort']) || !isset($sort_methods[$_GET['sort']]))
{
$_GET['sort'] = 'date';
$descending = !empty($options['view_newest_first']);
}
// ... and if they didn't...
else {
$descending = isset($_GET['desc']);
}
$context['sort_by'] = $_GET['sort'];
$_GET['sort'] = $sort_methods[$_GET['sort']];
$context['sort_direction'] = $descending ? 'down' : 'up';

// Get the page index ready......
if (!isset($_REQUEST['start']) || $_REQUEST['start'] < 0)
$_REQUEST['start'] = 0;

$context['page_index'] = constructPageIndex($scripturl . '?action=BrowseAttachments;search2=' . $context['hidden_search'] . (!empty($context['search_option']) ? ';'.$context['search_option'] : '') . ';sort=' . $context['sort_by'] . ($context['sort_direction'] == 'down' ? ';desc' : ''), $_REQUEST['start'], $context['num_' . $context['browse_type']], $modSettings['defaultMaxMessages']);
$context['start'] = $_REQUEST['start'];

// Choose a query depending on what we are viewing.
if ($context['browse_type'] == 'avatars')
$request = $smcFunc['db_query']('', '
SELECT
'' AS id_msg, IFNULL(mem.real_Name, '$txt['not_applicable']') AS poster_Name, mem.last_Login AS poster_time, 0 AS ID_TOPIC, a.id_member,
a.ID_ATTACH, a.filename, a.attachment_Type, a.size, a.width, a.height, a.downloads, '' AS subject, 0 AS ID_BOARD
FROM {db_prefix}attachments AS a
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = a.id_member)
WHERE a.id_member != 0
AND $context[search_query_standard_a]
ORDER BY $_GET[sort] ' . ($descending ? 'DESC' : 'ASC') . '
LIMIT $context[start], $modSettings[defaultMaxMessages]',
);
else {
$request = $smcFunc['db_query']('', '
SELECT
m.id_msg, IFNULL(mem.real_Name, m.poster_Name) AS poster_Name, m.poster_time, m.ID_TOPIC, m.id_member,
a.ID_ATTACH, a.filename, a.attachment_Type, a.size, a.width, a.height, a.downloads, mf.subject, t.ID_BOARD
FROM ({db_prefix}attachments AS a, {db_prefix}messages AS m, {db_prefix}topics AS t, {db_prefix}messages AS mf)
LEFT JOIN {db_prefix}members AS mem ON (mem.id_member = m.id_member)
WHERE a.id_msg = m.id_msg
AND a.attachment_Type = ' . ($context['browse_type'] == 'attachments' ? '0' : '3') . '
AND t.ID_TOPIC = m.ID_TOPIC
AND mf.id_msg = t.ID_FIRST_MSG
AND $context[search_query_standard_a]
ORDER BY $_GET[sort] ' . ($descending ? 'DESC' : 'ASC') . '
LIMIT $context[start], $modSettings[defaultMaxMessages]',
);
}

$context['posts'] = array();
while ($row = $smcFunc['db_fetch_assoc'] ($result))
$context['posts'][] = array(
'id' => $row['id_msg'],
'poster' => array(
'id' => $row['id_member'],
'name' => $row['poster_Name'],
'href' => empty($row['id_member']) ? '' : $scripturl . '?action=profile;u=' . $row['id_member'],
'link' => empty($row['id_member']) ? $row['poster_Name'] : '<a href="' . $scripturl . '?action=profile;u=' . $row['id_member'] . '">' . $row['poster_Name'] . '</a>'
),
'time' => empty($row['poster_time']) ? $txt['never'] : timeformat($row['poster_time']),
'timestamp' => forum_time(true, $row['poster_time']),
'attachment' => array(
'id' => $row['ID_ATTACH'],
'size' => $_FILES['attachment']['size'][$n],
'width' => $row['width'],
'height' => $row['height'],
'name' => $_FILES['attachment']['name'][$n],
'downloads' => $row['downloads'],
'href' => $row['attachment_Type'] == 1 ? $modSettings['custom_avatar_url'] . '/' . $row['filename'] : ($scripturl . '?action=dlattach;' . ($context['browse_type'] == 'avatars' ? 'type=avatar;' : 'topic=' . $row['ID_TOPIC'] . '.0;') . 'id=' . $row['ID_ATTACH']),
'link' => '<a href="' . ($row['attachment_Type'] == 1 ? $modSettings['custom_avatar_url'] . '/' . $row['filename'] : ($scripturl . '?action=dlattach;' . ($context['browse_type'] == 'avatars' ? 'type=avatar;' : 'topic=' . $row['ID_TOPIC'] . '.0;') . 'id=' . $row['ID_ATTACH'])) . '"' . (empty($row['width']) || empty($row['height']) ? '' : ' onclick="return reqWin(this.href + \';image\', ' . ($row['width'] + 20) . ', ' . ($row['height'] + 20) . ', true);"') . '>' . $row['filename'] . '</a>'
),
'topic' => $row['ID_TOPIC'],
'subject' => $row['subject'],
'link' => '<a href="' . $scripturl . '?topic=' . $row['ID_TOPIC'] . '.0">' . $row['subject'] . '</a>'
);

$smcFunc['db_free_result']($request);]]></add>
</operation>
</file>

<file name="$sourcedir/ManageSettings.php">
<operation>
<search position="replace"><![CDATA[ '',
// Reporting of personal messages?
array('check', 'enableReportPM'),]]></search>
<add><![CDATA[ '',
// Reporting of personal messages?
array('check', 'enableReportPM'),
'',
// Select the Groups?
array('text', 'Allowed_Attachments_Groups'),]]></add>
</operation>
</file>

<file name="$boarddir/Themes/default/ManageAttachments.template.php">
<operation>
<search position="before"><![CDATA[?>]]></search>
<add><![CDATA[function template_browse_special()
{
global $context, $settings, $options, $scripturl, $txt;

echo '
<table border="0" align="center" cellspacing="1" cellpadding="4" class="bordercolor" width="100%">
<form action="'.$scripturl.'?action=BrowseAttachments" method="post" name="AttachmentSearch">
<tr class="titlebg">
<td>', $txt['attachment_manager_browse_files'], '</td>
<td colspan="3" align="right">
<input type="text" name="search" value="" style="width: 160px;" />&nbsp;
<select name="searchoption" size="1" style="width: 75px;">
<option value="exact" selected="selected">'.$txt['attach_exact'].'</option>
<option value="each">'.$txt['attach_each'].'</option>
<option value="word">'.$txt['attach_word'].'</option>
</select>
<input type="submit" name="submit" value="', $txt[182], '" style="width: 11ex;" />
</td>
</tr>
</form>';

echo '
<tr class="titlebg">
<td nowrap="nowrap"><a href="', $scripturl, '?action=BrowseAttachments;', (isset($context['hidden_search']) ? 'search2='.$context['hidden_search'].';' : '') , $context['browse_type'], ';sort=name', $context['sort_by'] == 'name' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt['smf213'], $context['sort_by'] == 'name' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a></td>
<td nowrap="nowrap"><a href="', $scripturl, '?action=BrowseAttachments;', (isset($context['hidden_search']) ? 'search2='.$context['hidden_search'].';' : '') , $context['browse_type'], ';sort=size', $context['sort_by'] == 'size' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $txt['smf214'], $context['sort_by'] == 'size' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a></td>
<td nowrap="nowrap"><a href="', $scripturl, '?action=BrowseAttachments;', (isset($context['hidden_search']) ? 'search2='.$context['hidden_search'].';' : '') , $context['browse_type'], ';sort=member', $context['sort_by'] == 'member' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $context['browse_type'] == 'avatars' ? $txt['attachment_manager_member'] : $txt[279], $context['sort_by'] == 'member' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a></td>
<td nowrap="nowrap"><a href="', $scripturl, '?action=BrowseAttachments;', (isset($context['hidden_search']) ? 'search2='.$context['hidden_search'].';' : '') , $context['browse_type'], ';sort=date', $context['sort_by'] == 'date' && $context['sort_direction'] == 'up' ? ';desc' : '', '">', $context['browse_type'] == 'avatars' ? $txt['attachment_manager_last_active'] : $txt[317], $context['sort_by'] == 'date' ? ' <img src="' . $settings['images_url'] . '/sort_' . $context['sort_direction'] . '.gif" alt="" />' : '', '</a></td>
</tr>';
$alternate = false;
foreach ($context['posts'] as $post)
{
echo '
<tr class="', $alternate ? 'windowbg' : 'windowbg2', '">
<td>', $post['attachment']['link'], empty($post['attachment']['width']) || empty($post['attachment']['height']) ? '' : ' <span class="smalltext">' . $post['attachment']['width'] . 'x' . $post['attachment']['height'] . '</span>', '</td>
<td align="right">', $post['attachment']['size'], $txt['smf211'], '</td>
<td>', $post['poster']['link'], '</td>
<td class="smalltext">', $post['time'], $context['browse_type'] != 'avatars' ? '<br />' . $txt['smf88'] . ' ' . $post['link'] : '', '</td>
</tr>';
$alternate = !$alternate;
}
echo '
<tr class="catbg">
<td align="left" colspan="5" style="padding: 5px;"><b>', $txt[139], ':</b> ', $context['page_index'], '</td>
</tr>
</table>';
}]]></add>
</operation>
</file>
</modification>

1.1.19

Mensajes: 2

Ver Perfil 

En línea




Otros temas de su interes

Error Country flag sombra_21 Octubre 24, 2013, 12:59:56 pm
Fecha de nacimiento en Registro nodensdorian Diciembre 23, 2011, 08:49:30 am
Cual es este mod ¿es pago? ¿se hace manual? ¿como se hace? pipi2010 Septiembre 22, 2010, 07:49:14 am
Sd Automatic index pregunta Ryo-Odin Noviembre 07, 2010, 07:39:09 pm
MOD Thank-o-Matic error piola2.0 Octubre 25, 2011, 10:05:55 pm
Mod: Sqlite3 Cache Jack Julio 19, 2012, 08:14:18 am



Usuario:
Contraseña:
Sesión:
hermes bracelet replica, christian louboutin replica, van cleef and arpels replica, red bottoms replica, cartier love bracelet replica christian louboutin replica, christian louboutin replica, hermes bracelet replica,