Location: PHPKode > projects > Slashster > slashster/html/main.php
<?

# Slashster: Open Source Friend of a Friend Software
# Copyright 2004 Mark El-Wakil
# Contact: hide@address.com
# http://seventhcycle.net
#
# This file is part of Slashster.
#
# Slashster is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Slashster is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Slashster; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    import_request_variables("gPc");

    require_once("PageClass.php");

    $mpage = new PageClass("authonly");  
    $mpage->MembersOnly();
    $mpage->Initialize("authremainder"); 

?>

<BR>
<table width=700 border=0>
<tr><td width=400 valign=top>

<? Stats() ?>
<? Alerts() ?>
<BR>
<? Messages() ?>
<BR>
<? MessageBoard() ?>
<BR>
<? Tip() ?>
<BR>
<? NextStep() ?>

</td><td valign=top>
<? MeetPeople() ?>
<? NewPeople() ?>
<BR>
<? News() ?>
<BR>
<? MyFriends() ?>


</td></tr>
</table>

<?
   $cck = $mpage->PrintSnippit("CookieNum");
   $cck = intval($cck);

   srand(date("mdy") * $mpage->IdNum);
   $cck = rand(1,$cck);

   $sql = "select * from FortuneCookie where Id = \"$cck\" ";
   $cook = $mpage->DoQuery($sql,1);
   $cook = $cook[0];

?>

<table align=center border=0> 
<tr><td width=50>
<img alt="Today's Fortune Cookie, courtesy of fortune-mod" width=42 height=50 
src="images/fortunecookie.jpg">
</td><td>
<P><i><?= $cook[Txt] ?></i>
</td></tr>
</table>

<? $mpage->ClosePage(); 


