<?php include('class.upload.php'); ?>
<?php include ("classified.inc.php") ?>
<?php
// $Id: pnuser.php,v 1.1.1.1 2002/09/15 22:26:15 root Exp $
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2002 by the PostNuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program 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.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file: Jim McDonald
// Purpose of file:  Classifieds user display functions
// ----------------------------------------------------------------------

/**
 * the main user function
 * This function is the default function, and is called whenever the module is
 * initiated without defining arguments.  As such it can be used for a number
 * of things, but most commonly it either just shows the module menu and
 * returns or calls whatever the module designer feels should be the default
 * function (often this is the view() function)
 */
function classifieds_user_main()
{
  $baseurl = pnGetBaseURL();
  Header("Location: $baseurl");
  return true;

  // Create output object - this object will store all of our output so that
  // we can return it easily when required
  $output = new pnHTML();

  // Security check - important to do this as early as possible to avoid
  // potential security holes or just too much wasted processing.  For the
  // main function we want to check that the user has at least overview
  // privilege for some item within this component, or else they won't be
  // able to see anything and so we refuse access altogether.  The lowest
  // level of access for administration depends on the particular module, but
  // it is generally either 'overview' or 'read'
  if (!pnSecAuthAction(0, 'Classifieds::', '::', ACCESS_READ)) {
      $output->Text(_CLASSIFIEDSNOAUTH);
      return $output->GetOutput();
  }

  // Add menu to output - it helps if all of the module pages have a standard
  // menu at their head to aid in navigation
  $output->SetInputMode(_PNH_VERBATIMINPUT);
  $output->Text(classifieds_usermenu());
  $output->SetInputMode(_PNH_PARSEINPUT);

  // Return the output that has been generated by this function
  return $output->GetOutput();
}

/**
 * display item
 * This is a standard function to provide detailed informtion on a single item
 * available from the module.
 */
function classifieds_user_display($args)
{
  // Get parameters from whatever input we need.  All arguments to this
  // function should be obtained from pnVarCleanFromInput(), getting them
  // from other places such as the environment is not allowed, as that makes
  // assumptions that will not hold in future versions of PostNuke.
  list($tid,
       $objectid) = pnVarCleanFromInput('tid',
                                        'objectid');

  // User functions of this type can be called by other modules.  If this
  // happens then the calling module will be able to pass in arguments to
  // this function through the $args parameter.  Hence we extract these
  // arguments *after* we have obtained any form-based input through
  // pnVarCleanFromInput().
  extract($args);

  // At this stage we check to see if we have been passed $objectid, the
  // generic item identifier.  This could have been passed in by a hook or
  // through some other function calling this as part of a larger module, but
  // if it exists it overrides $tid
  //
  // Note that this module couuld just use $objectid everywhere to avoid all
  // of this munging of variables, but then the resultant code is less
  // descriptive, especially where multiple objects are being used.  The
  // decision of which of these ways to go is up to the module developer
  if (!empty($objectid)) {
      $tid = $objectid;
  }

  // Create output object - this object will store all of our output so that
  // we can return it easily when required
  $output = new pnHTML();

  // Add menu to output - it helps if all of the module pages have a standard
  // menu at their head to aid in navigation
  $output->SetInputMode(_PNH_VERBATIMINPUT);
  $output->Text(classifieds_usermenu());
  $output->SetInputMode(_PNH_PARSEINPUT);

  // Load API.  All of the actual work for obtaining information on the items
  // is done within the API, so we need to load that in before we can do
  // anything.  If the API fails to load an appropriate error message is
  // posted and the function returns
  if (!pnModAPILoad('Classifieds', 'user')) {
      $output->Text(_LOADFAILED);
      return $output->GetOutput();
  }

  // The API function is called.  The arguments to the function are passed in
  // as their own arguments array
  $item = pnModAPIFunc('Classifieds',
                        'user',
                        'get',
                        array('tid' => $tid));

  // The return value of the function is checked here, and if the function
  // suceeded then an appropriate message is posted.  Note that if the
  // function did not succeed then the API function should have already
  // posted a failure message so no action is required
  if ($item == false) {
      $output->Text(_CLASSIFIEDSITEMFAILED);
      return $output->GetOutput();
  }

  // Display details of the item.  Note the use of pnVarCensor() to remove
  // any words from the name that the administrator has deemed unsuitable for
  // the site.  Also note that a module variable is used here to determine
  // whether not not parts of the item information should be displayed in
  // bold type or not
  $output->Text(_CLASSIFIEDSNAME . ': ');
  if (pnModGetVar('Classifieds', 'bold')) {
      $output->BoldText(pnVarCensor($item['name']));
  } else {
      $output->Text(pnVarCensor($item['name']));
  }
  $output->Linebreak(2);
  $output->Text(_CLASSIFIEDSNUMBER . ': ');
  $output->Text($item['number']);
  $output->Linebreak(2);

  // Let any hooks know that we are displaying an item.  As this is a display
  // hook we're passing a URL as the extra info, which is the URL that any
  // hooks will show after they have finished their own work.  It is normal
  // for that URL to bring the user back to this function
  $output->SetInputMode(_PNH_VERBATIMINPUT);
  $output->Text(pnModCallHooks('item',
                               'display',
                               $tid,
                               pnModURL('Classifieds',
                                        'user',
                                        'display',
                                        array('tid' => $tid))));
  $output->SetInputMode(_PNH_PARSEINPUT);

  // Return the output that has been generated by this function
  return $output->GetOutput();
}

/**
 * generate menu fragment
 */
function classifieds_usermenu()
{
  // Create output object - this object will store all of our output so that
  // we can return it easily when required
  $output = new pnHTML();

  // Display status message if any.  Note that in future this functionality
  // will probably be in the theme rather than in this menu, but this is the
  // best place to keep it for now

  // Start options menu
  $output->Text(pnGetStatusMsg());
  $output->Linebreak(2);

  // Menu options.  These options are all added in a single row, to add
  // multiple rows of options the code below would just be repeated
  $output->TableStart(_CLASSIFIEDS);
  $output->SetOutputMode(_PNH_RETURNOUTPUT);
  $columns = array();
  $columns[] = $output->URL(pnModURL('Classifieds',
                                     'user',
                                     'view'),
                            _CLASSIFIEDSVIEW);
  $output->SetOutputMode(_PNH_KEEPOUTPUT);
  $output->SetInputMode(_PNH_VERBATIMINPUT);
  $output->TableAddRow($columns);
  $output->SetInputMode(_PNH_PARSEINPUT);
  $output->TableEnd();

  // Return the output that has been generated by this function
  return $output->GetOutput();
}

////////////////////////////////////////////////////////////////////////////

/**
 * This method checks to make sure an array doesn't have
 * an empty element.
 */
function array_hasempty($a)
{
  if ( is_array($a) )
  {
    foreach ( $a as $key => $value )
    {
      if ( $value == '' )
      {
        return TRUE;
      }
    }
    return FALSE;
  }
  else
  {
    return $a == '';
  }
}

/**
 * This function checks if the given string contains
 * alphabetical characters or numbers.
 * It also checks for the allowed additional characters.
 *
 * @param string - the string to check
 * @param string - list of individual characters to allow
 *                 besides a-zA-Z
 *
 * @return boolean FALSE - if any other extraneous
 *                         characters are found
 *                 TRUE upon succes.
 */
function is_alphanum($str, $from = "")
{
  // If the given string is only white spaces, return false
  if ( ereg("^[[:space:]]*$", $str) )
  {
    return FALSE;
  }

  $to = "";
  $len = strlen($from);
  for ( $i = 0; $i < $len; ++$i )
  {
    $to .= "a";
  }
  $str = strtr($str, $from, $to);
  $substr = eregi_replace("[a-z0-9]+", "", $str);
  if ( !array_hasempty($substr) )
  {
    return FALSE;
  }
  return TRUE;
}

/**
 * This function validates a single email address.
 * It supports email addresses in the format of
 * jane@blah.com or "Jane Doe <jane@blah.com>"
 *
 * @param string - the value to validate
 * @param bool - allows long email name format
 * @return TRUE = succes  FALSE = failed
 */
function is_email ($email, $allow_name = true)
{
  // no quotes allowed
  if ( strstr($email, '"') || strstr($email, "'") ) {
    return false;
  }

  //lets see if the email is in the form of
  //"Foo Bar <foo@bar.com>"
  $name = explode(" ", $email);
  if ( count($name) > 1 )
  {
    if (!$allow_name)
    {
        return false;
    }

    //it looks like they gave us an email
    //with a leading name such as Foo Bar <foo@bar.com>
    //find the email address inside <>
    $found_email = FALSE;
    foreach( $name as $key => $val )
    {
      if ( strstr($val, "@") )
      {
        $found_email = TRUE;
        if ( (substr($val, 0, 1) == "<") && (substr($val, strlen($val)-1, 1) == ">") )
        {
          $email = substr($val, 1, strlen($val)-2 );
        }
        else
        {
          //invalid email address
          //it must have a <
          return false;
        }
      }
    }
    if ( !$found_email )
    {
      //we couldn't find an email address
      //in the text.
      return false;
    }
  }

  if ( !is_alphanum($email, "@.-_/:") )
  {
    return false;
  }

  // "@.", ".@.", "_@.", .com, .net, .edu, .blah
  if ( !ereg("^( )*([a-zA-Z0-9_/:]|\\-|\\.)+@(([a-zA-Z0-9_]|\\-)+\\.)+[a-zA-Z]{2,4}$", $email, $arr) )
  {
    return false;
  }

  $len = strlen($email);
  if ( $len > 255 )
  {
    return false;
  }

  // email cannot end with a dot
  if ( ereg("\.$", $email) )
  {
    return false;
  }

  // no space
  if ( ereg(" ", $email, $arr) )
  {
      return false;
  }

  return true;
}

/**
 * This function checks if the given string contains
 * numerical digit characters.
 * It also checks for the allowed additional characters.
 *
 * @param string - the string to check
 * @param string - list of individual characters to allow
 *                 besides a-zA-Z
 *
 * @return boolean FALSE - if any other extraneous
 *                         characters are found
 *                 TRUE upon succes.
 */
function is_num($str, $from = "") {

    // If the given string is only white spaces, return false
    if ( ereg("^[[:space:]]*$", $str) ) {
        return FALSE;
    }

    //now do another simple check
    if ($from == '' && !is_numeric($str)) {
        return FALSE;
    }

    $to = "";
    $len = strlen($from);
    for ( $i = 0; $i < $len; ++$i ) {
        $to .= "0";
    }
    $str = strtr($str, $from, $to);
    $substr = eregi_replace("[-0-9]+", "", $str);
    if ( !array_hasempty($substr) ) {
        return FALSE;
    }
    return TRUE;
}

/**
 * This method makes sure a value lies within
 * a given range of values.
 * The error message can be customized by passing in
 * a customer error code
 *
 * @param mixed - the value u want to check
 * @param int - the size
 * @param mixed - the lower bound value
 * @param mixed - the upper bound value
 * @param string - the error code if any
 * @return TRUE = succes  FALSE = failed
 *
 */
function is_within_range($value, $size, $start, $end, $error=FALSE)
{
  if ( ($value == '') || !is_num($value) )
  {
      if ( $error )
        return FALSE;
      else
        return FALSE;
  }

  if ( $size )
  {
    if ( strlen($value) != $size )
    {
      if ( $error )
        return FALSE;
      else
        return FALSE;
    }
  }

  if ( (($start != NULL) && ($value < $start)) || (($end != NULL)   && ($value > $end)) )
  {
    if ( $error )
      return FALSE;
    else
      return FALSE;
  }
  return TRUE;
}

/**
 * This validates a string as a valid day of a month
 * It has to be greater then 0 and less then 31
 *
 * @param string - the value to validate
 * @return TRUE = succes  FALSE = failed
 */
function is_dateday($day)
{
  return is_within_range($day, 0, 1, 31, "INVALID_DAY");
}

/**
 * This validates a string as a valid month of the year
 * between 1 and 12 inclusive
 * is_datemonth - checks whether its a proper month
 *
 * @param string - the value to validate
 * @return TRUE = succes  FALSE = failed
 */
function is_datemonth($month)
{
  return is_within_range($month, 0, 1, 12, "INVALID_MONTH");
}

/**
 * See if the year is within
 * 1800 and 3000
 *
 * @param string - the value to validate
 * @return TRUE = succes  FALSE = failed
 */
function is_dateyear($year)
{
  return is_within_range($year, 0, 1800, 3000, "INVALID_YEAR");
}

/**
 * This validates a string as a valid date format
 * You can provide a seperator string that seperates
 * the fields
 *
 * NOTE: date is in YYYY-MO-DY format
 *
 * @param string - the value to validate
 * @return TRUE = succes  FALSE = failed
 */
