Does anyone know how to make it do that you can see how many guests (viewers) are online?
Does anyone know how to make it do that you can see how many guests (viewers) are online?
Try to use this code in one of your files or create a new file like "online_users" and include it where you want it to be shown:
You only have to create a txt file called "besucher.txt"PHP Code:<?php
$daten = "besucher.txt";
$time = time();
$ip = getenv("REMOTE_ADDR");
$ablaufzeit = $time - "300";
$pruefung = @file($daten);
while (list ($line_num, $line) = @each ($pruefung)) {
$zeiten = explode("&&",$line);
if($zeiten[0] <= $ablaufzeit) {
$fp = fopen( "$daten", "r" );
$contents = fread($fp, filesize($daten));
fclose($fp);
$line=quotemeta($line);
$string2 = "";
$replace = ereg_replace($line, $string2, $contents);
$fh=fopen($daten, "w");
@flock($fp,2);
fputs($fh, $replace);
@flock($fp,3);
fclose($fh);
}
}
$ippruefung = @file($daten);
while (list ($line_num, $line) = @each ($ippruefung)) {
$ips = explode("&&",$line);
if($ips[1] == $ip) {
$fp = fopen( "$daten", "r" );
$contents = fread($fp, filesize($daten));
fclose($fp);
$line=quotemeta($line);
$string2 = "";
$replace = ereg_replace($line, $string2, $contents);
$fh=fopen($daten, "w");
@flock($fp,2);
fputs($fh, $replace);
@flock($fp,3);
fclose($fh);
}
}
$fp = fopen("$daten", "a+");
flock($fp,2);
fputs ($fp, "$time&&$ip&&\n");
flock($fp,3);
fclose ($fp);
$anzahldaten = file($daten);
$anzahl = count($anzahldaten);
echo $anzahl." User online";
?>
Thank you lets say I want to place it in the front page where Currently Online is in that box can you guide me ot how and where?
OK, try this:
Look into your templates/tmpl_dfl/scripts/index.php and replace
PHP Code:function PageCompMemberStat( )
{
global $site;
global $prof;
global $oTemplConfig;
$free_mode = getParam("free_mode") == "on" ? 1 : 0;
// members statistics
$total_c = strlen( $_POST['total_c'] ) ? $_POST['total_c'] : getParam( "default_country" );
$total_c2 = strlen( $_POST['total_c2'] ) ? $_POST['total_c2'] : getParam( "default_country" );
$total_arr = db_arr( "SELECT COUNT(ID) FROM `Profiles` WHERE Status = 'Active'" );
$total_arr_week = db_arr( "SELECT COUNT(ID) FROM `Profiles` WHERE Status = 'Active' AND (TO_DAYS(NOW()) - TO_DAYS(LastReg)) <= 7" );
if ( !$free_mode )
$total_arr_gold = getMembersCount( MEMBERSHIP_ID_STANDARD, '', true );
$total_c_arr = db_arr( "SELECT COUNT(ID) FROM `Profiles` WHERE Status = 'Active' AND `Country` = '". process_db_input($total_c2) ."'" );
$total_members = $total_arr[0];
$total_c_members = $total_c_arr[0];
$total_c_members_onl = get_users_online_number('c', $total_c );
$total_arr_chatting = get_users_online_number('t');
$members_online = get_users_online_number();
$c_arr = $prof['countries'];
//#########################################################
$ret = '';
$ret .= '<div class="membes_statistic_block">';
$ret .= '<div class="clear_both"></div>';
$ret .= '<div style="position:relative; float:left;"><img src="' . $site['icons'] . 'group.gif" alt="" /></div>';
$ret .= '<div style="position:relative; float:left; white-space:nowrap; left:5px; font-weight:bold; color:#000;">' . _t("_Currently Online") . '</div>';
$ret .= '<div class="clear_both"></div>';
$ret .= '<div style="position:relative; border-bottom:1px solid silver; margin:5px 0px;"></div>';
$ret .= '<div class="member_stat_block">';
$ret .= '<div><img src="' . $site['icons'] . 'us.gif" alt="" /><span style="margin-left:5px;">' . _t("_Total") . ' - ' . $members_online . '</span></div>';
$ret .= '<div><img src="' . $site['icons'] . 'us.gif" alt="" /><span style="margin-left:5px;">' . _t("_Chatting") . ' - ' . $total_arr_chatting . '</span></div>';
$ret .= '<div><img src="' . $site['icons'] . 'us.gif" alt="" /><span style="margin-left:5px;">' . $total_c_members_onl . ' ' . _t("_members") . ' ' . _t("_from") . '</span></div>';
$ret .= '<div style="padding-left:20px;">';
$ret .= '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="cForm">';
$ret .= '<input type="hidden" name="total_c" value="' . $total_c . '" />';
$ret .= '<select style="width:123px;" name="total_c" onchange="javascript: document.forms[\'cForm\'].submit();">';
foreach ( $c_arr as $key => $value )
{
$ret .= '<option value="' . $key . '"';
if ( $key == $total_c )
$ret .= ' selected="selected"';
$ret .= '>' . _t( '__'.$value ) . '</option>';
}
$ret .= '</select>';
$ret .= '</form>';
$ret .= '</div>';
$ret .= '</div>';
$ret .= '</div>';
//#########################################################
$ret .= '<div style="margin-top:10px;">';
$ret .= '<div class="clear_both"></div>';
$ret .= '<div style="position:relative; float:left;"><img src="' . $site['icons'] . 'group.gif" alt="" /></div>';
$ret .= '<div style="position:relative; float:left; white-space:nowrap; left:5px; font-weight:bold; color:#000;">' . _t("_Total Registered") . '</div>';
$ret .= '<div class="clear_both"></div>';
$ret .= '<div style="position:relative; border-bottom:1px solid silver; margin:5px 0px;"></div>';
$ret .= '<div class="member_stat_block">';
$ret .= '<div><img src="' . $site['icons'] . 'us.gif" alt="" /><span style="margin-left:5px;">' . _t("_Total") . ' - ' . $total_arr[0] . '</span></div>';
if ( !$free_mode )
$ret .= '<div><img src="' . $site['icons'] . 'us.gif" alt="" /><span style="margin-left:5px;">' . _t("_Gold Members") . ' - ' . $total_arr_gold . '</span></div>';
$ret .= '<div><img src="' . $site['icons'] . 'us.gif" alt="" /><span style="margin-left:5px;">' . _t("_New this week") . ' - ' . $total_arr_week[0] . '</span></div>';
$ret .= '<div><img src="' . $site['icons'] . 'us.gif" alt="" /><span style="margin-left:5px;">' . $total_c_members . ' ' . _t("_members") . ' ' . _t("_from") . '</span></div>';
$ret .= '<div style="padding-left:20px;">';
$ret .= '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="cForm2">';
$ret .= '<input type="hidden" name="total_c2" value="' . $total_c2 . '" />';
$ret .= '<select style="width:123px;" name="total_c2" onchange="javascript: document.forms[\'cForm2\'].submit();">';
foreach ( $c_arr as $key => $value )
{
$ret .= '<option value="' . $key . '"';
if ( $key == $total_c2 )
$ret .= ' selected="selected"';
$ret .= '>' . _t( '__'.$value ) . '</option>';
}
$ret .= '</select>';
$ret .= '</form>';
$ret .= '</div>';
$ret .= '</div>';
$ret .= '</div>';
//#########################################################
return DesignBoxContent ( _t("_members"), $ret, $oTemplConfig -> PageCompMemberStat_db_num);
}
with
PHP Code:function visitors_online( )
{
$daten = "visitors.txt";
$time = time();
$ip = getenv("REMOTE_ADDR");
$ablaufzeit = $time - "300";
$pruefung = @file($daten);
while (list ($line_num, $line) = @each ($pruefung)) {
$zeiten = explode("&&",$line);
if($zeiten[0] <= $ablaufzeit) {
$fp = fopen( "$daten", "r" );
$contents = fread($fp, filesize($daten));
fclose($fp);
$line=quotemeta($line);
$string2 = "";
$replace = ereg_replace($line, $string2, $contents);
$fh=fopen($daten, "w");
@flock($fp,2);
fputs($fh, $replace);
@flock($fp,3);
fclose($fh);
}
}
$ippruefung = @file($daten);
while (list ($line_num, $line) = @each ($ippruefung)) {
$ips = explode("&&",$line);
if($ips[1] == $ip) {
$fp = fopen( "$daten", "r" );
$contents = fread($fp, filesize($daten));
fclose($fp);
$line=quotemeta($line);
$string2 = "";
$replace = ereg_replace($line, $string2, $contents);
$fh=fopen($daten, "w");
@flock($fp,2);
fputs($fh, $replace);
@flock($fp,3);
fclose($fh);
}
}
$fp = fopen("$daten", "a+");
flock($fp,2);
fputs ($fp, "$time&&$ip&&\n");
flock($fp,3);
fclose ($fp);
$anzahldaten = file($daten);
$anzahl = count($anzahldaten);
echo $anzahl;
}
function PageCompMemberStat( )
{
global $site;
global $prof;
global $oTemplConfig;
$free_mode = getParam("free_mode") == "on" ? 1 : 0;
// members statistics
$total_c = strlen( $_POST['total_c'] ) ? $_POST['total_c'] : getParam( "default_country" );
$total_c2 = strlen( $_POST['total_c2'] ) ? $_POST['total_c2'] : getParam( "default_country" );
$total_arr = db_arr( "SELECT COUNT(ID) FROM `Profiles` WHERE Status = 'Active'" );
$total_arr_week = db_arr( "SELECT COUNT(ID) FROM `Profiles` WHERE Status = 'Active' AND (TO_DAYS(NOW()) - TO_DAYS(LastReg)) <= 7" );
if ( !$free_mode )
$total_arr_gold = getMembersCount( MEMBERSHIP_ID_STANDARD, '', true );
$total_c_arr = db_arr( "SELECT COUNT(ID) FROM `Profiles` WHERE Status = 'Active' AND `Country` = '". process_db_input($total_c2) ."'" );
$total_members = $total_arr[0];
$total_c_members = $total_c_arr[0];
$total_c_members_onl = get_users_online_number('c', $total_c );
$total_arr_chatting = get_users_online_number('t');
$members_online = get_users_online_number();
$visitors_online = visitors_online( );
$c_arr = $prof['countries'];
//#########################################################
$ret = '';
$ret .= '<div class="membes_statistic_block">';
$ret .= '<div class="clear_both"></div>';
$ret .= '<div style="position:relative; float:left;"><img src="' . $site['icons'] . 'group.gif" alt="" /></div>';
$ret .= '<div style="position:relative; float:left; white-space:nowrap; left:5px; font-weight:bold; color:#000;">' . _t("_Currently Online") . '</div>';
$ret .= '<div class="clear_both"></div>';
$ret .= '<div style="position:relative; border-bottom:1px solid silver; margin:5px 0px;"></div>';
$ret .= '<div class="member_stat_block">';
$ret .= '<div><img src="' . $site['icons'] . 'us.gif" alt="" /><span style="margin-left:5px;">' . _t("_Visitors online") . ' - ' . $visitors_online . '</span></div>';
$ret .= '<div><img src="' . $site['icons'] . 'us.gif" alt="" /><span style="margin-left:5px;">' . _t("_Total") . ' - ' . $members_online . '</span></div>';
$ret .= '<div><img src="' . $site['icons'] . 'us.gif" alt="" /><span style="margin-left:5px;">' . _t("_Chatting") . ' - ' . $total_arr_chatting . '</span></div>';
$ret .= '<div><img src="' . $site['icons'] . 'us.gif" alt="" /><span style="margin-left:5px;">' . $total_c_members_onl . ' ' . _t("_members") . ' ' . _t("_from") . '</span></div>';
$ret .= '<div style="padding-left:20px;">';
$ret .= '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="cForm">';
$ret .= '<input type="hidden" name="total_c" value="' . $total_c . '" />';
$ret .= '<select style="width:123px;" name="total_c" onchange="javascript: document.forms[\'cForm\'].submit();">';
foreach ( $c_arr as $key => $value )
{
$ret .= '<option value="' . $key . '"';
if ( $key == $total_c )
$ret .= ' selected="selected"';
$ret .= '>' . _t( '__'.$value ) . '</option>';
}
$ret .= '</select>';
$ret .= '</form>';
$ret .= '</div>';
$ret .= '</div>';
$ret .= '</div>';
//#########################################################
$ret .= '<div style="margin-top:10px;">';
$ret .= '<div class="clear_both"></div>';
$ret .= '<div style="position:relative; float:left;"><img src="' . $site['icons'] . 'group.gif" alt="" /></div>';
$ret .= '<div style="position:relative; float:left; white-space:nowrap; left:5px; font-weight:bold; color:#000;">' . _t("_Total Registered") . '</div>';
$ret .= '<div class="clear_both"></div>';
$ret .= '<div style="position:relative; border-bottom:1px solid silver; margin:5px 0px;"></div>';
$ret .= '<div class="member_stat_block">';
$ret .= '<div><img src="' . $site['icons'] . 'us.gif" alt="" /><span style="margin-left:5px;">' . _t("_Total") . ' - ' . $total_arr[0] . '</span></div>';
if ( !$free_mode )
$ret .= '<div><img src="' . $site['icons'] . 'us.gif" alt="" /><span style="margin-left:5px;">' . _t("_Gold Members") . ' - ' . $total_arr_gold . '</span></div>';
$ret .= '<div><img src="' . $site['icons'] . 'us.gif" alt="" /><span style="margin-left:5px;">' . _t("_New this week") . ' - ' . $total_arr_week[0] . '</span></div>';
$ret .= '<div><img src="' . $site['icons'] . 'us.gif" alt="" /><span style="margin-left:5px;">' . $total_c_members . ' ' . _t("_members") . ' ' . _t("_from") . '</span></div>';
$ret .= '<div style="padding-left:20px;">';
$ret .= '<form action="'.$_SERVER['PHP_SELF'].'" method="post" name="cForm2">';
$ret .= '<input type="hidden" name="total_c2" value="' . $total_c2 . '" />';
$ret .= '<select style="width:123px;" name="total_c2" onchange="javascript: document.forms[\'cForm2\'].submit();">';
foreach ( $c_arr as $key => $value )
{
$ret .= '<option value="' . $key . '"';
if ( $key == $total_c2 )
$ret .= ' selected="selected"';
$ret .= '>' . _t( '__'.$value ) . '</option>';
}
$ret .= '</select>';
$ret .= '</form>';
$ret .= '</div>';
$ret .= '</div>';
$ret .= '</div>';
//#########################################################
return DesignBoxContent ( _t("_members"), $ret, $oTemplConfig -> PageCompMemberStat_db_num);
}
Then place a txt file called "visitors.txt" in your root directory and create a new language string for
It's not tested, but it should workPHP Code:_t("_Visitors online")
![]()
Last edited by Kleetus; 04-20-2007 at 09:05 AM.
On the new language string I go to languages click on create new language then what do I put? I just want to get it right.
Don't create a new language in "Manage Languages" menu !
"Add a new language key" in "Language Strings" menu !
Enter "_Visitors online" in "new language key name"
Select "Category" ("misc" or something else)
And add your discription in "String texts for available languages"
Warning: fopen(visitors.txt) [function.fopen]: failed to open stream: Permission denied in /home/jguzman/public_html/templates/tmpl_adl/scripts/index.php on line 108
Warning: flock(): supplied argument is not a valid stream resource in /home/jguzman/public_html/templates/tmpl_adl/scripts/index.php on line 109
Warning: fputs(): supplied argument is not a valid stream resource in /home/jguzman/public_html/templates/tmpl_adl/scripts/index.php on line 110
Warning: flock(): supplied argument is not a valid stream resource in /home/jguzman/public_html/templates/tmpl_adl/scripts/index.php on line 111
Warning: fclose(): supplied argument is not a valid stream resource in /home/jguzman/public_html/templates/tmpl_adl/scripts/index.php on line 112
Your almost there it is showing up in the box just getting these errors on to screen and messes up the screen a little.
Make the visitors.txt chmod 755
Still getting the error
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks