Uutiset:

SMF 2.1.4 has been released! Take it for a spin! Read more.

Main Menu
Advertisement:

Need some help with a bit of PHP - convert SMF 1 to SMF 2 code

Aloittaja EL34, elokuu 02, 2014, 08:29:53 AP

« edellinen - seuraava »

EL34

I use mod httpbl by snoopy virtual
He is not supporting this mod and has moved on, so I need to convert a bit of code he gave me for SMF 1 into SMF 2 code

Snoopy gave me a bit of custom code he wrote that deletes guest only from the http bl log file - log_httpBL
That will leave forum members only in the log file and delete all guest
This worked great in SMF 1 , but I have since upgraded to SMF 2 and want this feature back

The button code he gave me works fine. It adds a button when you are viewing the http bl log

The code that runs when the button is pressed would be different for SMF 2 but I am not familiar with how to alter that
I know where to insert the code in the httpbl_config.php file
I just need some PHP translation help

Here's is the code he gave me for SMF 1


// 'Remove Guests' (EL34) button was pressed.
else if (!empty($_POST['removeGuests']))
db_query("
DELETE FROM {$db_prefix}log_httpBL
WHERE username = 'Guest'", __FILE__, __LINE__);






SMF 2 delete code looks a bit different to me
Here's a SMF 2 code sample that deletes everything in the httpbl log




// 'Clear this log' button was pressed.
else if (!empty($_POST['clearThisLog']))
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}log_httpBL
WHERE ' . $query_where,
array(
)
);


How would the SMF 1 code shown above be written for SMF2?
All it has to do is delete all username of guest
thanks
Forum History -> EZBoard -> YABB -> SMF 1.1.19 -> SMF 2.0.19

Arantor

// 'Remove Guests' (EL34) button was pressed.
else if (!empty($_POST['removeGuests']))
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}log_httpBL
WHERE username = {string:guest}',
array(
'guest' => 'Guest',
)
);


should do the trick for the first block.
Holder of controversial views, all of which my own.


EL34

Thank you for the code and the super fast reply

I'll go insert it and report back
Forum History -> EZBoard -> YABB -> SMF 1.1.19 -> SMF 2.0.19

EL34

Thank you, the code worked but I had to change something to get it to work

Apparently the username was set to guest in the log-httpbl table in SMF 1

In SMF 2 the username is just blank if they are guest
So I changed the guest string comparison to blank and now it works

Thanks for your help

else if (!empty($_POST['removeGuests']))
$smcFunc['db_query']('', '
DELETE FROM {db_prefix}log_httpBL
WHERE username = {string:guest}',
array(
'guest' => '',
)
);
Forum History -> EZBoard -> YABB -> SMF 1.1.19 -> SMF 2.0.19

Arantor

Holder of controversial views, all of which my own.


Advertisement: