<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="/new.css">
<?php
include "ddfuncs/ad2.php";
require('../setClassPath.php');
require_once('db/TransManager.php');
require_once('util/InputHelper.php');

$input = InputHelper::getInstance();
$trans = TransManager::getInstance();

$cookieval      = $input->fullySanitize($_COOKIE['mystic']);
$catpath        = $input->fullySanitize($_GET['cat_path']);
$gender         = $input->fullySanitize($_GET['gender']);

$trans->beginTrans();
$pdo = $trans->getPDO();

if ($gender == '') {
?>
<title>Dating Advice for Men and Women</title>
<script type="text/javascript">
var _gaq=_gaq||[];_gaq.push(['_setAccount','UA-628020-4']);_gaq.push(['_trackPageview']);(function(){var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;ga.src=('https:'==document.location.protocol?'https://ssl':'http://www')+'.google-analytics.com/ga.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);})();
</script>
</head><body>
<div class="box full" style="background-color: #fdc;">
<h1>Dating Advice for Men and Women</h1>
<a href="/">Dating Diversions</a> | 
<a href="/stories.mv">Dating Stories</a> | 
<a href="/dating_jokes.html">Dating Jokes</a> | 
<a href="/singles-US/main.html">Geographical Dating Tips</a> | 
<a href="/gift_ideas.html">Great Gift Ideas</a>
</div>

<div class="boxt fullnp">
  <div class="boxtr rside flr ctr">
    <?= getAd($cookieval, '120x240', 'f', $pdo) ?>
  </div>
  <div class="main pad">
    <ul>
<?php

    $stmt = $pdo->prepare('SELECT cat_path, name, gender FROM advice_cat ORDER BY gender');
    $stmt->execute();
    while ($myrow = $stmt->fetch(PDO::FETCH_NUM))
        printf("<li><a href=\"/advice/%s/%s/advice.html\">%s</a></li>\r\n", $myrow[2], $myrow[0], $myrow[1]);
?>
    <hr>
    <div class="ctr">
      <?= getAd($cookieval, '468x60', 'f', $pdo) ?>
    </div>
  </div>
</div>
View our <a href="/privacy.html">Privacy Policy</a>

</body></html>

<?php
}
else if ($catpath == '')  {
    $genderdesc = 'Singles';
    if ($gender == 'men')
         $genderdesc = 'Men by Women';
     else if ($gender == 'women')
         $genderdesc = 'Women by Men';
     else if ($gender == 'gay')
         $genderdesc = 'Gay Singles';
     else if ($gender == 'christian')
         $genderdesc = 'Christians';
?>
<title>Dating Advice for <?= $genderdesc ?></title>
<script type="text/javascript">
var _gaq=_gaq||[];_gaq.push(['_setAccount','UA-628020-4']);_gaq.push(['_trackPageview']);(function(){var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;ga.src=('https:'==document.location.protocol?'https://ssl':'http://www')+'.google-analytics.com/ga.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);})();
</script>
</head><body>
<div class="box full" style="background-color: #ffddcc;">
<h1>Dating Advice for <?= $genderdesc ?></h1>
<a href="/">Dating Diversions</a> | 
<a href="/advice.html">More Dating Advice</a> | 
<a href="/stories.mv">Dating Stories</a> | 
<a href="/dating_jokes.html">Dating Jokes</a> | 
<a href="/singles-US/main.html">Geographical Dating Tips</a> | 
<a href="/gift_ideas.html">Great Gift Ideas</a>
</div>

<div class="boxt fullnp">
  <div class="boxtr rside flr ctr">
    <?= getAd($cookieval, '120x240', 'f', $pdo) ?>
  </div>
  <div class="main pad">
    <ul>
<?php

    $stmt = $pdo->prepare('SELECT cat_path, name, gender FROM advice_cat WHERE gender = ? ORDER BY gender');
    $stmt->bindParam(1, $gender);
    $stmt->execute();

    while ($myrow = $stmt->fetch(PDO::FETCH_NUM))
        printf("<li><a href=\"/advice/%s/%s/advice.html\">%s</a></li>\r\n", $myrow[2], $myrow[0], $myrow[1]);
?>
      </ul>
    <hr>
    <div class="ctr">
      <?= getAd($cookieval, '468x60', 'f', $pdo) ?>
    </div>
  </div>
</div>
View our <a href="/privacy.html">Privacy Policy</a>

</body></html>

<?php
}
else {
    $stmt = $pdo->prepare('SELECT name, description FROM advice_cat WHERE cat_path = ?');
    $stmt->bindParam(1, $catpath);
    $stmt->execute();
    $catname = '';
    $desc = '';
    if ($myrow = $stmt->fetch(PDO::FETCH_NUM)) {
        $catname = $myrow[0];
        $desc = $myrow[1];
    }
?>
<title>Dating <?= $catname ?></title>
<script type="text/javascript">
var _gaq=_gaq||[];_gaq.push(['_setAccount','UA-628020-4']);_gaq.push(['_trackPageview']);(function(){var ga=document.createElement('script');ga.type='text/javascript';ga.async=true;ga.src=('https:'==document.location.protocol?'https://ssl':'http://www')+'.google-analytics.com/ga.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(ga,s);})();
</script>
</head><body>
<div class="box full" style="background-color: #fdc;">
<h1><?= $catname ?></h1>
<a href="/">Dating Diversions</a> | 
<a href="/advice.html">More Dating Advice</a> | 
<a href="/stories.mv">Dating Stories</a> | 
<a href="/dating_jokes.html">Dating Jokes</a> | 
<a href="/singles-US/main.html">Geographical Dating Tips</a> | 
<a href="/gift_ideas.html">Great Gift Ideas</a>
</div>

<div class="boxt fullnp">
  <div class="boxtr rside flr ctr">
    <?= getAd($cookieval, '120x600', 'f', $pdo) ?>
  </div>
  <div class="main pad">
    <p><?= $desc ?></p>
    <h2>Visitor-Submitted Advice:</h2>
<?php
    $stmt = $pdo->prepare('SELECT title, body, name, location, date_added FROM advice WHERE cat_path = ? AND admin_flag = \'A\' ORDER BY date_added DESC');
    $stmt->bindParam(1, $catpath);
    $stmt->execute();
    $count = 0;
    while ($myrow = $stmt->fetch(PDO::FETCH_NUM)) {
        echo '<p>';
        if ($myrow[0] != '')
            echo '<b>' . $myrow[0] . '</b><br>';
        echo '"' . $myrow[1] . '" -<i>' . $myrow[2] . ', '. $myrow[3] .'</i></p><hr>' . "\r\n";
        $count++;
    }
    if ($count == 0) 
        echo '<p>No advice has been posted in this section yet.  You can be the first to submit advice, using the link below.</p>';

    if ($gender == 'men') {
        echo '<h3>Are You a Woman? <a href="post_advice.html">Post Your Advice to this Section</a></h3>';
        echo '<h3>Are You a Man? <a href="/advice/women/advice.html">Give Some Advice to Women</a></h3>';
    }
    else if ($gender == 'women') {
        echo '<h3>Are You a Man? <a href="post_advice.html">Post Your Advice to this Section</a></h3>';
        echo '<h3>Are You a Woman? <a href="/advice/men/advice.html">Give Some Advice to Men</a></h3>';
    }
?>
    <hr>
    <div class="ctr">
      <?= getAd($cookieval, '468x60', 'f', $pdo) ?>
    </div>
  </div>
</div>
View our <a href="/privacy.html">Privacy Policy</a>

</body></html>
<?php
}
$trans->commit();
$trans->disconnect();
?>
