<?php

include("../includes/site_config.php");
include('../session_handler.inc');
include('../error.php');
include('../functions.php');
include('../message.php');
/*if ($Sess_UserType != "A") {
    exit;
}*/
 $Flirt_ID = form_get('Flirt_ID');
 $text = form_get('text');
 //$_REQUEST['act'];

if($_REQUEST['act'] == 'save') {
    restrict_demo();
	$sql_query = "INSERT INTO flirt SET Text = '$text'";
    mysql_query($sql_query, $link);
}

elseif($_REQUEST['act'] == 'edit')
{
    restrict_demo();
	
	
	$sql_query = "UPDATE flirt SET Text = '$text' WHERE Flirt_ID = $Flirt_ID";
    
	mysql_query($sql_query);
 }
elseif($_REQUEST['act'] == 'remove')
{
    restrict_demo();
	$Flirt_ID = form_get('Flirt_ID');
    $sql_query = "DELETE FROM flirt WHERE Flirt_ID = $Flirt_ID";
    mysql_query($sql_query);
}

if($_GET['act'])
	echo "<script>location.location=\"admin_flirts.php\"</script>";
    //header("Location: $CONST_LINK_ROOT/admin/admin_flirts.php");

# retrieve the template
$area = 'member';

$sql_result = mysql_query("SELECT * FROM flirt", $link);

?><head>
<script language="JavaScript" type="text/JavaScript">

function MM_openBrWindow(theURL,winName,features) { //v2.0

  window.open(theURL,winName,features);
  return false;
}
</script>
</head>
<?php include("include/header.php"); ?>

<div class="mainwidth">
<div class="admin-page-header"><div class="admin-page-heading">&nbsp;&nbsp;Flirts Admin</div></div>
<div class="clear"></div>
<div class="admin-page">
<table width="650" align="<?php print("$CONST_TABLE_ALIGN"); ?>" border="0" cellspacing="<?php print("$CONST_TABLE_CELLSPACING"); ?>" cellpadding="<?php print("$CONST_TABLE_CELLPADDING"); ?>">

	<tr><td height="10px"></td></tr>
    <tr>
      <td align="left">

	<table width="80%"  border="0" cellspacing="<?php print("$CONST_SUBTABLE_CELLSPACING"); ?>" cellpadding="<?php print("$CONST_SUBTABLE_CELLPADDING"); ?>">
   <!-- <tr>
      <td colspan="2" align="left" class="tdhead">
        <input type="normal" class='normal' onclick="document.location.href = '<?=$CONST_LINK_ROOT?>/admin/admin_flirts_add.php'" value="<?=ADM_FLIRTS_ADD?>">
      </td>
    </tr>-->
    <!--<tr class="tdtoprow" align="left">
      <td>
        <?=ADM_FLIRTS_TEXT?>
      </td>
      <td >
        <?=GENERAL_DELETE?>
      </td>
     </tr>-->
        <?php
          while($flirt = mysql_fetch_object($sql_result)) {
        ?>

    <tr align=left class="normal" >
      <td>
      <?=htmlspecialchars($flirt->Text)?>
      </td>
	   <td>
	<!--<a href="javascript:;" 
onclick="MM_openBrWindow('spamwords_edit.php?Flirt_ID=<?=$flirt->Flirt_ID?>','','width=500,height=400');">
	     [<?=GENERAL_EDIT?>]
	</a>-->
	<a href="<?=$_SERVER['PHP_SELF']?>?Flirt_ID=<?=$flirt->Flirt_ID?>&edit_text=edit_text"><?=GENERAL_EDIT?></a>
      </td>
      <td>
        <a href="<?=$CONST_LINK_ROOT?>/admin/admin_flirts.php?act=remove&Flirt_ID=<?=$flirt->Flirt_ID?>" onClick="if (confirm('<?=ADM_FLIRTS_DELETE_CONFIRM?>')) {return true;} else {return false;}" >
            [<?=GENERAL_DELETE?>]
        </a>
      </td>
    </tr>
    <?php } ?>
	<tr>
      <td colspan="2" align="left" class="tdfoot">&nbsp; </td>
    </tr>
  </table>

	  </td>
    </tr>
  </table>
