News:

Join the Facebook Fan Page.

Main Menu

Say Thanks

Started by kelvincool, August 30, 2014, 05:16:29 PM

Previous topic - Next topic

Steve

I just know you're going to get the stock answer ... 'When it's ready.' lol
DO NOT pm me for support!

kelvincool

Ha, it's ready!

v2.3.0 is released

  • Added alerts event for when people get thanked, to turn it on for every user, go to Admin -> Features and Options -> Notifications and check the box next to When one of my posts is thanked
  • Added hook event at the end of thanks for other mods
  • Fixed bug where thank text being displayed on profile edit page causing error log

I toyed with the idea of enabling the alerts by default but wasn't sure everyone would want that on so right now it's up to the admins.

@Diego Andrés let me know if that hook is good enough or you need any other params passed through.

Diego Andrés

That's great, thanks!

SMF Tricks - Free & Premium Responsive Themes for SMF.

wylekk

PHP: 7.4.28, версия MySQL: 10.1.48-MariaDB-0+deb9u2.
SMF 2.1.2

On the server there are errors in the profile, on OpenServer everything works :-\

Database Error

'admin_pasbb.b.id_board' isn't in GROUP BY
File: /home/----/public_html/Sources/SayThanks.php
Line: 535

'admin_pasbb.b.id_board' isn't in GROUP BY
File: /home/admin/web/-----/public_html/Sources/SayThanks.php
Line: 565

Doug Heffernan

Quote from: wylekk on May 19, 2022, 09:55:33 AMPHP: 7.4.28, версия MySQL: 10.1.48-MariaDB-0+deb9u2.
SMF 2.1.2

On the server there are errors in the profile, on OpenServer everything works :-\

Database Error

'admin_pasbb.b.id_board' isn't in GROUP BY
File: /home/----/public_html/Sources/SayThanks.php
Line: 535

'admin_pasbb.b.id_board' isn't in GROUP BY
File: /home/admin/web/-----/public_html/Sources/SayThanks.php
Line: 565


This is related to this:

https://dev.mysql.com/doc/refman/8.0/en/group-by-handling.html

To fix it, find this code:

GROUP BY m.id_msg
And replace it with:

GROUP BY m.id_msg, b.id_board
if there will be a similiar error again, the solution is for each non-aggregated field to be grouped.

@kelvincool, another small issue that I noticed is that the $scripturl var has not been declaired as global in the language files. That threw an unindetified index scripturl message in my error log. Declairing the aforementioned var as global fixed it.

kelvincool

@wylekk that's an interesting error, I think that must be occuring because you have ONLY_FULL_GROUP_BY enabled on your mysql config, I've not touched this bit of code for years and I believe mysql enabled this option by default a few years back. What's kind of interesting is I also have this enabled on my local version but I don't get any errors. Anyways should be a relatively simple fix of adding all the columns to the group by like @Doug Heffernan has suggested there.

@Doug Heffernan good spot on that global declaration, will be fixed in next release.

wylekk

I made a converter for mod sitenx_2.3.0, transferred data from the tables smf_uzer_liks and smf_message. Disabled the built-in likes. Now users on the forum use the mod not from scratch. The mod is installed on the main site.

kelvincool

v2.3.1 is released

  • Fix for group by errors
  • Fix for $scripturl var in the language files

@wylekk that's cool that you made a converter  :)

wylekk

Quote from: kelvincool on May 23, 2022, 05:18:14 PMv2.3.1 is released

  • Fix for group by errors
  • Fix for $scripturl var in the language files


Everything works!

The converter below works on the Open Server, PHP7.1-7.4
File name - smf-art.php

  <?php
 
echo "<head> <style>
body {max-width:1224px; margin:auto;border:1px solid green; border-radius:10px;} 
.column {padding: 10px;}
.head{text-align:center; background-color: blue; color:white; border-radius:10px 10px 0 0; height: 65px;}
.bottom{text-align:center; background-color: blue; color:white; border-radius:0 0 10px 10px; height: 65px;}
.bott{color:red;}
</style></head>
<body>
<div class ='head'>Конвертер лайков форума smf212 на мод Say Thanks<br><br>
(Пожалуйста, проявите терпение, некоторые действия могут быть весьма долгими)</div>
 <div class ='bott'>сделано для сайта <a href=\"https://wylek.ru\">WYLEK.ru</a><br></div>


//--------------------------

  
  
$dblocation1 = "localhost";//сервер базы данных
  
$dbsmf = "smf211";//имя базы smf
  
$dbuser1 = "1234";//имя пользователя
  
$dbpasswd1 = "1234";//пароль от базы данных

  
$prefixsmf = "smf";//префикс таблиц SMF

