News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

email Inactive Users

Started by Isa.F, August 06, 2014, 11:20:01 PM

Previous topic - Next topic

Isa.F

Tinha este mod instalado sem problemas, ou pelo menos assim penso. http://custom.simplemachines.org/mods/index.php?mod=3849

Mas como estava a ter uma serie de bugs, reinstalei o fórum de raiz com a versão 2.0.8, não reinstalei alguns mods, e fiz uma selecçao e instalei versões mais recentes de alguns mods...

Fiquei com o fórum a zeros, e fui reinstalando os mods que queria, o único mod que me deu problemas foi este. Resolvi outros problemas, mas agora apareceu-me este...

Tenho que ir dormir que já não estou a ter paciencia para isto...


Quando o tento reinstalar, reparo que ele supostamente instala, ou seja, move os ficheiros que tem a mover, e faz algumas  modificações que supostamente tem a fazer, tanto que até me aparece o menu na admin... No entanto, no quadro dos mods ele aparece como desinstalado...  :-[ E se tento instala.lo o erro é sempre o mesmo:

Quote"Erro na base de dados
Duplicate entry 'emailInactiveUsers' for key 'task'
Ficheiro: /home/pedacinh/public_html/Packages/temp/install.php
Linha: 86


Nota: Parece que a sua base de dados precisa de ser actualizada. Os ficheiros estão na versão SMF 2.0.8, enquanto a sua base de dados está na versão 2.0.2. O erro pode ser eliminado se executar a última versão de upgrade.php."

Esse é o erro que aparece no painel de pacotes...


Mas depois no painel dos erros, aparecem destes ás dezenas:

http://pedacinhos-de-nos.net/index.php?action=admin;area=logs;sa=errorlog;desc
8: Undefined index: eiu_list
Ficheiro: /home/pedacinh/public_html/Sources/emailInactiveUsers.php
Linha: 28

http://pedacinhos-de-nos.net/index.php?action=admin;area=logs;sa=errorlog;desc
8: Undefined index: eiu_general
Ficheiro: /home/pedacinh/public_html/Sources/emailInactiveUsers.php
Linha: 27

http://pedacinhos-de-nos.net/index.php?action=admin;area=logs;c82bdac5=b71c1b86ecd2b25a6b96e98d71be3cce
Aplicar Filtro: Mostrar apenas os erros com a mesma mensagem
8: Undefined index: eiu_title
Ficheiro: /home/pedacinh/public_html/Sources/emailInactiveUsers.php
Linha: 22


Fogo, estou frustrada... Acho que tem a ver com a base de dados, uma vez que usei a mesma ao reinstalar o fórum, terá alguma coisa a ver com as tabelas, sei lá, já não percebo nada...

Estou frustrada  :-[


margarett

Tem calma. Se isto fosse fácil não tinha piada nenhuma :P

Esse erro acontece porque não desinstalaste o MOD, o que quer dizer que as alterações à BD ficaram lá. Quando instalas ele tenta criar um registo que já existe e por isso dá esse erro.

Tem de se apagar manualmente os "restos" :P da BD ou editar o instalador para que não tente criar o mesmo conteúdo 2x.
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Isa.F


Sim, é verdade, mas ontem parecia que tudo corria mal, bolas  :-[ A ver se hoje corre melhor  :)

Obrigada pela tua paciência  :) Achei que era desta que me mandavas ir dar uma volta ao bilhar grande, lol  :P


Ora então, desinstalar manualmente nos ficheiros costuma ser pacífico até porque este mod move uns ficheiros inteiros e é só apagar os ditos cujos...

O problema é mesmo na base de dados , ja estive a olhar para o ins tall para ver se me dá umas pistas mas nao estou  a ver...

Por acaso nao me sabes dizer o que tenho que apagar ?  ::)

Obrigada ;)

margarett

Sei, mas tenho de estar no pc ;)