<table width="<?php print("$CONST_TABLE_WIDTH"); ?>" align="<?php print("$CONST_TABLE_ALIGN"); ?>" border="0" cellspacing="<?php print("$CONST_TABLE_CELLSPACING"); ?>" cellpadding="<?php print("$CONST_TABLE_CELLPADDING"); ?>">
        <tr>
      <td align="right">
      <?php 	  //require_once("$CONST_INCLUDE_ROOT/user_status.inc.php");	  require_once("../user_status.inc.php");	  ?>
      </td>
    </tr>
    <tr>

    <td class="admin-head">
	<? if(!isset($_REQUEST['edit_text'])){?>
      <?= ADM_FLIRTS_ADD_SECTION_NAME ?>
	  <? } else { ?>
	  <?= ADM_FLIRTS_EDIT_SECTION_NAME ?>
   <? }?> 
	</td>
    </tr>
    <tr>
      <td><table width="100%"  border="0" cellspacing="<?php print("$CONST_SUBTABLE_CELLSPACING"); ?>" cellpadding="<?php print("$CONST_SUBTABLE_CELLPADDING"); ?>">
        <?php
        $sql_result = mysql_query("SELECT * FROM news WHERE news_id='$newsid'", $link);

        $news = mysql_fetch_object($sql_result);
        ?>
		<? if(!isset($_REQUEST['edit_text'])){?>
        <form method="post" action="<?php echo $CONST_LINK_ROOT?>/admin/admin_flirts.php<?php print("?PHPSESSID=".session_id()); ?>" enctype="multipart/form-data" style="padding:0px; margin:0px">
          <input type="hidden" name="act" value="save">
          <tr>
            <td align="center">

	   <table width="100%"  border="0" cellspacing="<?php print("$CONST_SUBTABLE_CELLSPACING"); ?>" cellpadding="<?php print("$CONST_SUBTABLE_CELLPADDING"); ?>">

                <tr>
                  <td colspan="2" height="10px"></td>
                </tr>
                <tr class="normal">
                  <td width="50px">
                    <?=ADM_FLIRTS_TEXT?>
                  </td>
                  <td> <input name="text" type="text" size=60 maxlength=60 class="input" value="<?=htmlspecialchars($flirt['text'])?>"></td>
                </tr><tr>
                  <td colspan="2" height="10px"></td>
                </tr>
                <tr>
                  <td colspan="2" align="center" class="tdfoot"> <input name="submit" type="submit" class="normal" value="<?=GENERAL_SAVE?>">
                 <!--   <input name="normal" type="normal" class="normal" onclick="window.location = '<?=$CONST_LINK_ROOT?>/admin/admin_flirts.php'" value="<?=GENERAL_CANCEL?>">-->
                  </td>
                </tr>
              </table></td>
          </tr>
        </form><? } else {
		
		$sql_result1 = mysql_query("SELECT * FROM flirt where Flirt_ID = $Flirt_ID", $link);
		$flirt_edit = mysql_fetch_object($sql_result1);
		
		?>
		
		 <form method="post" action="<?php echo $CONST_LINK_ROOT?>/admin/admin_flirts.php?Flirt_ID=<?=$flirt_edit->Flirt_ID?>" enctype="multipart/form-data" style="padding:0px; margin:0px">
          <input type="hidden" name="act" value="edit">
          <tr>
            <td align="center">

	   <table width="100%"  border="0" cellspacing="<?php print("$CONST_SUBTABLE_CELLSPACING"); ?>" cellpadding="<?php print("$CONST_SUBTABLE_CELLPADDING"); ?>">

                <tr>
                  <td colspan="2" height="10px"></td>
                </tr>
                <tr class="normal">
                  <td width="50px">
                    <?=EDIT_FLIRTS_TEXT?>
                  </td>
          <td> <input name="text" type="text" size=60 maxlength=60 class="input" value="<?=htmlspecialchars($flirt_edit->Text)?>"></td>
                </tr><tr>
                  <td colspan="2" height="10px"></td>
                </tr>
                <tr>
                  <td colspan="2" align="center" class="normal"> <input name="submit" type="submit" class="normal" value="<?=GENERAL_UPDATE?>">
                  <input name="normal" type="submit" class="normal" onclick="window.location = '<?=$CONST_LINK_ROOT?>/admin/admin_flirts.php'" value="<?=GENERAL_CANCEL?>">
                  </td>
                </tr>
              </table></td>
          </tr>
        </form>
		<? }?>
		
      </table></td>
    </tr>
</table></div><div class="admin-page-bottom"></div></div>

<?php mysql_close( $link ); ?>
<?php include("include/footer.php"); ?>