//конект к базе
$dbcnx = mysqli_connect($dblocation1,$dbuser1,$dbpasswd1);
  if(!
$dbcnx)
  {
  exit("
Сервер базы данных $dbsmf сейчас недоступенПовторите попытку позже.");
  }
  
$db_select = mysqli_select_db($dbcnx$dbsmf);
  if(!
$db_select)
  {
  exit("
База данных $dbsmf недоступнаОбратитесь к администратору для решения проблемы.");
  }
echo ('<br>'); 
echo "
Соединение с базой $dbsmf установлено!" . PHP_EOL;
echo ('<br>');
echo "
Информация о сервере" . mysqli_get_host_info($dbcnx) . PHP_EOL;
echo ('<br>*******************************************<br>');


echo'<a href=?step27>1. Лайки</a> --><a href=?step28>2. Пересчёт</a><br><br>';    


//лайки----------------------------------------------------------------------------------
if(isset(
$_GET['step27']))
{

$i = 0;
mysqli_set_charset(
$dbcnx, "utf8");
//очистка
$query = "TRUNCATE TABLE {$prefixsmf}_messages_thanks";
$result = mysqli_query($dbcnx$query);
if(!
$result) { echo ("<br><br><font color=red>mysql вернула ошибку <br><textarea style='width: 300px; height: 200px'>".mysqli_error($dbcnx)."</textarea><brв коде <br><textarea style='width: 300px; height: 200px'>{$query}</textarea><br><br></font>");} else echo "<br><br>Таблица успешно очищена<br>";
//очистка

//создаем столбцы
$sql = mysqli_query($dbcnx, "ALTER TABLE {$prefixsmf}_messages_thanks ADD COLUMN id_member_to TEXT AFTER id_member");
$sql = mysqli_query($dbcnx, "ALTER TABLE {$prefixsmf}_messages_thanks ADD COLUMN id_msg5 TEXT AFTER id_msg");
    
  //вытягиваем данные из таблицы smf_user_likes            
$post = mysqli_query($dbcnx, "SELECT FROM {$prefixsmf}_user_likes WHERE content_type='msg'");            
        while (
$news = mysqli_fetch_array($post)) {
            
$id_member=$news['id_member'];
            
$like_time=$news['like_time'];
            
$content_id=$news['content_id'];

          
$i++;

$query = "INSERT INTO `{$prefixsmf}_messages_thanks` (`id_msg`, `id_member`, `date_thanked`) VALUES
('$content_id''$id_member''$like_time');";

    if (mysqli_query(
$dbcnx$query)) {        
          echo "";
    } else {

          echo "
<br><br>Error" . $query . "<br><br>" . mysqli_error($dbcnx);
    }
    }

//заполняем столбец единицей    
$sql = mysqli_query($dbcnx, "UPDATE {$prefixsmf}_messages_thanks SET id_msg5=1");//

//перекидываем ID кому лайкнули
$sql = mysqli_query($dbcnx, "UPDATE {$prefixsmf}_messages_thanks, {$prefixsmf}_messages \n"
. "
SET {$prefixsmf}_messages_thanks.id_member_to = {$prefixsmf}_messages.id_member \n"
. "
where {$prefixsmf}_messages_thanks.id_msg = {$prefixsmf}_messages.id_msg");

mysqli_close(
$dbcnx);    
echo "
<br /><span style='color: green;'>Перенос завершён!</span><br />";
echo "
<span style='color: green;'>Всего конвертировано $i лайков</span><br>";
echo "
<br><div style='text-align:center;'><a href='smf-art.php'><button>Продолжить</button></a></div></div><div class ='bottom'></body></div>";
}


//==============================================================================================
//пересчет
if(isset(
$_GET['step28']))
{

$i = 0;
mysqli_set_charset(
$dbcnx, "utf8");
//очистка
$query = "TRUNCATE TABLE {$prefixsmf}_messages_thanks_stats";
$result = mysqli_query($dbcnx$query);
if(!
$result) { echo ("<br><br><font color=red>mysql вернула ошибку <br><textarea style='width: 300px; height: 200px'>".mysqli_error($dbcnx)."</textarea><brв коде <br><textarea style='width: 300px; height: 200px'>{$query}</textarea><br><br></font>");} else echo "<br><br>Таблица успешно очищена<br>";
//очистка


  //вытягиваем данные из таблицы smf_messages    
$post = mysqli_query($dbcnx, "SELECT FROM {$prefixsmf}_messages where likes>0");            
        while (
$news = mysqli_fetch_array($post)) {
            
$id_member=$news['id_member'];

                      
$i++;

$query = "REPLACE  INTO `{$prefixsmf}_messages_thanks_stats` (`id_member`) VALUES
('$id_member');";

    if (mysqli_query(
$dbcnx$query)) {        
          echo "";
    } else {

          echo "
<br><br>Error" . $query . "<br><br>" . mysqli_error($dbcnx);
    }            
    }


//вставляем колличество лайков юзакам    
$sql = mysqli_query($dbcnx, "UPDATE {$prefixsmf}_messages_thanks_stats {$prefixsmf}_messages_thanks_stats_ SET thanks_count = ( SELECT sum(id_msg5FROM {$prefixsmf}_messages_thanks WHERE id_member_to={$prefixsmf}_messages_thanks_stats_.id_member)"); 

// удаляем временные столбцы    
$sql = mysqli_query($dbcnx, "ALTER TABLE {$prefixsmf}_messages_thanks drop COLUMN id_member_to");    
$sql = mysqli_query($dbcnx, "ALTER TABLE {$prefixsmf}_messages_thanks drop COLUMN id_msg5");



mysqli_close(
$dbcnx);    
echo "
<br /><span style='color: green;'>Перенос завершён!</span><br />";
echo "
<br><div style='text-align:center;'><a href='smf-art.php'><button>Продолжить</button></a></div></div><div class ='bottom'></body></div>";
}            
 
  ?>


kelvincool

Released v2.3.2

  • Realised group by is also used on the stats page so I've fixed it there as well

Steve

DO NOT pm me for support!

sevamaster

Hello,
Just installed your mod, but it does not work. Thanks not added.
I have the following types of error:
Quotegnh73
 178.187.30.226
 31cf22bf7b1e3439be56e080f9539698
 http://dnray.com/index.php?pretty;board=specialty-hosting-and-markets;topic=send-text-messages-sms-online.0&amp;action=thank;msg=157;member=1;ajax=1;xml=1  Backtrace information

Type of error: General
Error messageSelect
The callable SayThanks::thank could not be called.

I have the only mod installed. It's Pretty URLs.

Probable the reason of error in this (Pretty URLs) mod.

Could you fix it? Or please say how to fix it.



kelvincool

@sevamaster I'll look into this, need to get my local set up working with pretty urls. I'm pretty sure you can configure pretty urls to filter out Action urls which might get around this problem.

sevamaster

Thank you kelvicool.
Please give me an example which actions I have to skip (filter)?

kelvincool

The main 2 actions to skip are: thank and withdrawthank

I think you would just put thank,withdrawthank in the field Skip Actions List

sevamaster

Hello kelvincool.

I added thank,withdrawthank in the field Skip Actions List. There is the same error.
I have even disabled Actions URL rewriting in the Pretty Urls settings. There is the same error.

Below there is Admin error log:

Quote178.187.30.226
 7d29bc951890ab9c0d49386c179066b0
 http://dnsray.com/index.php?pretty;board=specialty-hosting-and-markets;topic=what-is-affordable-backup-solutions.0&amp;action=thank;msg=134;member=13;ajax=1;xml=1  Backtrace information

Type of error: General
Error messageSelect
The callable SayThanks::thank could not be called.

And below server error_log:

[22-Jun-2022 00:20:24 America/Jamaica] PHP Fatal error:  Uncaught TypeError: call_user_func(): Argument #1 ($callback) must be a valid callback, no array or string given in /home/seomaste/public_html/dnray.com/index.php:203
Stack trace:
#0 {main}
  thrown in /home/seosasmaste/public_html/dnray.com/index.php on line 203

Probably it (error_log above) says about function below:
// What function shall we execute? (done like this for memory's sake.)
call_user_func(smf_main());

kelvincool

@sevamaster I finally got pretty urls installed locally, it's working fine on my setup, I actually think pretty urls is not the problem. What version of PHP are you using, I suspect it's probably to do with that.

Also are you using the latest version of this mod or are you still using 1.3.6?

Can you try using this version of SayThanks.php if you are using the latest version, it goes in the Sources directory.

sevamaster

Hi kelvincool,

PHP Version 8.1.7
10.3.35-MariaDB

Say Thanks v2.3.2
SMF 2.1.2

I replaced original SayThanks.php by attached above. And it works without any problems!

As I've understood, you replaced:
//integrate_actions
public function integrateActions(&$actionArray)
{
$actionArray['thank'] = array('SayThanks.php', 'SayThanks::thank');
$actionArray['withdrawthank'] = array('SayThanks.php', 'SayThanks::withdrawThank');
}
by
//integrate_actions
public function integrateActions(&$actionArray)
{
$actionArray['thank'] = array('SayThanks.php', 'SayThanks::thank#');
$actionArray['withdrawthank'] = array('SayThanks.php', 'SayThanks::withdrawThank#');
}

So, please keep it in the next versions.

Thank you for great mod!)

Speed King

Hello,

After installing Say Thanks 1.3.6 version on my 2.0.19 forum, everytime when I move a topic to another location, I get this error message:

[24-Aug-2022 13:28:26 Europe/Sofia] PHP Notice:  Undefined index: selected in /home/bulataka/public_html/forum/Sources/Load.php(2295) : eval()'d code on line 42


Forum details:

Forum version: SMF 2.0.19 (more detailed)
Current SMF version: SMF 2.0.19
GD version: bundled (2.1.0 compatible)
Database Server: MariaDB
MySQL version: 10.3.36-MariaDB-log
PHP: 7.4.30
Server version: Apache

kelvincool

Just installed a fresh 2.0.19 copy and installed the mod, I have not been able to replicate the issue, moving topics does not generate any errors for me.

Where are you seeing that error? In the error log within SMF? You got any other mods installed, could be a conflict. If you can attach your Load.php, that might help identify what's happened.

Advertisement: