<?php
/*
 * Copyright (c) 2004-2009 Luiz Otavio O Souza <loos.br@gmail.com>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*
 * $Id: bl.inc.php 102 2009-02-05 18:37:40Z loos-br $
 */

    /* FL = 1, AL = 2, BL = 4, RL = 8, PL = 16 */
    $LISTS_AL = 0x02;
    $LISTS_BL = 0x04;

    require_once('default.array.cmd.inc.php');

function lists($list, $text) {
 global $arrayStatus, $mysql;

    $sql  = "SELECT * FROM contacts WHERE ";
    $sql .= "email = '". mysql_escape_string($_REQUEST['email']) ."' ";
    $sql .= "AND (contact_lists & ". $list .") != 0 ";
    $sql .= "ORDER BY contact_email";
    $rs = mysql_query($sql, $mysql) or die('fail to run query');

    $sqlUser  = "SELECT display_name, status, commands FROM users WHERE ";
    $sqlUser .= "email = '". mysql_escape_string($_REQUEST['email']) ."'";

    $rsUser = mysql_query($sqlUser, $mysql) or die('fail to run queryUser');
    if ($rsUser) {
	$rowUser = mysql_fetch_array($rsUser);
	$status = NULL;
	if ($rowUser)
	    $status = $arrayStatus[$rowUser['status']];
    }
?>
 <div align="center">
  <div align="left" style="width:400px; background-color: #EFEFEF; border-color: gray; border-style: solid; border-width: 1;">
    <p align="center" style="background-color: #E0E0E0;">
	<table border=0 cellpadding=0 cellspacing=0>
	  <tr>
	    <td>
		<img src="imagens/<?php echo $status['img'] ?>"
		  alt="<?php echo $status['msg'] ?>" border=0>
	    </td>
	    <td>
		<a alt="Atualizar"
		  href="<?php echo $_SERVER['PHP_SELF'] ?>?email=<?php echo $_REQUEST['email']."&list=".$list ?>">
		<?php echo $rowUser['display_name'] ?>
		<?php echo ($status['img'] != "online.gif") ?
		  "<font color=\"gray\">(".$status['msg'].")</font>" : "" ?></a>
	    </td>
	  </tr>
	</table>
	<strong>
	<a alt="Atualizar"
	  href="<?php echo $_SERVER['PHP_SELF'] ?>?email=<?php echo $_REQUEST['email']."&list=".$list ?>">
		<?php echo $text; ?></a>
	</strong></p>
   <table border=0 width=398>
<?php
    while ($row = mysql_fetch_array($rs)) {
?>
     <tr>
     <td bgcolor="#EBEBEB" align="left"><?php echo $row['contact_email'] ?></td>
     </tr>
<?php
    }
?>
    </table>
  </div>
 </div>
<?php
}
?>