function is_date($value, $split_by="/")
{
  $x = explode($split_by, $value);
  $month = @$x[0];
  $day = @$x[1];
  $year = @$x[2];

  $retval = is_datemonth($month);
  if ( $retval != TRUE )
  {
    return $retval;
  }

  $retval = is_dateday($day);
  if ( $retval != TRUE )
  {
    return $retval;
  }

  $retval = is_dateyear($year);
  if ( $retval != TRUE )
  {
    return $retval;
  }

  // Check the overall validity of the date
  if ( !checkdate($month, $day, $year) )
  {
    return FALSE;
  }

  return TRUE;
}

function getRequiredClass($is_correct)
{
  if ( isset( $is_correct ) && !$is_correct )
  {
    return "required-red";
  }
  else
  {
    return "required";
  }
}

function cleanInputVars()
{
  $search = array('|</?\s*SCRIPT.*?>|si',
                  '|</?\s*FRAME.*?>|si',
                  '|</?\s*OBJECT.*?>|si',
                  '|</?\s*META.*?>|si',
                  '|</?\s*APPLET.*?>|si',
                  '|</?\s*LINK.*?>|si',
                  '|</?\s*IFRAME.*?>|si',
                  '|STYLE\s*=\s*"[^"]*"|si');

  $replace = array('');

  $resarray = array();
  foreach ( func_get_args() as $var )
  {
    if ( !isset( $var ) )
    {
      array_push( $resarray, NULL );
      continue;
    }

    if ( empty( $var ) )
    {
      array_push( $resarray, $var );
      continue;
    }

    // Clean var
    if ( get_magic_quotes_gpc() )
    {
      pnStripslashes($var);
    }

    $var = preg_replace($search, $replace, $var);

    // Add to result array
    array_push( $resarray, $var );
  }

  // Return vars
  if (func_num_args() == 1)
  {
    return $resarray[0];
  }
  else
  {
    return $resarray;
  }
}

function getAge( $datestring )
{
  $x = explode( '/', $datestring );
  $monthofbirth = @$x[0];
  $dayofbirth = @$x[1];
  $yearofbirth = @$x[2];

  $currentyear = date('Y');
  $currentmonth = date('m');
  $currentday = date('j');

  if ( $monthofbirth > $currentmonth )
  {
    $age = ( $currentyear - $yearofbirth ) - 1;
  }
  else
  {
    $age = ( $currentyear - $yearofbirth );
  }

  if ( $monthofbirth == $currentmonth )
  {
    if ( $dayofbirth <= $currentday )
    {
      $age = ( $currentyear - $yearofbirth );
    }
    else
    {
      $age = ( $currentyear - $yearofbirth ) - 1;
    }
  }
  return $age;
}

