We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12550
    • 107 Posts
    This little easy snippet show icq status (in text mode) of user in this moment: "offline" or "online".

    [!icq? &icq=`43471815` &online=`iam online now` &offline=`iam offline now`!]

    :-)
      • 27376
      • 576 Posts
      Small and simple!

      A great addition. Thank you!
        • 16702 ☆ A M B ☆
        • 536 Posts
        Very GOOD!!!

        but why not work image online or offline?

          palma non sine pulvere
          • 12550
          • 107 Posts
          No problem: [!icq? &icq=`43471815` &online=`<img src=online.gif>` &offline=`<img src=offline.gif>`!] smiley
            • 16702 ☆ A M B ☆
            • 536 Posts
            Quote from: iamask at May 27, 2007, 08:27 AM

            No problem: [!icq? &icq=`43471815` &online=`<img src=online.gif>` &offline=`<img src=offline.gif>`!] smiley


            i think with images not work.
            i try but no result...

              palma non sine pulvere
              • 27376
              • 576 Posts
              Quote from: iamask at May 27, 2007, 08:27 AM

              No problem: [!icq? &icq=`43471815` &online=`<img src=online.gif>` &offline=`<img src=offline.gif>`!] smiley
              Why not make those parameters just take the actual image source? Doing it like this is not XHTML compliant.
                • 7923
                • 4,213 Posts
                Here’s another one with some changes:

                - &offline and &online parameters support following:
                * chunkname
                * @FILE:path/to/file
                * @CODE:return value as text

                - Added &usecurl [1/0] parameter to make it use curl to get the picture. Some servers don’t allow fopen for urls (like mine). There is still one limiting thing with this too, the curl has to follow redirects to get the picture, but if safe mode is enabled in your server, you cannot use that CURLOPT_FOLLOWLOCATION option.

                <?php
                // Copyright @ 2007, iamask (icq: 43471815), modified by doze
                // For modxcms.com : [!icq? &icq=`43471815` &online=`online` &offline=`offline`!]
                //
                if (!function_exists('icqGetTemplate')) {
                	function icqGetTemplate($tpl){
                		global $modx;
                		$template = "";
                		if ($modx->getChunk($tpl) != "") {
                			$template = $modx->getChunk($tpl);
                		} else if(substr($tpl, 0, 6) == "@FILE:") {
                			$template = $this->get_file_contents($modx->config['base_path'].substr($tpl, 6));
                		} else if(substr($tpl, 0, 6) == "@CODE:") {
                			$template = substr($tpl, 6);
                		} else {
                			$template = FALSE;
                		}
                		return $template;
                	}
                }
                
                if (!function_exists('icqGet_file_contents')) {
                	function icqGet_file_contents($filename) {
                		// Function written at http://www.nutt.net/2006/07/08/file_get_contents-function-for-php-4/#more-210
                		// Returns the contents of file name passed
                		if (!function_exists('file_get_contents')) {
                			$fhandle = fopen($filename, "r");
                			$fcontents = fread($fhandle, filesize($filename));
                			fclose($fhandle);
                		} else	{
                			$fcontents = file_get_contents($filename);
                		}
                		return $fcontents;
                	}
                }
                
                $icq=(isset($icq))? $icq : "43471815";
                $offline=(isset($offline))? icqGetTemplate($offline) : "offline";
                $online=(isset($online))? icqGetTemplate($online) : "online";
                $usecurl=(isset($usecurl))? $usecurl : false;
                $handle;
                if ($usecurl) {
                	$tempfile = $modx->config['base_path'].'assets/cache/icq.temp';
                	$ch = curl_init("http://wwp.icq.com/scripts/online.dll?icq=$icq&img=5");
                	$handle = fopen ($tempfile, "w");
                	curl_setopt ($ch, CURLOPT_FILE, $handle);
                	curl_setopt ($ch, CURLOPT_HEADER, 0);
                	curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
                	curl_exec ($ch);
                	curl_close ($ch);
                	fclose ($handle);
                   	$handle = fopen($tempfile, "rb");
                } else {
                	$handle = fopen("http://wwp.icq.com/scripts/online.dll?icq=$icq&img=5", "rb");
                }
                
                $contentbig="";
                while (!feof($handle)) {
                  $contentbig .= fread($handle, 1024);
                }
                fclose($handle);
                if ($usecurl) {
                	unlink($tempfile);
                }
                if(strlen($contentbig)==141){
                	return $online;
                } else {
                	return $offline;
                }
                ?>
                


                  "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                  • 12550
                  • 107 Posts
                  wow ) very good )

                  Quote from: doze at May 28, 2007, 04:58 PM

                  Here’s another one with some changes:
                    • 16702 ☆ A M B ☆
                    • 536 Posts
                    i think this not work.
                      palma non sine pulvere
                      • 7923
                      • 4,213 Posts
                      i think it does

                      EDIT: Could someone move this topic to the "In development" forum?


                        "He can have a lollipop any time he wants to. That's what it means to be a programmer."