[Snippet] Website status in memberlist

Little Mods and Snips 1

[Snippet] Website status in memberlist

Postby Sekuro » 10 May 2012, 15:30

Website status in memberlist

This Snippet shows the website reachable status in memberlist

requested by: FranckTH
request topic: http://www.phpbb.com/community/viewtopi ... &t=2155208

demo: http://4seven.bplaced.net/forum/media/member ... &sk=a&sd=a

screen:

website_status.png

Instruction

download:

Image Image

rightclick > save image under ...

copy: both images to root/images/

open

memberlist.php

find

Code: Select all
$user->setup(array('memberlist', 'groups')); 


after add

Code: Select all
// Website status in memberlist / 4seven / 2012
if ($auth->acl_get('a_'))
{

function url_reachable($domain){

$a_url     = parse_url("$domain");
$host      = $a_url['host'];
$starttime = microtime(true);
$file      = @fsockopen ("$host", 80, $errno, $errstr, 0.2);
$stoptime  = microtime(true);
$status    = 0;

if (!$file){
$status = 0;}

else{
fclose($file);
$status = ($stoptime - $starttime) * 1000;
$status = floor($status);}
    
if 
(($status != 0) && ($status < 200)){
return '<img style="position:relative;top:2px;" src="images/link_yes.png" alt="" /> <span style="color:#999999;">' . $status . ' msec.</span><br />';}
    
else{
return ($status != 0) ? '<img style="position:relative;top:2px;" src="images/link_no.png" alt="" /> <span style="color:#999999;">Timeout: ' . $status . ' msec.</span><br />' : '<img style="position:relative;top:2px;" src="images/link_no.png" alt="" /> <span style="color:#999999;">Offline or Url not exists</span><br />';}}

}
// Remove the following part, if you want it for admins only
else
{

function url_reachable($domain){

$a_url     = parse_url("$domain");
$host      = $a_url['host'];
$starttime = microtime(true);
$file      = @fsockopen ("$host", 80, $errno, $errstr, 0.2);
$stoptime  = microtime(true);
$status    = 0;

if (!$file){
$status = 0;}

else{
fclose($file);
$status = ($stoptime - $starttime) * 1000;
$status = floor($status);}
    
if 
(($status != 0) && ($status < 200)){
return '<img style="position:relative;top:2px;" src="images/link_yes.png" alt="" /> ';}
    
else{
return '<img style="position:relative;top:2px;" src="images/link_no.png" alt="" /> ';}}

}
// Remove the part from last comment to here, if you want it for admins only
// Website status in memberlist / 4seven / 2012      


find

Code: Select all
        'U_WWW'            => (!empty($data['user_website'])) ? $data['user_website'] : ''


after add

Code: Select all
        // Website status in memberlist / 4seven / 2012
        'S_WWW_EXISTS'    => (!empty($data['user_website']) && function_exists('url_reachable')) ? url_reachable($data['user_website']) : false,
        // Website status in memberlist / 4seven / 2012     


open

styles/prosilver/memberlist_body.html

find

Code: Select all
<!-- IF memberrow.U_WWW --><div><a href="{memberrow.U_WWW}" title="{L_VISIT_WEBSITE}: {memberrow.U_WWW}">{memberrow.U_SHORT_WWW}</a></div><!-- ENDIF -->


replace with

Code: Select all
<!-- IF memberrow.U_WWW --><div><!-- IF memberrow.S_WWW_EXISTS -->{memberrow.S_WWW_EXISTS}<!-- ENDIF --><a href="{memberrow.U_WWW}" title="{L_VISIT_WEBSITE}: {memberrow.U_WWW}">{memberrow.U_SHORT_WWW}</a></div><!-- ENDIF --> 


clear all board- and browser-caches

note:
this is one of the fastest script for checking url availability.
it checks each [url] max. 200 msec. (0,2 sec.).
if many links are bad, the memberlist slows down.
Mod-Bot / Service-Team
User avatar
Sekuro

Tiptop

Tiptop
 
Posts: 241
Joined: 11 Feb 2008, 11:49
 
Resolution: 1440x900


Return to Snip Cl@ss I

Who is online

Users browsing this forum: No registered users and 1 guest

cron