function classifieds_user_sellinfo()
{
  // Create output object - this object will store all of our output so that
  // we can return it easily when required
  $output = new pnHTML();
  $output->SetInputMode(_PNH_VERBATIMINPUT);

  $is_capcha_correct = @$_SESSION['is_capcha_correct'];
  if ( !isset( $is_capcha_correct ) )
  {
    $is_capcha_correct = false;
  }

  if ( !$is_capcha_correct )
  {
    if ( !empty( $_SESSION['freecap_word_hash'] ) && !empty( $_POST['word'] ) )
    {
      // all freeCap words are lowercase.
      // font #4 looks uppercase, but trust me, it's not...

      if($_SESSION['hash_func'](strtolower($_POST['word']))==$_SESSION['freecap_word_hash'])
      {
        // reset freeCap session vars
        // cannot stress enough how important it is to do this
        // defeats re-use of known image with spoofed session id
        $_SESSION['freecap_attempts'] = 0;
        $_SESSION['freecap_word_hash'] = false;

        // now process form
        // now go somewhere else
        // header("Location: somewhere.php");
        $is_capcha_correct = true;
      }
      else
      {
        $is_capcha_correct = false;
      }
    }
    else
    {
      $is_capcha_correct = false;
    }
  }

  $_SESSION['is_capcha_correct'] = $is_capcha_correct;

  $formsubmit = @$_POST['formsubmit'];
  if ( isset( $formsubmit ) )
  {
    $classified_contact = $_POST['contact'];

    list( $x_category,
          $x_description,
          $x_full_name,
          $x_birthdate,
          $x_address_one,
          $x_address_two,
          $x_city,
          $x_state,
          $x_zip,
          $x_email_address,
          $x_phone_number,
          $x_subject,
          $x_price          ) = cleanInputVars( @$classified_contact['category'],
                                                @$classified_contact['description'],
                                                @$classified_contact['full_name'],
                                                @$classified_contact['birthdate'],
                                                @$classified_contact['address_one'],
                                                @$classified_contact['address_two'],
                                                @$classified_contact['city'],
                                                @$classified_contact['state'],
                                                @$classified_contact['zip'],
                                                @$classified_contact['email_address'],
                                                @$classified_contact['phone_number'],
                                                @$classified_contact['subject'],
                                                @$classified_contact['price'] );

    $error_text = '';
    $too_many_error_text = '';

    $is_category_correct      = isset( $x_category ) && $x_category > 0;
    $is_description_correct   = isset( $x_description ) && strlen( $x_description ) > 0 && strlen( $x_description ) <= 200;
    $is_full_name_correct     = isset( $x_full_name ) && strlen( $x_full_name ) > 0;
    $is_birthdate_correct     = isset( $x_birthdate ) && strlen( $x_birthdate ) > 0;
    $is_address_one_correct   = isset( $x_address_one ) && strlen( $x_address_one ) > 0;
    $is_city_correct          = isset( $x_city ) && strlen( $x_city ) > 0;
    $is_state_correct         = isset( $x_state ) && strlen( $x_state ) > 0;
    $is_zip_correct           = isset( $x_zip ) && strlen( $x_zip ) > 0;
    $is_email_address_correct = is_email ( $x_email_address );
    $is_phone_number_correct  = isset( $x_phone_number ) && strlen( $x_phone_number ) > 0;
    $is_subject_correct       = isset( $x_subject ) && strlen( $x_subject ) > 0;
    $is_too_many_classifieds  = false;

//    $is_price_correct         = isset( $x_price ) && strlen( $x_price ) > 0;



//////////////////////////////////////////////
/////// determine how many classifieds ///////
//////////////////////////////////////////////

  if ( $is_email_address_correct )
  {
    $exemptEmailAddresses = array( "david@blairbunch.com", 
                                   "home@kidspages.org", 
                                   "david@kidspages.org"
                                 );

    if ( !in_array( $x_email_address, $exemptEmailAddresses ) ) 
    {

// echo '<div style="font-size:24px"><br><br><br><br>';
        $strsql = "";
        $strsql .= "select 30 - ( TO_DAYS(now()) - TO_DAYS(submitdate) ) days ";
        $strsql .= "FROM `kp_classifieds`  ";
        $strsql .= "WHERE  ";
        $strsql .= "email='$x_email_address' and  ";
        $strsql .= "(status=0 or status=1 or status=2) and  ";
        $strsql .= "TO_DAYS(now()) - TO_DAYS(submitdate) < 30  ";
        $strsql .= "order by days asc ";

// echo '$strsql: ' . $strsql . '<br>';

        // classified listings
        list($dbconn) = pnDBGetConn();
        $bresult = $dbconn->Execute( $strsql );

// echo '$bresult: ' . $bresult . '<br>';

        $numclassifieds = $bresult->RecordCount();

// echo '$numclassifieds: ' . $numclassifieds . '<br>';

        list( $x_days_until_expire ) = $bresult->fields;

// echo '$x_days_until_expire: ' . $x_days_until_expire . '<br>';

        $bresult->Close();

        $is_too_many_classifieds = ( $numclassifieds >= 5 );
        if ( $is_too_many_classifieds )
        {
          $too_many_error_text = 'You already have 5 active classifieds. Please try back ' . ( ( $x_days_until_expire > 1 ) ? ( "in " . $x_days_until_expire . ' days' ) : 'tomorrow' ) . ' when your oldest classified ad expires.<br>';
        }

// echo '</div>';
    }
  }

//////////////////////////////////////////////
/////// determine how many classifieds ///////
//////////////////////////////////////////////

    $is_birthdate_correct = is_date( $x_birthdate );

    if ( $is_birthdate_correct )
    {
      if ( getAge( $x_birthdate ) < 18 )
      {
        $is_birthdate_correct = false;
        $error_text .= 'You must be 18 or older to enter a classifid ad.<br>';
      }
    }

    $is_input_correct = $is_category_correct && $is_description_correct && $is_full_name_correct &&
                        $is_birthdate_correct && $is_address_one_correct && $is_city_correct &&
                        $is_state_correct && $is_zip_correct && $is_email_address_correct &&
                        $is_phone_number_correct && $is_subject_correct && $is_capcha_correct;

    $is_form_correct = $is_input_correct && !$is_too_many_classifieds;

    if ( isset( $x_description ) && strlen( $x_description ) > 200 )
    {
      $error_text .= 'The ad description can\'t be more than 200 characters. Your current description is ' . strlen( $x_description ) . ' characters.<br>';
    }

/*
    if ( !$is_form_correct )
    {
      $is_capcha_correct = false;
    }
*/

    $_SESSION['is_capcha_correct'] = $is_capcha_correct;
    $_SESSION['category']      = intval( $x_category );
    $_SESSION['description']   = $x_description;
    $_SESSION['full_name']     = $x_full_name;
    $_SESSION['birthdate']     = $x_birthdate;
    $_SESSION['address_one']   = $x_address_one;
    $_SESSION['address_two']   = $x_address_two;
    $_SESSION['city']          = $x_city;
    $_SESSION['state']         = $x_state;
    $_SESSION['zip']           = $x_zip;
    $_SESSION['email_address'] = $x_email_address;
    $_SESSION['phone_number']  = $x_phone_number;
    $_SESSION['subject']       = $x_subject;
    $_SESSION['price']         = $x_price;

    $_SESSION['is_form_correct']       = $is_form_correct;

    $phpselfarr = explode("/", $_SERVER['PHP_SELF']);
    $phpselfarr = array_slice($phpselfarr, 0, -1);
    $app_base = implode("/", $phpselfarr);
    $base_url = "http://".$_SERVER['HTTP_HOST'] . $app_base;

    if ( $is_form_correct )
    {
      return classifieds_user_addimage();
    }
  }
  else
  {
    // todo: fix this
    $x_category      = @$_SESSION['category'];
    $x_description   = @$_SESSION['description'];
    $x_full_name     = @$_SESSION['full_name'];
    $x_birthdate     = @$_SESSION['birthdate'];
    $x_address_one   = @$_SESSION['address_one'];
    $x_address_two   = @$_SESSION['address_two'];
    $x_city          = @$_SESSION['city'];
    $x_state         = @$_SESSION['state'];
    $x_zip           = @$_SESSION['zip'];
    $x_email_address = @$_SESSION['email_address'];
    $x_phone_number  = @$_SESSION['phone_number'];
    $x_subject       = @$_SESSION['subject'];
    $x_price         = @$_SESSION['price'];
  }


  if ( @$_GET['loadform'] == "1" )
  {
    $x_category      = 3;
    $x_address_one   = '123 Main Street';
    $x_address_two   = 'Apartment 123';
    $x_birthdate     = '12/13/1934';
    $x_city          = 'Golden';
    $x_description   = 'This is really great.';
    $x_email_address = 'david@blairbunch.com';
    $x_full_name     = 'Frank Smith';
    $x_phone_number  = '303-333-1234';
    $x_price         = '123';
    $x_state         = 'CO';
    $x_subject       = 'Something great!';
    $x_zip           = '80302';
  }

  if ( empty( $x_state ) )
  {
    $x_state = 'CO';
  }

  if ( isset( $formsubmit ) && $formsubmit == "1" )
  {
    $x_requiredclass_description   = getRequiredClass( @$is_description_correct );
    $x_requiredclass_full_name     = getRequiredClass( @$is_full_name_correct );
    $x_requiredclass_birthdate     = getRequiredClass( @$is_birthdate_correct );
    $x_requiredclass_address_one   = getRequiredClass( @$is_address_one_correct );
    $x_requiredclass_city          = getRequiredClass( @$is_city_correct );
    $x_requiredclass_state         = getRequiredClass( @$is_state_correct );
    $x_requiredclass_zip           = getRequiredClass( @$is_zip_correct );
    $x_requiredclass_email_address = getRequiredClass( @$is_email_address_correct );
    $x_requiredclass_phone_number  = getRequiredClass( @$is_phone_number_correct );
    $x_requiredclass_subject       = getRequiredClass( @$is_subject_correct );
//    $x_requiredclass_price         = getRequiredClass( @$is_price_correct );
    $x_requiredclass_category      = getRequiredClass( @$is_category_correct );
    $x_requiredclass_capcha        = getRequiredClass( @$is_capcha_correct );
  }
  else
  {
    $x_requiredclass_description   = "required";
    $x_requiredclass_full_name     = "required";
    $x_requiredclass_birthdate     = "required";
    $x_requiredclass_address_one   = "required";
    $x_requiredclass_city          = "required";
    $x_requiredclass_state         = "required";
    $x_requiredclass_zip           = "required";
    $x_requiredclass_email_address = "required";
    $x_requiredclass_phone_number  = "required";
    $x_requiredclass_subject       = "required";
//    $x_requiredclass_price         = "required";
    $x_requiredclass_category      = "required";
    $x_requiredclass_capcha        = "required";
    $is_form_correct = true;
  }

  $x_description   = htmlspecialchars( @$x_description );
  $x_full_name     = htmlspecialchars( @$x_full_name );
  $x_birthdate     = htmlspecialchars( @$x_birthdate );
  $x_address_one   = htmlspecialchars( @$x_address_one );
  $x_address_two   = htmlspecialchars( @$x_address_two );
  $x_city          = htmlspecialchars( @$x_city );
  $x_state         = htmlspecialchars( @$x_state );
  $x_zip           = htmlspecialchars( @$x_zip );
  $x_email_address = htmlspecialchars( @$x_email_address );
  $x_phone_number  = htmlspecialchars( @$x_phone_number );
  $x_subject       = htmlspecialchars( @$x_subject );
  $x_price         = htmlspecialchars( @$x_price );

$output->Text(
<<<EOT

<script language="javascript">
<!--
function new_freecap()
{
  // loads new freeCap image
  if(document.getElementById)
  {
    // extract image name from image source (i.e. cut off ?randomness)
    thesrc = document.getElementById("freecap").src;
    thesrc = thesrc.substring(0,thesrc.lastIndexOf(".")+4);
    // add ?(random) to prevent browser/isp caching
    document.getElementById("freecap").src = thesrc+"?"+Math.round(Math.random()*100000);
  } else {
    alert("Sorry, cannot autoreload freeCap image. Submit the form and a new freeCap will be loaded.");
  }
}

function reset_form()
{
  if ( confirm("Are you sure that you want to reset this form?") )
  {
    window.document.classifiedform.contact_name.value = "";
    window.document.classifiedform.contact_birthdate.value = "";
    window.document.classifiedform.contact_address_one.value = "";
    window.document.classifiedform.contact_address_two.value = "";
    window.document.classifiedform.contact_city.value = "";
    window.document.classifiedform.contact_state.value = "CO";
    window.document.classifiedform.contact_zip.value = "";
    window.document.classifiedform.contact_email_address.value = "";
    window.document.classifiedform.contact_phone_number.value = "";
    window.document.classifiedform.contact_subject.value = "";
    window.document.classifiedform.contact_price.value = "";
    window.document.classifiedform.contact_description.value = "";
    window.document.classifiedform.contact_category.value = "";
  }
  else
  {
    window.document.classifiedform.search.focus();
  }
}

//-->
</script>

<link href="/css/classifieds.css" media="screen" rel="Stylesheet" type="text/css" />

  <div class="Container">
    <div id="DashContentFrame">
      <div class="Left">
        <div class="col">
          <div class="SectionHeader" style="padding-bottom:2px;margin-bottom:2px;">
            <h1>Classified Ad Entry Form</h1>
          </div>
          <form action="/oldkpindex.php" method="post" name="classifiedform">
            <input type="hidden" name="module" value="Classifieds">
            <input type="hidden" name="func" value="sellinfo">
            <input name="formsubmit" value="1" type="hidden" />
            <div id="basic_form">
EOT
);
              if ( isset( $is_form_correct ) && !$is_form_correct )
              {
                if ( $is_too_many_classifieds )
                {
                    $output->Text( '<p class="blockintro" style="margin-bottom:4px;"><b style="color:red;font-size:15px;font-weight:bold;line-height:normal">' . $too_many_error_text . '</b></p>' );
                }




                if ( !$is_input_correct && !$is_too_many_classifieds )
                {
                  $output->Text( '<p class="blockintro"><b style="color:red">Please fix the errors marked in red below.</b></p>' );
                  if ( !empty( $error_text ) )
                  {
                    $output->Text( '<p class="blockintro"><b style="color:red">' . $error_text . '</b></p>' );
                  }
                }
              }

$output->Text(
<<<EOT
              <p class="blockintro">
                Please enter fill out the form below. Your personal information will not be shown in your classified ad or shared with anyone.
              </p>
              <div style="height:5px; padding:0; border:0;" ></div>
              <p class="blockintro">
                When a buyer replies to your ad, you will receive an e-mail at the e-mail address you enter below. After that, it's up to you to contact the buyer at your discretion.
              </p>
              <div style="height:5px; padding:0; border:0;" ></div>
              <p class="blockintro">
                Items in bold are required.<br>
                NOTE: You must be 18 or older to submit a classified ad.
              </p>

              <div class="block">
                <h1 style="padding-bottom:2px;padding-top:0px;margin-top:0px;font-size:18px">Personal Info</h1>
                <dl>
                  <dt class="$x_requiredclass_full_name">Full Name</dt>
                  <dd><input id="contact_name" name="contact[full_name]" size="22" maxlength="80" value="$x_full_name" type="text" /></dd>

                  <dt class="$x_requiredclass_birthdate">Birthdate</dt>
                  <dd><input id="contact_birthdate" name="contact[birthdate]" size="22" maxlength="80" value="$x_birthdate" type="text" />  (ex: 5/14/1960)</dd>

                  <dt class="$x_requiredclass_address_one">Address 1</dt>
                  <dd><input id="contact_address_one" name="contact[address_one]" size="40" maxlength="80" value="$x_address_one" type="text" /></dd>

                  <dt>Address 2</dt>
                  <dd><input id="contact_address_two" name="contact[address_two]" size="40" maxlength="80" value="$x_address_two" type="text" /></dd>

                  <dt class="$x_requiredclass_city">City</dt>
                  <dd><input id="contact_city" name="contact[city]" size="22" maxlength="80" value="$x_city" type="text" /></dd>

                  <dt class="$x_requiredclass_state">State</dt>
                  <dd><input id="contact_state" name="contact[state]" size="2" maxlength="2" value="$x_state" type="text" /></dd>

                  <dt class="$x_requiredclass_zip">ZIP Code</dt>
                  <dd><input id="contact_zip" name="contact[zip]" size="22" maxlength="20" value="$x_zip" type="text" /></dd>

                  <dt class="$x_requiredclass_email_address">E-mail address</dt>
                  <dd><input id="contact_email_address" name="contact[email_address]" size="40" maxlength="80" value="$x_email_address" type="text" /></dd>

                  <dt class="$x_requiredclass_phone_number">Phone Number</dt>
                  <dd><input id="contact_phone_number" name="contact[phone_number]" size="22" maxlength="20" value="$x_phone_number" type="text" /></dd>

                  <hr>

                  <h1 style="padding-bottom:2px;padding-top:0px;margin-top:0px;font-size:18px">Classified Ad Info</h1>

                  <dt class="$x_requiredclass_category">Category</dt>
                  <dd><select id="contact_category" name="contact[category]">
EOT
);

  $categories = array(
    array( -1, 'Choose Category' ),
    array( -1, '--------' ),
    array( -1, 'FOR SALE' ),
    array(  3, '&#149; Automobiles' ),
    array(  4, '&#149; Sports Equipment' ),
    array(  5, '&#149; Musical Instruments' ),
    array(  6, '&#149; Clothing' ),
    array(  7, '&#149; Baby Stuff' ),
    array(  8, '&#149; Toys' ),
    array(  9, '&#149; Books' ),
    array( 10, '&#149; Collectibles' ),
    array( 11, '&#149; Household' ),
    array( 12, '&#149; Furniture' ),
    array( 13, '&#149; Tools' ),
    array( 14, '&#149; Tickets' ),
    array( 15, '&#149; Computer Equipment' ),
    array( 16, '&#149; Electronics' ),
    array( 17, '&#149; Movies/Music' ),
    array( 18, '&#149; Video Games/Systems' ),
    array( 19, '&#149; General Stuff' ),
    array( -1, '--------' ),
    array( 30, '&#149; Free Stuff' ),
    array( 20, '&#149; Pets' ),
    array( 21, '&#149; Barter' ),
    array( -1, '--------' ),
    array( -1, 'EVENTS' ),
    array( 24, '&#149; Garage Sales' ),
    array( 25, '&#149; Community Events' ),
    array( -1, '--------' ),
    array( 26, '&#149; Lost &amp; Found' ),
    array( -1, '--------' ),
    array( -1, 'CHILDCARE' ),
    array( 27, '&#149; Childcare Wanted' ),
    array( 28, '&#149; Childcare Provider' ),
    array( -1, '--------' ),
    array( 32, '&#149; Home Services' ),
    array( 29, '&#149; Lessons' ),
    array( -1, '--------' ),
    array( -1, 'REAL ESTATE' ),
    array( 31, '&#149; Vacation Rentals' ),
    array( 22, '&#149; Homes for Rent' ),
    array( 23, '&#149; Homes for Sale' ),
    array( -1, '--------' ),
    array( -1, 'EMPLOYMENT' ),
    array(  1, '&#149; Help Wanted' ),
//    array(  2, '&#149; Jobs Available' ),
    );

  foreach ( $categories as $value)
  {
    $option_tag  = '<option';
    if ( $value[0] !== -1 )
    {
      $option_tag .=  ' value="' . $value[0] . '"';
      if ( $value[0] == @$x_category )
      {
        $option_tag .=  ' selected';
      }
    }
    $option_tag .=  '>' . $value[1] . '</option>';

    $output->Text( $option_tag );
  }

$output->Text(
<<<EOT
                  </select></dd>

                  <dt class="$x_requiredclass_subject">Item/Title</dt>
                  <dd><input id="contact_subject" name="contact[subject]" size="50" maxlength="80" value="$x_subject" type="text" /></dd>

                  <dt>Price</dt>
                  <dd>$<input id="contact_price" name="contact[price]" size="20" maxlength="20" value="$x_price" type="text" /></dd>

                  <dt class="$x_requiredclass_description">Description</dt>
                  <dd><textarea id="contact_description" cols="50" name="contact[description]" rows="6">$x_description</textarea></dd>
EOT
);


if ( !$is_capcha_correct )
{
$output->Text(
<<<EOT
                  <dt class="$x_requiredclass_capcha">Security Word</dt>

                  <dd><img src="/freecap/freecap.php" id="freecap"></dd>

                  <dt>&nbsp;<br>&nbsp;<br>&nbsp;<br>&nbsp;<br></dt>

                  <dd>The Security Word ensures that a person and not a computer program is entering this classified ad. Please type the Security Word in the text box below.</dd>

                  <dt>&nbsp;</dt>
                  <dd>If you can't read the word, <a href="#" onClick="this.blur();new_freecap();return false;">click here</a></dd>

                  <dt>&nbsp;</dt>
                  <dd>word above: <input type="text" name="word"></dd>

EOT
);
}
else
{
$output->Text(
<<<EOT
                  <dt class="$x_requiredclass_capcha">Security Word</dt>
                  <dd style="font-size:12px;padding-top:3px;"><b>Verified</b></dd>
EOT
);
}

$output->Text(
<<<EOT
                </dl>
              </div>
              <div class="action">
                <input type="button" name="resetbutton" value="Reset" onClick="reset_form();" />&nbsp;
                <input type="submit" value="Continue">
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>

EOT
);

  return $output->GetOutput();
}

///////////////////////////////////////////////////////////////////////

function getRandomString( $len=40, $num=1, $uc=1, $lc=1 )
{
  if ( !$len || $len<1 || $len>100 )
  {
    return "";
  }
  if (!$num && !$uc && !$lc)
  {
    return "";
  }

  $s = "";
  $i = 0;
  do
  {
    switch ( mt_rand( 1, 3 ) )
    {
      // get number - ASCII characters (0:48 through 9:57)
      case 1:
        if ( $num == 1 )
        {
          $s .= chr( mt_rand( 48, 57 ) );
          $i++;
        }
        break;

      // get uppercase letter - ASCII characters (a:65 through z:90)
      case 2:
        if ( $uc == 1 )
        {
          $s .= chr( mt_rand( 65, 90 ) );
          $i++;
        }
        break;

      // get lowercase letter - ASCII characters (A:97 through Z:122)
      case 3:
        if ( $lc == 1 )
        {
          $s .= chr( mt_rand( 97, 122 ) );
          $i++;
        }
        break;
    }
  } while ( $i < $len );

  return $s;
}