function Stats()
{ 
   global $mpage;
?> 

<table width=400 border=1 cellspacing=0 cellpadding=5px>
<tr>
<td colspan=2 align=center class="stdtable">
<span class="title1" style="color:white;">
Hey <?= $mpage->user[Fname] ?>!
</span>
</td></tr>
<tr>
<td class="stdfilling" width=100 align=center valign=top><img 
src="userpics/<?= $mpage->PicPr($mpage->user[PicDefault], $mpage->IdNum) ?>-b.jpg" width=80 height=60>

<BR>
<small>[ <a href="<?= $mpage->stdurl ?>photos.php?id=<?= $mpage->IdNum 
?>">View Photos</a> ]</small>
<BR>
<small>[ <a href="<?= $mpage->stdurl ?>editphotos.php">Edit Photos</a> ]</small>

</td><td class="stdfilling">

<table width=150 border=1 cellspacing=0 cellpadding=2px bordercolor=black>

<tr><td class="stdaltfilling">&nbsp;<a href="<?= $mpage->stdurl ?>user.php"><b>View Profile</b></a></td></tr>
<tr><td class="stdaltfilling">&nbsp;<a href="<?= $mpage->stdurl ?>usersetup.php"><B>Edit Profile</b></a></td></tr>
<tr><td class="stdaltfilling">&nbsp;<a href="<?= $mpage->sstdurl ?>editaccount.php"><b>Account Settings</b></a></td></tr>
<tr><td class="stdaltfilling">&nbsp;<a href="<?= $mpage->sstdurl ?>login.php"><b>Log Out</b></a></td></tr>

</table>

<p>
You're hooked into <?= $mpage->NetworkSize ?> 
<?= ($mpage->NetworkSize == 1) ? "person" : "people" ?> 
in your network through <?= sizeof($mpage->Friend[1]) ?> 
<?= (sizeof($mpage->Friend[1]) == 1) ? "friend" : "friends" ?>.
</p>

</td>

</table>


<? }

function Alerts()
{       
   global $mpage;

   if (!$mpage->user[Verified])
   {
      $msg = "<P>Your email isn't verified.  Do so <a 
              href=\"".$mpage->stdurl."verify.php\">here</a>.";
   }

   $sql = "select count(*) from FriendRequest where End=$mpage->IdNum";
   $cnt = $mpage->DoQuery($sql);
   $cnt = $cnt[0][0];

   if ($cnt)
   {
      $msg .= "<P>You have $cnt new friend request(s).<BR>You can confirm/deny friend 
                  requests <a href=\"".$mpage->stdurl."confirmfriend.php\">here</a>.";
   }

   $sql = "select count(*) from Testimonials where End=$mpage->IdNum AND Approved=0";
   $cnt = $mpage->DoQuery($sql);
   $cnt = $cnt[0][0];

   if ($cnt)
   {
      $msg .= "<P>You have $cnt new testimonial(s).<BR>You can approve / reject
                  these testimonials <a href=\"".$mpage->stdurl."confirmtestimonial.php\">here</a>.";
   }

   if (!sizeof($mpage->Friend[1]))
   {
      $msg .= "<P>You have no friends on this site as of yet.  This means that you
                  won't be able to read posts, or interact with any people on the site.
                  <BR>(And what fun is <?= $mpage->sys[sitename] ?> without that?)
                  <BR><a href=\"".$mpage->stdurl."invite.php\">Invite Some Friends ASAP!</a>";
   }

   if (!$msg) return;


?>
<BR>
<table width=400 border=1 bordercolor=red cellspacing=0>
<tr><td bgcolor="ffaaaa" align=center><B>Alerts</b></td></tr>
<tr><td align=center style="color:red; font: bold;">

<?= $msg ?>

</td></tr>
</table>

<?
}

function Messages()
{
   global $mpage;

   $f = $mpage->user[DefMailInbox];

   $sql = "select SQL_CALC_FOUND_ROWS PrivateMessage.*,
           UserTable1.Fname as LoginA, UserTable2.Fname as LoginB,
           UNIX_TIMESTAMP(DateSent) as UT
           from PrivateMessage 
           left join UserTable as UserTable1 on PrivateMessage.Start = UserTable1.Id
           left join UserTable as UserTable2 on PrivateMessage.End   = UserTable2.Id
           where Owner=$mpage->IdNum AND Folder=\"$f\" order by PrivateMessage.Id desc limit 4";
   $r = $mpage->DoQuery($sql,1);

   $sql = "select FOUND_ROWS()";
   $rg = $mpage->DoQuery($sql);
   $rg = $rg[0][0];

   $sql = "select count(*) from PrivateMessage where Owner=$mpage->IdNum AND Folder=\"$f\"
           AND New = 1";
   $rt = $mpage->DoQuery($sql);
   $rt = $rt[0][0];


?>
    
<table width=400 border=1 cellspacing=0>
<tr><td class="stdtable" align=center colspan=4>
<B><a href="<?= $mpage->sstdurl ?>messages.php" class="stdtxt">Private Messages</a></b>
<BR> <?= $rg ?> messages / <?= $rt ?> new
           
</td></tr>


<? foreach ($r as $s) { ?>

<tr>
    <td class="stdfilling" width=100> &nbsp;<a 
href="user.php?id=<?= $s[Start] ?>"><?= $s[LoginA] ?></a> </td>
    <td class="stdfilling" width=15 align=center>
<? if ($s[Encrypted]) { ?>

<img src="images/padlock.gif" width=13 height=15 alt="Encrypted Message">

<? } else { ?>
&nbsp;
<? } ?>
    </td>
    <td class="stdfilling"> <a 

<? if ($s["New"]) { ?>
 class="newmsg"
<? } ?>

href="<?= $mpage->sstdurl ?>messages.php?r=<?= $s[Id] 
?>"><?= $s[Subject] ?></a> </td>
    <td class="stdfilling" width=120> <?= date("m/d/Y 
h:i:a",$s[UT]) ?> </td>
</tr>

<? } ?>

</table>
 

<?
}

function MessageBoard()
{
   global $mpage;

   $gtt = (sizeof($mpage->Friend[1])) ? $mpage->Friend[1] : array(0);

   $sql = "select CommentHead.*, UNIX_TIMESTAMP(Fdt) as Fdta, UNIX_TIMESTAMP(Ndt) as Ndta,
           UserTable.Fname, UserTable.Lname from CommentHead
           left join UserTable on UserTable.Id = FSubm
           WHERE FSubm IN (".join(",", $gtt).")
           order by CommentHead.Newest desc limit 4";

   $tps = $mpage->DoQuery($sql,1);

?>
  
<table width=400 border=1 cellspacing=0>
<tr><td colspan=3 align=center class="stdtable"><b><a class="stdtxt"
href="<?= $mpage->stdurl ?>bbs.php">MessageBoard</a></b></td></tr>

<? if (!sizeof($tps)) { ?>

<tr>
   <td class="stdfilling" colspan=3>
<BR>You currently have no friends posting here.
You can either<BR><a href="<?= $mpage->stdurl ?>bbs.php">Check The Messageboard</a>
for some friendly people posting, or get your friends to participate some more :)
<BR><BR>
   </td>
</tr>   

<? } ?>


<? foreach ($tps as $s) { ?>

<tr>
   <td class="stdfilling">
   &nbsp;<a href="<?= $mpage->stdurl ?>user.php?id=<?= $s[FSubm] ?>"><?= 
   $s[Fname] ?> <?= substr($s[Lname], 0,1) ?>.</a>
   </td>
   <td class="stdfilling">
   <a href="<?= $mpage->stdurl ?>bbs.php?postid=<?= $s[Id] ?>"><?= $s[Name] ?></a>
   </td>
   <td class="stdfilling" align=right>
   <?= date("m/d/Y", $s[Fdta]) ?>&nbsp;<BR>
   <?= date("h:i:a", $s[Fdta]) ?>&nbsp;
   </td>
</tr>

<? } ?>


<? if (sizeof($tps)) { ?>

<tr>
   <td colspan=3 align=right class="stdtable">
<B><a class="stdtxt" href="<?= $mpage->stdurl ?>bbs.php">More Posts</a></b>&nbsp;&nbsp;           
   </td>
</tr>
   
<? } ?>



</table>  


<?
}

function MeetPeople()
{
   global $mpage;

   $sql = "select userid, dt, UserTable.* from uotd left join UserTable on userid = UserTable.Id
           where dt = NOW()";
   $r = $mpage->DoQuery($sql,1);
   $r = $r[0];

   if ($mpage->UserDistance($r[Id]) == -1) $r = array();


?>
   
<table width=300 border=1 cellspacing=0>
<tr><td class="stdtable" align=center><B>Meet 
People

<? if (sizeof($r)) { ?>
</td><td align=center class="stdtable">
<B>User Of The Day</b>
<? } ?>
</b>


</td></tr>
<tr><td align=center width=<?= (sizeof($r)) ? 175 : 300 ?> 
class="stdfilling">

<a href="<?= $mpage->stdurl ?>people.php">Find People</a>
<BR><a href="<?= $mpage->stdurl ?>invite.php">Invite Friends</a>
<BR><a href="<?= $mpage->stdurl ?>usersearch.php">User Search</a>

</td>

<? if (sizeof($r)) { ?>

<td align=center class="stdaltfilling" width=125>
<BR>
<a href="<?= $mpage->stdurl ?>user.php?id=<?= $r[Id] ?>">
<img border=0 src="/userpics/<?= $mpage->PicPr($r[PicDefault], $r[Id]) ?>-b.jpg" width=80 height=60></a>
<BR>

<small> 
<a href="<?= $mpage->stdurl ?>user.php?id=<?= $r[Id] ?>"><?= $r[Fname] ?> <?= 
substr($r[Lname],0,1) ?></a>
<BR><B>
<? 
  $dst = $mpage->UserDistance($r[Id]);

  if ($dst == 0)
  {
      echo "(It's You!)";
  }
  elseif ($dst == 1)
  {
      echo "(Your Friend)";
  }
?>
</b></small>
<BR>
    

</td>
<? } ?>

</tr>
</table>

<?
}

function NewPeople()
{
   global $mpage;

   $sze2 = min( sizeof($mpage->Friend[2]) , 4);
   $arb2 = array_slice($mpage->Friend[2], sizeof($mpage->Friend[2])-$sze2, $sze2);

   $sze3 = min( sizeof($mpage->Friend[3]) , 4);
   $arb3 = array_slice($mpage->Friend[3], sizeof($mpage->Friend[3])-$sze3, $sze3);

   $sze4 = min( sizeof($mpage->Friend[4]) , 4);
   $arb4 = array_slice($mpage->Friend[4], sizeof($mpage->Friend[4])-$sze4, $sze4);

   $arb = array_merge($arb2, $arb3, $arb4);

   if (!sizeof($arb)) return;

   rsort($arb, SORT_NUMERIC);
   $arb = array_slice($arb, 0, 4);

   $sql = "select * from UserTable where Id IN (".join(",",$arb).") order by Id desc";
   $tbl = $mpage->DoQuery($sql,1);

?>
   
<BR>
<table width=300 border=1 bordercolor=black cellspacing=0>
<tr><td align=center colspan=4 class="stdtable"><B>New People</b></td></tr>
<tr>

<? for ($x = 0; $x < sizeof($arb); $x++) { ?>

<td width=75 align=center class="stdaltfilling">
<BR><a href="<?= $mpage->stdurl ?>user.php?id=<?= $tbl[$x][Id] 
?>"><img border=0 width=48 height=36 src="userpics/<?= $mpage->PicPr($tbl[$x][PicDefault], $tbl[$x][Id]) ?>-c.jpg"></a>
<BR><small><a href="<?= $mpage->stdurl ?>user.php?id=<?=
$tbl[$x][Id] ?>"><?= $tbl[$x][Fname] ?> <?= substr($tbl[$x][Lname],0,1) ?></a></small>
</td>

<? } ?>

<? for ($x; $x < 4; $x++) { ?>
<td width=75 height=36 class="stdaltfilling">&nbsp;</td>
<? } ?>

</tr></table>


<?
}

function MyFriends()
{
   global $mpage;

   if (!sizeof($mpage->Friend[1])) return;


   $fr = (sizeof($mpage->Friend[1])) ? $mpage->Friend[1] : array(0);

   

   $sql = "select * from UserTable where Id IN (".join(",", $fr).") order by Id asc limit 16";
   $r = $mpage->DoQuery($sql,1);
?>

<table width=300 border=1 cellspacing=0>
<tr><td align=center colspan=4 class="stdtable">
<B>My Friends (<?= sizeof($mpage->Friend[1]) ?>)</b>
[<a class="stdtxt" href="<?= $mpage->stdurl ?>editfriends.php">Edit Friends</a>]

</span>

</td></tr>

<? 
   for ($x = 0; $x < sizeof($r); $x++)  
   {
       if ($x % 4 == 0) echo "\n<tr>\n";
       ?>
          <td width=75 align=center class="stdaltfilling"><BR>
              <a href="<?= $mpage->stdurl ?>user.php?id=<?= $r[$x][Id] ?>">
              <img border=0 width=48 height=36 src="userpics/<?= $mpage->PicPr($r[$x][PicDefault], $r[$x][Id]) ?>-c.jpg"></a>
              <BR>
                  <small><a href="<?= $mpage->stdurl ?>user.php?id=<?= $r[$x][Id] ?>"><?= $r[$x][Fname] ?> 
                  <?= substr($r[$x][Lname], 0, 1) ?></a></small>
          </td>
       <?
       if ($x % 4 == 3) echo "\n</tr>\n";
   }
   
   for ($x; $x % 4 != 0; $x++)
   {
      echo "<td width=75 class=\"stdaltfilling\">&nbsp;</td>";
      if ($x % 4 == 3) echo "\n</tr>\n";
   }
?>  


</table>  


<?
}


function Tip()
{   
   global $mpage;

   $sql = "select * from Tips order by RAND() limit 1";
   $r = $mpage->DoQuery($sql,1);
   $r = $r[0][Txt];

   foreach ($mpage->sys as $k => $v)
   {
      $r = str_replace("#sys_$k#", $v, $r);
   }

?>  

<table width=400 border=1 bordercolor=black cellspacing=0>
<tr><td align=center class="stdtable"><B><?= $mpage->sys[sitename] ?> Tips</b></td></tr>
<tr><td class="stdfilling" align=center>

<?= $r ?>

</td></tr>
</table>

<?
}  

function NextStep()   
{ 
   global $mpage;
?>
  
<table width=400 border=1 bordercolor=black cellspacing=0>
<tr><td align=center class="stdtable"><B>Next Step</td></tr>
<tr><td align=center class="stdfilling">

<? if (!$mpage->user[Verified]) { ?>

You should verify your email to unlock most of the features on this site.
To do so, click <a href="<?= $mpage->stdurl ?>verify.php">here</a>

<? } elseif (!$mpage->user[PicDefault]) { ?>

You should <a href="<?= $mpage->stdurl ?>editphotos.php">upload a picture</a> to your profile.
More people will pay attention if you have a picture of you, or an interesting
icon.

<? } elseif (!sizeof($mpage->Friend[1])) { ?>

You have nobody on your friends list, so it's time to get some friends.  click
<a href="<?= $mpage->stdurl ?>invite.php">Invite Friends</a> in order to get some.

<? } elseif (!$mpage->user[Posts]) { ?>

Have you checked out the <a href="<?= $mpage->stdurl ?>bbs.php">Messageboard</a>?  You can make posts, and
if you create threads, you can moderate them.  Check it out.

<? } elseif (!$mpage->Friend[2]) { ?>

   None of your friends have buddies outside those of whom you consider friends

  <?
        $txtarr = array("maybe", "you", "can", "nag", "them", "to", 
                        "invite", "some", "more", "friends", "here");

        reset($mpage->Friend[1]);

        foreach ($txtarr as $f)
        {  
            $g = current($mpage->Friend[1]);

            if ($g) { ?>
              <a href="<?= $mpage->stdurl ?>composemessage.php?id=<?= $g ?>"><?= $f ?></a> 
            <? } else echo $f . " ";

            next($mpage->Friend[1]);
        }
 
        reset($mpage->Friend[1]);
  ?>


<? } else { ?>

Thank you for coming to <?= $mpage->sys[sitename] ?>.  Please continue to drop by and be sure 
<a href="<?= $mpage->stdurl ?>invite.php">to bring others</a>.

<? } ?>

</td></tr>
</table>  

<?
} 


function News()
{ 
   global $mpage;

   $a1 = array();

   $rsr = explode(",", $mpage->user[RSS]);

   foreach ($rsr as $k => $v)
   {
       $tp = explode("|", $v);
 
       if ($v) array_push($a1, $tp[1]);
       $rsr[$k] = $tp;
   }

   $a1 = (sizeof($a1)) ? $a1 : array(0);

   if (!sizeof($rsr)) return;

   ?><table width=300 border=1 cellspacing=0><?

   foreach ($rsr as $r) 
   {
       $tt = $r[0];


       $sql = ($tt) 
            ? "select * from RSS where Id = \"$tt\" "
            : "select * from RSS where Id NOT IN (".join(",",$a1).") order by RAND() limit 1"
            ;

       $tq = $mpage->DoQuery($sql,1);
       $tq = $tq[0];
       array_push($a1, $tq[Id]);
?>
        
<tr><td class="stdtable" align=center>
<a class="stdtxt" href="<?= $tq[SiteURL] ?>"><B><?= $tq[Name] ?></b></a>
</td></tr>  
   
<tr><td class="stdaltfilling">
        
<ul><BR> 
<small>
<?
   $gt1 = explode("<li>", $tq[Txt]);

   for ($x = 1; $x < sizeof($gt1) && $x < $r[1]+1  ; $x++)
        echo "<li>".$gt1[$x];

?> 
</small></ul>
</td></tr>


<? 
   }

   echo "</table>";


   return;



   $wh1 = ($mpage->user[RSS2])
        ? "where Id != ".$mpage->user[RSS2]
        : ""
        ;
  
   $wh2 = ($mpage->user[RSS1])
        ? "where Id != ".$mpage->user[RSS1]
        : ""                       
        ;

   $qu1 = ($mpage->user[RSS1])
        ? "where Id = ".$mpage->user[RSS1]." limit 1"
        : "$wh1 order by RAND() limit 1"
        ;

   $qu2 = ($mpage->user[RSS2])
        ? "where Id = ".$mpage->user[RSS2]." limit 1"
        : "$wh2 order by RAND() limit 1"
        ;

   $sql = "select * from RSS $qu1";
   $nw1 = $mpage->DoQuery($sql,1);
   $nw1 = $nw1[0];

   $sql = "select * from RSS $qu2";
   $nw2 = $mpage->DoQuery($sql,1);
   $nw2 = $nw2[0];

?>
  
<table width=300 border=1 cellspacing=0> 


<tr><td class="stdtable" align=center>
<a class="stdtxt" href="<?= $mpage->stdurl ?><?= $nw1[SiteURL] ?>"><B><?= $nw1[Name] ?></b></a> 
</td></tr> 

<tr><td class="stdaltfilling">

<ul><BR>
<small>
<?
   $gt = $nw1[Txt];
   $gt1 = explode("<li>", $gt);

   if ($gt1[1]) echo "<li>".$gt1[1];
   if ($gt1[2]) echo "<li>".$gt1[2];
   if ($gt1[3]) echo "<li>".$gt1[3];
   echo "</ul>";
?>
</small>
</td></tr>


<tr><td class="stdtable" align=center>
<a class="stdtxt" href="<?= $mpage->stdurl ?><?= $nw2[SiteURL] ?>"><B><?= $nw2[Name] ?></b></a> 
</td></tr> 

<tr><td class="stdaltfilling">

<BR><ul>
<small>
<? 
   $gt = $nw2[Txt];
   $gt1 = explode("<li>", $gt);

   if ($gt1[1]) echo "<li>".$gt1[1];
   if ($gt1[2]) echo "<li>".$gt1[2];
   if ($gt1[3]) echo "<li>".$gt1[3];
   echo "</ul>";
?>
</small>
</td></tr>


</table>


<? }


?>


Return current item: Slashster