Entretanto desinstala-o pelo gestor de pacotes, não manualmente. Se te der erros não continues, diz-me que erros é que dá ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Isa.F

 Isso queria eu, mas nao dá  :(

É que no painel de instalação de pacotes, o mod nao está supostamente instalado...

A opção que tem lá é   'instalar mod'

E quando até tento clicar em   'instalar mod' é quando dá o erro que referi...

No entanto ele está simi-instalado pois as definições do mod na admin estão lá todas bem como os ficheiros movidos. ..


Ja tentei apagar manualmente o que conseguia,  apagando os ficheiros movidos mas depois quando clico em instalar mod ele faz exactamente a mesma coisa que é semi-instalar o mod , mover novamente os ficheiros , e no fim da -me o tal erro que falei em cima. ..

Daí eu ontem ja estar a trepar pelas paredes com este mod... ele nao me deixa nem desinstalar nem instalar a 100%...


Penso que terei de o desinstalar todo manualmente inclusive tudo o que está na base de dados. .. e para isso preciso mesmo de ajuda que é para nao fazer asneiras ... :-[

margarett

O MOD usa principalmente "hooks" por isso a primeira coisa a fazer é apagar os ficheiros que o MOD copia. Na ausência dos ficheiros, os hooks falham silenciosamente e não chateiam ninguém.

Depois é preciso reverter as alterações à BD. Tenho de investigar isso e depois digo-te ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Isa.F

ACTUALIZAÇAO:

Como disse no outro tópico, já reinstalei o fórum fresquinho de base  :)

E não me arrisquei a instalar o tal email inactive users, como tal, á partida não tenho ficheiros nenhuns do mod.

No entanto, eu gosto desse mod e pretendo voltar a reinstala-lo.

Mas não me quero arriscar a instala-lo sem primeiro limpar esses restos na base de dados...  8)


Bruno, fico a aguardar então que me dês umas luzes sobre onde encontrar esses  restinhos!  ;)

margarett

OK, então:

Verifica que o ficheiro Sources\emailInactiveUsers.php não existe. Se existir, apaga-o.
Verifica que o ficheiro Themes\default\emailInactiveUsers.template.php não existe. Se existir, apaga-o.
Verifica que os ficheiros Themes\default\languages\emailInactiveUsers.xxxxx.php não existem. Se existirem, apaga-os
Verifica que o ficheiro Sources\ScheduledTasks.php *NÃO TEM*, no final ou perto, a função