/////////////////////////////////////////////////
function classifieds_user_addimage()
{
  $x_looks_good = @$_POST['looks_good'];
  if ( isset( $x_looks_good ) )
  {
    return classifieds_user_privacypolicy();
  }

  $x_submit_image_error = '';
  $x_classified_image = '';
  $file_upload_error_text = '';

  $x_submit_image = @$_POST['submit_image'];
  if ( isset( $x_submit_image ) )
  {
    $MyObject = new upload($_FILES['image_field']);
    $x_submit_image_error .= $MyObject->log;
    $x_submit_image_error .= '<hr>';
    if ($MyObject->uploaded)
    {
      $images_file_name = getRandomString();

//      $write_directory = '/stuff/mt/site/htdocs.pn/images/classifieds/';  // local
//      $write_directory = '/home/kp/public_html/images/classifieds/';  // remote

      $MyObject->image_resize           = true;
      $MyObject->image_convert          = 'jpg';
      $MyObject->image_x                = 300;
      $MyObject->image_y                = 300;
      $MyObject->image_ratio_no_zoom_in = true;
      $MyObject->file_new_name_body     = $images_file_name;
      $MyObject->process( IMAGE_PATH );

      $base_image_name = $MyObject->file_dst_name;

      $MyObject->image_resize           = true;
      $MyObject->image_convert          = 'jpg';
      $MyObject->image_x                = 80;
      $MyObject->image_y                = 80;
      $MyObject->image_ratio_no_zoom_in = true;
      $MyObject->file_new_name_body     = $images_file_name;
      $MyObject->file_name_body_add     = '_thumb';
      $MyObject->process( IMAGE_PATH );

      if ($MyObject->processed)
      {
        $x_submit_image_error .= 'image resized';
        $x_submit_image_error .= $MyObject->log;
        $x_submit_image_error .= '<b>file_dst_pathname</b>:  ' . $MyObject->file_dst_pathname . '<br>';
        $x_submit_image_error .= '<img src="/images/classifieds/' . $MyObject->file_dst_name . '"><br>';

        $x_classified_image = $base_image_name;
        $_SESSION['classified_image'] = $x_classified_image;
        $MyObject->clean();
      }
      else
      {
        $x_submit_image_error .= 'error : ' . $MyObject->error;
        $x_submit_image_error .= $MyObject->log;
      }
    }
    else
    {
      $x_submit_image_error .= 'error : ' . $MyObject->error;
      $x_submit_image_error .= $MyObject->log;
    }


    if ( !$MyObject->processed || !$MyObject->uploaded )
    {
      $file_upload_error_text = $MyObject->error;
    }
  }

  $remove_image = @$_GET['remove_image'];
  if ( !empty( $remove_image ) )
  {
    $x_classified_image = '';
    $_SESSION['classified_image'] = $x_classified_image;
  }


  // process classifieds
  $x_full_name     = htmlspecialchars( @$_SESSION['full_name'] );
  $x_birthdate     = htmlspecialchars( @$_SESSION['birthdate'] );
  $x_address_one   = htmlspecialchars( @$_SESSION['address_one'] );
  $x_address_two   = htmlspecialchars( @$_SESSION['address_two'] );
  $x_city          = htmlspecialchars( @$_SESSION['city'] );
  $x_state         = htmlspecialchars( @$_SESSION['state'] );
  $x_zip           = htmlspecialchars( @$_SESSION['zip'] );
  $x_email_address = htmlspecialchars( @$_SESSION['email_address'] );
  $x_phone_number  = htmlspecialchars( @$_SESSION['phone_number'] );
  $x_category      = htmlspecialchars( @$_SESSION['category'] );
  $x_subject       = htmlspecialchars( @$_SESSION['subject'] );
  $x_price         = htmlspecialchars( @$_SESSION['price'] );
  $x_description   = htmlspecialchars( @$_SESSION['description'] );
  $x_classified_image = @$_SESSION['classified_image'];


  // Create output object - this object will store all of our output so that
  // we can return it easily when required
  $output = new pnHTML();
  $output->SetInputMode(_PNH_VERBATIMINPUT);

$output->Text(
<<<EOT
<link href="/css/classifieds.css" media="screen" rel="Stylesheet" type="text/css" />
<script language="JavaScript">
// Toggles the layer visibility on
function showLayer(layerName)
{
  document.getElementById(layerName).style.visibility="visible";
}

// Toggles the layer visibility off
function hideLayer(layerName)
{
  document.getElementById(layerName).style.visibility="hidden";
}
</script>

  <div class="Container">
    <div id="DashContentFrame">
      <div class="Left">
        <div class="col">
          <div class="SectionHeader">
            <h1 style="font-size:25px">Add a Digital Photo&nbsp <span style="font-size:12px"><a href="/oldkpindex.php?module=Classifieds&func=preview">(No thanks, go to the next page)</a></span></h1>
          </div>
EOT
);

          if ( !empty( $x_classified_image ) )
          {
            $output->Text( "<center><img src=\"/images/classifieds/$x_classified_image\"><br></center>" );
          }
          else
          {
            $output->Text( "<center><b>No Photo Added</b><br></center>" );
          }


$output->Text(
<<<EOT
          <div style="margin-top:30px">
<!--
            <div class="SectionHeader" style="padding-bottom:0px; margin-bottom:0px">
              <h1 style="font-size:13;">Add a Digital Photo</h1>
            </div>
-->
            <div style="padding-top:4px; padding-bottom:4px">
            If you want to add a digital photo:
            <ul>
              <li>Click on the "Browse..." button below.</li>
              <li>Navigate to the GIF or JPG file you want to add.</li>
              <li>Click the "Open" button.</li>
              <li>Click on the "Upload Digital Photo" button below to add the photo to your ad. Depending on the size of the photo and your connection speed, it could take anywhere between a few seconds and a few minutes until you see the photo appear above.</li>
            </ul>
            Once the photo appears, or if you don't want to add a photo, click on "Continue" below.
            </div>
            <form action="/oldkpindex.php" method="post" enctype="multipart/form-data" onsubmit="hideLayer('sbmt');showLayer('upld');">
              <input type="hidden" name="module" value="Classifieds">
              <input type="hidden" name="func" value="addimage">
              <input name="submit_image" value="1" type="hidden" />
              <input type="file" size="50" name="image_field" value="">
              <div class="action" style="padding-top:2px;">
              <div style="position: relative;" >
                <div id="sbmt" style="position:absolute;left:0px;top:0px;">
                  <input type="submit" value="Upload Digital Photo">
                </div>
                <div id="upld" style="visibility:hidden;position:absolute;left:0px;top:0px;padding:0px;margin:0px;">
                  Uploading file. Please wait...
                </div>
              </div>
                <br><br>
EOT
);

  if ( !empty( $file_upload_error_text ) )
  {
    $output->Text( '<div style="color:red">' );
    $output->Text( $file_upload_error_text . '<br><br>' );
    $output->Text( '</div>' );
  }


$output->Text(
<<<EOT
                <a href="/oldkpindex.php?module=Classifieds&func=sellinfo">Edit Ad</a>&nbsp;&nbsp;

EOT
);

  if ( !empty( $x_classified_image ) )
  {
    $output->Text( '<a href="/oldkpindex.php?module=Classifieds&func=addimage&remove_image=1">Remove photo</a>&nbsp;&nbsp;' );
  }

$output->Text(
<<<EOT
                <a href="/oldkpindex.php?module=Classifieds&func=preview">Continue</a>
EOT
);


$output->Text(
<<<EOT
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>
  <img src="/images/global/pix.gif" width="610" height="1" border="0">

EOT
);

// $output->Text( '$MyObject->processed = ' . ( $MyObject->processed ? "Yes" : "No" ) . '<br>');
// $output->Text( '$MyObject->uploaded =  ' . ( $MyObject->uploaded ? "Yes" : "No" ) . '<br>');
// $output->Text( '$MyObject->error =     ' . $MyObject->error . '<br>');
// $output->Text( $x_submit_image_error );

  return $output->GetOutput();
}
/////////////////////////////////////////////////


function classifieds_user_preview()
{
  $x_looks_good = @$_POST['looks_good'];
  if ( isset( $x_looks_good ) )
  {
    return classifieds_user_privacypolicy();
  }

  // process classifieds
  $x_full_name     = htmlspecialchars( @$_SESSION['full_name'] );
  $x_birthdate     = htmlspecialchars( @$_SESSION['birthdate'] );
  $x_address_one   = htmlspecialchars( @$_SESSION['address_one'] );
  $x_address_two   = htmlspecialchars( @$_SESSION['address_two'] );
  $x_city          = htmlspecialchars( @$_SESSION['city'] );
  $x_state         = htmlspecialchars( @$_SESSION['state'] );
  $x_zip           = htmlspecialchars( @$_SESSION['zip'] );
  $x_email_address = htmlspecialchars( @$_SESSION['email_address'] );
  $x_phone_number  = htmlspecialchars( @$_SESSION['phone_number'] );
  $x_category      = htmlspecialchars( @$_SESSION['category'] );
  $x_subject       = htmlspecialchars( @$_SESSION['subject'] );
  $x_price         = htmlspecialchars( @$_SESSION['price'] );
  $x_description   = htmlspecialchars( @$_SESSION['description'] );
  $x_classified_image = @$_SESSION['classified_image'];

  // Create output object - this object will store all of our output so that
  // we can return it easily when required
  $output = new pnHTML();
  $output->SetInputMode(_PNH_VERBATIMINPUT);

$output->Text(
<<<EOT
<link href="/css/classifieds.css" media="screen" rel="Stylesheet" type="text/css" />

  <div class="Container">
    <div id="DashContentFrame">
      <div class="Left">
        <div class="col">
          <div class="SectionHeader">
            <h1 style="font-size:25px">Ad Preview</h1>
          </div>

          <div style="padding:7px; margin:5px; border: solid black 1px">
            <div class="SectionHeader">
              <h1 style="font-size:20px">$x_subject</h1>

EOT
);

if ( !empty( $x_price ) )
{
//  $output->Text( "<b>Price: \$$x_price</b>" );
  $output->Text( "<b>Price: $x_price</b>" );
}


$output->Text(
<<<EOT
            </div>
            <form action="/oldkpindex.php" method="post">
              <input type="hidden" name="module" value="Classifieds">
              <input type="hidden" name="func" value="preview">
              <input name="looks_good" value="1" type="hidden" />
              <p style="font-size:15px">$x_description</p>
EOT
);
              if ( !empty( $x_classified_image ) )
              {
                $output->Text( "<center><img src=\"/images/classifieds/$x_classified_image\"><br></center>" );
              }

$output->Text(
<<<EOT
          </div>
              <div class="action">
                <a href="/oldkpindex.php?module=Classifieds&func=sellinfo">Edit Ad</a>&nbsp;&nbsp;
                <a href="/oldkpindex.php?module=Classifieds&func=addimage">Edit Photo</a>&nbsp;&nbsp;
                <input type="submit" value="Looks Good">
              </div>
          </form>
        </div>
      </div>
    </div>
  </div>

EOT
);

  return $output->GetOutput();
}

///////////////////////////////////////////////////////////////////////
function classifieds_user_privacypolicy()
{
  if ( $_SESSION['privacy_policy_submit'] )
  {
    return classifieds_user_complete();
  }

  $x_privacy_policy_submit = @$_POST['privacy_policy_submit'];

  if ( isset( $x_privacy_policy_submit ) )
  {
    $is_form_correct = @$_SESSION['is_form_correct'];

    $x_privacy_policy_submit = true;
    $_SESSION['privacy_policy_submit'] = $x_privacy_policy_submit;

    if ( $is_form_correct && $x_privacy_policy_submit )
    {
      return classifieds_user_complete();
    }
  }

  // Create output object - this object will store all of our output so that
  // we can return it easily when required
  $output = new pnHTML();
  $output->SetInputMode(_PNH_VERBATIMINPUT);

$output->Text(
<<<EOT
<link href="/css/classifieds.css" media="screen" rel="Stylesheet" type="text/css" />

  <div class="Container">
    <div id="DashContentFrame">
      <div class="Left">
        <div class="col">
          <p class="blockintro" style="font-size:16px; font-weight: bold; color: #000; line-height: normal;padding:0px;margin-bottom:10px;margin-top:3px;">
            Before you can buy or sell, you must read and agree to Kids' Pages Online Classfieds Terms and Conditions.
          </p>
          <div class="SectionHeader" style="padding-bottom:0px;margin-bottom:5px;">
            <h1>Terms of Use</h1>
          </div>

          <form action="/oldkpindex.php" method="post">
            <input name="privacy_policy_submit" value="1" type="hidden" />
            <input type="hidden" name="module" value="Classifieds">
            <input type="hidden" name="func" value="privacypolicy">
            <div id="basic_form">
              <p class="blockintro" style="padding-bottom:0px;margin-bottom:5px;font-size:13px;"><strong>Please read our Terms of Use and click the button if you accept the Terms.</strong></p>
              <div class="privacy_policy">

<h2>Privacy Policy</h2>
<p>Kids' Pages goal is to provide you with tools and information to manage and protect your online privacy. We have established this privacy policy to explain what information we collect, who may receive that information, what we might do with the information, and how long we keep it.</p>

<h2>Information Collection and Use</h2>
<p>We collect your name, mailing address, phone number, and e-mail in order to process your request to place an ad on Kids' Pages classifieds. We use this information: to place your ad and to notify you if necessary. We may send you periodic e-mails about Kids' Pages events and services. We do not share your information with anyone. We have "marketing partners" and may send you information via e-mail about their services or events, but we will not give, rent, loan, or otherwise disclose anything about you to anyone. Traditional contact information is kept for as long as is legally required.</p>

<p>Kids' Pages does not use tracking devices for marketing purposes ("cookies", "web beacons," single-pixel gifs).</p>

<p>If, for some reason we have violated our privacy policy, please contact us at freeclassifieds@kidspages.org and we will correct the error as soon as you notify us.</p>

<h2>Disclaimer</h2>
<p>Kids' Pages assumes no responsibility for the content of classified ads or third party advertising presented on our web site. Kids' Pages will not be involved in person-to-person dealings. You are using this web site at your own risk.</p>

<h2>Terms and Condition of Service</h2>
<p>Kids' Pages Classifieds may be used for lawful purposes only. Any information in violation of any applicable law or regulation is prohibited. This includes, but is not limited to: copyrighted material; material that is obscene, defamatory, constitutes an illegal threat, or violates any laws. We do not accept any MLM, Work at Home, Income Guarantees or Get Rich Quick type content.</p>

<p>Kids' Pages Free Classifieds are published in good faith without verification, they will be reviewed for content, however before they are posted. Kids' Pages reserves the right to refuse, classify, revise or censor any ads for any reason in its sole discretion. Kids' Pages also reserves the right to unsubstantially change ads and messages described therein, as well as this legal disclaimer at any time. Kids' Pages does not endorse, guarantee or authenticate any listings offered for sale or trade</p>

<h2>User Agreement</h2>
<p>Kids' Pages has established the following terms and condition to ensure the quality of kidspages.org and the services we offer to you, our "Users". Users are responsible for all aspects of the transactions in which they choose to participate as buyers and/or sellers. All transactions conducted on kidspages.org must be consistent with any applicable legal rules and with Kids' Pages terms and conditions of service. Please review the terms and conditions in this agreement and make sure any transactions you conduct comply fully.</p>

<p>This document describes the terms and conditions on which Kids' Pages offers a User ("You") access to our services.</p>

<h2>PLEASE READ THIS AGREEMENT CAREFULLY</h2>
<p>By signing onto kidspages.org you accept both the terms and conditions in this User Agreement and our Terms of Use.</p>

<p>This agreement was revised on August 20, 2005 and may be modified again at any time.</p>

<h2>Acceptance of Terms</h2>
<p>By posting a free classified on kidspages.org, you agree to the terms of this User Agreement, and to abide by the other terms, policies, procedures, and guidelines on kidspages.org. Should you object to any term or condition of these Terms, any guidelines, or any subsequent modifications thereto or become dissatisfied with Kids' Pages in any way, your only recourse is to immediately discontinue use of kidspages.org.</p>

<h2>Free Classified Services</h2>
<p>Kids' Pages acts as a matching service for Users to locate people to buy, sell, and negotiate the exchange of goods and services. We cannot verify or endorse the quality, safety, or legality of the posted advertisements, or the truth or accuracy of the content on our site.</p>

<h2>User Obligations and Terms</h2>
<p>You are solely responsible for your information, and we act merely as a passive messenger. Your information includes any information you provide to us or other Users during the registration, trading, or posting process, in any public message area or through any email feature, including all text descriptions and/or photographs, digital images, or renderings of your items and services. We may take any action with respect to such information we deem necessary at our sole discretion if we believe it may create liability for us. You acknowledge that Kids' Pages has the right (but not the obligation) in their sole discretion to refuse, modify, or reorganize any content that is available via the service. Kids' Pages also has the right to suspend or terminate your use of kidspages.org and refuse any and all current or future use of our service, at any time and at our sole discretion. Kids' Pages reserves the right to change or discontinue, temporarily or permanently, some or all of our services at any time without notice.</p>

<p>You agree that your information and the content you post on kidspages.org:</p>
<br>
<div style="padding-left:15px;margin-left:24px;font-size:40px;padding-right:15px;">
  <ol>
    <li>Will be true, accurate, up-to-date and will not be false or misleading, deceitful, or constitute a "bait and switch"; and that you will provide an honest representation of your item for sale and indicating if your item is used, refurbished or a replica of the original.</li>
    <li>Will not have inappropriate ad content and will not be obscene or contain or offer explicit adult products or services and will not be harmful to minors in anyway.</li>
    <li>Will not involve the sale of stolen items or items that are not yours to sell.</li>
    <li>To place each item in the appropriate category. You must list your item in the most appropriate category. Kids' Pages reserves the right to relocate an ad that is deemed to be in an inappropriate category.</li>
    <li>Will not violate any law, statute, ordinance, or regulation, will not be defamatory, trade libelous, unlawfully threatening, or unlawfully harassing.</li>
    <li>Will not link directly or indirectly to or include descriptions of goods or services that (i) are prohibited under this Agreement or (ii) you do not have a right to link to or include and that they are all in accordance with Kids' Pages Free Classified Guidelines.</li>
  </ol>
</div>

<h2>License</h2>
<p>You agree to grant Kids' Pages a nonexclusive, worldwide, perpetual, irrevocable, royalty-free, right to exercise the copyright and publicity rights you have in your posted content, in any media now known or not currently known.</p>

<h2>Posting</h2>
<p>Classifieds are text descriptions, graphics, and/or pictures on kidspages.org supplied by you that either (a) describe a good or service you have or provide (b) describe a good or service item you are seeking. Free Classifieds are limited to five per e-mail address every thirty days. Kids' Pages is not responsible for the accuracy or content of classifieds. All classifieds are subject to approval based on Kids' Pages Free Classified Guidelines.</p>

<h2>Disputes</h2>
<p>Kids' Pages is not responsible for resolving disputes between parties.</p>

<h2>Suspension/Termination</h2>
<p>Kids' Pages may immediately temporarily suspend, indefinitely suspend, or terminate your use of kidspages.org, any of your current classified listings, and any other information you place on the site if you breach this agreement, if we are unable to verify or authenticate any information you provide to us, for violating the letter or spirit of the Terms or for any other reason.</p>

<p>Without limiting any other remedies, Kids' Pages may suspend or terminate your account if you are found (by conviction, settlement, insurance or escrow investigation, or otherwise) to have engaged in fraudulent activity in connection with our website.</p>

<h2>Indemnity</h2>
<p>You agree to defend, indemnify and hold Kids' Pages and its officers, directors and employees harmless from and against any and all claims made by or liabilities to any third party resulting from any activities conducted under your use or misuse of our services. This includes, but not limited to, posting content on kidspages.org, entering into transactions with other users, contacting others pertaining to their ad(s), infringing a third party's intellectual property or other rights, failing to deliver goods or payment after a sale agreement or otherwise arising out of your breach of this Agreement.</p>

<h2>Limit of liability</h2>
<p>In no event shall Kids' Pages be liable for lost profits or any special, incidental, or consequential damages (however arising, including negligence) arising out of or in connection with this agreement.</p>

<h2>General compliance with laws</h2>
<p>You shall comply with all applicable laws, statutes, ordinances and regulations regarding your use of our service and your negotiations, classified ad, purchase, and sale of items and services.</p>

<h2>Copyright</h2>
<p>All content included on kidspages.org, including text, graphics, logos, icons, and images, are the property of Kids' Pages, its licensors or its content suppliers, and is protected by U.S. and international copyright and trademark laws. The compilation of all content on this web site is the exclusive property of Kids' Pages and is protected by U.S. and international copyright laws. All software used on this site is the property of Kids' Pages and is protected by U.S. and international copyright laws. The content and software on this site may be used solely as a resource. You may not copy, publish, distribute, create derivative works of, or commercially exploit the content of kidspages.org, or use this website for any other purpose.</p>

              </div>
              <div class="action">
                <a href="/oldkpindex.php?module=Classifieds&func=sellinfo">Go Back</a>&nbsp;
                <input type="submit" value="Accept Terms of Use">
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>

EOT
);

  return $output->GetOutput();
}

///////////////////////////////////////////////////////////////////////
function classifieds_user_complete()
{
  // error_reporting (E_ALL);
  $is_form_correct = @$_SESSION['is_form_correct'];
  $privacy_policy_submit = $_SESSION['privacy_policy_submit'];

  if ( !( $is_form_correct && $privacy_policy_submit ) )
  {
    return classifieds_user_sellinfo();
  }

  // Create output object - this object will store all of our output so that
  // we can return it easily when required
  $output = new pnHTML();
  $output->SetInputMode(_PNH_VERBATIMINPUT);

  // process classifieds
  $x_full_name        = @$_SESSION['full_name'];
  $x_birthdate        = @$_SESSION['birthdate'];
  $x_address_one      = @$_SESSION['address_one'];
  $x_address_two      = @$_SESSION['address_two'];
  $x_city             = @$_SESSION['city'];
  $x_state            = @$_SESSION['state'];
  $x_zip              = @$_SESSION['zip'];
  $x_email_address    = @$_SESSION['email_address'];
  $x_phone_number     = @$_SESSION['phone_number'];
  $x_category         = @$_SESSION['category'];
  $x_subject          = @$_SESSION['subject'];
  $x_price            = @$_SESSION['price'];
  $x_description      = @$_SESSION['description'];
  $x_classified_image = @$_SESSION['classified_image'];

  $categories = array(
     1 => 'Help Wanted',
//     2 => 'Jobs Available',
     3 => 'Automobiles',
     4 => 'Sports Equipment',
     5 => 'Musical Instruments',
     6 => 'Clothing',
     7 => 'Baby Stuff',
     8 => 'Toys',
     9 => 'Books',
    10 => 'Collectibles',
    11 => 'Household',
    12 => 'Furniture',
    13 => 'Tools',
    14 => 'Tickets',
    15 => 'Computer Equipment',
    16 => 'Electronics',
    17 => 'Movies/Music',
    18 => 'Video Games/Systems',
    19 => 'General Stuff',
    20 => 'Pets',
    21 => 'Barter',
    22 => 'Homes for Rent',
    23 => 'Homes for Sale',
    24 => 'Garage Sales',
    25 => 'Community Events',
    26 => 'Lost &amp; Found',
    27 => 'Childcare Wanted',
    28 => 'Childcare Provider',
    29 => 'Lessons',
    30 => 'Free Stuff',
    31 => 'Vacation Rentals',
    32 => 'Home Services',
    );

  unset( $_SESSION['category'] );
  unset( $_SESSION['description'] );
  unset( $_SESSION['full_name'] );
  unset( $_SESSION['birthdate'] );
  unset( $_SESSION['address_one'] );
  unset( $_SESSION['address_two'] );
  unset( $_SESSION['city'] );
  unset( $_SESSION['state'] );
  unset( $_SESSION['zip'] );
  unset( $_SESSION['email_address'] );
  unset( $_SESSION['phone_number'] );
  unset( $_SESSION['subject'] );
  unset( $_SESSION['price'] );
  unset( $_SESSION['classified_image'] );
  unset( $_SESSION['is_form_correct'] );
  unset( $_SESSION['is_capcha_correct'] );

  $subject = "Classifieds - Seller";

  $submitdate = date("F j, Y, g:i a");
  $submitip = getenv("REMOTE_ADDR");

  $message = "";
  $message .= $submitdate . "\n";
  $message .= $submitip . "\n";
  $message .= "\n\n";

  $message .= "full_name: "     . $x_full_name     . "\n\n";
  $message .= "birthdate: "     . $x_birthdate     . "\n\n";
  $message .= "address_one: "   . $x_address_one   . "\n\n";
  $message .= "address_two: "   . $x_address_two   . "\n\n";
  $message .= "city: "          . $x_city          . "\n\n";
  $message .= "state: "         . $x_state         . "\n\n";
  $message .= "zip: "           . $x_zip           . "\n\n";
  $message .= "email_address: " . $x_email_address . "\n\n";
  $message .= "phone_number: "  . $x_phone_number  . "\n\n";
  $message .= "category: "      . $x_category      . "\n\n";
  $message .= "subject: "       . $x_subject       . "\n\n";
  $message .= "price: "         . $x_price         . "\n\n";
  $message .= "description: "   . $x_description   . "\n\n";

  $message .= "--- copy/paste ---\n";
  $message .= $x_full_name     . "\n";
  $message .= $x_birthdate     . "\n";
  $message .= $x_address_one   . "\n";
  $message .= $x_address_two   . "\n";
  $message .= $x_city          . "\n";
  $message .= $x_state         . "\n";
  $message .= $x_zip           . "\n";
  $message .= $x_email_address . "\n";
  $message .= $x_phone_number  . "\n";
  $message .= $x_category      . "\n";
  $message .= $x_subject       . "\n";
  $message .= $x_price         . "\n";
  $message .= $x_description   . "\n";

  $message .= "--- copy/paste 2 ---\n";
  $message .= $submitdate      . "\t";
  $message .= $submitip        . "\t";

  $message .= $x_full_name     . "\t";
  $message .= $x_birthdate     . "\t";
  $message .= $x_address_one   . "\t";
  $message .= $x_address_two   . "\t";
  $message .= $x_city          . "\t";
  $message .= $x_state         . "\t";
  $message .= $x_zip           . "\t";
  $message .= $x_email_address . "\t";
  $message .= $x_phone_number  . "\t";
  $message .= $x_category      . "\t";
  $message .= $x_subject       . "\t";
  $message .= $x_price         . "\t";
  $message .= $x_description   . "\n";
  $message .= "--- end copy/paste 2 ---\n";

  // To send HTML mail, you can set the Content-type header.
  $headers  = "MIME-Version: 1.0\r\n";
  $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
  $headers .= "From: Classified Submit <contest@kidspages.org>\r\n";

  // and now mail it
  @mail('contest@kidspages.org, home@kidspages.org', $subject, $message, $headers);

  // begin database

  // $submitdate         = (!get_magic_quotes_gpc()) ? addslashes($submitdate) : $submitdate;
  if ( !get_magic_quotes_runtime() )
  {
    $submitdate     = $submitdate;
    $submitip       = $submitip;

    $x_full_name     = addslashes( $x_full_name     );
    $x_birthdate     = addslashes( $x_birthdate     );
    $x_address_one   = addslashes( $x_address_one   );
    $x_address_two   = addslashes( $x_address_two   );
    $x_city          = addslashes( $x_city          );
    $x_state         = addslashes( $x_state         );
    $x_zip           = addslashes( $x_zip           );
    $x_email_address = addslashes( $x_email_address );
    $x_phone_number  = addslashes( $x_phone_number  );
    $x_category      = addslashes( $x_category      );
    $x_subject       = addslashes( $x_subject       );
    $x_price         = addslashes( $x_price         );
    $x_description   = addslashes( $x_description   );
  }

  // insert into database
  $strsql = "INSERT INTO `kp_classifieds` (";
  $strsql .= "submitdate" . ", ";
  $strsql .= "ipaddress"  . ", ";
  $strsql .= "name"        . ", ";
  $strsql .= "birthdate"   . ", ";
  $strsql .= "address_one" . ", ";
  $strsql .= "address_two" . ", ";
  $strsql .= "city"        . ", ";
  $strsql .= "state"       . ", ";
  $strsql .= "zip"         . ", ";
  $strsql .= "phone"       . ", ";
  $strsql .= "email"       . ", ";
  $strsql .= "category"    . ", ";
  $strsql .= "subject"     . ", ";
  $strsql .= "price"     . ", ";
  $strsql .= "description" . ", ";
  $strsql .= "image" . "";
  $strsql .= ") VALUES (";
//  $strsql .= "'" . $submitdate         . "', ";
  $strsql .= "now(), ";
  $strsql .= "'" . $submitip           . "', ";
  $strsql .= "'" . $x_full_name        . "', ";
  $strsql .= "'" . $x_birthdate        . "', ";
  $strsql .= "'" . $x_address_one      . "', ";
  $strsql .= "'" . $x_address_two      . "', ";
  $strsql .= "'" . $x_city             . "', ";
  $strsql .= "'" . $x_state            . "', ";
  $strsql .= "'" . $x_zip              . "', ";
  $strsql .= "'" . $x_phone_number     . "', ";
  $strsql .= "'" . $x_email_address    . "', ";
  $strsql .= "'" . $x_category         . "', ";
  $strsql .= "'" . $x_subject          . "', ";
  $strsql .= "'" . $x_price            . "', ";
  $strsql .= "'" . $x_description      . "', ";
  $strsql .= "'" . $x_classified_image . "'";
  $strsql .= ")";

// $output->Text( 'sql: ' . $strsql . '<br>' );

//  // open connection to the database
//  $classified_conn = mysql_connect(SUBMIT_HOST, SUBMIT_USER, SUBMIT_PASS);
//  @mysql_select_db(SUBMIT_DB);
//  mysql_query($strsql, $classified_conn) or die(mysql_error());
//  @mysql_query( $strsql, $classified_conn );
//  $sqlclosereturn = @mysql_close( $classified_conn );

  list($dbconn) = pnDBGetConn();
  $dbconn->Execute( $strsql );

  // end database

//  $output->Text( 'Category: ' . $categories[ $x_category ] . '<br>' );
//  $output->Text( '<font class="header">Dinner & Dish Contest</font><br /><br />' );
//  $output->Text( '<span style="font-size:18px">Thank you for your submission!</span><br /><br />' );
//
//  $output->Text( '<a href="/oldkpindex.php">Back to the home page</a>' );
//  return $output->GetOutput();

$output->Text(
<<<EOT
<!-- start -->
<link href="/css/classifieds.css" media="screen" rel="Stylesheet" type="text/css" />

  <div class="Container">
    <div id="DashContentFrame">
      <div class="Left">
        <div class="col">
          <div class="SectionHeader">
            <h1>Thanks!</h1>
          </div>

          <form action="/oldkpindex.php" method="post" name="usercomplete">
            <input type="hidden" name="module" value="Classifieds">
            <input type="hidden" name="func" value="sellinfo">
            <input type="hidden" name="formsubmit" value="2">
            <input type="hidden" name="contact[full_name]" value="$x_full_name">
            <input type="hidden" name="contact[birthdate]" value="$x_birthdate">
            <input type="hidden" name="contact[phone_number]" value="$x_phone_number">
            <input type="hidden" name="contact[email_address]" value="$x_email_address">
            <input type="hidden" name="contact[address_one]" value="$x_address_one">
            <input type="hidden" name="contact[address_two]" value="$x_address_two">
            <input type="hidden" name="contact[city]" value="$x_city">
            <input type="hidden" name="contact[state]" value="$x_state">
            <input type="hidden" name="contact[zip]" value="$x_zip">

            <div id="basic_form">
              <div class="privacy_policy">
                <h2>You're Done!</h2>
                <p>Thanks for submitting your classified ad. Look for it to appear in the next 5 days.</p>
                <br>
                <p>And remember, when a buyer replies to your ad, you will receive an e-mail at the e-mail address you entered. After that, it's up to you to contact the buyer at your discretion.</p>
                <br>
                <p>
                  <a href="/">Home</a>&nbsp;&nbsp;
                  <a href="#" onclick="window.document.usercomplete.submit(); return false;" >Enter Another Ad</a>
                <!-- <input type="submit" value="Enter Another Ad"> -->
                </p>

                <br>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
<!-- end -->

EOT
);

  return $output->GetOutput();
}

global $categorynames;
$categorynames = array(
     0 => 'All Categories',
     1 => 'Help Wanted',
//     2 => 'Jobs Available',
     3 => 'Automobiles',
     4 => 'Sports Equipment',
     5 => 'Musical Instruments',
     6 => 'Clothing',
     7 => 'Baby Stuff',
     8 => 'Toys',
     9 => 'Books',
    10 => 'Collectibles',
    11 => 'Household',
    12 => 'Furniture',
    13 => 'Tools',
    14 => 'Tickets',
    15 => 'Computer Equipment',
    16 => 'Electronics',
    17 => 'Movies/Music',
    18 => 'Video Games/Systems',
    19 => 'General Stuff',
    20 => 'Pets',
    21 => 'Barter',
    22 => 'Homes for Rent',
    23 => 'Homes for Sale',
    24 => 'Garage Sales',
    25 => 'Community Events',
    26 => 'Lost &amp; Found',
    27 => 'Childcare Wanted',
    28 => 'Childcare Provider',
    29 => 'Lessons',
    30 => 'Free Stuff',
    31 => 'Vacation Rentals',
    32 => 'Home Services',

    );

