Reptags for ICQ, Skype and Users Online

Post custom hacks and enhancements for phpwcms here only. Maybe some of these things will be included in official release later.
jscholtysik

Reptags for ICQ, Skype and Users Online

Post by jscholtysik »

Hi all,


I have modified my reptags for the Skype and ICQ status, written in 2006:

ICQ-Status (Copy the code into a new file, for example: reptag_ICQ.php and place this file in the frontend_render directory):

Code: Select all

<?php
/************************************************************************************************************************************
REPTAG CODE: {ICQ:starttext:spacer1:number:spacer2:alt:title:image:align}

Developer: Joachim Scholtysik
Homepage: http://www.scholtysik.net
phpwcms Version: 1.3.9

last modified:  23.05.2008

23.05.2008: Added phpwcms constants check written by O.G.
22.05.2008: Added two new parameters for spacers before and after the ICQ Account number
07.02.2006: Added closing tag </a>
02.02.2006: Initial release

Description:
Shows a status line for ICQ.

Installation:
				Copy this file into the frontend_render directory                
                
				Place this line into your template or article:

				{ICQ:starttext:spacer1:number:spacer2:alt:title:image:align}

				where 
				- starttext is the introducing text for the status line ($1)
				- spacer1 is the number of the spaces between the introducing text and your account number ($2)
				- number is your ICQ account ($3)
				- spacer2 is the number of the spaces between your account number and the ICQ image ($4)
                - alt is the alt text for the ICQ image ($5)
				- title is the title text for the ICQ image ($6)
				- image is the number of the ICQ image (1-10) ($7)
				- align is the alignment of the ICQ image (top, middle, bottom) ($8)
************************************************************************************************************************************/

// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
   die("You Cannot Access This Script Directly, Have a Nice Day.");
}
// ----------------------------------------------------------------

  if( ! (strpos($content["all"],'{ICQ:')===false)) { 
	$content["all"] = preg_replace('/\{ICQ:(.*?):(\d+):(\d+):(\d+):(.*?):(.*?):(\d+):(.*?)\}/','$1: <img src="img/leer.gif" width="$2" height="10px" border="0" alt="" /> $3 <img src="img/leer.gif" width="$4" height="10px" border="0" alt="" /> <img alt="$5" title="$6" src="http://status.icq.com/online.gif?icq=$3&img=$7" align="$8" /></a>',$content["all"]);
  } 
?>


Skype-Status (Copy the code into a new file, for example: reptag_SKYPE.php and place this file in the frontend_render directory):

Code: Select all

<?php
/************************************************************************************************************************************
REPTAG CODE: {SKYPE:starttext:spacer1:name:spacer2:alt:title:folder:align}

Developer: Joachim Scholtysik
Homepage: http://www.scholtysik.net
phpwcms Version: 1.3.9

last modified:  23.05.2008

23.05.2008: Added phpwcms constants check written by O.G.
22.05.2008: Added two new parameters for spacers before and after the Skype name
07.02.2006: Added closing tag </a>
02.02.2006: Initial release

Description:
Shows a status line for Skype.

Installation:
                Copy this file into the frontend_render directory

				Place this line into your template or article:
				
                {SKYPE:starttext:spacer1:name:spacer2:alt:title:folder:align}

				where 
				- starttext is the introducing text for the status line ($1)
				- spacer1 is the number of the spaces between the introducing text and your Skype name ($2)
				- name is your Skype name ($3)
				- spacer2 is the number of the spaces between your Skype name and the Skype image ($4)
                - alt is the alt text for the Skype image ($5)
				- title is the title text for the Skype image ($6)
				- folder is the folder for the Skype image, with slash (bigclassic/, smallclassic/, smallicon/) ($7)
				- align is the alignment of the Skype image (top, middle, bottom) ($8)
************************************************************************************************************************************/

// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
   die("You Cannot Access This Script Directly, Have a Nice Day.");
}
// ----------------------------------------------------------------

if( ! (strpos($content["all"],'{SKYPE:')===false)) { 
	$content["all"] = preg_replace('/\{SKYPE:(.*?):(\d+):(.*?):(\d+):(.*?):(.*?):(.*?):(.*?)\}/','$1: <img src="img/leer.gif" width="$2" height="10px" border="0" alt="" /> $3 <img src="img/leer.gif" width="$4" height="10px" border="0" alt="" /> <img alt="$5" title="$6" src="http://mystatus.skype.com/$7$3" align="$8" /></a>',$content["all"]);
} 
?>

And I wanted to see, how many users are online at my site, so I created this new reptag (runs without a real database, only with a flat file):

Users Online (Copy the code into a new file, for example: reptag_useronline.php and place this file and also a blank "count.txt" in the frontend_render directory):

Code: Select all

<?php 
/************************************************************************************************************************************
REPTAG CODE: {ONLINE}

Developer: Joachim Scholtysik
Homepage: http://www.scholtysik.net
phpwcms Version: 1.3.9

last modified:  18.06.2008

18.06.2008: Fix: Changed order of the variables $zeiten and $ips in the array
23.05.2008: Added phpwcms constants check written by O.G.
22.05.2008: Initial release

Description:
Shows a status line with users who are online.

Installation:
				Copy this file into the frontend_render directory                
                
				Create a blank file named "count.txt" and place it also in the frontend_render directory (CHMOD: 777)

				Place this line into your template or article:
				
				{ONLINE}
************************************************************************************************************************************/

// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
   die("You Cannot Access This Script Directly, Have a Nice Day.");
}
// ----------------------------------------------------------------

if( ! (strpos($content["all"],'{ONLINE}')===false)) { 
	$content["all"] = preg_replace('/\{ONLINE\}/',online(),$content["all"]);
}
 
function online() {
	$daten = $_SERVER['DOCUMENT_ROOT']."template/inc_script/frontend_render/count.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[1] <= $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[0] == $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, "$ip&&$time&&\n"); 
	flock($fp,3); 
	fclose ($fp); 
	$anzahldaten = file($daten); 
	$anzahl = count($anzahldaten); 
	$online=$anzahl." User(s) online"; 
	return $online;
}
?>
You can see all three reptags in action at http://www.scholtysik.net/index.php?impressum in the content area and in the footer.


Perhaps you will find it useful... ;-)


Joachim
Last edited by jscholtysik on Fri 18. Jul 2008, 23:27, edited 1 time in total.
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: Reptags for ICQ, Skype and Users Online

Post by update »

Very nice - thank you! I will go playing with these :)
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
User avatar
Cipolla
Posts: 451
Joined: Sat 16. Feb 2008, 20:39
Location: Muppet Show

Re: Reptags for ICQ, Skype and Users Online

Post by Cipolla »

Btw.:

is it right that your floating box to the left shows under the main content and not floating left? Screenshot with IE6.

/stuff/scholtysik.JPG

Image
...
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: Reptags for ICQ, Skype and Users Online

Post by update »

There is the following error with "users online":

Code: Select all

Warning: fopen(/home/www/my-domain/public_htmlcount.txt) [function.fopen]: failed to open stream: Permission denied in /home/www/my-domain/public_html/template/inc_script/frontend_render/reptag_users_online.php on line 79
Warning: flock() expects parameter 1 to be resource, boolean given in /home/www/my-domain/public_html/template/inc_script/frontend_render/reptag_users_online.php on line 80
Warning: fputs(): supplied argument is not a valid stream resource in /home/www/my-domain/public_html/template/inc_script/frontend_render/reptag_users_online.php on line 81
Warning: flock() expects parameter 1 to be resource, boolean given in /home/www/my-domain/public_html/template/inc_script/frontend_render/reptag_users_online.php on line 82
Warning: fclose(): supplied argument is not a valid stream resource in /home/www/my-domain/public_html/template/inc_script/frontend_render/reptag_users_online.php on line 83
Warning: file() [function.file]: Unable to access /home/www/my-domain/public_htmlcount.txt in /home/www/my-domain/public_html/template/inc_script/frontend_render/reptag_users_online.php on line 84
Warning: file(/home/www/my-domain/public_htmlcount.txt) [function.file]: failed to open stream: Permission denied in /home/www/my-domain/public_html/template/inc_script/frontend_render/reptag_users_online.php on line 84
versions: 135(05-12-07), 139 (r232)
Different servers... 777 on count.txt
How can I fix that?
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: Reptags for ICQ, Skype and Users Online

Post by update »

Ah - I just see something:
[function.file]: Unable to access /home/www/my-domain/public_html/count.txt
There is a missing slash... hmmm...
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: Reptags for ICQ, Skype and Users Online

Post by update »

now I changed it a little bit (no permission to write into frontend_render folder), threw the count.txt into root and added the missing slash:

Code: Select all

   //$daten = $_SERVER['DOCUMENT_ROOT']."template/inc_script/frontend_render/count.txt";
   $daten = $_SERVER['DOCUMENT_ROOT']."/"."count.txt";
now the error is gone :) and it's working
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
jscholtysik

Re: Reptags for ICQ, Skype and Users Online

Post by jscholtysik »

Hi Claus,


works at my site without any errors....


Joachim
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: Reptags for ICQ, Skype and Users Online

Post by update »

the problem probably has been the missing permission to write into the frontend_render folder (perhaps differences in restrictions?) I don't know - still testing ;)
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: Reptags for ICQ, Skype and Users Online

Post by update »

it's error free now, nicely updating the time stamp of the one and only entry - always only one, doesn't add any second / third line...
Do you have any idea?
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
jscholtysik

Re: Reptags for ICQ, Skype and Users Online

Post by jscholtysik »

Hi Claus,


I have fixed the script at the top of this thread, so it must work properly... ;-) The order of the variables $zeiten and $ips was wrong.


Have fun.


Joachim
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: Reptags for ICQ, Skype and Users Online

Post by update »

I'll give it a try - many thanks ;)
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: Reptags for ICQ, Skype and Users Online

Post by update »

seems to be working now - but only with the counter not being within the frontend_render folder. Anyway, this isn'T that bad ;) Thanks again!
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
jscholtysik

Re: Reptags for ICQ, Skype and Users Online

Post by jscholtysik »

Hi Claus,


strange, with me it works in the frontend_render folder... !?!


Joachim
User avatar
update
Moderator
Posts: 6455
Joined: Mon 10. Jan 2005, 17:29
Location: germany / outdoor

Re: Reptags for ICQ, Skype and Users Online

Post by update »

One more question: which number is it counting: the overall number or the number of visitors for the page?
It's mostly all about maintaining two or three customer's sites Still supporter for the band Mykket Morton. Visit Mykket Morton on FB. Listen Mykket Morton and live videos on youtube.
Now building a venue for young artists to get wet on stage, rehearsal rooms, a studio, a guitar shop - yes I'm going to build some guitars.
jscholtysik

Re: Reptags for ICQ, Skype and Users Online

Post by jscholtysik »

Hi claus,

please say it in german...

Thanks.


Joachim
Post Reply