rendered paste body<?php/*** Mod title: Links with category's* @author: daniel rokven (rokven [at] gmail.com / http://kierownik.nl)**/if ( isset( $_GET['id'] ) && intval( $_GET['id'] ) ) { define('PUN_ROOT', './'); require PUN_ROOT.'include/common.php'; $db->query('UPDATE '.$db->prefix.'links_links SET `hits` = `hits` + 1 WHERE `id` = '.$_GET['id'].' ') or error('Unable to insert the category '. print_r($db->error()),__FILE__, __LINE__, $db->error()); $query = $db->query('SELECT `url` FROM '.$db->prefix.'links_links WHERE `id` = '.$_GET['id'].' ') or error('Unable select the link '. print_r($db->error()),__FILE__, __LINE__, $db->error()); $link = $db->fetch_assoc( $query ); header("Location: ".$link['url'].""); exit();}session_start();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';if ( $pun_config['o_links_debug_info'] == '1' ) { function parsetime() { list($usec, $sec) = explode(" ",microtime()); return ((float)$usec + (float)$sec); } $start_time = parsetime();}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("The captcha function for the form could not be started, so out of security reasons this page is disabled"); } $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 hereif ( isset( $_POST['insert'] ) ) { $category = $_POST['category']; $name_link = $_POST['name_link']; $url = $_POST['url']; // if the name of the link is empty show message if ( $name_link == '' ) { message(''.$lang_links['error_name_link'].''); } // if the link is empty show message if ( !preg_match( "/^[a-zA-z0-9:\/\.\-\?&_=]+$/",$url ) ) { message(''.$lang_links['error_url'].''); } if ( $pun_config['o_links_captcha'] == '1' ) { // if the captcha is on and did not match show message if ( $_POST['captcha'] != $_SESSION['result'] ) { message( ''.$lang_links['error_captcha'].'' ); } } if ( $pun_config['o_links_review'] == '1' ) { $show = 1; $target = '_blank'; } else { $show = 0; $target = ''; } $url = $db->escape($url); $url = str_replace('&', '&', $url); $url = str_replace('&', '&', $url); $db->query("INSERT INTO `".$db->prefix."links_links` (`name_link`, `url`, `category`, `target`, `show`) VALUES ('".$db->escape($name_link)."', '".$url."', '".$category."', '".$target."', '".$show."') ") or error('Unable to insert the category '. 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 * 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_link.''."\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'] ); } $query = $db->query('SELECT * FROM `'.$db->prefix.'links_category` ORDER BY `category` ASC ') or error('Unable to fetch category list ', __FILE__, __LINE__, $db->error()); ?><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_link"> <?php echo $lang_links['link_name']; ?>* </label> <input type="text" name="name_link" maxlength="80" /><br /> <label for="url"> <?php echo $lang_links['link_url']; ?>* </label> <input type="text" name="url" maxlength="100" value="http://" /><br /> <label for="category"><?php echo $lang_links['category']; ?></label> <select name="category"> <?php while ( $data = $db->fetch_assoc( $query ) ) { echo '<option value="'.$data['id'].'">'.$data['category'].'</option>'; } ?> </select> <?php if ( $pun_config['o_links_captcha'] == '1' ) { echo ('<label for="captcha">'.captcha().'<br /><input type="text" name="captcha" maxlength="80" /></label>'); } ?> <label for="mandatory"><? echo '*<strong>'.$lang_links['mandatory'].'</strong>'; ?></label> <label 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 clas blockform --> <?php} else { ?> <div id="links"> <?phpif ( $pun_config['o_links_hits_count'] == '1' ) { $count_hits = '1';} else { $count_hits = '';}if ( $pun_user['g_id'] == '1' ) { $admin = '1';} else { $admin = '';}for ( $i = 1; $i < 5; $i++ ) { // select all category in column $i $query = $db->query('SELECT * 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()); echo "\t".'<div class="links_column_'.$i.'">'; while ( $cat = $db->fetch_assoc( $query ) ) { if ( $last_column != $cat['column'] ) { echo "\n\t\t".'<div class="links_category">'."\n\t\t\t".'<h2 class="links">'.$cat['category'].'</h2>'; } else { echo "\n\t\t".'<br />'."\n\t\t".'<div class="links_category">'."\n\t\t\t".'<h2 class="links">'.$cat['category'].'</h2>'; } $links = $db->query('SELECT * FROM `'.$db->prefix.'links_links` WHERE `category` = "'.$cat['id'].'" AND `show` = 1 ORDER BY `name_link` ASC ') or error('Unable to fetch all links '. print_r($db->error()),__FILE__, __LINE__, $db->error()); while ( $link = $db->fetch_assoc( $links ) ) { $link['url'] = str_replace('&', '&', $link['url']); $link['url'] = str_replace('&', '&', $link['url']); if ( $admin ) { $admin_hits = $link['hits']; } if ( !empty($link['image']) ) { $image = "<img style=\"vertical-align: middle;\" src=\"img/Links/".$link['image']."\" alt=\"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="'.$link['name_link'].'">'.$link['name_link'].'</a> '.$image.' '.$admin_hits.'</p>'); } else { echo ("\n\t\t\t".'<p class="links"><a href="'.$_SERVER['REQUEST_URI'].'?id='.$link['id'].'" title="'.$link['name_link'].'">'.$link['name_link'].'</a> '.$image.' '.$admin_hits.'</p>'); } } else { if ( $link['target'] == "_blank" ) { echo ("\n\t\t\t".'<p class="links"><a href="'.$link['url'].'" onclick="window.open(this.href); return false;" title="'.$link['name_link'].'">'.$link['name_link'].'</a> '.$image.'</p>'); } else { echo ("\n\t\t\t".'<p class="links"><a href="'.$link['url'].'" title="'.$link['name_link'].'">'.$link['name_link'].'</a> '.$image.'</p>'); } } $last_cat = $cat['height']; $last_column = $cat['column']; } echo "\n\t\t"."</div><!-- end div class=\"links_category\" -->"; } echo "\n\t".'</div><!-- end div class="links_column_'.$i.'" -->'."\n";}// end for loopecho "\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 * 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 * 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 ); $time = intval( ( parsetime() - $start_time ) *1000 ); echo "\n\t".'<p style="text-align: center;">'.$lang_links['page_loaded'].': '.$time.' ms. | '.$lang_links['total_cats'].': '.$a_cats.' | '.$lang_links['total_links'].': '.$a_links.'</p>'; } // end debug info // look here if anybody may post links, if so then show the link if ( $pun_config['o_links_guest_posts'] == '1' ) { echo ("\n\t".'<p style="text-align: center;"><a href="'.$_SERVER['REQUEST_URI'].'?new_link">'.$lang_links['add_new_link'].'</a></p>'); } if ( $pun_config['o_links_guest_posts'] == '0' && $pun_config['o_links_debug_info'] == '0' ) { echo "<br />"; } echo "\n"."</div> <!-- end div id=\"links\" -->";}require PUN_ROOT.'footer.php';