Topic: contact with captcha.

im working on a contact.php with captcha mod for it.
i got it displaying the captcha box and u can input it. and even on refresh it changes the code.
but the issue im running in to is when you submit u can do it without the captcha
i'm using the another pun captcha mod in my site for the register.php
can some one HELP ME?

Q
here is my code

<?php
define('PUN_ROOT', './');
define('PUN_QUIET_VISIT', 1);
require PUN_ROOT.'include/common.php';
$page_title = pun_htmlspecialchars($pun_config['o_board_title']) . ' / Contact';        //Set the page title here
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
require PUN_ROOT.'include/parser.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/prof_reg.php';
session_start();
//echo "<PRE>"; print_r ($pun_config); echo "</PRE>";

if ($_POST[form_sent] == 1) {
//Process The Form


?>

<?php
    $recipient = "$toName <".$toMail.">";
    $headers ="From: ".$_POST[name]." <".$_POST[email].">";
    $subject = "WEBFORM:".$_POST[subject];
    $message = str_replace("\\", "", $_POST[comments]);
    mail($pun_config['o_admin_email'], $subject, $message, $headers);
    if( ($_SESSION['security_code'] != $_POST['security_code']) || empty($_SESSION['security_code'] ) ) {
                
            message($lang_prof_reg['Bad security code']);
       }
?>


<div class="blockform">
    <h2><span>Contact <?php echo $pun_config['o_board_title']; ?></span></h2>
    <div class="box">
        <form id="contact" method="post" action="contact.php">
            <div class="inform">
                <fieldset>
                    <legend>Email Sent</legend>
                    <div class="infldset">
                        <b>Thank you for contacting us!</b> The following information was sent to <?php echo $pun_config['o_board_title']; ?>.<br /><br />
                        <label>Name:<br /><?php echo $_POST[name]; ?><br /></label>
                        <label>Email:<br /><?php echo $_POST[email]; ?><br /></label>
                        <label>Subject:<br /><?php echo $_POST[subject]; ?><br /></label>
                        <label>Comments:<br /><?php echo $_POST[comments]; ?><br /></label>
                    </div>
                </fieldset>
            </div>
        </form>
    </div>
</div>

<?php } else { 
//Display the Form
?>

<div class="blockform">
    <h2><span>Contact <?php echo $pun_config['o_board_title']; ?></span></h2>
    <div class="box">
        <form id="contact" method="post" action="contact.php">
            <div class="inform">
                <fieldset>
                    <legend>Enter your contact details</legend>
                    <div class="infldset">
                        Please enter your contact information and comments here. If you would like to share your comments with everyone, consider posting them on the <a href="forum.php">forum</a> instead!<br />
                        <input type="hidden" name="form_sent" value="1" /><br />
                        <label>Name<br /><input type="text" name="name" value="" size="40" maxlength="40" /><br /></label>
                        <label>Email<br /><input type="text" name="email" value="" size="40" maxlength="50" /><br /></label>
                        <label>Subject<br /><input type="text" name="subject" value="" size="40" maxlength="50" /><br /></label>
                        <label>Comments<br /><textarea name="comments" rows="5" cols="40"></textarea><br /></label>
                    </div>
                </fieldset>
            </div>
            <div class="inform">
                <fieldset>
                    <legend><?php echo $lang_prof_reg['Security code legend'] ?></legend>
                    <div class="infldset">
                        <p><img src="captcha/CaptchaSecurityImages.php?width=100&height=40&characters=5" /></p>
                        <div class="rbox">
                            <label><input id="security_code" name="security_code" type="text" /></label>
                        </div>
                    </div>
                </fieldset>
            </div>
            <p><input type="submit" name="update" value="Submit" /></p>
        </form>
    </div>
</div>



<?php
}    //close if statement
require PUN_ROOT.'footer.php';
My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

Re: contact with captcha.

where do you populate $_SESSION['security_code'] all i see is session_start();
I think that is the fault.

See my Links.php with captcha