/**
* Send mails to inactive users, also delete them if they haven't logged in since then.
*
* Column to_delete hold the current state of the account:
* 0 normal, up to date user
* 1 mail has been sent, user starts her/his grace period after mail was sent.
* 2 User has not been logged and her/his grace period is over, marked for admin deletion. These are the users who will appear on the mods user list.
* 3 Admin has marked this user for deletion and will be deleted next time the scheduled task is executed.
* 4 "Untouchable" means the user will not be fetched by the mod even if the account complies with all of the criteria to be marked for deletion.
* Column inactive_mail holds a different unix timestamp depending on the account current state:
* 0 if the user is up to date.
* It will hold the date the mail was sent to the mail queue when the user to_delete column is set to 1. This time is then used to check if their grace period is over or for resetting their status.
*
* @return boolean true The code inside the scheduled task was executed.
*/
function scheduled_emailInactiveUsers()
{
global $smcFunc, $modSettings, $txt, $sourcedir, $mbname;
global $scripturl;

// The mod must be enable
if (empty($modSettings['eiu_enable']))
return true;

loadLanguage('emailInactiveUsers');

// Today is a good day to do stuff don't you think?
$today = time();

// Is there any custom message?
$customMessage = !empty($modSettings['eiu_message']) ? $modSettings['eiu_message'] : $txt['eiu_custom_message'];
$customSubject = !empty($modSettings['eiu_subject']) ? $modSettings['eiu_subject'] : $txt['eiu_custom_subject'];
$postLimit = !empty($modSettings['eiu_posts']) ? $modSettings['eiu_posts'] : 5;

// How many days must the user needs to be inactive to get the mail? lets stay safe here and declare a default value too.
$inactiveFor = 86400 * (!empty($modSettings['eiu_inactiveFor']) ? $modSettings['eiu_inactiveFor'] : 15);

// The user hasn't been logged in since the mail was sent huh? how many days are we gonna wait until the account gets marked for deletion?
$sinceMail = 86400 * (!empty($modSettings['eiu_sinceMail']) ? $modSettings['eiu_sinceMail'] : 15);

// The groups from which the users will be fetched from.
$inGroups = !empty($modSettings['eiu_groups']) ? unserialize($modSettings['eiu_groups']) : array();

// Don't count the main admin group, AKA id_group 1
if (!empty($inGroups))
$inGroups = array_diff($inGroups, array(1));

// We gotta do a nasty thing here, we have to format a "FIND_IN_SET" for each selected group. Thanks to this we need PHP 5.3 or grater...
if (!empty($inGroups))
$additionalgroups = array_map(
function($k) {
return ' OR FIND_IN_SET('. $k .', additional_groups)';
}, $inGroups);

// For those who still want to use this but don't have php 5.3
/* if (!empty($inGroups))
foreach ($inGroups as $k)
$additionalgroups[] = ' OR FIND_IN_SET('. $k .', additional_groups)'; */

else
$additionalgroups = false;

// Right, we got all we need, lets do some expensive queries.
$request = $smcFunc['db_query']('', '
SELECT id_member, email_address, inactive_mail, member_name, real_name, last_login
FROM {db_prefix}members
WHERE inactive_mail = 0
AND posts <= {int:postLimit}
AND last_login < {int:inactiveFor}
AND date_registered < {int:inactiveFor}
AND is_activated = 1
AND to_delete = 0
AND email_address is NOT NULL
AND (id_group IN ({array_int:groups})
OR id_post_group IN ({array_int:groups})
'. (!empty($additionalgroups) ? implode(' ', $additionalgroups) : ''). ')',
array(
'inactiveFor' => $today - $inactiveFor,
'groups' => $inGroups,
'postLimit' => $postLimit,
)
);

$messages = array();

while($row = $smcFunc['db_fetch_assoc']($request))
{
// Lets create the message. Replace our wildcards with the actual data.
$replacements = array(
'{user_name}' => $row['real_name'],
'{display_name}' => $row['member_name'],
'{last_login}' => timeformat($row['last_login']),
'{forum_name}' => $mbname,
'{forum_url}' => $scripturl,
);

// Split the replacements up into two arrays, for use with str_replace.
$find = array();
$replace = array();

foreach ($replacements as $f => $r)
{
$find[] = $f;
$replace[] = $r;
}

$messages[$row['id_member']] = array(
'message' => str_replace($find, $replace, $customMessage),
'mail' => $row['email_address'],
'subject' => str_replace($find, $replace, $customSubject),
);
}

// Do we find someone?
if (!empty($messages))
{
// Gotta use a function in a far far away file...
require_once($sourcedir . '/Subs-Post.php');

// Send the mail away!
foreach($messages as $m)
sendmail($m['mail'], $m['subject'], $m['message'], null, null, false);

// OK, next thing, mark those users. Set sent_mail to the date the mail was sent, set inactive_mail to the future date where their grace period will end. Set to_delete as 1
$smcFunc['db_query']('', '
UPDATE {db_prefix}members
SET sent_mail = {int:today}, to_delete = {int:to_delete}, inactive_mail = {int:sinceMail}
WHERE id_member IN ({array_int:id_members})',
array(
'sinceMail' => $today + $sinceMail,
'today' => $today,
'id_members' => array_keys($messages),
'to_delete' => 1,
)
);
}

// Next step. Find out if any user marked for potential deletion or deletion has logged in since then and reset their status. Don't reset the untouchable status...
$smcFunc['db_query']('', '
UPDATE {db_prefix}members
SET inactive_mail = {int:cero}, to_delete = {int:cero}, sent_mail = {int:cero}
WHERE sent_mail > {int:cero}
AND last_login > sent_mail
AND to_delete >= {int:cero}
AND to_delete <= {int:tres}',
array(
'cero' => 0,
'tres' => 3,
)
);

/* Next. Find all users whose email was sent and see if their grace period time has expired, if so, mark them for deletion. If deletion is disabe then reset their status back to 0.
* Include the group check since its possible the users has changed their group since then.
* It is also possible for an user to log in at the very last minute that is, after the admin set the account for deletion but before the next scheduled task is executed... lucky bastard! */
$request = $smcFunc['db_query']('', '
UPDATE {db_prefix}members
SET to_delete = '. (!empty($modSettings['eiu_disable_removal']) ? '{int:cero}' : '{int:dos}') .'
WHERE inactive_mail < {int:today}
AND last_login < inactive_mail
AND posts <= {int:postLimit}
AND date_registered < {int:today}
AND is_activated = {int:uno}
AND to_delete = {int:uno}
AND (id_group IN ({array_int:groups})
OR id_post_group IN ({array_int:groups})
'. (!empty($additionalgroups) ? implode(' ', $additionalgroups) : ''). ')',
array(
'groups' => $inGroups,
'postLimit' => $postLimit,
'cero' => 0,
'uno' => 1,
'dos' => 2,
'today' => $today,
)
);

// We don't want to delete them...
if (!empty($modSettings['eiu_disable_removal']))
return true;

// Last step. Find those user the admin has decided to delete. No further checks here, it is all based on having "to_delete" set to 3.
$request = $smcFunc['db_query']('', '
SELECT id_member
FROM {db_prefix}members
WHERE to_delete = {int:toDelete}',
array(
'toDelete' => 3,
)
);

$usersToDelete = array();

while($row = $smcFunc['db_fetch_assoc']($request))
$usersToDelete[] = $row['id_member'];

// Any lucky ones?
if (!empty($usersToDelete))
{
// Redundant but still need to be sure.
require_once($sourcedir . '/emailInactiveUsers.php');

// This is a very expensive function :(
eiu_deleteMembers($usersToDelete);

// Re-build the "to delete" cache.
cache_put_data('eiu_users-2', null, 3600);
}

// And... we're done!
return true;
}


Vai a teu phpmyadmin (faz um backup da BD, não vá dar asneira :P ):
* tabela smf_members, apaga as colunas inactive_mail, sent_mail e to_delete

Finalmente, vai ao pacote do MOD e extrai os ficheiros: remove.php e removeScheduledTask.php. Faz upload deles para a raiz do teu forum (onde está o SSI.php) e corre-os, um de cada vez, pelo browser: ex: http://www.pedacinhos-de-nos.net/remove.php
Em ambos deves ficar com uma página em branco sem dizer nada, não te preocupes, é mesmo assim ;) Depois apaga-os.

E pronto, podes voltar a instalar o MOD :)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Isa.F

Já fiz backup, já confirmei que não existiam ficheiros nenhuns, e já estou a tentar apagar as colunas, até já as encontrei... Só há um pormenor...



Como é que eu apago as colunas, mesmo??  8)

margarett

ALTER TABLE smf_members DROP inactive_mail

I means para as outras ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Isa.F


Isa.F

#11
Acabei de reinstalar o tal mod novo email Inactive Users, mas agora voltaram a aparecer-me dois erros deste tipo:

http://pedacinhos-de-nos.net/index.php?action=admin;area=eiu;sa=general
2: in_array() expects parameter 2 to be array, boolean given
: /home/pedacinh/public_html/Themes/default/languages/emailInactiveUsers.english.php (show_settings sub template - eval?)
Linha: 903



E se desactivar a avaliaçao de temas, tenho:


http://www.XXXXXXXX/index.php?action=admin;area=eiu;fd15434=aaa846c4ac03221e10fb62f4f5d8351a
2: in_array() expects parameter 2 to be array, boolean given

Ficheiro: /home/XXXXXX/public_html/Themes/default/Admin.template.php
Linha: 903




Andei a fazer pesquisa, e pelos vistos houve quem tivesse relatado isso, e o autor responde isto:


Quote from: Suki on June 10, 2014, 03:10:44 PM
Quote from: demlak on May 13, 2014, 09:29:39 PM
i Just gave it a try.. is it standard, that "generel settings" and "user list" do show the same settings page "Email Inactive Users"?

i don´t see anything different on "user list"


p.s.
in the description text, there is a typo.. you wrote "not after the main was sent".. i think this should be "mail" not "main"..

p.p.s. error log says (german):
http://board.url/index.php?action=admin;area=eiu
Filter hinzufügen: Nur Fehlermeldungen mit der gleichen Nachricht anzeigen
2: in_array() expects parameter 2 to be array, boolean given
Filter hinzufügen: Nur Fehler von dieser Datei zeigen
Datei: /boardfolder/Themes/default/languages/emailInactiveUsers.english.php (show_settings sub template - eval?)
Zeile: 903



OK, I uploaded the correct package.

The "in_array() expects parameter 2 to be array, boolean given" error is an SMF bug when using a multiple select box, it only happens the first time you install the mod, by default SMF sets an non existent setting as a boolean false but the code to show the multiple select HTML code needs an array, in this case, an empty array.  I vaguely remember I fixed that on 2.1 but I don't know if I ever pushed the fix or not, will take a look at it when I get back.



Pelo que percebo, o erro é só quando entro nas definições do mod e depois nunca mais surge... a não ser que entre novamente no tal menu... Será assim?

Devo preocupar-me com isto, ou não?  ::)




EDIT:

Tinha referido nesta mensagem, que tinha antes um mod com a mesma função, até o nome era parecido "Auto Email Inactive Ordinary Users " mas enganei-me na versão que disse ter instalada. Achei que a versão que eu tinha era a AEIOU_v1.6 mas afinal era a emailinactive_1.7 http://custom.simplemachines.org/mods/index.php?mod=1186

Este mod não foi correctamente desinstalado. Já consegui apagar na base de dados 2 colunas criadas do AEIOU mas temo que possa haver mais resíduos... Precisava se calhar de uma ajudita para confirmar...  ;)


Este mod tem os seguintes ficheiros:


margarett

Lembra-me depois... Tenho de analisar isto com mais juízo ;)
Se forem conduzir, não bebam. Se forem beber... CHAMEM-ME!!!! :D

QuoteOver 90% of all computer problems can be traced back to the interface between the keyboard and the chair

Isa.F

Quote from: margarett on August 13, 2014, 08:37:12 PM
Lembra-me depois... Tenho de analisar isto com mais juízo ;)


OK!  :laugh:

Advertisement: