Show Number of Subscribers on Webpage

mrmyth

Member
Is there a way I can give a count of subscribers on a particular list where people sign up on my page?

I just want a counter of the number of people in the list to show on the page, so the public can see it go up.
 

stanbusk

Administrator
Staff member
Getting the available lists:
Code:
lm.php?cmd=lists[&email=email_addr][&pwd=password]
This command when used without the administrator password lets a visitor find out which lists he is subscribed to. When used with the administrator password the command returns detailed information of all lists available on the server, including each list name, recipient count and modification date.
 

mrmyth

Member
Okay so I got that to work for me in that it returns the information on a blank page.

How can I use that to display the information on my sign-up page?
 

stanbusk

Administrator
Staff member
Use the PHP 'echo' command. If you use the '.php' extension for your page rather than '.html' all your PHP code will be ran. You can insert PHP code absolutely anywhere. For example you can insert anywhere you want:
Code:
<?php echo "Hello World"; ?>
Try it, it is really amazing.
 

mrmyth

Member
That is awesome!

I can get text to show, but is there a way I can get the number of subscribers to show?

I'm also going to have to hide the password in my query too I suppose. (Maybe that's much more complicated.)
 

stanbusk

Administrator
Staff member
What is the output right now? About password, you can use the one in lm_settings.php using and include statement on your PHP file:
Code:
include( 'path_to_lm_folder/lm_settings.php' );
 

mrmyth

Member
Thanks Stan:

I realize that I'm asking how to do some php, without really knowing enough about it. I'm trying to comprehend but I'm a little stymied.

I will try to work with you gave me, but any more instruction is greatly appreciated. Right now I don't really know how to combine the Echo with the html url that gives me the data.

I only have one list, so I'm getting the date and time, list name and number of subscribers when I put the html in the browser.

I can put the echo command in a web page and get text but I can't combine the two so that I get the data on the page.

Just want the number of subscribers to show on my signup page, but for me it's a monumental task. :shock:

Thanks in advance.
 

stanbusk

Administrator
Staff member
The output of the command is plain text. The echo command print the text to the screen. You can assign the command output to a parameter like '$output' and then do a 'echo $output;'. Try this to print all the output. Now you will have to find a way to output the data you need only... Let me think...
 

mrmyth

Member
Thanks for the help Stan. Sorry I'm such a knucklehead on this. If this is something asked of me, it may prove useful for others.

Joel
 

mrmyth

Member
Stan:

Okay, I finally got somewhere and it is working. Took a little bit of searching around. I haven't been able to parse out just the number but this is what I have done so far.

I put this at the top of the page
Code:
include( '../lm_settings.php' );

to get the password
then where I want the info I put.

Code:
<?php
    ob_start();
    include('http://MYDOMAIN.com/LMFOLDER/lm.php?cmd=lists&pwd='.$admin_password);
    $myStr = ob_get_contents();
    ob_end_clean();
    echo 'List Name - Number of Subscribers - Date and Time';
	echo "<br/>";
	echo  $myStr;
?>

The current output looks something like this
List Name - Number of Subscribers - Date and Time
List1 502 2015-04-23 23:23:50

And that is okay, but still not so great looking

If you can help me figure out a way I can just get the number of subscribers, without the list name and date and time that would make it perfect.
 

stanbusk

Administrator
Staff member
Ok, you are learning PHP, an extremely useful language... It is C/C++ for the web :) This:
Code:
include( '../lm_settings.php' );
is correct. That way you include the contents of lm_settings.php into your file, parameters and functions alike. This:
Code:
<?php
    ob_start();
    include('http://MYDOMAIN.com/LMFOLDER/lm.php?cmd=lists&pwd='.$admin_password);
    $myStr = ob_get_contents();
    ob_end_clean();
    echo 'List Name - Number of Subscribers - Date and Time';
   echo "<br/>";
   echo  $myStr;
?>
is correct as well. Note that you can also write include( "http://MYDOMAIN.com/LMFOLDER/lm.php?cmd=lists&pwd=$admin_password"); that is, inserting the parameter directly into the string. Same effect. The output:
List Name - Number of Subscribers - Date and Time
List1 502 2015-04-23 23:23:50
is a tab delimited list of lists with one record per line. List name is in the first column and address count in the second column. I wrote a little function to extract data from delimited strings. It is called nthfield:
Code:
// Get the field number fieldnumber from $text for the given $delimiter
function nthfield($text, $delimiter, $fieldnumber) {
	$data = explode($delimiter, $text);
	return $data[$fieldnumber-1];
}
To extract the address count of your list, since you only have one, you can do:
Code:
$count = nthfield( $myStr, "\t", 2 );
 
Top