<?php
session_start('result');
define('PUN_ROOT', './');
define('PUN_MAIN', 1);
@include PUN_ROOT.'config.php';
require PUN_ROOT.'include/common.php';
require PUN_ROOT.'include/email.php';
require_once PUN_ROOT."lang/".$pun_user['language']."/Links_with_category.php";
// title
$page_title = pun_htmlspecialchars( $pun_config['o_board_title'] ).' / 
              '.$lang_links['page_title'];
require PUN_ROOT.'header.php';
// here is the path where the images are
$path = PUN_ROOT."img/Links"; // without the trailing slash
/**
*        Mod title:  Links with category's
*          @author:  daniel rokven (rokven [at] gmail.com / http://kierownik.nl)
**/
error_reporting(E_ALL);
if ( isset( $_GET['id'] ) && intval( $_GET['id'] ) ) {
  $id = intval( $_GET['id'] );
  $id_check = $db->query('SELECT
                            `id`
                          FROM
                            '.$db->prefix.'links_links
                          WHERE
                            `id` = '.$id.'
                         ') or error('Unable select the link 
                         '. print_r($db->error()),__FILE__, __LINE__, $db->error());
  $numrows = $db->num_rows( $id_check );
  if ( $numrows < 1 ) {
    message( $lang_links['not a valid id'] );
  }
  $db->query('UPDATE
                '.$db->prefix.'links_links
              SET
                `hits` = `hits` + 1
              WHERE
                `id` = '.$id.'
           ') or error('Unable to update the hits 
           '. print_r($db->error()),__FILE__, __LINE__, $db->error());
  $query = $db->query('SELECT
                         `url`
                       FROM
                         '.$db->prefix.'links_links
                       WHERE
                         `id` = '.$id.'
                      ') or error('Unable select the link 
                      '. print_r($db->error()),__FILE__, __LINE__, $db->error());
  $link = $db->fetch_assoc( $query );
  $url = $link['url'];
  $url = str_replace('&', '&', $url);
  $url = str_replace('%3A', ':', $url);
  $url = str_replace('%2F', '/', $url);
  header("Location: ".$url."");
  exit();
}
if ( isset( $_GET['new_link'] ) ) {
  $_SERVER['REQUEST_URI'] = str_replace( '?new_link', '', $_SERVER['REQUEST_URI'] );
}
if ( isset( $_GET['id'] ) ) {
  $_SERVER['REQUEST_URI'] = str_replace( '?id='.$_GET['id'].'', '', $_SERVER['REQUEST_URI'] );
}
if ( isset( $_GET['statistics'] ) ) {
  $_SERVER['REQUEST_URI'] = str_replace('?statistics', '',$_SERVER['REQUEST_URI']);
}
if ( isset( $_GET['stats_all_by_link'] ) ) {
  $_SERVER['REQUEST_URI'] = str_replace('&stats_all_by_link', '',$_SERVER['REQUEST_URI']);
}
if ( isset( $_GET['stats_by_category_by_link'] ) ) {
  $_SERVER['REQUEST_URI'] = str_replace('&stats_by_category_by_link', '',$_SERVER['REQUEST_URI']);
}
if ( isset( $_GET['stats_by_category_total'] ) ) {
  $_SERVER['REQUEST_URI'] = str_replace('&stats_by_category_total', '',$_SERVER['REQUEST_URI']);
}
if ( $pun_config['o_links_captcha'] == '1' ) {
  function captcha()
  {
    global $lang_links;
    // Function demands a started session, check here if the session is started
    if ( session_id() == '' ) {
      message( $lang_links['captcha not started'] );
    }
    $numbers       = array( 0 => "".$lang_links['zero']."",
                            1 => "".$lang_links['one']."",
                            2 => "".$lang_links['two']."",
                            3 => "".$lang_links['three']."",
                            4 => "".$lang_links['four']."",
                            5 => "".$lang_links['five']."",
                            6 => "".$lang_links['six']."",
                            7 => "".$lang_links['seven']."",
                            8 => "".$lang_links['eight']."",
                            9 => "".$lang_links['nine']."",
                           10 => "".$lang_links['ten'].""
                          );
    $possibilities = array(
                      array("dummy", "dummy"),
                      array("+", "".$lang_links['plus'].""),
                      array("-", "".$lang_links['minus'].""),
                      array("*", "".$lang_links['times']."")
                          );
    // Het eerste getal van de rekensom (random)
    $first  = rand( 1,count( $numbers )-1 );
    $second = rand( 1,count( $possibilities )-1 );
    $third  = rand( 1,count( $numbers )-2 );
      if ( ( $first <= $third ) ) {
        $first = '10';
      }
    $firstInt = $first;
    $secondInt = $possibilities[$second][0];
    $thirdInt = $third;

    $firstText = $numbers[$first];
    $secondText = $possibilities[$second][1];
    $thirdText = $numbers[$third];

    $tmpResult = '$result = '.$firstInt.$secondInt.$thirdInt.';';
    eval($tmpResult);
    // Set the session
    $_SESSION['result'] = $result;
    // return the captcha to the user
    return $lang_links['what_is']." 
          ".$firstText." 
          ".$secondText." 
          ".$thirdText."?*";
  }
}

// if the insert button is hit, insert the link here
if ( isset( $_POST['insert'] ) ) {
  // check here if anybody may post a link, if not show message
  if ( $pun_config['o_links_guest_posts'] == '0' ) {
    message( $lang_links['error_no_post'] );
  }
  $category = intval($_POST['category']);
  $name        = $db->escape($_POST['name']);
  $url      = $db->escape($_POST['url']);
  // if the name of the link is empty show message
  if ( $name == '' OR strlen( $name ) > 50 ) { 
    message( ''.$lang_links['error_name'].'' );
  }
  if ( $url == 'http://' OR strlen( $url ) > 255) { 
    message( ''.$lang_links['error_url'].'' );
  }
  // if the link is empty show message
  if ( !preg_match( "/^[a-zA-z0-9:\/\.\-\?&_=]+$/",$url ) ) {
    message(''.$lang_links['error_url'].'');
  }
  // check if the category id exists
  $get_category = $db->query('SELECT
                                `id`
                              FROM
                                `'.$db->prefix.'links_category`
                              WHERE
                                `id` = '.$category.'
                             ') or error('Unable to get the category 
                             '. print_r($db->error()),__FILE__, __LINE__, $db->error());
  $num_cats = $db->num_rows( $get_category );
  if ( $num_cats < 1 ) {
   message( $lang_links['not existing category'] );
  }
  if ( $pun_config['o_links_captcha'] == '1' )    {
    // if the captcha is on and it was not correct show message
    if ( $_POST['captcha'] != $_SESSION['result'] ) {
      message( ''.$lang_links['error_captcha'].'' );
    }
  }
  if ( $pun_config['o_links_approve'] == '1' ) {
    $show   = '1';
    $target = '_blank';
  } else {
    $show   = '0';
    $target = '';
  }
  $url       = str_replace('&', '&',     $url);
  $url       = str_replace('&',     '&', $url);
  $db->query("INSERT INTO 
                `".$db->prefix."links_links`
                (`name`,
                 `url`,
                 `category`,
                 `target`,
                 `added`,
                 `show`)
              VALUES
                ('".$name."',
                 '".$url."',
                 '".$category."',
                 '".$target."',
                 '".time()."',
                 '".$show."')
          ") or error('Unable to insert the links 
          '. print_r($db->error()),__FILE__, __LINE__, $db->error());

  // if the webmaster wants an email when a link is inserted then send it here
  if ( $pun_config['o_links_send_mail'] == '1' ) {
    $get_category = $db->query('SELECT
                                  `category`
                                FROM
                                  `'.$db->prefix.'links_category`
                                WHERE
                                  `id` = '.$category.'
                               ') or error('Unable to get the category 
                               '. print_r($db->error()),__FILE__, __LINE__, $db->error());
    $link_category = $db->fetch_assoc($get_category);
    $admin_mail    = $pun_config['o_webmaster_email'];
    $subject       = $lang_links['new_link_posted'].'
                    '.$pun_config['o_board_title'].'';
    $message       = $lang_links['mail_message']."\n";
    $message      .= $lang_links['link_name'].' : '.$name.''."\n";
    $message      .= $lang_links['link_url'].' : '.$url.''."\n";
    $message      .= $lang_links['category'].' : '.$link_category['category'].''."\n";
    $message      .= $lang_links['mail_message_2'].' : '.$pun_config['o_base_url'].'';
    pun_mail( $admin_mail, $subject, $message, pun_htmlspecialchars( $pun_config['o_board_title'] ) );
  }
  $updated = true;

  if ( $updated ) { 
    // Regenerate the config cache
    require_once PUN_ROOT.'include/cache.php';
    generate_config_cache();
    $redirect = str_replace("?new_link", "", $_SERVER['REQUEST_URI']);
    redirect($redirect, $lang_links['link_saved']);
  }

} elseif ( isset( $_GET['new_link'] ) ) {
  // check here if anybody may post a link, if not show message
  if ( $pun_config['o_links_guest_posts'] == '0' ) {
    message( $lang_links['error_no_post'] );
  }
  if ( $pun_config['o_links_captcha'] == '1' ) {
      if ( session_id() == '' ) {
        message( $lang_links['captcha not started'] );
      }
  }
  ?>
    <div id="links">
<div class="blockform">
  <h2><?php echo $lang_links['add_new_link']; ?></h2>
  <div class="box">
    <div class="inbox">
      <form id="new_link" method="post" action="<?php echo $_SERVER['REQUEST_URI'] ?>">
        <fieldset>
          <legend><?php echo $lang_links['add_new_link']; ?></legend>
            <label for="name">
              <?php echo $lang_links['link_name']; ?>*
            </label>
              <input id="name" type="text" name="name" maxlength="50" /><br />
            <label for="url">
              <?php echo $lang_links['link_url']; ?>*
            </label>
              <input id="url" type="text" name="url" maxlength="255" value="http://"
                /><br />
              <label for="category"><?php echo $lang_links['category']; ?></label>
              <select id="category" name="category">
                <?php
                  $query = $db->query('SELECT
                                         `id`, `category`
                                       FROM
                                         `'.$db->prefix.'links_category`
                                       ORDER BY
                                         `category`
                                         ASC
                                      ') or error('Unable to fetch category list
                                      ', __FILE__, __LINE__, $db->error());
                  while ( $data = $db->fetch_assoc( $query ) ) {
                    echo '<option value="'.$data['id'].'">'.pun_htmlspecialchars( $data['category'] ).'</option>';
                  }
                ?>
              </select>
              <?php
                if ( $pun_config['o_links_captcha'] == '1' ) {
                  echo ('<label for="captcha">'.captcha().'<br /><input id="captcha"
                          type="text" name="captcha" maxlength="80" /></label>');
                }
              ?>
              <label id="required" for="required"><?php echo '*<strong>'.$lang_links['required'].'</strong>'; ?></label>
              <label id="info" for="info"><?php echo $lang_links['add_new_link_info']; ?></label><br />
          </fieldset>
          <p><input type="submit" name="insert" value="<?php echo $lang_links['add_link']; ?>"/></p>
        </form>
      </div> <!-- end class inbox -->
    </div> <!-- end class box -->
  </div> <!-- end class blockform -->
</div> <!-- end id=Links -->
  <?php
} elseif ( isset( $_GET['statistics'] ) ) {
  if ( $pun_config['o_links_show_stats'] == '0' ) {
    message( ''.$lang_links['not see stats'].'' );
  }
  ?>
  <br />
  <div class="blockform">
    <h2>Clicks statistics</h2>
      <div class="box"><p style="padding-left: 15px;">
        <a href="<?php echo $_SERVER['REQUEST_URI'].'?statistics&stats_by_category_by_link' ?>"><?php echo $lang_links['By Category By Link'] ?></a> | <a href="<?php echo $_SERVER['REQUEST_URI'].'?statistics&stats_by_category_total' ?>"><?php echo $lang_links['By Category Total'] ?></a> | <a href="<?php echo $_SERVER['REQUEST_URI'].'?statistics&stats_all_by_link' ?>"><?php echo $lang_links['all links'] ?></a>
        </p></div>
  </div>
<?php
if ( isset( $_GET['stats_by_category_by_link'] ) ) {
        include "libchart/libchart.php";
    function php4_scandir($dir,$listDirectories=false, $skipDots=true) {
      $dirArray = array();
      if ($handle = opendir($dir)) {
        while (false !== ($file = readdir($handle))) {
          if ($file != "." && $file != ".." || $skipDots == false) {
            #added the $dir. in this line
            if($listDirectories == false && is_dir($dir.$file)) { continue; }
              array_push($dirArray,basename($file));
          }
        }
        closedir($handle);
      }
      return $dirArray;
    }
    $file_height = '';
  ?>
  <br />
  <div class="blockform">
    <h2>Clicks statistics</h2>
      <div class="box" style="padding-left: 15px;"><br style="clear: both;" />
  <?php
  $fetch_category = $db->query("SELECT
                                  `id`, `category`
                                FROM
                                  `".$db->prefix."links_category`
                                ") or error( 'Unable to fetch category list
                                ', __FILE__, __LINE__, $db->error() );
  $i = 1;
  while ( $data = $db->fetch_assoc( $fetch_category) ) {
    $select_links = $db->query("SELECT
                                  `name`,
                                  `hits`
                                FROM
                                  `".$db->prefix."links_links`
                                WHERE
                                  `category` = ".$data['id']."
                                AND
                                  `show` = 1
                                ") or error( 'Unable to fetch category list
                                ', __FILE__, __LINE__, $db->error() );
    $numrows = $db->num_rows( $select_links );
    $category = $data['category'];
    if ( $numrows < 10 ) {
      $height_chart = $numrows * 50;
    } else {
      $height_chart = $numrows * 20;
    }
    if ( $height_chart < 100 ) {
      $height_chart = 100;
    }
    $chart = new HorizontalChart(500, $height_chart);
    $dir =  php4_scandir( 'libchart/generated/stats_by_category_by_link/' );
    foreach ( $dir as $file ) {
      $file_array = getimagesize('libchart/generated/stats_by_category_by_link/'.$file);
      if ( $file_height == '' ) {
        $file_height = $file_array['1'];
      } elseif ( $file_array['1'] > $file_height ) {
        $file_height = $file_array['1'];
      }
    }
    $height = ( $file_height / ( 500 / 150 ) ) + 20;
    while ( $data = $db->fetch_assoc( $select_links ) ) {
      $chart->addPoint(new Point("".$data['name']."", $data['hits']));
    }
    $category_name = pun_htmlspecialchars( $category );
    $chart->setTitle("".$category."");
    if ( !function_exists( 'clean_image_name' ) )
    {
      function clean_image_name($text)
      {
        $text=strtolower($text);
        $code_entities_match = array(' ','--','"','!','@','#','$','%','^','&','*','(',')','_','+','{','}','|',':','"','<','>','?','[',']','\\',';',"'",',','.','/','*','+','~','`','=');
        $code_entities_replace = array('-','-','','','','','','','','','','','','','','','','','','','','','','','','');
        $text = str_replace($code_entities_match, $code_entities_replace, $text);
        return $text;
      }
    }
    $image_name = clean_image_name( $category );
    $chart->render("libchart/generated/stats_by_category_by_link/".$image_name."_".$i.".png");
    echo '<p style="text-align: center; padding: 3px; height: '.$height.'px; float: left;">';
    echo $category_name.'<br />';
    ?>
    <a href="<?php echo PUN_ROOT.'libchart/generated/stats_by_category_by_link/'.$image_name.'_'.$i ?>.png" class="highslide" onclick="return hs.expand(this)">
    <img alt="Horizontal bars chart" src="libchart/generated/stats_by_category_by_link/<?php echo $image_name.'_'.$i ?>.png" style="width: 150px; border: 1px solid gray;"/>
    </a>
    </p>
    <?php
    $i++;
  }
  ?>
  <div class="clearer"></div>
  <div class='highslide-caption' id='the-caption'>
    <a href="#" onclick="return hs.previous(this)" class="control" style="float:left; display: block">
      Previous
      <br/>
      <small style="font-weight: normal; text-transform: none">left arrow key</small>
    </a>
    <a href="#" onclick="return hs.next(this)" class="control" style="float:left; display: block; text-align: right; margin-left: 50px">
      Next<br/>
      <small style="font-weight: normal; text-transform: none">right arrow key</small>
    </a>
    <a href="#" onclick="return hs.close(this)" class="control">Close</a>
    <a href="#" class="highslide-move control">Move</a>
    <div style="clear:both"></div>
  </div>
  </div></div>
  <?php
} // end clicks all per link

if ( isset( $_GET['stats_by_category_total'] ) ) {
        include "libchart/libchart.php";
  ?>
  <br />
  <div class="blockform">
    <h2>Clicks statistics</h2>
      <div class="box">
  <?php
  $fetch_category = $db->query("SELECT
                                  `id`, `category`
                                FROM
                                  `".$db->prefix."links_category`
                                ORDER BY
                                  `category`
                                  DESC
                                ") or error( 'Unable to fetch category list
                                ', __FILE__, __LINE__, $db->error() );
  $numrows = $db->num_rows( $fetch_category );
  if ( $numrows < 10 ) {
    $height_chart = $numrows * 50;
  } else {
    $height_chart = $numrows * 20;
  }
  if ( $height_chart < 100 ) {
    $height_chart = 100;
  }
  $chart = new HorizontalChart(500, $height_chart);
  while ( $data_category = $db->fetch_assoc( $fetch_category) ) {    
    $select_links = $db->query("SELECT
                                  `show`,
                                  sum(hits) as hits,
                                  `category`
                                FROM
                                  `".$db->prefix."links_links`
                                WHERE
                                  `show` = 1
                                AND
                                  `category` = ".$data_category['id']."
                                GROUP BY
                                  `category`
                                ORDER BY
                                  `hits`
                                  DESC
                                ") or error( 'Unable to fetch category list
                                ', __FILE__, __LINE__, $db->error() );

    while ( $data1 = $db->fetch_assoc( $select_links ) ) {
      $chart->addPoint(new Point("".$data_category['category']."", $data1['hits']));
    }
  }
        $chart->setTitle("Which category is the most popular");
        $chart->render("libchart/generated/stats_by_category_total/stats_by_category_total.png");
  ?>
        <p style="text-align: center;">
          <img alt="Horizontal bars chart"  src="libchart/generated/stats_by_category_total/stats_by_category_total.png" style="border: 1px solid gray;"/>
        </p>
      </div>
    </div>
  <?php
} // end clicks per category total

if ( isset( $_GET['stats_all_by_link'] ) ) {
        include "libchart/libchart.php";
  ?>
  <br />
  <div class="blockform">
    <h2>Clicks statistics</h2>
      <div class="box">
  <?php
  $fetch_categories = $db->query("SELECT
                                    `name`, `hits`
                                  FROM
                                    `".$db->prefix."links_links`
                                  ORDER BY
                                    `hits`
                                    ASC
                                  ") or error( 'Unable to fetch category list
                                  ', __FILE__, __LINE__, $db->error() );
  $numrows = $db->num_rows( $fetch_categories );
  if ( $numrows < 10 ) {
    $height_chart = $numrows * 50;
  } else {
    $height_chart = $numrows * 15;
  }
                $chart = new HorizontalChart(500, $height_chart);
  while ( $data = $db->fetch_assoc( $fetch_categories ) ) {
    $chart->addPoint(new Point("".$data['name']."", $data['hits']));
  }
        $chart->setTitle("Which link is the most popular");
        $chart->render("libchart/generated/stats_all_by_link/stats_all.png");
  ?>
        <p style="text-align: center;">
          <img alt="Horizontal bars chart"  src="libchart/generated/stats_all_by_link/stats_all.png" style="border: 1px solid gray;"/>
        </p>
      </div>
    </div>
  <?php
} // end $_GET['stats_all_by_link']
} // end $_GET['click_statistics']


 else {
  ?>
    <div id="links">
  <?php
  if ( $pun_config['o_links_hits_count'] == '1' ) {
    $count_hits = true;
  } else {
    $count_hits = false;
  }
  if ( $pun_user['g_id'] == PUN_ADMIN ) {
    $admin = true;
  } else {
    $admin = false;
  }
  for ( $i = 1; $i < 5; $i++ ) {
    // select all category in column $i
    $query = $db->query('SELECT
                           `id`, `category`, `height`, `image`, `order`, `column`
                         FROM 
                            `'.$db->prefix.'links_category`
                          WHERE
                            `column` = "'.$i.'"
                          ORDER BY 
                            `height`
                            DESC
                          ') or error('Unable to fetch all the category\'s 
                          '. print_r($db->error()),__FILE__, __LINE__, $db->error());
    $numRows = $db->num_rows( $query );
    echo "\t".'<div class="links_column_'.$i.'">';
    if ( $numRows == '' ) {
      echo " ";
    }
    $last_column = '';
    while ( $cat = $db->fetch_assoc( $query ) ) {
    $cat_name = pun_htmlspecialchars( $cat['category'] );
      if ( !empty( $cat['order'] ) ) {
        if ( $cat['order'] == '1' ) {
          $order = 'name';
          $dir   = 'ASC';
        } elseif ( $cat['order'] == '2' ) {
          $order = 'name';
          $dir   = 'DESC';
        } elseif ( $cat['order'] == '3' ) {
          $order = 'added';
          $dir   = 'ASC';
        } elseif ( $cat['order'] == '4' ) {
          $order = 'added';
          $dir   = 'DESC';
        } elseif ( $cat['order'] == '5' ) {
          $order = 'hits';
          $dir   = 'ASC';
        } elseif ( $cat['order'] == '6' ) {
          $order = 'hits';
          $dir   = 'DESC';
        }         
      } else {
        $order = 'name';
        $dir   = 'ASC';
      }
      if ( !empty( $cat['image'] ) ) {
        $cat_image = '<img src="'.$path.'/'.$cat['image'].'" alt="'.$cat['image'].'" />';
      } else {
        $cat_image = '';
      }
      if ( $last_column != $cat['column'] ) {
        echo "\n\t\t".'<h2 class="links">'.$cat_image.' '.$cat_name.'</h2>';
      } else {
        echo "\n\t\t".'<br />'."\n\t\t".'<h2 class="links">'.$cat_image.' '.$cat_name.'</h2>';
      }
      $links = $db->query('SELECT
                              `id`, `name`, `url`, `title_tag`, `target`, `added`, `image`, `hits`
                            FROM
                              `'.$db->prefix.'links_links`
                            WHERE
                              `category` = "'.$cat['id'].'"
                            AND
                              `show` = 1
                            ORDER BY
                              `'.$order.'`
                              '.$dir.'
                            ') or error('Unable to fetch all links 
                            '. print_r($db->error()),__FILE__, __LINE__, $db->error());
      while ( $link = $db->fetch_assoc( $links ) ) {
        $url  = pun_htmlspecialchars( $link['url'] );
        $name = pun_htmlspecialchars( $link['name'] );
        if ( empty( $link['title_tag'] ) ) {
          $title_tag = $name;
        } else {
          $title_tag = $link['title_tag'];
        }
        if ( $admin ) {
          $admin_hits = "(".$link['hits'].")";
        } else { $admin_hits = ''; }
        if ( !empty($link['image']) ) {
          $image = "<img style=\"margin: 0px; padding: 0px; vertical-align: middle;\" src=\"".$path."/".$link['image']."\" alt=\"".$link['image']."\" />";
        } else {
          $image = "";
        }
        if ( $count_hits == '1') {
          if ( $link['target'] == "_blank" ) {
            echo ("\n\t\t\t".'<p class="links"><a href="'.$_SERVER['REQUEST_URI'].'?id='.$link['id'].'" onclick="window.open(this.href); return false;" title="'.$title_tag.'">'.$name.'</a> '.$image.' '.$admin_hits.'</p>');
          } else {
            echo ("\n\t\t\t".'<p class="links"><a href="'.$_SERVER['REQUEST_URI'].'?id='.$link['id'].'" title="'.$title_tag.'">'.$name.'</a> '.$image.' '.$admin_hits.'</p>');
          }
        } else {
            if ( $link['target'] == "_blank" ) {
              echo ("\n\t\t\t".'<p class="links"><a href="'.$url.'" onclick="window.open(this.href); return false;" title="'.$title_tag.'">'.$name.'</a> '.$image.'</p>');
            } else {
              echo ("\n\t\t\t".'<p class="links"><a href="'.$url.'" title="'.$title_tag.'">'.$name.'</a> '.$image.'</p>');
            }
        }
        $last_cat    = $cat['height'];
        $last_column = $cat['column'];
      }
    }
    echo "\n\t".'</div><!-- end div class="links_column_'.$i.'" -->'."\n";

}// end for loop

echo "\t"."<div class=\"clearer\"></div>";
  // look here if the webmaster wants the footer
  if ( $pun_config['o_links_debug_info'] == '1' ) {
    $all_links = $db->query('SELECT
                               `id`
                             FROM
                               `'.$db->prefix.'links_links`
                             WHERE
                               `show` = 1
                           ') or error('Unable to fetch all the links 
                           '. print_r($db->error()),__FILE__, __LINE__, $db->error());
    $all_cats  = $db->query('SELECT
                               `id`
                             FROM
                               `'.$db->prefix.'links_category`
                           ') or error('Unable to fetch all the category\'s 
                           '. print_r($db->error()),__FILE__, __LINE__, $db->error());
    $a_links = $db->num_rows( $all_links );
    $a_cats  = $db->num_rows( $all_cats );
    echo "\n\t".'<p style="text-align: center;">'.$lang_links['total_cats'].': '.$a_cats.' |  '.$lang_links['total_links'].': '.$a_links.'</p>';
  } else { echo "<br />"; } // end debug info
  // look here if anybody may post links, if so then show the link
  if ( $pun_config['o_links_guest_posts'] == '1' AND $pun_config['o_links_show_stats'] == '1' ) {
    echo ("\n\t".'<p style="text-align: center;"><a href="'.$_SERVER['REQUEST_URI'].'?new_link">'.$lang_links['add_new_link'].'</a> | <a href="'.$_SERVER['REQUEST_URI'].'?statistics">'.$lang_links['show stats'].'</a></p><br />');
  } elseif ( $pun_config['o_links_guest_posts'] == '1' AND $pun_config['o_links_show_stats'] == '0' ) {
    echo ("\n\t".'<p style="text-align: center;"><a href="'.$_SERVER['REQUEST_URI'].'?new_link">'.$lang_links['add_new_link'].'</a></p><br />');
  } elseif ( $pun_config['o_links_guest_posts'] == '0' AND $pun_config['o_links_show_stats'] == '1' ) {
    echo ("\n\t".'<p style="text-align: center;"><a href="'.$_SERVER['REQUEST_URI'].'?statistics">'.$lang_links['show stats'].'</a></p><br />');
  }
  
//   if ( $pun_config['o_links_guest_posts'] == '0' AND $pun_config['o_links_debug_info'] == '0' AND $pun_config['o_links_show_stats'] == '0' ) {
//     echo "<br />";
//   }
  echo "\n"."</div> <!-- end div id=\"links\" -->";
}

require PUN_ROOT.'footer.php';

Re: contact with captcha.

kierownik, im trying to understand that mod (another captcha mod) so i just started adding lines and debug it at the same time. im getting hit my spam threw my contact.php so ....
anything worth a try to stop it.

Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!

4 (edited by MattF 2007-06-19 19:01)

Re: contact with captcha.

Quaker, look in the programming section. There's some info on the sessions bit in there. big_smile

http://punbb.org/forums/viewtopic.php?id=16090

Re: contact with captcha.

Spammers have find a way to spam captcha sites...

http://blogs.pandasoftware.com/blogs/im … xrumer.swf

PunnyBunny..

Re: contact with captcha.

kier,thanks ill look at that tomorrow..

mattf, i will also look at that, im not a true programmer so bare with me.

saint i read that article a while back.

i never got the notice that someone replied  back to my thread..
Q

My stuff or my style might sux, but atleast I'm willing to help when I can.
Don't be stupid and help ! We are the stupid one's !!!