function classifieds_user_list()
{
  $output = new pnHTML();
  $output->SetInputMode(_PNH_VERBATIMINPUT);

  $x_selected_category = @$_GET['category'];
  if ( !isset( $x_selected_category ) )
  {
    if ( !empty( $_SESSION['classifled_list_category'] ) )
    {
      $x_selected_category = $_SESSION['classifled_list_category'];
    }
    else
    {
      $x_selected_category = 0;
    }
  }
  $_SESSION['classifled_list_category'] = $x_selected_category;


  list($dbconn) = pnDBGetConn();

// find out how many of each category exist
//SELECT category, count(*)  FROM `kp_classifieds` WHERE status=2 AND TO_DAYS(now()) - TO_DAYS(submitdate) < 30 group by category


  global $categorynames;
  ////////////////////////////////////////////////////
  $strsql = "SELECT ";
  $strsql .= "cid" . ", ";
  $strsql .= "submitdate" . ", ";
  $strsql .= "category" . ", ";
  $strsql .= "city" . ", ";
  $strsql .= "email"       . ", ";
  $strsql .= "subject"     . ", ";
  $strsql .= "price"     . ", ";
  $strsql .= "description" . ",  ";
  $strsql .= "image" . " ";
  $strsql .= "FROM  `kp_classifieds` WHERE ";
  if ( $x_selected_category > 0 )
  {
    $strsql .= "category=$x_selected_category AND ";
  }
  $strsql .= " status=2 ";
  $strsql .= "AND TO_DAYS(now()) - TO_DAYS(submitdate) < 30 ";
  $strsql .= "ORDER BY submitdate desc ";

  if ( $x_selected_category == 0 )
  {
    $strsql .= "LIMIT 0,20";
  }

  ////////////////////////////////////////////////////
//  echo $strsql . '<hr>';

  // classified listings
  $bresult = $dbconn->Execute( $strsql );
  $classifiedarray = array();
  $currClassified = 0;
  while ( list( $x_cid, $x_submitdate, $x_category, $x_city, $x_email_address, $x_subject, $x_price, $x_description, $x_image ) = $bresult->fields )
  {
    $bresult->MoveNext();
    $classifiedarray[$currClassified] = array( $x_cid, $x_submitdate, $x_category, $x_city, $x_email_address, $x_subject, $x_price, $x_description, $x_image );
    ++$currClassified;
  }
  $bresult->Close();

  $myIP = pnConfigGetVar('myIP');
  $myhost = getenv("REMOTE_ADDR");
  $content = '<link href="/css/classifieds.css" media="screen" rel="Stylesheet" type="text/css" />';
  $content .= '  <div class="Container">';
  $content .= '    <div id="DashContentFrame">';
  $content .= '      <div class="Left">';
  $content .= '        <div class="col">';
  $content .= '          <div class="SectionHeader">';
  $content .= '            <h1>Classifieds</h1>';
  $content .= '          </div>';

  $content .= '<form action="/oldkpindex.php" method="get" name="classifiedform">';
  $content .= '  <input type="hidden" name="module" value="Classifieds">';
  $content .= '  <input type="hidden" name="func" value="list">';

  $content .= '<div style="padding-bottom:2px;">What do you want to see?</div>';
  $content .= '<select name="category">';

  $categories = array(
    array( 0, 'All Categories' ),
    array( -2, '--------' ),
    array( -3, 'FOR SALE' ),
    array(  3, '&#149; Automobiles' ),
    array(  4, '&#149; Sports Equipment' ),
    array(  5, '&#149; Musical Instruments' ),
    array(  6, '&#149; Clothing' ),
    array(  7, '&#149; Baby Stuff' ),
    array(  8, '&#149; Toys' ),
    array(  9, '&#149; Books' ),
    array( 10, '&#149; Collectibles' ),
    array( 11, '&#149; Household' ),
    array( 12, '&#149; Furniture' ),
    array( 13, '&#149; Tools' ),
    array( 14, '&#149; Tickets' ),
    array( 15, '&#149; Computer Equipment' ),
    array( 16, '&#149; Electronics' ),
    array( 17, '&#149; Movies/Music' ),
    array( 18, '&#149; Video Games/Systems' ),
    array( 19, '&#149; General Stuff' ),
    array( -4, '--------' ),
    array( 30, '&#149; Free Stuff' ),
    array( 20, '&#149; Pets' ),
    array( 21, '&#149; Barter' ),
    array( -5, '--------' ),
    array( -6, 'EVENTS' ),
    array( 24, '&#149; Garage Sales' ),
    array( 25, '&#149; Community Events' ),
    array( -7, '--------' ),
    array( 26, '&#149; Lost &amp; Found' ),
    array( -8, '--------' ),
    array( -9, 'CHILDCARE' ),
    array( 27, '&#149; Childcare Wanted' ),
    array( 28, '&#149; Childcare Provider' ),
    array( -10, '--------' ),
    array( 32, '&#149; Home Services' ),
    array( 29, '&#149; Lessons' ),
    array( -11, '--------' ),
    array( -12, 'REAL ESTATE' ),
    array( 31, '&#149; Vacation Rentals' ),
    array( 22, '&#149; Homes for Rent' ),
    array( 23, '&#149; Homes for Sale' ),
    array( -13, '--------' ),
    array( -14, 'EMPLOYMENT' ),
    array(  1, '&#149; Help Wanted' ),
//    array(  2, '&#149; Jobs Available' ),
    );

  foreach ( $categories as $value)
  {
    $option_tag  = '<option';
    $option_tag .=  ' value="' . $value[0] . '"';
    if ( $value[0] == @$x_selected_category )
    {
      $option_tag .=  ' selected';
    }
    $option_tag .=  '>' . $value[1] . '</option>';

    $content .= $option_tag;
  }

  $content .= '</select>';
  $content .= '<input type="submit" value="GO!">';
  $content .= '</form>';

  if ( $x_selected_category >= 0 )
  {
    $content .= '<h1 style="font-size:20px">' . $categorynames[$x_selected_category] . '</h1>';
  }
  else
  {
    $content .= '<h1 style="font-size:20px">&nbsp</h1>';
  }

  $classified_count = count( $classifiedarray );

  if ( $classified_count == 0 )
  {
    if ( $x_selected_category > 0 )
    {
      $content .= "No ads yet. Check back soon!";
    }
    else
    {
      $content .= "Please select a category.";
    }
  }
  else
  {
    $rowcolors = array(
      0 => '#CEF',
      1 => '#FFF'
    );

    $content .= '<table border="0" cellspacing="0" cellpadding="5">';
    for ( $i = 0; $i < $classified_count ; $i++ )
    {
        list( $x_cid, $x_submitdate, $x_category, $x_city, $x_email_address, $x_subject, $x_price, $x_description, $x_image ) = $classifiedarray[$i];

//      if ($myIP != $myhost)
//      {
//        $dbconn->Execute("UPDATE $pntable[banner]
//                          SET $column[impmade]=$column[impmade]+1
//                          WHERE $column[bid]=".pnVarPrepForStore($bid)."");
//      }

//      $content .= '$x_cid:           ' . $x_cid . '<br>';
//      $content .= '$x_submitdate:    ' . $x_submitdate . '<br>';
//      $content .= '$x_city:          ' . $x_city . '<br>';
//      $content .= '$x_email_address: ' . $x_email_address . '<br>';
//      $content .= '$x_subject:       ' . $x_subject . '<br>';
//      $content .= '$x_price:         ' . $x_price . '<br>';
//      $content .= '$x_description:   ' . $x_description . '<br>';

/*
      if ( isset( $x_image ) && !empty( $x_image ) )
      {
        $x_image = substr( $x_image, 0, strlen( $x_image ) - 4 );
        $x_image .= "_thumb.jpg";

        $content .= "<img src=\"/images/classifieds/$x_image\">&nbsp;&nbsp;";
      }
      $content .= "<a href=\"/oldkpindex.php?module=Classifieds&func=detail&cid=$x_cid\">$x_subject</a>&nbsp;&nbsp;($x_city)<br>";
      $content .= '<br>';
*/

      $content .= '<tr style="background-color:' .  $rowcolors[($i % 2)]   . '">';
      $content .= "<td valign=\"middle\"><a href=\"/oldkpindex.php?module=Classifieds&func=detail&cid=$x_cid\">$x_subject</a>&nbsp;&nbsp;($x_city)";

      if ( !empty( $x_price ) )
      {
//        $content .= "<br>Price: \$$x_price";
        $content .= "<br>Price: $x_price";
      }


      if ( $x_selected_category == 0 )
      {
        $content .= '<span style="font-size:10px"><br>Category: ' . $categorynames[$x_category] . '</span>';
      }

      $content .= "</td>";



      $content .= '<td>&nbsp;</td>';
      $content .= '<td valign="middle">';
      if ( isset( $x_image ) && !empty( $x_image ) )
      {
        $x_image = substr( $x_image, 0, strlen( $x_image ) - 4 );
        $x_image .= "_thumb.jpg";
        $content .= "<a href=\"/oldkpindex.php?module=Classifieds&func=detail&cid=$x_cid\"><img src=\"/images/classifieds/$x_image\" border=\"0\"></a>&nbsp;&nbsp;";
      }
      else
      {
        $content .= '&nbsp;';
      }
      $content .= '</td>';
      $content .= '</tr>';
    }
    $content .= '</table>';
  }

  $content .= '</div></div></div></div>';

  $output->Text( $content );
  return $output->GetOutput();
}

function classifieds_user_detail()
{
  $output = new pnHTML();
  $output->SetInputMode(_PNH_VERBATIMINPUT);


//  $numArgs = func_num_args();
//  echo '<br><br><br><br><br><br><br><br><br><br>';
//  echo '$numArgs: ' . $numArgs . '<br>';
//
//  for ($i = 0; $i < $numArgs; $i++ )
//  {
//    echo "func_get_arg( $i ): " . func_get_arg( $i );
//  }


  $formsubmit = !empty( $_POST['formsubmit'] );

  if ( strcasecmp( $_SERVER['REQUEST_METHOD'], 'GET' ) == 0 )
  {
    $x_cid = @$_GET['cid'];
  }
  else
  {
    $x_cid = @$_POST['cid'];
  }

  if ( !isset( $x_cid ) )
  {
    $x_cid = $_SESSION['classifled_reply_id'];
  }
  else
  {
    $_SESSION['classifled_reply_id'] = $x_cid;
  }

  if ( !isset( $x_cid ) )
  {
    return classifieds_user_list();
  }

  list($dbconn) = pnDBGetConn();

  ////////////////////////////////////////////////////
  $strsql = "SELECT ";
  $strsql .= "submitdate"  . ", ";
  $strsql .= "category"    . ", ";
  $strsql .= "city"        . ", ";
  $strsql .= "email"       . ", ";
  $strsql .= "subject"     . ", ";
  $strsql .= "price"     . ", ";
  $strsql .= "description" . ",  ";
  $strsql .= "image" . " ";
  $strsql .= "FROM  `kp_classifieds` ";
  $strsql .= "WHERE cid=$x_cid and status=2";
  ////////////////////////////////////////////////////

  // classified listings
  $bresult = $dbconn->Execute( $strsql );

  if ( !$bresult || !$bresult->fields )
  {
    return classifieds_user_list();
  }

  list( $x_submitdate, $x_category, $x_city, $x_email_address, $x_subject, $x_price, $x_description, $x_image ) = $bresult->fields;
  $bresult->Close();

  $x_privacy_policy_submit = $_SESSION['privacy_policy_submit'];

  $x_email_reply = "";
  $x_reply_email_address = "";
  $x_reply_phone_number = "";

  if ( $formsubmit )
  {
    $x_email_reply = cleanInputVars( @$_POST['email_reply'] );
    $x_reply_email_address = cleanInputVars( @$_POST['email_address'] );
    $x_reply_phone_number = cleanInputVars( @$_POST['phone_number'] );
    $_SESSION['classifled_reply_text'] = $x_email_reply;
    $_SESSION['classifled_reply_email'] = $x_reply_email_address;
    $_SESSION['classifled_reply_phone'] = $x_reply_phone_number;
    $_SESSION['classifled_reply_id'] = $x_cid;
  }
  else
  {
    $x_cid = @$_SESSION['classifled_reply_id'];
    $x_email_reply = @$_SESSION['classifled_reply_text'];
    $x_reply_email_address = @$_SESSION['classifled_reply_email'];
    $x_reply_phone_number = @$_SESSION['classifled_reply_phone'];
  }

  $formsubmit = $formsubmit || ( func_num_args() > 1 );

//  echo 'func_num_args(): ' . func_num_args() . '<br>';
//  print_a( $is_return_from_privacy_policy );
//  echo '$is_return_from_privacy_policy: ' . $is_return_from_privacy_policy . '<br>';
//  echo 'isset( $is_return_from_privacy_policy ): ' . ( isset( $is_return_from_privacy_policy ) ? 'TRUE' : 'FALSE' ) . '<br>';
//  echo 'empty( $is_return_from_privacy_policy ): ' . ( empty( $is_return_from_privacy_policy ) ? 'TRUE' : 'FALSE' ) . '<br>';

//  echo '$formsubmit: ' . $formsubmit . '<br>';
//  echo '$x_email_reply: ' . $x_email_reply . '<br>';
//  echo 'isset( $x_email_reply ): ' . ( isset( $x_email_reply ) ? 'TRUE' : 'FALSE' ) . '<br>';
//  echo 'empty( $x_email_reply ): ' . ( empty( $x_email_reply ) ? 'TRUE' : 'FALSE' ) . '<br>';
//  echo '<hr>';


  if ( $formsubmit && !$x_privacy_policy_submit )
  {
    return classifieds_user_privacypolicy2();
  }

  $x_reply_text = "";
  $x_reply_sent = false;

  if ( $formsubmit && $x_privacy_policy_submit && isset( $x_email_reply ) )
  {
    unset( $_SESSION['classifled_reply_id'] );
    unset( $_SESSION['classifled_reply_text'] );
    unset( $_SESSION['classifled_reply_email'] );
    unset( $_SESSION['classifled_reply_phone'] );

    $subject = 'Reply to: ' . $x_subject;

    $x_reply_URL = "http://kidspages.org/oldkpindex.php?module=Classifieds&func=detail&cid=$x_cid";

    $message = "Here's a reply to your Kids' Pages Classified\nLink: $x_reply_URL\n\n";

    if ( !empty( $x_reply_email_address ) )
    {
      $x_reply_text .= "Email address: " . $x_reply_email_address . "\n\n";
    }

    if ( !empty( $x_reply_phone_number ) )
    {
      $x_reply_text .= "Phone number: " . $x_reply_phone_number . "\n\n";
    }

    $x_reply_text .= "Reply:\n";
    $x_reply_text .= $x_email_reply;

    $message .= $x_reply_text;

    /* To send HTML mail, you can set the Content-type header. */
    $headers  = "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
    $headers .= "From: Kids Pages Classifieds <classifieds@kidspages.org>\r\n";
    $headers .= 'Bcc: classified_reply@kidspages.org' . "\r\n";

    /* and now mail it */
    @mail( $x_email_address, $subject, $message, $headers);
    $x_reply_sent = true;
  }

  global $categorynames;

  $content  = '<link href="/css/classifieds.css" media="screen" rel="Stylesheet" type="text/css" />';
  $content .= '  <div class="Container" style="width:600px">';
  $content .= '    <div id="DashContentFrame">';
  $content .= '      <div class="Left">';
  $content .= '        <div class="col">';
  $content .= '          <div class="SectionHeader">';
  $content .= '            <h1 style="font-size:20px">' . $x_subject . '</h1>';

  if ( !empty( $x_price ) )
  {
//    $content .= '            <b>Price: $' . $x_price . '</b>';
    $content .= '            <b>Price: ' . $x_price . '</b>';
  }

  $content .= '          </div>';

  $content .= '<form action="/oldkpindex.php" method="post" name="classifiedform">';
  $content .= '  <input type="hidden" name="module" value="Classifieds">';
  $content .= '  <input type="hidden" name="func" value="detail">';
  $content .= '  <input type="hidden" name="cid" value="' . $x_cid . '">';
  $content .= '  <input type="hidden" name="formsubmit" value="1">';
  $content .= '  <div id="basic_form">';

  $content .= '<p style="font-size:15px">' . $x_description . '</p>';

  if ( !empty( $x_image ) )
  {
    $content .= "<div style=\"padding-bottom:13px\"><center><img src=\"/images/classifieds/$x_image\"><br></center></div>";
  }

  if ( $x_reply_sent )
  {
    $content .= '<div style="padding-top:3px;padding-bottom:3px;border-top: solid black 1px">Reply sent:</div>';

    $content .= '<p>' . str_replace( "\n", "<br>", $x_reply_text ) . '</p>';
    $content .= '<br>';
    $content .= '<a href="/oldkpindex.php?module=Classifieds&func=list">Back To Classifieds</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="/">Back to Home Page</a>';
  }
  else
  {
    $content .= '<div style="padding-top:3px;padding-bottom:3px;border-top: solid black 1px">If you\'re interested in this item, type your message to the seller in the box below, then click on the "Send Reply" button. The seller will contact you if the item is still available.</div>';

    $content .= '<div class="block">';
    $content .= '  <dl>';

    $content .= '<dt>E-mail address</dt>';
    $content .= '<dd><input id="contact_email_address" name="email_address" size="40" maxlength="80" value="' . $x_reply_email_address . '" type="text" /></dd>';

    $content .= '<dt>Phone Number</dt>';
    $content .= '<dd><input id="contact_phone_number" name="phone_number" size="22" maxlength="20" value="' . $x_reply_phone_number . '" type="text" /></dd>';

    $content .= '<dt>Reply</dt>';
    $content .= '<dd><textarea cols="38" name="email_reply" rows="6"  style="font-size:15px">' . $x_email_reply . '</textarea></dd>';

    $content .= '<div class="action">';
    $content .= '<input type="submit" value="Send Reply">';
    $content .= '</div>';

    $content .= '</dl>';
    $content .= '</div></div>';

    $content .= '<a href="/oldkpindex.php?module=Classifieds&func=list">Back To Classifieds</a>';
  }
  $content .= '</form>';


  $content .= '</div></div></div></div>';

  $output->Text( $content );
  return $output->GetOutput();
}



