collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 408
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

If you're interested in helping other members with support requests, consider joining the Community Support Helpers group.

Author Topic: [Block] Announce new registered users awaiting for account approval  (Read 15703 times)

0 Members and 2 Guests are viewing this topic.

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Custom PHP Block: Announce new registered users awaiting for account approval



Features:
  • Displays latest members awaiting account approval
  • Uses pages for lengthy lists
  • Allows option to adjust list length & character length (at top of block code)
  • Links to user profiles & registration
  • Option to externally check if IP is flagged as spam
  • Visible only to Administrators

Note: Adjust the language where necessary.



Recommended settings:
  • Permissions: Custom - Admin Only (logic is set up for this anyway - not mandatory)
  • Display Options: Show block Everywhere
  • Style Options: No title & No body
  • Set up for Top/Bottom or Header/Footer display



SMF 2.0 PHP Block Code:
Code: [Select]
/* block:sp-aru3 <-----> c/o Underdog */
/* SMF 2.0x version */
/* Announce new registers waiting for account approval block */
global $context, $scripturl, $settings, $smcFunc;

$check_ip = true; /* Check if IP's are flagged as spam from external sources */
$show_data = true; /* true: show registers info  /  false: only show number of registers */
$h3_format = 'titlebg'; /* catbg/titlebg  - css title style  */
$h3top = true; /* true = show bar above info  /  false = show bar below info  */
$char_length = 30; /* max character length */
$rows = 3; /* visibile rows */
$prev = 'Prev'; /* Previous text */
$next = 'Next'; /* Next text */
$highlight = '#FEE333'; /* Stress color for flagged IP's */

if ($context['user']['is_admin'])
{

$total = 0;
$offset = (int)$rows;
$needed_data = array('id_member', 'member_name', 'email_address', 'date_registered', 'member_ip');


/* Some js to control the pages */
echo '<script type="text/javascript">
function Pager(tableName, itemsPerPage) {
this.tableName = tableName;
this.itemsPerPage = itemsPerPage;
this.currentPage = 1;
this.pages = 0;
this.inited = false;

this.showRecords = function(from, to) {
var rows = document.getElementById(tableName).rows;
// i starts from 1 to skip table header row';
echo "
for (var i = 1; i < rows.length; i++) {
if (i < from || i > to)
rows[i].style.display = 'none';
else
rows[i].style.display = '';
}";
echo '
}

this.showPage = function(pageNumber) {
if (! this.inited) {
alert("not inited");
return;
}';
echo "
var oldPageAnchor = document.getElementById('pg'+this.currentPage);
oldPageAnchor.className = 'pg-normal';

this.currentPage = pageNumber;
var newPageAnchor = document.getElementById('pg'+this.currentPage);
newPageAnchor.className = 'pg-selected';

var from = (pageNumber - 1) * itemsPerPage + 1;
var to = from + itemsPerPage - 1;
this.showRecords(from, to);
}

this.prev = function() {
if (this.currentPage > 1)
this.showPage(this.currentPage - 1);
}

this.next = function() {
if (this.currentPage < this.pages) {
this.showPage(this.currentPage + 1);
}
}

this.init = function() {
var rows = document.getElementById(tableName).rows;
var records = (rows.length - 1);
this.pages = Math.ceil(records / itemsPerPage);
this.inited = true;
}";
echo '
this.showPageNav = function(pagerName, positionId) {
if (! this.inited) {
alert("not inited");
return;
}
var element = document.getElementById(positionId);';
echo "
var pagerHtml = '<span onclick=";
echo '"';
echo "' + pagerName + '.prev();";
echo '" class="pg-normal"> &#8920; ', $prev, ' </span> | ';
echo "';
for (var page = 1; page <= this.pages; page++)
pagerHtml += '<span id=";
echo '"';
echo "pg' + page + '";
echo '" class="pg-normal" onclick="';
echo "' + pagerName + '.showPage(' + page + ');";
echo '">';
echo "' + page + '</span> | ';
pagerHtml += '<span onclick=";
echo '"';
echo "'+pagerName+'.next();";
echo '" class="pg-normal"> ', $next,' &#8921;</span>';
echo "';

element.innerHTML = pagerHtml;
}
}
function RegsRegenerate()
{
window.location.reload()
}

function RegsRegenerator()
{
if (document.layers)
{
appear()
setTimeout(";
echo '"window.onresize=RegsRegenerate",450)
}
}

function changetext(whichcontent)
{
if (document.all||document.getElementById)
{
cross_el=document.getElementById? document.getElementById("descriptions"):document.all.descriptions
cross_el.innerHTML=';
echo "'<div style=";
echo '"font-family:Arial Narrow Bold;font-size:small;">';
echo "'+whichcontent+'</div>'
}
else if (document.layers)
{
document.d1.document.d2.document.write('<div style=";
echo '"font-family:Arial Narrow Bold;font-size:small;">';
echo "'+whichcontent+'</div>')
document.d1.document.d2.document.close()
}

}

function appear()
{
document.d1.visibility='show'
}
</script>";
/* end of js controller */

$pages = '<script type="text/javascript"><!--
        var pager = new Pager("UserRegSP", '.(int)$rows.');
        pager.init();
        pager.showPageNav("pager", "RegsPagePosition");
        pager.showPage(1);
    //--></script>';

$result = $smcFunc['db_query']('', "SELECT id_member, member_name, date_registered, is_activated, email_address, member_ip FROM {db_prefix}members WHERE (is_activated = 3)");
while ($val = $smcFunc['db_fetch_assoc']($result))
{
foreach ($needed_data as $data)
$registers[$total][$data] = strlen($val[$data]) >= ((int)$char_length) ? $val[$data] = substr($val[$data],0,((int)$char_length - 1)).'...':$val[$data];

$total++;
}
$smcFunc['db_free_result']($result);

if ((int)$total > 0 && $show_data)
{
echo '
<script type="text/javascript">
<!--
window.onload=RegsRegenerator
//-->
</script>';
if ($h3top)
{
echo '
<h3 class="'.$h3_format.' centertext" style="border-radius:10px;-webkit-border-radius:10px;-moz-border-radius:10px;">
<span class="left"></span>
<span style="float:left;overflow:hidden;padding-left:10px;vertical-align:middle;">Members pending approval: ',$total,'</span>';
if ((int)$total > (int)$rows)
echo '
<span id="RegsPagePosition" style="text-align:center;overflow:hidden;margin-left:auto;margin-right:auto;vertical-align:middle;"></span>';

echo '
<span style="float:right;overflow:hidden;padding-right:10px;vertical-align:middle;">
<a href="'. $scripturl . '?action=admin;area=viewmembers;sa=browse;type=approve;'.$context['session_var'] . '=' . $context['session_id'].'">
Approve Members
</a>
</span>
</h3>';
}
echo '
<table border="0" style="border-collapse: collapse;width:100%;overflow:hidden;">
<tr class="catbg smalltext">
<td class="catbg" style="border:0px;height: 18px;background: url(',$settings['actual_theme_url'],'/images/theme/main_block.png) no-repeat 0 -160px;text-align:left;width:10%;">ID#</td>
<td class="catbg" style="text-align:left;background: url(',$settings['actual_theme_url'],'/images/theme/main_block.png) no-repeat 50% -160px;height: 18px;width:25%;">Name</td>
<td class="catbg" style="text-align:left;background: url(',$settings['actual_theme_url'],'/images/theme/main_block.png) no-repeat 50% -160px;height: 18px;width:25%;">Email Address</td>
<td class="catbg" style="text-align:left;background: url(',$settings['actual_theme_url'],'/images/theme/main_block.png) no-repeat 50% -160px;height: 18px;width:25%;">Date Registered</td>
<td class="catbg" style="text-align:right;border:0px;background: url(',$settings['actual_theme_url'],'/images/theme/main_block.png) no-repeat 100% -160px;height: 18px;line-height: 10px;width:15%;">
IP Address
</td>
</tr>
</table>
<table border="0" style="border-collapse: collapse;width:100%;overflow:hidden;" id="UserRegSP">
<tr class="catbg">
<td colspan="5"><hr /></td></tr>';
foreach ($registers as $new_member)
{
if (empty($new_member['id_member']))
continue;

$new_member['date_registered'] = date("D M j, Y \a\\t g:m a", $new_member['date_registered']);
echo '
<tr class="windowbg">';
foreach ($needed_data as $data)
{
if ($data == 'member_ip')
{
if (($check_ip) && ip_spamcheck(trim($new_member[$data])))
echo '
<td style="text-align:right;width:15%;background-color: '.$highlight.';">';
else
echo '
<td style="text-align:right;width:15%;">';

}
elseif ($data == 'id_member')
echo '
<td style="text-align:left;width:10%;">';
else
echo '
<td style="text-align:left;width:25%;position:relative;left:-6px;">';

echo '
<a href="',$scripturl,'?action=profile;u=',$new_member['id_member'],'">',$new_member[$data],'</a>
</td>';
}
echo '
</tr>';
}

while (((int)$offset - $total%$rows) != ((int)$rows+1))
{
echo '
<tr class="windowbg">
<td style="width: 96%" colspan="5">&nbsp;</td>
</tr>';
$offset++;
}
echo '
</table>
<table border="0" style="padding:0px;border-collapse: collapse;width:100%;overflow:hidden;">
<tr>
<td class="catbg" colspan="5" style="border:0px;height:18px;">
<span class="botslice"></span>
</td>
</tr>
</table>';
if (!$h3top)
{
echo '
<h3 class="'.$h3_format.' centertext" style="border-radius:10px;-webkit-border-radius:10px;-moz-border-radius:10px;">
<span class="left"></span>
<span style="float:left;overflow:hidden;padding-left:10px;vertical-align:middle;">Members pending approval: ',$total,'</span>';
if ((int)$total > 3)
echo '
<span id="RegsPagePosition" style="text-align:center;overflow:hidden;margin-left:auto;margin-right:auto;vertical-align:middle;"></span>';

echo '
<span style="float:right;overflow:hidden;padding-right:10px;vertical-align:middle;">
<a href="'. $scripturl . '?action=admin;area=viewmembers;sa=browse;type=approve;'.$context['session_var'] . '=' . $context['session_id'].'">
Approve Members
</a>
</span>
</h3>';
}
echo '
<span style="text-align:center;overflow:hidden;padding-left:20%;">', $pages, '</span>';
}
elseif ((int)$total > 0)
{
echo '
<h3 class="'.$h3_format.'">
<span class="left"></span>
<span style="float:left;overflow:hidden;padding-left:10px;vertical-align:middle;">';
if ((int)$total > 1)
echo '<< You have a total of ',$total,' members waiting for their account to be approved >>';
else
echo '<< You have 1 member waiting for their account to be approved >>';

echo '
</span>
<span style="float:right;overflow:hidden;padding-right:10px;vertical-align:middle;">
<a href="'. $scripturl . '?action=admin;area=viewmembers;sa=browse;type=approve;'.$context['session_var'] . '=' . $context['session_id'].'">
Approve Members
</a>
</span>
</h3>';
}
}

/* Check if IP is on spam lists */
function ip_spamcheck($ip = '0.0.0.0')
{
/* This array contains spam search urls & their pass flags */
  $feeds = array('IP Blacklist Lookup' => array('http://www.find-ip-address.org/ip-blacklist-lookup.php?ip='.$ip, 'IP address <b>'.$ip.'</b> is NOT listed in RBL (Real-time Blackhole List) database<br /> and it is not on any Spam Blacklist'), 'Honeypot' => array('http://www.projecthoneypot.org/ip_'.$ip, 'We don\'t have data on this IP currently.'));

foreach ($feeds as $feed => $data)
{
/* Use cURL to get the url file contents ... close the session first! */
session_write_close();
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$data[0]);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 5);
$html = curl_exec($ch);
curl_close($ch);

/* Check for a timeout else check the html */
if ((empty($html)) || !$html)
$spamflag = false;
elseif (strpos($html, $data[1]))
$spamflag = false;
else
$spamflag = true;
}

return $spamflag;
}



Some theme's do not readily display data for this in the SMF navigation bar.
This block will enable forum Admins to be notified when registered account approvals are pending.
Submitted upon request. 
« Last Edit: March 15, 2018, 01:18:46 PM by Chen Zhen »

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22

For anyone interested in using this block:

  I tested this & found the css I used seems to work for its appearance on an assortment of themes.
If anyone has issues with it (appearance wise) then let me know in this thread with reference to the theme being used.

Thank you.


Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: [Block] Announce new registered users awaiting for account approval
« Reply #2 on: December 21, 2012, 11:55:21 PM »
The block in the first post has been updated which now includes the option of externally checking if the IP's have been flagged as spam. These IP's will be highlighted (stressed) on the list of pending users.

Options to enable/disable this feature & the highlight color can be opted at the top of the block code.
The rounded corners for the left part of the title bar has also been fixed/adjusted.
 

Offline killernos

  • Just Registered
  • Posts: 1
  • SMF Version: 2.0.7
  • SP Version: 2.3.5
Re: [Block] Announce new registered users awaiting for account approval
« Reply #3 on: January 25, 2014, 04:19:06 PM »
this is a great block can you add approve or deny to the very right?
please and great work.

Offline player.samp

  • Translator
  • *
  • Posts: 50
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: [Block] Announce new registered users awaiting for account approval
« Reply #4 on: April 08, 2014, 11:16:08 AM »
I get this message when I try to create that block:

"Database error in block code. Please check the code."

:(

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: [Block] Announce new registered users awaiting for account approval
« Reply #5 on: April 11, 2014, 12:04:33 AM »
player.samp,

  I edited the block code shown in the first post. Please try it out and let me know if it works for you this time.

Regards.
 

Offline player.samp

  • Translator
  • *
  • Posts: 50
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: [Block] Announce new registered users awaiting for account approval
« Reply #6 on: April 11, 2014, 08:16:12 AM »
Still error in the database and when I check the preview I don't see anything except from the title of the block... No content. :/

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: [Block] Announce new registered users awaiting for account approval
« Reply #7 on: April 11, 2014, 08:39:33 AM »
player.samp,

This works fine for me when tested on a default SimplePortal installation.
You will not see anything unless you have your forum set to admin approval for registration and only if there are people that have registered pending approval.

Offline player.samp

  • Translator
  • *
  • Posts: 50
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: [Block] Announce new registered users awaiting for account approval
« Reply #8 on: April 11, 2014, 09:31:47 AM »
player.samp,

This works fine for me when tested on a default SimplePortal installation.
You will not see anything unless you have your forum set to admin approval for registration and only if there are people that have registered pending approval.

Okay, so maybe there is a database problem right now because no user tried to register.

So I will try to make it when a user will try to register and then see if it works.

Offline Chen Zhen

  • The Underdog
  • Operations Manager
  • *
  • Posts: 1350
  • Gender: Male
  • Kinesis
    • WebDev
  • SMF Version: 2.1
  • EhPortal Version: 1.22
Re: [Block] Announce new registered users awaiting for account approval
« Reply #9 on: April 11, 2014, 11:00:32 AM »
player.samp,,

  It should still allow you to save the block code no matter what. It checks db columns that exist for SMF by default so there should be no database error. Also the block should have the settings of no body and no title checked because you do not want the body & title to appear for users without permission to view such data. Also it will not appear at all if no users are pending approval that way. It has its own style layout that does not require the block title & body style attributes.
 

Offline player.samp

  • Translator
  • *
  • Posts: 50
  • Gender: Male
  • SMF Version: 2.0.11
  • SP Version: 2.3.6
Re: [Block] Announce new registered users awaiting for account approval
« Reply #10 on: June 21, 2014, 07:32:15 PM »
When I click now on preview I am redirected to this link:

"data:,"

And I am trying it on SMF 2.0.6.