Page Index Toggle Pages: 1
Topic Tools
 10 HTML or PHP Bridge ... (Read 8,099 times)
JonB
YaBB Administrator
YaBB Next Team
Operations Team
Beta Testers
Support Team
*****
Offline



Posts: 3,768
Location: Land of the Blazing Sun!

YaBB 2.6.0
Re: HTML or PHP Bridge ...
Reply #11 - Sep 28th, 2011 at 9:21pm
Post Tools
That's a cool site, Dandello.

Cool
  

I find your lack of faith disturbing.
Back to top
IP Logged
 
Dandello
YaBB Administrator
YaBB Next Team
Operations Team
Beta Testers
Support Team
*****
Online



Posts: 2,079
Location: Earth

YaBB 2.6.0
Re: HTML or PHP Bridge ...
Reply #10 - Sep 28th, 2011 at 4:32pm
Post Tools
Okay - got it - including lastpost.
Check the required Perl modules to make sure you have them. A couple aren't standard on every server but are available through Cpan.

Code (Perl)
Select All
#!/usr/bin/perl
# $Id: yabboard $
# $Date: 9.26.11 $
# $HeadURL: shadolibrary.org $
# $Revision: 2011 $
# $Source: /yabboard.pl $
##################################################################################
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
use List::Util qw(sum);
use Time::localtime;
use Readonly;
our $VERSION = 2.0;

print "Content-type: text/html\n\n" or croak 'cannot print line1';

my ( $memcount, $latestmember ) = membershipget();
chomp $latestmember;
my $totalm         = 0;
my $totalt         = 0;
my $lastposttime   = 0;
my $lastthreadtime = 0;
Readonly my $YEAR => 1900;

my $file      = qq{yabb2/Members/$latestmember.vars};
my $realnamea = 'no name';
open my $FBOOK, '<', $file or croak '<strong>Welcome, Guest</strong>';
my @fbook = <$FBOOK>;
close $FBOOK or croak 'cannot close user file';
foreach my $i (@fbook) {
    chomp $i;
    my ( $ind, $realname ) = split /,/xsm, $i;
    $realname =~ s/"//gxsm;    #";
    if ( $ind eq q{'realname'} ) {
        $realnamea = $realname;
    }
}

my @aoa_t = ();
my @aoa_m = ();

#open and clean forum totals array
my $file_tot = q{yabb2/Boards/forum.totals};
open my $FTOT, '<', $file_tot or croak 'cannot open file_tot';
my @f_tot = <$FTOT>;
close $FTOT or croak 'cannot close forum_tot';

my @wlinks = ();
my %seen   = ();
foreach my $item (@f_tot) {
    if ( !$seen{$item} ) {
        $seen{$item} = 1;
        push @wlinks, $item;
    }
}

my $ln      = 0;
my $array_t = 0;
my $array_m = 0;

#get data from cleaned forum totals array
#F1|134|2482|1284563170|ka1bqp|1282061264|114|Re: FDK In Training|xx|0h
my @newfile = (0);
my $cn      = 0;
foreach my $k (@wlinks) {
    my (
        $brd,        $topic, $posts,      $timein, $lsposter,
        $ltdatetime, $xw,    $post_title, $xx,     $xy
    ) = split /[|]/xsm, $k;
    if (   $brd ne 'recycle'
        && $brd        ne 'spam'
        && $brd        ne 'prob'
        && $brd        ne 'F2'
        && $brd        ne 'T2'
        && $brd        ne 'ff8'
        && $brd        ne 'vent'
        && $timein     ne 'N/A'
        && $post_title ne q{} )
    {
        $newfile[$cn] = join q{|}, $timein, $brd, $topic, $posts, $lsposter,
          $xw, $post_title, $xx, $xy, $ltdatetime;
        $cn++;
    }
}

my @sorted = reverse sort @newfile;
foreach my $j (@sorted) {
    my (
        $timein, $brd,        $topic, $posts, $lsposter,
        $xw,     $post_title, $xx,    $xy,    $ltdatetime
    ) = split /[|]/xsm, $j;
    $array_t    = $topic;
    $array_m    = $posts;
    $aoa_t[$ln] = $array_t;
    $aoa_m[$ln] = $array_m;
    $ln++;
}
$totalt = sum(@aoa_t);
$totalm = sum(@aoa_m);

my $sort = $sorted[0];
my @newpost = split /[|]/xsm, $sort;

my $tm   = localtime $newpost[0];
my $year = $tm->year + $YEAR;
my $mont = $tm->mon;
my $dayt = $tm->mday;