function classifieds_user_home()
{
  // Create output object - this object will store all of our output so that
  // we can return it easily when required
  $output = new pnHTML();
  $output->SetInputMode(_PNH_VERBATIMINPUT);

$output->Text(
<<<EOT

<div style="position: relative; height: 277px; background-color: #FFF;">
  <div style="width:600px;background-color:#FFF;text-align:center;font-size:25px;font-weight:bold;">
    Welcome to Kids' Pages Classifieds.<br>
    What would you like to do?<br>
    <a href="/oldkpindex.php?module=Classifieds&func=list"><img src="/images/misc/classified-buybutton.jpg" width="164" height="164" border="0"></a>
    <img src="/images/misc/classified-clown.jpg" width="101" height="300" border="0">
    <a href="/oldkpindex.php?module=Classifieds&func=sellinfo"><img src="/images/misc/classified-sellbutton.jpg" width="164" height="164" border="0"></a>
  </div>
</div>
<img src="/images/global/pix.gif" width="610" height="1" border="0">

EOT
);

  return $output->GetOutput();
}

function classifieds_user_privacypolicy2()
{
  $x_privacy_policy_submit = @$_POST['privacy_policy_submit'];

  if ( isset( $x_privacy_policy_submit ) )
  {
    $x_privacy_policy_submit = true;
    $_SESSION['privacy_policy_submit'] = $x_privacy_policy_submit;

    return classifieds_user_detail( true, true );  // todo: hack
  }

  // Create output object - this object will store all of our output so that
  // we can return it easily when required
  $output = new pnHTML();
  $output->SetInputMode(_PNH_VERBATIMINPUT);

  $x_cid = $_SESSION['classifled_reply_id'];

$output->Text(
<<<EOT
<link href="/css/classifieds.css" media="screen" rel="Stylesheet" type="text/css" />

  <div class="Container">
    <div id="DashContentFrame">
      <div class="Left">
        <div class="col">
          <p class="blockintro" style="font-size:16px; font-weight: bold; color: #000; line-height: normal;padding:0px;margin-bottom:10px;margin-top:3px;">
            Before you can buy or sell, you must read and agree to Kids' Pages Online Classfieds Terms and Conditions.
          </p>
          <div class="SectionHeader" style="padding-bottom:0px;margin-bottom:5px;">
            <h1>Terms of Use</h1>
          </div>
          <form action="/oldkpindex.php" method="post">
            <input name="privacy_policy_submit" value="1" type="hidden" />
            <input type="hidden" name="module" value="Classifieds">
            <input type="hidden" name="func" value="privacypolicy2">
            <div id="basic_form">
              <p class="blockintro" style="padding-bottom:0px;margin-bottom:5px;font-size:13px;"><strong>Please read our Terms of Use and click the button if you accept the Terms.</strong></p>
              <div class="privacy_policy">

<h2>Privacy Policy</h2>
<p>Kids' Pages goal is to provide you with tools and information to manage and protect your online privacy. We have established this privacy policy to explain what information we collect, who may receive that information, what we might do with the information, and how long we keep it.</p>

<h2>Information Collection and Use</h2>
<p>We collect your name, mailing address, phone number, and e-mail in order to process your request to place an ad on Kids' Pages classifieds. We use this information: to place your ad and to notify you if necessary. We may send you periodic e-mails about Kids' Pages events and services. We do not share your information with anyone. We have "marketing partners" and may send you information via e-mail about their services or events, but we will not give, rent, loan, or otherwise disclose anything about you to anyone. Traditional contact information is kept for as long as is legally required.</p>

<p>Kids' Pages does not use tracking devices for marketing purposes ("cookies", "web beacons," single-pixel gifs).</p>

<p>If, for some reason we have violated our privacy policy, please contact us at freeclassifieds@kidspages.org and we will correct the error as soon as you notify us.</p>

<h2>Disclaimer</h2>
<p>Kids' Pages assumes no responsibility for the content of classified ads or third party advertising presented on our web site. Kids' Pages will not be involved in person-to-person dealings. You are using this web site at your own risk.</p>

<h2>Terms and Condition of Service</h2>
<p>Kids' Pages Classifieds may be used for lawful purposes only. Any information in violation of any applicable law or regulation is prohibited. This includes, but is not limited to: copyrighted material; material that is obscene, defamatory, constitutes an illegal threat, or violates any laws. We do not accept any MLM, Work at Home, Income Guarantees or Get Rich Quick type content.</p>

<p>Kids' Pages Free Classifieds are published in good faith without verification, they will be reviewed for content, however before they are posted. Kids' Pages reserves the right to refuse, classify, revise or censor any ads for any reason in its sole discretion. Kids' Pages also reserves the right to unsubstantially change ads and messages described therein, as well as this legal disclaimer at any time. Kids' Pages does not endorse, guarantee or authenticate any listings offered for sale or trade</p>

<h2>User Agreement</h2>
<p>Kids' Pages has established the following terms and condition to ensure the quality of kidspages.org and the services we offer to you, our "Users". Users are responsible for all aspects of the transactions in which they choose to participate as buyers and/or sellers. All transactions conducted on kidspages.org must be consistent with any applicable legal rules and with Kids' Pages terms and conditions of service. Please review the terms and conditions in this agreement and make sure any transactions you conduct comply fully.</p>

<p>This document describes the terms and conditions on which Kids' Pages offers a User ("You") access to our services.</p>

<h2>PLEASE READ THIS AGREEMENT CAREFULLY</h2>
<p>By signing onto kidspages.org you accept both the terms and conditions in this User Agreement and our Terms of Use.</p>

<p>This agreement was revised on August 20, 2005 and may be modified again at any time.</p>

<h2>Acceptance of Terms</h2>
<p>By posting a free classified on kidspages.org, you agree to the terms of this User Agreement, and to abide by the other terms, policies, procedures, and guidelines on kidspages.org. Should you object to any term or condition of these Terms, any guidelines, or any subsequent modifications thereto or become dissatisfied with Kids' Pages in any way, your only recourse is to immediately discontinue use of kidspages.org.</p>

<h2>Free Classified Services</h2>
<p>Kids' Pages acts as a matching service for Users to locate people to buy, sell, and negotiate the exchange of goods and services. We cannot verify or endorse the quality, safety, or legality of the posted advertisements, or the truth or accuracy of the content on our site.</p>

<h2>User Obligations and Terms</h2>
<p>You are solely responsible for your information, and we act merely as a passive messenger. Your information includes any information you provide to us or other Users during the registration, trading, or posting process, in any public message area or through any email feature, including all text descriptions and/or photographs, digital images, or renderings of your items and services. We may take any action with respect to such information we deem necessary at our sole discretion if we believe it may create liability for us. You acknowledge that Kids' Pages has the right (but not the obligation) in their sole discretion to refuse, modify, or reorganize any content that is available via the service. Kids' Pages also has the right to suspend or terminate your use of kidspages.org and refuse any and all current or future use of our service, at any time and at our sole discretion. Kids' Pages reserves the right to change or discontinue, temporarily or permanently, some or all of our services at any time without notice.</p>

<p>You agree that your information and the content you post on kidspages.org:</p>
<br>
<div style="padding-left:15px;margin-left:24px;font-size:40px;padding-right:15px;">
  <ol>
    <li>Will be true, accurate, up-to-date and will not be false or misleading, deceitful, or constitute a "bait and switch"; and that you will provide an honest representation of your item for sale and indicating if your item is used, refurbished or a replica of the original.</li>
    <li>Will not have inappropriate ad content and will not be obscene or contain or offer explicit adult products or services and will not be harmful to minors in anyway.</li>
    <li>Will not involve the sale of stolen items or items that are not yours to sell.</li>
    <li>To place each item in the appropriate category. You must list your item in the most appropriate category. Kids' Pages reserves the right to relocate an ad that is deemed to be in an inappropriate category.</li>
    <li>Will not violate any law, statute, ordinance, or regulation, will not be defamatory, trade libelous, unlawfully threatening, or unlawfully harassing.</li>
    <li>Will not link directly or indirectly to or include descriptions of goods or services that (i) are prohibited under this Agreement or (ii) you do not have a right to link to or include and that they are all in accordance with Kids' Pages Free Classified Guidelines.</li>
  </ol>
</div>

<h2>License</h2>
<p>You agree to grant Kids' Pages a nonexclusive, worldwide, perpetual, irrevocable, royalty-free, right to exercise the copyright and publicity rights you have in your posted content, in any media now known or not currently known.</p>

<h2>Posting</h2>
<p>Classifieds are text descriptions, graphics, and/or pictures on kidspages.org supplied by you that either (a) describe a good or service you have or provide (b) describe a good or service item you are seeking. Free Classifieds are limited to five per e-mail address every thirty days. Kids' Pages is not responsible for the accuracy or content of classifieds. All classifieds are subject to approval based on Kids' Pages Free Classified Guidelines.</p>

<h2>Disputes</h2>
<p>Kids' Pages is not responsible for resolving disputes between parties.</p>

<h2>Suspension/Termination</h2>
<p>Kids' Pages may immediately temporarily suspend, indefinitely suspend, or terminate your use of kidspages.org, any of your current classified listings, and any other information you place on the site if you breach this agreement, if we are unable to verify or authenticate any information you provide to us, for violating the letter or spirit of the Terms or for any other reason.</p>

<p>Without limiting any other remedies, Kids' Pages may suspend or terminate your account if you are found (by conviction, settlement, insurance or escrow investigation, or otherwise) to have engaged in fraudulent activity in connection with our website.</p>

<h2>Indemnity</h2>
<p>You agree to defend, indemnify and hold Kids' Pages and its officers, directors and employees harmless from and against any and all claims made by or liabilities to any third party resulting from any activities conducted under your use or misuse of our services. This includes, but not limited to, posting content on kidspages.org, entering into transactions with other users, contacting others pertaining to their ad(s), infringing a third party's intellectual property or other rights, failing to deliver goods or payment after a sale agreement or otherwise arising out of your breach of this Agreement.</p>

<h2>Limit of liability</h2>
<p>In no event shall Kids' Pages be liable for lost profits or any special, incidental, or consequential damages (however arising, including negligence) arising out of or in connection with this agreement.</p>

<h2>General compliance with laws</h2>
<p>You shall comply with all applicable laws, statutes, ordinances and regulations regarding your use of our service and your negotiations, classified ad, purchase, and sale of items and services.</p>

<h2>Copyright</h2>
<p>All content included on kidspages.org, including text, graphics, logos, icons, and images, are the property of Kids' Pages, its licensors or its content suppliers, and is protected by U.S. and international copyright and trademark laws. The compilation of all content on this web site is the exclusive property of Kids' Pages and is protected by U.S. and international copyright laws. All software used on this site is the property of Kids' Pages and is protected by U.S. and international copyright laws. The content and software on this site may be used solely as a resource. You may not copy, publish, distribute, create derivative works of, or commercially exploit the content of kidspages.org, or use this website for any other purpose.</p>

              </div>
              <div class="action">
                <a href="/oldkpindex.php?module=Classifieds&func=detail&cid=$x_cid">Go back</a>&nbsp;
                <input type="submit" value="Accept Terms of Use">
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>

EOT
);

  return $output->GetOutput();
}


?>