1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

WordPress hack issues

Discussion in 'WordPress' started by SEbasic, Dec 7, 2004.

  1. #1
    Let me just begin by reitterating that I am a complete newbie to programming.
    I don't have a clue.
    If this is a really simple to anwser question, I apologise for wasting your time...

    Anyway...
    There is a hack available for WordPress that basically allows you to scrap the traditional achiving available with most blogs (By month)...

    It is called NicerArchives.
    here is the code for the <head>
    <?php require('wp-config.php'); $single = 1; $siteurl = get_settings('siteurl'); ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    
    <head profile="http://gmpg.org/xfn/1">
    	<title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
    
    	<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" />
    	<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats -->
    
    	<style type="text/css" media="screen">
    		@import url( <?php echo get_settings('siteurl'); ?>/wp-layout.css );
    	</style>
    
    	<link rel="stylesheet" type="text/css" media="print" href="<?php echo get_settings('siteurl'); ?>/print.css" />
    	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
    	<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
    	<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
    
    	<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
        <?php wp_get_archives('type=monthly&format=link'); ?>
    	<?php //comments_popup_script(); // off by default ?>
    	<?php wp_head(); ?>
    Code (markup):
     
    SEbasic, Dec 7, 2004 IP
  2. SEbasic

    SEbasic Peon

    Messages:
    6,317
    Likes Received:
    318
    Best Answers:
    0
    Trophy Points:
    0
    #2
    The rest of it.

    
    </head>
    
    <body>
    <div id="rap">
    <h1 id="header"><a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h1>
    
    
    <div id="content">
    
    <?php
    $posts_per_page = '-1';
    
    $defaultorderby = 'post_date';
    $defaultorder = 'DESC';
    
    define('NL', "\n");
    
    function show_year_select() {
        global $wpdb, $tableposts, $m;
        $m = substr($m,0,4);
        $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) as year FROM $tableposts ORDER BY year ASC");
        $output .= '<option value="">All Years</option>'.NL;
        foreach ($years as $year) {
            $output .= '<option value="'.$year.'"';
            if ($year == $m) {
                $output .= ' selected="selected"';
            }
            $output .= '>'.$year.'</option>';
        }
        $output  = '<select name="m">'.NL.$output.'</select>'.NL;
        echo $output;
    }
    
    function show_author_select() {
        global $wpdb, $tableusers, $author;
        $users = $wpdb->get_results("SELECT * FROM $tableusers WHERE user_level > 0", ARRAY_A);
        $output .= '<option value="">All Authors</option>'.NL;
        foreach ($users as $user) {
            $output .= '<option value="'.$user['ID'].'"';
            if ($user['ID'] == $author) {
                $output .= 'selected="selected"';
            }
            $output .= '>'.$user['user_nickname'].'</option>'.NL;
        }
        $output = '<select name="author">'.NL.$output.'</select>'.NL;
        echo $output;
    }
    
    function show_orderby_select() {
        global $orderby;
        $orderby = explode(' ', $orderby);
        $orderby = $orderby[0];
        if ($orderby == 'date') {
           $output .= '<option value="date" selected="selected">Date</option>'.NL;
        } else {
           $output .= '<option value="date">Date</option>'.NL;
        }
        if ($orderby == 'title') {
           $output .= '<option value="title" selected="selected">Title</option>'.NL;
        } else {
           $output .= '<option value="title">Title</option>'.NL;
        }
        if ($orderby == 'category') {
           $output .= '<option value="category" selected="selected">Category</option>'.NL;
        } else {
           $output .= '<option value="category">Category</option>'.NL;
        }
        $output = '<select name="orderby" onchange="Choose(this)">'.NL.$output.'</select>'.NL;
        echo $output;
    }
    
    function show_order_select() {
        global $order;
        if ($order == 'ASC') {
           $output .= '<option value="ASC" selected="selected">Ascending</option>'.NL;
        } else {
           $output .= '<option value="ASC">Ascending</option>'.NL;
        }
        if ($order == 'DESC') {
           $output .= '<option value="DESC" selected="selected">Descending</option>'.NL;
        } else {
           $output .= '<option value="DESC">Descending</option>'.NL;
       }
       $output = '<select name="order" id="asc_desc">'.NL.$output.'</select>'.NL;
       echo $output;
    }
    
    function archive_header($before='', $after='') {
        global $post, $orderby, $month, $previous, $siteurl, $blogfilename, $archiveheadstart, $archiveheadend, $category_name;
        $orderby = explode(' ', $orderby);
        $orderby = $orderby[0];
        if ('date' == $orderby || empty($orderby)) {
            $thismonth = mysql2date('m', $post->post_date);
            $thisyear = mysql2date('Y', $post->post_date);
            $thisdate = $thisyear.$thismonth;
            if ($thisdate != $previous) {
                $thismonth = mysql2date('m', $post->post_date);
                $output .= '<strong><br/><br/><a href="'.$siteurl.'/'.$blogfilename.'?m='.$thisdate.'">'.$month[$thismonth].' '.$thisyear.'</a></strong>';
            }
            $previous = $thisdate;
        } elseif ('title' == $orderby) {
            preg_match('/[a-z0-9]{1}/i', $post->post_title, $match);
            $thisletter = ucfirst($match[0]);
            if ($thisletter != $previous) {
                $output .= "<br/><br/>".$thisletter;
            }
            $previous = $thisletter;
        } elseif ('category' == $orderby) {
            $thiscategory = $category_name;
            if ($thiscategory != $previous) {
                $output .= '<br/><br/><strong><a href="'.$siteurl.'/'.$blogfilename.'?cat='.$thiscategory.'">'.get_catname($thiscategory).'</a></strong>';
            }
            $previous = $thiscategory;
        }
        if (!empty($output)) {
            $output = $before.$output.$after.NL;
            echo $output;
        }
    }
    
    function archive_date($format='Y-m-d H:i:s') {
        global $post;
        echo mysql2date($format, $post->post_date);
    }
    
    ?>
    
    <script language="javascript" type="text/javascript">
    function Choose(whichSort) {
        if (whichSort.selectedIndex == 2) {
            document.getElementById('asc_desc').selectedIndex = 1;
        } else {
            document.getElementById('asc_desc').selectedIndex = 0;
        }
    }
    </script>
    
    <?php
    //Make sure categories get parsed out, they are deprecated in wp-blog-header.php
    if ($_POST["orderby"] == 'category') {
        global $author, $m;
        $orderby = 'category';
        if ($_POST["order"] == '') $order = "DESC";
        else $order = $_POST["order"];
        $year = '' . intval($_POST["m"]);
        $m = $year;
        $author = ''.intval($_POST["author"]);
        if (empty($author)) {
            $whichauthor='';
        } else {
            $author = ''.urldecode($author).'';
            $author = addslashes_gpc($author);
            if (stristr($author, '-')) {
                $eq = '!=';
                $andor = 'AND';
                $author = explode('-', $author);
                $author = ''.intval($author[1]);
            } else {
                $eq = '=';
                $andor = 'OR';
            }
            $author_array = explode(' ', $author);
            $whichauthor .= ' AND (post_author '.$eq.' '.intval($author_array[0]);
            for ($i = 1; $i < (count($author_array)); $i = $i + 1) {
                $whichauthor .= ' '.$andor.' post_author '.$eq.' '.intval($author_array[$i]);
            }
            $whichauthor .= ')';
        }
    
        // Author stuff for nice URIs
    
        if ('' != $author_name) {
            if (stristr($author_name,'/')) {
                $author_name = explode('/',$author_name);
                if ($author_name[count($author_name)-1]) {
                $author_name = $author_name[count($author_name)-1];#no trailing slash
                } else {
                $author_name = $author_name[count($author_name)-2];#there was a trailling slash
                }
            }
            $author_name = preg_replace('|[^a-z0-9-]|', '', strtolower($author_name));
            $author = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_nicename='".$author_name."'");
            $whichauthor .= ' AND (post_author = '.intval($author).')';
        }
        if (!empty($year)) $where .= ' AND YEAR(post_date)=' . $year;
        if (!empty($whichauthor)) $where .= $whichauthor;
        ?>
        <?php show_order_select() ?>
        <?php show_year_select() ?>
        <?php show_author_select() ?>
        <input type="submit" name="submit" value="sort" />
        </form>
        <?php
        $dogs = $wpdb->get_results("SELECT * FROM $tablecategories WHERE 1=1 ORDER BY cat_name $order");
        foreach ($dogs as $catt) {
            $categories = $wpdb->get_results("SELECT * FROM $tablepost2cat WHERE category_id = $catt->cat_ID");
            if ($categories) {
                foreach ($categories as $post2category) {
                    $posts = $wpdb->get_results("SELECT * FROM $tableposts WHERE $post2category->post_id = ID".$where);
                    //$category_realname = $wpdb->get_row("SELECT cat_name FROM $tablecategories WHERE cat_ID = $post2category->category_id");
                    //print_r($category_realname);
                    global $category_name;
                    $category_name = $post2category->category_id;
                    if ($posts) {
                        foreach ($posts as $post) {
                            start_wp();
                            archive_header('<h3>', '</h3>');
                            archive_date('m-d-Y h:iA') ?>: <a href="<?php echo get_permalink($post->ID) ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a><br />
                            <?php
    
                        }
                    }
                }
            }
        }
    }
    else {
        require_once ('wp-blog-header.php');
        // echo $request;
        ?>
    
        Sort By:
        <form action="<?php getenv('PHP_SELF') ?>" method="post">
        <?php show_orderby_select() ?>
        <?php show_order_select() ?>
        <?php show_year_select() ?>
        <?php show_author_select() ?>
        <input type="submit" name="submit" value="sort" />
        </form>
    
        <?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>
        <?php //print_r($post); ?>
        <?php archive_header('<h3>', '</h3>') ?>
        <?php archive_date('m-d-Y h:iA') ?>: <a href="<?php echo get_permalink($post->ID) ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a><br />
        <?php } }
        }?>
    </div>
    
    </div>
    
    <p class="credit"><!--<?php echo $wpdb->querycount; ?> queries.--> <?php timer_stop(1); ?> || <cite>Powered by <a href="http://wordpress.org" title="Powered by WordPress, state-of-the-art semantic personal publishing platform"><strong>WordPress</strong></a></cite></p>
    </body>
    </html>
    Code (markup):
     
    SEbasic, Dec 7, 2004 IP
  3. SEbasic

    SEbasic Peon

    Messages:
    6,317
    Likes Received:
    318
    Best Answers:
    0
    Trophy Points:
    0
    #3
    So that is the original php file named narchives.php

    Where my problem start to arise is when I try to take what I perceved as being the actual PHP working code and paste it into my own skinned template that fits with the rest of the site.

    Here is what I have for that (Just the <head> again):
    <?php require('wp-config.php'); $single = 1; $siteurl = get_settings('siteurl'); ?>
    <?php
    /* Don't remove this line. */
    require('./wp-blog-header.php');
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head profile="http://gmpg.org/xfn/1">
    	<title><?php bloginfo('name'); ?><?php wp_title(); ?></title>
    
    	<meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" />
    	<meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /> <!-- leave this for stats -->
    
    	<style type="text/css" media="screen">
    		@import url( <?php echo get_settings('siteurl'); ?>/wp-layout.css );
    	</style>
    
    	<link rel="stylesheet" type="text/css" media="print" href="<?php echo get_settings('siteurl'); ?>/print.css" />
    	<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
    	<link rel="alternate" type="text/xml" title="RSS .92" href="<?php bloginfo('rss_url'); ?>" />
    	<link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
    
    	<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
        <?php wp_get_archives('type=monthly&format=link'); ?>
    	<?php //comments_popup_script(); // off by default ?>
    	<?php wp_head(); ?>
    
    	<!--[if gte IE 4]>
    	<link rel="stylesheet" href="http://www.softalien.com/ie.css" type="text/css" />
    	<![endif]-->
    Code (markup):
     
    SEbasic, Dec 7, 2004 IP
  4. SEbasic

    SEbasic Peon

    Messages:
    6,317
    Likes Received:
    318
    Best Answers:
    0
    Trophy Points:
    0
    #4
    </head>
    
    <body>
    
    <div id="rap">
    <div id="masthead">
    <span class="logo"><a href="http://www.softalien.com"><img src="http://www.softalien.com/images/logo.gif" alt="SoftAlien.com" /></a></span><h1 id="header"><a href="<?php bloginfo('url'); ?>"><?php bloginfo('name'); ?></a></h1>
    </div>
    <div id="hmenu">
    <div id="hnav">
    </div>
    </div>
    <div id="content">
    <img src="http://www.softalien.com/images/content-header.gif" alt="*" />
    <?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
    
    <?php the_date('','<h3>','</h3>'); ?>
    
    <div class="post">
    <?php
    $posts_per_page = '-1';
    
    $defaultorderby = 'post_date';
    $defaultorder = 'DESC';
    
    define('NL', "\n");
    
    function show_year_select() {
        global $wpdb, $tableposts, $m;
        $m = substr($m,0,4);
        $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) as year FROM $tableposts ORDER BY year ASC");
        $output .= '<option value="">All Years</option>'.NL;
        foreach ($years as $year) {
            $output .= '<option value="'.$year.'"';
            if ($year == $m) {
                $output .= ' selected="selected"';
            }
            $output .= '>'.$year.'</option>';
        }
        $output  = '<select name="m">'.NL.$output.'</select>'.NL;
        echo $output;
    }
    
    function show_author_select() {
        global $wpdb, $tableusers, $author;
        $users = $wpdb->get_results("SELECT * FROM $tableusers WHERE user_level > 0", ARRAY_A);
        $output .= '<option value="">All Authors</option>'.NL;
        foreach ($users as $user) {
            $output .= '<option value="'.$user['ID'].'"';
            if ($user['ID'] == $author) {
                $output .= 'selected="selected"';
            }
            $output .= '>'.$user['user_nickname'].'</option>'.NL;
        }
        $output = '<select name="author">'.NL.$output.'</select>'.NL;
        echo $output;
    }
    
    function show_orderby_select() {
        global $orderby;
        $orderby = explode(' ', $orderby);
        $orderby = $orderby[0];
        if ($orderby == 'date') {
           $output .= '<option value="date" selected="selected">Date</option>'.NL;
        } else {
           $output .= '<option value="date">Date</option>'.NL;
        }
        if ($orderby == 'title') {
           $output .= '<option value="title" selected="selected">Title</option>'.NL;
        } else {
           $output .= '<option value="title">Title</option>'.NL;
        }
        if ($orderby == 'category') {
           $output .= '<option value="category" selected="selected">Category</option>'.NL;
        } else {
           $output .= '<option value="category">Category</option>'.NL;
        }
        $output = '<select name="orderby" onchange="Choose(this)">'.NL.$output.'</select>'.NL;
        echo $output;
    }
    
    function show_order_select() {
        global $order;
        if ($order == 'ASC') {
           $output .= '<option value="ASC" selected="selected">Ascending</option>'.NL;
        } else {
           $output .= '<option value="ASC">Ascending</option>'.NL;
        }
        if ($order == 'DESC') {
           $output .= '<option value="DESC" selected="selected">Descending</option>'.NL;
        } else {
           $output .= '<option value="DESC">Descending</option>'.NL;
       }
       $output = '<select name="order" id="asc_desc">'.NL.$output.'</select>'.NL;
       echo $output;
    }
    
    function archive_header($before='', $after='') {
        global $post, $orderby, $month, $previous, $siteurl, $blogfilename, $archiveheadstart, $archiveheadend, $category_name;
        $orderby = explode(' ', $orderby);
        $orderby = $orderby[0];
        if ('date' == $orderby || empty($orderby)) {
            $thismonth = mysql2date('m', $post->post_date);
            $thisyear = mysql2date('Y', $post->post_date);
            $thisdate = $thisyear.$thismonth;
            if ($thisdate != $previous) {
                $thismonth = mysql2date('m', $post->post_date);
                $output .= '<strong><br/><br/><a href="'.$siteurl.'/'.$blogfilename.'?m='.$thisdate.'">'.$month[$thismonth].' '.$thisyear.'</a></strong>';
            }
            $previous = $thisdate;
        } elseif ('title' == $orderby) {
            preg_match('/[a-z0-9]{1}/i', $post->post_title, $match);
            $thisletter = ucfirst($match[0]);
            if ($thisletter != $previous) {
                $output .= "<br/><br/>".$thisletter;
            }
            $previous = $thisletter;
        } elseif ('category' == $orderby) {
            $thiscategory = $category_name;
            if ($thiscategory != $previous) {
                $output .= '<br/><br/><strong><a href="'.$siteurl.'/'.$blogfilename.'?cat='.$thiscategory.'">'.get_catname($thiscategory).'</a></strong>';
            }
            $previous = $thiscategory;
        }
        if (!empty($output)) {
            $output = $before.$output.$after.NL;
            echo $output;
        }
    }
    
    function archive_date($format='Y-m-d H:i:s') {
        global $post;
        echo mysql2date($format, $post->post_date);
    }
    
    ?>
    
    <script language="javascript" type="text/javascript">
    function Choose(whichSort) {
        if (whichSort.selectedIndex == 2) {
            document.getElementById('asc_desc').selectedIndex = 1;
        } else {
            document.getElementById('asc_desc').selectedIndex = 0;
        }
    }
    </script>
    
    <?php
    //Make sure categories get parsed out, they are deprecated in wp-blog-header.php
    if ($_POST["orderby"] == 'category') {
        global $author, $m;
        $orderby = 'category';
        if ($_POST["order"] == '') $order = "DESC";
        else $order = $_POST["order"];
        $year = '' . intval($_POST["m"]);
        $m = $year;
        $author = ''.intval($_POST["author"]);
        if (empty($author)) {
            $whichauthor='';
        } else {
            $author = ''.urldecode($author).'';
            $author = addslashes_gpc($author);
            if (stristr($author, '-')) {
                $eq = '!=';
                $andor = 'AND';
                $author = explode('-', $author);
                $author = ''.intval($author[1]);
            } else {
                $eq = '=';
                $andor = 'OR';
            }
            $author_array = explode(' ', $author);
            $whichauthor .= ' AND (post_author '.$eq.' '.intval($author_array[0]);
            for ($i = 1; $i < (count($author_array)); $i = $i + 1) {
                $whichauthor .= ' '.$andor.' post_author '.$eq.' '.intval($author_array[$i]);
            }
            $whichauthor .= ')';
        }
    
        // Author stuff for nice URIs
    
        if ('' != $author_name) {
            if (stristr($author_name,'/')) {
                $author_name = explode('/',$author_name);
                if ($author_name[count($author_name)-1]) {
                $author_name = $author_name[count($author_name)-1];#no trailing slash
                } else {
                $author_name = $author_name[count($author_name)-2];#there was a trailling slash
                }
            }
            $author_name = preg_replace('|[^a-z0-9-]|', '', strtolower($author_name));
            $author = $wpdb->get_var("SELECT ID FROM $tableusers WHERE user_nicename='".$author_name."'");
            $whichauthor .= ' AND (post_author = '.intval($author).')';
        }
        if (!empty($year)) $where .= ' AND YEAR(post_date)=' . $year;
        if (!empty($whichauthor)) $where .= $whichauthor;
        ?>
    
        Sort By:
        <form action="<?php getenv('PHP_SELF') ?>" method="post">
        <?php show_orderby_select() ?>
        <?php show_order_select() ?>
        <?php show_year_select() ?>
        <?php show_author_select() ?>
        <input type="submit" name="submit" value="sort" />
        </form>
        <?php
        $dogs = $wpdb->get_results("SELECT * FROM $tablecategories WHERE 1=1 ORDER BY cat_name $order");
        foreach ($dogs as $catt) {
            $categories = $wpdb->get_results("SELECT * FROM $tablepost2cat WHERE category_id = $catt->cat_ID");
            if ($categories) {
                foreach ($categories as $post2category) {
                    $posts = $wpdb->get_results("SELECT * FROM $tableposts WHERE $post2category->post_id = ID".$where);
                    //$category_realname = $wpdb->get_row("SELECT cat_name FROM $tablecategories WHERE cat_ID = $post2category->category_id");
                    //print_r($category_realname);
                    global $category_name;
                    $category_name = $post2category->category_id;
    
                    if ($posts) {
                        foreach ($posts as $post) {
                            start_wp();
                            archive_header('<h3>', '</h3>');
                            archive_date('m-d-Y h:iA') ?>: <a href="<?php echo get_permalink($post->ID) ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a><br />
                            <?php
    
                        }
                    }
                }
            }
        }
    }
    else {
        require_once ('wp-blog-header.php');
        // echo $request;
        ?>
    
        Sort By:
        <form action="<?php getenv('PHP_SELF') ?>" method="post">
        <?php show_orderby_select() ?>
        <?php show_order_select() ?>
        <?php show_year_select() ?>
        <?php show_author_select() ?>
        <input type="submit" name="submit" value="sort" />
        </form>
    
        <?php if ($posts) { foreach ($posts as $post) { start_wp(); ?>
        <?php //print_r($post); ?>
        <?php archive_header('<h3>', '</h3>') ?>
        <?php archive_date('m-d-Y h:iA') ?>: <a href="<?php echo get_permalink($post->ID) ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>"><?php the_title(); ?></a><br />
        <?php } }
        }?>
    
    
    Code (markup):
     
    SEbasic, Dec 7, 2004 IP
  5. SEbasic

    SEbasic Peon

    Messages:
    6,317
    Likes Received:
    318
    Best Answers:
    0
    Trophy Points:
    0
    #5
    </div>
    
    <?php endforeach; else: ?>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
    <?php endif; ?>
    <img src="http://www.softalien.com/images/post-foot.gif" alt="*" />
    </div>
    
    
    <div id="menu">
    <div id="nav">
     <span class="navimage"><img src="http://www.softalien.com/images/categories.gif" alt="Navigate" /></span>
    <ul>
    <li id="categories">
      <ul>
    	<?php wp_list_cats(); ?>
    
    	<li><a href="http://forum.softalien.com/">Forum</a></li>
      </ul>
     </li>
    </ul>
     <span class="navimage"><label for="s"><img src="http://www.softalien.com/images/search.gif" alt="Find What You Want" /></label></span>
    <ul>
     <li id="search">
       <form id="searchform" method="get" action="<?php echo $PHP_SELF; ?>">
    	<div>
    		<input type="text" name="s" id="s" size="15" /><br />
    		<input class="submit" type="submit" name="submit" value="<?php _e('Search'); ?>" />
    	</div>
    	</form>
     </li>
    </ul>
     <span class="navimage"><img src="http://www.softalien.com/images/links.gif" alt="Linkage" /></span>
    <ul>
    	<?php get_links_list(); ?>
    </ul>
     <span class="navimage"><img src="http://www.softalien.com/images/other.gif" alt="Join In" /></span>
    <ul>
     <li id="other">
    	<ul>
    		<li><a href="<?php echo get_settings('siteurl'); ?>/wp-login.php"><?php _e('Login'); ?></a></li>
    		<li><a href="<?php echo get_settings('siteurl'); ?>/wp-register.php"><?php _e('Register'); ?></a></li>
    	</ul>
     </li>
    </ul>
     <span class="navimage"><img src="http://www.softalien.com/images/meta.gif" alt="Feeds &amp; Validation" /></span>
     <ul>
     <li id="meta">
      <ul>
    		<li><a href="<?php bloginfo('rss2_url'); ?>" title="<?php _e('Syndicate this site using RSS'); ?>"><?php _e('<abbr title="Really Simple Syndication">RSS</abbr> 2.0'); ?></a></li>
    		<li><a href="<?php bloginfo('comments_rss2_url'); ?>" title="<?php _e('The latest comments to all posts in RSS'); ?>"><?php _e('Comments <abbr title="Really Simple Syndication">RSS</abbr> 2.0'); ?></a></li>
    		<li><a href="http://validator.w3.org/check/referer" title="<?php _e('This page validates as XHTML 1.0 Transitional'); ?>"><?php _e('Valid <abbr title="eXtensible HyperText Markup Language">XHTML</abbr>'); ?></a></li>
    		<li><a href="http://wordpress.org/" title="<?php _e('Powered by WordPress; state-of-the-art semantic personal publishing platform.'); ?>">WP</a></li>
      </ul>
     </li>
     </ul>
    </ul>
    <span class="navimage"><img src="http://www.softalien.com/images/nav-footer.gif" alt="*" /></span>
    </div>
    </div>
    
    
    <div id="clearer">&nbsp;</div>
    <div id="footer">
    <p class="credit"><!--<?php echo $wpdb->querycount; ?> queries.--> <?php timer_stop(1); ?><a href="http://www.wordpress.org/">WP</a> | <a href="http://www.seo-dev.co.uk/seraphim-proudleduck/">Seraphim Proudleduck</a></p>
    </div>
    </div>
    </body>
    </html>
    
    Code (markup):

    This doesn't work...

    The actual message I get is this:
    I have been working on this for ages now and just can't seem to get anywhere...

    you can see the actual (non-working) file here... http://www.softalien.com/narchives.php

    Are there any PHP users out there who know what that error message means and what I have to do to get rid of it?

    Cheers

    Oliver

    Apologies for all the elongated posts...

    Too much code there...
     
    SEbasic, Dec 7, 2004 IP
  6. flawebworks

    flawebworks Tech Services

    Messages:
    991
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    78
    #6
    I think you need to use the my-hacks file. Have you done that?
    http://wordpress.org/support/10/5963

    May as well scratch that comment. I just uploaded the file; works great.
    Big help; aren't I?

    Your error message:

    Quote:
    Fatal error: Cannot redeclare show_year_select() (previously declared in /home/softalie/public_html/narchives.php:59) in /home/softalie/public_html/narchives.php on line 58

    leads me to believe that you are trying to show the year twice; something along that line. Look at the code in a text editor; specifically the code on line 58 and 59. What's it say?
     
    flawebworks, Dec 7, 2004 IP
  7. SEbasic

    SEbasic Peon

    Messages:
    6,317
    Likes Received:
    318
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Here is the code from the original
    
    function show_author_select() {
    58>>>>>>>    global $wpdb, $tableusers, $author;
    59>>>>>>>    $users = $wpdb->get_results("SELECT * FROM $tableusers WHERE user_level > 0", ARRAY_A);
        $output .= '<option value="">All Authors</option>'.NL;
        foreach ($users as $user) {
            $output .= '<option value="'.$user['ID'].'"';
            if ($user['ID'] == $author) {
                $output .= 'selected="selected"';
            }
            $output .= '>'.$user['user_nickname'].'</option>'.NL;
        }
        $output = '<select name="author">'.NL.$output.'</select>'.NL;
        echo $output;
    }
    Code (markup):
    The code on mine (What's there now)...

    
    <?php
    $posts_per_page = '-1';
    
    $defaultorderby = 'post_date';
    $defaultorder = 'DESC';
    
    define('NL', "\n");
    
    function show_year_select() {
    58>>>>>>    global $wpdb, $tableposts, $m;
    59>>>>>>    $m = substr($m,0,4);
        $years = $wpdb->get_col("SELECT DISTINCT YEAR(post_date) as year FROM $tableposts ORDER BY year ASC");
        $output .= '<option value="">All Years</option>'.NL;
        foreach ($years as $year) {
            $output .= '<option value="'.$year.'"';
            if ($year == $m) {
                $output .= ' selected="selected"';
            }
            $output .= '>'.$year.'</option>';
        }
        $output  = '<select name="m">'.NL.$output.'</select>'.NL;
        echo $output;
    }
    
    
    Code (markup):
    Thanks for having a look...

    This has been driving me nuts.
     
    SEbasic, Dec 7, 2004 IP
  8. flawebworks

    flawebworks Tech Services

    Messages:
    991
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    78
    #8
    I'm not sure exactly what you're trying to accomplish ( I know what the file is for) but your code:

    function show_year_select() {
    58>>>>>> global $wpdb, $tableposts, $m;
    59>>>>>> $m = substr($m,0,4);

    Is what's flubbing the works. What are you trying to make it do, specifically?

    If you use the code in the original file; it should work. I did no tweaking whatsever; uploaded the original narchives.php to all of my blog sites and it works great; but I'm not doing anything special to it Looks good the way it is, more or less: http://jramer.com/narchives.php

    function show_author_select() {
    global $wpdb, $tableusers, $author;
    $users = $wpdb->get_results("SELECT * FROM $tableusers WHERE user_level > 0", ARRAY_A);
     
    flawebworks, Dec 7, 2004 IP
  9. SEbasic

    SEbasic Peon

    Messages:
    6,317
    Likes Received:
    318
    Best Answers:
    0
    Trophy Points:
    0
    #9
    The actual template that the hack has been built on, is the default wordpress template.

    I had to end up drastically changing the HTML provided in that template in order to make the site look the way I wanted.

    It's a pain in the arse, because I know all of this is my fault, but to have things work the way I want I have to get this to work...

    I've been trying everything and I just can't think of a way to get it to work...

    I don't even understand it :rolleyes:

    I'll keep trying and see if something works...

    No biggie. :)

    Cheers... :)
     
    SEbasic, Dec 7, 2004 IP
  10. MIRENGE

    MIRENGE Peon

    Messages:
    107
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Am also a newbie in the internet marketing and i must say that i dont understand what you are talking about.
     
    MIRENGE, Jun 24, 2011 IP