my $sup = q{<sup>st</sup>};
if ( $dayt == 1 ) {
    $sup = q{<sup>st</sup>};
}
else {
    $sup = q{<sup>th</sup>};
}

my @months = qw(
  Jan Feb Mar Apr May Jun
  Jul Aug Sep Oct Nov Dec
);

print
qq{<br /><span style='font-size:80%'>The Writers&#39; Guild contains a total of <b>$totalm Posts</b> within <b>$totalt Topics</b>.<br />We have a total of $memcount registered members.<br />The most recent public post is: <a href='../cgi-bin/yabb2/YaBB.pl?num=$newpost[9]'>$newpost[6]</a> ($months[$mont] $dayt$sup, $year)<br />The newest member is $realnamea.</span>}
  or croak 'cannot print totals';

sub membershipget {
    my $filea = q{yabb2/Members/members.ttl};
    open my $FILEMEMGET, '<', $filea or croak 'cannot open file';
    $_ = <$FILEMEMGET>;
    close $FILEMEMGET or croak 'cannot close file';
    return split /[|]/xsm, $_;
}
 



The code can no doubt be cleaned up a bit. Again, this was written for my forum, so some things won't apply to yours.

To see it in action: http://www.shadolibrary.org/

  

If you only have one solution to a problem you're not trying hard enough!
Back to top
WWW  
IP Logged
 
Dandello
YaBB Administrator
YaBB Next Team
Operations Team
Beta Testers
Support Team
*****
Online



Posts: 2,079
Location: Earth

YaBB 2.6.0
Re: HTML or PHP Bridge ...
Reply #9 - Sep 28th, 2011 at 5:08am
Post Tools
I don't see any way to do some of these things in PHP - but hey, I'm a Perl Monger from way back.  Grin

Next project, actually getting the newest post link squared away.
  

If you only have one solution to a problem you're not trying hard enough!
Back to top
WWW  
IP Logged
 
Derek Barnstorm
Support Team
YaBB Next Team
Development Team
Beta Testers
****
Offline



Posts: 1,269
Location: United Kingdom

None
Re: HTML or PHP Bridge ...
Reply #8 - Sep 28th, 2011 at 2:52am
Post Tools
It's nice to see someone doing something creative with YaBB and sharing it. Smiley
  
Back to top
 
IP Logged
 
Dandello
YaBB Administrator
YaBB Next Team
Operations Team
Beta Testers
Support Team
*****
Online



Posts: 2,079
Location: Earth

YaBB 2.6.0
Re: HTML or PHP Bridge ...
Reply #7 - Sep 28th, 2011 at 2:07am
Post Tools
We can now get the number of posts and topics, number of members and the name of the newest member.

Code (Perl)
Select All
#!/usr/bin/perl
# $Id: yabboard $
# $Date: 9.26.11 $
# $HeadURL: shadolibrary.org $
# $Revision: 2011 $
# $Source: /yabboard.pl $
##################################################################################
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
use List::Util qw(sum);
our $VERSION = 2.0;

print "Content-type: text/html\n\n" or croak 'cannot print line1';

my ( $memcount, $latestmember ) = membershipget();
chomp $latestmember;
my $totalm         = 0;
my $totalt         = 0;
my $lastposttime   = 0;
my $lastthreadtime = 0;

#{yabb lastpostlink} {yabb lastpostdate}
#{yabb recentposts}

my $file      = qq{yabb2/Members/$latestmember.vars};
my $realnamea = 'no name';
open my $FBOOK, '<', $file or croak '<strong>Welcome, Guest</strong>';
my @fbook = <$FBOOK>;
close $FBOOK or croak 'cannot close user file';
foreach my $i (@fbook) {
    chomp $i;
    my ( $ind, $realname ) = split /,/xsm, $i;
    $realname =~ s/"//gxsm;    #";
    if ( $ind eq q{'realname'} ) {
        $realnamea = $realname;
    }
}

my @aoa_t = ();
my @aoa_m = ();

#open and clean forum totals array
my $file_tot = q{yabb2/Boards/forum.totals};
open my $FTOT, '<', $file_tot or croak 'cannot open file_tot';
my @f_tot = <$FTOT>;
close $FTOT or croak 'cannot close forum_tot';

my @wlinks = ();
my %seen   = ();
foreach my $item (@f_tot) {
    if ( !$seen{$item} ) {
        $seen{$item} = 1;
        push @wlinks, $item;
    }
}

my $ln      = 0;
my $array_t = 0;
my $array_m = 0;

#get data from cleaned forum totals array
foreach my $j (@wlinks) {
    my (
        $brd,        $topic, $posts,      $timein, $lsposter,
        $ltdatetime, $xw,    $post_title, $xx,     $xy
    ) = split /[|]/xsm, $j;
    if (   $brd ne 'recycle'
        && $brd    ne 'spam'
        && $brd    ne 'prob'
        && $timein ne 'N/A' )
    {
        $array_t = $topic;
        $array_m = $posts;
    }
    else {
        $array_t = 0;
        $array_m = 0;
    }
    $aoa_t[$ln] = $array_t;
    $aoa_m[$ln] = $array_m;
    $ln++;
}

$totalt = sum(@aoa_t);
$totalm = sum(@aoa_m);

print
qq{<br /><span style='font-size:80%'>The Writers&#39; Guild contains a total of <b>$totalm Posts</b> within <b>$totalt Topics</b>.<br />We have a total of $memcount registered members.<br />The newest member is $realnamea.</span>}
  or croak 'cannot print totals';

sub membershipget {
    my $filea = q{yabb2/Members/members.ttl};
    open my $FILEMEMGET, '<', $filea or croak 'cannot open file';
    $_ = <$FILEMEMGET>;
    close $FILEMEMGET or croak 'cannot close file';
    return split /[|]/xsm, $_;
}
 



Again, the SSI code for getting the results of the script into your html page:
Code
Select All
<!--#include virtual='cgi-bin/yabboard.pl' --> 



A couple notes - the paths are not derived from variables so you may need to alter them for your differences.

Code (Perl)
Select All
    if (   $brd ne 'recycle'
        && $brd    ne 'spam'
        && $brd    ne 'prob'
        && $timein ne 'N/A' ) { 


tells the script not to grab totals from recycle or other board tallies that you probably don't want counted - on my set up I have spam and prob boards that are staff only. Trying to get this information out of the forum.master or forum.control files was just way more trouble than it was worth.

Have fun.  Cool
  

If you only have one solution to a problem you're not trying hard enough!
Back to top
WWW  
IP Logged
 
Dandello
YaBB Administrator
YaBB Next Team
Operations Team
Beta Testers
Support Team
*****
Online



Posts: 2,079
Location: Earth

YaBB 2.6.0
Re: HTML or PHP Bridge ...
Reply #6 - Sep 27th, 2011 at 3:10pm
Post Tools
Very old thread I know but...

I'm running YaBB 2.5AE and my 'static' web pages all use Perl-based Server-side includes.

So a Perl based user name reader (ala Capt. John's PHP one) for your static home page:

Code (Perl)
Select All
#!/usr/bin/perl
# $Id: yabbuserfile $
# $Date: 4.21.11 $
# $HeadURL: shadolibrary.org $
# $Revision: 2011 $
# $Source: /yabbuserfile.pl $
##################################################################################
use strict;
use warnings;
use CGI::Carp qw(fatalsToBrowser);
use CGI qw(:standard);
our $VERSION = 2.0;

print "Content-type: text/html\n\n" or croak 'cannot print line1';

my $username = cookie("Y2User-26598");
if(defined $username){
	my $file = qq{yabb2/Members/$username.vars};
	open my $FBOOK, '<', $file or croak '<strong>Welcome, Guest</strong>';
	my @fbook = <$FBOOK>;
	close $FBOOK or croak 'cannot close user file';
	foreach my $i (@fbook) {
		chomp $i;
    		my ( $ind, $realname ) = split /,/xsm,$i;
	    	$realname =~ s/"//gxsm; #";
    		if($ind eq q{'realname'}) {
			print qq{<strong>Hello $realname</strong> | <a href="cgi-bin/yabb2/YaBB.pl?action=viewprofile;username=$username" rel="nofollow">Profile</a><a href="cgi-bin/yabb2/YaBB.pl?action=logout" rel="nofollow">Sign out</a>};
 		}
	}
}
else {
	print q{<strong>Welcome, Guest. Please <a href="cgi-bin/yabb2/YaBB.pl?action=login">Login</a> or <a href="cgi-bin/yabb2/YaBB.pl?action=register">Register</a></strong>};
}

 



Note that this requires
Code
Select All
use CGI::Carp qw(fatalsToBrowser) 



Needless to say, you'll need to adjust the urls to suit your usage.

Insert:
Code
Select All
<!--#include virtual='cgi-bin/yabbuserfile.pl' --> 

in your home page code where you want the name to appear.
« Last Edit: Sep 27th, 2011 at 3:12pm by Dandello »  

If you only have one solution to a problem you're not trying hard enough!
Back to top
WWW  
IP Logged
 
coldnex
YaBB Newcomer
*
Offline



Posts: 6

None
Re: HTML or PHP Bridge ...
Reply #5 - Sep 22nd, 2010 at 8:39pm
Post Tools
Doherty wrote on Sep 27th, 2008 at 8:25am:
Just wondering if there could be a html or php bridge for forum statistics and users online. I remember using that in a much older version of YaBB as it was a mod in boardmod many years ago. I would love to have that.


I know this is a really old topic but to my understanding to show the users online simply add

Code
Select All
<yabb onlineusers> 

  
Back to top
 
IP Logged
 
Doherty
Full Member
***
Offline



Posts: 108
Location: Petal, Ms
Re: HTML or PHP Bridge ...
Reply #4 - Sep 27th, 2008 at 8:25am
Post Tools
Just wondering if there could be a html or php bridge for forum statistics and users online. I remember using that in a much older version of YaBB as it was a mod in boardmod many years ago. I would love to have that.
  
Back to top
WWW  
IP Logged
 
ChiMoHe
YaBB Newcomer
*
Offline



Posts: 22
Location: Trip2Blog
Re: HTML or PHP Bridge ...
Reply #3 - Apr 17th, 2008 at 5:05am
Post Tools
Quote:
HTML for a YaBB Login

Code
Select All
   <!-- Start of User Login -->
    <div id="userlogin">
  <div id="userlogin_header">
    <h2><span>User Login</span></h2>
  </div>
  <form action="http://www.yourdomain.com/cgi-bin/yabb2/YaBB.pl?action=login2" method="post">
    <div id="field_username"> <strong><span>Log in:</span></strong>
	<input type="text" name="username" />
    </div>
    <div id="field_password"> <strong><span>Password:</span></strong>
	<input type="password" name="passwrd" />
    </div>

<input type="hidden" name="cookielength" value="1" />

    <div id="button_enter">
	<input type="image" src="images/userlogin_enter.gif" alt="Enter" class="button" />
    </div>

	<input type="hidden" name="formsession" value="73899A95898F933E7090907E8287375C8486887F255037" /></form>
  <div id="userlogin_links"> <a href="http://www.yourdomain.com/cgi-bin/yabb2/YaBB.pl?action=register" id="register"><strong><span>Register >>></span></strong></a> <br />
    <a href="http://www.yourdomain.com/cgi-bin/yabb2/YaBB.pl?action=register" id="notregister"><strong><span>Not Registered Yet?</span></strong></a> </div>
    </div>
    <!-- End of User Login --> 



   OR see this thread here: http://www.boardmod.org/yabb/YaBB.pl?board=programming;action=display;num=118365...


These Need work and finalizing !


this line
Code
Select All
	<input type="image" src="images/userlogin_enter.gif" alt="Enter" class="button" />
 



should be
Code
Select All
	<input type="submit" src="images/userlogin_enter.gif" alt="Enter" class="button" />
 




HTML Code for YaBB2.2.1 Login
Code
Select All
<!-- Start of User Login -->
  <div class="bordercolor" style="width: 700px; margin-bottom: 8px; margin-left: auto; margin-right: auto;">

<table cellpadding="4" cellspacing="1" border="0" width="100%" align="center">
  <tr>
    <td class="titlebg" colspan="2"><b>Login</b></td>
  </tr>
  <tr>
    <td class="windowbg2" colspan="2" valign="middle">

    <form action="http://www.yourdomain.com/yabb2/YaBB.pl?action=login2" method="post">
    <div style="clear: both; padding-top: 4px; margin-left: auto; margin-right: auto; width: 600px;">
	<span style="float: left; width: 50%; text-align: left; margin-bottom: 5px;">
	  Username or email address: <br />
	  <input type="text" name="username" size="30" maxlength="30" style="width: 285px;" tabindex="1" />
	</span>
	<span style="float: left; width: 25%; text-align: left; margin-bottom: 5px;">
	  Password:<br />
	  <input type="password" name="passwrd" size="15" maxlength="30" style="width: 110px;" tabindex="2" />
	</span>

	  <input type="hidden" name="cookielength" value="1" />

    </div>
    <div style="clear: both; margin-top: 5px; margin-left: auto; margin-right: auto; width: 370px;">
	<span style="float: left; width: 49%; margin-bottom: 5px;">
	  <input type="submit" value="Login" tabindex="5" accesskey="l" style="float: left; width: 175px;" class="button" />
	</span>
	<span style="float: left; width: 49%; margin-bottom: 5px;">
	  <input type="button" value="Forgot password?" style="float: right; width: 175px;" onclick="location.href='http://www.yourdomain.com/yabb2/YaBB.pl?action=reminder'" class="button" />
	</span>
	<br /><br />
    </div>
	  <input type="hidden" name="formsession" value="5A7C677E3C4C626169206D6163497B6B7D7A0E0" /></form>
    </td>
  </tr>
</table>
<!-- End of User Login --></div>

 

« Last Edit: Apr 17th, 2008 at 5:25am by ChiMoHe »  
Back to top
IP Logged
 
Divinity
Full Member
***
Offline



Posts: 168
Re: HTML or PHP Bridge ...
Reply #2 - Mar 5th, 2008 at 5:09am
Post Tools
OH OH OH OH

"Can you hear the excitement in my typeing?" lol

I think this is waht I'm looking for maybe?????

I just started searching for how to do this this morning, hopefully I don't have to recreate the wheel....

I added an php arcade and would like to integrate the two databases so they use the same members....

Is that what this does?

One other question....
I have never messed with php, my index.php page only has One line in it says "<?php require("Arcade.php"); ?>
(It's a php Arcade and arcade.php is a file but it doesn't have <body> anywhere in it.

I've tried opening index.php in, alleycode, flashMX, and crimson editor. Same line using all of them.

Any guesses what I might need to do?
  

Back to top
 
IP Logged
 
James Bone
Support Team
****
Offline



Posts: 2,256
Location: Costa Blanca, Spain
Re: HTML or PHP Bridge ...
Reply #1 - Jan 8th, 2008 at 9:32pm
Post Tools
Looks good, will tidy the php code a bit but otherwise works!
  

&&Do you need some YaBB friendly webhosting? Contact me by clicking here and i will hook you up!
Back to top
WWW  
IP Logged
 
Captain John
Ex Member


HTML or PHP Bridge ...
Jan 8th, 2008 at 9:17pm
Post Tools
MANY users have requested this ... (I am NOT a programmer) .. But here is a couple tries a few users have started, if someone will pick it up and run with it.

HTML PHP Welcome
You just need to use the yabb cookies and vars files.

create yabbuserfile.php

Code
Select All
<?php
$username = $_REQUEST['Y2User-77511'];
$file = "/yabb/members/".$username.".vars";
$lines = file($file);
foreach ($lines as $line_num => $line)
{
htmlspecialchars($line) . "<br />\n";
$var = explode(",", $line);
$var[0] = eregi_replace("'", "", $var[0]);
$userinfo[$var[0]] = eregi_replace('"', '', $var[1]);
}
?> 




At the top of your index.php place:

Code
Select All
<?
include 'yabbuserfile.php';
$realname = $userinfo['realname'];
?> 




Then after <body> in your index.php

Code
Select All
<?
if ($realname) {
echo <<<EOF
<strong>$realname</strong> | <a href="/yabb/YaBB.pl?action=viewprofile;username=$username" rel="nofollow">Profile</a> | <a href="/yabb/YaBB.pl?action=get_cal;calshow=1">Event Calendar | <a href="/yabb/YaBB.pl?action=logout">Sign out</a><p>
EOF;
 } else {
echo <<<EOF
<strong>Welcome, Guest. Please <a href="/yabb/YaBB.pl?action=login">Login</a> or <a href="/yabb/YaBB.pl?action=register">Register</a>.</strong>
EOF;
 }
?> 




HTML for a YaBB Login

Code
Select All
   <!-- Start of User Login -->
    <div id="userlogin">
  <div id="userlogin_header">
    <h2><span>User Login</span></h2>
  </div>
  <form action="http://www.yourdomain.com/cgi-bin/yabb2/YaBB.pl?action=login2" method="post">
    <div id="field_username"> <strong><span>Log in:</span></strong>
	<input type="text" name="username" />
    </div>
    <div id="field_password"> <strong><span>Password:</span></strong>
	<input type="password" name="passwrd" />
    </div>

<input type="hidden" name="cookielength" value="1" />

    <div id="button_enter">
	<input type="image" src="images/userlogin_enter.gif" alt="Enter" class="button" />
    </div>

	<input type="hidden" name="formsession" value="73899A95898F933E7090907E8287375C8486887F255037" /></form>
  <div id="userlogin_links"> <a href="http://www.yourdomain.com/cgi-bin/yabb2/YaBB.pl?action=register" id="register"><strong><span>Register >>></span></strong></a> <br />
    <a href="http://www.yourdomain.com/cgi-bin/yabb2/YaBB.pl?action=register" id="notregister"><strong><span>Not Registered Yet?</span></strong></a> </div>
    </div>
    <!-- End of User Login --> 



    OR see this thread here: http://www.boardmod.org/yabb/YaBB.pl?board=programming;action=display;num=118365...


These Need work and finalizing !
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Topic Tools
 
  « Board Index ‹ Board  ^Top